Skip to main content

OdeCallbacks

Struct OdeCallbacks 

Source
pub struct OdeCallbacks<M: Matrix> { /* private fields */ }
Expand description

ODE equations defined by C callbacks, see the module documentation.

Implementations§

Source§

impl<M: Matrix> OdeCallbacks<M>

Source

pub unsafe fn new( callbacks: OdeCallbacksDesc<M::T>, ctx: M::C, ) -> Result<Self, DiffsolError>

Create the equations from callbacks. All parameters are zero at the start.

This function takes ownership of callbacks.user_data, also if it returns an error. See the module documentation.

For sparse matrix types, this function finds the sparsity pattern of each derivative callback. To do this, it calls the callback with NaN inputs at the initial state and t = 0.

§Safety
  • Each function pointer in callbacks must be null or a valid function with the signature that the module documentation gives.
  • Each function must stay valid until the equations are dropped.
  • Each function must read and write only the array lengths in the table.
  • If free_user_data is set, the equations own user_data. Do not free user_data yourself, and do not give it to other equations.
  • If free_user_data is not set, user_data must stay valid until the equations are dropped.
Source

pub fn take_callback_error(&self) -> Option<OdeCallbackError>

Take (and clear) the first error recorded while evaluating the callbacks.

Trait Implementations§

Source§

impl<M: Matrix> Drop for OdeCallbacks<M>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl<M: Matrix> OdeEquations for OdeCallbacks<M>

Source§

fn rhs(&self) -> OdeCallbacksRhs<'_, M>

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

fn mass(&self) -> Option<OdeCallbacksMass<'_, M>>

returns the mass matrix M as a LinearOp
Source§

fn root(&self) -> Option<OdeCallbacksRoot<'_, M>>

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

fn out(&self) -> Option<OdeCallbacksOut<'_, M>>

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

fn reset(&self) -> Option<OdeCallbacksReset<'_, M>>

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) -> OdeCallbacksInit<'_, M>

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

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

sets the current parameters of the equations
Source§

fn get_params(&self, p: &mut M::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: Matrix> OdeEquationsRef<'a> for OdeCallbacks<M>

Source§

impl<M: Matrix> Op for OdeCallbacks<M>

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 context(&self) -> &Self::C

return the context of the operator
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.)

Auto Trait Implementations§

§

impl<M> !Freeze for OdeCallbacks<M>

§

impl<M> !RefUnwindSafe for OdeCallbacks<M>

§

impl<M> !Sync for OdeCallbacks<M>

§

impl<M> Forget for OdeCallbacks<M>

§

impl<M> Send for OdeCallbacks<M>
where OdeCallbacksDesc<<M as MatrixCommon>::T>: Send, <M as MatrixCommon>::V: Send, <M as MatrixCommon>::C: Send, Patterns<M>: Send,

§

impl<M> Unpin for OdeCallbacks<M>
where OdeCallbacksDesc<<M as MatrixCommon>::T>: Unpin, <M as MatrixCommon>::V: Unpin, <M as MatrixCommon>::C: Unpin, Patterns<M>: Unpin,

§

impl<M> UnsafeUnpin for OdeCallbacks<M>

§

impl<M> UnwindSafe for OdeCallbacks<M>

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<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> OdeEquationsAdjoint for T
where <T as OdeEquationsRef<'a>>::Out: for<'a> NonLinearOpSensAdjoint<M = <T as Op>::M, V = <T as Op>::V, T = <T as Op>::T, C = <T as Op>::C, M = <T as Op>::M, V = <T as Op>::V, T = <T as Op>::T, C = <T as Op>::C> + for<'a> NonLinearOpAdjoint, <T as OdeEquationsRef<'a>>::Rhs: for<'a> NonLinearOpSensAdjoint<M = <T as Op>::M, V = <T as Op>::V, T = <T as Op>::T, C = <T as Op>::C, M = <T as Op>::M, V = <T as Op>::V, T = <T as Op>::T, C = <T as Op>::C> + for<'a> NonLinearOpAdjoint, <T as OdeEquationsRef<'a>>::Root: for<'a> NonLinearOpTimePartial<M = <T as Op>::M, V = <T as Op>::V, T = <T as Op>::T, C = <T as Op>::C, M = <T as Op>::M, V = <T as Op>::V, T = <T as Op>::T, C = <T as Op>::C, M = <T as Op>::M, V = <T as Op>::V, T = <T as Op>::T, C = <T as Op>::C, M = <T as Op>::M, V = <T as Op>::V, T = <T as Op>::T, C = <T as Op>::C> + for<'a> NonLinearOpAdjoint + for<'a> NonLinearOpJacobian + for<'a> NonLinearOpSensAdjoint, <T as OdeEquationsRef<'a>>::Init: for<'a> ConstantOpSensAdjoint<M = <T as Op>::M, V = <T as Op>::V, T = <T as Op>::T, C = <T as Op>::C>, T: OdeEquations, <T as OdeEquationsRef<'a>>::Mass: for<'a> LinearOpTranspose<M = <T as Op>::M, V = <T as Op>::V, T = <T as Op>::T, C = <T as Op>::C>,

