GridFire 0.0.1a General Purpose Nuclear Network

Loading...
Searching...
No Matches
engine_multiscale.h
Go to the documentation of this file.
1#pragma once
2
3#include "gridfire/engine/engine_abstract.h"
4#include "gridfire/engine/views/engine_view_abstract.h"
5#include "gridfire/engine/engine_graph.h"
6
7#include "unsupported/Eigen/NonLinearOptimization"
8
9 namespace gridfire {
27 struct QSECacheConfig {
28 double T9_tol;
29 double rho_tol;
30 double Yi_tol;
31 };
32
47 struct QSECacheKey {
48 double m_T9;
49 double m_rho;
50 std::vector<double> m_Y;
51
52 std::size_t m_hash = 0;
53
54 // TODO: We should probably sort out how to adjust these from absolute to relative tolerances.
55 QSECacheConfig m_cacheConfig = {
56 1e-3, // Default tolerance for T9
57 1e-1, // Default tolerance for rho
58 1e-3 // Default tolerance for species abundances
59 };
60
70 QSECacheKey(
71 const double T9,
72 const double rho,
73 const std::vector<double>& Y
74 );
75
84 size_t hash() const;
85
94 static long bin(double value, double tol);
95
101 bool operator==(const QSECacheKey& other) const;
102
103 };
104}
105
106// Needs to be in this order (splitting gridfire namespace up) to avoid some issues with forward declarations and the () operator.
107 namespace std {
108 template <>
109 struct hash<gridfire::QSECacheKey> {
115 size_t operator()(const gridfire::QSECacheKey& key) const noexcept {
116 // The hash is pre-computed, so we just return it.
117 return key.m_hash;
118 }
119 };
120} // namespace std
121
122 namespace gridfire {
174 class MultiscalePartitioningEngineView final: public DynamicEngine, public EngineView<DynamicEngine> {
181 typedef std::tuple<std::vector<fourdst::atomic::Species>, std::vector<size_t>, std::vector<fourdst::atomic::Species>, std::vector<size_t>> QSEPartition;
182 public:
190 explicit MultiscalePartitioningEngineView(GraphEngine& baseEngine);
191
198 [[nodiscard]] const std::vector<fourdst::atomic::Species> & getNetworkSpecies() const override;
199
225 [[nodiscard]] std::expected<StepDerivatives<double>, expectations::StaleEngineError> calculateRHSAndEnergy(
226 const std::vector<double> &Y_full,
227 double T9,
228 double rho
229 ) const override;
230
252 void generateJacobianMatrix(
253 const std::vector<double> &Y_full,
254 double T9,
255 double rho
256 ) const override;
257
273 [[nodiscard]] double getJacobianMatrixEntry(
274 int i_full,
275 int j_full
276 ) const override;
277
286 void generateStoichiometryMatrix() override;
287
301 [[nodiscard]] int getStoichiometryMatrixEntry(
302 int speciesIndex,
303 int reactionIndex
304 ) const override;
305
326 [[nodiscard]] double calculateMolarReactionFlow(
327 const reaction::Reaction &reaction,
328 const std::vector<double> &Y_full,
329 double T9,
330 double rho
331 ) const override;
332
339 [[nodiscard]] const reaction::LogicalReactionSet & getNetworkReactions() const override;
340
355 void setNetworkReactions(
356 const reaction::LogicalReactionSet &reactions
357 ) override;
358
377 [[nodiscard]] std::expected<std::unordered_map<fourdst::atomic::Species, double>, expectations::StaleEngineError> getSpeciesTimescales(
378 const std::vector<double> &Y,
379 double T9,
380 double rho
381 ) const override;
382
401 [[nodiscard]] std::expected<std::unordered_map<fourdst::atomic::Species, double>, expectations::StaleEngineError> getSpeciesDestructionTimescales(
402 const std::vector<double> &Y,
403 double T9,
404 double rho
405 ) const override;
406
433 fourdst::composition::Composition update(
434 const NetIn &netIn
435 ) override;
436
450 bool isStale(const NetIn& netIn) override;
451
459 void setScreeningModel(
460 screening::ScreeningType model
461 ) override;
462
470 [[nodiscard]] screening::ScreeningType getScreeningModel() const override;
471
477 const DynamicEngine & getBaseEngine() const override;
478
497 std::vector<std::vector<size_t>> analyzeTimescalePoolConnectivity(
498 const std::vector<std::vector<size_t>> &timescale_pools,
499 const std::vector<double> &Y,
500 double T9,
501 double rho
502 ) const;
503
531 void partitionNetwork(
532 const std::vector<double>& Y,
533 double T9,
534 double rho
535 );
536
547 void partitionNetwork(
548 const NetIn& netIn
549 );
550
564 void exportToDot(
565 const std::string& filename,
566 const std::vector<double>& Y,
567 const double T9,
568 const double rho
569 ) const;
570
579 [[nodiscard]] int getSpeciesIndex(const fourdst::atomic::Species &species) const override;
580
589 [[nodiscard]] std::vector<double> mapNetInToMolarAbundanceVector(const NetIn &netIn) const override;
590
602 [[nodiscard]] PrimingReport primeEngine(const NetIn &netIn) override;
603
615 [[nodiscard]] std::vector<fourdst::atomic::Species> getFastSpecies() const;
627 [[nodiscard]] const std::vector<fourdst::atomic::Species>& getDynamicSpecies() const;
628
648 fourdst::composition::Composition equilibrateNetwork(
649 const std::vector<double> &Y,
650 double T9,
651 double rho
652 );
653
665 fourdst::composition::Composition equilibrateNetwork(
666 const NetIn &netIn
667 );
668
669
670 private:
677 struct QSEGroup {
678 std::set<size_t> species_indices;
679 bool is_in_equilibrium = false;
680 std::set<size_t> algebraic_indices;
681 std::set<size_t> seed_indices;
682 double mean_timescale;
683
689 bool operator<(const QSEGroup& other) const;
695 bool operator>(const QSEGroup& other) const;
701 bool operator==(const QSEGroup& other) const;
707 bool operator!=(const QSEGroup& other) const;
708 };
709
729 struct EigenFunctor {
730 using InputType = Eigen::Matrix<double, Eigen::Dynamic, 1>;
731 using OutputType = Eigen::Matrix<double, Eigen::Dynamic, 1>;
732 using JacobianType = Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>;
733 enum {
734 InputsAtCompileTime = Eigen::Dynamic,
735 ValuesAtCompileTime = Eigen::Dynamic
736 };
737
741 MultiscalePartitioningEngineView* m_view;
745 const std::vector<size_t>& m_qse_solve_indices;
749 const std::vector<double>& m_Y_full_initial;
753 const double m_T9;
757 const double m_rho;
761 const Eigen::VectorXd& m_Y_scale;
762
773 EigenFunctor(
774 MultiscalePartitioningEngineView& view,
775 const std::vector<size_t>& qse_solve_indices,
776 const std::vector<double>& Y_full_initial,
777 const double T9,
778 const double rho,
779 const Eigen::VectorXd& Y_scale
780 ) :
781 m_view(&view),
782 m_qse_solve_indices(qse_solve_indices),
783 m_Y_full_initial(Y_full_initial),
784 m_T9(T9),
785 m_rho(rho),
786 m_Y_scale(Y_scale) {}
787
792 [[nodiscard]] int values() const { return m_qse_solve_indices.size(); }
797 [[nodiscard]] int inputs() const { return m_qse_solve_indices.size(); }
798
805 int operator()(const InputType& v_qse, OutputType& f_qse) const;
812 int df(const InputType& v_qse, JacobianType& J_qse) const;
813 };
814
815
822 struct CacheStats {
823 enum class operators {
824 CalculateRHSAndEnergy,
825 GenerateJacobianMatrix,
826 CalculateMolarReactionFlow,
827 GetSpeciesTimescales,
828 GetSpeciesDestructionTimescales,
829 Other,
830 All
831 };
832
836 std::map<operators, std::string> operatorsNameMap = {
837 {operators::CalculateRHSAndEnergy, "calculateRHSAndEnergy"},
838 {operators::GenerateJacobianMatrix, "generateJacobianMatrix"},
839 {operators::CalculateMolarReactionFlow, "calculateMolarReactionFlow"},
840 {operators::GetSpeciesTimescales, "getSpeciesTimescales"},
841 {operators::GetSpeciesDestructionTimescales, "getSpeciesDestructionTimescales"},
842 {operators::Other, "other"}
843 };
844
848 size_t m_hit = 0;
852 size_t m_miss = 0;
853
857 std::map<operators, size_t> m_operatorHits = {
858 {operators::CalculateRHSAndEnergy, 0},
859 {operators::GenerateJacobianMatrix, 0},
860 {operators::CalculateMolarReactionFlow, 0},
861 {operators::GetSpeciesTimescales, 0},
862 {operators::GetSpeciesDestructionTimescales, 0},
863 {operators::Other, 0}
864 };
865
869 std::map<operators, size_t> m_operatorMisses = {
870 {operators::CalculateRHSAndEnergy, 0},
871 {operators::GenerateJacobianMatrix, 0},
872 {operators::CalculateMolarReactionFlow, 0},
873 {operators::GetSpeciesTimescales, 0},
874 {operators::GetSpeciesDestructionTimescales, 0},
875 {operators::Other, 0}
876 };
877
883 void hit(const operators op=operators::Other);
889 void miss(const operators op=operators::Other);
890
896 [[nodiscard]] size_t hits(const operators op=operators::All) const;
902 [[nodiscard]] size_t misses(const operators op=operators::All) const;
903 };
904
905
906 private:
910 quill::Logger* m_logger = LogManager::getInstance().getLogger("log");
914 GraphEngine& m_baseEngine;
918 std::vector<QSEGroup> m_qse_groups;
922 std::vector<fourdst::atomic::Species> m_dynamic_species;
926 std::vector<size_t> m_dynamic_species_indices;
930 std::vector<fourdst::atomic::Species> m_algebraic_species;
934 std::vector<size_t> m_algebraic_species_indices;
935
939 std::vector<size_t> m_activeSpeciesIndices;
943 std::vector<size_t> m_activeReactionIndices;
944
945 // 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)
953 mutable std::unordered_map<QSECacheKey, std::vector<double>> m_qse_abundance_cache;
957 mutable CacheStats m_cacheStats;
958
959
960
961
962 private:
979 std::vector<std::vector<size_t>> partitionByTimescale(
980 const std::vector<double> &Y_full,
981 double T9,
982 double rho
983 ) const;
984
998 std::unordered_map<size_t, std::vector<size_t>> buildConnectivityGraph(
999 const std::unordered_set<size_t> &fast_reaction_indices
1000 ) const;
1001
1020 std::vector<QSEGroup> validateGroupsWithFluxAnalysis(
1021 const std::vector<QSEGroup> &candidate_groups,
1022 const std::vector<double>& Y,
1023 double T9,
1024 double rho
1025 ) const;
1026
1045 std::vector<double> solveQSEAbundances(
1046 const std::vector<double> &Y_full,
1047 double T9,
1048 double rho
1049 );
1050
1066 size_t identifyMeanSlowestPool(
1067 const std::vector<std::vector<size_t>>& pools,
1068 const std::vector<double> &Y,
1069 double T9,
1070 double rho
1071 ) const;
1072
1086 std::unordered_map<size_t, std::vector<size_t>> buildConnectivityGraph(
1087 const std::vector<size_t>& species_pool
1088 ) const;
1089
1108 std::vector<QSEGroup> constructCandidateGroups(
1109 const std::vector<std::vector<size_t>>& candidate_pools,
1110 const std::vector<double>& Y,
1111 double T9,
1112 double rho
1113 ) const;
1114 };
1115}
1116
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