Diffsol is a library for solving ordinary differential equations (ODEs) or semi-explicit differential algebraic equations (DAEs) in Rust. You can use it out-of-the-box with vectors and matrices from the nalgebra or faer crates, or you can implement your own types by implementing the various vector and matrix traits in diffsol.
DiffSol implements the following solvers:
- A variable order Backwards Difference Formulae (BDF) solver, suitable for stiff problems and singular mass matrices.
- A Singly Diagonally Implicit Runge-Kutta (SDIRK or ESDIRK) solver, suitable for moderately stiff problems and singular mass matrices. You can use your own butcher tableau or use one of the provided (
tr_bdf2
oresdirk34
).
All solvers feature:
- adaptive step-size control to given tolerances,
- dense output,
- event handling,
- stepping to specific times,
- numerical quadrature of an optional output function over time
- forward sensitivity analysis,
- backwards or adjoint sensitivity analysis,
For comparison, the BDF solvers are similar to MATLAB's ode15s
solver, the bdf
solver in SciPy's solve_ivp
function, or the BDF solver in SUNDIALS.
The ESDIRK solver using the provided tr_bdf2
tableau is similar to MATLAB's ode23t
solver.
Users can specify the equations to solve in the following ODE form, either using closures or the DiffSL Domain Specific Language (DSL):
where
See instructions on the crates.io page.
For more documentation and examples, see the API documentation.