This library provides a pure Rust implementation of SciPy's solve_ivp functionality with a typed builder API for first-order, second-order, and Hamiltonian systems. It is also available as a Python package with a SciPy-compatible solve_ivp interface.
Features
Currently implemented solvers:
- DOP853: An 8th order Dormand-Prince method with step-size control and dense output.
- DOPRI5: A 5th order Dormand-Prince method with step-size control and dense output.
- RK4: The classic 4th order Runge-Kutta method with fixed step-size and cubic Hermite interpolation for dense output.
- RK23: A 3rd order Runge-Kutta method with 2nd order error estimate for step-size control.
- LSODA: An automatic Adams/BDF switching multistep method for problems that may change stiffness.
- Radau: A 5th order implicit Runge-Kutta method of Radau IIA type with step-size control and dense output.
- BDF: A variable-order (1 to 5) Backward Differentiation Formula method for stiff ODEs with adaptive step-size control and dense output.
- Symplectic methods: Fixed-step structured solvers for separable Hamiltonian and second-order systems, including Symplectic Euler, Velocity Verlet, Ruth 3, and Yoshida 4.
Installation
Rust
Python
Example Usage
return -0.5 *
# Solve the ODE
=
use *;
;
More complete examples:
- Rust:
docs/rust-examples.md - Python:
docs/python-examples.md
Symplectic Usage
For structured mechanics problems, use the dedicated second-order or Hamiltonian
builders instead of the Rust first-order Ivp::first_order(...) path.
use *;
;
Python can also route these methods through solve_ivp. Second-order problems
can use a plain acceleration callback, and Hamiltonian problems can use a
callback pair:
return -
=
return
return
=
On the Python side, invalid callback shapes now raise normal Python exceptions
with explicit messages. For example, a symplectic callback returning the wrong
number of values raises ValueError, and an incomplete Hamiltonian callback
pair raises TypeError.
Current limitation: event handling is not yet supported for symplectic methods.