GridFire v0.7.1_rc2
General Purpose Nuclear Network
Loading...
Searching...
No Matches
gridfire::engine::DefinedEngineView Class Reference

#include <engine_defined.h>

Inheritance diagram for gridfire::engine::DefinedEngineView:
[legend]
Collaboration diagram for gridfire::engine::DefinedEngineView:
[legend]

Public Member Functions

 DefinedEngineView (const std::vector< std::string > &peNames, GraphEngine &baseEngine)
 
const DynamicEnginegetBaseEngine () const override
 Get the base engine associated with this defined engine view.
 
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 >, engine::EngineStatuscalculateRHSAndEnergy (const fourdst::composition::CompositionAbstract &comp, double T9, double rho) const override
 Calculates the right-hand side (dY/dt) and energy generation for the active species.
 
EnergyDerivatives calculateEpsDerivatives (const fourdst::composition::CompositionAbstract &comp, double T9, double rho) const override
 Calculate the derivatives of the energy generation rate with respect to T and rho.
 
NetworkJacobian generateJacobianMatrix (const fourdst::composition::CompositionAbstract &comp, double T9, double rho) const override
 Generates the Jacobian matrix for the active species.
 
NetworkJacobian generateJacobianMatrix (const fourdst::composition::CompositionAbstract &comp, double T9, double rho, const std::vector< fourdst::atomic::Species > &activeSpecies) const override
 Generates the Jacobian matrix for the active species.
 
NetworkJacobian generateJacobianMatrix (const fourdst::composition::CompositionAbstract &comp, double T9, double rho, const SparsityPattern &sparsityPattern) const override
 Generates the Jacobian matrix for a given sparsity pattern.
 
void generateStoichiometryMatrix () override
 Generates the stoichiometry matrix for the active reactions and species.
 
int getStoichiometryMatrixEntry (const fourdst::atomic::Species &species, const reaction::Reaction &reaction) const override
 Gets an entry from the stoichiometry matrix for the active species and reactions.
 
double calculateMolarReactionFlow (const reaction::Reaction &reaction, const fourdst::composition::CompositionAbstract &comp, double T9, double rho) const override
 Calculates the molar reaction flow for a given reaction in the active network.
 
const reaction::ReactionSetgetNetworkReactions () const override
 Gets the set of active logical reactions in the network.
 
void setNetworkReactions (const reaction::ReactionSet &reactions) override
 Sets the active reactions in the network.
 
std::expected< std::unordered_map< fourdst::atomic::Species, double >, engine::EngineStatusgetSpeciesTimescales (const fourdst::composition::CompositionAbstract &comp, double T9, double rho) const override
 Computes timescales for all active species in the network.
 
std::expected< std::unordered_map< fourdst::atomic::Species, double >, engine::EngineStatusgetSpeciesDestructionTimescales (const fourdst::composition::CompositionAbstract &comp, double T9, double rho) const override
 Computes destruction timescales for all active species in the network.
 
fourdst::composition::Composition update (const NetIn &netIn) override
 Updates the engine view if it is marked as stale.
 
bool isStale (const NetIn &netIn) override
 Checks if the engine view is stale.
 
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.
 
size_t getSpeciesIndex (const fourdst::atomic::Species &species) const override
 Maps a species from the full network to its index in the defined active network.
 
std::vector< double > mapNetInToMolarAbundanceVector (const NetIn &netIn) const override
 Map from a NetIn object to a vector of molar abundances for the active species.
 
PrimingReport primeEngine (const NetIn &netIn) override
 Prime the engine view for calculations. This will delegate to the base engine.
 
fourdst::composition::Composition collectComposition (const fourdst::composition::CompositionAbstract &comp, double T9, double rho) const override
 Collects a Composition object from the base engine.
 
SpeciesStatus getSpeciesStatus (const fourdst::atomic::Species &species) const override
 Gets the status of a species in the active network.
 
- Public Member Functions inherited from gridfire::engine::DynamicEngine
virtual BuildDepthType getDepth () const
 Get the depth of the network.
 
virtual void rebuild (const fourdst::composition::CompositionAbstract &comp, BuildDepthType depth)
 Rebuild the network with a specified depth.
 
- Public Member Functions inherited from gridfire::engine::Engine
virtual ~Engine ()=default
 Virtual destructor.
 
