Skip to content

Validation

Every solver in the engine ships with tests that run in CI on every change. Three kinds:

  1. Exact solutions. Start from a closed-form soliton, run for many periods, compare pointwise.
  2. Invariants. Compute the conserved quantities before and after and demand they agree to round-off.
  3. Qualitative physics. Two solitons must emerge from a collision with their original amplitudes.
ScenarioCheckedResult
Projectileposition against the closed form at any time stepround-off
Mass on a springperiod against Verlet’s known dispersion, energy drift1e-8, 1e-5
Atwood machine, block and hanging massacceleration, tension, normal forceround-off
Simple pendulum, 2 radperiod against the elliptic integral, convergence order1.7e-8, order 2.0
Block on inclineat rest with friction mgsin⁡θm g \sin\theta; sliding acceleration1e-10
Sliding blockstopping distance, friction work, ledger drift4e-9, 5e-10, 3e-9
Collisionselastic and inelastic outgoing velocities, energy lost, 90° scattering of equal discs1e-10
Rolling discrolling acceleration and v=ωRv = \omega R; slipping when μs\mu_s is too small1e-8
Seesawbalanced stays still; tipping angular acceleration1e-9
Bouncing ballapex ratios e2e^2, first landing time3e-5, 1e-6 s
Massive pulley, flywheelacceleration, both tensions, rim speed1e-8
Every catalogue scenariobuilds, runs, round-trips through JSONpasses
EquationTestError
KdVsingle soliton, t=5t = 55×10−85 \times 10^{-8}
KdVtwo-soliton invariants, 8000 stepsdrift <10−8< 10^{-8}
KdVcollision amplitude recoverywithin 0.020.02 of exact
NLSmoving bright soliton, t=10t = 103×10−93 \times 10^{-9}
NLStwo-soliton invariants, 10000 stepsdrift <10−8< 10^{-8}

Reproduce with:

Terminal window
git clone https://github.com/soliton-physics/soliton
cd soliton && cargo test --release

The playground shows the invariants and their drift live in the side panel, so you can watch the solver’s accuracy while it runs.