feat(GridFire): Added a number of python hooks
python hooks to make getting base composition more reliable; further, a number of small changes made to aid in my analysis in response to ref report 1
This commit is contained in:
@@ -3,13 +3,25 @@
|
||||
#include "fourdst/config/config.h"
|
||||
|
||||
namespace gridfire::config {
|
||||
struct CVODESolverConfig {
|
||||
struct BoundaryFluxConfig {
|
||||
double relativeThreshold = 3e-8;
|
||||
double absoluteThreshold = 1e-24;
|
||||
};
|
||||
|
||||
struct TriggerConfig {
|
||||
double offDiagonalThreshold = 1e10;
|
||||
double timestepCollapseRatio = 0.5;
|
||||
double maxConvergenceFailures = 2;
|
||||
BoundaryFluxConfig boundaryFlux;
|
||||
};
|
||||
struct PointSolverConfig {
|
||||
double absTol = 1.0e-8;
|
||||
double relTol = 1.0e-5;
|
||||
TriggerConfig trigger;
|
||||
};
|
||||
|
||||
struct SolverConfig {
|
||||
CVODESolverConfig cvode;
|
||||
PointSolverConfig pointSolver;
|
||||
};
|
||||
|
||||
struct AdaptiveEngineViewConfig {
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
#include "gridfire/engine/types/reporting.h"
|
||||
#include "gridfire/engine/types/jacobian.h"
|
||||
|
||||
#include "gridfire/exceptions/error_engine.h"
|
||||
|
||||
#include "gridfire/engine/scratchpads/blob.h"
|
||||
|
||||
#include "fourdst/composition/composition_abstract.h"
|
||||
@@ -183,6 +185,7 @@ namespace gridfire::engine {
|
||||
/**
|
||||
* @brief Generate the Jacobian matrix for the current state.
|
||||
*
|
||||
* @param ctx The scratchpad context for the current state.
|
||||
* @param comp Composition object containing current abundances.
|
||||
* @param T9 Temperature in units of 10^9 K.
|
||||
* @param rho Density in g/cm^3.
|
||||
@@ -200,6 +203,7 @@ namespace gridfire::engine {
|
||||
/**
|
||||
* @brief Generate the Jacobian matrix for the current state using a subset of active species.
|
||||
*
|
||||
* @param ctx The scratchpad context for the current state.
|
||||
* @param comp Composition object containing current abundances.
|
||||
* @param T9 Temperature in units of 10^9 K.
|
||||
* @param rho Density in g/cm^3.
|
||||
@@ -221,6 +225,7 @@ namespace gridfire::engine {
|
||||
/**
|
||||
* @brief Generate the Jacobian matrix for the current state with a specified sparsity pattern.
|
||||
*
|
||||
* @param ctx Get the scratchpad context for the current state.
|
||||
* @param comp Composition object containing current abundances.
|
||||
* @param T9 Temperature in units of 10^9 K.
|
||||
* @param rho Density in g/cm^3.
|
||||
@@ -245,6 +250,7 @@ namespace gridfire::engine {
|
||||
/**
|
||||
* @brief Calculate the molar reaction flow for a given reaction.
|
||||
*
|
||||
* @param ctx The scratchpad context for the current state.
|
||||
* @param reaction The reaction for which to calculate the flow.
|
||||
* @param comp Composition object containing current abundances.
|
||||
* @param T9 Temperature in units of 10^9 K.
|
||||
@@ -289,6 +295,39 @@ namespace gridfire::engine {
|
||||
scratch::StateBlob& ctx
|
||||
) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Get the set of inactive reactions in the network.
|
||||
*
|
||||
* @return ReactionSet containing all inactive reactions.
|
||||
*
|
||||
* By default, this method returns an empty set. Derived classes can override
|
||||
* this method to provide the actual set of inactive reactions based on their
|
||||
* internal logic (e.g., reaction flow culling, QSE partitioning).
|
||||
*/
|
||||
[[nodiscard]] virtual reaction::ReactionSet getInactiveNetworkReactions(
|
||||
scratch::StateBlob &ctx
|
||||
) const {
|
||||
return reaction::ReactionSet{};
|
||||
}
|
||||
|
||||
[[nodiscard]] virtual double getInactiveReactionMolarReactionFlow(
|
||||
scratch::StateBlob& ctx,
|
||||
const reaction::Reaction &reaction,
|
||||
const fourdst::composition::CompositionAbstract &comp,
|
||||
const double T9,
|
||||
const double rho
|
||||
) const {
|
||||
std::string warning_msg = std::format(
|
||||
"[GridFire Warning ({}, {}, {})]: Engine of type '{}' does not implement getInactiveReactionMolarReactionFlow. Returning 0.0 flow for reaction '{}'.",
|
||||
__FILE__,
|
||||
__LINE__,
|
||||
__FUNCTION__,
|
||||
typeid(*this).name(),
|
||||
reaction.id()
|
||||
);
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Compute timescales for all species in the network.
|
||||
@@ -311,6 +350,7 @@ namespace gridfire::engine {
|
||||
/**
|
||||
* @brief Compute destruction timescales for all species in the network.
|
||||
*
|
||||
* @param ctx The scratchpad context for the current state.
|
||||
* @param comp Composition object containing current abundances.
|
||||
* @param T9 Temperature in units of 10^9 K.
|
||||
* @param rho Density in g/cm^3.
|
||||
@@ -329,6 +369,7 @@ namespace gridfire::engine {
|
||||
/**
|
||||
* @brief Update the thread local scratch pad state of a network.
|
||||
*
|
||||
* @param ctx The scratchpad context for the current state.
|
||||
* @param netIn A struct containing the current network input, such as
|
||||
* temperature, density, and composition.
|
||||
*
|
||||
@@ -354,6 +395,8 @@ namespace gridfire::engine {
|
||||
/**
|
||||
* @brief Get the current electron screening model.
|
||||
*
|
||||
* @param ctx The scratchpad context for the current state.
|
||||
*
|
||||
* @return The currently active screening model type.
|
||||
*
|
||||
* @par Usage Example:
|
||||
@@ -368,6 +411,7 @@ namespace gridfire::engine {
|
||||
/**
|
||||
* @brief Get the index of a species in the network.
|
||||
*
|
||||
* @param ctx The scratchpad context for the current state.
|
||||
* @param species The species to look up.
|
||||
*
|
||||
* This method allows querying the index of a specific species in the
|
||||
@@ -382,6 +426,7 @@ namespace gridfire::engine {
|
||||
/**
|
||||
* @brief Prime the engine with initial conditions.
|
||||
*
|
||||
* @param ctx The scratchpad context for the current state.
|
||||
* @param netIn The input conditions for the network.
|
||||
* @return PrimingReport containing information about the priming process.
|
||||
*
|
||||
@@ -403,6 +448,7 @@ namespace gridfire::engine {
|
||||
* from each sub engine.
|
||||
* @note It is up to each engine to decide how to handle filling in the return composition.
|
||||
* @note These methods return an unfinalized composition which must then be finalized by the caller
|
||||
* @param ctx The scratchpad context for the current state.
|
||||
* @param comp Input composition to "normalize".
|
||||
* @param T9
|
||||
* @param rho
|
||||
@@ -434,5 +480,7 @@ namespace gridfire::engine {
|
||||
scratch::StateBlob& ctx
|
||||
) const = 0;
|
||||
|
||||
[[nodiscard]] virtual std::unique_ptr<scratch::StateBlob> constructStateBlob(const scratch::StateBlob *blob) const = 0;
|
||||
|
||||
};
|
||||
}
|
||||
@@ -137,6 +137,18 @@ namespace gridfire::engine {
|
||||
*/
|
||||
explicit GraphEngine(const reaction::ReactionSet &reactions);
|
||||
|
||||
void addReaction(
|
||||
const reaction::Reaction& reaction
|
||||
);
|
||||
|
||||
void addReaction(
|
||||
const std::string& reaction_id
|
||||
);
|
||||
|
||||
std::unique_ptr<scratch::StateBlob> constructStateBlob(
|
||||
const scratch::StateBlob *blob = nullptr
|
||||
) const override;
|
||||
|
||||
/**
|
||||
* @brief Calculates the right-hand side (dY/dt) and energy generation rate.
|
||||
*
|
||||
@@ -204,6 +216,7 @@ namespace gridfire::engine {
|
||||
double rho
|
||||
) const override;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Calculates the derivatives of the energy generation rate with respect to temperature and density for a subset of reactions
|
||||
*
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include "fourdst/config/config.h"
|
||||
#include "fourdst/logging/logging.h"
|
||||
|
||||
#include "gridfire/engine/procedures/construction.h"
|
||||
#include "gridfire/engine/scratchpads/blob.h"
|
||||
|
||||
#include "quill/Logger.h"
|
||||
@@ -234,6 +233,26 @@ namespace gridfire::engine {
|
||||
scratch::StateBlob& ctx
|
||||
) const override;
|
||||
|
||||
/**
|
||||
* @brief Gets the set of inactive logical reactions in the network.
|
||||
*
|
||||
* @return ReactionSet containing all inactive reactions.
|
||||
*
|
||||
* This method returns the set of reactions that have been culled from the active
|
||||
* network based on the adaptation criteria.
|
||||
*/
|
||||
[[nodiscard]] reaction::ReactionSet getInactiveNetworkReactions(
|
||||
scratch::StateBlob &ctx
|
||||
) const override;
|
||||
|
||||
[[nodiscard]] double getInactiveReactionMolarReactionFlow(
|
||||
scratch::StateBlob& ctx,
|
||||
const reaction::Reaction &reaction,
|
||||
const fourdst::composition::CompositionAbstract &comp,
|
||||
double T9,
|
||||
double rho
|
||||
) const override;
|
||||
|
||||
/**
|
||||
* @brief Computes timescales for all active species in the network.
|
||||
*
|
||||
@@ -319,6 +338,7 @@ namespace gridfire::engine {
|
||||
/**
|
||||
* @brief Primes the engine with the given network input.
|
||||
*
|
||||
* @param ctx The scratchpad context for storing thread-local data.
|
||||
* @param netIn The current network input, containing temperature, density, and composition.
|
||||
* @return A PrimingReport indicating the result of the priming operation.
|
||||
*
|
||||
@@ -367,6 +387,8 @@ namespace gridfire::engine {
|
||||
[[nodiscard]] std::optional<StepDerivatives<double>>getMostRecentRHSCalculation(
|
||||
scratch::StateBlob &ctx
|
||||
) const override;
|
||||
|
||||
[[nodiscard]] std::unique_ptr<scratch::StateBlob> constructStateBlob(const scratch::StateBlob *blob) const override;
|
||||
private:
|
||||
using LogManager = fourdst::logging::LogManager;
|
||||
|
||||
@@ -399,7 +421,7 @@ namespace gridfire::engine {
|
||||
* @param netIn The current network input, containing temperature, density, and composition.
|
||||
* @return 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
|
||||
* present in netIn but are present in the definition of the base engine are registered but have 0 mass fraction.
|
||||
*
|
||||
* @par Algorithm:
|
||||
* 1. Iterates through all species in the base engine's network.
|
||||
|
||||
@@ -255,6 +255,9 @@ namespace gridfire::engine {
|
||||
[[nodiscard]] std::optional<StepDerivatives<double>>getMostRecentRHSCalculation(
|
||||
scratch::StateBlob &ctx
|
||||
) const override;
|
||||
|
||||
[[nodiscard]] std::unique_ptr<scratch::StateBlob> constructStateBlob(const scratch::StateBlob *blob) const override;
|
||||
|
||||
protected:
|
||||
bool m_isStale = true;
|
||||
GraphEngine& m_baseEngine;
|
||||
@@ -343,7 +346,6 @@ namespace gridfire::engine {
|
||||
scratch::StateBlob& ctx,
|
||||
const std::vector<std::string>& peNames
|
||||
) const;
|
||||
|
||||
};
|
||||
|
||||
class FileDefinedEngineView final: public DefinedEngineView {
|
||||
|
||||
@@ -611,6 +611,8 @@ namespace gridfire::engine {
|
||||
[[nodiscard]] std::optional<StepDerivatives<double>>getMostRecentRHSCalculation(
|
||||
scratch::StateBlob &
|
||||
) const override;
|
||||
|
||||
[[nodiscard]] std::unique_ptr<scratch::StateBlob> constructStateBlob(const scratch::StateBlob *blob) const override;
|
||||
public:
|
||||
/**
|
||||
* @brief Struct representing a QSE group.
|
||||
@@ -990,9 +992,6 @@ namespace gridfire::engine {
|
||||
const std::vector<QSEGroup> &groups,
|
||||
const std::vector<reaction::ReactionSet> &groupReactions
|
||||
);
|
||||
|
||||
public:
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace gridfire::engine {
|
||||
/**
|
||||
* @brief Constructs the view by looking up the priming species by symbol.
|
||||
*
|
||||
* @param ctx State Blob containing Engine context
|
||||
* @param primingSymbol Symbol string of the species to prime.
|
||||
* @param baseEngine Reference to the base DynamicEngine to wrap.
|
||||
* @pre primingSymbol must correspond to a valid species in atomic::species registry.
|
||||
@@ -46,6 +47,7 @@ namespace gridfire::engine {
|
||||
/**
|
||||
* @brief Constructs the view using an existing Species object.
|
||||
*
|
||||
* @param ctx State Blob containing Engine context
|
||||
* @param primingSpecies The species object to prime.
|
||||
* @param baseEngine Reference to the base DynamicEngine to wrap.
|
||||
* @pre primingSpecies must be valid and present in the network of baseEngine.
|
||||
@@ -66,6 +68,7 @@ namespace gridfire::engine {
|
||||
/**
|
||||
* @brief Constructs the set of reaction names that involve the priming species.
|
||||
*
|
||||
* @param ctx State blob containing engine context
|
||||
* @param primingSpecies Species for which to collect priming reactions.
|
||||
* @param baseEngine Base engine containing the full network of reactions.
|
||||
* @pre baseEngine.getNetworkReactions() returns a valid iterable set of reactions.
|
||||
|
||||
@@ -11,4 +11,4 @@
|
||||
#include "gridfire/trigger/trigger.h"
|
||||
#include "gridfire/utils/utils.h"
|
||||
|
||||
#include "types/types.h"
|
||||
#include "gridfire/types/types.h"
|
||||
|
||||
@@ -58,6 +58,8 @@ namespace gridfire::solver {
|
||||
const size_t currentNonlinearIterations; ///< Total number of non-linear iterations
|
||||
const std::map<fourdst::atomic::Species, std::unordered_map<std::string, double>>& reactionContributionMap; ///< Map of reaction contributions for the current step
|
||||
engine::scratch::StateBlob& state_ctx; ///< Reference to the engine scratch state blob
|
||||
double current_total_energy = 0.0; ///< Current energy generation rate [erg/g/s]
|
||||
double current_neutrino_energy_loss_rate = 0.0; ///< Current neutrino energy loss rate [erg/g/s]
|
||||
|
||||
PointSolverTimestepContext(
|
||||
double t,
|
||||
@@ -76,6 +78,8 @@ namespace gridfire::solver {
|
||||
);
|
||||
|
||||
[[nodiscard]] std::vector<std::tuple<std::string, std::string>> describe() const override;
|
||||
|
||||
[[nodiscard]] fourdst::composition::Composition getPhysicalComposition() const;
|
||||
};
|
||||
|
||||
using TimestepCallback = std::function<void(const PointSolverTimestepContext& context)>; ///< Type alias for a timestep callback function.
|
||||
@@ -169,6 +173,13 @@ namespace gridfire::solver {
|
||||
const engine::DynamicEngine& engine
|
||||
);
|
||||
|
||||
PointSolver(
|
||||
const engine::DynamicEngine& engine,
|
||||
const config::GridFireConfig& config
|
||||
);
|
||||
|
||||
|
||||
config::GridFireConfig getConfig() const { return *m_config; }
|
||||
/**
|
||||
* @brief Integrate from t=0 to netIn.tMax and return final composition and energy.
|
||||
*
|
||||
@@ -264,6 +275,17 @@ namespace gridfire::solver {
|
||||
*/
|
||||
static int cvode_jac_wrapper(sunrealtype t, N_Vector y, N_Vector ydot, SUNMatrix J, void *user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
|
||||
|
||||
/**
|
||||
* @brief CVODE error handler that logs errors and warnings from SUNDIALS using the solver's logger.
|
||||
* @param line
|
||||
* @param func
|
||||
* @param file
|
||||
* @param msg
|
||||
* @param err_code
|
||||
* @param err_user_data
|
||||
* @param sunctx
|
||||
*/
|
||||
static void cvode_error_handler(int line, const char *func, const char *file, const char *msg, SUNErrCode err_code, void *err_user_data, SUNContext sunctx);
|
||||
/**
|
||||
* @brief Compute RHS into ydot at time t from the engine and current state y.
|
||||
*
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "gridfire/trigger/trigger_result.h"
|
||||
#include "gridfire/solver/strategies/PointSolver.h"
|
||||
#include "fourdst/logging/logging.h"
|
||||
#include "gridfire/config/config.h"
|
||||
|
||||
#include <string>
|
||||
#include <deque>
|
||||
@@ -316,6 +317,46 @@ namespace gridfire::trigger::solver::CVODE {
|
||||
bool rel_failure(const gridfire::solver::PointSolverTimestepContext& ctx) const;
|
||||
};
|
||||
|
||||
class BoundaryFluxTrigger final : public Trigger<gridfire::solver::PointSolverTimestepContext> {
|
||||
public:
|
||||
explicit BoundaryFluxTrigger(double relativeThreshold, double absoluteThreshold);
|
||||
bool check(const gridfire::solver::PointSolverTimestepContext &ctx) const override;
|
||||
void update(const gridfire::solver::PointSolverTimestepContext &ctx) override;
|
||||
void step(const gridfire::solver::PointSolverTimestepContext &ctx) override;
|
||||
void reset() override;
|
||||
|
||||
std::string name() const override;
|
||||
TriggerResult why(const gridfire::solver::PointSolverTimestepContext &ctx) const override;
|
||||
std::string describe() const override;
|
||||
size_t numTriggers() const override;
|
||||
size_t numMisses() const override;
|
||||
private:
|
||||
enum class ReactionSetType : uint8_t {
|
||||
ACTIVE,
|
||||
INACTIVE
|
||||
};
|
||||
|
||||
static double get_reaction_set_flow(
|
||||
const reaction::ReactionSet& reactions,
|
||||
const gridfire::solver::PointSolverTimestepContext& ctx,
|
||||
const fourdst::composition::Composition& comp,
|
||||
double T9,
|
||||
double rho,
|
||||
ReactionSetType type
|
||||
);
|
||||
private:
|
||||
quill::Logger* m_logger = fourdst::logging::LogManager::getInstance().getLogger("log");
|
||||
|
||||
mutable size_t m_hits = 0;
|
||||
mutable size_t m_misses = 0;
|
||||
mutable size_t m_updates = 0;
|
||||
mutable size_t m_resets = 0;
|
||||
|
||||
double m_relativeThreshold;
|
||||
double m_absoluteThreshold;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Compose a trigger suitable for deciding engine re-partitioning during CVODE solves.
|
||||
*
|
||||
@@ -329,18 +370,9 @@ namespace gridfire::trigger::solver::CVODE {
|
||||
* See engine_partitioning_trigger.cpp for construction details using OrTrigger and
|
||||
* EveryNthTrigger from trigger_logical.h.
|
||||
*
|
||||
* @param simulationTimeInterval Interval used by SimulationTimeTrigger (> 0).
|
||||
* @param offDiagonalThreshold Off-diagonal Jacobian magnitude threshold (>= 0).
|
||||
* @param timestepCollapseRatio Threshold for timestep deviation (>= 0, and <= 1 when relative).
|
||||
* @param maxConvergenceFailures Window size for timestep averaging (>= 1 recommended).
|
||||
* @return A unique_ptr to a composed Trigger<TimestepContext> implementing the policy above.
|
||||
*
|
||||
* @note The exact policy is subject to change; this function centralizes that decision.
|
||||
*/
|
||||
std::unique_ptr<Trigger<gridfire::solver::PointSolverTimestepContext>> makeEnginePartitioningTrigger(
|
||||
double simulationTimeInterval,
|
||||
double offDiagonalThreshold,
|
||||
double timestepCollapseRatio,
|
||||
size_t maxConvergenceFailures
|
||||
);
|
||||
std::unique_ptr<Trigger<gridfire::solver::PointSolverTimestepContext>> makeEnginePartitioningTrigger(const config::TriggerConfig& cfg);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,8 @@
|
||||
#include "cppad/cppad.hpp"
|
||||
#include "cppad/utility/sparse_rc.hpp"
|
||||
#include "cppad/utility/sparse_rcv.hpp"
|
||||
|
||||
#include "fourdst/composition/exceptions/exceptions_composition.h"
|
||||
#include "gridfire/reaction/reaclib.h"
|
||||
|
||||
|
||||
namespace {
|
||||
@@ -132,6 +133,36 @@ namespace gridfire::engine {
|
||||
syncInternalMaps();
|
||||
}
|
||||
|
||||
void GraphEngine::addReaction(
|
||||
const reaction::Reaction& reaction
|
||||
) {
|
||||
m_reactions.add_reaction(reaction);
|
||||
syncInternalMaps();
|
||||
}
|
||||
|
||||
void GraphEngine::addReaction(
|
||||
const std::string& reaction_id
|
||||
) {
|
||||
const auto& allReaclibReactions = reaclib::get_all_reaclib_reactions();
|
||||
const auto& reaction = allReaclibReactions.get(reaction_id);
|
||||
if (reaction.has_value()) {
|
||||
m_reactions.add_reaction(reaction.value()->clone());
|
||||
} else {
|
||||
throw exceptions::BadCollectionError(std::format("Unable to locate reaction with ID {} in reaclib set", reaction_id));
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<scratch::StateBlob> GraphEngine::constructStateBlob(const scratch::StateBlob *blob) const {
|
||||
if (blob) {
|
||||
throw exceptions::ScratchPadError("GraphEngine does not support accepting an external StateBlob. The state blob for GraphEngine must be constructed internally to ensure it contains the correct scratchpad states.");
|
||||
}
|
||||
auto i_blob = std::make_unique<scratch::StateBlob>();
|
||||
i_blob->enroll<engine::scratch::GraphEngineScratchPad>();
|
||||
auto* state = scratch::get_state<scratch::GraphEngineScratchPad, false>(*i_blob);
|
||||
state->initialize(*this);
|
||||
return i_blob;
|
||||
}
|
||||
|
||||
std::expected<StepDerivatives<double>, EngineStatus> GraphEngine::calculateRHSAndEnergy(
|
||||
scratch::StateBlob& ctx,
|
||||
const fourdst::composition::CompositionAbstract &comp,
|
||||
@@ -761,7 +792,14 @@ namespace gridfire::engine {
|
||||
for (const auto& species : m_networkSpecies ) {
|
||||
result.registerSpecies(species);
|
||||
if (comp.contains(species)) {
|
||||
result.setMolarAbundance(species, comp.getMolarAbundance(species));
|
||||
double Y = comp.getMolarAbundance(species);
|
||||
if (Y < 0.0 && std::abs(Y) <= 1e-16) {
|
||||
result.setMolarAbundance(species, 0.0);
|
||||
} else if (Y < 0.0 && std::abs(Y) >= 1e-16) {
|
||||
throw fourdst::composition::exceptions::InvalidCompositionError(std::format("Molar abundance for species {} is negative (Y = {}). GraphEngine does not support non-physical negative abundances, even if they are very small in magnitude (clamp is 1e-16). Check input composition for validity.", species.name(), Y));
|
||||
} else {
|
||||
result.setMolarAbundance(species, Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -997,7 +1035,7 @@ namespace gridfire::engine {
|
||||
for (const auto& species: m_networkSpecies) {
|
||||
double Yi = 0.0; // Small floor to avoid issues with zero abundances
|
||||
if (comp.contains(species)) {
|
||||
Yi = comp.getMolarAbundance(species);
|
||||
Yi = std::max(comp.getMolarAbundance(species), 1e-30);
|
||||
}
|
||||
x[i] = Yi;
|
||||
i++;
|
||||
|
||||
@@ -166,6 +166,35 @@ namespace gridfire::engine {
|
||||
return scratch::get_state<scratch::AdaptiveEngineViewScratchPad, true>(ctx) -> active_reactions;
|
||||
}
|
||||
|
||||
reaction::ReactionSet AdaptiveEngineView::getInactiveNetworkReactions(scratch::StateBlob &ctx) const {
|
||||
const reaction::ReactionSet& baseEngineReactions = m_baseEngine.getNetworkReactions(ctx);
|
||||
const reaction::ReactionSet baseEngineInactiveReactions = m_baseEngine.getInactiveNetworkReactions(ctx);
|
||||
|
||||
|
||||
reaction::ReactionSet inactiveReactions = baseEngineInactiveReactions;
|
||||
const auto* state = scratch::get_state<scratch::AdaptiveEngineViewScratchPad, true>(ctx);
|
||||
const reaction::ReactionSet& activeReactions = state->active_reactions;
|
||||
|
||||
for (const auto& active_reaction : baseEngineReactions) {
|
||||
if (!inactiveReactions.contains(*active_reaction) && !activeReactions.contains(*active_reaction)) {
|
||||
inactiveReactions.add_reaction(*active_reaction);
|
||||
}
|
||||
}
|
||||
|
||||
return inactiveReactions;
|
||||
|
||||
}
|
||||
|
||||
double AdaptiveEngineView::getInactiveReactionMolarReactionFlow(
|
||||
scratch::StateBlob &ctx,
|
||||
const reaction::Reaction &reaction,
|
||||
const fourdst::composition::CompositionAbstract &comp,
|
||||
const double T9,
|
||||
const double rho
|
||||
) const {
|
||||
return m_baseEngine.calculateMolarReactionFlow(ctx, reaction, comp, T9, rho);
|
||||
}
|
||||
|
||||
std::expected<std::unordered_map<Species, double>, EngineStatus> AdaptiveEngineView::getSpeciesTimescales(
|
||||
scratch::StateBlob& ctx,
|
||||
const fourdst::composition::CompositionAbstract &comp,
|
||||
@@ -268,6 +297,19 @@ namespace gridfire::engine {
|
||||
return m_baseEngine.getMostRecentRHSCalculation(ctx);
|
||||
}
|
||||
|
||||
std::unique_ptr<scratch::StateBlob> AdaptiveEngineView::constructStateBlob(const scratch::StateBlob *blob) const {
|
||||
std::unique_ptr<scratch::StateBlob> i_blob;
|
||||
if (blob) {
|
||||
i_blob = blob->clone_structure();
|
||||
} else {
|
||||
i_blob = std::make_unique<scratch::StateBlob>();
|
||||
}
|
||||
i_blob->enroll<scratch::AdaptiveEngineViewScratchPad>();
|
||||
auto* state = scratch::get_state<scratch::AdaptiveEngineViewScratchPad, false>(*i_blob);
|
||||
state->initialize(*this);
|
||||
return i_blob;
|
||||
}
|
||||
|
||||
size_t AdaptiveEngineView::getSpeciesIndex(
|
||||
scratch::StateBlob& ctx,
|
||||
const Species &species
|
||||
|
||||
@@ -267,6 +267,10 @@ namespace gridfire::engine {
|
||||
return m_baseEngine.getMostRecentRHSCalculation(ctx);
|
||||
}
|
||||
|
||||
std::unique_ptr<scratch::StateBlob> DefinedEngineView::constructStateBlob(const scratch::StateBlob *blob) const {
|
||||
throw exceptions::ScratchPadError("DefinedEngineView does not support StateBlob construction. This will be implemented in a future version.");
|
||||
}
|
||||
|
||||
std::vector<size_t> DefinedEngineView::constructSpeciesIndexMap(
|
||||
scratch::StateBlob& ctx
|
||||
) const {
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "sunlinsol/sunlinsol_dense.h"
|
||||
|
||||
#include "xxhash64.h"
|
||||
#include "fourdst/composition/exceptions/exceptions_composition.h"
|
||||
#include "fourdst/composition/utils/composition_hash.h"
|
||||
|
||||
namespace {
|
||||
@@ -1123,6 +1124,19 @@ namespace gridfire::engine {
|
||||
return m_baseEngine.getMostRecentRHSCalculation(ctx);
|
||||
}
|
||||
|
||||
std::unique_ptr<scratch::StateBlob> MultiscalePartitioningEngineView::constructStateBlob(const scratch::StateBlob *blob) const {
|
||||
std::unique_ptr<scratch::StateBlob> i_blob;
|
||||
if (blob) {
|
||||
i_blob = blob->clone_structure();
|
||||
} else {
|
||||
i_blob = std::make_unique<scratch::StateBlob>();
|
||||
}
|
||||
i_blob->enroll<scratch::MultiscalePartitioningEngineViewScratchPad>();
|
||||
auto* state = scratch::get_state<scratch::MultiscalePartitioningEngineViewScratchPad, false>(*i_blob);
|
||||
state->initialize();
|
||||
return i_blob;
|
||||
}
|
||||
|
||||
size_t MultiscalePartitioningEngineView::getSpeciesIndex(
|
||||
scratch::StateBlob& ctx,
|
||||
const Species &species
|
||||
@@ -1549,8 +1563,10 @@ namespace gridfire::engine {
|
||||
m_logger->flush_log();
|
||||
throw exceptions::EngineError("Non-finite abundance computed for species " + std::string(sp.name()) + " in QSE group solve.");
|
||||
}
|
||||
if (y < 0.0 && std::abs(y) < 1e-20) {
|
||||
if (y < 0.0 && std::abs(y) < 1e-16) {
|
||||
abundances.push_back(0.0);
|
||||
} else if (y < 0 && std::abs(y) >= 1e-16) {
|
||||
throw fourdst::composition::exceptions::InvalidCompositionError(std::format("Computed negative and non-trivial abundance {} for species {} in QSE group solve at T9 = {}, rho = {}. This likely indicates a failure of the QSE solver to converge to a physical solution.", y, sp.name(), T9, rho));
|
||||
} else {
|
||||
abundances.push_back(y);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "gridfire/trigger/procedures/trigger_pprint.h"
|
||||
#include "gridfire/exceptions/error_solver.h"
|
||||
#include "gridfire/utils/sundials.h"
|
||||
#include "gridfire/config/config.h"
|
||||
|
||||
|
||||
namespace gridfire::solver {
|
||||
@@ -74,6 +75,19 @@ namespace gridfire::solver {
|
||||
return description;
|
||||
}
|
||||
|
||||
fourdst::composition::Composition PointSolverTimestepContext::getPhysicalComposition() const {
|
||||
sunrealtype* y_data = N_VGetArrayPointer(state);
|
||||
std::vector<double> y_vec(y_data, y_data + networkSpecies.size());
|
||||
|
||||
for (int i = 0; i < y_vec.size(); i++) {
|
||||
if (y_vec[i] < 0 && std::abs(y_vec[i]) <= 1e-16) {
|
||||
y_vec[i] = 0.0; // clamp to 0 to avoid small numerical noise issues
|
||||
}
|
||||
}
|
||||
const fourdst::composition::Composition base_comp(networkSpecies, y_vec);
|
||||
return engine.collectComposition(state_ctx, base_comp, T9, rho);
|
||||
}
|
||||
|
||||
void PointSolverContext::init() {
|
||||
reset_all();
|
||||
init_context();
|
||||
@@ -165,6 +179,15 @@ namespace gridfire::solver {
|
||||
const DynamicEngine &engine
|
||||
): SingleZoneNetworkSolver(engine) {}
|
||||
|
||||
PointSolver::PointSolver(
|
||||
const engine::DynamicEngine &engine,
|
||||
const config::GridFireConfig &config
|
||||
) : SingleZoneNetworkSolver(engine) {
|
||||
m_config.mutate([&config](auto& cfg) {
|
||||
cfg = config;
|
||||
});
|
||||
}
|
||||
|
||||
NetOut PointSolver::evaluate(
|
||||
SolverContextBase& solver_ctx,
|
||||
const NetIn& netIn
|
||||
@@ -179,10 +202,13 @@ namespace gridfire::solver {
|
||||
bool forceReinitialize
|
||||
) const {
|
||||
auto* sctx_p = dynamic_cast<PointSolverContext*>(&solver_ctx);
|
||||
if (sctx_p == nullptr) {
|
||||
throw exceptions::SolverError("Provided solver context is not of type PointSolverContext");
|
||||
}
|
||||
|
||||
LOG_TRACE_L1(m_logger, "Starting solver evaluation with T9: {} and rho: {}", netIn.temperature/1e9, netIn.density);
|
||||
LOG_TRACE_L1(m_logger, "Building engine update trigger....");
|
||||
auto trigger = trigger::solver::CVODE::makeEnginePartitioningTrigger(1e12, 1e10, 0.5, 2);
|
||||
auto trigger = trigger::solver::CVODE::makeEnginePartitioningTrigger(m_config->solver.pointSolver.trigger);
|
||||
LOG_TRACE_L1(m_logger, "Engine update trigger built!");
|
||||
|
||||
|
||||
@@ -194,10 +220,10 @@ namespace gridfire::solver {
|
||||
// 3. If the user has not set tolerances in code and the config does not have them, use hardcoded defaults
|
||||
|
||||
if (!sctx_p->abs_tol.has_value()) {
|
||||
sctx_p->abs_tol = m_config->solver.cvode.absTol;
|
||||
sctx_p->abs_tol = m_config->solver.pointSolver.absTol;
|
||||
}
|
||||
if (!sctx_p->rel_tol.has_value()) {
|
||||
sctx_p->rel_tol = m_config->solver.cvode.relTol;
|
||||
sctx_p->rel_tol = m_config->solver.pointSolver.relTol;
|
||||
}
|
||||
|
||||
|
||||
@@ -369,6 +395,8 @@ namespace gridfire::solver {
|
||||
rcMap,
|
||||
*sctx_p->engine_ctx
|
||||
);
|
||||
ctx.current_total_energy = current_energy;
|
||||
ctx.current_neutrino_energy_loss_rate = accumulated_neutrino_energy_loss;
|
||||
|
||||
prev_nonlinear_iterations = nliters + total_nonlinear_iterations;
|
||||
prev_convergence_failures = nlcfails + total_convergence_failures;
|
||||
@@ -395,7 +423,7 @@ namespace gridfire::solver {
|
||||
trigger::printWhy(trigger->why(ctx));
|
||||
}
|
||||
trigger->update(ctx);
|
||||
accumulated_energy += current_energy; // Add the specific energy rate to the accumulated energy
|
||||
accumulated_energy = current_energy; // Add the specific energy rate to the accumulated energy
|
||||
total_nonlinear_iterations += nliters;
|
||||
total_convergence_failures += nlcfails;
|
||||
total_steps += n_steps;
|
||||
@@ -569,7 +597,7 @@ namespace gridfire::solver {
|
||||
LOG_INFO(m_logger, "CVODE iteration complete");
|
||||
|
||||
sunrealtype* y_data = N_VGetArrayPointer(sctx_p->Y);
|
||||
accumulated_energy += y_data[numSpecies];
|
||||
accumulated_energy = y_data[numSpecies];
|
||||
std::vector<double> y_vec(y_data, y_data + numSpecies);
|
||||
|
||||
for (double & i : y_vec) {
|
||||
@@ -789,6 +817,16 @@ namespace gridfire::solver {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void PointSolver::cvode_error_handler(int line, const char *func, const char *file, const char *msg, SUNErrCode err_code, void *err_user_data, SUNContext sunctx) {
|
||||
auto* logger = static_cast<quill::Logger*>(err_user_data);
|
||||
if (!logger) return;
|
||||
|
||||
if (err_code < 0) {
|
||||
LOG_ERROR(logger, "[SUNDIALS ERROR] {} at {}:{}: {}", func, file, line, msg);
|
||||
} else {
|
||||
LOG_WARNING(logger, "[SUNDIALS WARNING] {} at {}:{}: {}", func, file, line, msg);
|
||||
}
|
||||
}
|
||||
PointSolver::CVODERHSOutputData PointSolver::calculate_rhs(
|
||||
const sunrealtype t,
|
||||
N_Vector y,
|
||||
@@ -863,9 +901,12 @@ namespace gridfire::solver {
|
||||
|
||||
sctx_p->cvode_mem = CVodeCreate(CV_BDF, sctx_p->sun_ctx);
|
||||
utils::check_cvode_flag(sctx_p->cvode_mem == nullptr ? -1 : 0, "CVodeCreate");
|
||||
|
||||
sctx_p->Y = utils::init_sun_vector(N, sctx_p->sun_ctx);
|
||||
sctx_p->YErr = N_VClone(sctx_p->Y);
|
||||
|
||||
SUNContext_PushErrHandler(sctx_p->sun_ctx, cvode_error_handler, m_logger);
|
||||
|
||||
sunrealtype *y_data = N_VGetArrayPointer(sctx_p->Y);
|
||||
for (size_t i = 0; i < numSpecies; i++) {
|
||||
const auto& species = m_engine.getNetworkSpecies(*sctx_p->engine_ctx)[i];
|
||||
@@ -880,6 +921,7 @@ namespace gridfire::solver {
|
||||
|
||||
utils::check_cvode_flag(CVodeInit(sctx_p->cvode_mem, cvode_rhs_wrapper, current_time, sctx_p->Y), "CVodeInit");
|
||||
utils::check_cvode_flag(CVodeSStolerances(sctx_p->cvode_mem, relTol, absTol), "CVodeSStolerances");
|
||||
utils::check_cvode_flag(CVodeSetInitStep(sctx_p->cvode_mem, 1.0e-8), "CVodeSetInitStep");
|
||||
|
||||
// Constraints
|
||||
// We constrain the solution vector using CVODE's built in constraint flags as outlines on page 53 of the CVODE manual
|
||||
@@ -1003,10 +1045,10 @@ namespace gridfire::solver {
|
||||
std::vector<double> E_full(y_err_data, y_err_data + num_components - 1);
|
||||
|
||||
if (!sctx_p->abs_tol.has_value()) {
|
||||
sctx_p->abs_tol = m_config->solver.cvode.absTol;
|
||||
sctx_p->abs_tol = m_config->solver.pointSolver.absTol;
|
||||
}
|
||||
if (!sctx_p->rel_tol.has_value()) {
|
||||
sctx_p->rel_tol = m_config->solver.cvode.relTol;
|
||||
sctx_p->rel_tol = m_config->solver.pointSolver.relTol;
|
||||
}
|
||||
|
||||
auto result = diagnostics::report_limiting_species(ctx, *user_data.engine, Y_full, E_full, sctx_p->rel_tol.value(), sctx_p->abs_tol.value(), 10, to_file);
|
||||
|
||||
@@ -4,12 +4,16 @@
|
||||
#include "gridfire/trigger/trigger_logical.h"
|
||||
#include "gridfire/trigger/trigger_abstract.h"
|
||||
|
||||
#include "sundials/sundials_nvector.h"
|
||||
|
||||
#include "quill/LogMacros.h"
|
||||
|
||||
#include <memory>
|
||||
#include <deque>
|
||||
#include <string>
|
||||
|
||||
#include "gridfire/utils/utils.h"
|
||||
|
||||
namespace {
|
||||
template <typename T>
|
||||
void push_to_fixed_deque(std::deque<T>& dq, T value, size_t max_size) {
|
||||
@@ -369,23 +373,195 @@ namespace gridfire::trigger::solver::CVODE {
|
||||
return false;
|
||||
}
|
||||
|
||||
BoundaryFluxTrigger::BoundaryFluxTrigger(
|
||||
const double relativeThreshold,
|
||||
const double absoluteThreshold
|
||||
) :
|
||||
m_relativeThreshold(relativeThreshold),
|
||||
m_absoluteThreshold(absoluteThreshold) {
|
||||
if (m_relativeThreshold <= 0.0) {
|
||||
throw exceptions::GridFireError(std::format("Relative threshold must be positive and non zero, currently it is {}", m_relativeThreshold));
|
||||
}
|
||||
}
|
||||
|
||||
void BoundaryFluxTrigger::step(const gridfire::solver::PointSolverTimestepContext &ctx) {
|
||||
// Does nothing; not a stateful trigger
|
||||
}
|
||||
|
||||
|
||||
bool BoundaryFluxTrigger::check(const gridfire::solver::PointSolverTimestepContext &ctx) const {
|
||||
// First get the current total flow through all active reactions
|
||||
sunrealtype* y_data = N_VGetArrayPointer(ctx.state);
|
||||
std::vector<double> Y(y_data, y_data + ctx.networkSpecies.size());
|
||||
// Adjust any tiny negative abundances to zero using std::ranges
|
||||
std::ranges::transform(
|
||||
Y,
|
||||
Y.begin(),
|
||||
[](const double y) {
|
||||
if (y < 0 && y > -1e-16) {
|
||||
return 0.0;
|
||||
}
|
||||
return y;
|
||||
}
|
||||
);
|
||||
const fourdst::composition::Composition comp(ctx.networkSpecies, Y);
|
||||
|
||||
const double net_active_flow = get_reaction_set_flow(
|
||||
ctx.engine.getNetworkReactions(ctx.state_ctx),
|
||||
ctx,
|
||||
comp,
|
||||
ctx.T9,
|
||||
ctx.rho,
|
||||
ReactionSetType::ACTIVE
|
||||
);
|
||||
|
||||
const reaction::ReactionSet inactiveReactions = ctx.engine.getInactiveNetworkReactions(ctx.state_ctx);
|
||||
if (inactiveReactions.empty()) {
|
||||
m_misses++;
|
||||
return false; // No inactive reactions to consider
|
||||
}
|
||||
|
||||
const double net_boundary_flow = get_reaction_set_flow(
|
||||
inactiveReactions,
|
||||
ctx,
|
||||
comp,
|
||||
ctx.T9,
|
||||
ctx.rho,
|
||||
ReactionSetType::INACTIVE
|
||||
);
|
||||
|
||||
|
||||
if (net_boundary_flow > m_absoluteThreshold) {
|
||||
m_hits++;
|
||||
return true;
|
||||
}
|
||||
|
||||
const double relative_boundary_flow = net_boundary_flow / (net_active_flow + 1e-300); // Avoid division by zero
|
||||
if (relative_boundary_flow >= m_relativeThreshold) {
|
||||
m_hits++;
|
||||
return true;
|
||||
}
|
||||
|
||||
m_misses++;
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
void BoundaryFluxTrigger::update(const gridfire::solver::PointSolverTimestepContext &ctx) {
|
||||
// No-op since this is a stateless trigger
|
||||
m_updates++;
|
||||
}
|
||||
|
||||
void BoundaryFluxTrigger::reset() {
|
||||
m_hits = 0;
|
||||
m_misses = 0;
|
||||
m_updates = 0;
|
||||
m_resets++;
|
||||
}
|
||||
|
||||
std::string BoundaryFluxTrigger::name() const {
|
||||
return "BoundaryFluxTrigger";
|
||||
}
|
||||
|
||||
std::string BoundaryFluxTrigger::describe() const {
|
||||
return std::format("BoundaryFluxTrigger(rel={}, abs={})", m_relativeThreshold, m_absoluteThreshold);
|
||||
}
|
||||
|
||||
TriggerResult BoundaryFluxTrigger::why(const gridfire::solver::PointSolverTimestepContext &ctx) const {
|
||||
sunrealtype* y_data = N_VGetArrayPointer(ctx.state);
|
||||
const std::vector<double> Y(y_data, y_data + ctx.networkSpecies.size());
|
||||
const fourdst::composition::Composition comp(ctx.networkSpecies, Y);
|
||||
|
||||
const double net_active_flow = get_reaction_set_flow(
|
||||
ctx.engine.getNetworkReactions(ctx.state_ctx),
|
||||
ctx,
|
||||
comp,
|
||||
ctx.T9,
|
||||
ctx.rho,
|
||||
ReactionSetType::ACTIVE
|
||||
);
|
||||
const reaction::ReactionSet inactiveReactions = ctx.engine.getInactiveNetworkReactions(ctx.state_ctx);
|
||||
const double net_boundary_flow = get_reaction_set_flow(
|
||||
inactiveReactions,
|
||||
ctx,
|
||||
comp,
|
||||
ctx.T9,
|
||||
ctx.rho,
|
||||
ReactionSetType::INACTIVE
|
||||
);
|
||||
|
||||
TriggerResult result;
|
||||
result.name = name();
|
||||
if (check(ctx)) {
|
||||
result.value = true;
|
||||
result.description = std::format(
|
||||
"Triggered because boundary flux ({} mol/s) exceeded thresholds: absolute threshold = {} mol/s, relative threshold = {} (boundary flow = {} mol/s, active flow = {} mol/s)",
|
||||
net_boundary_flow,
|
||||
m_absoluteThreshold,
|
||||
m_relativeThreshold,
|
||||
net_boundary_flow,
|
||||
net_active_flow
|
||||
);
|
||||
} else {
|
||||
result.value = false;
|
||||
result.description = std::format(
|
||||
"Not triggered because boundary flux ({} mol/g/s) did not exceed thresholds: absolute threshold = {} mol/g/s, relative threshold = {} (boundary flow = {} mol/g/s, active flow = {} mol/g/s)",
|
||||
net_boundary_flow,
|
||||
m_absoluteThreshold,
|
||||
m_relativeThreshold,
|
||||
net_boundary_flow,
|
||||
net_active_flow
|
||||
);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
size_t BoundaryFluxTrigger::numMisses() const {
|
||||
return m_misses;
|
||||
}
|
||||
|
||||
double BoundaryFluxTrigger::get_reaction_set_flow(
|
||||
const reaction::ReactionSet &reactions,
|
||||
const gridfire::solver::PointSolverTimestepContext &ctx,
|
||||
const fourdst::composition::Composition &comp,
|
||||
const double T9,
|
||||
const double rho,
|
||||
const ReactionSetType type
|
||||
) {
|
||||
double flow = 0.0;
|
||||
for (const auto& reaction: reactions) {
|
||||
double rFlow = 0.0;
|
||||
if (type == ReactionSetType::ACTIVE) {
|
||||
rFlow = ctx.engine.calculateMolarReactionFlow(ctx.state_ctx, *reaction, comp, T9, rho);
|
||||
} else {
|
||||
rFlow = ctx.engine.getInactiveReactionMolarReactionFlow(ctx.state_ctx, *reaction, comp, T9, rho);
|
||||
}
|
||||
flow += std::abs(rFlow);
|
||||
}
|
||||
|
||||
return flow;
|
||||
|
||||
}
|
||||
|
||||
size_t BoundaryFluxTrigger::numTriggers() const {
|
||||
return m_hits;
|
||||
}
|
||||
|
||||
std::unique_ptr<Trigger<gridfire::solver::PointSolverTimestepContext>> makeEnginePartitioningTrigger(
|
||||
const double simulationTimeInterval,
|
||||
const double offDiagonalThreshold,
|
||||
const double timestepCollapseRatio,
|
||||
const size_t maxConvergenceFailures
|
||||
const config::TriggerConfig& cfg
|
||||
) {
|
||||
using ctx_t = gridfire::solver::PointSolverTimestepContext;
|
||||
|
||||
// 1. INSTABILITY TRIGGERS (High Priority)
|
||||
// 1. INSTABILITY TRIGGERS
|
||||
auto convergenceFailureTrigger = std::make_unique<ConvergenceFailureTrigger>(
|
||||
maxConvergenceFailures,
|
||||
cfg.maxConvergenceFailures,
|
||||
1.0f,
|
||||
10
|
||||
);
|
||||
|
||||
auto timestepCollapseTrigger = std::make_unique<TimestepCollapseTrigger>(
|
||||
timestepCollapseRatio,
|
||||
cfg.timestepCollapseRatio,
|
||||
true, // relative
|
||||
5
|
||||
);
|
||||
@@ -396,12 +572,24 @@ namespace gridfire::trigger::solver::CVODE {
|
||||
);
|
||||
|
||||
// 2. MAINTENANCE TRIGGERS
|
||||
auto offDiagTrigger = std::make_unique<OffDiagonalTrigger>(offDiagonalThreshold);
|
||||
auto offDiagTrigger = std::make_unique<OffDiagonalTrigger>(cfg.offDiagonalThreshold);
|
||||
|
||||
// 3. PREDICTIVE TRIGGERS
|
||||
auto boundaryFluxTrigger = std::make_unique<BoundaryFluxTrigger>(
|
||||
cfg.boundaryFlux.relativeThreshold,
|
||||
cfg.boundaryFlux.absoluteThreshold
|
||||
);
|
||||
|
||||
// Combine boundary flux into off-diagonal trigger
|
||||
auto nonInstabilityGroup = std::make_unique<OrTrigger<ctx_t>>(
|
||||
std::move(offDiagTrigger),
|
||||
std::move(boundaryFluxTrigger)
|
||||
);
|
||||
|
||||
// Combine: (Instability) OR (Structure Change)
|
||||
return std::make_unique<OrTrigger<ctx_t>>(
|
||||
std::move(instabilityGroup),
|
||||
std::move(offDiagTrigger)
|
||||
std::move(nonInstabilityGroup)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,10 +6,24 @@
|
||||
namespace py = pybind11;
|
||||
|
||||
void register_config_bindings(pybind11::module &m) {
|
||||
|
||||
py::class_<gridfire::config::BoundaryFluxConfig>(m, "BoundaryFluxConfig")
|
||||
.def(py::init<>())
|
||||
.def_readwrite("relativeThreshold", &gridfire::config::BoundaryFluxConfig::relativeThreshold)
|
||||
.def_readwrite("absoluteThreshold", &gridfire::config::BoundaryFluxConfig::absoluteThreshold);
|
||||
|
||||
py::class_<gridfire::config::TriggerConfig>(m, "TriggerConfig")
|
||||
.def(py::init<>())
|
||||
.def_readwrite("offDiagonalThreshold", &gridfire::config::TriggerConfig::offDiagonalThreshold)
|
||||
.def_readwrite("timestepCollapseRatio", &gridfire::config::TriggerConfig::timestepCollapseRatio)
|
||||
.def_readwrite("maxConvergenceFailures", &gridfire::config::TriggerConfig::maxConvergenceFailures)
|
||||
.def_readwrite("boundaryFlux", &gridfire::config::TriggerConfig::boundaryFlux);
|
||||
|
||||
py::class_<gridfire::config::PointSolverConfig>(m, "PointSolverConfig")
|
||||
.def(py::init<>())
|
||||
.def_readwrite("absTol", &gridfire::config::PointSolverConfig::absTol)
|
||||
.def_readwrite("relTol", &gridfire::config::PointSolverConfig::relTol);
|
||||
.def_readwrite("relTol", &gridfire::config::PointSolverConfig::relTol)
|
||||
.def_readwrite("trigger", &gridfire::config::PointSolverConfig::trigger);
|
||||
|
||||
py::class_<gridfire::config::SolverConfig>(m, "SolverConfig")
|
||||
.def(py::init<>())
|
||||
|
||||
@@ -194,6 +194,25 @@ namespace {
|
||||
py::arg("ctx"),
|
||||
py::arg("species"),
|
||||
"Get the status of a species in the network."
|
||||
)
|
||||
.def("constructStateBlob",
|
||||
&T::constructStateBlob,
|
||||
py::arg("blob") = std::nullopt,
|
||||
"Construct the state blob for this engine. Generally base engines (GraphEngine) can call this with no arguments whereas views should take an argument to an already constructed state blob which will be cloned and then the clone will be modified"
|
||||
)
|
||||
.def(
|
||||
"getMostRecentRHSCalculation",
|
||||
[](const T& self, sp::StateBlob& ctx) -> std::optional<gridfire::engine::StepDerivatives<double>> {
|
||||
auto result = self.getMostRecentRHSCalculation(ctx);
|
||||
if (!result.has_value()) {
|
||||
return std::nullopt;
|
||||
} else {
|
||||
return result.value();
|
||||
}
|
||||
|
||||
},
|
||||
py::arg("ctx"),
|
||||
"Retrieve the most recent RHS calculation from the engine"
|
||||
);
|
||||
|
||||
}
|
||||
@@ -529,7 +548,18 @@ void con_stype_register_graph_engine_bindings(const pybind11::module &m) {
|
||||
&gridfire::engine::GraphEngine::isUsingReverseReactions,
|
||||
"Check if the engine is using reverse reactions."
|
||||
);
|
||||
|
||||
py_graph_engine_bindings.def(
|
||||
"addReaction",
|
||||
py::overload_cast<const gridfire::reaction::Reaction&>(&gridfire::engine::GraphEngine::addReaction),
|
||||
py::arg("reaction"),
|
||||
"Add a reaction to the engine's network manually."
|
||||
);
|
||||
py_graph_engine_bindings.def(
|
||||
"addReaction",
|
||||
py::overload_cast<const std::string&>(&gridfire::engine::GraphEngine::addReaction),
|
||||
py::arg("reaction_id"),
|
||||
"Add a reaction to the engine's network manually using a reaction identifier string."
|
||||
);
|
||||
// Register the general dynamic engine bindings
|
||||
registerDynamicEngineDefs<gridfire::engine::GraphEngine, gridfire::engine::DynamicEngine>(py_graph_engine_bindings);
|
||||
}
|
||||
|
||||
@@ -293,6 +293,16 @@ std::optional<gridfire::engine::StepDerivatives<double>> PyDynamicEngine::getMos
|
||||
);
|
||||
}
|
||||
|
||||
std::unique_ptr<gridfire::engine::scratch::StateBlob> PyDynamicEngine::constructStateBlob(
|
||||
const gridfire::engine::scratch::StateBlob *blob) const {
|
||||
PYBIND11_OVERRIDE_PURE(
|
||||
std::unique_ptr<gridfire::engine::scratch::StateBlob>,
|
||||
gridfire::engine::DynamicEngine,
|
||||
constructStateBlob,
|
||||
blob
|
||||
);
|
||||
}
|
||||
|
||||
const gridfire::engine::Engine& PyEngineView::getBaseEngine() const {
|
||||
PYBIND11_OVERRIDE_PURE(
|
||||
const gridfire::engine::Engine&,
|
||||
|
||||
@@ -130,6 +130,10 @@ public:
|
||||
gridfire::engine::scratch::StateBlob &ctx
|
||||
) const override;
|
||||
|
||||
std::unique_ptr<gridfire::engine::scratch::StateBlob> constructStateBlob(
|
||||
const gridfire::engine::scratch::StateBlob *blob
|
||||
) const override;
|
||||
|
||||
private:
|
||||
mutable std::vector<fourdst::atomic::Species> m_species_cache;
|
||||
};
|
||||
|
||||
@@ -51,6 +51,13 @@ void register_solver_bindings(const py::module &m) {
|
||||
},
|
||||
py::return_value_policy::reference_internal
|
||||
);
|
||||
py_cvode_timestep_context.def_property_readonly(
|
||||
"composition",
|
||||
[](const gridfire::solver::PointSolverTimestepContext& self) -> fourdst::composition::Composition {
|
||||
return self.getPhysicalComposition();
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
|
||||
auto py_solver_context_base = py::class_<gridfire::solver::SolverContextBase>(m, "SolverContextBase");
|
||||
@@ -166,6 +173,20 @@ void register_solver_bindings(const py::module &m) {
|
||||
"Initialize the PointSolver object."
|
||||
);
|
||||
|
||||
py_point_solver.def(
|
||||
py::init<gridfire::engine::DynamicEngine&, gridfire::config::GridFireConfig&>(),
|
||||
py::arg("engine"),
|
||||
py::arg("config"),
|
||||
"Initialize the PointSolver object with a configuration set."
|
||||
);
|
||||
|
||||
py_point_solver.def(
|
||||
"getConfig",
|
||||
&gridfire::solver::PointSolver::getConfig,
|
||||
"Get a copy of the config object"
|
||||
);
|
||||
|
||||
|
||||
py_point_solver.def(
|
||||
"evaluate",
|
||||
py::overload_cast<gridfire::solver::SolverContextBase&, const gridfire::NetIn&, bool, bool>(&gridfire::solver::PointSolver::evaluate, py::const_),
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,16 +0,0 @@
|
||||
"""
|
||||
Python bindings for the fourdst utility modules which are a part of the 4D-STAR project.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
from . import config
|
||||
from . import engine
|
||||
from . import exceptions
|
||||
from . import io
|
||||
from . import partition
|
||||
from . import policy
|
||||
from . import reaction
|
||||
from . import screening
|
||||
from . import solver
|
||||
from . import type
|
||||
from . import utils
|
||||
__all__: list[str] = ['config', 'engine', 'exceptions', 'io', 'partition', 'policy', 'reaction', 'screening', 'solver', 'type', 'utils']
|
||||
@@ -1,47 +0,0 @@
|
||||
"""
|
||||
GridFire configuration bindings
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import typing
|
||||
__all__: list[str] = ['AdaptiveEngineViewConfig', 'CVODESolverConfig', 'EngineConfig', 'EngineViewConfig', 'GridFireConfig', 'SolverConfig']
|
||||
class AdaptiveEngineViewConfig:
|
||||
def __init__(self) -> None:
|
||||
...
|
||||
@property
|
||||
def relativeCullingThreshold(self) -> float:
|
||||
...
|
||||
@relativeCullingThreshold.setter
|
||||
def relativeCullingThreshold(self, arg0: typing.SupportsFloat) -> None:
|
||||
...
|
||||
class CVODESolverConfig:
|
||||
def __init__(self) -> None:
|
||||
...
|
||||
@property
|
||||
def absTol(self) -> float:
|
||||
...
|
||||
@absTol.setter
|
||||
def absTol(self, arg0: typing.SupportsFloat) -> None:
|
||||
...
|
||||
@property
|
||||
def relTol(self) -> float:
|
||||
...
|
||||
@relTol.setter
|
||||
def relTol(self, arg0: typing.SupportsFloat) -> None:
|
||||
...
|
||||
class EngineConfig:
|
||||
views: EngineViewConfig
|
||||
def __init__(self) -> None:
|
||||
...
|
||||
class EngineViewConfig:
|
||||
adaptiveEngineView: AdaptiveEngineViewConfig
|
||||
def __init__(self) -> None:
|
||||
...
|
||||
class GridFireConfig:
|
||||
engine: EngineConfig
|
||||
solver: SolverConfig
|
||||
def __init__(self) -> None:
|
||||
...
|
||||
class SolverConfig:
|
||||
cvode: CVODESolverConfig
|
||||
def __init__(self) -> None:
|
||||
...
|
||||
@@ -1,972 +0,0 @@
|
||||
"""
|
||||
Engine and Engine View bindings
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import collections.abc
|
||||
import fourdst._phys.atomic
|
||||
import fourdst._phys.composition
|
||||
import gridfire._gridfire.io
|
||||
import gridfire._gridfire.partition
|
||||
import gridfire._gridfire.reaction
|
||||
import gridfire._gridfire.screening
|
||||
import gridfire._gridfire.type
|
||||
import numpy
|
||||
import numpy.typing
|
||||
import typing
|
||||
from . import diagnostics
|
||||
from . import scratchpads
|
||||
__all__: list[str] = ['ACTIVE', 'ADAPTIVE_ENGINE_VIEW', 'AdaptiveEngineView', 'BuildDepthType', 'DEFAULT', 'DEFINED_ENGINE_VIEW', 'DefinedEngineView', 'DynamicEngine', 'EQUILIBRIUM', 'Engine', 'EngineTypes', 'FILE_DEFINED_ENGINE_VIEW', 'FULL_SUCCESS', 'FifthOrder', 'FileDefinedEngineView', 'FourthOrder', 'Full', 'GRAPH_ENGINE', 'GraphEngine', 'INACTIVE_FLOW', 'MAX_ITERATIONS_REACHED', 'MULTISCALE_PARTITIONING_ENGINE_VIEW', 'MultiscalePartitioningEngineView', 'NONE', 'NOT_PRESENT', 'NO_SPECIES_TO_PRIME', 'NetworkBuildDepth', 'NetworkConstructionFlags', 'NetworkJacobian', 'NetworkPrimingEngineView', 'PRIMING_ENGINE_VIEW', 'PrimingReport', 'PrimingReportStatus', 'REACLIB', 'REACLIB_STRONG', 'REACLIB_WEAK', 'SecondOrder', 'Shallow', 'SparsityPattern', 'SpeciesStatus', 'StepDerivatives', 'ThirdOrder', 'WRL_BETA_MINUS', 'WRL_BETA_PLUS', 'WRL_ELECTRON_CAPTURE', 'WRL_POSITRON_CAPTURE', 'WRL_WEAK', 'build_nuclear_network', 'diagnostics', 'primeNetwork', 'regularize_jacobian', 'scratchpads']
|
||||
class AdaptiveEngineView(DynamicEngine):
|
||||
def __init__(self, baseEngine: DynamicEngine) -> None:
|
||||
"""
|
||||
Construct an adaptive engine view with a base engine.
|
||||
"""
|
||||
def calculateEpsDerivatives(self, ctx: scratchpads.StateBlob, comp: ..., T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> ...:
|
||||
"""
|
||||
Calculate deps/dT and deps/drho
|
||||
"""
|
||||
def calculateMolarReactionFlow(self: DynamicEngine, ctx: scratchpads.StateBlob, reaction: ..., comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> float:
|
||||
"""
|
||||
Calculate the molar reaction flow for a given reaction.
|
||||
"""
|
||||
def calculateRHSAndEnergy(self: DynamicEngine, ctx: scratchpads.StateBlob, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> StepDerivatives:
|
||||
"""
|
||||
Calculate the right-hand side (dY/dt) and energy generation rate.
|
||||
"""
|
||||
def collectComposition(self, ctx: scratchpads.StateBlob, composition: ..., T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> fourdst._phys.composition.Composition:
|
||||
"""
|
||||
Recursively collect composition from current engine and any sub engines if they exist.
|
||||
"""
|
||||
@typing.overload
|
||||
def generateJacobianMatrix(self: DynamicEngine, ctx: scratchpads.StateBlob, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> NetworkJacobian:
|
||||
"""
|
||||
Generate the Jacobian matrix for the current state.
|
||||
"""
|
||||
@typing.overload
|
||||
def generateJacobianMatrix(self: DynamicEngine, ctx: scratchpads.StateBlob, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat, activeSpecies: collections.abc.Sequence[fourdst._phys.atomic.Species]) -> NetworkJacobian:
|
||||
"""
|
||||
Generate the jacobian matrix only for the subset of the matrix representing the active species.
|
||||
"""
|
||||
@typing.overload
|
||||
def generateJacobianMatrix(self: DynamicEngine, ctx: scratchpads.StateBlob, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat, sparsityPattern: collections.abc.Sequence[tuple[typing.SupportsInt, typing.SupportsInt]]) -> NetworkJacobian:
|
||||
"""
|
||||
Generate the jacobian matrix for the given sparsity pattern
|
||||
"""
|
||||
def getBaseEngine(self) -> DynamicEngine:
|
||||
"""
|
||||
Get the base engine associated with this adaptive engine view.
|
||||
"""
|
||||
def getNetworkReactions(self, arg0: scratchpads.StateBlob) -> gridfire._gridfire.reaction.ReactionSet:
|
||||
"""
|
||||
Get the set of logical reactions in the network.
|
||||
"""
|
||||
def getNetworkSpecies(self, arg0: scratchpads.StateBlob) -> list[fourdst._phys.atomic.Species]:
|
||||
"""
|
||||
Get the list of species in the network.
|
||||
"""
|
||||
def getScreeningModel(self, arg0: scratchpads.StateBlob) -> gridfire._gridfire.screening.ScreeningType:
|
||||
"""
|
||||
Get the current screening model of the engine.
|
||||
"""
|
||||
def getSpeciesDestructionTimescales(self: DynamicEngine, ctx: scratchpads.StateBlob, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> dict[fourdst._phys.atomic.Species, float]:
|
||||
"""
|
||||
Get the destruction timescales for each species in the network.
|
||||
"""
|
||||
def getSpeciesIndex(self, ctx: scratchpads.StateBlob, species: fourdst._phys.atomic.Species) -> int:
|
||||
"""
|
||||
Get the index of a species in the network.
|
||||
"""
|
||||
def getSpeciesStatus(self, ctx: scratchpads.StateBlob, species: fourdst._phys.atomic.Species) -> SpeciesStatus:
|
||||
"""
|
||||
Get the status of a species in the network.
|
||||
"""
|
||||
def getSpeciesTimescales(self: DynamicEngine, ctx: scratchpads.StateBlob, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> dict[fourdst._phys.atomic.Species, float]:
|
||||
"""
|
||||
Get the timescales for each species in the network.
|
||||
"""
|
||||
def primeEngine(self, ctx: scratchpads.StateBlob, netIn: gridfire._gridfire.type.NetIn) -> PrimingReport:
|
||||
"""
|
||||
Prime the engine with a NetIn object to prepare for calculations.
|
||||
"""
|
||||
def project(self, ctx: scratchpads.StateBlob, netIn: gridfire._gridfire.type.NetIn) -> fourdst._phys.composition.Composition:
|
||||
"""
|
||||
Update the engine state based on the provided NetIn object.
|
||||
"""
|
||||
class BuildDepthType:
|
||||
pass
|
||||
class DefinedEngineView(DynamicEngine):
|
||||
def __init__(self, peNames: collections.abc.Sequence[str], baseEngine: GraphEngine) -> None:
|
||||
"""
|
||||
Construct a defined engine view with a list of tracked reactions and a base engine.
|
||||
"""
|
||||
def calculateEpsDerivatives(self, ctx: scratchpads.StateBlob, comp: ..., T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> ...:
|
||||
"""
|
||||
Calculate deps/dT and deps/drho
|
||||
"""
|
||||
def calculateMolarReactionFlow(self: DynamicEngine, ctx: scratchpads.StateBlob, reaction: ..., comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> float:
|
||||
"""
|
||||
Calculate the molar reaction flow for a given reaction.
|
||||
"""
|
||||
def calculateRHSAndEnergy(self: DynamicEngine, ctx: scratchpads.StateBlob, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> StepDerivatives:
|
||||
"""
|
||||
Calculate the right-hand side (dY/dt) and energy generation rate.
|
||||
"""
|
||||
def collectComposition(self, ctx: scratchpads.StateBlob, composition: ..., T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> fourdst._phys.composition.Composition:
|
||||
"""
|
||||
Recursively collect composition from current engine and any sub engines if they exist.
|
||||
"""
|
||||
@typing.overload
|
||||
def generateJacobianMatrix(self: DynamicEngine, ctx: scratchpads.StateBlob, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> NetworkJacobian:
|
||||
"""
|
||||
Generate the Jacobian matrix for the current state.
|
||||
"""
|
||||
@typing.overload
|
||||
def generateJacobianMatrix(self: DynamicEngine, ctx: scratchpads.StateBlob, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat, activeSpecies: collections.abc.Sequence[fourdst._phys.atomic.Species]) -> NetworkJacobian:
|
||||
"""
|
||||
Generate the jacobian matrix only for the subset of the matrix representing the active species.
|
||||
"""
|
||||
@typing.overload
|
||||
def generateJacobianMatrix(self: DynamicEngine, ctx: scratchpads.StateBlob, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat, sparsityPattern: collections.abc.Sequence[tuple[typing.SupportsInt, typing.SupportsInt]]) -> NetworkJacobian:
|
||||
"""
|
||||
Generate the jacobian matrix for the given sparsity pattern
|
||||
"""
|
||||
def getBaseEngine(self) -> DynamicEngine:
|
||||
"""
|
||||
Get the base engine associated with this defined engine view.
|
||||
"""
|
||||
def getNetworkReactions(self, arg0: scratchpads.StateBlob) -> gridfire._gridfire.reaction.ReactionSet:
|
||||
"""
|
||||
Get the set of logical reactions in the network.
|
||||
"""
|
||||
def getNetworkSpecies(self, arg0: scratchpads.StateBlob) -> list[fourdst._phys.atomic.Species]:
|
||||
"""
|
||||
Get the list of species in the network.
|
||||
"""
|
||||
def getScreeningModel(self, arg0: scratchpads.StateBlob) -> gridfire._gridfire.screening.ScreeningType:
|
||||
"""
|
||||
Get the current screening model of the engine.
|
||||
"""
|
||||
def getSpeciesDestructionTimescales(self: DynamicEngine, ctx: scratchpads.StateBlob, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> dict[fourdst._phys.atomic.Species, float]:
|
||||
"""
|
||||
Get the destruction timescales for each species in the network.
|
||||
"""
|
||||
def getSpeciesIndex(self, ctx: scratchpads.StateBlob, species: fourdst._phys.atomic.Species) -> int:
|
||||
"""
|
||||
Get the index of a species in the network.
|
||||
"""
|
||||
def getSpeciesStatus(self, ctx: scratchpads.StateBlob, species: fourdst._phys.atomic.Species) -> SpeciesStatus:
|
||||
"""
|
||||
Get the status of a species in the network.
|
||||
"""
|
||||
def getSpeciesTimescales(self: DynamicEngine, ctx: scratchpads.StateBlob, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> dict[fourdst._phys.atomic.Species, float]:
|
||||
"""
|
||||
Get the timescales for each species in the network.
|
||||
"""
|
||||
def primeEngine(self, ctx: scratchpads.StateBlob, netIn: gridfire._gridfire.type.NetIn) -> PrimingReport:
|
||||
"""
|
||||
Prime the engine with a NetIn object to prepare for calculations.
|
||||
"""
|
||||
def project(self, ctx: scratchpads.StateBlob, netIn: gridfire._gridfire.type.NetIn) -> fourdst._phys.composition.Composition:
|
||||
"""
|
||||
Update the engine state based on the provided NetIn object.
|
||||
"""
|
||||
class DynamicEngine:
|
||||
pass
|
||||
class Engine:
|
||||
pass
|
||||
class EngineTypes:
|
||||
"""
|
||||
Members:
|
||||
|
||||
GRAPH_ENGINE : The standard graph-based engine.
|
||||
|
||||
ADAPTIVE_ENGINE_VIEW : An engine that adapts based on certain criteria.
|
||||
|
||||
MULTISCALE_PARTITIONING_ENGINE_VIEW : An engine that partitions the system at multiple scales.
|
||||
|
||||
PRIMING_ENGINE_VIEW : An engine that uses a priming strategy for simulations.
|
||||
|
||||
DEFINED_ENGINE_VIEW : An engine defined by user specifications.
|
||||
|
||||
FILE_DEFINED_ENGINE_VIEW : An engine defined through external files.
|
||||
"""
|
||||
ADAPTIVE_ENGINE_VIEW: typing.ClassVar[EngineTypes] # value = <EngineTypes.ADAPTIVE_ENGINE_VIEW: 1>
|
||||
DEFINED_ENGINE_VIEW: typing.ClassVar[EngineTypes] # value = <EngineTypes.DEFINED_ENGINE_VIEW: 4>
|
||||
FILE_DEFINED_ENGINE_VIEW: typing.ClassVar[EngineTypes] # value = <EngineTypes.FILE_DEFINED_ENGINE_VIEW: 5>
|
||||
GRAPH_ENGINE: typing.ClassVar[EngineTypes] # value = <EngineTypes.GRAPH_ENGINE: 0>
|
||||
MULTISCALE_PARTITIONING_ENGINE_VIEW: typing.ClassVar[EngineTypes] # value = <EngineTypes.MULTISCALE_PARTITIONING_ENGINE_VIEW: 2>
|
||||
PRIMING_ENGINE_VIEW: typing.ClassVar[EngineTypes] # value = <EngineTypes.PRIMING_ENGINE_VIEW: 3>
|
||||
__members__: typing.ClassVar[dict[str, EngineTypes]] # value = {'GRAPH_ENGINE': <EngineTypes.GRAPH_ENGINE: 0>, 'ADAPTIVE_ENGINE_VIEW': <EngineTypes.ADAPTIVE_ENGINE_VIEW: 1>, 'MULTISCALE_PARTITIONING_ENGINE_VIEW': <EngineTypes.MULTISCALE_PARTITIONING_ENGINE_VIEW: 2>, 'PRIMING_ENGINE_VIEW': <EngineTypes.PRIMING_ENGINE_VIEW: 3>, 'DEFINED_ENGINE_VIEW': <EngineTypes.DEFINED_ENGINE_VIEW: 4>, 'FILE_DEFINED_ENGINE_VIEW': <EngineTypes.FILE_DEFINED_ENGINE_VIEW: 5>}
|
||||
def __eq__(self, other: typing.Any) -> bool:
|
||||
...
|
||||
def __getstate__(self) -> int:
|
||||
...
|
||||
def __hash__(self) -> int:
|
||||
...
|
||||
def __index__(self) -> int:
|
||||
...
|
||||
def __init__(self, value: typing.SupportsInt) -> None:
|
||||
...
|
||||
def __int__(self) -> int:
|
||||
...
|
||||
def __ne__(self, other: typing.Any) -> bool:
|
||||
...
|
||||
@typing.overload
|
||||
def __repr__(self) -> str:
|
||||
...
|
||||
@typing.overload
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
String representation of the EngineTypes.
|
||||
"""
|
||||
def __setstate__(self, state: typing.SupportsInt) -> None:
|
||||
...
|
||||
def __str__(self) -> str:
|
||||
...
|
||||
@property
|
||||
def name(self) -> str:
|
||||
...
|
||||
@property
|
||||
def value(self) -> int:
|
||||
...
|
||||
class FileDefinedEngineView(DefinedEngineView):
|
||||
def __init__(self, baseEngine: GraphEngine, fileName: str, parser: gridfire._gridfire.io.NetworkFileParser) -> None:
|
||||
"""
|
||||
Construct a defined engine view from a file and a base engine.
|
||||
"""
|
||||
def calculateEpsDerivatives(self, ctx: scratchpads.StateBlob, comp: ..., T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> ...:
|
||||
"""
|
||||
Calculate deps/dT and deps/drho
|
||||
"""
|
||||
def calculateMolarReactionFlow(self: DynamicEngine, ctx: scratchpads.StateBlob, reaction: ..., comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> float:
|
||||
"""
|
||||
Calculate the molar reaction flow for a given reaction.
|
||||
"""
|
||||
def calculateRHSAndEnergy(self: DynamicEngine, ctx: scratchpads.StateBlob, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> StepDerivatives:
|
||||
"""
|
||||
Calculate the right-hand side (dY/dt) and energy generation rate.
|
||||
"""
|
||||
def collectComposition(self, ctx: scratchpads.StateBlob, composition: ..., T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> fourdst._phys.composition.Composition:
|
||||
"""
|
||||
Recursively collect composition from current engine and any sub engines if they exist.
|
||||
"""
|
||||
@typing.overload
|
||||
def generateJacobianMatrix(self: DynamicEngine, ctx: scratchpads.StateBlob, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> NetworkJacobian:
|
||||
"""
|
||||
Generate the Jacobian matrix for the current state.
|
||||
"""
|
||||
@typing.overload
|
||||
def generateJacobianMatrix(self: DynamicEngine, ctx: scratchpads.StateBlob, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat, activeSpecies: collections.abc.Sequence[fourdst._phys.atomic.Species]) -> NetworkJacobian:
|
||||
"""
|
||||
Generate the jacobian matrix only for the subset of the matrix representing the active species.
|
||||
"""
|
||||
@typing.overload
|
||||
def generateJacobianMatrix(self: DynamicEngine, ctx: scratchpads.StateBlob, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat, sparsityPattern: collections.abc.Sequence[tuple[typing.SupportsInt, typing.SupportsInt]]) -> NetworkJacobian:
|
||||
"""
|
||||
Generate the jacobian matrix for the given sparsity pattern
|
||||
"""
|
||||
def getBaseEngine(self) -> DynamicEngine:
|
||||
"""
|
||||
Get the base engine associated with this file defined engine view.
|
||||
"""
|
||||
def getNetworkFile(self) -> str:
|
||||
"""
|
||||
Get the network file associated with this defined engine view.
|
||||
"""
|
||||
def getNetworkReactions(self, arg0: scratchpads.StateBlob) -> gridfire._gridfire.reaction.ReactionSet:
|
||||
"""
|
||||
Get the set of logical reactions in the network.
|
||||
"""
|
||||
def getNetworkSpecies(self, arg0: scratchpads.StateBlob) -> list[fourdst._phys.atomic.Species]:
|
||||
"""
|
||||
Get the list of species in the network.
|
||||
"""
|
||||
def getParser(self) -> gridfire._gridfire.io.NetworkFileParser:
|
||||
"""
|
||||
Get the parser used for this defined engine view.
|
||||
"""
|
||||
def getScreeningModel(self, arg0: scratchpads.StateBlob) -> gridfire._gridfire.screening.ScreeningType:
|
||||
"""
|
||||
Get the current screening model of the engine.
|
||||
"""
|
||||
def getSpeciesDestructionTimescales(self: DynamicEngine, ctx: scratchpads.StateBlob, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> dict[fourdst._phys.atomic.Species, float]:
|
||||
"""
|
||||
Get the destruction timescales for each species in the network.
|
||||
"""
|
||||
def getSpeciesIndex(self, ctx: scratchpads.StateBlob, species: fourdst._phys.atomic.Species) -> int:
|
||||
"""
|
||||
Get the index of a species in the network.
|
||||
"""
|
||||
def getSpeciesStatus(self, ctx: scratchpads.StateBlob, species: fourdst._phys.atomic.Species) -> SpeciesStatus:
|
||||
"""
|
||||
Get the status of a species in the network.
|
||||
"""
|
||||
def getSpeciesTimescales(self: DynamicEngine, ctx: scratchpads.StateBlob, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> dict[fourdst._phys.atomic.Species, float]:
|
||||
"""
|
||||
Get the timescales for each species in the network.
|
||||
"""
|
||||
def primeEngine(self, ctx: scratchpads.StateBlob, netIn: gridfire._gridfire.type.NetIn) -> PrimingReport:
|
||||
"""
|
||||
Prime the engine with a NetIn object to prepare for calculations.
|
||||
"""
|
||||
def project(self, ctx: scratchpads.StateBlob, netIn: gridfire._gridfire.type.NetIn) -> fourdst._phys.composition.Composition:
|
||||
"""
|
||||
Update the engine state based on the provided NetIn object.
|
||||
"""
|
||||
class GraphEngine(DynamicEngine):
|
||||
@typing.overload
|
||||
def __init__(self, composition: fourdst._phys.composition.Composition, depth: gridfire._gridfire.engine.NetworkBuildDepth | typing.SupportsInt = ...) -> None:
|
||||
"""
|
||||
Initialize GraphEngine with a composition and build depth.
|
||||
"""
|
||||
@typing.overload
|
||||
def __init__(self, composition: fourdst._phys.composition.Composition, partitionFunction: gridfire._gridfire.partition.PartitionFunction, depth: gridfire._gridfire.engine.NetworkBuildDepth | typing.SupportsInt = ...) -> None:
|
||||
"""
|
||||
Initialize GraphEngine with a composition, partition function and build depth.
|
||||
"""
|
||||
@typing.overload
|
||||
def __init__(self, reactions: gridfire._gridfire.reaction.ReactionSet) -> None:
|
||||
"""
|
||||
Initialize GraphEngine with a set of reactions.
|
||||
"""
|
||||
def calculateEpsDerivatives(self, ctx: scratchpads.StateBlob, comp: ..., T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> ...:
|
||||
"""
|
||||
Calculate deps/dT and deps/drho
|
||||
"""
|
||||
def calculateMolarReactionFlow(self: DynamicEngine, ctx: scratchpads.StateBlob, reaction: ..., comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> float:
|
||||
"""
|
||||
Calculate the molar reaction flow for a given reaction.
|
||||
"""
|
||||
def calculateRHSAndEnergy(self: DynamicEngine, ctx: scratchpads.StateBlob, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> StepDerivatives:
|
||||
"""
|
||||
Calculate the right-hand side (dY/dt) and energy generation rate.
|
||||
"""
|
||||
def calculateReverseRate(self, reaction: ..., T9: typing.SupportsFloat, rho: typing.SupportsFloat, composition: ...) -> float:
|
||||
"""
|
||||
Calculate the reverse rate for a given reaction at a specific temperature, density, and composition.
|
||||
"""
|
||||
def calculateReverseRateTwoBody(self, reaction: ..., T9: typing.SupportsFloat, forwardRate: typing.SupportsFloat, expFactor: typing.SupportsFloat) -> float:
|
||||
"""
|
||||
Calculate the reverse rate for a two-body reaction at a specific temperature.
|
||||
"""
|
||||
def calculateReverseRateTwoBodyDerivative(self, reaction: ..., T9: typing.SupportsFloat, rho: typing.SupportsFloat, composition: fourdst._phys.composition.Composition, reverseRate: typing.SupportsFloat) -> float:
|
||||
"""
|
||||
Calculate the derivative of the reverse rate for a two-body reaction at a specific temperature.
|
||||
"""
|
||||
def collectComposition(self, ctx: scratchpads.StateBlob, composition: ..., T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> fourdst._phys.composition.Composition:
|
||||
"""
|
||||
Recursively collect composition from current engine and any sub engines if they exist.
|
||||
"""
|
||||
def exportToCSV(self, ctx: scratchpads.StateBlob, filename: str) -> None:
|
||||
"""
|
||||
Export the network to a CSV file for analysis.
|
||||
"""
|
||||
def exportToDot(self, ctx: scratchpads.StateBlob, filename: str) -> None:
|
||||
"""
|
||||
Export the network to a DOT file for visualization.
|
||||
"""
|
||||
@typing.overload
|
||||
def generateJacobianMatrix(self: DynamicEngine, ctx: scratchpads.StateBlob, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> NetworkJacobian:
|
||||
"""
|
||||
Generate the Jacobian matrix for the current state.
|
||||
"""
|
||||
@typing.overload
|
||||
def generateJacobianMatrix(self: DynamicEngine, ctx: scratchpads.StateBlob, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat, activeSpecies: collections.abc.Sequence[fourdst._phys.atomic.Species]) -> NetworkJacobian:
|
||||
"""
|
||||
Generate the jacobian matrix only for the subset of the matrix representing the active species.
|
||||
"""
|
||||
@typing.overload
|
||||
def generateJacobianMatrix(self: DynamicEngine, ctx: scratchpads.StateBlob, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat, sparsityPattern: collections.abc.Sequence[tuple[typing.SupportsInt, typing.SupportsInt]]) -> NetworkJacobian:
|
||||
"""
|
||||
Generate the jacobian matrix for the given sparsity pattern
|
||||
"""
|
||||
def getNetworkReactions(self, arg0: scratchpads.StateBlob) -> gridfire._gridfire.reaction.ReactionSet:
|
||||
"""
|
||||
Get the set of logical reactions in the network.
|
||||
"""
|
||||
def getNetworkSpecies(self, arg0: scratchpads.StateBlob) -> list[fourdst._phys.atomic.Species]:
|
||||
"""
|
||||
Get the list of species in the network.
|
||||
"""
|
||||
def getPartitionFunction(self, arg0: scratchpads.StateBlob) -> gridfire._gridfire.partition.PartitionFunction:
|
||||
"""
|
||||
Get the partition function used by the engine.
|
||||
"""
|
||||
def getScreeningModel(self, arg0: scratchpads.StateBlob) -> gridfire._gridfire.screening.ScreeningType:
|
||||
"""
|
||||
Get the current screening model of the engine.
|
||||
"""
|
||||
@typing.overload
|
||||
def getSpeciesDestructionTimescales(self, ctx: scratchpads.StateBlob, composition: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat, activeReactions: gridfire._gridfire.reaction.ReactionSet) -> ...:
|
||||
...
|
||||
@typing.overload
|
||||
def getSpeciesDestructionTimescales(self: DynamicEngine, ctx: scratchpads.StateBlob, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> dict[fourdst._phys.atomic.Species, float]:
|
||||
"""
|
||||
Get the destruction timescales for each species in the network.
|
||||
"""
|
||||
def getSpeciesIndex(self, ctx: scratchpads.StateBlob, species: fourdst._phys.atomic.Species) -> int:
|
||||
"""
|
||||
Get the index of a species in the network.
|
||||
"""
|
||||
def getSpeciesStatus(self, ctx: scratchpads.StateBlob, species: fourdst._phys.atomic.Species) -> SpeciesStatus:
|
||||
"""
|
||||
Get the status of a species in the network.
|
||||
"""
|
||||
@typing.overload
|
||||
def getSpeciesTimescales(self, ctx: scratchpads.StateBlob, composition: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat, activeReactions: gridfire._gridfire.reaction.ReactionSet) -> ...:
|
||||
...
|
||||
@typing.overload
|
||||
def getSpeciesTimescales(self: DynamicEngine, ctx: scratchpads.StateBlob, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> dict[fourdst._phys.atomic.Species, float]:
|
||||
"""
|
||||
Get the timescales for each species in the network.
|
||||
"""
|
||||
def involvesSpecies(self, ctx: scratchpads.StateBlob, species: fourdst._phys.atomic.Species) -> bool:
|
||||
"""
|
||||
Check if a given species is involved in the network.
|
||||
"""
|
||||
def isPrecomputationEnabled(self, arg0: scratchpads.StateBlob) -> bool:
|
||||
"""
|
||||
Check if precomputation is enabled for the engine.
|
||||
"""
|
||||
def isUsingReverseReactions(self, arg0: scratchpads.StateBlob) -> bool:
|
||||
"""
|
||||
Check if the engine is using reverse reactions.
|
||||
"""
|
||||
def primeEngine(self, ctx: scratchpads.StateBlob, netIn: gridfire._gridfire.type.NetIn) -> PrimingReport:
|
||||
"""
|
||||
Prime the engine with a NetIn object to prepare for calculations.
|
||||
"""
|
||||
def project(self, ctx: scratchpads.StateBlob, netIn: gridfire._gridfire.type.NetIn) -> fourdst._phys.composition.Composition:
|
||||
"""
|
||||
Update the engine state based on the provided NetIn object.
|
||||
"""
|
||||
class MultiscalePartitioningEngineView(DynamicEngine):
|
||||
def __init__(self, baseEngine: GraphEngine) -> None:
|
||||
"""
|
||||
Construct a multiscale partitioning engine view with a base engine.
|
||||
"""
|
||||
def calculateEpsDerivatives(self, ctx: scratchpads.StateBlob, comp: ..., T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> ...:
|
||||
"""
|
||||
Calculate deps/dT and deps/drho
|
||||
"""
|
||||
def calculateMolarReactionFlow(self: DynamicEngine, ctx: scratchpads.StateBlob, reaction: ..., comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> float:
|
||||
"""
|
||||
Calculate the molar reaction flow for a given reaction.
|
||||
"""
|
||||
def calculateRHSAndEnergy(self: DynamicEngine, ctx: scratchpads.StateBlob, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> StepDerivatives:
|
||||
"""
|
||||
Calculate the right-hand side (dY/dt) and energy generation rate.
|
||||
"""
|
||||
def collectComposition(self, ctx: scratchpads.StateBlob, composition: ..., T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> fourdst._phys.composition.Composition:
|
||||
"""
|
||||
Recursively collect composition from current engine and any sub engines if they exist.
|
||||
"""
|
||||
def exportToDot(self, ctx: scratchpads.StateBlob, filename: str, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> None:
|
||||
"""
|
||||
Export the network to a DOT file for visualization.
|
||||
"""
|
||||
@typing.overload
|
||||
def generateJacobianMatrix(self: DynamicEngine, ctx: scratchpads.StateBlob, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> NetworkJacobian:
|
||||
"""
|
||||
Generate the Jacobian matrix for the current state.
|
||||
"""
|
||||
@typing.overload
|
||||
def generateJacobianMatrix(self: DynamicEngine, ctx: scratchpads.StateBlob, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat, activeSpecies: collections.abc.Sequence[fourdst._phys.atomic.Species]) -> NetworkJacobian:
|
||||
"""
|
||||
Generate the jacobian matrix only for the subset of the matrix representing the active species.
|
||||
"""
|
||||
@typing.overload
|
||||
def generateJacobianMatrix(self: DynamicEngine, ctx: scratchpads.StateBlob, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat, sparsityPattern: collections.abc.Sequence[tuple[typing.SupportsInt, typing.SupportsInt]]) -> NetworkJacobian:
|
||||
"""
|
||||
Generate the jacobian matrix for the given sparsity pattern
|
||||
"""
|
||||
def getBaseEngine(self) -> DynamicEngine:
|
||||
"""
|
||||
Get the base engine associated with this multiscale partitioning engine view.
|
||||
"""
|
||||
def getDynamicSpecies(self: scratchpads.StateBlob) -> list[fourdst._phys.atomic.Species]:
|
||||
"""
|
||||
Get the list of dynamic species in the network.
|
||||
"""
|
||||
def getFastSpecies(self, arg0: scratchpads.StateBlob) -> list[fourdst._phys.atomic.Species]:
|
||||
"""
|
||||
Get the list of fast species in the network.
|
||||
"""
|
||||
def getNetworkReactions(self, arg0: scratchpads.StateBlob) -> gridfire._gridfire.reaction.ReactionSet:
|
||||
"""
|
||||
Get the set of logical reactions in the network.
|
||||
"""
|
||||
def getNetworkSpecies(self, arg0: scratchpads.StateBlob) -> list[fourdst._phys.atomic.Species]:
|
||||
"""
|
||||
Get the list of species in the network.
|
||||
"""
|
||||
def getNormalizedEquilibratedComposition(self, ctx: scratchpads.StateBlob, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> fourdst._phys.composition.Composition:
|
||||
"""
|
||||
Get the normalized equilibrated composition for the algebraic species.
|
||||
"""
|
||||
def getScreeningModel(self, arg0: scratchpads.StateBlob) -> gridfire._gridfire.screening.ScreeningType:
|
||||
"""
|
||||
Get the current screening model of the engine.
|
||||
"""
|
||||
def getSpeciesDestructionTimescales(self: DynamicEngine, ctx: scratchpads.StateBlob, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> dict[fourdst._phys.atomic.Species, float]:
|
||||
"""
|
||||
Get the destruction timescales for each species in the network.
|
||||
"""
|
||||
def getSpeciesIndex(self, ctx: scratchpads.StateBlob, species: fourdst._phys.atomic.Species) -> int:
|
||||
"""
|
||||
Get the index of a species in the network.
|
||||
"""
|
||||
def getSpeciesStatus(self, ctx: scratchpads.StateBlob, species: fourdst._phys.atomic.Species) -> SpeciesStatus:
|
||||
"""
|
||||
Get the status of a species in the network.
|
||||
"""
|
||||
def getSpeciesTimescales(self: DynamicEngine, ctx: scratchpads.StateBlob, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> dict[fourdst._phys.atomic.Species, float]:
|
||||
"""
|
||||
Get the timescales for each species in the network.
|
||||
"""
|
||||
def involvesSpecies(self: scratchpads.StateBlob, species: fourdst._phys.atomic.Species) -> bool:
|
||||
"""
|
||||
Check if a given species is involved in the network (in either the algebraic or dynamic set).
|
||||
"""
|
||||
def involvesSpeciesInDynamic(self: scratchpads.StateBlob, species: fourdst._phys.atomic.Species) -> bool:
|
||||
"""
|
||||
Check if a given species is involved in the network's dynamic set.
|
||||
"""
|
||||
def involvesSpeciesInQSE(self: scratchpads.StateBlob, species: fourdst._phys.atomic.Species) -> bool:
|
||||
"""
|
||||
Check if a given species is involved in the network's algebraic set.
|
||||
"""
|
||||
def partitionNetwork(self, ctx: scratchpads.StateBlob, netIn: gridfire._gridfire.type.NetIn) -> fourdst._phys.composition.Composition:
|
||||
"""
|
||||
Partition the network based on species timescales and connectivity.
|
||||
"""
|
||||
def primeEngine(self, ctx: scratchpads.StateBlob, netIn: gridfire._gridfire.type.NetIn) -> PrimingReport:
|
||||
"""
|
||||
Prime the engine with a NetIn object to prepare for calculations.
|
||||
"""
|
||||
def project(self, ctx: scratchpads.StateBlob, netIn: gridfire._gridfire.type.NetIn) -> fourdst._phys.composition.Composition:
|
||||
"""
|
||||
Update the engine state based on the provided NetIn object.
|
||||
"""
|
||||
class NetworkBuildDepth:
|
||||
"""
|
||||
Members:
|
||||
|
||||
Full : Full network build depth
|
||||
|
||||
Shallow : Shallow network build depth
|
||||
|
||||
SecondOrder : Second order network build depth
|
||||
|
||||
ThirdOrder : Third order network build depth
|
||||
|
||||
FourthOrder : Fourth order network build depth
|
||||
|
||||
FifthOrder : Fifth order network build depth
|
||||
"""
|
||||
FifthOrder: typing.ClassVar[NetworkBuildDepth] # value = <NetworkBuildDepth.FifthOrder: 5>
|
||||
FourthOrder: typing.ClassVar[NetworkBuildDepth] # value = <NetworkBuildDepth.FourthOrder: 4>
|
||||
Full: typing.ClassVar[NetworkBuildDepth] # value = <NetworkBuildDepth.Full: -1>
|
||||
SecondOrder: typing.ClassVar[NetworkBuildDepth] # value = <NetworkBuildDepth.SecondOrder: 2>
|
||||
Shallow: typing.ClassVar[NetworkBuildDepth] # value = <NetworkBuildDepth.Shallow: 1>
|
||||
ThirdOrder: typing.ClassVar[NetworkBuildDepth] # value = <NetworkBuildDepth.ThirdOrder: 3>
|
||||
__members__: typing.ClassVar[dict[str, NetworkBuildDepth]] # value = {'Full': <NetworkBuildDepth.Full: -1>, 'Shallow': <NetworkBuildDepth.Shallow: 1>, 'SecondOrder': <NetworkBuildDepth.SecondOrder: 2>, 'ThirdOrder': <NetworkBuildDepth.ThirdOrder: 3>, 'FourthOrder': <NetworkBuildDepth.FourthOrder: 4>, 'FifthOrder': <NetworkBuildDepth.FifthOrder: 5>}
|
||||
def __eq__(self, other: typing.Any) -> bool:
|
||||
...
|
||||
def __getstate__(self) -> int:
|
||||
...
|
||||
def __hash__(self) -> int:
|
||||
...
|
||||
def __index__(self) -> int:
|
||||
...
|
||||
def __init__(self, value: typing.SupportsInt) -> None:
|
||||
...
|
||||
def __int__(self) -> int:
|
||||
...
|
||||
def __ne__(self, other: typing.Any) -> bool:
|
||||
...
|
||||
def __repr__(self) -> str:
|
||||
...
|
||||
def __setstate__(self, state: typing.SupportsInt) -> None:
|
||||
...
|
||||
def __str__(self) -> str:
|
||||
...
|
||||
@property
|
||||
def name(self) -> str:
|
||||
...
|
||||
@property
|
||||
def value(self) -> int:
|
||||
...
|
||||
class NetworkConstructionFlags:
|
||||
"""
|
||||
Members:
|
||||
|
||||
NONE : No special construction flags.
|
||||
|
||||
REACLIB_STRONG : Include strong reactions from reaclib.
|
||||
|
||||
WRL_BETA_MINUS : Include beta-minus decay reactions from weak rate library.
|
||||
|
||||
WRL_BETA_PLUS : Include beta-plus decay reactions from weak rate library.
|
||||
|
||||
WRL_ELECTRON_CAPTURE : Include electron capture reactions from weak rate library.
|
||||
|
||||
WRL_POSITRON_CAPTURE : Include positron capture reactions from weak rate library.
|
||||
|
||||
REACLIB_WEAK : Include weak reactions from reaclib.
|
||||
|
||||
WRL_WEAK : Include all weak reactions from weak rate library.
|
||||
|
||||
REACLIB : Include all reactions from reaclib.
|
||||
|
||||
DEFAULT : Default construction flags (Reaclib strong and weak).
|
||||
"""
|
||||
DEFAULT: typing.ClassVar[NetworkConstructionFlags] # value = <NetworkConstructionFlags.REACLIB: 33>
|
||||
NONE: typing.ClassVar[NetworkConstructionFlags] # value = <NetworkConstructionFlags.NONE: 0>
|
||||
REACLIB: typing.ClassVar[NetworkConstructionFlags] # value = <NetworkConstructionFlags.REACLIB: 33>
|
||||
REACLIB_STRONG: typing.ClassVar[NetworkConstructionFlags] # value = <NetworkConstructionFlags.REACLIB_STRONG: 1>
|
||||
REACLIB_WEAK: typing.ClassVar[NetworkConstructionFlags] # value = <NetworkConstructionFlags.REACLIB_WEAK: 32>
|
||||
WRL_BETA_MINUS: typing.ClassVar[NetworkConstructionFlags] # value = <NetworkConstructionFlags.WRL_BETA_MINUS: 2>
|
||||
WRL_BETA_PLUS: typing.ClassVar[NetworkConstructionFlags] # value = <NetworkConstructionFlags.WRL_BETA_PLUS: 4>
|
||||
WRL_ELECTRON_CAPTURE: typing.ClassVar[NetworkConstructionFlags] # value = <NetworkConstructionFlags.WRL_ELECTRON_CAPTURE: 8>
|
||||
WRL_POSITRON_CAPTURE: typing.ClassVar[NetworkConstructionFlags] # value = <NetworkConstructionFlags.WRL_POSITRON_CAPTURE: 16>
|
||||
WRL_WEAK: typing.ClassVar[NetworkConstructionFlags] # value = <NetworkConstructionFlags.WRL_WEAK: 30>
|
||||
__members__: typing.ClassVar[dict[str, NetworkConstructionFlags]] # value = {'NONE': <NetworkConstructionFlags.NONE: 0>, 'REACLIB_STRONG': <NetworkConstructionFlags.REACLIB_STRONG: 1>, 'WRL_BETA_MINUS': <NetworkConstructionFlags.WRL_BETA_MINUS: 2>, 'WRL_BETA_PLUS': <NetworkConstructionFlags.WRL_BETA_PLUS: 4>, 'WRL_ELECTRON_CAPTURE': <NetworkConstructionFlags.WRL_ELECTRON_CAPTURE: 8>, 'WRL_POSITRON_CAPTURE': <NetworkConstructionFlags.WRL_POSITRON_CAPTURE: 16>, 'REACLIB_WEAK': <NetworkConstructionFlags.REACLIB_WEAK: 32>, 'WRL_WEAK': <NetworkConstructionFlags.WRL_WEAK: 30>, 'REACLIB': <NetworkConstructionFlags.REACLIB: 33>, 'DEFAULT': <NetworkConstructionFlags.REACLIB: 33>}
|
||||
def __eq__(self, other: typing.Any) -> bool:
|
||||
...
|
||||
def __getstate__(self) -> int:
|
||||
...
|
||||
def __hash__(self) -> int:
|
||||
...
|
||||
def __index__(self) -> int:
|
||||
...
|
||||
def __init__(self, value: typing.SupportsInt) -> None:
|
||||
...
|
||||
def __int__(self) -> int:
|
||||
...
|
||||
def __ne__(self, other: typing.Any) -> bool:
|
||||
...
|
||||
@typing.overload
|
||||
def __repr__(self) -> str:
|
||||
...
|
||||
@typing.overload
|
||||
def __repr__(self) -> str:
|
||||
...
|
||||
def __setstate__(self, state: typing.SupportsInt) -> None:
|
||||
...
|
||||
def __str__(self) -> str:
|
||||
...
|
||||
@property
|
||||
def name(self) -> str:
|
||||
...
|
||||
@property
|
||||
def value(self) -> int:
|
||||
...
|
||||
class NetworkJacobian:
|
||||
@typing.overload
|
||||
def __getitem__(self, key: tuple[fourdst._phys.atomic.Species, fourdst._phys.atomic.Species]) -> float:
|
||||
"""
|
||||
Get an entry from the Jacobian matrix using species identifiers.
|
||||
"""
|
||||
@typing.overload
|
||||
def __getitem__(self, key: tuple[typing.SupportsInt, typing.SupportsInt]) -> float:
|
||||
"""
|
||||
Get an entry from the Jacobian matrix using indices.
|
||||
"""
|
||||
@typing.overload
|
||||
def __setitem__(self, key: tuple[fourdst._phys.atomic.Species, fourdst._phys.atomic.Species], value: typing.SupportsFloat) -> None:
|
||||
"""
|
||||
Set an entry in the Jacobian matrix using species identifiers.
|
||||
"""
|
||||
@typing.overload
|
||||
def __setitem__(self, key: tuple[typing.SupportsInt, typing.SupportsInt], value: typing.SupportsFloat) -> None:
|
||||
"""
|
||||
Set an entry in the Jacobian matrix using indices.
|
||||
"""
|
||||
def data(self) -> ...:
|
||||
"""
|
||||
Get the underlying sparse matrix data.
|
||||
"""
|
||||
def infs(self) -> list[tuple[tuple[fourdst._phys.atomic.Species, fourdst._phys.atomic.Species], float]]:
|
||||
"""
|
||||
Get all infinite entries in the Jacobian matrix.
|
||||
"""
|
||||
def mapping(self) -> dict[fourdst._phys.atomic.Species, int]:
|
||||
"""
|
||||
Get the species-to-index mapping.
|
||||
"""
|
||||
def nans(self) -> list[tuple[tuple[fourdst._phys.atomic.Species, fourdst._phys.atomic.Species], float]]:
|
||||
"""
|
||||
Get all NaN entries in the Jacobian matrix.
|
||||
"""
|
||||
def nnz(self) -> int:
|
||||
"""
|
||||
Get the number of non-zero entries in the Jacobian matrix.
|
||||
"""
|
||||
def rank(self) -> int:
|
||||
"""
|
||||
Get the rank of the Jacobian matrix.
|
||||
"""
|
||||
def shape(self) -> tuple[int, int]:
|
||||
"""
|
||||
Get the shape of the Jacobian matrix as (rows, columns).
|
||||
"""
|
||||
def singular(self) -> bool:
|
||||
"""
|
||||
Check if the Jacobian matrix is singular.
|
||||
"""
|
||||
def to_csv(self, filename: str) -> None:
|
||||
"""
|
||||
Export the Jacobian matrix to a CSV file.
|
||||
"""
|
||||
def to_numpy(self) -> numpy.typing.NDArray[numpy.float64]:
|
||||
"""
|
||||
Convert the Jacobian matrix to a NumPy array.
|
||||
"""
|
||||
class NetworkPrimingEngineView(DefinedEngineView):
|
||||
@typing.overload
|
||||
def __init__(self, ctx: scratchpads.StateBlob, primingSymbol: str, baseEngine: GraphEngine) -> None:
|
||||
"""
|
||||
Construct a priming engine view with a priming symbol and a base engine.
|
||||
"""
|
||||
@typing.overload
|
||||
def __init__(self, ctx: scratchpads.StateBlob, primingSpecies: fourdst._phys.atomic.Species, baseEngine: GraphEngine) -> None:
|
||||
"""
|
||||
Construct a priming engine view with a priming species and a base engine.
|
||||
"""
|
||||
def calculateEpsDerivatives(self, ctx: scratchpads.StateBlob, comp: ..., T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> ...:
|
||||
"""
|
||||
Calculate deps/dT and deps/drho
|
||||
"""
|
||||
def calculateMolarReactionFlow(self: DynamicEngine, ctx: scratchpads.StateBlob, reaction: ..., comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> float:
|
||||
"""
|
||||
Calculate the molar reaction flow for a given reaction.
|
||||
"""
|
||||
def calculateRHSAndEnergy(self: DynamicEngine, ctx: scratchpads.StateBlob, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> StepDerivatives:
|
||||
"""
|
||||
Calculate the right-hand side (dY/dt) and energy generation rate.
|
||||
"""
|
||||
def collectComposition(self, ctx: scratchpads.StateBlob, composition: ..., T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> fourdst._phys.composition.Composition:
|
||||
"""
|
||||
Recursively collect composition from current engine and any sub engines if they exist.
|
||||
"""
|
||||
@typing.overload
|
||||
def generateJacobianMatrix(self: DynamicEngine, ctx: scratchpads.StateBlob, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> NetworkJacobian:
|
||||
"""
|
||||
Generate the Jacobian matrix for the current state.
|
||||
"""
|
||||
@typing.overload
|
||||
def generateJacobianMatrix(self: DynamicEngine, ctx: scratchpads.StateBlob, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat, activeSpecies: collections.abc.Sequence[fourdst._phys.atomic.Species]) -> NetworkJacobian:
|
||||
"""
|
||||
Generate the jacobian matrix only for the subset of the matrix representing the active species.
|
||||
"""
|
||||
@typing.overload
|
||||
def generateJacobianMatrix(self: DynamicEngine, ctx: scratchpads.StateBlob, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat, sparsityPattern: collections.abc.Sequence[tuple[typing.SupportsInt, typing.SupportsInt]]) -> NetworkJacobian:
|
||||
"""
|
||||
Generate the jacobian matrix for the given sparsity pattern
|
||||
"""
|
||||
def getBaseEngine(self) -> DynamicEngine:
|
||||
"""
|
||||
Get the base engine associated with this priming engine view.
|
||||
"""
|
||||
def getNetworkReactions(self, arg0: scratchpads.StateBlob) -> gridfire._gridfire.reaction.ReactionSet:
|
||||
"""
|
||||
Get the set of logical reactions in the network.
|
||||
"""
|
||||
def getNetworkSpecies(self, arg0: scratchpads.StateBlob) -> list[fourdst._phys.atomic.Species]:
|
||||
"""
|
||||
Get the list of species in the network.
|
||||
"""
|
||||
def getScreeningModel(self, arg0: scratchpads.StateBlob) -> gridfire._gridfire.screening.ScreeningType:
|
||||
"""
|
||||
Get the current screening model of the engine.
|
||||
"""
|
||||
def getSpeciesDestructionTimescales(self: DynamicEngine, ctx: scratchpads.StateBlob, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> dict[fourdst._phys.atomic.Species, float]:
|
||||
"""
|
||||
Get the destruction timescales for each species in the network.
|
||||
"""
|
||||
def getSpeciesIndex(self, ctx: scratchpads.StateBlob, species: fourdst._phys.atomic.Species) -> int:
|
||||
"""
|
||||
Get the index of a species in the network.
|
||||
"""
|
||||
def getSpeciesStatus(self, ctx: scratchpads.StateBlob, species: fourdst._phys.atomic.Species) -> SpeciesStatus:
|
||||
"""
|
||||
Get the status of a species in the network.
|
||||
"""
|
||||
def getSpeciesTimescales(self: DynamicEngine, ctx: scratchpads.StateBlob, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> dict[fourdst._phys.atomic.Species, float]:
|
||||
"""
|
||||
Get the timescales for each species in the network.
|
||||
"""
|
||||
def primeEngine(self, ctx: scratchpads.StateBlob, netIn: gridfire._gridfire.type.NetIn) -> PrimingReport:
|
||||
"""
|
||||
Prime the engine with a NetIn object to prepare for calculations.
|
||||
"""
|
||||
def project(self, ctx: scratchpads.StateBlob, netIn: gridfire._gridfire.type.NetIn) -> fourdst._phys.composition.Composition:
|
||||
"""
|
||||
Update the engine state based on the provided NetIn object.
|
||||
"""
|
||||
class PrimingReport:
|
||||
def __repr__(self) -> str:
|
||||
...
|
||||
@property
|
||||
def primedComposition(self) -> fourdst._phys.composition.Composition:
|
||||
"""
|
||||
The composition after priming.
|
||||
"""
|
||||
@property
|
||||
def status(self) -> PrimingReportStatus:
|
||||
"""
|
||||
Status message from the priming process.
|
||||
"""
|
||||
@property
|
||||
def success(self) -> bool:
|
||||
"""
|
||||
Indicates if the priming was successful.
|
||||
"""
|
||||
class PrimingReportStatus:
|
||||
"""
|
||||
Members:
|
||||
|
||||
FULL_SUCCESS : Priming was full successful.
|
||||
|
||||
NO_SPECIES_TO_PRIME : Solver Failed to converge during priming.
|
||||
|
||||
MAX_ITERATIONS_REACHED : Engine has already been primed.
|
||||
"""
|
||||
FULL_SUCCESS: typing.ClassVar[PrimingReportStatus] # value = <PrimingReportStatus.FULL_SUCCESS: 0>
|
||||
MAX_ITERATIONS_REACHED: typing.ClassVar[PrimingReportStatus] # value = <PrimingReportStatus.MAX_ITERATIONS_REACHED: 1>
|
||||
NO_SPECIES_TO_PRIME: typing.ClassVar[PrimingReportStatus] # value = <PrimingReportStatus.NO_SPECIES_TO_PRIME: 2>
|
||||
__members__: typing.ClassVar[dict[str, PrimingReportStatus]] # value = {'FULL_SUCCESS': <PrimingReportStatus.FULL_SUCCESS: 0>, 'NO_SPECIES_TO_PRIME': <PrimingReportStatus.NO_SPECIES_TO_PRIME: 2>, 'MAX_ITERATIONS_REACHED': <PrimingReportStatus.MAX_ITERATIONS_REACHED: 1>}
|
||||
def __eq__(self, other: typing.Any) -> bool:
|
||||
...
|
||||
def __getstate__(self) -> int:
|
||||
...
|
||||
def __hash__(self) -> int:
|
||||
...
|
||||
def __index__(self) -> int:
|
||||
...
|
||||
def __init__(self, value: typing.SupportsInt) -> None:
|
||||
...
|
||||
def __int__(self) -> int:
|
||||
...
|
||||
def __ne__(self, other: typing.Any) -> bool:
|
||||
...
|
||||
@typing.overload
|
||||
def __repr__(self) -> str:
|
||||
...
|
||||
@typing.overload
|
||||
def __repr__(self) -> str:
|
||||
"""
|
||||
String representation of the PrimingReport.
|
||||
"""
|
||||
def __setstate__(self, state: typing.SupportsInt) -> None:
|
||||
...
|
||||
def __str__(self) -> str:
|
||||
...
|
||||
@property
|
||||
def name(self) -> str:
|
||||
...
|
||||
@property
|
||||
def value(self) -> int:
|
||||
...
|
||||
class SparsityPattern:
|
||||
pass
|
||||
class SpeciesStatus:
|
||||
"""
|
||||
Members:
|
||||
|
||||
ACTIVE : Species is active in the network.
|
||||
|
||||
EQUILIBRIUM : Species is in equilibrium.
|
||||
|
||||
INACTIVE_FLOW : Species is inactive due to flow.
|
||||
|
||||
NOT_PRESENT : Species is not present in the network.
|
||||
"""
|
||||
ACTIVE: typing.ClassVar[SpeciesStatus] # value = <SpeciesStatus.ACTIVE: 0>
|
||||
EQUILIBRIUM: typing.ClassVar[SpeciesStatus] # value = <SpeciesStatus.EQUILIBRIUM: 1>
|
||||
INACTIVE_FLOW: typing.ClassVar[SpeciesStatus] # value = <SpeciesStatus.INACTIVE_FLOW: 2>
|
||||
NOT_PRESENT: typing.ClassVar[SpeciesStatus] # value = <SpeciesStatus.NOT_PRESENT: 3>
|
||||
__members__: typing.ClassVar[dict[str, SpeciesStatus]] # value = {'ACTIVE': <SpeciesStatus.ACTIVE: 0>, 'EQUILIBRIUM': <SpeciesStatus.EQUILIBRIUM: 1>, 'INACTIVE_FLOW': <SpeciesStatus.INACTIVE_FLOW: 2>, 'NOT_PRESENT': <SpeciesStatus.NOT_PRESENT: 3>}
|
||||
def __eq__(self, other: typing.Any) -> bool:
|
||||
...
|
||||
def __getstate__(self) -> int:
|
||||
...
|
||||
def __hash__(self) -> int:
|
||||
...
|
||||
def __index__(self) -> int:
|
||||
...
|
||||
def __init__(self, value: typing.SupportsInt) -> None:
|
||||
...
|
||||
def __int__(self) -> int:
|
||||
...
|
||||
def __ne__(self, other: typing.Any) -> bool:
|
||||
...
|
||||
@typing.overload
|
||||
def __repr__(self) -> str:
|
||||
...
|
||||
@typing.overload
|
||||
def __repr__(self) -> str:
|
||||
...
|
||||
def __setstate__(self, state: typing.SupportsInt) -> None:
|
||||
...
|
||||
def __str__(self) -> str:
|
||||
...
|
||||
@property
|
||||
def name(self) -> str:
|
||||
...
|
||||
@property
|
||||
def value(self) -> int:
|
||||
...
|
||||
class StepDerivatives:
|
||||
@property
|
||||
def dYdt(self) -> dict[fourdst._phys.atomic.Species, float]:
|
||||
"""
|
||||
The right-hand side (dY/dt) of the ODE system.
|
||||
"""
|
||||
@property
|
||||
def energy(self) -> float:
|
||||
"""
|
||||
The energy generation rate.
|
||||
"""
|
||||
def build_nuclear_network(composition: ..., weakInterpolator: ..., maxLayers: gridfire._gridfire.engine.NetworkBuildDepth | typing.SupportsInt = ..., ReactionTypes: NetworkConstructionFlags = ...) -> gridfire._gridfire.reaction.ReactionSet:
|
||||
"""
|
||||
Build a nuclear network from a composition using all archived reaction data.
|
||||
"""
|
||||
def primeNetwork(ctx: scratchpads.StateBlob, netIn: gridfire._gridfire.type.NetIn, engine: ..., ignoredReactionTypes: collections.abc.Sequence[...] | None = None) -> PrimingReport:
|
||||
"""
|
||||
Prime a network with a short timescale ignition
|
||||
"""
|
||||
def regularize_jacobian(jacobian: NetworkJacobian, composition: fourdst._phys.composition.Composition) -> NetworkJacobian:
|
||||
"""
|
||||
regularize_jacobian
|
||||
"""
|
||||
ACTIVE: SpeciesStatus # value = <SpeciesStatus.ACTIVE: 0>
|
||||
ADAPTIVE_ENGINE_VIEW: EngineTypes # value = <EngineTypes.ADAPTIVE_ENGINE_VIEW: 1>
|
||||
DEFAULT: NetworkConstructionFlags # value = <NetworkConstructionFlags.REACLIB: 33>
|
||||
DEFINED_ENGINE_VIEW: EngineTypes # value = <EngineTypes.DEFINED_ENGINE_VIEW: 4>
|
||||
EQUILIBRIUM: SpeciesStatus # value = <SpeciesStatus.EQUILIBRIUM: 1>
|
||||
FILE_DEFINED_ENGINE_VIEW: EngineTypes # value = <EngineTypes.FILE_DEFINED_ENGINE_VIEW: 5>
|
||||
FULL_SUCCESS: PrimingReportStatus # value = <PrimingReportStatus.FULL_SUCCESS: 0>
|
||||
FifthOrder: NetworkBuildDepth # value = <NetworkBuildDepth.FifthOrder: 5>
|
||||
FourthOrder: NetworkBuildDepth # value = <NetworkBuildDepth.FourthOrder: 4>
|
||||
Full: NetworkBuildDepth # value = <NetworkBuildDepth.Full: -1>
|
||||
GRAPH_ENGINE: EngineTypes # value = <EngineTypes.GRAPH_ENGINE: 0>
|
||||
INACTIVE_FLOW: SpeciesStatus # value = <SpeciesStatus.INACTIVE_FLOW: 2>
|
||||
MAX_ITERATIONS_REACHED: PrimingReportStatus # value = <PrimingReportStatus.MAX_ITERATIONS_REACHED: 1>
|
||||
MULTISCALE_PARTITIONING_ENGINE_VIEW: EngineTypes # value = <EngineTypes.MULTISCALE_PARTITIONING_ENGINE_VIEW: 2>
|
||||
NONE: NetworkConstructionFlags # value = <NetworkConstructionFlags.NONE: 0>
|
||||
NOT_PRESENT: SpeciesStatus # value = <SpeciesStatus.NOT_PRESENT: 3>
|
||||
NO_SPECIES_TO_PRIME: PrimingReportStatus # value = <PrimingReportStatus.NO_SPECIES_TO_PRIME: 2>
|
||||
PRIMING_ENGINE_VIEW: EngineTypes # value = <EngineTypes.PRIMING_ENGINE_VIEW: 3>
|
||||
REACLIB: NetworkConstructionFlags # value = <NetworkConstructionFlags.REACLIB: 33>
|
||||
REACLIB_STRONG: NetworkConstructionFlags # value = <NetworkConstructionFlags.REACLIB_STRONG: 1>
|
||||
REACLIB_WEAK: NetworkConstructionFlags # value = <NetworkConstructionFlags.REACLIB_WEAK: 32>
|
||||
SecondOrder: NetworkBuildDepth # value = <NetworkBuildDepth.SecondOrder: 2>
|
||||
Shallow: NetworkBuildDepth # value = <NetworkBuildDepth.Shallow: 1>
|
||||
ThirdOrder: NetworkBuildDepth # value = <NetworkBuildDepth.ThirdOrder: 3>
|
||||
WRL_BETA_MINUS: NetworkConstructionFlags # value = <NetworkConstructionFlags.WRL_BETA_MINUS: 2>
|
||||
WRL_BETA_PLUS: NetworkConstructionFlags # value = <NetworkConstructionFlags.WRL_BETA_PLUS: 4>
|
||||
WRL_ELECTRON_CAPTURE: NetworkConstructionFlags # value = <NetworkConstructionFlags.WRL_ELECTRON_CAPTURE: 8>
|
||||
WRL_POSITRON_CAPTURE: NetworkConstructionFlags # value = <NetworkConstructionFlags.WRL_POSITRON_CAPTURE: 16>
|
||||
WRL_WEAK: NetworkConstructionFlags # value = <NetworkConstructionFlags.WRL_WEAK: 30>
|
||||
@@ -1,16 +0,0 @@
|
||||
"""
|
||||
A submodule for engine diagnostics
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import collections.abc
|
||||
import fourdst._phys.composition
|
||||
import gridfire._gridfire.engine
|
||||
import gridfire._gridfire.engine.scratchpads
|
||||
import typing
|
||||
__all__: list[str] = ['inspect_jacobian_stiffness', 'inspect_species_balance', 'report_limiting_species']
|
||||
def inspect_jacobian_stiffness(ctx: gridfire._gridfire.engine.scratchpads.StateBlob, engine: gridfire._gridfire.engine.DynamicEngine, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat, json: bool) -> ... | None:
|
||||
...
|
||||
def inspect_species_balance(ctx: gridfire._gridfire.engine.scratchpads.StateBlob, engine: gridfire._gridfire.engine.DynamicEngine, species_name: str, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat, json: bool) -> ... | None:
|
||||
...
|
||||
def report_limiting_species(ctx: gridfire._gridfire.engine.scratchpads.StateBlob, engine: gridfire._gridfire.engine.DynamicEngine, Y_full: collections.abc.Sequence[typing.SupportsFloat], E_full: collections.abc.Sequence[typing.SupportsFloat], relTol: typing.SupportsFloat, absTol: typing.SupportsFloat, top_n: typing.SupportsInt, json: bool) -> ... | None:
|
||||
...
|
||||
@@ -1,267 +0,0 @@
|
||||
"""
|
||||
Engine ScratchPad bindings
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import fourdst._phys.atomic
|
||||
import fourdst._phys.composition
|
||||
import gridfire._gridfire.reaction
|
||||
import typing
|
||||
__all__: list[str] = ['ADAPTIVE_ENGINE_VIEW_SCRATCHPAD', 'ADFunRegistrationResult', 'ALREADY_REGISTERED', 'AdaptiveEngineViewScratchPad', 'DEFINED_ENGINE_VIEW_SCRATCHPAD', 'DefinedEngineViewScratchPad', 'GRAPH_ENGINE_SCRATCHPAD', 'GraphEngineScratchPad', 'MULTISCALE_PARTITIONING_ENGINE_VIEW_SCRATCHPAD', 'MultiscalePartitioningEngineViewScratchPad', 'SCRATCHPAD_BAD_CAST', 'SCRATCHPAD_NOT_FOUND', 'SCRATCHPAD_NOT_INITIALIZED', 'SCRATCHPAD_OUT_OF_BOUNDS', 'SCRATCHPAD_TYPE_COLLISION', 'SCRATCHPAD_UNKNOWN_ERROR', 'SUCCESS', 'ScratchPadType', 'StateBlob', 'StateBlobError']
|
||||
class ADFunRegistrationResult:
|
||||
"""
|
||||
Members:
|
||||
|
||||
SUCCESS
|
||||
|
||||
ALREADY_REGISTERED
|
||||
"""
|
||||
ALREADY_REGISTERED: typing.ClassVar[ADFunRegistrationResult] # value = <ADFunRegistrationResult.ALREADY_REGISTERED: 1>
|
||||
SUCCESS: typing.ClassVar[ADFunRegistrationResult] # value = <ADFunRegistrationResult.SUCCESS: 0>
|
||||
__members__: typing.ClassVar[dict[str, ADFunRegistrationResult]] # value = {'SUCCESS': <ADFunRegistrationResult.SUCCESS: 0>, 'ALREADY_REGISTERED': <ADFunRegistrationResult.ALREADY_REGISTERED: 1>}
|
||||
def __eq__(self, other: typing.Any) -> bool:
|
||||
...
|
||||
def __getstate__(self) -> int:
|
||||
...
|
||||
def __hash__(self) -> int:
|
||||
...
|
||||
def __index__(self) -> int:
|
||||
...
|
||||
def __init__(self, value: typing.SupportsInt) -> None:
|
||||
...
|
||||
def __int__(self) -> int:
|
||||
...
|
||||
def __ne__(self, other: typing.Any) -> bool:
|
||||
...
|
||||
def __repr__(self) -> str:
|
||||
...
|
||||
def __setstate__(self, state: typing.SupportsInt) -> None:
|
||||
...
|
||||
def __str__(self) -> str:
|
||||
...
|
||||
@property
|
||||
def name(self) -> str:
|
||||
...
|
||||
@property
|
||||
def value(self) -> int:
|
||||
...
|
||||
class AdaptiveEngineViewScratchPad:
|
||||
ID: typing.ClassVar[ScratchPadType] # value = <ScratchPadType.ADAPTIVE_ENGINE_VIEW_SCRATCHPAD: 2>
|
||||
def __init__(self) -> None:
|
||||
...
|
||||
def __repr__(self) -> str:
|
||||
...
|
||||
def clone(self) -> ...:
|
||||
...
|
||||
def initialize(self, arg0: ...) -> None:
|
||||
...
|
||||
def is_initialized(self) -> bool:
|
||||
...
|
||||
@property
|
||||
def active_reactions(self) -> gridfire._gridfire.reaction.ReactionSet:
|
||||
...
|
||||
@property
|
||||
def active_species(self) -> list[fourdst._phys.atomic.Species]:
|
||||
...
|
||||
@property
|
||||
def has_initialized(self) -> bool:
|
||||
...
|
||||
class DefinedEngineViewScratchPad:
|
||||
ID: typing.ClassVar[ScratchPadType] # value = <ScratchPadType.DEFINED_ENGINE_VIEW_SCRATCHPAD: 3>
|
||||
def __init__(self) -> None:
|
||||
...
|
||||
def __repr__(self) -> str:
|
||||
...
|
||||
def clone(self) -> ...:
|
||||
...
|
||||
def is_initialized(self) -> bool:
|
||||
...
|
||||
@property
|
||||
def active_reactions(self) -> gridfire._gridfire.reaction.ReactionSet:
|
||||
...
|
||||
@property
|
||||
def active_species(self) -> set[fourdst._phys.atomic.Species]:
|
||||
...
|
||||
@property
|
||||
def has_initialized(self) -> bool:
|
||||
...
|
||||
@property
|
||||
def reaction_index_map(self) -> list[int]:
|
||||
...
|
||||
@property
|
||||
def species_index_map(self) -> list[int]:
|
||||
...
|
||||
class GraphEngineScratchPad:
|
||||
ID: typing.ClassVar[ScratchPadType] # value = <ScratchPadType.GRAPH_ENGINE_SCRATCHPAD: 0>
|
||||
def __init__(self) -> None:
|
||||
...
|
||||
def __repr__(self) -> str:
|
||||
...
|
||||
def clone(self) -> ...:
|
||||
...
|
||||
def initialize(self, engine: ...) -> None:
|
||||
...
|
||||
def is_initialized(self) -> bool:
|
||||
...
|
||||
@property
|
||||
def has_initialized(self) -> bool:
|
||||
...
|
||||
@property
|
||||
def local_abundance_cache(self) -> list[float]:
|
||||
...
|
||||
@property
|
||||
def most_recent_rhs_calculation(self) -> ... | None:
|
||||
...
|
||||
@property
|
||||
def stepDerivativesCache(self) -> dict[int, ...]:
|
||||
...
|
||||
class MultiscalePartitioningEngineViewScratchPad:
|
||||
ID: typing.ClassVar[ScratchPadType] # value = <ScratchPadType.MULTISCALE_PARTITIONING_ENGINE_VIEW_SCRATCHPAD: 1>
|
||||
def __init__(self) -> None:
|
||||
...
|
||||
def __repr__(self) -> str:
|
||||
...
|
||||
def clone(self) -> ...:
|
||||
...
|
||||
def initialize(self) -> None:
|
||||
...
|
||||
def is_initialized(self) -> bool:
|
||||
...
|
||||
@property
|
||||
def algebraic_species(self) -> list[fourdst._phys.atomic.Species]:
|
||||
...
|
||||
@property
|
||||
def composition_cache(self) -> dict[int, fourdst._phys.composition.Composition]:
|
||||
...
|
||||
@property
|
||||
def dynamic_species(self) -> list[fourdst._phys.atomic.Species]:
|
||||
...
|
||||
@property
|
||||
def has_initialized(self) -> bool:
|
||||
...
|
||||
@property
|
||||
def qse_groups(self) -> list[...]:
|
||||
...
|
||||
class ScratchPadType:
|
||||
"""
|
||||
Members:
|
||||
|
||||
GRAPH_ENGINE_SCRATCHPAD
|
||||
|
||||
MULTISCALE_PARTITIONING_ENGINE_VIEW_SCRATCHPAD
|
||||
|
||||
ADAPTIVE_ENGINE_VIEW_SCRATCHPAD
|
||||
|
||||
DEFINED_ENGINE_VIEW_SCRATCHPAD
|
||||
"""
|
||||
ADAPTIVE_ENGINE_VIEW_SCRATCHPAD: typing.ClassVar[ScratchPadType] # value = <ScratchPadType.ADAPTIVE_ENGINE_VIEW_SCRATCHPAD: 2>
|
||||
DEFINED_ENGINE_VIEW_SCRATCHPAD: typing.ClassVar[ScratchPadType] # value = <ScratchPadType.DEFINED_ENGINE_VIEW_SCRATCHPAD: 3>
|
||||
GRAPH_ENGINE_SCRATCHPAD: typing.ClassVar[ScratchPadType] # value = <ScratchPadType.GRAPH_ENGINE_SCRATCHPAD: 0>
|
||||
MULTISCALE_PARTITIONING_ENGINE_VIEW_SCRATCHPAD: typing.ClassVar[ScratchPadType] # value = <ScratchPadType.MULTISCALE_PARTITIONING_ENGINE_VIEW_SCRATCHPAD: 1>
|
||||
__members__: typing.ClassVar[dict[str, ScratchPadType]] # value = {'GRAPH_ENGINE_SCRATCHPAD': <ScratchPadType.GRAPH_ENGINE_SCRATCHPAD: 0>, 'MULTISCALE_PARTITIONING_ENGINE_VIEW_SCRATCHPAD': <ScratchPadType.MULTISCALE_PARTITIONING_ENGINE_VIEW_SCRATCHPAD: 1>, 'ADAPTIVE_ENGINE_VIEW_SCRATCHPAD': <ScratchPadType.ADAPTIVE_ENGINE_VIEW_SCRATCHPAD: 2>, 'DEFINED_ENGINE_VIEW_SCRATCHPAD': <ScratchPadType.DEFINED_ENGINE_VIEW_SCRATCHPAD: 3>}
|
||||
def __eq__(self, other: typing.Any) -> bool:
|
||||
...
|
||||
def __getstate__(self) -> int:
|
||||
...
|
||||
def __hash__(self) -> int:
|
||||
...
|
||||
def __index__(self) -> int:
|
||||
...
|
||||
def __init__(self, value: typing.SupportsInt) -> None:
|
||||
...
|
||||
def __int__(self) -> int:
|
||||
...
|
||||
def __ne__(self, other: typing.Any) -> bool:
|
||||
...
|
||||
def __repr__(self) -> str:
|
||||
...
|
||||
def __setstate__(self, state: typing.SupportsInt) -> None:
|
||||
...
|
||||
def __str__(self) -> str:
|
||||
...
|
||||
@property
|
||||
def name(self) -> str:
|
||||
...
|
||||
@property
|
||||
def value(self) -> int:
|
||||
...
|
||||
class StateBlob:
|
||||
@staticmethod
|
||||
def error_to_string(arg0: StateBlobError) -> str:
|
||||
...
|
||||
def __init__(self) -> None:
|
||||
...
|
||||
def __repr__(self) -> str:
|
||||
...
|
||||
def clone_structure(self) -> StateBlob:
|
||||
...
|
||||
def enroll(self, arg0: ScratchPadType) -> None:
|
||||
...
|
||||
def get(self, arg0: ScratchPadType) -> ...:
|
||||
...
|
||||
def get_registered_scratchpads(self) -> set[ScratchPadType]:
|
||||
...
|
||||
def get_status(self, arg0: ScratchPadType) -> ...:
|
||||
...
|
||||
def get_status_map(self) -> dict[ScratchPadType, ...]:
|
||||
...
|
||||
class StateBlobError:
|
||||
"""
|
||||
Members:
|
||||
|
||||
SCRATCHPAD_OUT_OF_BOUNDS
|
||||
|
||||
SCRATCHPAD_NOT_FOUND
|
||||
|
||||
SCRATCHPAD_BAD_CAST
|
||||
|
||||
SCRATCHPAD_NOT_INITIALIZED
|
||||
|
||||
SCRATCHPAD_TYPE_COLLISION
|
||||
|
||||
SCRATCHPAD_UNKNOWN_ERROR
|
||||
"""
|
||||
SCRATCHPAD_BAD_CAST: typing.ClassVar[StateBlobError] # value = <StateBlobError.SCRATCHPAD_BAD_CAST: 1>
|
||||
SCRATCHPAD_NOT_FOUND: typing.ClassVar[StateBlobError] # value = <StateBlobError.SCRATCHPAD_NOT_FOUND: 0>
|
||||
SCRATCHPAD_NOT_INITIALIZED: typing.ClassVar[StateBlobError] # value = <StateBlobError.SCRATCHPAD_NOT_INITIALIZED: 2>
|
||||
SCRATCHPAD_OUT_OF_BOUNDS: typing.ClassVar[StateBlobError] # value = <StateBlobError.SCRATCHPAD_OUT_OF_BOUNDS: 4>
|
||||
SCRATCHPAD_TYPE_COLLISION: typing.ClassVar[StateBlobError] # value = <StateBlobError.SCRATCHPAD_TYPE_COLLISION: 3>
|
||||
SCRATCHPAD_UNKNOWN_ERROR: typing.ClassVar[StateBlobError] # value = <StateBlobError.SCRATCHPAD_UNKNOWN_ERROR: 5>
|
||||
__members__: typing.ClassVar[dict[str, StateBlobError]] # value = {'SCRATCHPAD_OUT_OF_BOUNDS': <StateBlobError.SCRATCHPAD_OUT_OF_BOUNDS: 4>, 'SCRATCHPAD_NOT_FOUND': <StateBlobError.SCRATCHPAD_NOT_FOUND: 0>, 'SCRATCHPAD_BAD_CAST': <StateBlobError.SCRATCHPAD_BAD_CAST: 1>, 'SCRATCHPAD_NOT_INITIALIZED': <StateBlobError.SCRATCHPAD_NOT_INITIALIZED: 2>, 'SCRATCHPAD_TYPE_COLLISION': <StateBlobError.SCRATCHPAD_TYPE_COLLISION: 3>, 'SCRATCHPAD_UNKNOWN_ERROR': <StateBlobError.SCRATCHPAD_UNKNOWN_ERROR: 5>}
|
||||
def __eq__(self, other: typing.Any) -> bool:
|
||||
...
|
||||
def __getstate__(self) -> int:
|
||||
...
|
||||
def __hash__(self) -> int:
|
||||
...
|
||||
def __index__(self) -> int:
|
||||
...
|
||||
def __init__(self, value: typing.SupportsInt) -> None:
|
||||
...
|
||||
def __int__(self) -> int:
|
||||
...
|
||||
def __ne__(self, other: typing.Any) -> bool:
|
||||
...
|
||||
def __repr__(self) -> str:
|
||||
...
|
||||
def __setstate__(self, state: typing.SupportsInt) -> None:
|
||||
...
|
||||
def __str__(self) -> str:
|
||||
...
|
||||
@property
|
||||
def name(self) -> str:
|
||||
...
|
||||
@property
|
||||
def value(self) -> int:
|
||||
...
|
||||
ADAPTIVE_ENGINE_VIEW_SCRATCHPAD: ScratchPadType # value = <ScratchPadType.ADAPTIVE_ENGINE_VIEW_SCRATCHPAD: 2>
|
||||
ALREADY_REGISTERED: ADFunRegistrationResult # value = <ADFunRegistrationResult.ALREADY_REGISTERED: 1>
|
||||
DEFINED_ENGINE_VIEW_SCRATCHPAD: ScratchPadType # value = <ScratchPadType.DEFINED_ENGINE_VIEW_SCRATCHPAD: 3>
|
||||
GRAPH_ENGINE_SCRATCHPAD: ScratchPadType # value = <ScratchPadType.GRAPH_ENGINE_SCRATCHPAD: 0>
|
||||
MULTISCALE_PARTITIONING_ENGINE_VIEW_SCRATCHPAD: ScratchPadType # value = <ScratchPadType.MULTISCALE_PARTITIONING_ENGINE_VIEW_SCRATCHPAD: 1>
|
||||
SCRATCHPAD_BAD_CAST: StateBlobError # value = <StateBlobError.SCRATCHPAD_BAD_CAST: 1>
|
||||
SCRATCHPAD_NOT_FOUND: StateBlobError # value = <StateBlobError.SCRATCHPAD_NOT_FOUND: 0>
|
||||
SCRATCHPAD_NOT_INITIALIZED: StateBlobError # value = <StateBlobError.SCRATCHPAD_NOT_INITIALIZED: 2>
|
||||
SCRATCHPAD_OUT_OF_BOUNDS: StateBlobError # value = <StateBlobError.SCRATCHPAD_OUT_OF_BOUNDS: 4>
|
||||
SCRATCHPAD_TYPE_COLLISION: StateBlobError # value = <StateBlobError.SCRATCHPAD_TYPE_COLLISION: 3>
|
||||
SCRATCHPAD_UNKNOWN_ERROR: StateBlobError # value = <StateBlobError.SCRATCHPAD_UNKNOWN_ERROR: 5>
|
||||
SUCCESS: ADFunRegistrationResult # value = <ADFunRegistrationResult.SUCCESS: 0>
|
||||
@@ -1,61 +0,0 @@
|
||||
"""
|
||||
GridFire exceptions bindings
|
||||
"""
|
||||
from __future__ import annotations
|
||||
__all__: list[str] = ['BadCollectionError', 'BadRHSEngineError', 'CVODESolverFailureError', 'DebugException', 'EngineError', 'FailedToPartitionEngineError', 'GridFireError', 'HashingError', 'IllConditionedJacobianError', 'InvalidQSESolutionError', 'JacobianError', 'KINSolSolverFailureError', 'MissingBaseReactionError', 'MissingKeyReactionError', 'MissingSeedSpeciesError', 'NetworkResizedError', 'PolicyError', 'ReactionError', 'ReactionParsingError', 'SUNDIALSError', 'ScratchPadError', 'SingularJacobianError', 'SolverError', 'StaleJacobianError', 'UnableToSetNetworkReactionsError', 'UninitializedJacobianError', 'UnknownJacobianError', 'UtilityError']
|
||||
class BadCollectionError(EngineError):
|
||||
pass
|
||||
class BadRHSEngineError(EngineError):
|
||||
pass
|
||||
class CVODESolverFailureError(SUNDIALSError):
|
||||
pass
|
||||
class DebugException(GridFireError):
|
||||
pass
|
||||
class EngineError(GridFireError):
|
||||
pass
|
||||
class FailedToPartitionEngineError(EngineError):
|
||||
pass
|
||||
class GridFireError(Exception):
|
||||
pass
|
||||
class HashingError(UtilityError):
|
||||
pass
|
||||
class IllConditionedJacobianError(SolverError):
|
||||
pass
|
||||
class InvalidQSESolutionError(EngineError):
|
||||
pass
|
||||
class JacobianError(EngineError):
|
||||
pass
|
||||
class KINSolSolverFailureError(SUNDIALSError):
|
||||
pass
|
||||
class MissingBaseReactionError(PolicyError):
|
||||
pass
|
||||
class MissingKeyReactionError(PolicyError):
|
||||
pass
|
||||
class MissingSeedSpeciesError(PolicyError):
|
||||
pass
|
||||
class NetworkResizedError(EngineError):
|
||||
pass
|
||||
class PolicyError(GridFireError):
|
||||
pass
|
||||
class ReactionError(GridFireError):
|
||||
pass
|
||||
class ReactionParsingError(ReactionError):
|
||||
pass
|
||||
class SUNDIALSError(SolverError):
|
||||
pass
|
||||
class ScratchPadError(GridFireError):
|
||||
pass
|
||||
class SingularJacobianError(SolverError):
|
||||
pass
|
||||
class SolverError(GridFireError):
|
||||
pass
|
||||
class StaleJacobianError(JacobianError):
|
||||
pass
|
||||
class UnableToSetNetworkReactionsError(EngineError):
|
||||
pass
|
||||
class UninitializedJacobianError(JacobianError):
|
||||
pass
|
||||
class UnknownJacobianError(JacobianError):
|
||||
pass
|
||||
class UtilityError(GridFireError):
|
||||
pass
|
||||
@@ -1,14 +0,0 @@
|
||||
"""
|
||||
GridFire io bindings
|
||||
"""
|
||||
from __future__ import annotations
|
||||
__all__: list[str] = ['NetworkFileParser', 'ParsedNetworkData', 'SimpleReactionListFileParser']
|
||||
class NetworkFileParser:
|
||||
pass
|
||||
class ParsedNetworkData:
|
||||
pass
|
||||
class SimpleReactionListFileParser(NetworkFileParser):
|
||||
def parse(self, filename: str) -> ParsedNetworkData:
|
||||
"""
|
||||
Parse a simple reaction list file and return a ParsedNetworkData object.
|
||||
"""
|
||||
@@ -1,142 +0,0 @@
|
||||
"""
|
||||
GridFire partition function bindings
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import collections.abc
|
||||
import typing
|
||||
__all__: list[str] = ['BasePartitionType', 'CompositePartitionFunction', 'GroundState', 'GroundStatePartitionFunction', 'PartitionFunction', 'RauscherThielemann', 'RauscherThielemannPartitionDataRecord', 'RauscherThielemannPartitionFunction', 'basePartitionTypeToString', 'stringToBasePartitionType']
|
||||
class BasePartitionType:
|
||||
"""
|
||||
Members:
|
||||
|
||||
RauscherThielemann
|
||||
|
||||
GroundState
|
||||
"""
|
||||
GroundState: typing.ClassVar[BasePartitionType] # value = <BasePartitionType.GroundState: 1>
|
||||
RauscherThielemann: typing.ClassVar[BasePartitionType] # value = <BasePartitionType.RauscherThielemann: 0>
|
||||
__members__: typing.ClassVar[dict[str, BasePartitionType]] # value = {'RauscherThielemann': <BasePartitionType.RauscherThielemann: 0>, 'GroundState': <BasePartitionType.GroundState: 1>}
|
||||
def __eq__(self, other: typing.Any) -> bool:
|
||||
...
|
||||
def __getstate__(self) -> int:
|
||||
...
|
||||
def __hash__(self) -> int:
|
||||
...
|
||||
def __index__(self) -> int:
|
||||
...
|
||||
def __init__(self, value: typing.SupportsInt) -> None:
|
||||
...
|
||||
def __int__(self) -> int:
|
||||
...
|
||||
def __ne__(self, other: typing.Any) -> bool:
|
||||
...
|
||||
def __repr__(self) -> str:
|
||||
...
|
||||
def __setstate__(self, state: typing.SupportsInt) -> None:
|
||||
...
|
||||
def __str__(self) -> str:
|
||||
...
|
||||
@property
|
||||
def name(self) -> str:
|
||||
...
|
||||
@property
|
||||
def value(self) -> int:
|
||||
...
|
||||
class CompositePartitionFunction:
|
||||
@typing.overload
|
||||
def __init__(self, partitionFunctions: collections.abc.Sequence[BasePartitionType]) -> None:
|
||||
"""
|
||||
Create a composite partition function from a list of base partition types.
|
||||
"""
|
||||
@typing.overload
|
||||
def __init__(self, arg0: CompositePartitionFunction) -> None:
|
||||
"""
|
||||
Copy constructor for CompositePartitionFunction.
|
||||
"""
|
||||
def evaluate(self, z: typing.SupportsInt, a: typing.SupportsInt, T9: typing.SupportsFloat) -> float:
|
||||
"""
|
||||
Evaluate the composite partition function for given Z, A, and T9.
|
||||
"""
|
||||
def evaluateDerivative(self, z: typing.SupportsInt, a: typing.SupportsInt, T9: typing.SupportsFloat) -> float:
|
||||
"""
|
||||
Evaluate the derivative of the composite partition function for given Z, A, and T9.
|
||||
"""
|
||||
def get_type(self) -> str:
|
||||
"""
|
||||
Get the type of the partition function (should return 'Composite').
|
||||
"""
|
||||
def supports(self, z: typing.SupportsInt, a: typing.SupportsInt) -> bool:
|
||||
"""
|
||||
Check if the composite partition function supports given Z and A.
|
||||
"""
|
||||
class GroundStatePartitionFunction(PartitionFunction):
|
||||
def __init__(self) -> None:
|
||||
...
|
||||
def evaluate(self, z: typing.SupportsInt, a: typing.SupportsInt, T9: typing.SupportsFloat) -> float:
|
||||
"""
|
||||
Evaluate the ground state partition function for given Z, A, and T9.
|
||||
"""
|
||||
def evaluateDerivative(self, z: typing.SupportsInt, a: typing.SupportsInt, T9: typing.SupportsFloat) -> float:
|
||||
"""
|
||||
Evaluate the derivative of the ground state partition function for given Z, A, and T9.
|
||||
"""
|
||||
def get_type(self) -> str:
|
||||
"""
|
||||
Get the type of the partition function (should return 'GroundState').
|
||||
"""
|
||||
def supports(self, z: typing.SupportsInt, a: typing.SupportsInt) -> bool:
|
||||
"""
|
||||
Check if the ground state partition function supports given Z and A.
|
||||
"""
|
||||
class PartitionFunction:
|
||||
pass
|
||||
class RauscherThielemannPartitionDataRecord:
|
||||
@property
|
||||
def a(self) -> int:
|
||||
"""
|
||||
Mass number
|
||||
"""
|
||||
@property
|
||||
def ground_state_spin(self) -> float:
|
||||
"""
|
||||
Ground state spin
|
||||
"""
|
||||
@property
|
||||
def normalized_g_values(self) -> float:
|
||||
"""
|
||||
Normalized g-values for the first 24 energy levels
|
||||
"""
|
||||
@property
|
||||
def z(self) -> int:
|
||||
"""
|
||||
Atomic number
|
||||
"""
|
||||
class RauscherThielemannPartitionFunction(PartitionFunction):
|
||||
def __init__(self) -> None:
|
||||
...
|
||||
def evaluate(self, z: typing.SupportsInt, a: typing.SupportsInt, T9: typing.SupportsFloat) -> float:
|
||||
"""
|
||||
Evaluate the Rauscher-Thielemann partition function for given Z, A, and T9.
|
||||
"""
|
||||
def evaluateDerivative(self, z: typing.SupportsInt, a: typing.SupportsInt, T9: typing.SupportsFloat) -> float:
|
||||
"""
|
||||
Evaluate the derivative of the Rauscher-Thielemann partition function for given Z, A, and T9.
|
||||
"""
|
||||
def get_type(self) -> str:
|
||||
"""
|
||||
Get the type of the partition function (should return 'RauscherThielemann').
|
||||
"""
|
||||
def supports(self, z: typing.SupportsInt, a: typing.SupportsInt) -> bool:
|
||||
"""
|
||||
Check if the Rauscher-Thielemann partition function supports given Z and A.
|
||||
"""
|
||||
def basePartitionTypeToString(type: BasePartitionType) -> str:
|
||||
"""
|
||||
Convert BasePartitionType to string.
|
||||
"""
|
||||
def stringToBasePartitionType(typeStr: str) -> BasePartitionType:
|
||||
"""
|
||||
Convert string to BasePartitionType.
|
||||
"""
|
||||
GroundState: BasePartitionType # value = <BasePartitionType.GroundState: 1>
|
||||
RauscherThielemann: BasePartitionType # value = <BasePartitionType.RauscherThielemann: 0>
|
||||
@@ -1,769 +0,0 @@
|
||||
"""
|
||||
GridFire network policy bindings
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import collections.abc
|
||||
import fourdst._phys.atomic
|
||||
import fourdst._phys.composition
|
||||
import gridfire._gridfire.engine
|
||||
import gridfire._gridfire.engine.scratchpads
|
||||
import gridfire._gridfire.partition
|
||||
import gridfire._gridfire.reaction
|
||||
import typing
|
||||
__all__: list[str] = ['CNOChainPolicy', 'CNOIChainPolicy', 'CNOIIChainPolicy', 'CNOIIIChainPolicy', 'CNOIVChainPolicy', 'ConstructionResults', 'HotCNOChainPolicy', 'HotCNOIChainPolicy', 'HotCNOIIChainPolicy', 'HotCNOIIIChainPolicy', 'INITIALIZED_UNVERIFIED', 'INITIALIZED_VERIFIED', 'MISSING_KEY_REACTION', 'MISSING_KEY_SPECIES', 'MainSequencePolicy', 'MainSequenceReactionChainPolicy', 'MultiReactionChainPolicy', 'NetworkPolicy', 'NetworkPolicyStatus', 'ProtonProtonChainPolicy', 'ProtonProtonIChainPolicy', 'ProtonProtonIIChainPolicy', 'ProtonProtonIIIChainPolicy', 'ReactionChainPolicy', 'TemperatureDependentChainPolicy', 'TripleAlphaChainPolicy', 'UNINITIALIZED', 'network_policy_status_to_string']
|
||||
class CNOChainPolicy(MultiReactionChainPolicy):
|
||||
def __eq__(self, other: ReactionChainPolicy) -> bool:
|
||||
"""
|
||||
Check equality with another ReactionChainPolicy.
|
||||
"""
|
||||
def __hash__(self) -> int:
|
||||
...
|
||||
def __init__(self) -> None:
|
||||
...
|
||||
def __ne__(self, other: ReactionChainPolicy) -> bool:
|
||||
"""
|
||||
Check inequality with another ReactionChainPolicy.
|
||||
"""
|
||||
def __repr__(self) -> str:
|
||||
...
|
||||
@typing.overload
|
||||
def contains(self, id: str) -> bool:
|
||||
"""
|
||||
Check if the reaction chain contains a reaction with the given ID.
|
||||
"""
|
||||
@typing.overload
|
||||
def contains(self, reaction: ...) -> bool:
|
||||
"""
|
||||
Check if the reaction chain contains the given reaction.
|
||||
"""
|
||||
def get_reactions(self) -> gridfire._gridfire.reaction.ReactionSet:
|
||||
"""
|
||||
Get the ReactionSet representing this reaction chain.
|
||||
"""
|
||||
def hash(self, seed: typing.SupportsInt) -> int:
|
||||
"""
|
||||
Compute a hash value for the reaction chain policy.
|
||||
"""
|
||||
@typing.overload
|
||||
def name(self) -> str:
|
||||
"""
|
||||
Get the name of the reaction chain policy.
|
||||
"""
|
||||
@typing.overload
|
||||
def name(self) -> str:
|
||||
"""
|
||||
Get the name of the reaction chain policy.
|
||||
"""
|
||||
class CNOIChainPolicy(TemperatureDependentChainPolicy):
|
||||
def __eq__(self, other: ReactionChainPolicy) -> bool:
|
||||
"""
|
||||
Check equality with another ReactionChainPolicy.
|
||||
"""
|
||||
def __hash__(self) -> int:
|
||||
...
|
||||
def __init__(self) -> None:
|
||||
...
|
||||
def __ne__(self, other: ReactionChainPolicy) -> bool:
|
||||
"""
|
||||
Check inequality with another ReactionChainPolicy.
|
||||
"""
|
||||
def __repr__(self) -> str:
|
||||
...
|
||||
@typing.overload
|
||||
def contains(self, id: str) -> bool:
|
||||
"""
|
||||
Check if the reaction chain contains a reaction with the given ID.
|
||||
"""
|
||||
@typing.overload
|
||||
def contains(self, reaction: ...) -> bool:
|
||||
"""
|
||||
Check if the reaction chain contains the given reaction.
|
||||
"""
|
||||
def get_reactions(self) -> gridfire._gridfire.reaction.ReactionSet:
|
||||
"""
|
||||
Get the ReactionSet representing this reaction chain.
|
||||
"""
|
||||
def hash(self, seed: typing.SupportsInt) -> int:
|
||||
"""
|
||||
Compute a hash value for the reaction chain policy.
|
||||
"""
|
||||
@typing.overload
|
||||
def name(self) -> str:
|
||||
"""
|
||||
Get the name of the reaction chain policy.
|
||||
"""
|
||||
@typing.overload
|
||||
def name(self) -> str:
|
||||
"""
|
||||
Get the name of the reaction chain policy.
|
||||
"""
|
||||
class CNOIIChainPolicy(TemperatureDependentChainPolicy):
|
||||
def __eq__(self, other: ReactionChainPolicy) -> bool:
|
||||
"""
|
||||
Check equality with another ReactionChainPolicy.
|
||||
"""
|
||||
def __hash__(self) -> int:
|
||||
...
|
||||
def __init__(self) -> None:
|
||||
...
|
||||
def __ne__(self, other: ReactionChainPolicy) -> bool:
|
||||
"""
|
||||
Check inequality with another ReactionChainPolicy.
|
||||
"""
|
||||
def __repr__(self) -> str:
|
||||
...
|
||||
@typing.overload
|
||||
def contains(self, id: str) -> bool:
|
||||
"""
|
||||
Check if the reaction chain contains a reaction with the given ID.
|
||||
"""
|
||||
@typing.overload
|
||||
def contains(self, reaction: ...) -> bool:
|
||||
"""
|
||||
Check if the reaction chain contains the given reaction.
|
||||
"""
|
||||
def get_reactions(self) -> gridfire._gridfire.reaction.ReactionSet:
|
||||
"""
|
||||
Get the ReactionSet representing this reaction chain.
|
||||
"""
|
||||
def hash(self, seed: typing.SupportsInt) -> int:
|
||||
"""
|
||||
Compute a hash value for the reaction chain policy.
|
||||
"""
|
||||
@typing.overload
|
||||
def name(self) -> str:
|
||||
"""
|
||||
Get the name of the reaction chain policy.
|
||||
"""
|
||||
@typing.overload
|
||||
def name(self) -> str:
|
||||
"""
|
||||
Get the name of the reaction chain policy.
|
||||
"""
|
||||
class CNOIIIChainPolicy(TemperatureDependentChainPolicy):
|
||||
def __eq__(self, other: ReactionChainPolicy) -> bool:
|
||||
"""
|
||||
Check equality with another ReactionChainPolicy.
|
||||
"""
|
||||
def __hash__(self) -> int:
|
||||
...
|
||||
def __init__(self) -> None:
|
||||
...
|
||||
def __ne__(self, other: ReactionChainPolicy) -> bool:
|
||||
"""
|
||||
Check inequality with another ReactionChainPolicy.
|
||||
"""
|
||||
def __repr__(self) -> str:
|
||||
...
|
||||
@typing.overload
|
||||
def contains(self, id: str) -> bool:
|
||||
"""
|
||||
Check if the reaction chain contains a reaction with the given ID.
|
||||
"""
|
||||
@typing.overload
|
||||
def contains(self, reaction: ...) -> bool:
|
||||
"""
|
||||
Check if the reaction chain contains the given reaction.
|
||||
"""
|
||||
def get_reactions(self) -> gridfire._gridfire.reaction.ReactionSet:
|
||||
"""
|
||||
Get the ReactionSet representing this reaction chain.
|
||||
"""
|
||||
def hash(self, seed: typing.SupportsInt) -> int:
|
||||
"""
|
||||
Compute a hash value for the reaction chain policy.
|
||||
"""
|
||||
@typing.overload
|
||||
def name(self) -> str:
|
||||
"""
|
||||
Get the name of the reaction chain policy.
|
||||
"""
|
||||
@typing.overload
|
||||
def name(self) -> str:
|
||||
"""
|
||||
Get the name of the reaction chain policy.
|
||||
"""
|
||||
class CNOIVChainPolicy(TemperatureDependentChainPolicy):
|
||||
def __eq__(self, other: ReactionChainPolicy) -> bool:
|
||||
"""
|
||||
Check equality with another ReactionChainPolicy.
|
||||
"""
|
||||
def __hash__(self) -> int:
|
||||
...
|
||||
def __init__(self) -> None:
|
||||
...
|
||||
def __ne__(self, other: ReactionChainPolicy) -> bool:
|
||||
"""
|
||||
Check inequality with another ReactionChainPolicy.
|
||||
"""
|
||||
def __repr__(self) -> str:
|
||||
...
|
||||
@typing.overload
|
||||
def contains(self, id: str) -> bool:
|
||||
"""
|
||||
Check if the reaction chain contains a reaction with the given ID.
|
||||
"""
|
||||
@typing.overload
|
||||
def contains(self, reaction: ...) -> bool:
|
||||
"""
|
||||
Check if the reaction chain contains the given reaction.
|
||||
"""
|
||||
def get_reactions(self) -> gridfire._gridfire.reaction.ReactionSet:
|
||||
"""
|
||||
Get the ReactionSet representing this reaction chain.
|
||||
"""
|
||||
def hash(self, seed: typing.SupportsInt) -> int:
|
||||
"""
|
||||
Compute a hash value for the reaction chain policy.
|
||||
"""
|
||||
@typing.overload
|
||||
def name(self) -> str:
|
||||
"""
|
||||
Get the name of the reaction chain policy.
|
||||
"""
|
||||
@typing.overload
|
||||
def name(self) -> str:
|
||||
"""
|
||||
Get the name of the reaction chain policy.
|
||||
"""
|
||||
class ConstructionResults:
|
||||
@property
|
||||
def engine(self) -> gridfire._gridfire.engine.DynamicEngine:
|
||||
...
|
||||
@property
|
||||
def scratch_blob(self) -> gridfire._gridfire.engine.scratchpads.StateBlob:
|
||||
...
|
||||
class HotCNOChainPolicy(MultiReactionChainPolicy):
|
||||
def __eq__(self, other: ReactionChainPolicy) -> bool:
|
||||
"""
|
||||
Check equality with another ReactionChainPolicy.
|
||||
"""
|
||||
def __hash__(self) -> int:
|
||||
...
|
||||
def __init__(self) -> None:
|
||||
...
|
||||
def __ne__(self, other: ReactionChainPolicy) -> bool:
|
||||
"""
|
||||
Check inequality with another ReactionChainPolicy.
|
||||
"""
|
||||
def __repr__(self) -> str:
|
||||
...
|
||||
@typing.overload
|
||||
def contains(self, id: str) -> bool:
|
||||
"""
|
||||
Check if the reaction chain contains a reaction with the given ID.
|
||||
"""
|
||||
@typing.overload
|
||||
def contains(self, reaction: ...) -> bool:
|
||||
"""
|
||||
Check if the reaction chain contains the given reaction.
|
||||
"""
|
||||
def get_reactions(self) -> gridfire._gridfire.reaction.ReactionSet:
|
||||
"""
|
||||
Get the ReactionSet representing this reaction chain.
|
||||
"""
|
||||
def hash(self, seed: typing.SupportsInt) -> int:
|
||||
"""
|
||||
Compute a hash value for the reaction chain policy.
|
||||
"""
|
||||
@typing.overload
|
||||
def name(self) -> str:
|
||||
"""
|
||||
Get the name of the reaction chain policy.
|
||||
"""
|
||||
@typing.overload
|
||||
def name(self) -> str:
|
||||
"""
|
||||
Get the name of the reaction chain policy.
|
||||
"""
|
||||
class HotCNOIChainPolicy(TemperatureDependentChainPolicy):
|
||||
def __eq__(self, other: ReactionChainPolicy) -> bool:
|
||||
"""
|
||||
Check equality with another ReactionChainPolicy.
|
||||
"""
|
||||
def __hash__(self) -> int:
|
||||
...
|
||||
def __init__(self) -> None:
|
||||
...
|
||||
def __ne__(self, other: ReactionChainPolicy) -> bool:
|
||||
"""
|
||||
Check inequality with another ReactionChainPolicy.
|
||||
"""
|
||||
def __repr__(self) -> str:
|
||||
...
|
||||
@typing.overload
|
||||
def contains(self, id: str) -> bool:
|
||||
"""
|
||||
Check if the reaction chain contains a reaction with the given ID.
|
||||
"""
|
||||
@typing.overload
|
||||
def contains(self, reaction: ...) -> bool:
|
||||
"""
|
||||
Check if the reaction chain contains the given reaction.
|
||||
"""
|
||||
def get_reactions(self) -> gridfire._gridfire.reaction.ReactionSet:
|
||||
"""
|
||||
Get the ReactionSet representing this reaction chain.
|
||||
"""
|
||||
def hash(self, seed: typing.SupportsInt) -> int:
|
||||
"""
|
||||
Compute a hash value for the reaction chain policy.
|
||||
"""
|
||||
@typing.overload
|
||||
def name(self) -> str:
|
||||
"""
|
||||
Get the name of the reaction chain policy.
|
||||
"""
|
||||
@typing.overload
|
||||
def name(self) -> str:
|
||||
"""
|
||||
Get the name of the reaction chain policy.
|
||||
"""
|
||||
class HotCNOIIChainPolicy(TemperatureDependentChainPolicy):
|
||||
def __eq__(self, other: ReactionChainPolicy) -> bool:
|
||||
"""
|
||||
Check equality with another ReactionChainPolicy.
|
||||
"""
|
||||
def __hash__(self) -> int:
|
||||
...
|
||||
def __init__(self) -> None:
|
||||
...
|
||||
def __ne__(self, other: ReactionChainPolicy) -> bool:
|
||||
"""
|
||||
Check inequality with another ReactionChainPolicy.
|
||||
"""
|
||||
def __repr__(self) -> str:
|
||||
...
|
||||
@typing.overload
|
||||
def contains(self, id: str) -> bool:
|
||||
"""
|
||||
Check if the reaction chain contains a reaction with the given ID.
|
||||
"""
|
||||
@typing.overload
|
||||
def contains(self, reaction: ...) -> bool:
|
||||
"""
|
||||
Check if the reaction chain contains the given reaction.
|
||||
"""
|
||||
def get_reactions(self) -> gridfire._gridfire.reaction.ReactionSet:
|
||||
"""
|
||||
Get the ReactionSet representing this reaction chain.
|
||||
"""
|
||||
def hash(self, seed: typing.SupportsInt) -> int:
|
||||
"""
|
||||
Compute a hash value for the reaction chain policy.
|
||||
"""
|
||||
@typing.overload
|
||||
def name(self) -> str:
|
||||
"""
|
||||
Get the name of the reaction chain policy.
|
||||
"""
|
||||
@typing.overload
|
||||
def name(self) -> str:
|
||||
"""
|
||||
Get the name of the reaction chain policy.
|
||||
"""
|
||||
class HotCNOIIIChainPolicy(TemperatureDependentChainPolicy):
|
||||
def __eq__(self, other: ReactionChainPolicy) -> bool:
|
||||
"""
|
||||
Check equality with another ReactionChainPolicy.
|
||||
"""
|
||||
def __hash__(self) -> int:
|
||||
...
|
||||
def __init__(self) -> None:
|
||||
...
|
||||
def __ne__(self, other: ReactionChainPolicy) -> bool:
|
||||
"""
|
||||
Check inequality with another ReactionChainPolicy.
|
||||
"""
|
||||
def __repr__(self) -> str:
|
||||
...
|
||||
@typing.overload
|
||||
def contains(self, id: str) -> bool:
|
||||
"""
|
||||
Check if the reaction chain contains a reaction with the given ID.
|
||||
"""
|
||||
@typing.overload
|
||||
def contains(self, reaction: ...) -> bool:
|
||||
"""
|
||||
Check if the reaction chain contains the given reaction.
|
||||
"""
|
||||
def get_reactions(self) -> gridfire._gridfire.reaction.ReactionSet:
|
||||
"""
|
||||
Get the ReactionSet representing this reaction chain.
|
||||
"""
|
||||
def hash(self, seed: typing.SupportsInt) -> int:
|
||||
"""
|
||||
Compute a hash value for the reaction chain policy.
|
||||
"""
|
||||
@typing.overload
|
||||
def name(self) -> str:
|
||||
"""
|
||||
Get the name of the reaction chain policy.
|
||||
"""
|
||||
@typing.overload
|
||||
def name(self) -> str:
|
||||
"""
|
||||
Get the name of the reaction chain policy.
|
||||
"""
|
||||
class MainSequencePolicy(NetworkPolicy):
|
||||
@typing.overload
|
||||
def __init__(self, composition: fourdst._phys.composition.Composition) -> None:
|
||||
"""
|
||||
Construct MainSequencePolicy from an existing composition.
|
||||
"""
|
||||
@typing.overload
|
||||
def __init__(self, seed_species: collections.abc.Sequence[fourdst._phys.atomic.Species], mass_fractions: collections.abc.Sequence[typing.SupportsFloat]) -> None:
|
||||
"""
|
||||
Construct MainSequencePolicy from seed species and mass fractions.
|
||||
"""
|
||||
def construct(self) -> ConstructionResults:
|
||||
"""
|
||||
Construct the network according to the policy.
|
||||
"""
|
||||
def get_engine_stack(self) -> list[gridfire._gridfire.engine.DynamicEngine]:
|
||||
...
|
||||
def get_engine_types_stack(self) -> list[gridfire._gridfire.engine.EngineTypes]:
|
||||
"""
|
||||
Get the types of engines in the stack constructed by the network policy.
|
||||
"""
|
||||
def get_partition_function(self) -> gridfire._gridfire.partition.PartitionFunction:
|
||||
...
|
||||
def get_seed_reactions(self) -> gridfire._gridfire.reaction.ReactionSet:
|
||||
"""
|
||||
Get the set of seed reactions required by the network policy.
|
||||
"""
|
||||
def get_seed_species(self) -> set[fourdst._phys.atomic.Species]:
|
||||
"""
|
||||
Get the set of seed species required by the network policy.
|
||||
"""
|
||||
def get_stack_scratch_blob(self) -> gridfire._gridfire.engine.scratchpads.StateBlob:
|
||||
...
|
||||
def get_status(self) -> NetworkPolicyStatus:
|
||||
"""
|
||||
Get the current status of the network policy.
|
||||
"""
|
||||
def name(self) -> str:
|
||||
"""
|
||||
Get the name of the network policy.
|
||||
"""
|
||||
class MainSequenceReactionChainPolicy(MultiReactionChainPolicy):
|
||||
def __eq__(self, other: ReactionChainPolicy) -> bool:
|
||||
"""
|
||||
Check equality with another ReactionChainPolicy.
|
||||
"""
|
||||
def __hash__(self) -> int:
|
||||
...
|
||||
def __init__(self) -> None:
|
||||
...
|
||||
def __ne__(self, other: ReactionChainPolicy) -> bool:
|
||||
"""
|
||||
Check inequality with another ReactionChainPolicy.
|
||||
"""
|
||||
def __repr__(self) -> str:
|
||||
...
|
||||
@typing.overload
|
||||
def contains(self, id: str) -> bool:
|
||||
"""
|
||||
Check if the reaction chain contains a reaction with the given ID.
|
||||
"""
|
||||
@typing.overload
|
||||
def contains(self, reaction: ...) -> bool:
|
||||
"""
|
||||
Check if the reaction chain contains the given reaction.
|
||||
"""
|
||||
def get_reactions(self) -> gridfire._gridfire.reaction.ReactionSet:
|
||||
"""
|
||||
Get the ReactionSet representing this reaction chain.
|
||||
"""
|
||||
def hash(self, seed: typing.SupportsInt) -> int:
|
||||
"""
|
||||
Compute a hash value for the reaction chain policy.
|
||||
"""
|
||||
@typing.overload
|
||||
def name(self) -> str:
|
||||
"""
|
||||
Get the name of the reaction chain policy.
|
||||
"""
|
||||
@typing.overload
|
||||
def name(self) -> str:
|
||||
"""
|
||||
Get the name of the reaction chain policy.
|
||||
"""
|
||||
class MultiReactionChainPolicy(ReactionChainPolicy):
|
||||
pass
|
||||
class NetworkPolicy:
|
||||
pass
|
||||
class NetworkPolicyStatus:
|
||||
"""
|
||||
Members:
|
||||
|
||||
UNINITIALIZED
|
||||
|
||||
INITIALIZED_UNVERIFIED
|
||||
|
||||
MISSING_KEY_REACTION
|
||||
|
||||
MISSING_KEY_SPECIES
|
||||
|
||||
INITIALIZED_VERIFIED
|
||||
"""
|
||||
INITIALIZED_UNVERIFIED: typing.ClassVar[NetworkPolicyStatus] # value = <NetworkPolicyStatus.INITIALIZED_UNVERIFIED: 1>
|
||||
INITIALIZED_VERIFIED: typing.ClassVar[NetworkPolicyStatus] # value = <NetworkPolicyStatus.INITIALIZED_VERIFIED: 4>
|
||||
MISSING_KEY_REACTION: typing.ClassVar[NetworkPolicyStatus] # value = <NetworkPolicyStatus.MISSING_KEY_REACTION: 2>
|
||||
MISSING_KEY_SPECIES: typing.ClassVar[NetworkPolicyStatus] # value = <NetworkPolicyStatus.MISSING_KEY_SPECIES: 3>
|
||||
UNINITIALIZED: typing.ClassVar[NetworkPolicyStatus] # value = <NetworkPolicyStatus.UNINITIALIZED: 0>
|
||||
__members__: typing.ClassVar[dict[str, NetworkPolicyStatus]] # value = {'UNINITIALIZED': <NetworkPolicyStatus.UNINITIALIZED: 0>, 'INITIALIZED_UNVERIFIED': <NetworkPolicyStatus.INITIALIZED_UNVERIFIED: 1>, 'MISSING_KEY_REACTION': <NetworkPolicyStatus.MISSING_KEY_REACTION: 2>, 'MISSING_KEY_SPECIES': <NetworkPolicyStatus.MISSING_KEY_SPECIES: 3>, 'INITIALIZED_VERIFIED': <NetworkPolicyStatus.INITIALIZED_VERIFIED: 4>}
|
||||
def __eq__(self, other: typing.Any) -> bool:
|
||||
...
|
||||
def __getstate__(self) -> int:
|
||||
...
|
||||
def __hash__(self) -> int:
|
||||
...
|
||||
def __index__(self) -> int:
|
||||
...
|
||||
def __init__(self, value: typing.SupportsInt) -> None:
|
||||
...
|
||||
def __int__(self) -> int:
|
||||
...
|
||||
def __ne__(self, other: typing.Any) -> bool:
|
||||
...
|
||||
def __repr__(self) -> str:
|
||||
...
|
||||
def __setstate__(self, state: typing.SupportsInt) -> None:
|
||||
...
|
||||
def __str__(self) -> str:
|
||||
...
|
||||
@property
|
||||
def name(self) -> str:
|
||||
...
|
||||
@property
|
||||
def value(self) -> int:
|
||||
...
|
||||
class ProtonProtonChainPolicy(MultiReactionChainPolicy):
|
||||
def __eq__(self, other: ReactionChainPolicy) -> bool:
|
||||
"""
|
||||
Check equality with another ReactionChainPolicy.
|
||||
"""
|
||||
def __hash__(self) -> int:
|
||||
...
|
||||
def __init__(self) -> None:
|
||||
...
|
||||
def __ne__(self, other: ReactionChainPolicy) -> bool:
|
||||
"""
|
||||
Check inequality with another ReactionChainPolicy.
|
||||
"""
|
||||
def __repr__(self) -> str:
|
||||
...
|
||||
@typing.overload
|
||||
def contains(self, id: str) -> bool:
|
||||
"""
|
||||
Check if the reaction chain contains a reaction with the given ID.
|
||||
"""
|
||||
@typing.overload
|
||||
def contains(self, reaction: ...) -> bool:
|
||||
"""
|
||||
Check if the reaction chain contains the given reaction.
|
||||
"""
|
||||
def get_reactions(self) -> gridfire._gridfire.reaction.ReactionSet:
|
||||
"""
|
||||
Get the ReactionSet representing this reaction chain.
|
||||
"""
|
||||
def hash(self, seed: typing.SupportsInt) -> int:
|
||||
"""
|
||||
Compute a hash value for the reaction chain policy.
|
||||
"""
|
||||
@typing.overload
|
||||
def name(self) -> str:
|
||||
"""
|
||||
Get the name of the reaction chain policy.
|
||||
"""
|
||||
@typing.overload
|
||||
def name(self) -> str:
|
||||
"""
|
||||
Get the name of the reaction chain policy.
|
||||
"""
|
||||
class ProtonProtonIChainPolicy(TemperatureDependentChainPolicy):
|
||||
def __eq__(self, other: ReactionChainPolicy) -> bool:
|
||||
"""
|
||||
Check equality with another ReactionChainPolicy.
|
||||
"""
|
||||
def __hash__(self) -> int:
|
||||
...
|
||||
def __init__(self) -> None:
|
||||
...
|
||||
def __ne__(self, other: ReactionChainPolicy) -> bool:
|
||||
"""
|
||||
Check inequality with another ReactionChainPolicy.
|
||||
"""
|
||||
def __repr__(self) -> str:
|
||||
...
|
||||
@typing.overload
|
||||
def contains(self, id: str) -> bool:
|
||||
"""
|
||||
Check if the reaction chain contains a reaction with the given ID.
|
||||
"""
|
||||
@typing.overload
|
||||
def contains(self, reaction: ...) -> bool:
|
||||
"""
|
||||
Check if the reaction chain contains the given reaction.
|
||||
"""
|
||||
def get_reactions(self) -> gridfire._gridfire.reaction.ReactionSet:
|
||||
"""
|
||||
Get the ReactionSet representing this reaction chain.
|
||||
"""
|
||||
def hash(self, seed: typing.SupportsInt) -> int:
|
||||
"""
|
||||
Compute a hash value for the reaction chain policy.
|
||||
"""
|
||||
@typing.overload
|
||||
def name(self) -> str:
|
||||
"""
|
||||
Get the name of the reaction chain policy.
|
||||
"""
|
||||
@typing.overload
|
||||
def name(self) -> str:
|
||||
"""
|
||||
Get the name of the reaction chain policy.
|
||||
"""
|
||||
class ProtonProtonIIChainPolicy(TemperatureDependentChainPolicy):
|
||||
def __eq__(self, other: ReactionChainPolicy) -> bool:
|
||||
"""
|
||||
Check equality with another ReactionChainPolicy.
|
||||
"""
|
||||
def __hash__(self) -> int:
|
||||
...
|
||||
def __init__(self) -> None:
|
||||
...
|
||||
def __ne__(self, other: ReactionChainPolicy) -> bool:
|
||||
"""
|
||||
Check inequality with another ReactionChainPolicy.
|
||||
"""
|
||||
def __repr__(self) -> str:
|
||||
...
|
||||
@typing.overload
|
||||
def contains(self, id: str) -> bool:
|
||||
"""
|
||||
Check if the reaction chain contains a reaction with the given ID.
|
||||
"""
|
||||
@typing.overload
|
||||
def contains(self, reaction: ...) -> bool:
|
||||
"""
|
||||
Check if the reaction chain contains the given reaction.
|
||||
"""
|
||||
def get_reactions(self) -> gridfire._gridfire.reaction.ReactionSet:
|
||||
"""
|
||||
Get the ReactionSet representing this reaction chain.
|
||||
"""
|
||||
def hash(self, seed: typing.SupportsInt) -> int:
|
||||
"""
|
||||
Compute a hash value for the reaction chain policy.
|
||||
"""
|
||||
@typing.overload
|
||||
def name(self) -> str:
|
||||
"""
|
||||
Get the name of the reaction chain policy.
|
||||
"""
|
||||
@typing.overload
|
||||
def name(self) -> str:
|
||||
"""
|
||||
Get the name of the reaction chain policy.
|
||||
"""
|
||||
class ProtonProtonIIIChainPolicy(TemperatureDependentChainPolicy):
|
||||
def __eq__(self, other: ReactionChainPolicy) -> bool:
|
||||
"""
|
||||
Check equality with another ReactionChainPolicy.
|
||||
"""
|
||||
def __hash__(self) -> int:
|
||||
...
|
||||
def __init__(self) -> None:
|
||||
...
|
||||
def __ne__(self, other: ReactionChainPolicy) -> bool:
|
||||
"""
|
||||
Check inequality with another ReactionChainPolicy.
|
||||
"""
|
||||
def __repr__(self) -> str:
|
||||
...
|
||||
@typing.overload
|
||||
def contains(self, id: str) -> bool:
|
||||
"""
|
||||
Check if the reaction chain contains a reaction with the given ID.
|
||||
"""
|
||||
@typing.overload
|
||||
def contains(self, reaction: ...) -> bool:
|
||||
"""
|
||||
Check if the reaction chain contains the given reaction.
|
||||
"""
|
||||
def get_reactions(self) -> gridfire._gridfire.reaction.ReactionSet:
|
||||
"""
|
||||
Get the ReactionSet representing this reaction chain.
|
||||
"""
|
||||
def hash(self, seed: typing.SupportsInt) -> int:
|
||||
"""
|
||||
Compute a hash value for the reaction chain policy.
|
||||
"""
|
||||
@typing.overload
|
||||
def name(self) -> str:
|
||||
"""
|
||||
Get the name of the reaction chain policy.
|
||||
"""
|
||||
@typing.overload
|
||||
def name(self) -> str:
|
||||
"""
|
||||
Get the name of the reaction chain policy.
|
||||
"""
|
||||
class ReactionChainPolicy:
|
||||
pass
|
||||
class TemperatureDependentChainPolicy(ReactionChainPolicy):
|
||||
pass
|
||||
class TripleAlphaChainPolicy(TemperatureDependentChainPolicy):
|
||||
def __eq__(self, other: ReactionChainPolicy) -> bool:
|
||||
"""
|
||||
Check equality with another ReactionChainPolicy.
|
||||
"""
|
||||
def __hash__(self) -> int:
|
||||
...
|
||||
def __init__(self) -> None:
|
||||
...
|
||||
def __ne__(self, other: ReactionChainPolicy) -> bool:
|
||||
"""
|
||||
Check inequality with another ReactionChainPolicy.
|
||||
"""
|
||||
def __repr__(self) -> str:
|
||||
...
|
||||
@typing.overload
|
||||
def contains(self, id: str) -> bool:
|
||||
"""
|
||||
Check if the reaction chain contains a reaction with the given ID.
|
||||
"""
|
||||
@typing.overload
|
||||
def contains(self, reaction: ...) -> bool:
|
||||
"""
|
||||
Check if the reaction chain contains the given reaction.
|
||||
"""
|
||||
def get_reactions(self) -> gridfire._gridfire.reaction.ReactionSet:
|
||||
"""
|
||||
Get the ReactionSet representing this reaction chain.
|
||||
"""
|
||||
def hash(self, seed: typing.SupportsInt) -> int:
|
||||
"""
|
||||
Compute a hash value for the reaction chain policy.
|
||||
"""
|
||||
@typing.overload
|
||||
def name(self) -> str:
|
||||
"""
|
||||
Get the name of the reaction chain policy.
|
||||
"""
|
||||
@typing.overload
|
||||
def name(self) -> str:
|
||||
"""
|
||||
Get the name of the reaction chain policy.
|
||||
"""
|
||||
def network_policy_status_to_string(status: NetworkPolicyStatus) -> str:
|
||||
"""
|
||||
Convert a NetworkPolicyStatus enum value to its string representation.
|
||||
"""
|
||||
INITIALIZED_UNVERIFIED: NetworkPolicyStatus # value = <NetworkPolicyStatus.INITIALIZED_UNVERIFIED: 1>
|
||||
INITIALIZED_VERIFIED: NetworkPolicyStatus # value = <NetworkPolicyStatus.INITIALIZED_VERIFIED: 4>
|
||||
MISSING_KEY_REACTION: NetworkPolicyStatus # value = <NetworkPolicyStatus.MISSING_KEY_REACTION: 2>
|
||||
MISSING_KEY_SPECIES: NetworkPolicyStatus # value = <NetworkPolicyStatus.MISSING_KEY_SPECIES: 3>
|
||||
UNINITIALIZED: NetworkPolicyStatus # value = <NetworkPolicyStatus.UNINITIALIZED: 0>
|
||||
@@ -1,249 +0,0 @@
|
||||
"""
|
||||
GridFire reaction bindings
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import collections.abc
|
||||
import fourdst._phys.atomic
|
||||
import fourdst._phys.composition
|
||||
import typing
|
||||
__all__: list[str] = ['LogicalReaclibReaction', 'RateCoefficientSet', 'ReaclibReaction', 'ReactionSet', 'get_all_reactions', 'packReactionSet']
|
||||
class LogicalReaclibReaction(ReaclibReaction):
|
||||
@typing.overload
|
||||
def __init__(self, reactions: collections.abc.Sequence[ReaclibReaction]) -> None:
|
||||
"""
|
||||
Construct a LogicalReaclibReaction from a vector of ReaclibReaction objects.
|
||||
"""
|
||||
@typing.overload
|
||||
def __init__(self, reactions: collections.abc.Sequence[ReaclibReaction], is_reverse: bool) -> None:
|
||||
"""
|
||||
Construct a LogicalReaclibReaction from a vector of ReaclibReaction objects.
|
||||
"""
|
||||
def __len__(self) -> int:
|
||||
"""
|
||||
Overload len() to return the number of source rates.
|
||||
"""
|
||||
def add_reaction(self, reaction: ReaclibReaction) -> None:
|
||||
"""
|
||||
Add another Reaction source to this logical reaction.
|
||||
"""
|
||||
def calculate_forward_rate_log_derivative(self, T9: typing.SupportsFloat, rho: typing.SupportsFloat, Ye: typing.SupportsFloat, mue: typing.SupportsFloat, Composition: fourdst._phys.composition.Composition) -> float:
|
||||
"""
|
||||
Calculate the forward rate log derivative at a given temperature T9 (in units of 10^9 K).
|
||||
"""
|
||||
def calculate_rate(self, T9: typing.SupportsFloat, rho: typing.SupportsFloat, Ye: typing.SupportsFloat, mue: typing.SupportsFloat, Y: collections.abc.Sequence[typing.SupportsFloat], index_to_species_map: collections.abc.Mapping[typing.SupportsInt, fourdst._phys.atomic.Species]) -> float:
|
||||
"""
|
||||
Calculate the reaction rate at a given temperature T9 (in units of 10^9 K). Note that for a reaclib reaction only T9 is actually used, all other parameters are there for interface compatibility.
|
||||
"""
|
||||
def size(self) -> int:
|
||||
"""
|
||||
Get the number of source rates contributing to this logical reaction.
|
||||
"""
|
||||
def sources(self) -> list[str]:
|
||||
"""
|
||||
Get the list of source labels for the aggregated rates.
|
||||
"""
|
||||
class RateCoefficientSet:
|
||||
def __init__(self, a0: typing.SupportsFloat, a1: typing.SupportsFloat, a2: typing.SupportsFloat, a3: typing.SupportsFloat, a4: typing.SupportsFloat, a5: typing.SupportsFloat, a6: typing.SupportsFloat) -> None:
|
||||
"""
|
||||
Construct a RateCoefficientSet with the given parameters.
|
||||
"""
|
||||
class ReaclibReaction:
|
||||
__hash__: typing.ClassVar[None] = None
|
||||
def __eq__(self, arg0: ReaclibReaction) -> bool:
|
||||
"""
|
||||
Equality operator for reactions based on their IDs.
|
||||
"""
|
||||
def __init__(self, id: str, peName: str, chapter: typing.SupportsInt, reactants: collections.abc.Sequence[fourdst._phys.atomic.Species], products: collections.abc.Sequence[fourdst._phys.atomic.Species], qValue: typing.SupportsFloat, label: str, sets: RateCoefficientSet, reverse: bool = False) -> None:
|
||||
"""
|
||||
Construct a Reaction with the given parameters.
|
||||
"""
|
||||
def __neq__(self, arg0: ReaclibReaction) -> bool:
|
||||
"""
|
||||
Inequality operator for reactions based on their IDs.
|
||||
"""
|
||||
def __repr__(self) -> str:
|
||||
...
|
||||
def all_species(self) -> set[fourdst._phys.atomic.Species]:
|
||||
"""
|
||||
Get all species involved in the reaction (both reactants and products) as a set.
|
||||
"""
|
||||
def calculate_rate(self, T9: typing.SupportsFloat, rho: typing.SupportsFloat, Y: collections.abc.Sequence[typing.SupportsFloat]) -> float:
|
||||
"""
|
||||
Calculate the reaction rate at a given temperature T9 (in units of 10^9 K).
|
||||
"""
|
||||
def chapter(self) -> int:
|
||||
"""
|
||||
Get the REACLIB chapter number defining the reaction structure.
|
||||
"""
|
||||
def contains(self, species: fourdst._phys.atomic.Species) -> bool:
|
||||
"""
|
||||
Check if the reaction contains a specific species.
|
||||
"""
|
||||
def contains_product(self, arg0: fourdst._phys.atomic.Species) -> bool:
|
||||
"""
|
||||
Check if the reaction contains a specific product species.
|
||||
"""
|
||||
def contains_reactant(self, arg0: fourdst._phys.atomic.Species) -> bool:
|
||||
"""
|
||||
Check if the reaction contains a specific reactant species.
|
||||
"""
|
||||
def excess_energy(self) -> float:
|
||||
"""
|
||||
Calculate the excess energy from the mass difference of reactants and products.
|
||||
"""
|
||||
def hash(self, seed: typing.SupportsInt = 0) -> int:
|
||||
"""
|
||||
Compute a hash for the reaction based on its ID.
|
||||
"""
|
||||
def id(self) -> str:
|
||||
"""
|
||||
Get the unique identifier of the reaction.
|
||||
"""
|
||||
def is_reverse(self) -> bool:
|
||||
"""
|
||||
Check if this is a reverse reaction rate.
|
||||
"""
|
||||
def num_species(self) -> int:
|
||||
"""
|
||||
Count the number of species in the reaction.
|
||||
"""
|
||||
def peName(self) -> str:
|
||||
"""
|
||||
Get the reaction name in (projectile, ejectile) notation (e.g., 'p(p,g)d').
|
||||
"""
|
||||
def product_species(self) -> set[fourdst._phys.atomic.Species]:
|
||||
"""
|
||||
Get the product species of the reaction as a set.
|
||||
"""
|
||||
def products(self) -> list[fourdst._phys.atomic.Species]:
|
||||
"""
|
||||
Get a list of product species in the reaction.
|
||||
"""
|
||||
def qValue(self) -> float:
|
||||
"""
|
||||
Get the Q-value of the reaction in MeV.
|
||||
"""
|
||||
def rateCoefficients(self) -> RateCoefficientSet:
|
||||
"""
|
||||
get the set of rate coefficients.
|
||||
"""
|
||||
def reactant_species(self) -> set[fourdst._phys.atomic.Species]:
|
||||
"""
|
||||
Get the reactant species of the reaction as a set.
|
||||
"""
|
||||
def reactants(self) -> list[fourdst._phys.atomic.Species]:
|
||||
"""
|
||||
Get a list of reactant species in the reaction.
|
||||
"""
|
||||
def sourceLabel(self) -> str:
|
||||
"""
|
||||
Get the source label for the rate data (e.g., 'wc12w', 'st08').
|
||||
"""
|
||||
@typing.overload
|
||||
def stoichiometry(self, species: fourdst._phys.atomic.Species) -> int:
|
||||
"""
|
||||
Get the stoichiometry of the reaction as a map from species to their coefficients.
|
||||
"""
|
||||
@typing.overload
|
||||
def stoichiometry(self) -> dict[fourdst._phys.atomic.Species, int]:
|
||||
"""
|
||||
Get the stoichiometry of the reaction as a map from species to their coefficients.
|
||||
"""
|
||||
class ReactionSet:
|
||||
__hash__: typing.ClassVar[None] = None
|
||||
@staticmethod
|
||||
def from_clones(reactions: collections.abc.Sequence[...]) -> ReactionSet:
|
||||
"""
|
||||
Create a ReactionSet that takes ownership of the reactions by cloning the input reactions.
|
||||
"""
|
||||
def __eq__(self, LogicalReactionSet: ReactionSet) -> bool:
|
||||
"""
|
||||
Equality operator for LogicalReactionSets based on their contents.
|
||||
"""
|
||||
def __getitem__(self, index: typing.SupportsInt) -> ...:
|
||||
"""
|
||||
Get a LogicalReaclibReaction by index.
|
||||
"""
|
||||
def __getitem___(self, id: str) -> ...:
|
||||
"""
|
||||
Get a LogicalReaclibReaction by its ID.
|
||||
"""
|
||||
@typing.overload
|
||||
def __init__(self, reactions: collections.abc.Sequence[...]) -> None:
|
||||
"""
|
||||
Construct a LogicalReactionSet from a vector of LogicalReaclibReaction objects.
|
||||
"""
|
||||
@typing.overload
|
||||
def __init__(self) -> None:
|
||||
"""
|
||||
Default constructor for an empty LogicalReactionSet.
|
||||
"""
|
||||
@typing.overload
|
||||
def __init__(self, other: ReactionSet) -> None:
|
||||
"""
|
||||
Copy constructor for LogicalReactionSet.
|
||||
"""
|
||||
def __len__(self) -> int:
|
||||
"""
|
||||
Overload len() to return the number of LogicalReactions.
|
||||
"""
|
||||
def __ne__(self, LogicalReactionSet: ReactionSet) -> bool:
|
||||
"""
|
||||
Inequality operator for LogicalReactionSets based on their contents.
|
||||
"""
|
||||
def __repr__(self) -> str:
|
||||
...
|
||||
def add_reaction(self, reaction: ...) -> None:
|
||||
"""
|
||||
Add a LogicalReaclibReaction to the set.
|
||||
"""
|
||||
def clear(self) -> None:
|
||||
"""
|
||||
Remove all LogicalReactions from the set.
|
||||
"""
|
||||
@typing.overload
|
||||
def contains(self, id: str) -> bool:
|
||||
"""
|
||||
Check if the set contains a specific LogicalReaclibReaction.
|
||||
"""
|
||||
@typing.overload
|
||||
def contains(self, reaction: ...) -> bool:
|
||||
"""
|
||||
Check if the set contains a specific Reaction.
|
||||
"""
|
||||
def contains_product(self, species: fourdst._phys.atomic.Species) -> bool:
|
||||
"""
|
||||
Check if any reaction in the set has the species as a product.
|
||||
"""
|
||||
def contains_reactant(self, species: fourdst._phys.atomic.Species) -> bool:
|
||||
"""
|
||||
Check if any reaction in the set has the species as a reactant.
|
||||
"""
|
||||
def contains_species(self, species: fourdst._phys.atomic.Species) -> bool:
|
||||
"""
|
||||
Check if any reaction in the set involves the given species.
|
||||
"""
|
||||
def getReactionSetSpecies(self) -> set[fourdst._phys.atomic.Species]:
|
||||
"""
|
||||
Get all species involved in the reactions of the set as a set of Species objects.
|
||||
"""
|
||||
def hash(self, seed: typing.SupportsInt = 0) -> int:
|
||||
"""
|
||||
Compute a hash for the LogicalReactionSet based on its contents.
|
||||
"""
|
||||
def remove_reaction(self, reaction: ...) -> None:
|
||||
"""
|
||||
Remove a LogicalReaclibReaction from the set.
|
||||
"""
|
||||
def size(self) -> int:
|
||||
"""
|
||||
Get the number of LogicalReactions in the set.
|
||||
"""
|
||||
def get_all_reactions() -> ReactionSet:
|
||||
"""
|
||||
Get all reactions from the REACLIB database.
|
||||
"""
|
||||
def packReactionSet(reactionSet: ReactionSet) -> ReactionSet:
|
||||
"""
|
||||
Convert a ReactionSet to a LogicalReactionSet by aggregating reactions with the same peName.
|
||||
"""
|
||||
@@ -1,68 +0,0 @@
|
||||
"""
|
||||
GridFire plasma screening bindings
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import collections.abc
|
||||
import fourdst._phys.atomic
|
||||
import gridfire._gridfire.reaction
|
||||
import typing
|
||||
__all__: list[str] = ['BARE', 'BareScreeningModel', 'ScreeningModel', 'ScreeningType', 'WEAK', 'WeakScreeningModel', 'selectScreeningModel']
|
||||
class BareScreeningModel:
|
||||
def __init__(self) -> None:
|
||||
...
|
||||
def calculateScreeningFactors(self, reactions: gridfire._gridfire.reaction.ReactionSet, species: collections.abc.Sequence[fourdst._phys.atomic.Species], Y: collections.abc.Sequence[typing.SupportsFloat], T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> list[float]:
|
||||
"""
|
||||
Calculate the bare plasma screening factors. This always returns 1.0 (bare)
|
||||
"""
|
||||
class ScreeningModel:
|
||||
pass
|
||||
class ScreeningType:
|
||||
"""
|
||||
Members:
|
||||
|
||||
BARE
|
||||
|
||||
WEAK
|
||||
"""
|
||||
BARE: typing.ClassVar[ScreeningType] # value = <ScreeningType.BARE: 0>
|
||||
WEAK: typing.ClassVar[ScreeningType] # value = <ScreeningType.WEAK: 1>
|
||||
__members__: typing.ClassVar[dict[str, ScreeningType]] # value = {'BARE': <ScreeningType.BARE: 0>, 'WEAK': <ScreeningType.WEAK: 1>}
|
||||
def __eq__(self, other: typing.Any) -> bool:
|
||||
...
|
||||
def __getstate__(self) -> int:
|
||||
...
|
||||
def __hash__(self) -> int:
|
||||
...
|
||||
def __index__(self) -> int:
|
||||
...
|
||||
def __init__(self, value: typing.SupportsInt) -> None:
|
||||
...
|
||||
def __int__(self) -> int:
|
||||
...
|
||||
def __ne__(self, other: typing.Any) -> bool:
|
||||
...
|
||||
def __repr__(self) -> str:
|
||||
...
|
||||
def __setstate__(self, state: typing.SupportsInt) -> None:
|
||||
...
|
||||
def __str__(self) -> str:
|
||||
...
|
||||
@property
|
||||
def name(self) -> str:
|
||||
...
|
||||
@property
|
||||
def value(self) -> int:
|
||||
...
|
||||
class WeakScreeningModel:
|
||||
def __init__(self) -> None:
|
||||
...
|
||||
def calculateScreeningFactors(self, reactions: gridfire._gridfire.reaction.ReactionSet, species: collections.abc.Sequence[fourdst._phys.atomic.Species], Y: collections.abc.Sequence[typing.SupportsFloat], T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> list[float]:
|
||||
"""
|
||||
Calculate the weak plasma screening factors using the Salpeter (1954) model.
|
||||
"""
|
||||
def selectScreeningModel(type: ScreeningType) -> ScreeningModel:
|
||||
"""
|
||||
Select a screening model based on the specified type. Returns a pointer to the selected model.
|
||||
"""
|
||||
BARE: ScreeningType # value = <ScreeningType.BARE: 0>
|
||||
WEAK: ScreeningType # value = <ScreeningType.WEAK: 1>
|
||||
@@ -1,157 +0,0 @@
|
||||
"""
|
||||
GridFire numerical solver bindings
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import collections.abc
|
||||
import fourdst._phys.atomic
|
||||
import gridfire._gridfire.engine
|
||||
import gridfire._gridfire.engine.scratchpads
|
||||
import gridfire._gridfire.type
|
||||
import types
|
||||
import typing
|
||||
__all__: list[str] = ['GridSolver', 'GridSolverContext', 'MultiZoneDynamicNetworkSolver', 'PointSolver', 'PointSolverContext', 'PointSolverTimestepContext', 'SingleZoneDynamicNetworkSolver', 'SolverContextBase']
|
||||
class GridSolver(MultiZoneDynamicNetworkSolver):
|
||||
def __init__(self, engine: gridfire._gridfire.engine.DynamicEngine, solver: SingleZoneDynamicNetworkSolver) -> None:
|
||||
"""
|
||||
Initialize the GridSolver object.
|
||||
"""
|
||||
def evaluate(self, solver_ctx: SolverContextBase, netIns: collections.abc.Sequence[gridfire._gridfire.type.NetIn]) -> list[gridfire._gridfire.type.NetOut]:
|
||||
"""
|
||||
evaluate the dynamic engine using the dynamic engine class
|
||||
"""
|
||||
class GridSolverContext(SolverContextBase):
|
||||
detailed_logging: bool
|
||||
stdout_logging: bool
|
||||
zone_completion_logging: bool
|
||||
def __init__(self, ctx_template: gridfire._gridfire.engine.scratchpads.StateBlob) -> None:
|
||||
...
|
||||
@typing.overload
|
||||
def clear_callback(self) -> None:
|
||||
...
|
||||
@typing.overload
|
||||
def clear_callback(self, zone_idx: typing.SupportsInt) -> None:
|
||||
...
|
||||
def init(self) -> None:
|
||||
...
|
||||
def reset(self) -> None:
|
||||
...
|
||||
@typing.overload
|
||||
def set_callback(self, callback: collections.abc.Callable[[...], None]) -> None:
|
||||
...
|
||||
@typing.overload
|
||||
def set_callback(self, callback: collections.abc.Callable[[...], None], zone_idx: typing.SupportsInt) -> None:
|
||||
...
|
||||
class MultiZoneDynamicNetworkSolver:
|
||||
def evaluate(self, solver_ctx: SolverContextBase, netIns: collections.abc.Sequence[gridfire._gridfire.type.NetIn]) -> list[gridfire._gridfire.type.NetOut]:
|
||||
"""
|
||||
evaluate the dynamic engine using the dynamic engine class for multiple zones (using openmp if available)
|
||||
"""
|
||||
class PointSolver(SingleZoneDynamicNetworkSolver):
|
||||
def __init__(self, engine: gridfire._gridfire.engine.DynamicEngine) -> None:
|
||||
"""
|
||||
Initialize the PointSolver object.
|
||||
"""
|
||||
def evaluate(self, solver_ctx: SolverContextBase, netIn: gridfire._gridfire.type.NetIn, display_trigger: bool = False, force_reinitialization: bool = False) -> gridfire._gridfire.type.NetOut:
|
||||
"""
|
||||
evaluate the dynamic engine using the dynamic engine class
|
||||
"""
|
||||
class PointSolverContext:
|
||||
callback: collections.abc.Callable[[PointSolverTimestepContext], None] | None
|
||||
detailed_logging: bool
|
||||
stdout_logging: bool
|
||||
def __init__(self, engine_ctx: gridfire._gridfire.engine.scratchpads.StateBlob) -> None:
|
||||
...
|
||||
def clear_context(self) -> None:
|
||||
...
|
||||
def has_context(self) -> bool:
|
||||
...
|
||||
def init(self) -> None:
|
||||
...
|
||||
def init_context(self) -> None:
|
||||
...
|
||||
def reset_all(self) -> None:
|
||||
...
|
||||
def reset_cvode(self) -> None:
|
||||
...
|
||||
def reset_user(self) -> None:
|
||||
...
|
||||
@property
|
||||
def J(self) -> _generic_SUNMatrix:
|
||||
...
|
||||
@property
|
||||
def LS(self) -> _generic_SUNLinearSolver:
|
||||
...
|
||||
@property
|
||||
def Y(self) -> _generic_N_Vector:
|
||||
...
|
||||
@property
|
||||
def YErr(self) -> _generic_N_Vector:
|
||||
...
|
||||
@property
|
||||
def abs_tol(self) -> float:
|
||||
...
|
||||
@abs_tol.setter
|
||||
def abs_tol(self, arg1: typing.SupportsFloat) -> None:
|
||||
...
|
||||
@property
|
||||
def cvode_mem(self) -> types.CapsuleType:
|
||||
...
|
||||
@property
|
||||
def engine_ctx(self) -> gridfire._gridfire.engine.scratchpads.StateBlob:
|
||||
...
|
||||
@property
|
||||
def num_steps(self) -> int:
|
||||
...
|
||||
@property
|
||||
def rel_tol(self) -> float:
|
||||
...
|
||||
@rel_tol.setter
|
||||
def rel_tol(self, arg1: typing.SupportsFloat) -> None:
|
||||
...
|
||||
@property
|
||||
def sun_ctx(self) -> SUNContext_:
|
||||
...
|
||||
class PointSolverTimestepContext:
|
||||
@property
|
||||
def T9(self) -> float:
|
||||
...
|
||||
@property
|
||||
def currentConvergenceFailures(self) -> int:
|
||||
...
|
||||
@property
|
||||
def currentNonlinearIterations(self) -> int:
|
||||
...
|
||||
@property
|
||||
def dt(self) -> float:
|
||||
...
|
||||
@property
|
||||
def engine(self) -> gridfire._gridfire.engine.DynamicEngine:
|
||||
...
|
||||
@property
|
||||
def last_step_time(self) -> float:
|
||||
...
|
||||
@property
|
||||
def networkSpecies(self) -> list[fourdst._phys.atomic.Species]:
|
||||
...
|
||||
@property
|
||||
def num_steps(self) -> int:
|
||||
...
|
||||
@property
|
||||
def rho(self) -> float:
|
||||
...
|
||||
@property
|
||||
def state(self) -> list[float]:
|
||||
...
|
||||
@property
|
||||
def state_ctx(self) -> gridfire._gridfire.engine.scratchpads.StateBlob:
|
||||
...
|
||||
@property
|
||||
def t(self) -> float:
|
||||
...
|
||||
class SingleZoneDynamicNetworkSolver:
|
||||
def evaluate(self, solver_ctx: SolverContextBase, netIn: gridfire._gridfire.type.NetIn) -> gridfire._gridfire.type.NetOut:
|
||||
"""
|
||||
evaluate the dynamic engine using the dynamic engine class for a single zone
|
||||
"""
|
||||
class SolverContextBase:
|
||||
pass
|
||||
@@ -1,67 +0,0 @@
|
||||
"""
|
||||
GridFire type bindings
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import fourdst._phys.composition
|
||||
import typing
|
||||
__all__: list[str] = ['NetIn', 'NetOut']
|
||||
class NetIn:
|
||||
composition: fourdst._phys.composition.Composition
|
||||
def __init__(self) -> None:
|
||||
...
|
||||
def __repr__(self) -> str:
|
||||
...
|
||||
@property
|
||||
def density(self) -> float:
|
||||
...
|
||||
@density.setter
|
||||
def density(self, arg0: typing.SupportsFloat) -> None:
|
||||
...
|
||||
@property
|
||||
def dt0(self) -> float:
|
||||
...
|
||||
@dt0.setter
|
||||
def dt0(self, arg0: typing.SupportsFloat) -> None:
|
||||
...
|
||||
@property
|
||||
def energy(self) -> float:
|
||||
...
|
||||
@energy.setter
|
||||
def energy(self, arg0: typing.SupportsFloat) -> None:
|
||||
...
|
||||
@property
|
||||
def tMax(self) -> float:
|
||||
...
|
||||
@tMax.setter
|
||||
def tMax(self, arg0: typing.SupportsFloat) -> None:
|
||||
...
|
||||
@property
|
||||
def temperature(self) -> float:
|
||||
...
|
||||
@temperature.setter
|
||||
def temperature(self, arg0: typing.SupportsFloat) -> None:
|
||||
...
|
||||
class NetOut:
|
||||
def __repr__(self) -> str:
|
||||
...
|
||||
@property
|
||||
def composition(self) -> fourdst._phys.composition.Composition:
|
||||
...
|
||||
@property
|
||||
def dEps_dRho(self) -> float:
|
||||
...
|
||||
@property
|
||||
def dEps_dT(self) -> float:
|
||||
...
|
||||
@property
|
||||
def energy(self) -> float:
|
||||
...
|
||||
@property
|
||||
def num_steps(self) -> int:
|
||||
...
|
||||
@property
|
||||
def specific_neutrino_energy_loss(self) -> float:
|
||||
...
|
||||
@property
|
||||
def specific_neutrino_flux(self) -> float:
|
||||
...
|
||||
@@ -1,18 +0,0 @@
|
||||
"""
|
||||
GridFire utility method bindings
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import fourdst._phys.composition
|
||||
import gridfire._gridfire.engine
|
||||
import gridfire._gridfire.engine.scratchpads
|
||||
import typing
|
||||
from . import hashing
|
||||
__all__: list[str] = ['formatNuclearTimescaleLogString', 'hash_atomic', 'hash_reaction', 'hashing']
|
||||
def formatNuclearTimescaleLogString(ctx: gridfire._gridfire.engine.scratchpads.StateBlob, engine: gridfire._gridfire.engine.DynamicEngine, Y: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> str:
|
||||
"""
|
||||
Format a string for logging nuclear timescales based on temperature, density, and energy generation rate.
|
||||
"""
|
||||
def hash_atomic(a: typing.SupportsInt, z: typing.SupportsInt) -> int:
|
||||
...
|
||||
def hash_reaction(reaction: ...) -> int:
|
||||
...
|
||||
@@ -1,6 +0,0 @@
|
||||
"""
|
||||
module for gridfire hashing functions
|
||||
"""
|
||||
from __future__ import annotations
|
||||
from . import reaction
|
||||
__all__: list[str] = ['reaction']
|
||||
@@ -1,12 +0,0 @@
|
||||
"""
|
||||
utility module for hashing gridfire reaction functions
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import typing
|
||||
__all__: list[str] = ['mix_species', 'multiset_combine', 'splitmix64']
|
||||
def mix_species(a: typing.SupportsInt, z: typing.SupportsInt) -> int:
|
||||
...
|
||||
def multiset_combine(acc: typing.SupportsInt, x: typing.SupportsInt) -> int:
|
||||
...
|
||||
def splitmix64(x: typing.SupportsInt) -> int:
|
||||
...
|
||||
80
tests/python/logger.py
Normal file
80
tests/python/logger.py
Normal file
@@ -0,0 +1,80 @@
|
||||
from enum import Enum
|
||||
|
||||
from typing import Dict, List, Any, SupportsFloat
|
||||
import json
|
||||
from datetime import datetime
|
||||
import os
|
||||
import sys
|
||||
|
||||
from gridfire.solver import PointSolverTimestepContext
|
||||
from gridfire._gridfire.engine.scratchpads import StateBlob
|
||||
import gridfire
|
||||
|
||||
class LogEntries(Enum):
|
||||
Step = "Step"
|
||||
t = "t"
|
||||
dt = "dt"
|
||||
eps = "eps"
|
||||
Composition = "Composition"
|
||||
ReactionContributions = "ReactionContributions"
|
||||
|
||||
|
||||
class StepLogger:
|
||||
def __init__(self):
|
||||
self.num_steps : int = 0
|
||||
self.steps : List[Dict[LogEntries, Any]] = []
|
||||
|
||||
def log_step(self, ctx: PointSolverTimestepContext):
|
||||
comp_data: Dict[str, SupportsFloat] = {}
|
||||
for species in ctx.engine.getNetworkSpecies(ctx.state_ctx):
|
||||
sid = ctx.engine.getSpeciesIndex(ctx.state_ctx, species)
|
||||
comp_data[species.name()] = ctx.state[sid]
|
||||
entry : Dict[LogEntries, Any] = {
|
||||
LogEntries.Step: ctx.num_steps,
|
||||
LogEntries.t: ctx.t,
|
||||
LogEntries.dt: ctx.dt,
|
||||
LogEntries.eps: ctx.state[-1],
|
||||
LogEntries.Composition: comp_data,
|
||||
}
|
||||
self.steps.append(entry)
|
||||
self.num_steps += 1
|
||||
|
||||
def to_json(self, filename: str, **kwargs):
|
||||
serializable_steps : List[Dict[str, Any]] = [
|
||||
{
|
||||
LogEntries.Step.value: step[LogEntries.Step],
|
||||
LogEntries.t.value: step[LogEntries.t],
|
||||
LogEntries.dt.value: step[LogEntries.dt],
|
||||
LogEntries.eps.value: step[LogEntries.eps],
|
||||
LogEntries.Composition.value: step[LogEntries.Composition],
|
||||
}
|
||||
for step in self.steps
|
||||
]
|
||||
out_data : Dict[str, Any] = {
|
||||
"Metadata": {
|
||||
"NumSteps": self.num_steps,
|
||||
**kwargs,
|
||||
"DateCreated": datetime.now().isoformat(),
|
||||
"GridFireVersion": gridfire.__version__,
|
||||
"Author": "Emily M. Boudreaux",
|
||||
"OS": os.uname().sysname,
|
||||
"ClangVersion": os.popen("clang --version").read().strip(),
|
||||
"GccVersion": os.popen("gcc --version").read().strip(),
|
||||
"PythonVersion": sys.version,
|
||||
},
|
||||
"Steps": serializable_steps
|
||||
}
|
||||
with open(filename, 'w') as f:
|
||||
json.dump(out_data, f, indent=4)
|
||||
|
||||
|
||||
def summary(self) -> Dict[str, Any]:
|
||||
if not self.steps:
|
||||
return {}
|
||||
final_step = self.steps[-1]
|
||||
summary_data : Dict[str, Any] = {
|
||||
"TotalSteps": self.num_steps,
|
||||
"FinalTime": final_step[LogEntries.t],
|
||||
"FinalComposition": final_step[LogEntries.Composition],
|
||||
}
|
||||
return summary_data
|
||||
343
validation/ManuscriptFigures/BBQCompare/bbq_compare.py
Normal file
343
validation/ManuscriptFigures/BBQCompare/bbq_compare.py
Normal file
@@ -0,0 +1,343 @@
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
from IPython.core.pylabtools import figsize
|
||||
from gridfire.solver import PointSolver, PointSolverContext
|
||||
from gridfire.policy import MainSequencePolicy
|
||||
|
||||
from gridfire.engine import GraphEngine, MultiscalePartitioningEngineView, AdaptiveEngineView
|
||||
from gridfire.engine import NetworkBuildDepth
|
||||
|
||||
from scipy.signal import find_peaks
|
||||
|
||||
from gridfire.config import GridFireConfig
|
||||
|
||||
from fourdst.composition import Composition
|
||||
from scipy.integrate import trapezoid
|
||||
|
||||
from fourdst.composition import CanonicalComposition
|
||||
from fourdst.atomic import Species
|
||||
from gridfire.type import NetIn, NetOut
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
|
||||
## Note that my default style uses tex rendering. If you do not have tex installed
|
||||
## simply comment out this line
|
||||
plt.style.use("../utils/pub.mplstyle")
|
||||
|
||||
from scipy.interpolate import interp1d, CubicSpline
|
||||
|
||||
from enum import Enum
|
||||
|
||||
import sys
|
||||
import os
|
||||
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "../utils")))
|
||||
|
||||
from logger import StepLogger
|
||||
|
||||
class ShowSave(Enum):
|
||||
SHOW="SHOW"
|
||||
SAVE="SAVE"
|
||||
|
||||
def __str__(self):
|
||||
return self.value
|
||||
|
||||
def rescale_composition(comp_ref : Composition, ZZs : float, Y_primordial : float = 0.248) -> Composition:
|
||||
CC : CanonicalComposition = comp_ref.getCanonicalComposition()
|
||||
|
||||
dY_dZ = (CC.Y - Y_primordial) / CC.Z
|
||||
|
||||
Z_new = CC.Z * (10**ZZs)
|
||||
Y_bulk_new = Y_primordial + (dY_dZ * Z_new)
|
||||
X_new = 1.0 - Z_new - Y_bulk_new
|
||||
|
||||
if X_new < 0: raise ValueError(f"ZZs={ZZs} yields unphysical composition (X < 0)")
|
||||
|
||||
ratio_H = X_new / CC.X if CC.X > 0 else 0
|
||||
ratio_He = Y_bulk_new / CC.Y if CC.Y > 0 else 0
|
||||
ratio_Z = Z_new / CC.Z if CC.Z > 0 else 0
|
||||
|
||||
Y_new_list = []
|
||||
newComp : Composition = Composition()
|
||||
s: Species
|
||||
for s in comp_ref.getRegisteredSpecies():
|
||||
Xi_ref = comp_ref.getMassFraction(s)
|
||||
|
||||
if s.el() == "H":
|
||||
Xi_new = Xi_ref * ratio_H
|
||||
elif s.el() == "He":
|
||||
Xi_new = Xi_ref * ratio_He
|
||||
else:
|
||||
Xi_new = Xi_ref * ratio_Z
|
||||
|
||||
Y = Xi_new / s.mass()
|
||||
newComp.registerSpecies(s)
|
||||
newComp.setMolarAbundance(s, Y)
|
||||
|
||||
return newComp
|
||||
|
||||
def init_composition(ZZs : float = 0) -> Composition:
|
||||
Y_solar = [7.0262E-01, 1.7479E-06, 6.8955E-02, 2.5000E-04, 7.8554E-05, 6.0144E-04, 8.1031E-05, 2.1513E-05]
|
||||
S = ["H-1", "He-3", "He-4", "C-12", "N-14", "O-16", "Ne-20", "Mg-24"]
|
||||
return rescale_composition(Composition(S, Y_solar), ZZs)
|
||||
|
||||
|
||||
def init_netIn(temp: float, rho: float, time: float, comp: Composition) -> NetIn:
|
||||
n : NetIn = NetIn()
|
||||
n.temperature = temp
|
||||
n.density = rho
|
||||
n.tMax = time
|
||||
n.dt0 = 1e-12
|
||||
n.composition = comp
|
||||
return n
|
||||
|
||||
def years_to_seconds(years: float) -> float:
|
||||
return years * 3.1536e7
|
||||
|
||||
def quantify_engine_error(df_base, df_approx, r_base: NetOut, r_approx: NetOut, species_list, floor_val=1e-30):
|
||||
temporal_results = {}
|
||||
final_state_results = {}
|
||||
|
||||
t_base = df_base['t'].values
|
||||
|
||||
tracking_cols = ['eps'] + species_list
|
||||
|
||||
for col in tracking_cols:
|
||||
if col not in df_base.columns or col not in df_approx.columns:
|
||||
continue
|
||||
|
||||
y_base = df_base[col].values
|
||||
|
||||
interpolator = interp1d(
|
||||
df_approx['t'],
|
||||
df_approx[col],
|
||||
kind='linear',
|
||||
bounds_error=False,
|
||||
fill_value=(df_approx[col].iloc[0], df_approx[col].iloc[-1])
|
||||
)
|
||||
|
||||
y_approx_interp = interpolator(t_base)
|
||||
|
||||
abs_diff = np.abs(y_approx_interp - y_base)
|
||||
|
||||
rel_diff = abs_diff / np.maximum(np.abs(y_base), floor_val)
|
||||
|
||||
l2_diff = np.sqrt(trapezoid(abs_diff**2, x=t_base))
|
||||
l2_base = np.sqrt(trapezoid(y_base**2, x=t_base))
|
||||
|
||||
temporal_results[col] = {
|
||||
'Max Rel Error (Temporal)': np.max(rel_diff),
|
||||
'L2 Rel Error (Temporal)': l2_diff / max(l2_base, floor_val)
|
||||
}
|
||||
def calc_rel_err(val_approx, val_base):
|
||||
return abs(val_approx - val_base) / max(abs(val_base), floor_val)
|
||||
|
||||
final_state_results['Energy'] = {
|
||||
'Final Rel Error': calc_rel_err(r_approx.energy, r_base.energy)
|
||||
}
|
||||
|
||||
final_state_results['Neutrino Loss'] = {
|
||||
'Final Rel Error': calc_rel_err(r_approx.specific_neutrino_energy_loss, r_base.specific_neutrino_energy_loss)
|
||||
}
|
||||
|
||||
for sp in species_list:
|
||||
try:
|
||||
val_base = r_base.composition[sp]
|
||||
val_approx = r_approx.composition[sp]
|
||||
final_state_results[f"Final {sp}"] = {
|
||||
'Final Rel Error': calc_rel_err(val_approx, val_base)
|
||||
}
|
||||
except (KeyError, TypeError, AttributeError):
|
||||
pass
|
||||
|
||||
return pd.DataFrame(temporal_results).T, pd.DataFrame(final_state_results).T
|
||||
|
||||
def main(save_show):
|
||||
C = init_composition()
|
||||
netIn = init_netIn(1.5e7, 1.6e2, years_to_seconds(10e9), C)
|
||||
|
||||
|
||||
stepLogger = StepLogger()
|
||||
|
||||
engine_graph = GraphEngine(C, 4)
|
||||
|
||||
solver_ctx_graph = PointSolverContext(engine_graph.constructStateBlob())
|
||||
solver_ctx_graph.stdout_logging = True
|
||||
solver_ctx_graph.callback = lambda ctx: stepLogger.log_step(ctx)
|
||||
|
||||
solver_single = PointSolver(engine_graph)
|
||||
|
||||
r_graph = solver_single.evaluate(solver_ctx_graph, netIn, False, False)
|
||||
df_graph : pd.DataFrame = stepLogger.df
|
||||
stepLogger.reset()
|
||||
|
||||
QSE_engine = MultiscalePartitioningEngineView(engine_graph)
|
||||
solver_ctx_graph_qse = PointSolverContext(QSE_engine.constructStateBlob(engine_graph.constructStateBlob()))
|
||||
solver_ctx_graph_qse.stdout_logging = True
|
||||
solver_ctx_graph_qse.callback = lambda ctx: stepLogger.log_step(ctx)
|
||||
|
||||
solver_QSE = PointSolver(QSE_engine)
|
||||
r_qse = solver_QSE.evaluate(solver_ctx_graph_qse, netIn, False, False)
|
||||
|
||||
df_qse = stepLogger.df
|
||||
stepLogger.reset()
|
||||
|
||||
# policy = MainSequencePolicy(C)
|
||||
# construct = policy.construct()
|
||||
# solver_AE_QSE = PointSolver(construct.engine)
|
||||
# solver_ctx_graph_qse_ae = PointSolverContext(construct.scratch_blob)
|
||||
# solver_ctx_graph_qse_ae.callback = lambda ctx: stepLogger.log_step(ctx)
|
||||
# solver_ctx_graph_qse_ae.stdout_logging = False
|
||||
#
|
||||
# r_ae_qse = solver_AE_QSE.evaluate(solver_ctx_graph_qse_ae, netIn, False, False)
|
||||
#
|
||||
# df_ae_qse = stepLogger.df
|
||||
# stepLogger.reset()
|
||||
|
||||
# fig, axs = plt.subplots(2, 1, figsize=(10, 7))
|
||||
S = ["H-1", "He-4", "C-12", "N-14", "O-16", "Mg-24"]
|
||||
t = np.logspace(7, 17.5, 5000)
|
||||
# for spID, sp in enumerate(S):
|
||||
# gf = interp1d(df_graph.t, df_graph[sp])
|
||||
# qf = interp1d(df_qse.t, df_qse[sp])
|
||||
#
|
||||
# ax = axs[0]
|
||||
# ax.loglog(t, gf(t), 'o-', color=f"C{spID}")
|
||||
# ax.loglog(t, qf(t), 'o', color=f"C{spID}", linestyle='dashed')
|
||||
#
|
||||
# ax.text(1, df_graph[sp].iloc[0]*1.1, sp, fontsize=12, color=f"C{spID}")
|
||||
#
|
||||
# ax = axs[1]
|
||||
# ax.semilogx(t, (qf(t)-gf(t))/gf(t), color=f"C{spID}")
|
||||
#
|
||||
# axs[1].set_xlabel("Time [s]", fontsize=15)
|
||||
# axs[0].set_ylabel("Molar Abundance [mol/g]", fontsize=15)
|
||||
# axs[1].set_ylabel("Relative Error", fontsize=15)
|
||||
#
|
||||
# fig, ax = plt.subplots(1, 1, figsize=(10, 7))
|
||||
# ge = interp1d(df_graph.t, df_graph.eps)
|
||||
# qe = interp1d(df_qse.t, df_qse.eps)
|
||||
# ax.loglog(t, np.abs((qe(t) - ge(t)) / ge(t)))
|
||||
|
||||
temporal_err_qse, final_err_qse = quantify_engine_error(
|
||||
df_base=df_graph,
|
||||
df_approx=df_qse,
|
||||
r_base=r_graph,
|
||||
r_approx=r_qse,
|
||||
species_list=S
|
||||
)
|
||||
|
||||
qse_rel_eps_error = (df_graph.eps.iloc[-1] - df_qse.eps.iloc[-1])/df_qse.eps.iloc[-1]
|
||||
|
||||
|
||||
fig, ax = plt.subplots(1, 1, figsize=(10, 7))
|
||||
# ax.semilogx(df_graph.t, df_graph["H-2"], 'o-', color='red')
|
||||
# ax.semilogx(df_qse.t, df_qse["H-2"], 'o', color='blue', linestyle='dashed')
|
||||
|
||||
graph_h1 = interp1d(df_graph.t, df_graph["H-1"])
|
||||
qse_h1 = interp1d(df_qse.t, df_qse["H-1"])
|
||||
graph_h2 = interp1d(df_graph.t, df_graph["H-2"])
|
||||
qse_h2 = interp1d(df_qse.t, df_qse["H-2"])
|
||||
|
||||
graph_DH = graph_h2(t)/graph_h1(t)
|
||||
qse_DH = qse_h2(t)/qse_h1(t)
|
||||
|
||||
dex_diff = np.abs(np.log10(graph_h2(t)) - np.log10(qse_h2(t)))
|
||||
dex_dh_diff = np.abs(np.log10(graph_DH) - np.log10(qse_DH))
|
||||
# ax.semilogx(t, dex_diff, color='green')
|
||||
ax.loglog(t, dex_dh_diff, color='black')
|
||||
# ax.semilogx(t, qse_h2(t)/qse_h1(t), color='green')
|
||||
ax.set_xlabel("Time [s]", fontsize=17)
|
||||
ax.set_ylabel(r"$\left|\log_{10}\left(\frac{D}{H})\right)_{graph} - \log_{10}\left(\frac{D}{H}\right)_{qse}\right|$", fontsize=17)
|
||||
|
||||
if save_show == ShowSave.SAVE:
|
||||
plt.savefig("DHErr.pdf")
|
||||
plt.close()
|
||||
else:
|
||||
plt.show()
|
||||
|
||||
sums_qse = {}
|
||||
sums_graph = {}
|
||||
symbols = {}
|
||||
|
||||
for sp, y in r_qse.composition:
|
||||
z = sp.z()
|
||||
symbols[z] = sp.el()
|
||||
|
||||
y_graph = r_graph.composition.getMolarAbundance(sp)
|
||||
|
||||
sums_qse[int(z)] = sums_qse.get(z, 0.0) + y
|
||||
sums_graph[int(z)] = sums_graph.get(z, 0.0) + y_graph
|
||||
|
||||
print(sums_qse[3])
|
||||
print(sums_graph[3])
|
||||
|
||||
z_list = sorted(sums_qse.keys())
|
||||
dex_list = []
|
||||
|
||||
symbols = [val for key, val in symbols.items()]
|
||||
|
||||
for z in z_list:
|
||||
total_qse = sums_qse[z]
|
||||
total_graph = sums_graph[z]
|
||||
|
||||
if total_graph > 1e-13 and total_qse > 1e-13:
|
||||
offset = np.log10(total_qse / total_graph)
|
||||
else:
|
||||
if z >= 14:
|
||||
offset = np.nan # Disable these for visualization, they all have abundances so small (on the order of -100 it doesnt matter)
|
||||
else:
|
||||
offset = 0.0
|
||||
|
||||
dex_list.append(offset)
|
||||
fig, ax = plt.subplots(1, 1, figsize=(10, 7))
|
||||
data = sorted(zip(z_list, symbols, dex_list), key=lambda x: x[0])
|
||||
sorted_z, sorted_symbols, sorted_dex = zip(*data)
|
||||
print(sorted_symbols)
|
||||
print(sorted_dex)
|
||||
# 2. Create the plot
|
||||
fig, ax = plt.subplots(1, 1, figsize=(12, 6))
|
||||
print(sorted_symbols)
|
||||
bars = ax.bar(sorted_symbols, sorted_dex, color='grey', edgecolor='grey', alpha=0.8)
|
||||
|
||||
# 3. Add styling and labels
|
||||
ax.axhline(0, color='black', linewidth=0.8) # Adds a clear baseline at 0 dex
|
||||
ax.set_xlabel('Element', fontsize=25)
|
||||
ax.set_ylabel('Offset [dex]', fontsize=25)
|
||||
|
||||
if save_show == ShowSave.SAVE:
|
||||
plt.savefig("DexElementalOffset.pdf")
|
||||
plt.close()
|
||||
|
||||
|
||||
e_graph = interp1d(df_graph.t, df_graph.eps)
|
||||
e_qse = interp1d(df_qse.t, df_qse.eps)
|
||||
|
||||
dex_eps_diff = np.log10(e_graph(t)) - np.log10(e_qse(t))
|
||||
fig, ax = plt.subplots(1, 1, figsize=(10, 7))
|
||||
ax.semilogx(t, dex_eps_diff, color='black')
|
||||
ax.set_xlabel("Time [s]", fontsize=25)
|
||||
ax.set_xlabel("Offset [dex]", fontsize=25)
|
||||
|
||||
if save_show == ShowSave.SAVE:
|
||||
plt.savefig("DexEpsOffset.pdf")
|
||||
plt.close()
|
||||
|
||||
|
||||
if save_show == ShowSave.SHOW:
|
||||
plt.show()
|
||||
|
||||
print("=== QSE ===")
|
||||
print(temporal_err_qse)
|
||||
print(final_err_qse)
|
||||
print(f"Relative ε error: {qse_rel_eps_error}")
|
||||
|
||||
print(f"Neutrino Loss Difference [dex]: {np.log10(r_graph.specific_neutrino_energy_loss) - np.log10(r_qse.specific_neutrino_energy_loss)}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
import argparse
|
||||
app = argparse.ArgumentParser(prog="Derivative Smoothness", description="Generate of view plots of derivative smoothness")
|
||||
app.add_argument("-s", type=ShowSave, default=ShowSave.SHOW, choices=list(ShowSave), help="Whether to show or save the generated plot")
|
||||
|
||||
args = app.parse_args()
|
||||
main(args.s)
|
||||
343
validation/ManuscriptFigures/ErrorBudget/error_budget.py
Normal file
343
validation/ManuscriptFigures/ErrorBudget/error_budget.py
Normal file
@@ -0,0 +1,343 @@
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
from IPython.core.pylabtools import figsize
|
||||
from gridfire.solver import PointSolver, PointSolverContext
|
||||
from gridfire.policy import MainSequencePolicy
|
||||
|
||||
from gridfire.engine import GraphEngine, MultiscalePartitioningEngineView, AdaptiveEngineView
|
||||
from gridfire.engine import NetworkBuildDepth
|
||||
|
||||
from scipy.signal import find_peaks
|
||||
|
||||
from gridfire.config import GridFireConfig
|
||||
|
||||
from fourdst.composition import Composition
|
||||
from scipy.integrate import trapezoid
|
||||
|
||||
from fourdst.composition import CanonicalComposition
|
||||
from fourdst.atomic import Species
|
||||
from gridfire.type import NetIn, NetOut
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
|
||||
## Note that my default style uses tex rendering. If you do not have tex installed
|
||||
## simply comment out this line
|
||||
plt.style.use("../utils/pub.mplstyle")
|
||||
|
||||
from scipy.interpolate import interp1d, CubicSpline
|
||||
|
||||
from enum import Enum
|
||||
|
||||
import sys
|
||||
import os
|
||||
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "../utils")))
|
||||
|
||||
from logger import StepLogger
|
||||
|
||||
class ShowSave(Enum):
|
||||
SHOW="SHOW"
|
||||
SAVE="SAVE"
|
||||
|
||||
def __str__(self):
|
||||
return self.value
|
||||
|
||||
def rescale_composition(comp_ref : Composition, ZZs : float, Y_primordial : float = 0.248) -> Composition:
|
||||
CC : CanonicalComposition = comp_ref.getCanonicalComposition()
|
||||
|
||||
dY_dZ = (CC.Y - Y_primordial) / CC.Z
|
||||
|
||||
Z_new = CC.Z * (10**ZZs)
|
||||
Y_bulk_new = Y_primordial + (dY_dZ * Z_new)
|
||||
X_new = 1.0 - Z_new - Y_bulk_new
|
||||
|
||||
if X_new < 0: raise ValueError(f"ZZs={ZZs} yields unphysical composition (X < 0)")
|
||||
|
||||
ratio_H = X_new / CC.X if CC.X > 0 else 0
|
||||
ratio_He = Y_bulk_new / CC.Y if CC.Y > 0 else 0
|
||||
ratio_Z = Z_new / CC.Z if CC.Z > 0 else 0
|
||||
|
||||
Y_new_list = []
|
||||
newComp : Composition = Composition()
|
||||
s: Species
|
||||
for s in comp_ref.getRegisteredSpecies():
|
||||
Xi_ref = comp_ref.getMassFraction(s)
|
||||
|
||||
if s.el() == "H":
|
||||
Xi_new = Xi_ref * ratio_H
|
||||
elif s.el() == "He":
|
||||
Xi_new = Xi_ref * ratio_He
|
||||
else:
|
||||
Xi_new = Xi_ref * ratio_Z
|
||||
|
||||
Y = Xi_new / s.mass()
|
||||
newComp.registerSpecies(s)
|
||||
newComp.setMolarAbundance(s, Y)
|
||||
|
||||
return newComp
|
||||
|
||||
def init_composition(ZZs : float = 0) -> Composition:
|
||||
Y_solar = [7.0262E-01, 1.7479E-06, 6.8955E-02, 2.5000E-04, 7.8554E-05, 6.0144E-04, 8.1031E-05, 2.1513E-05]
|
||||
S = ["H-1", "He-3", "He-4", "C-12", "N-14", "O-16", "Ne-20", "Mg-24"]
|
||||
return rescale_composition(Composition(S, Y_solar), ZZs)
|
||||
|
||||
|
||||
def init_netIn(temp: float, rho: float, time: float, comp: Composition) -> NetIn:
|
||||
n : NetIn = NetIn()
|
||||
n.temperature = temp
|
||||
n.density = rho
|
||||
n.tMax = time
|
||||
n.dt0 = 1e-12
|
||||
n.composition = comp
|
||||
return n
|
||||
|
||||
def years_to_seconds(years: float) -> float:
|
||||
return years * 3.1536e7
|
||||
|
||||
def quantify_engine_error(df_base, df_approx, r_base: NetOut, r_approx: NetOut, species_list, floor_val=1e-30):
|
||||
temporal_results = {}
|
||||
final_state_results = {}
|
||||
|
||||
t_base = df_base['t'].values
|
||||
|
||||
tracking_cols = ['eps'] + species_list
|
||||
|
||||
for col in tracking_cols:
|
||||
if col not in df_base.columns or col not in df_approx.columns:
|
||||
continue
|
||||
|
||||
y_base = df_base[col].values
|
||||
|
||||
interpolator = interp1d(
|
||||
df_approx['t'],
|
||||
df_approx[col],
|
||||
kind='linear',
|
||||
bounds_error=False,
|
||||
fill_value=(df_approx[col].iloc[0], df_approx[col].iloc[-1])
|
||||
)
|
||||
|
||||
y_approx_interp = interpolator(t_base)
|
||||
|
||||
abs_diff = np.abs(y_approx_interp - y_base)
|
||||
|
||||
rel_diff = abs_diff / np.maximum(np.abs(y_base), floor_val)
|
||||
|
||||
l2_diff = np.sqrt(trapezoid(abs_diff**2, x=t_base))
|
||||
l2_base = np.sqrt(trapezoid(y_base**2, x=t_base))
|
||||
|
||||
temporal_results[col] = {
|
||||
'Max Rel Error (Temporal)': np.max(rel_diff),
|
||||
'L2 Rel Error (Temporal)': l2_diff / max(l2_base, floor_val)
|
||||
}
|
||||
def calc_rel_err(val_approx, val_base):
|
||||
return abs(val_approx - val_base) / max(abs(val_base), floor_val)
|
||||
|
||||
final_state_results['Energy'] = {
|
||||
'Final Rel Error': calc_rel_err(r_approx.energy, r_base.energy)
|
||||
}
|
||||
|
||||
final_state_results['Neutrino Loss'] = {
|
||||
'Final Rel Error': calc_rel_err(r_approx.specific_neutrino_energy_loss, r_base.specific_neutrino_energy_loss)
|
||||
}
|
||||
|
||||
for sp in species_list:
|
||||
try:
|
||||
val_base = r_base.composition[sp]
|
||||
val_approx = r_approx.composition[sp]
|
||||
final_state_results[f"Final {sp}"] = {
|
||||
'Final Rel Error': calc_rel_err(val_approx, val_base)
|
||||
}
|
||||
except (KeyError, TypeError, AttributeError):
|
||||
pass
|
||||
|
||||
return pd.DataFrame(temporal_results).T, pd.DataFrame(final_state_results).T
|
||||
|
||||
def main(save_show):
|
||||
C = init_composition()
|
||||
netIn = init_netIn(1.5e7, 1.6e2, years_to_seconds(10e9), C)
|
||||
|
||||
|
||||
stepLogger = StepLogger()
|
||||
|
||||
engine_graph = GraphEngine(C, 4)
|
||||
|
||||
solver_ctx_graph = PointSolverContext(engine_graph.constructStateBlob())
|
||||
solver_ctx_graph.stdout_logging = True
|
||||
solver_ctx_graph.callback = lambda ctx: stepLogger.log_step(ctx)
|
||||
|
||||
solver_single = PointSolver(engine_graph)
|
||||
|
||||
r_graph = solver_single.evaluate(solver_ctx_graph, netIn, False, False)
|
||||
df_graph = stepLogger.df
|
||||
stepLogger.reset()
|
||||
|
||||
QSE_engine = MultiscalePartitioningEngineView(engine_graph)
|
||||
solver_ctx_graph_qse = PointSolverContext(QSE_engine.constructStateBlob(engine_graph.constructStateBlob()))
|
||||
solver_ctx_graph_qse.stdout_logging = True
|
||||
solver_ctx_graph_qse.callback = lambda ctx: stepLogger.log_step(ctx)
|
||||
|
||||
solver_QSE = PointSolver(QSE_engine)
|
||||
r_qse = solver_QSE.evaluate(solver_ctx_graph_qse, netIn, False, False)
|
||||
|
||||
df_qse = stepLogger.df
|
||||
stepLogger.reset()
|
||||
|
||||
# policy = MainSequencePolicy(C)
|
||||
# construct = policy.construct()
|
||||
# solver_AE_QSE = PointSolver(construct.engine)
|
||||
# solver_ctx_graph_qse_ae = PointSolverContext(construct.scratch_blob)
|
||||
# solver_ctx_graph_qse_ae.callback = lambda ctx: stepLogger.log_step(ctx)
|
||||
# solver_ctx_graph_qse_ae.stdout_logging = False
|
||||
#
|
||||
# r_ae_qse = solver_AE_QSE.evaluate(solver_ctx_graph_qse_ae, netIn, False, False)
|
||||
#
|
||||
# df_ae_qse = stepLogger.df
|
||||
# stepLogger.reset()
|
||||
|
||||
# fig, axs = plt.subplots(2, 1, figsize=(10, 7))
|
||||
S = ["H-1", "He-4", "C-12", "N-14", "O-16", "Mg-24"]
|
||||
t = np.logspace(7, 17.5, 5000)
|
||||
# for spID, sp in enumerate(S):
|
||||
# gf = interp1d(df_graph.t, df_graph[sp])
|
||||
# qf = interp1d(df_qse.t, df_qse[sp])
|
||||
#
|
||||
# ax = axs[0]
|
||||
# ax.loglog(t, gf(t), 'o-', color=f"C{spID}")
|
||||
# ax.loglog(t, qf(t), 'o', color=f"C{spID}", linestyle='dashed')
|
||||
#
|
||||
# ax.text(1, df_graph[sp].iloc[0]*1.1, sp, fontsize=12, color=f"C{spID}")
|
||||
#
|
||||
# ax = axs[1]
|
||||
# ax.semilogx(t, (qf(t)-gf(t))/gf(t), color=f"C{spID}")
|
||||
#
|
||||
# axs[1].set_xlabel("Time [s]", fontsize=15)
|
||||
# axs[0].set_ylabel("Molar Abundance [mol/g]", fontsize=15)
|
||||
# axs[1].set_ylabel("Relative Error", fontsize=15)
|
||||
#
|
||||
# fig, ax = plt.subplots(1, 1, figsize=(10, 7))
|
||||
# ge = interp1d(df_graph.t, df_graph.eps)
|
||||
# qe = interp1d(df_qse.t, df_qse.eps)
|
||||
# ax.loglog(t, np.abs((qe(t) - ge(t)) / ge(t)))
|
||||
|
||||
temporal_err_qse, final_err_qse = quantify_engine_error(
|
||||
df_base=df_graph,
|
||||
df_approx=df_qse,
|
||||
r_base=r_graph,
|
||||
r_approx=r_qse,
|
||||
species_list=S
|
||||
)
|
||||
|
||||
qse_rel_eps_error = (df_graph.eps.iloc[-1] - df_qse.eps.iloc[-1])/df_qse.eps.iloc[-1]
|
||||
|
||||
|
||||
fig, ax = plt.subplots(1, 1, figsize=(10, 7))
|
||||
# ax.semilogx(df_graph.t, df_graph["H-2"], 'o-', color='red')
|
||||
# ax.semilogx(df_qse.t, df_qse["H-2"], 'o', color='blue', linestyle='dashed')
|
||||
|
||||
graph_h1 = interp1d(df_graph.t, df_graph["H-1"])
|
||||
qse_h1 = interp1d(df_qse.t, df_qse["H-1"])
|
||||
graph_h2 = interp1d(df_graph.t, df_graph["H-2"])
|
||||
qse_h2 = interp1d(df_qse.t, df_qse["H-2"])
|
||||
|
||||
graph_DH = graph_h2(t)/graph_h1(t)
|
||||
qse_DH = qse_h2(t)/qse_h1(t)
|
||||
|
||||
dex_diff = np.abs(np.log10(graph_h2(t)) - np.log10(qse_h2(t)))
|
||||
dex_dh_diff = np.abs(np.log10(graph_DH) - np.log10(qse_DH))
|
||||
# ax.semilogx(t, dex_diff, color='green')
|
||||
ax.loglog(t, dex_dh_diff, color='black')
|
||||
# ax.semilogx(t, qse_h2(t)/qse_h1(t), color='green')
|
||||
ax.set_xlabel("Time [s]", fontsize=17)
|
||||
ax.set_ylabel(r"$\left|\log_{10}\left(\frac{D}{H})\right)_{graph} - \log_{10}\left(\frac{D}{H}\right)_{qse}\right|$", fontsize=17)
|
||||
|
||||
if save_show == ShowSave.SAVE:
|
||||
plt.savefig("DHErr.pdf")
|
||||
plt.close()
|
||||
else:
|
||||
plt.show()
|
||||
|
||||
sums_qse = {}
|
||||
sums_graph = {}
|
||||
symbols = {}
|
||||
|
||||
for sp, y in r_qse.composition:
|
||||
z = sp.z()
|
||||
symbols[z] = sp.el()
|
||||
|
||||
y_graph = r_graph.composition.getMolarAbundance(sp)
|
||||
|
||||
sums_qse[int(z)] = sums_qse.get(z, 0.0) + y
|
||||
sums_graph[int(z)] = sums_graph.get(z, 0.0) + y_graph
|
||||
|
||||
print(sums_qse[3])
|
||||
print(sums_graph[3])
|
||||
|
||||
z_list = sorted(sums_qse.keys())
|
||||
dex_list = []
|
||||
|
||||
symbols = [val for key, val in symbols.items()]
|
||||
|
||||
for z in z_list:
|
||||
total_qse = sums_qse[z]
|
||||
total_graph = sums_graph[z]
|
||||
|
||||
if total_graph > 1e-13 and total_qse > 1e-13:
|
||||
offset = np.log10(total_qse / total_graph)
|
||||
else:
|
||||
if z >= 14:
|
||||
offset = np.nan # Disable these for visualization, they all have abundances so small (on the order of -100 it doesnt matter)
|
||||
else:
|
||||
offset = 0.0
|
||||
|
||||
dex_list.append(offset)
|
||||
fig, ax = plt.subplots(1, 1, figsize=(10, 7))
|
||||
data = sorted(zip(z_list, symbols, dex_list), key=lambda x: x[0])
|
||||
sorted_z, sorted_symbols, sorted_dex = zip(*data)
|
||||
print(sorted_symbols)
|
||||
print(sorted_dex)
|
||||
# 2. Create the plot
|
||||
fig, ax = plt.subplots(1, 1, figsize=(12, 6))
|
||||
print(sorted_symbols)
|
||||
bars = ax.bar(sorted_symbols, sorted_dex, color='grey', edgecolor='grey', alpha=0.8)
|
||||
|
||||
# 3. Add styling and labels
|
||||
ax.axhline(0, color='black', linewidth=0.8) # Adds a clear baseline at 0 dex
|
||||
ax.set_xlabel('Element', fontsize=25)
|
||||
ax.set_ylabel('Offset [dex]', fontsize=25)
|
||||
|
||||
if save_show == ShowSave.SAVE:
|
||||
plt.savefig("DexElementalOffset.pdf")
|
||||
plt.close()
|
||||
|
||||
|
||||
e_graph = interp1d(df_graph.t, df_graph.eps)
|
||||
e_qse = interp1d(df_qse.t, df_qse.eps)
|
||||
|
||||
dex_eps_diff = np.log10(e_graph(t)) - np.log10(e_qse(t))
|
||||
fig, ax = plt.subplots(1, 1, figsize=(10, 7))
|
||||
ax.semilogx(t, dex_eps_diff, color='black')
|
||||
ax.set_xlabel("Time [s]", fontsize=25)
|
||||
ax.set_xlabel("Offset [dex]", fontsize=25)
|
||||
|
||||
if save_show == ShowSave.SAVE:
|
||||
plt.savefig("DexEpsOffset.pdf")
|
||||
plt.close()
|
||||
|
||||
|
||||
if save_show == ShowSave.SHOW:
|
||||
plt.show()
|
||||
|
||||
print("=== QSE ===")
|
||||
print(temporal_err_qse)
|
||||
print(final_err_qse)
|
||||
print(f"Relative ε error: {qse_rel_eps_error}")
|
||||
|
||||
print(f"Neutrino Loss Difference [dex]: {np.log10(r_graph.specific_neutrino_energy_loss) - np.log10(r_qse.specific_neutrino_energy_loss)}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
import argparse
|
||||
app = argparse.ArgumentParser(prog="Derivative Smoothness", description="Generate of view plots of derivative smoothness")
|
||||
app.add_argument("-s", type=ShowSave, default=ShowSave.SHOW, choices=list(ShowSave), help="Whether to show or save the generated plot")
|
||||
|
||||
args = app.parse_args()
|
||||
main(args.s)
|
||||
@@ -0,0 +1,227 @@
|
||||
import numpy as np
|
||||
from IPython.core.pylabtools import figsize
|
||||
from gridfire.solver import PointSolver, PointSolverContext
|
||||
from gridfire.policy import MainSequencePolicy
|
||||
|
||||
from scipy.signal import find_peaks
|
||||
|
||||
from gridfire.config import GridFireConfig
|
||||
|
||||
from fourdst.composition import Composition
|
||||
from scipy.integrate import trapezoid
|
||||
|
||||
from fourdst.composition import CanonicalComposition
|
||||
from fourdst.atomic import Species
|
||||
from gridfire.type import NetIn
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
|
||||
## Note that my default style uses tex rendering. If you do not have tex installed
|
||||
## simply comment out this line
|
||||
plt.style.use("../utils/pub.mplstyle")
|
||||
|
||||
from scipy.interpolate import interp1d, CubicSpline
|
||||
|
||||
from enum import Enum
|
||||
|
||||
import sys
|
||||
import os
|
||||
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "../utils")))
|
||||
|
||||
from logger import StepLogger
|
||||
|
||||
class ShowSave(Enum):
|
||||
SHOW="SHOW"
|
||||
SAVE="SAVE"
|
||||
|
||||
def __str__(self):
|
||||
return self.value
|
||||
|
||||
def rescale_composition(comp_ref : Composition, ZZs : float, Y_primordial : float = 0.248) -> Composition:
|
||||
CC : CanonicalComposition = comp_ref.getCanonicalComposition()
|
||||
|
||||
dY_dZ = (CC.Y - Y_primordial) / CC.Z
|
||||
|
||||
Z_new = CC.Z * (10**ZZs)
|
||||
Y_bulk_new = Y_primordial + (dY_dZ * Z_new)
|
||||
X_new = 1.0 - Z_new - Y_bulk_new
|
||||
|
||||
if X_new < 0: raise ValueError(f"ZZs={ZZs} yields unphysical composition (X < 0)")
|
||||
|
||||
ratio_H = X_new / CC.X if CC.X > 0 else 0
|
||||
ratio_He = Y_bulk_new / CC.Y if CC.Y > 0 else 0
|
||||
ratio_Z = Z_new / CC.Z if CC.Z > 0 else 0
|
||||
|
||||
Y_new_list = []
|
||||
newComp : Composition = Composition()
|
||||
s: Species
|
||||
for s in comp_ref.getRegisteredSpecies():
|
||||
Xi_ref = comp_ref.getMassFraction(s)
|
||||
|
||||
if s.el() == "H":
|
||||
Xi_new = Xi_ref * ratio_H
|
||||
elif s.el() == "He":
|
||||
Xi_new = Xi_ref * ratio_He
|
||||
else:
|
||||
Xi_new = Xi_ref * ratio_Z
|
||||
|
||||
Y = Xi_new / s.mass()
|
||||
newComp.registerSpecies(s)
|
||||
newComp.setMolarAbundance(s, Y)
|
||||
|
||||
return newComp
|
||||
|
||||
def init_composition(ZZs : float = 0) -> Composition:
|
||||
Y_solar = [7.0262E-01, 9.7479E-06, 6.8955E-02, 2.5000E-04, 7.8554E-05, 6.0144E-04, 8.1031E-05, 2.1513E-05]
|
||||
S = ["H-1", "He-3", "He-4", "C-12", "N-14", "O-16", "Ne-20", "Mg-24"]
|
||||
return rescale_composition(Composition(S, Y_solar), ZZs)
|
||||
|
||||
|
||||
def init_netIn(temp: float, rho: float, time: float, comp: Composition) -> NetIn:
|
||||
n : NetIn = NetIn()
|
||||
n.temperature = temp
|
||||
n.density = rho
|
||||
n.tMax = time
|
||||
n.dt0 = 1e-12
|
||||
n.composition = comp
|
||||
return n
|
||||
|
||||
def years_to_seconds(years: float) -> float:
|
||||
return years * 3.1536e7
|
||||
|
||||
def main(save_show):
|
||||
C = init_composition()
|
||||
netIn = init_netIn(1.5e7, 160, years_to_seconds(10e9), C)
|
||||
policy = MainSequencePolicy(C)
|
||||
construct = policy.construct()
|
||||
|
||||
# 3e-8 and 1e-24 are the default tolerances we adopt as testing indicates it works well for
|
||||
# main sequence evolution. We encorage researchers to trial various relative and
|
||||
# absolute thresholds
|
||||
# config = GridFireConfig()
|
||||
# config.solver.pointSolver.trigger.boundaryFlux.relativeThreshold = 3e-8
|
||||
# config.solver.pointSolver.trigger.boundaryFlux.absoluteThreshold = 1e-24
|
||||
# solver = PointSolver(construct.engine, config)
|
||||
|
||||
solver = PointSolver(construct.engine)
|
||||
solver_ctx = PointSolverContext(construct.scratch_blob)
|
||||
|
||||
stepLogger = StepLogger()
|
||||
solver_ctx.callback = lambda ctx: stepLogger.log_step(ctx);
|
||||
solver.evaluate(solver_ctx, netIn, False, False)
|
||||
|
||||
df = stepLogger.df
|
||||
|
||||
|
||||
fig, axs = plt.subplots(2, 1, figsize=(17, 10))
|
||||
|
||||
t = np.linspace(df.t.min(), df.t.max(), 1000)
|
||||
|
||||
# Note we are not plotting Ne-20 as its molar abundance is so close to N-14 that it makes it hard to
|
||||
# distinguish that species
|
||||
PlottingSpecies = ["H-1", "He-3", "He-4", "C-12", "N-14", "O-16", "Mg-24"]
|
||||
stable_index = 10
|
||||
|
||||
for sp in PlottingSpecies:
|
||||
x = df.t[stable_index:]
|
||||
y = df[sp][stable_index:]
|
||||
axs[0].loglog(x, y)
|
||||
axs[1].semilogx(x, np.gradient(y, x))
|
||||
|
||||
axs[0].text(x.iloc[0], y.iloc[0]*1.1, sp, fontsize=12)
|
||||
|
||||
axs[0].set_ylabel("$Y$ [mol/g]", fontsize=23)
|
||||
axs[1].set_ylabel(r"$\frac{dY}{dt}$ [mol/g/s]", fontsize=23)
|
||||
axs[1].set_xlabel("Time [s]")
|
||||
|
||||
ax_eps = axs[0].twinx()
|
||||
ax_deps = axs[1].twinx()
|
||||
|
||||
ax_eps.set_ylabel(r"$\epsilon$ [erg/g/s]", rotation=270, labelpad=25, fontsize=23)
|
||||
ax_deps.set_ylabel(r"$\frac{d\epsilon}{dt}$ [erg/g/s$^2$]", rotation=270, labelpad=25, fontsize=23)
|
||||
|
||||
ax_eps.axvline(1.008e+15, color='grey', linestyle='dashed')
|
||||
ax_deps.axvline(1.008e+15, color='grey', linestyle='dashed')
|
||||
|
||||
ax_eps.loglog(df.t[stable_index:], df.eps[stable_index:], color='red', linestyle='dashed')
|
||||
ax_eps.text(df.t[stable_index:].iloc[0]*1.05, df.eps[stable_index:].iloc[0]*3, r"$\epsilon$", rotation=25, fontsize=20)
|
||||
|
||||
ax_deps.semilogx(df.t[stable_index:], np.gradient(df.eps[stable_index:], df.t[stable_index:]), color='red', linestyle='dashed')
|
||||
|
||||
|
||||
if save_show == ShowSave.SHOW:
|
||||
plt.show()
|
||||
else:
|
||||
plt.savefig("smoothness_plot.pdf")
|
||||
plt.close()
|
||||
|
||||
|
||||
t = df.t.values
|
||||
eps = df.eps.values
|
||||
|
||||
# Use this plot to determine the index to test removal of
|
||||
# fig, ax = plt.subplots(1, 1, figsize=(10, 7))
|
||||
# ax.plot(np.gradient(eps, t))
|
||||
# ax.grid()
|
||||
# plt.show()
|
||||
|
||||
idx = 156
|
||||
t1 = t
|
||||
eps1 = eps
|
||||
|
||||
t2 = np.delete(t, idx)
|
||||
eps2 = np.delete(eps, idx)
|
||||
|
||||
f_deps_1 = interp1d(t1, np.gradient(eps1, t1))
|
||||
f_deps_2 = interp1d(t2, np.gradient(eps2, t2))
|
||||
|
||||
int_deps_1 = trapezoid(f_deps_1(t), t)
|
||||
int_deps_2 = trapezoid(f_deps_2(t), t)
|
||||
|
||||
rel_err = (int_deps_1 - int_deps_2) / int_deps_2
|
||||
print(f"Rel Error: {rel_err:+0.3E}")
|
||||
|
||||
window = 10
|
||||
indices = np.arange(idx - window, idx + window + 1)
|
||||
indices_no_gap = np.delete(indices, window)
|
||||
|
||||
clean_t = t[indices_no_gap]
|
||||
clean_eps = eps[indices_no_gap]
|
||||
spline = CubicSpline(clean_t, clean_eps)
|
||||
|
||||
eps_predicted = spline(t[idx])
|
||||
eps_actual = eps[idx]
|
||||
|
||||
absolute_jump = np.abs(eps_actual - eps_predicted)
|
||||
relative_jump = absolute_jump / eps_actual
|
||||
|
||||
print(f"Local Discontinuity at index {idx}: {relative_jump:.3%}")
|
||||
|
||||
E_actual = trapezoid(eps, t)
|
||||
|
||||
t_clean = np.delete(t, idx)
|
||||
eps_clean_points = np.delete(eps, idx)
|
||||
spline = CubicSpline(t_clean, eps_clean_points)
|
||||
|
||||
eps_smooth = np.copy(eps)
|
||||
eps_smooth[idx] = spline(t[idx])
|
||||
|
||||
E_smooth = trapezoid(eps_smooth, t)
|
||||
|
||||
total_rel_error = (E_actual - E_smooth) / E_smooth
|
||||
print(f"Total Relative Energy Error: {total_rel_error:+0.12E}")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import argparse
|
||||
app = argparse.ArgumentParser(prog="Derivative Smoothness", description="Generate of view plots of derivative smoothness")
|
||||
app.add_argument("-s", type=ShowSave, default=ShowSave.SHOW, choices=list(ShowSave), help="Whether to show or save the generated plot")
|
||||
|
||||
args = app.parse_args()
|
||||
main(args.s)
|
||||
80
validation/ManuscriptFigures/utils/logger.py
Normal file
80
validation/ManuscriptFigures/utils/logger.py
Normal file
@@ -0,0 +1,80 @@
|
||||
from enum import Enum
|
||||
|
||||
from typing import Dict, List, Any, SupportsFloat
|
||||
import json
|
||||
from datetime import datetime
|
||||
import os
|
||||
import sys
|
||||
|
||||
from gridfire.solver import PointSolverTimestepContext
|
||||
from gridfire._gridfire.engine.scratchpads import StateBlob
|
||||
import gridfire
|
||||
|
||||
class LogEntries(Enum):
|
||||
Step = "Step"
|
||||
t = "t"
|
||||
dt = "dt"
|
||||
eps = "eps"
|
||||
Composition = "Composition"
|
||||
ReactionContributions = "ReactionContributions"
|
||||
|
||||
|
||||
class StepLogger:
|
||||
def __init__(self):
|
||||
self.num_steps : int = 0
|
||||
self.steps : List[Dict[LogEntries, Any]] = []
|
||||
|
||||
def log_step(self, ctx: PointSolverTimestepContext):
|
||||
comp_data: Dict[str, SupportsFloat] = {}
|
||||
for species in ctx.engine.getNetworkSpecies(ctx.state_ctx):
|
||||
sid = ctx.engine.getSpeciesIndex(ctx.state_ctx, species)
|
||||
comp_data[species.name()] = ctx.state[sid]
|
||||
entry : Dict[LogEntries, Any] = {
|
||||
LogEntries.Step: ctx.num_steps,
|
||||
LogEntries.t: ctx.t,
|
||||
LogEntries.dt: ctx.dt,
|
||||
LogEntries.eps: ctx.state[-1],
|
||||
LogEntries.Composition: comp_data,
|
||||
}
|
||||
self.steps.append(entry)
|
||||
self.num_steps += 1
|
||||
|
||||
def to_json(self, filename: str, **kwargs):
|
||||
serializable_steps : List[Dict[str, Any]] = [
|
||||
{
|
||||
LogEntries.Step.value: step[LogEntries.Step],
|
||||
LogEntries.t.value: step[LogEntries.t],
|
||||
LogEntries.dt.value: step[LogEntries.dt],
|
||||
LogEntries.eps.value: step[LogEntries.eps],
|
||||
LogEntries.Composition.value: step[LogEntries.Composition],
|
||||
}
|
||||
for step in self.steps
|
||||
]
|
||||
out_data : Dict[str, Any] = {
|
||||
"Metadata": {
|
||||
"NumSteps": self.num_steps,
|
||||
**kwargs,
|
||||
"DateCreated": datetime.now().isoformat(),
|
||||
"GridFireVersion": gridfire.__version__,
|
||||
"Author": "Emily M. Boudreaux",
|
||||
"OS": os.uname().sysname,
|
||||
"ClangVersion": os.popen("clang --version").read().strip(),
|
||||
"GccVersion": os.popen("gcc --version").read().strip(),
|
||||
"PythonVersion": sys.version,
|
||||
},
|
||||
"Steps": serializable_steps
|
||||
}
|
||||
with open(filename, 'w') as f:
|
||||
json.dump(out_data, f, indent=4)
|
||||
|
||||
|
||||
def summary(self) -> Dict[str, Any]:
|
||||
if not self.steps:
|
||||
return {}
|
||||
final_step = self.steps[-1]
|
||||
summary_data : Dict[str, Any] = {
|
||||
"TotalSteps": self.num_steps,
|
||||
"FinalTime": final_step[LogEntries.t],
|
||||
"FinalComposition": final_step[LogEntries.Composition],
|
||||
}
|
||||
return summary_data
|
||||
0
validation/ManuscriptFigures/utils/pub.mplstyle
Normal file
0
validation/ManuscriptFigures/utils/pub.mplstyle
Normal file
Reference in New Issue
Block a user