GridFire 0.0.1a General Purpose Nuclear Network

Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
gridfire::DefinedEngineView Class Reference

`#include <engine_defined.h>`

Inheritance diagram for gridfire::DefinedEngineView:

## Public Member Functions
| DefinedEngineView (const std::vector< std::string > &peNames, DynamicEngine &baseEngine)
const DynamicEngine & | getBaseEngine () const override
| Access the underlying engine instance.
const std::vector< fourdst::atomic::Species > & | getNetworkSpecies () const override
| Gets the list of active species in the network defined by the file.
std::expected< StepDerivatives< double >, expectations::StaleEngineError > | calculateRHSAndEnergy (const std::vector< double > &Y_defined, const double T9, const double rho) const override
| Calculates the right-hand side (dY/dt) and energy generation for the active species.
void | generateJacobianMatrix (const std::vector< double > &Y_dynamic, const double T9, const double rho) const override
| Generates the Jacobian matrix for the active species.
double | getJacobianMatrixEntry (const int i_defined, const int j_defined) const override
| Gets an entry from the Jacobian matrix for the active species.
void | generateStoichiometryMatrix () override
| Generates the stoichiometry matrix for the active reactions and species.
int | getStoichiometryMatrixEntry (const int speciesIndex_defined, const int reactionIndex_defined) const override
| Gets an entry from the stoichiometry matrix for the active species and reactions.
double | calculateMolarReactionFlow (const reaction::Reaction &reaction, const std::vector< double > &Y_defined, const double T9, const double rho) const override
| Calculates the molar reaction flow for a given reaction in the active network.
const reaction::LogicalReactionSet & | getNetworkReactions () const override
| Gets the set of active logical reactions in the network.
void | setNetworkReactions (const reaction::LogicalReactionSet &reactions) override
std::expected< std::unordered_map< fourdst::atomic::Species, double >, expectations::StaleEngineError > | getSpeciesTimescales (const std::vector< double > &Y_defined, const double T9, const double rho) const override
| Computes timescales for all active species in the network.
std::expected< std::unordered_map< fourdst::atomic::Species, double >, expectations::StaleEngineError > | getSpeciesDestructionTimescales (const std::vector< double > &Y_defined, const double T9, const double rho) const override
fourdst::composition::Composition | update (const NetIn &netIn) override
| Updates the engine view if it is marked as stale.
bool | isStale (const NetIn &netIn) override
void | setScreeningModel (screening::ScreeningType model) override
| Sets the screening model for the base engine.
screening::ScreeningType | getScreeningModel () const override
| Gets the screening model from the base engine.
int | getSpeciesIndex (const fourdst::atomic::Species &species) const override
std::vector< double > | mapNetInToMolarAbundanceVector (const NetIn &netIn) const override
PrimingReport | primeEngine (const NetIn &netIn) override
Public Member Functions inherited from gridfire::DynamicEngine
virtual void | generateJacobianMatrix (const std::vector< double > &Y_dynamic, double T9, double rho, const SparsityPattern &sparsityPattern) const
virtual BuildDepthType | getDepth () const
virtual void | rebuild (const fourdst::composition::Composition &comp, BuildDepthType depth)
Public Member Functions inherited from gridfire::Engine
virtual | ~Engine ()=default
| Virtual destructor.
Public Member Functions inherited from gridfire::EngineView< DynamicEngine >
virtual | ~EngineView ()=default
| Virtual destructor.

## Protected Attributes
bool | m_isStale = true
DynamicEngine & | m_baseEngine

## Private Member Functions
std::vector< size_t > | constructSpeciesIndexMap () const
| Constructs the species index map.
std::vector< size_t > | constructReactionIndexMap () const
| Constructs the reaction index map.
std::vector< double > | mapViewToFull (const std::vector< double > &defined) const
| Maps a vector of culled abundances to a vector of full abundances.
std::vector< double > | mapFullToView (const std::vector< double > &full) const
| Maps a vector of full abundances to a vector of culled abundances.
size_t | mapViewToFullSpeciesIndex (size_t definedSpeciesIndex) const
| Maps a culled species index to a full species index.
size_t | mapViewToFullReactionIndex (size_t definedReactionIndex) const
| Maps a culled reaction index to a full reaction index.
void | validateNetworkState () const
void | collect (const std::vector< std::string > &peNames)

## Private Attributes
quill::Logger * | m_logger = fourdst::logging::LogManager::getInstance().getLogger("log")
| Active species in the defined engine.
std::vector< fourdst::atomic::Species > | m_activeSpecies
| Active reactions in the defined engine.
reaction::LogicalReactionSet | m_activeReactions
| Maps indices of active species to indices in the full network.
std::vector< size_t > | m_speciesIndexMap
| Maps indices of active reactions to indices in the full network.
std::vector< size_t > | m_reactionIndexMap

