Interactive lab: Loschmidt echo on small spin chains + a toy 2-spin COSY spectrum. Open portfolio code — not employer IP.
pip install -r requirements.txt
make test
make lab # Streamlit UIIn my bachelor years I interned at TerraQuantum. The work sat at a junction I still find addictive:
- NMR — relaxation timescales, multidimensional spectra (COSY and friends)
- Small quantum registers — modelling dynamics at roughly 8 / 16 qubits
Practically, that meant asking how chemical-shift / J-coupling / T₂ language from spectroscopy informs what a few-dozen-qubit simulator can and cannot faithfully reverse. Echoes die for the same family of reasons a quantum circuit loses fidelity: imperfect control, unwanted couplings, decoherence.
I never stopped caring about quantum computing. This repo is a clean-room teaching lab that keeps that thread public without shipping TerraQuantum Hamiltonians, pulse libraries, or proprietary datasets.
- Build an open XXZ Heisenberg chain on
n = 2…4spins (exact Hilbert space2ⁿ). - Prepare a product of
|+\ranglestates (sensitive to dephasing). - Evolve forward with
Hfor timet. - Attempt time reversal with
-(H + εV)—εVis a staggered local-Z perturbation (imperfect reversal / coherent error). - Optionally apply a crude T₂ model: damp density-matrix off-diagonals
by
e^{-t/T₂}between the two halves. - Plot
F(t) = |⟨ψ₀| ψ_final(t)⟩|²
When ε = 0 and T₂ is off, F(t) ≈ 1. Turn either knob and the echo decays —
NMR spin-echo intuition in a few lines of NumPy/SciPy.
A minimal 2-spin fragment with chemical shifts ω₁, ω₂ and coupling J:
- Thermal-ish toy density matrix → soft π/2 pulse → evolve
t₁→ mixing pulses → evolvet₂. - Read a complex FID-like signal with a T₂ envelope.
- 2D FFT → magnitude map.
Diagonal ridges track the shifts; cross-peaks grow with J. This is a
teaching FFT picture, not a spectrometer processing pipeline — enough to see
why COSY encodes correlated transitions, the same correlation idea that shows
up when you embed few-spin pieces into a small QC model.
| Spins | Dim | Here |
|---|---|---|
| 2–4 | 4–16 | Interactive dense expm |
| 8 | 256 | Exact offline OK, not for casual sliders |
| 16 | 65 536 | Sparse / tensor / circuit methods |
The bachelor question (NMR relaxation & COSY ↔ small QC) still stands. Engineering a serious 16-qubit simulator is a different repository.
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
make test
make lab| Path | Role |
|---|---|
qelab/pauli.py |
Kronecker Pauli helpers |
qelab/hamiltonian.py |
XXZ chain + reversal perturbation |
qelab/evolve.py |
Unitaries + phenomenological T₂ |
qelab/loschmidt.py |
Echo protocol |
qelab/cosy_toy.py |
Educational COSY-like map |
app.py |
Streamlit UI |
BACKGROUND.md |
Shorter NMR ↔ QC notes |
- Not a real NMR processing stack
- Not a production 16-qubit simulator
- Not TerraQuantum IP
MIT. If you only skim one file beyond this README, make it BACKGROUND.md.