ASCOT5
Loading...
Searching...
No Matches
Functions
endcond.c File Reference

Marker simulation end conditions. More...

#include <math.h>
#include "endcond.h"
#include "particle.h"
#include "simulate.h"
#include "physlib.h"
#include "consts.h"
#include "plasma.h"

Go to the source code of this file.

Functions

void endcond_check_fo (particle_simd_fo *p_f, particle_simd_fo *p_i, sim_data *sim)
 Check end conditions for FO markers.
 
void endcond_check_gc (particle_simd_gc *p_f, particle_simd_gc *p_i, sim_data *sim)
 Check end conditions for GC markers.
 
void endcond_check_ml (particle_simd_ml *p_f, particle_simd_ml *p_i, sim_data *sim)
 Check end conditions for ML markers.
 
void endcond_parse (int endcond, int *endconds)
 Split endcond to an array of end conditions.
 
void endcond_parse2str (int endcond, char *str)
 Represent end condition in human-readable format.
 

Detailed Description

Marker simulation end conditions.

In the absence of errors, marker simulation is ended when marker meets even one of the active end conditions. User can choose which end conditions are active.

The end conditions are:

As magnetic field lines have no energy, emin and therm are never checked for them. Guiding centers are the only markers for which hybrid is checked.

In the code, the end conditions are represented as bit arrays with each bit corresponding to a specific end condition. Each marker has a field "endcond", and when marker meets an end condition, the corresponding bit is flagged. This way if marker simultaneously meets several end conditions, all can be flagged.

Additionally, when marker meets an end condition, its running state is set to False which notates its simulation should be discontinued. If the end condition is wall collision, the ID of the wall element the marker collided with is stored in the marker fields.

Todo
Error checking would be a good idea

Definition in file endcond.c.

Function Documentation

◆ endcond_check_fo()

void endcond_check_fo ( particle_simd_fo * p_f,
particle_simd_fo * p_i,
sim_data * sim )

Check end conditions for FO markers.

The end conditions are checked for all markers within the SIMD marker struct.

Parameters
p_fpointer to SIMD struct storing marker states at the end of current time-step
p_ipointer to SIMD struct storing marker states at the beginning of current time-step
simpointer to simulation data struct

Definition at line 73 of file endcond.c.

◆ endcond_check_gc()

void endcond_check_gc ( particle_simd_gc * p_f,
particle_simd_gc * p_i,
sim_data * sim )

Check end conditions for GC markers.

The end conditions are checked for all markers within the SIMD marker struct.

Parameters
p_fpointer to SIMD struct storing marker states at the end of current time-step
p_ipointer to SIMD struct storing marker states at the beginning of current time-step
simpointer to simulation data struct

Definition at line 262 of file endcond.c.

◆ endcond_check_ml()

void endcond_check_ml ( particle_simd_ml * p_f,
particle_simd_ml * p_i,
sim_data * sim )

Check end conditions for ML markers.

The end conditions are checked for all markers within the SIMD marker struct.

Parameters
p_fpointer to SIMD struct storing marker states at the end of current time-step
p_ipointer to SIMD struct storing marker states at the beginning of current time-step
simpointer to simulation data struct

Definition at line 435 of file endcond.c.

◆ endcond_parse()

void endcond_parse ( int endcond,
int * endconds )

Split endcond to an array of end conditions.

This function splits the bit array end condition to an array where the active end conditions are presented by numbers. Number for each end condition are defined in this function.

Parameters
endcondbit array representing marker end conditions
endcondsinteger array large enough to hold all end conditions

Definition at line 538 of file endcond.c.

◆ endcond_parse2str()

void endcond_parse2str ( int endcond,
char * str )

Represent end condition in human-readable format.

This function takes end condition represented as integer, as given by endcond_parse().

Parameters
endcondend condition integer representation
strend condition as human-readable string

Definition at line 564 of file endcond.c.