- Public Member Functions inherited from gridfire::engine::EngineView< DynamicEngine >
virtual ~EngineView ()=default
 Virtual destructor.
 

Protected Attributes

bool m_isStale = true
 
GraphEnginem_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::set< fourdst::atomic::Species > m_activeSpecies
 Cache for the active species vector to avoid dangling references.
 
std::optional< std::vector< fourdst::atomic::Species > > m_activeSpeciesVectorCache = std::nullopt
 Active reactions in the defined engine.
 
reaction::ReactionSet 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
 

Constructor & Destructor Documentation

◆ DefinedEngineView()

gridfire::engine::DefinedEngineView::DefinedEngineView ( const std::vector< std::string > &  peNames,
GraphEngine baseEngine 
)

Member Function Documentation

◆ calculateEpsDerivatives()

EnergyDerivatives gridfire::engine::DefinedEngineView::calculateEpsDerivatives ( const fourdst::composition::CompositionAbstract &  comp,
double  T9,
double  rho 
) const
overridevirtual

Calculate the derivatives of the energy generation rate with respect to T and rho.

Parameters
compComposition object containing current abundances.
T9Temperature in units of 10^9 K.
rhoDensity in g/cm^3.
Returns
EnergyDerivatives containing dEps/dT and dEps/dRho.

This method computes the partial derivatives of the specific nuclear energy generation rate with respect to temperature and density for the current state.

Implements gridfire::engine::DynamicEngine.

◆ calculateMolarReactionFlow()

double gridfire::engine::DefinedEngineView::calculateMolarReactionFlow ( const reaction::Reaction reaction,
const fourdst::composition::CompositionAbstract &  comp,
double  T9,
double  rho 
) const
overridevirtual

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

Parameters
reactionThe reaction for which to calculate the flow.
compA Composition object containing the current composition of the system
T9Temperature in units of 10^9 K.
rhoDensity in g/cm^3.
Returns
Molar flow rate for the reaction (e.g., mol/g/s).
Exceptions
std::runtime_errorIf the view is stale or if the reaction is not in the active set.

Implements gridfire::engine::DynamicEngine.

◆ calculateRHSAndEnergy()

std::expected< StepDerivatives< double >, EngineStatus > gridfire::engine::DefinedEngineView::calculateRHSAndEnergy ( const fourdst::composition::CompositionAbstract &  comp,
double  T9,
double  rho 
) const
overridevirtual

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

Parameters
compA Composition object containing the current composition of the system
T9The temperature in units of 10^9 K.
rhoThe 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_errorIf the view is stale (i.e., update() has not been called after setNetworkFile()).

Implements gridfire::engine::Engine.

◆ collect()

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

◆ collectComposition()

fourdst::composition::Composition gridfire::engine::DefinedEngineView::collectComposition ( const fourdst::composition::CompositionAbstract &  comp,
double  T9,
double  rho 
) const
overridevirtual

Collects a Composition object from the base engine.

Parameters
compThe full Composition object.
T9The temperature in units of 10^9 K.
rhoThe density in g/cm^3.
Returns
A composition object representing the state of the engine stack and the current view.

Implements gridfire::engine::DynamicEngine.

◆ constructReactionIndexMap()

std::vector< size_t > gridfire::engine::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_errorIf an active reaction is not found in the base engine's reaction list.

◆ constructSpeciesIndexMap()

std::vector< size_t > gridfire::engine::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_errorIf an active species is not found in the base engine's species list.

◆ generateJacobianMatrix() [1/3]

NetworkJacobian gridfire::engine::DefinedEngineView::generateJacobianMatrix ( const fourdst::composition::CompositionAbstract &  comp,
double  T9,
double  rho 
) const
overridevirtual

Generates the Jacobian matrix for the active species.

Parameters
compA Composition object containing the current composition of the system
T9The temperature in units of 10^9 K.
rhoThe density in g/cm^3.
Exceptions
std::runtime_errorIf the view is stale.

Implements gridfire::engine::DynamicEngine.

◆ generateJacobianMatrix() [2/3]

NetworkJacobian gridfire::engine::DefinedEngineView::generateJacobianMatrix ( const fourdst::composition::CompositionAbstract &  comp,
double  T9,
double  rho,
const SparsityPattern sparsityPattern 
) const
overridevirtual

