Loading...
Searching...
No Matches
gridfire::AdaptiveEngineView Class Referencefinal

An engine view that dynamically adapts the reaction network based on runtime conditions. More...

`#include <engine_adaptive.h>`

Inheritance diagram for gridfire::AdaptiveEngineView:
[legend]
Collaboration diagram for gridfire::AdaptiveEngineView:
[legend]

## Classes

struct | ReactionFlow
| A struct to hold a reaction and its flow rate. More...

## Public Member Functions

| AdaptiveEngineView (DynamicEngine &baseEngine)
| Constructs an AdaptiveEngineView.
fourdst::composition::Composition | update (const NetIn &netIn) override
| Updates the active species and reactions based on the current conditions.
bool | isStale (const NetIn &netIn) override
const std::vector< fourdst::atomic::Species > & | getNetworkSpecies () const override
| Gets the list of active species in the network.
std::expected< StepDerivatives< double >, expectations::StaleEngineError > | calculateRHSAndEnergy (const fourdst::composition::Composition &comp, double T9, double rho) const override
| Calculates the right-hand side (dY/dt) and energy generation for the active species.
EnergyDerivatives | calculateEpsDerivatives (const fourdst::composition::Composition &comp, double T9, double rho) const override
void | generateJacobianMatrix (const fourdst::composition::Composition &comp, double T9, double rho) const override
| Generates the Jacobian matrix for the active species.
void | generateJacobianMatrix (const fourdst::composition::Composition &comp, double T9, double rho, const std::vector< fourdst::atomic::Species > &activeSpecies) const override
void | generateJacobianMatrix (const fourdst::composition::Composition &comp, double T9, double rho, const SparsityPattern &sparsityPattern) const override
double | getJacobianMatrixEntry (const fourdst::atomic::Species &rowSpecies, const fourdst::atomic::Species &colSpecies) const override
| Gets an entry from the Jacobian matrix for the active species.
void | generateStoichiometryMatrix () override
| Generates the stoichiometry matrix for the active reactions and species.
int | getStoichiometryMatrixEntry (const fourdst::atomic::Species &species, const reaction::Reaction &reaction) const override
| Gets an entry from the stoichiometry matrix for the active species and reactions.
double | calculateMolarReactionFlow (const reaction::Reaction &reaction, const fourdst::composition::Composition &comp, double T9, double rho) const override
| Calculates the molar reaction flow for a given reaction in the active network.
const reaction::ReactionSet & | getNetworkReactions () const override
| Gets the set of active logical reactions in the network.
void | setNetworkReactions (const reaction::ReactionSet &reactions) override
std::expected< std::unordered_map< fourdst::atomic::Species, double >, expectations::StaleEngineError > | getSpeciesTimescales (const fourdst::composition::Composition &comp, double T9, double rho) const override
| Computes timescales for all active species in the network.
std::expected< std::unordered_map< fourdst::atomic::Species, double >, expectations::StaleEngineError > | getSpeciesDestructionTimescales (const fourdst::composition::Composition &comp, double T9, double rho) const override
const DynamicEngine & | getBaseEngine () const override
| Gets the base engine.
void | setScreeningModel (screening::ScreeningType model) override
| Sets the screening model for the base engine.
screening::ScreeningType | getScreeningModel () const override
| Gets the screening model from the base engine.
size_t | getSpeciesIndex (const fourdst::atomic::Species &species) const override
| Get the index of a species in the network.
std::vector< double > | mapNetInToMolarAbundanceVector (const NetIn &netIn) const override
| Map a NetIn object to a vector of molar abundances.
PrimingReport | primeEngine (const NetIn &netIn) override
| Prime the engine with initial conditions.
fourdst::composition::Composition | collectComposition (fourdst::composition::Composition &comp) const override
| Recursively collect composition from current engine and any sub engines if they exist.
Public Member Functions inherited from gridfire::DynamicEngine
virtual BuildDepthType | getDepth () const
| Get the depth of the network.
virtual void | rebuild (const fourdst::composition::Composition &comp, BuildDepthType depth)
| Rebuild the network with a specified depth.
Public Member Functions inherited from gridfire::Engine
virtual | ~Engine ()=default
| Virtual destructor.
Public Member Functions inherited from gridfire::EngineView< DynamicEngine >
virtual | ~EngineView ()=default
| Virtual destructor.

