Loading...
Searching...
No Matches
gridfire::rates::weak::WeakReaction Class Referencefinal

Concrete Reaction representing a single weak process (beta±, e−/e+ capture). More...

`#include <weak.h>`

Inheritance diagram for gridfire::rates::weak::WeakReaction:
[legend]
Collaboration diagram for gridfire::rates::weak::WeakReaction:
[legend]

## Classes

class | AtomicWeakRate
| CppAD atomic that wraps weak-rate interpolation for AD evaluation. More...
struct | constants

## Public Member Functions

| WeakReaction (const fourdst::atomic::Species &species, WeakReactionType type, const WeakRateInterpolator &interpolator)
| Construct a WeakReaction for a specific weak channel and parent species.
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
| Scalar weak reaction rate λ(T9, rho, Ye, μe) in 1/s.
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
| AD-enabled weak reaction rate λ(T9, rho, Ye, μe) in 1/s.
std::string_view | id () const override
| Unique identifier string for the weak channel.
const std::vector< fourdst::atomic::Species > & | reactants () const override
| Reactants list (parent nuclide only).
const std::vector< fourdst::atomic::Species > & | products () const override
| Products list (daughter nuclide only).
bool | contains (const fourdst::atomic::Species &species) const override
| Check if a species participates in this weak reaction.
bool | contains_reactant (const fourdst::atomic::Species &species) const override
| Check if a species is the reactant (parent).
bool | contains_product (const fourdst::atomic::Species &species) const override
| Check if a species is the product (daughter).
std::unordered_set< fourdst::atomic::Species > | all_species () const override
| Set of both parent and daughter species.
std::unordered_set< fourdst::atomic::Species > | reactant_species () const override
| Singleton set containing only the parent species.
std::unordered_set< fourdst::atomic::Species > | product_species () const override
| Singleton set containing only the daughter species.
size_t | num_species () const override
| Number of unique species involved (always 2 for weak reactions).
std::unordered_map< fourdst::atomic::Species, int > | stoichiometry () const override
| Full stoichiometry map: parent -1, daughter +1.
int | stoichiometry (const fourdst::atomic::Species &species) const override
| Stoichiometric coefficient for a species: -1 (parent), +1 (daughter), 0 otherwise.
uint64_t | hash (uint64_t seed) const override
| Content-based 64-bit hash for this reaction.
double | qValue () const override
| Q-value (MeV) based on nuclear mass differences and channel.
double | calculate_energy_generation_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
| Net energy generation rate (MeV/s) for this weak reaction.
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 override
| AD-enabled net energy generation rate (MeV/s).
double | calculate_log_rate_partial_deriv_wrt_T9 (double T9, double rho, double Ye, double mue, const fourdst::composition::Composition &composition) const override
| Logarithmic temperature sensitivity of the rate at the given state.
reaction::ReactionType | type () const override
| Reaction type tag for runtime dispatch.
std::unique_ptr< Reaction > | clone () const override
| Polymorphic deep copy.
bool | is_reverse () const override
| Weak reactions are parameterized in the forward sense (never reverse).
const WeakRateInterpolator & | getWeakRateInterpolator () const
| Access the underlying rate interpolator used by this reaction.
std::optional< std::vector< reaction::RateCoefficientSet > > | getRateCoefficients () const override
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.

## Private Member Functions

template<IsArithmeticOrAD T>
T | calculate_rate (T T9, T rho, T Ye, T mue, const std::vector< T > &Y, const std::unordered_map< size_t, fourdst::atomic::Species > &index_to_species_map) const
| Internal unified implementation for scalar/AD rate evaluation.
double | get_log_rate_from_payload (const WeakRatePayload &payload) const
| Extract the channel-specific log10(rate) from an interpolated payload. Mapping: β−→log_beta_minus, β+→log_beta_plus, e− capture→log_electron_capture, e+ capture→log_positron_capture.
double | get_log_neutrino_loss_from_payload (const WeakRatePayload &payload) const
| Extract the channel-specific log10(neutrino loss) from a payload. Mapping: β−/e+ capture→log_antineutrino_loss_bd; β+/e− capture→log_neutrino_loss_ec.

