From e4d187389c12639d085502e937f9e5f2af930d70 Mon Sep 17 00:00:00 2001 From: Michael Zingale Date: Thu, 23 Apr 2026 14:49:09 -0400 Subject: [PATCH 1/3] add a simple unit test that just evaluates a tabular weak rate this requires a pynucastro net. This is for debugging the interpolation. --- unit_test/table_rate_cell/GNUmakefile | 39 +++++++++++++++++++ unit_test/table_rate_cell/Make.package | 2 + unit_test/table_rate_cell/README.md | 7 ++++ unit_test/table_rate_cell/_parameters | 5 +++ unit_test/table_rate_cell/burn_cell.H | 52 ++++++++++++++++++++++++++ unit_test/table_rate_cell/main.cpp | 28 ++++++++++++++ 6 files changed, 133 insertions(+) create mode 100644 unit_test/table_rate_cell/GNUmakefile create mode 100644 unit_test/table_rate_cell/Make.package create mode 100644 unit_test/table_rate_cell/README.md create mode 100644 unit_test/table_rate_cell/_parameters create mode 100644 unit_test/table_rate_cell/burn_cell.H create mode 100644 unit_test/table_rate_cell/main.cpp diff --git a/unit_test/table_rate_cell/GNUmakefile b/unit_test/table_rate_cell/GNUmakefile new file mode 100644 index 0000000000..74c5099aec --- /dev/null +++ b/unit_test/table_rate_cell/GNUmakefile @@ -0,0 +1,39 @@ +PRECISION = DOUBLE +PROFILE = FALSE + +DEBUG = FALSE + +DIM = 3 + +COMP = gnu + +USE_MPI = FALSE +USE_OMP = FALSE + +USE_REACT = TRUE + +EBASE = main + +BL_NO_FORT = TRUE + +# define the location of the Microphysics top directory +MICROPHYSICS_HOME := ../.. + +# This sets the EOS directory +EOS_DIR := helmholtz + +# This sets the network directory +NETWORK_DIR := he-burn/ase-iron +SCREEN_METHOD := screen5 +CONDUCTIVITY_DIR := stellar + +INTEGRATOR_DIR = VODE + +EXTERN_SEARCH += . .. + +Bpack := ./Make.package +Blocs := . + +include $(MICROPHYSICS_HOME)/unit_test/Make.unit_test + + diff --git a/unit_test/table_rate_cell/Make.package b/unit_test/table_rate_cell/Make.package new file mode 100644 index 0000000000..a58b0ccabf --- /dev/null +++ b/unit_test/table_rate_cell/Make.package @@ -0,0 +1,2 @@ +CEXE_sources += main.cpp +CEXE_headers += burn_cell.H diff --git a/unit_test/table_rate_cell/README.md b/unit_test/table_rate_cell/README.md new file mode 100644 index 0000000000..bc43c1a345 --- /dev/null +++ b/unit_test/table_rate_cell/README.md @@ -0,0 +1,7 @@ +# table_rate_cell + +A simple driver to just evaluate a tabulated weak rate from a +pynucastro network. + +This is setup for the ``ase-iron`` network and just does the +interpolation and outputs the raw rate. diff --git a/unit_test/table_rate_cell/_parameters b/unit_test/table_rate_cell/_parameters new file mode 100644 index 0000000000..c1db53d0cd --- /dev/null +++ b/unit_test/table_rate_cell/_parameters @@ -0,0 +1,5 @@ +@namespace: unit_test + +density real 2.e7 + +temperature real 4.e9 diff --git a/unit_test/table_rate_cell/burn_cell.H b/unit_test/table_rate_cell/burn_cell.H new file mode 100644 index 0000000000..14b9637174 --- /dev/null +++ b/unit_test/table_rate_cell/burn_cell.H @@ -0,0 +1,52 @@ +#ifndef BURN_CELL_H +#define BURN_CELL_H + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +AMREX_INLINE +void burn_cell_c() +{ + + amrex::Real massfractions[NumSpec] = {1.0_rt / NumSpec}; + + + std::cout << std::endl; + std::cout << "State Density (g/cm^3): " << unit_test_rp::density << std::endl; + std::cout << "State Temperature (K): " << unit_test_rp::temperature << std::endl; + std::cout << std::endl; + + amrex::Real ye{}; + for (int i = 0; i < NumSpec; ++i) { + ye += zion[i] * massfractions[i] / aion[i]; + } + + auto rhoy = unit_test_rp::density * ye; + auto T = unit_test_rp::temperature; + + amrex::Real log_temp = std::log10(T); + amrex::Real log_rhoy = std::log10(rhoy); + + [[maybe_unused]] amrex::Real rate, drate_dt, edot_nu, edot_gamma; + + tabular_evaluate(j_Co56_Fe56_meta, j_Co56_Fe56_rhoy, j_Co56_Fe56_temp, j_Co56_Fe56_data, + log_rhoy, log_temp, T, rate, drate_dt, edot_nu, edot_gamma); + + std::cout << "Co56 -> Fe56 rate = " << rate << std::endl; + + tabular_evaluate(j_Co56_Ni56_meta, j_Co56_Ni56_rhoy, j_Co56_Ni56_temp, j_Co56_Ni56_data, + log_rhoy, log_temp, T, rate, drate_dt, edot_nu, edot_gamma); + + std::cout << "Co56 -> Ni56 rate = " << rate << std::endl; + +} +#endif diff --git a/unit_test/table_rate_cell/main.cpp b/unit_test/table_rate_cell/main.cpp new file mode 100644 index 0000000000..faffbc210b --- /dev/null +++ b/unit_test/table_rate_cell/main.cpp @@ -0,0 +1,28 @@ +#include + +#include +#include +#include +#include +#include + +using namespace unit_test_rp; + +int main(int argc, char *argv[]) { + + amrex::Initialize(argc, argv); + + std::cout << "starting the single zone burn..." << std::endl; + + init_unit_test(); + + // C++ EOS initialization (must be done after init_extern_parameters) + eos_init(small_temp, small_dens); + + // C++ Network, RHS, screening, rates initialization + network_init(); + + burn_cell_c(); + + amrex::Finalize(); +} From cbfd5d4f19a520881e6d927c56824a9c4ba2d0df Mon Sep 17 00:00:00 2001 From: Michael Zingale Date: Thu, 23 Apr 2026 15:19:23 -0400 Subject: [PATCH 2/3] fix mass fractions and Ye --- unit_test/table_rate_cell/burn_cell.H | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/unit_test/table_rate_cell/burn_cell.H b/unit_test/table_rate_cell/burn_cell.H index 14b9637174..30c6af4043 100644 --- a/unit_test/table_rate_cell/burn_cell.H +++ b/unit_test/table_rate_cell/burn_cell.H @@ -17,7 +17,11 @@ AMREX_INLINE void burn_cell_c() { - amrex::Real massfractions[NumSpec] = {1.0_rt / NumSpec}; + amrex::Real massfractions[NumSpec]{}; + for (int n = 0; n < NumSpec; ++n) { + massfractions[n] = 1.0_rt / NumSpec; + } + std::cout << std::endl; @@ -30,6 +34,9 @@ void burn_cell_c() ye += zion[i] * massfractions[i] / aion[i]; } + std::cout << "Ye = " << ye << std::endl; + std::cout << std::endl; + auto rhoy = unit_test_rp::density * ye; auto T = unit_test_rp::temperature; From b8ec19e5ff668ab9029bcf4564a775b6bee24cb3 Mon Sep 17 00:00:00 2001 From: Michael Zingale Date: Thu, 23 Apr 2026 15:46:03 -0400 Subject: [PATCH 3/3] update docs --- Docs/source/unit_tests.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Docs/source/unit_tests.rst b/Docs/source/unit_tests.rst index 64594a8e86..675399a4c8 100644 --- a/Docs/source/unit_tests.rst +++ b/Docs/source/unit_tests.rst @@ -165,6 +165,11 @@ One-zone tests exercise the partition function interpolation for a few select nuclei. +* ``table_rate_cell`` + + evaluate a tabular weak rate from a pynucastro network. This is meant to be + used for a direct comparison to pynucastro to make sure the interpolation is + working. Infrastructure tests ====================