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

ASCOT Fusion Source Integrator AFSI. More...

#include <string.h>
#include <math.h>
#include <hdf5_hl.h>
#include "ascot5.h"
#include "print.h"
#include "gitver.h"
#include "consts.h"
#include "random.h"
#include "simulate.h"
#include "boschhale.h"
#include "diag/dist_5D.h"
#include "hdf5_interface.h"
#include "hdf5io/hdf5_helpers.h"
#include "hdf5io/hdf5_dist.h"
#include "afsi.h"

Go to the source code of this file.

Functions

void afsi_sample_reactant_momenta (afsi_data *react1, afsi_data *react2, real m1, real m2, int n, int iR, int iphi, int iz, real *ppara1, real *pperp1, real *ppara2, real *pperp2)
 Sample velocities from reactant distributions.
 
void afsi_compute_product_momenta (int i, real m1, real m2, real mprod1, real mprod2, real Q, real *ppara1, real *pperp1, real *ppara2, real *pperp2, real *vcom2, real *pparaprod1, real *pperpprod1, real *pparaprod2, real *pperpprod2)
 Compute momenta of reaction products.
 
void afsi_sample_5D (dist_5D_data *dist, int n, int iR, int iphi, int iz, real *ppara, real *pperp)
 Sample ppara and pperp from a 5D distribution.
 
void afsi_sample_thermal (afsi_thermal_data *data, real mass, int n, int iR, int iphi, int iz, real *ppara, real *pperp)
 Sample ppara and pperp from a thermal (Maxwellian) population.
 
real afsi_get_density (afsi_data *dist, int iR, int iphi, int iz)
 Get particle density.
 
real afsi_get_volume (afsi_data *dist, int iR)
 Get physical volume of a distribution cell.
 
void afsi_run (sim_offload_data *sim, Reaction reaction, int n, afsi_data *react1, afsi_data *react2, real mult, dist_5D_offload_data *prod1_offload_data, dist_5D_offload_data *prod2_offload_data, real *prod1_offload_array, real *prod2_offload_array)
 Calculate fusion source from two arbitrary ion distributions.
 
void afsi_test_dist (dist_5D_data *dist1)
 Test distribution.
 
void afsi_test_thermal ()
 Test thermal source.
 

Variables

random_data rdata
 

Detailed Description

ASCOT Fusion Source Integrator AFSI.

Definition in file afsi.c.

Function Documentation

◆ afsi_sample_reactant_momenta()

void afsi_sample_reactant_momenta ( afsi_data * react1,
afsi_data * react2,
real m1,
real m2,
int n,
int iR,
int iphi,
int iz,
real * ppara1,
real * pperp1,
real * ppara2,
real * pperp2 )

Sample velocities from reactant distributions.

Parameters
react1reactant 1 distribution data.
react2reactant 2 distribution data.
m1mass of reactant 1 [kg].
m2mass of reactant 2 [kg].
nnumber of samples.
iRR index of the distribution cell where sampling is done.
iphiphi index of the distribution cell where sampling is done.
izz index of the distribution cell where sampling is done.
ppara1array where the parallel momentum of react1 will be stored
pperp1array where the perpendicular momentum of react1 will be stored
ppara2array where the parallel momentum of react2 will be stored
pperp2array where the perpendicular momentum of react2 will be stored

Definition at line 278 of file afsi.c.

◆ afsi_compute_product_momenta()

void afsi_compute_product_momenta ( int i,
real m1,
real m2,
real mprod1,
real mprod2,
real Q,
real * ppara1,
real * pperp1,
real * ppara2,
real * pperp2,
real * vcom2,
real * pparaprod1,
real * pperpprod1,
real * pparaprod2,
real * pperpprod2 )

Compute momenta of reaction products.

