GridFire 0.0.1a
General Purpose Nuclear Network
Loading...
Searching...
No Matches
engine_defined.h
Go to the documentation of this file.
1#pragma once
2
6#include "gridfire/network.h"
7
8#include "fourdst/config/config.h"
9#include "fourdst/logging/logging.h"
10
11#include "quill/Logger.h"
12
13#include <string>
14
15namespace gridfire{
16 class FileDefinedEngineView final: public DynamicEngine, public EngineView<DynamicEngine> {
17 public:
18 explicit FileDefinedEngineView(
19 DynamicEngine& baseEngine,
20 const std::string& fileName,
21 const io::NetworkFileParser& parser
22 );
23
24 // --- EngineView Interface ---
25 const DynamicEngine& getBaseEngine() const override;
26
27 // --- Engine Interface ---
28 const std::vector<fourdst::atomic::Species>& getNetworkSpecies() const override;
29
30 // --- DynamicEngine Interface ---
32 const std::vector<double>& Y_defined,
33 const double T9,
34 const double rho
35 ) const override;
37 const std::vector<double>& Y_defined,
38 const double T9,
39 const double rho
40 ) override;
42 const int i_defined,
43 const int j_defined
44 ) const override;
45 void generateStoichiometryMatrix() override;
47 const int speciesIndex_defined,
48 const int reactionIndex_defined
49 ) const override;
52 const std::vector<double>& Y_defined,
53 const double T9,
54 const double rho
55 ) const override;
57 std::unordered_map<fourdst::atomic::Species, double> getSpeciesTimescales(
58 const std::vector<double>& Y_defined,
59 const double T9,
60 const double rho
61 ) const override;
62
63 void update(const NetIn &netIn) override;
64
65 void setNetworkFile(const std::string& fileName);
66
68
69 [[nodiscard]] screening::ScreeningType getScreeningModel() const override;
70 private:
71 using Config = fourdst::config::Config;
72 using LogManager = fourdst::logging::LogManager;
73 Config& m_config = Config::getInstance();
74 quill::Logger* m_logger = LogManager::getInstance().getLogger("log");
75
77 std::string m_fileName;
79
80 std::vector<fourdst::atomic::Species> m_activeSpecies;
82
83 std::vector<size_t> m_speciesIndexMap;
84 std::vector<size_t> m_reactionIndexMap;
85
86 bool m_isStale = true;
87
88 private:
89 void buildFromFile(const std::string& fileName);
90
101 std::vector<size_t> constructSpeciesIndexMap() const;
102
113 std::vector<size_t> constructReactionIndexMap() const;
114
122 std::vector<double> mapViewToFull(const std::vector<double>& culled) const;
123
131 std::vector<double> mapFullToView(const std::vector<double>& full) const;
132
141 size_t mapViewToFullSpeciesIndex(size_t culledSpeciesIndex) const;
142
151 size_t mapViewToFullReactionIndex(size_t culledReactionIndex) const;
152
153 void validateNetworkState() const;
154 };
155}
Abstract class for engines supporting Jacobian and stoichiometry operations.
Abstract base class for a "view" of a reaction network engine.
const io::NetworkFileParser & m_parser
Parser for the network file.
double getJacobianMatrixEntry(const int i_defined, const int j_defined) const override
Get an entry from the previously generated Jacobian matrix.
std::string m_fileName
Name of the file defining the reaction set considered by the engine view.
void generateStoichiometryMatrix() override
Generate the stoichiometry matrix for the network.
std::vector< fourdst::atomic::Species > m_activeSpecies
Active species in the defined engine.
StepDerivatives< double > calculateRHSAndEnergy(const std::vector< double > &Y_defined, const double T9, const double rho) const override
Calculate the right-hand side (dY/dt) and energy generation.
void buildFromFile(const std::string &fileName)
void generateJacobianMatrix(const std::vector< double > &Y_defined, const double T9, const double rho) override
Generate the Jacobian matrix for the current state.
const DynamicEngine & getBaseEngine() const override
Access the underlying engine instance.
std::vector< size_t > constructSpeciesIndexMap() const
Constructs the species index map.
const reaction::LogicalReactionSet & getNetworkReactions() const override
Get the set of logical reactions in the network.
fourdst::config::Config Config
const std::vector< fourdst::atomic::Species > & getNetworkSpecies() const override
Get the list of species in the network.
size_t mapViewToFullSpeciesIndex(size_t culledSpeciesIndex) const
Maps a culled species index to a full species index.
FileDefinedEngineView(DynamicEngine &baseEngine, const std::string &fileName, const io::NetworkFileParser &parser)
void setNetworkFile(const std::string &fileName)
std::vector< double > mapFullToView(const std::vector< double > &full) const
Maps a vector of full abundances to a vector of culled abundances.
int getStoichiometryMatrixEntry(const int speciesIndex_defined, const int reactionIndex_defined) const override
Get an entry from the stoichiometry matrix.
std::vector< double > mapViewToFull(const std::vector< double > &culled) const
Maps a vector of culled abundances to a vector of full abundances.
double calculateMolarReactionFlow(const reaction::Reaction &reaction, const std::vector< double > &Y_defined, const double T9, const double rho) const override
Calculate the molar reaction flow for a given reaction.
fourdst::logging::LogManager LogManager
void update(const NetIn &netIn) override
std::unordered_map< fourdst::atomic::Species, double > getSpeciesTimescales(const std::vector< double > &Y_defined, const double T9, const double rho) const override
Compute timescales for all species in the network.
void setScreeningModel(screening::ScreeningType model) override
screening::ScreeningType getScreeningModel() const override
reaction::LogicalReactionSet m_activeReactions
Active reactions in the defined engine.
size_t mapViewToFullReactionIndex(size_t culledReactionIndex) const
Maps a culled reaction index to a full reaction index.
std::vector< size_t > constructReactionIndexMap() const
Constructs the reaction index map.
std::vector< size_t > m_speciesIndexMap
Maps indices of active species to indices in the full network.
std::vector< size_t > m_reactionIndexMap
Maps indices of active reactions to indices in the full network.
Represents a single nuclear reaction from a specific data source.
Definition reaction.h:72
Abstract interfaces for reaction network engines in GridFire.
Abstract interfaces for engine "views" in GridFire.
TemplatedReactionSet< LogicalReaction > LogicalReactionSet
A set of logical reactions.
Definition reaction.h:557
Structure holding derivatives and energy generation for a network step.