[][src]Struct mathru::analysis::differential_equation::ordinary::BogackiShampine32

pub struct BogackiShampine32<T> { /* fields omitted */ }

Solves an ODE using the Bogacki Shampine algorithm.

https://en.wikipedia.org/wiki/Bogacki-Shampine_method

Implementations

impl<T> BogackiShampine32<T> where
    T: Real
[src]

pub fn new(
    n_max: u32,
    h_0: T,
    fac: T,
    fac_min: T,
    fac_max: T,
    abs_tol: T,
    rel_tol: T
) -> BogackiShampine32<T>
[src]

Creates a Bogacki-Shampine 2 3 instance

pub fn solve<F>(
    &self,
    prob: &F
) -> Result<(Vec<T>, Vec<Vector<T>>), &'static str> where
    F: ExplicitODE<T>, 
[src]

Example

use mathru::{
    algebra::linear::{Matrix, Vector},
    analysis::differential_equation::ordinary::{BogackiShampine32, ExplicitODE},
    *,
};

// Define ODE
// $`y^{'} = ay = f(x, y) `$
// $`y = C a e^{at}`$
// $'y(t_{s}) = C a e^{at_s} => C = \frac{y(t_s)}{ae^{at_s}}`$
pub struct ExplicitODEProblem
{
    time_span: (f64, f64),
    init_cond: Vector<f64>,
}

impl Default for ExplicitODEProblem
{
    fn default() -> ExplicitODEProblem
    {
        ExplicitODEProblem { time_span: (0.0, 2.0),
                             init_cond: vector![0.5] }
    }
}

impl ExplicitODE<f64> for ExplicitODEProblem
{
    fn func(self: &Self, t: &f64, x: &Vector<f64>) -> Vector<f64>
    {
        return x * &2.0f64;
    }

    fn time_span(self: &Self) -> (f64, f64)
    {
        return self.time_span;
    }

    fn init_cond(self: &Self) -> Vector<f64>
    {
        return self.init_cond.clone();
    }
}

let problem: ExplicitODEProblem = ExplicitODEProblem::default();

let h_0: f64 = 0.0001;
let fac: f64 = 0.9;
let fac_min: f64 = 0.01;
let fac_max: f64 = 2.0;
let n_max: u32 = 100;
let abs_tol: f64 = 10e-6;
let rel_tol: f64 = 10e-3;

let solver: BogackiShampine32<f64> =
    BogackiShampine32::new(n_max, h_0, fac, fac_min, fac_max, abs_tol, rel_tol);

let (t, y): (Vec<f64>, Vec<Vector<f64>>) = solver.solve(&problem).unwrap();

pub fn get_abs_tol(&self) -> &T[src]

pub fn get_rel_tol(&self) -> &T[src]

pub fn set_abs_tol(&mut self, abs_tol: T)[src]

pub fn set_rel_tol(&mut self, rel_tol: T)[src]

Trait Implementations

impl<T: Clone> Clone for BogackiShampine32<T>[src]

impl<T: Copy> Copy for BogackiShampine32<T>[src]

impl<T: Debug> Debug for BogackiShampine32<T>[src]

impl<T> Default for BogackiShampine32<T> where
    T: Real
[src]

impl<'de, T> Deserialize<'de> for BogackiShampine32<T> where
    T: Deserialize<'de>, 
[src]

impl<T> Serialize for BogackiShampine32<T> where
    T: Serialize
[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for BogackiShampine32<T> where
    T: RefUnwindSafe

impl<T> Send for BogackiShampine32<T> where
    T: Send

impl<T> Sync for BogackiShampine32<T> where
    T: Sync

impl<T> Unpin for BogackiShampine32<T> where
    T: Unpin

impl<T> UnwindSafe for BogackiShampine32<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,