v0.4.0: magnetic fields, symmetry folding, SCBA, two Berry frames, dipole optics, sparse everything
Every item on the v0.3.0 "not yet implemented" list is now implemented, each pinned to exact anchors (100 tests total, up from 69):
Magnetic fields by Peierls substitution (with_peierls): uniform out-of-plane fields on finite models (Peierls, Z. Phys. 80, 763 (1933)). The midpoint line integral is exact for linear gauges, so the anchors are machine-precision statements, not approximations: the flux-threaded ring reproduces 2t cos((2 pi j + Theta)/N) to 1e-12, Landau and symmetric gauges give identical spectra, the plaquette-flux product is exactly e^(2 pi i phi), the spectrum is exactly periodic in the flux quantum -- and the lowest Landau level of a 1600-site square flake sits at -4|t| + hbar omega_c/2 to 3%, macroscopically degenerate. Periodic models are refused (magnetic unit cells stay out of scope, stated).
Point-group k-mesh folding (symmetry_fold): folds the grid by a user-supplied point group, and refuses anything unverified -- each operation must map the reciprocal lattice to itself (integer fractional matrix) AND leave the spectrum invariant at random test k-points. Graphene's C6 fold (about x6 fewer points) reproduces full-grid DOS and chemical potentials to 1e-12; the fold also passes on the time-reversal-broken Haldane model (C6 remains a spectral symmetry -- verified, not assumed) while a 90-degree rotation and a bond-stretched model are refused. Valid for spectral observables only, stated plainly.
Elastic self-consistent Born self-energy (scba_transmission): Sigma_i = W^2 diag(G_ii) iterated to a verified fixed point (residual < 1e-10, Im Sigma <= 0). Anchors: W = 0 is the coherent result exactly, and the central layer of a long chain reproduces the independent bulk scalar SCBA equation -- built in the tests from the closed-form chain Green function, a completely separate code path -- to 1e-3. Inelastic (Keldysh) electron-phonon SCBA and vertex corrections remain out of scope, stated.
Berry phases beyond the Loewdin frame (frame="atomic"): links built from the same atomic-gauge assembly and site-diagonal position convention as the velocity operator, midpoint overlap metric, explicit zone-wrap closure. The Chern number is frame-independent and the two frames return the same exact integers on the overlap Haldane model in both phases; the atomic-frame SSH Zak phases are -/+ pi/2 (the intracell-position contribution) with the exact pi difference, and inversion antisymmetry survives the overlap.
KPM for nonorthogonal bases: kpm_dos now runs the recurrence on S^-1 H through a sparse LU of S. The nonorthogonal chain reproduces its band-center DOS 1/(2 pi |t|), integrates to the orbital count, and vanishes identically outside the exact band edges 2t/(1 +- 2s).
Sparse optics, topology and transport: kpm_sigma (double-Chebyshev Kubo-Greenwood conductivity, Weisse et al., RMP 78, 275 (2006)) matches the kernel-independent molecular line weight to 3% and the dense Kubo route on a dimerized chain to 2%; berry accepts solver="sparse" (same integers as dense, C = 2 on stacked Haldane copies); transmission_sparse (sparse-LU device solver) equals dense direct inversion to machine precision, overlap and complex Sigma(E) included. bloch_derivative_sparse completes the sparse assembly.
Intra-atomic dipole velocity term (model.set_dipole): v gains i(E_n - E_m) X_nm from on-site position blocks. The site-diagonal approximation leaves an atomic s->p transition exactly dark; the dipole block makes it bright with the hand-derived peak spin 4 pi (Delta d)^2/(eta sqrt(2 pi) Delta) to 1e-3, and a dipole that commutes with H changes nothing identically. Orthogonal bases only, refused otherwise.
Install: pip install hamop -- archived on Zenodo under concept DOI 10.5281/zenodo.22311381.