GridFire 0.6.0
General Purpose Nuclear Network
|
Abstract class for engines supporting Jacobian and stoichiometry operations. More...
#include <engine_abstract.h>
Public Member Functions | |
virtual void | generateJacobianMatrix (const std::vector< double > &Y_dynamic, double T9, double rho) const =0 |
Generate the Jacobian matrix for the current state. | |
virtual void | generateJacobianMatrix (const std::vector< double > &Y_dynamic, double T9, double rho, const SparsityPattern &sparsityPattern) const |
virtual double | getJacobianMatrixEntry (int i, int j) const =0 |
Get an entry from the previously generated Jacobian matrix. | |
virtual void | generateStoichiometryMatrix ()=0 |
Generate the stoichiometry matrix for the network. | |
virtual int | getStoichiometryMatrixEntry (int speciesIndex, int reactionIndex) const =0 |
Get an entry from the stoichiometry matrix. | |
virtual double | calculateMolarReactionFlow (const reaction::Reaction &reaction, const std::vector< double > &Y, double T9, double rho) const =0 |
Calculate the molar reaction flow for a given reaction. | |
virtual const reaction::LogicalReactionSet & | getNetworkReactions () const =0 |
Get the set of logical reactions in the network. | |
virtual void | setNetworkReactions (const reaction::LogicalReactionSet &reactions)=0 |
virtual std::expected< std::unordered_map< fourdst::atomic::Species, double >, expectations::StaleEngineError > | getSpeciesTimescales (const std::vector< double > &Y, double T9, double rho) const =0 |
Compute timescales for all species in the network. | |
virtual std::expected< std::unordered_map< fourdst::atomic::Species, double >, expectations::StaleEngineError > | getSpeciesDestructionTimescales (const std::vector< double > &Y, double T9, double rho) const =0 |
virtual fourdst::composition::Composition | update (const NetIn &netIn)=0 |
Update the internal state of the engine. | |
virtual bool | isStale (const NetIn &netIn)=0 |
virtual void | setScreeningModel (screening::ScreeningType model)=0 |
Set the electron screening model. | |
virtual screening::ScreeningType | getScreeningModel () const =0 |
Get the current electron screening model. | |
virtual int | getSpeciesIndex (const fourdst::atomic::Species &species) const =0 |
Get the index of a species in the network. | |
virtual std::vector< double > | mapNetInToMolarAbundanceVector (const NetIn &netIn) const =0 |
Map a NetIn object to a vector of molar abundances. | |
virtual PrimingReport | primeEngine (const NetIn &netIn)=0 |
Prime the engine with initial conditions. | |
virtual BuildDepthType | getDepth () const |
Get the depth of the network. | |
virtual void | rebuild (const fourdst::composition::Composition &comp, BuildDepthType depth) |
Rebuild the network with a specified depth. | |
![]() | |
virtual | ~Engine ()=default |
Virtual destructor. | |
virtual const std::vector< fourdst::atomic::Species > & | getNetworkSpecies () const =0 |
Get the list of species in the network. | |
virtual std::expected< StepDerivatives< double >, expectations::StaleEngineError > | calculateRHSAndEnergy (const std::vector< double > &Y, double T9, double rho) const =0 |
Calculate the right-hand side (dY/dt) and energy generation. | |
Abstract class for engines supporting Jacobian and stoichiometry operations.
Extends Engine with additional methods for:
Intended usage: Derive from this class to implement engines that support advanced solver features such as implicit integration, sensitivity analysis, QSE (Quasi-Steady-State Equilibrium) handling, and more.
|
nodiscardpure virtual |
Calculate the molar reaction flow for a given reaction.
reaction | The reaction for which to calculate the flow. |
Y | Vector of current abundances. |
T9 | Temperature in units of 10^9 K. |
rho | Density in g/cm^3. |
This method computes the net rate at which the given reaction proceeds under the current state.
Implemented in gridfire::AdaptiveEngineView, gridfire::DefinedEngineView, gridfire::GraphEngine, gridfire::MultiscalePartitioningEngineView, and PyDynamicEngine.
|
pure virtual |
Generate the Jacobian matrix for the current state.
Y_dynamic | Vector of current abundances. |
T9 | Temperature in units of 10^9 K. |
rho | Density 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().
Implemented in gridfire::AdaptiveEngineView, gridfire::DefinedEngineView, gridfire::GraphEngine, gridfire::MultiscalePartitioningEngineView, and PyDynamicEngine.
|
inlinevirtual |
Reimplemented in gridfire::GraphEngine, and PyDynamicEngine.
|
pure virtual |
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.
Implemented in gridfire::AdaptiveEngineView, gridfire::DefinedEngineView, gridfire::GraphEngine, gridfire::MultiscalePartitioningEngineView, and PyDynamicEngine.
|
inlinenodiscardvirtual |
Get the depth of the network.
This method is intended to provide information about the network's structure, such as how many layers of reactions or species are present. It can be useful for diagnostics and understanding the network's complexity.
Reimplemented in gridfire::GraphEngine, and PyDynamicEngine.
|
nodiscardpure virtual |
Get an entry from the previously generated Jacobian matrix.
i | Row index (species index). |
j | Column index (species index). |
The Jacobian must have been generated by generateJacobianMatrix() before calling this.
Implemented in gridfire::AdaptiveEngineView, gridfire::DefinedEngineView, gridfire::GraphEngine, gridfire::MultiscalePartitioningEngineView, and PyDynamicEngine.
|
nodiscardpure virtual |
Get the set of logical reactions in the network.
Implemented in gridfire::AdaptiveEngineView, gridfire::DefinedEngineView, gridfire::GraphEngine, gridfire::MultiscalePartitioningEngineView, and PyDynamicEngine.
|
nodiscardpure virtual |
Get the current electron screening model.
Implemented in gridfire::AdaptiveEngineView, gridfire::DefinedEngineView, gridfire::GraphEngine, gridfire::MultiscalePartitioningEngineView, and PyDynamicEngine.
|
nodiscardpure virtual |
|
nodiscardpure virtual |
Get the index of a species in the network.
species | The species to look up. |
This method allows querying the index of a specific species in the engine's internal representation. It is useful for accessing species data efficiently.
Implemented in gridfire::AdaptiveEngineView, gridfire::DefinedEngineView, gridfire::GraphEngine, gridfire::MultiscalePartitioningEngineView, and PyDynamicEngine.
|
nodiscardpure virtual |
Compute timescales for all species in the network.
Y | Vector of current abundances. |
T9 | Temperature in units of 10^9 K. |
rho | Density in g/cm^3. |
This method estimates the timescale for abundance change of each species, which can be used for timestep control, diagnostics, and reaction network culling.
Implemented in gridfire::AdaptiveEngineView, gridfire::DefinedEngineView, gridfire::GraphEngine, gridfire::MultiscalePartitioningEngineView, and PyDynamicEngine.
|
nodiscardpure virtual |
Get an entry from the stoichiometry matrix.
speciesIndex | Index of the species. |
reactionIndex | Index of the reaction. |
The stoichiometry matrix must have been generated by generateStoichiometryMatrix().
Implemented in gridfire::AdaptiveEngineView, gridfire::DefinedEngineView, gridfire::GraphEngine, gridfire::MultiscalePartitioningEngineView, and PyDynamicEngine.
|
pure virtual |
|
nodiscardpure virtual |
Map a NetIn object to a vector of molar abundances.
netIn | The input conditions for the network. |
This method converts the input conditions into a vector of molar abundances, which can be used for further calculations or diagnostics.
Implemented in gridfire::AdaptiveEngineView, gridfire::DefinedEngineView, gridfire::GraphEngine, gridfire::MultiscalePartitioningEngineView, and PyDynamicEngine.
|
nodiscardpure virtual |
Prime the engine with initial conditions.
netIn | The input conditions for the network. |
This method is used to prepare the engine for calculations by setting up initial conditions, reactions, and species. It may involve compiling reaction rates, initializing internal data structures, and performing any necessary pre-computation.
Implemented in gridfire::AdaptiveEngineView, gridfire::DefinedEngineView, gridfire::GraphEngine, gridfire::MultiscalePartitioningEngineView, and PyDynamicEngine.
|
inlinevirtual |
Rebuild the network with a specified depth.
comp | The composition to rebuild the network with. |
depth | The desired depth of the network. |
This method is intended to allow dynamic adjustment of the network's depth, which may involve adding or removing species and reactions based on the specified depth. However, not all engines support this operation.
Reimplemented in gridfire::GraphEngine, and PyDynamicEngine.
|
pure virtual |
|
pure virtual |
Set the electron screening model.
model | The type of screening model to use for reaction rate calculations. |
This method allows changing the screening model at runtime. Screening corrections account for the electrostatic shielding of nuclei by electrons, which affects reaction rates in dense stellar plasmas.
Implemented in gridfire::AdaptiveEngineView, gridfire::DefinedEngineView, gridfire::GraphEngine, gridfire::MultiscalePartitioningEngineView, and PyDynamicEngine.
|
pure virtual |
Update the internal state of the engine.
netIn | A struct containing the current network input, such as temperature, density, and composition. |
This method is intended to be implemented by derived classes to update their internal state based on the provided network conditions. For example, an adaptive engine might use this to re-evaluate which reactions and species are active. For other engines that do not support manually updating, this method might do nothing.
Implemented in gridfire::AdaptiveEngineView, gridfire::DefinedEngineView, gridfire::GraphEngine, gridfire::MultiscalePartitioningEngineView, and PyDynamicEngine.