Loading...
Searching...
No Matches
gridfire::reaction::LogicalReaclibReaction Class Referencefinal

Represents a "logical" reaction that aggregates rates from multiple sources. More...

`#include <reaction.h>`

Inheritance diagram for gridfire::reaction::LogicalReaclibReaction:
[legend]
Collaboration diagram for gridfire::reaction::LogicalReaclibReaction:
[legend]

## Public Member Functions

| LogicalReaclibReaction (const std::vector< std::unique_ptr< ReaclibReaction > > &reactions)
| Constructs a LogicalReaction from a vector of `Reaction` objects. Implicitly assumes that the logical reaction is for a forward (i.e. not reverse) reaction.
| LogicalReaclibReaction (const std::vector< std::unique_ptr< ReaclibReaction > > &reactions, bool reverse)
void | add_reaction (const ReaclibReaction &reaction)
| Adds another `Reaction` source to this logical reaction.
size_t | size () const
| Gets the number of source rates contributing to this logical reaction.
std::vector< std::string > | sources () const
| Gets the list of source labels for the aggregated rates.
double | calculate_rate (double T9, double rho, double Ye, double mue, const std::vector< double > &Y, const std::unordered_map< size_t, fourdst::atomic::Species > &index_to_species_map) const override
| Calculates the total reaction rate by summing all source rates.
double | calculate_log_rate_partial_deriv_wrt_T9 (double T9, double rho, double Ye, double mue, const fourdst::composition::Composition &comp) const override
| Logarithmic partial derivative of the rate with respect to temperature.
ReactionType | type () const override
| Category of this reaction (e.g., REACLIB, WEAK, LOGICAL_REACLIB).
std::unique_ptr< Reaction > | clone () const override
| Polymorphic deep copy.
CppAD::AD< double > | calculate_rate (CppAD::AD< double > T9, CppAD::AD< double > rho, CppAD::AD< double > Ye, CppAD::AD< double > mue, const std::vector< CppAD::AD< double > > &Y, const std::unordered_map< size_t, fourdst::atomic::Species > &index_to_species_map) const override
| Calculates the total reaction rate using CppAD types.
std::optional< std::vector< RateCoefficientSet > > | getRateCoefficients () const override
Iterators
Provides iterators to loop over the rate coefficient sets.
auto | begin ()
auto | begin () const
auto | end ()
auto | end () const
Public Member Functions inherited from gridfire::reaction::ReaclibReaction
| ~ReaclibReaction () override=default
| ReaclibReaction (std::string_view id, std::string_view peName, int chapter, const std::vector< fourdst::atomic::Species > &reactants, const std::vector< fourdst::atomic::Species > &products, double qValue, std::string_view label, const RateCoefficientSet &sets, bool reverse=false)
| Constructs a Reaction object.
double | calculate_rate (double T9, double rho, double Ye, double mue, const std::vector< double > &Y, const std::unordered_map< size_t, fourdst::atomic::Species > &index_to_species_map) const override
| Calculates the reaction rate for a given temperature.
CppAD::AD< double > | calculate_rate (CppAD::AD< double > T9, CppAD::AD< double > rho, CppAD::AD< double > Ye, CppAD::AD< double > mue, const std::vector< CppAD::AD< double > > &Y, const std::unordered_map< size_t, fourdst::atomic::Species > &index_to_species_map) const override
| Calculates the reaction rate for a given temperature using CppAD types.
double | calculate_log_rate_partial_deriv_wrt_T9 (double T9, double rho, double Ye, double mue, const fourdst::composition::Composition &comp) const override
| Logarithmic partial derivative of the rate with respect to temperature.
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.
ReactionType | type () const override
| Category of this reaction (e.g., REACLIB, WEAK, LOGICAL_REACLIB).
const RateCoefficientSet & | rateCoefficients () const
| Gets the set of rate coefficients.
std::optional< std::vector< RateCoefficientSet > > | getRateCoefficients () const override
bool | contains (const fourdst::atomic::Species &species) const override
| Checks if the reaction involves a given species as a reactant or product.
bool | contains_reactant (const fourdst::atomic::Species &species) const override
| Checks if the reaction involves a given species as a reactant.
bool | contains_product (const fourdst::atomic::Species &species) const override
| Checks if the reaction involves a given species as a product.
std::unordered_set< fourdst::atomic::Species > | all_species () const override
| Gets a set of all unique species involved in the reaction.
std::unordered_set< fourdst::atomic::Species > | reactant_species () const override
| Gets a set of all unique reactant species.
std::unordered_set< fourdst::atomic::Species > | product_species () const override
| Gets a set of all unique product species.
size_t | num_species () const override
| Gets the number of unique species involved in the reaction.
int | stoichiometry (const fourdst::atomic::Species &species) const override
| Calculates the stoichiometric coefficient for a given species.
std::unordered_map< fourdst::atomic::Species, int > | stoichiometry () const override
| Gets a map of all species to their stoichiometric coefficients.
std::string_view | id () const override
| Gets the unique identifier of the reaction.
double | qValue () const override
| Gets the Q-value of the reaction.
const std::vector< fourdst::atomic::Species > & | reactants () const override
| Gets the vector of reactant species.
const std::vector< fourdst::atomic::Species > & | products () const override
| Gets the vector of product species.
bool | is_reverse () const override
| 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 ReaclibReaction &other) const
| Compares this reaction with another for equality based on their IDs.
bool | operator!= (const ReaclibReaction &other) const
| Compares this reaction with another for inequality.
uint64_t | hash (uint64_t seed) const override
| Computes a hash for the reaction based on its ID.
std::unique_ptr< Reaction > | clone () const override
| Polymorphic deep copy.
size_t | countReactantOccurrences (const fourdst::atomic::Species &species) const override
size_t | countProductOccurrences (const fourdst::atomic::Species &species) const override
Public Member Functions inherited from gridfire::reaction::Reaction
virtual | ~Reaction ()=default
| Virtual destructor for correct polymorphic cleanup.
virtual double | calculate_energy_generation_rate (const double T9, const double rho, const double Ye, double mue, const std::vector< double > &Y, const std::unordered_map< size_t, fourdst::atomic::Species > &index_to_species_map) const
| Convenience: energy generation rate from this reaction (double version).
virtual CppAD::AD< double > | calculate_energy_generation_rate (const CppAD::AD< double > &T9, const CppAD::AD< double > &rho, const CppAD::AD< double > &Ye, const CppAD::AD< double > &mue, const std::vector< CppAD::AD< double > > &Y, const std::unordered_map< size_t, fourdst::atomic::Species > &index_to_species_map) const
| Convenience: AD-enabled energy generation rate (AD version).