Generates the Jacobian matrix for a given sparsity pattern.

Parameters
compA Composition object containing the current composition of the system
T9The temperature in units of 10^9 K.
rhoThe density in g/cm^3.
sparsityPatternThe sparsity pattern to use for the Jacobian matrix.
Exceptions
std::runtime_errorIf the view is stale.

Implements gridfire::engine::DynamicEngine.

◆ generateJacobianMatrix() [3/3]

NetworkJacobian gridfire::engine::DefinedEngineView::generateJacobianMatrix ( const fourdst::composition::CompositionAbstract &  comp,
double  T9,
double  rho,
const std::vector< fourdst::atomic::Species > &  activeSpecies 
) const
overridevirtual

Generates the Jacobian matrix for the active species.

Parameters
compA Composition object containing the current composition of the system
T9The temperature in units of 10^9 K.
rhoThe density in g/cm^3.
activeSpeciesThe vector of active species to include in the Jacobian.
Exceptions
std::runtime_errorIf the view is stale.

Implements gridfire::engine::DynamicEngine.

◆ generateStoichiometryMatrix()

void gridfire::engine::DefinedEngineView::generateStoichiometryMatrix ( )
overridevirtual

Generates the stoichiometry matrix for the active reactions and species.

Exceptions
std::runtime_errorIf the view is stale.

Implements gridfire::engine::DynamicEngine.

◆ getBaseEngine()

const DynamicEngine & gridfire::engine::DefinedEngineView::getBaseEngine ( ) const
overridevirtual

Get the base engine associated with this defined engine view.

Returns
A const reference to the base DynamicEngine.

Implements gridfire::engine::EngineView< DynamicEngine >.

◆ getNetworkReactions()

const reaction::ReactionSet & gridfire::engine::DefinedEngineView::getNetworkReactions ( ) const
overridevirtual

Gets the set of active logical reactions in the network.

Returns
Reference to the LogicalReactionSet containing all active reactions.
Exceptions
std::runtime_errorIf the view is stale.

Implements gridfire::engine::DynamicEngine.

◆ getNetworkSpecies()

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

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::Engine.

◆ getScreeningModel()

screening::ScreeningType gridfire::engine::DefinedEngineView::getScreeningModel ( ) const
overridevirtual

Gets the screening model from the base engine.

Returns
The current screening model type.

Implements gridfire::engine::DynamicEngine.

◆ getSpeciesDestructionTimescales()

std::expected< std::unordered_map< Species, double >, EngineStatus > gridfire::engine::DefinedEngineView::getSpeciesDestructionTimescales ( const fourdst::composition::CompositionAbstract &  comp,
double  T9,
double  rho 
) const
overridevirtual

Computes destruction timescales for all active species in the network.

Parameters
compA Composition object containing the current composition of the system
T9Temperature in units of 10^9 K.
rhoDensity in g/cm^3.
Returns
Map from Species to their destruction timescales (s).
Exceptions
std::runtime_errorIf the view is stale.

Implements gridfire::engine::DynamicEngine.

◆ getSpeciesIndex()

size_t gridfire::engine::DefinedEngineView::getSpeciesIndex ( const fourdst::atomic::Species &  species) const
overridevirtual

Maps a species from the full network to its index in the defined active network.

Parameters
speciesThe species to map.
Returns
The index of the species in the active network.
Exceptions
std::runtime_errorIf the species is not in the active set.

Implements gridfire::engine::DynamicEngine.

◆ getSpeciesStatus()

SpeciesStatus gridfire::engine::DefinedEngineView::getSpeciesStatus ( const fourdst::atomic::Species &  species) const
overridevirtual

Gets the status of a species in the active network.

Parameters
speciesThe species for which to get the status.
Returns
The SpeciesStatus indicating if the species is active, inactive, or not present.

Implements gridfire::engine::DynamicEngine.

◆ getSpeciesTimescales()

std::expected< std::unordered_map< Species, double >, EngineStatus > gridfire::engine::DefinedEngineView::getSpeciesTimescales ( const fourdst::composition::CompositionAbstract &  comp,
double  T9,
double  rho 
) const
overridevirtual

