File reaction.hxx#

Defines

REACTION_H#

Typedefs

typedef Options &(*OPTYPE)(Options&, Field3D)#
struct ReactionBase : public Component#
#include <reaction.hxx>

Temporary struct to use as a base class for all reactions components. Ensures reaction strings are paired up correctly with component classes. Can be removed when all reaction classes have been refactored to inherit from Reaction.

Subclassed by HydrogenChargeExchange, OpenADAS, OpenADASChargeExchange, Reaction, SOLKITHydrogenChargeExchange

Public Functions

inline ReactionBase()#

Public Static Functions

static inline int get_instance_num()#

Protected Attributes

int inst_num#
struct Reaction : public ReactionBase#
#include <reaction.hxx>

Struct intended to act as a base for all reactions.

Subclassed by AmjuelReaction

Public Functions

Reaction(std::string name, Options &alloptions)#
virtual void transform(Options &state) final override#

Add density, momentum and energy sources that apply to all reactions (e.g. those driven by species population changes), then call transform_additional() to allow subclasses to add other terms.

Parameters:

state

virtual void outputVars(Options &state) final override#

Copy all diagnostics into the output, setting the appropriate metadata at the same time.

Parameters:

state

Protected Functions

void add_diagnostic(const std::string &sp_name, const std::string &diag_name, const std::string &long_diag_name, ReactionDiagnosticType type, const std::string &data_source, DiagnosticTransformerType transformer = negate, const std::string &standard_name = "")#

Add a new entry in this Reaction’s diagnostic (multi)map. The (non-unique) Key is < sp_name, type >

Add a new diagnostic.

Parameters:
  • sp_name – name of the species with which to associate the diagnostic

  • diag_name – name of the diagnostic (also the key used when updating it in the state object)

  • long_diag_name – doc string to use as the diagnostic description

  • type – an enum that associates the diagnostic with density, momentum or energy sources

  • data_source – name of the associated data source (e.g. ‘Amjuel H.x.y’)

  • transformer – optional transformer function to call on field data when the diagnostic is updated

  • standard_name – optional ‘standard_name’ to use in the output file

  • sp_name – Species with which the diagnostic will be associated

  • diag_name – Label used in the output (and to store it temporarily in the state)

  • description – Description to use as the ‘long_name’ output attribute

  • type – enum identifying the diagnostic type, also used to determine source name

  • data_source – Name to use as the ‘source’ output attribute

  • transformer – Optional transformer function to use when modifying the diagnostic (default is ‘negate’, i.e. the diagnostic has the opposite sign to the source)

  • standard_name – Optional string to use as the ‘standard_name’ output attribute

void calc_weightsums(Options &state)#

Calculate weightsums used in transform(). Can’t be done at construction because the species masses may not be set.

Compute weight sums, if it hasn’t been done already. Energy : sum of (+ve pop change) participation factors Momentum : sum of (+ve pop change) participation factors, weighted by mass.

Parameters:
  • state – Current sim state

  • state – current simulation state

inline virtual BoutReal eval_sigma_v_E([[maybe_unused]] BoutReal T, [[maybe_unused]] BoutReal n)#

Evaluate <sigma . v . E> at a particular density and temperature (Subclasses MAY define)

Parameters:
  • T – a temperature

  • n – a density

Returns:

BoutReal the electron energy loss rate

virtual BoutReal eval_sigma_v(BoutReal T, BoutReal n) = 0#

Evaluate <sigma.v> at a particular density and temperature (Subclasses MUST define)

Parameters:
  • T – a temperature

  • n – a density

Returns:

BoutReal <sigma.v>(n,T)

inline virtual void transform_additional([[maybe_unused]] Options &state, [[maybe_unused]] Field3D &reaction_rate)#

A hook with which subclasses can perform additional transform tasks, over and above those implemented in Reaction::transform. (Subclasses MAY define)

Parameters:
  • state

  • reaction_rate

template<OPTYPE operation>
inline void update_source(Options &state, const std::string &sp_name, ReactionDiagnosticType type, Field3D &fld)#

Update both a species source term and the corresponding diagnostics (if any exist and if diagnostics are enabled)

Template Parameters:

operation – function to call on the state to update the source term and the diagnostic. Either Component::add, Component::subtract or Component::set

Parameters:
  • state – the state to update

  • sp_name – the species to update

  • type – the type of source/diagnostic to update

  • fld – the field used in the update

Protected Attributes

std::unique_ptr<ReactionParser> parser#

Reaction string parser.

BoutReal Tnorm#

Normalisations, extracted from input options.

BoutReal Nnorm#
BoutReal FreqNorm#
BoutReal rate_multiplier#

Rate multipliers, extracted from input options.

BoutReal radiation_multiplier#
bool diagnose#

Output diagnostics?

std::multimap<std::pair<std::string, ReactionDiagnosticType>, ReactionDiagnostic> diagnostics#

map of (species_name,diagnostic_type)->diagnostic_object

bool includes_sigma_v_e = true#

Whether or not reaction data includes <sigma v E> (Default to true as a reminder to override eval_sigma_v_E)

Private Functions

void zero_diagnostics(Options &state)#

Reset the temporary values of the diagnostics stored in the state.

Parameters:

state

Private Members

BoutReal energy_weightsum#

Sum of weights to use when calculating energy source due to population change.

BoutReal momentum_weightsum#

Sum of weights to use when calculating momentum source due to population change.

const std::string name#

Label to use for this reaction in a state / Options object.

std::map<std::string, BoutReal> pfactors#

Participation factors of all species.