## Private Attributes

const constants | m_constants
fourdst::atomic::Species | m_reactant
fourdst::atomic::Species | m_product
std::vector< fourdst::atomic::Species > | m_reactants
std::vector< fourdst::atomic::Species > | m_products
size_t | m_reactant_a
size_t | m_reactant_z
size_t | m_product_a
size_t | m_product_z
std::string | m_id
WeakReactionType | m_type
const WeakRateInterpolator & | m_interpolator
AtomicWeakRate | m_atomic

## Detailed Description

Concrete Reaction representing a single weak process (beta±, e−/e+ capture).

Wraps interpolation logic for tabulated weak rates and provides both scalar and AD interfaces for rate and energy generation. The reactants/products are the parent/daughter nuclei of the weak process.

the product nucleus is resolved from (A,Z) and channel via simple charge-changing rules (β−: Z+1; β+: Z−1; e− capture: Z−1; e+ capture: Z+1). The reaction ID is formatted like "Parent(channel)Product" with ν/ν̄ decorations, and an internal CppAD atomic (AtomicWeakRate) is prepared for AD energy calculations.

## Constructor & Destructor Documentation

## WeakReaction()

gridfire::rates::weak::WeakReaction::WeakReaction | ( | const fourdst::atomic::Species & | species,
|  | WeakReactionType | type,
|  | const WeakRateInterpolator & | interpolator )

explicit

Construct a WeakReaction for a specific weak channel and parent species.

Parameters

  species | Parent nuclide undergoing the weak process.
  type | The weak reaction channel (beta−, beta+, e− capture, e+ capture).
  interpolator | Reference to a WeakRateInterpolator providing tabulated data.

Precondition
  The product nuclide must be resolvable for the given (species, type).

Postcondition
  Object is ready to compute rates using the provided interpolator.

Exceptions

  std::runtime_error | If the product species cannot be resolved for the channel (product resolution uses the charge-changing rules described above).

## Member Function Documentation

## all_species()

std::unordered_set< fourdst::atomic::Species > gridfire::rates::weak::WeakReaction::all_species | ( |  | ) | const

nodiscardoverridevirtual

Set of both parent and daughter species.

Implements gridfire::reaction::Reaction.

## calculate_energy_generation_rate() [1/2]

CppAD::AD< double > gridfire::rates::weak::WeakReaction::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

nodiscardoverridevirtual

AD-enabled net energy generation rate (MeV/s).

Uses an internal CppAD atomic to compute two outputs at once: the rate λ and the neutrino loss ν_loss at (T9, log10(rho*Ye), μe). Returns λ · (Q − ν_loss). The atomic throws on interpolation failure.

Exceptions

  std::runtime_error | If the atomic rate evaluation fails to interpolate.

Reimplemented from gridfire::reaction::Reaction.

## calculate_energy_generation_rate() [2/2]

double gridfire::rates::weak::WeakReaction::calculate_energy_generation_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

nodiscardoverridevirtual

Net energy generation rate (MeV/s) for this weak reaction.

Interpolates once to obtain both the log10(rate) and the appropriate log10(neutrino-loss) for the channel, converts to linear values, computes E_deposited = Q − ν_loss, and returns λ · E_deposited. Throws on interpolation failure.

Channel mapping for neutrino-loss column:

- β− decay and e+ capture: use log_antineutrino_loss_bd
- β+ decay and e− capture: use log_neutrino_loss_ec

Parameters

  T9 | Temperature in GK.
  rho | Density in g cm^-3.
  Ye | Electron fraction.
  mue | Electron chemical potential (MeV).
  Y | Composition vector (unused for weak channels).
  index_to_species_map | Index-to-species map (unused for weak channels).

Returns
  Energy generation rate in MeV/s.

Exceptions

  std::runtime_error | On interpolation failure.