## Private Types

using | Config = fourdst::config::Config
using | LogManager = fourdst::logging::LogManager
typedef std::pair< std::unordered_set< const reaction::Reaction * >, std::unordered_set< fourdst::atomic::Species > > | RescueSet

## Private Member Functions

std::vector< size_t > | constructSpeciesIndexMap () const
| Constructs the species index map.
std::vector< size_t > | constructReactionIndexMap () const
| Constructs the reaction index map.
std::vector< double > | mapCulledToFull (const std::vector< double > &culled) const
| Maps a vector of culled abundances to a vector of full abundances.
std::vector< double > | mapFullToCulled (const std::vector< double > &full) const
| Maps a vector of full abundances to a vector of culled abundances.
size_t | mapCulledToFullSpeciesIndex (size_t culledSpeciesIndex) const
| Maps a culled species index to a full species index.
size_t | mapCulledToFullReactionIndex (size_t culledReactionIndex) const
| Maps a culled reaction index to a full reaction index.
void | validateState () const
| Validates that the AdaptiveEngineView is not stale.
std::pair< std::vector< ReactionFlow >, fourdst::composition::Composition > | calculateAllReactionFlows (const NetIn &netIn) const
| Calculates the molar reaction flow rate for all reactions in the full network.
std::unordered_set< fourdst::atomic::Species > | findReachableSpecies (const NetIn &netIn) const
| Finds all species that are reachable from the initial fuel through the reaction network.
std::vector< const reaction::Reaction * > | cullReactionsByFlow (const std::vector< ReactionFlow > &allFlows, const std::unordered_set< fourdst::atomic::Species > &reachableSpecies, const fourdst::composition::Composition &comp, double maxFlow) const
| Culls reactions from the network based on their flow rates.
RescueSet | rescueEdgeSpeciesDestructionChannel (const fourdst::composition::Composition &comp, double T9, double rho, const std::vector< fourdst::atomic::Species > &activeSpecies, const reaction::ReactionSet &activeReactions) const
void | finalizeActiveSet (const std::vector< const reaction::Reaction * > &finalReactions)
| Finalizes the set of active species and reactions.

## Private Attributes

Config & | m_config = Config::getInstance()
| A reference to the singleton Config instance, used for retrieving configuration parameters.
quill::Logger * | m_logger = LogManager::getInstance().getLogger("log")
| A pointer to the logger instance, used for logging messages.
DynamicEngine & | m_baseEngine
| The underlying engine to which this view delegates calculations.
std::vector< fourdst::atomic::Species > | m_activeSpecies
| The set of species that are currently active in the network.
reaction::ReactionSet | m_activeReactions
| The set of reactions that are currently active in the network.
std::vector< size_t > | m_speciesIndexMap
| A map from the indices of the active species to the indices of the corresponding species in the full network.
std::vector< size_t > | m_reactionIndexMap
| A map from the indices of the active reactions to the indices of the corresponding reactions in the full network.
bool | m_isStale = true
| A flag indicating whether the view is stale and needs to be updated.

## Detailed Description

An engine view that dynamically adapts the reaction network based on runtime conditions.

This class implements an EngineView that dynamically culls species and reactions from the full reaction network based on their reaction flow rates and connectivity. This allows for efficient simulation of reaction networks by focusing computational effort on the most important species and reactions.

The AdaptiveEngineView maintains a subset of "active" species and reactions, and maps between the full network indices and the active subset indices. This allows the base engine to operate on the full network data, while the AdaptiveEngineView provides a reduced view for external clients.

The adaptation process is driven by the `update()` method, which performs the following steps:

