1
+ /**
2
+ * @file
3
+ * @brief Interface for solving initial-value problems (IVP) for ordinary differential equations (ODE).
4
+ *
5
+ * This interface defines the interface for solving initial-value problems
6
+ * for ordinary differential equations:
7
+ * \f[
8
+ * \frac{dy}{dt} = f(t, y), \quad y(t_0) = y_0,
9
+ * \f]
10
+ * where \f$y\f$ is the state vector, \f$t\f$ is the time,
11
+ * \f$f\f$ is the right-hand side (RHS) function.
12
+ */
1
13
#pragma once
2
14
3
15
#ifdef __cplusplus
@@ -6,49 +18,93 @@ extern "C" {
6
18
7
19
#include <oif/api.h>
8
20
9
- typedef int (* oif_ivp_rhs_fn_t )(double , OIFArrayF64 * y , OIFArrayF64 * ydot , void * user_data );
21
+ /**
22
+ * User-provided right-hand side function for the system of ODEs.
23
+ *
24
+ * @param[in] t Current time
25
+ * @param[in] y State vector at time `t`
26
+ * @param[out] ydot Derivative of the state vector, which must be computed during the function call
27
+ * @param[in] user_data User data (additional context) required by the right-hand side function
28
+ */
29
+ typedef int (* oif_ivp_rhs_fn_t )(double t , OIFArrayF64 * y , OIFArrayF64 * ydot , void * user_data );
10
30
11
31
/**
12
- * Set right hand side of the system of ordinary differential equations.
32
+ * Set right-hand side of the system of ordinary differential equations.
33
+ *
34
+ * @param[in] implh Implementation handle
35
+ * @param[in] rhs Right-hand side callback function
13
36
*/
14
37
int
15
38
oif_ivp_set_rhs_fn (ImplHandle implh , oif_ivp_rhs_fn_t rhs );
16
39
17
40
/**
18
- * Set initial value y(t0) = y0.
41
+ * Set initial value :math:`y(t0) = y0`.
42
+ *
43
+ * @param[in] implh Implementation handle
44
+ * @param[in] y0 Initial value
45
+ * @param[in] t0 Initial time
19
46
*/
20
47
int
21
48
oif_ivp_set_initial_value (ImplHandle implh , OIFArrayF64 * y0 , double t0 );
22
49
23
50
/**
24
- * Set user data that can be used to pass additional information
51
+ * Set user data (additional context) to pass additional information
25
52
* to the right-hand side function.
53
+ *
54
+ * User data can be any object that is needed by the right-hand side function.
55
+ * For example, if only a scalar value is required as an additional parameter,
56
+ * then `user_data` can be just the pointer to that value.
57
+ * If multiple values are required, then `user_data` can be a pointer to a
58
+ * structure defined by the user, and the it is the user's responsibility
59
+ * to cast the pointer to the correct type in the right-hand side function.
60
+ *
61
+ * @param[in] implh Implementation handle
62
+ * @param[in] user_data User data (pointer to a user-defined object)
26
63
*/
27
64
int
28
65
oif_ivp_set_user_data (ImplHandle implh , void * user_data );
29
66
30
67
/**
31
68
* Set tolerances for adaptive time integration.
32
- * @param rtol Relative tolerance
33
- * @param atol Absolute tolerance
69
+ *
70
+ * @param[in] implh Implementation handle
71
+ * @param[in] rtol Relative tolerance
72
+ * @param[in] atol Absolute tolerance
34
73
*/
35
74
int
36
75
oif_ivp_set_tolerances (ImplHandle implh , double rtol , double atol );
37
76
38
77
/**
39
78
* Integrate to time `t` and write the solution to `y`.
79
+ *
80
+ * @param[in] implh Implementation handle
81
+ * @param[in] t Time at which we want the solution
82
+ * @param[out] y Array to which the solution at time `t` will be written
40
83
*/
41
84
int
42
85
oif_ivp_integrate (ImplHandle implh , double t , OIFArrayF64 * y );
43
86
44
87
/**
45
88
* Set integrator and optionally its parameters.
89
+ *
90
+ * Many implementations of ODE solvers contain multiple integrators,
91
+ * with each integrator having specific options.
92
+ * Hence, this function allows the user to set these options for a particular
93
+ * integrator.
94
+ * The integrator name and the options must be checked in the documentation
95
+ * of a particular implementation.
96
+ *
97
+ * @param[in] implh Implementation handle
98
+ * @param[in] integrator_name Name of the integrator
99
+ * @param[in] config Configuration dictionary for the integrator
46
100
*/
47
101
int
48
102
oif_ivp_set_integrator (ImplHandle implh , char * integrator_name , OIFConfigDict * config );
49
103
50
104
/**
51
105
* Print statistics about integration.
106
+ *
107
+ * @param[in] implh Implementation handle
52
108
*/
53
109
int
54
110
oif_ivp_print_stats (ImplHandle implh );
0 commit comments