Skip to main content

OdeSolverEquations

Struct OdeSolverEquations 

Source
pub struct OdeSolverEquations<M, Rhs, Init, Mass, Root, Out, Reset = UnitCallable<M>>
where M: Matrix,
{ /* private fields */ }
Expand description

This struct implements the ODE equation trait OdeEquations for a given right-hand side op, mass op, optional root op, and initial condition function.

While the crate::OdeBuilder struct is the easiest way to define an ODE problem, occasionally a user might want to use their own structs that define the equations instead of closures or the DiffSL languave, and this can be done using OdeSolverEquations.

The main traits that you need to implement are the crate::Op and NonLinearOp trait, which define a nonlinear operator or function F that maps an input vector x to an output vector y, (i.e. y = F(x)). Once you have implemented this trait, you can then pass an instance of your struct to the rhs argument of the Self::new method. Once you have created an instance of OdeSolverEquations, you can then use crate::OdeBuilder::build_from_eqn to create a problem.

Implementations§

Source§

impl<M, Rhs, Init, Mass, Root, Out, Reset> OdeSolverEquations<M, Rhs, Init, Mass, Root, Out, Reset>
where M: Matrix,

Source

pub fn new( rhs: Rhs, init: Init, mass: Option<Mass>, root: Option<Root>, out: Option<Out>, reset: Option<Reset>, p: M::V, ) -> Self

Trait Implementations§

Source§

impl<M, Rhs, Init, Mass, Root, Out, Reset> OdeEquations for OdeSolverEquations<M, Rhs, Init, Mass, Root, Out, Reset>
where M: Matrix, Rhs: Op<M = M, V = M::V, T = M::T, C = M::C>, Init: Op<M = M, V = M::V, T = M::T, C = M::C>, Mass: Op<M = M, V = M::V, T = M::T, C = M::C>, Root: Op<M = M, V = M::V, T = M::T, C = M::C>, Out: Op<M = M, V = M::V, T = M::T, C = M::C>, Reset: Op<M = M, V = M::V, T = M::T, C = M::C>, for<'a> ParameterisedOp<'a, Rhs>: NonLinearOp<M = M, V = M::V, T = M::T, C = M::C>, for<'a> ParameterisedOp<'a, Init>: ConstantOp<M = M, V = M::V, T = M::T, C = M::C>, for<'a> ParameterisedOp<'a, Mass>: LinearOp<M = M, V = M::V, T = M::T, C = M::C>, for<'a> ParameterisedOp<'a, Root>: NonLinearOp<M = M, V = M::V, T = M::T, C = M::C>, for<'a> ParameterisedOp<'a, Out>: NonLinearOp<M = M, V = M::V, T = M::T, C = M::C>, for<'a> ParameterisedOp<'a, Reset>: NonLinearOp<M = M, V = M::V, T = M::T, C = M::C>,

Source§

fn rhs(&self) -> ParameterisedOp<'_, Rhs>

returns the right-hand side function F(t, y) as a NonLinearOp
Source§

fn mass(&self) -> Option<ParameterisedOp<'_, Mass>>

returns the mass matrix M as a LinearOp
Source§

fn root(&self) -> Option<ParameterisedOp<'_, Root>>

returns the root function G(t, y) as a NonLinearOp
Source§

fn reset(&self) -> Option<ParameterisedOp<'_, Reset>>

returns the optional reset function R(y) as a NonLinearOp. When provided, this is called after a root event at index 0 to reset the state.
Source§

fn init(&self) -> ParameterisedOp<'_, Init>

returns the initial condition, i.e. y(t), where t is the initial time
Source§

fn out(&self) -> Option<ParameterisedOp<'_, Out>>

returns the output function H(t, y) as a NonLinearOp
Source§

fn set_params(&mut self, p: &Self::V)

sets the current parameters of the equations
Source§

fn get_params(&self, p: &mut Self::V)

gets the current parameters of the equations
Source§

fn set_model_index(&mut self, _m: usize)

sets the current model index of the equations Read more
Source§