1. Reaction Flow Calculation: Calculates the molar reaction flow rate for each reaction in the full network based on the current temperature, density, and composition.
2. Reaction Culling: Culls reactions with flow rates below a threshold, determined by a relative culling threshold multiplied by the maximum flow rate.
3. Connectivity Analysis: Performs a connectivity analysis to identify species that are reachable from the initial fuel species through the culled reaction network.
4. Species Culling: Culls species that are not reachable from the initial fuel.
5. Index Map Construction: Constructs index maps to map between the full network indices and the active subset indices for species and reactions.

<DynamicEngine>

See also
  engine_abstract.h
  engine_view_abstract.h
  AdaptiveEngineView::update()

## Member Typedef Documentation

## Config

using gridfire::AdaptiveEngineView::Config = fourdst::config::Config

private

## LogManager

using gridfire::AdaptiveEngineView::LogManager = fourdst::logging::LogManager

private

## RescueSet

typedef std::pair<std::unordered_set<const reaction::Reaction*>, std::unordered_set<fourdst::atomic::Species> > gridfire::AdaptiveEngineView::RescueSet

private

## Constructor & Destructor Documentation

## AdaptiveEngineView()

gridfire::AdaptiveEngineView::AdaptiveEngineView | ( | DynamicEngine & | baseEngine | ) |

explicit

Constructs an AdaptiveEngineView.

Parameters

  baseEngine | The underlying DynamicEngine to which this view delegates calculations.

Initializes the active species and reactions to the full network, and constructs the initial index maps.

## Member Function Documentation

## calculateAllReactionFlows()

std::pair< std::vector< AdaptiveEngineView::ReactionFlow >, fourdst::composition::Composition > gridfire::AdaptiveEngineView::calculateAllReactionFlows | ( | const NetIn & | netIn | ) | const

nodiscardprivate

Calculates the molar reaction flow rate for all reactions in the full network.

This method iterates through all reactions in the base engine's network and calculates their molar flow rates based on the provided network input conditions (temperature, density, and composition). It also constructs a vector of molar abundances for all species in the full network.

Parameters

  netIn | The current network input, containing temperature, density, and composition.

Returns
  A pair with the first element a vector of ReactionFlow structs, each containing a pointer to a reaction and its calculated flow rate and the second being a composition object where species which were not present in netIn but are present in the definition of the base engine are registered but have 0 mass fraction.

Algorithm:
  1. Iterates through all species in the base engine's network.
  2. For each species, it retrieves the molar abundance from `netIn.composition`. If the species is not found, its abundance is set to 0.0.
  3. Converts the temperature from Kelvin to T9.
  4. Iterates through all reactions in the base engine's network.
  5. For each reaction, it calls the base engine's `calculateMolarReactionFlow` to get the flow rate.
  6. Stores the reaction pointer and its flow rate in a `ReactionFlow` struct and adds it to the returned vector.

## calculateEpsDerivatives()

EnergyDerivatives gridfire::AdaptiveEngineView::calculateEpsDerivatives | ( | const fourdst::composition::Composition & | comp,
|  | double | T9,
|  | double | rho ) const

nodiscardoverridevirtual

Parameters

  comp | The current composition of the system.
  T9 | The temperature in units of 10^9 K.
  rho | The density in g/cm^3.

Returns
  A struct containing the derivatives of the energy generation rate with respect to temperature and density.

Implements gridfire::DynamicEngine.

## calculateMolarReactionFlow()

double gridfire::AdaptiveEngineView::calculateMolarReactionFlow | ( | const reaction::Reaction & | reaction,
|  | const fourdst::composition::Composition & | comp,
|  | double | T9,
|  | double | rho ) const

nodiscardoverridevirtual

Calculates the molar reaction flow for a given reaction in the active network.

Parameters

  reaction | The reaction for which to calculate the flow.
  comp | Composition object containing current abundances.
  T9 | Temperature in units of 10^9 K.
  rho | Density in g/cm^3.

Returns
  Molar flow rate for the reaction (e.g., mol/g/s).

