26DECLARE_TARGET_SIMD_UNIFORM(sim)
29#define DUMMY_TIMESTEP_VAL 1.0
50 int* cycle = (
int*) malloc(mrk_array_size*
sizeof(
int));
54 real* hin_default = (
real*) malloc(mrk_array_size*
sizeof(
real));
55 real* hnext_recom = (
real*) malloc(mrk_array_size*
sizeof(
real));
58 real* hout_rfof = (
real*) malloc(mrk_array_size*
sizeof(
real));
66 real cputime, cputime_last;
75 for(
int i=0; i< mrk_array_size; i++) {
91 for(
int i = 0; i < mrk_array_size; i++) {
94 hin[i] = hin_default[i];
111 real* rnd = (
real*) malloc(5*mrk_array_size*
sizeof(
real));
112 GPU_MAP_TO_DEVICE(hin[0:mrk_array_size], rnd[0:5*mrk_array_size], hin_default[0:mrk_array_size], hnext_recom[0:mrk_array_size], hout_rfof[0:mrk_array_size])
113 while(n_running > 0) {
116 GPU_PARALLEL_LOOP_ALL_LEVELS
117 for(
int i = 0; i < p.
n_mrk; i++) {
124 GPU_PARALLEL_LOOP_ALL_LEVELS
125 for(
int i = 0; i < p.
n_mrk; i++) {
145 GPU_PARALLEL_LOOP_ALL_LEVELS
146 for(
int i = 0; i < p.
n_mrk; i++) {
161 rfof_resonance_check_and_kick_gc(
166 for(
int i = 0; i <
NSIMD; i++) {
167 if(p.
running[i] && hout_rfof[i] < 0){
170 hnext_recom[i] = hout_rfof[i];
175 hin[i] = hin_default[i];
185 GPU_PARALLEL_LOOP_ALL_LEVELS
186 for(
int i = 0; i < p.
n_mrk; i++) {
187 if(hnext_recom[i] < 0) {
191 hin[i] = -hnext_recom[i];
194 if(hnext_recom[i] < 0) {
201 p.
cputime[i] += cputime - cputime_last;
205 cputime_last = cputime;
216 GPU_PARALLEL_LOOP_ALL_LEVELS_REDUCTION(n_running)
217 for(
int i = 0; i < p.
n_mrk; i++)
219 if(p.
running[i] > 0) n_running++;
228 for(
int i = 0; i < p.
n_mrk; i++) {
233 rfof_clear_history(&rfof_mrk, i);
243 GPU_MAP_FROM_DEVICE(sim[0:1])
253 rfof_tear_down(&rfof_mrk);
282 p->
mu[i], p->
ppar[i], Bnorm);
Header file for B_field.c.
Header file for E_field.c.
Main header file for ASCOT5.
#define NSIMD
Number of particles simulated simultaneously in a particle group operations.
#define A5_WTIME
Wall time.
Header file containing physical and mathematical constants.
void diag_update_gc(diag_data *data, B_field_data *Bdata, particle_simd_gc *p_f, particle_simd_gc *p_i)
Collects diagnostics when marker represents a guiding center.
void endcond_check_gc(particle_simd_gc *p_f, particle_simd_gc *p_i, sim_data *sim)
Check end conditions for GC markers.
Header file for endcond.c.
#define math_normc(a1, a2, a3)
Calculate norm of 3D vector from its components a1, a2, a3.
Header file for mccc package.
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.
void particle_allocate_gc(particle_simd_gc *p_gc, int nmrk)
Allocates guiding center struct representing particle markers.
void particle_onload_gc(particle_simd_gc *p)
Onload guiding center particle struct from the GPU.
void particle_copy_gc(particle_simd_gc *p1, int i, particle_simd_gc *p2, int j)
Copy GC struct.
void particle_offload_gc(particle_simd_gc *p)
Offload guiding center particle struct to GPU.
int particle_cycle_gc(particle_queue *q, particle_simd_gc *p, B_field_data *Bdata, int *cycle)
Replace finished GC markers with new ones or dummies.
Header file for particle.c.
Methods to evaluate elementary physical quantities.
#define phys_gyrofreq_ppar(m, q, mu, ppar, B)
Evaluate gyrofrequency [rad/s] from parallel momentum and magnetic moment.
Header file for plasma.c.
#define random_normal_simd(data, n, r)
Contains the functions to be called from the simulation loop when using ICRH.
Header file for simulate.c.
#define DUMMY_TIMESTEP_VAL
real simulate_gc_fixed_inidt(sim_data *sim, particle_simd_gc *p, int i)
Calculates time step value.
void simulate_gc_fixed(particle_queue *pq, sim_data *sim, int mrk_array_size)
Simulates guiding centers using fixed time-step.
Header file for simulate_gc_fixed.c.
void step_gc_rk4(particle_simd_gc *p, real *h, B_field_data *Bdata, E_field_data *Edata, int aldforce)
Integrate a guiding center step for a struct of markers with RK4.
void step_gc_rk4_mhd(particle_simd_gc *p, real *h, B_field_data *Bdata, E_field_data *Edata, boozer_data *boozer, mhd_data *mhd, int aldforce)
Integrate a guiding center step with RK4 with MHD modes present.
Header file for step_gc_rk4.c.
Struct representing NSIMD guiding center markers.
Reusable struct for storing marker specific data during the simulation loop.
random_data * random_data