Skip to main content

OdeLane

Struct OdeLane 

Source
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_end and every component of y0 are finite
  • dx0 is finite and strictly positive
  • x_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: S

The system this lane integrates, owned outright.

§y0: Vec<f64>

Initial state at x_start, one entry per equation.

§x_start: f64

Start of the integration interval.

§x_end: f64

End of the integration interval; must be >= x_start.

§dx0: f64

First 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>

Source

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, with x_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);

Trait Implementations§

Source§

impl<S: Clone + OdeSystem> Clone for OdeLane<S>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<S: Debug + OdeSystem> Debug for OdeLane<S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<S: PartialEq + OdeSystem> PartialEq for OdeLane<S>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<S: PartialEq + OdeSystem> StructuralPartialEq for OdeLane<S>

Auto Trait Implementations§

§

impl<S> Freeze for OdeLane<S>
where S: Freeze,

§

impl<S> RefUnwindSafe for OdeLane<S>
where S: RefUnwindSafe,

§

impl<S> Send for OdeLane<S>
where S: Send,

§

impl<S> Sync for OdeLane<S>
where S: Sync,

§

impl<S> Unpin for OdeLane<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for OdeLane<S>
where S: UnsafeUnpin,

§

impl<S> UnwindSafe for OdeLane<S>
where S: 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.