BDF6

Type Alias BDF6 

Source
pub type BDF6<'a, N, D, T, F> = BDF<'a, N, D, 7, T, F, BDF6Coefficients<N>>;
Expand description

6th order backwards differentiation formula method for solving an initial value problem.

Defines the higher and lower order coefficients. Uses [BDFInfo] for the actual solving.

§Examples

use std::error::Error;
use bacon_sci::{BSVector, ivp::{IVPSolver, IVPError, bdf::BDF6}};

fn derivatives(_t: f64, state: &[f64], _p: &mut ()) -> Result<BSVector<f64, 1>, Box<dyn Error>> {
    Ok(-BSVector::from_column_slice(state))
}

fn example() -> Result<(), IVPError> {
    let bdf = BDF6::new()?
        .with_maximum_dt(0.1)?
        .with_minimum_dt(0.00001)?
        .with_tolerance(0.00001)?
        .with_initial_time(0.0)?
        .with_ending_time(10.0)?
        .with_initial_conditions_slice(&[1.0])?
        .with_derivative(derivatives)
        .solve(())?;
    let path = bdf.collect_vec()?;
    for (time, state) in &path {
        assert!(((-time).exp() - state.column(0)[0]).abs() < 0.001);
    }
    Ok(())
}

Aliased Type§

pub struct BDF6<'a, N, D, T, F> { /* private fields */ }