ASCOT5
Loading...
Searching...
No Matches
Functions
ascot5_main.h File Reference

Functions to execute main program externally. More...

#include "ascot5.h"
#include "offload.h"
#include "simulate.h"

Go to the source code of this file.

Functions

int pack_offload_array (sim_offload_data *sim, offload_package *offload_data, real **B_offload_array, real **E_offload_array, real **plasma_offload_array, real **neutral_offload_array, real **wall_offload_array, int **wall_int_offload_array, real **boozer_offload_array, real **mhd_offload_array, real **asigma_offload_array, real **offload_array, int **int_offload_array)
 Prepare offload array to be offloaded.
 
int prepare_markers (sim_offload_data *sim, int n_tot, input_particle *pin, particle_state **pout, int *nprts, real *B_offload_array)
 Prepare markers for offload.
 
int write_rungroup (sim_offload_data *sim, particle_state *ps, int n_tot, char *qid)
 Create and store run group and marker inistate.
 
int offload_and_simulate (sim_offload_data *sim, int n_tot, int n_proc, particle_state *pin, offload_package *offload_data, real *offload_array, int *int_offload_array, int *n_gather, particle_state **pout, real *diag_offload_array)
 Offload data to target, carry out the simulation, and return to host.
 
int write_output (sim_offload_data *sim, particle_state *ps_gathered, int n_tot, real *diag_offload_array)
 Store simulation output data.
 
void print_marker_summary (particle_state *ps, int n_tot)
 Writes a summary of what happened to the markers during simulation.
 

Detailed Description

Functions to execute main program externally.

The main progam for ascot5 is in ascot5_main.c. This header file declares the functions needed to carry out the simulation, so that hey can be used by an external program (i.e. via the python interface).

Definition in file ascot5_main.h.

Function Documentation

◆ pack_offload_array()

int pack_offload_array ( sim_offload_data * sim,
offload_package * offload_data,
real ** B_offload_array,
real ** E_offload_array,
real ** plasma_offload_array,
real ** neutral_offload_array,
real ** wall_offload_array,
int ** wall_int_offload_array,
real ** boozer_offload_array,
real ** mhd_offload_array,
real ** asigma_offload_array,
real ** offload_array,
int ** int_offload_array )

Prepare offload array to be offloaded.

When data is read, it is stored to input specific offload arrays which are packed as a single array here (two actually as one array contains integers and the other floats). The initial individual arrays are deallocated.

Parameters
simsimulation offload data struct
offload_dataempty offload package
B_offload_arraymagnetic field offload array
E_offload_arrayelectric field offload array
plasma_offload_arrayplasma offload array
neutral_offload_arrayneutrals offload array
wall_offload_arraywall offload array
wall_int_offload_arraywall integer offload array
boozer_offload_arrayboozer offload array
mhd_offload_arrayMHD data offload array
asigma_offload_arrayatomic data offload array
offload_arraypointer to common offload array created here
int_offload_arraypointer to common offload integer array created here
Returns
zero on success

Definition at line 341 of file ascot5_main.c.

◆ prepare_markers()

int prepare_markers ( sim_offload_data * sim,
int n_tot,
input_particle * pin,
particle_state ** pout,
int * n_proc,
real * B_offload_array )

Prepare markers for offload.

This function initializes the marker states and allocates memory for the particle states. The input markers are read from the HDF5 file and stored in the input_particle_states array. The initial marker states are then calculated and stored in the particle_states array.

When MPI is used, the marker states are initialized only for those markers that are used in this MPI process.

Parameters
simsimulation offload data struct
n_tottotal number of markers
pinpointer to marker input array which is deallocated here
poutpointer to marker state array created here
n_procpointer to variable for number of markers for this process
B_offload_arraypointer to magnetic field data needed for marker init
Returns
zero on success

Definition at line 278 of file ascot5_main.c.

◆ write_rungroup()

int write_rungroup ( sim_offload_data * sim,
particle_state * ps,
int n_tot,
char * qid )

Create and store run group and marker inistate.

Parameters
simsimulation offload data struct
psmarker state array for this process
n_tottotal number of markers in this simulation
qidunique identifier for this run group
Returns
zero on success

Definition at line 408 of file ascot5_main.c.

◆ offload_and_simulate()

int offload_and_simulate ( sim_offload_data * sim,
int n_tot,
int n_proc,
particle_state * pin,
offload_package * offload_data,
real * offload_array,
int * int_offload_array,
int * n_gather,
particle_state ** pout,
real * diag_offload_array )

Offload data to target, carry out the simulation, and return to host.

Parameters
simsimulation offload data struct
n_tottotal number of markers
n_procnumber of markers in this process
pinmarker state array for this process (deallocated here)
offload_datapacked offload data struct
offload_arraypacked offload array containing the input data
int_offload_arraypacked offload integer array containg the input data
n_gatherpointer for storing the number of markers in pout (either n_tot or n_proc)
poutpointer to array containing all endstates in the simulation
diag_offload_arrayarray to store output data
Returns
zero on success

Definition at line 469 of file ascot5_main.c.

◆ write_output()

int write_output ( sim_offload_data * sim,
particle_state * ps,
int n_tot,
real * diag_offload_array )

Store simulation output data.

Parameters
simsimulation offload data
psmarker endstate array to be written
n_totnumber of markers
diag_offload_arraydiagnostics offload data array
Returns
zero on success

Definition at line 508 of file ascot5_main.c.

◆ print_marker_summary()

void print_marker_summary ( particle_state * ps,
int n_tot )

Writes a summary of what happened to the markers during simulation.

This function writes a summary of marker end conditions and possible simulation-time errors. Since simulation can have billions and billions of markers, we only show how many markers had specific error or end condition.

End conditions and errors are printed in human-readable format.

This function is called by the root MPI process only.

Parameters
psarray of marker states after simulation has finished
n_totnumber of markers in the array

Definition at line 736 of file ascot5_main.c.