40 #pragma omp simd aligned(h, hnext : 64)
41 for(i = 0; i <
NSIMD; i++) {
45 real k1[6], k2[6], k3[6], k4[6], k5[6], k6[6];
49 real mass = p->mass[i];;
50 real charge = p->charge[i];
64 yprev[3] = p->ppar[i];
66 yprev[5] = p->zeta[i];
70 B_dB[1] = p->B_r_dr[i];
71 B_dB[2] = p->B_r_dphi[i];
72 B_dB[3] = p->B_r_dz[i];
74 B_dB[4] = p->B_phi[i];
75 B_dB[5] = p->B_phi_dr[i];
76 B_dB[6] = p->B_phi_dphi[i];
77 B_dB[7] = p->B_phi_dz[i];
80 B_dB[9] = p->B_z_dr[i];
81 B_dB[10] = p->B_z_dphi[i];
82 B_dB[11] = p->B_z_dz[i];
91 for(
int j = 0; j < 6; j++) {
100 t0 + (1.0/5)*h[i], Bdata);
104 t0 + (1.0/5)*h[i], Edata, Bdata);
109 for(
int j = 0; j < 6; j++) {
113 + (9.0/40) * k2[j] );
119 t0 + (3.0/10)*h[i], Bdata);
123 t0 + (3.0/10)*h[i], Edata, Bdata);
128 for(
int j = 0; j < 6; j++) {
133 + ( 6.0/5 ) * k3[j] );
139 t0 + (3.0/5)*h[i], Bdata);
143 t0 + (3.0/5)*h[i], Edata, Bdata);
148 for(
int j = 0; j < 6; j++) {
154 + ( 35.0/27) * k4[j] );
164 t0 + h[i], Edata, Bdata);
169 for(
int j = 0; j < 6; j++) {
172 ( 1631.0/55296 ) * k1[j]
173 + ( 175.0/512 ) * k2[j]
174 + ( 575.0/13824 ) * k3[j]
175 + (44275.0/110592) * k4[j]
176 + ( 253.0/4096 ) * k5[j] );
182 t0 + (7.0/8)*h[i], Bdata);
186 t0 + (7.0/8)*h[i], Edata, Bdata);
198 for(
int j = 0; j < 6; j++) {
202 + (250.0/621 ) * k3[j]
203 + (125.0/594 ) * k4[j]
204 + (512.0/1771) * k6[j] );
208 ( 2825.0/27648) * k1[j]
209 + (18575.0/48384) * k3[j]
210 + (13525.0/55296) * k4[j]
211 + ( 277.0/14336) * k5[j]
212 + ( 1.0/4 ) * k6[j] );
214 real yerr = fabs(rk5[j] - rk4[j]);
215 real ytol = fabs(yprev[j]) + fabs(k1[j]*h[i])
217 err = fmax( err, yerr/ytol );
220 real rk1[3] = {k1[0]*h[i], k1[1]*h[i], k1[2]*h[i]};
222 rk5[0] * rk5[0] + rk4[0] * rk4[0]
223 - 2 * rk5[0] * rk4[0] * cos(rk5[1] - rk4[1])
224 + ( rk5[2] - rk4[2] ) * ( rk5[2] - rk4[2] );
226 yprev[0] * yprev[0] + rk1[0] * rk1[0]
227 - 2 * yprev[0] * rk1[0] * cos(yprev[1] - rk1[1])
228 + ( yprev[2] - rk1[2] ) * ( yprev[2] - rk1[2] )
230 err = fmax( err, sqrt(yerr/ytol) );
237 hnext[i] = 0.85*h[i]*pow(err,-0.2);
240 if(hnext[i] > 1.5*h[i]) {
246 hnext[i] = -0.85*h[i]*pow(err,-0.25);
255 else if(!errflag && rk5[0] <= 0) {
259 else if(!errflag && rk5[4] < 0) {
282 p->time[i] + h[i], Bdata);
286 p->time[i] + h[i], Bdata);
294 p->B_r_dr[i] = B_dB[1];
295 p->B_r_dphi[i] = B_dB[2];
296 p->B_r_dz[i] = B_dB[3];
298 p->B_phi[i] = B_dB[4];
299 p->B_phi_dr[i] = B_dB[5];
300 p->B_phi_dphi[i] = B_dB[6];
301 p->B_phi_dz[i] = B_dB[7];
304 p->B_z_dr[i] = B_dB[9];
305 p->B_z_dphi[i] = B_dB[10];
306 p->B_z_dz[i] = B_dB[11];
312 p->theta[i] += atan2( (R0-axisrz[0]) * (p->z[i]-axisrz[1])
313 - (z0-axisrz[1]) * (p->r[i]-axisrz[0]),
314 (R0-axisrz[0]) * (p->r[i]-axisrz[0])
315 + (z0-axisrz[1]) * (p->z[i]-axisrz[1]) );
350#pragma omp simd aligned(h, hnext : 64)
351 for(i = 0; i <
NSIMD; i++) {
355 real k1[6], k2[6], k3[6], k4[6], k5[6], k6[6];
359 real mass = p->mass[i];;
360 real charge = p->charge[i];
368 real t0 = p->time[i];
373 yprev[1] = p->phi[i];
375 yprev[3] = p->ppar[i];
377 yprev[5] = p->zeta[i];
381 B_dB[1] = p->B_r_dr[i];
382 B_dB[2] = p->B_r_dphi[i];
383 B_dB[3] = p->B_r_dz[i];
385 B_dB[4] = p->B_phi[i];
386 B_dB[5] = p->B_phi_dr[i];
387 B_dB[6] = p->B_phi_dphi[i];
388 B_dB[7] = p->B_phi_dz[i];
391 B_dB[9] = p->B_z_dr[i];
392 B_dB[10] = p->B_z_dphi[i];
393 B_dB[11] = p->B_z_dz[i];
400 errflag =
mhd_eval(mhd_dmhd, yprev[0], yprev[1], yprev[2],
406 for(
int j = 0; j < 6; j++) {
415 t0 + (1.0/5)*h[i], Bdata);
419 t0 + (1.0/5)*h[i], Edata, Bdata);
422 errflag =
mhd_eval(mhd_dmhd, tempy[0], tempy[1], tempy[2],
429 for(
int j = 0; j < 6; j++) {
433 + (9.0/40) * k2[j] );
439 t0 + (3.0/10)*h[i], Bdata);
443 t0 + (3.0/10)*h[i], Edata, Bdata);
446 errflag =
mhd_eval(mhd_dmhd, tempy[0], tempy[1], tempy[2],
453 for(
int j = 0; j < 6; j++) {
458 + ( 6.0/5 ) * k3[j] );
464 t0 + (3.0/5)*h[i], Bdata);
468 t0 + (3.0/5)*h[i], Edata, Bdata);
471 errflag =
mhd_eval(mhd_dmhd, tempy[0], tempy[1], tempy[2],
478 for(
int j = 0; j < 6; j++) {
484 + ( 35.0/27) * k4[j] );
494 t0 + h[i], Edata, Bdata);
497 errflag =
mhd_eval(mhd_dmhd, tempy[0], tempy[1], tempy[2],
504 for(
int j = 0; j < 6; j++) {
507 ( 1631.0/55296 ) * k1[j]
508 + ( 175.0/512 ) * k2[j]
509 + ( 575.0/13824 ) * k3[j]
510 + (44275.0/110592) * k4[j]
511 + ( 253.0/4096 ) * k5[j] );
517 t0 + (7.0/8)*h[i], Bdata);
521 t0 + (7.0/8)*h[i], Edata, Bdata);
524 errflag =
mhd_eval(mhd_dmhd, tempy[0], tempy[1], tempy[2],
538 for(
int j = 0; j < 5; j++) {
542 + (250.0/621 ) * k3[j]
543 + (125.0/594 ) * k4[j]
544 + (512.0/1771) * k6[j] );
548 ( 2825.0/27648) * k1[j]
549 + (18575.0/48384) * k3[j]
550 + (13525.0/55296) * k4[j]
551 + ( 277.0/14336) * k5[j]
552 + ( 1.0/4 ) * k6[j] );
554 real yerr = fabs(rk5[j] - rk4[j]);
555 real ytol = fabs(yprev[j]) + fabs(k1[j]*h[i])
557 err = fmax( err, yerr/ytol );
560 real rk1[3] = {k1[0]*h[i], k1[1]*h[i], k1[2]*h[i]};
562 rk5[0] * rk5[0] + rk4[0] * rk4[0]
563 - 2 * rk5[0] * rk4[0] * cos(rk5[1] - rk4[1])
564 + ( rk5[2] - rk4[2] ) * ( rk5[2] - rk4[2] );
566 yprev[0] * yprev[0] + rk1[0] * rk1[0]
567 - 2 * yprev[0] * rk1[0] * cos(yprev[1] - rk1[1])
568 + ( yprev[2] - rk1[2] ) * ( yprev[2] - rk1[2] )
570 err = fmax( err, sqrt(yerr/ytol) );
577 hnext[i] = 0.85*h[i]*pow(err,-0.2);
580 if(hnext[i] > 1.5*h[i]) {
586 hnext[i] = -0.85*h[i]*pow(err,-0.25);
608 p->time[i] + h[i], Bdata);
612 p->time[i] + h[i], Bdata);
620 p->B_r_dr[i] = B_dB[1];
621 p->B_r_dphi[i] = B_dB[2];
622 p->B_r_dz[i] = B_dB[3];
624 p->B_phi[i] = B_dB[4];
625 p->B_phi_dr[i] = B_dB[5];
626 p->B_phi_dphi[i] = B_dB[6];
627 p->B_phi_dz[i] = B_dB[7];
630 p->B_z_dr[i] = B_dB[9];
631 p->B_z_dphi[i] = B_dB[10];
632 p->B_z_dz[i] = B_dB[11];
638 p->theta[i] += atan2( (R0-axisrz[0]) * (p->z[i]-axisrz[1])
639 - (z0-axisrz[1]) * (p->r[i]-axisrz[0]),
640 (R0-axisrz[0]) * (p->r[i]-axisrz[0])
641 + (z0-axisrz[1]) * (p->z[i]-axisrz[1]) );