15 mechanism_memory
const *
const __restrict__ mech) {
37 for (
int i = 0; i <
NSP; ++i) {
45 if ((nrm1 !=
ZERO) && (nrm2 !=
ZERO)) {
46 dynrm = nrm1 * sqrt(
UROUND);
47 for (
int i = 0; i <
NSP; ++i) {
50 }
else if (nrm1 !=
ZERO) {
51 dynrm = nrm1 * sqrt(
UROUND);
52 for (
int i = 0; i <
NSP; ++i) {
55 }
else if (nrm2 !=
ZERO) {
57 for (
int i = 0; i <
NSP; ++i) {
58 v[
INDEX(i)] *= (dynrm / nrm2);
62 for (
int i = 0; i <
NSP; ++i) {
69 for (
int iter = 1; iter <= itmax; ++iter) {
71 dydt (t, pr, v, Fv, mech);
74 for (
int i = 0; i <
NSP; ++i) {
81 nrm2 = fabs(sigma - nrm2) / sigma;
82 if ((iter >= 2) && (fabs(sigma - nrm2) <= (fmax(sigma, small) *
P01))) {
83 for (
int i = 0; i <
NSP; ++i) {
86 return (
ONEP2 * sigma);
90 for (
int i = 0; i <
NSP; ++i) {
94 int ind = (iter %
NSP);
98 return (
ONEP2 * sigma);
105 const Real* F_0,
const int s,
Real* y_j,
107 mechanism_memory
const *
const __restrict__ mech) {
122 Real temp2 = sqrt(temp1);
123 const Real arg = (
Real)(s) * log(w0 + temp2);
124 const Real w1 = sinh(arg) * temp1 / (cosh(arg) * (
Real)(s) * temp2 - w0 * sinh(arg));
133 Real mu_t = w1 * b_jm1;
134 for (
int i = 0; i <
NSP; ++i) {
148 for (
int j = 2; j <= s; ++j) {
150 Real zj =
TWO * w0 * zjm1 - zjm2;
151 Real dzj =
TWO * w0 * dzjm1 - dzjm2 +
TWO * zjm1;
152 Real d2zj =
TWO * w0 * d2zjm1 - d2zjm2 +
FOUR * dzjm1;
153 Real b_j = d2zj / (dzj * dzj);
154 Real gamma_t =
ONE - (zjm1 * b_jm1);
156 Real nu = -b_j / b_jm2;
157 Real mu =
TWO * b_j * w0 / b_jm1;
161 dydt (t + (h * c_jm1), pr, y_jm1, y_j, mech);
163 for (
int i = 0; i <
NSP; ++i) {
165 + h * mu_t * (y_j[
INDEX(i)] - (gamma_t * F_0[
INDEX(i)]));
167 Real c_j = (mu * c_jm1) + (nu * c_jm2) + mu_t * (
ONE - gamma_t);
170 for (
int i = 0; i <
NSP; ++i) {
196 mechanism_memory
const *
const __restrict__ mech,
211 int mMax = (int)(round(sqrt(
RTOL / (10.0 *
UROUND))));
217 Real *
const __restrict__ y_n = solver->y_n;
219 for (
int i = 0; i <
NSP; ++i) {
224 Real *
const __restrict__ F_n = solver->F_n;
226 dydt (t, pr, y_n, F_n, mech);
230 Real *
const __restrict__ work = solver->work;
232 for (
int i = 0; i <
NSP; ++i) {
237 const Real stepSizeMax = fabs(tEnd - t);
238 Real stepSizeMin =
TEN *
UROUND * fmax(fabs(t), stepSizeMax);
241 Real *
const __restrict__ temp_arr = solver->temp_arr;
243 Real *
const __restrict__ temp_arr2 = solver->temp_arr2;
246 Real *
const __restrict__ y_jm1 = solver->y_jm1;
247 Real *
const __restrict__ y_jm2 = solver->y_jm2;
254 if ((nstep % 25) == 0) {
262 work[
INDEX(2)] = stepSizeMax;
266 work[
INDEX(2)] = fmax(work[
INDEX(2)], stepSizeMin);
268 for (
int i = 0; i <
NSP; ++i) {
271 dydt (t + work[
INDEX(2)], pr, temp_arr, temp_arr2, mech);
274 for (
int i = 0; i <
NSP; ++i) {
278 err = work[
INDEX(2)] * sqrt(err /
NSP);
280 if ((
P1 * work[
INDEX(2)]) < (stepSizeMax * sqrt(err))) {
281 work[
INDEX(2)] = fmax(
P1 * work[
INDEX(2)] / sqrt(err), stepSizeMin);
283 work[
INDEX(2)] = stepSizeMax;
290 if ((
ONEP1 * work[
INDEX(2)]) >= fabs(tEnd - t)) {
291 work[
INDEX(2)] = fabs(tEnd - t);
303 rkc_step (t, pr, work[
INDEX(2)], y_n, F_n, m, y, y_jm1, y_jm2, mech);
306 dydt (t + work[
INDEX(2)], pr, y, temp_arr, mech);
310 for (
int i = 0; i <
NSP; ++i) {
336 if (
P8 < (fac * temp2)) {
342 if (temp1 < (fac * temp2)) {
348 work[
INDEX(0)] = err;
351 for (
int i = 0; i <
NSP; ++i) {
356 work[
INDEX(2)] *= fmax(
P1, fac);
357 work[
INDEX(2)] = fmax(stepSizeMin, fmin(stepSizeMax, work[
INDEX(2)]));
368 int *
const __restrict__ result = solver->result;
#define T_ID
The global CUDA thread index.
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.
#define GRID_DIM
The total number of threads in the Grid, provides an offset between vector entries.
Contains header definitions for the CUDA RHS function for the van der Pol example.
__device__ Real rkc_spec_rad(const Real t, const Real pr, const Real hmax, const Real *y, const Real *F, Real *v, Real *Fv, mechanism_memory const *const __restrict__ mech)
__device__ void integrate(const Real tstart, const Real tEnd, const Real pr, Real *y, mechanism_memory const *const __restrict__ mech, solver_memory const *const __restrict__ solver)
#define EC_success
Successful time step.
__device__ void rkc_step(const Real t, const Real pr, const Real h, const Real *y_0, const Real *F_0, const int s, Real *y_j, Real *y_jm1, Real *y_jm2, mechanism_memory const *const __restrict__ mech)
#define INDEX(i)
Convenience macro to get the value of a vector at index i, calculated as i * GRID_DIM + T_ID...
Memory required for Radau-IIa GPU solver.