|
GridFire v0.7.6rc4.0
General Purpose Nuclear Network
|
An engine view that partitions the reaction network into multiple groups based on timescales. More...
#include <engine_multiscale.h>
Classes | |
| struct | FluxValidationResult |
| struct | QSEGroup |
| Struct representing a QSE group. More... | |
| class | QSESolver |
Public Member Functions | |
| MultiscalePartitioningEngineView (DynamicEngine &baseEngine) | |
| Constructs a MultiscalePartitioningEngineView. | |
| const std::vector< fourdst::atomic::Species > & | getNetworkSpecies (scratch::StateBlob &ctx) const override |
| Gets the list of species in the network. | |
| std::expected< StepDerivatives< double >, engine::EngineStatus > | calculateRHSAndEnergy (scratch::StateBlob &ctx, const fourdst::composition::CompositionAbstract &comp, double T9, double rho, bool trust) const override |
| Calculates the right-hand side (dY/dt) and energy generation. | |
| EnergyDerivatives | calculateEpsDerivatives (scratch::StateBlob &ctx, const fourdst::composition::CompositionAbstract &comp, double T9, double rho) const override |
| Calculates the energy generation rate derivatives with respect to abundances. | |
| NetworkJacobian | generateJacobianMatrix (scratch::StateBlob &ctx, const fourdst::composition::CompositionAbstract &comp, double T9, double rho) const override |
| Generates the Jacobian matrix for the current state. | |
| NetworkJacobian | generateJacobianMatrix (scratch::StateBlob &ctx, const fourdst::composition::CompositionAbstract &comp, double T9, double rho, const std::vector< fourdst::atomic::Species > &activeSpecies) const override |
| Generates the Jacobian matrix for a subset of active species. | |
| NetworkJacobian | generateJacobianMatrix (scratch::StateBlob &ctx, const fourdst::composition::CompositionAbstract &comp, double T9, double rho, const SparsityPattern &sparsityPattern) const override |
| Generates the Jacobian matrix using a sparsity pattern. | |
| double | calculateMolarReactionFlow (scratch::StateBlob &ctx, const reaction::Reaction &reaction, const fourdst::composition::CompositionAbstract &comp, double T9, double rho) const override |
| Calculates the molar reaction flow for a given reaction. | |
| const reaction::ReactionSet & | getNetworkReactions (scratch::StateBlob &ctx) const override |
| Gets the set of logical reactions in the network. | |
| std::expected< std::unordered_map< fourdst::atomic::Species, double >, EngineStatus > | getSpeciesTimescales (scratch::StateBlob &ctx, const fourdst::composition::CompositionAbstract &comp, double T9, double rho) const override |
| Computes timescales for all species in the network. | |
| std::expected< std::unordered_map< fourdst::atomic::Species, double >, EngineStatus > | getSpeciesDestructionTimescales (scratch::StateBlob &ctx, const fourdst::composition::CompositionAbstract &comp, double T9, double rho) const override |
| Computes destruction timescales for all species in the network. | |
| fourdst::composition::Composition | project (scratch::StateBlob &ctx, const NetIn &netIn) const override |
| Updates the internal state of the engine, performing partitioning and QSE equilibration. | |
| screening::ScreeningType | getScreeningModel (scratch::StateBlob &ctx) const override |
| Gets the current electron screening model. | |
| const DynamicEngine & | getBaseEngine () const override |
| Gets the base engine. | |
| fourdst::composition::Composition | partitionNetwork (scratch::StateBlob &ctx, const NetIn &netIn) const |
Partitions the network based on timescales from a NetIn struct. | |
| void | exportToDot (scratch::StateBlob &ctx, const std::string &filename, const fourdst::composition::Composition &comp, double T9, double rho) const |
| Exports the network to a DOT file for visualization. | |
| size_t | getSpeciesIndex (scratch::StateBlob &ctx, const fourdst::atomic::Species &species) const override |
| Gets the index of a species in the full network. | |
| PrimingReport | primeEngine (scratch::StateBlob &ctx, const NetIn &netIn) const override |
| Primes the engine with a specific species. | |
| std::vector< fourdst::atomic::Species > | getFastSpecies (scratch::StateBlob &ctx) const |
| Gets the fast species in the network. | |
| fourdst::composition::Composition | getNormalizedEquilibratedComposition (scratch::StateBlob &ctx, const fourdst::composition::CompositionAbstract &comp, double T9, double rho, bool trust) const |
| Gets a normalized composition with QSE species equilibrated. | |
| fourdst::composition::Composition | collectComposition (scratch::StateBlob &ctx, const fourdst::composition::CompositionAbstract &comp, double T9, double rho) const override |
| Collect the composition from this and sub engines. | |
| SpeciesStatus | getSpeciesStatus (scratch::StateBlob &ctx, const fourdst::atomic::Species &species) const override |
| Gets the status of a species in the network. | |
| std::optional< StepDerivatives< double > > | getMostRecentRHSCalculation (scratch::StateBlob &) const override |
| std::unique_ptr< scratch::StateBlob > | constructStateBlob (const scratch::StateBlob *blob) const override |
Public Member Functions inherited from gridfire::engine::DynamicEngine | |
| virtual reaction::ReactionSet | getInactiveNetworkReactions (scratch::StateBlob &ctx) const |
| Get the set of inactive reactions in the network. | |
| virtual double | getInactiveReactionMolarReactionFlow (scratch::StateBlob &ctx, const reaction::Reaction &reaction, const fourdst::composition::CompositionAbstract &comp, const double T9, const double rho) const |
Public Member Functions inherited from gridfire::engine::Engine | |
| virtual | ~Engine ()=default |
| Virtual destructor. | |
Public Member Functions inherited from gridfire::engine::EngineView< DynamicEngine > | |
| virtual | ~EngineView ()=default |
| Virtual destructor. | |
Static Public Member Functions | |
| static const std::vector< fourdst::atomic::Species > & | getDynamicSpecies (scratch::StateBlob &ctx) |
| Gets the dynamic species in the network. | |
| static bool | involvesSpecies (scratch::StateBlob &ctx, const fourdst::atomic::Species &species) |
| Checks if a species is involved in the partitioned network. | |
| static bool | involvesSpeciesInQSE (scratch::StateBlob &ctx, const fourdst::atomic::Species &species) |
| Check if a species is involved in the QSE (algebraic) set. | |
| static bool | involvesSpeciesInDynamic (scratch::StateBlob &ctx, const fourdst::atomic::Species &species) |
| Check if a species is involved in the dynamic set. | |
Private Types | |
| typedef 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. | |
Private Member Functions | |
| std::vector< std::vector< fourdst::atomic::Species > > | partitionByTimescale (scratch::StateBlob &ctx, const fourdst::composition::Composition &comp, double T9, double rho) const |
| Partitions the network by timescale. | |
| std::pair< bool, reaction::ReactionSet > | group_is_a_qse_cluster (scratch::StateBlob &ctx, const fourdst::composition::Composition &comp, double T9, double rho, const QSEGroup &group) const |
| bool | group_is_a_qse_pipeline (scratch::StateBlob &ctx, const fourdst::composition::Composition &comp, double T9, double rho, const QSEGroup &group) const |
| FluxValidationResult | validateGroupsWithFluxAnalysis (scratch::StateBlob &ctx, const std::vector< QSEGroup > &candidate_groups, const fourdst::composition::Composition &comp, double T9, double rho) const |
| Validates candidate QSE groups using flux analysis. | |
| auto | solveQSEAbundances (scratch::StateBlob &ctx, const fourdst::composition::CompositionAbstract &comp, double T9, double rho) const -> fourdst::composition::Composition |
| Solves for the QSE abundances of the algebraic species in a given state. | |
| size_t | identifyMeanSlowestPool (scratch::StateBlob &ctx, const std::vector< std::vector< fourdst::atomic::Species > > &pools, const fourdst::composition::Composition &comp, double T9, double rho) const |
| Identifies the pool with the slowest mean timescale. | |
| std::unordered_map< fourdst::atomic::Species, std::vector< fourdst::atomic::Species > > | buildConnectivityGraph (scratch::StateBlob &ctx, const std::vector< fourdst::atomic::Species > &species_pool, const fourdst::composition::Composition &comp, double T9, double rho) const |
| Builds a connectivity graph from a species pool. | |
| std::vector< QSEGroup > | constructCandidateGroups (scratch::StateBlob &ctx, const std::vector< std::vector< fourdst::atomic::Species > > &candidate_pools, const fourdst::composition::Composition &comp, double T9, double rho) const |
| Constructs candidate QSE groups from connected timescale pools. | |
| std::vector< std::vector< fourdst::atomic::Species > > | analyzeTimescalePoolConnectivity (scratch::StateBlob &ctx, const std::vector< std::vector< fourdst::atomic::Species > > ×cale_pools, const fourdst::composition::Composition &comp, double T9, double rho) const |
| Analyzes the connectivity of timescale pools. | |
| std::vector< QSEGroup > | pruneValidatedGroups (scratch::StateBlob &ctx, const std::vector< QSEGroup > &groups, const std::vector< reaction::ReactionSet > &groupReactions, const fourdst::composition::Composition &comp, double T9, double rho) const |
Static Private Member Functions | |
| static std::vector< QSEGroup > | merge_coupled_groups (scratch::StateBlob &ctx, const std::vector< QSEGroup > &groups, const std::vector< reaction::ReactionSet > &groupReactions) |
Private Attributes | |
| quill::Logger * | m_logger = LogManager::getInstance().getLogger("log") |
| Logger instance for logging messages. | |
| DynamicEngine & | m_baseEngine |
| The base engine to which this view delegates calculations. | |
An engine view that partitions the reaction network into multiple groups based on timescales.
partitionNetwork() and equilibrateNetwork() methods. The partitioning process involves:getSpeciesDestructionTimescales from the base engine, all species are sorted by their characteristic timescales.solveQSEAbundances uses a Levenberg-Marquardt nonlinear solver (Eigen::LevenbergMarquardt) to find the equilibrium abundances of the "algebraic" species, holding the "seed" species constant.All calculations are cached using QSECacheKey to avoid re-partitioning and re-solving for similar thermodynamic conditions.
<DynamicEngine>
|
private |
Type alias for a QSE partition.
A QSE partition is a tuple containing the fast species, their indices, the slow species, and their indices.
|
explicit |
Constructs a MultiscalePartitioningEngineView.
| baseEngine | The underlying GraphEngine to which this view delegates calculations. It must be a GraphEngine and not a more general DynamicEngine because this view relies on its specific implementation details. |
|
private |
Analyzes the connectivity of timescale pools.
| ctx | The scratch data for thread-local storage. |
| timescale_pools | A vector of vectors of species indices, where each inner vector represents a timescale pool. |
| comp | |
| T9 | |
| rho |
buildConnectivityGraph. It then finds the connected components within that graph using a Breadth-First Search (BFS). The resulting components from all pools are collected and returned.
|
private |
Builds a connectivity graph from a species pool.
| ctx | The scratch data for thread-local storage. |
| species_pool | A vector of species indices representing a species pool. |
| comp | |
| T9 | |
| rho |
species_pool (one as a reactant and one as a product), it adds edges between all reactants and products from that reaction that are also in the pool.
|
nodiscardoverridevirtual |
Calculates the energy generation rate derivatives with respect to abundances.
| ctx | The scratch data for thread-local storage. |
| comp | The current composition. |
| T9 | The temperature in units of 10^9 K. |
| rho | The density in g/cm^3. |
Implements gridfire::engine::DynamicEngine.
|
nodiscardoverridevirtual |
Calculates the molar reaction flow for a given reaction.
| ctx | The scratch data for thread-local storage. |
| reaction | The reaction for which to calculate the flow. |
| comp | The current composition. |
| T9 | Temperature in units of 10^9 K. |
| rho | Density in g/cm^3. |
Y_full, overwrites the algebraic species abundances with the cached equilibrium values, and then calls the base engine's calculateMolarReactionFlow with this modified abundance vector.| StaleEngineError | If the QSE cache misses. |
Implements gridfire::engine::DynamicEngine.
|
nodiscardoverridevirtual |
Calculates the right-hand side (dY/dt) and energy generation.
| ctx | The scratch data for thread-local storage. |
| comp | The current composition. |
| T9 | Temperature in units of 10^9 K. |
| rho | Density in g/cm^3. |
| trust |
std::expected containing StepDerivatives<double> on success, or a StaleEngineError if the engine's QSE cache does not contain a solution for the given state.m_qse_abundance_cache). If a cache hit occurs, it calls the base engine's calculateRHSAndEnergy. It then manually sets the time derivatives (dydt) of all identified algebraic species to zero, effectively removing their differential equations from the system being solved.update() or equilibrateNetwork() for the current thermodynamic conditions, so that a valid entry exists in the QSE cache. dydt=0 for all algebraic species.| StaleEngineError | If the QSE cache does not contain an entry for the given (T9, rho, Y_full). This indicates update() was not called recently enough. |
Implements gridfire::engine::Engine.
|
overridevirtual |
Collect the composition from this and sub engines.
This method operates by injecting the current equilibrium abundances for algebraic species into the composition object so that they can be bubbled up to the caller.
| ctx | The scratch data for thread-local storage. |
| comp | Input Composition |
| T9 | |
| rho |
| BadCollectionError | if there is a species in the algebraic species set which does not show up in the reported composition from the base engine.:w |
Implements gridfire::engine::DynamicEngine.
|
private |
Constructs candidate QSE groups from connected timescale pools.
| ctx | The scratch data for thread-local storage. |
| candidate_pools | A vector of vectors of species indices, where each inner vector represents a connected pool of species with similar fast timescales. |
| comp | Vector of current molar abundances. |
| T9 | Temperature in units of 10^9 K. |
| rho | Density in g/cm^3. |
QSEGroup structs, ready for flux validation.QSEGroup struct.candidate_pools should be connected components from analyzeTimescalePoolConnectivity. QSEGroup objects is returned.
|
nodiscardoverridevirtual |
Implements gridfire::engine::DynamicEngine.
| void gridfire::engine::MultiscalePartitioningEngineView::exportToDot | ( | scratch::StateBlob & | ctx, |
| const std::string & | filename, | ||
| const fourdst::composition::Composition & | comp, | ||
| double | T9, | ||
| double | rho ) const |
Exports the network to a DOT file for visualization.
| ctx | The scratch data for thread-local storage. |
| filename | The name of the DOT file to create. |
| comp | Composition object |
| T9 | Temperature in units of 10^9 K. |
| rho | Density in g/cm^3. |
|
nodiscardoverridevirtual |
Generates the Jacobian matrix for the current state.
| ctx | The scratch data for thread-local storage. |
| comp | The current composition. |
| T9 | Temperature in units of 10^9 K. |
| rho | Density in g/cm^3. |
dydt=0 from calculateRHSAndEnergy).| exceptions::StaleEngineError | If the QSE cache misses, as it cannot proceed without a valid partition. |
Implements gridfire::engine::DynamicEngine.
|
nodiscardoverridevirtual |
Generates the Jacobian matrix using a sparsity pattern.
| ctx | The scratch data for thread-local storage. |
| comp | The current composition. |
| T9 | Temperature in units of 10^9 K. |
| rho | Density in g/cm^3. |
| sparsityPattern | The sparsity pattern to use for the Jacobian. |
generateJacobianMatrix method with the provided sparsity pattern.| exceptions::StaleEngineError | If the QSE cache misses. |
Implements gridfire::engine::DynamicEngine.
|
nodiscardoverridevirtual |
Generates the Jacobian matrix for a subset of active species.
| ctx | The scratch data for thread-local storage. |
| comp | The current composition. |
| T9 | Temperature in units of 10^9 K. |
| rho | Density in g/cm^3. |
| activeSpecies | The subset of species to include in the Jacobian. |
generateJacobianMatrix with the specified active species. The returned Jacobian still reflects the full network, but only for the active species subset.| exceptions::StaleEngineError | If the QSE cache misses. |
Implements gridfire::engine::DynamicEngine.
|
nodiscardoverridevirtual |
Gets the base engine.
Implements gridfire::engine::EngineView< DynamicEngine >.
|
staticnodiscard |
Gets the dynamic species in the network.
m_dynamic_species member vector.partitionNetwork() must have been called.
|
nodiscard |
Gets the fast species in the network.
m_algebraic_species member vector.partitionNetwork() must have been called.
|
nodiscardoverridevirtual |
Implements gridfire::engine::DynamicEngine.
|
nodiscardoverridevirtual |
Gets the set of logical reactions in the network.
LogicalReactionSet from the base engine, containing all reactions in the full network. Implements gridfire::engine::DynamicEngine.
|
nodiscardoverridevirtual |
Gets the list of species in the network.
Species objects representing all species in the underlying base engine. This view does not alter the species list itself, only how their abundances are evolved. Implements gridfire::engine::Engine.
| fourdst::composition::Composition gridfire::engine::MultiscalePartitioningEngineView::getNormalizedEquilibratedComposition | ( | scratch::StateBlob & | ctx, |
| const fourdst::composition::CompositionAbstract & | comp, | ||
| double | T9, | ||
| double | rho, | ||
| bool | trust ) const |
Gets a normalized composition with QSE species equilibrated.
| ctx | The scratch data for thread-local storage. |
| comp | The input composition. |
| T9 | Temperature in units of 10^9 K. |
| rho | Density in g/cm^3. |
| trust |
Composition object with algebraic species set to their equilibrium values.solveQSEAbundances() to compute the equilibrium abundances for the algebraic species, then constructs a new Composition object reflecting these values.| StaleEngineError | If the QSE cache misses. |
|
nodiscardoverridevirtual |
Gets the current electron screening model.
getScreeningModel(). Implements gridfire::engine::DynamicEngine.
|
nodiscardoverridevirtual |
Computes destruction timescales for all species in the network.
| ctx | The scratch data for thread-local storage. |
| comp | The current composition. |
| T9 | Temperature in units of 10^9 K. |
| rho | Density in g/cm^3. |
std::expected containing a map from Species to their characteristic destruction timescales (s) on success, or a StaleEngineError on failure.| StaleEngineError | If the QSE cache misses. |
Implements gridfire::engine::DynamicEngine.
|
nodiscardoverridevirtual |
Gets the index of a species in the full network.
| ctx | The scratch data for thread-local storage. |
| species | The species to get the index of. |
getSpeciesIndex(). Implements gridfire::engine::DynamicEngine.
|
overridevirtual |
Gets the status of a species in the network.
| ctx | The scratch data for thread-local storage. |
| species | The species to query. |
SpeciesStatus indicating if the species is dynamic, algebraic, or not involved.m_dynamic_species and m_algebraic_species to determine the appropriate status.partitionNetwork() must have been called. Implements gridfire::engine::DynamicEngine.
|
nodiscardoverridevirtual |
Computes timescales for all species in the network.
| ctx | The scratch data for thread-local storage. |
| comp | The current composition. |
| T9 | Temperature in units of 10^9 K. |
| rho | Density in g/cm^3. |
std::expected containing a map from Species to their characteristic timescales (s) on success, or a StaleEngineError on failure.Y / (dY/dt) for each species.| StaleEngineError | If the QSE cache misses. |
Implements gridfire::engine::DynamicEngine.
|
private |
|
private |
|
private |
Identifies the pool with the slowest mean timescale.
| ctx | The scratch data for thread-local storage. |
| pools | A vector of vectors of species indices, where each inner vector represents a timescale pool. |
| comp | Vector of current molar abundances for the full network. |
| T9 | Temperature in units of 10^9 K. |
| rho | Density in g/cm^3. |
|
static |
Checks if a species is involved in the partitioned network.
| ctx | The scratch data for thread-local storage. |
| species | The species to check. |
true if the species is in either the dynamic or algebraic sets, false otherwise.m_dynamic_species and m_algebraic_species.partitionNetwork() must have been called.
|
static |
Check if a species is involved in the dynamic set.
| ctx | The scratch data for thread-local storage. |
| species | The species to check. |
|
static |
Check if a species is involved in the QSE (algebraic) set.
| ctx | The scratch data for thread-local storage. |
| species | The species to check. |
|
staticprivate |
|
private |
Partitions the network by timescale.
| ctx | The scratch data for thread-local storage. |
| comp | Vector of current molar abundances for all species. |
| T9 | Temperature in units of 10^9 K. |
| rho | Density in g/cm^3. |
| fourdst::composition::Composition gridfire::engine::MultiscalePartitioningEngineView::partitionNetwork | ( | scratch::StateBlob & | ctx, |
| const NetIn & | netIn ) const |
Partitions the network based on timescales from a NetIn struct.
| ctx | The scratch data for thread-local storage. |
| netIn | A struct containing the current network input. |
partitionNetwork.netIn struct into Y, T9, and rho and then calls the primary partitionNetwork method.
|
nodiscardoverridevirtual |
Primes the engine with a specific species.
| netIn | A struct containing the current network input. |
PrimingReport struct containing information about the priming process.primeEngine(). The multiscale view does not currently interact with the priming process. Implements gridfire::engine::DynamicEngine.
|
overridevirtual |
Updates the internal state of the engine, performing partitioning and QSE equilibration.
| ctx | The scratch data for thread-local storage. |
| netIn | A struct containing the current network input: temperature, density, and composition. |
@how
equilibrateNetwork().equilibrateNetwork() in turn calls partitionNetwork() to define the dynamic and algebraic species sets.solveQSEAbundances() to compute the equilibrium abundances.m_qse_abundance_cache.fourdst::composition::Composition object reflecting the equilibrated state is created and returned.netIn struct should contain a valid physical state. m_dynamic_species, m_algebraic_species, etc. are populated). The m_qse_abundance_cache is populated with the QSE solution for the given state. The returned composition reflects the new equilibrium. Implements gridfire::engine::DynamicEngine.
|
private |
|
private |
Solves for the QSE abundances of the algebraic species in a given state.
| ctx | The scratch data for thread-local storage. |
| comp | Vector of current molar abundances for all species in the base engine. |
| T9 | Temperature in units of 10^9 K. |
| rho | Density in g/cm^3. |
LevenbergMarquardt class. The problem is defined by the EigenFunctor which computes the residuals and Jacobian for the QSE equations.
|
private |
Validates candidate QSE groups using flux analysis.
| ctx | The scratch data for thread-local storage. |
| candidate_groups | A vector of candidate QSE groups. |
| comp | Vector of current molar abundances for the full network. |
| T9 | Temperature in units of 10^9 K. |
| rho | Density in g/cm^3. |
|
private |
The base engine to which this view delegates calculations.
|
private |
Logger instance for logging messages.