4.2.1. ivp¶
Interface for solving initial-value problems (IVP) for ordinary differential equations (ODE).
This interface defines the interface for solving initial-value problems for ordinary differential equations:
Typedefs
-
typedef int (*oif_ivp_rhs_fn_t)(double t, OIFArrayF64 *y, OIFArrayF64 *ydot, void *user_data)¶
User-provided right-hand side function for the system of ODEs.
- Param t:
[in] Current time
- Param y:
[in] State vector at time
t
- Param ydot:
[out] Derivative of the state vector, which must be computed during the function call
- Param user_data:
[in] User data (additional context) required by the right-hand side function
Functions
-
int oif_ivp_set_rhs_fn(ImplHandle implh, oif_ivp_rhs_fn_t rhs)¶
Set right-hand side of the system of ordinary differential equations.
- Parameters:
implh – [in] Implementation handle
rhs – [in] Right-hand side callback function
-
int oif_ivp_set_initial_value(ImplHandle implh, OIFArrayF64 *y0, double t0)¶
Set initial value :math:
y(t0) = y0
.- Parameters:
implh – [in] Implementation handle
y0 – [in] Initial value
t0 – [in] Initial time
-
int oif_ivp_set_user_data(ImplHandle implh, void *user_data)¶
Set user data (additional context) to pass additional information to the right-hand side function.
User data can be any object that is needed by the right-hand side function. For example, if only a scalar value is required as an additional parameter, then
user_data
can be just the pointer to that value. If multiple values are required, thenuser_data
can be a pointer to a structure defined by the user, and the it is the user’s responsibility to cast the pointer to the correct type in the right-hand side function.- Parameters:
implh – [in] Implementation handle
user_data – [in] User data (pointer to a user-defined object)
-
int oif_ivp_set_tolerances(ImplHandle implh, double rtol, double atol)¶
Set tolerances for adaptive time integration.
- Parameters:
implh – [in] Implementation handle
rtol – [in] Relative tolerance
atol – [in] Absolute tolerance
-
int oif_ivp_integrate(ImplHandle implh, double t, OIFArrayF64 *y)¶
Integrate to time
t
and write the solution toy
.- Parameters:
implh – [in] Implementation handle
t – [in] Time at which we want the solution
y – [out] Array to which the solution at time
t
will be written
-
int oif_ivp_set_integrator(ImplHandle implh, char *integrator_name, OIFConfigDict *config)¶
Set integrator and optionally its parameters.
Many implementations of ODE solvers contain multiple integrators, with each integrator having specific options. Hence, this function allows the user to set these options for a particular integrator. The integrator name and the options must be checked in the documentation of a particular implementation.
- Parameters:
implh – [in] Implementation handle
integrator_name – [in] Name of the integrator
config – [in] Configuration dictionary for the integrator
-
int oif_ivp_print_stats(ImplHandle implh)¶
Print statistics about integration.
- Parameters:
implh – [in] Implementation handle