From 6088fb9c12791bb56c9430e1a2feda864ba315b6 Mon Sep 17 00:00:00 2001 From: Emily Boudreaux Date: Thu, 30 Oct 2025 15:06:59 -0400 Subject: [PATCH] test(graphnet_sandbox): updated graphnet sandbox to test full network stack --- tests/graphnet_sandbox/main.cpp | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/tests/graphnet_sandbox/main.cpp b/tests/graphnet_sandbox/main.cpp index b32f232d..5311bc92 100644 --- a/tests/graphnet_sandbox/main.cpp +++ b/tests/graphnet_sandbox/main.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "gridfire/engine/engine_graph.h" #include "gridfire/engine/engine_approx8.h" @@ -34,8 +35,7 @@ void measure_execution_time(const std::function& callback, const std::st callback(); const auto endTime = std::chrono::steady_clock::now(); const auto duration = std::chrono::duration_cast(endTime - startTime); - std::cout << "Execution time for " << name << ": " - << duration.count()/1e9 << " s\n"; + std::cout << "Execution time for " << name << ": " << duration.count()/1e9 << " s\n"; } void quill_terminate_handler() @@ -82,7 +82,7 @@ int main(int argc, char* argv[]){ g_previousHandler = std::set_terminate(quill_terminate_handler); quill::Logger* logger = fourdst::logging::LogManager::getInstance().getLogger("log"); - logger->set_log_level(quill::LogLevel::TraceL3); + logger->set_log_level(quill::LogLevel::TraceL2); LOG_INFO(logger, "Starting Adaptive Engine View Example..."); using namespace gridfire; @@ -109,31 +109,38 @@ int main(int argc, char* argv[]){ netIn.temperature = 1.5e7; netIn.density = 1.6e2; netIn.energy = 0; + + // TODO: There is a bug when I get to very low concentrations of hydrogen where the solver will crash. I suspect this can be resolved with triggers netIn.tMax = 3e16; // netIn.tMax = 1e-14; netIn.dt0 = 1e-12; GraphEngine ReaclibEngine(composition, partitionFunction, NetworkBuildDepth::SecondOrder); - ReaclibEngine.setUseReverseReactions(false); - ReaclibEngine.setPrecomputation(false); - // DefinedEngineView ppEngine({"p(p,e+)d", "d(p,g)he3", "he3(he3,2p)he4"}, ReaclibEngine); + ReaclibEngine.setPrecomputation(true); + ReaclibEngine.setUseReverseReactions(false); + + DefinedEngineView subsetView({"p(p,e+)d", "d(p,g)he3", "n(p,g)d", "d(n,g)t"}, ReaclibEngine); MultiscalePartitioningEngineView partitioningView(ReaclibEngine); + AdaptiveEngineView adaptiveView(partitioningView); + + fourdst::composition::Composition updatedComposition = adaptiveView.update(netIn); + + adaptiveView.generateJacobianMatrix(updatedComposition, netIn.temperature/1e9, netIn.density); + solver::CVODESolverStrategy solver(adaptiveView); NetOut netOut; - - netOut = solver.evaluate(netIn); - // consumptionFile.close(); + std::cout << "Initial H-1: " << netIn.composition.getMassFraction("H-1") << std::endl; std::cout << "NetOut H-1: " << netOut.composition.getMassFraction("H-1") << std::endl; - double initialHydrogen = netIn.composition.getMassFraction("H-1"); double finalHydrogen = netOut.composition.getMassFraction("H-1"); double fractionalConsumedHydrogen = (initialHydrogen - finalHydrogen) / initialHydrogen * 100.0; std::cout << "Fractional consumed hydrogen: " << fractionalConsumedHydrogen << "%" << std::endl; + std::cout << "Final D abundance " << netOut.composition.getMolarAbundance("H-2") << std::endl; std::cout << netOut << std::endl; } \ No newline at end of file