lsode

Crates.iolsode
lib.rslsode
version0.2.8
sourcesrc
created_at2020-03-05 09:19:10.85532
updated_at2020-12-09 16:15:53.684625
descriptionSolve systems of differntial equations using LSODE subroutine from ODEPACK written in Fortran.
homepagehttps://github.com/tungli/lsode-rust.git
repositoryhttps://github.com/tungli/lsode-rust.git
max_upload_size
id215652
size1,301,615
Jan Tungli (tungli)

documentation

https://docs.rs/lsode/

README

Docs are here.

Solve systems of differential equations

This crate uses ODEPACK Fortran library to solve systems of ordinary differential equations.

I created this crate mainly to be able to solve stiff ODE problems in Rust.

Example

This example has the setup from DifferentialEquations.jl documentation.

use lsode::{linspace, solve_ode};

fn main() {
    let l: f64 = 1.0;
    let m: f64 = 1.0;
    let g: f64 = 9.81;
    let torque = |t: &f64| 0.1*t.sin();

    let f = |y: &[f64], t: &f64 | {
        let mut dy = vec![0.0, 0.0];
        dy[0] = y[1];
        dy[1] = -3.0*g/(2.0*l)*y[0].sin() + 3.0/(m*l*l)*torque(t);
        dy
    };

    let y0 = [0.01, 0.0];
    let ts = linspace(0.0, 10.0, 1000);
    let (atol, rtol) = (1e-6, 1e-6);

    let sol = solve_ode(f, &y0, ts.clone(), atol, rtol);

    for (i, t) in sol.iter().zip(ts) {
        println!("{} {} {}", t, i[0], i[1]);
    }
}

ODEPACK

I obtained the ODEPACK code that is present in this repository from here. I do not know what the licensing of the original ODEPACK code is, I assume it is released to the public domain.

Commit count: 9

cargo fmt