Parameters
imarker index on input velocity and output momentum arrays.
m1mass of reactant 1 [kg].
m2mass of reactant 2 [kg].
mprod1mass of product 1 [kg].
mprod2mass of product 2 [kg].
Qenergy released in the reaction [eV].
ppara1the parallel momentum of react1
pperp1the perpendicular momentum of react1
ppara2the parallel momentum of react2
pperp2the perpendicular momentum of react2
vcom2pointer for storing relative velocity of i'th reactants
pparaprod1array where parallel momentum of product 1 is stored.
pperpprod1array where perpendicular momentum of product 1 is stored.
pparaprod2array where parallel momentum of product 2 is stored.
pperpprod2array where perpendicular momentum of product 2 is stored.

Definition at line 318 of file afsi.c.

◆ afsi_sample_5D()

void afsi_sample_5D ( dist_5D_data * dist,
int n,
int iR,
int iphi,
int iz,
real * ppara,
real * pperp )

Sample ppara and pperp from a 5D distribution.

Parameters
distpointer to the distribution data.
nnumber of values to be sampled.
iRR index where sampling is done.
iphiphi index where sampling is done.
izz index where sampling is done.
pparapointer to array where sampled parallel momenta are stored.
pperppointer to array where sampled perpedicular momenta are stored.

Definition at line 392 of file afsi.c.

◆ afsi_sample_thermal()

void afsi_sample_thermal ( afsi_thermal_data * data,
real mass,
int n,
int iR,
int iphi,
int iz,
real * ppara,
real * pperp )

Sample ppara and pperp from a thermal (Maxwellian) population.

Sampling from Maxwellian distribution is done using Eq. (7) in "Efficient Algorithm for Generating Maxwell Random Variables", N. Mohamed, DOI 10.1007/s10955-011-0364-y

Parameters
datapointer to the thermal data.
massmass of the particle species.
nnumber of values to be sampled.
iRR index where sampling is done.
iphiphi index where sampling is done.
izz index where sampling is done.
pparapointer to array where sampled parallel momenta are stored.
pperppointer to array where sampled perpedicular momenta are stored.

Definition at line 451 of file afsi.c.

◆ afsi_get_density()

real afsi_get_density ( afsi_data * dist,
int iR,
int iphi,
int iz )

Get particle density.

Parameters
distpointer to afsi data.
iRR index at which density is queried.
iphiphi index at which density is queried.
izz index at which density is queried.
Returns
density [m^-3] or zero if type was unknown.

Definition at line 479 of file afsi.c.

◆ afsi_get_volume()

real afsi_get_volume ( afsi_data * dist,
int iR )

Get physical volume of a distribution cell.

Parameters
distdistribution.
iRradial index of the cell.
Returns
cell volume [m^3].

Definition at line 514 of file afsi.c.

◆ afsi_run()

void afsi_run ( sim_offload_data * sim,
Reaction reaction,
int n,
afsi_data * react1,
afsi_data * react2,
real mult,
dist_5D_offload_data * prod1_offload_data,
dist_5D_offload_data * prod2_offload_data,
real * prod1_offload_array,
real * prod2_offload_array )

Calculate fusion source from two arbitrary ion distributions.

Inputs and outputs are expected to have same physical (R, phi, z) dimensions.

Parameters
simpointer to simulation offload data
reactionfusion reaction type, see the description
nnumber of Monte Carlo samples to be used
react1reactant 1 distribution data
react2reactant 2 distribution data
multfactor by which the output is scaled
prod1_offload_datadistribution data for product 1 output
prod2_offload_datadistribution data for product 2 output
prod1_offload_arrayarray where product 1 distribution is stored
prod2_offload_arrayarray where product 2 distribution is stored

Definition at line 55 of file afsi.c.

◆ afsi_test_dist()

void afsi_test_dist ( dist_5D_data * dist1)

Test distribution.

Parameters
dist1distribution to be tested.

Definition at line 538 of file afsi.c.

◆ afsi_test_thermal()

void afsi_test_thermal ( )

Test thermal source.

Definition at line 561 of file afsi.c.

Variable Documentation

◆ rdata

random_data rdata

Random number generator used by AFSI

Definition at line 22 of file afsi.c.