ASCOT5
Loading...
Searching...
No Matches
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 "physlib.h"

Go to the source code of this file.

Functions

void afsi_compute_product_momenta_2d (int i, real m1, real m2, real mprod1, real mprod2, real Q, int prodmomspace, real *ppara1, real *pperp1, real *ppara2, real *pperp2, real *vcom2, real *prod1_p1, real *prod1_p2, real *prod2_p1, real *prod2_p2)
 Compute momenta of reaction products.
 
void afsi_sample_reactant_momenta_2d (sim_data *sim, afsi_data *afsi, real mass1, real mass2, real vol, int nsample, size_t i0, size_t i1, size_t i2, real r, real phi, real z, real time, real rho, real *density1, real *ppara1, real *pperp1, real *density2, real *ppara2, real *pperp2)
 Sample velocities from reactant distributions.
 
void afsi_sample_beam_2d (histogram *hist, real mass, real vol, int nsample, size_t i0, size_t i1, size_t i2, real *density, real *ppara, real *pperp)
 Sample ppara and pperp from a 5D distribution.
 
void afsi_sample_thermal_2d (sim_data *sim, int ispecies, real mass, int nsample, real r, real phi, real z, real time, real rho, real *density, real *ppara, real *pperp)
 Sample ppara and pperp from a thermal (Maxwellian) population.
 
void afsi_run (sim_data *sim, afsi_data *afsi, int n, histogram *prod1, histogram *prod2)
 Calculate fusion source from two arbitrary ion distributions.
 

Variables

random_data rdata
 

Detailed Description

ASCOT Fusion Source Integrator AFSI.

Definition in file afsi.c.

Function Documentation

◆ afsi_compute_product_momenta_2d()

void afsi_compute_product_momenta_2d ( int i,
real m1,
real m2,
real mprod1,
real mprod2,
real Q,
int prodmomspace,
real * ppara1,
real * pperp1,
real * ppara2,
real * pperp2,
real * vcom2,
real * prod1_p1,
real * prod1_p2,
real * prod2_p1,
real * prod2_p2 )

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 308 of file afsi.c.

◆ afsi_sample_reactant_momenta_2d()

void afsi_sample_reactant_momenta_2d ( sim_data * sim,
afsi_data * afsi,
real mass1,
real mass2,
real vol,
int nsample,
size_t i0,
size_t i1,
size_t i2,
real r,
real phi,
real z,
real time,
real rho,
real * density1,
real * ppara1,
real * pperp1,
real * density2,
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 397 of file afsi.c.

◆ afsi_sample_beam_2d()

void afsi_sample_beam_2d ( histogram * hist,
real mass,
real vol,
int nsample,
size_t i0,
size_t i1,
size_t i2,
real * density,
real * ppara,
real * pperp )

Sample ppara and pperp from a 5D distribution.

Parameters
distpointer to the distribution data.
nsamplenumber of values to be sampled.
spatial_indexspatial 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 430 of file afsi.c.

◆ afsi_sample_thermal_2d()

void afsi_sample_thermal_2d ( sim_data * sim,
int ispecies,
real mass,
int nsample,
real r,
real phi,
real z,
real time,
real rho,
real * density,
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.
nsamplenumber of values to be sampled.
spatial_indexspatial 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 516 of file afsi.c.

◆ afsi_run()

void afsi_run ( sim_data * sim,
afsi_data * afsi,
int n,
histogram * prod1,
histogram * prod2 )

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 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_datadistribution data for product 1 output
prod2_datadistribution data for product 2 output

Definition at line 60 of file afsi.c.

Variable Documentation

◆ rdata

random_data rdata

Random number generator used by AFSI

Definition at line 26 of file afsi.c.