Graph Framework
Loading...
Searching...
No Matches
particle_in_cell.hpp File Reference

Utilities needed for a particle in cell code. More...

#include <numbers>
#include <bit>
#include "piecewise.hpp"
#include "workflow.hpp"
#include "random.hpp"
#include "logical.hpp"

Go to the source code of this file.

Classes

class  graph::apply_u_node< T >
 U Collision node. More...
 
class  graph::apply_xi_node< T >
 Xi Collision node. More...
 
class  pic::characteristics< T >
 Characteristic factors. More...
 
class  pic::parameters< T >
 Parameter Class. More...
 
class  pic::ion< T >
 ion class. More...
 
class  pic::mesh< T >
 Mesh class. More...
 

Namespaces

namespace  graph
 Name space for graph nodes.
 

Typedefs

template<std::floating_point T>
using graph::shared_apply_u = std::shared_ptr< apply_u_node< T > >
 Convenience type alias for shared sqrt nodes.
 
template<std::floating_point T>
using graph::shared_apply_xi = std::shared_ptr< apply_xi_node< T > >
 Convenience type alias for shared sqrt nodes.
 

Enumerations

enum  pic::model { pic::hinton , pic::chen }
 Model for coulomb scattering operators. More...
 

Functions

template<std::floating_point T>
shared_leaf< T > graph::apply_u (shared_leaf< T > x, shared_leaf< T > i, shared_leaf< T > rand, shared_leaf< T > mof, shared_leaf< T > tbnu_e_dt, shared_leaf< T > A, shared_leaf< T > B)
 Build apply_u node.
 
template<std::floating_point T>
shared_apply_u< T > graph::apply_u_cast (shared_leaf< T > x)
 Cast to a apply_u node.
 
template<std::floating_point T>
shared_leaf< T > graph::apply_xi (shared_leaf< T > x, shared_leaf< T > i, shared_leaf< T > rand, shared_leaf< T > nu_D_dt)
 Build apply_xi node.
 
template<std::floating_point T>
shared_apply_xi< T > graph::apply_xi_cast (shared_leaf< T > x)
 Cast to a apply_u node.
 
template<std::floating_point T>
std::array< graph::shared_leaf< T >, 3 > pic::cartesian_to_sphereical (graph::shared_leaf< T > x, graph::shared_leaf< T > y)
 Convert from cartesian to sphereical coordinates.
 
template<std::floating_point T>
std::array< graph::shared_leaf< T >, 2 > pic::sphereical_to_cartesian (graph::shared_leaf< T > w, graph::shared_leaf< T > xi, graph::shared_leaf< T > sinphi)
 Convert from sphereical to cartesian coordinates.
 
template<std::floating_point T, model M>
graph::shared_leaf< T > pic::build_colision_rate (graph::shared_leaf< T > xab, const T mass_a, const T mass_b, graph::shared_leaf< T > gb, graph::shared_leaf< T > nuab0, graph::shared_leaf< T > erfp_xab)
 Calculate ν_{E}.
 
template<std::floating_point T, model M>
std::array< graph::shared_leaf< T >, 2 > pic::build_ion_ion_collision (const ion< T > &ion_a, const ion< T > &ion_b, const mesh< T > &mesh, const characteristics< T > &norms, const parameters< T > &params, graph::shared_leaf< T > total_density, graph::shared_leaf< T > total_flux, const graph::shared_random_state< T > state)
 Build ion ion collision.
 
template<std::floating_point T, model M>
std::array< graph::shared_leaf< T >, 2 > pic::build_ion_electron_collision (const ion< T > &ion_a, const mesh< T > &mesh, const characteristics< T > &norms, const parameters< T > &params, graph::shared_leaf< T > total_density, graph::shared_leaf< T > total_flux, const graph::shared_random_state< T > state)
 Build ion electron collision.
 
template<std::floating_point T, model M>
std::array< graph::shared_leaf< T >, 2 > pic::build_common_collision (const ion< T > &ion_a, const characteristics< T > &norms, graph::shared_leaf< T > uxb, graph::shared_leaf< T > tb, graph::shared_leaf< T > nb, const T mass_b, const uint8_t zb2, const T dt, const graph::shared_random_state< T > state)
 Build common collisions graphs for all species.
 
template<std::floating_point T>
std::array< graph::shared_leaf< T >, 3 > pic::build_initialization (const pic::ion< T > &ion, const mesh< T > &mesh, const characteristics< T > &norms, const parameters< T > &params, const graph::shared_random_state< T > state)
 Build initialization.
 
template<std::floating_point T>
std::array< graph::shared_leaf< T >, 3 > pic::build_reinjection (const ion< T > &ion, const mesh< T > &mesh, const characteristics< T > &norms, const parameters< T > &params, const graph::shared_random_state< T > state)
 Build reinjected expressions.
 