This method maps the culled abundances to the full network abundances and calls the base engine to calculate the molar reaction flow.

Exceptions

  std::runtime_error | If the AdaptiveEngineView is stale (i.e., `update()` has not been called).
  std::runtime_error | If the reaction is not part of the active reactions in the adaptive engine view.

Implements gridfire::DynamicEngine.

## calculateRHSAndEnergy()

std::expected< StepDerivatives< double >, expectations::StaleEngineError > gridfire::AdaptiveEngineView::calculateRHSAndEnergy | ( | const fourdst::composition::Composition & | comp,
|  | double | T9,
|  | double | rho ) const

nodiscardoverridevirtual

Calculates the right-hand side (dY/dt) and energy generation for the active species.

Parameters

  comp | The current composition of the system.
  T9 | The temperature in units of 10^9 K.
  rho | The density in g/cm^3.

Returns
  A StepDerivatives struct containing the derivatives of the active species and the nuclear energy generation rate.

This method maps the culled abundances to the full network abundances, calls the base engine to calculate the RHS and energy generation, and then maps the full network derivatives back to the culled derivatives.

Exceptions

  std::runtime_error | If the AdaptiveEngineView is stale (i.e., `update()` has not been called).

See also
  AdaptiveEngineView::update()

Implements gridfire::Engine.

## collectComposition()

fourdst::composition::Composition gridfire::AdaptiveEngineView::collectComposition | ( | fourdst::composition::Composition & | comp | ) | const

overridevirtual

Recursively collect composition from current engine and any sub engines if they exist.

If species i is defined in comp and in any sub engine or self composition then the molar abundance of species i in the returned composition will be that defined in comp. If there are species defined in sub engine compositions which are not defined in comp then their molar abundances will be based on the reported values from each sub engine.

Note
  It is up to each engine to decide how to handle filling in the return composition.
  These methods return an unfinalized composition which must then be finalized by the caller

Parameters

  comp | Input composition to "normalize".

Returns
  An updated composition which is a superset of comp. This may contain species which were culled, for example, by either QSE partitioning or reaction flow rate culling

Implements gridfire::DynamicEngine.

## constructReactionIndexMap()

std::vector< size_t > gridfire::AdaptiveEngineView::constructReactionIndexMap | ( |  | ) | const

nodiscardprivate

Constructs the reaction index map.

Returns
  A vector mapping culled reaction indices to full reaction indices.

This method creates a map from the indices of the active reactions to the indices of the corresponding reactions in the full network.

See also
  AdaptiveEngineView::update()

## constructSpeciesIndexMap()

std::vector< size_t > gridfire::AdaptiveEngineView::constructSpeciesIndexMap | ( |  | ) | const

nodiscardprivate

Constructs the species index map.

Returns
  A vector mapping culled species indices to full species indices.

This method creates a map from the indices of the active species to the indices of the corresponding species in the full network.

See also
  AdaptiveEngineView::update()

## cullReactionsByFlow()

std::vector< const reaction::Reaction * > gridfire::AdaptiveEngineView::cullReactionsByFlow | ( | const std::vector< ReactionFlow > & | allFlows,
|  | const std::unordered_set< fourdst::atomic::Species > & | reachableSpecies,
|  | const fourdst::composition::Composition & | comp,
|  | double | maxFlow ) const

nodiscardprivate

Culls reactions from the network based on their flow rates.

This method filters the list of all reactions, keeping only those with a flow rate above an absolute culling threshold. The threshold is calculated by multiplying the maximum flow rate by a relative culling threshold read from the configuration.

Parameters

  allFlows | A vector of all reactions and their flow rates.
  reachableSpecies | A set of all species reachable from the initial fuel.
  comp | The current composition of the system.
  maxFlow | The maximum reaction flow rate in the network.

Returns
  A vector of pointers to the reactions that have been kept after culling.

