Skip to main content

Module ode_advanced

Module ode_advanced 

Source
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

  1. Symplectic integrators (verlet_step, ruth3_step, yoshida4_step, integrate_symplectic) for separable Hamiltonian systems H(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.
  2. 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.
  3. Dense output (hermite_dense_output) — cubic-Hermite continuous extension giving the state at any t + θΔt without re-evaluating the derivative.
  4. Forward sensitivity (integrate_with_sensitivity) — integrates the variational equation ds/dt = f_y·s alongside the state to get ∂y/∂y₀.

Structs§

SensitivityResult
Result of integrate_with_sensitivity.
SymplecticResult
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§

SymplecticMethod
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 tiny h.
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 points y1(newer), y0(older).
hermite_dense_output
Cubic-Hermite dense output: the state at θ ∈ [0,1] within a step from (t₀,y0) to (t₁,y1) where f0=f(t₀,y0), f1=f(t₁,y1) and h=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) over steps steps of size h with the L-stable BDF2 formula, bootstrapped by one BDF1 step. Returns the final y. Zero-heap (keeps only the two-point history). Stable for stiff systems at large h.
integrate_symplectic
Integrate a separable Hamiltonian system for steps steps of size h.
integrate_with_sensitivity
Integrate dy/dt = f(t,y) together with the variational equation ds/dt = f_y(t,y)·s, s(0)=1, by RK4 on the augmented (y, s) system. Returns y(t) and ∂y/∂y₀ at t₀ + steps·h. f_y is 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.