## Private Member Functions

template<typename T >
T | calculate_rate (const T T9) const
| Template implementation for calculating the total reaction rate.

## Private Attributes

std::vector< std::string > | m_sources
| List of source labels.
std::vector< RateCoefficientSet > | m_rates
| List of rate coefficient sets from each source.
bool | m_weak = false

## Friends

std::ostream & | operator<< (std::ostream &os, const LogicalReaclibReaction &r)

## Additional Inherited Members

Protected Attributes inherited from gridfire::reaction::ReaclibReaction
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::unordered_map< fourdst::atomic::Species, size_t > | m_reactants
| Reactants of the reaction.
std::unordered_map< fourdst::atomic::Species, size_t > | m_products
| Products of the reaction.
std::optional< std::vector< fourdst::atomic::Species > > | m_reactantsVec
std::optional< std::vector< fourdst::atomic::Species > > | m_productsVec
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.

## Detailed Description

Represents a "logical" reaction that aggregates rates from multiple sources.

A LogicalReaclibReaction shares the same reactants and products but combines rates from different evaluations (e.g., "wc12" and "st08" for the same physical reaction). The total rate is the sum of the individual rates. It inherits from Reaction, using the properties of the first provided reaction as its base properties (reactants, products, Q-value, etc.).

## Constructor & Destructor Documentation

## LogicalReaclibReaction() [1/2]

gridfire::reaction::LogicalReaclibReaction::LogicalReaclibReaction | ( | const std::vector< std::unique_ptr< ReaclibReaction > > & | reactions | ) |

explicit

Constructs a LogicalReaction from a vector of `Reaction` objects. Implicitly assumes that the logical reaction is for a forward (i.e. not reverse) reaction.

Parameters

  reactions | A vector of reactions that represent the same logical process.

Exceptions

  std::runtime_error | if the provided reactions have inconsistent Q-values.

## LogicalReaclibReaction() [2/2]

gridfire::reaction::LogicalReaclibReaction::LogicalReaclibReaction | ( | const std::vector< std::unique_ptr< ReaclibReaction > > & | reactions,
|  | bool | reverse
| ) |  |

explicit

@breif Constructs a LogicalReaction from a vector of `Reaction` objects and allows the user to specify if the logical set is for a reverse reaction explicitly

Parameters

  reactions | A vector of reactions that represent the same logical process
  reverse | A flag to control if this logical reaction is reverse or not

Returns
  std::runtime_error if the provided reactions have inconsistent Q-values.

## Member Function Documentation

## add_reaction()

void gridfire::reaction::LogicalReaclibReaction::add_reaction | ( | const ReaclibReaction & | reaction | ) |

Adds another `Reaction` source to this logical reaction.

Parameters

  reaction | The reaction to add.

Exceptions

  std::runtime_error | if the reaction has a different `peName`, a duplicate source label, or an inconsistent Q-value.

## begin() [1/2]

auto gridfire::reaction::LogicalReaclibReaction::begin | ( |  | ) |

inline

## begin() [2/2]

auto gridfire::reaction::LogicalReaclibReaction::begin | ( |  | ) | const

inline

## calculate_log_rate_partial_deriv_wrt_T9()

