GridFire 0.6.0
General Purpose Nuclear Network
|
#include <py_engine.h>
Public Member Functions | |
const std::vector< fourdst::atomic::Species > & | getNetworkSpecies () const override |
PyDynamicEngine Implementation ///. | |
std::expected< gridfire::StepDerivatives< double >, gridfire::expectations::StaleEngineError > | calculateRHSAndEnergy (const std::vector< double > &Y, double T9, double rho) const override |
Calculate the right-hand side (dY/dt) and energy generation. | |
void | generateJacobianMatrix (const std::vector< double > &Y_dynamic, double T9, double rho) const override |
Generate the Jacobian matrix for the current state. | |
void | generateJacobianMatrix (const std::vector< double > &Y_dynamic, double T9, double rho, const gridfire::SparsityPattern &sparsityPattern) const override |
double | getJacobianMatrixEntry (int i, int j) const override |
Get an entry from the previously generated Jacobian matrix. | |
void | generateStoichiometryMatrix () override |
Generate the stoichiometry matrix for the network. | |
int | getStoichiometryMatrixEntry (int speciesIndex, int reactionIndex) const override |
Get an entry from the stoichiometry matrix. | |
double | calculateMolarReactionFlow (const gridfire::reaction::Reaction &reaction, const std::vector< double > &Y, double T9, double rho) const override |
Calculate the molar reaction flow for a given reaction. | |
const gridfire::reaction::LogicalReactionSet & | getNetworkReactions () const override |
Get the set of logical reactions in the network. | |
void | setNetworkReactions (const gridfire::reaction::LogicalReactionSet &reactions) override |
std::expected< std::unordered_map< fourdst::atomic::Species, double >, gridfire::expectations::StaleEngineError > | getSpeciesTimescales (const std::vector< double > &Y, double T9, double rho) const override |
Compute timescales for all species in the network. | |
std::expected< std::unordered_map< fourdst::atomic::Species, double >, gridfire::expectations::StaleEngineError > | getSpeciesDestructionTimescales (const std::vector< double > &Y, double T9, double rho) const override |
fourdst::composition::Composition | update (const gridfire::NetIn &netIn) override |
Update the internal state of the engine. | |
bool | isStale (const gridfire::NetIn &netIn) override |
void | setScreeningModel (gridfire::screening::ScreeningType model) override |
Set the electron screening model. | |
gridfire::screening::ScreeningType | getScreeningModel () const override |
Get the current electron screening model. | |
int | getSpeciesIndex (const fourdst::atomic::Species &species) const override |
Get the index of a species in the network. | |
std::vector< double > | mapNetInToMolarAbundanceVector (const gridfire::NetIn &netIn) const override |
Map a NetIn object to a vector of molar abundances. | |
gridfire::PrimingReport | primeEngine (const gridfire::NetIn &netIn) override |
Prime the engine with initial conditions. | |
gridfire::BuildDepthType | getDepth () const override |
Get the depth of the network. | |
void | rebuild (const fourdst::composition::Composition &comp, gridfire::BuildDepthType depth) override |
Rebuild the network with a specified depth. | |
![]() | |
virtual | ~Engine ()=default |
Virtual destructor. | |
Private Attributes | |
std::vector< fourdst::atomic::Species > | m_species_cache |
|
overridevirtual |
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.
Implements gridfire::DynamicEngine.
|
overridevirtual |
Calculate the right-hand side (dY/dt) and energy generation.
Y | Vector of current abundances for all species. |
T9 | Temperature in units of 10^9 K. |
rho | Density in g/cm^3. |
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.
|
overridevirtual |
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().
Implements gridfire::DynamicEngine.
|
overridevirtual |
Reimplemented from gridfire::DynamicEngine.
|
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.
|
inlineoverridevirtual |
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 from gridfire::DynamicEngine.
|
overridevirtual |
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.
Implements gridfire::DynamicEngine.
|
overridevirtual |
Get the set of logical reactions in the network.
Implements gridfire::DynamicEngine.
|
overridevirtual |
PyDynamicEngine Implementation ///.
Implements gridfire::Engine.
|
overridevirtual |
Get the current electron screening model.
Implements gridfire::DynamicEngine.
|
overridevirtual |
Implements gridfire::DynamicEngine.
|
overridevirtual |
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.
Implements gridfire::DynamicEngine.
|
overridevirtual |
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.
Implements gridfire::DynamicEngine.
|
overridevirtual |
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().
Implements gridfire::DynamicEngine.
|
overridevirtual |
Implements gridfire::DynamicEngine.
|
overridevirtual |
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.
Implements gridfire::DynamicEngine.
|
overridevirtual |
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.
Implements gridfire::DynamicEngine.
|
inlineoverridevirtual |
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 from gridfire::DynamicEngine.
|
overridevirtual |
Implements gridfire::DynamicEngine.
|
overridevirtual |
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.
Implements gridfire::DynamicEngine.
|
overridevirtual |
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.
Implements gridfire::DynamicEngine.
|
mutableprivate |