#runge-kutta #differential-equations #ode #solving #equation #ordinary #explicit

nightly fast_ode

Fast Runge-Kutta implementation for solving ordinary differential equations

5 releases (1 stable)

1.0.0 Jun 17, 2023
0.1.3 Mar 24, 2022
0.1.2 Mar 24, 2022
0.1.1 Oct 13, 2021
0.1.0 Oct 13, 2021

#726 in Algorithms

Download history 25/week @ 2023-12-18 7/week @ 2024-01-08 24/week @ 2024-01-22 12/week @ 2024-01-29 4/week @ 2024-02-05 16/week @ 2024-02-12 53/week @ 2024-02-19 79/week @ 2024-02-26 55/week @ 2024-03-04 40/week @ 2024-03-11 39/week @ 2024-03-18 10/week @ 2024-03-25 108/week @ 2024-04-01

200 downloads per month

MIT/Apache

29KB
755 lines

This crate is (afaik) the fastest implementation of the explicit Runge-Kutta method of order 5(4) with the Dormand-Prince pair of formulas. It is identical to scipy's implementation. This crate can be used to solve ordinary differential equations.

I do not use this crate anymore and I do not intend to increase the project scope, but I will address/fix every issue reported. IMHO this is a small but very well written and documented crate.

Example:

struct HarmonicOde {}
impl fast_ode::DifferentialEquation<2> for HarmonicOde {
    fn ode_dot_y(&self, _t: f64, y: &fast_ode::Coord<2>) -> (fast_ode::Coord<2>, bool) {
        let x = y.0[0];
        let v = y.0[1];
        (fast_ode::Coord::<2>([v, -x]), true)
    }
}
let ode = HarmonicOde {};
let res = fast_ode::solve_ivp(&ode, (0., 10.), fast_ode::Coord([0., 1.]), |_, _| true, 1e-6, 1e-3);
let numerical_sol = match res {
    fast_ode::IvpResult::FinalTimeReached(y) => y.0,
    _ => panic!(),
};
let theoretical_sol = [10_f64.sin(), 10_f64.cos()];
assert!(numerical_sol[0]-theoretical_sol[0] < 1e-2);
assert!(numerical_sol[1]-theoretical_sol[1] < 1e-2);

Dependencies

~17KB