HUB
Sign inSign up
trappedion-lab logo

credkellar/trappedion-lab

By credkellar

•Updated 17 days ago

TrappedIon-Lab: trapped-ion lab - Lamb-Dicke sidebands, sideband cooling, MS gate, Rabi flop. Sim!!!

Image
Machine learning & AI
Developer tools
Data science
1

169

credkellar/trappedion-lab repository overview

⁠TrappedIon-Lab 🪤⚛️

Trapped-Ion Physics Lab — Lamb-Dicke Sidebands, Sideband Cooling & the Mølmer–Sørensen Gate — by Darion Kellar

Educational trapped-ion physics lab in ONE pure-Python file: the displacement matrix <n'|exp(ieta(a + a+))|n> computed by exact Laguerre summation (row unitarity worst deviation 1.33e-15 over eta in {0.05, 0.1, 0.2, 0.5, 1.0}), the carrier / red / blue sideband spectrum read off it and graded against the Lamb-Dicke scalings (max error 1.15e-03 at eta = 0.05, 0.8632 at eta = 0.5, where the carrier approximation goes negative), a resolved-sideband cooling rate model that walks a thermal distribution from n-bar 4.533386 to 0.005277 - the eta^2/2 floor, ground population 0.994739 - while carrier-only driving moves n-bar by exactly zero, a two-ion Mølmer–Sørensen gate integrated with RK4 (g/delta = 0.25, one closed loop, 50.0 us) that produces a computed Bell state with F = 0.988444 and concurrence = 0.976935 in the advertised phonon space 0..3, priced against a 0..7 reference run (F = 0.999998) so the truncation cost (dF = 0.011554, dC = 0.023061) is printed rather than hidden, and carrier Rabi flopping whose thermal peaks decay 0.987931 -> 0.581209 while the pure n = 0 state holds 1.000000. A from-scratch distance-weighted kNN classifier labels regimes from the lab's own policy.

Pure Python standard library. Zero dependencies. Zero network. Honest scope: every parameter is a LABELLED teaching number - a 40Ca+-like ion, a 1 MHz trap, a 729 nm laser, a set that happens to imply eta = 0.096879 - and no ion was trapped, cooled, or entangled. The gate fidelity is a property of a 16-amplitude model and is printed with its truncation cost; nothing here is a device specification, a benchmark, or a measurement. Every trap-control / laser / hardware / certification / advantage use is a permanent HOLD gate (14 total).

⁠🧰 Tech Stack Badges & Full Architecture Tech Stack

⁠💻 Core Programming Languages & Core Systems

Python Stdlib Only Network Deterministic License Lamb-Dicke MS Gate

  • 🐍 Python 3.12, pure standard library (cmath, math, hashlib, json, sys) — zero dependencies, zero network, deterministic (double-run byte-identical)
  • 🔢 Displacement core from scratch: generalised Laguerre polynomials by their exact finite sum, giving every ⟨n′|exp(iη(a + a†))|n⟩ — row unitarity Σ|M|² = 1 asserted to <1e-9 for all five η values before any spectrum is trusted
  • 📊 Spectrum + cooling core: carrier / red / blue ratios read off the matrix, the Lamb–Dicke scalings graded against them, and a rate model on p_n (n ≤ 20) whose transfer rates and repump recoil kernel are both built from the same exact elements
  • 🔗 Gate core: the Mølmer–Sørensen interaction-picture Hamiltonian applied by index arithmetic on a 2-qubit × phonon statevector, integrated with RK4; concurrence by Wootters' formula with a from-scratch Hermitian eigensolver (real-embedding Jacobi)
  • 🧠 TinyML kNN regime classifier (from scratch, stdlib, distance-weighted): lamb-dicke-resolved / lamb-dicke-marginal / unresolved-sideband / beyond-lamb-dicke from (η, Ω₀/ω, n̄), labels from the lab's own policy
  • 🪑 Council seats: Gemini Argon 4 DECIDER (names-only, tighten-only) + Muse advisor (never overrides HOLD) + Google Flow plan-only (rendered = False, live = 0)
⁠⛓️ Web3 & Infrastructure
  • 🚫 Not applicable — honestly. No blockchain, no Web3, no tokens: the "infrastructure" in this lab is one offline file holding a harmonic oscillator, a laser coupling, and two simulated ions. No fake badges here.
⁠⚙️ Platform Support & Hardware Architecture

Linux macOS Windows

  • 🖥️ Pure Python — runs anywhere Python 3.12+ runs (Linux, macOS, Windows), plus the python:3.12-slim Docker image
  • 🔒 No hardware is controlled, ever: real traps, lasers, vacuum systems, and control electronics are permanent HOLD gates (see the gate table below)
⁠⚡ Low-Level Infrastructure & Performance
  • 🚫 No low-level code — honestly. No C, no C++, no GPU, no compiled extensions: this is one interpreted Python file on purpose, so every matrix element can be read, checked, and diffed. Performance here means honest algorithms — exact finite sums instead of special-function calls, an RK4 integrator whose step count is printed, and a gate run twice in two Hilbert spaces so the truncation error is measured, not guessed.