impl<'a, M, Rhs, Init, Mass, Root, Out, Reset> OdeEquationsRef<'a> for OdeSolverEquations<M, Rhs, Init, Mass, Root, Out, Reset>
where M: Matrix, Rhs: Op<M = M, V = M::V, T = M::T, C = M::C>, Init: Op<M = M, V = M::V, T = M::T, C = M::C>, Mass: Op<M = M, V = M::V, T = M::T, C = M::C>, Root: Op<M = M, V = M::V, T = M::T, C = M::C>, Out: Op<M = M, V = M::V, T = M::T, C = M::C>, Reset: Op<M = M, V = M::V, T = M::T, C = M::C>, ParameterisedOp<'a, Rhs>: NonLinearOp<M = M, V = M::V, T = M::T, C = M::C>, ParameterisedOp<'a, Init>: ConstantOp<M = M, V = M::V, T = M::T, C = M::C>, ParameterisedOp<'a, Mass>: LinearOp<M = M, V = M::V, T = M::T, C = M::C>, ParameterisedOp<'a, Root>: NonLinearOp<M = M, V = M::V, T = M::T, C = M::C>, ParameterisedOp<'a, Out>: NonLinearOp<M = M, V = M::V, T = M::T, C = M::C>, ParameterisedOp<'a, Reset>: NonLinearOp<M = M, V = M::V, T = M::T, C = M::C>,

Source§

impl<M, Rhs, Init, Mass, Root, Out, Reset> Op for OdeSolverEquations<M, Rhs, Init, Mass, Root, Out, Reset>
where M: Matrix, Init: Op<M = M, V = M::V, T = M::T, C = M::C>, Rhs: Op<M = M, V = M::V, T = M::T, C = M::C>, Mass: Op<M = M, V = M::V, T = M::T, C = M::C>, Root: Op<M = M, V = M::V, T = M::T, C = M::C>, Out: Op<M = M, V = M::V, T = M::T, C = M::C>, Reset: Op<M = M, V = M::V, T = M::T, C = M::C>,

Source§

type T = <M as MatrixCommon>::T

Source§

type V = <M as MatrixCommon>::V

Source§

type M = M

Source§

type C = <M as MatrixCommon>::C

Source§

fn nstates(&self) -> usize

Return the number of input states of the operator.
Source§

fn nout(&self) -> usize

Return the number of outputs of the operator.
Source§

fn nparams(&self) -> usize

Return the number of parameters of the operator.
Source§

fn statistics(&self) -> OpStatistics

Return statistics about the operator (e.g. how many times it was called, how many times the jacobian was computed, etc.)
Source§

fn context(&self) -> &Self::C

return the context of the operator

Auto Trait Implementations§

§

impl<M, Rhs, Init, Mass, Root, Out, Reset> Freeze for OdeSolverEquations<M, Rhs, Init, Mass, Root, Out, Reset>
where Rhs: Freeze, Init: Freeze, <M as MatrixCommon>::V: Freeze, Mass: Freeze, Root: Freeze, Out: Freeze, Reset: Freeze,

§

impl<M, Rhs, Init, Mass, Root, Out, Reset> RefUnwindSafe for OdeSolverEquations<M, Rhs, Init, Mass, Root, Out, Reset>

§

impl<M, Rhs, Init, Mass, Root, Out, Reset> Send for OdeSolverEquations<M, Rhs, Init, Mass, Root, Out, Reset>
where Rhs: Send, Init: Send, Mass: Send, Root: Send, Out: Send, Reset: Send,

§

impl<M, Rhs, Init, Mass, Root, Out, Reset> Sync for OdeSolverEquations<M, Rhs, Init, Mass, Root, Out, Reset>
where Rhs: Sync, Init: Sync, <M as MatrixCommon>::V: Sync, Mass: Sync, Root: Sync, Out: Sync, Reset: Sync,

§

impl<M, Rhs, Init, Mass, Root, Out, Reset> Unpin for OdeSolverEquations<M, Rhs, Init, Mass, Root, Out, Reset>
where Rhs: Unpin, Init: Unpin, <M as MatrixCommon>::V: Unpin, Mass: Unpin, Root: Unpin, Out: Unpin, Reset: Unpin,

§

impl<M, Rhs, Init, Mass, Root, Out, Reset> UnsafeUnpin for OdeSolverEquations<M, Rhs, Init, Mass, Root, Out, Reset>
where Rhs: UnsafeUnpin, Init: UnsafeUnpin, <M as MatrixCommon>::V: UnsafeUnpin, Mass: UnsafeUnpin, Root: UnsafeUnpin, Out: UnsafeUnpin, Reset: UnsafeUnpin,

§

impl<M, Rhs, Init, Mass, Root, Out, Reset> UnwindSafe for OdeSolverEquations<M, Rhs, Init, Mass, Root, Out, Reset>
where Rhs: UnwindSafe, Init: UnwindSafe, <M as MatrixCommon>::V: UnwindSafe, Mass: UnwindSafe, Root: UnwindSafe, Out: UnwindSafe, Reset: 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> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> DistributionExt for T
where T: ?Sized,

Source§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V