## Detailed Description

Definition at line 16 of file engine_defined.h.

## Constructor & Destructor Documentation

## ◆ DefinedEngineView()

gridfire::DefinedEngineView::DefinedEngineView | ( | const std::vector< std::string > & | peNames,
|  | DynamicEngine & | baseEngine )

Definition at line 17 of file engine_defined.cpp.

## Member Function Documentation

## ◆ calculateMolarReactionFlow()

double gridfire::DefinedEngineView::calculateMolarReactionFlow | ( | const reaction::Reaction & | reaction,
|  | const std::vector< double > & | Y_defined,
|  | const double | T9,
|  | const double | rho ) const
| override virtual

Calculates the molar reaction flow for a given reaction in the active network.

Parameters

  reaction | The reaction for which to calculate the flow.
  Y_defined | Vector of current abundances for the active species.
  T9 | Temperature in units of 10^9 K.
  rho | Density in g/cm^3.

Returns
  Molar flow rate for the reaction (e.g., mol/g/s).

Exceptions

  std::runtime_error | If the view is stale or if the reaction is not in the active set.

Implements gridfire::DynamicEngine.

Definition at line 91 of file engine_defined.cpp.

## ◆ calculateRHSAndEnergy()

std::expected< StepDerivatives< double >, expectations::StaleEngineError > gridfire::DefinedEngineView::calculateRHSAndEnergy | ( | const std::vector< double > & | Y_defined,
|  | const double | T9,
|  | const double | rho ) const
| override virtual

Calculates the right-hand side (dY/dt) and energy generation for the active species.

Parameters

  Y_defined | A vector of abundances for the active species.
  T9 | The temperature in units of 10^9 K.
  rho | The density in g/cm^3.

Returns
  A StepDerivatives struct containing the derivatives of the active species and the nuclear energy generation rate.

Exceptions

  std::runtime_error | If the view is stale (i.e., `update()` has not been called after `setNetworkFile()`).

Implements gridfire::Engine.

Definition at line 30 of file engine_defined.cpp.

## ◆ collect()

void gridfire::DefinedEngineView::collect | ( | const std::vector< std::string > & | peNames | ) |
| private

Definition at line 321 of file engine_defined.cpp.

## ◆ constructReactionIndexMap()

std::vector< size_t > gridfire::DefinedEngineView::constructReactionIndexMap | ( |  | ) | const
| private

Constructs the reaction index map.

Returns
  A vector mapping defined reaction indices to full reaction indices.

This method creates a map from the indices of the active reactions to the indices of the corresponding reactions in the full network.

Exceptions

  std::runtime_error | If an active reaction is not found in the base engine's reaction list.

Definition at line 245 of file engine_defined.cpp.

## ◆ constructSpeciesIndexMap()

std::vector< size_t > gridfire::DefinedEngineView::constructSpeciesIndexMap | ( |  | ) | const
| private

Constructs the species index map.

Returns
  A vector mapping defined species indices to full species indices.

This method creates a map from the indices of the active species to the indices of the corresponding species in the full network.

Exceptions

  std::runtime_error | If an active species is not found in the base engine's species list.

Definition at line 216 of file engine_defined.cpp.

## ◆ generateJacobianMatrix()

void gridfire::DefinedEngineView::generateJacobianMatrix | ( | const std::vector< double > & | Y_dynamic,
|  | const double | T9,
|  | const double | rho ) const
| override virtual

Generates the Jacobian matrix for the active species.

Parameters

  Y_dynamic | A vector of abundances for the active species.
  T9 | The temperature in units of 10^9 K.
  rho | The density in g/cm^3.

Exceptions

  std::runtime_error | If the view is stale.

Implements gridfire::DynamicEngine.

Definition at line 51 of file engine_defined.cpp.

## ◆ generateStoichiometryMatrix()

void gridfire::DefinedEngineView::generateStoichiometryMatrix | ( |  | ) |
| override virtual

Generates the stoichiometry matrix for the active reactions and species.

Exceptions

  std::runtime_error | If the view is stale.

Implements gridfire::DynamicEngine.

Definition at line 74 of file engine_defined.cpp.

## ◆ getBaseEngine()

const DynamicEngine & gridfire::DefinedEngineView::getBaseEngine | ( |  | ) | const
| override virtual

Access the underlying engine instance.

Returns
  Const reference to the underlying engine.

This method must be implemented by derived classes to provide access to the base engine. The returned reference should remain valid for the lifetime of the EngineView.

Example:

const DynamicEngine& engine = myView.getBaseEngine();
gridfire::DynamicEngine
Abstract class for engines supporting Jacobian and stoichiometry operations.
Definition engine_abstract.h:130

Implements gridfire::EngineView< DynamicEngine >.

Definition at line 22 of file engine_defined.cpp.