template<std::floating_point T>
graph::shared_leaf< T > pic::build_magnetic_field (graph::shared_leaf< T > x, const characteristics< T > &norms, const parameters< T > &params)
 Build a magnetic field.
 
template<std::floating_point T, size_t I = 0, mesh< T >::offset O = mesh<T>::center>
graph::shared_leaf< T > pic::build_density (graph::shared_leaf< T > x, const ion< T > &ion, const mesh< T > &mesh, const characteristics< T > &norms, const parameters< T > &params)
 Build expressions for the density.
 
template<std::floating_point T, size_t I = 0, mesh< T >::offset O = mesh<T>::center>
graph::shared_leaf< T > pic::build_density_gradient (graph::shared_leaf< T > x, const ion< T > &ion, const mesh< T > &mesh, const characteristics< T > &norms, const parameters< T > &params)
 Build expressions for the density gradient.
 
template<std::floating_point T>
graph::shared_leaf< T > pic::build_electron_temperature (graph::shared_leaf< T > x, const characteristics< T > &norms)
 Build Expressions for Electron temperature.
 
template<std::floating_point T, mesh< T >::offset O = mesh<T>::center>
graph::shared_leaf< T > pic::build_electric_efield (graph::shared_leaf< T > x, const ion< T > &ion, const mesh< T > &mesh, const characteristics< T > &norms, const parameters< T > &params)
 Build expressions for the electric field.
 
template<std::floating_point T>
graph::shared_leaf< T > pic::build_interpolate_efield (graph::shared_leaf< T > x, const ion< T > &ion, const mesh< T > &mesh, const characteristics< T > &norms, const parameters< T > &params)
 Build interpolation expression.
 
template<std::floating_point T>
std::array< graph::shared_leaf< T >, 3 > pic::build_F_expressions (const std::array< graph::shared_leaf< T >, 3 > z, const ion< T > &ion, const mesh< T > &mesh, const characteristics< T > &norms, const parameters< T > &params)
 Build F expressions.
 
template<std::floating_point T>
std::array< graph::shared_leaf< T >, 3 > pic::build_rk4_step (const ion< T > &ion, const mesh< T > &mesh, const characteristics< T > &norms, const parameters< T > &params)
 Build Runga Kutta step update.
 

Variables

template<std::floating_point T>
constexpr T pic::c = static_cast<T> (299792458.0)
 Speed of light m/s.
 
template<std::floating_point T>
constexpr T pic::epsilon0 = static_cast<T> (8.8541878188E-12)
 Vacuum permitivity F/m.
 
template<std::floating_point T>
constexpr T pic::q = static_cast<T> (1.602176634E-19)
 Fundamental charge coulombs.
 
template<std::floating_point T>
constexpr T pic::m_hydrogen = static_cast<T> (1.67362192595E-27)
 Hydrogen mass kg.
 
template<std::floating_point T>
constexpr T pic::m_atomic = static_cast<T> (1.66053906892E-27)
 Atomic mass.
 
template<std::floating_point T>
constexpr T pic::m_electron = static_cast<T> (9.1093837139E-31)
 Electron mass kg.
 
template<std::floating_point T>
constexpr T pic::kb = static_cast<T> (1.380649E-23)
 Boltzman constant.
 

Detailed Description

Utilities needed for a particle in cell code.

Defines graphs for use in Particle In Cell (PIC) codes.

Enumeration Type Documentation

◆ model

enum pic::model

Model for coulomb scattering operators.

Enumerator
hinton 

From Hinton 1983 EQ 92 and T.S. Chen 1988 EQ 50.

chen 

From T.S. Chen 1988 Report EQ 57 commonly used for NBI.

Function Documentation

◆ build_colision_rate()

template<std::floating_point T, model M>
graph::shared_leaf< T > pic::build_colision_rate ( graph::shared_leaf< T >  xab,
const T  mass_a,
const T  mass_b,
graph::shared_leaf< T >  gb,
graph::shared_leaf< T >  nuab0,
graph::shared_leaf< T >  erfp_xab 
)

Calculate ν_{E}.

Template Parameters
TBase type of the calculation.
MThe pic::model of the calculation.
Parameters
[in]xab
[in]mass_aMass of particle a.
[in]mass_bMass of particle b.
[in]gb
[in]nuab0
[in]erfp_xabDerivaive of error function.
Returns
ν_{E}.

◆ build_common_collision()

