GridFire 0.0.1a
General Purpose Nuclear Network
Loading...
Searching...
No Matches
py_engine.h
Go to the documentation of this file.
1#pragma once
2
5
6#include "fourdst/composition/atomicSpecies.h"
7
8#include <vector>
9#include <expected>
10
11
12class PyEngine final : public gridfire::Engine {
13public:
14 const std::vector<fourdst::atomic::Species>& getNetworkSpecies() const override;
15 std::expected<gridfire::StepDerivatives<double>,gridfire::expectations::StaleEngineError> calculateRHSAndEnergy(const std::vector<double> &Y, double T9, double rho) const override;
16private:
17 mutable std::vector<fourdst::atomic::Species> m_species_cache;
18};
19
21public:
22 const std::vector<fourdst::atomic::Species>& getNetworkSpecies() const override;
23 std::expected<gridfire::StepDerivatives<double>,gridfire::expectations::StaleEngineError> calculateRHSAndEnergy(const std::vector<double> &Y, double T9, double rho) const override;
24 void generateJacobianMatrix(const std::vector<double> &Y_dynamic, double T9, double rho) const override;
25 void generateJacobianMatrix(const std::vector<double> &Y_dynamic, double T9, double rho, const gridfire::SparsityPattern &sparsityPattern) const override;
26 double getJacobianMatrixEntry(int i, int j) const override;
27 void generateStoichiometryMatrix() override;
28 int getStoichiometryMatrixEntry(int speciesIndex, int reactionIndex) const override;
29 double calculateMolarReactionFlow(const gridfire::reaction::Reaction &reaction, const std::vector<double> &Y, double T9, double rho) const override;
31 void setNetworkReactions(const gridfire::reaction::LogicalReactionSet& reactions) override;
32 std::expected<std::unordered_map<fourdst::atomic::Species, double>, gridfire::expectations::StaleEngineError> getSpeciesTimescales(const std::vector<double> &Y, double T9, double rho) const override;
33 std::expected<std::unordered_map<fourdst::atomic::Species, double>, gridfire::expectations::StaleEngineError> getSpeciesDestructionTimescales(const std::vector<double> &Y, double T9, double rho) const override;
34 fourdst::composition::Composition update(const gridfire::NetIn &netIn) override;
35 bool isStale(const gridfire::NetIn &netIn) override;
38 int getSpeciesIndex(const fourdst::atomic::Species &species) const override;
39 std::vector<double> mapNetInToMolarAbundanceVector(const gridfire::NetIn &netIn) const override;
42 throw std::logic_error("Network depth not supported by this engine.");
43 }
44 void rebuild(const fourdst::composition::Composition& comp, gridfire::BuildDepthType depth) override {
45 throw std::logic_error("Setting network depth not supported by this engine.");
46 }
47private:
48 mutable std::vector<fourdst::atomic::Species> m_species_cache;
49
50
51};
52
53class PyEngineView final : public gridfire::EngineView<gridfire::Engine> {
54 const gridfire::Engine& getBaseEngine() const override;
55};
56
57class PyDynamicEngineView final : public gridfire::EngineView<gridfire::DynamicEngine> {
58 const gridfire::DynamicEngine& getBaseEngine() const override;
59};
std::expected< std::unordered_map< fourdst::atomic::Species, double >, gridfire::expectations::StaleEngineError > getSpeciesDestructionTimescales(const std::vector< double > &Y, double T9, double rho) const 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.
double getJacobianMatrixEntry(int i, int j) const override
Get an entry from the previously generated Jacobian matrix.
Definition py_engine.cpp:97
void generateStoichiometryMatrix() override
Generate the stoichiometry matrix for the network.
std::vector< fourdst::atomic::Species > m_species_cache
Definition py_engine.h:48
int getSpeciesIndex(const fourdst::atomic::Species &species) const override
void rebuild(const fourdst::composition::Composition &comp, gridfire::BuildDepthType depth) override
Definition py_engine.h:44
bool isStale(const gridfire::NetIn &netIn) override
const gridfire::reaction::LogicalReactionSet & getNetworkReactions() const override
Get the set of logical reactions in the network.
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.
Definition py_engine.cpp:70
void generateJacobianMatrix(const std::vector< double > &Y_dynamic, double T9, double rho) const override
Generate the Jacobian matrix for the current state.
Definition py_engine.cpp:79
std::vector< double > mapNetInToMolarAbundanceVector(const gridfire::NetIn &netIn) const override
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.
int getStoichiometryMatrixEntry(int speciesIndex, int reactionIndex) const override
Get an entry from the stoichiometry matrix.
gridfire::screening::ScreeningType getScreeningModel() const override
Get the current electron screening model.
gridfire::PrimingReport primeEngine(const gridfire::NetIn &netIn) override
gridfire::BuildDepthType getDepth() const override
Definition py_engine.h:41
fourdst::composition::Composition update(const gridfire::NetIn &netIn) override
Update the internal state of the engine.
void setScreeningModel(gridfire::screening::ScreeningType model) override
Set the electron screening model.
const std::vector< fourdst::atomic::Species > & getNetworkSpecies() const override
PyDynamicEngine Implementation ///.
Definition py_engine.cpp:50
void setNetworkReactions(const gridfire::reaction::LogicalReactionSet &reactions) override
const gridfire::DynamicEngine & getBaseEngine() const override
Access the underlying engine instance.
const std::vector< fourdst::atomic::Species > & getNetworkSpecies() const override
Get the list of species in the network.
Definition py_engine.cpp:16
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.
Definition py_engine.cpp:37
std::vector< fourdst::atomic::Species > m_species_cache
Definition py_engine.h:17
const gridfire::Engine & getBaseEngine() const override
Access the underlying engine instance.
Abstract class for engines supporting Jacobian and stoichiometry operations.
Abstract base class for a reaction network engine.
Abstract base class for a "view" of a reaction network engine.
Represents a single nuclear reaction from a specific data source.
Definition reaction.h:72
Core header for the GridFire reaction network engine module.
TemplatedReactionSet< LogicalReaction > LogicalReactionSet
A set of logical reactions.
Definition reaction.h:563
ScreeningType
Enumerates the available plasma screening models.
std::variant< NetworkBuildDepth, int > BuildDepthType
Variant specifying either a predefined NetworkBuildDepth or a custom integer depth.
Definition building.h:37
std::vector< std::pair< size_t, size_t > > SparsityPattern
Captures the result of a network priming operation.
Definition reporting.h:67