ASCOT5
Loading...
Searching...
No Matches
Functions | Variables
asigma.c File Reference

Atomic reaction data interface. More...

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "ascot5.h"
#include "print.h"
#include "error.h"
#include "asigma.h"
#include "asigma/asigma_loc.h"
#include "consts.h"

Go to the source code of this file.

Functions

void asigma_extrapolate (int extrapolate)
 Toggle extrapolation when evaluating cross sections.
 
int asigma_init_offload (asigma_offload_data *offload_data, real **offload_array)
 Load atomic reaction data and prepare parameters.
 
void asigma_free_offload (asigma_offload_data *offload_data, real **offload_array)
 Free offload array and reset parameters.
 
int asigma_init (asigma_data *asigma_data, asigma_offload_data *offload_data, real *offload_array)
 Initializes atomic reaction data struct on target.
 
a5err asigma_eval_sigma (real *sigma, int z_1, int a_1, int z_2, int a_2, real E_coll_per_amu, asigma_reac_type reac_type, asigma_data *asigma_data)
 Evaluate atomic reaction cross-section.
 
a5err asigma_eval_sigmav (real *sigmav, int z_1, int a_1, real m_1, int z_2, int a_2, real E, real T_e, real T_0, real n_i, asigma_reac_type reac_type, asigma_data *asigma_data)
 Evaluate atomic reaction rate coefficient.
 
a5err asigma_eval_cx (real *ratecoeff, int z_1, int a_1, real E, real mass, int nspec, const int *znum, const int *anum, real T_0, real *n_0, asigma_data *asigma_data)
 Evaluate charge exchange rate coefficient.
 
a5err asigma_eval_bms (real *ratecoeff, int z_1, int a_1, real E, real mass, int nion, const int *znum, const int *anum, real T_e, real *n_i, asigma_data *asigma_data)
 Evaluate beam stopping rate coefficient.
 

Variables

static int ASIGMA_EXTRAPOLATE = 0
 

Detailed Description

Atomic reaction data interface.

This is an interface through which atomic reaction data is initialized and accessed. Reading, for example from local files, is done elsewhere.

The name asigma is short for atomicsigma. The word sigma refers to cross-section, a fundamental type of reaction probability data. Note that the data is not necessarily in the form of pure cross-sections. It might be in some derivative form, such as rate coefficients.

To add a new atomic reaction data instance, make sure the functions are implemented and called from this interface, and that asigma.h contains enum type for the new instance.

The interface checks which instance given data corresponds to from the "type"-field in asigma_offload_data or asigma_data that is given as an argument, and calls the relevant function for that instance.

Definition in file asigma.c.

Function Documentation

◆ asigma_extrapolate()

void asigma_extrapolate ( int extrapolate)

Toggle extrapolation when evaluating cross sections.

In this context the extrapolation means values outside the abscissae are set to zero instead of raising an error.

Parameters
extrapolateflag whether to extrapolate

Definition at line 45 of file asigma.c.

◆ asigma_init_offload()

int asigma_init_offload ( asigma_offload_data * offload_data,
real ** offload_array )

Load atomic reaction data and prepare parameters.

This function fills the relevant atomic sigma offload struct with parameters and allocates and fills the offload array. Sets offload array length in the offload struct.

The offload data has to have a type when this function is called as it should be set when the offload data is constructed from inputs.

This function is host only.

Parameters
offload_datapointer to offload data struct
offload_arraypointer to pointer to offload array
Returns
zero if initialization succeeded

Definition at line 66 of file asigma.c.

◆ asigma_free_offload()

void asigma_free_offload ( asigma_offload_data * offload_data,
real ** offload_array )

Free offload array and reset parameters.

This function deallocates the offload_array.

This function is host only.

Parameters
offload_datapointer to offload data struct
offload_arraypointer to pointer to offload array

Definition at line 104 of file asigma.c.

◆ asigma_init()

int asigma_init ( asigma_data * asigma_data,
asigma_offload_data * offload_data,
real * offload_array )

Initializes atomic reaction data struct on target.

This function copies some atomic reaction parameters from the offload struct to the struct on target and sets the atomic reaction data pointers to correct offsets in the offload array.

