pub struct DOPRI5<const L: usize, T: Real, V: State<T>, H: Fn(T) -> V, D: CallBackData> {
pub h0: T,
pub rtol: T,
pub atol: T,
pub h_max: T,
pub h_min: T,
pub max_steps: usize,
pub safe: T,
pub fac1: T,
pub fac2: T,
pub beta: T,
pub max_delay: Option<T>,
/* private fields */
}Expand description
Dormand-Prince 5(4) method adapted for DDEs. 5th order method with embedded 4th order error estimation and 5th order dense output. FSAL property. 7 stages, 6 function evaluations per step.
§Example
use differential_equations::prelude::*;
use differential_equations::dde::methods::DOPRI5;
use nalgebra::{Vector2, vector};
let mut dopri5 = DOPRI5::new()
.rtol(1e-6)
.atol(1e-6);
let t0 = 0.0;
let tf = 5.0;
let y0 = vector![1.0, 0.0];
let phi = |t| { // History function for t <= t0
if t <= 0.0 { vector![1.0, 0.0] } else { panic!("phi called for t > t0") }
};
struct ExampleDDE;
impl DDE<1, f64, Vector2<f64>> for ExampleDDE {
fn diff(&self, t: f64, y: &Vector2<f64>, yd: &[Vector2<f64>; 1], dydt: &mut Vector2<f64>) {
dydt[0] = yd[0][1];
dydt[1] = -yd[0][0] - 1.0 * y[1];
}
fn lags(&self, t: f64, y: &Vector2<f64>, lags: &mut [f64; 1]) {
lags[0] = 1.0; // Constant delay tau = 1.0
}
}
let problem = DDEProblem::new(ExampleDDE, t0, tf, y0, phi);
let solution = problem.solve(&mut dopri5).unwrap();
let (t, y) = solution.last().unwrap();
println!("DOPRI5 Solution at t={}: ({}, {})", t, y[0], y[1]);§Settings
rtol,atol,h0,h_max,h_min,max_steps,safe,fac1,fac2,beta,max_delay.
§Default Settings
rtol- 1e-3atol- 1e-6h0- Noneh_max- Noneh_min- 0.0max_steps- 100_000safe- 0.9fac1- 0.2fac2- 10.0beta- 0.04 (PI stabilization enabled by default for DOPRI5)max_delay- None
Fields§
§h0: T§rtol: T§atol: T§h_max: T§h_min: T§max_steps: usize§safe: T§fac1: T§fac2: T§beta: T§max_delay: Option<T>Implementations§
Source§impl<const L: usize, T: Real, V: State<T>, H: Fn(T) -> V, D: CallBackData> DOPRI5<L, T, V, H, D>
impl<const L: usize, T: Real, V: State<T>, H: Fn(T) -> V, D: CallBackData> DOPRI5<L, T, V, H, D>
pub fn new() -> Self
pub fn rtol(self, rtol: T) -> Self
pub fn atol(self, atol: T) -> Self
pub fn h0(self, h0: T) -> Self
pub fn h_max(self, h_max: T) -> Self
pub fn h_min(self, h_min: T) -> Self
pub fn max_steps(self, max_steps: usize) -> Self
pub fn safe(self, safe: T) -> Self
pub fn fac1(self, fac1: T) -> Self
pub fn fac2(self, fac2: T) -> Self
pub fn beta(self, beta: T) -> Self
pub fn max_delay(self, max_delay: T) -> Self
Trait Implementations§
Source§impl<const L: usize, T: Real, V: State<T>, H: Fn(T) -> V, D: CallBackData> DDENumericalMethod<L, T, V, H, D> for DOPRI5<L, T, V, H, D>
impl<const L: usize, T: Real, V: State<T>, H: Fn(T) -> V, D: CallBackData> DDENumericalMethod<L, T, V, H, D> for DOPRI5<L, T, V, H, D>
Source§fn init<F>(
&mut self,
dde: &F,
t0: T,
tf: T,
y0: &V,
phi: H,
) -> Result<Evals, Error<T, V>>where
F: DDE<L, T, V, D>,
fn init<F>(
&mut self,
dde: &F,
t0: T,
tf: T,
y0: &V,
phi: H,
) -> Result<Evals, Error<T, V>>where
F: DDE<L, T, V, D>,
Initialize DDENumericalMethod before solving DDE. Read more
Source§fn step<F>(&mut self, dde: &F) -> Result<Evals, Error<T, V>>where
F: DDE<L, T, V, D>,
fn step<F>(&mut self, dde: &F) -> Result<Evals, Error<T, V>>where
F: DDE<L, T, V, D>,
Perform one integration step for the DDE. Read more
Source§fn status(&self) -> &Status<T, V, D>
fn status(&self) -> &Status<T, V, D>
Get the current status of the solver (Solving, Complete, Error, etc.).
Source§fn set_status(&mut self, status: Status<T, V, D>)
fn set_status(&mut self, status: Status<T, V, D>)
Set the status of the solver.
Source§impl<const L: usize, T: Real, V: State<T>, H: Fn(T) -> V, D: CallBackData> Default for DOPRI5<L, T, V, H, D>
impl<const L: usize, T: Real, V: State<T>, H: Fn(T) -> V, D: CallBackData> Default for DOPRI5<L, T, V, H, D>
Source§impl<const L: usize, T: Real, V: State<T>, H: Fn(T) -> V, D: CallBackData> Interpolation<T, V> for DOPRI5<L, T, V, H, D>
impl<const L: usize, T: Real, V: State<T>, H: Fn(T) -> V, D: CallBackData> Interpolation<T, V> for DOPRI5<L, T, V, H, D>
Auto Trait Implementations§
impl<const L: usize, T, V, H, D> Freeze for DOPRI5<L, T, V, H, D>
impl<const L: usize, T, V, H, D> RefUnwindSafe for DOPRI5<L, T, V, H, D>
impl<const L: usize, T, V, H, D> Send for DOPRI5<L, T, V, H, D>
impl<const L: usize, T, V, H, D> Sync for DOPRI5<L, T, V, H, D>
impl<const L: usize, T, V, H, D> Unpin for DOPRI5<L, T, V, H, D>
impl<const L: usize, T, V, H, D> UnwindSafe for DOPRI5<L, T, V, H, 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.