ASCOT5
Loading...
Searching...
No Matches
Data Structures | Enumerations | Functions
simulate.h File Reference

Header file for simulate.c. More...

#include "ascot5.h"
#include "B_field.h"
#include "E_field.h"
#include "plasma.h"
#include "neutral.h"
#include "wall.h"
#include "boozer.h"
#include "mhd.h"
#include "asigma.h"
#include "nbi.h"
#include "diag.h"
#include "offload.h"
#include "random.h"
#include "simulate/mccc/mccc.h"

Go to the source code of this file.

Data Structures

struct  sim_offload_data
 Simulation offload struct. More...
 
struct  sim_data
 Simulation data struct. More...
 

Enumerations

enum  SIMULATION_MODE { simulate_mode_fo = 1 , simulate_mode_gc = 2 , simulate_mode_hybrid = 3 , simulate_mode_ml = 4 }
 Simulaton modes. More...
 

Functions

void simulate_init_offload (sim_offload_data *sim)
 Initializes simulation settings.
 
void sim_init (sim_data *sim, sim_offload_data *sim_offload)
 Initialize simulation data struct on target.
 
void simulate (int id, int n_particles, particle_state *p, sim_offload_data *sim_offload, offload_package *offload_data, real *offload_array, int *int_offload_array, real *diag_offload_array)
 Execute marker simulation.
 

Detailed Description

Header file for simulate.c.

Contains declarations of simulation_offload_data and simulation_data structs. Also simulation mode enums are declared here.

Definition in file simulate.h.

Enumeration Type Documentation

◆ SIMULATION_MODE

Simulaton modes.

These enums are used to determine which simulation mode will be executed.

Enumerator
simulate_mode_fo 

Models markers as particles using particle_simd_fo struct and simulate_fo_fixed.c simulation loop

simulate_mode_gc 

Models markers as guiding centers using particle_simd_gc struct and simulate_gc_fixed.c or simulate_gc_adaptive.c simulation loops

simulate_mode_hybrid 

Models markers first like using simulate_mode_gc. Additional end condition is used for markers that get close to wall. After all markers are finished, simulation for markers that were close to the wall is continued with using simulate_mode_fo mode

simulate_mode_ml 

Models markers as field lines using particle_simd_ml struct and simulate_ml_adaptive.c simulation loop

Definition at line 31 of file simulate.h.

Function Documentation

◆ simulate_init_offload()

void simulate_init_offload ( sim_offload_data * sim)

Initializes simulation settings.

This function adjusts simulation settings, e.g. how physics are included, according to the given simulation data. This function should only be called once right after input data has been read.

Parameters
simsimulation offload struct which has all fields initialized

Definition at line 349 of file simulate.c.

◆ sim_init()

void sim_init ( sim_data * sim,
sim_offload_data * offload_data )

Initialize simulation data struct on target.

This function copies the simulation parameters from the offload struct to the struct on the target.

Parameters
simpointer to data struct on target
offload_datapointer to offload data struct

Definition at line 365 of file simulate.c.

◆ simulate()

void simulate ( int id,
int n_particles,
particle_state * p,
sim_offload_data * sim_offload,
offload_package * offload_data,
real * offload_array,
int * int_offload_array,
real * diag_offload_array )

Execute marker simulation.

This simulates markers using given inputs and options. All different types of simulations are initialized and run via this function.

This function proceeds as follows:

  1. Input offload data is unpacked and initialized by calling respective init functions.
  2. Meta data (e.g. random number generator) is initialized.
  3. Markers are put into simulation queue.
  4. Threads are spawned. One thread is dedicated for monitoring progress, if monitoring is active.
  5. Other threads execute marker simulation using the mode the user has chosen.
  • Process continues once all markers have been simulated and each thread has finished. Monitoring is also terminated.
  1. (If hybrid mode is active) Markers with hybrid end condition active are placed on a new queue, and they have their end condition deactivated and they are simulated with simulate_fo_fixed.c until they have met some other end condition. Threads are spawned and progress is monitored as previously.
  2. Simulation data is deallocated except for data that is mapped back to host.
  3. Execution returns to host where this function was called.
Parameters
idtarget id where this function is executed, zero if on host
n_particlestotal number of markers to be simulated
ppointer to array storing all marker states to be simulated
sim_offloadpointer to simulation offload data
offload_datapointer to the rest of the offload data
offload_arraypointer to input data offload array
int_offload_arraypointer to input data int offload array
diag_offload_arraypointer to diagnostics offload array
Todo
Reorganize this function so that it conforms to documentation.

Definition at line 80 of file simulate.c.