pub struct EvenSolout<T: Real> { /* private fields */ }Expand description
An output handler that provides solution points at evenly spaced time intervals.
§Overview
EvenSolout generates output points at strictly uniform time intervals, creating
a regular grid of solution points. This is especially useful for visualization,
post-processing, or when interfacing with other systems that expect uniformly
sampled data.
Unlike DefaultSolout which captures the naturally occurring solver steps (which
may have varying time intervals), EvenSolout uses interpolation to evaluate the
solution at precise time points separated by a fixed interval.
§Example
use differential_equations::prelude::*;
use differential_equations::solout::EvenSolout;
use nalgebra::{Vector2, vector};
// Simple harmonic oscillator
struct HarmonicOscillator;
impl ODE<f64, Vector2<f64>> for HarmonicOscillator {
fn diff(&self, _t: f64, y: &Vector2<f64>, dydt: &mut Vector2<f64>) {
// y[0] = position, y[1] = velocity
dydt[0] = y[1];
dydt[1] = -y[0];
}
}
// Create the system and solver
let system = HarmonicOscillator;
let t0 = 0.0;
let tf = 10.0;
let y0 = vector![1.0, 0.0];
let mut solver = DOP853::new().rtol(1e-6).atol(1e-8);
// Generate output points with a fixed interval of 0.1
let mut even_output = EvenSolout::new(0.1, t0, tf);
// Solve with evenly spaced output
let problem = ODEProblem::new(system, t0, tf, y0);
let solution = problem.solout(&mut even_output).solve(&mut solver).unwrap();
// Note: This is equivalent to using the convenience method:
let solution = problem.even(0.1).solve(&mut solver).unwrap();§Output Characteristics
The output will contain points at regular intervals: t₀, t₀+dt, t₀+2dt, …, tₙ. The final point tₙ is guaranteed to be included, even if it doesn’t fall exactly on the regular grid. Any evaluation points that fall outside the integration range are ignored.
Implementations§
Source§impl<T: Real> EvenSolout<T>
impl<T: Real> EvenSolout<T>
Sourcepub fn new(dt: T, t0: T, tf: T) -> Self
pub fn new(dt: T, t0: T, tf: T) -> Self
Creates a new EvenSolout instance with the specified time interval.
This output handler will generate solution points at regular intervals of dt
starting from t0 and continuing through tf. The points will be aligned
with t0 (i.e., t₀, t₀+dt, t₀+2dt, …).
§Arguments
dt- The fixed time interval between output pointst0- The initial time of the integrationtf- The final time of the integration
§Returns
- A new
EvenSoloutinstance
Trait Implementations§
Source§impl<T, V, D> Solout<T, V, D> for EvenSolout<T>
impl<T, V, D> Solout<T, V, D> for EvenSolout<T>
Source§fn solout<I>(
&mut self,
t_curr: T,
t_prev: T,
y_curr: &V,
y_prev: &V,
interpolator: &mut I,
solution: &mut Solution<T, V, D>,
) -> ControlFlag<T, V, D>where
I: Interpolation<T, V>,
fn solout<I>(
&mut self,
t_curr: T,
t_prev: T,
y_curr: &V,
y_prev: &V,
interpolator: &mut I,
solution: &mut Solution<T, V, D>,
) -> ControlFlag<T, V, D>where
I: Interpolation<T, V>,
Auto Trait Implementations§
impl<T> Freeze for EvenSolout<T>where
T: Freeze,
impl<T> RefUnwindSafe for EvenSolout<T>where
T: RefUnwindSafe,
impl<T> Send for EvenSolout<T>
impl<T> Sync for EvenSolout<T>
impl<T> Unpin for EvenSolout<T>where
T: Unpin,
impl<T> UnwindSafe for EvenSolout<T>where
T: 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
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.