Algorithm:
  1. Retrieves the `RelativeCullingThreshold` from the configuration.
  2. Calculates the `absoluteCullingThreshold` by multiplying `maxFlow` with the relative threshold.
  3. Iterates through `allFlows`.
  4. A reaction is kept if its `flowRate` is greater than the `absoluteCullingThreshold`.
  5. The pointers to the kept reactions are stored in a vector and returned.

## finalizeActiveSet()

void gridfire::AdaptiveEngineView::finalizeActiveSet | ( | const std::vector< const reaction::Reaction * > & | finalReactions | ) |

private

Finalizes the set of active species and reactions.

This method takes the final list of culled reactions and populates the `m_activeReactions` and `m_activeSpecies` members. The active species are determined by collecting all reactants and products from the final reactions. The active species list is then sorted by mass.

Parameters

  finalReactions | A vector of pointers to the reactions to be included in the active set.

Postcondition
  - `m_activeReactions` is cleared and populated with the reactions from `finalReactions`.
  - `m_activeSpecies` is cleared and populated with all unique species present in `finalReactions`.
  - `m_activeSpecies` is sorted by atomic mass.

## findReachableSpecies()

std::unordered_set< Species > gridfire::AdaptiveEngineView::findReachableSpecies | ( | const NetIn & | netIn | ) | const

nodiscardprivate

Finds all species that are reachable from the initial fuel through the reaction network.

This method performs a connectivity analysis to identify all species that can be produced starting from the initial fuel species. A species is considered part of the initial fuel if its mass fraction is above a certain threshold (`ABUNDANCE_FLOOR`).

Parameters

  netIn | The current network input, containing the initial composition.

Returns
  An unordered set of all reachable species.

Algorithm:
  1. Initializes a set `reachable` and a queue `to_visit` with the initial fuel species.
  2. Iteratively processes the reaction network until no new species can be reached.
  3. In each pass, it iterates through all reactions in the base engine's network.
  4. If all reactants of a reaction are in the `reachable` set, all products of that reaction are added to the `reachable` set.
  5. The process continues until a full pass over all reactions does not add any new species to the `reachable` set.

## generateJacobianMatrix() [1/3]

void gridfire::AdaptiveEngineView::generateJacobianMatrix | ( | const fourdst::composition::Composition & | comp,
|  | double | T9,
|  | double | rho ) const

overridevirtual

Generates the Jacobian matrix for the active species.

Parameters

  comp | The current composition of the system.
  T9 | The temperature in units of 10^9 K.
  rho | The density in g/cm^3.

This method maps the culled abundances to the full network abundances and calls the base engine to generate the Jacobian matrix.

Exceptions

  std::runtime_error | If the AdaptiveEngineView is stale (i.e., `update()` has not been called).

See also
  AdaptiveEngineView::update()

Implements gridfire::DynamicEngine.

## generateJacobianMatrix() [2/3]

void gridfire::AdaptiveEngineView::generateJacobianMatrix | ( | const fourdst::composition::Composition & | comp,
|  | double | T9,
|  | double | rho,
|  | const SparsityPattern & | sparsityPattern ) const

overridevirtual

Implements gridfire::DynamicEngine.

## generateJacobianMatrix() [3/3]

void gridfire::AdaptiveEngineView::generateJacobianMatrix | ( | const fourdst::composition::Composition & | comp,
|  | double | T9,
|  | double | rho,
|  | const std::vector< fourdst::atomic::Species > & | activeSpecies ) const

overridevirtual

Implements gridfire::DynamicEngine.

## generateStoichiometryMatrix()

void gridfire::AdaptiveEngineView::generateStoichiometryMatrix | ( |  | ) |

overridevirtual

Generates the stoichiometry matrix for the active reactions and species.

This method calls the base engine to generate the stoichiometry matrix.

Exceptions

  std::runtime_error | If the AdaptiveEngineView is stale (i.e., `update()` has not been called).

Note
  The stoichiometry matrix generated by the base engine is assumed to be consistent with the active species and reactions in this view.

Implements gridfire::DynamicEngine.

## getBaseEngine()

const DynamicEngine & gridfire::AdaptiveEngineView::getBaseEngine | ( |  | ) | const

