GridFire 0.0.1a
General Purpose Nuclear Network
Loading...
Searching...
No Matches
engine_adaptive.h
Go to the documentation of this file.
1#pragma once
4#include "gridfire/network.h"
5
6#include "fourdst/composition/atomicSpecies.h"
7#include "fourdst/config/config.h"
8#include "fourdst/logging/logging.h"
9
10#include "quill/Logger.h"
11
12namespace gridfire {
45 class AdaptiveEngineView final : public DynamicEngine, public EngineView<DynamicEngine> {
46 public:
55 explicit AdaptiveEngineView(DynamicEngine& baseEngine);
56
74 void update(const NetIn& netIn);
75
80 const std::vector<fourdst::atomic::Species>& getNetworkSpecies() const override;
81
99 const std::vector<double> &Y_culled,
100 const double T9,
101 const double rho
102 ) const override;
103
118 const std::vector<double> &Y_culled,
119 const double T9,
120 const double rho
121 ) override;
122
138 const int i_culled,
139 const int j_culled
140 ) const override;
141
151 void generateStoichiometryMatrix() override;
152
168 const int speciesIndex_culled,
169 const int reactionIndex_culled
170 ) const override;
171
189 const std::vector<double> &Y_culled,
190 double T9,
191 double rho
192 ) const override;
193
200
214 std::unordered_map<fourdst::atomic::Species, double> getSpeciesTimescales(
215 const std::vector<double> &Y_culled,
216 double T9,
217 double rho
218 ) const override;
219
224 const DynamicEngine& getBaseEngine() const override { return m_baseEngine; }
225 private:
226 using Config = fourdst::config::Config;
227 using LogManager = fourdst::logging::LogManager;
228 Config& m_config = Config::getInstance();
229 quill::Logger* m_logger = LogManager::getInstance().getLogger("log");
230
232
233 std::vector<fourdst::atomic::Species> m_activeSpecies;
235
236 std::vector<size_t> m_speciesIndexMap;
237 std::vector<size_t> m_reactionIndexMap;
238
239 bool m_isStale = true;
240
241 private:
252 std::vector<size_t> constructSpeciesIndexMap() const;
253
264 std::vector<size_t> constructReactionIndexMap() const;
265
273 std::vector<double> mapCulledToFull(const std::vector<double>& culled) const;
274
282 std::vector<double> mapFullToCulled(const std::vector<double>& full) const;
283
292 size_t mapCulledToFullSpeciesIndex(size_t culledSpeciesIndex) const;
293
302 size_t mapCulledToFullReactionIndex(size_t culledReactionIndex) const;
303
309 void validateState() const;
310 private:
318 };
319}
double calculateMolarReactionFlow(const reaction::Reaction &reaction, const std::vector< double > &Y_culled, double T9, double rho) const override
Calculates the molar reaction flow for a given reaction in the active network.
const reaction::LogicalReactionSet & getNetworkReactions() const override
Gets the set of active logical reactions in the network.
reaction::LogicalReactionSet m_activeReactions
std::vector< size_t > m_reactionIndexMap
void generateStoichiometryMatrix() override
Generates the stoichiometry matrix for the active reactions and species.
size_t mapCulledToFullSpeciesIndex(size_t culledSpeciesIndex) const
Maps a culled species index to a full species index.
std::vector< double > mapFullToCulled(const std::vector< double > &full) const
Maps a vector of full abundances to a vector of culled abundances.
void update(const NetIn &netIn)
Updates the active species and reactions based on the current conditions.
double getJacobianMatrixEntry(const int i_culled, const int j_culled) const override
Gets an entry from the Jacobian matrix for the active species.
fourdst::logging::LogManager LogManager
std::vector< size_t > m_speciesIndexMap
int getStoichiometryMatrixEntry(const int speciesIndex_culled, const int reactionIndex_culled) const override
Gets an entry from the stoichiometry matrix for the active species and reactions.
std::vector< double > mapCulledToFull(const std::vector< double > &culled) const
Maps a vector of culled abundances to a vector of full abundances.
StepDerivatives< double > calculateRHSAndEnergy(const std::vector< double > &Y_culled, const double T9, const double rho) const override
Calculates the right-hand side (dY/dt) and energy generation for the active species.
std::vector< size_t > constructReactionIndexMap() const
Constructs the reaction index map.
std::vector< size_t > constructSpeciesIndexMap() const
Constructs the species index map.
size_t mapCulledToFullReactionIndex(size_t culledReactionIndex) const
Maps a culled reaction index to a full reaction index.
std::unordered_map< fourdst::atomic::Species, double > getSpeciesTimescales(const std::vector< double > &Y_culled, double T9, double rho) const override
Computes timescales for all active species in the network.
const std::vector< fourdst::atomic::Species > & getNetworkSpecies() const override
Gets the list of active species in the network.
void generateJacobianMatrix(const std::vector< double > &Y_culled, const double T9, const double rho) override
Generates the Jacobian matrix for the active species.
AdaptiveEngineView(DynamicEngine &baseEngine)
Constructs an AdaptiveEngineView.
void validateState() const
Validates that the AdaptiveEngineView is not stale.
const DynamicEngine & getBaseEngine() const override
Gets the base engine.
std::vector< fourdst::atomic::Species > m_activeSpecies
fourdst::config::Config Config
Abstract class for engines supporting Jacobian and stoichiometry operations.
Abstract base class for a "view" of a reaction network engine.
A collection of LogicalReaction objects.
Definition reaction.h:554
Represents a single nuclear reaction from a specific data source.
Definition reaction.h:71
Abstract interfaces for reaction network engines in GridFire.
Abstract interfaces for engine "views" in GridFire.
A struct to hold a reaction and its flow rate.
Structure holding derivatives and energy generation for a network step.