pub struct BDF6<N, S>where
N: ComplexField,
S: DimName + DimMin<S, Output = S>,
DefaultAllocator: Allocator<N, S> + Allocator<N, U7> + Allocator<N, S, S> + Allocator<N, U1, S> + Allocator<(usize, usize), S>,{ /* private fields */ }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 nalgebra::{VectorN, U1};
use bacon_sci::ivp::{BDF6, BDFSolver};
fn derivatives(_t: f64, state: &[f64], _p: &mut ()) -> Result<VectorN<f64, U1>, String> {
Ok(-VectorN::<f64, U1>::from_column_slice(state))
}
fn example() -> Result<(), String> {
let bdf = BDF6::new()
.with_dt_max(0.1)?
.with_dt_min(0.00001)?
.with_tolerance(0.00001)?
.with_start(0.0)?
.with_end(10.0)?
.with_initial_conditions(&[1.0])?
.build();
let path = bdf.solve_ivp(derivatives, &mut ())?;
for (time, state) in &path {
assert!(((-time).exp() - state.column(0)[0]).abs() < 0.001);
}
Ok(())
}Implementations§
Trait Implementations§
Source§impl<N, S> BDFSolver<N, S, U7> for BDF6<N, S>
impl<N, S> BDFSolver<N, S, U7> for BDF6<N, S>
Source§fn higher_coefficients() -> VectorN<N::RealField, U7>
fn higher_coefficients() -> VectorN<N::RealField, U7>
The polynomial interpolation coefficients for the higher-order
method. Should start
with the coefficient for the derivative
function without h, then n - 1. The
coefficients for the previous terms
should have the sign as if they’re on the
same side of the = as the next state.
Source§fn lower_coefficients() -> VectorN<N::RealField, U7>
fn lower_coefficients() -> VectorN<N::RealField, U7>
The polynomial interpolation coefficients for the lower-order
method. Must be
one less in length than higher_coefficients.
Should start with the coefficient for the
derivative function without h, then n-1. The
coefficients for the previous terms
should have the sign as if they’re on the
same side of the = as the next state.
Source§fn solve_ivp<T: Clone, F: FnMut(N::RealField, &[N], &mut T) -> Result<VectorN<N, S>, String>>(
self,
f: F,
params: &mut T,
) -> Result<Vec<(N::RealField, VectorN<N, S>)>, String>
fn solve_ivp<T: Clone, F: FnMut(N::RealField, &[N], &mut T) -> Result<VectorN<N, S>, String>>( self, f: F, params: &mut T, ) -> Result<Vec<(N::RealField, VectorN<N, S>)>, String>
Use BDFInfo to solve an initial value problem
Source§fn with_tolerance(self, tol: N::RealField) -> Result<Self, String>
fn with_tolerance(self, tol: N::RealField) -> Result<Self, String>
Set the error tolerance for this solver.
Source§fn with_dt_max(self, max: N::RealField) -> Result<Self, String>
fn with_dt_max(self, max: N::RealField) -> Result<Self, String>
Set the maximum time step for this solver.
Source§fn with_dt_min(self, min: N::RealField) -> Result<Self, String>
fn with_dt_min(self, min: N::RealField) -> Result<Self, String>
Set the minimum time step for this solver.
Source§fn with_start(self, t_initial: N::RealField) -> Result<Self, String>
fn with_start(self, t_initial: N::RealField) -> Result<Self, String>
Set the initial time for this solver.
Source§fn with_end(self, t_final: N::RealField) -> Result<Self, String>
fn with_end(self, t_final: N::RealField) -> Result<Self, String>
Set the end time for this solver.
Auto Trait Implementations§
impl<N, S> !Freeze for BDF6<N, S>
impl<N, S> !RefUnwindSafe for BDF6<N, S>
impl<N, S> !Send for BDF6<N, S>
impl<N, S> !Sync for BDF6<N, S>
impl<N, S> !Unpin for BDF6<N, S>
impl<N, S> !UnwindSafe for BDF6<N, S>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.