Example
  double eps = rxn.calculate_energy_generation_rate(3.0, 1e7, 0.5, 2.0, {}, {});

Reimplemented from gridfire::reaction::Reaction.

## calculate_log_rate_partial_deriv_wrt_T9()

double gridfire::rates::weak::WeakReaction::calculate_log_rate_partial_deriv_wrt_T9 | ( | double | T9,
|  | double | rho,
|  | double | Ye,
|  | double | mue,
|  | const fourdst::composition::Composition & | composition ) const

nodiscardoverridevirtual

Logarithmic temperature sensitivity of the rate at the given state.

Implementation status: requests derivative tables from the interpolator and throws on failure; otherwise the function is not yet implemented and does not return a value. Avoid calling until implemented.

Parameters

  T9 | Temperature in GK.
  rho | Density in g cm^-3.
  Ye | Electron fraction.
  mue | Electron chemical potential (MeV).
  composition | Composition context (not used by weak channels presently).

Returns
  d ln λ / d ln T9.

Exceptions

  std::runtime_error | On interpolation failure.

Implements gridfire::reaction::Reaction.

## calculate_rate() [1/3]

CppAD::AD< double > gridfire::rates::weak::WeakReaction::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

nodiscardoverridevirtual

AD-enabled weak reaction rate λ(T9, rho, Ye, μe) in 1/s.

Current implementation returns 0.0. AD support is provided for the energy-generation overload below using an internal CppAD atomic that evaluates both the rate and neutrino loss consistently. A future implementation may mirror that atomic here and return the AD rate.

Parameters

  T9 | Temperature in GK (AD type).
  rho | Mass density (g cm^-3, AD type).
  Ye | Electron fraction (AD type).
  mue | Electron chemical potential (MeV, AD type).
  Y | Composition vector (unused for weak channels).
  index_to_species_map | Index-to-species map (unused for weak channels).

Returns
  Reaction rate (1/s) as CppAD::AD<double> (currently 0.0).

Example
  using AD = CppAD::AD<double>;
  AD lambda_ad = rxn.calculate_rate(AD(3.0), AD(1e7), AD(0.5), AD(2.0), {}, {});

Implements gridfire::reaction::Reaction.

## calculate_rate() [2/3]

double gridfire::rates::weak::WeakReaction::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

nodiscardoverridevirtual

Scalar weak reaction rate λ(T9, rho, Ye, μe) in 1/s.

Performs a single interpolation of the weak-rate tables at (T9, log10(rho*Ye), μe). If the selected log10(rate) is ≤ sentinel (-60), returns 0; otherwise returns 10^{log10(rate)}. On interpolation failure, throws with a message including (A,Z) and the state point.

Parameters

  T9 | Temperature in GK (1e9 K).
  rho | Mass density (g cm^-3).
  Ye | Electron fraction.
  mue | Electron chemical potential (MeV).
  Y | Composition vector (unused for weak channels).
  index_to_species_map | Index-to-species map (unused for weak channels).

Returns
  Reaction rate (1/s).

Exceptions

  std::runtime_error | On interpolation failure.

Example
  double lambda = rxn.calculate_rate(2.0, 1e8, 0.4, 1.5, {}, {});

Implements gridfire::reaction::Reaction.

## calculate_rate() [3/3]

template<IsArithmeticOrAD T>

T gridfire::rates::weak::WeakReaction::calculate_rate | ( | T | T9,
|  | T | rho,
|  | T | Ye,
|  | T | mue,
|  | const std::vector< T > & | Y,
|  | const std::unordered_map< size_t, fourdst::atomic::Species > & | index_to_species_map ) const

private

Internal unified implementation for scalar/AD rate evaluation.

Template Parameters

  T | double or CppAD::AD<double>.

Parameters

  T9,rho,Ye,mue | Thermodynamic state.
  Y | Composition vector (unused for weak channels).
  index_to_species_map | Index-to-species map (unused for weak channels).

