pub struct OdeLane<S: OdeSystem> {
pub system: S,
pub y0: Vec<f64>,
pub x_start: f64,
pub x_end: f64,
pub dx0: f64,
}Expand description
One member of an ODE ensemble: a system, its initial condition, and the interval to advance it over.
The system is owned by value, so an ensemble is a plain
Vec<OdeLane<S>> with no lifetime parameter anywhere and no possibility of
the system slice and the initial-condition slice disagreeing in length. S
may be any concrete type implementing OdeSystem, including the caller’s
own enum over several systems — which is how one ensemble holds genuinely
different physics in different lanes.
§Units
x_start, x_end and dx0 are in the independent variable’s units
(typically seconds); y0’s components are in whatever units that lane’s
state carries, which need not be the same as each other. All are the
caller’s own units — see the module-level “Units” section.
§Validity
A lane is rejected with OdeLaneStatus::InvalidLane, before any
integration, unless all of the following hold:
y0.len() == system.n_eqns()x_start,x_endand every component ofy0are finitedx0is finite and strictly positivex_end >= x_start— the underlying interval loop integrates forwards only, so a reversed interval is a caller error rather than a backwards integration
x_end == x_start is legal and is a no-op: the lane completes in zero steps
with its state unchanged.
Fields§
§system: SThe system this lane integrates, owned outright.
y0: Vec<f64>Initial state at x_start, one entry per equation.
x_start: f64Start of the integration interval.
x_end: f64End of the integration interval; must be >= x_start.
dx0: f64First step size to attempt. Must be finite and > 0; the adaptive
controller adjusts it from there, so it is a starting guess and not a
constraint.
Implementations§
Source§impl<S: OdeSystem> OdeLane<S>
impl<S: OdeSystem> OdeLane<S>
Sourcepub fn new(system: S, y0: Vec<f64>, x_start: f64, x_end: f64, dx0: f64) -> Self
pub fn new(system: S, y0: Vec<f64>, x_start: f64, x_end: f64, dx0: f64) -> Self
Build one ensemble lane.
§Arguments
system— the system to integrate, moved into the lane.y0— initial state,system.n_eqns()entries.x_start,x_end— the interval, in the independent variable’s units, withx_end >= x_start.dx0— first step size to attempt, same units,> 0.
§Example
use outram_foam_basic_lib::ode::OdeSystem;
use outram_foam_basic_lib::ode::parallel::OdeLane;
struct Decay;
impl OdeSystem for Decay {
fn n_eqns(&self) -> usize { 1 }
fn derivatives(&self, _x: f64, y: &[f64], d: &mut Vec<f64>) { d[0] = -y[0]; }
}
let lane = OdeLane::new(Decay, vec![1.0], 0.0, 1.0, 0.1);
assert_eq!(lane.y0.len(), 1);