GridFire 0.0.1a
General Purpose Nuclear Network
Loading...
Searching...
No Matches
gridfire::FileDefinedEngineView Class Referencefinal

#include <engine_defined.h>

Inheritance diagram for gridfire::FileDefinedEngineView:
gridfire::DynamicEngine gridfire::EngineView< DynamicEngine > gridfire::Engine

Public Member Functions

 FileDefinedEngineView (DynamicEngine &baseEngine, const std::string &fileName, const io::NetworkFileParser &parser)
 
const DynamicEnginegetBaseEngine () const override
 Access the underlying engine instance.
 
const std::vector< fourdst::atomic::Species > & getNetworkSpecies () const override
 Get the list of species in the network.
 
StepDerivatives< double > calculateRHSAndEnergy (const std::vector< double > &Y_defined, const double T9, const double rho) const override
 Calculate the right-hand side (dY/dt) and energy generation.
 
void generateJacobianMatrix (const std::vector< double > &Y_defined, const double T9, const double rho) override
 Generate the Jacobian matrix for the current state.
 
double getJacobianMatrixEntry (const int i_defined, const int j_defined) const override
 Get an entry from the previously generated Jacobian matrix.
 
void generateStoichiometryMatrix () override
 Generate the stoichiometry matrix for the network.
 
int getStoichiometryMatrixEntry (const int speciesIndex_defined, const int reactionIndex_defined) const override
 Get an entry from the stoichiometry matrix.
 
double calculateMolarReactionFlow (const reaction::Reaction &reaction, const std::vector< double > &Y_defined, const double T9, const double rho) const override
 Calculate the molar reaction flow for a given reaction.
 
const reaction::LogicalReactionSetgetNetworkReactions () const override
 Get the set of logical reactions in the network.
 
std::unordered_map< fourdst::atomic::Species, double > getSpeciesTimescales (const std::vector< double > &Y_defined, const double T9, const double rho) const override
 Compute timescales for all species in the network.
 
void update (const NetIn &netIn) override
 
void setNetworkFile (const std::string &fileName)
 
void setScreeningModel (screening::ScreeningType model) override
 
screening::ScreeningType getScreeningModel () const override
 
- 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.
 

Private Types

using Config = fourdst::config::Config
 
using LogManager = fourdst::logging::LogManager
 

Private Member Functions

void buildFromFile (const std::string &fileName)
 
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 > &culled) 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 culledSpeciesIndex) const
 Maps a culled species index to a full species index.
 
size_t mapViewToFullReactionIndex (size_t culledReactionIndex) const
 Maps a culled reaction index to a full reaction index.
 
void validateNetworkState () const
 

Private Attributes

Configm_config = Config::getInstance()
 
quill::Logger * m_logger = LogManager::getInstance().getLogger("log")
 
DynamicEnginem_baseEngine
 
std::string m_fileName
 Name of the file defining the reaction set considered by the engine view.
 
const io::NetworkFileParserm_parser
 Parser for the network file.
 
std::vector< fourdst::atomic::Species > m_activeSpecies
 Active species in the defined engine.
 
reaction::LogicalReactionSet m_activeReactions
 Active reactions in the defined engine.
 
std::vector< size_t > m_speciesIndexMap
 Maps indices of active species to indices in the full network.
 
std::vector< size_t > m_reactionIndexMap
 Maps indices of active reactions to indices in the full network.
 
bool m_isStale = true
 

Detailed Description

Definition at line 16 of file engine_defined.h.

Member Typedef Documentation

◆ Config

using gridfire::FileDefinedEngineView::Config = fourdst::config::Config
private

Definition at line 71 of file engine_defined.h.

◆ LogManager

using gridfire::FileDefinedEngineView::LogManager = fourdst::logging::LogManager
private

Definition at line 72 of file engine_defined.h.

Constructor & Destructor Documentation

◆ FileDefinedEngineView()

gridfire::FileDefinedEngineView::FileDefinedEngineView ( DynamicEngine & baseEngine,
const std::string & fileName,
const io::NetworkFileParser & parser )
explicit

Definition at line 8 of file engine_defined.cpp.

Member Function Documentation

◆ buildFromFile()

void gridfire::FileDefinedEngineView::buildFromFile ( const std::string & fileName)
private

Definition at line 208 of file engine_defined.cpp.

◆ calculateMolarReactionFlow()

double gridfire::FileDefinedEngineView::calculateMolarReactionFlow ( const reaction::Reaction & reaction,
const std::vector< double > & Y,
const double T9,
const double rho ) const
overridevirtual

Calculate the molar reaction flow for a given reaction.

