Loading...
Searching...
No Matches
engine_multiscale.h
Go to the documentation of this file.
#pragma once
#include "gridfire/engine/engine_abstract.h"
#include "gridfire/engine/views/engine_view_abstract.h"
#include "gridfire/engine/engine_graph.h"
#include "unsupported/Eigen/NonLinearOptimization"
namespace gridfire {
struct QSECacheConfig {
double T9_tol;
double rho_tol;
double Yi_tol;
};
struct QSECacheKey {
double m_T9;
double m_rho;
std::vector<double> m_Y;
std::size_t m_hash = 0;
// TODO: We should probably sort out how to adjust these from absolute to relative tolerances.
QSECacheConfig m_cacheConfig = {
1e-3, // Default tolerance for T9
1e-1, // Default tolerance for rho
1e-3 // Default tolerance for species abundances
};
QSECacheKey(
const double T9,
const double rho,
const std::vector<double>& Y
);
size_t hash() const;
static long bin(double value, double tol);
bool operator==(const QSECacheKey& other) const;
};
}
// Needs to be in this order (splitting gridfire namespace up) to avoid some issues with forward declarations and the () operator.
namespace std {
template <>
struct hash<gridfire::QSECacheKey> {
size_t operator()(const gridfire::QSECacheKey& key) const noexcept {
// The hash is pre-computed, so we just return it.
return key.m_hash;
}
};
} // namespace std
namespace gridfire {
class MultiscalePartitioningEngineView final: public DynamicEngine, public EngineView<DynamicEngine> {
typedef std::tuple<std::vector<fourdst::atomic::Species>, std::vector<size_t>, std::vector<fourdst::atomic::Species>, std::vector<size_t>> QSEPartition;
public:
explicit MultiscalePartitioningEngineView(GraphEngine& baseEngine);
[[nodiscard]] const std::vector<fourdst::atomic::Species> & getNetworkSpecies() const override;
[[nodiscard]] std::expected<StepDerivatives<double>, expectations::StaleEngineError> calculateRHSAndEnergy(
const std::vector<double> &Y_full,
double T9,
double rho
) const override;
void generateJacobianMatrix(
const std::vector<double> &Y_full,
double T9,
double rho
) const override;
[[nodiscard]] double getJacobianMatrixEntry(
int i_full,
int j_full
) const override;
void generateStoichiometryMatrix() override;
[[nodiscard]] int getStoichiometryMatrixEntry(
int speciesIndex,
int reactionIndex
) const override;
[[nodiscard]] double calculateMolarReactionFlow(
const reaction::Reaction &reaction,
const std::vector<double> &Y_full,
double T9,
double rho
) const override;
[[nodiscard]] const reaction::LogicalReactionSet & getNetworkReactions() const override;
void setNetworkReactions(
const reaction::LogicalReactionSet &reactions
) override;
[[nodiscard]] std::expected<std::unordered_map<fourdst::atomic::Species, double>, expectations::StaleEngineError> getSpeciesTimescales(
const std::vector<double> &Y,
double T9,
double rho
) const override;
[[nodiscard]] std::expected<std::unordered_map<fourdst::atomic::Species, double>, expectations::StaleEngineError> getSpeciesDestructionTimescales(
const std::vector<double> &Y,
double T9,
double rho
) const override;
fourdst::composition::Composition update(
const NetIn &netIn
) override;
bool isStale(const NetIn& netIn) override;
void setScreeningModel(
screening::ScreeningType model
) override;
[[nodiscard]] screening::ScreeningType getScreeningModel() const override;
const DynamicEngine & getBaseEngine() const override;
std::vector<std::vector<size_t>> analyzeTimescalePoolConnectivity(
const std::vector<std::vector<size_t>> &timescale_pools,
const std::vector<double> &Y,
double T9,
double rho
) const;
void partitionNetwork(
const std::vector<double>& Y,
double T9,
double rho
);
void partitionNetwork(
const NetIn& netIn
);
void exportToDot(
const std::string& filename,
const std::vector<double>& Y,
const double T9,
const double rho
) const;
[[nodiscard]] int getSpeciesIndex(const fourdst::atomic::Species &species) const override;
[[nodiscard]] std::vector<double> mapNetInToMolarAbundanceVector(const NetIn &netIn) const override;
[[nodiscard]] PrimingReport primeEngine(const NetIn &netIn) override;
[[nodiscard]] std::vector<fourdst::atomic::Species> getFastSpecies() const;
[[nodiscard]] const std::vector<fourdst::atomic::Species>& getDynamicSpecies() const;
fourdst::composition::Composition equilibrateNetwork(
const std::vector<double> &Y,
double T9,
double rho
);
fourdst::composition::Composition equilibrateNetwork(
const NetIn &netIn
);
private:
struct QSEGroup {
std::set<size_t> species_indices;
bool is_in_equilibrium = false;
std::set<size_t> algebraic_indices;
std::set<size_t> seed_indices;
double mean_timescale;
bool operator<(const QSEGroup& other) const;
bool operator>(const QSEGroup& other) const;
bool operator==(const QSEGroup& other) const;
bool operator!=(const QSEGroup& other) const;
};
struct EigenFunctor {
using InputType = Eigen::Matrix<double, Eigen::Dynamic, 1>;
using OutputType = Eigen::Matrix<double, Eigen::Dynamic, 1>;
using JacobianType = Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>;
enum {
InputsAtCompileTime = Eigen::Dynamic,
ValuesAtCompileTime = Eigen::Dynamic
};
MultiscalePartitioningEngineView* m_view;
const std::vector<size_t>& m_qse_solve_indices;
const std::vector<double>& m_Y_full_initial;
const double m_T9;
const double m_rho;
const Eigen::VectorXd& m_Y_scale;
EigenFunctor(
MultiscalePartitioningEngineView& view,
const std::vector<size_t>& qse_solve_indices,
const std::vector<double>& Y_full_initial,
const double T9,
const double rho,
const Eigen::VectorXd& Y_scale
) :
m_view(&view),
m_qse_solve_indices(qse_solve_indices),
m_Y_full_initial(Y_full_initial),
m_T9(T9),
m_rho(rho),
m_Y_scale(Y_scale) {}
[[nodiscard]] int values() const { return m_qse_solve_indices.size(); }
[[nodiscard]] int inputs() const { return m_qse_solve_indices.size(); }
int operator()(const InputType& v_qse, OutputType& f_qse) const;
int df(const InputType& v_qse, JacobianType& J_qse) const;
};
struct CacheStats {
enum class operators {
CalculateRHSAndEnergy,
GenerateJacobianMatrix,
CalculateMolarReactionFlow,
GetSpeciesTimescales,
GetSpeciesDestructionTimescales,
Other,
All
};
std::map<operators, std::string> operatorsNameMap = {
{operators::CalculateRHSAndEnergy, "calculateRHSAndEnergy"},
{operators::GenerateJacobianMatrix, "generateJacobianMatrix"},
{operators::CalculateMolarReactionFlow, "calculateMolarReactionFlow"},
{operators::GetSpeciesTimescales, "getSpeciesTimescales"},
{operators::GetSpeciesDestructionTimescales, "getSpeciesDestructionTimescales"},
{operators::Other, "other"}
};
size_t m_hit = 0;
size_t m_miss = 0;
std::map<operators, size_t> m_operatorHits = {
{operators::CalculateRHSAndEnergy, 0},
{operators::GenerateJacobianMatrix, 0},
{operators::CalculateMolarReactionFlow, 0},
{operators::GetSpeciesTimescales, 0},
{operators::GetSpeciesDestructionTimescales, 0},
{operators::Other, 0}
};
std::map<operators, size_t> m_operatorMisses = {
{operators::CalculateRHSAndEnergy, 0},
{operators::GenerateJacobianMatrix, 0},
{operators::CalculateMolarReactionFlow, 0},
{operators::GetSpeciesTimescales, 0},
{operators::GetSpeciesDestructionTimescales, 0},
{operators::Other, 0}
};
void hit(const operators op=operators::Other);
void miss(const operators op=operators::Other);
[[nodiscard]] size_t hits(const operators op=operators::All) const;
[[nodiscard]] size_t misses(const operators op=operators::All) const;
};
private:
quill::Logger* m_logger = LogManager::getInstance().getLogger("log");
GraphEngine& m_baseEngine;
std::vector<QSEGroup> m_qse_groups;
std::vector<fourdst::atomic::Species> m_dynamic_species;
std::vector<size_t> m_dynamic_species_indices;
std::vector<fourdst::atomic::Species> m_algebraic_species;
std::vector<size_t> m_algebraic_species_indices;
std::vector<size_t> m_activeSpeciesIndices;
std::vector<size_t> m_activeReactionIndices;
// TODO: Enhance the hashing for the cache to consider not just T and rho but also the current abundance in some careful way that automatically ignores small changes (i.e. network should only be repartitioned sometimes)
mutable std::unordered_map<QSECacheKey, std::vector<double>> m_qse_abundance_cache;
mutable CacheStats m_cacheStats;
private:
std::vector<std::vector<size_t>> partitionByTimescale(
const std::vector<double> &Y_full,
double T9,
double rho
) const;
std::unordered_map<size_t, std::vector<size_t>> buildConnectivityGraph(
const std::unordered_set<size_t> &fast_reaction_indices
) const;
std::vector<QSEGroup> validateGroupsWithFluxAnalysis(
const std::vector<QSEGroup> &candidate_groups,
const std::vector<double>& Y,
double T9,
double rho
) const;
std::vector<double> solveQSEAbundances(
const std::vector<double> &Y_full,
double T9,
double rho
);
size_t identifyMeanSlowestPool(
const std::vector<std::vector<size_t>>& pools,
const std::vector<double> &Y,
double T9,
double rho
) const;
std::unordered_map<size_t, std::vector<size_t>> buildConnectivityGraph(
const std::vector<size_t>& species_pool
) const;
std::vector<QSEGroup> constructCandidateGroups(
const std::vector<std::vector<size_t>>& candidate_pools,
const std::vector<double>& Y,
double T9,
double rho
) const;
};
}
gridfire::DynamicEngine
Abstract class for engines supporting Jacobian and stoichiometry operations.
Definition engine_abstract.h:130
gridfire::EngineView
Abstract base class for a "view" of a reaction network engine.
Definition engine_view_abstract.h:74
gridfire::GraphEngine
A reaction network engine that uses a graph-based representation.
Definition engine_graph.h:100
gridfire::MultiscalePartitioningEngineView::m_baseEngine
GraphEngine & m_baseEngine
The base engine to which this view delegates calculations.
Definition engine_multiscale.h:914
gridfire::MultiscalePartitioningEngineView::primeEngine
PrimingReport primeEngine(const NetIn &netIn) override
Primes the engine with a specific species.
Definition engine_multiscale.cpp:793
gridfire::MultiscalePartitioningEngineView::MultiscalePartitioningEngineView
MultiscalePartitioningEngineView(GraphEngine &baseEngine)
Constructs a MultiscalePartitioningEngineView.
Definition engine_multiscale.cpp:153
gridfire::MultiscalePartitioningEngineView::setScreeningModel
void setScreeningModel(screening::ScreeningType model) override
Sets the electron screening model.
Definition engine_multiscale.cpp:402
gridfire::MultiscalePartitioningEngineView::m_qse_groups
std::vector< QSEGroup > m_qse_groups
The list of identified equilibrium groups.
Definition engine_multiscale.h:918
gridfire::MultiscalePartitioningEngineView::getDynamicSpecies
const std::vector< fourdst::atomic::Species > & getDynamicSpecies() const
Gets the dynamic species in the network.
Definition engine_multiscale.cpp:789
gridfire::MultiscalePartitioningEngineView::getBaseEngine
const DynamicEngine & getBaseEngine() const override
Gets the base engine.
Definition engine_multiscale.cpp:412
gridfire::MultiscalePartitioningEngineView::QSEPartition
std::tuple< std::vector< fourdst::atomic::Species >, std::vector< size_t >, std::vector< fourdst::atomic::Species >, std::vector< size_t > > QSEPartition
Type alias for a QSE partition.
Definition engine_multiscale.h:181
gridfire::MultiscalePartitioningEngineView::m_dynamic_species_indices
std::vector< size_t > m_dynamic_species_indices
Indices mapping the dynamic species back to the base engine's full species list.
Definition engine_multiscale.h:926
gridfire::MultiscalePartitioningEngineView::solveQSEAbundances
std::vector< double > solveQSEAbundances(const std::vector< double > &Y_full, double T9, double rho)
Solves for the QSE abundances of the algebraic species in a given state.
Definition engine_multiscale.cpp:1136
gridfire::MultiscalePartitioningEngineView::getFastSpecies
std::vector< fourdst::atomic::Species > getFastSpecies() const
Gets the fast species in the network.
Definition engine_multiscale.cpp:776
gridfire::MultiscalePartitioningEngineView::m_activeReactionIndices
std::vector< size_t > m_activeReactionIndices
Indices of all reactions involving only active species.
Definition engine_multiscale.h:943
gridfire::MultiscalePartitioningEngineView::m_algebraic_species
std::vector< fourdst::atomic::Species > m_algebraic_species
Species that are treated as algebraic (in QSE) in the QSE groups.
Definition engine_multiscale.h:930
gridfire::MultiscalePartitioningEngineView::equilibrateNetwork
fourdst::composition::Composition equilibrateNetwork(const std::vector< double > &Y, double T9, double rho)
Equilibrates the network by partitioning and solving for QSE abundances.
Definition engine_multiscale.cpp:797
gridfire::MultiscalePartitioningEngineView::getStoichiometryMatrixEntry
int getStoichiometryMatrixEntry(int speciesIndex, int reactionIndex) const override
Gets an entry from the stoichiometry matrix.
Definition engine_multiscale.cpp:246
gridfire::MultiscalePartitioningEngineView::m_algebraic_species_indices
std::vector< size_t > m_algebraic_species_indices
Indices of algebraic species in the full network.
Definition engine_multiscale.h:934
gridfire::MultiscalePartitioningEngineView::identifyMeanSlowestPool
size_t identifyMeanSlowestPool(const std::vector< std::vector< size_t > > &pools, const std::vector< double > &Y, double T9, double rho) const
Identifies the pool with the slowest mean timescale.
Definition engine_multiscale.cpp:1291
gridfire::MultiscalePartitioningEngineView::getSpeciesTimescales
std::expected< std::unordered_map< fourdst::atomic::Species, double >, expectations::StaleEngineError > getSpeciesTimescales(const std::vector< double > &Y, double T9, double rho) const override
Computes timescales for all species in the network.
Definition engine_multiscale.cpp:295
gridfire::MultiscalePartitioningEngineView::m_activeSpeciesIndices
std::vector< size_t > m_activeSpeciesIndices
Indices of all species considered active in the current partition (dynamic + algebraic).
Definition engine_multiscale.h:939
gridfire::MultiscalePartitioningEngineView::getNetworkSpecies
const std::vector< fourdst::atomic::Species > & getNetworkSpecies() const override
Gets the list of species in the network.
Definition engine_multiscale.cpp:157
gridfire::MultiscalePartitioningEngineView::update
fourdst::composition::Composition update(const NetIn &netIn) override
Updates the internal state of the engine, performing partitioning and QSE equilibration.
Definition engine_multiscale.cpp:356
gridfire::MultiscalePartitioningEngineView::m_qse_abundance_cache
std::unordered_map< QSECacheKey, std::vector< double > > m_qse_abundance_cache
Cache for QSE abundances based on T9, rho, and Y.
Definition engine_multiscale.h:953
gridfire::MultiscalePartitioningEngineView::calculateRHSAndEnergy
std::expected< StepDerivatives< double >, expectations::StaleEngineError > calculateRHSAndEnergy(const std::vector< double > &Y_full, double T9, double rho) const override
Calculates the right-hand side (dY/dt) and energy generation.
Definition engine_multiscale.cpp:161
gridfire::MultiscalePartitioningEngineView::calculateMolarReactionFlow
double calculateMolarReactionFlow(const reaction::Reaction &reaction, const std::vector< double > &Y_full, double T9, double rho) const override
Calculates the molar reaction flow for a given reaction.
Definition engine_multiscale.cpp:253
gridfire::MultiscalePartitioningEngineView::getScreeningModel
screening::ScreeningType getScreeningModel() const override
Gets the current electron screening model.
Definition engine_multiscale.cpp:408
gridfire::MultiscalePartitioningEngineView::partitionNetwork
void partitionNetwork(const std::vector< double > &Y, double T9, double rho)
Partitions the network into dynamic and algebraic (QSE) groups based on timescales.
Definition engine_multiscale.cpp:438
gridfire::MultiscalePartitioningEngineView::m_logger
quill::Logger * m_logger
Logger instance for logging messages.
Definition engine_multiscale.h:910
gridfire::MultiscalePartitioningEngineView::getSpeciesIndex
int getSpeciesIndex(const fourdst::atomic::Species &species) const override
Gets the index of a species in the full network.
Definition engine_multiscale.cpp:846
gridfire::MultiscalePartitioningEngineView::getSpeciesDestructionTimescales
std::expected< std::unordered_map< fourdst::atomic::Species, double >, expectations::StaleEngineError > getSpeciesDestructionTimescales(const std::vector< double > &Y, double T9, double rho) const override
Computes destruction timescales for all species in the network.
Definition engine_multiscale.cpp:326
gridfire::MultiscalePartitioningEngineView::validateGroupsWithFluxAnalysis
std::vector< QSEGroup > validateGroupsWithFluxAnalysis(const std::vector< QSEGroup > &candidate_groups, const std::vector< double > &Y, double T9, double rho) const
Validates candidate QSE groups using flux analysis.
Definition engine_multiscale.cpp:1002
gridfire::MultiscalePartitioningEngineView::m_cacheStats
CacheStats m_cacheStats
Statistics for the QSE abundance cache.
Definition engine_multiscale.h:957
gridfire::MultiscalePartitioningEngineView::mapNetInToMolarAbundanceVector
std::vector< double > mapNetInToMolarAbundanceVector(const NetIn &netIn) const override
Maps a NetIn struct to a molar abundance vector for the full network.
Definition engine_multiscale.cpp:768
gridfire::MultiscalePartitioningEngineView::buildConnectivityGraph
std::unordered_map< size_t, std::vector< size_t > > buildConnectivityGraph(const std::unordered_set< size_t > &fast_reaction_indices) const
Builds a connectivity graph from a set of fast reaction indices.
gridfire::MultiscalePartitioningEngineView::generateStoichiometryMatrix
void generateStoichiometryMatrix() override
Generates the stoichiometry matrix for the network.
Definition engine_multiscale.cpp:242
gridfire::MultiscalePartitioningEngineView::constructCandidateGroups
std::vector< QSEGroup > constructCandidateGroups(const std::vector< std::vector< size_t > > &candidate_pools, const std::vector< double > &Y, double T9, double rho) const
Constructs candidate QSE groups from connected timescale pools.
Definition engine_multiscale.cpp:1405
gridfire::MultiscalePartitioningEngineView::getJacobianMatrixEntry
double getJacobianMatrixEntry(int i_full, int j_full) const override
Gets an entry from the previously generated Jacobian matrix.
Definition engine_multiscale.cpp:228
gridfire::MultiscalePartitioningEngineView::setNetworkReactions
void setNetworkReactions(const reaction::LogicalReactionSet &reactions) override
Sets the set of logical reactions in the network.
Definition engine_multiscale.cpp:290
gridfire::MultiscalePartitioningEngineView::generateJacobianMatrix
void generateJacobianMatrix(const std::vector< double > &Y_full, double T9, double rho) const override
Generates the Jacobian matrix for the current state.
Definition engine_multiscale.cpp:204
gridfire::MultiscalePartitioningEngineView::exportToDot
void exportToDot(const std::string &filename, const std::vector< double > &Y, const double T9, const double rho) const
Exports the network to a DOT file for visualization.
Definition engine_multiscale.cpp:558
gridfire::MultiscalePartitioningEngineView::partitionByTimescale
std::vector< std::vector< size_t > > partitionByTimescale(const std::vector< double > &Y_full, double T9, double rho) const
Partitions the network by timescale.
Definition engine_multiscale.cpp:850
gridfire::MultiscalePartitioningEngineView::getNetworkReactions
const reaction::LogicalReactionSet & getNetworkReactions() const override
Gets the set of logical reactions in the network.
Definition engine_multiscale.cpp:286
gridfire::MultiscalePartitioningEngineView::isStale
bool isStale(const NetIn &netIn) override
Checks if the engine's internal state is stale relative to the provided conditions.
Definition engine_multiscale.cpp:390
gridfire::MultiscalePartitioningEngineView::m_dynamic_species
std::vector< fourdst::atomic::Species > m_dynamic_species
The simplified set of species presented to the solver (the "slow" species).
Definition engine_multiscale.h:922
gridfire::MultiscalePartitioningEngineView::analyzeTimescalePoolConnectivity
std::vector< std::vector< size_t > > analyzeTimescalePoolConnectivity(const std::vector< std::vector< size_t > > &timescale_pools, const std::vector< double > &Y, double T9, double rho) const
Analyzes the connectivity of timescale pools.
Definition engine_multiscale.cpp:416
gridfire::reaction::Reaction
Represents a single nuclear reaction from a specific data source.
Definition reaction.h:72
engine_abstract.h
Abstract interfaces for reaction network engines in GridFire.
engine_graph.h
engine_view_abstract.h
Abstract interfaces for engine "views" in GridFire.
gridfire::reaction
Definition reaction.h:25
gridfire::reaction::LogicalReactionSet
TemplatedReactionSet< LogicalReaction > LogicalReactionSet
A set of logical reactions.
Definition reaction.h:563
gridfire::screening::ScreeningType
ScreeningType
Enumerates the available plasma screening models.
Definition screening_types.h:15
gridfire
Definition engine_abstract.h:31
std
STL namespace.
gridfire::MultiscalePartitioningEngineView::CacheStats
Struct for tracking cache statistics.
Definition engine_multiscale.h:822
gridfire::MultiscalePartitioningEngineView::CacheStats::m_hit
size_t m_hit
Total number of cache hits.
Definition engine_multiscale.h:848
gridfire::MultiscalePartitioningEngineView::CacheStats::misses
size_t misses(const operators op=operators::All) const
Gets the number of misses for a specific operator or all operators.
Definition engine_multiscale.cpp:1636
gridfire::MultiscalePartitioningEngineView::CacheStats::hit
void hit(const operators op=operators::Other)
Increments the hit counter for a given operator.
Definition engine_multiscale.cpp:1612
gridfire::MultiscalePartitioningEngineView::CacheStats::m_miss
size_t m_miss
Total number of cache misses.
Definition engine_multiscale.h:852
gridfire::MultiscalePartitioningEngineView::CacheStats::hits
size_t hits(const operators op=operators::All) const
Gets the number of hits for a specific operator or all operators.
Definition engine_multiscale.cpp:1629
gridfire::MultiscalePartitioningEngineView::CacheStats::m_operatorHits
std::map< operators,size_t > m_operatorHits
Map from operators to the number of cache hits for that operator.
Definition engine_multiscale.h:857
gridfire::MultiscalePartitioningEngineView::CacheStats::operators
operators
Definition engine_multiscale.h:823
gridfire::MultiscalePartitioningEngineView::CacheStats::operators::CalculateMolarReactionFlow
@ CalculateMolarReactionFlow
Definition engine_multiscale.h:826
gridfire::MultiscalePartitioningEngineView::CacheStats::operators::Other
@ Other
Definition engine_multiscale.h:829
gridfire::MultiscalePartitioningEngineView::CacheStats::operators::GetSpeciesTimescales
@ GetSpeciesTimescales
Definition engine_multiscale.h:827
gridfire::MultiscalePartitioningEngineView::CacheStats::operators::GenerateJacobianMatrix
@ GenerateJacobianMatrix
Definition engine_multiscale.h:825
gridfire::MultiscalePartitioningEngineView::CacheStats::operators::GetSpeciesDestructionTimescales
@ GetSpeciesDestructionTimescales
Definition engine_multiscale.h:828
gridfire::MultiscalePartitioningEngineView::CacheStats::operators::CalculateRHSAndEnergy
@ CalculateRHSAndEnergy
Definition engine_multiscale.h:824
gridfire::MultiscalePartitioningEngineView::CacheStats::operators::All
@ All
Definition engine_multiscale.h:830
gridfire::MultiscalePartitioningEngineView::CacheStats::miss
void miss(const operators op=operators::Other)
Increments the miss counter for a given operator.
Definition engine_multiscale.cpp:1620
gridfire::MultiscalePartitioningEngineView::CacheStats::operatorsNameMap
std::map< operators,std::string > operatorsNameMap
Map from operators to their string names for logging.
Definition engine_multiscale.h:836
gridfire::MultiscalePartitioningEngineView::CacheStats::m_operatorMisses
std::map< operators,size_t > m_operatorMisses
Map from operators to the number of cache misses for that operator.
Definition engine_multiscale.h:869
gridfire::MultiscalePartitioningEngineView::EigenFunctor::inputs
int inputs() const
Gets the number of input values to the functor (size of the variable vector).
Definition engine_multiscale.h:797
gridfire::MultiscalePartitioningEngineView::EigenFunctor::EigenFunctor
EigenFunctor(MultiscalePartitioningEngineView &view, const std::vector< size_t > &qse_solve_indices, const std::vector< double > &Y_full_initial, const double T9, const double rho, const Eigen::VectorXd &Y_scale)
Constructs an EigenFunctor.
Definition engine_multiscale.h:773
gridfire::MultiscalePartitioningEngineView::EigenFunctor::m_Y_full_initial
const std::vector< double > & m_Y_full_initial
Initial abundances of all species in the full network.
Definition engine_multiscale.h:749
gridfire::MultiscalePartitioningEngineView::EigenFunctor::InputType
Eigen::Matrix< double, Eigen::Dynamic, 1 > InputType
Definition engine_multiscale.h:730
gridfire::MultiscalePartitioningEngineView::EigenFunctor::OutputType
Eigen::Matrix< double, Eigen::Dynamic, 1 > OutputType
Definition engine_multiscale.h:731
gridfire::MultiscalePartitioningEngineView::EigenFunctor::m_rho
const double m_rho
Density in g/cm^3.
Definition engine_multiscale.h:757
gridfire::MultiscalePartitioningEngineView::EigenFunctor::m_qse_solve_indices
const std::vector< size_t > & m_qse_solve_indices
Indices of the species to solve for in the QSE group.
Definition engine_multiscale.h:745
gridfire::MultiscalePartitioningEngineView::EigenFunctor::ValuesAtCompileTime
@ ValuesAtCompileTime
Definition engine_multiscale.h:735
gridfire::MultiscalePartitioningEngineView::EigenFunctor::InputsAtCompileTime
@ InputsAtCompileTime
Definition engine_multiscale.h:734
gridfire::MultiscalePartitioningEngineView::EigenFunctor::values
int values() const
Gets the number of output values from the functor (size of the residual vector).
Definition engine_multiscale.h:792
gridfire::MultiscalePartitioningEngineView::EigenFunctor::m_T9
const double m_T9
Temperature in units of 10^9 K.
Definition engine_multiscale.h:753
gridfire::MultiscalePartitioningEngineView::EigenFunctor::m_Y_scale
const Eigen::VectorXd & m_Y_scale
Scaling factors for the species abundances, used to improve solver stability.
Definition engine_multiscale.h:761
gridfire::MultiscalePartitioningEngineView::EigenFunctor::df
int df(const InputType &v_qse, JacobianType &J_qse) const
Evaluates the Jacobian of the functor, J_qse = d(f_qse)/d(v_qse).
Definition engine_multiscale.cpp:1525
gridfire::MultiscalePartitioningEngineView::EigenFunctor::JacobianType
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > JacobianType
Definition engine_multiscale.h:732
gridfire::MultiscalePartitioningEngineView::EigenFunctor::operator()
int operator()(const InputType &v_qse, OutputType &f_qse) const
Evaluates the functor's residual vector f_qse = dY_alg/dt.
Definition engine_multiscale.cpp:1503
gridfire::MultiscalePartitioningEngineView::EigenFunctor::m_view
MultiscalePartitioningEngineView * m_view
Pointer to the MultiscalePartitioningEngineView instance.
Definition engine_multiscale.h:741
gridfire::MultiscalePartitioningEngineView::QSEGroup
Struct representing a QSE group.
Definition engine_multiscale.h:677
gridfire::MultiscalePartitioningEngineView::QSEGroup::operator<
bool operator<(const QSEGroup &other) const
Less-than operator for QSEGroup, used for sorting.
Definition engine_multiscale.cpp:1600
gridfire::MultiscalePartitioningEngineView::QSEGroup::species_indices
std::set< size_t > species_indices
Indices of all species in this group.
Definition engine_multiscale.h:678
gridfire::MultiscalePartitioningEngineView::QSEGroup::mean_timescale
double mean_timescale
Mean timescale of the group.
Definition engine_multiscale.h:682
gridfire::MultiscalePartitioningEngineView::QSEGroup::operator>
bool operator>(const QSEGroup &other) const
Greater-than operator for QSEGroup.
Definition engine_multiscale.cpp:1604
gridfire::MultiscalePartitioningEngineView::QSEGroup::operator==
bool operator==(const QSEGroup &other) const
Equality operator for QSEGroup.
Definition engine_multiscale.cpp:1596
gridfire::MultiscalePartitioningEngineView::QSEGroup::seed_indices
std::set< size_t > seed_indices
Indices of dynamic species in this group.
Definition engine_multiscale.h:681
gridfire::MultiscalePartitioningEngineView::QSEGroup::algebraic_indices
std::set< size_t > algebraic_indices
Indices of algebraic species in this group.
Definition engine_multiscale.h:680
gridfire::MultiscalePartitioningEngineView::QSEGroup::operator!=
bool operator!=(const QSEGroup &other) const
Inequality operator for QSEGroup.
Definition engine_multiscale.cpp:1608
gridfire::MultiscalePartitioningEngineView::QSEGroup::is_in_equilibrium
bool is_in_equilibrium
Flag set by flux analysis.
Definition engine_multiscale.h:679
gridfire::NetIn
Definition network.h:53
gridfire::PrimingReport
Captures the result of a network priming operation.
Definition reporting.h:67
gridfire::QSECacheConfig
Configuration struct for the QSE cache.
Definition engine_multiscale.h:27
gridfire::QSECacheConfig::Yi_tol
double Yi_tol
Absolute tolerance to produce the same hash for species abundances.
Definition engine_multiscale.h:30
gridfire::QSECacheConfig::rho_tol
double rho_tol
Absolute tolerance to produce the same hash for rho.
Definition engine_multiscale.h:29
gridfire::QSECacheConfig::T9_tol
double T9_tol
Absolute tolerance to produce the same hash for T9.
Definition engine_multiscale.h:28
gridfire::QSECacheKey
Key struct for the QSE abundance cache.
Definition engine_multiscale.h:47
gridfire::QSECacheKey::m_T9
double m_T9
Definition engine_multiscale.h:48
gridfire::QSECacheKey::QSECacheKey
QSECacheKey(const double T9, const double rho, const std::vector< double > &Y)
Constructs a QSECacheKey.
Definition engine_multiscale.cpp:1556
gridfire::QSECacheKey::m_cacheConfig
QSECacheConfig m_cacheConfig
Definition engine_multiscale.h:55
gridfire::QSECacheKey::hash
size_t hash() const
Computes the hash value for this key.
Definition engine_multiscale.cpp:1567
gridfire::QSECacheKey::m_hash
std::size_t m_hash
Precomputed hash value for this key.
Definition engine_multiscale.h:52
gridfire::QSECacheKey::m_rho
double m_rho
Definition engine_multiscale.h:49
gridfire::QSECacheKey::bin
static long bin(double value, double tol)
Converts a value to a discrete bin based on a tolerance.
Definition engine_multiscale.cpp:1588
gridfire::QSECacheKey::operator==
bool operator==(const QSECacheKey &other) const
Equality operator for QSECacheKey.
Definition engine_multiscale.cpp:1592
gridfire::QSECacheKey::m_Y
std::vector< double > m_Y
Note that the ordering of Y must match the dynamic species indices in the view.
Definition engine_multiscale.h:50
gridfire::expectations::StaleEngineError
Definition expected_engine.h:44
std::hash< gridfire::QSECacheKey >::operator()
size_t operator()(const gridfire::QSECacheKey &key) const noexcept
Computes the hash of a QSECacheKey for use in std::unordered_map.
Definition engine_multiscale.h:115