# GridFire: PyDynamicEngine Class Reference

Loading...
Searching...
No Matches
PyDynamicEngine Class Referencefinal

`#include <py_engine.h>`

Inheritance diagram for PyDynamicEngine:

## 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
void | generateJacobianMatrix (const std::vector< double > &Y_dynamic, double T9, double rho) const override
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
void | generateStoichiometryMatrix () override
| Generate the stoichiometry matrix for the network.
int | getStoichiometryMatrixEntry (int speciesIndex, int reactionIndex) const override
double | calculateMolarReactionFlow (const gridfire::reaction::Reaction &reaction, const std::vector< double > &Y, double T9, double rho) const override
const gridfire::reaction::ReactionSet & | getNetworkReactions () const override
| Get the set of logical reactions in the network.
void | setNetworkReactions (const gridfire::reaction::ReactionSet &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
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.
size_t | 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.
Public Member Functions inherited from gridfire::DynamicEngine
virtual void | generateJacobianMatrix (const fourdst::composition::Composition &comp, double T9, double rho) const =0
| Generate the Jacobian matrix for the current state.
virtual void | generateJacobianMatrix (const fourdst::composition::Composition &comp, double T9, double rho, const SparsityPattern &sparsityPattern) const
virtual double | getJacobianMatrixEntry (const fourdst::atomic::Species &rowSpecies, const fourdst::atomic::Species &colSpecies) const =0
| Get an entry from the previously generated Jacobian matrix.
virtual int | getStoichiometryMatrixEntry (const fourdst::atomic::Species &species, const reaction::Reaction &reaction) const =0
| Get an entry from the stoichiometry matrix.
virtual double | calculateMolarReactionFlow (const reaction::Reaction &reaction, const fourdst::composition::Composition &comp, double T9, double rho) const =0
| Calculate the molar reaction flow for a given reaction.
virtual EnergyDerivatives | calculateEpsDerivatives (const fourdst::composition::Composition &comp, double T9, double rho) const =0
| Calculate the derivatives of the energy generation rate with respect to T and rho.
virtual std::expected< std::unordered_map< fourdst::atomic::Species, double >, expectations::StaleEngineError > | getSpeciesTimescales (const fourdst::composition::Composition &comp, 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 fourdst::composition::Composition &comp, double T9, double rho) const =0
Public Member Functions inherited from gridfire::Engine
virtual | ~Engine ()=default
| Virtual destructor.
virtual std::expected< StepDerivatives< double >, expectations::StaleEngineError > | calculateRHSAndEnergy (const fourdst::composition::Composition &comp, double T9, double rho) const =0
| Calculate the right-hand side (dY/dt) and energy generation.

## Private Attributes

std::vector< fourdst::atomic::Species > | m_species_cache

## Member Function Documentation

## calculateMolarReactionFlow()

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

override

## calculateRHSAndEnergy()

std::expected< gridfire::StepDerivatives< double >, gridfire::expectations::StaleEngineError > PyDynamicEngine::calculateRHSAndEnergy | ( | const std::vector< double > & | Y,
|  | double | T9,
|  | double | rho ) const

override

## generateJacobianMatrix() [1/2]

void PyDynamicEngine::generateJacobianMatrix | ( | const std::vector< double > & | Y_dynamic,
|  | double | T9,
|  | double | rho ) const

override

## generateJacobianMatrix() [2/2]

void PyDynamicEngine::generateJacobianMatrix | ( | const std::vector< double > & | Y_dynamic,
|  | double | T9,
|  | double | rho,
|  | const gridfire::SparsityPattern & | sparsityPattern ) const

override

## generateStoichiometryMatrix()

void PyDynamicEngine::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.

## getDepth()

gridfire::BuildDepthType PyDynamicEngine::getDepth | ( |  | ) | const

inlineoverridevirtual

Get the depth of the network.

Returns
  The depth of the network, which may indicate the level of detail or complexity in the reaction 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.

## getJacobianMatrixEntry()

double PyDynamicEngine::getJacobianMatrixEntry | ( | int | i,
|  | int | j ) const

override

## getNetworkReactions()

const gridfire::reaction::ReactionSet & PyDynamicEngine::getNetworkReactions | ( |  | ) | const

overridevirtual

Get the set of logical reactions in the network.

Returns
  Reference to the LogicalReactionSet containing all reactions.

Implements gridfire::DynamicEngine.

## getNetworkSpecies()

const std::vector< fourdst::atomic::Species > & PyDynamicEngine::getNetworkSpecies | ( |  | ) | const

overridevirtual

PyDynamicEngine Implementation ///.

Implements gridfire::Engine.

## getScreeningModel()

gridfire::screening::ScreeningType PyDynamicEngine::getScreeningModel | ( |  | ) | const

overridevirtual

Get the current electron screening model.

Returns
  The currently active screening model type.

Usage Example:
  screening::ScreeningType currentModel = myEngine.getScreeningModel();

Implements gridfire::DynamicEngine.

## getSpeciesDestructionTimescales()

std::expected< std::unordered_map< fourdst::atomic::Species, double >, gridfire::expectations::StaleEngineError > PyDynamicEngine::getSpeciesDestructionTimescales | ( | const std::vector< double > & | Y,
|  | double | T9,
|  | double | rho ) const

override

## getSpeciesIndex()

size_t PyDynamicEngine::getSpeciesIndex | ( | const fourdst::atomic::Species & | species | ) | const

overridevirtual

Get the index of a species in the network.

Parameters

  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.

## getSpeciesTimescales()

std::expected< std::unordered_map< fourdst::atomic::Species, double >, gridfire::expectations::StaleEngineError > PyDynamicEngine::getSpeciesTimescales | ( | const std::vector< double > & | Y,
|  | double | T9,
|  | double | rho ) const

override

## getStoichiometryMatrixEntry()

int PyDynamicEngine::getStoichiometryMatrixEntry | ( | int | speciesIndex,
|  | int | reactionIndex ) const

override

## isStale()

bool PyDynamicEngine::isStale | ( | const gridfire::NetIn & | netIn | ) |

overridevirtual

Implements gridfire::DynamicEngine.

## mapNetInToMolarAbundanceVector()

std::vector< double > PyDynamicEngine::mapNetInToMolarAbundanceVector | ( | const gridfire::NetIn & | netIn | ) | const

overridevirtual

Map a NetIn object to a vector of molar abundances.

Parameters

  netIn | The input conditions for the network.

Returns
  A vector of molar abundances corresponding to the species in 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.

## primeEngine()

gridfire::PrimingReport PyDynamicEngine::primeEngine | ( | const gridfire::NetIn & | netIn | ) |

overridevirtual

Prime the engine with initial conditions.

Parameters

  netIn | The input conditions for the network.

Returns
  PrimingReport containing information about the priming process.

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.

## rebuild()

void PyDynamicEngine::rebuild | ( | const fourdst::composition::Composition & | comp,
|  | gridfire::BuildDepthType | depth )

inlineoverridevirtual

Rebuild the network with a specified depth.

Parameters

  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.

## setNetworkReactions()

void PyDynamicEngine::setNetworkReactions | ( | const gridfire::reaction::ReactionSet & | reactions | ) |

overridevirtual

Implements gridfire::DynamicEngine.

## setScreeningModel()

void PyDynamicEngine::setScreeningModel | ( | gridfire::screening::ScreeningType | model | ) |

overridevirtual

Set the electron screening model.

Parameters

  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.

Usage Example:
  myEngine.setScreeningModel(screening::ScreeningType::WEAK);

Postcondition
  The engine will use the specified screening model for subsequent rate calculations.

Implements gridfire::DynamicEngine.

## update()

fourdst::composition::Composition PyDynamicEngine::update | ( | const gridfire::NetIn & | netIn | ) |

overridevirtual

Update the internal state of the engine.

Parameters

  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.

Usage Example:
  NetIn input = { ... };
  myEngine.update(input);

Postcondition
  The internal state of the engine is updated to reflect the new conditions.

Implements gridfire::DynamicEngine.

## Member Data Documentation

## m_species_cache

std::vector<fourdst::atomic::Species> PyDynamicEngine::m_species_cache

mutableprivate

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

- src/python/engine/trampoline/py_engine.h
- src/python/engine/trampoline/py_engine.cpp