pub struct Adams2<N, const S: usize>where
N: ComplexField + FromPrimitive + Copy,
<N as ComplexField>::RealField: FromPrimitive + Copy,{ /* private fields */ }Expand description
3rd order Adams predictor-corrector method for solving an IVP.
Defines the predictor and corrector coefficients, as well as the error coefficient. Uses AdamsInfo for the actual solving.
Examples
use nalgebra::SVector;
use bacon_sci::ivp::{Adams2, AdamsSolver};
fn derivatives(_t: f64, state: &[f64], _p: &mut ()) -> Result<SVector<f64, 1>, String> {
Ok(SVector::<f64, 1>::from_column_slice(state))
}
fn example() -> Result<(), String> {
let adams = Adams2::new()
.with_dt_max(0.1)?
.with_dt_min(0.00001)?
.with_tolerance(0.00001)?
.with_start(0.0)?
.with_end(1.0)?
.with_initial_conditions(&[1.0])?
.build();
let path = adams.solve_ivp(derivatives, &mut ())?;
for (time, state) in &path {
assert!((time.exp() - state.column(0)[0]).abs() < 0.001);
}
Ok(())
}Implementations§
source§impl<N, const S: usize> Adams2<N, S>where
N: ComplexField + FromPrimitive + Copy,
<N as ComplexField>::RealField: FromPrimitive + Copy,
impl<N, const S: usize> Adams2<N, S>where N: ComplexField + FromPrimitive + Copy, <N as ComplexField>::RealField: FromPrimitive + Copy,
Trait Implementations§
source§impl<N, const S: usize> AdamsSolver<N, S, 3> for Adams2<N, S>where
N: ComplexField + FromPrimitive + Copy,
<N as ComplexField>::RealField: FromPrimitive + Copy,
impl<N, const S: usize> AdamsSolver<N, S, 3> for Adams2<N, S>where N: ComplexField + FromPrimitive + Copy, <N as ComplexField>::RealField: FromPrimitive + Copy,
source§fn predictor_coefficients() -> SVector<N::RealField, 3>
fn predictor_coefficients() -> SVector<N::RealField, 3>
The polynomial interpolation coefficients for the predictor. Should start
with the coefficient for n - 1
source§fn corrector_coefficients() -> SVector<N::RealField, 3>
fn corrector_coefficients() -> SVector<N::RealField, 3>
The polynomial interpolation coefficients for the corrector. Must be
the same length as predictor_coefficients. Should start with the
implicit coefficient.
source§fn error_coefficient() -> N::RealField
fn error_coefficient() -> N::RealField
Coefficient for multiplying error by.
source§fn solve_ivp<T: Clone, F: FnMut(N::RealField, &[N], &mut T) -> Result<SVector<N, S>, String>>(
self,
f: F,
params: &mut T
) -> Result<Vec<(N::RealField, SVector<N, S>)>, String>
fn solve_ivp<T: Clone, F: FnMut(N::RealField, &[N], &mut T) -> Result<SVector<N, S>, String>>( self, f: F, params: &mut T ) -> Result<Vec<(N::RealField, SVector<N, S>)>, String>
Use AdamsInfo 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.
source§impl<N, const S: usize> Clone for Adams2<N, S>where
N: ComplexField + FromPrimitive + Copy + Clone,
<N as ComplexField>::RealField: FromPrimitive + Copy,
impl<N, const S: usize> Clone for Adams2<N, S>where N: ComplexField + FromPrimitive + Copy + Clone, <N as ComplexField>::RealField: FromPrimitive + Copy,
source§impl<N, const S: usize> Debug for Adams2<N, S>where
N: ComplexField + FromPrimitive + Copy + Debug,
<N as ComplexField>::RealField: FromPrimitive + Copy,
impl<N, const S: usize> Debug for Adams2<N, S>where N: ComplexField + FromPrimitive + Copy + Debug, <N as ComplexField>::RealField: FromPrimitive + Copy,
source§impl<N, const S: usize> Default for Adams2<N, S>where
N: ComplexField + FromPrimitive + Copy,
<N as ComplexField>::RealField: FromPrimitive + Copy,
impl<N, const S: usize> Default for Adams2<N, S>where N: ComplexField + FromPrimitive + Copy, <N as ComplexField>::RealField: FromPrimitive + Copy,
Auto Trait Implementations§
impl<N, const S: usize> RefUnwindSafe for Adams2<N, S>where N: RefUnwindSafe, <N as ComplexField>::RealField: RefUnwindSafe,
impl<N, const S: usize> Send for Adams2<N, S>
impl<N, const S: usize> Sync for Adams2<N, S>
impl<N, const S: usize> Unpin for Adams2<N, S>where N: Unpin, <N as ComplexField>::RealField: Unpin,
impl<N, const S: usize> UnwindSafe for Adams2<N, S>where N: UnwindSafe, <N as ComplexField>::RealField: UnwindSafe,
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
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,
§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 more§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).§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.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.