From ddaaa1149d9cddf69c83fd57493f4326c6dcc89c Mon Sep 17 00:00:00 2001 From: Michael Zingale Date: Fri, 7 Feb 2025 07:11:32 -0500 Subject: [PATCH 1/3] more work on the docs intro (#1735) --- Docs/source/burn_cell.rst | 2 ++ Docs/source/getting_started.rst | 16 +++++++++++++--- Docs/source/rp_intro.rst | 3 +-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Docs/source/burn_cell.rst b/Docs/source/burn_cell.rst index 125ef8ed6b..502961153b 100644 --- a/Docs/source/burn_cell.rst +++ b/Docs/source/burn_cell.rst @@ -1,3 +1,5 @@ +.. _sec:burn_cell: + ************* ``burn_cell`` ************* diff --git a/Docs/source/getting_started.rst b/Docs/source/getting_started.rst index 18e09c0656..ab6482767a 100644 --- a/Docs/source/getting_started.rst +++ b/Docs/source/getting_started.rst @@ -58,17 +58,27 @@ one-zone burn. In ``Microphysics/`` do: cd unit_test/burn_cell make -This will create an executable called ``main3d.gnu.ex``. Then you can run it as: +This will create an executable called ``main3d.gnu.ex``. +By default, the test is built with the 13-isotope ``aprox13`` network, +``helmholtz`` EOS, and VODE integrator. + + +Then you can run it as: .. prompt:: bash ./main3d.gnu.ex inputs_aprox13 -By default, the test is built with the 13-isotope ``aprox13`` network, -``helmholtz`` EOS, and VODE integrator. Here ``inputs_aprox13`` is the inputs file that sets options. +This will output information about the starting and final state to the +terminal and produce a file ``state_over_time.txt`` that contains the +thermodynamic history at different points in time. + +.. note:: + See the :ref:`sec:burn_cell` documentation for more details on this + unit test and how to visualize the output. Running with AMReX Application Code =================================== diff --git a/Docs/source/rp_intro.rst b/Docs/source/rp_intro.rst index 027de8f709..70f9034f77 100644 --- a/Docs/source/rp_intro.rst +++ b/Docs/source/rp_intro.rst @@ -6,7 +6,7 @@ The behavior of the network and EOS are controlled by many runtime parameters. These parameters are defined in plain-text files ``_parameters`` located in the different directories that hold the microphysics code. At compile time, a script in the AMReX build -system, findparams.py, locates all of the ``_parameters`` files that +system, ``findparams.py``, locates all of the ``_parameters`` files that are needed for the given choice of network, integrator, and EOS, and assembles all of the runtime parameters into a set of header files (using the ``write_probin.py`` script). @@ -32,4 +32,3 @@ noted in separate tables. .. toctree:: runtime_parameters - From dad2c499627d9e2213bd42898abb7c8a2a3b5f84 Mon Sep 17 00:00:00 2001 From: Michael Zingale Date: Fri, 7 Feb 2025 07:11:42 -0500 Subject: [PATCH 2/3] document eos_cell.H (#1737) --- Docs/source/burn_cell.rst | 2 +- Docs/source/eos_cell.rst | 72 ++++++++++++++++++++++++++++++++++ Docs/source/one_zone_tests.rst | 1 + 3 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 Docs/source/eos_cell.rst diff --git a/Docs/source/burn_cell.rst b/Docs/source/burn_cell.rst index 502961153b..5c442dc6b8 100644 --- a/Docs/source/burn_cell.rst +++ b/Docs/source/burn_cell.rst @@ -141,7 +141,7 @@ choice of network. network or integrator. -To run the code, enter the burn_cell directory and run:: +To run the code, in the ``burn_cell`` directory run:: ./main3d.gnu.ex inputs diff --git a/Docs/source/eos_cell.rst b/Docs/source/eos_cell.rst new file mode 100644 index 0000000000..ff7fc94553 --- /dev/null +++ b/Docs/source/eos_cell.rst @@ -0,0 +1,72 @@ +************ +``eos_cell`` +************ + +.. index:: eos_cell + +``eos_cell`` simply calls the equation of state on an input density, temperature, +and composition, and then outputs the full thermodynamic state. This is mainly +used to understand the thermodynamics one might encounter in a simulation +when using a particular EOS. + +Getting Started +=============== + +The ``eos_cell`` code is located in +``Microphysics/unit_test/eos_cell``. An inputs file which sets the +default parameters for your thermodynamic state is needed to run the +test. + +Setting the thermodynamics +-------------------------- + +The parameters that affect the thermodynamics are: + +* ``unit_test.density`` : the initial density + +* ``unit_test.temperature`` : the initial temperature + +* ``unit_test.small_temp`` : the low temperature cutoff used in the equation of state + +* ``unit_test.small_dens`` : the low density cutoff used in the equation of state + +The composition can be set in the same way as in ``burn_cell``, either +by setting each mass fraction explicitly via the parameters, +``unit_test.X1``, ``unit_test.X2``, ..., or forcing them to be all +equal via ``unit_test.uniform_xn=1``. + + +Building and Running the Code +============================= + +The code can be built simply as: + +.. prompt:: bash + + make + +.. note:: + + Even though there are no reactions, a network is still required, + and can be set via the ``NETWORK_DIR`` build variable. By default, + the ``aprox13`` network is used. + + The network choice serves only to set the composition, and a + ``general_null`` network may also be used. + +The build process will automatically create links in the build +directory to any required EOS table. + +To run the code, in the ``eos_cell`` directory run:: + + ./main3d.gnu.ex inputs_eos + +where ``inputs_eos`` is the provided inputs file. You may edit the +thermodynamic state in that file prior to running. + + +Output +====== + +All output is directed to ``stdout`` and simply lists the entries in the +full ``eos_t`` datatype. diff --git a/Docs/source/one_zone_tests.rst b/Docs/source/one_zone_tests.rst index f77ef68c57..fa4a4c9060 100644 --- a/Docs/source/one_zone_tests.rst +++ b/Docs/source/one_zone_tests.rst @@ -11,3 +11,4 @@ have analysis scripts, which we describe in the next sections. :hidden: burn_cell.rst + eos_cell.rst From 31304489dd48659a5e7b25c7028dfbdd6d88e89e Mon Sep 17 00:00:00 2001 From: Michael Zingale Date: Fri, 7 Feb 2025 07:12:04 -0500 Subject: [PATCH 3/3] remove duplicate init_species_all_equal in favor of uniform_xn (#1736) 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/burn_cell_sdc/burn_cell.H | 2 +- unit_test/eos_cell/eos_cell.H | 2 +- unit_test/jac_cell/jac_cell.H | 6 ++++-- unit_test/react_util.H | 9 +++++++-- unit_test/test_react/_parameters | 2 -- 9 files changed, 20 insertions(+), 18 deletions(-) diff --git a/Docs/source/burn_cell.rst b/Docs/source/burn_cell.rst index 5c442dc6b8..7ccfdde5e8 100644 --- a/Docs/source/burn_cell.rst +++ b/Docs/source/burn_cell.rst @@ -82,7 +82,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/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 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