Computes timescales for all active species in the network.

Parameters
compA Composition object containing the current composition of the system
T9Temperature in units of 10^9 K.
rhoDensity in g/cm^3.
Returns
Map from Species to their characteristic timescales (s).
Exceptions
std::runtime_errorIf the view is stale.

Implements gridfire::engine::DynamicEngine.

◆ getStoichiometryMatrixEntry()

int gridfire::engine::DefinedEngineView::getStoichiometryMatrixEntry ( const fourdst::atomic::Species &  species,
const reaction::Reaction reaction 
) const
overridevirtual

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

Parameters
speciesThe species for which to get the stoichiometric coefficient.
reactionThe reaction for which to get the stoichiometric coefficient.
Returns
The stoichiometric coefficient for the given species and reaction.
Exceptions
std::runtime_errorIf the view is stale.
std::out_of_rangeIf an index is out of bounds.

Implements gridfire::engine::DynamicEngine.

◆ isStale()

bool gridfire::engine::DefinedEngineView::isStale ( const NetIn netIn)
overridevirtual

Checks if the engine view is stale.

Parameters
netInThe current network input (unused).
Returns
True if the view is stale and needs to be updated; false otherwise.

Implements gridfire::engine::DynamicEngine.

◆ mapFullToView()

std::vector< double > gridfire::engine::DefinedEngineView::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.

◆ mapNetInToMolarAbundanceVector()

std::vector< double > gridfire::engine::DefinedEngineView::mapNetInToMolarAbundanceVector ( const NetIn netIn) const
overridevirtual

Map from a NetIn object to a vector of molar abundances for the active species.

Parameters
netInThe NetIn object containing the full network abundances.
Returns
A vector of molar abundances for the active species.

Implements gridfire::engine::DynamicEngine.

◆ mapViewToFull()

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

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

Parameters
definedA 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.

◆ mapViewToFullReactionIndex()

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

Maps a culled reaction index to a full reaction index.

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

◆ mapViewToFullSpeciesIndex()

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

Maps a culled species index to a full species index.

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

◆ primeEngine()

PrimingReport gridfire::engine::DefinedEngineView::primeEngine ( const NetIn netIn)
overridevirtual

Prime the engine view for calculations. This will delegate to the base engine.

Parameters
netInThe current network input.
Returns
The PrimingReport from the base engine.

Implements gridfire::engine::DynamicEngine.

◆ setNetworkReactions()

void gridfire::engine::DefinedEngineView::setNetworkReactions ( const reaction::ReactionSet reactions)
overridevirtual

Sets the active reactions in the network.

Parameters
reactionsThe ReactionSet containing the reactions to set as active.
Postcondition
The view is marked as stale and will need to be updated.

Implements gridfire::engine::DynamicEngine.

◆ setScreeningModel()

void gridfire::engine::DefinedEngineView::setScreeningModel ( screening::ScreeningType  model)
overridevirtual

Sets the screening model for the base engine.

Parameters
modelThe screening model to set.

Implements gridfire::engine::DynamicEngine.

◆ update()

fourdst::composition::Composition gridfire::engine::DefinedEngineView::update ( const NetIn netIn)
overridevirtual

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
netInThe current network input (unused).
Postcondition
If the view was stale, it is rebuilt and is no longer stale.

Implements gridfire::engine::DynamicEngine.

◆ validateNetworkState()

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

Member Data Documentation

◆ m_activeReactions

reaction::ReactionSet gridfire::engine::DefinedEngineView::m_activeReactions
private

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

◆ m_activeSpecies

std::set<fourdst::atomic::Species> gridfire::engine::DefinedEngineView::m_activeSpecies
private

Cache for the active species vector to avoid dangling references.

◆ m_activeSpeciesVectorCache

std::optional<std::vector<fourdst::atomic::Species> > gridfire::engine::DefinedEngineView::m_activeSpeciesVectorCache = std::nullopt
mutableprivate

Active reactions in the defined engine.

◆ m_baseEngine

GraphEngine& gridfire::engine::DefinedEngineView::m_baseEngine
protected

◆ m_isStale

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

◆ m_logger

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

Active species in the defined engine.

Logger instance for trace and debug information.

◆ m_reactionIndexMap

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

◆ m_speciesIndexMap

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

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


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