Quantum Magnetism Lab — Spin Chains, the Bethe Ansatz & the Ising Critical Point — by Darion Kellar
Educational quantum magnetism lab in ONE pure-Python file: the exact ground states of small spin-1/2 chains, every headline number graded against a known analytic result. The Heisenberg XXX antiferromagnet is diagonalised in the Sz = 0 sector (bitmask basis; from-scratch Jacobi eigensolver at N <= 8, Lanczos at N = 10, the two asserted to agree at N = 8): E0/N = -0.467129 (N = 6), -0.456387 (N = 8), -0.451545 (N = 10), every finite ring below the Bethe-ansatz limit 1/4 - ln 2 = -0.443147 and rising toward it with the conformal -pi^2/12N^2 correction; the exactly soluble N = 4 ring gives E0 = -2. The ground states are proved singlets by applying S^2 as an operator (<S^2> ~ 1e-18), the bond correlator is computed two independent ways to <1e-9 agreement, and <Sz_0 Sz_r> alternates in sign and decays (+0.250000, -0.152129, +0.065259, -0.062984, +0.049708). Flipping J to -1 returns the ferromagnet: E0 = -N/4 exactly, <S^2> = 20 = S(S+1) at S = N/2, every bond +1/4. The transverse-field Ising chain is solved by Jordan-Wigner free fermions (eps_k = 2 sqrt(1 + h^2 - 2h cos k)): gap 0.196271 at h = 1, matching 4 sin(pi/2N) to machine precision and located by a blind scan whose argmin is exactly h = 1.00; critical energy closing on -4/pi; Hellmann-Feynman correlators giving = = 0.636876 at criticality, the self-duality value 2/pi = 0.636620 from finite sums. The XY chain cross-checks the same machinery down to -1/pi (error 3.2e-5 at N = 128). A from-scratch distance-weighted kNN labels eight computed ground states antiferromagnetic / ferromagnetic / critical / paramagnetic-disordered from the lab's own policy.
Pure Python standard library. Zero dependencies. Zero network. Honest scope: a finite chain approaches the thermodynamic limit - it never reaches it, and it is not a material. No material was discovered, no magnet was designed, no sample was measured, and a computed critical point is an exact model value, not a measurement of any real material's transition. Every materials / magnet / device / sensor / storage / measurement use is a permanent HOLD gate (14 total).
🧰 Tech Stack Badges & Full Architecture Tech Stack
🐍 Python 3.12, pure standard library (math, hashlib, json, sys) — zero dependencies, zero network, deterministic (double-run byte-identical)
🧲 Exact-diagonalisation core from scratch: bitmask Sz = 0 basis (dims 6 / 20 / 70 / 252), a cyclic Jacobi eigensolver written out in full for the dense Hamiltonians, and a Lanczos iteration with full reorthogonalisation against the sparse Hamiltonian action for N = 10 — the two methods are asserted to agree at N = 8 in CHECKS
⚡ Jordan–Wigner free-fermion core: TFIM spectrum ε_k = 2√(J² + h² − 2Jh·cos k) on the antiperiodic momenta k = (2m+1)π/N, ground energy as the k-sum −½Σε_k, correlators by Hellmann–Feynman centred differences of that exact sum; XY chain ε_k = J·cos k as the cross-check
🎯 Graded against exact results, not other simulations: Bethe ansatz 1/4 − ln 2, XY −1/π, TFIM critical −4/π and 2/π duality, gap 4 sin(π/2N), the soluble N = 4 ring (E0 = −2), the ferromagnet's S(S+1) = 20
🧠 TinyML kNN phase classifier (from scratch, stdlib, distance-weighted): antiferromagnetic / ferromagnetic / critical / paramagnetic-disordered from correlator + gap + magnetisation, 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)
🚫 Not applicable — honestly. No blockchain, no Web3, no tokens: the "infrastructure" in this lab is one offline file holding a bitmask basis, a Jacobi solver, and two Jordan–Wigner k-sums. Materials and device claims are permanent HOLD gates, not features. No fake badges here.
🚫 No low-level code — honestly. No C, no C++, no GPU, no compiled extensions: this is one interpreted Python file on purpose, so every eigenvalue can be read, checked, and diffed. Performance here means honest algorithms — a 252-dimensional Lanczos with full reorthogonalisation instead of a dense 252×252 diagonalisation, and closed-form k-sums instead of diagonalising the Ising chain at all — all deterministic and byte-identical between runs.
🚫 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.
Bethe ansatz as grading target — E0/N = -0.500000 (N = 4, exact), -0.467129, -0.456387, -0.451545 rising toward 1/4 - ln 2 = -0.443147 from below; N = 10 within 0.0084 of the limit, conformal correction -pi^2/12N^2 made visible.
Two eigensolvers, cross-graded — cyclic Jacobi on dense Sz = 0 Hamiltonians (dims 6 / 20 / 70) and a fully reorthogonalised Lanczos at dim 252; agreement at N = 8 asserted to <1e-9 in CHECKS.
Singlet receipt — S^2 applied as an operator to the computed ground states: <S^2> = -3.1e-18 (N = 8), -8.5e-17 (N = 10); asserted < 1e-9.
Correlator, two ways — <S_i.S_i+1> by direct operator action and by E0/N energy bookkeeping: identical to <1e-9 at both sizes.
Ferromagnet mirror — J = -1: E0 = -2 = -N/4 exactly, <S^2> = 20 = S(S+1) with S = N/2, bond correlator +0.250000, sector gap 0.292893.
Critical point, three ways — gap table (2.000000 at h = 0 -> 0.196271 at h = 1 -> 4.014420 at h = 3), closed form 4 sin(pi/2N) matched to machine precision, blind h-scan argmin exactly 1.00.
Duality from finite sums — at h = 1, Hellmann-Feynman differences of the exact k-sum give = = 0.636876 against the infinite-chain 2/pi = 0.636620.
XY cross-check — eps_k = J cos k: E0/N = -0.320364 (N = 16) -> -0.318342 (N = 128) approaching -1/pi = -0.318310 from below, error shrinking like 1/N^2.
TinyML kNN classifier — antiferromagnetic / ferromagnetic / critical / paramagnetic-disordered from (correlator, gap, magnetisation); the h = 2 and h = 3 field-polarised states are NOT mislabelled ferromagnetic - the gap feature vetoes it. Agreement with the lab policy asserted on all scenarios and all 350 grid rows.
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).