18 int i_pperp,
int i_time,
int i_q,
size_t step_6,
19 size_t step_5,
size_t step_4,
size_t step_3,
20 size_t step_2,
size_t step_1) {
21 return (
size_t)(i_rho) * step_6
22 + (
size_t)(i_theta) * step_5
23 + (
size_t)(i_phi) * step_4
24 + (
size_t)(i_ppara) * step_3
25 + (
size_t)(i_pperp) * step_2
26 + (
size_t)(i_time) * step_1
37 size_t n_q = (size_t)(data->
n_q);
38 size_t n_time = (size_t)(data->
n_time);
39 size_t n_pperp = (size_t)(data->
n_pperp);
40 size_t n_ppara = (size_t)(data->
n_ppara);
41 size_t n_phi = (size_t)(data->
n_phi);
42 size_t n_theta = (size_t)(data->
n_theta);
43 data->
step_6 = n_q * n_time * n_pperp * n_ppara * n_phi * n_theta;
44 data->
step_5 = n_q * n_time * n_pperp * n_ppara * n_phi;
45 data->
step_4 = n_q * n_time * n_pperp * n_ppara;
46 data->
step_3 = n_q * n_time * n_pperp;
47 data->
step_2 = n_q * n_time;
88 GPU_PARALLEL_LOOP_ALL_LEVELS
89 for(
int i = 0; i < p_f->
n_mrk; i++) {
92 int i_rho = floor((p_f->
rho[i] - dist->
min_rho)
99 int i_phi = floor((phi - dist->
min_phi)
106 int i_theta = floor((theta - dist->
min_theta)
112 + p_f->
p_z[i] * p_f->
B_z[i])
113 / sqrt( p_f->
B_r[i] * p_f->
B_r[i]
115 + p_f->
B_z[i] * p_f->
B_z[i]);
116 int i_ppara = floor((ppara - dist->
min_ppara)
123 + p_f->
p_z[i] * p_f->
p_z[i]
125 int i_pperp = floor((pperp - dist->
min_pperp)
135 if(i_rho >= 0 && i_rho <= dist->n_rho - 1 &&
136 i_phi >= 0 && i_phi <= dist->n_phi - 1 &&
137 i_theta >= 0 && i_theta <= dist->n_theta - 1 &&
138 i_ppara >= 0 && i_ppara <= dist->n_ppara - 1 &&
139 i_pperp >= 0 && i_pperp <= dist->n_pperp - 1 &&
140 i_time >= 0 && i_time <= dist->n_time - 1 &&
141 i_q >= 0 && i_q <= dist->n_q - 1 ) {
144 i_rho, i_theta, i_phi, i_ppara, i_pperp,
183 for(
int i = 0; i <
NSIMD; i++) {
184 if(p_f->running[i]) {
186 i_rho[i] = floor((p_f->rho[i] - dist->
min_rho)
193 i_phi[i] = floor((phi[i] - dist->
min_phi)
200 i_theta[i] = floor((theta[i] - dist->
min_theta)
204 i_ppara[i] = floor((p_f->ppar[i] - dist->
min_ppara)
207 pperp[i] = sqrt(2 * sqrt( p_f->B_r[i] * p_f->B_r[i]
208 + p_f->B_phi[i] * p_f->B_phi[i]
209 + p_f->B_z[i] * p_f->B_z[i] )
210 * p_f->mu[i] * p_f->mass[i]);
211 i_pperp[i] = floor((pperp[i] - dist->
min_pperp)
215 i_time[i] = floor((p_f->time[i] - dist->
min_time)
221 if(i_rho[i] >= 0 && i_rho[i] <= dist->
n_rho - 1 &&
222 i_phi[i] >= 0 && i_phi[i] <= dist->
n_phi - 1 &&
223 i_theta[i] >= 0 && i_theta[i] <= dist->
n_theta - 1 &&
224 i_ppara[i] >= 0 && i_ppara[i] <= dist->
n_ppara - 1 &&
225 i_pperp[i] >= 0 && i_pperp[i] <= dist->
n_pperp - 1 &&
226 i_time[i] >= 0 && i_time[i] <= dist->
n_time - 1 &&
227 i_q[i] >= 0 && i_q[i] <= dist->
n_q - 1 ) {
229 weight[i] = p_f->weight[i] * (p_f->time[i] - p_i->time[i]);
237 for(
int i = 0; i <
NSIMD; i++) {
238 if(p_f->running[i] && ok[i]) {
240 i_rho[i], i_theta[i], i_phi[i], i_ppara[i], i_pperp[i],
Main header file for ASCOT5.
#define NSIMD
Number of particles simulated simultaneously in a particle group operations.
Header file containing physical and mathematical constants.
#define CONST_E
Elementary charge [C].
int dist_rho5D_init(dist_rho5D_data *data)
Initializes distribution data.
void dist_rho5D_free(dist_rho5D_data *data)
Free the allocated resources.
void dist_rho5D_offload(dist_rho5D_data *data)
Offload data to the accelerator.
void dist_rho5D_update_gc(dist_rho5D_data *dist, particle_simd_gc *p_f, particle_simd_gc *p_i)
Update the histogram from guiding center markers.
size_t dist_rho5D_index(int i_rho, int i_theta, int i_phi, int i_ppara, int i_pperp, int i_time, int i_q, size_t step_6, size_t step_5, size_t step_4, size_t step_3, size_t step_2, size_t step_1)
Internal function calculating the index in the histogram array.
void dist_rho5D_update_fo(dist_rho5D_data *dist, particle_simd_fo *p_f, particle_simd_fo *p_i)
Update the histogram from full-orbit particles.
Header file for dist_rho5D.c.
real fmod(real x, real y)
Compute the modulus of two real numbers.
Header file for particle.c.
Methods to evaluate elementary physical quantities.
Struct representing NSIMD particle markers.
Struct representing NSIMD guiding center markers.