19 return (
size_t)(i_mu) * step_2
20 + (
size_t)(i_Ekin) * step_1
31 size_t n_Ptor = (size_t)(data->
n_Ptor);
32 size_t n_Ekin = (size_t)(data->
n_Ekin);
33 data->
step_2 = n_Ptor * n_Ekin;
70 GPU_PARALLEL_LOOP_ALL_LEVELS
71 for(
int i = 0; i < p_f->
n_mrk; i++) {
73 real Ekin, Ptor, Bnorm, psi, mu, xi, pnorm, ppar;
87 int i_mu = floor((mu - dist->
min_mu)
91 int i_Ekin = floor((Ekin - dist->
min_Ekin)
96 int i_Ptor = floor((Ptor - dist->
min_Ptor)
99 if(i_mu >= 0 && i_mu <= dist->n_mu - 1 &&
100 i_Ekin >= 0 && i_Ekin <= dist->n_Ekin - 1 &&
101 i_Ptor >= 0 && i_Ptor <= dist->n_Ptor - 1 ) {
134 for(
int i = 0; i <
NSIMD; i++) {
135 if(p_f->running[i]) {
136 real Ekin, Ptor, B, psi;
139 p_f->time[i], Bdata);
141 B =
math_normc(p_f->B_r[i], p_f->B_phi[i], p_f->B_z[i]);
142 i_mu[i] = floor((p_f->mu[i] - dist->
min_mu)
147 i_Ekin[i] = floor((Ekin - dist->
min_Ekin)
152 i_Ptor[i] = floor((Ptor - dist->
min_Ptor)
155 if(i_mu[i] >= 0 && i_mu[i] <= dist->
n_mu - 1 &&
156 i_Ekin[i] >= 0 && i_Ekin[i] <= dist->
n_Ekin - 1 &&
157 i_Ptor[i] >= 0 && i_Ptor[i] <= dist->
n_Ptor - 1 ) {
159 weight[i] = p_f->weight[i] * (p_f->time[i] - p_i->time[i]);
167 for(
int i = 0; i <
NSIMD; i++) {
168 if(p_f->running[i] && ok[i]) {
a5err B_field_eval_psi(real *psi, real r, real phi, real z, real t, B_field_data *Bdata)
Evaluate poloidal flux psi.
Main header file for ASCOT5.
#define NSIMD
Number of particles simulated simultaneously in a particle group operations.
Header file containing physical and mathematical constants.
void dist_COM_update_fo(dist_COM_data *dist, B_field_data *Bdata, particle_simd_fo *p_f, particle_simd_fo *p_i)
Update the histogram from full-orbit markers.
void dist_COM_free(dist_COM_data *data)
Free allocated resources.
size_t dist_COM_index(int i_mu, int i_Ekin, int i_Ptor, size_t step_2, size_t step_1)
Internal function calculating the index in the histogram array.
void dist_COM_offload(dist_COM_data *data)
Offload data to the accelerator.
void dist_COM_update_gc(dist_COM_data *dist, B_field_data *Bdata, particle_simd_gc *p_f, particle_simd_gc *p_i)
Update the histogram from guiding center markers.
int dist_COM_init(dist_COM_data *data)
Initializes distribution data.
Header file for dist_com.c.
#define math_dot(a, b)
Calculate dot product a[3] dot b[3].
#define math_normc(a1, a2, a3)
Calculate norm of 3D vector from its components a1, a2, a3.
Header file for particle.c.
Methods to evaluate elementary physical quantities.
#define phys_ptoroid_fo(q, R, pphi, psi)
Evaluate toroidal canonical momentum for particle.
#define physlib_Ekin_ppar(m, mu, ppar, B)
Evaluate kinetic energy [J] from parallel momentum.
#define physlib_Ekin_pnorm(m, p)
Evaluate kinetic energy [J] from momentum norm.
#define phys_ptoroid_gc(q, R, ppar, psi, B, Bphi)
Evaluate toroidal canonical momentum for guiding center.
#define physlib_gc_mu(m, p, xi, B)
Evaluate guiding center magnetic moment [J/T] from momentum norm and pitch.
Magnetic field simulation data.
Histogram parameters on target.
Struct representing NSIMD particle markers.
Struct representing NSIMD guiding center markers.