Expand description
ODE solvers and numerical integration in Rust.
§Overview
At its core, this crate is designed to work with scalar-valued, vector-valued, and matrix-valued ordinary differential equations.
ODE Type | Function Signature |
---|---|
scalar-valued | $$\frac{dy}{dt}=f(t,y)\quad\quad\left(f:\mathbb{R}\times\mathbb{R}\to\mathbb{R}\right)$$ |
vector-valued | $$\frac{d\mathbf{y}}{dt}=\mathbf{f}(t,\mathbf{y})\quad\quad\left(\mathbf{f}:\mathbb{R}\times\mathbb{R}^{p}\to\mathbb{R}^{p}\right)$$ |
matrix-valued | $$\frac{d\mathbf{Y}}{dt}=\mathbf{F}(t,\mathbf{Y})\quad\quad\left(\mathbf{F}:\mathbb{R}\times\mathbb{R}^{p\times r}\to\mathbb{R}^{p\times r}\right)$$ |
§Initial Value Problem (IVP) Solver
The solve_ivp()
function is a general purpose IVP solver with the following features:
- it accepts a generic parameter defining the integration method
- it can be used for scalar-valued, vector-valued, and matrix-valued problems (this is
accomplished by accepting another generic parameter defining the type of the ODE state)
- any types of vectors or matrices can be used with this function as long as they implement
the
OdeState
trait (see TheOdeState
trait section below).
- any types of vectors or matrices can be used with this function as long as they implement
the
§Integration Methods
§Runge-Kutta Methods
Integration Method | Order | Implementation |
---|---|---|
Euler Method | 2 | Euler |
Midpoint Method | 2 | RK2 |
Heun’s Second-Order Method | 2 | RK2Heun |
Ralston’s Second-Order Method | 2 | RK2Ralston |
Classic (Kutta’s) Third-Order method | 2 | RK3 |
Heun’s Third-Order Method | 3 | RK3Heun |
Ralston’s Third-Order Method | 3 | RK3Ralston |
Strong Stability Preserving Runge-Kutta Third-Order Method | 3 | SSPRK3 |
(Classic) Runge-Kutta Fourth-Order Method | 4 | RK4 |
Ralston’s Fourth-Order Method | 4 | RK4Ralston |
3/8 Rule Fourth Order Method | 4 | RK438 |
§The OdeState
trait
To allow users to use their favorite vector and matrix representations, this crate defines the
OdeState
trait. As long as the ODE state trait is implemented for a type, you can use that
type to define an ODE to be solved using this crate.
This crate already defines the OdeState
for a variety of different types from the standard
library, nalgebra
, and ndarray
. For a full list, refer to the OdeState
documentation.
This crate also provides macros to automate the implementation of the OdeState
trait for
types that implement linalg_traits::Scalar
, linalg_traits::Vector
, or
linalg_traits::Matrix
traits.
Macro | Description |
---|---|
impl_ode_state_for_scalar! | Implement OdeState for a scalar type already implementing the linalg_traits::Scalar trait. |
impl_ode_state_for_dvector! | Implement OdeState for a dynamically-sized vector type already implementing the linalg_traits::Vector trait. |
impl_ode_state_for_svector! | Implement OdeState for a statically-sized vector type already implementing the linalg_traits::Vector trait. |
impl_ode_state_for_dmatrix! | Implement OdeState for a dynamically-sized matrix type already implementing the linalg_traits::Matrix trait. |
impl_ode_state_for_smatrix! | Implement OdeState for a statically-sized matrix type already implementing the linalg_traits::Matrix trait. |
Macros§
- impl_
ode_ state_ for_ dmatrix - Macro to implement the
OdeState
trait for dynamically-sized matrix types. - impl_
ode_ state_ for_ dvector - Macro to implement the
OdeState
trait for dynamically-sized vector types. - impl_
ode_ state_ for_ scalar - Macro to implement the
OdeState
trait for scalar types. - impl_
ode_ state_ for_ smatrix - Macro to implement the
OdeState
trait for statically-sized matrix types. - impl_
ode_ state_ for_ svector - Macro to implement the
crate::OdeState
trait for statically-sized vector types.
Structs§
- Euler
- Euler (first-order) method.
- RK2
- Midpoint (second-order) method.
- RK3
- Classic (Kutta’s) third-order method.
- RK4
- Classic Runge-Kutta fourth-order method.
- RK2Heun
- Heun’s second-order method.
- RK2Ralston
- Ralston’s second-order method.
- RK3Heun
- Heun’s third-order method.
- RK3Ralston
- Ralston’s third-order method.
- RK4Ralston
- Ralston’s fourth-order method.
- RK438
- 3/8 rule fourth-order method.
- SSPRK3
- Strong stability preserving Runge-Kutta third-order method.
- Solution
- Solution of an ordinary differential equation
dy/dt = f(t,y)
.
Enums§
- State
Index - Index for indexing into ODE state.
Traits§
- Integration
Method - Trait defining an integration method.
- OdeState
- Trait defining an ODE solver state (i.e. the dependent variable in an ODE).
Functions§
- solve_
ivp - Solve an initial value problem.