17size_t dist_5D_index(
int i_r,
int i_phi,
int i_z,
int i_ppara,
int i_pperp,
18 int i_time,
int i_q,
size_t step_6,
size_t step_5,
19 size_t step_4,
size_t step_3,
size_t step_2,
21 return (
size_t)(i_r) * step_6
22 + (
size_t)(i_phi) * step_5
23 + (
size_t)(i_z) * 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_z = (size_t)(data->
n_z);
42 size_t n_phi = (size_t)(data->
n_phi);
43 data->
step_6 = n_q * n_time * n_pperp * n_ppara * n_z * n_phi;
44 data->
step_5 = n_q * n_time * n_pperp * n_ppara * n_z;
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;
90 GPU_PARALLEL_LOOP_ALL_LEVELS
91 for(
int i = 0; i < p_f->
n_mrk; i++) {
100 int i_phi = floor((phi - dist->
min_phi)
103 int i_z = floor((p_f->
z[i] - dist->
min_z)
108 + p_f->
p_z[i] * p_f->
B_z[i])
109 / sqrt( p_f->
B_r[i] * p_f->
B_r[i]
111 + p_f->
B_z[i] * p_f->
B_z[i]);
112 int i_ppara = floor((ppara - dist->
min_ppara)
118 + p_f->
p_z[i] * p_f->
p_z[i]
120 int i_pperp = floor((pperp - dist->
min_pperp)
129 if(i_r >= 0 && i_r <= dist->n_r - 1 &&
130 i_phi >= 0 && i_phi <= dist->n_phi - 1 &&
131 i_z >= 0 && i_z <= dist->n_z - 1 &&
132 i_ppara >= 0 && i_ppara <= dist->n_ppara - 1 &&
133 i_pperp >= 0 && i_pperp <= dist->n_pperp - 1 &&
134 i_time >= 0 && i_time <= dist->n_time - 1 &&
135 i_q >= 0 && i_q <= dist->n_q - 1 ) {
139 i_r, i_phi, i_z, i_ppara, i_pperp, i_time,
177 for(
int i = 0; i <
NSIMD; i++) {
178 if(p_f->running[i]) {
179 i_r[i] = floor((p_f->r[i] - dist->
min_r)
186 i_phi[i] = floor((phi[i] - dist->
min_phi)
189 i_z[i] = floor((p_f->z[i] - dist->
min_z)
192 i_ppara[i] = floor((p_f->ppar[i] - dist->
min_ppara)
195 pperp[i] = sqrt(2 * sqrt( p_f->B_r[i] * p_f->B_r[i]
196 + p_f->B_phi[i] * p_f->B_phi[i]
197 + p_f->B_z[i] * p_f->B_z[i] )
198 * p_f->mu[i] * p_f->mass[i]);
199 i_pperp[i] = floor((pperp[i] - dist->
min_pperp)
202 i_time[i] = floor((p_f->time[i] - dist->
min_time)
208 if(i_r[i] >= 0 && i_r[i] <= dist->
n_r - 1 &&
209 i_phi[i] >= 0 && i_phi[i] <= dist->
n_phi - 1 &&
210 i_z[i] >= 0 && i_z[i] <= dist->
n_z - 1 &&
211 i_ppara[i] >= 0 && i_ppara[i] <= dist->
n_ppara - 1 &&
212 i_pperp[i] >= 0 && i_pperp[i] <= dist->
n_pperp - 1 &&
213 i_time[i] >= 0 && i_time[i] <= dist->
n_time - 1 &&
214 i_q[i] >= 0 && i_q[i] <= dist->
n_q - 1 ) {
216 weight[i] = p_f->weight[i] * (p_f->time[i] - p_i->time[i]);
224 for(
int i = 0; i <
NSIMD; i++) {
225 if(p_f->running[i] && ok[i]) {
227 i_r[i], i_phi[i], i_z[i], i_ppara[i], i_pperp[i], i_time[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]
void dist_5D_update_gc(dist_5D_data *dist, particle_simd_gc *p_f, particle_simd_gc *p_i)
Update the histogram from guiding center markers.
size_t dist_5D_index(int i_r, int i_phi, int i_z, 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)
Function for calculating the index in the histogram array.
void dist_5D_update_fo(dist_5D_data *dist, particle_simd_fo *p_f, particle_simd_fo *p_i)
Update the histogram from full-orbit particles.
void dist_5D_free(dist_5D_data *data)
Free allocated resources.
int dist_5D_init(dist_5D_data *data)
Initializes distribution from offload data.
void dist_5D_offload(dist_5D_data *data)
Offload data to the accelerator.
Header file for dist_5D.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.