inlinenodiscardoverridevirtual

Gets the base engine.

Returns
  A const reference to the base engine.

Implements gridfire::EngineView< DynamicEngine >.

## getJacobianMatrixEntry()

double gridfire::AdaptiveEngineView::getJacobianMatrixEntry | ( | const fourdst::atomic::Species & | rowSpecies,
|  | const fourdst::atomic::Species & | colSpecies ) const

nodiscardoverridevirtual

Gets an entry from the Jacobian matrix for the active species.

Parameters

  rowSpecies | The species corresponding to the row index in the culled species list.
  colSpecies | The species corresponding to the column index in the culled species list

Returns
  The value of the Jacobian matrix at (i_culled, j_culled).

This method maps the culled indices to the full network indices and calls the base engine to get the Jacobian matrix entry.

Exceptions

  std::runtime_error | If the AdaptiveEngineView is stale (i.e., `update()` has not been called).
  std::out_of_range | If the culled index is out of bounds for the species index map.

See also
  AdaptiveEngineView::update()

Implements gridfire::DynamicEngine.

## getNetworkReactions()

const reaction::ReactionSet & gridfire::AdaptiveEngineView::getNetworkReactions | ( |  | ) | const

nodiscardoverridevirtual

Gets the set of active logical reactions in the network.

Returns
  Reference to the LogicalReactionSet containing all active reactions.

Implements gridfire::DynamicEngine.

## getNetworkSpecies()

const std::vector< Species > & gridfire::AdaptiveEngineView::getNetworkSpecies | ( |  | ) | const

nodiscardoverridevirtual

Gets the list of active species in the network.

Returns
  A const reference to the vector of active species.

Implements gridfire::Engine.

## getScreeningModel()

screening::ScreeningType gridfire::AdaptiveEngineView::getScreeningModel | ( |  | ) | const

nodiscardoverridevirtual

Gets the screening model from the base engine.

This method delegates the call to the base engine to get the screening model.

Returns
  The current screening model type.

Usage Example:
  AdaptiveEngineView engineView(...);
  screening::ScreeningType model = engineView.getScreeningModel();
  gridfire::AdaptiveEngineView::AdaptiveEngineView
  AdaptiveEngineView(DynamicEngine &baseEngine)
  Constructs an AdaptiveEngineView.
  Definition engine_adaptive.cpp:16
  gridfire::screening::ScreeningType
  ScreeningType
  Enumerates the available plasma screening models.
  Definition screening_types.h:15

Implements gridfire::DynamicEngine.

## getSpeciesDestructionTimescales()

std::expected< std::unordered_map< Species, double >, expectations::StaleEngineError > gridfire::AdaptiveEngineView::getSpeciesDestructionTimescales | ( | const fourdst::composition::Composition & | comp,
|  | double | T9,
|  | double | rho ) const

nodiscardoverridevirtual

Implements gridfire::DynamicEngine.

## getSpeciesIndex()

size_t gridfire::AdaptiveEngineView::getSpeciesIndex | ( | const fourdst::atomic::Species & | species | ) | const

nodiscardoverridevirtual

Get the index of a species in the network.

Parameters

  species | The species to look up.

This method allows querying the index of a specific species in the engine's internal representation. It is useful for accessing species data efficiently.

Implements gridfire::DynamicEngine.

## getSpeciesTimescales()

std::expected< std::unordered_map< Species, double >, expectations::StaleEngineError > gridfire::AdaptiveEngineView::getSpeciesTimescales | ( | const fourdst::composition::Composition & | comp,
|  | double | T9,
|  | double | rho ) const

nodiscardoverridevirtual

Computes timescales for all active species in the network.

Parameters

  comp | Composition object containing current abundances.
  T9 | Temperature in units of 10^9 K.
  rho | Density in g/cm^3.

Returns
  Map from Species to their characteristic timescales (s).

This method maps the culled abundances to the full network abundances and calls the base engine to compute the species timescales.

