GridFire v0.7.6rc4.0
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 (scratch::StateBlob &ctx) const override
 Gets the list of active species in the network defined by the file.
 
std::expected< StepDerivatives< double >, EngineStatuscalculateRHSAndEnergy (scratch::StateBlob &ctx, const fourdst::composition::CompositionAbstract &comp, double T9, double rho, bool trust) const override
 Calculates the right-hand side (dY/dt) and energy generation for the active species.
 
EnergyDerivatives calculateEpsDerivatives (scratch::StateBlob &ctx, 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 (scratch::StateBlob &ctx, const fourdst::composition::CompositionAbstract &comp, double T9, double rho) const override
 Generates the Jacobian matrix for the active species.
 
NetworkJacobian generateJacobianMatrix (scratch::StateBlob &ctx, 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 (scratch::StateBlob &ctx, const fourdst::composition::CompositionAbstract &comp, double T9, double rho, const SparsityPattern &sparsityPattern) const override
 Generates the Jacobian matrix for a given sparsity pattern.
 
double calculateMolarReactionFlow (scratch::StateBlob &ctx, 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 (scratch::StateBlob &ctx) const override
 Gets the set of active logical reactions in the network.
 
std::expected< std::unordered_map< fourdst::atomic::Species, double >, EngineStatusgetSpeciesTimescales (scratch::StateBlob &ctx, 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 >, EngineStatusgetSpeciesDestructionTimescales (scratch::StateBlob &ctx, const fourdst::composition::CompositionAbstract &comp, double T9, double rho) const override
 Computes destruction timescales for all active species in the network.
 
fourdst::composition::Composition project (scratch::StateBlob &ctx, const NetIn &netIn) const override
 Updates the engine view if it is marked as stale.
 
screening::ScreeningType getScreeningModel (scratch::StateBlob &ctx) const override
 Gets the screening model from the base engine.
 
size_t getSpeciesIndex (scratch::StateBlob &ctx, const fourdst::atomic::Species &species) const override
 Maps a species from the full network to its index in the defined active network.
 
PrimingReport primeEngine (scratch::StateBlob &ctx, const NetIn &netIn) const override
 Prime the engine view for calculations. This will delegate to the base engine.
 
fourdst::composition::Composition collectComposition (scratch::StateBlob &ctx, const fourdst::composition::CompositionAbstract &comp, double T9, double rho) const override
 Collects a Composition object from the base engine.
 
SpeciesStatus getSpeciesStatus (scratch::StateBlob &ctx, const fourdst::atomic::Species &species) const override
 Gets the status of a species in the active network.
 
std::optional< StepDerivatives< double > > getMostRecentRHSCalculation (scratch::StateBlob &ctx) const override
 
std::unique_ptr< scratch::StateBlobconstructStateBlob (const scratch::StateBlob *blob) const override
 
- Public Member Functions inherited from gridfire::engine::DynamicEngine
virtual reaction::ReactionSet getInactiveNetworkReactions (scratch::StateBlob &ctx) const
 Get the set of inactive reactions in the network.
 
virtual double getInactiveReactionMolarReactionFlow (scratch::StateBlob &ctx, const reaction::Reaction &reaction, const fourdst::composition::CompositionAbstract &comp, const double T9, const double rho) const
 
- 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 (scratch::StateBlob &ctx) const
 Constructs the species index map.
 
std::vector< size_t > constructReactionIndexMap (scratch::StateBlob &ctx) const
 Constructs the reaction index map.
 
std::vector< double > mapViewToFull (scratch::StateBlob &ctx, const std::vector< double > &defined) const
 Maps a vector of culled abundances to a vector of full abundances.
 
size_t mapViewToFullSpeciesIndex (scratch::StateBlob &ctx, size_t definedSpeciesIndex) const
 Maps a culled species index to a full species index.
 
size_t mapViewToFullReactionIndex (scratch::StateBlob &ctx, size_t definedReactionIndex) const
 Maps a culled reaction index to a full reaction index.
 
void collect (scratch::StateBlob &ctx, const std::vector< std::string > &peNames) const
 

Static Private Member Functions

static std::vector< double > mapFullToView (scratch::StateBlob &ctx, const std::vector< double > &full)
 Maps a vector of full abundances to a vector of culled abundances.
 

Private Attributes

quill::Logger * m_logger = LogManager::getInstance().getLogger("log")
 Logger instance for trace and debug information.
 

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 ( scratch::StateBlob & ctx,
const fourdst::composition::CompositionAbstract & comp,
double T9,
double rho ) const
nodiscardoverridevirtual

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 ( scratch::StateBlob & ctx,
const reaction::Reaction & reaction,
const fourdst::composition::CompositionAbstract & comp,
double T9,
double rho ) const
nodiscardoverridevirtual

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 ( scratch::StateBlob & ctx,
const fourdst::composition::CompositionAbstract & comp,
double T9,
double rho,
bool trust ) const
nodiscardoverridevirtual

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.
trust
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 ( scratch::StateBlob & ctx,
const std::vector< std::string > & peNames ) const
private

◆ collectComposition()

fourdst::composition::Composition gridfire::engine::DefinedEngineView::collectComposition ( scratch::StateBlob & ctx,
const fourdst::composition::CompositionAbstract & comp,
double T9,
double rho ) const
nodiscardoverridevirtual

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 ( scratch::StateBlob & ctx) const
nodiscardprivate

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 ( scratch::StateBlob & ctx) const
nodiscardprivate

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.

◆ constructStateBlob()

std::unique_ptr< scratch::StateBlob > gridfire::engine::DefinedEngineView::constructStateBlob ( const scratch::StateBlob * blob) const
nodiscardoverridevirtual

◆ generateJacobianMatrix() [1/3]

NetworkJacobian gridfire::engine::DefinedEngineView::generateJacobianMatrix ( scratch::StateBlob & ctx,
const fourdst::composition::CompositionAbstract & comp,
double T9,
double rho ) const
nodiscardoverridevirtual

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 ( scratch::StateBlob & ctx,
const fourdst::composition::CompositionAbstract & comp,
double T9,
double rho,
const SparsityPattern & sparsityPattern ) const
nodiscardoverridevirtual

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 ( scratch::StateBlob & ctx,
const fourdst::composition::CompositionAbstract & comp,
double T9,
double rho,
const std::vector< fourdst::atomic::Species > & activeSpecies ) const
nodiscardoverridevirtual

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.

◆ getBaseEngine()

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

Get the base engine associated with this defined engine view.

Returns
A const reference to the base DynamicEngine.

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

◆ getMostRecentRHSCalculation()

std::optional< StepDerivatives< double > > gridfire::engine::DefinedEngineView::getMostRecentRHSCalculation ( scratch::StateBlob & ctx) const
nodiscardoverridevirtual

◆ getNetworkReactions()

const reaction::ReactionSet & gridfire::engine::DefinedEngineView::getNetworkReactions ( scratch::StateBlob & ctx) const
nodiscardoverridevirtual

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 ( scratch::StateBlob & ctx) const
nodiscardoverridevirtual

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 ( scratch::StateBlob & ctx) const
nodiscardoverridevirtual

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 ( scratch::StateBlob & ctx,
const fourdst::composition::CompositionAbstract & comp,
double T9,
double rho ) const
nodiscardoverridevirtual

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 ( scratch::StateBlob & ctx,
const fourdst::atomic::Species & species ) const
nodiscardoverridevirtual

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 ( scratch::StateBlob & ctx,
const fourdst::atomic::Species & species ) const
nodiscardoverridevirtual

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 ( scratch::StateBlob & ctx,
const fourdst::composition::CompositionAbstract & comp,
double T9,
double rho ) const
nodiscardoverridevirtual

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.

◆ mapFullToView()

std::vector< double > gridfire::engine::DefinedEngineView::mapFullToView ( scratch::StateBlob & ctx,
const std::vector< double > & full )
staticnodiscardprivate

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.

◆ mapViewToFull()

std::vector< double > gridfire::engine::DefinedEngineView::mapViewToFull ( scratch::StateBlob & ctx,
const std::vector< double > & defined ) const
nodiscardprivate

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 ( scratch::StateBlob & ctx,
size_t definedReactionIndex ) const
nodiscardprivate

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 ( scratch::StateBlob & ctx,
size_t definedSpeciesIndex ) const
nodiscardprivate

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 ( scratch::StateBlob & ctx,
const NetIn & netIn ) const
nodiscardoverridevirtual

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.

◆ project()

fourdst::composition::Composition gridfire::engine::DefinedEngineView::project ( scratch::StateBlob & ctx,
const NetIn & netIn ) const
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.

Member Data Documentation

◆ 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 = LogManager::getInstance().getLogger("log")
private

Logger instance for trace and debug information.


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