## ◆ getJacobianMatrixEntry()

double gridfire::DefinedEngineView::getJacobianMatrixEntry | ( | const int | i_defined,
|  | const int | j_defined ) const
| override virtual

Gets an entry from the Jacobian matrix for the active species.

Parameters

  i_defined | The row index (species index) in the defined matrix.
  j_defined | The column index (species index) in the defined matrix.

Returns
  The value of the Jacobian matrix at (i_defined, j_defined).

Exceptions

  std::runtime_error | If the view is stale.
  std::out_of_range | If an index is out of bounds.

Implements gridfire::DynamicEngine.

Definition at line 62 of file engine_defined.cpp.

## ◆ getNetworkReactions()

const reaction::LogicalReactionSet & gridfire::DefinedEngineView::getNetworkReactions | ( |  | ) | const
| override virtual

Gets the set of active logical reactions in the network.

Returns
  Reference to the LogicalReactionSet containing all active reactions.

Exceptions

  std::runtime_error | If the view is stale.

Implements gridfire::DynamicEngine.

Definition at line 108 of file engine_defined.cpp.

## ◆ getNetworkSpecies()

const std::vector< Species > & gridfire::DefinedEngineView::getNetworkSpecies | ( |  | ) | const
| override virtual

Gets the list of active species in the network defined by the file.

Returns
  A const reference to the vector of active species.

Implements gridfire::Engine.

Definition at line 26 of file engine_defined.cpp.

## ◆ getScreeningModel()

screening::ScreeningType gridfire::DefinedEngineView::getScreeningModel | ( |  | ) | const
| nodiscard override virtual

Gets the screening model from the base engine.

Returns
  The current screening model type.

Implements gridfire::DynamicEngine.

Definition at line 184 of file engine_defined.cpp.

## ◆ getSpeciesDestructionTimescales()

std::expected< std::unordered_map< fourdst::atomic::Species, double >, expectations::StaleEngineError > gridfire::DefinedEngineView::getSpeciesDestructionTimescales | ( | const std::vector< double > & | Y_defined,
|  | const double | T9,
|  | const double | rho ) const
| nodiscard override virtual

Implements gridfire::DynamicEngine.

Definition at line 146 of file engine_defined.cpp.

## ◆ getSpeciesIndex()

int gridfire::DefinedEngineView::getSpeciesIndex | ( | const fourdst::atomic::Species & | species | ) | const
| nodiscard override virtual

Implements gridfire::DynamicEngine.

Definition at line 188 of file engine_defined.cpp.

## ◆ getSpeciesTimescales()

std::expected< std::unordered_map< Species, double >, expectations::StaleEngineError > gridfire::DefinedEngineView::getSpeciesTimescales | ( | const std::vector< double > & | Y_defined,
|  | const double | T9,
|  | const double | rho ) const
| nodiscard override virtual

Computes timescales for all active species in the network.

Parameters

  Y_defined | Vector of current abundances for the active species.
  T9 | Temperature in units of 10^9 K.
  rho | Density in g/cm^3.

Returns
  Map from Species to their characteristic timescales (s).

Exceptions

  std::runtime_error | If the view is stale.

Implements gridfire::DynamicEngine.

Definition at line 122 of file engine_defined.cpp.

## ◆ getStoichiometryMatrixEntry()

int gridfire::DefinedEngineView::getStoichiometryMatrixEntry | ( | const int | speciesIndex_defined,
|  | const int | reactionIndex_defined ) const
| override virtual

Gets an entry from the stoichiometry matrix for the active species and reactions.

Parameters

  speciesIndex_defined | The index of the species in the defined species list.
  reactionIndex_defined | The index of the reaction in the defined reaction list.

Returns
  The stoichiometric coefficient for the given species and reaction.

Exceptions

  std::runtime_error | If the view is stale.
  std::out_of_range | If an index is out of bounds.

Implements gridfire::DynamicEngine.

Definition at line 80 of file engine_defined.cpp.

## ◆ isStale()

bool gridfire::DefinedEngineView::isStale | ( | const NetIn & | netIn | ) |
| override virtual

Implements gridfire::DynamicEngine.

Definition at line 175 of file engine_defined.cpp.

## ◆ mapFullToView()

std::vector< double > gridfire::DefinedEngineView::mapFullToView | ( | const std::vector< double > & | full | ) | const
| private

Maps a vector of full abundances to a vector of culled abundances.

Parameters

  full | A vector of abundances for the full network.

Returns
  A vector of abundances for the active species, with the abundances of the active species copied from the full vector.

Definition at line 286 of file engine_defined.cpp.

## ◆ mapNetInToMolarAbundanceVector()

std::vector< double > gridfire::DefinedEngineView::mapNetInToMolarAbundanceVector | ( | const NetIn & | netIn | ) | const
| nodiscard override virtual

