2025-07-10 09:36:05 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "gridfire/engine/engine_abstract.h"
|
|
|
|
|
#include "gridfire/network.h"
|
|
|
|
|
|
|
|
|
|
#include "fourdst/composition/atomicSpecies.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace gridfire {
|
2025-07-14 14:50:49 -04:00
|
|
|
|
2025-07-24 11:10:45 -04:00
|
|
|
/**
|
|
|
|
|
* @brief Primes absent species in the network to their equilibrium abundances.
|
|
|
|
|
*
|
|
|
|
|
* Executes a network priming algorithm that iteratively rebuilds the reaction network,
|
|
|
|
|
* calculates equilibrium mass fractions for species with zero initial abundance,
|
|
|
|
|
* and applies mass transfers based on reaction flows.
|
|
|
|
|
*
|
|
|
|
|
* Refer to priming.cpp for implementation details on logging, algorithmic steps, and error handling.
|
|
|
|
|
*
|
|
|
|
|
* @param netIn Input network data containing initial composition, temperature, and density.
|
|
|
|
|
* @param engine DynamicEngine used to build and evaluate the reaction network.
|
2025-10-14 13:37:48 -04:00
|
|
|
* @param ignoredReactionTypes Types of reactions to ignore during priming (e.g., weak reactions).
|
2025-07-24 11:10:45 -04:00
|
|
|
* @pre netIn.composition defines species and their mass fractions; engine is constructed with a valid network.
|
|
|
|
|
* @post engine.networkReactions restored to its initial state; returned report contains primedComposition,
|
|
|
|
|
* massFractionChanges for each species, success flag, and status code.
|
|
|
|
|
* @return PrimingReport encapsulating the results of the priming operation.
|
|
|
|
|
*/
|
|
|
|
|
PrimingReport primeNetwork(
|
2025-08-14 13:33:46 -04:00
|
|
|
const NetIn& netIn,
|
2025-10-14 13:37:48 -04:00
|
|
|
DynamicEngine& engine,
|
|
|
|
|
const std::optional<std::vector<reaction::ReactionType>>& ignoredReactionTypes
|
2025-07-24 11:10:45 -04:00
|
|
|
);
|
2025-07-14 14:50:49 -04:00
|
|
|
|
2025-07-24 11:10:45 -04:00
|
|
|
/**
|
|
|
|
|
* @brief Computes the destruction rate constant for a specific species.
|
|
|
|
|
*
|
|
|
|
|
* Calculates the sum of molar reaction flows for all reactions where the species
|
|
|
|
|
* is a reactant (negative stoichiometry) after scaling its abundance to unity.
|
|
|
|
|
*
|
|
|
|
|
* @param engine Engine providing the current set of network reactions and flow calculations.
|
|
|
|
|
* @param species The atomic species whose destruction rate is computed.
|
2025-10-07 15:16:03 -04:00
|
|
|
* @param composition Current composition providing abundances for all species.
|
2025-07-24 11:10:45 -04:00
|
|
|
* @param T9 Temperature in units of 10^9 K.
|
|
|
|
|
* @param rho Density of the medium.
|
2025-10-14 13:37:48 -04:00
|
|
|
* @param reactionTypesToIgnore types of reactions to ignore during calculation.
|
2025-07-24 11:10:45 -04:00
|
|
|
* @pre Y.size() matches engine.getNetworkReactions().size() mapping species order.
|
|
|
|
|
* @post Returned rate constant is non-negative.
|
|
|
|
|
* @return Sum of absolute stoichiometry-weighted destruction flows for the species.
|
|
|
|
|
*/
|
|
|
|
|
double calculateDestructionRateConstant(
|
|
|
|
|
const DynamicEngine& engine,
|
|
|
|
|
const fourdst::atomic::Species& species,
|
2025-10-07 15:16:03 -04:00
|
|
|
const fourdst::composition::Composition& composition,
|
2025-07-24 11:10:45 -04:00
|
|
|
double T9,
|
2025-10-14 13:37:48 -04:00
|
|
|
double rho, const std::optional<std::vector<reaction::ReactionType>> &
|
|
|
|
|
reactionTypesToIgnore
|
2025-07-24 11:10:45 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Computes the creation rate for a specific species.
|
|
|
|
|
*
|
|
|
|
|
* Sums molar reaction flows for all reactions where the species
|
|
|
|
|
* appears as a product (positive stoichiometry).
|
|
|
|
|
*
|
|
|
|
|
* @param engine Engine providing the current set of network reactions and flow calculations.
|
|
|
|
|
* @param species The atomic species whose creation rate is computed.
|
2025-10-07 15:16:03 -04:00
|
|
|
* @param composition Composition object containing current abundances.
|
2025-07-24 11:10:45 -04:00
|
|
|
* @param T9 Temperature in units of 10^9 K.
|
|
|
|
|
* @param rho Density of the medium.
|
2025-10-14 13:37:48 -04:00
|
|
|
* @param reactionTypesToIgnore types of reactions to ignore during calculation.
|
2025-07-24 11:10:45 -04:00
|
|
|
* @pre Y.size() matches engine.getNetworkReactions().size() mapping species order.
|
|
|
|
|
* @post Returned creation rate is non-negative.
|
|
|
|
|
* @return Sum of stoichiometry-weighted creation flows for the species.
|
|
|
|
|
*/
|
|
|
|
|
double calculateCreationRate(
|
|
|
|
|
const DynamicEngine& engine,
|
|
|
|
|
const fourdst::atomic::Species& species,
|
2025-10-07 15:16:03 -04:00
|
|
|
const fourdst::composition::Composition& composition,
|
2025-07-24 11:10:45 -04:00
|
|
|
double T9,
|
2025-10-14 13:37:48 -04:00
|
|
|
double rho, const std::optional<std::vector<reaction::ReactionType>> &reactionTypesToIgnore
|
2025-07-24 11:10:45 -04:00
|
|
|
);
|
|
|
|
|
}
|