From 27b71fc2c0dd883cad7b534b73395acecee732ea Mon Sep 17 00:00:00 2001 From: Michael Zingale Date: Thu, 6 Feb 2025 14:38:41 -0500 Subject: [PATCH 1/2] remove duplicate init_species_all_equal in favor of uniform_xn test_react had already implemented uniform_xn, so now we bump that runtime parameter up a level so all unit tests can use it. --- Docs/source/burn_cell.rst | 2 +- unit_test/_parameters | 3 +++ unit_test/burn_cell/_parameters | 2 -- unit_test/burn_cell/burn_cell.H | 10 +++------- unit_test/react_util.H | 9 +++++++-- unit_test/test_react/_parameters | 2 -- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Docs/source/burn_cell.rst b/Docs/source/burn_cell.rst index 125ef8ed6b..76ac79c6c3 100644 --- a/Docs/source/burn_cell.rst +++ b/Docs/source/burn_cell.rst @@ -80,7 +80,7 @@ by setting: :: - unit_test.init_species_all_equal = 1 + unit_test.uniform_xn = 1 Controlling time diff --git a/unit_test/_parameters b/unit_test/_parameters index 755f5354cb..2fd9224d2e 100644 --- a/unit_test/_parameters +++ b/unit_test/_parameters @@ -39,3 +39,6 @@ X32 real 0.0e0 X33 real 0.0e0 X34 real 0.0e0 X35 real 0.0e0 + +uniform_xn bool 0 + diff --git a/unit_test/burn_cell/_parameters b/unit_test/burn_cell/_parameters index 4ad72846d0..5a39427b8c 100644 --- a/unit_test/burn_cell/_parameters +++ b/unit_test/burn_cell/_parameters @@ -17,5 +17,3 @@ density real 1.e7 temperature real 3.e9 skip_initial_normalization bool 0 - -init_species_all_equal bool 0 diff --git a/unit_test/burn_cell/burn_cell.H b/unit_test/burn_cell/burn_cell.H index 43496f1a67..482fb580f9 100644 --- a/unit_test/burn_cell/burn_cell.H +++ b/unit_test/burn_cell/burn_cell.H @@ -21,14 +21,10 @@ void burn_cell_c() // Make sure user set all the mass fractions to values in the interval [0, 1] for (int n = 1; n <= NumSpec; ++n) { - if (unit_test_rp::init_species_all_equal) { - massfractions[n-1] = 1.0_rt / static_cast(NumSpec); - } else { - massfractions[n-1] = get_xn(n); + massfractions[n-1] = get_xn(n, unit_test_rp::uniform_xn); - if (massfractions[n-1] < 0 || massfractions[n-1] > 1) { - amrex::Error("mass fraction for " + short_spec_names_cxx[n-1] + " not initialized in the interval [0,1]!"); - } + if (massfractions[n-1] < 0 || massfractions[n-1] > 1) { + amrex::Error("mass fraction for " + short_spec_names_cxx[n-1] + " not initialized in the interval [0,1]!"); } } diff --git a/unit_test/react_util.H b/unit_test/react_util.H index 16177f4a9c..7579b753e3 100644 --- a/unit_test/react_util.H +++ b/unit_test/react_util.H @@ -88,7 +88,7 @@ init_t setup_composition(const int nz) { AMREX_INLINE AMREX_GPU_HOST_DEVICE -void get_xn(const int k, const init_t cd, amrex::Real *xn_zone, int uniform_composition = 0) { +void get_xn(const int k, const init_t cd, amrex::Real *xn_zone, bool uniform_composition=false) { for (int n = 0; n < NumSpec; n++) { xn_zone[n] = 0.0_rt; @@ -167,10 +167,15 @@ void get_xn(const int k, const init_t cd, amrex::Real *xn_zone, int uniform_comp /// AMREX_INLINE AMREX_GPU_HOST_DEVICE -amrex::Real get_xn(const int index) { +amrex::Real get_xn(const int index, bool uniform_composition=false) { amrex::Real mass_fraction{}; + if (uniform_composition) { + mass_fraction = 1.0_rt / NumSpec; + return mass_fraction; + } + switch (index) { case 1: diff --git a/unit_test/test_react/_parameters b/unit_test/test_react/_parameters index 918582dd7b..6cfcdab221 100644 --- a/unit_test/test_react/_parameters +++ b/unit_test/test_react/_parameters @@ -5,8 +5,6 @@ dens_max real 1.e9 temp_min real 1.e6 temp_max real 1.e15 -uniform_xn int 0 - tmax real 0.1e0 small_temp real 1.e5 From 60bde117fac92c997bf0f93887e179c6efa5194f Mon Sep 17 00:00:00 2001 From: Michael Zingale Date: Thu, 6 Feb 2025 14:46:23 -0500 Subject: [PATCH 2/2] more syncing --- unit_test/burn_cell_sdc/burn_cell.H | 2 +- unit_test/eos_cell/eos_cell.H | 2 +- unit_test/jac_cell/jac_cell.H | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/unit_test/burn_cell_sdc/burn_cell.H b/unit_test/burn_cell_sdc/burn_cell.H index 1583042eaa..f5e926e1c2 100644 --- a/unit_test/burn_cell_sdc/burn_cell.H +++ b/unit_test/burn_cell_sdc/burn_cell.H @@ -20,7 +20,7 @@ void burn_cell_c() // Make sure user set all the mass fractions to values in the interval [0, 1] for (int n = 1; n <= NumSpec; ++n) { - massfractions[n-1] = get_xn(n); + massfractions[n-1] = get_xn(n, unit_test_rp::uniform_xn); if (massfractions[n-1] < 0 || massfractions[n-1] > 1) { amrex::Error("mass fraction for " + short_spec_names_cxx[n-1] + " not initialized in the interval [0,1]!"); diff --git a/unit_test/eos_cell/eos_cell.H b/unit_test/eos_cell/eos_cell.H index e1d7a5c438..da033d7c20 100644 --- a/unit_test/eos_cell/eos_cell.H +++ b/unit_test/eos_cell/eos_cell.H @@ -24,7 +24,7 @@ void eos_cell_c() // Make sure user set all the mass fractions to values in the interval [0, 1] for (int n = 1; n <= NumSpec; ++n) { - massfractions[n-1] = get_xn(n); + massfractions[n-1] = get_xn(n, unit_test_rp::uniform_xn); if (massfractions[n-1] < 0 || massfractions[n-1] > 1) { amrex::Error("mass fraction for " + short_spec_names_cxx[n-1] + " not initialized in the interval [0,1]!"); diff --git a/unit_test/jac_cell/jac_cell.H b/unit_test/jac_cell/jac_cell.H index fd49859883..33f03cb0c3 100644 --- a/unit_test/jac_cell/jac_cell.H +++ b/unit_test/jac_cell/jac_cell.H @@ -22,7 +22,7 @@ void jac_cell_c() // Make sure user set all the mass fractions to values in the interval [0, 1] for (int n = 1; n <= NumSpec; ++n) { - massfractions[n-1] = get_xn(n); + massfractions[n-1] = get_xn(n, unit_test_rp::uniform_xn); if (massfractions[n-1] < 0 || massfractions[n-1] > 1) { amrex::Error("mass fraction for " + short_spec_names_cxx[n-1] + " not initialized in the interval [0,1]!"); @@ -38,7 +38,9 @@ void jac_cell_c() burn_state.xn[n] = massfractions[n]; } - normalize_abundances_burn(burn_state); + if (! unit_test_rp::skip_initial_normalization) { + normalize_abundances_burn(burn_state); + } // get the energy