Implements gridfire::DynamicEngine.

Definition at line 201 of file engine_defined.cpp.

## ◆ mapViewToFull()

std::vector< double > gridfire::DefinedEngineView::mapViewToFull | ( | const std::vector< double > & | defined | ) | const
| private

Maps a vector of culled abundances to a vector of full abundances.

Parameters

  defined | A vector of abundances for the active species.

Returns
  A vector of abundances for the full network, with the abundances of the active species copied from the defined vector.

Definition at line 277 of file engine_defined.cpp.

## ◆ mapViewToFullReactionIndex()

size_t gridfire::DefinedEngineView::mapViewToFullReactionIndex | ( | size_t | definedReactionIndex | ) | const
| private

Maps a culled reaction index to a full reaction index.

Parameters

  definedReactionIndex | The index of the reaction in the defined reaction list.

Returns
  The index of the corresponding reaction in the full network.

Exceptions

  std::out_of_range | If the defined index is out of bounds for the reaction index map.

Definition at line 304 of file engine_defined.cpp.

## ◆ mapViewToFullSpeciesIndex()

size_t gridfire::DefinedEngineView::mapViewToFullSpeciesIndex | ( | size_t | definedSpeciesIndex | ) | const
| private

Maps a culled species index to a full species index.

Parameters

  definedSpeciesIndex | The index of the species in the defined species list.

Returns
  The index of the corresponding species in the full network.

Exceptions

  std::out_of_range | If the defined index is out of bounds for the species index map.

Definition at line 295 of file engine_defined.cpp.

## ◆ primeEngine()

PrimingReport gridfire::DefinedEngineView::primeEngine | ( | const NetIn & | netIn | ) |
| nodiscard override virtual

Implements gridfire::DynamicEngine.

Definition at line 212 of file engine_defined.cpp.

## ◆ setNetworkReactions()

void gridfire::DefinedEngineView::setNetworkReactions | ( | const reaction::LogicalReactionSet & | reactions | ) |
| override virtual

Implements gridfire::DynamicEngine.

Definition at line 114 of file engine_defined.cpp.

## ◆ setScreeningModel()

void gridfire::DefinedEngineView::setScreeningModel | ( | screening::ScreeningType | model | ) |
| override virtual

Sets the screening model for the base engine.

Parameters

  model | The screening model to set.

Implements gridfire::DynamicEngine.

Definition at line 180 of file engine_defined.cpp.

## ◆ update()

fourdst::composition::Composition gridfire::DefinedEngineView::update | ( | const NetIn & | netIn | ) |
| override virtual

Updates the engine view if it is marked as stale.

This method checks if the view is stale (e.g., after `setNetworkFile` was called). If it is, it rebuilds the active network from the currently set file. The `netIn` parameter is not used by this implementation but is required by the interface.

Parameters

  netIn | The current network input (unused).

Postcondition
  If the view was stale, it is rebuilt and is no longer stale.

Implements gridfire::DynamicEngine.

Definition at line 171 of file engine_defined.cpp.

## ◆ validateNetworkState()

void gridfire::DefinedEngineView::validateNetworkState | ( |  | ) | const
| private

Definition at line 313 of file engine_defined.cpp.

## Member Data Documentation

## ◆ m_activeReactions

reaction::LogicalReactionSet gridfire::DefinedEngineView::m_activeReactions
| private

Maps indices of active species to indices in the full network.

Definition at line 184 of file engine_defined.h.

## ◆ m_activeSpecies

std::vector<fourdst::atomic::Species> gridfire::DefinedEngineView::m_activeSpecies
| private

Active reactions in the defined engine.

Definition at line 182 of file engine_defined.h.

## ◆ m_baseEngine

DynamicEngine& gridfire::DefinedEngineView::m_baseEngine
| protected

Definition at line 178 of file engine_defined.h.

## ◆ m_isStale

bool gridfire::DefinedEngineView::m_isStale = true
| protected

Definition at line 177 of file engine_defined.h.

## ◆ m_logger

quill::Logger* gridfire::DefinedEngineView::m_logger = fourdst::logging::LogManager::getInstance().getLogger("log")
| private

Active species in the defined engine.

Logger instance for trace and debug information.

Definition at line 180 of file engine_defined.h.

## ◆ m_reactionIndexMap

std::vector<size_t> gridfire::DefinedEngineView::m_reactionIndexMap
| private

Definition at line 189 of file engine_defined.h.

## ◆ m_speciesIndexMap

std::vector<size_t> gridfire::DefinedEngineView::m_speciesIndexMap
| private

Maps indices of active reactions to indices in the full network.

Definition at line 187 of file engine_defined.h.

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

- src/include/gridfire/engine/views/engine_defined.h
- src/lib/engine/views/engine_defined.cpp