Parameters
reactionThe reaction for which to calculate the flow.
YVector of current abundances.
T9Temperature in units of 10^9 K.
rhoDensity in g/cm^3.
Returns
Molar flow rate for the reaction (e.g., mol/g/s).

This method computes the net rate at which the given reaction proceeds under the current state.

Implements gridfire::DynamicEngine.

Definition at line 85 of file engine_defined.cpp.

◆ calculateRHSAndEnergy()

StepDerivatives< double > gridfire::FileDefinedEngineView::calculateRHSAndEnergy ( const std::vector< double > & Y,
const double T9,
const double rho ) const
overridevirtual

Calculate the right-hand side (dY/dt) and energy generation.

Parameters
YVector of current abundances for all species.
T9Temperature in units of 10^9 K.
rhoDensity in g/cm^3.
Returns
StepDerivatives<double> containing dY/dt and energy generation rate.

This function must be implemented by derived classes to compute the time derivatives of all species and the specific nuclear energy generation rate for the current state.

Implements gridfire::Engine.

Definition at line 29 of file engine_defined.cpp.

◆ constructReactionIndexMap()

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

Constructs the reaction index map.

Returns
A vector mapping culled 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.

See also
AdaptiveEngineView::update()

Definition at line 176 of file engine_defined.cpp.

◆ constructSpeciesIndexMap()

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

Constructs the species index map.

Returns
A vector mapping culled 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.

See also
AdaptiveEngineView::update()

Definition at line 147 of file engine_defined.cpp.

◆ generateJacobianMatrix()

void gridfire::FileDefinedEngineView::generateJacobianMatrix ( const std::vector< double > & Y,
const double T9,
const double rho )
overridevirtual

Generate the Jacobian matrix for the current state.

Parameters
YVector of current abundances.
T9Temperature in units of 10^9 K.
rhoDensity in g/cm^3.

This method must compute and store the Jacobian matrix (∂(dY/dt)_i/∂Y_j) for the current state. The matrix can then be accessed via getJacobianMatrixEntry().

Implements gridfire::DynamicEngine.

Definition at line 45 of file engine_defined.cpp.

◆ generateStoichiometryMatrix()

void gridfire::FileDefinedEngineView::generateStoichiometryMatrix ( )
overridevirtual

Generate the stoichiometry matrix for the network.

This method must compute and store the stoichiometry matrix, which encodes the net change of each species in each reaction.

Implements gridfire::DynamicEngine.

Definition at line 68 of file engine_defined.cpp.

◆ getBaseEngine()

const DynamicEngine & gridfire::FileDefinedEngineView::getBaseEngine ( ) const
overridevirtual

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();
Abstract class for engines supporting Jacobian and stoichiometry operations.

Implements gridfire::EngineView< DynamicEngine >.

Definition at line 21 of file engine_defined.cpp.

◆ getJacobianMatrixEntry()

double gridfire::FileDefinedEngineView::getJacobianMatrixEntry ( const int i,
const int j ) const
overridevirtual

Get an entry from the previously generated Jacobian matrix.

Parameters
iRow index (species index).
jColumn index (species index).
Returns
Value of the Jacobian matrix at (i, j).

The Jacobian must have been generated by generateJacobianMatrix() before calling this.

Implements gridfire::DynamicEngine.

Definition at line 56 of file engine_defined.cpp.

◆ getNetworkReactions()

const reaction::LogicalReactionSet & gridfire::FileDefinedEngineView::getNetworkReactions ( ) const
overridevirtual

Get the set of logical reactions in the network.

Returns
Reference to the LogicalReactionSet containing all reactions.

Implements gridfire::DynamicEngine.

Definition at line 102 of file engine_defined.cpp.

◆ getNetworkSpecies()

const std::vector< Species > & gridfire::FileDefinedEngineView::getNetworkSpecies ( ) const
overridevirtual

Get the list of species in the network.

Returns
Vector of Species objects representing all network species.

Implements gridfire::Engine.

Definition at line 25 of file engine_defined.cpp.

◆ getScreeningModel()

screening::ScreeningType gridfire::FileDefinedEngineView::getScreeningModel ( ) const
nodiscardoverridevirtual

Implements gridfire::DynamicEngine.

Definition at line 143 of file engine_defined.cpp.

◆ getSpeciesTimescales()

std::unordered_map< Species, double > gridfire::FileDefinedEngineView::getSpeciesTimescales ( const std::vector< double > & Y,
const double T9,
const double rho ) const
overridevirtual

Compute timescales for all species in the network.

Parameters
YVector of current abundances.
T9Temperature in units of 10^9 K.
rhoDensity in g/cm^3.
Returns
Map from Species to their characteristic timescales (s).

