Skip to main content

OdeSystem

Trait OdeSystem 

Source
pub trait OdeSystem<S: Scalar> {
    // Required methods
    fn dim(&self) -> usize;
    fn rhs(&self, t: S, y: &[S], dydt: &mut [S]);

    // Provided methods
    fn jacobian(&self, t: S, y: &[S], jac: &mut [S]) { ... }
    fn is_autonomous(&self) -> bool { ... }
    fn has_mass_matrix(&self) -> bool { ... }
    fn mass_matrix(&self, mass: &mut [S]) { ... }
    fn is_singular_mass(&self) -> bool { ... }
    fn algebraic_indices(&self) -> Vec<usize> { ... }
}
Expand description

A system of ordinary differential equations.

Represents: dy/dt = f(t, y)

Required Methods§

Source

fn dim(&self) -> usize

Dimension of the system.

Source

fn rhs(&self, t: S, y: &[S], dydt: &mut [S])

Compute the right-hand side: dydt = f(t, y)

Provided Methods§

Source

fn jacobian(&self, t: S, y: &[S], jac: &mut [S])

Optionally compute the Jacobian: J = ∂f/∂y, row-major (jac[i*n + j] = ∂f_i/∂y_j, length ).

Default: forward finite differences. Step size is the textbook precision-aware choice for forward FD, h = sqrt(S::EPSILON) * (1 + |y_j|). The sqrt(S::EPSILON)-not-a-hardcoded-constant form keeps the FD useful at every Scalar precision: f64 lands at ≈1.49e-8, f32 at ≈3.45e-4. A hardcoded 1e-8 would fall below f32::EPSILON ≈ 1.19e-7 and quantise the perturbation to zero.

Source

fn is_autonomous(&self) -> bool

Is the system autonomous? (f does not depend on t explicitly)

Source

fn has_mass_matrix(&self) -> bool

Does this system have a mass matrix?

Source

fn mass_matrix(&self, mass: &mut [S])

Get the mass matrix M for the DAE: M * y’ = f(t, y)

Default returns identity (standard ODE). For DAEs, override to return the (possibly singular) mass matrix.

The matrix is stored in row-major order: mass[i * n + j] = M[i, j]

Source

fn is_singular_mass(&self) -> bool

Is the mass matrix singular? (i.e., is this a DAE?)

Source

fn algebraic_indices(&self) -> Vec<usize>

Return indices of algebraic variables (where M[i,i] = 0).

Default returns empty (all differential).

Implementors§

Source§

impl<S: Scalar> OdeSystem<S> for ReducedDaeSystem<S>

Source§

impl<S: Scalar, F> OdeSystem<S> for OdeProblem<S, F>
where F: Fn(S, &[S], &mut [S]),

Source§

impl<S: Scalar, F, M> OdeSystem<S> for DaeProblem<S, F, M>
where F: Fn(S, &[S], &mut [S]), M: Fn(&mut [S]),

Source§

impl<S: Scalar, Sys: ParametricOdeSystem<S>> OdeSystem<S> for AugmentedSystem<S, Sys>