Returns
  Reaction rate (1/s) as T. For double, performs table interpolation and returns 0 when the tabulated log10(rate) ≤ sentinel; for AD, calls the atomic and returns the first output.

Precondition
  T9 > 0, rho > 0, 0 < Ye <= 1.

Postcondition
  No persistent state is modified.

Exceptions

  std::runtime_error | If interpolation fails (double path) or the atomic fails (AD path).

## clone()

std::unique_ptr< reaction::Reaction > gridfire::rates::weak::WeakReaction::clone | ( |  | ) | const

nodiscardoverridevirtual

Polymorphic deep copy.

Implements gridfire::reaction::Reaction.

## contains()

bool gridfire::rates::weak::WeakReaction::contains | ( | const fourdst::atomic::Species & | species | ) | const

nodiscardoverridevirtual

Check if a species participates in this weak reaction.

Implements gridfire::reaction::Reaction.

## contains_product()

bool gridfire::rates::weak::WeakReaction::contains_product | ( | const fourdst::atomic::Species & | species | ) | const

nodiscardoverridevirtual

Check if a species is the product (daughter).

Implements gridfire::reaction::Reaction.

## contains_reactant()

bool gridfire::rates::weak::WeakReaction::contains_reactant | ( | const fourdst::atomic::Species & | species | ) | const

nodiscardoverridevirtual

Check if a species is the reactant (parent).

Implements gridfire::reaction::Reaction.

## countProductOccurrences()

size_t gridfire::rates::weak::WeakReaction::countProductOccurrences | ( | const fourdst::atomic::Species & | species | ) | const

nodiscardoverridevirtual

Implements gridfire::reaction::Reaction.

## countReactantOccurrences()

size_t gridfire::rates::weak::WeakReaction::countReactantOccurrences | ( | const fourdst::atomic::Species & | species | ) | const

nodiscardoverridevirtual

Implements gridfire::reaction::Reaction.

## get_log_neutrino_loss_from_payload()

double gridfire::rates::weak::WeakReaction::get_log_neutrino_loss_from_payload | ( | const WeakRatePayload & | payload | ) | const

private

Extract the channel-specific log10(neutrino loss) from a payload. Mapping: β−/e+ capture→log_antineutrino_loss_bd; β+/e− capture→log_neutrino_loss_ec.

## get_log_rate_from_payload()

double gridfire::rates::weak::WeakReaction::get_log_rate_from_payload | ( | const WeakRatePayload & | payload | ) | const

private

Extract the channel-specific log10(rate) from an interpolated payload. Mapping: β−→log_beta_minus, β+→log_beta_plus, e− capture→log_electron_capture, e+ capture→log_positron_capture.

## getRateCoefficients()

std::optional< std::vector< reaction::RateCoefficientSet > > gridfire::rates::weak::WeakReaction::getRateCoefficients | ( |  | ) | const

inlinenodiscardoverridevirtual

Implements gridfire::reaction::Reaction.

## getWeakRateInterpolator()

const WeakRateInterpolator & gridfire::rates::weak::WeakReaction::getWeakRateInterpolator | ( |  | ) | const

nodiscard

Access the underlying rate interpolator used by this reaction.

## hash()

uint64_t gridfire::rates::weak::WeakReaction::hash | ( | uint64_t | seed | ) | const

nodiscardoverridevirtual

Content-based 64-bit hash for this reaction.

Implements gridfire::reaction::Reaction.

## id()

std::string_view gridfire::rates::weak::WeakReaction::id | ( |  | ) | const

nodiscardoverridevirtual

Unique identifier string for the weak channel.

Returns
  A stable string view (e.g., "Fe52(e-,ν)Mn52").

Implements gridfire::reaction::Reaction.

## is_reverse()

bool gridfire::rates::weak::WeakReaction::is_reverse | ( |  | ) | const

nodiscardoverridevirtual

Weak reactions are parameterized in the forward sense (never reverse).

Implements gridfire::reaction::Reaction.

## num_species()

size_t gridfire::rates::weak::WeakReaction::num_species | ( |  | ) | const

