File rate_helper.hxx#

Defines

RATE_HELPER_H#
namespace hermes

Typedefs

using OneDRateFunc = std::function<BoutReal(BoutReal, BoutReal)>#

Signatures for different rate calculations. N.B. one extra arg required for the mass action factor.

using TwoDRateFunc = std::function<BoutReal(BoutReal, BoutReal, BoutReal)>#
using RateFuncVariant = std::variant<OneDRateFunc, TwoDRateFunc>#

Variables

template<RateParamsTypes>
constexpr bool dependent_false = false#
static const std::string Teff_name = "Teff"#
struct CellData#
#include <rate_helper.hxx>

Struct to hold pre-averaged data for each cell.

Public Functions

inline CellData()#
inline CellData(BoutReal c, BoutReal l, BoutReal r)#

Public Members

BoutReal centre#
BoutReal left#
BoutReal right#
struct RateData#
#include <rate_helper.hxx>

Struct to hold reaction rate and collision frequency data.

Public Functions

inline const Field3D &coll_freq(const std::string &reactant_name) const#

Extract collision frequency for a reactant.

Parameters:

reactant_name – Name of the reactant

Throws:

BoutException – if reactant name not found

Returns:

const Field3D& The collision frequency field

Public Members

Field3D rate#

The reaction rate Field3D.

std::map<std::string, Field3D> collision_frequencies#

Collision frequencies keyed by reactant name.

template<RateParamsTypes RateParamsType>
struct RateHelper#
#include <rate_helper.hxx>

Struct to encapsulate reaction rate and collision frequency calculations for a number of different parameterisations.

Template Parameters:

RateParamsType – type identifying the reaction rate function parameters.

Public Functions

inline RateHelper(const GuardedOptions state, const Options &units, const std::vector<std::string> &reactant_names, const Region<Ind3D> region)#

Construct a new RateHelper, extracting and storing some fields from the state for use later in the rate calculation.

Parameters:
  • state

  • reactant_names – vector of reactant names

  • rate_calc_func – function with which to compute the rate from the mass action factor, n_e and T_e

  • region – the region in which to calculate the rate

inline RateData calc_rates(const RateFuncVariant &rate_calc_func_variant, bool do_averaging = true)#

Compute the cell-averaged reaction rate and collision frequencies, accounting for reactant densities.

Parameters:
  • rate_calc_func_variant – a function that calculates the rate. Typed as std::variant to easily switch between different rate parameterisations.

  • do_averaging – whether to perform cell averaging

Returns:

RateData containing the calculated rates and collision frequencies

Private Functions

inline void add_rate_param(const std::string &field_lbl, const Field3D &fld)#

Store a field associated with a rate parameter.

Parameters:
  • field_lbl – Label/tag associated with the field

  • fld – reference to the field object

inline void calc_Teff(const GuardedOptions state, const Options &units, const std::vector<std::string> &reactant_names, Field3D &Teff)#

Compute the effective temperature (in eV) of heavy reactants.

Used to scale different isotope masses and finite neutral particle temperatures by using the effective temperature (Amjuel p43) T_eff = (M/M_1)T_1 + (M/M_2)T_2

Todo:

read clamp values from json

Parameters:
  • state[in]

  • reactant_names[in] names of all reactant species

  • Teff[inout] Field3D object in which to store the result

inline CellData compute_collision_freq_density(Ind3D i, bool do_averaging, const std::string &reactant_name, const CellData &mass_actions)#

Compute the density product to use in a collision frequency by dividing the total mass action factor by a specific reactant’s density.

Parameters:
  • i – central index

  • do_averaging – whether to compute left and right values

  • reactant_name – name of the reactant to exclude from the product

  • mass_actions – pre-computed mass action factor

Returns:

CellData struct containing centre, left, and right values

inline CellData compute_mass_actions(Ind3D i, bool do_averaging)#

Compute the product of all reactant densities at centre, left, and right positions.

Parameters:
  • i – central index

  • do_averaging – whether to compute left and right values

Returns:

CellData struct containing centre, left, and right mass action factors

inline CellData compute_rate_param(const std::string &name, Ind3D i, bool do_averaging)#

Extract the value of a rate parameter at centre, left, and right positions.

Parameters:
  • name – name of the parameter (label in state[“species”])

  • i – central index

  • do_averaging – whether to compute left and right values

Returns:

CellData struct containing centre, left, and right values

Private Members

size_t num_reactants#

Size of reactant_names, cached to avoid repeated .size() calls.

RateFuncVariant rate_calc_func#

Function to calculate reaction rate as a function of n_e, T_e.

std::map<std::string, const Field3D*> reactant_densities#

Reactant densities, keyed by species name (stored as pointers to avoid copying)

std::vector<std::string> reactant_names#

Reactant names in the order provided to the constructor.

const Region<Ind3D> region#

region in which to calculate the rate

std::map<std::string, const Field3D*> rate_params#
Field3D Teff_storage#