From 11a596b75be4dbf717cdb25fa113baa6aea6a08a Mon Sep 17 00:00:00 2001 From: Emily Boudreaux Date: Sat, 20 Dec 2025 16:02:52 -0500 Subject: [PATCH] feat(python): Python Bindings Python Bindings are working again --- build-config/cppad/meson.build | 2 + build-config/sundials/cvode/meson.build | 5 +- build-config/sundials/kinsol/meson.build | 5 +- build-python/meson.build | 4 + meson.build | 2 +- pip_install_mac_patch.sh | 2 +- pyproject.toml | 4 +- src/include/gridfire/config/config.h | 27 - src/include/gridfire/policy/policy_abstract.h | 1 + .../gridfire/solver/strategies/GridSolver.h | 3 + src/lib/solver/strategies/GridSolver.cpp | 13 + src/meson.build | 21 +- src/python/bindings.cpp | 11 + src/python/config/bindings.cpp | 34 + src/python/config/bindings.h | 5 + src/python/engine/bindings.cpp | 130 ++- src/python/engine/meson.build | 21 - src/python/engine/scratchpads/bindings.cpp | 152 +++ src/python/engine/scratchpads/bindings.h | 7 + src/python/engine/trampoline/meson.build | 21 - src/python/engine/trampoline/py_engine.cpp | 193 ++-- src/python/engine/trampoline/py_engine.h | 79 +- src/python/exceptions/bindings.cpp | 4 + src/python/exceptions/meson.build | 17 - src/python/gridfire/__init__.py | 59 +- src/python/io/meson.build | 17 - src/python/io/trampoline/meson.build | 21 - src/python/meson.build | 10 - src/python/partition/meson.build | 19 - src/python/partition/trampoline/meson.build | 21 - src/python/policy/bindings.cpp | 44 +- src/python/policy/meson.build | 19 - src/python/policy/trampoline/meson.build | 21 - src/python/policy/trampoline/py_policy.cpp | 12 +- src/python/policy/trampoline/py_policy.h | 4 +- src/python/reaction/meson.build | 17 - src/python/screening/meson.build | 19 - src/python/screening/trampoline/meson.build | 21 - src/python/solver/bindings.cpp | 253 +++-- src/python/solver/meson.build | 17 - src/python/solver/trampoline/meson.build | 21 - src/python/solver/trampoline/py_solver.cpp | 71 +- src/python/solver/trampoline/py_solver.h | 37 +- src/python/types/meson.build | 17 - src/python/utils/bindings.cpp | 1 + src/python/utils/meson.build | 17 - stubs/gridfire/__init__.pyi | 31 +- stubs/gridfire/_gridfire/__init__.pyi | 3 +- stubs/gridfire/_gridfire/config.pyi | 47 + stubs/gridfire/_gridfire/engine/__init__.pyi | 432 +++----- .../gridfire/_gridfire/engine/diagnostics.pyi | 7 +- .../gridfire/_gridfire/engine/scratchpads.pyi | 267 +++++ stubs/gridfire/_gridfire/exceptions.pyi | 4 +- stubs/gridfire/_gridfire/policy.pyi | 23 +- stubs/gridfire/_gridfire/solver.pyi | 135 ++- stubs/gridfire/_gridfire/type.pyi | 6 + stubs/gridfire/_gridfire/utils/__init__.pyi | 3 +- stubs/gridfiregridfire/__init__.pyi | 42 + stubs/gridfiregridfire/_gridfire/__init__.pyi | 16 + stubs/gridfiregridfire/_gridfire/config.pyi | 47 + .../_gridfire/engine/__init__.pyi | 972 ++++++++++++++++++ .../_gridfire/engine/diagnostics.pyi | 16 + .../_gridfire/engine/scratchpads.pyi | 267 +++++ .../gridfiregridfire/_gridfire/exceptions.pyi | 61 ++ stubs/gridfiregridfire/_gridfire/io.pyi | 14 + .../gridfiregridfire/_gridfire/partition.pyi | 142 +++ stubs/gridfiregridfire/_gridfire/policy.pyi | 769 ++++++++++++++ stubs/gridfiregridfire/_gridfire/reaction.pyi | 249 +++++ .../gridfiregridfire/_gridfire/screening.pyi | 68 ++ stubs/gridfiregridfire/_gridfire/solver.pyi | 157 +++ stubs/gridfiregridfire/_gridfire/type.pyi | 67 ++ .../_gridfire/utils/__init__.pyi | 18 + .../_gridfire/utils/hashing/__init__.pyi | 6 + .../_gridfire/utils/hashing/reaction.pyi | 12 + .../extern/fortran/gridfire_evolve_multi.f90 | 21 +- tests/python/test.py | 106 +- validation/vv/GridFireValidationSuite.py | 2 +- validation/vv/testsuite.py | 10 +- 78 files changed, 4411 insertions(+), 1110 deletions(-) create mode 100644 src/python/config/bindings.cpp create mode 100644 src/python/config/bindings.h delete mode 100644 src/python/engine/meson.build create mode 100644 src/python/engine/scratchpads/bindings.cpp create mode 100644 src/python/engine/scratchpads/bindings.h delete mode 100644 src/python/engine/trampoline/meson.build delete mode 100644 src/python/exceptions/meson.build delete mode 100644 src/python/io/meson.build delete mode 100644 src/python/io/trampoline/meson.build delete mode 100644 src/python/meson.build delete mode 100644 src/python/partition/meson.build delete mode 100644 src/python/partition/trampoline/meson.build delete mode 100644 src/python/policy/meson.build delete mode 100644 src/python/policy/trampoline/meson.build delete mode 100644 src/python/reaction/meson.build delete mode 100644 src/python/screening/meson.build delete mode 100644 src/python/screening/trampoline/meson.build delete mode 100644 src/python/solver/meson.build delete mode 100644 src/python/solver/trampoline/meson.build delete mode 100644 src/python/types/meson.build delete mode 100644 src/python/utils/meson.build create mode 100644 stubs/gridfire/_gridfire/config.pyi create mode 100644 stubs/gridfire/_gridfire/engine/scratchpads.pyi create mode 100644 stubs/gridfiregridfire/__init__.pyi create mode 100644 stubs/gridfiregridfire/_gridfire/__init__.pyi create mode 100644 stubs/gridfiregridfire/_gridfire/config.pyi create mode 100644 stubs/gridfiregridfire/_gridfire/engine/__init__.pyi create mode 100644 stubs/gridfiregridfire/_gridfire/engine/diagnostics.pyi create mode 100644 stubs/gridfiregridfire/_gridfire/engine/scratchpads.pyi create mode 100644 stubs/gridfiregridfire/_gridfire/exceptions.pyi create mode 100644 stubs/gridfiregridfire/_gridfire/io.pyi create mode 100644 stubs/gridfiregridfire/_gridfire/partition.pyi create mode 100644 stubs/gridfiregridfire/_gridfire/policy.pyi create mode 100644 stubs/gridfiregridfire/_gridfire/reaction.pyi create mode 100644 stubs/gridfiregridfire/_gridfire/screening.pyi create mode 100644 stubs/gridfiregridfire/_gridfire/solver.pyi create mode 100644 stubs/gridfiregridfire/_gridfire/type.pyi create mode 100644 stubs/gridfiregridfire/_gridfire/utils/__init__.pyi create mode 100644 stubs/gridfiregridfire/_gridfire/utils/hashing/__init__.pyi create mode 100644 stubs/gridfiregridfire/_gridfire/utils/hashing/reaction.pyi diff --git a/build-config/cppad/meson.build b/build-config/cppad/meson.build index a2e8544d..7cbb3682 100644 --- a/build-config/cppad/meson.build +++ b/build-config/cppad/meson.build @@ -18,6 +18,8 @@ cppad_cmake_options.add_cmake_defines({ 'include_doc': 'false' }) +cppad_cmake_options.set_install(false) + cppad_sp = cmake.subproject( 'cppad', options: cppad_cmake_options, diff --git a/build-config/sundials/cvode/meson.build b/build-config/sundials/cvode/meson.build index 4b19f6ad..90596bf9 100644 --- a/build-config/sundials/cvode/meson.build +++ b/build-config/sundials/cvode/meson.build @@ -7,7 +7,8 @@ cvode_cmake_options.add_cmake_defines({ 'BUILD_SHARED_LIBS' : 'OFF', 'BUILD_STATIC_LIBS' : 'ON', 'EXAMPLES_ENABLE_C' : 'OFF', - 'CMAKE_POSITION_INDEPENDENT_CODE': true + 'CMAKE_POSITION_INDEPENDENT_CODE': true, + 'CMAKE_PLATFORM_NO_VERSIONED_SONAME': 'ON' }) @@ -16,6 +17,8 @@ cvode_cmake_options.add_cmake_defines({ 'CMAKE_INSTALL_INCLUDEDIR': get_option('includedir') }) +cvode_cmake_options.set_install(false) + if meson.is_cross_build() and host_machine.system() == 'emscripten' cvode_cmake_options.add_cmake_defines({ 'CMAKE_C_FLAGS': '-s MEMORY64=1 -s ALLOW_MEMORY_GROWTH=1', diff --git a/build-config/sundials/kinsol/meson.build b/build-config/sundials/kinsol/meson.build index b14cbe74..fd795ef2 100644 --- a/build-config/sundials/kinsol/meson.build +++ b/build-config/sundials/kinsol/meson.build @@ -8,7 +8,8 @@ kinsol_cmake_options.add_cmake_defines({ 'BUILD_SHARED_LIBS' : 'OFF', 'BUILD_STATIC_LIBS' : 'ON', 'EXAMPLES_ENABLE_C' : 'OFF', - 'CMAKE_POSITION_INDEPENDENT_CODE': true + 'CMAKE_POSITION_INDEPENDENT_CODE': true, + 'CMAKE_PLATFORM_NO_VERSIONED_SONAME': 'ON' }) kinsol_cmake_options.add_cmake_defines({ @@ -16,6 +17,8 @@ kinsol_cmake_options.add_cmake_defines({ 'CMAKE_INSTALL_INCLUDEDIR': get_option('includedir') }) +kinsol_cmake_options.set_install(false) + kinsol_sp = cmake.subproject( 'kinsol', options: kinsol_cmake_options, diff --git a/build-python/meson.build b/build-python/meson.build index 87234f3b..74960332 100644 --- a/build-python/meson.build +++ b/build-python/meson.build @@ -28,6 +28,8 @@ if get_option('build_python') meson.project_source_root() + '/src/python/policy/bindings.cpp', meson.project_source_root() + '/src/python/policy/trampoline/py_policy.cpp', meson.project_source_root() + '/src/python/utils/bindings.cpp', + meson.project_source_root() + '/src/python/config/bindings.cpp', + meson.project_source_root() + '/src/python/engine/scratchpads/bindings.cpp', ] @@ -56,6 +58,7 @@ if get_option('build_python') files( meson.project_source_root() + '/src/python/gridfire/__init__.py', meson.project_source_root() + '/stubs/gridfire/_gridfire/__init__.pyi', + meson.project_source_root() + '/stubs/gridfire/_gridfire/config.pyi', meson.project_source_root() + '/stubs/gridfire/_gridfire/exceptions.pyi', meson.project_source_root() + '/stubs/gridfire/_gridfire/partition.pyi', meson.project_source_root() + '/stubs/gridfire/_gridfire/reaction.pyi', @@ -72,6 +75,7 @@ if get_option('build_python') files( meson.project_source_root() + '/stubs/gridfire/_gridfire/engine/__init__.pyi', meson.project_source_root() + '/stubs/gridfire/_gridfire/engine/diagnostics.pyi', + meson.project_source_root() + '/stubs/gridfire/_gridfire/engine/scratchpads.pyi' ), subdir: 'gridfire/engine', ) diff --git a/meson.build b/meson.build index 2a74f508..c7e707d3 100644 --- a/meson.build +++ b/meson.build @@ -18,7 +18,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # *********************************************************************** # -project('GridFire', ['c', 'cpp'], version: 'v0.7.4_rc2', default_options: ['cpp_std=c++23'], meson_version: '>=1.5.0') +project('GridFire', ['c', 'cpp'], version: 'v0.7.4rc3', default_options: ['cpp_std=c++23'], meson_version: '>=1.5.0') # Start by running the code which validates the build environment subdir('build-check') diff --git a/pip_install_mac_patch.sh b/pip_install_mac_patch.sh index fd0747b0..66491797 100755 --- a/pip_install_mac_patch.sh +++ b/pip_install_mac_patch.sh @@ -56,7 +56,7 @@ echo "Site packages: $SITE_PACKAGES" echo "" echo -e "${GREEN}Step 2: Installing fourdst with pip...${NC}" -$PYTHON_BIN -m pip install . -v +$PYTHON_BIN -m pip install . -v --no-build-isolation if [ $? -ne 0 ]; then echo -e "${RED}Error: pip install failed${NC}" diff --git a/pyproject.toml b/pyproject.toml index bedbcdc0..6fbb15f2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ build-backend = "mesonpy" [project] name = "gridfire" # Choose your Python package name -version = "0.7.4_rc2" # Your project's version +version = "v0.7.4rc3" # Your project's version description = "Python interface to the GridFire nuclear network code" readme = "README.md" license = { file = "LICENSE.txt" } # Reference your license file [cite: 2] @@ -22,4 +22,4 @@ maintainers = [ ] [tool.meson-python.args] -setup = ['-Dpkg-config=false'] +setup = ['-Dpkg_config=false', '-Dbuildtype=release', '-Dopenmp_support=true', '-Dasan=false', '-Dlog_level=error', '-Dbuild_tests=false', '-Dbuild_c_api=false', '-Dbuild_examples=false', '-Dbuild_benchmarks=false', '-Dbuild_tools=false', '-Dplugin_support=false', '-Duse_mimalloc=false', '-Dbuild_python=true'] diff --git a/src/include/gridfire/config/config.h b/src/include/gridfire/config/config.h index 52ebf648..13380ba5 100644 --- a/src/include/gridfire/config/config.h +++ b/src/include/gridfire/config/config.h @@ -8,34 +8,8 @@ namespace gridfire::config { double relTol = 1.0e-5; }; - - struct SpectralSolverConfig { - struct Trigger { - double timestepCollapseRatio = 0.5; - size_t maxConvergenceFailures = 2; - double relativeFailureRate = 0.5; - size_t windowSize = 10; - }; - struct MonitorFunctionConfig { - double structure_weight = 1.0; - double abundance_weight = 10.0; - double alpha = 0.2; - double beta = 0.8; - }; - struct BasisConfig { - size_t num_elements = 50; - }; - double absTol = 1.0e-8; - double relTol = 1.0e-5; - size_t degree = 3; - MonitorFunctionConfig monitorFunction; - BasisConfig basis; - Trigger trigger; - }; - struct SolverConfig { CVODESolverConfig cvode; - SpectralSolverConfig spectral; }; struct AdaptiveEngineViewConfig { @@ -57,5 +31,4 @@ namespace gridfire::config { }; - } \ No newline at end of file diff --git a/src/include/gridfire/policy/policy_abstract.h b/src/include/gridfire/policy/policy_abstract.h index fdff8eaa..d04f44dc 100644 --- a/src/include/gridfire/policy/policy_abstract.h +++ b/src/include/gridfire/policy/policy_abstract.h @@ -25,6 +25,7 @@ #include #include "gridfire/engine/types/engine_types.h" +#include "gridfire/engine/scratchpads/blob.h" namespace gridfire::policy { diff --git a/src/include/gridfire/solver/strategies/GridSolver.h b/src/include/gridfire/solver/strategies/GridSolver.h index 1b94c92e..416d35c6 100644 --- a/src/include/gridfire/solver/strategies/GridSolver.h +++ b/src/include/gridfire/solver/strategies/GridSolver.h @@ -20,6 +20,9 @@ namespace gridfire::solver { void set_callback(const std::function &callback); void set_callback(const std::function &callback, size_t zone_idx); + void clear_callback(); + void clear_callback(size_t zone_idx); + void set_stdout_logging(bool enable) override; void set_detailed_logging(bool enable) override; diff --git a/src/lib/solver/strategies/GridSolver.cpp b/src/lib/solver/strategies/GridSolver.cpp index f69f58da..8729be4e 100644 --- a/src/lib/solver/strategies/GridSolver.cpp +++ b/src/lib/solver/strategies/GridSolver.cpp @@ -28,6 +28,19 @@ namespace gridfire::solver { timestep_callbacks[zone_idx] = callback; } + void GridSolverContext::clear_callback() { + for (auto &cb : timestep_callbacks) { + cb = nullptr; + } + } + + void GridSolverContext::clear_callback(const size_t zone_idx) { + if (zone_idx >= timestep_callbacks.size()) { + throw exceptions::SolverError("GridSolverContext::clear_callback: zone_idx out of range."); + } + timestep_callbacks[zone_idx] = nullptr; + } + void GridSolverContext::set_stdout_logging(const bool enable) { zone_stdout_logging = enable; } diff --git a/src/meson.build b/src/meson.build index 712793ac..ecc7115e 100644 --- a/src/meson.build +++ b/src/meson.build @@ -58,12 +58,21 @@ if get_option('openmp_support') endif # Define the libnetwork library so it can be linked against by other parts of the build system -libgridfire = library('gridfire', - gridfire_sources, - include_directories: include_directories('include'), - dependencies: gridfire_build_dependencies, - objects: [cvode_objs, kinsol_objs], - install : true) +if get_option('build_python') + libgridfire = static_library('gridfire', + gridfire_sources, + include_directories: include_directories('include'), + dependencies: gridfire_build_dependencies, + objects: [cvode_objs, kinsol_objs], + install : false) +else + libgridfire = library('gridfire', + gridfire_sources, + include_directories: include_directories('include'), + dependencies: gridfire_build_dependencies, + objects: [cvode_objs, kinsol_objs], + install : true) +endif gridfire_dep = declare_dependency( include_directories: include_directories('include'), diff --git a/src/python/bindings.cpp b/src/python/bindings.cpp index b0d88baa..0103831f 100644 --- a/src/python/bindings.cpp +++ b/src/python/bindings.cpp @@ -4,6 +4,7 @@ #include "types/bindings.h" #include "partition/bindings.h" #include "engine/bindings.h" +#include "engine/scratchpads/bindings.h" #include "exceptions/bindings.h" #include "io/bindings.h" #include "reaction/bindings.h" @@ -11,6 +12,7 @@ #include "solver/bindings.h" #include "utils/bindings.h" #include "policy/bindings.h" +#include "config/bindings.h" PYBIND11_MODULE(_gridfire, m) { m.doc() = "Python bindings for the fourdst utility modules which are a part of the 4D-STAR project."; @@ -20,6 +22,9 @@ PYBIND11_MODULE(_gridfire, m) { pybind11::module::import("fourdst.config"); pybind11::module::import("fourdst.atomic"); + auto configMod = m.def_submodule("config", "GridFire configuration bindings"); + register_config_bindings(configMod); + auto typeMod = m.def_submodule("type", "GridFire type bindings"); register_type_bindings(typeMod); @@ -39,6 +44,12 @@ PYBIND11_MODULE(_gridfire, m) { register_exception_bindings(exceptionMod); auto engineMod = m.def_submodule("engine", "Engine and Engine View bindings"); + auto scratchpadMod = engineMod.def_submodule("scratchpads", "Engine ScratchPad bindings"); + + register_scratchpad_types_bindings(scratchpadMod); + register_scratchpad_bindings(scratchpadMod); + register_state_blob_bindings(scratchpadMod); + register_engine_bindings(engineMod); auto solverMod = m.def_submodule("solver", "GridFire numerical solver bindings"); diff --git a/src/python/config/bindings.cpp b/src/python/config/bindings.cpp new file mode 100644 index 00000000..0b88ead5 --- /dev/null +++ b/src/python/config/bindings.cpp @@ -0,0 +1,34 @@ +#include "bindings.h" + +#include "gridfire/config/config.h" +#include + +namespace py = pybind11; + +void register_config_bindings(pybind11::module &m) { + py::class_(m, "CVODESolverConfig") + .def(py::init<>()) + .def_readwrite("absTol", &gridfire::config::CVODESolverConfig::absTol) + .def_readwrite("relTol", &gridfire::config::CVODESolverConfig::relTol); + + py::class_(m, "SolverConfig") + .def(py::init<>()) + .def_readwrite("cvode", &gridfire::config::SolverConfig::cvode); + + py::class_(m, "AdaptiveEngineViewConfig") + .def(py::init<>()) + .def_readwrite("relativeCullingThreshold", &gridfire::config::AdaptiveEngineViewConfig::relativeCullingThreshold); + + py::class_(m, "EngineViewConfig") + .def(py::init<>()) + .def_readwrite("adaptiveEngineView", &gridfire::config::EngineViewConfig::adaptiveEngineView); + + py::class_(m, "EngineConfig") + .def(py::init<>()) + .def_readwrite("views", &gridfire::config::EngineConfig::views); + + py::class_(m, "GridFireConfig") + .def(py::init<>()) + .def_readwrite("solver", &gridfire::config::GridFireConfig::solver) + .def_readwrite("engine", &gridfire::config::GridFireConfig::engine); +} \ No newline at end of file diff --git a/src/python/config/bindings.h b/src/python/config/bindings.h new file mode 100644 index 00000000..2c0e1a05 --- /dev/null +++ b/src/python/config/bindings.h @@ -0,0 +1,5 @@ +#pragma once + +#include + +void register_config_bindings(pybind11::module &m); diff --git a/src/python/engine/bindings.cpp b/src/python/engine/bindings.cpp index 93675194..e01ff1e6 100644 --- a/src/python/engine/bindings.cpp +++ b/src/python/engine/bindings.cpp @@ -12,6 +12,7 @@ namespace py = pybind11; +namespace sp = gridfire::engine::scratch; namespace { template @@ -23,16 +24,18 @@ namespace { "calculateRHSAndEnergy", []( const gridfire::engine::DynamicEngine& self, + sp::StateBlob& ctx, const fourdst::composition::Composition& comp, const double T9, const double rho ) { - auto result = self.calculateRHSAndEnergy(comp, T9, rho); + auto result = self.calculateRHSAndEnergy(ctx, comp, T9, rho, false); if (!result.has_value()) { throw gridfire::exceptions::EngineError(std::format("calculateRHSAndEnergy returned a potentially recoverable error {}", gridfire::engine::EngineStatus_to_string(result.error()))); } return result.value(); }, + py::arg("ctx"), py::arg("comp"), py::arg("T9"), py::arg("rho"), @@ -40,6 +43,7 @@ namespace { ) .def("calculateEpsDerivatives", &gridfire::engine::DynamicEngine::calculateEpsDerivatives, + py::arg("ctx"), py::arg("comp"), py::arg("T9"), py::arg("rho"), @@ -47,11 +51,13 @@ namespace { ) .def("generateJacobianMatrix", [](const gridfire::engine::DynamicEngine& self, + sp::StateBlob& ctx, const fourdst::composition::Composition& comp, const double T9, const double rho) -> gridfire::engine::NetworkJacobian { - return self.generateJacobianMatrix(comp, T9, rho); + return self.generateJacobianMatrix(ctx, comp, T9, rho); }, + py::arg("ctx"), py::arg("comp"), py::arg("T9"), py::arg("rho"), @@ -59,12 +65,14 @@ namespace { ) .def("generateJacobianMatrix", [](const gridfire::engine::DynamicEngine& self, + sp::StateBlob& ctx, const fourdst::composition::Composition& comp, const double T9, const double rho, const std::vector& activeSpecies) -> gridfire::engine::NetworkJacobian { - return self.generateJacobianMatrix(comp, T9, rho, activeSpecies); + return self.generateJacobianMatrix(ctx, comp, T9, rho, activeSpecies); }, + py::arg("ctx"), py::arg("comp"), py::arg("T9"), py::arg("rho"), @@ -73,31 +81,32 @@ namespace { ) .def("generateJacobianMatrix", [](const gridfire::engine::DynamicEngine& self, + sp::StateBlob& ctx, const fourdst::composition::Composition& comp, const double T9, const double rho, const gridfire::engine::SparsityPattern& sparsityPattern) -> gridfire::engine::NetworkJacobian { - return self.generateJacobianMatrix(comp, T9, rho, sparsityPattern); + return self.generateJacobianMatrix(ctx, comp, T9, rho, sparsityPattern); }, + py::arg("ctx"), py::arg("comp"), py::arg("T9"), py::arg("rho"), py::arg("sparsityPattern"), "Generate the jacobian matrix for the given sparsity pattern" ) - .def("generateStoichiometryMatrix", - &T::generateStoichiometryMatrix - ) .def("calculateMolarReactionFlow", []( const gridfire::engine::DynamicEngine& self, + sp::StateBlob& ctx, const gridfire::reaction::Reaction& reaction, const fourdst::composition::Composition& comp, const double T9, const double rho ) -> double { - return self.calculateMolarReactionFlow(reaction, comp, T9, rho); + return self.calculateMolarReactionFlow(ctx, reaction, comp, T9, rho); }, + py::arg("ctx"), py::arg("reaction"), py::arg("comp"), py::arg("T9"), @@ -110,28 +119,21 @@ namespace { .def("getNetworkReactions", &T::getNetworkReactions, "Get the set of logical reactions in the network." ) - .def ("setNetworkReactions", &T::setNetworkReactions, - py::arg("reactions"), - "Set the network reactions to a new set of reactions." - ) - .def("getStoichiometryMatrixEntry", &T::getStoichiometryMatrixEntry, - py::arg("species"), - py::arg("reaction"), - "Get an entry from the stoichiometry matrix." - ) .def("getSpeciesTimescales", []( const gridfire::engine::DynamicEngine& self, + sp::StateBlob& ctx, const fourdst::composition::Composition& comp, const double T9, const double rho ) -> std::unordered_map { - const auto result = self.getSpeciesTimescales(comp, T9, rho); + const auto result = self.getSpeciesTimescales(ctx, comp, T9, rho); if (!result.has_value()) { throw gridfire::exceptions::EngineError(std::format("getSpeciesTimescales has returned a potentially recoverable error {}", gridfire::engine::EngineStatus_to_string(result.error()))); } return result.value(); }, + py::arg("ctx"), py::arg("comp"), py::arg("T9"), py::arg("rho"), @@ -140,67 +142,48 @@ namespace { .def("getSpeciesDestructionTimescales", []( const gridfire::engine::DynamicEngine& self, + sp::StateBlob& ctx, const fourdst::composition::Composition& comp, const double T9, const double rho ) -> std::unordered_map { - const auto result = self.getSpeciesDestructionTimescales(comp, T9, rho); + const auto result = self.getSpeciesDestructionTimescales(ctx, comp, T9, rho); if (!result.has_value()) { throw gridfire::exceptions::EngineError(std::format("getSpeciesDestructionTimescales has returned a potentially recoverable error {}", gridfire::engine::EngineStatus_to_string(result.error()))); } return result.value(); }, + py::arg("ctx"), py::arg("comp"), py::arg("T9"), py::arg("rho"), "Get the destruction timescales for each species in the network." ) - .def("update", - &T::update, + .def("project", + &T::project, + py::arg("ctx"), py::arg("netIn"), "Update the engine state based on the provided NetIn object." ) - .def("setScreeningModel", - &T::setScreeningModel, - py::arg("screeningModel"), - "Set the screening model for the engine." - ) .def("getScreeningModel", &T::getScreeningModel, "Get the current screening model of the engine." ) .def("getSpeciesIndex", &T::getSpeciesIndex, + py::arg("ctx"), py::arg("species"), "Get the index of a species in the network." ) - .def("mapNetInToMolarAbundanceVector", - &T::mapNetInToMolarAbundanceVector, - py::arg("netIn"), - "Map a NetIn object to a vector of molar abundances." - ) .def("primeEngine", &T::primeEngine, + py::arg("ctx"), py::arg("netIn"), "Prime the engine with a NetIn object to prepare for calculations." ) - .def("getDepth", - &T::getDepth, - "Get the current build depth of the engine." - ) - .def("rebuild", - &T::rebuild, - py::arg("composition"), - py::arg("depth") = gridfire::engine::NetworkBuildDepth::Full, - "Rebuild the engine with a new composition and build depth." - ) - .def("isStale", - &T::isStale, - py::arg("netIn"), - "Check if the engine is stale based on the provided NetIn object." - ) .def("collectComposition", &T::collectComposition, + py::arg("ctx"), py::arg("composition"), py::arg("T9"), py::arg("rho"), @@ -208,6 +191,7 @@ namespace { ) .def("getSpeciesStatus", &T::getSpeciesStatus, + py::arg("ctx"), py::arg("species"), "Get the status of a species in the network." ); @@ -253,6 +237,7 @@ void register_engine_diagnostic_bindings(pybind11::module &m) { auto diagnostics = m.def_submodule("diagnostics", "A submodule for engine diagnostics"); diagnostics.def("report_limiting_species", &gridfire::engine::diagnostics::report_limiting_species, + py::arg("ctx"), py::arg("engine"), py::arg("Y_full"), py::arg("E_full"), @@ -264,6 +249,7 @@ void register_engine_diagnostic_bindings(pybind11::module &m) { diagnostics.def("inspect_species_balance", &gridfire::engine::diagnostics::inspect_species_balance, + py::arg("ctx"), py::arg("engine"), py::arg("species_name"), py::arg("comp"), @@ -274,6 +260,7 @@ void register_engine_diagnostic_bindings(pybind11::module &m) { diagnostics.def("inspect_jacobian_stiffness", &gridfire::engine::diagnostics::inspect_jacobian_stiffness, + py::arg("ctx"), py::arg("engine"), py::arg("comp"), py::arg("T9"), @@ -311,6 +298,7 @@ void register_engine_construction_bindings(pybind11::module &m) { void register_engine_priming_bindings(pybind11::module &m) { m.def("primeNetwork", &gridfire::engine::primeNetwork, + py::arg("ctx"), py::arg("netIn"), py::arg("engine"), py::arg("ignoredReactionTypes") = std::nullopt, @@ -456,19 +444,16 @@ void con_stype_register_graph_engine_bindings(const pybind11::module &m) { py::arg("reactions"), "Initialize GraphEngine with a set of reactions." ); - py_graph_engine_bindings.def_static("getNetReactionStoichiometry", - &gridfire::engine::GraphEngine::getNetReactionStoichiometry, - py::arg("reaction"), - "Get the net stoichiometry for a given reaction." - ); py_graph_engine_bindings.def("getSpeciesTimescales", [](const gridfire::engine::GraphEngine& self, + sp::StateBlob& ctx, const fourdst::composition::Composition& composition, const double T9, const double rho, const gridfire::reaction::ReactionSet& activeReactions) { - return self.getSpeciesTimescales(composition, T9, rho, activeReactions); + return self.getSpeciesTimescales(ctx, composition, T9, rho, activeReactions); }, + py::arg("ctx"), py::arg("composition"), py::arg("T9"), py::arg("rho"), @@ -476,12 +461,14 @@ void con_stype_register_graph_engine_bindings(const pybind11::module &m) { ); py_graph_engine_bindings.def("getSpeciesDestructionTimescales", [](const gridfire::engine::GraphEngine& self, + sp::StateBlob& ctx, const fourdst::composition::Composition& composition, const double T9, const double rho, const gridfire::reaction::ReactionSet& activeReactions) { - return self.getSpeciesDestructionTimescales(composition, T9, rho, activeReactions); + return self.getSpeciesDestructionTimescales(ctx, composition, T9, rho, activeReactions); }, + py::arg("ctx"), py::arg("composition"), py::arg("T9"), py::arg("rho"), @@ -489,24 +476,22 @@ void con_stype_register_graph_engine_bindings(const pybind11::module &m) { ); py_graph_engine_bindings.def("involvesSpecies", &gridfire::engine::GraphEngine::involvesSpecies, + py::arg("ctx"), py::arg("species"), "Check if a given species is involved in the network." ); py_graph_engine_bindings.def("exportToDot", &gridfire::engine::GraphEngine::exportToDot, + py::arg("ctx"), py::arg("filename"), "Export the network to a DOT file for visualization." ); py_graph_engine_bindings.def("exportToCSV", &gridfire::engine::GraphEngine::exportToCSV, + py::arg("ctx"), py::arg("filename"), "Export the network to a CSV file for analysis." ); - py_graph_engine_bindings.def("setPrecomputation", - &gridfire::engine::GraphEngine::setPrecomputation, - py::arg("precompute"), - "Enable or disable precomputation for the engine." - ); py_graph_engine_bindings.def("isPrecomputationEnabled", &gridfire::engine::GraphEngine::isPrecomputationEnabled, "Check if precomputation is enabled for the engine." @@ -544,11 +529,6 @@ 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("setUseReverseReactions", - &gridfire::engine::GraphEngine::setUseReverseReactions, - py::arg("useReverse"), - "Enable or disable the use of reverse reactions in the engine." - ); // Register the general dynamic engine bindings registerDynamicEngineDefs(py_graph_engine_bindings); @@ -587,11 +567,13 @@ void register_engine_view_bindings(const pybind11::module &m) { registerDynamicEngineDefs(py_file_defined_engine_view_bindings); auto py_priming_engine_view_bindings = py::class_(m, "NetworkPrimingEngineView"); - py_priming_engine_view_bindings.def(py::init(), + py_priming_engine_view_bindings.def(py::init(), + py::arg("ctx"), py::arg("primingSymbol"), py::arg("baseEngine"), "Construct a priming engine view with a priming symbol and a base engine."); - py_priming_engine_view_bindings.def(py::init(), + py_priming_engine_view_bindings.def(py::init(), + py::arg("ctx"), py::arg("primingSpecies"), py::arg("baseEngine"), "Construct a priming engine view with a priming species and a base engine."); @@ -622,15 +604,12 @@ void register_engine_view_bindings(const pybind11::module &m) { ); py_multiscale_engine_view_bindings.def("partitionNetwork", &gridfire::engine::MultiscalePartitioningEngineView::partitionNetwork, + py::arg("ctx"), py::arg("netIn"), "Partition the network based on species timescales and connectivity."); - py_multiscale_engine_view_bindings.def("partitionNetwork", - py::overload_cast(&gridfire::engine::MultiscalePartitioningEngineView::partitionNetwork), - py::arg("netIn"), - "Partition the network based on a NetIn object." - ); py_multiscale_engine_view_bindings.def("exportToDot", &gridfire::engine::MultiscalePartitioningEngineView::exportToDot, + py::arg("ctx"), py::arg("filename"), py::arg("comp"), py::arg("T9"), @@ -661,7 +640,16 @@ void register_engine_view_bindings(const pybind11::module &m) { "Check if a given species is involved in the network's dynamic set." ); py_multiscale_engine_view_bindings.def("getNormalizedEquilibratedComposition", - &gridfire::engine::MultiscalePartitioningEngineView::getNormalizedEquilibratedComposition, + []( + const gridfire::engine::MultiscalePartitioningEngineView& self, + sp::StateBlob& ctx, + const fourdst::composition::Composition& comp, + const double T9, + const double rho + ) { + return self.getNormalizedEquilibratedComposition(ctx, comp, T9, rho, false); + }, + py::arg("ctx"), py::arg("comp"), py::arg("T9"), py::arg("rho"), diff --git a/src/python/engine/meson.build b/src/python/engine/meson.build deleted file mode 100644 index e1b412a7..00000000 --- a/src/python/engine/meson.build +++ /dev/null @@ -1,21 +0,0 @@ -subdir('trampoline') - -# Define the library -bindings_sources = files('bindings.cpp') -bindings_headers = files('bindings.h') - -dependencies = [ - gridfire_dep, - python3_dep, - pybind11_dep, -] - -message('⏳ Python bindings for GridFire Engine are being registered...') -shared_module('py_gf_engine', - bindings_sources, - cpp_args: ['-fvisibility=default'], - install : true, - dependencies: dependencies, - include_directories: include_directories('.') -) -message('✅ Python bindings for GridFire Engine registered successfully!') \ No newline at end of file diff --git a/src/python/engine/scratchpads/bindings.cpp b/src/python/engine/scratchpads/bindings.cpp new file mode 100644 index 00000000..1d1c4ca1 --- /dev/null +++ b/src/python/engine/scratchpads/bindings.cpp @@ -0,0 +1,152 @@ +#include +#include // Needed for vectors, maps, sets, strings +#include // Needed for binding std::vector, std::map etc. if needed directly + +#include "gridfire/engine/scratchpads/scratchpads.h" + +#include "bindings.h" + +namespace py = pybind11; +namespace sp = gridfire::engine::scratch; + +template +void build_state_getter(py::module& m) { + +} + +void register_scratchpad_types_bindings(pybind11::module &m) { + py::enum_(m, "ScratchPadType") + .value("GRAPH_ENGINE_SCRATCHPAD", sp::ScratchPadType::GRAPH_ENGINE_SCRATCHPAD) + .value("MULTISCALE_PARTITIONING_ENGINE_VIEW_SCRATCHPAD", sp::ScratchPadType::MULTISCALE_PARTITIONING_ENGINE_VIEW_SCRATCHPAD) + .value("ADAPTIVE_ENGINE_VIEW_SCRATCHPAD", sp::ScratchPadType::ADAPTIVE_ENGINE_VIEW_SCRATCHPAD) + .value("DEFINED_ENGINE_VIEW_SCRATCHPAD", sp::ScratchPadType::DEFINED_ENGINE_VIEW_SCRATCHPAD) + .export_values(); +} + +void register_scratchpad_bindings(pybind11::module_ &m) { + py::enum_(m, "ADFunRegistrationResult") + .value("SUCCESS", sp::GraphEngineScratchPad::ADFunRegistrationResult::SUCCESS) + .value("ALREADY_REGISTERED", sp::GraphEngineScratchPad::ADFunRegistrationResult::ALREADY_REGISTERED) + .export_values(); + + py::class_(m, "GraphEngineScratchPad") + .def(py::init<>()) + .def("initialize", &sp::GraphEngineScratchPad::initialize, py::arg("engine")) + .def("clone", &sp::GraphEngineScratchPad::clone) + .def("is_initialized", &sp::GraphEngineScratchPad::is_initialized) + .def_readonly("most_recent_rhs_calculation", &sp::GraphEngineScratchPad::most_recent_rhs_calculation) + .def_readonly("local_abundance_cache", &sp::GraphEngineScratchPad::local_abundance_cache) + .def_readonly("has_initialized", &sp::GraphEngineScratchPad::has_initialized) + .def_readonly("stepDerivativesCache", &sp::GraphEngineScratchPad::stepDerivativesCache) + .def_readonly_static("ID", &sp::GraphEngineScratchPad::ID) + .def("__repr__", [](const sp::GraphEngineScratchPad &self) { + return std::format("{}", self); + }); + + py::class_(m, "MultiscalePartitioningEngineViewScratchPad") + .def(py::init<>()) + .def("initialize", &sp::MultiscalePartitioningEngineViewScratchPad::initialize) + .def("clone", &sp::MultiscalePartitioningEngineViewScratchPad::clone) + .def("is_initialized", &sp::MultiscalePartitioningEngineViewScratchPad::is_initialized) + .def_readonly("qse_groups", &sp::MultiscalePartitioningEngineViewScratchPad::qse_groups) + .def_readonly("dynamic_species", &sp::MultiscalePartitioningEngineViewScratchPad::dynamic_species) + .def_readonly("algebraic_species", &sp::MultiscalePartitioningEngineViewScratchPad::algebraic_species) + .def_readonly("composition_cache", &sp::MultiscalePartitioningEngineViewScratchPad::composition_cache) + .def_readonly("has_initialized", &sp::MultiscalePartitioningEngineViewScratchPad::has_initialized) + .def_readonly_static("ID", &sp::MultiscalePartitioningEngineViewScratchPad::ID) + .def("__repr__", [](const sp::MultiscalePartitioningEngineViewScratchPad &self) { + return std::format("{}", self); + }); + + py::class_(m, "AdaptiveEngineViewScratchPad") + .def(py::init<>()) + .def("initialize", &sp::AdaptiveEngineViewScratchPad::initialize) + .def("clone", &sp::AdaptiveEngineViewScratchPad::clone) + .def("is_initialized", &sp::AdaptiveEngineViewScratchPad::is_initialized) + .def_readonly("active_species", &sp::AdaptiveEngineViewScratchPad::active_species) + .def_readonly("active_reactions", &sp::AdaptiveEngineViewScratchPad::active_reactions) + .def_readonly("has_initialized", &sp::AdaptiveEngineViewScratchPad::has_initialized) + .def_readonly_static("ID", &sp::AdaptiveEngineViewScratchPad::ID) + .def("__repr__", [](const sp::AdaptiveEngineViewScratchPad &self) { + return std::format("{}", self); + }); + + py::class_(m, "DefinedEngineViewScratchPad") + .def(py::init<>()) + .def("clone", &sp::DefinedEngineViewScratchPad::clone) + .def("is_initialized", &sp::DefinedEngineViewScratchPad::is_initialized) + .def_readonly("active_species", &sp::DefinedEngineViewScratchPad::active_species) + .def_readonly("active_reactions", &sp::DefinedEngineViewScratchPad::active_reactions) + .def_readonly("species_index_map", &sp::DefinedEngineViewScratchPad::species_index_map) + .def_readonly("reaction_index_map", &sp::DefinedEngineViewScratchPad::reaction_index_map) + .def_readonly("has_initialized", &sp::DefinedEngineViewScratchPad::has_initialized) + .def_readonly_static("ID", &sp::DefinedEngineViewScratchPad::ID) + .def("__repr__", [](const sp::DefinedEngineViewScratchPad &self) { + return std::format("{}", self); + }); +} + +void register_state_blob_bindings(pybind11::module_ &m) { + py::enum_(m, "StateBlobError") + .value("SCRATCHPAD_OUT_OF_BOUNDS", sp::StateBlob::Error::SCRATCHPAD_OUT_OF_BOUNDS) + .value("SCRATCHPAD_NOT_FOUND", sp::StateBlob::Error::SCRATCHPAD_NOT_FOUND) + .value("SCRATCHPAD_BAD_CAST", sp::StateBlob::Error::SCRATCHPAD_BAD_CAST) + .value("SCRATCHPAD_NOT_INITIALIZED", sp::StateBlob::Error::SCRATCHPAD_NOT_INITIALIZED) + .value("SCRATCHPAD_TYPE_COLLISION", sp::StateBlob::Error::SCRATCHPAD_TYPE_COLLISION) + .value("SCRATCHPAD_UNKNOWN_ERROR", sp::StateBlob::Error::SCRATCHPAD_UNKNOWN_ERROR) + .export_values(); + + py::class_(m, "StateBlob") + .def(py::init<>()) + .def("enroll", [](sp::StateBlob &self, const sp::ScratchPadType type) { + switch (type) { + case sp::ScratchPadType::GRAPH_ENGINE_SCRATCHPAD: + self.enroll(); + break; + case sp::ScratchPadType::MULTISCALE_PARTITIONING_ENGINE_VIEW_SCRATCHPAD: + self.enroll(); + break; + case sp::ScratchPadType::ADAPTIVE_ENGINE_VIEW_SCRATCHPAD: + self.enroll(); + break; + case sp::ScratchPadType::DEFINED_ENGINE_VIEW_SCRATCHPAD: + self.enroll(); + break; + default: + throw std::invalid_argument("Unknown ScratchPadType for enrollment."); + } + }) + .def("get", [](const sp::StateBlob &self, const sp::ScratchPadType type) { + auto result = self.get(type); + if (!result.has_value()) { + throw std::runtime_error("Error retrieving scratchpad: " + sp::StateBlob::error_to_string(result.error())); + } + return result.value(); + }, + pybind11::return_value_policy::reference_internal + ) + .def("clone_structure", &sp::StateBlob::clone_structure) + .def("get_registered_scratchpads", &sp::StateBlob::get_registered_scratchpads) + .def("get_status", [](const sp::StateBlob &self, const sp::ScratchPadType type) -> sp::StateBlob::ScratchPadStatus { + switch (type) { + case sp::ScratchPadType::GRAPH_ENGINE_SCRATCHPAD: + return self.get_status(); + case sp::ScratchPadType::MULTISCALE_PARTITIONING_ENGINE_VIEW_SCRATCHPAD: + return self.get_status(); + case sp::ScratchPadType::ADAPTIVE_ENGINE_VIEW_SCRATCHPAD: + return self.get_status(); + case sp::ScratchPadType::DEFINED_ENGINE_VIEW_SCRATCHPAD: + return self.get_status(); + default: + throw std::invalid_argument("Unknown ScratchPadType for status retrieval."); + } + }) + .def("get_status_map", &sp::StateBlob::get_status_map) + .def_static("error_to_string", &sp::StateBlob::error_to_string) + .def("__repr__", [](const sp::StateBlob &self) { + return std::format("{}", self); + }); +} + + + diff --git a/src/python/engine/scratchpads/bindings.h b/src/python/engine/scratchpads/bindings.h new file mode 100644 index 00000000..d9799e5b --- /dev/null +++ b/src/python/engine/scratchpads/bindings.h @@ -0,0 +1,7 @@ +#pragma once + +#include + +void register_scratchpad_types_bindings(pybind11::module_& m); +void register_scratchpad_bindings(pybind11::module_& m); +void register_state_blob_bindings(pybind11::module_& m); \ No newline at end of file diff --git a/src/python/engine/trampoline/meson.build b/src/python/engine/trampoline/meson.build deleted file mode 100644 index 78472541..00000000 --- a/src/python/engine/trampoline/meson.build +++ /dev/null @@ -1,21 +0,0 @@ -gf_engine_trampoline_sources = files('py_engine.cpp') - -gf_engine_trapoline_dependencies = [ - gridfire_dep, - pybind11_dep, - python3_dep, -] - -gf_engine_trampoline_lib = static_library( - 'engine_trampolines', - gf_engine_trampoline_sources, - include_directories: include_directories('.'), - dependencies: gf_engine_trapoline_dependencies, - install: false, -) - -gr_engine_trampoline_dep = declare_dependency( - link_with: gf_engine_trampoline_lib, - include_directories: ('.'), - dependencies: gf_engine_trapoline_dependencies, -) diff --git a/src/python/engine/trampoline/py_engine.cpp b/src/python/engine/trampoline/py_engine.cpp index 76da9ea4..c54d0f94 100644 --- a/src/python/engine/trampoline/py_engine.cpp +++ b/src/python/engine/trampoline/py_engine.cpp @@ -13,36 +13,29 @@ namespace py = pybind11; -const std::vector& PyEngine::getNetworkSpecies() const { - /* - * Acquire the GIL (Global Interpreter Lock) for thread safety - * with the Python interpreter. - */ - py::gil_scoped_acquire gil; - - /* - * get_override() looks for a Python method that overrides this C++ one. - */ - - if (const py::function override = py::get_override(this, "getNetworkSpecies")) { - const py::object result = override(); - m_species_cache = result.cast>(); - return m_species_cache; - } - - py::pybind11_fail("Tried to call pure virtual function \"DynamicEngine::getNetworkSpecies\""); +const std::vector& PyEngine::getNetworkSpecies( + gridfire::engine::scratch::StateBlob& ctx +) const { + PYBIND11_OVERRIDE_PURE( + const std::vector&, + gridfire::engine::Engine, + getNetworkSpecies, + ctx + ); } std::expected, gridfire::engine::EngineStatus> PyEngine::calculateRHSAndEnergy( + gridfire::engine::scratch::StateBlob& ctx, const fourdst::composition::CompositionAbstract &comp, double T9, - double rho + double rho, + bool trust ) const { PYBIND11_OVERRIDE_PURE( PYBIND11_TYPE(std::expected, gridfire::engine::EngineStatus>), gridfire::engine::Engine, calculateRHSAndEnergy, - comp, T9, rho + ctx, comp, T9, rho, trust ); } @@ -50,41 +43,35 @@ std::expected, gridfire::engine::Engin /// PyDynamicEngine Implementation /// ///////////////////////////////////// -const std::vector& PyDynamicEngine::getNetworkSpecies() const { - /* - * Acquire the GIL (Global Interpreter Lock) for thread safety - * with the Python interpreter. - */ - py::gil_scoped_acquire gil; - - /* - * get_override() looks for a Python method that overrides this C++ one. - */ - - if (const py::function override = py::get_override(this, "getNetworkSpecies")) { - const py::object result = override(); - m_species_cache = result.cast>(); - return m_species_cache; - } - - py::pybind11_fail("Tried to call pure virtual function \"DynamicEngine::getNetworkSpecies\""); +const std::vector& PyDynamicEngine::getNetworkSpecies( + gridfire::engine::scratch::StateBlob& ctx +) const { + PYBIND11_OVERRIDE_PURE( + const std::vector&, + gridfire::engine::DynamicEngine, + getNetworkSpecies, + ctx + ); } std::expected, gridfire::engine::EngineStatus> PyDynamicEngine::calculateRHSAndEnergy( + gridfire::engine::scratch::StateBlob& ctx, const fourdst::composition::CompositionAbstract &comp, double T9, - double rho + double rho, + bool trust ) const { PYBIND11_OVERRIDE_PURE( PYBIND11_TYPE(std::expected, gridfire::engine::EngineStatus>), gridfire::engine::DynamicEngine, calculateRHSAndEnergy, - comp, T9, rho + ctx, comp, T9, rho, trust ); } gridfire::engine::NetworkJacobian PyDynamicEngine::generateJacobianMatrix( + gridfire::engine::scratch::StateBlob& ctx, const fourdst::composition::CompositionAbstract& comp, double T9, double rho @@ -100,6 +87,7 @@ gridfire::engine::NetworkJacobian PyDynamicEngine::generateJacobianMatrix( } gridfire::engine::NetworkJacobian PyDynamicEngine::generateJacobianMatrix( + gridfire::engine::scratch::StateBlob& ctx, const fourdst::composition::CompositionAbstract &comp, const double T9, const double rho, @@ -109,6 +97,7 @@ gridfire::engine::NetworkJacobian PyDynamicEngine::generateJacobianMatrix( gridfire::engine::NetworkJacobian, gridfire::engine::DynamicEngine, generateJacobianMatrix, + ctx, comp, T9, rho, @@ -117,6 +106,7 @@ gridfire::engine::NetworkJacobian PyDynamicEngine::generateJacobianMatrix( } gridfire::engine::NetworkJacobian PyDynamicEngine::generateJacobianMatrix( + gridfire::engine::scratch::StateBlob& ctx, const fourdst::composition::CompositionAbstract &comp, double T9, double rho, @@ -126,6 +116,7 @@ gridfire::engine::NetworkJacobian PyDynamicEngine::generateJacobianMatrix( gridfire::engine::NetworkJacobian, gridfire::engine::DynamicEngine, generateJacobianMatrix, + ctx, comp, T9, rho, @@ -133,28 +124,8 @@ gridfire::engine::NetworkJacobian PyDynamicEngine::generateJacobianMatrix( ); } -void PyDynamicEngine::generateStoichiometryMatrix() { - PYBIND11_OVERRIDE_PURE( - void, - gridfire::engine::DynamicEngine, - generateStoichiometryMatrix - ); -} - -int PyDynamicEngine::getStoichiometryMatrixEntry( - const fourdst::atomic::Species& species, - const gridfire::reaction::Reaction& reaction -) const { - PYBIND11_OVERRIDE_PURE( - int, - gridfire::engine::DynamicEngine, - getStoichiometryMatrixEntry, - species, - reaction - ); -} - double PyDynamicEngine::calculateMolarReactionFlow( + gridfire::engine::scratch::StateBlob& ctx, const gridfire::reaction::Reaction &reaction, const fourdst::composition::CompositionAbstract &comp, double T9, @@ -164,6 +135,7 @@ double PyDynamicEngine::calculateMolarReactionFlow( double, gridfire::engine::DynamicEngine, calculateMolarReactionFlow, + ctx, reaction, comp, T9, @@ -171,24 +143,19 @@ double PyDynamicEngine::calculateMolarReactionFlow( ); } -const gridfire::reaction::ReactionSet& PyDynamicEngine::getNetworkReactions() const { +const gridfire::reaction::ReactionSet& PyDynamicEngine::getNetworkReactions( + gridfire::engine::scratch::StateBlob& ctx +) const { PYBIND11_OVERRIDE_PURE( const gridfire::reaction::ReactionSet&, gridfire::engine::DynamicEngine, - getNetworkReactions - ); -} - -void PyDynamicEngine::setNetworkReactions(const gridfire::reaction::ReactionSet& reactions) { - PYBIND11_OVERRIDE_PURE( - void, - gridfire::engine::DynamicEngine, - setNetworkReactions, - reactions + getNetworkReactions, + ctx ); } std::expected, gridfire::engine::EngineStatus> PyDynamicEngine::getSpeciesTimescales( + gridfire::engine::scratch::StateBlob& ctx, const fourdst::composition::CompositionAbstract &comp, double T9, double rho @@ -197,6 +164,7 @@ std::expected, gridfire::en PYBIND11_TYPE(std::expected, gridfire::engine::EngineStatus>), gridfire::engine::DynamicEngine, getSpeciesTimescales, + ctx, comp, T9, rho @@ -204,6 +172,7 @@ std::expected, gridfire::en } std::expected, gridfire::engine::EngineStatus> PyDynamicEngine::getSpeciesDestructionTimescales( + gridfire::engine::scratch::StateBlob& ctx, const fourdst::composition::CompositionAbstract &comp, double T9, double rho @@ -212,80 +181,71 @@ std::expected, gridfire::en PYBIND11_TYPE(std::expected, gridfire::engine::EngineStatus>), gridfire::engine::DynamicEngine, getSpeciesDestructionTimescales, - comp, T9, rho + ctx, comp, T9, rho ); } -fourdst::composition::Composition PyDynamicEngine::update(const gridfire::NetIn &netIn) { +fourdst::composition::Composition PyDynamicEngine::project( + gridfire::engine::scratch::StateBlob& ctx, + const gridfire::NetIn &netIn +) const { PYBIND11_OVERRIDE_PURE( fourdst::composition::Composition, gridfire::engine::DynamicEngine, - update, + project, + ctx, netIn ); } -bool PyDynamicEngine::isStale(const gridfire::NetIn &netIn) { - PYBIND11_OVERRIDE_PURE( - bool, - gridfire::engine::DynamicEngine, - isStale, - netIn - ); -} - -void PyDynamicEngine::setScreeningModel(gridfire::screening::ScreeningType model) { - PYBIND11_OVERRIDE_PURE( - void, - gridfire::engine::DynamicEngine, - setScreeningModel, - model - ); -} - -gridfire::screening::ScreeningType PyDynamicEngine::getScreeningModel() const { +gridfire::screening::ScreeningType PyDynamicEngine::getScreeningModel( + gridfire::engine::scratch::StateBlob& ctx +) const { PYBIND11_OVERRIDE_PURE( gridfire::screening::ScreeningType, gridfire::engine::DynamicEngine, - getScreeningModel + getScreeningModel, + ctx ); } -size_t PyDynamicEngine::getSpeciesIndex(const fourdst::atomic::Species &species) const { +size_t PyDynamicEngine::getSpeciesIndex( + gridfire::engine::scratch::StateBlob& ctx, + const fourdst::atomic::Species &species +) const { PYBIND11_OVERRIDE_PURE( int, gridfire::engine::DynamicEngine, getSpeciesIndex, + ctx, species ); } -std::vector PyDynamicEngine::mapNetInToMolarAbundanceVector(const gridfire::NetIn &netIn) const { - PYBIND11_OVERRIDE_PURE( - std::vector, - gridfire::engine::DynamicEngine, - mapNetInToMolarAbundanceVector, - netIn - ); -} - -gridfire::engine::PrimingReport PyDynamicEngine::primeEngine(const gridfire::NetIn &netIn) { +gridfire::engine::PrimingReport PyDynamicEngine::primeEngine( + gridfire::engine::scratch::StateBlob& ctx, + const gridfire::NetIn &netIn +) const { PYBIND11_OVERRIDE_PURE( gridfire::engine::PrimingReport, gridfire::engine::DynamicEngine, primeEngine, + ctx, netIn ); } gridfire::engine::EnergyDerivatives PyDynamicEngine::calculateEpsDerivatives( + gridfire::engine::scratch::StateBlob& ctx, const fourdst::composition::CompositionAbstract &comp, const double T9, - const double rho) const { + const double rho +) const { PYBIND11_OVERRIDE_PURE( gridfire::engine::EnergyDerivatives, gridfire::engine::DynamicEngine, calculateEpsDerivatives, + ctx, comp, T9, rho @@ -293,6 +253,7 @@ gridfire::engine::EnergyDerivatives PyDynamicEngine::calculateEpsDerivatives( } fourdst::composition::Composition PyDynamicEngine::collectComposition( + gridfire::engine::scratch::StateBlob& ctx, const fourdst::composition::CompositionAbstract &comp, const double T9, const double rho @@ -301,21 +262,37 @@ fourdst::composition::Composition PyDynamicEngine::collectComposition( fourdst::composition::Composition, gridfire::engine::DynamicEngine, collectComposition, + ctx, comp, T9, rho ); } -gridfire::engine::SpeciesStatus PyDynamicEngine::getSpeciesStatus(const fourdst::atomic::Species &species) const { +gridfire::engine::SpeciesStatus PyDynamicEngine::getSpeciesStatus( + gridfire::engine::scratch::StateBlob& ctx, + const fourdst::atomic::Species &species +) const { PYBIND11_OVERRIDE_PURE( gridfire::engine::SpeciesStatus, gridfire::engine::DynamicEngine, getSpeciesStatus, + ctx, species ); } +std::optional> PyDynamicEngine::getMostRecentRHSCalculation( + gridfire::engine::scratch::StateBlob &ctx +) const { + PYBIND11_OVERRIDE_PURE( + PYBIND11_TYPE(std::optional>), + gridfire::engine::DynamicEngine, + getMostRecentRHSCalculation, + ctx + ); +} + const gridfire::engine::Engine& PyEngineView::getBaseEngine() const { PYBIND11_OVERRIDE_PURE( const gridfire::engine::Engine&, diff --git a/src/python/engine/trampoline/py_engine.h b/src/python/engine/trampoline/py_engine.h index 3eaaf3ff..6c0cf8cf 100644 --- a/src/python/engine/trampoline/py_engine.h +++ b/src/python/engine/trampoline/py_engine.h @@ -10,12 +10,16 @@ class PyEngine final : public gridfire::engine::Engine { public: - const std::vector& getNetworkSpecies() const override; + const std::vector& getNetworkSpecies( + gridfire::engine::scratch::StateBlob& ctx + ) const override; std::expected, gridfire::engine::EngineStatus> calculateRHSAndEnergy( + gridfire::engine::scratch::StateBlob& ctx, const fourdst::composition::CompositionAbstract &comp, double T9, - double rho + double rho, + bool trust ) const override; private: mutable std::vector m_species_cache; @@ -23,21 +27,27 @@ private: class PyDynamicEngine final : public gridfire::engine::DynamicEngine { public: - const std::vector& getNetworkSpecies() const override; + const std::vector& getNetworkSpecies( + gridfire::engine::scratch::StateBlob& ctx + ) const override; std::expected, gridfire::engine::EngineStatus> calculateRHSAndEnergy( + gridfire::engine::scratch::StateBlob& ctx, const fourdst::composition::CompositionAbstract &comp, double T9, - double rho + double rho, + bool trust ) const override; gridfire::engine::NetworkJacobian generateJacobianMatrix( + gridfire::engine::scratch::StateBlob& ctx, const fourdst::composition::CompositionAbstract& comp, double T9, double rho ) const override; gridfire::engine::NetworkJacobian generateJacobianMatrix( + gridfire::engine::scratch::StateBlob& ctx, const fourdst::composition::CompositionAbstract &comp, double T9, double rho, @@ -45,96 +55,81 @@ public: ) const override; gridfire::engine::NetworkJacobian generateJacobianMatrix( + gridfire::engine::scratch::StateBlob& ctx, const fourdst::composition::CompositionAbstract& comp, double T9, double rho, const gridfire::engine::SparsityPattern &sparsityPattern ) const override; - void generateStoichiometryMatrix() override; - - int getStoichiometryMatrixEntry( - const fourdst::atomic::Species& species, - const gridfire::reaction::Reaction& reaction - ) const override; - double calculateMolarReactionFlow( + gridfire::engine::scratch::StateBlob& ctx, const gridfire::reaction::Reaction &reaction, const fourdst::composition::CompositionAbstract &comp, double T9, double rho ) const override; - const gridfire::reaction::ReactionSet& getNetworkReactions() const override; - - void setNetworkReactions( - const gridfire::reaction::ReactionSet& reactions - ) override; + const gridfire::reaction::ReactionSet& getNetworkReactions( + gridfire::engine::scratch::StateBlob& ctx + ) const override; std::expected, gridfire::engine::EngineStatus> getSpeciesTimescales( + gridfire::engine::scratch::StateBlob& ctx, const fourdst::composition::CompositionAbstract &comp, double T9, double rho ) const override; std::expected, gridfire::engine::EngineStatus> getSpeciesDestructionTimescales( + gridfire::engine::scratch::StateBlob& ctx, const fourdst::composition::CompositionAbstract &comp, double T9, double rho ) const override; - fourdst::composition::Composition update( + fourdst::composition::Composition project( + gridfire::engine::scratch::StateBlob& ctx, const gridfire::NetIn &netIn - ) override; + ) const override; - bool isStale( - const gridfire::NetIn &netIn - ) override; - - void setScreeningModel( - gridfire::screening::ScreeningType model - ) override; - - gridfire::screening::ScreeningType getScreeningModel() const override; + gridfire::screening::ScreeningType getScreeningModel( + gridfire::engine::scratch::StateBlob& ctx + ) const override; size_t getSpeciesIndex( + gridfire::engine::scratch::StateBlob& ctx, const fourdst::atomic::Species &species ) const override; - std::vector mapNetInToMolarAbundanceVector( + gridfire::engine::PrimingReport primeEngine( + gridfire::engine::scratch::StateBlob& ctx, const gridfire::NetIn &netIn ) const override; - gridfire::engine::PrimingReport primeEngine( - const gridfire::NetIn &netIn - ) override; - - gridfire::engine::BuildDepthType getDepth() const override { - throw std::logic_error("Network depth not supported by this engine."); - } - void rebuild( - const fourdst::composition::CompositionAbstract &comp, - gridfire::engine::BuildDepthType depth - ) override { - throw std::logic_error("Setting network depth not supported by this engine."); - } - [[nodiscard]] gridfire::engine::EnergyDerivatives calculateEpsDerivatives( + gridfire::engine::scratch::StateBlob& ctx, const fourdst::composition::CompositionAbstract &comp, double T9, double rho ) const override; fourdst::composition::Composition collectComposition( + gridfire::engine::scratch::StateBlob& ctx, const fourdst::composition::CompositionAbstract &comp, double T9, double rho ) const override; gridfire::engine::SpeciesStatus getSpeciesStatus( + gridfire::engine::scratch::StateBlob& ctx, const fourdst::atomic::Species &species ) const override; + std::optional> getMostRecentRHSCalculation( + gridfire::engine::scratch::StateBlob &ctx + ) const override; + private: mutable std::vector m_species_cache; }; diff --git a/src/python/exceptions/bindings.cpp b/src/python/exceptions/bindings.cpp index 14110dce..9575b1b3 100644 --- a/src/python/exceptions/bindings.cpp +++ b/src/python/exceptions/bindings.cpp @@ -2,6 +2,8 @@ #include "bindings.h" +#include "gridfire/exceptions/error_scratchpad.h" + namespace py = pybind11; #include "gridfire/exceptions/exceptions.h" @@ -44,4 +46,6 @@ void register_exception_bindings(const py::module &m) { py::register_exception(m, "CVODESolverFailureError", m.attr("SUNDIALSError")); py::register_exception(m, "KINSolSolverFailureError", m.attr("SUNDIALSError")); + py::register_exception(m, "ScratchPadError", m.attr("GridFireError")); + } diff --git a/src/python/exceptions/meson.build b/src/python/exceptions/meson.build deleted file mode 100644 index e644dce6..00000000 --- a/src/python/exceptions/meson.build +++ /dev/null @@ -1,17 +0,0 @@ -# Define the library -bindings_sources = files('bindings.cpp') -bindings_headers = files('bindings.h') - -dependencies = [ - gridfire_dep, - python3_dep, - pybind11_dep, -] - -shared_module('py_gf_exceptions', - bindings_sources, - cpp_args: ['-fvisibility=default'], - install : true, - dependencies: dependencies, - include_directories: include_directories('.') -) diff --git a/src/python/gridfire/__init__.py b/src/python/gridfire/__init__.py index 65d6e5e5..b0d38784 100644 --- a/src/python/gridfire/__init__.py +++ b/src/python/gridfire/__init__.py @@ -1,7 +1,7 @@ from ._gridfire import * import sys -from ._gridfire import type, utils, engine, solver, exceptions, partition, reaction, screening, io, policy +from ._gridfire import type, utils, engine, solver, exceptions, partition, reaction, screening, io, policy, config sys.modules['gridfire.type'] = type sys.modules['gridfire.utils'] = utils @@ -13,8 +13,61 @@ sys.modules['gridfire.reaction'] = reaction sys.modules['gridfire.screening'] = screening sys.modules['gridfire.policy'] = policy sys.modules['gridfire.io'] = io +sys.modules['gridfire.config'] = config -__all__ = ['type', 'utils', 'engine', 'solver', 'exceptions', 'partition', 'reaction', 'screening', 'io', 'policy'] +__all__ = ['type', 'utils', 'engine', 'solver', 'exceptions', 'partition', 'reaction', 'screening', 'io', 'policy', 'config'] -__version__ = "v0.7.4_rc2" +import importlib.metadata +try: + _meta = importlib.metadata.metadata('gridfire') + __version__ = _meta['Version'] + __author__ = _meta['Author'] + __license__ = _meta['License'] + __email__ = _meta['Author-email'] + __url__ = _meta['Home-page'] or _meta.get('Project-URL', '').split(',')[0].split(' ')[-1].strip() + __description__ = _meta['Summary'] +except importlib.metadata.PackageNotFoundError : + __version__ = 'unknown - Package not installed' + __author__ = 'Emily M. Boudreaux' + __license__ = 'GNU General Public License v3.0' + __email__ = 'emily.boudreaux@dartmouth.edu' + __url__ = 'https://github.com/4D-STAR/GridFire' + +def gf_metadata(): + return { + 'version': __version__, + 'author': __author__, + 'license': __license__, + 'email': __email__, + 'url': __url__, + 'description': __description__ + } + +def gf_version(): + return __version__ + +def gf_author(): + return __author__ + +def gf_license(): + return __license__ + +def gf_email(): + return __email__ + +def gf_url(): + return __url__ + +def gf_description(): + return __description__ + +def gf_collaboration(): + return "4D-STAR Collaboration" + +def gf_credits(): + return [ + "Emily M. Boudreaux - Lead Developer", + "Aaron Dotter - Co-Developer", + "4D-STAR Collaboration - Contributors" + ] \ No newline at end of file diff --git a/src/python/io/meson.build b/src/python/io/meson.build deleted file mode 100644 index 998cd712..00000000 --- a/src/python/io/meson.build +++ /dev/null @@ -1,17 +0,0 @@ -# Define the library -bindings_sources = files('bindings.cpp') -bindings_headers = files('bindings.h') - -dependencies = [ - gridfire_dep, - python3_dep, - pybind11_dep, -] - -shared_module('py_gf_io', - bindings_sources, - cpp_args: ['-fvisibility=default'], - install : true, - dependencies: dependencies, - include_directories: include_directories('.') -) diff --git a/src/python/io/trampoline/meson.build b/src/python/io/trampoline/meson.build deleted file mode 100644 index 8fc8552c..00000000 --- a/src/python/io/trampoline/meson.build +++ /dev/null @@ -1,21 +0,0 @@ -gf_io_trampoline_sources = files('py_io.cpp') - -gf_io_trapoline_dependencies = [ - gridfire_dep, - pybind11_dep, - python3_dep, -] - -gf_io_trampoline_lib = static_library( - 'io_trampolines', - gf_io_trampoline_sources, - include_directories: include_directories('.'), - dependencies: gf_io_trapoline_dependencies, - install: false, -) - -gr_io_trampoline_dep = declare_dependency( - link_with: gf_io_trampoline_lib, - include_directories: ('.'), - dependencies: gf_io_trapoline_dependencies, -) diff --git a/src/python/meson.build b/src/python/meson.build deleted file mode 100644 index c38cfbed..00000000 --- a/src/python/meson.build +++ /dev/null @@ -1,10 +0,0 @@ -subdir('types') -subdir('utils') -subdir('exceptions') -subdir('io') -subdir('partition') -subdir('reaction') -subdir('screening') -subdir('engine') -subdir('policy') -subdir('solver') diff --git a/src/python/partition/meson.build b/src/python/partition/meson.build deleted file mode 100644 index 2dc31349..00000000 --- a/src/python/partition/meson.build +++ /dev/null @@ -1,19 +0,0 @@ -subdir('trampoline') - -# Define the library -bindings_sources = files('bindings.cpp') -bindings_headers = files('bindings.h') - -dependencies = [ - gridfire_dep, - python3_dep, - pybind11_dep, -] - -shared_module('py_gf_partition', - bindings_sources, - cpp_args: ['-fvisibility=default'], - install : true, - dependencies: dependencies, - include_directories: include_directories('.') -) diff --git a/src/python/partition/trampoline/meson.build b/src/python/partition/trampoline/meson.build deleted file mode 100644 index 1115b683..00000000 --- a/src/python/partition/trampoline/meson.build +++ /dev/null @@ -1,21 +0,0 @@ -gf_partition_trampoline_sources = files('py_partition.cpp') - -gf_partition_trapoline_dependencies = [ - gridfire_dep, - pybind11_dep, - python3_dep, -] - -gf_partition_trampoline_lib = static_library( - 'partition_trampolines', - gf_partition_trampoline_sources, - include_directories: include_directories('.'), - dependencies: gf_partition_trapoline_dependencies, - install: false, -) - -gr_partition_trampoline_dep = declare_dependency( - link_with: gf_partition_trampoline_lib, - include_directories: ('.'), - dependencies: gf_partition_trapoline_dependencies, -) diff --git a/src/python/policy/bindings.cpp b/src/python/policy/bindings.cpp index 175936a9..d82897f6 100644 --- a/src/python/policy/bindings.cpp +++ b/src/python/policy/bindings.cpp @@ -8,7 +8,6 @@ #include "gridfire/policy/policy.h" -PYBIND11_DECLARE_HOLDER_TYPE(T, std::unique_ptr, true) // Declare unique_ptr as a holder type for pybind11 namespace py = pybind11; @@ -103,9 +102,30 @@ namespace { .def( "construct", &T::construct, - py::return_value_policy::reference, "Construct the network according to the policy." + ) + .def( + "get_engine_stack", + [](const T &self) { + const auto& stack = self.get_engine_stack(); + std::vector engine_ptrs; + engine_ptrs.reserve(stack.size()); + for (const auto& engine_uptr : stack) { + engine_ptrs.push_back(engine_uptr.get()); + } + + return engine_ptrs; + }, + py::return_value_policy::reference_internal + ) + .def( + "get_stack_scratch_blob", + &T::get_stack_scratch_blob + ) + .def( + "get_partition_function", + &T::get_partition_function ); } } @@ -215,6 +235,26 @@ void register_network_policy_bindings(pybind11::module &m) { .value("INITIALIZED_VERIFIED", gridfire::policy::NetworkPolicyStatus::INITIALIZED_VERIFIED) .export_values(); + m.def("network_policy_status_to_string", + &gridfire::policy::NetworkPolicyStatusToString, + py::arg("status"), + "Convert a NetworkPolicyStatus enum value to its string representation." + ); + + py::class_(m, "ConstructionResults") + .def_property_readonly("engine", + [](const gridfire::policy::ConstructionResults &self) -> const gridfire::engine::DynamicEngine& { + return self.engine; + }, + py::return_value_policy::reference + ) + .def_property_readonly("scratch_blob", + [](const gridfire::policy::ConstructionResults &self) { + return self.scratch_blob.get(); + }, + py::return_value_policy::reference_internal + ); + py::class_ py_networkPolicy(m, "NetworkPolicy"); py::class_ py_mainSeqPolicy(m, "MainSequencePolicy"); py_mainSeqPolicy.def( diff --git a/src/python/policy/meson.build b/src/python/policy/meson.build deleted file mode 100644 index 9913850e..00000000 --- a/src/python/policy/meson.build +++ /dev/null @@ -1,19 +0,0 @@ -# Define the library -subdir('trampoline') - -bindings_sources = files('bindings.cpp') -bindings_headers = files('bindings.h') - -dependencies = [ - gridfire_dep, - python3_dep, - pybind11_dep, -] - -shared_module('py_gf_policy', - bindings_sources, - cpp_args: ['-fvisibility=default'], - install : true, - dependencies: dependencies, - include_directories: include_directories('.') -) diff --git a/src/python/policy/trampoline/meson.build b/src/python/policy/trampoline/meson.build deleted file mode 100644 index e0cf7622..00000000 --- a/src/python/policy/trampoline/meson.build +++ /dev/null @@ -1,21 +0,0 @@ -gf_policy_trampoline_sources = files('py_policy.cpp') - -gf_policy_trapoline_dependencies = [ - gridfire_dep, - pybind11_dep, - python3_dep, -] - -gf_policy_trampoline_lib = static_library( - 'policy_trampolines', - gf_policy_trampoline_sources, - include_directories: include_directories('.'), - dependencies: gf_policy_trapoline_dependencies, - install: false, -) - -gr_policy_trampoline_dep = declare_dependency( - link_with: gf_policy_trampoline_lib, - include_directories: ('.'), - dependencies: gf_policy_trapoline_dependencies, -) diff --git a/src/python/policy/trampoline/py_policy.cpp b/src/python/policy/trampoline/py_policy.cpp index 600f4186..2c934e70 100644 --- a/src/python/policy/trampoline/py_policy.cpp +++ b/src/python/policy/trampoline/py_policy.cpp @@ -39,9 +39,9 @@ const gridfire::reaction::ReactionSet& PyNetworkPolicy::get_seed_reactions() con ); } -gridfire::engine::DynamicEngine& PyNetworkPolicy::construct() { +gridfire::policy::ConstructionResults PyNetworkPolicy::construct() { PYBIND11_OVERRIDE_PURE( - gridfire::engine::DynamicEngine&, + gridfire::policy::ConstructionResults, gridfire::policy::NetworkPolicy, construct ); @@ -79,6 +79,14 @@ const std::unique_ptr& PyNetworkPolicy:: ); } +std::unique_ptr PyNetworkPolicy::get_stack_scratch_blob() const { + PYBIND11_OVERRIDE_PURE( + std::unique_ptr, + gridfire::policy::NetworkPolicy, + get_stack_scratch_blob + ); +} + const gridfire::reaction::ReactionSet &PyReactionChainPolicy::get_reactions() const { PYBIND11_OVERRIDE_PURE( const gridfire::reaction::ReactionSet &, diff --git a/src/python/policy/trampoline/py_policy.h b/src/python/policy/trampoline/py_policy.h index 91c6692b..43b67ea4 100644 --- a/src/python/policy/trampoline/py_policy.h +++ b/src/python/policy/trampoline/py_policy.h @@ -13,7 +13,7 @@ public: [[nodiscard]] const gridfire::reaction::ReactionSet& get_seed_reactions() const override; - [[nodiscard]] gridfire::engine::DynamicEngine& construct() override; + [[nodiscard]] gridfire::policy::ConstructionResults construct() override; [[nodiscard]] gridfire::policy::NetworkPolicyStatus get_status() const override; @@ -22,6 +22,8 @@ public: [[nodiscard]] std::vector get_engine_types_stack() const override; [[nodiscard]] const std::unique_ptr& get_partition_function() const override; + + [[nodiscard]] std::unique_ptr get_stack_scratch_blob() const override; }; class PyReactionChainPolicy final : public gridfire::policy::ReactionChainPolicy { diff --git a/src/python/reaction/meson.build b/src/python/reaction/meson.build deleted file mode 100644 index ca4dc8ee..00000000 --- a/src/python/reaction/meson.build +++ /dev/null @@ -1,17 +0,0 @@ -# Define the library -bindings_sources = files('bindings.cpp') -bindings_headers = files('bindings.h') - -dependencies = [ - gridfire_dep, - python3_dep, - pybind11_dep, -] - -shared_module('py_gf_reaction', - bindings_sources, - cpp_args: ['-fvisibility=default'], - install : true, - dependencies: dependencies, - include_directories: include_directories('.') -) diff --git a/src/python/screening/meson.build b/src/python/screening/meson.build deleted file mode 100644 index 99f7dd89..00000000 --- a/src/python/screening/meson.build +++ /dev/null @@ -1,19 +0,0 @@ -subdir('trampoline') - -# Define the library -bindings_sources = files('bindings.cpp') -bindings_headers = files('bindings.h') - -dependencies = [ - gridfire_dep, - python3_dep, - pybind11_dep, -] - -shared_module('py_gf_screening', - bindings_sources, - cpp_args: ['-fvisibility=default'], - install : true, - dependencies: dependencies, - include_directories: include_directories('.') -) diff --git a/src/python/screening/trampoline/meson.build b/src/python/screening/trampoline/meson.build deleted file mode 100644 index 45552332..00000000 --- a/src/python/screening/trampoline/meson.build +++ /dev/null @@ -1,21 +0,0 @@ -gf_screening_trampoline_sources = files('py_screening.cpp') - -gf_screening_trapoline_dependencies = [ - gridfire_dep, - pybind11_dep, - python3_dep, -] - -gf_screening_trampoline_lib = static_library( - 'screening_trampolines', - gf_screening_trampoline_sources, - include_directories: include_directories('.'), - dependencies: gf_screening_trapoline_dependencies, - install: false, -) - -gr_screening_trampoline_dep = declare_dependency( - link_with: gf_screening_trampoline_lib, - include_directories: ('.'), - dependencies: gf_screening_trapoline_dependencies, -) diff --git a/src/python/solver/bindings.cpp b/src/python/solver/bindings.cpp index dd4e85f3..ec706ecd 100644 --- a/src/python/solver/bindings.cpp +++ b/src/python/solver/bindings.cpp @@ -7,125 +7,226 @@ #include "bindings.h" -#include "gridfire/solver/strategies/CVODE_solver_strategy.h" +#include "gridfire/solver/strategies/PointSolver.h" +#include "gridfire/engine/scratchpads/blob.h" #include "trampoline/py_solver.h" namespace py = pybind11; void register_solver_bindings(const py::module &m) { - auto py_solver_context_base = py::class_(m, "SolverContextBase"); - - auto py_cvode_timestep_context = py::class_(m, "CVODETimestepContext"); - py_cvode_timestep_context.def_readonly("t", &gridfire::solver::CVODESolverStrategy::TimestepContext::t); + auto py_cvode_timestep_context = py::class_(m, "PointSolverTimestepContext"); + py_cvode_timestep_context.def_readonly("t", &gridfire::solver::PointSolverTimestepContext::t); py_cvode_timestep_context.def_property_readonly( "state", - [](const gridfire::solver::CVODESolverStrategy::TimestepContext& self) -> std::vector { + [](const gridfire::solver::PointSolverTimestepContext& self) -> std::vector { const sunrealtype* nvec_data = N_VGetArrayPointer(self.state); const sunindextype length = N_VGetLength(self.state); - return std::vector(nvec_data, nvec_data + length); + return {nvec_data, nvec_data + length}; } ); - py_cvode_timestep_context.def_readonly("dt", &gridfire::solver::CVODESolverStrategy::TimestepContext::dt); - py_cvode_timestep_context.def_readonly("last_step_time", &gridfire::solver::CVODESolverStrategy::TimestepContext::last_step_time); - py_cvode_timestep_context.def_readonly("T9", &gridfire::solver::CVODESolverStrategy::TimestepContext::T9); - py_cvode_timestep_context.def_readonly("rho", &gridfire::solver::CVODESolverStrategy::TimestepContext::rho); - py_cvode_timestep_context.def_readonly("num_steps", &gridfire::solver::CVODESolverStrategy::TimestepContext::num_steps); - py_cvode_timestep_context.def_readonly("currentConvergenceFailures", &gridfire::solver::CVODESolverStrategy::TimestepContext::currentConvergenceFailures); - py_cvode_timestep_context.def_readonly("currentNonlinearIterations", &gridfire::solver::CVODESolverStrategy::TimestepContext::currentNonlinearIterations); + py_cvode_timestep_context.def_readonly("dt", &gridfire::solver::PointSolverTimestepContext::dt); + py_cvode_timestep_context.def_readonly("last_step_time", &gridfire::solver::PointSolverTimestepContext::last_step_time); + py_cvode_timestep_context.def_readonly("T9", &gridfire::solver::PointSolverTimestepContext::T9); + py_cvode_timestep_context.def_readonly("rho", &gridfire::solver::PointSolverTimestepContext::rho); + py_cvode_timestep_context.def_readonly("num_steps", &gridfire::solver::PointSolverTimestepContext::num_steps); + py_cvode_timestep_context.def_readonly("currentConvergenceFailures", &gridfire::solver::PointSolverTimestepContext::currentConvergenceFailures); + py_cvode_timestep_context.def_readonly("currentNonlinearIterations", &gridfire::solver::PointSolverTimestepContext::currentNonlinearIterations); py_cvode_timestep_context.def_property_readonly( "engine", - [](const gridfire::solver::CVODESolverStrategy::TimestepContext& self) -> const gridfire::engine::DynamicEngine& { + [](const gridfire::solver::PointSolverTimestepContext& self) -> const gridfire::engine::DynamicEngine& { return self.engine; } ); py_cvode_timestep_context.def_property_readonly( "networkSpecies", - [](const gridfire::solver::CVODESolverStrategy::TimestepContext& self) -> std::vector { + [](const gridfire::solver::PointSolverTimestepContext& self) -> std::vector { return self.networkSpecies; } ); + py_cvode_timestep_context.def_property_readonly( + "state_ctx", + [](const gridfire::solver::PointSolverTimestepContext& self) { + return &(self.state_ctx); + }, + py::return_value_policy::reference_internal + ); - auto py_dynamic_network_solver_strategy = py::class_(m, "DynamicNetworkSolverStrategy"); - py_dynamic_network_solver_strategy.def( + + auto py_solver_context_base = py::class_(m, "SolverContextBase"); + auto py_point_solver_context = py::class_(m, "PointSolverContext"); + + py_point_solver_context + .def_readonly( + "sun_ctx", &gridfire::solver::PointSolverContext::sun_ctx + ) + .def_readonly( + "cvode_mem", &gridfire::solver::PointSolverContext::cvode_mem + ) + .def_readonly( + "Y", &gridfire::solver::PointSolverContext::Y + ) + .def_readonly( + "YErr", &gridfire::solver::PointSolverContext::YErr + ) + .def_readonly( + "J", &gridfire::solver::PointSolverContext::J + ) + .def_readonly( + "LS", &gridfire::solver::PointSolverContext::LS + ) + .def_property_readonly( + "engine_ctx", + [](const gridfire::solver::PointSolverContext& self) -> gridfire::engine::scratch::StateBlob& { + return *(self.engine_ctx); + }, + py::return_value_policy::reference + ) + .def_readonly( + "num_steps", &gridfire::solver::PointSolverContext::num_steps + ) + .def_property( + "abs_tol", + [](const gridfire::solver::PointSolverContext& self) -> double { + return self.abs_tol.value(); + }, + [](gridfire::solver::PointSolverContext& self, double abs_tol) -> void { + self.abs_tol = abs_tol; + } + ) + .def_property( + "rel_tol", + [](const gridfire::solver::PointSolverContext& self) -> double { + return self.rel_tol.value(); + }, + [](gridfire::solver::PointSolverContext& self, double rel_tol) -> void { + self.rel_tol = rel_tol; + } + ) + .def_property( + "stdout_logging", + [](const gridfire::solver::PointSolverContext& self) -> bool { + return self.stdout_logging; + }, + [](gridfire::solver::PointSolverContext& self, const bool enable) -> void { + self.stdout_logging = enable; + } + ) + .def_property( + "detailed_logging", + [](const gridfire::solver::PointSolverContext& self) -> bool { + return self.detailed_step_logging; + }, + [](gridfire::solver::PointSolverContext& self, const bool enable) -> void { + self.detailed_step_logging = enable; + } + ) + .def_property( + "callback", + [](const gridfire::solver::PointSolverContext& self) -> std::optional> { + return self.callback; + }, + [](gridfire::solver::PointSolverContext& self, const std::optional>& cb) { + self.callback = cb; + } + ) + .def("reset_all", &gridfire::solver::PointSolverContext::reset_all) + .def("reset_user", &gridfire::solver::PointSolverContext::reset_user) + .def("reset_cvode", &gridfire::solver::PointSolverContext::reset_cvode) + .def("clear_context", &gridfire::solver::PointSolverContext::clear_context) + .def("init_context", &gridfire::solver::PointSolverContext::init_context) + .def("has_context", &gridfire::solver::PointSolverContext::has_context) + .def("init", &gridfire::solver::PointSolverContext::init) + .def(py::init(), py::arg("engine_ctx")); + + + + auto py_single_zone_dynamic_network_solver = py::class_(m, "SingleZoneDynamicNetworkSolver"); + py_single_zone_dynamic_network_solver.def( "evaluate", - &gridfire::solver::DynamicNetworkSolverStrategy::evaluate, + &gridfire::solver::SingleZoneDynamicNetworkSolver::evaluate, + py::arg("solver_ctx"), py::arg("netIn"), - "evaluate the dynamic engine using the dynamic engine class" + "evaluate the dynamic engine using the dynamic engine class for a single zone" + ); + auto py_multi_zone_dynamic_network_solver = py::class_(m, "MultiZoneDynamicNetworkSolver"); + py_multi_zone_dynamic_network_solver.def( + "evaluate", + &gridfire::solver::MultiZoneDynamicNetworkSolver::evaluate, + py::arg("solver_ctx"), + py::arg("netIns"), + "evaluate the dynamic engine using the dynamic engine class for multiple zones (using openmp if available)" ); + auto py_point_solver = py::class_(m, "PointSolver"); - py_dynamic_network_solver_strategy.def( - "describe_callback_context", - &gridfire::solver::DynamicNetworkSolverStrategy::describe_callback_context, - "Get a structure representing what data is in the callback context in a human readable format" - ); - - auto py_cvode_solver_strategy = py::class_(m, "CVODESolverStrategy"); - - py_cvode_solver_strategy.def( + py_point_solver.def( py::init(), py::arg("engine"), - "Initialize the CVODESolverStrategy object." + "Initialize the PointSolver object." ); - py_cvode_solver_strategy.def( + py_point_solver.def( "evaluate", - py::overload_cast(&gridfire::solver::CVODESolverStrategy::evaluate), + py::overload_cast(&gridfire::solver::PointSolver::evaluate, py::const_), + py::arg("solver_ctx"), py::arg("netIn"), py::arg("display_trigger") = false, + py::arg("force_reinitialization") = false, "evaluate the dynamic engine using the dynamic engine class" ); - py_cvode_solver_strategy.def( - "get_stdout_logging_enabled", - &gridfire::solver::CVODESolverStrategy::get_stdout_logging_enabled, - "Check if solver logging to standard output is enabled." + auto py_grid_solver_context = py::class_(m, "GridSolverContext"); + py_grid_solver_context.def(py::init(), py::arg("ctx_template")); + py_grid_solver_context.def("init", &gridfire::solver::GridSolverContext::init); + py_grid_solver_context.def("reset", &gridfire::solver::GridSolverContext::reset); + py_grid_solver_context.def("set_callback", py::overload_cast&>(&gridfire::solver::GridSolverContext::set_callback) , py::arg("callback")); + py_grid_solver_context.def("set_callback", py::overload_cast&, size_t>(&gridfire::solver::GridSolverContext::set_callback) , py::arg("callback"), py::arg("zone_idx")); + py_grid_solver_context.def("clear_callback", py::overload_cast<>(&gridfire::solver::GridSolverContext::clear_callback)); + py_grid_solver_context.def("clear_callback", py::overload_cast(&gridfire::solver::GridSolverContext::clear_callback), py::arg("zone_idx")); + py_grid_solver_context.def_property( + "stdout_logging", + [](const gridfire::solver::GridSolverContext& self) -> bool { + return self.zone_stdout_logging; + }, + [](gridfire::solver::GridSolverContext& self, const bool enable) -> void { + self.zone_stdout_logging = enable; + } + ) + .def_property( + "detailed_logging", + [](const gridfire::solver::GridSolverContext& self) -> bool { + return self.zone_detailed_logging; + }, + [](gridfire::solver::GridSolverContext& self, const bool enable) -> void { + self.zone_detailed_logging = enable; + } + ) + .def_property( + "zone_completion_logging", + [](const gridfire::solver::GridSolverContext& self) -> bool { + return self.zone_completion_logging; + }, + [](gridfire::solver::GridSolverContext& self, const bool enable) -> void { + self.zone_completion_logging = enable; + } ); - py_cvode_solver_strategy.def( - "set_stdout_logging_enabled", - &gridfire::solver::CVODESolverStrategy::set_stdout_logging_enabled, - py::arg("logging_enabled"), - "Enable logging to standard output." + auto py_grid_solver = py::class_(m, "GridSolver"); + py_grid_solver.def( + py::init(), + py::arg("engine"), + py::arg("solver"), + "Initialize the GridSolver object." ); - py_cvode_solver_strategy.def( - "set_absTol", - &gridfire::solver::CVODESolverStrategy::set_absTol, - py::arg("absTol"), - "Set the absolute tolerance for the CVODE solver." + py_grid_solver.def( + "evaluate", + &gridfire::solver::GridSolver::evaluate, + py::arg("solver_ctx"), + py::arg("netIns"), + "evaluate the dynamic engine using the dynamic engine class" ); - py_cvode_solver_strategy.def( - "set_relTol", - &gridfire::solver::CVODESolverStrategy::set_relTol, - py::arg("relTol"), - "Set the relative tolerance for the CVODE solver." - ); - - py_cvode_solver_strategy.def( - "get_absTol", - &gridfire::solver::CVODESolverStrategy::get_absTol, - "Get the absolute tolerance for the CVODE solver." - ); - - py_cvode_solver_strategy.def( - "get_relTol", - &gridfire::solver::CVODESolverStrategy::get_relTol, - "Get the relative tolerance for the CVODE solver." - ); - - py_cvode_solver_strategy.def( - "set_callback", - []( - gridfire::solver::CVODESolverStrategy& self, - std::function cb - ) { - self.set_callback(std::any(cb)); - }, - py::arg("cb"), - "Set a callback function which will run at the end of every successful timestep" - ); } diff --git a/src/python/solver/meson.build b/src/python/solver/meson.build deleted file mode 100644 index e21ee519..00000000 --- a/src/python/solver/meson.build +++ /dev/null @@ -1,17 +0,0 @@ -# Define the library -bindings_sources = files('bindings.cpp') -bindings_headers = files('bindings.h') - -dependencies = [ - gridfire_dep, - python3_dep, - pybind11_dep, -] - -shared_module('py_gf_solver', - bindings_sources, - cpp_args: ['-fvisibility=default'], - install : true, - dependencies: dependencies, - include_directories: include_directories('.') -) diff --git a/src/python/solver/trampoline/meson.build b/src/python/solver/trampoline/meson.build deleted file mode 100644 index b252dba6..00000000 --- a/src/python/solver/trampoline/meson.build +++ /dev/null @@ -1,21 +0,0 @@ -gf_solver_trampoline_sources = files('py_solver.cpp') - -gf_solver_trapoline_dependencies = [ - gridfire_dep, - pybind11_dep, - python3_dep, -] - -gf_solver_trampoline_lib = static_library( - 'solver_trampolines', - gf_solver_trampoline_sources, - include_directories: include_directories('.'), - dependencies: gf_solver_trapoline_dependencies, - install: false, -) - -gr_solver_trampoline_dep = declare_dependency( - link_with: gf_solver_trampoline_lib, - include_directories: ('.'), - dependencies: gf_solver_trapoline_dependencies, -) diff --git a/src/python/solver/trampoline/py_solver.cpp b/src/python/solver/trampoline/py_solver.cpp index 2b735571..abdc5622 100644 --- a/src/python/solver/trampoline/py_solver.cpp +++ b/src/python/solver/trampoline/py_solver.cpp @@ -13,38 +13,63 @@ namespace py = pybind11; -gridfire::NetOut PyDynamicNetworkSolverStrategy::evaluate(const gridfire::NetIn &netIn) { +gridfire::NetOut PySingleZoneDynamicNetworkSolver::evaluate( + gridfire::solver::SolverContextBase &solver_ctx, + const gridfire::NetIn &netIn +) const { PYBIND11_OVERRIDE_PURE( - gridfire::NetOut, // Return type - gridfire::solver::DynamicNetworkSolverStrategy, // Base class - evaluate, // Method name - netIn // Arguments + gridfire::NetOut, + gridfire::solver::SingleZoneDynamicNetworkSolver, + evaluate, + solver_ctx, + netIn ); } -void PyDynamicNetworkSolverStrategy::set_callback(const std::any &callback) { +std::vector PyMultiZoneDynamicNetworkSolver::evaluate( + gridfire::solver::SolverContextBase &solver_ctx, + const std::vector &netIns +) const { PYBIND11_OVERRIDE_PURE( - void, - gridfire::solver::DynamicNetworkSolverStrategy, // Base class - set_callback, // Method name - callback // Arguments + std::vector, + gridfire::solver::MultiZoneDynamicNetworkSolver, + evaluate, + solver_ctx, + netIns ); } -std::vector> PyDynamicNetworkSolverStrategy::describe_callback_context() const { - using DescriptionVector = std::vector>; +std::vector> PyTimestepContextBase::describe() const { + using ReturnType = std::vector>; PYBIND11_OVERRIDE_PURE( - DescriptionVector, // Return type - gridfire::solver::DynamicNetworkSolverStrategy, // Base class - describe_callback_context // Method name - ); -} - -std::vector> PySolverContextBase::describe() const { - using DescriptionVector = std::vector>; - PYBIND11_OVERRIDE_PURE( - DescriptionVector, - gridfire::solver::SolverContextBase, + ReturnType, + gridfire::solver::TimestepContextBase, describe ); } + +void PySolverContextBase::init() { + PYBIND11_OVERRIDE_PURE( + void, + gridfire::solver::SolverContextBase, + init + ); +} + +void PySolverContextBase::set_stdout_logging(bool enable) { + PYBIND11_OVERRIDE_PURE( + void, + gridfire::solver::SolverContextBase, + set_stdout_logging, + enable + ); +} + +void PySolverContextBase::set_detailed_logging(bool enable) { + PYBIND11_OVERRIDE_PURE( + void, + gridfire::solver::SolverContextBase, + set_detailed_logging, + enable + ); +} \ No newline at end of file diff --git a/src/python/solver/trampoline/py_solver.h b/src/python/solver/trampoline/py_solver.h index ef0713de..98a17414 100644 --- a/src/python/solver/trampoline/py_solver.h +++ b/src/python/solver/trampoline/py_solver.h @@ -7,14 +7,37 @@ #include #include -class PyDynamicNetworkSolverStrategy final : public gridfire::solver::DynamicNetworkSolverStrategy { - explicit PyDynamicNetworkSolverStrategy(gridfire::engine::DynamicEngine &engine) : gridfire::solver::DynamicNetworkSolverStrategy(engine) {} - gridfire::NetOut evaluate(const gridfire::NetIn &netIn) override; - void set_callback(const std::any &callback) override; - [[nodiscard]] std::vector> describe_callback_context() const override; +class PySingleZoneDynamicNetworkSolver final : public gridfire::solver::SingleZoneDynamicNetworkSolver { +public: + explicit PySingleZoneDynamicNetworkSolver(const gridfire::engine::DynamicEngine &engine) : gridfire::solver::SingleZoneDynamicNetworkSolver(engine) {} + + gridfire::NetOut evaluate( + gridfire::solver::SolverContextBase &solver_ctx, + const gridfire::NetIn &netIn + ) const override; +}; + +class PyMultiZoneDynamicNetworkSolver final : public gridfire::solver::MultiZoneDynamicNetworkSolver { +public: + explicit PyMultiZoneDynamicNetworkSolver( + const gridfire::engine::DynamicEngine &engine, + const gridfire::solver::SingleZoneDynamicNetworkSolver &local_solver + ) : gridfire::solver::MultiZoneDynamicNetworkSolver(engine, local_solver) {} + + std::vector evaluate( + gridfire::solver::SolverContextBase &solver_ctx, + const std::vector &netIns + ) const override; +}; + +class PyTimestepContextBase final : public gridfire::solver::TimestepContextBase { +public: + [[nodiscard]] std::vector> describe() const override; }; class PySolverContextBase final : public gridfire::solver::SolverContextBase { public: - [[nodiscard]] std::vector> describe() const override; -}; \ No newline at end of file + void init() override; + void set_stdout_logging(bool enable) override; + void set_detailed_logging(bool enable) override; +}; diff --git a/src/python/types/meson.build b/src/python/types/meson.build deleted file mode 100644 index d76e8b6e..00000000 --- a/src/python/types/meson.build +++ /dev/null @@ -1,17 +0,0 @@ -# Define the library -bindings_sources = files('bindings.cpp') -bindings_headers = files('bindings.h') - -dependencies = [ - gridfire_dep, - python3_dep, - pybind11_dep, -] - -shared_module('py_gf_types', - bindings_sources, - cpp_args: ['-fvisibility=default'], - install : true, - dependencies: dependencies, - include_directories: include_directories('.') -) diff --git a/src/python/utils/bindings.cpp b/src/python/utils/bindings.cpp index fabcf2dd..a7a081cb 100644 --- a/src/python/utils/bindings.cpp +++ b/src/python/utils/bindings.cpp @@ -12,6 +12,7 @@ namespace py = pybind11; void register_utils_bindings(py::module &m) { m.def("formatNuclearTimescaleLogString", &gridfire::utils::formatNuclearTimescaleLogString, + py::arg("ctx"), py::arg("engine"), py::arg("Y"), py::arg("T9"), diff --git a/src/python/utils/meson.build b/src/python/utils/meson.build deleted file mode 100644 index 5c97a3a5..00000000 --- a/src/python/utils/meson.build +++ /dev/null @@ -1,17 +0,0 @@ -# Define the library -bindings_sources = files('bindings.cpp') -bindings_headers = files('bindings.h') - -dependencies = [ - gridfire_dep, - python3_dep, - pybind11_dep, -] - -shared_module('py_gf_utils', - bindings_sources, - cpp_args: ['-fvisibility=default'], - install : true, - dependencies: dependencies, - include_directories: include_directories('.') -) diff --git a/stubs/gridfire/__init__.pyi b/stubs/gridfire/__init__.pyi index e15f3ac9..a5db9463 100644 --- a/stubs/gridfire/__init__.pyi +++ b/stubs/gridfire/__init__.pyi @@ -1,4 +1,5 @@ from __future__ import annotations +from gridfire._gridfire import config from gridfire._gridfire import engine from gridfire._gridfire import exceptions from gridfire._gridfire import io @@ -9,7 +10,33 @@ from gridfire._gridfire import screening from gridfire._gridfire import solver from gridfire._gridfire import type from gridfire._gridfire import utils +import importlib as importlib import sys as sys from . import _gridfire -__all__: list = ['type', 'utils', 'engine', 'solver', 'exceptions', 'partition', 'reaction', 'screening', 'io', 'core', 'cli'] -__version__: str = 'v0.7.0_alpha_2025_10_25' +__all__: list = ['type', 'utils', 'engine', 'solver', 'exceptions', 'partition', 'reaction', 'screening', 'io', 'policy', 'config'] +def gf_author(): + ... +def gf_collaboration(): + ... +def gf_credits(): + ... +def gf_description(): + ... +def gf_email(): + ... +def gf_license(): + ... +def gf_metadata(): + ... +def gf_url(): + ... +def gf_version(): + ... +__author__ = None +__description__: str = 'Python interface to the GridFire nuclear network code' +__email__: str = '"Emily M. Boudreaux" , Aaron Dotter ' +__license__: str = 'GNU GENERAL PUBLIC LICENSE\n Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. \n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n Preamble\n\n The GNU General Public License is a free, copyleft license for\n software and other kinds of works.\n\n The licenses for most software and other practical works are designed\n to take away your freedom to share and change the works. By contrast,\n the GNU General Public License is intended to guarantee your freedom to\n share and change all versions of a program--to make sure it remains free\n software for all its users. We, the Free Software Foundation, use the\n GNU General Public License for most of our software; it applies also to\n any other work released this way by its authors. You can apply it to\n your programs, too.\n\n When we speak of free software, we are referring to freedom, not\n price. Our General Public Licenses are designed to make sure that you\n have the freedom to distribute copies of free software (and charge for\n them if you wish), that you receive source code or can get it if you\n want it, that you can change the software or use pieces of it in new\n free programs, and that you know you can do these things.\n\n To protect your rights, we need to prevent others from denying you\n these rights or asking you to surrender the rights. Therefore, you have\n certain responsibilities if you distribute copies of the software, or if\n you modify it: responsibilities to respect the freedom of others.\n\n For example, if you distribute copies of such a program, whether\n gratis or for a fee, you must pass on to the recipients the same\n freedoms that you received. You must make sure that they, too, receive\n or can get the source code. And you must show them these terms so they\n know their rights.\n\n Developers that use the GNU GPL protect your rights with two steps:\n (1) assert copyright on the software, and (2) offer you this License\n giving you legal permission to copy, distribute and/or modify it.\n\n For the developers\' and authors\' protection, the GPL clearly explains\n that there is no warranty for this free software. For both users\' and\n authors\' sake, the GPL requires that modified versions be marked as\n changed, so that their problems will not be attributed erroneously to\n authors of previous versions.\n\n Some devices are designed to deny users access to install or run\n modified versions of the software inside them, although the manufacturer\n can do so. This is fundamentally incompatible with the aim of\n protecting users\' freedom to change the software. The systematic\n pattern of such abuse occurs in the area of products for individuals to\n use, which is precisely where it is most unacceptable. Therefore, we\n have designed this version of the GPL to prohibit the practice for those\n products. If such problems arise substantially in other domains, we\n stand ready to extend this provision to those domains in future versions\n of the GPL, as needed to protect the freedom of users.\n\n Finally, every program is threatened constantly by software patents.\n States should not allow patents to restrict development and use of\n software on general-purpose computers, but in those that do, we wish to\n avoid the special danger that patents applied to a free program could\n make it effectively proprietary. To prevent this, the GPL assures that\n patents cannot be used to render the program non-free.\n\n The precise terms and conditions for copying, distribution and\n modification follow.\n\n TERMS AND CONDITIONS\n\n 0. Definitions.\n\n "This License" refers to version 3 of the GNU General Public License.\n\n "Copyright" also means copyright-like laws that apply to other kinds of\n works, such as semiconductor masks.\n\n "The Program" refers to any copyrightable work licensed under this\n License. Each licensee is addressed as "you". "Licensees" and\n "recipients" may be individuals or organizations.\n\n To "modify" a work means to copy from or adapt all or part of the work\n in a fashion requiring copyright permission, other than the making of an\n exact copy. The resulting work is called a "modified version" of the\n earlier work or a work "based on" the earlier work.\n\n A "covered work" means either the unmodified Program or a work based\n on the Program.\n\n To "propagate" a work means to do anything with it that, without\n permission, would make you directly or secondarily liable for\n infringement under applicable copyright law, except executing it on a\n computer or modifying a private copy. Propagation includes copying,\n distribution (with or without modification), making available to the\n public, and in some countries other activities as well.\n\n To "convey" a work means any kind of propagation that enables other\n parties to make or receive copies. Mere interaction with a user through\n a computer network, with no transfer of a copy, is not conveying.\n\n An interactive user interface displays "Appropriate Legal Notices"\n to the extent that it includes a convenient and prominently visible\n feature that (1) displays an appropriate copyright notice, and (2)\n tells the user that there is no warranty for the work (except to the\n extent that warranties are provided), that licensees may convey the\n work under this License, and how to view a copy of this License. If\n the interface presents a list of user commands or options, such as a\n menu, a prominent item in the list meets this criterion.\n\n 1. Source Code.\n\n The "source code" for a work means the preferred form of the work\n for making modifications to it. "Object code" means any non-source\n form of a work.\n\n A "Standard Interface" means an interface that either is an official\n standard defined by a recognized standards body, or, in the case of\n interfaces specified for a particular programming language, one that\n is widely used among developers working in that language.\n\n The "System Libraries" of an executable work include anything, other\n than the work as a whole, that (a) is included in the normal form of\n packaging a Major Component, but which is not part of that Major\n Component, and (b) serves only to enable use of the work with that\n Major Component, or to implement a Standard Interface for which an\n implementation is available to the public in source code form. A\n "Major Component", in this context, means a major essential component\n (kernel, window system, and so on) of the specific operating system\n (if any) on which the executable work runs, or a compiler used to\n produce the work, or an object code interpreter used to run it.\n\n The "Corresponding Source" for a work in object code form means all\n the source code needed to generate, install, and (for an executable\n work) run the object code and to modify the work, including scripts to\n control those activities. However, it does not include the work\'s\n System Libraries, or general-purpose tools or generally available free\n programs which are used unmodified in performing those activities but\n which are not part of the work. For example, Corresponding Source\n includes interface definition files associated with source files for\n the work, and the source code for shared libraries and dynamically\n linked subprograms that the work is specifically designed to require,\n such as by intimate data communication or control flow between those\n subprograms and other parts of the work.\n\n The Corresponding Source need not include anything that users\n can regenerate automatically from other parts of the Corresponding\n Source.\n\n The Corresponding Source for a work in source code form is that\n same work.\n\n 2. Basic Permissions.\n\n All rights granted under this License are granted for the term of\n copyright on the Program, and are irrevocable provided the stated\n conditions are met. This License explicitly affirms your unlimited\n permission to run the unmodified Program. The output from running a\n covered work is covered by this License only if the output, given its\n content, constitutes a covered work. This License acknowledges your\n rights of fair use or other equivalent, as provided by copyright law.\n\n You may make, run and propagate covered works that you do not\n convey, without conditions so long as your license otherwise remains\n in force. You may convey covered works to others for the sole purpose\n of having them make modifications exclusively for you, or provide you\n with facilities for running those works, provided that you comply with\n the terms of this License in conveying all material for which you do\n not control copyright. Those thus making or running the covered works\n for you must do so exclusively on your behalf, under your direction\n and control, on terms that prohibit them from making any copies of\n your copyrighted material outside their relationship with you.\n\n Conveying under any other circumstances is permitted solely under\n the conditions stated below. Sublicensing is not allowed; section 10\n makes it unnecessary.\n\n 3. Protecting Users\' Legal Rights From Anti-Circumvention Law.\n\n No covered work shall be deemed part of an effective technological\n measure under any applicable law fulfilling obligations under article\n 11 of the WIPO copyright treaty adopted on 20 December 1996, or\n similar laws prohibiting or restricting circumvention of such\n measures.\n\n When you convey a covered work, you waive any legal power to forbid\n circumvention of technological measures to the extent such circumvention\n is effected by exercising rights under this License with respect to\n the covered work, and you disclaim any intention to limit operation or\n modification of the work as a means of enforcing, against the work\'s\n users, your or third parties\' legal rights to forbid circumvention of\n technological measures.\n\n 4. Conveying Verbatim Copies.\n\n You may convey verbatim copies of the Program\'s source code as you\n receive it, in any medium, provided that you conspicuously and\n appropriately publish on each copy an appropriate copyright notice;\n keep intact all notices stating that this License and any\n non-permissive terms added in accord with section 7 apply to the code;\n keep intact all notices of the absence of any warranty; and give all\n recipients a copy of this License along with the Program.\n\n You may charge any price or no price for each copy that you convey,\n and you may offer support or warranty protection for a fee.\n\n 5. Conveying Modified Source Versions.\n\n You may convey a work based on the Program, or the modifications to\n produce it from the Program, in the form of source code under the\n terms of section 4, provided that you also meet all of these conditions:\n\n a) The work must carry prominent notices stating that you modified\n it, and giving a relevant date.\n\n b) The work must carry prominent notices stating that it is\n released under this License and any conditions added under section\n 7. This requirement modifies the requirement in section 4 to\n "keep intact all notices".\n\n c) You must license the entire work, as a whole, under this\n License to anyone who comes into possession of a copy. This\n License will therefore apply, along with any applicable section 7\n additional terms, to the whole of the work, and all its parts,\n regardless of how they are packaged. This License gives no\n permission to license the work in any other way, but it does not\n invalidate such permission if you have separately received it.\n\n d) If the work has interactive user interfaces, each must display\n Appropriate Legal Notices; however, if the Program has interactive\n interfaces that do not display Appropriate Legal Notices, your\n work need not make them do so.\n\n A compilation of a covered work with other separate and independent\n works, which are not by their nature extensions of the covered work,\n and which are not combined with it such as to form a larger program,\n in or on a volume of a storage or distribution medium, is called an\n "aggregate" if the compilation and its resulting copyright are not\n used to limit the access or legal rights of the compilation\'s users\n beyond what the individual works permit. Inclusion of a covered work\n in an aggregate does not cause this License to apply to the other\n parts of the aggregate.\n\n 6. Conveying Non-Source Forms.\n\n You may convey a covered work in object code form under the terms\n of sections 4 and 5, provided that you also convey the\n machine-readable Corresponding Source under the terms of this License,\n in one of these ways:\n\n a) Convey the object code in, or embodied in, a physical product\n (including a physical distribution medium), accompanied by the\n Corresponding Source fixed on a durable physical medium\n customarily used for software interchange.\n\n b) Convey the object code in, or embodied in, a physical product\n (including a physical distribution medium), accompanied by a\n written offer, valid for at least three years and valid for as\n long as you offer spare parts or customer support for that product\n model, to give anyone who possesses the object code either (1) a\n copy of the Corresponding Source for all the software in the\n product that is covered by this License, on a durable physical\n medium customarily used for software interchange, for a price no\n more than your reasonable cost of physically performing this\n conveying of source, or (2) access to copy the\n Corresponding Source from a network server at no charge.\n\n c) Convey individual copies of the object code with a copy of the\n written offer to provide the Corresponding Source. This\n alternative is allowed only occasionally and noncommercially, and\n only if you received the object code with such an offer, in accord\n with subsection 6b.\n\n d) Convey the object code by offering access from a designated\n place (gratis or for a charge), and offer equivalent access to the\n Corresponding Source in the same way through the same place at no\n further charge. You need not require recipients to copy the\n Corresponding Source along with the object code. If the place to\n copy the object code is a network server, the Corresponding Source\n may be on a different server (operated by you or a third party)\n that supports equivalent copying facilities, provided you maintain\n clear directions next to the object code saying where to find the\n Corresponding Source. Regardless of what server hosts the\n Corresponding Source, you remain obligated to ensure that it is\n available for as long as needed to satisfy these requirements.\n\n e) Convey the object code using peer-to-peer transmission, provided\n you inform other peers where the object code and Corresponding\n Source of the work are being offered to the general public at no\n charge under subsection 6d.\n\n A separable portion of the object code, whose source code is excluded\n from the Corresponding Source as a System Library, need not be\n included in conveying the object code work.\n\n A "User Product" is either (1) a "consumer product", which means any\n tangible personal property which is normally used for personal, family,\n or household purposes, or (2) anything designed or sold for incorporation\n into a dwelling. In determining whether a product is a consumer product,\n doubtful cases shall be resolved in favor of coverage. For a particular\n product received by a particular user, "normally used" refers to a\n typical or common use of that class of product, regardless of the status\n of the particular user or of the way in which the particular user\n actually uses, or expects or is expected to use, the product. A product\n is a consumer product regardless of whether the product has substantial\n commercial, industrial or non-consumer uses, unless such uses represent\n the only significant mode of use of the product.\n\n "Installation Information" for a User Product means any methods,\n procedures, authorization keys, or other information required to install\n and execute modified versions of a covered work in that User Product from\n a modified version of its Corresponding Source. The information must\n suffice to ensure that the continued functioning of the modified object\n code is in no case prevented or interfered with solely because\n modification has been made.\n\n If you convey an object code work under this section in, or with, or\n specifically for use in, a User Product, and the conveying occurs as\n part of a transaction in which the right of possession and use of the\n User Product is transferred to the recipient in perpetuity or for a\n fixed term (regardless of how the transaction is characterized), the\n Corresponding Source conveyed under this section must be accompanied\n by the Installation Information. But this requirement does not apply\n if neither you nor any third party retains the ability to install\n modified object code on the User Product (for example, the work has\n been installed in ROM).\n\n The requirement to provide Installation Information does not include a\n requirement to continue to provide support service, warranty, or updates\n for a work that has been modified or installed by the recipient, or for\n the User Product in which it has been modified or installed. Access to a\n network may be denied when the modification itself materially and\n adversely affects the operation of the network or violates the rules and\n protocols for communication across the network.\n\n Corresponding Source conveyed, and Installation Information provided,\n in accord with this section must be in a format that is publicly\n documented (and with an implementation available to the public in\n source code form), and must require no special password or key for\n unpacking, reading or copying.\n\n 7. Additional Terms.\n\n "Additional permissions" are terms that supplement the terms of this\n License by making exceptions from one or more of its conditions.\n Additional permissions that are applicable to the entire Program shall\n be treated as though they were included in this License, to the extent\n that they are valid under applicable law. If additional permissions\n apply only to part of the Program, that part may be used separately\n under those permissions, but the entire Program remains governed by\n this License without regard to the additional permissions.\n\n When you convey a copy of a covered work, you may at your option\n remove any additional permissions from that copy, or from any part of\n it. (Additional permissions may be written to require their own\n removal in certain cases when you modify the work.) You may place\n additional permissions on material, added by you to a covered work,\n for which you have or can give appropriate copyright permission.\n\n Notwithstanding any other provision of this License, for material you\n add to a covered work, you may (if authorized by the copyright holders of\n that material) supplement the terms of this License with terms:\n\n a) Disclaiming warranty or limiting liability differently from the\n terms of sections 15 and 16 of this License; or\n\n b) Requiring preservation of specified reasonable legal notices or\n author attributions in that material or in the Appropriate Legal\n Notices displayed by works containing it; or\n\n c) Prohibiting misrepresentation of the origin of that material, or\n requiring that modified versions of such material be marked in\n reasonable ways as different from the original version; or\n\n d) Limiting the use for publicity purposes of names of licensors or\n authors of the material; or\n\n e) Declining to grant rights under trademark law for use of some\n trade names, trademarks, or service marks; or\n\n f) Requiring indemnification of licensors and authors of that\n material by anyone who conveys the material (or modified versions of\n it) with contractual assumptions of liability to the recipient, for\n any liability that these contractual assumptions directly impose on\n those licensors and authors.\n\n All other non-permissive additional terms are considered "further\n restrictions" within the meaning of section 10. If the Program as you\n received it, or any part of it, contains a notice stating that it is\n governed by this License along with a term that is a further\n restriction, you may remove that term. If a license document contains\n a further restriction but permits relicensing or conveying under this\n License, you may add to a covered work material governed by the terms\n of that license document, provided that the further restriction does\n not survive such relicensing or conveying.\n\n If you add terms to a covered work in accord with this section, you\n must place, in the relevant source files, a statement of the\n additional terms that apply to those files, or a notice indicating\n where to find the applicable terms.\n\n Additional terms, permissive or non-permissive, may be stated in the\n form of a separately written license, or stated as exceptions;\n the above requirements apply either way.\n\n 8. Termination.\n\n You may not propagate or modify a covered work except as expressly\n provided under this License. Any attempt otherwise to propagate or\n modify it is void, and will automatically terminate your rights under\n this License (including any patent licenses granted under the third\n paragraph of section 11).\n\n However, if you cease all violation of this License, then your\n license from a particular copyright holder is reinstated (a)\n provisionally, unless and until the copyright holder explicitly and\n finally terminates your license, and (b) permanently, if the copyright\n holder fails to notify you of the violation by some reasonable means\n prior to 60 days after the cessation.\n\n Moreover, your license from a particular copyright holder is\n reinstated permanently if the copyright holder notifies you of the\n violation by some reasonable means, this is the first time you have\n received notice of violation of this License (for any work) from that\n copyright holder, and you cure the violation prior to 30 days after\n your receipt of the notice.\n\n Termination of your rights under this section does not terminate the\n licenses of parties who have received copies or rights from you under\n this License. If your rights have been terminated and not permanently\n reinstated, you do not qualify to receive new licenses for the same\n material under section 10.\n\n 9. Acceptance Not Required for Having Copies.\n\n You are not required to accept this License in order to receive or\n run a copy of the Program. Ancillary propagation of a covered work\n occurring solely as a consequence of using peer-to-peer transmission\n to receive a copy likewise does not require acceptance. However,\n nothing other than this License grants you permission to propagate or\n modify any covered work. These actions infringe copyright if you do\n not accept this License. Therefore, by modifying or propagating a\n covered work, you indicate your acceptance of this License to do so.\n\n 10. Automatic Licensing of Downstream Recipients.\n\n Each time you convey a covered work, the recipient automatically\n receives a license from the original licensors, to run, modify and\n propagate that work, subject to this License. You are not responsible\n for enforcing compliance by third parties with this License.\n\n An "entity transaction" is a transaction transferring control of an\n organization, or substantially all assets of one, or subdividing an\n organization, or merging organizations. If propagation of a covered\n work results from an entity transaction, each party to that\n transaction who receives a copy of the work also receives whatever\n licenses to the work the party\'s predecessor in interest had or could\n give under the previous paragraph, plus a right to possession of the\n Corresponding Source of the work from the predecessor in interest, if\n the predecessor has it or can get it with reasonable efforts.\n\n You may not impose any further restrictions on the exercise of the\n rights granted or affirmed under this License. For example, you may\n not impose a license fee, royalty, or other charge for exercise of\n rights granted under this License, and you may not initiate litigation\n (including a cross-claim or counterclaim in a lawsuit) alleging that\n any patent claim is infringed by making, using, selling, offering for\n sale, or importing the Program or any portion of it.\n\n 11. Patents.\n\n A "contributor" is a copyright holder who authorizes use under this\n License of the Program or a work on which the Program is based. The\n work thus licensed is called the contributor\'s "contributor version".\n\n A contributor\'s "essential patent claims" are all patent claims\n owned or controlled by the contributor, whether already acquired or\n hereafter acquired, that would be infringed by some manner, permitted\n by this License, of making, using, or selling its contributor version,\n but do not include claims that would be infringed only as a\n consequence of further modification of the contributor version. For\n purposes of this definition, "control" includes the right to grant\n patent sublicenses in a manner consistent with the requirements of\n this License.\n\n Each contributor grants you a non-exclusive, worldwide, royalty-free\n patent license under the contributor\'s essential patent claims, to\n make, use, sell, offer for sale, import and otherwise run, modify and\n propagate the contents of its contributor version.\n\n In the following three paragraphs, a "patent license" is any express\n agreement or commitment, however denominated, not to enforce a patent\n (such as an express permission to practice a patent or covenant not to\n sue for patent infringement). To "grant" such a patent license to a\n party means to make such an agreement or commitment not to enforce a\n patent against the party.\n\n If you convey a covered work, knowingly relying on a patent license,\n and the Corresponding Source of the work is not available for anyone\n to copy, free of charge and under the terms of this License, through a\n publicly available network server or other readily accessible means,\n then you must either (1) cause the Corresponding Source to be so\n available, or (2) arrange to deprive yourself of the benefit of the\n patent license for this particular work, or (3) arrange, in a manner\n consistent with the requirements of this License, to extend the patent\n license to downstream recipients. "Knowingly relying" means you have\n actual knowledge that, but for the patent license, your conveying the\n covered work in a country, or your recipient\'s use of the covered work\n in a country, would infringe one or more identifiable patents in that\n country that you have reason to believe are valid.\n\n If, pursuant to or in connection with a single transaction or\n arrangement, you convey, or propagate by procuring conveyance of, a\n covered work, and grant a patent license to some of the parties\n receiving the covered work authorizing them to use, propagate, modify\n or convey a specific copy of the covered work, then the patent license\n you grant is automatically extended to all recipients of the covered\n work and works based on it.\n\n A patent license is "discriminatory" if it does not include within\n the scope of its coverage, prohibits the exercise of, or is\n conditioned on the non-exercise of one or more of the rights that are\n specifically granted under this License. You may not convey a covered\n work if you are a party to an arrangement with a third party that is\n in the business of distributing software, under which you make payment\n to the third party based on the extent of your activity of conveying\n the work, and under which the third party grants, to any of the\n parties who would receive the covered work from you, a discriminatory\n patent license (a) in connection with copies of the covered work\n conveyed by you (or copies made from those copies), or (b) primarily\n for and in connection with specific products or compilations that\n contain the covered work, unless you entered into that arrangement,\n or that patent license was granted, prior to 28 March 2007.\n\n Nothing in this License shall be construed as excluding or limiting\n any implied license or other defenses to infringement that may\n otherwise be available to you under applicable patent law.\n\n 12. No Surrender of Others\' Freedom.\n\n If conditions are imposed on you (whether by court order, agreement or\n otherwise) that contradict the conditions of this License, they do not\n excuse you from the conditions of this License. If you cannot convey a\n covered work so as to satisfy simultaneously your obligations under this\n License and any other pertinent obligations, then as a consequence you may\n not convey it at all. For example, if you agree to terms that obligate you\n to collect a royalty for further conveying from those to whom you convey\n the Program, the only way you could satisfy both those terms and this\n License would be to refrain entirely from conveying the Program.\n\n 13. Use with the GNU Affero General Public License.\n\n Notwithstanding any other provision of this License, you have\n permission to link or combine any covered work with a work licensed\n under version 3 of the GNU Affero General Public License into a single\n combined work, and to convey the resulting work. The terms of this\n License will continue to apply to the part which is the covered work,\n but the special requirements of the GNU Affero General Public License,\n section 13, concerning interaction through a network will apply to the\n combination as such.\n\n 14. Revised Versions of this License.\n\n The Free Software Foundation may publish revised and/or new versions of\n the GNU General Public License from time to time. Such new versions will\n be similar in spirit to the present version, but may differ in detail to\n address new problems or concerns.\n\n Each version is given a distinguishing version number. If the\n Program specifies that a certain numbered version of the GNU General\n Public License "or any later version" applies to it, you have the\n option of following the terms and conditions either of that numbered\n version or of any later version published by the Free Software\n Foundation. If the Program does not specify a version number of the\n GNU General Public License, you may choose any version ever published\n by the Free Software Foundation.\n\n If the Program specifies that a proxy can decide which future\n versions of the GNU General Public License can be used, that proxy\'s\n public statement of acceptance of a version permanently authorizes you\n to choose that version for the Program.\n\n Later license versions may give you additional or different\n permissions. However, no additional obligations are imposed on any\n author or copyright holder as a result of your choosing to follow a\n later version.\n\n 15. Disclaimer of Warranty.\n\n THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\n APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\n HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY\n OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\n THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\n IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\n ALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n 16. Limitation of Liability.\n\n IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\n WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\n THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\n GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\n USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\n DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\n PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\n EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\n SUCH DAMAGES.\n\n 17. Interpretation of Sections 15 and 16.\n\n If the disclaimer of warranty and limitation of liability provided\n above cannot be given local legal effect according to their terms,\n reviewing courts shall apply local law that most closely approximates\n an absolute waiver of all civil liability in connection with the\n Program, unless a warranty or assumption of liability accompanies a\n copy of the Program in return for a fee.\n\n END OF TERMS AND CONDITIONS\n\n How to Apply These Terms to Your New Programs\n\n If you develop a new program, and you want it to be of the greatest\n possible use to the public, the best way to achieve this is to make it\n free software which everyone can redistribute and change under these terms.\n\n To do so, attach the following notices to the program. It is safest\n to attach them to the start of each source file to most effectively\n state the exclusion of warranty; and each file should have at least\n the "copyright" line and a pointer to where the full notice is found.\n\n \n Copyright (C) \n\n This program is free software: you can redistribute it and/or modify\n it under the terms of the GNU General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU General Public License for more details.\n\n You should have received a copy of the GNU General Public License\n along with this program. If not, see .\n\n Also add information on how to contact you by electronic and paper mail.\n\n If the program does terminal interaction, make it output a short\n notice like this when it starts in an interactive mode:\n\n Copyright (C) \n This program comes with ABSOLUTELY NO WARRANTY; for details type `show w\'.\n This is free software, and you are welcome to redistribute it\n under certain conditions; type `show c\' for details.\n\n The hypothetical commands `show w\' and `show c\' should show the appropriate\n parts of the General Public License. Of course, your program\'s commands\n might be different; for a GUI interface, you would use an "about box".\n\n You should also get your employer (if you work as a programmer) or school,\n if any, to sign a "copyright disclaimer" for the program, if necessary.\n For more information on this, and how to apply and follow the GNU GPL, see\n .\n\n The GNU General Public License does not permit incorporating your program\n into proprietary programs. If your program is a subroutine library, you\n may consider it more useful to permit linking proprietary applications with\n the library. If this is what you want to do, use the GNU Lesser General\n Public License instead of this License. But first, please read\n .' +__url__: str = '' +__version__: str = '0.7.4rc3' +__warningregistry__: dict = {'version': 0} +_meta: importlib.metadata._adapters.Message # value = diff --git a/stubs/gridfire/_gridfire/__init__.pyi b/stubs/gridfire/_gridfire/__init__.pyi index 23b26003..58a175d8 100644 --- a/stubs/gridfire/_gridfire/__init__.pyi +++ b/stubs/gridfire/_gridfire/__init__.pyi @@ -2,6 +2,7 @@ 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 @@ -12,4 +13,4 @@ from . import screening from . import solver from . import type from . import utils -__all__: list[str] = ['engine', 'exceptions', 'io', 'partition', 'policy', 'reaction', 'screening', 'solver', 'type', 'utils'] +__all__: list[str] = ['config', 'engine', 'exceptions', 'io', 'partition', 'policy', 'reaction', 'screening', 'solver', 'type', 'utils'] diff --git a/stubs/gridfire/_gridfire/config.pyi b/stubs/gridfire/_gridfire/config.pyi new file mode 100644 index 00000000..57eb9940 --- /dev/null +++ b/stubs/gridfire/_gridfire/config.pyi @@ -0,0 +1,47 @@ +""" +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: + ... diff --git a/stubs/gridfire/_gridfire/engine/__init__.pyi b/stubs/gridfire/_gridfire/engine/__init__.pyi index b652bc70..bda6579c 100644 --- a/stubs/gridfire/_gridfire/engine/__init__.pyi +++ b/stubs/gridfire/_gridfire/engine/__init__.pyi @@ -14,110 +14,81 @@ import numpy import numpy.typing import typing from . import diagnostics -__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'] +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, comp: ..., T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> ...: + def calculateEpsDerivatives(self, ctx: scratchpads.StateBlob, comp: ..., T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> ...: """ Calculate deps/dT and deps/drho """ - def calculateMolarReactionFlow(self: DynamicEngine, reaction: ..., comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> float: + 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, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> StepDerivatives: + 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, composition: ..., T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> fourdst._phys.composition.Composition: + 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, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> NetworkJacobian: + 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, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat, activeSpecies: collections.abc.Sequence[fourdst._phys.atomic.Species]) -> NetworkJacobian: + 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, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat, sparsityPattern: collections.abc.Sequence[tuple[typing.SupportsInt, typing.SupportsInt]]) -> NetworkJacobian: + 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 generateStoichiometryMatrix(self) -> None: - ... def getBaseEngine(self) -> DynamicEngine: """ Get the base engine associated with this adaptive engine view. """ - def getDepth(self) -> gridfire._gridfire.engine.NetworkBuildDepth | int: - """ - Get the current build depth of the engine. - """ - def getNetworkReactions(self) -> gridfire._gridfire.reaction.ReactionSet: + def getNetworkReactions(self, arg0: scratchpads.StateBlob) -> gridfire._gridfire.reaction.ReactionSet: """ Get the set of logical reactions in the network. """ - def getNetworkSpecies(self) -> list[fourdst._phys.atomic.Species]: + def getNetworkSpecies(self, arg0: scratchpads.StateBlob) -> list[fourdst._phys.atomic.Species]: """ Get the list of species in the network. """ - def getScreeningModel(self) -> gridfire._gridfire.screening.ScreeningType: + def getScreeningModel(self, arg0: scratchpads.StateBlob) -> gridfire._gridfire.screening.ScreeningType: """ Get the current screening model of the engine. """ - def getSpeciesDestructionTimescales(self: DynamicEngine, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> dict[fourdst._phys.atomic.Species, float]: + 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, species: fourdst._phys.atomic.Species) -> int: + def getSpeciesIndex(self, ctx: scratchpads.StateBlob, species: fourdst._phys.atomic.Species) -> int: """ Get the index of a species in the network. """ - def getSpeciesStatus(self, species: fourdst._phys.atomic.Species) -> SpeciesStatus: + 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, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> dict[fourdst._phys.atomic.Species, float]: + 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 getStoichiometryMatrixEntry(self, species: fourdst._phys.atomic.Species, reaction: ...) -> int: - """ - Get an entry from the stoichiometry matrix. - """ - def isStale(self, netIn: gridfire._gridfire.type.NetIn) -> bool: - """ - Check if the engine is stale based on the provided NetIn object. - """ - def mapNetInToMolarAbundanceVector(self, netIn: gridfire._gridfire.type.NetIn) -> list[float]: - """ - Map a NetIn object to a vector of molar abundances. - """ - def primeEngine(self, netIn: gridfire._gridfire.type.NetIn) -> PrimingReport: + def primeEngine(self, ctx: scratchpads.StateBlob, netIn: gridfire._gridfire.type.NetIn) -> PrimingReport: """ Prime the engine with a NetIn object to prepare for calculations. """ - def rebuild(self, composition: ..., depth: gridfire._gridfire.engine.NetworkBuildDepth | typing.SupportsInt = ...) -> None: - """ - Rebuild the engine with a new composition and build depth. - """ - def setNetworkReactions(self, reactions: gridfire._gridfire.reaction.ReactionSet) -> None: - """ - Set the network reactions to a new set of reactions. - """ - def setScreeningModel(self, screeningModel: gridfire._gridfire.screening.ScreeningType) -> None: - """ - Set the screening model for the engine. - """ - def update(self, netIn: gridfire._gridfire.type.NetIn) -> fourdst._phys.composition.Composition: + 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. """ @@ -128,104 +99,74 @@ class DefinedEngineView(DynamicEngine): """ Construct a defined engine view with a list of tracked reactions and a base engine. """ - def calculateEpsDerivatives(self, comp: ..., T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> ...: + def calculateEpsDerivatives(self, ctx: scratchpads.StateBlob, comp: ..., T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> ...: """ Calculate deps/dT and deps/drho """ - def calculateMolarReactionFlow(self: DynamicEngine, reaction: ..., comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> float: + 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, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> StepDerivatives: + 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, composition: ..., T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> fourdst._phys.composition.Composition: + 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, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> NetworkJacobian: + 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, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat, activeSpecies: collections.abc.Sequence[fourdst._phys.atomic.Species]) -> NetworkJacobian: + 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, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat, sparsityPattern: collections.abc.Sequence[tuple[typing.SupportsInt, typing.SupportsInt]]) -> NetworkJacobian: + 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 generateStoichiometryMatrix(self) -> None: - ... def getBaseEngine(self) -> DynamicEngine: """ Get the base engine associated with this defined engine view. """ - def getDepth(self) -> gridfire._gridfire.engine.NetworkBuildDepth | int: - """ - Get the current build depth of the engine. - """ - def getNetworkReactions(self) -> gridfire._gridfire.reaction.ReactionSet: + def getNetworkReactions(self, arg0: scratchpads.StateBlob) -> gridfire._gridfire.reaction.ReactionSet: """ Get the set of logical reactions in the network. """ - def getNetworkSpecies(self) -> list[fourdst._phys.atomic.Species]: + def getNetworkSpecies(self, arg0: scratchpads.StateBlob) -> list[fourdst._phys.atomic.Species]: """ Get the list of species in the network. """ - def getScreeningModel(self) -> gridfire._gridfire.screening.ScreeningType: + def getScreeningModel(self, arg0: scratchpads.StateBlob) -> gridfire._gridfire.screening.ScreeningType: """ Get the current screening model of the engine. """ - def getSpeciesDestructionTimescales(self: DynamicEngine, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> dict[fourdst._phys.atomic.Species, float]: + 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, species: fourdst._phys.atomic.Species) -> int: + def getSpeciesIndex(self, ctx: scratchpads.StateBlob, species: fourdst._phys.atomic.Species) -> int: """ Get the index of a species in the network. """ - def getSpeciesStatus(self, species: fourdst._phys.atomic.Species) -> SpeciesStatus: + 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, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> dict[fourdst._phys.atomic.Species, float]: + 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 getStoichiometryMatrixEntry(self, species: fourdst._phys.atomic.Species, reaction: ...) -> int: - """ - Get an entry from the stoichiometry matrix. - """ - def isStale(self, netIn: gridfire._gridfire.type.NetIn) -> bool: - """ - Check if the engine is stale based on the provided NetIn object. - """ - def mapNetInToMolarAbundanceVector(self, netIn: gridfire._gridfire.type.NetIn) -> list[float]: - """ - Map a NetIn object to a vector of molar abundances. - """ - def primeEngine(self, netIn: gridfire._gridfire.type.NetIn) -> PrimingReport: + def primeEngine(self, ctx: scratchpads.StateBlob, netIn: gridfire._gridfire.type.NetIn) -> PrimingReport: """ Prime the engine with a NetIn object to prepare for calculations. """ - def rebuild(self, composition: ..., depth: gridfire._gridfire.engine.NetworkBuildDepth | typing.SupportsInt = ...) -> None: - """ - Rebuild the engine with a new composition and build depth. - """ - def setNetworkReactions(self, reactions: gridfire._gridfire.reaction.ReactionSet) -> None: - """ - Set the network reactions to a new set of reactions. - """ - def setScreeningModel(self, screeningModel: gridfire._gridfire.screening.ScreeningType) -> None: - """ - Set the screening model for the engine. - """ - def update(self, netIn: gridfire._gridfire.type.NetIn) -> fourdst._phys.composition.Composition: + 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. """ @@ -293,56 +234,50 @@ class FileDefinedEngineView(DefinedEngineView): """ Construct a defined engine view from a file and a base engine. """ - def calculateEpsDerivatives(self, comp: ..., T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> ...: + def calculateEpsDerivatives(self, ctx: scratchpads.StateBlob, comp: ..., T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> ...: """ Calculate deps/dT and deps/drho """ - def calculateMolarReactionFlow(self: DynamicEngine, reaction: ..., comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> float: + 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, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> StepDerivatives: + 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, composition: ..., T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> fourdst._phys.composition.Composition: + 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, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> NetworkJacobian: + 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, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat, activeSpecies: collections.abc.Sequence[fourdst._phys.atomic.Species]) -> NetworkJacobian: + 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, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat, sparsityPattern: collections.abc.Sequence[tuple[typing.SupportsInt, typing.SupportsInt]]) -> NetworkJacobian: + 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 generateStoichiometryMatrix(self) -> None: - ... def getBaseEngine(self) -> DynamicEngine: """ Get the base engine associated with this file defined engine view. """ - def getDepth(self) -> gridfire._gridfire.engine.NetworkBuildDepth | int: - """ - Get the current build depth of the engine. - """ def getNetworkFile(self) -> str: """ Get the network file associated with this defined engine view. """ - def getNetworkReactions(self) -> gridfire._gridfire.reaction.ReactionSet: + def getNetworkReactions(self, arg0: scratchpads.StateBlob) -> gridfire._gridfire.reaction.ReactionSet: """ Get the set of logical reactions in the network. """ - def getNetworkSpecies(self) -> list[fourdst._phys.atomic.Species]: + def getNetworkSpecies(self, arg0: scratchpads.StateBlob) -> list[fourdst._phys.atomic.Species]: """ Get the list of species in the network. """ @@ -350,64 +285,35 @@ class FileDefinedEngineView(DefinedEngineView): """ Get the parser used for this defined engine view. """ - def getScreeningModel(self) -> gridfire._gridfire.screening.ScreeningType: + def getScreeningModel(self, arg0: scratchpads.StateBlob) -> gridfire._gridfire.screening.ScreeningType: """ Get the current screening model of the engine. """ - def getSpeciesDestructionTimescales(self: DynamicEngine, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> dict[fourdst._phys.atomic.Species, float]: + 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, species: fourdst._phys.atomic.Species) -> int: + def getSpeciesIndex(self, ctx: scratchpads.StateBlob, species: fourdst._phys.atomic.Species) -> int: """ Get the index of a species in the network. """ - def getSpeciesStatus(self, species: fourdst._phys.atomic.Species) -> SpeciesStatus: + 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, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> dict[fourdst._phys.atomic.Species, float]: + 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 getStoichiometryMatrixEntry(self, species: fourdst._phys.atomic.Species, reaction: ...) -> int: - """ - Get an entry from the stoichiometry matrix. - """ - def isStale(self, netIn: gridfire._gridfire.type.NetIn) -> bool: - """ - Check if the engine is stale based on the provided NetIn object. - """ - def mapNetInToMolarAbundanceVector(self, netIn: gridfire._gridfire.type.NetIn) -> list[float]: - """ - Map a NetIn object to a vector of molar abundances. - """ - def primeEngine(self, netIn: gridfire._gridfire.type.NetIn) -> PrimingReport: + def primeEngine(self, ctx: scratchpads.StateBlob, netIn: gridfire._gridfire.type.NetIn) -> PrimingReport: """ Prime the engine with a NetIn object to prepare for calculations. """ - def rebuild(self, composition: ..., depth: gridfire._gridfire.engine.NetworkBuildDepth | typing.SupportsInt = ...) -> None: - """ - Rebuild the engine with a new composition and build depth. - """ - def setNetworkReactions(self, reactions: gridfire._gridfire.reaction.ReactionSet) -> None: - """ - Set the network reactions to a new set of reactions. - """ - def setScreeningModel(self, screeningModel: gridfire._gridfire.screening.ScreeningType) -> None: - """ - Set the screening model for the engine. - """ - def update(self, netIn: gridfire._gridfire.type.NetIn) -> fourdst._phys.composition.Composition: + 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): - @staticmethod - def getNetReactionStoichiometry(reaction: ...) -> dict[fourdst._phys.atomic.Species, int]: - """ - Get the net stoichiometry for a given reaction. - """ @typing.overload def __init__(self, composition: fourdst._phys.composition.Composition, depth: gridfire._gridfire.engine.NetworkBuildDepth | typing.SupportsInt = ...) -> None: """ @@ -423,15 +329,15 @@ class GraphEngine(DynamicEngine): """ Initialize GraphEngine with a set of reactions. """ - def calculateEpsDerivatives(self, comp: ..., T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> ...: + def calculateEpsDerivatives(self, ctx: scratchpads.StateBlob, comp: ..., T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> ...: """ Calculate deps/dT and deps/drho """ - def calculateMolarReactionFlow(self: DynamicEngine, reaction: ..., comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> float: + 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, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> StepDerivatives: + 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. """ @@ -447,128 +353,90 @@ class GraphEngine(DynamicEngine): """ Calculate the derivative of the reverse rate for a two-body reaction at a specific temperature. """ - def collectComposition(self, composition: ..., T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> fourdst._phys.composition.Composition: + 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, filename: str) -> None: + def exportToCSV(self, ctx: scratchpads.StateBlob, filename: str) -> None: """ Export the network to a CSV file for analysis. """ - def exportToDot(self, filename: str) -> None: + def exportToDot(self, ctx: scratchpads.StateBlob, filename: str) -> None: """ Export the network to a DOT file for visualization. """ @typing.overload - def generateJacobianMatrix(self: DynamicEngine, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> NetworkJacobian: + 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, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat, activeSpecies: collections.abc.Sequence[fourdst._phys.atomic.Species]) -> NetworkJacobian: + 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, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat, sparsityPattern: collections.abc.Sequence[tuple[typing.SupportsInt, typing.SupportsInt]]) -> NetworkJacobian: + 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 generateStoichiometryMatrix(self) -> None: - ... - def getDepth(self) -> gridfire._gridfire.engine.NetworkBuildDepth | int: - """ - Get the current build depth of the engine. - """ - def getNetworkReactions(self) -> gridfire._gridfire.reaction.ReactionSet: + def getNetworkReactions(self, arg0: scratchpads.StateBlob) -> gridfire._gridfire.reaction.ReactionSet: """ Get the set of logical reactions in the network. """ - def getNetworkSpecies(self) -> list[fourdst._phys.atomic.Species]: + def getNetworkSpecies(self, arg0: scratchpads.StateBlob) -> list[fourdst._phys.atomic.Species]: """ Get the list of species in the network. """ - def getPartitionFunction(self) -> gridfire._gridfire.partition.PartitionFunction: + def getPartitionFunction(self, arg0: scratchpads.StateBlob) -> gridfire._gridfire.partition.PartitionFunction: """ Get the partition function used by the engine. """ - def getScreeningModel(self) -> gridfire._gridfire.screening.ScreeningType: + def getScreeningModel(self, arg0: scratchpads.StateBlob) -> gridfire._gridfire.screening.ScreeningType: """ Get the current screening model of the engine. """ @typing.overload - def getSpeciesDestructionTimescales(self, composition: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat, activeReactions: gridfire._gridfire.reaction.ReactionSet) -> ...: + 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, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> dict[fourdst._phys.atomic.Species, float]: + 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, species: fourdst._phys.atomic.Species) -> int: + def getSpeciesIndex(self, ctx: scratchpads.StateBlob, species: fourdst._phys.atomic.Species) -> int: """ Get the index of a species in the network. """ - def getSpeciesStatus(self, species: fourdst._phys.atomic.Species) -> SpeciesStatus: + 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, composition: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat, activeReactions: gridfire._gridfire.reaction.ReactionSet) -> ...: + 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, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> dict[fourdst._phys.atomic.Species, float]: + 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 getStoichiometryMatrixEntry(self, species: fourdst._phys.atomic.Species, reaction: ...) -> int: - """ - Get an entry from the stoichiometry matrix. - """ - def involvesSpecies(self, species: fourdst._phys.atomic.Species) -> bool: + 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) -> bool: + def isPrecomputationEnabled(self, arg0: scratchpads.StateBlob) -> bool: """ Check if precomputation is enabled for the engine. """ - def isStale(self, netIn: gridfire._gridfire.type.NetIn) -> bool: - """ - Check if the engine is stale based on the provided NetIn object. - """ - def isUsingReverseReactions(self) -> bool: + def isUsingReverseReactions(self, arg0: scratchpads.StateBlob) -> bool: """ Check if the engine is using reverse reactions. """ - def mapNetInToMolarAbundanceVector(self, netIn: gridfire._gridfire.type.NetIn) -> list[float]: - """ - Map a NetIn object to a vector of molar abundances. - """ - def primeEngine(self, netIn: gridfire._gridfire.type.NetIn) -> PrimingReport: + def primeEngine(self, ctx: scratchpads.StateBlob, netIn: gridfire._gridfire.type.NetIn) -> PrimingReport: """ Prime the engine with a NetIn object to prepare for calculations. """ - def rebuild(self, composition: ..., depth: gridfire._gridfire.engine.NetworkBuildDepth | typing.SupportsInt = ...) -> None: - """ - Rebuild the engine with a new composition and build depth. - """ - def setNetworkReactions(self, reactions: gridfire._gridfire.reaction.ReactionSet) -> None: - """ - Set the network reactions to a new set of reactions. - """ - def setPrecomputation(self, precompute: bool) -> None: - """ - Enable or disable precomputation for the engine. - """ - def setScreeningModel(self, screeningModel: gridfire._gridfire.screening.ScreeningType) -> None: - """ - Set the screening model for the engine. - """ - def setUseReverseReactions(self, useReverse: bool) -> None: - """ - Enable or disable the use of reverse reactions in the engine. - """ - def update(self, netIn: gridfire._gridfire.type.NetIn) -> fourdst._phys.composition.Composition: + 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. """ @@ -577,142 +445,106 @@ class MultiscalePartitioningEngineView(DynamicEngine): """ Construct a multiscale partitioning engine view with a base engine. """ - def calculateEpsDerivatives(self, comp: ..., T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> ...: + def calculateEpsDerivatives(self, ctx: scratchpads.StateBlob, comp: ..., T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> ...: """ Calculate deps/dT and deps/drho """ - def calculateMolarReactionFlow(self: DynamicEngine, reaction: ..., comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> float: + 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, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> StepDerivatives: + 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, composition: ..., T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> fourdst._phys.composition.Composition: + 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, filename: str, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> None: + 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, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> NetworkJacobian: + 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, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat, activeSpecies: collections.abc.Sequence[fourdst._phys.atomic.Species]) -> NetworkJacobian: + 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, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat, sparsityPattern: collections.abc.Sequence[tuple[typing.SupportsInt, typing.SupportsInt]]) -> NetworkJacobian: + 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 generateStoichiometryMatrix(self) -> None: - ... def getBaseEngine(self) -> DynamicEngine: """ Get the base engine associated with this multiscale partitioning engine view. """ - def getDepth(self) -> gridfire._gridfire.engine.NetworkBuildDepth | int: - """ - Get the current build depth of the engine. - """ - def getDynamicSpecies(self) -> list[fourdst._phys.atomic.Species]: + def getDynamicSpecies(self: scratchpads.StateBlob) -> list[fourdst._phys.atomic.Species]: """ Get the list of dynamic species in the network. """ - def getFastSpecies(self) -> list[fourdst._phys.atomic.Species]: + def getFastSpecies(self, arg0: scratchpads.StateBlob) -> list[fourdst._phys.atomic.Species]: """ Get the list of fast species in the network. """ - def getNetworkReactions(self) -> gridfire._gridfire.reaction.ReactionSet: + def getNetworkReactions(self, arg0: scratchpads.StateBlob) -> gridfire._gridfire.reaction.ReactionSet: """ Get the set of logical reactions in the network. """ - def getNetworkSpecies(self) -> list[fourdst._phys.atomic.Species]: + def getNetworkSpecies(self, arg0: scratchpads.StateBlob) -> list[fourdst._phys.atomic.Species]: """ Get the list of species in the network. """ - def getNormalizedEquilibratedComposition(self, comp: ..., T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> fourdst._phys.composition.Composition: + 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) -> gridfire._gridfire.screening.ScreeningType: + def getScreeningModel(self, arg0: scratchpads.StateBlob) -> gridfire._gridfire.screening.ScreeningType: """ Get the current screening model of the engine. """ - def getSpeciesDestructionTimescales(self: DynamicEngine, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> dict[fourdst._phys.atomic.Species, float]: + 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, species: fourdst._phys.atomic.Species) -> int: + def getSpeciesIndex(self, ctx: scratchpads.StateBlob, species: fourdst._phys.atomic.Species) -> int: """ Get the index of a species in the network. """ - def getSpeciesStatus(self, species: fourdst._phys.atomic.Species) -> SpeciesStatus: + 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, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> dict[fourdst._phys.atomic.Species, float]: + 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 getStoichiometryMatrixEntry(self, species: fourdst._phys.atomic.Species, reaction: ...) -> int: - """ - Get an entry from the stoichiometry matrix. - """ - def involvesSpecies(self, species: fourdst._phys.atomic.Species) -> bool: + 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, species: fourdst._phys.atomic.Species) -> bool: + 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, species: fourdst._phys.atomic.Species) -> bool: + 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 isStale(self, netIn: gridfire._gridfire.type.NetIn) -> bool: - """ - Check if the engine is stale based on the provided NetIn object. - """ - def mapNetInToMolarAbundanceVector(self, netIn: gridfire._gridfire.type.NetIn) -> list[float]: - """ - Map a NetIn object to a vector of molar abundances. - """ - @typing.overload - def partitionNetwork(self, netIn: gridfire._gridfire.type.NetIn) -> fourdst._phys.composition.Composition: + def partitionNetwork(self, ctx: scratchpads.StateBlob, netIn: gridfire._gridfire.type.NetIn) -> fourdst._phys.composition.Composition: """ Partition the network based on species timescales and connectivity. """ - @typing.overload - def partitionNetwork(self, netIn: gridfire._gridfire.type.NetIn) -> fourdst._phys.composition.Composition: - """ - Partition the network based on a NetIn object. - """ - def primeEngine(self, netIn: gridfire._gridfire.type.NetIn) -> PrimingReport: + def primeEngine(self, ctx: scratchpads.StateBlob, netIn: gridfire._gridfire.type.NetIn) -> PrimingReport: """ Prime the engine with a NetIn object to prepare for calculations. """ - def rebuild(self, composition: ..., depth: gridfire._gridfire.engine.NetworkBuildDepth | typing.SupportsInt = ...) -> None: - """ - Rebuild the engine with a new composition and build depth. - """ - def setNetworkReactions(self, reactions: gridfire._gridfire.reaction.ReactionSet) -> None: - """ - Set the network reactions to a new set of reactions. - """ - def setScreeningModel(self, screeningModel: gridfire._gridfire.screening.ScreeningType) -> None: - """ - Set the screening model for the engine. - """ - def update(self, netIn: gridfire._gridfire.type.NetIn) -> fourdst._phys.composition.Composition: + 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. """ @@ -893,113 +725,83 @@ class NetworkJacobian: """ class NetworkPrimingEngineView(DefinedEngineView): @typing.overload - def __init__(self, primingSymbol: str, baseEngine: GraphEngine) -> None: + 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, primingSpecies: fourdst._phys.atomic.Species, baseEngine: GraphEngine) -> None: + 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, comp: ..., T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> ...: + def calculateEpsDerivatives(self, ctx: scratchpads.StateBlob, comp: ..., T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> ...: """ Calculate deps/dT and deps/drho """ - def calculateMolarReactionFlow(self: DynamicEngine, reaction: ..., comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> float: + 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, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> StepDerivatives: + 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, composition: ..., T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> fourdst._phys.composition.Composition: + 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, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> NetworkJacobian: + 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, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat, activeSpecies: collections.abc.Sequence[fourdst._phys.atomic.Species]) -> NetworkJacobian: + 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, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat, sparsityPattern: collections.abc.Sequence[tuple[typing.SupportsInt, typing.SupportsInt]]) -> NetworkJacobian: + 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 generateStoichiometryMatrix(self) -> None: - ... def getBaseEngine(self) -> DynamicEngine: """ Get the base engine associated with this priming engine view. """ - def getDepth(self) -> gridfire._gridfire.engine.NetworkBuildDepth | int: - """ - Get the current build depth of the engine. - """ - def getNetworkReactions(self) -> gridfire._gridfire.reaction.ReactionSet: + def getNetworkReactions(self, arg0: scratchpads.StateBlob) -> gridfire._gridfire.reaction.ReactionSet: """ Get the set of logical reactions in the network. """ - def getNetworkSpecies(self) -> list[fourdst._phys.atomic.Species]: + def getNetworkSpecies(self, arg0: scratchpads.StateBlob) -> list[fourdst._phys.atomic.Species]: """ Get the list of species in the network. """ - def getScreeningModel(self) -> gridfire._gridfire.screening.ScreeningType: + def getScreeningModel(self, arg0: scratchpads.StateBlob) -> gridfire._gridfire.screening.ScreeningType: """ Get the current screening model of the engine. """ - def getSpeciesDestructionTimescales(self: DynamicEngine, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> dict[fourdst._phys.atomic.Species, float]: + 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, species: fourdst._phys.atomic.Species) -> int: + def getSpeciesIndex(self, ctx: scratchpads.StateBlob, species: fourdst._phys.atomic.Species) -> int: """ Get the index of a species in the network. """ - def getSpeciesStatus(self, species: fourdst._phys.atomic.Species) -> SpeciesStatus: + 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, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> dict[fourdst._phys.atomic.Species, float]: + 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 getStoichiometryMatrixEntry(self, species: fourdst._phys.atomic.Species, reaction: ...) -> int: - """ - Get an entry from the stoichiometry matrix. - """ - def isStale(self, netIn: gridfire._gridfire.type.NetIn) -> bool: - """ - Check if the engine is stale based on the provided NetIn object. - """ - def mapNetInToMolarAbundanceVector(self, netIn: gridfire._gridfire.type.NetIn) -> list[float]: - """ - Map a NetIn object to a vector of molar abundances. - """ - def primeEngine(self, netIn: gridfire._gridfire.type.NetIn) -> PrimingReport: + def primeEngine(self, ctx: scratchpads.StateBlob, netIn: gridfire._gridfire.type.NetIn) -> PrimingReport: """ Prime the engine with a NetIn object to prepare for calculations. """ - def rebuild(self, composition: ..., depth: gridfire._gridfire.engine.NetworkBuildDepth | typing.SupportsInt = ...) -> None: - """ - Rebuild the engine with a new composition and build depth. - """ - def setNetworkReactions(self, reactions: gridfire._gridfire.reaction.ReactionSet) -> None: - """ - Set the network reactions to a new set of reactions. - """ - def setScreeningModel(self, screeningModel: gridfire._gridfire.screening.ScreeningType) -> None: - """ - Set the screening model for the engine. - """ - def update(self, netIn: gridfire._gridfire.type.NetIn) -> fourdst._phys.composition.Composition: + 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. """ @@ -1131,7 +933,7 @@ def build_nuclear_network(composition: ..., weakInterpolator: ..., maxLayers: gr """ Build a nuclear network from a composition using all archived reaction data. """ -def primeNetwork(netIn: gridfire._gridfire.type.NetIn, engine: ..., ignoredReactionTypes: collections.abc.Sequence[...] | None = None) -> PrimingReport: +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 """ diff --git a/stubs/gridfire/_gridfire/engine/diagnostics.pyi b/stubs/gridfire/_gridfire/engine/diagnostics.pyi index 5e25cf40..e0955a9e 100644 --- a/stubs/gridfire/_gridfire/engine/diagnostics.pyi +++ b/stubs/gridfire/_gridfire/engine/diagnostics.pyi @@ -5,11 +5,12 @@ 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(engine: gridfire._gridfire.engine.DynamicEngine, comp: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat, json: bool) -> ... | None: +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(engine: gridfire._gridfire.engine.DynamicEngine, species_name: str, 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(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: +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: ... diff --git a/stubs/gridfire/_gridfire/engine/scratchpads.pyi b/stubs/gridfire/_gridfire/engine/scratchpads.pyi new file mode 100644 index 00000000..6509bc84 --- /dev/null +++ b/stubs/gridfire/_gridfire/engine/scratchpads.pyi @@ -0,0 +1,267 @@ +""" +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 = + SUCCESS: typing.ClassVar[ADFunRegistrationResult] # value = + __members__: typing.ClassVar[dict[str, ADFunRegistrationResult]] # value = {'SUCCESS': , 'ALREADY_REGISTERED': } + 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 = + 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 = + 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 = + 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 = + 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 = + DEFINED_ENGINE_VIEW_SCRATCHPAD: typing.ClassVar[ScratchPadType] # value = + GRAPH_ENGINE_SCRATCHPAD: typing.ClassVar[ScratchPadType] # value = + MULTISCALE_PARTITIONING_ENGINE_VIEW_SCRATCHPAD: typing.ClassVar[ScratchPadType] # value = + __members__: typing.ClassVar[dict[str, ScratchPadType]] # value = {'GRAPH_ENGINE_SCRATCHPAD': , 'MULTISCALE_PARTITIONING_ENGINE_VIEW_SCRATCHPAD': , 'ADAPTIVE_ENGINE_VIEW_SCRATCHPAD': , 'DEFINED_ENGINE_VIEW_SCRATCHPAD': } + 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 = + SCRATCHPAD_NOT_FOUND: typing.ClassVar[StateBlobError] # value = + SCRATCHPAD_NOT_INITIALIZED: typing.ClassVar[StateBlobError] # value = + SCRATCHPAD_OUT_OF_BOUNDS: typing.ClassVar[StateBlobError] # value = + SCRATCHPAD_TYPE_COLLISION: typing.ClassVar[StateBlobError] # value = + SCRATCHPAD_UNKNOWN_ERROR: typing.ClassVar[StateBlobError] # value = + __members__: typing.ClassVar[dict[str, StateBlobError]] # value = {'SCRATCHPAD_OUT_OF_BOUNDS': , 'SCRATCHPAD_NOT_FOUND': , 'SCRATCHPAD_BAD_CAST': , 'SCRATCHPAD_NOT_INITIALIZED': , 'SCRATCHPAD_TYPE_COLLISION': , 'SCRATCHPAD_UNKNOWN_ERROR': } + 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 = +ALREADY_REGISTERED: ADFunRegistrationResult # value = +DEFINED_ENGINE_VIEW_SCRATCHPAD: ScratchPadType # value = +GRAPH_ENGINE_SCRATCHPAD: ScratchPadType # value = +MULTISCALE_PARTITIONING_ENGINE_VIEW_SCRATCHPAD: ScratchPadType # value = +SCRATCHPAD_BAD_CAST: StateBlobError # value = +SCRATCHPAD_NOT_FOUND: StateBlobError # value = +SCRATCHPAD_NOT_INITIALIZED: StateBlobError # value = +SCRATCHPAD_OUT_OF_BOUNDS: StateBlobError # value = +SCRATCHPAD_TYPE_COLLISION: StateBlobError # value = +SCRATCHPAD_UNKNOWN_ERROR: StateBlobError # value = +SUCCESS: ADFunRegistrationResult # value = diff --git a/stubs/gridfire/_gridfire/exceptions.pyi b/stubs/gridfire/_gridfire/exceptions.pyi index bfcb1ea1..92796a95 100644 --- a/stubs/gridfire/_gridfire/exceptions.pyi +++ b/stubs/gridfire/_gridfire/exceptions.pyi @@ -2,7 +2,7 @@ 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', 'SingularJacobianError', 'SolverError', 'StaleJacobianError', 'UnableToSetNetworkReactionsError', 'UninitializedJacobianError', 'UnknownJacobianError', 'UtilityError'] +__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): @@ -43,6 +43,8 @@ class ReactionParsingError(ReactionError): pass class SUNDIALSError(SolverError): pass +class ScratchPadError(GridFireError): + pass class SingularJacobianError(SolverError): pass class SolverError(GridFireError): diff --git a/stubs/gridfire/_gridfire/policy.pyi b/stubs/gridfire/_gridfire/policy.pyi index b5bf1af1..3a5c89b9 100644 --- a/stubs/gridfire/_gridfire/policy.pyi +++ b/stubs/gridfire/_gridfire/policy.pyi @@ -6,9 +6,11 @@ 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', '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'] +__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: """ @@ -224,6 +226,13 @@ class CNOIVChainPolicy(TemperatureDependentChainPolicy): """ 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: """ @@ -407,14 +416,18 @@ class MainSequencePolicy(NetworkPolicy): """ Construct MainSequencePolicy from seed species and mass fractions. """ - def construct(self) -> gridfire._gridfire.engine.DynamicEngine: + 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. @@ -423,6 +436,8 @@ class MainSequencePolicy(NetworkPolicy): """ 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. @@ -743,6 +758,10 @@ class TripleAlphaChainPolicy(TemperatureDependentChainPolicy): """ 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 = INITIALIZED_VERIFIED: NetworkPolicyStatus # value = MISSING_KEY_REACTION: NetworkPolicyStatus # value = diff --git a/stubs/gridfire/_gridfire/solver.pyi b/stubs/gridfire/_gridfire/solver.pyi index ee9938ef..44ae0beb 100644 --- a/stubs/gridfire/_gridfire/solver.pyi +++ b/stubs/gridfire/_gridfire/solver.pyi @@ -5,47 +5,113 @@ 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] = ['CVODESolverStrategy', 'CVODETimestepContext', 'DynamicNetworkSolverStrategy', 'SolverContextBase'] -class CVODESolverStrategy(DynamicNetworkSolverStrategy): - def __init__(self, engine: gridfire._gridfire.engine.DynamicEngine) -> None: +__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 CVODESolverStrategy object. + Initialize the GridSolver object. """ - def evaluate(self, netIn: gridfire._gridfire.type.NetIn, display_trigger: bool = False) -> gridfire._gridfire.type.NetOut: + 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 """ - def get_absTol(self) -> float: +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]: """ - Get the absolute tolerance for the CVODE solver. + evaluate the dynamic engine using the dynamic engine class for multiple zones (using openmp if available) """ - def get_relTol(self) -> float: +class PointSolver(SingleZoneDynamicNetworkSolver): + def __init__(self, engine: gridfire._gridfire.engine.DynamicEngine) -> None: """ - Get the relative tolerance for the CVODE solver. + Initialize the PointSolver object. """ - def get_stdout_logging_enabled(self) -> bool: + def evaluate(self, solver_ctx: SolverContextBase, netIn: gridfire._gridfire.type.NetIn, display_trigger: bool = False, force_reinitialization: bool = False) -> gridfire._gridfire.type.NetOut: """ - Check if solver logging to standard output is enabled. + evaluate the dynamic engine using the dynamic engine class """ - def set_absTol(self, absTol: typing.SupportsFloat) -> None: - """ - Set the absolute tolerance for the CVODE solver. - """ - def set_callback(self, cb: collections.abc.Callable[[CVODETimestepContext], None]) -> None: - """ - Set a callback function which will run at the end of every successful timestep - """ - def set_relTol(self, relTol: typing.SupportsFloat) -> None: - """ - Set the relative tolerance for the CVODE solver. - """ - def set_stdout_logging_enabled(self, logging_enabled: bool) -> None: - """ - Enable logging to standard output. - """ -class CVODETimestepContext(SolverContextBase): +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: ... @@ -77,16 +143,15 @@ class CVODETimestepContext(SolverContextBase): def state(self) -> list[float]: ... @property + def state_ctx(self) -> gridfire._gridfire.engine.scratchpads.StateBlob: + ... + @property def t(self) -> float: ... -class DynamicNetworkSolverStrategy: - def describe_callback_context(self) -> list[tuple[str, str]]: +class SingleZoneDynamicNetworkSolver: + def evaluate(self, solver_ctx: SolverContextBase, netIn: gridfire._gridfire.type.NetIn) -> gridfire._gridfire.type.NetOut: """ - Get a structure representing what data is in the callback context in a human readable format - """ - def evaluate(self, netIn: gridfire._gridfire.type.NetIn) -> gridfire._gridfire.type.NetOut: - """ - evaluate the dynamic engine using the dynamic engine class + evaluate the dynamic engine using the dynamic engine class for a single zone """ class SolverContextBase: pass diff --git a/stubs/gridfire/_gridfire/type.pyi b/stubs/gridfire/_gridfire/type.pyi index 45332f62..739086da 100644 --- a/stubs/gridfire/_gridfire/type.pyi +++ b/stubs/gridfire/_gridfire/type.pyi @@ -59,3 +59,9 @@ class NetOut: @property def num_steps(self) -> int: ... + @property + def specific_neutrino_energy_loss(self) -> float: + ... + @property + def specific_neutrino_flux(self) -> float: + ... diff --git a/stubs/gridfire/_gridfire/utils/__init__.pyi b/stubs/gridfire/_gridfire/utils/__init__.pyi index d8738d61..0a86e92c 100644 --- a/stubs/gridfire/_gridfire/utils/__init__.pyi +++ b/stubs/gridfire/_gridfire/utils/__init__.pyi @@ -4,10 +4,11 @@ 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(engine: gridfire._gridfire.engine.DynamicEngine, Y: fourdst._phys.composition.Composition, T9: typing.SupportsFloat, rho: typing.SupportsFloat) -> str: +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. """ diff --git a/stubs/gridfiregridfire/__init__.pyi b/stubs/gridfiregridfire/__init__.pyi new file mode 100644 index 00000000..a5db9463 --- /dev/null +++ b/stubs/gridfiregridfire/__init__.pyi @@ -0,0 +1,42 @@ +from __future__ import annotations +from gridfire._gridfire import config +from gridfire._gridfire import engine +from gridfire._gridfire import exceptions +from gridfire._gridfire import io +from gridfire._gridfire import partition +from gridfire._gridfire import policy +from gridfire._gridfire import reaction +from gridfire._gridfire import screening +from gridfire._gridfire import solver +from gridfire._gridfire import type +from gridfire._gridfire import utils +import importlib as importlib +import sys as sys +from . import _gridfire +__all__: list = ['type', 'utils', 'engine', 'solver', 'exceptions', 'partition', 'reaction', 'screening', 'io', 'policy', 'config'] +def gf_author(): + ... +def gf_collaboration(): + ... +def gf_credits(): + ... +def gf_description(): + ... +def gf_email(): + ... +def gf_license(): + ... +def gf_metadata(): + ... +def gf_url(): + ... +def gf_version(): + ... +__author__ = None +__description__: str = 'Python interface to the GridFire nuclear network code' +__email__: str = '"Emily M. Boudreaux" , Aaron Dotter ' +__license__: str = 'GNU GENERAL PUBLIC LICENSE\n Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. \n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n Preamble\n\n The GNU General Public License is a free, copyleft license for\n software and other kinds of works.\n\n The licenses for most software and other practical works are designed\n to take away your freedom to share and change the works. By contrast,\n the GNU General Public License is intended to guarantee your freedom to\n share and change all versions of a program--to make sure it remains free\n software for all its users. We, the Free Software Foundation, use the\n GNU General Public License for most of our software; it applies also to\n any other work released this way by its authors. You can apply it to\n your programs, too.\n\n When we speak of free software, we are referring to freedom, not\n price. Our General Public Licenses are designed to make sure that you\n have the freedom to distribute copies of free software (and charge for\n them if you wish), that you receive source code or can get it if you\n want it, that you can change the software or use pieces of it in new\n free programs, and that you know you can do these things.\n\n To protect your rights, we need to prevent others from denying you\n these rights or asking you to surrender the rights. Therefore, you have\n certain responsibilities if you distribute copies of the software, or if\n you modify it: responsibilities to respect the freedom of others.\n\n For example, if you distribute copies of such a program, whether\n gratis or for a fee, you must pass on to the recipients the same\n freedoms that you received. You must make sure that they, too, receive\n or can get the source code. And you must show them these terms so they\n know their rights.\n\n Developers that use the GNU GPL protect your rights with two steps:\n (1) assert copyright on the software, and (2) offer you this License\n giving you legal permission to copy, distribute and/or modify it.\n\n For the developers\' and authors\' protection, the GPL clearly explains\n that there is no warranty for this free software. For both users\' and\n authors\' sake, the GPL requires that modified versions be marked as\n changed, so that their problems will not be attributed erroneously to\n authors of previous versions.\n\n Some devices are designed to deny users access to install or run\n modified versions of the software inside them, although the manufacturer\n can do so. This is fundamentally incompatible with the aim of\n protecting users\' freedom to change the software. The systematic\n pattern of such abuse occurs in the area of products for individuals to\n use, which is precisely where it is most unacceptable. Therefore, we\n have designed this version of the GPL to prohibit the practice for those\n products. If such problems arise substantially in other domains, we\n stand ready to extend this provision to those domains in future versions\n of the GPL, as needed to protect the freedom of users.\n\n Finally, every program is threatened constantly by software patents.\n States should not allow patents to restrict development and use of\n software on general-purpose computers, but in those that do, we wish to\n avoid the special danger that patents applied to a free program could\n make it effectively proprietary. To prevent this, the GPL assures that\n patents cannot be used to render the program non-free.\n\n The precise terms and conditions for copying, distribution and\n modification follow.\n\n TERMS AND CONDITIONS\n\n 0. Definitions.\n\n "This License" refers to version 3 of the GNU General Public License.\n\n "Copyright" also means copyright-like laws that apply to other kinds of\n works, such as semiconductor masks.\n\n "The Program" refers to any copyrightable work licensed under this\n License. Each licensee is addressed as "you". "Licensees" and\n "recipients" may be individuals or organizations.\n\n To "modify" a work means to copy from or adapt all or part of the work\n in a fashion requiring copyright permission, other than the making of an\n exact copy. The resulting work is called a "modified version" of the\n earlier work or a work "based on" the earlier work.\n\n A "covered work" means either the unmodified Program or a work based\n on the Program.\n\n To "propagate" a work means to do anything with it that, without\n permission, would make you directly or secondarily liable for\n infringement under applicable copyright law, except executing it on a\n computer or modifying a private copy. Propagation includes copying,\n distribution (with or without modification), making available to the\n public, and in some countries other activities as well.\n\n To "convey" a work means any kind of propagation that enables other\n parties to make or receive copies. Mere interaction with a user through\n a computer network, with no transfer of a copy, is not conveying.\n\n An interactive user interface displays "Appropriate Legal Notices"\n to the extent that it includes a convenient and prominently visible\n feature that (1) displays an appropriate copyright notice, and (2)\n tells the user that there is no warranty for the work (except to the\n extent that warranties are provided), that licensees may convey the\n work under this License, and how to view a copy of this License. If\n the interface presents a list of user commands or options, such as a\n menu, a prominent item in the list meets this criterion.\n\n 1. Source Code.\n\n The "source code" for a work means the preferred form of the work\n for making modifications to it. "Object code" means any non-source\n form of a work.\n\n A "Standard Interface" means an interface that either is an official\n standard defined by a recognized standards body, or, in the case of\n interfaces specified for a particular programming language, one that\n is widely used among developers working in that language.\n\n The "System Libraries" of an executable work include anything, other\n than the work as a whole, that (a) is included in the normal form of\n packaging a Major Component, but which is not part of that Major\n Component, and (b) serves only to enable use of the work with that\n Major Component, or to implement a Standard Interface for which an\n implementation is available to the public in source code form. A\n "Major Component", in this context, means a major essential component\n (kernel, window system, and so on) of the specific operating system\n (if any) on which the executable work runs, or a compiler used to\n produce the work, or an object code interpreter used to run it.\n\n The "Corresponding Source" for a work in object code form means all\n the source code needed to generate, install, and (for an executable\n work) run the object code and to modify the work, including scripts to\n control those activities. However, it does not include the work\'s\n System Libraries, or general-purpose tools or generally available free\n programs which are used unmodified in performing those activities but\n which are not part of the work. For example, Corresponding Source\n includes interface definition files associated with source files for\n the work, and the source code for shared libraries and dynamically\n linked subprograms that the work is specifically designed to require,\n such as by intimate data communication or control flow between those\n subprograms and other parts of the work.\n\n The Corresponding Source need not include anything that users\n can regenerate automatically from other parts of the Corresponding\n Source.\n\n The Corresponding Source for a work in source code form is that\n same work.\n\n 2. Basic Permissions.\n\n All rights granted under this License are granted for the term of\n copyright on the Program, and are irrevocable provided the stated\n conditions are met. This License explicitly affirms your unlimited\n permission to run the unmodified Program. The output from running a\n covered work is covered by this License only if the output, given its\n content, constitutes a covered work. This License acknowledges your\n rights of fair use or other equivalent, as provided by copyright law.\n\n You may make, run and propagate covered works that you do not\n convey, without conditions so long as your license otherwise remains\n in force. You may convey covered works to others for the sole purpose\n of having them make modifications exclusively for you, or provide you\n with facilities for running those works, provided that you comply with\n the terms of this License in conveying all material for which you do\n not control copyright. Those thus making or running the covered works\n for you must do so exclusively on your behalf, under your direction\n and control, on terms that prohibit them from making any copies of\n your copyrighted material outside their relationship with you.\n\n Conveying under any other circumstances is permitted solely under\n the conditions stated below. Sublicensing is not allowed; section 10\n makes it unnecessary.\n\n 3. Protecting Users\' Legal Rights From Anti-Circumvention Law.\n\n No covered work shall be deemed part of an effective technological\n measure under any applicable law fulfilling obligations under article\n 11 of the WIPO copyright treaty adopted on 20 December 1996, or\n similar laws prohibiting or restricting circumvention of such\n measures.\n\n When you convey a covered work, you waive any legal power to forbid\n circumvention of technological measures to the extent such circumvention\n is effected by exercising rights under this License with respect to\n the covered work, and you disclaim any intention to limit operation or\n modification of the work as a means of enforcing, against the work\'s\n users, your or third parties\' legal rights to forbid circumvention of\n technological measures.\n\n 4. Conveying Verbatim Copies.\n\n You may convey verbatim copies of the Program\'s source code as you\n receive it, in any medium, provided that you conspicuously and\n appropriately publish on each copy an appropriate copyright notice;\n keep intact all notices stating that this License and any\n non-permissive terms added in accord with section 7 apply to the code;\n keep intact all notices of the absence of any warranty; and give all\n recipients a copy of this License along with the Program.\n\n You may charge any price or no price for each copy that you convey,\n and you may offer support or warranty protection for a fee.\n\n 5. Conveying Modified Source Versions.\n\n You may convey a work based on the Program, or the modifications to\n produce it from the Program, in the form of source code under the\n terms of section 4, provided that you also meet all of these conditions:\n\n a) The work must carry prominent notices stating that you modified\n it, and giving a relevant date.\n\n b) The work must carry prominent notices stating that it is\n released under this License and any conditions added under section\n 7. This requirement modifies the requirement in section 4 to\n "keep intact all notices".\n\n c) You must license the entire work, as a whole, under this\n License to anyone who comes into possession of a copy. This\n License will therefore apply, along with any applicable section 7\n additional terms, to the whole of the work, and all its parts,\n regardless of how they are packaged. This License gives no\n permission to license the work in any other way, but it does not\n invalidate such permission if you have separately received it.\n\n d) If the work has interactive user interfaces, each must display\n Appropriate Legal Notices; however, if the Program has interactive\n interfaces that do not display Appropriate Legal Notices, your\n work need not make them do so.\n\n A compilation of a covered work with other separate and independent\n works, which are not by their nature extensions of the covered work,\n and which are not combined with it such as to form a larger program,\n in or on a volume of a storage or distribution medium, is called an\n "aggregate" if the compilation and its resulting copyright are not\n used to limit the access or legal rights of the compilation\'s users\n beyond what the individual works permit. Inclusion of a covered work\n in an aggregate does not cause this License to apply to the other\n parts of the aggregate.\n\n 6. Conveying Non-Source Forms.\n\n You may convey a covered work in object code form under the terms\n of sections 4 and 5, provided that you also convey the\n machine-readable Corresponding Source under the terms of this License,\n in one of these ways:\n\n a) Convey the object code in, or embodied in, a physical product\n (including a physical distribution medium), accompanied by the\n Corresponding Source fixed on a durable physical medium\n customarily used for software interchange.\n\n b) Convey the object code in, or embodied in, a physical product\n (including a physical distribution medium), accompanied by a\n written offer, valid for at least three years and valid for as\n long as you offer spare parts or customer support for that product\n model, to give anyone who possesses the object code either (1) a\n copy of the Corresponding Source for all the software in the\n product that is covered by this License, on a durable physical\n medium customarily used for software interchange, for a price no\n more than your reasonable cost of physically performing this\n conveying of source, or (2) access to copy the\n Corresponding Source from a network server at no charge.\n\n c) Convey individual copies of the object code with a copy of the\n written offer to provide the Corresponding Source. This\n alternative is allowed only occasionally and noncommercially, and\n only if you received the object code with such an offer, in accord\n with subsection 6b.\n\n d) Convey the object code by offering access from a designated\n place (gratis or for a charge), and offer equivalent access to the\n Corresponding Source in the same way through the same place at no\n further charge. You need not require recipients to copy the\n Corresponding Source along with the object code. If the place to\n copy the object code is a network server, the Corresponding Source\n may be on a different server (operated by you or a third party)\n that supports equivalent copying facilities, provided you maintain\n clear directions next to the object code saying where to find the\n Corresponding Source. Regardless of what server hosts the\n Corresponding Source, you remain obligated to ensure that it is\n available for as long as needed to satisfy these requirements.\n\n e) Convey the object code using peer-to-peer transmission, provided\n you inform other peers where the object code and Corresponding\n Source of the work are being offered to the general public at no\n charge under subsection 6d.\n\n A separable portion of the object code, whose source code is excluded\n from the Corresponding Source as a System Library, need not be\n included in conveying the object code work.\n\n A "User Product" is either (1) a "consumer product", which means any\n tangible personal property which is normally used for personal, family,\n or household purposes, or (2) anything designed or sold for incorporation\n into a dwelling. In determining whether a product is a consumer product,\n doubtful cases shall be resolved in favor of coverage. For a particular\n product received by a particular user, "normally used" refers to a\n typical or common use of that class of product, regardless of the status\n of the particular user or of the way in which the particular user\n actually uses, or expects or is expected to use, the product. A product\n is a consumer product regardless of whether the product has substantial\n commercial, industrial or non-consumer uses, unless such uses represent\n the only significant mode of use of the product.\n\n "Installation Information" for a User Product means any methods,\n procedures, authorization keys, or other information required to install\n and execute modified versions of a covered work in that User Product from\n a modified version of its Corresponding Source. The information must\n suffice to ensure that the continued functioning of the modified object\n code is in no case prevented or interfered with solely because\n modification has been made.\n\n If you convey an object code work under this section in, or with, or\n specifically for use in, a User Product, and the conveying occurs as\n part of a transaction in which the right of possession and use of the\n User Product is transferred to the recipient in perpetuity or for a\n fixed term (regardless of how the transaction is characterized), the\n Corresponding Source conveyed under this section must be accompanied\n by the Installation Information. But this requirement does not apply\n if neither you nor any third party retains the ability to install\n modified object code on the User Product (for example, the work has\n been installed in ROM).\n\n The requirement to provide Installation Information does not include a\n requirement to continue to provide support service, warranty, or updates\n for a work that has been modified or installed by the recipient, or for\n the User Product in which it has been modified or installed. Access to a\n network may be denied when the modification itself materially and\n adversely affects the operation of the network or violates the rules and\n protocols for communication across the network.\n\n Corresponding Source conveyed, and Installation Information provided,\n in accord with this section must be in a format that is publicly\n documented (and with an implementation available to the public in\n source code form), and must require no special password or key for\n unpacking, reading or copying.\n\n 7. Additional Terms.\n\n "Additional permissions" are terms that supplement the terms of this\n License by making exceptions from one or more of its conditions.\n Additional permissions that are applicable to the entire Program shall\n be treated as though they were included in this License, to the extent\n that they are valid under applicable law. If additional permissions\n apply only to part of the Program, that part may be used separately\n under those permissions, but the entire Program remains governed by\n this License without regard to the additional permissions.\n\n When you convey a copy of a covered work, you may at your option\n remove any additional permissions from that copy, or from any part of\n it. (Additional permissions may be written to require their own\n removal in certain cases when you modify the work.) You may place\n additional permissions on material, added by you to a covered work,\n for which you have or can give appropriate copyright permission.\n\n Notwithstanding any other provision of this License, for material you\n add to a covered work, you may (if authorized by the copyright holders of\n that material) supplement the terms of this License with terms:\n\n a) Disclaiming warranty or limiting liability differently from the\n terms of sections 15 and 16 of this License; or\n\n b) Requiring preservation of specified reasonable legal notices or\n author attributions in that material or in the Appropriate Legal\n Notices displayed by works containing it; or\n\n c) Prohibiting misrepresentation of the origin of that material, or\n requiring that modified versions of such material be marked in\n reasonable ways as different from the original version; or\n\n d) Limiting the use for publicity purposes of names of licensors or\n authors of the material; or\n\n e) Declining to grant rights under trademark law for use of some\n trade names, trademarks, or service marks; or\n\n f) Requiring indemnification of licensors and authors of that\n material by anyone who conveys the material (or modified versions of\n it) with contractual assumptions of liability to the recipient, for\n any liability that these contractual assumptions directly impose on\n those licensors and authors.\n\n All other non-permissive additional terms are considered "further\n restrictions" within the meaning of section 10. If the Program as you\n received it, or any part of it, contains a notice stating that it is\n governed by this License along with a term that is a further\n restriction, you may remove that term. If a license document contains\n a further restriction but permits relicensing or conveying under this\n License, you may add to a covered work material governed by the terms\n of that license document, provided that the further restriction does\n not survive such relicensing or conveying.\n\n If you add terms to a covered work in accord with this section, you\n must place, in the relevant source files, a statement of the\n additional terms that apply to those files, or a notice indicating\n where to find the applicable terms.\n\n Additional terms, permissive or non-permissive, may be stated in the\n form of a separately written license, or stated as exceptions;\n the above requirements apply either way.\n\n 8. Termination.\n\n You may not propagate or modify a covered work except as expressly\n provided under this License. Any attempt otherwise to propagate or\n modify it is void, and will automatically terminate your rights under\n this License (including any patent licenses granted under the third\n paragraph of section 11).\n\n However, if you cease all violation of this License, then your\n license from a particular copyright holder is reinstated (a)\n provisionally, unless and until the copyright holder explicitly and\n finally terminates your license, and (b) permanently, if the copyright\n holder fails to notify you of the violation by some reasonable means\n prior to 60 days after the cessation.\n\n Moreover, your license from a particular copyright holder is\n reinstated permanently if the copyright holder notifies you of the\n violation by some reasonable means, this is the first time you have\n received notice of violation of this License (for any work) from that\n copyright holder, and you cure the violation prior to 30 days after\n your receipt of the notice.\n\n Termination of your rights under this section does not terminate the\n licenses of parties who have received copies or rights from you under\n this License. If your rights have been terminated and not permanently\n reinstated, you do not qualify to receive new licenses for the same\n material under section 10.\n\n 9. Acceptance Not Required for Having Copies.\n\n You are not required to accept this License in order to receive or\n run a copy of the Program. Ancillary propagation of a covered work\n occurring solely as a consequence of using peer-to-peer transmission\n to receive a copy likewise does not require acceptance. However,\n nothing other than this License grants you permission to propagate or\n modify any covered work. These actions infringe copyright if you do\n not accept this License. Therefore, by modifying or propagating a\n covered work, you indicate your acceptance of this License to do so.\n\n 10. Automatic Licensing of Downstream Recipients.\n\n Each time you convey a covered work, the recipient automatically\n receives a license from the original licensors, to run, modify and\n propagate that work, subject to this License. You are not responsible\n for enforcing compliance by third parties with this License.\n\n An "entity transaction" is a transaction transferring control of an\n organization, or substantially all assets of one, or subdividing an\n organization, or merging organizations. If propagation of a covered\n work results from an entity transaction, each party to that\n transaction who receives a copy of the work also receives whatever\n licenses to the work the party\'s predecessor in interest had or could\n give under the previous paragraph, plus a right to possession of the\n Corresponding Source of the work from the predecessor in interest, if\n the predecessor has it or can get it with reasonable efforts.\n\n You may not impose any further restrictions on the exercise of the\n rights granted or affirmed under this License. For example, you may\n not impose a license fee, royalty, or other charge for exercise of\n rights granted under this License, and you may not initiate litigation\n (including a cross-claim or counterclaim in a lawsuit) alleging that\n any patent claim is infringed by making, using, selling, offering for\n sale, or importing the Program or any portion of it.\n\n 11. Patents.\n\n A "contributor" is a copyright holder who authorizes use under this\n License of the Program or a work on which the Program is based. The\n work thus licensed is called the contributor\'s "contributor version".\n\n A contributor\'s "essential patent claims" are all patent claims\n owned or controlled by the contributor, whether already acquired or\n hereafter acquired, that would be infringed by some manner, permitted\n by this License, of making, using, or selling its contributor version,\n but do not include claims that would be infringed only as a\n consequence of further modification of the contributor version. For\n purposes of this definition, "control" includes the right to grant\n patent sublicenses in a manner consistent with the requirements of\n this License.\n\n Each contributor grants you a non-exclusive, worldwide, royalty-free\n patent license under the contributor\'s essential patent claims, to\n make, use, sell, offer for sale, import and otherwise run, modify and\n propagate the contents of its contributor version.\n\n In the following three paragraphs, a "patent license" is any express\n agreement or commitment, however denominated, not to enforce a patent\n (such as an express permission to practice a patent or covenant not to\n sue for patent infringement). To "grant" such a patent license to a\n party means to make such an agreement or commitment not to enforce a\n patent against the party.\n\n If you convey a covered work, knowingly relying on a patent license,\n and the Corresponding Source of the work is not available for anyone\n to copy, free of charge and under the terms of this License, through a\n publicly available network server or other readily accessible means,\n then you must either (1) cause the Corresponding Source to be so\n available, or (2) arrange to deprive yourself of the benefit of the\n patent license for this particular work, or (3) arrange, in a manner\n consistent with the requirements of this License, to extend the patent\n license to downstream recipients. "Knowingly relying" means you have\n actual knowledge that, but for the patent license, your conveying the\n covered work in a country, or your recipient\'s use of the covered work\n in a country, would infringe one or more identifiable patents in that\n country that you have reason to believe are valid.\n\n If, pursuant to or in connection with a single transaction or\n arrangement, you convey, or propagate by procuring conveyance of, a\n covered work, and grant a patent license to some of the parties\n receiving the covered work authorizing them to use, propagate, modify\n or convey a specific copy of the covered work, then the patent license\n you grant is automatically extended to all recipients of the covered\n work and works based on it.\n\n A patent license is "discriminatory" if it does not include within\n the scope of its coverage, prohibits the exercise of, or is\n conditioned on the non-exercise of one or more of the rights that are\n specifically granted under this License. You may not convey a covered\n work if you are a party to an arrangement with a third party that is\n in the business of distributing software, under which you make payment\n to the third party based on the extent of your activity of conveying\n the work, and under which the third party grants, to any of the\n parties who would receive the covered work from you, a discriminatory\n patent license (a) in connection with copies of the covered work\n conveyed by you (or copies made from those copies), or (b) primarily\n for and in connection with specific products or compilations that\n contain the covered work, unless you entered into that arrangement,\n or that patent license was granted, prior to 28 March 2007.\n\n Nothing in this License shall be construed as excluding or limiting\n any implied license or other defenses to infringement that may\n otherwise be available to you under applicable patent law.\n\n 12. No Surrender of Others\' Freedom.\n\n If conditions are imposed on you (whether by court order, agreement or\n otherwise) that contradict the conditions of this License, they do not\n excuse you from the conditions of this License. If you cannot convey a\n covered work so as to satisfy simultaneously your obligations under this\n License and any other pertinent obligations, then as a consequence you may\n not convey it at all. For example, if you agree to terms that obligate you\n to collect a royalty for further conveying from those to whom you convey\n the Program, the only way you could satisfy both those terms and this\n License would be to refrain entirely from conveying the Program.\n\n 13. Use with the GNU Affero General Public License.\n\n Notwithstanding any other provision of this License, you have\n permission to link or combine any covered work with a work licensed\n under version 3 of the GNU Affero General Public License into a single\n combined work, and to convey the resulting work. The terms of this\n License will continue to apply to the part which is the covered work,\n but the special requirements of the GNU Affero General Public License,\n section 13, concerning interaction through a network will apply to the\n combination as such.\n\n 14. Revised Versions of this License.\n\n The Free Software Foundation may publish revised and/or new versions of\n the GNU General Public License from time to time. Such new versions will\n be similar in spirit to the present version, but may differ in detail to\n address new problems or concerns.\n\n Each version is given a distinguishing version number. If the\n Program specifies that a certain numbered version of the GNU General\n Public License "or any later version" applies to it, you have the\n option of following the terms and conditions either of that numbered\n version or of any later version published by the Free Software\n Foundation. If the Program does not specify a version number of the\n GNU General Public License, you may choose any version ever published\n by the Free Software Foundation.\n\n If the Program specifies that a proxy can decide which future\n versions of the GNU General Public License can be used, that proxy\'s\n public statement of acceptance of a version permanently authorizes you\n to choose that version for the Program.\n\n Later license versions may give you additional or different\n permissions. However, no additional obligations are imposed on any\n author or copyright holder as a result of your choosing to follow a\n later version.\n\n 15. Disclaimer of Warranty.\n\n THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\n APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\n HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY\n OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\n THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\n IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\n ALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n 16. Limitation of Liability.\n\n IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\n WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\n THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\n GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\n USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\n DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\n PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\n EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\n SUCH DAMAGES.\n\n 17. Interpretation of Sections 15 and 16.\n\n If the disclaimer of warranty and limitation of liability provided\n above cannot be given local legal effect according to their terms,\n reviewing courts shall apply local law that most closely approximates\n an absolute waiver of all civil liability in connection with the\n Program, unless a warranty or assumption of liability accompanies a\n copy of the Program in return for a fee.\n\n END OF TERMS AND CONDITIONS\n\n How to Apply These Terms to Your New Programs\n\n If you develop a new program, and you want it to be of the greatest\n possible use to the public, the best way to achieve this is to make it\n free software which everyone can redistribute and change under these terms.\n\n To do so, attach the following notices to the program. It is safest\n to attach them to the start of each source file to most effectively\n state the exclusion of warranty; and each file should have at least\n the "copyright" line and a pointer to where the full notice is found.\n\n \n Copyright (C) \n\n This program is free software: you can redistribute it and/or modify\n it under the terms of the GNU General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU General Public License for more details.\n\n You should have received a copy of the GNU General Public License\n along with this program. If not, see .\n\n Also add information on how to contact you by electronic and paper mail.\n\n If the program does terminal interaction, make it output a short\n notice like this when it starts in an interactive mode:\n\n Copyright (C) \n This program comes with ABSOLUTELY NO WARRANTY; for details type `show w\'.\n This is free software, and you are welcome to redistribute it\n under certain conditions; type `show c\' for details.\n\n The hypothetical commands `show w\' and `show c\' should show the appropriate\n parts of the General Public License. Of course, your program\'s commands\n might be different; for a GUI interface, you would use an "about box".\n\n You should also get your employer (if you work as a programmer) or school,\n if any, to sign a "copyright disclaimer" for the program, if necessary.\n For more information on this, and how to apply and follow the GNU GPL, see\n .\n\n The GNU General Public License does not permit incorporating your program\n into proprietary programs. If your program is a subroutine library, you\n may consider it more useful to permit linking proprietary applications with\n the library. If this is what you want to do, use the GNU Lesser General\n Public License instead of this License. But first, please read\n .' +__url__: str = '' +__version__: str = '0.7.4rc3' +__warningregistry__: dict = {'version': 0} +_meta: importlib.metadata._adapters.Message # value = diff --git a/stubs/gridfiregridfire/_gridfire/__init__.pyi b/stubs/gridfiregridfire/_gridfire/__init__.pyi new file mode 100644 index 00000000..58a175d8 --- /dev/null +++ b/stubs/gridfiregridfire/_gridfire/__init__.pyi @@ -0,0 +1,16 @@ +""" +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'] diff --git a/stubs/gridfiregridfire/_gridfire/config.pyi b/stubs/gridfiregridfire/_gridfire/config.pyi new file mode 100644 index 00000000..57eb9940 --- /dev/null +++ b/stubs/gridfiregridfire/_gridfire/config.pyi @@ -0,0 +1,47 @@ +""" +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: + ... diff --git a/stubs/gridfiregridfire/_gridfire/engine/__init__.pyi b/stubs/gridfiregridfire/_gridfire/engine/__init__.pyi new file mode 100644 index 00000000..bda6579c --- /dev/null +++ b/stubs/gridfiregridfire/_gridfire/engine/__init__.pyi @@ -0,0 +1,972 @@ +""" +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 = + DEFINED_ENGINE_VIEW: typing.ClassVar[EngineTypes] # value = + FILE_DEFINED_ENGINE_VIEW: typing.ClassVar[EngineTypes] # value = + GRAPH_ENGINE: typing.ClassVar[EngineTypes] # value = + MULTISCALE_PARTITIONING_ENGINE_VIEW: typing.ClassVar[EngineTypes] # value = + PRIMING_ENGINE_VIEW: typing.ClassVar[EngineTypes] # value = + __members__: typing.ClassVar[dict[str, EngineTypes]] # value = {'GRAPH_ENGINE': , 'ADAPTIVE_ENGINE_VIEW': , 'MULTISCALE_PARTITIONING_ENGINE_VIEW': , 'PRIMING_ENGINE_VIEW': , 'DEFINED_ENGINE_VIEW': , 'FILE_DEFINED_ENGINE_VIEW': } + 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 = + FourthOrder: typing.ClassVar[NetworkBuildDepth] # value = + Full: typing.ClassVar[NetworkBuildDepth] # value = + SecondOrder: typing.ClassVar[NetworkBuildDepth] # value = + Shallow: typing.ClassVar[NetworkBuildDepth] # value = + ThirdOrder: typing.ClassVar[NetworkBuildDepth] # value = + __members__: typing.ClassVar[dict[str, NetworkBuildDepth]] # value = {'Full': , 'Shallow': , 'SecondOrder': , 'ThirdOrder': , 'FourthOrder': , 'FifthOrder': } + 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 = + NONE: typing.ClassVar[NetworkConstructionFlags] # value = + REACLIB: typing.ClassVar[NetworkConstructionFlags] # value = + REACLIB_STRONG: typing.ClassVar[NetworkConstructionFlags] # value = + REACLIB_WEAK: typing.ClassVar[NetworkConstructionFlags] # value = + WRL_BETA_MINUS: typing.ClassVar[NetworkConstructionFlags] # value = + WRL_BETA_PLUS: typing.ClassVar[NetworkConstructionFlags] # value = + WRL_ELECTRON_CAPTURE: typing.ClassVar[NetworkConstructionFlags] # value = + WRL_POSITRON_CAPTURE: typing.ClassVar[NetworkConstructionFlags] # value = + WRL_WEAK: typing.ClassVar[NetworkConstructionFlags] # value = + __members__: typing.ClassVar[dict[str, NetworkConstructionFlags]] # value = {'NONE': , 'REACLIB_STRONG': , 'WRL_BETA_MINUS': , 'WRL_BETA_PLUS': , 'WRL_ELECTRON_CAPTURE': , 'WRL_POSITRON_CAPTURE': , 'REACLIB_WEAK': , 'WRL_WEAK': , 'REACLIB': , 'DEFAULT': } + 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 = + MAX_ITERATIONS_REACHED: typing.ClassVar[PrimingReportStatus] # value = + NO_SPECIES_TO_PRIME: typing.ClassVar[PrimingReportStatus] # value = + __members__: typing.ClassVar[dict[str, PrimingReportStatus]] # value = {'FULL_SUCCESS': , 'NO_SPECIES_TO_PRIME': , 'MAX_ITERATIONS_REACHED': } + 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 = + EQUILIBRIUM: typing.ClassVar[SpeciesStatus] # value = + INACTIVE_FLOW: typing.ClassVar[SpeciesStatus] # value = + NOT_PRESENT: typing.ClassVar[SpeciesStatus] # value = + __members__: typing.ClassVar[dict[str, SpeciesStatus]] # value = {'ACTIVE': , 'EQUILIBRIUM': , 'INACTIVE_FLOW': , 'NOT_PRESENT': } + 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 = +ADAPTIVE_ENGINE_VIEW: EngineTypes # value = +DEFAULT: NetworkConstructionFlags # value = +DEFINED_ENGINE_VIEW: EngineTypes # value = +EQUILIBRIUM: SpeciesStatus # value = +FILE_DEFINED_ENGINE_VIEW: EngineTypes # value = +FULL_SUCCESS: PrimingReportStatus # value = +FifthOrder: NetworkBuildDepth # value = +FourthOrder: NetworkBuildDepth # value = +Full: NetworkBuildDepth # value = +GRAPH_ENGINE: EngineTypes # value = +INACTIVE_FLOW: SpeciesStatus # value = +MAX_ITERATIONS_REACHED: PrimingReportStatus # value = +MULTISCALE_PARTITIONING_ENGINE_VIEW: EngineTypes # value = +NONE: NetworkConstructionFlags # value = +NOT_PRESENT: SpeciesStatus # value = +NO_SPECIES_TO_PRIME: PrimingReportStatus # value = +PRIMING_ENGINE_VIEW: EngineTypes # value = +REACLIB: NetworkConstructionFlags # value = +REACLIB_STRONG: NetworkConstructionFlags # value = +REACLIB_WEAK: NetworkConstructionFlags # value = +SecondOrder: NetworkBuildDepth # value = +Shallow: NetworkBuildDepth # value = +ThirdOrder: NetworkBuildDepth # value = +WRL_BETA_MINUS: NetworkConstructionFlags # value = +WRL_BETA_PLUS: NetworkConstructionFlags # value = +WRL_ELECTRON_CAPTURE: NetworkConstructionFlags # value = +WRL_POSITRON_CAPTURE: NetworkConstructionFlags # value = +WRL_WEAK: NetworkConstructionFlags # value = diff --git a/stubs/gridfiregridfire/_gridfire/engine/diagnostics.pyi b/stubs/gridfiregridfire/_gridfire/engine/diagnostics.pyi new file mode 100644 index 00000000..e0955a9e --- /dev/null +++ b/stubs/gridfiregridfire/_gridfire/engine/diagnostics.pyi @@ -0,0 +1,16 @@ +""" +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: + ... diff --git a/stubs/gridfiregridfire/_gridfire/engine/scratchpads.pyi b/stubs/gridfiregridfire/_gridfire/engine/scratchpads.pyi new file mode 100644 index 00000000..6509bc84 --- /dev/null +++ b/stubs/gridfiregridfire/_gridfire/engine/scratchpads.pyi @@ -0,0 +1,267 @@ +""" +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 = + SUCCESS: typing.ClassVar[ADFunRegistrationResult] # value = + __members__: typing.ClassVar[dict[str, ADFunRegistrationResult]] # value = {'SUCCESS': , 'ALREADY_REGISTERED': } + 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 = + 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 = + 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 = + 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 = + 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 = + DEFINED_ENGINE_VIEW_SCRATCHPAD: typing.ClassVar[ScratchPadType] # value = + GRAPH_ENGINE_SCRATCHPAD: typing.ClassVar[ScratchPadType] # value = + MULTISCALE_PARTITIONING_ENGINE_VIEW_SCRATCHPAD: typing.ClassVar[ScratchPadType] # value = + __members__: typing.ClassVar[dict[str, ScratchPadType]] # value = {'GRAPH_ENGINE_SCRATCHPAD': , 'MULTISCALE_PARTITIONING_ENGINE_VIEW_SCRATCHPAD': , 'ADAPTIVE_ENGINE_VIEW_SCRATCHPAD': , 'DEFINED_ENGINE_VIEW_SCRATCHPAD': } + 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 = + SCRATCHPAD_NOT_FOUND: typing.ClassVar[StateBlobError] # value = + SCRATCHPAD_NOT_INITIALIZED: typing.ClassVar[StateBlobError] # value = + SCRATCHPAD_OUT_OF_BOUNDS: typing.ClassVar[StateBlobError] # value = + SCRATCHPAD_TYPE_COLLISION: typing.ClassVar[StateBlobError] # value = + SCRATCHPAD_UNKNOWN_ERROR: typing.ClassVar[StateBlobError] # value = + __members__: typing.ClassVar[dict[str, StateBlobError]] # value = {'SCRATCHPAD_OUT_OF_BOUNDS': , 'SCRATCHPAD_NOT_FOUND': , 'SCRATCHPAD_BAD_CAST': , 'SCRATCHPAD_NOT_INITIALIZED': , 'SCRATCHPAD_TYPE_COLLISION': , 'SCRATCHPAD_UNKNOWN_ERROR': } + 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 = +ALREADY_REGISTERED: ADFunRegistrationResult # value = +DEFINED_ENGINE_VIEW_SCRATCHPAD: ScratchPadType # value = +GRAPH_ENGINE_SCRATCHPAD: ScratchPadType # value = +MULTISCALE_PARTITIONING_ENGINE_VIEW_SCRATCHPAD: ScratchPadType # value = +SCRATCHPAD_BAD_CAST: StateBlobError # value = +SCRATCHPAD_NOT_FOUND: StateBlobError # value = +SCRATCHPAD_NOT_INITIALIZED: StateBlobError # value = +SCRATCHPAD_OUT_OF_BOUNDS: StateBlobError # value = +SCRATCHPAD_TYPE_COLLISION: StateBlobError # value = +SCRATCHPAD_UNKNOWN_ERROR: StateBlobError # value = +SUCCESS: ADFunRegistrationResult # value = diff --git a/stubs/gridfiregridfire/_gridfire/exceptions.pyi b/stubs/gridfiregridfire/_gridfire/exceptions.pyi new file mode 100644 index 00000000..92796a95 --- /dev/null +++ b/stubs/gridfiregridfire/_gridfire/exceptions.pyi @@ -0,0 +1,61 @@ +""" +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 diff --git a/stubs/gridfiregridfire/_gridfire/io.pyi b/stubs/gridfiregridfire/_gridfire/io.pyi new file mode 100644 index 00000000..6024a26b --- /dev/null +++ b/stubs/gridfiregridfire/_gridfire/io.pyi @@ -0,0 +1,14 @@ +""" +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. + """ diff --git a/stubs/gridfiregridfire/_gridfire/partition.pyi b/stubs/gridfiregridfire/_gridfire/partition.pyi new file mode 100644 index 00000000..50c78f24 --- /dev/null +++ b/stubs/gridfiregridfire/_gridfire/partition.pyi @@ -0,0 +1,142 @@ +""" +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 = + RauscherThielemann: typing.ClassVar[BasePartitionType] # value = + __members__: typing.ClassVar[dict[str, BasePartitionType]] # value = {'RauscherThielemann': , 'GroundState': } + 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 = +RauscherThielemann: BasePartitionType # value = diff --git a/stubs/gridfiregridfire/_gridfire/policy.pyi b/stubs/gridfiregridfire/_gridfire/policy.pyi new file mode 100644 index 00000000..3a5c89b9 --- /dev/null +++ b/stubs/gridfiregridfire/_gridfire/policy.pyi @@ -0,0 +1,769 @@ +""" +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 = + INITIALIZED_VERIFIED: typing.ClassVar[NetworkPolicyStatus] # value = + MISSING_KEY_REACTION: typing.ClassVar[NetworkPolicyStatus] # value = + MISSING_KEY_SPECIES: typing.ClassVar[NetworkPolicyStatus] # value = + UNINITIALIZED: typing.ClassVar[NetworkPolicyStatus] # value = + __members__: typing.ClassVar[dict[str, NetworkPolicyStatus]] # value = {'UNINITIALIZED': , 'INITIALIZED_UNVERIFIED': , 'MISSING_KEY_REACTION': , 'MISSING_KEY_SPECIES': , 'INITIALIZED_VERIFIED': } + 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 = +INITIALIZED_VERIFIED: NetworkPolicyStatus # value = +MISSING_KEY_REACTION: NetworkPolicyStatus # value = +MISSING_KEY_SPECIES: NetworkPolicyStatus # value = +UNINITIALIZED: NetworkPolicyStatus # value = diff --git a/stubs/gridfiregridfire/_gridfire/reaction.pyi b/stubs/gridfiregridfire/_gridfire/reaction.pyi new file mode 100644 index 00000000..d2659168 --- /dev/null +++ b/stubs/gridfiregridfire/_gridfire/reaction.pyi @@ -0,0 +1,249 @@ +""" +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. + """ diff --git a/stubs/gridfiregridfire/_gridfire/screening.pyi b/stubs/gridfiregridfire/_gridfire/screening.pyi new file mode 100644 index 00000000..e2b9c181 --- /dev/null +++ b/stubs/gridfiregridfire/_gridfire/screening.pyi @@ -0,0 +1,68 @@ +""" +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 = + WEAK: typing.ClassVar[ScreeningType] # value = + __members__: typing.ClassVar[dict[str, ScreeningType]] # value = {'BARE': , 'WEAK': } + 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 = +WEAK: ScreeningType # value = diff --git a/stubs/gridfiregridfire/_gridfire/solver.pyi b/stubs/gridfiregridfire/_gridfire/solver.pyi new file mode 100644 index 00000000..44ae0beb --- /dev/null +++ b/stubs/gridfiregridfire/_gridfire/solver.pyi @@ -0,0 +1,157 @@ +""" +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 diff --git a/stubs/gridfiregridfire/_gridfire/type.pyi b/stubs/gridfiregridfire/_gridfire/type.pyi new file mode 100644 index 00000000..739086da --- /dev/null +++ b/stubs/gridfiregridfire/_gridfire/type.pyi @@ -0,0 +1,67 @@ +""" +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: + ... diff --git a/stubs/gridfiregridfire/_gridfire/utils/__init__.pyi b/stubs/gridfiregridfire/_gridfire/utils/__init__.pyi new file mode 100644 index 00000000..0a86e92c --- /dev/null +++ b/stubs/gridfiregridfire/_gridfire/utils/__init__.pyi @@ -0,0 +1,18 @@ +""" +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: + ... diff --git a/stubs/gridfiregridfire/_gridfire/utils/hashing/__init__.pyi b/stubs/gridfiregridfire/_gridfire/utils/hashing/__init__.pyi new file mode 100644 index 00000000..b85a400a --- /dev/null +++ b/stubs/gridfiregridfire/_gridfire/utils/hashing/__init__.pyi @@ -0,0 +1,6 @@ +""" +module for gridfire hashing functions +""" +from __future__ import annotations +from . import reaction +__all__: list[str] = ['reaction'] diff --git a/stubs/gridfiregridfire/_gridfire/utils/hashing/reaction.pyi b/stubs/gridfiregridfire/_gridfire/utils/hashing/reaction.pyi new file mode 100644 index 00000000..131f482d --- /dev/null +++ b/stubs/gridfiregridfire/_gridfire/utils/hashing/reaction.pyi @@ -0,0 +1,12 @@ +""" +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: + ... diff --git a/tests/extern/fortran/gridfire_evolve_multi.f90 b/tests/extern/fortran/gridfire_evolve_multi.f90 index 83381788..341e2d48 100644 --- a/tests/extern/fortran/gridfire_evolve_multi.f90 +++ b/tests/extern/fortran/gridfire_evolve_multi.f90 @@ -14,16 +14,16 @@ program main_multi ! --- 1. Define Species --- character(len=5), dimension(NUM_SPECIES) :: species_names = [ & "H-1 ", & - "He-3 ", & - "He-4 ", & - "C-12 ", & - "N-14 ", & - "O-16 ", & - "Ne-20", & - "Mg-24" & - ] + "He-3 ", & + "He-4 ", & + "C-12 ", & + "N-14 ", & + "O-16 ", & + "Ne-20", & + "Mg-24" & + ] - ! Initial Mass Fractions (converted to Molar Abundances Y = X/A) + ! Initial Mass Fractions ! Standard solar-ish composition template real(c_double), dimension(NUM_SPECIES) :: abundance_root = [ & 0.702616602672027d0, & @@ -71,7 +71,6 @@ program main_multi T_arr(z) = 1.0d7 + dble(z-1) * 1.0d5 rho_arr(z) = 1.5d2 - ! Debug print for first few zones if (z <= 3) then print '(A, I0, A, ES12.5, A, ES12.5, A)', & " Zone ", z-1, " - Temp: ", T_arr(z), " K, Rho: ", rho_arr(z), " g/cm^3" @@ -98,8 +97,6 @@ program main_multi print *, "Evolving system..." ! Note: We pass the arrays T_arr and rho_arr. - ! Ensure your interface change (removing 'value' attribute) is applied - ! so these are passed by reference (address). call net%gff_evolve(Y_in, T_arr, rho_arr, tMax, dt0, & Y_out, energy_out, dedt, dedrho, & snu_e_loss, snu_flux, dmass, ierr) diff --git a/tests/python/test.py b/tests/python/test.py index 74b512ba..7e5f4276 100644 --- a/tests/python/test.py +++ b/tests/python/test.py @@ -1,51 +1,73 @@ -from gridfire.engine import GraphEngine, MultiscalePartitioningEngineView, AdaptiveEngineView -from gridfire.solver import DirectNetworkSolver +from gridfire.solver import PointSolver, PointSolverContext +from gridfire.policy import MainSequencePolicy +from fourdst.composition import Composition + +from fourdst.composition import CanonicalComposition +from fourdst.atomic import Species from gridfire.type import NetIn -from fourdst.composition import Composition -from fourdst.atomic import species +def rescale_composition(comp_ref : Composition, ZZs : float, Y_primordial : float = 0.248) -> Composition: + CC : CanonicalComposition = comp_ref.getCanonicalComposition() -symbols : list[str] = ["H-1", "He-3", "He-4", "C-12", "N-14", "O-16", "Ne-20", "Mg-24"] -X : list[float] = [0.708, 2.94e-5, 0.276, 0.003, 0.0011, 9.62e-3, 1.62e-3, 5.16e-4] + 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) -comp = Composition() -comp.registerSymbol(symbols) -comp.setMassFraction(symbols, X) -comp.finalize(True) - -print(f"Initial H-1 mass fraction {comp.getMassFraction("H-1")}") - -netIn = NetIn() -netIn.composition = comp -netIn.temperature = 1.5e7 -netIn.density = 1.6e2 -netIn.tMax = 4e17 -netIn.dt0 = 1e-12 - -baseEngine = GraphEngine(netIn.composition, 2) -baseEngine.setUseReverseReactions(False) - -qseEngine = MultiscalePartitioningEngineView(baseEngine) - -adaptiveEngine = AdaptiveEngineView(qseEngine) - -solver = DirectNetworkSolver(adaptiveEngine) - - -def callback(context): - H1Index = context.engine.getSpeciesIndex(species["H-1"]) - He4Index = context.engine.getSpeciesIndex(species["He-4"]) - C12ndex = context.engine.getSpeciesIndex(species["C-12"]) - Mgh24ndex = context.engine.getSpeciesIndex(species["Mg-24"]) - print(f"Time: {context.t}, H-1: {context.state[H1Index]}, He-4: {context.state[He4Index]}, C-12: {context.state[C12ndex]}, Mg-24: {context.state[Mgh24ndex]}") - -# solver.set_callback(callback) -results = solver.evaluate(netIn) - -print(f"Final H-1 mass fraction {results.composition.getMassFraction("H-1")}") - +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(): + C = init_composition() + netIn = init_netIn(2.75e6, 1.5e1, years_to_seconds(10e9), C) + policy = MainSequencePolicy(C) + construct = policy.construct() + solver = PointSolver(construct.engine) + solver_ctx = PointSolverContext(construct.scratch_blob) + results = solver.evaluate(solver_ctx, netIn, False, False) + print(results) +if __name__ == "__main__": + main() diff --git a/validation/vv/GridFireValidationSuite.py b/validation/vv/GridFireValidationSuite.py index 2a81672a..eff9081c 100644 --- a/validation/vv/GridFireValidationSuite.py +++ b/validation/vv/GridFireValidationSuite.py @@ -103,7 +103,7 @@ if __name__ == "__main__": parser.add_argument('--suite', type=str, choices=[suite.name for suite in ValidationSuites], nargs="+", help="The validation suite to run.") parser.add_argument("--all", action="store_true", help="Run all validation suites.") parser.add_argument("--pynucastro-compare", action="store_true", help="Generate pynucastro comparison data.") - parser.add_argument("--pync-engine", type=str, choices=["GraphEngine", "MultiscalePartitioningEngineView", "AdaptiveEngineView"], default="AdaptiveEngineView", help="The GridFire engine to use to select the reactions for pyuncastro comparison.") + parser.add_argument("--pync-engine", type=str, choices=["GraphEngine", "MultiscalePartitioningEngineView", "AdaptiveEngineView"], default="AdaptiveEngineView", help="The GridFire engine to use to select the reactions for pynucastro comparison.") args = parser.parse_args() if args.all: diff --git a/validation/vv/testsuite.py b/validation/vv/testsuite.py index 397831f8..d698ca9c 100644 --- a/validation/vv/testsuite.py +++ b/validation/vv/testsuite.py @@ -9,7 +9,7 @@ from gridfire.engine import EngineTypes from gridfire.policy import MainSequencePolicy from gridfire.type import NetIn, NetOut from gridfire.exceptions import GridFireError -from gridfire.solver import CVODESolverStrategy +from gridfire.solver import PointSolver, PointSolverContext from logger import StepLogger from typing import List import re @@ -221,16 +221,16 @@ class TestSuite(ABC): with open(f"GridFireValidationSuite_{self.name}_pynucastro.json", "w") as f: json.dump(pynucastro_json, f, indent=4) - def evolve(self, engine: DynamicEngine, netIn: NetIn, pynucastro_compare: bool = True, engine_type: EngineTypes | None = None): - solver : CVODESolverStrategy = CVODESolverStrategy(engine) + def evolve(self, engine: DynamicEngine, solver_ctx: PointSolverContext, netIn: NetIn, pynucastro_compare: bool = True, engine_type: EngineTypes | None = None): + solver : PointSolver = PointSolver(engine) stepLogger : StepLogger = StepLogger() - solver.set_callback(lambda ctx: stepLogger.log_step(ctx)) + solver_ctx.callback(lambda ctx: stepLogger.log_step(ctx)) startTime = time.time() try: startTime = time.time() - netOut : NetOut = solver.evaluate(netIn) + netOut : NetOut = solver.evaluate(solver_ctx, netIn) endTime = time.time() stepLogger.to_json( f"GridFireValidationSuite_{self.name}_OKAY.json",