Exceptions

  std::runtime_error | If the AdaptiveEngineView is stale (i.e., `update()` has not been called).

Implements gridfire::DynamicEngine.

## getStoichiometryMatrixEntry()

int gridfire::AdaptiveEngineView::getStoichiometryMatrixEntry | ( | const fourdst::atomic::Species & | species,
|  | const reaction::Reaction & | reaction ) const

nodiscardoverridevirtual

Gets an entry from the stoichiometry matrix for the active species and reactions.

Parameters

  species | The species for which to get the stoichiometric coefficient.
  reaction | The reaction for which to get the stoichiometric coefficient.

Returns
  The stoichiometric coefficient for the given species and reaction.

This method maps the culled indices to the full network indices and calls the base engine to get the stoichiometry matrix entry.

Exceptions

  std::runtime_error | If the AdaptiveEngineView is stale (i.e., `update()` has not been called).
  std::out_of_range | If the culled index is out of bounds for the species or reaction index map.

See also
  AdaptiveEngineView::update()

Implements gridfire::DynamicEngine.

## isStale()

bool gridfire::AdaptiveEngineView::isStale | ( | const NetIn & | netIn | ) |

overridevirtual

Implements gridfire::DynamicEngine.

## mapCulledToFull()

std::vector< double > gridfire::AdaptiveEngineView::mapCulledToFull | ( | const std::vector< double > & | culled | ) | const

nodiscardprivate

Maps a vector of culled abundances to a vector of full abundances.

Parameters

  culled | A vector of abundances for the active species.

Returns
  A vector of abundances for the full network, with the abundances of the active species copied from the culled vector.

## mapCulledToFullReactionIndex()

size_t gridfire::AdaptiveEngineView::mapCulledToFullReactionIndex | ( | size_t | culledReactionIndex | ) | const

nodiscardprivate

Maps a culled reaction index to a full reaction index.

Parameters

  culledReactionIndex | The index of the reaction in the culled reaction list.

Returns
  The index of the corresponding reaction in the full network.

Exceptions

  std::out_of_range | If the culled index is out of bounds for the reaction index map.

## mapCulledToFullSpeciesIndex()

size_t gridfire::AdaptiveEngineView::mapCulledToFullSpeciesIndex | ( | size_t | culledSpeciesIndex | ) | const

nodiscardprivate

Maps a culled species index to a full species index.

Parameters

  culledSpeciesIndex | The index of the species in the culled species list.

Returns
  The index of the corresponding species in the full network.

Exceptions

  std::out_of_range | If the culled index is out of bounds for the species index map.

## mapFullToCulled()

std::vector< double > gridfire::AdaptiveEngineView::mapFullToCulled | ( | const std::vector< double > & | full | ) | const

nodiscardprivate

Maps a vector of full abundances to a vector of culled abundances.

Parameters

  full | A vector of abundances for the full network.

Returns
  A vector of abundances for the active species, with the abundances of the active species copied from the full vector.

## mapNetInToMolarAbundanceVector()

std::vector< double > gridfire::AdaptiveEngineView::mapNetInToMolarAbundanceVector | ( | const NetIn & | netIn | ) | const

nodiscardoverridevirtual

Map a NetIn object to a vector of molar abundances.

Parameters

  netIn | The input conditions for the network.

Returns
  A vector of molar abundances corresponding to the species in the network.

This method converts the input conditions into a vector of molar abundances, which can be used for further calculations or diagnostics.

Implements gridfire::DynamicEngine.

## primeEngine()

PrimingReport gridfire::AdaptiveEngineView::primeEngine | ( | const NetIn & | netIn | ) |

nodiscardoverridevirtual

Prime the engine with initial conditions.

Parameters

  netIn | The input conditions for the network.

Returns
  PrimingReport containing information about the priming process.

This method is used to prepare the engine for calculations by setting up initial conditions, reactions, and species. It may involve compiling reaction rates, initializing internal data structures, and performing any necessary pre-computation.

Implements gridfire::DynamicEngine.

## rescueEdgeSpeciesDestructionChannel()

