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>
impl<M: Matrix> OdeCallbacks<M>
Sourcepub unsafe fn new(
callbacks: OdeCallbacksDesc<M::T>,
ctx: M::C,
) -> Result<Self, DiffsolError>
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
callbacksmust 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_datais set, the equations ownuser_data. Do not freeuser_datayourself, and do not give it to other equations. - If
free_user_datais not set,user_datamust stay valid until the equations are dropped.
Sourcepub fn take_callback_error(&self) -> Option<OdeCallbackError>
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>
impl<M: Matrix> Drop for OdeCallbacks<M>
Source§impl<M: Matrix> OdeEquations for OdeCallbacks<M>
impl<M: Matrix> OdeEquations for OdeCallbacks<M>
Source§fn rhs(&self) -> OdeCallbacksRhs<'_, M>
fn rhs(&self) -> OdeCallbacksRhs<'_, M>
returns the right-hand side function
F(t, y) as a NonLinearOpSource§fn root(&self) -> Option<OdeCallbacksRoot<'_, M>>
fn root(&self) -> Option<OdeCallbacksRoot<'_, M>>
returns the root function
G(t, y) as a NonLinearOpSource§fn out(&self) -> Option<OdeCallbacksOut<'_, M>>
fn out(&self) -> Option<OdeCallbacksOut<'_, M>>
returns the output function
H(t, y) as a NonLinearOpSource§fn reset(&self) -> Option<OdeCallbacksReset<'_, M>>
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>
fn init(&self) -> OdeCallbacksInit<'_, M>
returns the initial condition, i.e.
y(t), where t is the initial timeSource§fn set_params(&mut self, p: &M::V)
fn set_params(&mut self, p: &M::V)
sets the current parameters of the equations
Source§fn get_params(&self, p: &mut M::V)
fn get_params(&self, p: &mut M::V)
gets the current parameters of the equations
Source§fn set_model_index(&mut self, _m: usize)
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>
impl<'a, M: Matrix> OdeEquationsRef<'a> for OdeCallbacks<M>
type Mass = OdeCallbacksMass<'a, M>
type Rhs = OdeCallbacksRhs<'a, M>
type Root = OdeCallbacksRoot<'a, M>
type Init = OdeCallbacksInit<'a, M>
type Out = OdeCallbacksOut<'a, M>
type Reset = OdeCallbacksReset<'a, M>
Source§impl<M: Matrix> Op for OdeCallbacks<M>
impl<M: Matrix> Op for OdeCallbacks<M>
type T = <M as MatrixCommon>::T
type V = <M as MatrixCommon>::V
type M = M
type C = <M as MatrixCommon>::C
Source§fn statistics(&self) -> OpStatistics
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>where
OdeCallbacksDesc<<M as MatrixCommon>::T>: UnsafeUnpin,
<M as MatrixCommon>::V: UnsafeUnpin,
<M as MatrixCommon>::C: UnsafeUnpin,
Patterns<M>: UnsafeUnpin,
impl<M> UnwindSafe for OdeCallbacks<M>where
OdeCallbacksDesc<<M as MatrixCommon>::T>: UnwindSafe,
<M as MatrixCommon>::V: UnwindSafe,
<M as MatrixCommon>::C: UnwindSafe,
Patterns<M>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T, U> Imply<T> for U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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 moreimpl<T> OdeEquationsAdjoint for Twhere
<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>,
impl<T> OdeEquationsImplicit for Twhere
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>,
impl<T> OdeEquationsImplicitAdjoint for Twhere
<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>,
impl<T> OdeEquationsImplicitSens for Twhere
<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
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
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
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
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.