#differential-equations #ode #solver #matrix #formula #backward #vector

diffsol

A library for solving ordinary differential equations (ODEs) in Rust

3 releases

0.1.4 Apr 5, 2024
0.1.3 Apr 4, 2024
0.1.2 Feb 20, 2024
0.1.1 Feb 20, 2024
0.1.0 Feb 20, 2024

#394 in Math

Download history 264/week @ 2024-02-16 82/week @ 2024-02-23 12/week @ 2024-03-01 9/week @ 2024-03-08 5/week @ 2024-03-15 34/week @ 2024-03-29 155/week @ 2024-04-05

200 downloads per month

MIT and maybe GPL-3.0-or-later

245KB
6K SLoC

DiffSol

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 crate, or you can implement your own types by implementing the various vector and matrix traits in diffsol.

Features

DiffSol has two implementations of the Backward Differentiation Formula (BDF) method, one in pure rust, the other wrapping the Sundials IDA solver. This method is a variable step-size implicit method that is suitable for stiff ODEs and semi-explicit DAEs and is similar to the BDF method in MATLAB's ode15s solver or the bdf solver in SciPy's solve_ivp function.

Users can specify the equations to solve in the following ODE form:

M \frac{dy}{dt} = f(t, y, p)

where $M$ is a mass matrix, $y$ is the state vector, $t$ is the time, $p$ is a vector of parameters, and $f$ is the right-hand side function. The mass matrix $M$ is optional (assumed to be the identity matrix if not provided).

Installation

Add the following to your Cargo.toml file:

[dependencies]
diffeq = "0.1"

or add it on the command line:

cargo add diffeq

Usage

For more documentation and examples, see the API documentation.

Dependencies

~14–20MB
~415K SLoC