14#include <unordered_map>
40 concept IsArithmeticOrAD = std::is_same_v<T, double> || std::is_same_v<T, CppAD::AD<double>>;
59 template <IsArithmeticOrAD T>
95 [[nodiscard]]
virtual const std::vector<fourdst::atomic::Species>&
getNetworkSpecies()
const = 0;
110 const std::vector<double>& Y,
143 const std::vector<double>& Y_dynamic,
149 const std::vector<double>& Y_dynamic,
154 throw std::logic_error(
"Sparsity pattern not supported by this engine.");
208 const std::vector<double>& Y,
234 const std::vector<double>& Y,
240 const std::vector<double>& Y,
265 virtual fourdst::composition::Composition
update(
const NetIn &netIn) = 0;
299 [[nodiscard]]
virtual int getSpeciesIndex(
const fourdst::atomic::Species &species)
const = 0;
306 throw std::logic_error(
"Network depth not supported by this engine.");
310 throw std::logic_error(
"Setting network depth not supported by this engine.");
Abstract class for engines supporting Jacobian and stoichiometry operations.
virtual BuildDepthType getDepth() const
virtual double getJacobianMatrixEntry(int i, int j) const =0
Get an entry from the previously generated Jacobian matrix.
virtual PrimingReport primeEngine(const NetIn &netIn)=0
virtual void generateJacobianMatrix(const std::vector< double > &Y_dynamic, double T9, double rho) const =0
Generate the Jacobian matrix for the current state.
virtual void setScreeningModel(screening::ScreeningType model)=0
Set the electron screening model.
virtual void rebuild(const fourdst::composition::Composition &comp, BuildDepthType depth)
virtual std::vector< double > mapNetInToMolarAbundanceVector(const NetIn &netIn) const =0
virtual double calculateMolarReactionFlow(const reaction::Reaction &reaction, const std::vector< double > &Y, double T9, double rho) const =0
Calculate the molar reaction flow for a given reaction.
virtual std::expected< std::unordered_map< fourdst::atomic::Species, double >, expectations::StaleEngineError > getSpeciesTimescales(const std::vector< double > &Y, double T9, double rho) const =0
Compute timescales for all species in the network.
virtual std::expected< std::unordered_map< fourdst::atomic::Species, double >, expectations::StaleEngineError > getSpeciesDestructionTimescales(const std::vector< double > &Y, double T9, double rho) const =0
virtual screening::ScreeningType getScreeningModel() const =0
Get the current electron screening model.
virtual void generateJacobianMatrix(const std::vector< double > &Y_dynamic, double T9, double rho, const SparsityPattern &sparsityPattern) const
virtual bool isStale(const NetIn &netIn)=0
virtual fourdst::composition::Composition update(const NetIn &netIn)=0
Update the internal state of the engine.
virtual const reaction::LogicalReactionSet & getNetworkReactions() const =0
Get the set of logical reactions in the network.
virtual int getSpeciesIndex(const fourdst::atomic::Species &species) const =0
virtual void generateStoichiometryMatrix()=0
Generate the stoichiometry matrix for the network.
virtual int getStoichiometryMatrixEntry(int speciesIndex, int reactionIndex) const =0
Get an entry from the stoichiometry matrix.
virtual void setNetworkReactions(const reaction::LogicalReactionSet &reactions)=0
Abstract base class for a reaction network engine.
virtual const std::vector< fourdst::atomic::Species > & getNetworkSpecies() const =0
Get the list of species in the network.
virtual ~Engine()=default
Virtual destructor.
virtual std::expected< StepDerivatives< double >, expectations::StaleEngineError > calculateRHSAndEnergy(const std::vector< double > &Y, double T9, double rho) const =0
Calculate the right-hand side (dY/dt) and energy generation.
Represents a single nuclear reaction from a specific data source.
Concept for types allowed in engine calculations.
TemplatedReactionSet< LogicalReaction > LogicalReactionSet
A set of logical reactions.
ScreeningType
Enumerates the available plasma screening models.
std::variant< NetworkBuildDepth, int > BuildDepthType
Variant specifying either a predefined NetworkBuildDepth or a custom integer depth.
std::vector< std::pair< size_t, size_t > > SparsityPattern
Defines classes for representing and managing nuclear reactions.
Captures the result of a network priming operation.
Structure holding derivatives and energy generation for a network step.
T nuclearEnergyGenerationRate
Specific energy generation rate (e.g., erg/g/s).
std::vector< T > dydt
Derivatives of abundances (dY/dt for each species).