GridFire 0.0.1a
General Purpose Nuclear Network
|
Represents a single nuclear reaction from a specific data source. More...
#include <reaction.h>
Public Member Functions | |
virtual | ~Reaction ()=default |
Virtual destructor. | |
Reaction (const std::string_view id, const std::string_view peName, const int chapter, const std::vector< fourdst::atomic::Species > &reactants, const std::vector< fourdst::atomic::Species > &products, const double qValue, const std::string_view label, const RateCoefficientSet &sets, const bool reverse=false) | |
Constructs a Reaction object. | |
virtual double | calculate_rate (const double T9) const |
Calculates the reaction rate for a given temperature. | |
virtual CppAD::AD< double > | calculate_rate (const CppAD::AD< double > T9) const |
Calculates the reaction rate for a given temperature using CppAD types. | |
virtual std::string_view | peName () const |
Gets the reaction name in (projectile, ejectile) notation. | |
int | chapter () const |
Gets the REACLIB chapter number. | |
std::string_view | sourceLabel () const |
Gets the source label for the rate data. | |
const RateCoefficientSet & | rateCoefficients () const |
Gets the set of rate coefficients. | |
bool | contains (const fourdst::atomic::Species &species) const |
Checks if the reaction involves a given species as a reactant or product. | |
bool | contains_reactant (const fourdst::atomic::Species &species) const |
Checks if the reaction involves a given species as a reactant. | |
bool | contains_product (const fourdst::atomic::Species &species) const |
Checks if the reaction involves a given species as a product. | |
std::unordered_set< fourdst::atomic::Species > | all_species () const |
Gets a set of all unique species involved in the reaction. | |
std::unordered_set< fourdst::atomic::Species > | reactant_species () const |
Gets a set of all unique reactant species. | |
std::unordered_set< fourdst::atomic::Species > | product_species () const |
Gets a set of all unique product species. | |
size_t | num_species () const |
Gets the number of unique species involved in the reaction. | |
int | stoichiometry (const fourdst::atomic::Species &species) const |
Calculates the stoichiometric coefficient for a given species. | |
std::unordered_map< fourdst::atomic::Species, int > | stoichiometry () const |
Gets a map of all species to their stoichiometric coefficients. | |
std::string_view | id () const |
Gets the unique identifier of the reaction. | |
double | qValue () const |
Gets the Q-value of the reaction. | |
const std::vector< fourdst::atomic::Species > & | reactants () const |
Gets the vector of reactant species. | |
const std::vector< fourdst::atomic::Species > & | products () const |
Gets the vector of product species. | |
bool | is_reverse () const |
Checks if this is a reverse reaction rate. | |
double | excess_energy () const |
Calculates the excess energy from the mass difference of reactants and products. | |
bool | operator== (const Reaction &other) const |
Compares this reaction with another for equality based on their IDs. | |
bool | operator!= (const Reaction &other) const |
Compares this reaction with another for inequality. | |
uint64_t | hash (uint64_t seed=0) const |
Computes a hash for the reaction based on its ID. | |
Protected Attributes | |
quill::Logger * | m_logger = fourdst::logging::LogManager::getInstance().getLogger("log") |
std::string | m_id |
Unique identifier for the reaction (e.g., "h1+h1=>h2+e+nu"). | |
std::string | m_peName |
Name of the reaction in (projectile, ejectile) notation (e.g. "p(p,g)d"). | |
int | m_chapter |
Chapter number from the REACLIB database, defining the reaction structure. | |
double | m_qValue = 0.0 |
Q-value of the reaction in MeV. | |
std::vector< fourdst::atomic::Species > | m_reactants |
Reactants of the reaction. | |
std::vector< fourdst::atomic::Species > | m_products |
Products of the reaction. | |
std::string | m_sourceLabel |
Source label for the rate data (e.g., "wc12w", "st08"). | |
RateCoefficientSet | m_rateCoefficients |
The seven rate coefficients. | |
bool | m_reverse = false |
Flag indicating if this is a reverse reaction rate. | |
Private Member Functions | |
template<typename T> | |
T | calculate_rate (const T T9) const |
Template implementation for calculating the reaction rate. | |
Friends | |
std::ostream & | operator<< (std::ostream &os, const Reaction &r) |
Represents a single nuclear reaction from a specific data source.
This class encapsulates all properties of a single nuclear reaction as defined in formats like REACLIB, including reactants, products, Q-value, and rate coefficients from a particular evaluation (source).
Example:
Definition at line 72 of file reaction.h.
|
virtualdefault |
Virtual destructor.
gridfire::reaction::Reaction::Reaction | ( | const std::string_view | id, |
const std::string_view | peName, | ||
const int | chapter, | ||
const std::vector< fourdst::atomic::Species > & | reactants, | ||
const std::vector< fourdst::atomic::Species > & | products, | ||
const double | qValue, | ||
const std::string_view | label, | ||
const RateCoefficientSet & | sets, | ||
const bool | reverse = false ) |
Constructs a Reaction object.
id | A unique identifier for the reaction. |
peName | The name in (projectile, ejectile) notation (e.g., "p(p,g)d"). |
chapter | The REACLIB chapter number, defining reaction structure. |
reactants | A vector of reactant species. |
products | A vector of product species. |
qValue | The Q-value of the reaction in MeV. |
label | The source label for the rate data (e.g., "wc12", "st08"). |
sets | The set of rate coefficients. |
reverse | True if this is a reverse reaction rate. |
Definition at line 19 of file reaction.cpp.
|
nodiscard |
Gets a set of all unique species involved in the reaction.
Definition at line 70 of file reaction.cpp.
|
nodiscardvirtual |
Calculates the reaction rate for a given temperature using CppAD types.
T9 | The temperature in units of 10^9 K, as a CppAD::AD<double>. |
Reimplemented in gridfire::reaction::LogicalReaction.
Definition at line 43 of file reaction.cpp.
|
nodiscardvirtual |
Calculates the reaction rate for a given temperature.
T9 | The temperature in units of 10^9 K. |
Reimplemented in gridfire::reaction::LogicalReaction.
Definition at line 39 of file reaction.cpp.
|
inlinenodiscardprivate |
Template implementation for calculating the reaction rate.
T | The numeric type (double or CppAD::AD<double>). |
T9 | The temperature in units of 10^9 K. |
The rate is calculated using the standard REACLIB formula: rate = exp(a0 + a1/T9 + a2/T9^(1/3) + a3*T9^(1/3) + a4*T9 + a5*T9^(5/3) + a6*ln(T9))
Definition at line 281 of file reaction.h.
|
inlinenodiscard |
Gets the REACLIB chapter number.
Definition at line 126 of file reaction.h.
|
nodiscard |
Checks if the reaction involves a given species as a reactant or product.
species | The species to check for. |
Definition at line 47 of file reaction.cpp.
|
nodiscard |
Checks if the reaction involves a given species as a product.
species | The species to check for. |
Definition at line 61 of file reaction.cpp.
|
nodiscard |
Checks if the reaction involves a given species as a reactant.
species | The species to check for. |
Definition at line 52 of file reaction.cpp.
|
nodiscard |
Calculates the excess energy from the mass difference of reactants and products.
Definition at line 123 of file reaction.cpp.
|
nodiscard |
Computes a hash for the reaction based on its ID.
seed | The seed for the hash function. |
Uses the XXHash64 algorithm on the reaction's ID string.
Definition at line 136 of file reaction.cpp.
|
inlinenodiscard |
Gets the unique identifier of the reaction.
Definition at line 202 of file reaction.h.
|
inlinenodiscard |
Checks if this is a reverse reaction rate.
Definition at line 226 of file reaction.h.
|
nodiscard |
Gets the number of unique species involved in the reaction.
Definition at line 108 of file reaction.cpp.
|
inline |
Compares this reaction with another for inequality.
other | The other Reaction to compare with. |
Definition at line 246 of file reaction.h.
|
inline |
Compares this reaction with another for equality based on their IDs.
other | The other Reaction to compare with. |
Definition at line 239 of file reaction.h.
|
inlinenodiscardvirtual |
Gets the reaction name in (projectile, ejectile) notation.
Definition at line 120 of file reaction.h.
|
nodiscard |
Gets a set of all unique product species.
Definition at line 85 of file reaction.cpp.
|
inlinenodiscard |
Gets the vector of product species.
Definition at line 220 of file reaction.h.
|
inlinenodiscard |
Gets the Q-value of the reaction.
Definition at line 208 of file reaction.h.
|
inlinenodiscard |
Gets the set of rate coefficients.
Definition at line 138 of file reaction.h.
|
nodiscard |
Gets a set of all unique reactant species.
Definition at line 77 of file reaction.cpp.
|
inlinenodiscard |
Gets the vector of reactant species.
Definition at line 214 of file reaction.h.
|
inlinenodiscard |
Gets the source label for the rate data.
Definition at line 132 of file reaction.h.
|
nodiscard |
Gets a map of all species to their stoichiometric coefficients.
Definition at line 112 of file reaction.cpp.
|
nodiscard |
Calculates the stoichiometric coefficient for a given species.
species | The species for which to find the coefficient. |
|
friend |
Definition at line 256 of file reaction.h.
|
protected |
Chapter number from the REACLIB database, defining the reaction structure.
Definition at line 264 of file reaction.h.
|
protected |
Unique identifier for the reaction (e.g., "h1+h1=>h2+e+nu").
Definition at line 262 of file reaction.h.
|
protected |
Definition at line 261 of file reaction.h.
|
protected |
Name of the reaction in (projectile, ejectile) notation (e.g. "p(p,g)d").
Definition at line 263 of file reaction.h.
|
protected |
Products of the reaction.
Definition at line 267 of file reaction.h.
|
protected |
Q-value of the reaction in MeV.
Definition at line 265 of file reaction.h.
|
protected |
The seven rate coefficients.
Definition at line 269 of file reaction.h.
|
protected |
Reactants of the reaction.
Definition at line 266 of file reaction.h.
|
protected |
Flag indicating if this is a reverse reaction rate.
Definition at line 270 of file reaction.h.
|
protected |
Source label for the rate data (e.g., "wc12w", "st08").
Definition at line 268 of file reaction.h.