template<std::floating_point T, model M>
std::array< graph::shared_leaf< T >, 2 > pic::build_common_collision ( const ion< T > &  ion_a,
const characteristics< T > &  norms,
graph::shared_leaf< T >  uxb,
graph::shared_leaf< T >  tb,
graph::shared_leaf< T >  nb,
const T  mass_b,
const uint8_t  zb2,
const T  dt,
const graph::shared_random_state< T >  state 
)

Build common collisions graphs for all species.

Template Parameters
TBase type of the calculation.
MThe pic::model of the calculation.
Parameters
[in]ion_aIons for species a.
[in]normsA pic::characteristics object.
[in]uxb
[in]tbTemperature of species b.
[in]nbDensity of species b.
[in]mass_bMass of species b.
[in]zb2Z effective squared.
[in]dtTime step.
[in]stateRandom state node.

◆ build_density()

template<std::floating_point T, size_t I = 0, mesh< T >::offset O = mesh<T>::center>
graph::shared_leaf< T > pic::build_density ( graph::shared_leaf< T >  x,
const ion< T > &  ion,
const mesh< T > &  mesh,
const characteristics< T > &  norms,
const parameters< T > &  params 
)

Build expressions for the density.

Template Parameters
TBase type of the calculation.
IMesh index.
OMesh offset.
Parameters
[in]xThe x position.
[in]ionA pic::ion object.
[in]meshA pic::mesh object.
[in]normsA pic::characteristics object.
[in]paramsA pic::parameters object.
Returns
The expression for the density.

◆ build_density_gradient()

template<std::floating_point T, size_t I = 0, mesh< T >::offset O = mesh<T>::center>
graph::shared_leaf< T > pic::build_density_gradient ( graph::shared_leaf< T >  x,
const ion< T > &  ion,
const mesh< T > &  mesh,
const characteristics< T > &  norms,
const parameters< T > &  params 
)

Build expressions for the density gradient.

Template Parameters
TBase type of the calculation.
IMesh index.
OMesh offset.
Parameters
[in]xThe x position.
[in]ionA pic::ion object.
[in]meshA pic::mesh object.
[in]normsA pic::characteristics object.
[in]paramsA pic::parameters object.
Returns
The expression for the density.

◆ build_electric_efield()

template<std::floating_point T, mesh< T >::offset O = mesh<T>::center>
graph::shared_leaf< T > pic::build_electric_efield ( graph::shared_leaf< T >  x,
const ion< T > &  ion,
const mesh< T > &  mesh,
const characteristics< T > &  norms,
const parameters< T > &  params 
)

Build expressions for the electric field.

Template Parameters
TBase type of the calculation.
OMesh offset.
Parameters
[in]xThe x position.
[in]ionA pic::ion object.
[in]meshA pic::mesh object.
[in]normsA pic::characteristics object.
[in]paramsA pic::parameters object.

◆ build_electron_temperature()

template<std::floating_point T>
graph::shared_leaf< T > pic::build_electron_temperature ( graph::shared_leaf< T >  x,
const characteristics< T > &  norms 
)

Build Expressions for Electron temperature.

Template Parameters
TBase type of the calculation.
Parameters
[in]xThe x position.
[in]normsA pic::characteristics object.
Returns
The expressions for the electron temperature.

◆ build_F_expressions()

template<std::floating_point T>
std::array< graph::shared_leaf< T >, 3 > pic::build_F_expressions ( const std::array< graph::shared_leaf< T >, 3 >  z,
const ion< T > &  ion,
const mesh< T > &  mesh,
const characteristics< T > &  norms,
const parameters< T > &  params 
)

Build F expressions.

Template Parameters
TBase type of the calculation.
Parameters
[in]zRunga Kutta substep.
[in]ionA pic::ion object.
[in]meshA pic::mesh object.
[in]normsA pic::characteristics object.
[in]paramsA pic::parameters object.
Returns
the Forces on the particles.

◆ build_initialization()

template<std::floating_point T>
std::array< graph::shared_leaf< T >, 3 > pic::build_initialization ( const pic::ion< T > &  ion,
const mesh< T > &  mesh,
const characteristics< T > &  norms,
const parameters< T > &  params,
const graph::shared_random_state< T >  state 
)

Build initialization.

Template Parameters
TBase type of the calculation.
Parameters
[in]ionA pic::ion object.
[in]meshA pic::mesh object.
[in]normsA pic::characteristics object.
[in]paramsA pic::parameters object.
[in]stateRandom state node.
Returns
Initialized normalized values for x, v||, and v⟂

◆ build_interpolate_efield()

template<std::floating_point T>
graph::shared_leaf< T > pic::build_interpolate_efield ( graph::shared_leaf< T >  x,
const ion< T > &  ion,
const mesh< T > &  mesh,
const characteristics< T > &  norms,
const parameters< T > &  params 
)

Build interpolation expression.