Source§

impl<T> OdeEquationsImplicit for T
where T: OdeEquations, <T as OdeEquationsRef<'a>>::Rhs: for<'a> NonLinearOpJacobian<M = <T as Op>::M, V = <T as Op>::V, T = <T as Op>::T, C = <T as Op>::C>,

Source§

impl<T> OdeEquationsImplicitAdjoint for T
where <T as OdeEquationsRef<'a>>::Root: for<'a> NonLinearOpAdjoint<M = <T as Op>::M, V = <T as Op>::V, T = <T as Op>::T, C = <T as Op>::C, M = <T as Op>::M, V = <T as Op>::V, T = <T as Op>::T, C = <T as Op>::C, M = <T as Op>::M, V = <T as Op>::V, T = <T as Op>::T, C = <T as Op>::C, M = <T as Op>::M, V = <T as Op>::V, T = <T as Op>::T, C = <T as Op>::C> + for<'a> NonLinearOpJacobian + for<'a> NonLinearOpSensAdjoint + for<'a> NonLinearOpTimePartial, <T as OdeEquationsRef<'a>>::Reset: for<'a> NonLinearOpSensAdjoint<M = <T as Op>::M, V = <T as Op>::V, T = <T as Op>::T, C = <T as Op>::C, M = <T as Op>::M, V = <T as Op>::V, T = <T as Op>::T, C = <T as Op>::C, M = <T as Op>::M, V = <T as Op>::V, T = <T as Op>::T, C = <T as Op>::C, M = <T as Op>::M, V = <T as Op>::V, T = <T as Op>::T, C = <T as Op>::C> + for<'a> NonLinearOpJacobian + for<'a> NonLinearOpTimePartial + for<'a> NonLinearOpAdjoint, <T as OdeEquationsRef<'a>>::Out: for<'a> NonLinearOpAdjoint<M = <T as Op>::M, V = <T as Op>::V, T = <T as Op>::T, C = <T as Op>::C, M = <T as Op>::M, V = <T as Op>::V, T = <T as Op>::T, C = <T as Op>::C> + for<'a> NonLinearOpSensAdjoint, <T as OdeEquationsRef<'a>>::Init: for<'a> ConstantOpSensAdjoint<M = <T as Op>::M, V = <T as Op>::V, T = <T as Op>::T, C = <T as Op>::C>, T: OdeEquationsImplicit, <T as OdeEquationsRef<'a>>::Rhs: for<'a> NonLinearOpAdjoint<M = <T as Op>::M, V = <T as Op>::V, T = <T as Op>::T, C = <T as Op>::C, M = <T as Op>::M, V = <T as Op>::V, T = <T as Op>::T, C = <T as Op>::C> + for<'a> NonLinearOpSensAdjoint, <T as OdeEquationsRef<'a>>::Mass: for<'a> LinearOpTranspose<M = <T as Op>::M, V = <T as Op>::V, T = <T as Op>::T, C = <T as Op>::C>,

Source§

impl<T> OdeEquationsImplicitSens for T
where <T as OdeEquationsRef<'a>>::Reset: for<'a> NonLinearOpJacobian<M = <T as Op>::M, V = <T as Op>::V, T = <T as Op>::T, C = <T as Op>::C, M = <T as Op>::M, V = <T as Op>::V, T = <T as Op>::T, C = <T as Op>::C, M = <T as Op>::M, V = <T as Op>::V, T = <T as Op>::T, C = <T as Op>::C> + for<'a> NonLinearOpTimePartial + for<'a> NonLinearOpSens, <T as OdeEquationsRef<'a>>::Out: for<'a> NonLinearOpSens<M = <T as Op>::M, V = <T as Op>::V, T = <T as Op>::T, C = <T as Op>::C, M = <T as Op>::M, V = <T as Op>::V, T = <T as Op>::T, C = <T as Op>::C> + for<'a> NonLinearOpJacobian, <T as OdeEquationsRef<'a>>::Root: for<'a> NonLinearOpSens<M = <T as Op>::M, V = <T as Op>::V, T = <T as Op>::T, C = <T as Op>::C, M = <T as Op>::M, V = <T as Op>::V, T = <T as Op>::T, C = <T as Op>::C, M = <T as Op>::M, V = <T as Op>::V, T = <T as Op>::T, C = <T as Op>::C> + for<'a> NonLinearOpTimePartial + for<'a> NonLinearOpJacobian, <T as OdeEquationsRef<'a>>::Init: for<'a> ConstantOpSens<M = <T as Op>::M, V = <T as Op>::V, T = <T as Op>::T, C = <T as Op>::C>, T: OdeEquationsImplicit, <T as OdeEquationsRef<'a>>::Rhs: for<'a> NonLinearOpSens<M = <T as Op>::M, V = <T as Op>::V, T = <T as Op>::T, C = <T as Op>::C>,

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> 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 = !

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.