diff --git a/Docs/source/unit_tests.rst b/Docs/source/unit_tests.rst index 64594a8e8..675399a4c 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 ==================== diff --git a/unit_test/table_rate_cell/GNUmakefile b/unit_test/table_rate_cell/GNUmakefile new file mode 100644 index 000000000..74c5099ae --- /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 000000000..a58b0ccab --- /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 000000000..bc43c1a34 --- /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 000000000..c1db53d0c --- /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 000000000..30c6af404 --- /dev/null +++ b/unit_test/table_rate_cell/burn_cell.H @@ -0,0 +1,59 @@ +#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]{}; + for (int n = 0; n < NumSpec; ++n) { + massfractions[n] = 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]; + } + + std::cout << "Ye = " << ye << std::endl; + std::cout << std::endl; + + 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 000000000..faffbc210 --- /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(); +}