Crate numint

Source
Expand description

githubcrates-iodocs-rs

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 TypeFunction 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 The OdeState trait section below).

§Integration Methods

Integration MethodImplementation
Euler (Runge-Kutta First-Order) MethodEuler
(Classic) Runge-Kutta Fourth-Order MethodRK4

§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.

MacroDescription
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§

Structs§

  • Euler (1st-order Runge-Kutta) method.
  • (Classic) Runge-Kutta fourth-order method.
  • Solution of an ordinary differential equation dy/dt = f(t,y).

Enums§

Traits§

  • Trait defining an integration method.
  • Trait defining an ODE solver state (i.e. the dependent variable in an ODE).

Functions§