Skip to content

DynamicalSystem

Defined in: state.rs:286

pub trait DynamicalSystem

A dynamical system that can compute state derivatives at a given time.

The derivative has the same type as the state (standard ODE formulation: for y = [q, q’], dy/dt = [q’, q”] is also of type State).

fn derivatives(&self, t: f64, state: &::State) -> ::State


fn next_discontinuity_after(&self, _t: f64) -> Option<f64>

The next time after t at which the right-hand side changes discontinuously, if the system knows one in advance.

A solver evaluates the right-hand side at stage times of its own choosing, so a term that switches inside a step is sampled at whichever stages happen to fall on each side of the switch — and one that switches on and off between two stages is not sampled at all. A system that knows when it switches can say so here, and a propagation loop can end its step there instead.

Implementations must return a finite time strictly greater than t, and must not report t itself. Switches whose time depends on the state (a limit the trajectory reaches, a threshold it crosses) are not knowable here and are not reported.

What a system reports is what it knows on its caller’s behalf: the schedules carried by the parts it holds. A function the caller passed in — a prescribed trajectory, a prescribed mass — is the caller’s own knowledge, and a caller who wrote a piecewise one already holds its breakpoints. A propagation loop takes boundaries from both.

The default answers None: a system whose right-hand side is continuous needs no boundary.


fn derivatives_in_segment(&self, _segment: &SegmentContext, t: f64, state: &::State) -> ::State

Derivatives at t, evaluated for the segment the solver is stepping through.

A solver reaches this through SegmentSystem, which binds one segment and forwards derivatives(Self::derivatives) here. A term that switches on a schedule answers for segment.start however late in the segment t falls, which is what keeps the stage on segment.end on the inside of a half-open interval that ends there.

A term that reads the state keeps reading state: a segment fixes a schedule in time, not a feedback law.

The default ignores the segment and forwards to derivatives(Self::derivatives), which is right for every system whose right-hand side is continuous.

SegmentSystem: crate::SegmentSystem