File rate_helper.hxx#

Defines

RATE_HELPER_H#
namespace hermes

Typedefs

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

Signatures for different rate calculations.

using TwoDRateFunc = std::function<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 DataTriple#
#include <rate_helper.hxx>

Struct to hold values used in cell averaging.

Public Functions

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

Public Members

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

Public Functions

inline CellProps(size_t num_reactants)#

Public Members

DataTriple rate#
std::vector<DataTriple> densities#
std::vector<DataTriple> collision_freqs#
struct RateData#
#include <rate_helper.hxx>

Struct to hold final (possibly averaged) reaction rate and collision frequency fields that get returned by calc_rates()

Public Functions

inline RateData(const std::vector<std::string> &reactant_names)#
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::vector<Field3D> collision_frequencies#

Collision frequencies keyed by reactant name.

Private Members

std::map<std::string, size_t> reactant_indices#

Reactant indices 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

  • 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 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 void apply_density_factors(CellProps &cell_props, bool do_averaging = true)#

Multiply rates by all reactant densities, collision frequencies by all densities except the target species.

Parameters:
  • cell_props[inout] – temporary struct already containing rates, collision freqs, densities

  • do_averaging[in] – whether to compute left and right values for averaging

inline void collect_densities(Ind3D i, CellProps &cell_props, bool do_averaging)#
inline DataTriple compute_rate_param(std::size_t idx, 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.

std::vector<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::vector<const Field3D*> rate_params#
Field3D Teff_storage#