rusoda

Crates.iorusoda
lib.rsrusoda
version0.1.0
sourcesrc
created_at2023-10-30 08:56:56.122772
updated_at2023-10-30 08:56:56.122772
descriptionPure rust and just need log dependencies implementation of odepack dlsoda.
homepagehttps://github.com/ElliotLaw/rusoda
repositoryhttps://github.com/ElliotLaw/rusoda
max_upload_size
id1018232
size111,239
(ElliotLaw)

documentation

README

rusoda

Description

rust implementation of odepack dlsoda

Instructions

  1. Build a struct which contains your ode system coeffs and number of eqs.
struct Oral1Cpt {
    incalc_par: Vec<f64>,
    neq: usize,
}
  1. Implement OdeSystem trait for your struct(define the ode function).
use rusoda::OdeSystem;

impl OdeSystem for Oral1Cpt {
    fn func(&self, _t: f64, _y: &mut [f64], _dy: &mut [f64]) {
        let ka = self.incalc_par[0];
        let cl = self.incalc_par[1];
        let v = self.incalc_par[2];
        (*_dy)[0] = -ka * (*_y)[0];
        (*_dy)[1] = ka * (*_y)[0] - cl / v * (*_y)[1];
    }
}
  1. Initialize LSODA solver and call "solve" method.
use rusoda::IStateInput;
use rusoda::LSODA;

use std::time::Instant;
    env_logger::init();
    let mut t = 0.;
    let tout = 12.;
    let y = [4.0, 0.0];
    let mut lsoda = LSODA::init();
    let sys = Oral1Cpt::init(vec![3.09, 32., 648.]);

    let mut state = IStateInput::InitialCall;
    let tt = Instant::now();

    let res = lsoda.solve(
        &sys, sys.neq, &y, &mut t, tout, &mut state, 1e-3, 1e-6, false,
    );

    println!("{:?},TIME:{}MS", res, tt.elapsed().as_millis())
Commit count: 15

cargo fmt