Crates.io | rusoda |
lib.rs | rusoda |
version | 0.1.0 |
source | src |
created_at | 2023-10-30 08:56:56.122772 |
updated_at | 2023-10-30 08:56:56.122772 |
description | Pure rust and just need log dependencies implementation of odepack dlsoda. |
homepage | https://github.com/ElliotLaw/rusoda |
repository | https://github.com/ElliotLaw/rusoda |
max_upload_size | |
id | 1018232 |
size | 111,239 |
rust implementation of odepack dlsoda
struct Oral1Cpt {
incalc_par: Vec<f64>,
neq: usize,
}
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];
}
}
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())