26#include "step/step_gc_cashkarp.h"
30DECLARE_TARGET_SIMD_UNIFORM(sim)
33#define DUMMY_TIMESTEP_VAL 1.0
76 real cputime, cputime_last;
83 for(
int i=0; i<
NSIMD; i++) {
86 acceleration.
acc[i] = 1.0;
88 acceleration.
cross[i].crossed_once = 0;
99 for(
int i = 0; i <
NSIMD; i++) {
124 while(n_running > 0) {
128 for(
int i = 0; i <
NSIMD; i++) {
140 for(
int i = 0; i <
NSIMD; i++) {
160 for(
int i = 0; i <
NSIMD; i++) {
164 hout_orb[i] = -hout_orb[i];
167 if(p.running[i] && hout_orb[i] < 0){
169 hnext[i] = hout_orb[i];
180 hout_col, tol_col, wienarr, &sim->
B_data,
185 for(
int i = 0; i <
NSIMD; i++) {
186 if(p.running[i] && hout_col[i] < 0){
188 hnext[i] = hout_col[i];
195 rfof_resonance_check_and_kick_gc(
200 for(
int i = 0; i <
NSIMD; i++) {
201 if(p.running[i] && hout_rfof[i] < 0){
203 hnext[i] = hout_rfof[i];
212 for(
int i = 0; i <
NSIMD; i++) {
213 if(p.id[i] > 0 && !p.err[i]) {
219 if(dphi > 1 && dphi > drho) {
220 hnext[i] = -hin[i]/dphi;
222 else if(drho > 1 && drho > dphi) {
223 hnext[i] = -hin[i]/drho;
243 * hin[i] * acceleration.
acc[i];
244 p.mileage[i] += hin[i] * acceleration.
acc[i];
246 acceleration.
orbittime[i] += hin[i] * acceleration.
acc[i];
249 if(hnext[i] > hout_orb[i]) {
252 hnext[i] = hout_orb[i];
254 if(hnext[i] > hout_col[i]) {
257 hnext[i] = hout_col[i];
259 if(hnext[i] > hout_rfof[i]) {
261 hnext[i] = hout_rfof[i];
263 if(hnext[i] == 1.0) {
275 p.cputime[i] += cputime - cputime_last;
279 cputime_last = cputime;
297 for(
int i = 0; i <
NSIMD; i++) {
300 acceleration.
acc[i] = 1.0;
302 acceleration.
cross[i].crossed_once = 0;
309 rfof_clear_history(&rfof_mrk, i);
319 rfof_tear_down(&rfof_mrk);
362 real colltime = 1/(100*nu);
363 if(h > colltime) {h=colltime;}
390 for(
int i = 0; i <
NSIMD; i++) {
392 int omp_crossed = ((p->z[i] - rz[1]) * (p0->z[i] - rz[1]) < 0) &&
394 if(omp_crossed && acc->
cross[i].crossed_twice) {
395 if( ((
float)acc->
cross[i].first_ppar - 0.5) * p->ppar[i] > 0 ) {
401 acc->
cross[i].crossed_once = 1;
402 acc->
cross[i].crossed_twice = 0;
403 acc->
cross[i].first_ppar = p->ppar[i] > 0;
406 else if(omp_crossed && acc->
cross[i].crossed_once) {
407 acc->
cross[i].crossed_twice = 1;
408 if( ((
float)acc->
cross[i].first_ppar - 0.5) * p->ppar[i] > 0 ) {
410 acc->
cross[i].crossed_once = 1;
411 acc->
cross[i].crossed_twice = 0;
412 acc->
cross[i].first_ppar = p->ppar[i] > 0;
416 else if(omp_crossed) {
417 acc->
cross[i].crossed_once = 1;
418 acc->
cross[i].first_ppar = p->ppar[i] > 0;
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.
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 for boozer.c.
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_milstein(particle_simd_gc *p, real *hin, real *acc, real *collfreq, real *hout, real tol, mccc_wienarr *w, B_field_data *Bdata, plasma_data *pdata, mccc_data *mdata, real *rnd)
Integrate collisions for one time-step.
a5err mccc_wiener_clean(mccc_wienarr *w, real t)
Removes Wiener processes from the array that are no longer required.
void mccc_wiener_initialize(mccc_wienarr *w, real initime)
Initializes a struct that stores generated Wiener processes.
header file for mccc_wiener.c
void particle_copy_gc(particle_simd_gc *p1, int i, particle_simd_gc *p2, int j)
Copy GC struct.
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.
void recalculate_acceleration(Acceleration *acc, sim_data *sim, particle_simd_gc *p, particle_simd_gc *p0)
real simulate_gc_adaptive_inidt(sim_data *sim, particle_simd_gc *p, int i)
Calculates time step value.
void simulate_gc_adaptive(particle_queue *pq, sim_data *sim)
Simulates guiding centers using adaptive time-step.
#define DUMMY_TIMESTEP_VAL
Header file for simulate_gc_adaptive.c.
void step_gc_cashkarp_mhd(particle_simd_gc *p, real *h, real *hnext, real tol, B_field_data *Bdata, E_field_data *Edata, boozer_data *boozer, mhd_data *mhd, int aldforce)
Integrate a guiding center step for a struct of markers with MHD.
void step_gc_cashkarp(particle_simd_gc *p, real *h, real *hnext, real tol, B_field_data *Bdata, E_field_data *Edata, int aldforce)
Integrate a guiding center step for a struct of markers.
Struct for storing Wiener processes.
Struct representing NSIMD guiding center markers.
Reusable struct for storing marker specific data during the simulation loop.