This method estimates the timescale for abundance change of each species, which can be used for timestep control, diagnostics, and reaction network culling.

Implements gridfire::DynamicEngine.

Definition at line 108 of file engine_defined.cpp.

◆ getStoichiometryMatrixEntry()

int gridfire::FileDefinedEngineView::getStoichiometryMatrixEntry ( const int speciesIndex,
const int reactionIndex ) const
overridevirtual

Get an entry from the stoichiometry matrix.

Parameters
speciesIndexIndex of the species.
reactionIndexIndex of the reaction.
Returns
Stoichiometric coefficient for the species in the reaction.

The stoichiometry matrix must have been generated by generateStoichiometryMatrix().

Implements gridfire::DynamicEngine.

Definition at line 74 of file engine_defined.cpp.

◆ mapFullToView()

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

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

Parameters
fullA 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 276 of file engine_defined.cpp.

◆ mapViewToFull()

std::vector< double > gridfire::FileDefinedEngineView::mapViewToFull ( const std::vector< double > & culled) const
private

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

Parameters
culledA 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 culled vector.

Definition at line 267 of file engine_defined.cpp.

◆ mapViewToFullReactionIndex()

size_t gridfire::FileDefinedEngineView::mapViewToFullReactionIndex ( size_t culledReactionIndex) const
private

Maps a culled reaction index to a full reaction index.

Parameters
culledReactionIndexThe index of the reaction in the culled reaction list.
Returns
The index of the corresponding reaction in the full network.
Exceptions
std::out_of_rangeIf the culled index is out of bounds for the reaction index map.

Definition at line 294 of file engine_defined.cpp.

◆ mapViewToFullSpeciesIndex()

size_t gridfire::FileDefinedEngineView::mapViewToFullSpeciesIndex ( size_t culledSpeciesIndex) const
private

Maps a culled species index to a full species index.

Parameters
culledSpeciesIndexThe index of the species in the culled species list.
Returns
The index of the corresponding species in the full network.
Exceptions
std::out_of_rangeIf the culled index is out of bounds for the species index map.

Definition at line 285 of file engine_defined.cpp.

◆ setNetworkFile()

void gridfire::FileDefinedEngineView::setNetworkFile ( const std::string & fileName)

Definition at line 133 of file engine_defined.cpp.

◆ setScreeningModel()

void gridfire::FileDefinedEngineView::setScreeningModel ( screening::ScreeningType model)
overridevirtual

Implements gridfire::DynamicEngine.

Definition at line 139 of file engine_defined.cpp.

◆ update()

void gridfire::FileDefinedEngineView::update ( const NetIn & netIn)
overridevirtual

Implements gridfire::DynamicEngine.

Definition at line 127 of file engine_defined.cpp.

◆ validateNetworkState()

void gridfire::FileDefinedEngineView::validateNetworkState ( ) const
private

Definition at line 303 of file engine_defined.cpp.

Member Data Documentation

◆ m_activeReactions

reaction::LogicalReactionSet gridfire::FileDefinedEngineView::m_activeReactions
private

Active reactions in the defined engine.

Definition at line 81 of file engine_defined.h.

◆ m_activeSpecies

std::vector<fourdst::atomic::Species> gridfire::FileDefinedEngineView::m_activeSpecies
private

Active species in the defined engine.

Definition at line 80 of file engine_defined.h.

◆ m_baseEngine

DynamicEngine& gridfire::FileDefinedEngineView::m_baseEngine
private

Definition at line 76 of file engine_defined.h.

◆ m_config

Config& gridfire::FileDefinedEngineView::m_config = Config::getInstance()
private

Definition at line 73 of file engine_defined.h.

◆ m_fileName

std::string gridfire::FileDefinedEngineView::m_fileName
private

Name of the file defining the reaction set considered by the engine view.

Definition at line 77 of file engine_defined.h.

◆ m_isStale

bool gridfire::FileDefinedEngineView::m_isStale = true
private

Definition at line 86 of file engine_defined.h.

◆ m_logger

quill::Logger* gridfire::FileDefinedEngineView::m_logger = LogManager::getInstance().getLogger("log")
private

Definition at line 74 of file engine_defined.h.

◆ m_parser

const io::NetworkFileParser& gridfire::FileDefinedEngineView::m_parser
private

Parser for the network file.

Definition at line 78 of file engine_defined.h.

◆ m_reactionIndexMap

std::vector<size_t> gridfire::FileDefinedEngineView::m_reactionIndexMap
private

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

Definition at line 84 of file engine_defined.h.

◆ m_speciesIndexMap

std::vector<size_t> gridfire::FileDefinedEngineView::m_speciesIndexMap
private

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

Definition at line 83 of file engine_defined.h.


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