Loading...
Searching...
No Matches
engine_priming.cpp
Go to the documentation of this file.
#include "gridfire/engine/views/engine_priming.h"
#include "gridfire/solver/solver.h"
#include "fourdst/composition/species.h"
#include "fourdst/logging/logging.h"
#include "quill/LogMacros.h"
#include "quill/Logger.h"
#include <vector>
#include <string>
#include <unordered_set>
#include <stdexcept>
#include <unordered_map>
#include <utility>
#include <ranges>
#include <cmath>
namespace gridfire {
using fourdst::atomic::species;
NetworkPrimingEngineView::NetworkPrimingEngineView(
const std::string &primingSymbol,
DynamicEngine &baseEngine
) :
DefinedEngineView(
constructPrimingReactionSet(
species.at(primingSymbol),
baseEngine
),
baseEngine
),
m_primingSpecies(species.at(primingSymbol)) {}
NetworkPrimingEngineView::NetworkPrimingEngineView(
const fourdst::atomic::Species &primingSpecies,
DynamicEngine &baseEngine
) :
DefinedEngineView(
constructPrimingReactionSet(
primingSpecies,
baseEngine
),
baseEngine
),
m_primingSpecies(primingSpecies) {
}
std::vector<std::string> NetworkPrimingEngineView::constructPrimingReactionSet(
const fourdst::atomic::Species &primingSpecies,
const DynamicEngine &baseEngine
) const {
std::unordered_set<std::string> primeReactions;
for (const auto &reaction : baseEngine.getNetworkReactions()) {
if (reaction.contains(primingSpecies)) {
primeReactions.insert(std::string(reaction.peName()));
}
}
if (primeReactions.empty()) {
LOG_ERROR(m_logger, "No priming reactions found for species '{}'.", primingSpecies.name());
m_logger->flush_log();
throw std::runtime_error("No priming reactions found for species '" + std::string(primingSpecies.name()) + "'.");
}
std::vector<std::string> primingReactionSet(primeReactions.begin(), primeReactions.end());
// LOG_INFO(m_logger, "Constructed priming reaction set with {} reactions for species '{}'.", primingReactionSet.size(), primingSpecies.name());
return primingReactionSet;
}
}
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