38 #pragma omp simd aligned(h : 64)
39 for(i = 0; i <
NSIMD; i++) {
43 real k1[6], k2[6], k3[6], k4[6];
48 real mass = p->mass[i];
49 real charge = p->charge[i];
63 yprev[3] = p->ppar[i];
65 yprev[5] = p->zeta[i];
69 B_dB[1] = p->B_r_dr[i];
70 B_dB[2] = p->B_r_dphi[i];
71 B_dB[3] = p->B_r_dz[i];
73 B_dB[4] = p->B_phi[i];
74 B_dB[5] = p->B_phi_dr[i];
75 B_dB[6] = p->B_phi_dphi[i];
76 B_dB[7] = p->B_phi_dz[i];
79 B_dB[9] = p->B_z_dr[i];
80 B_dB[10] = p->B_z_dphi[i];
81 B_dB[11] = p->B_z_dz[i];
94 for(
int j = 0; j < 6; j++) {
95 tempy[j] = yprev[j] + h[i]*k1[j]/2.0;
101 t0 + h[i]/2.0, Bdata);
105 t0 + h[i]/2.0, Edata, Bdata);
110 for(
int j = 0; j < 6; j++) {
111 tempy[j] = yprev[j] + h[i]*k2[j]/2.0;
117 t0 + h[i]/2.0, Bdata);
121 t0 + h[i]/2.0, Edata, Bdata);
126 for(
int j = 0; j < 6; j++) {
127 tempy[j] = yprev[j] + h[i]*k3[j];
137 t0 + h[i], Edata, Bdata);}
138 if(!errflag) {
step_gceom(k4, tempy, mass, charge, B_dB, E);
140 for(
int j = 0; j < 6; j++) {
142 + h[i]/6.0 * (k1[j] + 2*k2[j] + 2*k3[j] + k4[j]);
147 if(!errflag && y[0] <= 0) {
150 if(!errflag && y[4] < 0) {
184 p->B_r_dr[i] = B_dB[1];
185 p->B_r_dphi[i] = B_dB[2];
186 p->B_r_dz[i] = B_dB[3];
188 p->B_phi[i] = B_dB[4];
189 p->B_phi_dr[i] = B_dB[5];
190 p->B_phi_dphi[i] = B_dB[6];
191 p->B_phi_dz[i] = B_dB[7];
194 p->B_z_dr[i] = B_dB[9];
195 p->B_z_dphi[i] = B_dB[10];
196 p->B_z_dz[i] = B_dB[11];
203 p->theta[i] += atan2( (R0-axisrz[0]) * (p->z[i]-axisrz[1])
204 - (z0-axisrz[1]) * (p->r[i]-axisrz[0]),
205 (R0-axisrz[0]) * (p->r[i]-axisrz[0])
206 + (z0-axisrz[1]) * (p->z[i]-axisrz[1]) );
235 #pragma omp simd aligned(h : 64)
236 for(i = 0; i <
NSIMD; i++) {
240 real k1[6], k2[6], k3[6], k4[6];
245 real mass = p->mass[i];
246 real charge = p->charge[i];
254 real t0 = p->time[i];
259 yprev[1] = p->phi[i];
261 yprev[3] = p->ppar[i];
263 yprev[5] = p->zeta[i];
267 B_dB[1] = p->B_r_dr[i];
268 B_dB[2] = p->B_r_dphi[i];
269 B_dB[3] = p->B_r_dz[i];
271 B_dB[4] = p->B_phi[i];
272 B_dB[5] = p->B_phi_dr[i];
273 B_dB[6] = p->B_phi_dphi[i];
274 B_dB[7] = p->B_phi_dz[i];
277 B_dB[9] = p->B_z_dr[i];
278 B_dB[10] = p->B_z_dphi[i];
279 B_dB[11] = p->B_z_dz[i];
286 errflag =
mhd_eval(mhd_dmhd, yprev[0], yprev[1], yprev[2], t0,
295 for(
int j = 0; j < 6; j++) {
296 tempy[j] = yprev[j] + h[i]/2.0*k1[j];
301 t0 + h[i]/2.0, Bdata);
305 t0 + h[i]/2.0, Edata, Bdata);
308 errflag =
mhd_eval(mhd_dmhd, tempy[0], tempy[1], tempy[2],
317 for(
int j = 0; j < 6; j++) {
318 tempy[j] = yprev[j] + h[i]/2.0*k2[j];
323 t0 + h[i]/2.0, Bdata);
327 t0 + h[i]/2.0, Edata, Bdata);
330 errflag =
mhd_eval(mhd_dmhd, tempy[0], tempy[1], tempy[2],
338 for(
int j = 0; j < 6; j++) {
339 tempy[j] = yprev[j] + h[i]*k3[j];
348 t0 + h[i], Edata, Bdata);
351 errflag =
mhd_eval(mhd_dmhd, tempy[0], tempy[1], tempy[2],
358 for(
int j = 0; j < 6; j++) {
360 + h[i]/6.0 * (k1[j] + 2*k2[j] + 2*k3[j] + k4[j]);
364 if(!errflag && y[0] <= 0) {
367 else if(!errflag && fabs(y[4]) >=
CONST_C) {
370 else if(!errflag && y[4] < 0) {
404 p->B_r_dr[i] = B_dB[1];
405 p->B_r_dphi[i] = B_dB[2];
406 p->B_r_dz[i] = B_dB[3];
408 p->B_phi[i] = B_dB[4];
409 p->B_phi_dr[i] = B_dB[5];
410 p->B_phi_dphi[i] = B_dB[6];
411 p->B_phi_dz[i] = B_dB[7];
414 p->B_z_dr[i] = B_dB[9];
415 p->B_z_dphi[i] = B_dB[10];
416 p->B_z_dz[i] = B_dB[11];
423 p->theta[i] += atan2( (R0-axisrz[0]) * (p->z[i]-axisrz[1])
424 - (z0-axisrz[1]) * (p->r[i]-axisrz[0]),
425 (R0-axisrz[0]) * (p->r[i]-axisrz[0])
426 + (z0-axisrz[1]) * (p->z[i]-axisrz[1]) );
a5err mhd_eval(real mhd_dmhd[10], real r, real phi, real z, real t, int includemode, boozer_data *boozerdata, mhd_data *mhddata, B_field_data *Bdata)
Evaluate the needed quantities from MHD mode for orbit following.
Header file for particle.c.
Struct representing NSIMD guiding center markers.