AdaptiveEngineView::RescueSet gridfire::AdaptiveEngineView::rescueEdgeSpeciesDestructionChannel | ( | const fourdst::composition::Composition & | comp,
|  | double | T9,
|  | double | rho,
|  | const std::vector< fourdst::atomic::Species > & | activeSpecies,
|  | const reaction::ReactionSet & | activeReactions ) const

nodiscardprivate

## setNetworkReactions()

void gridfire::AdaptiveEngineView::setNetworkReactions | ( | const reaction::ReactionSet & | reactions | ) |

overridevirtual

Implements gridfire::DynamicEngine.

## setScreeningModel()

void gridfire::AdaptiveEngineView::setScreeningModel | ( | screening::ScreeningType | model | ) |

overridevirtual

Sets the screening model for the base engine.

This method delegates the call to the base engine to set the electron screening model.

Parameters

  model | The electron screening model to set.

Usage Example:
  AdaptiveEngineView engineView(...);
  engineView.setScreeningModel(screening::ScreeningType::WEAK);
  gridfire::screening::ScreeningType::WEAK
  @ WEAK
  Weak screening model (Salpeter, 1954).
  Definition screening_types.h:35

Postcondition
  The screening model of the base engine is updated.

Implements gridfire::DynamicEngine.

## update()

fourdst::composition::Composition gridfire::AdaptiveEngineView::update | ( | const NetIn & | netIn | ) |

overridevirtual

Updates the active species and reactions based on the current conditions.

Parameters

  netIn | The current network input, containing temperature, density, and composition.

This method performs the reaction flow calculation, reaction culling, connectivity analysis, and index map construction steps described above.

The culling thresholds are read from the configuration using the following keys:

- `gridfire:AdaptiveEngineView:RelativeCullingThreshold` (default: 1e-75)

Exceptions

  std::runtime_error | If there is a mismatch between the active reactions and the base engine.

Postcondition
  The active species and reactions are updated, and the index maps are reconstructed.

See also
  AdaptiveEngineView
  AdaptiveEngineView::constructSpeciesIndexMap()
  AdaptiveEngineView::constructReactionIndexMap()

Implements gridfire::DynamicEngine.

## validateState()

void gridfire::AdaptiveEngineView::validateState | ( |  | ) | const

private

Validates that the AdaptiveEngineView is not stale.

Exceptions

  std::runtime_error | If the AdaptiveEngineView is stale (i.e., `update()` has not been called).

## Member Data Documentation

## m_activeReactions

reaction::ReactionSet gridfire::AdaptiveEngineView::m_activeReactions

private

The set of reactions that are currently active in the network.

## m_activeSpecies

std::vector<fourdst::atomic::Species> gridfire::AdaptiveEngineView::m_activeSpecies

private

The set of species that are currently active in the network.

## m_baseEngine

DynamicEngine& gridfire::AdaptiveEngineView::m_baseEngine

private

The underlying engine to which this view delegates calculations.

## m_config

Config& gridfire::AdaptiveEngineView::m_config = Config::getInstance()

private

A reference to the singleton Config instance, used for retrieving configuration parameters.

## m_isStale

bool gridfire::AdaptiveEngineView::m_isStale = true

private

A flag indicating whether the view is stale and needs to be updated.

## m_logger

quill::Logger* gridfire::AdaptiveEngineView::m_logger = LogManager::getInstance().getLogger("log")

private

A pointer to the logger instance, used for logging messages.

## m_reactionIndexMap

std::vector<size_t> gridfire::AdaptiveEngineView::m_reactionIndexMap

private

A map from the indices of the active reactions to the indices of the corresponding reactions in the full network.

## m_speciesIndexMap

std::vector<size_t> gridfire::AdaptiveEngineView::m_speciesIndexMap

private

A map from the indices of the active species to the indices of the corresponding species in the full network.

The documentation for this class was generated from the following files:

- src/include/gridfire/engine/views/engine_adaptive.h
- src/lib/engine/views/engine_adaptive.cpp