Skip to main content

OdeSystem

Trait OdeSystem 

Source
pub trait OdeSystem<const N: usize> {
    type Error;

    // Required method
    fn derivative(
        &mut self,
        t_s: f64,
        y: &[f64; N],
    ) -> Result<[f64; N], Self::Error>;

    // Provided methods
    fn absolute_tolerance_weights(&self) -> [f64; N] { ... }
    fn event_count(&self) -> usize { ... }
    fn event_direction(&self, _index: usize) -> Direction { ... }
    fn event_value(&mut self, _index: usize, _t_s: f64, _y: &[f64; N]) -> f64 { ... }
    fn accept_step(&mut self, _step: &Step<N>) -> ControlFlow<()> { ... }
}
Expand description

A first-order system y' = f(t, y) with N components, its events and its step observer.

Only derivative is required. The event methods declare scalar functions g_i(t, y) whose crossings stop the integration (none by default), and accept_step sees every accepted step. One type carries all three so that a flight phase can record from, and stop on, its own state.

Required Associated Types§

Source

type Error

The error the derivative can return.

Required Methods§

Source

fn derivative( &mut self, t_s: f64, y: &[f64; N], ) -> Result<[f64; N], Self::Error>

The derivative f(t, y).

§Errors

Whatever the system can’t evaluate. In an adaptive step the integrator treats an error as a rejection and retries with a shorter step, because a long step’s stages can probe states off the trajectory; the error is returned once the step can’t shrink further, or at once for the step’s first stage and for RK4.

Provided Methods§

Source

fn absolute_tolerance_weights(&self) -> [f64; N]

Per-component weights wᵢ on the absolute tolerance, so that components in different units share one Adaptive::absolute_tolerance: component i is held to wᵢ·atol + rtol·|yᵢ|. Every weight must be finite and positive. All ones by default.

Source

fn event_count(&self) -> usize

The number of event functions (none by default).

Source

fn event_direction(&self, _index: usize) -> Direction

The direction of event index.

Source

fn event_value(&mut self, _index: usize, _t_s: f64, _y: &[f64; N]) -> f64

g_index(t, y). A non-finite value stops the integration with IntegrationError::EventNotFinite.

Source

fn accept_step(&mut self, _step: &Step<N>) -> ControlFlow<()>

Sees each accepted step, including one shortened to end at an event or a stop time. Returning Break stops the integration at the end of this step with Advance::Stopped (unless events fired there, which take precedence).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§