⁠🛠️ DevOps & Build Tools

Docker GitHub Actions pytest Git

  • 🐳 Docker (python:3.12-slim), GitHub Actions CI + Docker Publish (delivered in the paste pack)
  • 🎯 Target image: credkellar/trappedion-lab:latest
  • 🧪 Tests: pytest (30 tests) + the built-in CHECKS suite (52 checks) in main.py
⁠☁️ Cloud Providers
  • 🚫 None — honestly. No cloud provider is used or needed: the lab runs fully offline on your own machine or in a local Docker container. Docker Hub appears only as the registry the publish workflow pushes the image to.

⁠🐳 Quick start

docker pull credkellar/trappedion-lab:latest
docker run --rm credkellar/trappedion-lab:latest

The default command runs the full demo plus the built-in self-checks (CHECKS 52/52).

Run a specific command instead:

docker run --rm credkellar/trappedion-lab:latest python3 main.py checks     # CHECKS 52/52
docker run --rm credkellar/trappedion-lab:latest python3 main.py matrix     # displacement matrix + unitarity (JSON)
docker run --rm credkellar/trappedion-lab:latest python3 main.py sidebands  # spectrum + Lamb-Dicke grading (JSON)
docker run --rm credkellar/trappedion-lab:latest python3 main.py cooling    # cooling run + carrier-only contrast (JSON)
docker run --rm credkellar/trappedion-lab:latest python3 main.py gate       # MS gate: F, concurrence, truncation cost (JSON)
docker run --rm credkellar/trappedion-lab:latest python3 main.py rabi       # Rabi flopping: pure vs thermal (JSON)
docker run --rm credkellar/trappedion-lab:latest python3 main.py classify   # kNN verdicts: resolved / marginal / unresolved / beyond
docker run --rm credkellar/trappedion-lab:latest python3 main.py holds      # 14 HOLD gates

⁠🔬 What's inside

  • Displacement matrix, summed exactly — generalised Laguerre by its finite sum; rows n <= 12 sum |M|^2 to 1 with worst deviation 1.33e-15 across eta = 0.05..1.0.
  • Eta derived, not typed — the labelled Ca+ set (40 amu, 1 MHz, 729 nm) gives x0 = 11.240 nm and eta = 0.096879; the teaching eta = 0.1 is labelled as its rounding.
  • Sideband spectrum — at eta = 0.1 the carrier slides 0.995012 -> 0.916795 for n = 0..8, blue grows 0.099501 -> 0.286702, and red from n = 0 is exactly 0: the floor that makes ground-state cooling possible.
  • Lamb-Dicke limit, graded — max error (n <= 6) 1.15e-03 at eta = 0.05 vs 0.8632 at eta = 0.5, where the carrier approximation reads -0.625 against the exact +0.071430.
  • Cooling to the eta^2/2 floor — 400 cycles: n-bar 4.533386 -> 3.7161 -> 3.0320 -> 1.6078 -> 0.4894 -> 0.005277, ground population 0.994739; the floor is the recoil balance, computed not scripted.
  • Carrier-only control — same bookkeeping, Delta n = 0 transfer: n-bar 4.533386 -> 4.533386. Exactly zero cooling, stated in numbers.
  • Mølmer–Sørensen gate — RK4, 720 steps, one closed loop at g/delta = 0.25 (g/2pi = 5 kHz, delta/2pi = 20 kHz, 50.0 us): F = 0.988444, concurrence = 0.976935 in the 0..3 phonon space.
  • Truncation cost, printed — the 0..7 reference run gives F = 0.999998, C = 0.999996 with the motion back in n = 0 to 0.999997; the cost of the small space is dF = 0.011554, dC = 0.023061.
  • Rabi contrast collapse — pi time 5.025 us at the labelled Omega_0; thermal peaks 0.987931 / 0.908213 / 0.808783 / 0.677182 / 0.618153 / 0.581209 at odd multiples of t_pi while the pure state stays at 1.000000.
  • TinyML kNN classifier — lamb-dicke-resolved / marginal / unresolved-sideband / beyond-lamb-dicke from (eta, Omega_0/omega, n-bar); agreement with the lab's policy asserted on all 336 grid points.
  • Advisory seats — Gemini Argon 4 DECIDER (names-only, tighten-only, sha256 trace), Muse advisor (can never override HOLD), Google Flow plan-only (rendered = False, live = 0).

⁠✅ Verified

  • pytest: 30 passed
  • Built-in checks: CHECKS 52/52
  • Deterministic: double-run byte-identical
  • Base image: python:3.12-slim

⁠🏷️ Categories

Science · Developer tools · Machine learning & AI

  • License: MIT © 2026 Darion Kellar
  • Image: credkellar/trappedion-lab:latest
Tag summary
Recent tags
Content type
Image
Digest
sha256:926ee7524…
Size
41.6 MB
Last updated
17 days ago
docker pull credkellar/trappedion-lab:latest