pub struct APCF4<T: Real, V: State<T>, D: CallBackData> {
pub h: T,
pub evals: usize,
/* private fields */
}Expand description
Adams-Predictor-Corrector 4th Order Fixed Step Size Method.
The Adams-Predictor-Corrector method is an explicit method that uses the previous states to predict the next state.
The First 3 steps, of fixed step size h, are calculated using
the Runge-Kutta method of order 4(5) and then the Adams-Predictor-Corrector
method is used to calculate the remaining steps tell the final time.
§Example
use differential_equations::prelude::*;
use differential_equations::ode::methods::adams::APCF4;
use nalgebra::{SVector, vector};
struct HarmonicOscillator {
k: f64,
}
impl ODE<f64, SVector<f64, 2>> for HarmonicOscillator {
fn diff(&self, _t: f64, y: &SVector<f64, 2>, dydt: &mut SVector<f64, 2>) {
dydt[0] = y[1];
dydt[1] = -self.k * y[0];
}
}
let mut apcf4 = APCF4::new(0.01);
let t0 = 0.0;
let tf = 10.0;
let y0 = vector![1.0, 0.0];
let system = HarmonicOscillator { k: 1.0 };
let results = ODEProblem::new(system, t0, tf, y0).solve(&mut apcf4).unwrap();
let expected = vector![-0.83907153, 0.54402111];
assert!((results.y.last().unwrap()[0] - expected[0]).abs() < 1e-2);
assert!((results.y.last().unwrap()[1] - expected[1]).abs() < 1e-2);§Settings
h- Step Size
Fields§
§h: T§evals: usizeImplementations§
Trait Implementations§
Source§impl<T: Real, V: State<T>, D: CallBackData> Interpolation<T, V> for APCF4<T, V, D>
impl<T: Real, V: State<T>, D: CallBackData> Interpolation<T, V> for APCF4<T, V, D>
Source§impl<T: Real, V: State<T>, D: CallBackData> ODENumericalMethod<T, V, D> for APCF4<T, V, D>
impl<T: Real, V: State<T>, D: CallBackData> ODENumericalMethod<T, V, D> for APCF4<T, V, D>
Source§fn init<F>(
&mut self,
ode: &F,
t0: T,
tf: T,
y0: &V,
) -> Result<Evals, Error<T, V>>where
F: ODE<T, V, D>,
fn init<F>(
&mut self,
ode: &F,
t0: T,
tf: T,
y0: &V,
) -> Result<Evals, Error<T, V>>where
F: ODE<T, V, D>,
Initialize ODENumericalMethod before solving ODE Read more
Source§fn step<F>(&mut self, ode: &F) -> Result<Evals, Error<T, V>>where
F: ODE<T, V, D>,
fn step<F>(&mut self, ode: &F) -> Result<Evals, Error<T, V>>where
F: ODE<T, V, D>,
Step through solving the ODE by one step Read more
Source§fn set_status(&mut self, status: Status<T, V, D>)
fn set_status(&mut self, status: Status<T, V, D>)
Set status of solver
Auto Trait Implementations§
impl<T, V, D> Freeze for APCF4<T, V, D>
impl<T, V, D> RefUnwindSafe for APCF4<T, V, D>
impl<T, V, D> Send for APCF4<T, V, D>
impl<T, V, D> Sync for APCF4<T, V, D>
impl<T, V, D> Unpin for APCF4<T, V, D>
impl<T, V, D> UnwindSafe for APCF4<T, V, D>
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<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.