Physics validation
zkit validate runs TDSE-Z on cases with exact solutions or exact
identities, reads every output table through zkit.Run, and checks
every column. With a second binary it also compares every column of every
table between the two builds, so a change to TDSE-Z can be shown to leave the
physics unchanged.
pip install "zkit-lib[validation]" # or pip install -e ".[validation]" in a clone
export TDSEZ_BINARY=/path/to/tdsez.x
zkit validate --quick # 2D cases, about 20 s
zkit validate --np 8 # all cases, about 10 min
zkit validate --np 8 --reference old/tdsez.x
The command exits with 0 when every check passes. Runs are kept in
--workdir (default zkit-validation/) for inspection.
Conventions
q = Charge (-1 electron), s = -q: the carrier sees s V and the
field term s E.r. Columns of td/<name>_observables.h5:
dipoles 2D: t Ex Ey Dx Dy Ax Ay 3D: t Ex Ey Ez Dx Dy Dz Ax Ay Az
energies t Kin Pot Int Tot InvMass Norm
currents t Lz dGamma J.. J_intra.. J_inter.. J_bc..
populations t P_0 ...
autocorrelation t Re Im of <psi(0)|M|psi(t)>
Cases
Transition dipoles (1D, 2D, 3D). A stationary run saves the eigenstates
and the dipole operators; dipoles.x computes every \(d^{(a)}_{ij}\).
The spectrum and every \(|d_{ij}|\) are compared with
zkit.analytic: oscillators with one frequency per axis
(\(\omega = 0.5\); \((0.6, 0.83)\); \((0.6, 0.83, 1.17)\)),
\(\langle n|x_a|n+1\rangle = \sqrt{(n+1)/2\omega_a}\), and the hard-wall
box of width 10, \(\langle n|x|m\rangle = -8Lnm/(\pi^2(n^2-m^2)^2)\) for
\(n+m\) odd. The rows of dipole_spectrum.x and recombination.x
must equal the full matrix on every axis. --quick skips the 3D case.
Static Kramers-Henneberger frame (Mode = kh; 1D linear with
\(m = 2\), 2D circular, 3D linear). For an oscillator the cycle-averaged
potential is \(V + \tfrac12 m\omega_0^2\langle|\boldsymbol\alpha|^2\rangle\),
so every level shifts by \(\tfrac14 m\omega_0^2\alpha_0^2\) (linear) or
\(\tfrac12 m\omega_0^2\alpha_0^2\) (circular),
\(\alpha_0 = |q|E_0/m\omega^2\) (zkit.analytic.kh_oscillator_shift()).
The KH levels minus the Mode = td levels on the same grid must equal the
shift (the discretisation cancels), and the KH levels the closed form.
Free Gaussian packet in a uniform field (3D, mass 0.7, q = -1 and
+1). For a linear potential Ehrenfest is exact:
the kinetic energy is \(\sum_a [m\langle v_a\rangle^2/2 + 1/(8 m w_a^2)]\), and the autocorrelation follows by quadrature in momentum space (gauge transformation to the velocity gauge). The field integrals are taken symbolically from the deck’s expressions.
Driven harmonic oscillator (2D, mass 1.5, q = -1 and +1), started
in the ground state: the state stays a coherent state
\(|\alpha(t)\rangle e^{i\varphi}\) with
\(\dot\alpha = -i\omega\alpha - ig\),
\(\dot\varphi = -\omega/2 - g\,\mathrm{Re}\,\alpha\),
\(g = sE/\sqrt{2m\omega}\). This fixes D, J, A, Kin,
Pot, Int, Tot, P_0 = |<0|psi>|^2, the complex autocorrelation,
the accumulated Berry phase and E_0 = omega.
Position-dependent mass (2D and 3D; no closed form). A field-free
eigenstate is stationary: D constant, J = A = 0, Tot = E_0,
P_0 = 1 and autocorrelation \(e^{-iE_0t}\). A driven state obeys
Ehrenfest, \(J = \dot D\) and \(A = \ddot D\) (fourth-order
differences), and the operator and discrete accelerations agree. Both forms
are tested.
Every run additionally checks the carrier sign and the field columns
against zkit.physics.Physics, the norm, and the energy theorem for a
Hermitian Hamiltonian,
with \(\dot{\mathbf E}\) differentiated symbolically
(zkit.physics.Physics.field_derivative()).
Tolerances and what limits them
Exact identities (field columns, <1/m>, the current decomposition, norms,
stationary states with the discrete acceleration) are checked to rounding.
Comparisons with exact dynamics are limited by the spatial discretisation and
the time step; on the validation grids they agree to 3e-5 or better. Derived
checks that differentiate or integrate the output in time (d2D/dt2, the
energy theorem) inherit that error amplified, and their tolerances say so. The
operator-form acceleration of an eigenstate is zero only to the spatial
discretisation error, which falls as \(h^4\) (degree 4): 5.2e-6 at
\(h = 1.1\), 8.2e-7 at \(h = 0.75\) in 3D.
The free packet is stopped at t = 3, before its tail reaches the
reflecting walls of the box.
API
Physics validation of TDSE-Z against analytic results (zkit validate).
Runs TDSE-Z on cases with exact solutions or exact identities, reads every
output table through zkit.Run and checks every column:
free Gaussian packet in a uniform field (3D, mass 0.7, both charge signs): Ehrenfest is exact for a linear potential, so <r>, <v>, the acceleration, the kinetic energy and the autocorrelation (momentum-space quadrature) are known exactly;
driven harmonic oscillator from its ground state (2D, mass 1.5, both signs): the state stays a coherent state, which gives <r>, <p>, all energies, the ground-state population, the complex autocorrelation and the Berry phase;
transition dipoles (1D, 2D, 3D): the spectrum and every |<i|x_a|j>| of the post-processor
dipoles.xagainst the exact oscillator (distinct frequencies per axis) and hard-wall box results (zkit.analytic), and the rows ofdipole_spectrum.xandrecombination.xagainst the full matrix;static Kramers-Henneberger frame (
Mode = kh; 1D, 2D circular, 3D): oscillator levels shift by m w0^2 <|alpha|^2>/2 exactly, against a lab-frame run on the same grid and against the closed-form levels;position-dependent mass (2D, 3D; no closed form): a field-free eigenstate is stationary (D, J, A, energies constant, autocorrelation exp(-i E0 t)); a driven state obeys Ehrenfest (J = dD/dt, A = d2D/dt2), the energy theorem dTot/dt = s E’(t).<r>, and the operator and discrete accelerations agree.
With a reference binary every column of every table is also compared between the two builds.
TDSE-Z conventions: q = Charge, s = -q; the carrier sees s V and the field
term s E.r. Tables of td/<name>_observables.h5:
dipoles 2D: t Ex Ey Dx Dy Ax Ay 3D: t Ex Ey Ez Dx Dy Dz Ax Ay Az
energies t Kin Pot Int Tot InvMass Norm
currents t Lz dGamma J.. J_intra.. J_inter.. J_bc..
populations t P_0 ... autocorrelation t Re Im of <psi(0)\|M\|psi(t)>
- class zkit.validation.Check(case: 'str', quantity: 'str', error: 'float', tol: 'float')
- Parameters:
case (str)
quantity (str)
error (float)
tol (float)
- class zkit.validation.Report(checks: 'List[Check]' = <factory>, diffs: 'Dict[str, float]'=<factory>)
- Parameters:
checks (List[Check])
diffs (Dict[str, float])
- class zkit.validation.Validator(binary, reference=None, nproc=4, workdir='zkit-validation', mpiexec='mpiexec')
Run the validation cases with
binary(andreference) inworkdir.- common(case, run, q, dim, ehrenfest=(0.0001, 0.001), energy_tol=2e-05)
zkit/deck consistency, norm, <1/m> and the identities every run obeys.
- zkit.validation.coherent_state(t, m, omega, s, fields)
Driven oscillator H = sum_a [p_a^2/2m + m w^2 x_a^2/2 + s E_a(t) x_a] from the ground state: |alpha(t)> e^{i phi}, alpha’ = -i w alpha - i g, phi’ = -w/2 - g Re(alpha), g = s E / sqrt(2 m w).
Returns <x>, <p> (nt, d) and the amplitude <0|psi(t)> (product over axes).
- Parameters:
fields (Sequence[Callable])
- zkit.validation.default_binary()
TDSEZ_BINARY, then tdsez.x / tdsez on PATH.
- Return type:
str | None
- zkit.validation.field_work(t, r, s, dE)
int_0^t s E’(tau).<r>(tau) dtau (Simpson), the change of the total energy <H> + s E.<r> for a Hermitian Hamiltonian.
- Parameters:
dE (Sequence[Callable])
- zkit.validation.free_packet(t, m, k0, x0, s, int_E, int2_E)
Free carrier in a uniform field, H = p^2/2m + s E(t).r (exact Ehrenfest).
int_E[a](t)= int_0^t E_a,int2_E[a](t)= int_0^t int_0^tau E_a. Returns <r>(t) and <v>(t), shape (nt, d).
- zkit.validation.free_packet_autocorrelation(t, m, w, k0, x0, s, int_E, n_k=6001, n_tau=200001)
<psi0|psi(t)> for the Gaussian packet psi0 = prod_a (2 pi w^2)^(-1/4) exp(-(x-c)^2/4w^2 + i k0 x) under H = p^2/2m + s E(t).r, by quadrature in momentum space (gauge psi = e^{iA.r} chi, A’ = -s E):
prod_a int conj(phi0(k)) phi0(k - A(t)) exp(-i int_0^t (k - A(t) + A(tau))^2 / 2m dtau) dk.
- zkit.validation.kramers_henneberger(v, case, n_states=5)
Mode = kh against the exact oscillator shift: KH minus lab-frame levels on the same grid (the discretisation cancels) and the absolute levels.
- Parameters:
v (Validator)
case (str)
n_states (int)
- Return type:
None
- zkit.validation.time_derivative(y, h, order=1)
Fourth-order central difference on interior points [2:-2] (axis 0).
- Parameters:
y (ndarray)
h (float)
order (int)
- Return type:
ndarray