GridFire 0.0.1a General Purpose Nuclear Network

Loading...
Searching...
No Matches
engine_priming.cpp
Go to the documentation of this file.
1#include "gridfire/engine/views/engine_priming.h"
2#include "gridfire/solver/solver.h"
3
4#include "fourdst/composition/species.h"
5#include "fourdst/logging/logging.h"
6
7#include "quill/LogMacros.h"
8#include "quill/Logger.h"
9
10#include <vector>
11#include <string>
12#include <unordered_set>
13#include <stdexcept>
14#include <unordered_map>
15#include <utility>
16#include <ranges>
17#include <cmath>
18
19
20 namespace gridfire {
21 using fourdst::atomic::species;
22
23 NetworkPrimingEngineView::NetworkPrimingEngineView(
24 const std::string &primingSymbol,
25 DynamicEngine &baseEngine
26 ) :
27 DefinedEngineView(
28 constructPrimingReactionSet(
29 species.at(primingSymbol),
30 baseEngine
31 ),
32 baseEngine
33 ),
34 m_primingSpecies(species.at(primingSymbol)) {}
35
36 NetworkPrimingEngineView::NetworkPrimingEngineView(
37 const fourdst::atomic::Species &primingSpecies,
38 DynamicEngine &baseEngine
39 ) :
40 DefinedEngineView(
41 constructPrimingReactionSet(
42 primingSpecies,
43 baseEngine
44 ),
45 baseEngine
46 ),
47 m_primingSpecies(primingSpecies) {
48 }
49
50
51 std::vector<std::string> NetworkPrimingEngineView::constructPrimingReactionSet(
52 const fourdst::atomic::Species &primingSpecies,
53 const DynamicEngine &baseEngine
54 ) const {
55 std::unordered_set<std::string> primeReactions;
56 for (const auto &reaction : baseEngine.getNetworkReactions()) {
57 if (reaction.contains(primingSpecies)) {
58 primeReactions.insert(std::string(reaction.peName()));
59 }
60 }
61 if (primeReactions.empty()) {
62 LOG_ERROR(m_logger, "No priming reactions found for species '{}'.", primingSpecies.name());
63 m_logger->flush_log();
64 throw std::runtime_error("No priming reactions found for species '" + std::string(primingSpecies.name()) + "'.");
65 }
66 std::vector<std::string> primingReactionSet(primeReactions.begin(), primeReactions.end());
67 // LOG_INFO(m_logger, "Constructed priming reaction set with {} reactions for species '{}'.", primingReactionSet.size(), primingSpecies.name());
68 return primingReactionSet;
69 }
70
71
72
73}
gridfire::DefinedEngineView::DefinedEngineView
DefinedEngineView(const std::vector< std::string > &peNames, DynamicEngine &baseEngine)
Definition engine_defined.cpp:17
gridfire::DynamicEngine
Abstract class for engines supporting Jacobian and stoichiometry operations.
Definition engine_abstract.h:130
gridfire::DynamicEngine::getNetworkReactions
virtual const reaction::LogicalReactionSet & getNetworkReactions() const =0
Get the set of logical reactions in the network.
gridfire::NetworkPrimingEngineView::m_logger
quill::Logger * m_logger
Definition engine_priming.h:56
gridfire::NetworkPrimingEngineView::constructPrimingReactionSet
std::vector< std::string > constructPrimingReactionSet(const fourdst::atomic::Species &primingSpecies, const DynamicEngine &baseEngine) const
Constructs the set of reaction names that involve the priming species.
Definition engine_priming.cpp:51
gridfire::NetworkPrimingEngineView::NetworkPrimingEngineView
NetworkPrimingEngineView(const std::string &primingSymbol, DynamicEngine &baseEngine)
Constructs the view by looking up the priming species by symbol.
Definition engine_priming.cpp:23
gridfire::NetworkPrimingEngineView::m_primingSpecies
fourdst::atomic::Species m_primingSpecies
The priming species, if specified.
Definition engine_priming.h:57
engine_priming.h
gridfire::reaction
Definition reaction.h:25
gridfire
Definition engine_abstract.h:31
solver.h