Exact references¶
Question: does the code match a result known in closed form, or computable exactly?
physverify ships a collection of exact results that people kept writing by hand. Each one is tested in physverify's own test suite against an independent computation (finite differences, enumeration, orbit integration).
physverify references
lists them; help(physverify.references.<name>) gives the formula and its source.
Example: a Schroedinger solver against the Morse levels¶
"""Exact references: compare a finite-difference Schroedinger solver with the Morse levels."""
import numpy as np
from physverify import references as R
D, a = 12.0, 1.0 # hbar = m = 1
x = np.linspace(-2.5, 14.0, 3000)
h = x[1] - x[0]
V = D * (1 - np.exp(-a * x)) ** 2
off = np.full(len(x) - 1, 0.5 / h**2)
H = np.diag(1 / h**2 + V) - np.diag(off, 1) - np.diag(off, -1)
E = np.linalg.eigvalsh(H)[:4]
exact = R.morse_levels(np.arange(4), a * np.sqrt(2 * D), a * a / 2)
for v in range(4):
print(f"v={v}: solver {E[v]:.5f} exact {exact[v]:.5f} difference {abs(E[v] - exact[v]):.1e}")
Output:
v=0: solver 2.32447 exact 2.32449 difference 2.0e-05
v=1: solver 6.22340 exact 6.22347 difference 6.4e-05
v=2: solver 9.12235 exact 9.12245 difference 9.7e-05
v=3: solver 11.02134 exact 11.02143 difference 8.6e-05
The differences are small and shrink as the grid is refined, as they should for a second-order finite-difference Hamiltonian.
What is available¶
| Area | References |
|---|---|
| Statistical physics | 2D Ising model by exact enumeration (up to 4x4), classical Heisenberg chain, open transverse-field Ising chain ground energy |
| Heat and transport | heat-equation sine modes, a moving and spreading Gaussian, the semi-infinite solid with a temperature step |
| Mechanics | double-pendulum accelerations and energy, cantilever tip deflection and slope |
| Quantum mechanics | infinite square well, square-barrier transmission, Morse levels and turning points |
| Gravitation | Schwarzschild quasinormal frequencies, Kerr innermost stable orbit, exact light deflection |
| Reactor physics | asymptotic period from the inhour equation, for either sign of reactivity |
A real code used the positive-reactivity formula for a negative reactivity and was off by a factor of about 7000; the reference handles both signs.