Expand description
Advanced ODE integrators: symplectic, stiff (BDF), dense output, and forward
sensitivity — the doctorate-level capabilities the ode_solver scalar RK4/BVP
core does not provide.
Kept in its own focused module (rather than growing the 1000-line ode_solver.rs
monolith) per the split rule. Zero-heap: every routine is pure-scalar
arithmetic over f64, parameterised by closures (impl Fn) — no Vec/Box,
no allocation. Suitable for the constrained / off-grid core.
§What lives here
- Symplectic integrators (
verlet_step,ruth3_step,yoshida4_step,integrate_symplectic) for separable Hamiltonian systemsH(q,p)=T(p)+V(q)— they conserve energy with bounded oscillation over millions of steps instead of the secular drift a non-symplectic method (RK4) shows. - Stiff BDF solvers (
bdf1_step,bdf2_step,integrate_bdf) — L-stable backward-differentiation formulas with a Newton corrector, for stiff thermodynamic / phase-transition ODEs where explicit methods blow up. - Dense output (
hermite_dense_output) — cubic-Hermite continuous extension giving the state at anyt + θΔtwithout re-evaluating the derivative. - Forward sensitivity (
integrate_with_sensitivity) — integrates the variational equationds/dt = f_y·salongside the state to get∂y/∂y₀.
Structs§
- Sensitivity
Result - Result of
integrate_with_sensitivity. - Symplectic
Result - Result of
integrate_symplectic: the final phase-space point plus the maximum energy deviation seen over the run — the headline symplectic property is that this stays bounded (no secular drift) even over millions of steps.
Enums§
- Symplectic
Method - Symplectic integrator order selector.
Functions§
- bdf1_
step - One BDF1 (backward / implicit Euler) step: solve
y₁ = y₀ + h·f(t₁, y₁)by Newton iteration. L-stable — the workhorse for stiff systems where explicit Euler/RK would require an impractically tinyh. - bdf2_
step - One BDF2 step:
y₂ = (4/3)y₁ − (1/3)y₀ + (2/3)h·f(t₂, y₂), solved by Newton. Second-order and L-stable; needs the two previous pointsy1(newer),y0(older). - hermite_
dense_ output - Cubic-Hermite dense output: the state at
θ ∈ [0,1]within a step from(t₀,y0)to(t₁,y1)wheref0=f(t₀,y0),f1=f(t₁,y1)andh=t₁−t₀, WITHOUT re-evaluating the derivative. Exact for cubic trajectories; matches the endpoints and their slopes (θ=0 → y0,θ=1 → y1). - integrate_
bdf - Integrate
dy/dt = f(t,y)overstepssteps of sizehwith the L-stable BDF2 formula, bootstrapped by one BDF1 step. Returns the finaly. Zero-heap (keeps only the two-point history). Stable for stiff systems at largeh. - integrate_
symplectic - Integrate a separable Hamiltonian system for
stepssteps of sizeh. - integrate_
with_ sensitivity - Integrate
dy/dt = f(t,y)together with the variational equationds/dt = f_y(t,y)·s,s(0)=1, by RK4 on the augmented(y, s)system. Returnsy(t)and∂y/∂y₀att₀ + steps·h.f_yis estimated by central differences. Zero-heap. - ruth3_
step - One Ruth (1983) 3rd-order symplectic step. Three (kick, drift) sub-stages with the canonical Ruth coefficients.
- verlet_
step - One Störmer–Verlet (velocity-Verlet / leapfrog) step — 2nd-order symplectic and
time-reversible.
force(q) = -∂V/∂q,kinetic_velocity(p) = ∂T/∂p(= p/m). - yoshida4_
step - One Yoshida (1990) 4th-order symplectic step, built as a symmetric composition of
three Verlet sub-steps with the Yoshida weights
w1, w0, w1.