ASCOT5
Loading...
Searching...
No Matches
simulate_gc_adaptive.c File Reference

Simulate guiding centers using adaptive time-step. More...

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <omp.h>
#include <math.h>
#include "../ascot5.h"
#include "../endcond.h"
#include "../consts.h"
#include "../physlib.h"
#include "../simulate.h"
#include "../particle.h"
#include "../wall.h"
#include "../diag.h"
#include "../B_field.h"
#include "../E_field.h"
#include "../boozer.h"
#include "../mhd.h"
#include "../rfof.h"
#include "../plasma.h"
#include "simulate_gc_adaptive.h"
#include "step/step_gc_cashkarp.h"
#include "mccc/mccc.h"
#include "mccc/mccc_wiener.h"

Go to the source code of this file.

Macros

#define DUMMY_TIMESTEP_VAL   1.0

Functions

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, int mrk_array_size)
 Simulates guiding centers using adaptive time-step.
void recalculate_acceleration (Acceleration *acc, sim_data *sim, particle_simd_gc *p, particle_simd_gc *p0)
void acceleration_allocate (Acceleration *acceleration, int nmrk)
 Allocates struct representing acceleration struc.
void acceleration_offload (Acceleration *acceleration, int mrk_array_size)
 Offload acceleration struct to GPU.

Detailed Description

Simulate guiding centers using adaptive time-step.

Definition in file simulate_gc_adaptive.c.

Macro Definition Documentation

◆ DUMMY_TIMESTEP_VAL

#define DUMMY_TIMESTEP_VAL   1.0

Dummy time step value

Definition at line 33 of file simulate_gc_adaptive.c.

Function Documentation

◆ simulate_gc_adaptive_inidt()

real simulate_gc_adaptive_inidt ( sim_data * sim,
particle_simd_gc * p,
int i )

Calculates time step value.

The returned time step is either directly user-defined, 1/100th of collision frequency or user-defined fraction of gyro-motion.

Parameters
simpointer to simulation data struct
pSIMD array of markers
iindex of marker for which time step is assessed
Returns
Calculated time step

Definition at line 362 of file simulate_gc_adaptive.c.

◆ simulate_gc_adaptive()

void simulate_gc_adaptive ( particle_queue * pq,
sim_data * sim,
int mrk_array_size )

Simulates guiding centers using adaptive time-step.

The simulation includes:

  • orbit-following with Cash-Karp method
  • Coulomb collisions with Milstein method

The simulation is carried until all marker have met some end condition or are aborted/rejected. The final state of the markers is stored in the given marker array. Other output is stored in the diagnostic array.

The adaptive time-step is determined by integrator error tolerances as well as user-defined limits for how much marker state can change during a single time-step.

Parameters
pqparticles to be simulated
simsimulation data

Definition at line 55 of file simulate_gc_adaptive.c.

◆ recalculate_acceleration()

void recalculate_acceleration ( Acceleration * acc,
sim_data * sim,
particle_simd_gc * p,
particle_simd_gc * p0 )

Recalculate acceleration factor.

The acceleration is updated when crossing OMP. During the first crossing, the counter for orbit time is started. For the next crossing, we check if OMP was crossed in the same direction as first. If not, the crossing is ignored and for the third crossing we check the direction again. If this is not in the same direction as the first, the counters are nullified, acceleration is set to one, and the process is started again. This way we can account both for passing and banana particles, and for the cases where collisions have changed the orbit topology.

When we have two suitable crossings, the acceleration factor is updated and the counter for the orbit time and crossings are nullified.

Definition at line 412 of file simulate_gc_adaptive.c.

◆ acceleration_allocate()

void acceleration_allocate ( Acceleration * acceleration,
int nmrk )

Allocates struct representing acceleration struc.

Size used for memory allocation is NSIMD for CPU run and the total number of particles for GPU.

Parameters
Accelerationstruct to allocate
nmrkthe number of markers that the struct represents

Definition at line 461 of file simulate_gc_adaptive.c.

◆ acceleration_offload()

void acceleration_offload ( Acceleration * acceleration,
int mrk_array_size )

Offload acceleration struct to GPU.

Parameters
accelerationpointer to the acceleration struct to be offloaded.

Definition at line 472 of file simulate_gc_adaptive.c.