Template Parameters
TBase type of the calculation.
Parameters
[in]xThe x position.
[in]ionA pic::ion object.
[in]meshA pic::mesh object.
[in]normsA pic::characteristics object.
[in]paramsA pic::parameters object.
Returns
The interpolated mesh quantity.

◆ build_ion_electron_collision()

template<std::floating_point T, model M>
std::array< graph::shared_leaf< T >, 2 > pic::build_ion_electron_collision ( const ion< T > &  ion_a,
const mesh< T > &  mesh,
const characteristics< T > &  norms,
const parameters< T > &  params,
graph::shared_leaf< T >  total_density,
graph::shared_leaf< T >  total_flux,
const graph::shared_random_state< T >  state 
)

Build ion electron collision.

Template Parameters
TBase type of the calculation.
MThe pic::model of the calculation.
Parameters
[in]ion_aIons for species a.
[in]meshA pic::mesh object.
[in]normsA pic::characteristics object.
[in]paramsA pic::parameters object.
[in]total_densityAccumulated density.
[in]total_fluxAccumulated total_flux.
[in]stateRandom state node.

◆ build_ion_ion_collision()

template<std::floating_point T, model M>
std::array< graph::shared_leaf< T >, 2 > pic::build_ion_ion_collision ( const ion< T > &  ion_a,
const ion< T > &  ion_b,
const mesh< T > &  mesh,
const characteristics< T > &  norms,
const parameters< T > &  params,
graph::shared_leaf< T >  total_density,
graph::shared_leaf< T >  total_flux,
const graph::shared_random_state< T >  state 
)

Build ion ion collision.

Template Parameters
TBase type of the calculation.
MThe pic::model of the calculation.
Parameters
[in]ion_aIons for species a.
[in]ion_bIons for species b.
[in]meshA pic::mesh object.
[in]normsA pic::characteristics object.
[in]paramsA pic::parameters object.
[in,out]total_densityAccumulated density.
[in,out]total_fluxAccumulated total_flux.
[in]stateRandom state node.

◆ build_magnetic_field()

template<std::floating_point T>
graph::shared_leaf< T > pic::build_magnetic_field ( graph::shared_leaf< T >  x,
const characteristics< T > &  norms,
const parameters< T > &  params 
)

Build a magnetic field.

Template Parameters
TBase type of the calculation.
Parameters
[in]xThe x position.
[in]normsA pic::characteristics object.
[in]paramsA pic::parameters object.
Returns
The expression for the magnetic field.

◆ build_reinjection()

template<std::floating_point T>
std::array< graph::shared_leaf< T >, 3 > pic::build_reinjection ( const ion< T > &  ion,
const mesh< T > &  mesh,
const characteristics< T > &  norms,
const parameters< T > &  params,
const graph::shared_random_state< T >  state 
)

Build reinjected expressions.

If the particles leave the mesh, reinitalize them using the same initialization.

Template Parameters
TBase type of the calculation.
Parameters
[in]ionA pic::ion object.
[in]meshA pic::mesh object.
[in]normsA pic::characteristics object.
[in]paramsA pic::parameters object.
[in]stateRandom state node.
Returns
Reinjected values for x, v||, and v⟂

◆ build_rk4_step()

template<std::floating_point T>
std::array< graph::shared_leaf< T >, 3 > pic::build_rk4_step ( const ion< T > &  ion,
const mesh< T > &  mesh,
const characteristics< T > &  norms,
const parameters< T > &  params 
)

Build Runga Kutta step update.

Template Parameters
TBase type of the calculation.
Parameters
[in]ionA pic::ion object.
[in]meshA pic::mesh object.
[in]normsA pic::characteristics object.
[in]paramsA pic::parameters object.
Returns
Step update expressions for x, v_para, and x_perp.

◆ cartesian_to_sphereical()

template<std::floating_point T>
std::array< graph::shared_leaf< T >, 3 > pic::cartesian_to_sphereical ( graph::shared_leaf< T >  x,
graph::shared_leaf< T >  y 
)

Convert from cartesian to sphereical coordinates.

Template Parameters
TBase type of the calculation.
Parameters
[in]x
[in]y
Returns
The coordinates as sphereical coordinates.

◆ sphereical_to_cartesian()

template<std::floating_point T>
std::array< graph::shared_leaf< T >, 2 > pic::sphereical_to_cartesian ( graph::shared_leaf< T >  w,
graph::shared_leaf< T >  xi,
graph::shared_leaf< T >  sinphi 
)

Convert from sphereical to cartesian coordinates.

Template Parameters
TBase type of the calculation.
Parameters
[in]w
[in]xi
[in]sinphi
Returns
The coordinates as cartesian coordinates.