Source code for vivyd.solvers.compatibility
from ..typing import arrf64
from typing import Callable, Protocol, runtime_checkable
default_handle = lambda t, state: None
[docs]
@runtime_checkable
class SolverCompatible(Protocol):
state_size: int
"""Number of state variables in the model."""
[docs]
def __call__(self, t: float, state: arrf64, handle: Callable = default_handle) -> arrf64:
"""
Evaluate the model at a given time and state. The handle is a function
that can be called inside the model to provide additional functionality.
Parameters
----------
t: float
The current time.
state: arrf64
The current state of the system, as a one-dimensional array, the
length of which must be equal to the `state_size` attribute of the
model.
handle: Callable
A function that can be called inside the model to provide additional
functionality. Default is a no-op function.
Returns
-------
arrf64
The derivatives of the state variables, as a one-dimensional array,
the length of which must be equal to the `state_size` attribute of
the model.
"""
...