24 void eval_jacob (
const double t,
const double pres,
const double * cy,
double * jac) {
27 memcpy(y, cy,
NSP *
sizeof(
double));
29 dydt (t, pres, y, dy);
48 y_coeffs[0] = 1.0 / 12.0;
49 y_coeffs[1] = -2.0 / 3.0;
50 y_coeffs[2] = 2.0 / 3.0;
51 y_coeffs[3] = -1.0 / 12.0;
61 y_coeffs[0] = -1.0 / 60.0;
62 y_coeffs[1] = 3.0 / 20.0;
63 y_coeffs[2] = -3.0 / 4.0;
64 y_coeffs[3] = 3.0 / 4.0;
65 y_coeffs[4] = -3.0 / 20.0;
66 y_coeffs[5] = 1.0 / 60.0;
72 for (
int i = 0; i <
NSP; ++i) {
77 double srur = sqrt(DBL_EPSILON);
81 for (
int i = 0; i <
NSP; ++i) {
82 sum += (ewt[i] * dy[i]) * (ewt[i] * dy[i]);
84 double fac = sqrt(sum / ((
double)(
NSP)));
85 double r0 = 1000.0 *
RTOL * DBL_EPSILON * ((double)(
NSP)) * fac;
90 for (
int j = 0; j <
NSP; ++j) {
91 double yj_orig = y[j];
92 double r = fmax(srur * fabs(yj_orig), r0 / ewt[j]);
96 dydt (t, pres, y, ftemp);
99 for (
int i = 0; i <
NSP; ++i) {
100 jac[i +
NSP*j] = (ftemp[i] - dy[i]) / r;
104 for (
int i = 0; i <
NSP; ++i) {
105 jac[i +
NSP*j] = 0.0;
108 for (
int k = 0; k <
FD_ORD; ++k) {
109 y[j] = yj_orig + x_coeffs[k] * r;
110 dydt (t, pres, y, ftemp);
113 for (
int i = 0; i <
NSP; ++i) {
114 jac[i +
NSP*j] += y_coeffs[k] * ftemp[i];
118 for (
int i = 0; i <
NSP; ++i) {
Contains header definitions for the RHS function for the van der Pol example.
void dydt(const double t, const double mu, const double *__restrict__ y, double *__restrict__ dy)
An implementation of the RHS of the van der Pol equation.
void eval_jacob(const double t, const double pres, const double *cy, double *jac)
Computes a finite difference Jacobian of order FD_ORD of the RHS function dydt at the given pressure ...
A file generated by Scons that specifies various options to the solvers.
#define FD_ORD
The finite difference order [Default: 1].