Parameters
asigma_datapointer to data struct on target
offload_datapointer to offload data struct
offload_arraypointer to offload array
Returns
zero if initialization succeeded

Definition at line 126 of file asigma.c.

◆ asigma_eval_sigma()

a5err asigma_eval_sigma ( real * sigma,
int z_1,
int a_1,
int z_2,
int a_2,
real E_coll_per_amu,
asigma_reac_type reac_type,
asigma_data * asigma_data )

Evaluate atomic reaction cross-section.

This function evaluates the cross-section (sigma) for the atomic reaction corresponding to the reaction identifiers given as parameters at the given mass-normalized collision energy.

This is a SIMD function.

Parameters
sigmapointer to evaluated cross-section
z_1atomic number of fast particle
a_1atomic mass number of fast particle
z_2atomic number of bulk particle
a_2atomic mass number of bulk particle
E_coll_per_amuenergy per amu corresponding to collision speed
reac_typereaction type
asigma_datapointer to atomic data struct
Returns
Non-zero a5err value if evaluation failed, zero otherwise

Definition at line 166 of file asigma.c.

◆ asigma_eval_sigmav()

a5err asigma_eval_sigmav ( real * sigmav,
int z_1,
int a_1,
real m_1,
int z_2,
int a_2,
real E,
real T_e,
real T_0,
real n_i,
asigma_reac_type reac_type,
asigma_data * asigma_data )

Evaluate atomic reaction rate coefficient.

This function evaluates the rate coefficient (<sigma*v>) for the atomic reaction corresponding to the reaction identifiers given as parameters at the given fast particle energy and bulk plasma conditions.

This is a SIMD function.

Parameters
sigmavpointer to evaluated rate coefficient
z_1atomic number of fast particle
a_1atomic mass number of fast particle
m_1mass of fast particle
z_2atomic number of bulk particle
a_2atomic mass number of bulk particle
Eenergy of fast particle
T_eelectron temperature of bulk plasma
T_0temperature of bulk neutrals
n_iion density of bulk plasma
reac_typereaction type
asigma_datapointer to atomic data struct
Returns
Non-zero a5err value if evaluation failed, zero otherwise

Definition at line 216 of file asigma.c.

◆ asigma_eval_cx()

a5err asigma_eval_cx ( real * ratecoeff,
int z_1,
int a_1,
real E,
real mass,
int nspec,
const int * znum,
const int * anum,
real T_0,
real * n_0,
asigma_data * asigma_data )

Evaluate charge exchange rate coefficient.

This is a SIMD function.

Parameters
ratecoeffpointer to evaluated rate coefficient
z_1atomic number of fast particle
a_1atomic mass number of fast particle
Eenergy of fast particle
massmass of fast particle
nspecnumber of bulk neutral species
znumatomic numbers of bulk particles
anumatomic mass numbers of bulk particles
T_0temperature of bulk neutrals
n_0densities of bulk neutrals
asigma_datapointer to atomic data struct
Returns
Non-zero a5err value if evaluation failed, zero otherwise

Definition at line 262 of file asigma.c.

◆ asigma_eval_bms()

a5err asigma_eval_bms ( real * ratecoeff,
int z_1,
int a_1,
real E,
real mass,
int nion,
const int * znum,
const int * anum,
real T_e,
real * n_i,
asigma_data * asigma_data )

Evaluate beam stopping rate coefficient.

This is a SIMD function.

Parameters
ratecoeffpointer to evaluated rate coefficient
z_1atomic number of fast particle
a_1atomic mass number of fast particle
Eenergy of fast particle
massmass of fast particle
nionnumber of bulk ion species
znumatomic numbers of bulk particles
anumatomic mass numbers of bulk particles
T_eelectron temperature of bulk plasma
n_idensities of bulk ions
asigma_datapointer to atomic data struct
Returns
Non-zero a5err value if evaluation failed, zero otherwise

Definition at line 308 of file asigma.c.

Variable Documentation

◆ ASIGMA_EXTRAPOLATE

int ASIGMA_EXTRAPOLATE = 0
static

Set values outside abscissae to zero instead of raising an error.

Definition at line 34 of file asigma.c.