EvenSolout

Struct EvenSolout 

Source
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 = ExplicitRungeKutta::dop853().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>

Source

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 points
  • t0 - The initial time of the integration
  • tf - The final time of the integration
§Returns
  • A new EvenSolout instance

Trait Implementations§

Source§

impl<T, Y> Solout<T, Y> for EvenSolout<T>
where T: Real, Y: State<T>,

Source§

fn solout<I>( &mut self, t_curr: T, t_prev: T, y_curr: &Y, y_prev: &Y, interpolator: &mut I, solution: &mut Solution<T, Y>, ) -> ControlFlag<T, Y>
where I: Interpolation<T, Y>,

Solout function to choose which points to output during the solving process. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

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

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.