pub struct DDEProblem<const L: usize, T, V, D, F, H>{
pub dde: F,
pub t0: T,
pub tf: T,
pub y0: V,
pub phi: H,
/* private fields */
}Expand description
Initial Value Problem for Delay Differential Equations (DDEs)
The Initial Value Problem takes the form: y’(t) = f(t, y(t), y(t-tau1), …), t ∈ [t0, tf], y(t) = phi(t) for t <= t0
§Overview
The DDEProblem struct provides a simple interface for solving DDEs:
§Example
use differential_equations::prelude::*;
use nalgebra::{Vector2, vector};
let mut rkf45 = ExplicitRungeKutta::rkf45()
.rtol(1e-6)
.atol(1e-6);
let t0 = 0.0;
let tf = 10.0;
let y0 = vector![1.0, 0.0];
let phi = |t| {
y0
};
struct Example;
impl DDE<1, f64, Vector2<f64>> for Example {
fn diff(&self, t: f64, y: &Vector2<f64>, yd: &[Vector2<f64>; 1], dydt: &mut Vector2<f64>) {
dydt[0] = y[1] + yd[0][0];
dydt[1] = -y[0] + yd[0][1];
}
fn lags(&self, _t: f64, _y: &Vector2<f64>, lags: &mut [f64; 1]) {
lags[0] = 1.0; // Fixed delay of 1.0
}
}
let solution = DDEProblem::new(Example, t0, tf, y0, phi).solve(&mut rkf45).unwrap();
let (t, y) = solution.last().unwrap();
println!("Solution: ({}, {})", t, y);§Fields
dde- DDE implementing the differential equationt0- Initial timetf- Final timey0- Initial state vector att0phi- Initial history functionphi(t)fort <= t0
§Basic Usage
new(dde, t0, tf, y0, phi)- Create a new DDEProblemsolve(&mut solver)- Solve using default output (solver step points)
§Output Control Methods
These methods configure how solution points are generated and returned:
even(dt)- Generate evenly spaced output points with intervaldtdense(n)- Includeninterpolated points between each solver stept_eval(points)- Evaluate solution at specific time pointssolout(custom_solout)- Use a custom output handler
Each returns a solver configuration that can be executed with .solve(&mut solver).
Fields§
§dde: F§t0: T§tf: T§y0: V§phi: HImplementations§
Source§impl<const L: usize, T, V, D, F, H> DDEProblem<L, T, V, D, F, H>
impl<const L: usize, T, V, D, F, H> DDEProblem<L, T, V, D, F, H>
Sourcepub fn new(dde: F, t0: T, tf: T, y0: V, phi: H) -> Self
pub fn new(dde: F, t0: T, tf: T, y0: V, phi: H) -> Self
Create a new Initial Value Problem for DDEs
§Arguments
dde- DDE containing the Differential Equation and Optional Terminate Function.t0- Initial Time.tf- Final Time.y0- Initial State Vector att0.phi- Initial History Functionphi(t)fort <= t0.
§Returns
- DDEProblem Problem ready to be solved.
Sourcepub fn solve<S>(&self, solver: &mut S) -> Result<Solution<T, V, D>, Error<T, V>>
pub fn solve<S>(&self, solver: &mut S) -> Result<Solution<T, V, D>, Error<T, V>>
Solve the DDEProblem using a default solout, e.g. outputting solutions at calculated steps.
§Returns
Result<Solution<T, V, D>, Error<T, V>>-Ok(Solution)if successful or interrupted by events,Err(Error)if errors or issues are encountered.
Sourcepub fn solout<'a, O: Solout<T, V, D>>(
&'a self,
solout: &'a mut O,
) -> DDEProblemMutRefSoloutPair<'a, L, T, V, D, F, H, O>
pub fn solout<'a, O: Solout<T, V, D>>( &'a self, solout: &'a mut O, ) -> DDEProblemMutRefSoloutPair<'a, L, T, V, D, F, H, O>
Returns a DDEProblem DelayNumericalMethod with the provided solout function for outputting points.
§Returns
- DDEProblem DelayNumericalMethod with the provided solout function ready for .solve() method.
Sourcepub fn even(
&self,
dt: T,
) -> DDEProblemSoloutPair<'_, L, T, V, D, F, H, EvenSolout<T>>
pub fn even( &self, dt: T, ) -> DDEProblemSoloutPair<'_, L, T, V, D, F, H, EvenSolout<T>>
Uses the an Even Solout implementation to output evenly spaced points between the initial and final time. Note that this does not include the solution of the calculated steps.
§Arguments
dt- Interval between each output point.
§Returns
- DDEProblem DelayNumericalMethod with Even Solout function ready for .solve() method.
Sourcepub fn dense(
&self,
n: usize,
) -> DDEProblemSoloutPair<'_, L, T, V, D, F, H, DenseSolout>
pub fn dense( &self, n: usize, ) -> DDEProblemSoloutPair<'_, L, T, V, D, F, H, DenseSolout>
Uses the Dense Output method to output n number of interpolation points between each step. Note this includes the solution of the calculated steps.
§Arguments
n- Number of interpolation points between each step.
§Returns
- DDEProblem DelayNumericalMethod with Dense Output function ready for .solve() method.
Sourcepub fn t_eval(
&self,
points: Vec<T>,
) -> DDEProblemSoloutPair<'_, L, T, V, D, F, H, TEvalSolout<T>>
pub fn t_eval( &self, points: Vec<T>, ) -> DDEProblemSoloutPair<'_, L, T, V, D, F, H, TEvalSolout<T>>
Sourcepub fn crossing(
&self,
component_idx: usize,
threshhold: T,
direction: CrossingDirection,
) -> DDEProblemSoloutPair<'_, L, T, V, D, F, H, CrossingSolout<T>>
pub fn crossing( &self, component_idx: usize, threshhold: T, direction: CrossingDirection, ) -> DDEProblemSoloutPair<'_, L, T, V, D, F, H, CrossingSolout<T>>
Uses the CrossingSolout method to output points when a specific component crosses a threshold. Note this does not include the solution of the calculated steps.
§Arguments
component_idx- Index of the component to monitor for crossing.threshhold- Value to cross.direction- Direction of crossing (positive or negative).
§Returns
- DDEProblem DelayNumericalMethod with CrossingSolout function ready for .solve() method.
Sourcepub fn hyperplane_crossing<V1>(
&self,
point: V1,
normal: V1,
extractor: fn(&V) -> V1,
direction: CrossingDirection,
) -> DDEProblemSoloutPair<'_, L, T, V, D, F, H, HyperplaneCrossingSolout<T, V1, V>>where
V1: State<T>,
pub fn hyperplane_crossing<V1>(
&self,
point: V1,
normal: V1,
extractor: fn(&V) -> V1,
direction: CrossingDirection,
) -> DDEProblemSoloutPair<'_, L, T, V, D, F, H, HyperplaneCrossingSolout<T, V1, V>>where
V1: State<T>,
Uses the HyperplaneCrossingSolout method to output points when a specific hyperplane is crossed. Note this does not include the solution of the calculated steps.
§Arguments
point- Point on the hyperplane.normal- Normal vector of the hyperplane.extractor- Function to extract the component from the state vector.direction- Direction of crossing (positive or negative).
§Returns
- DDEProblem DelayNumericalMethod with HyperplaneCrossingSolout function ready for .solve() method.
Trait Implementations§
Source§impl<const L: usize, T, V, D, F, H> Clone for DDEProblem<L, T, V, D, F, H>
impl<const L: usize, T, V, D, F, H> Clone for DDEProblem<L, T, V, D, F, H>
Source§fn clone(&self) -> DDEProblem<L, T, V, D, F, H>
fn clone(&self) -> DDEProblem<L, T, V, D, F, H>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<const L: usize, T, V, D, F, H> Debug for DDEProblem<L, T, V, D, F, H>
impl<const L: usize, T, V, D, F, H> Debug for DDEProblem<L, T, V, D, F, H>
Auto Trait Implementations§
impl<const L: usize, T, V, D, F, H> Freeze for DDEProblem<L, T, V, D, F, H>
impl<const L: usize, T, V, D, F, H> RefUnwindSafe for DDEProblem<L, T, V, D, F, H>
impl<const L: usize, T, V, D, F, H> Send for DDEProblem<L, T, V, D, F, H>
impl<const L: usize, T, V, D, F, H> Sync for DDEProblem<L, T, V, D, F, H>
impl<const L: usize, T, V, D, F, H> Unpin for DDEProblem<L, T, V, D, F, H>
impl<const L: usize, T, V, D, F, H> UnwindSafe for DDEProblem<L, T, V, D, F, H>
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
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>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
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
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.