nodiscardoverridevirtual

Number of unique species involved (always 2 for weak reactions).

Implements gridfire::reaction::Reaction.

## product_species()

std::unordered_set< fourdst::atomic::Species > gridfire::rates::weak::WeakReaction::product_species | ( |  | ) | const

nodiscardoverridevirtual

Singleton set containing only the daughter species.

Implements gridfire::reaction::Reaction.

## products()

const std::vector< fourdst::atomic::Species > & gridfire::rates::weak::WeakReaction::products | ( |  | ) | const

nodiscardoverridevirtual

Products list (daughter nuclide only).

Returns
  Vector with the daughter species.

Implements gridfire::reaction::Reaction.

## qValue()

double gridfire::rates::weak::WeakReaction::qValue | ( |  | ) | const

nodiscardoverridevirtual

Q-value (MeV) based on nuclear mass differences and channel.

Computes Q = (M_parent − M_daughter) c^2 converted to MeV. For β+ decay subtract 2 m_e c^2, for e+ capture add 2 m_e c^2; for β− and e− capture it is just the nuclear mass difference. Neutrino rest mass is ignored.

Implements gridfire::reaction::Reaction.

## reactant_species()

std::unordered_set< fourdst::atomic::Species > gridfire::rates::weak::WeakReaction::reactant_species | ( |  | ) | const

nodiscardoverridevirtual

Singleton set containing only the parent species.

Implements gridfire::reaction::Reaction.

## reactants()

const std::vector< fourdst::atomic::Species > & gridfire::rates::weak::WeakReaction::reactants | ( |  | ) | const

nodiscardoverridevirtual

Reactants list (parent nuclide only).

Returns
  Vector with the parent species.

Implements gridfire::reaction::Reaction.

## stoichiometry() [1/2]

std::unordered_map< fourdst::atomic::Species, int > gridfire::rates::weak::WeakReaction::stoichiometry | ( |  | ) | const

nodiscardoverridevirtual

Full stoichiometry map: parent -1, daughter +1.

Implements gridfire::reaction::Reaction.

## stoichiometry() [2/2]

int gridfire::rates::weak::WeakReaction::stoichiometry | ( | const fourdst::atomic::Species & | species | ) | const

nodiscardoverridevirtual

Stoichiometric coefficient for a species: -1 (parent), +1 (daughter), 0 otherwise.

Implements gridfire::reaction::Reaction.

## type()

reaction::ReactionType gridfire::rates::weak::WeakReaction::type | ( |  | ) | const

nodiscardoverridevirtual

Reaction type tag for runtime dispatch.

Implements gridfire::reaction::Reaction.

## Member Data Documentation

## m_atomic

AtomicWeakRate gridfire::rates::weak::WeakReaction::m_atomic

mutableprivate

## m_constants

const constants gridfire::rates::weak::WeakReaction::m_constants

private

## m_id

std::string gridfire::rates::weak::WeakReaction::m_id

private

## m_interpolator

const WeakRateInterpolator& gridfire::rates::weak::WeakReaction::m_interpolator

private

## m_product

fourdst::atomic::Species gridfire::rates::weak::WeakReaction::m_product

private

## m_product_a

size_t gridfire::rates::weak::WeakReaction::m_product_a

private

## m_product_z

size_t gridfire::rates::weak::WeakReaction::m_product_z

private

## m_products

std::vector<fourdst::atomic::Species> gridfire::rates::weak::WeakReaction::m_products

private

## m_reactant

fourdst::atomic::Species gridfire::rates::weak::WeakReaction::m_reactant

private

## m_reactant_a

size_t gridfire::rates::weak::WeakReaction::m_reactant_a

private

## m_reactant_z

size_t gridfire::rates::weak::WeakReaction::m_reactant_z

private

## m_reactants

std::vector<fourdst::atomic::Species> gridfire::rates::weak::WeakReaction::m_reactants

private

## m_type

WeakReactionType gridfire::rates::weak::WeakReaction::m_type

private

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

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