double gridfire::reaction::LogicalReaclibReaction::calculate_log_rate_partial_deriv_wrt_T9 | ( | double | T9,
|  | double | rho,
|  | double | Ye,
|  | double | mue,
|  | const fourdst::composition::Composition & | comp
| ) |  | const

overridevirtual

Logarithmic partial derivative of the rate with respect to temperature.

Implementations return d(ln rate)/d(ln T9) or an equivalent measure (as documented by the concrete class), evaluated at the provided state.

Parameters

  T9 | Temperature in GK (10^9 K).
  rho | Mass density (g cm^-3).
  Ye | Electron fraction.
  mue | Electron chemical potential.
  comp | Composition object providing composition in a convenient form.

Returns
  The logarithmic temperature derivative of the rate.

Implements gridfire::reaction::Reaction.

## calculate_rate() [1/3]

template<typename T >

T gridfire::reaction::LogicalReaclibReaction::calculate_rate | ( | const T | T9 | ) | const

inlineprivate

Template implementation for calculating the total reaction rate.

Template Parameters

  T | The numeric type (double or CppAD::AD<double>).

Parameters

  T9 | The temperature in units of 10^9 K.

Returns
  The total calculated reaction rate.

This method iterates through all stored `RateCoefficientSet`s, calculates the rate for each, and returns their sum.

## calculate_rate() [2/3]

CppAD::AD< double > gridfire::reaction::LogicalReaclibReaction::calculate_rate | ( | CppAD::AD< double > | T9,
|  | CppAD::AD< double > | rho,
|  | CppAD::AD< double > | Ye,
|  | CppAD::AD< double > | mue,
|  | const std::vector< CppAD::AD< double > > & | Y,
|  | const std::unordered_map< size_t, fourdst::atomic::Species > & | index_to_species_map
| ) |  | const

overridevirtual

Calculates the total reaction rate using CppAD types.

Parameters

  T9 | The temperature in units of 10^9 K, as a CppAD::AD<double>.
  rho |
  Ye |
  mue |
  Y |
  index_to_species_map |

Returns
  The total calculated reaction rate, as a CppAD::AD<double>.

Implements gridfire::reaction::Reaction.

## calculate_rate() [3/3]

double gridfire::reaction::LogicalReaclibReaction::calculate_rate | ( | double | T9,
|  | double | rho,
|  | double | Ye,
|  | double | mue,
|  | const std::vector< double > & | Y,
|  | const std::unordered_map< size_t, fourdst::atomic::Species > & | index_to_species_map
| ) |  | const

overridevirtual

Calculates the total reaction rate by summing all source rates.

Parameters

  T9 | The temperature in units of 10^9 K.
  rho |
  Ye |
  mue |
  Y |
  index_to_species_map |

Returns
  The total calculated reaction rate.

Implements gridfire::reaction::Reaction.

## clone()

std::unique_ptr< Reaction > gridfire::reaction::LogicalReaclibReaction::clone | ( |  | ) | const

overridevirtual

Polymorphic deep copy.

Returns
  A std::unique_ptr owning a new Reaction equal to this one.

Implements gridfire::reaction::Reaction.

## end() [1/2]

auto gridfire::reaction::LogicalReaclibReaction::end | ( |  | ) |

inline

## end() [2/2]

auto gridfire::reaction::LogicalReaclibReaction::end | ( |  | ) | const

inline

## getRateCoefficients()

std::optional< std::vector< RateCoefficientSet > > gridfire::reaction::LogicalReaclibReaction::getRateCoefficients | ( |  | ) | const

overridevirtual

Implements gridfire::reaction::Reaction.

## size()

size_t gridfire::reaction::LogicalReaclibReaction::size | ( |  | ) | const

inline

Gets the number of source rates contributing to this logical reaction.

Returns
  The number of aggregated rates.

## sources()

std::vector< std::string > gridfire::reaction::LogicalReaclibReaction::sources | ( |  | ) | const

inline

Gets the list of source labels for the aggregated rates.

Returns
  A vector of source label strings.

## type()

ReactionType gridfire::reaction::LogicalReaclibReaction::type | ( |  | ) | const

inlineoverridevirtual

Category of this reaction (e.g., REACLIB, WEAK, LOGICAL_REACLIB).

Returns
  Enumerated reaction type for runtime dispatch and filtering.

Implements gridfire::reaction::Reaction.

## Friends And Related Symbol Documentation

## operator<<

std::ostream & operator<< | ( | std::ostream & | os,
|  | const LogicalReaclibReaction & | r
| ) |  |

friend

## Member Data Documentation

## m_rates

std::vector<RateCoefficientSet> gridfire::reaction::LogicalReaclibReaction::m_rates

private

List of rate coefficient sets from each source.

## m_sources

std::vector<std::string> gridfire::reaction::LogicalReaclibReaction::m_sources

private

List of source labels.

## m_weak

bool gridfire::reaction::LogicalReaclibReaction::m_weak = false

private

The documentation for this class was generated from the following files:

- src/include/gridfire/reaction/reaction.h
- src/lib/reaction/reaction.cpp