37 GPU_DATA_IS_MAPPED(h[0:p->
n_mrk], rnd[0:3*p->
n_mrk])
38 GPU_PARALLEL_LOOP_ALL_LEVELS
39 for(
int i = 0; i < p->
n_mrk; i++) {
52 real vin, pin, vflow, vpar, vperp2, xiin, Xin_xyz[3];
53 Xin_xyz[0] = p->
r[i] * cos(p->
phi[i]);
54 Xin_xyz[1] = p->
r[i] * sin(p->
phi[i]);
58 &vflow, p->
rho[i], p->
r[i], p->
phi[i], p->
z[i], p->
time[i],
65 vperp2 = (1 - xiin * xiin) * vin * vin;
66 vin = sqrt((vpar - vflow) * (vpar - vflow) + vperp2);
67 xiin = (vpar - vflow) / vin;
73 p->
r[i], p->
phi[i], p->
z[i],
79 mccc_coefs_clog(clogab, p->
mass[i], p->
charge[i], vin,
80 n_species, mb, qb, nb, Tb);
86 real K = 0, Dpara = 0, nu = 0, DX = 0;
88 for(
int j = 0; j < n_species; j++) {
89 real vb = sqrt( 2 * Tb[j] / mb[j] );
92 mccc_coefs_mufun(mufun, x, mdata);
95 qb[j], nb[j], vb, clogab[j],
98 qb[j], nb[j], vb, clogab[j],
101 qb[j], nb[j], vb, clogab[j],
104 qb[j], nb[j], vb, clogab[j],
114 real sdt = sqrt(h[i]);
116 dW[0]=sdt*rnd[0*p->
n_mrk + i];
117 dW[1]=sdt*rnd[1*p->
n_mrk + i];
118 dW[2]=sdt*rnd[2*p->
n_mrk + i];
119 dW[3]=sdt*rnd[3*p->
n_mrk + i];
120 dW[4]=sdt*rnd[4*p->
n_mrk + i];
125 real k1 = sqrt(2*DX);
128 real vout, xiout, Xout_xyz[3];
129 Xout_xyz[0] = Xin_xyz[0] + k1 * ( dW[0] - k2 * bhat[0] );
130 Xout_xyz[1] = Xin_xyz[1] + k1 * ( dW[1] - k2 * bhat[1] );
131 Xout_xyz[2] = Xin_xyz[2] + k1 * ( dW[2] - k2 * bhat[2] );
132 vout = vin + K*h[i] + sqrt( 2 * Dpara ) * dW[3];
133 xiout = xiin - xiin*nu*h[i] + sqrt(( 1 - xiin*xiin ) * nu) * dW[4];
138 vout = 2 * cutoff - vout;
142 xiout = ( (xiout > 0) - (xiout < 0) )
143 * ( 2 - fabs( xiout ) );
155 Xout_xyz[0] = Xin_xyz[0];
156 Xout_xyz[1] = Xin_xyz[1];
157 Xout_xyz[2] = Xin_xyz[2];
160 vperp2 = (1 - xiout * xiout) * vout * vout;
161 vout = sqrt((vpar + vflow) * (vpar + vflow) + vperp2);
162 xiout = (vpar + vflow) / vout;
170 real B_dB[15], psi[1], rho[2];
173 Xout_rpz[2], p->
time[i] + h[i],
178 Xout_rpz[2], p->
time[i] + h[i],
192 p->
B_phi[i] = B_dB[4];
204 Bnorm =
math_normc(B_dB[0], B_dB[4], B_dB[8]);
206 p->
r[i] = Xout_rpz[0];
207 p->
z[i] = Xout_rpz[2];
214 p->
theta[i] += atan2( (R0-axisrz[0]) * (p->
z[i]-axisrz[1])
215 - (z0-axisrz[1]) * (p->
r[i]-axisrz[0]),
216 (R0-axisrz[0]) * (p->
r[i]-axisrz[0])
217 + (z0-axisrz[1]) * (p->
z[i]-axisrz[1]) );
218 p->
phi[i] += atan2( Xin_xyz[0] * Xout_xyz[1]
219 - Xin_xyz[1] * Xout_xyz[0],
220 Xin_xyz[0] * Xout_xyz[0]
221 + Xin_xyz[1] * Xout_xyz[1] );
a5err B_field_eval_rho(real rho[2], real psi, B_field_data *Bdata)
Evaluate normalized poloidal flux rho and its psi derivative.
a5err B_field_eval_psi(real *psi, real r, real phi, real z, real t, B_field_data *Bdata)
Evaluate poloidal flux psi.
a5err B_field_eval_B_dB(real B_dB[15], real r, real phi, real z, real t, B_field_data *Bdata)
Evaluate magnetic field and its derivatives.
a5err B_field_get_axis_rz(real rz[2], B_field_data *Bdata, real phi)
Return magnetic axis Rz-coordinates.
Header file for B_field.c.
Main header file for ASCOT5.
#define MAX_SPECIES
Maximum number of plasma species.
Header file containing physical and mathematical constants.
unsigned long int a5err
Simulation error flag.
#define math_dot(a, b)
Calculate dot product a[3] dot b[3].
#define math_unit(a, b)
Calculate unit vector b from a 3D vector a.
#define math_xyz2rpz(xyz, rpz)
Convert cartesian coordinates xyz to cylindrical coordinates rpz.
#define math_vec_rpz2xyz(vrpz, vxyz, phi)
Transform vector from cylindrical to cartesian basis: vrpz -> vxyz, phi is the toroidal angle in radi...
#define math_normc(a1, a2, a3)
Calculate norm of 3D vector from its components a1, a2, a3.
#define math_norm(a)
Calculate norm of 3D vector a.
Header file for mccc package.
#define MCCC_CUTOFF
Defines minimum energy boundary condition.
void mccc_gc_euler(particle_simd_gc *p, real *h, B_field_data *Bdata, plasma_data *pdata, mccc_data *mdata, real *rnd)
Integrate collisions for one time-step.
Routines to evaluate coefficients needed to evaluate collisions.
#define mccc_coefs_Dpara(ma, qa, va, qb, nb, vb, clogab, mu0)
Evaluate non-relativistic parallel diffusion coefficient [m^2/s^3].
#define mccc_coefs_dDpara(ma, qa, va, qb, nb, vb, clogab, mu0, dmu0)
Evaluate derivative of non-relativistic parallel diffusion coefficient [m/s^2].
#define mccc_coefs_K(va, Dpara, dDpara, Q)
Evaluate guiding center drag coefficient [m/s^2].
#define mccc_coefs_Dperp(ma, qa, va, qb, nb, vb, clogab, mu1)
Evaluate non-relativistic perpendicular diffusion coefficient [m^2/s^3].
#define mccc_coefs_nu(va, Dperp)
Evaluate pitch collision frequency [1/s].
#define mccc_coefs_DX(xi, Dpara, Dperp, gyrofreq)
Evaluate spatial diffusion coefficient [m^2/s].
#define mccc_coefs_Q(ma, qa, mb, qb, nb, vb, clogab, mu0)
Evaluate non-relativistic drag coefficient [m/s^2].
Header file for particle.c.
Methods to evaluate elementary physical quantities.
#define physlib_gc_xi(m, mu, ppar, B)
Evaluate guiding center pitch from parallel momentum and magnetic moment.
#define physlib_pnorm_vnorm(m, v)
Evaluate momentum norm [kg m/s] from velocity norm.
#define physlib_vnorm_pnorm(m, p)
Evaluate velocity norm [m/s] from momentum norm.
#define phys_gyrofreq_pnorm(m, q, p, B)
Evaluate gyrofrequency [rad/s] from momentum norm.
#define physlib_gc_ppar(p, xi)
Evaluate guiding center parallel momentum [kg m/s] from momentum norm and pitch.
#define physlib_gc_p(m, mu, ppar, B)
Evaluate guiding center momentum norm [kg m/s] from parallel momentum and magnetic moment.
#define physlib_gc_mu(m, p, xi, B)
Evaluate guiding center magnetic moment [J/T] from momentum norm and pitch.
const real * plasma_get_species_mass(plasma_data *pls_data)
Get mass of all plasma species.
int plasma_get_n_species(plasma_data *pls_data)
Get the number of plasma species.
a5err plasma_eval_flow(real *vflow, real rho, real r, real phi, real z, real t, plasma_data *pls_data)
Evalate plasma flow along the field lines.
const real * plasma_get_species_charge(plasma_data *pls_data)
Get charge of all plasma species.
a5err plasma_eval_densandtemp(real *dens, real *temp, real rho, real r, real phi, real z, real t, plasma_data *pls_data)
Evaluate plasma density and temperature for all species.
Header file for plasma.c.
Header file for random.c.
Magnetic field simulation data.
Parameters and data required to evaluate Coulomb collisions.
Struct representing NSIMD guiding center markers.