#include <gsl/gsl_odeiv2.h>
#include "misc.h"
Go to the source code of this file.
|
int | solve2 (double xg[], int N, double h, double yg[][2], int(*derivs)(double, const double[2], double[2], void *), void *data, int flag) |
| Second-order differential equation solver. More...
|
|
#define ABORT_ON_OVERFLOW 0 |
#define DIVERGENCE_THRESHOLD 100 |
#define NORMALIZE_ON_OVERFLOW 2 |
#define RETURN_ON_OVERFLOW 1 |
int solve2 |
( |
double |
xg[], |
|
|
int |
N, |
|
|
double |
h, |
|
|
double |
yg[][2], |
|
|
int(*)(double, const double[2], double[2], void *) |
derivs, |
|
|
void * |
data, |
|
|
int |
flag |
|
) |
| |
This routine is adapted from the O₂scl file "ode_iv_solve.h". The modification it the following:
- When the solution reaches some dangerously high absolute value, the function either exits (returning the last solved index that was kept inside the limits) or renormalizes the up-to-now solution so that the overflow is avoided.
- Parameters
-
xg | Independent variable grid. |
N | Size of the grid. |
h | Grid spacing. |
yg | (out) Solution. |
derivs | Second derivative callback of the signature * int derivs( double x, const double y[2], double dydx[2], void* params)
*
|
data | Custom data pointer to pass to the "derivs" routine. |
flag | Behaviour on overflow, one of { ABORT_ON_OVERFLOW | RETURN_ON_OVERFLOW | NORMALIZE_ON_OVERFLOW }. |
- Returns
- N for successful run of n < N for forced terminantion on overflow, where n is the index of last valid field in yg and ypg.