Skip to content

About

Interactive Loschmidt echo + toy COSY lab: NMR relaxation intuition for small quantum registers (TerraQuantum-inspired portfolio, open clean-room code).

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

Quantum Echo Lab

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 UI

Motivation

In 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.


What happens in the lab

1. Loschmidt echo tab

  1. Build an open XXZ Heisenberg chain on n = 2…4 spins (exact Hilbert space 2ⁿ).
  2. Prepare a product of |+\rangle states (sensitive to dephasing).
  3. Evolve forward with H for time t.
  4. Attempt time reversal with -(H + εV) — εV is a staggered local-Z perturbation (imperfect reversal / coherent error).
  5. Optionally apply a crude T₂ model: damp density-matrix off-diagonals by e^{-t/T₂} between the two halves.
  6. 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.

2. Toy COSY tab

A minimal 2-spin fragment with chemical shifts ω₁, ω₂ and coupling J:

  1. Thermal-ish toy density matrix → soft π/2 pulse → evolve t₁ → mixing pulses → evolve t₂.
  2. Read a complex FID-like signal with a T₂ envelope.
  3. 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.

3. Scaling note (honest)

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.


Quick start

python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

make test
make lab

Layout

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

Scope / non-goals

  • 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.

About

Interactive Loschmidt echo + toy COSY lab: NMR relaxation intuition for small quantum registers (TerraQuantum-inspired portfolio, open clean-room code).

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages