diff --git a/.clang-tidy b/.clang-tidy index 1e228494af..2bd4310f7a 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -19,6 +19,7 @@ Checks: > -misc-include-cleaner, -misc-non-private-member-variables-in-classes, -misc-use-anonymous-namespace, + -misc-use-internal-linkage, modernize-*, -modernize-avoid-c-arrays, -modernize-use-trailing-return-type, @@ -29,12 +30,14 @@ Checks: > -readability-avoid-const-params-in-decls, -readability-braces-around-statements, -readability-else-after-return, + -readability-enum-initial-value, -readability-function-cognitive-complexity, -readability-function-size, -readability-identifier-length, -readability-implicit-bool-conversion, -readability-isolate-declaration, -readability-magic-numbers, + -readability-math-missing-parentheses, -readability-named-parameter, -readability-simplify-boolean-expr, mpi-*, diff --git a/.github/workflows/burn_cell_metal_chem.yml b/.github/workflows/burn_cell_metal_chem.yml index 6c587eebf2..13ec5f98ea 100644 --- a/.github/workflows/burn_cell_metal_chem.yml +++ b/.github/workflows/burn_cell_metal_chem.yml @@ -31,7 +31,7 @@ jobs: - name: Compile run: | cd unit_test/burn_cell_metal_chem - make -j 2 + make -j 4 - name: Run and compare outputs for different Z values, also including cosmic ray ionization run: | diff --git a/.github/workflows/burn_cell_primordial_chem.yml b/.github/workflows/burn_cell_primordial_chem.yml index 04f04643e2..7b2ba7a781 100644 --- a/.github/workflows/burn_cell_primordial_chem.yml +++ b/.github/workflows/burn_cell_primordial_chem.yml @@ -31,7 +31,7 @@ jobs: - name: Compile and run run: | cd unit_test/burn_cell_primordial_chem - make -j 2 + make -j 4 ./main1d.gnu.DEBUG.ex inputs_primordial_chem amrex.fpe_trap_{invalid,zero,overflow}=1 > test.out - name: Print backtrace diff --git a/.github/workflows/c-linter.yml b/.github/workflows/c-linter.yml index 56d6bc7235..30e4baa8c8 100644 --- a/.github/workflows/c-linter.yml +++ b/.github/workflows/c-linter.yml @@ -26,7 +26,7 @@ jobs: uses: AMReX-Astro/cpp-linter-action@main with: build_path: 'unit_test/test_react' - make_options: '-j 2 USE_OMP=FALSE USE_MPI=FALSE USE_CUDA=FALSE DEBUG=TRUE' + make_options: '-j 4 USE_OMP=FALSE USE_MPI=FALSE USE_CUDA=FALSE DEBUG=TRUE' ignore_files: 'amrex|util/gcem' header_filter: '(/conductivity/|/constants/|/EOS/|/integration/|/interfaces/|/networks/|/neutrinos/|/nse_solver/|/opacity/|/rates/|/screening/|/util/|^\./).*\.H$' config_file: ${GITHUB_WORKSPACE}/.clang-tidy diff --git a/.github/workflows/castro-development.yml b/.github/workflows/castro-development.yml index 451f4c2037..273e32a7c6 100644 --- a/.github/workflows/castro-development.yml +++ b/.github/workflows/castro-development.yml @@ -47,7 +47,7 @@ jobs: export MICROPHYSICS_HOME=${PWD} cd Castro/Exec/science/flame_wave/ - make -j2 CCACHE=ccache USE_MPI=FALSE + make -j 4 CCACHE=ccache USE_MPI=FALSE ccache -s du -hs ~/.cache/ccache @@ -64,7 +64,7 @@ jobs: export MICROPHYSICS_HOME=${PWD} cd Castro/Exec/science/subchandra/ - make -j2 CCACHE=ccache USE_MPI=FALSE + make -j 4 CCACHE=ccache USE_MPI=FALSE ccache -s du -hs ~/.cache/ccache diff --git a/.github/workflows/castro.yml b/.github/workflows/castro.yml index 0ea9864aca..4a5b1d58e8 100644 --- a/.github/workflows/castro.yml +++ b/.github/workflows/castro.yml @@ -51,7 +51,7 @@ jobs: export MICROPHYSICS_HOME=${PWD} cd Castro/Exec/science/flame_wave/ - make -j2 CCACHE=ccache USE_MPI=FALSE + make -j 4 CCACHE=ccache USE_MPI=FALSE ccache -s du -hs ~/.cache/ccache @@ -68,7 +68,7 @@ jobs: export MICROPHYSICS_HOME=${PWD} cd Castro/Exec/science/subchandra/ - make -j2 CCACHE=ccache USE_MPI=FALSE + make -j 4 CCACHE=ccache USE_MPI=FALSE ccache -s du -hs ~/.cache/ccache diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml index 6482717f89..6563da5f78 100644 --- a/.github/workflows/clang-tidy.yml +++ b/.github/workflows/clang-tidy.yml @@ -26,10 +26,10 @@ jobs: - name: Install dependencies run: | - .github/workflows/dependencies_clang-tidy-apt-llvm.sh 17 + .github/workflows/dependencies_clang-tidy-apt-llvm.sh 19 - name: Compile burn_cell_sdc run: | cd unit_test/burn_cell_sdc - make USE_MPI=FALSE USE_CLANG_TIDY=TRUE CLANG_TIDY=clang-tidy-17 CLANG_TIDY_WARN_ERROR=TRUE -j 4 + make USE_MPI=FALSE USE_CLANG_TIDY=TRUE CLANG_TIDY=clang-tidy-19 CLANG_TIDY_WARN_ERROR=TRUE -j 4 diff --git a/.github/workflows/cmake_build_cell_primordial_chem.yml b/.github/workflows/cmake_build_cell_primordial_chem.yml index 844ab4c8d7..6063770722 100644 --- a/.github/workflows/cmake_build_cell_primordial_chem.yml +++ b/.github/workflows/cmake_build_cell_primordial_chem.yml @@ -18,5 +18,5 @@ jobs: run: | mkdir build && cd build cmake .. -DBUILD_UNIT_TEST=true -DBUILD_AMReX=true - make -j2 + make -j 4 ctest --output-on-failure diff --git a/.github/workflows/cuda.yml b/.github/workflows/cuda.yml index 7e418249a8..fab16b93fe 100644 --- a/.github/workflows/cuda.yml +++ b/.github/workflows/cuda.yml @@ -32,17 +32,17 @@ jobs: run: | export PATH=/usr/local/nvidia/bin:/usr/local/cuda/bin:${PATH} cd unit_test/test_react - make NETWORK_DIR=aprox13 USE_CUDA=TRUE COMP=gnu USE_MPI=FALSE -j 2 + make NETWORK_DIR=aprox13 USE_CUDA=TRUE COMP=gnu USE_MPI=FALSE -j 4 - name: compile test_react (ignition_reaclib/URCA-simple) run: | export PATH=/usr/local/nvidia/bin:/usr/local/cuda/bin:${PATH} cd unit_test/test_react make realclean - make NETWORK_DIR=ignition_reaclib/URCA-simple USE_CUDA=TRUE COMP=gnu USE_MPI=FALSE -j 2 + make NETWORK_DIR=ignition_reaclib/URCA-simple USE_CUDA=TRUE COMP=gnu USE_MPI=FALSE -j 4 - name: compile test_nse_net (ase) run: | export PATH=/usr/local/nvidia/bin:/usr/local/cuda/bin:${PATH} cd unit_test/test_nse_net - make USE_CUDA=TRUE COMP=gnu USE_MPI=FALSE -j 2 + make USE_CUDA=TRUE COMP=gnu USE_MPI=FALSE -j 4 diff --git a/.github/workflows/macos_build_cell_metal_chem.yml b/.github/workflows/macos_build_cell_metal_chem.yml index 581fdd82af..7880dabafc 100644 --- a/.github/workflows/macos_build_cell_metal_chem.yml +++ b/.github/workflows/macos_build_cell_metal_chem.yml @@ -12,11 +12,10 @@ jobs: - name: Install dependencies run: | brew install cmake openmpi python3 || true - brew link --overwrite python@3.11 - name: Compile and run run: | mkdir build && cd build cmake .. -DBUILD_UNIT_TEST_MC=true -DBUILD_AMReX=true - make -j2 + make -j 4 ctest --output-on-failure diff --git a/.github/workflows/macos_build_cell_primordial_chem.yml b/.github/workflows/macos_build_cell_primordial_chem.yml index 243dae2a41..0390c426c1 100644 --- a/.github/workflows/macos_build_cell_primordial_chem.yml +++ b/.github/workflows/macos_build_cell_primordial_chem.yml @@ -12,11 +12,10 @@ jobs: - name: Install dependencies run: | brew install cmake openmpi python3 || true - brew link --overwrite python@3.11 - name: Compile and run run: | mkdir build && cd build cmake .. -DBUILD_UNIT_TEST_PC=true -DBUILD_AMReX=true - make -j2 + make -j 4 ctest --output-on-failure diff --git a/.github/workflows/test_neutrinos.yml b/.github/workflows/test_neutrinos.yml index 46cb99cd8c..4ab1a80cc8 100644 --- a/.github/workflows/test_neutrinos.yml +++ b/.github/workflows/test_neutrinos.yml @@ -29,7 +29,7 @@ jobs: - name: Build the fextrema tool run: | cd external/amrex/Tools/Plotfile - make programs=fextrema -j 2 + make programs=fextrema -j 4 - name: Compile run: | diff --git a/.github/workflows/test_partition_functions.yml b/.github/workflows/test_partition_functions.yml new file mode 100644 index 0000000000..2752920610 --- /dev/null +++ b/.github/workflows/test_partition_functions.yml @@ -0,0 +1,44 @@ +name: test_partition_functions + +on: [pull_request] +jobs: + test_partition_functions: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Get AMReX + run: | + mkdir external + cd external + git clone https://github.com/AMReX-Codes/amrex.git + cd amrex + git checkout development + echo 'AMREX_HOME=$(GITHUB_WORKSPACE)/external/amrex' >> $GITHUB_ENV + echo $AMREX_HOME + if [[ -n "${AMREX_HOME}" ]]; then exit 1; fi + cd ../.. + + - name: Install dependencies + run: | + sudo apt-get update -y -qq + sudo apt-get -qq -y install curl cmake jq clang g++>=9.3.0 + + - name: Compile + run: | + cd unit_test/test_part_func + make clean + make -j 4 + + - name: Run test_part_func + run: | + cd unit_test/test_part_func + ./main3d.gnu.ex > test.out + + - name: Compare to stored output + run: | + cd unit_test/test_part_func + diff -I "^Initializing AMReX" -I "^AMReX" -I "^reading in reaclib rates" test.out ci-benchmarks/part_func.out + diff --git a/.github/workflows/test_rhs.yml b/.github/workflows/test_rhs.yml index 4654200513..21b4a9dcd8 100644 --- a/.github/workflows/test_rhs.yml +++ b/.github/workflows/test_rhs.yml @@ -29,7 +29,7 @@ jobs: - name: Build the fextrema tool run: | cd external/amrex/Tools/Plotfile - make programs=fextrema -j 2 + make programs=fextrema -j 4 - name: Compile, test_rhs (VODE, ignition_simple) run: | diff --git a/CHANGES.md b/CHANGES.md index 18872f398f..224a101517 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,15 @@ +# 24.12 + + * documentation improvements (#1661, #1667, #1670) + + * optimize tabular NSE EOS calls (#1668) + + * CI fixes (#1666, #1671, #1675) and new partition function CI + (#1673) + + * `burn_cell` can now initialize all mass fractions to be equal + (#1665) + # 24.10 * metal chemistry updates (#1648) with ices (#1650) and cosmic rays (#1651) diff --git a/integration/VODE/vode_dvhin.H b/integration/VODE/vode_dvhin.H index 055ddc1394..20c6747224 100644 --- a/integration/VODE/vode_dvhin.H +++ b/integration/VODE/vode_dvhin.H @@ -122,17 +122,13 @@ void dvhin (BurnT& state, DvodeT& vstate, amrex::Real& H0, int& NITER, int& IER) } - // Iteration done. Apply bounds, bias factor, and sign. Then exit. + // Iteration done. Apply bounds and bias factor. Then exit. H0 = hnew * 0.5_rt; - if (H0 < HLB) { - H0 = HLB; - } - if (H0 > HUB) { - H0 = HUB; - } + H0 = std::clamp(H0, HLB, HUB); } + // apply sign H0 = std::copysign(H0, vstate.tout - vstate.t); NITER = iter; IER = 0; diff --git a/networks/aprox13/actual_network.H b/networks/aprox13/actual_network.H index 937585dd88..f678123274 100644 --- a/networks/aprox13/actual_network.H +++ b/networks/aprox13/actual_network.H @@ -134,7 +134,7 @@ namespace NSE_INDEX #endif namespace Rates { - enum NetworkRates { + enum NetworkRates: std::uint8_t { He4_He4_He4_to_C12 = 1, C12_He4_to_O16, C12_C12_to_Ne20_He4, diff --git a/networks/aprox21/actual_network.H b/networks/aprox21/actual_network.H index dcade97f08..9fca91944a 100644 --- a/networks/aprox21/actual_network.H +++ b/networks/aprox21/actual_network.H @@ -152,7 +152,7 @@ namespace NSE_INDEX #endif namespace Rates { - enum NetworkRates { + enum NetworkRates : std::uint8_t { H1_H1_to_He3 = 1, H1_H1_H1_to_He3, P_to_N, diff --git a/networks/iso7/actual_network.H b/networks/iso7/actual_network.H index ea60bd0351..82f81313cc 100644 --- a/networks/iso7/actual_network.H +++ b/networks/iso7/actual_network.H @@ -114,7 +114,7 @@ namespace NSE_INDEX #endif namespace Rates { - enum NetworkRates { + enum NetworkRates : std::uint8_t { C12_He4_to_O16 = 1, He4_He4_He4_to_C12, C12_C12_to_Ne20_He4, diff --git a/networks/rprox/actual_network.H b/networks/rprox/actual_network.H index c16d12dc61..4afd4fc8bb 100644 --- a/networks/rprox/actual_network.H +++ b/networks/rprox/actual_network.H @@ -112,7 +112,7 @@ namespace network namespace Rates { - enum NetworkRates + enum NetworkRates : std::uint8_t { He4_He4_He4_to_C12 = 1, C12_H1_to_N13, diff --git a/networks/subch_base/subch_base.py b/networks/subch_base/subch_base.py index b191b33217..af388f856b 100644 --- a/networks/subch_base/subch_base.py +++ b/networks/subch_base/subch_base.py @@ -94,9 +94,6 @@ def doit(): net.make_ap_pg_approx(intermediate_nuclei=["cl35", "k39", "sc43", "v47", "mn51", "co55"]) net.remove_nuclei(["cl35", "k39", "sc43", "v47", "mn51", "co55"]) - # finally, the aprox nets don't include the reverse rates for - # C12+C12, C12+O16, and O16+O16, so remove those - print(f"number of nuclei: {len(net.unique_nuclei)}") print(f"number of rates: {len(net.rates)}") diff --git a/networks/subch_simple/subch_simple.py b/networks/subch_simple/subch_simple.py index a4edaa0fec..1983ab4550 100644 --- a/networks/subch_simple/subch_simple.py +++ b/networks/subch_simple/subch_simple.py @@ -91,9 +91,6 @@ def doit(): net.make_ap_pg_approx(intermediate_nuclei=["cl35", "k39", "sc43", "v47", "mn51", "co55"]) net.remove_nuclei(["cl35", "k39", "sc43", "v47", "mn51", "co55"]) - # finally, the aprox nets don't include the reverse rates for - # C12+C12, C12+O16, and O16+O16, so remove those - print(f"number of nuclei: {len(net.unique_nuclei)}") print(f"number of rates: {len(net.rates)}") diff --git a/nse_tabular/nse_eos.H b/nse_tabular/nse_eos.H index 425e0d70df..1006889325 100644 --- a/nse_tabular/nse_eos.H +++ b/nse_tabular/nse_eos.H @@ -65,7 +65,7 @@ nse_T_abar_from_e(const amrex::Real rho, const amrex::Real e_in, const amrex::Re amrex::Real abar_old = nse_state.abar; // call the EOS with the initial guess for T - eos_extra_t eos_state; + eos_re_extra_t eos_state; eos_state.rho = rho; eos_state.T = T; eos_state.aux[iye] = Ye; @@ -156,7 +156,7 @@ nse_rho_abar_from_e(const amrex::Real T, const amrex::Real e_in, const amrex::Re amrex::Real abar_old = nse_state.abar; // call the EOS with the initial guess for rho - eos_extra_t eos_state; + eos_re_extra_t eos_state; eos_state.rho = rho; eos_state.T = T; eos_state.aux[iye] = Ye; @@ -247,7 +247,7 @@ nse_T_abar_from_p(const amrex::Real rho, const amrex::Real p_in, const amrex::Re amrex::Real abar_old = nse_state.abar; // call the EOS with the initial guess for T - eos_extra_t eos_state; + eos_rep_extra_t eos_state; eos_state.rho = rho; eos_state.T = T; eos_state.aux[iye] = Ye; @@ -338,7 +338,7 @@ nse_rho_abar_from_p(const amrex::Real T, const amrex::Real p_in, const amrex::Re amrex::Real abar_old = nse_state.abar; // call the EOS with the initial guess for rho - eos_extra_t eos_state; + eos_rep_extra_t eos_state; eos_state.rho = rho; eos_state.T = T; eos_state.aux[iye] = Ye; diff --git a/sphinx_docs/source/conf.py b/sphinx_docs/source/conf.py index a266702ffb..64e5ef03d1 100644 --- a/sphinx_docs/source/conf.py +++ b/sphinx_docs/source/conf.py @@ -223,8 +223,11 @@ def get_version(): linkcheck_retries = 3 linkcheck_timeout = 100 +linkcheck_allow_unauthorized = True +linkcheck_ignore = [r"https://doi.org/10.1103/[Pp]hys[Rr]ev*"] user_agent = "Mozilla/5.0 (X11; Linux x86_64; rv:25.0) Gecko/20100101 Firefox/25.0" + # -- Options for Texinfo output ------------------------------------------- # Grouping the document tree into Texinfo files. List of tuples diff --git a/sphinx_docs/source/data_structures.rst b/sphinx_docs/source/data_structures.rst index a76cf1f0cc..8a4c4ccc3c 100644 --- a/sphinx_docs/source/data_structures.rst +++ b/sphinx_docs/source/data_structures.rst @@ -13,6 +13,8 @@ EOS ``eos_t`` --------- +.. index:: eos_t + The main data structure for interacting with the EOS is ``eos_t``. This is a collection of data specifying the microphysical state of the fluid that we are evaluating. This has many components. For a @@ -49,6 +51,8 @@ Networks ``burn_t`` ---------- +.. index:: burn_t + The main data structure for interacting with the reaction networks is ``burn_t``. This holds the composition (mass fractions), thermodynamic state, and a lot of internal information used by the reaction network @@ -89,7 +93,9 @@ the user will only need to fill/use the following information: ``rate_t``, ``rate_fr_t`` ------------------------- -The ``rate_t`` and ``rate_fr_t`` structures are used internally in a network to pass the +.. index:: rate_t + +The ``rate_t`` structure is used internally in a network to pass the raw reaction rate information (usually just the temperature-dependent terms) between various subroutines. It does not come out of the network-specific righthand side or Jacobian routines. @@ -97,6 +103,8 @@ network-specific righthand side or Jacobian routines. ``burn_type.H`` --------------- +.. index:: burn_type.H + In addition to defining the ``burn_t`` type, the header ``burn_type.H`` also defines integer indices into the solution vector that can be used to access the different components of the state: diff --git a/sphinx_docs/source/eos.rst b/sphinx_docs/source/eos.rst index f49d4987fa..dee9ee809f 100644 --- a/sphinx_docs/source/eos.rst +++ b/sphinx_docs/source/eos.rst @@ -9,6 +9,8 @@ an EOS module in case you want to build your own. Available Equations of State ============================ +.. index:: eos_t + The following equations of state are available in Microphysics. Except where noted, each of these EOSs will provide the full thermodynamic data (including all derivatives) in the ``eos_t`` @@ -22,7 +24,7 @@ equation of state: .. math:: p = (\gamma - 1) \rho e. -:math:`\gamma` is specified by the runtime parameter ``eos_gamma``. For +:math:`\gamma` is specified by the runtime parameter ``eos.eos_gamma``. For an ideal gas, this represents the ratio of specific heats. The gas is assumed to be ideal, with the pressure given by @@ -30,12 +32,12 @@ assumed to be ideal, with the pressure given by where :math:`k` is Boltzmann’s constant and :math:`\mu` is the mean molecular weight, calculated from the composition, :math:`X_k`. This EOS assumes -the gas is either completely neutral (``assume_neutral = T``), +the gas is either completely neutral (``eos.assume_neutral = 1``), giving: .. math:: \mu^{-1} = \sum_k \frac{X_k}{A_k} -or completely ionized (``assume_neutral = F``), giving: +or completely ionized (``eos.assume_neutral = 0``), giving: .. math:: \mu^{-1} = \sum_k \left ( 1 + Z_k \right ) \frac{X_k}{A_k} @@ -43,11 +45,6 @@ The entropy comes from the Sackur-Tetrode equation. Because of the complex way that composition enters into the entropy, the entropy formulation here is only correct for a :math:`\gamma = 5/3` gas. -Note that the implementation provided in Microphysics is the same as -the version shipped with MAESTRO, but more general than the -``gamma_law`` EOS provided with CASTRO. CASTRO’s default EOS only -fills the thermodynamic information in ``eos_t`` that is required -by the hydrodynamics module in CASTRO. polytrope --------- @@ -63,21 +60,21 @@ only independent variable; there is no temperature dependence. The user either selects from a set of predefined options reflecting physical polytropes (e.g. a non-relativistic, fully degenerate electron gas) or inputs their own values for :math:`K` and :math:`\gamma` -via ``polytrope_K`` and ``polytrope_gamma``. +via ``eos.polytrope_K`` and ``eos.polytrope_gamma``. -The runtime parameter ``polytrope_type`` selects the pre-defined +The runtime parameter ``eos.polytrope_type`` selects the pre-defined polytropic relations. The options are: -- ``polytrope_type = 1``: sets :math:`\gamma = 5/3` and +- ``eos.polytrope_type = 1``: sets :math:`\gamma = 5/3` and .. math:: K = \left ( \frac{3}{\pi} \right)^{2/3} \frac{h^2}{20 m_e m_p^{5/3}} \frac{1}{\mu_e^{5/3}} - where :math:`mu_e` is the mean molecular weight per electron, specified via ``polytrope_mu_e`` + where :math:`mu_e` is the mean molecular weight per electron, specified via ``eos.polytrope_mu_e`` This is the form appropriate for a non-relativistic fully-degenerate electron gas. -- ``polytrope_type = 2``: sets :math:`\gamma = 4/3` and +- ``eos.polytrope_type = 2``: sets :math:`\gamma = 4/3` and .. math:: K = \left ( \frac{3}{\pi} \right)^{1/3} \frac{hc}{8 m_p^{4/3}} \frac{1}{\mu_e^{4/3}} @@ -161,12 +158,12 @@ and :math:`p = \rho e (\gamma_\mathrm{effective} - 1)`. This equation of state takes several runtime parameters that can set the :math:`\gamma_i` for a specific species. The parameters are: -- ``eos_gamma_default``: the default :math:`\gamma` to apply for all +- ``eos.eos_gamma_default``: the default :math:`\gamma` to apply for all species -- ``species_X_name`` and ``species_X_gamma``: set the +- ``eos.species_X_name`` and ``eos.species_X_gamma``: set the :math:`\gamma_i` for the species whose name is given as - ``species_X_name`` to the value provided by ``species_X_gamma``. + ``eos.species_X_name`` to the value provided by ``eos.species_X_gamma``. Here, ``X`` can be one of the letters: ``a``, ``b``, or ``c``, allowing us to specify custom :math:`\gamma_i` for up to three different species. @@ -209,6 +206,8 @@ appropriate interpolation table from that site to use this. Interface and Modes =================== +.. index:: eos_t, eos_re_t, eos_rep_t, eos_rh_t, chem_eos_t + The EOS is called as: .. code:: c++ @@ -244,6 +243,11 @@ The *eos_type* passed in is one of * ``eos_rep_t`` : expands on ``eos_re_t`` to include pressure information +* ``eos_rh_t`` : expands on ``eos_rep_t`` to include enthalpy information + +* ``chem_eos_t`` : adds some quantities needed for the primordial chemistry EOS + and explicitly does not include the mass fractions. + In general, you should use the type that has the smallest set of information needed, since we optimize out needless quantities at compile type (via C++ templating) for ``eos_re_t`` and ``eos_rep_t``. @@ -260,6 +264,7 @@ compile type (via C++ templating) for ``eos_re_t`` and ``eos_rep_t``. Auxiliary Composition --------------------- +.. index:: USE_AUX_THERMO With ``USE_AUX_THERMO=TRUE``, we interpret the composition from the auxiliary variables. The auxiliary variables are @@ -298,6 +303,21 @@ The equation of state also needs :math:`\bar{Z}` which is easily computed as \bar{Z} = \bar{A} Y_e +Composition Derivatives +----------------------- + +.. index:: eos_extra_t, eos_re_extra_t, eos_rep_extra_t + +The derivatives $\partial p/\partial A$, $\partial p/\partial Z$, +and $\partial e/\partial A$, $\partial e/\partial Z$ are available via +the ``eos_extra_t``, ``eos_re_extra_t``, ``eos_rep_extra_t``, which +extends the non-"extra" variants with these additional fields. + +The composition derivatives can be used via the ``composition_derivatives()`` function +in ``eos_composition.H`` +to compute :math:`\partial p/\partial X_k |_{\rho, T, X_j}`, :math:`\partial e/\partial X_k |_{\rho, T, X_j}`, and :math:`\partial h/\partial X_k |_{\rho, T, X_j}`. + + Initialization and Cutoff Values ================================ @@ -328,6 +348,3 @@ appropriate time for, say, loading an interpolation table into memory. The main evaluation routine is called ``actual_eos``. It should accept an eos_input and an eos_t state; see Section :ref:`data_structures`. - - - diff --git a/sphinx_docs/source/getting_started.rst b/sphinx_docs/source/getting_started.rst index a338f28ec6..b02c121249 100644 --- a/sphinx_docs/source/getting_started.rst +++ b/sphinx_docs/source/getting_started.rst @@ -5,6 +5,8 @@ Getting Started Standalone ========== +.. index:: AMREX_HOME + Microphysics can be used in a "standalone" fashion to run the unit tests and explore the behavior of the reaction networks. The main requirement is a copy of AMReX: @@ -23,6 +25,8 @@ to set the ``AMREX_HOME`` environment variable to point to the (where you change ``/path/to/amrex`` to your actual path). +.. index:: burn_cell + A good unit test to start with is ``burn_cell`` -- this is simply a one-zone burn. In ``Microphysics/`` do: @@ -45,6 +49,8 @@ Here ``inputs_aprox21`` is the inputs file that sets options. Running with AMReX Application Code =================================== +.. index:: MICROPHYSICS_HOME + Getting started with Microphysics using either CASTRO or MAESTROeX is straightforward. Because the modules here are already in a format that the AMReX codes understand, you only need to provide to the code diff --git a/sphinx_docs/source/index.rst b/sphinx_docs/source/index.rst index 7b48af3de1..c0e9fc7623 100644 --- a/sphinx_docs/source/index.rst +++ b/sphinx_docs/source/index.rst @@ -6,18 +6,36 @@ AMReX-Astro Microphysics ************************ -A collection of microphysics routines (equations of state, +AMReX-Astro Microphysics is a collection of microphysics routines (equations of state, reaction networks, ...) and utilities (ODE integrators, NSE solvers) for astrophysical simulation codes. -.. toctree:: - :maxdepth: 1 +The original design was to support the `AMReX +`_ codes `CASTRO +`_ and MAESTRO (now `MAESTROeX +`_). These all have a +consistent interface and the separate Microphysics repository allows +them to share the same equation of state, reaction networks, and more. +Later, Microphysics was adopted by the `Quokka `_ +simulation code. + +While there are a number of unit tests that exercise the functionality, +Microphysics is primarily intended to be used along with another simulation +code. At the moment, the interfaces and +build stubs are compatible with the AMReX codes and use the AMReX build +system. + +A number of the routines contained here we authored by other people. +We bundle them here with permission, usually changing the interfaces +to be compatible with our standardized interface. We in particular +thank Frank Timmes for numerous reaction networks and his equation +of state routines. - preface .. toctree:: :maxdepth: 1 :caption: Microphysics overview + :hidden: getting_started design @@ -28,6 +46,7 @@ for astrophysical simulation codes. .. toctree:: :maxdepth: 1 :caption: EOS and transport + :hidden: eos transport @@ -35,6 +54,7 @@ for astrophysical simulation codes. .. toctree:: :maxdepth: 1 :caption: Reaction networks + :hidden: networks-overview networks @@ -44,6 +64,7 @@ for astrophysical simulation codes. .. toctree:: :maxdepth: 1 :caption: ODE integrators + :hidden: integrators ode_integrators @@ -53,6 +74,7 @@ for astrophysical simulation codes. .. toctree:: :maxdepth: 1 :caption: Unit tests + :hidden: unit_tests comprehensive_tests @@ -61,13 +83,13 @@ for astrophysical simulation codes. .. toctree:: :maxdepth: 1 :caption: References + :hidden: zreferences +.. toctree:: + :maxdepth: 1 + :caption: Index + :hidden: -Indices and tables -================== - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` + genindex diff --git a/sphinx_docs/source/integrators.rst b/sphinx_docs/source/integrators.rst index cf6c87565d..77c6b93063 100644 --- a/sphinx_docs/source/integrators.rst +++ b/sphinx_docs/source/integrators.rst @@ -17,11 +17,13 @@ The equations we integrate to do a nuclear burn are: \frac{de}{dt} = f(\rho,X_k,T) :label: eq:enuc_integrate -Here, :math:`X_k` is the mass fraction of species :math:`k`, :math:`e` is the specific -nuclear energy created through reactions. Also needed are density :math:`\rho`, -temperature :math:`T`, and the specific heat. The function :math:`f` provides the energy release from reactions and can often be expressed in terms of the -instantaneous reaction terms, :math:`\dot{X}_k`. As noted in the previous -section, this is implemented in a network-specific manner. +Here, :math:`X_k` is the mass fraction of species :math:`k`, :math:`e` +is the specific nuclear energy created through reactions. Also needed +are density :math:`\rho`, temperature :math:`T`, and the specific +heat. The function :math:`f` provides the energy release from +reactions and can often be expressed in terms of the instantaneous +reaction terms, :math:`\dot{X}_k`. As noted in the previous section, +this is implemented in a network-specific manner. In this system, :math:`e` is equal to the total specific internal energy. This allows us to easily call the EOS during the burn to obtain the temperature. @@ -223,7 +225,7 @@ flow is (for VODE): and zero out the temperature and energy derivatives if we are not integrating those quantities. -#. apply any boosting if ``react_boost`` > 0 +#. apply any boosting if ``integrator.react_boost`` > 0 Jacobian implementation diff --git a/sphinx_docs/source/networks-overview.rst b/sphinx_docs/source/networks-overview.rst index f4beb95e9a..02074c1a73 100644 --- a/sphinx_docs/source/networks-overview.rst +++ b/sphinx_docs/source/networks-overview.rst @@ -114,9 +114,11 @@ There are two primary files within each network directory. state and (respectively) the time-derivatives and Jacobian elements to fill in. - Note: some networks do not provide an analytic Jacobian and instead - rely on the numerical difference-approximation to the Jacobian. In - this case, the interface ``actual_jac`` is still needed to compile. + .. note:: + + Some networks do not provide an analytic Jacobian and instead + rely on the numerical difference-approximation to the Jacobian. In + this case, the interface ``actual_jac`` is still needed to compile. Notice that these modules have initialization routines: diff --git a/sphinx_docs/source/networks.rst b/sphinx_docs/source/networks.rst index e0fd944f00..660054d3a4 100644 --- a/sphinx_docs/source/networks.rst +++ b/sphinx_docs/source/networks.rst @@ -56,6 +56,8 @@ for plotfile variables, and the mass number, :math:`A`, and proton number, :math The name of the inputs file by one of two make variables: +.. index:: NETWORK_INPUTS, GENERAL_NET_INPUTS + * ``NETWORK_INPUTS`` : this is simply the name of the "`.net`" file, without any path. The build system will look for it in the current directory and then in ``$(MICROPHYSICS_HOME)/networks/general_null/``. diff --git a/sphinx_docs/source/nse.rst b/sphinx_docs/source/nse.rst index 67b646b1f4..f0dfb51cf7 100644 --- a/sphinx_docs/source/nse.rst +++ b/sphinx_docs/source/nse.rst @@ -7,6 +7,8 @@ instead of integrating the entire network when the conditions are appropriate. There are 2 different implementations of NSE in Microphysics, that have slightly different use cases. +.. index:: USE_NSE_TABLE, USE_NSE_NET + * :ref:`tabulated_nse` : this uses a table of NSE abundances given :math:`(\rho, T, Y_e)` generate from a large network (125 isotopes). The table also returns :math:`dY_e/dt` resulting from @@ -130,7 +132,7 @@ The basic flow of a simulation using ``aprox19`` + the NSE table is as follows: * use :math:`\rho`, :math:`T`, and :math:`Y_e` to call the table. This returns: :math:`dY_e/dt`, :math:`(B/A)_{\rm out}`, and :math:`\bar{A}_{\rm out}`. - * update :math:`Y_e` [#fY]_ : + * update :math:`Y_e` : .. math:: @@ -188,13 +190,13 @@ The composition check considers the following nuclei groups: and we then say that a composition supports NSE if: -* :math:`X(C_group)` < ``C_nse`` +* :math:`X(C_\mathrm{group})` < ``C_nse`` -* :math:`X(O_group)` < ``O_nse`` +* :math:`X(O_\mathrm{group})` < ``O_nse`` -* :math:`X(Si_group)` < ``Si_nse`` +* :math:`X(Si_\mathrm{group})` < ``Si_nse`` -* :math:`X(Fe_group) + X(He_group)` > ``He_Fe_nse`` +* :math:`X(Fe_\mathrm{group}) + X(He_\mathrm{group})` > ``He_Fe_nse`` @@ -441,14 +443,3 @@ to the self-consistent nse check: the subsequent NSE checks. This is mainly to avoid unnecessary computations of computing the NSE mass fractions when the current temperature is too low. This is set to 4.0e9 by default. - - -.. rubric:: Footnotes - -.. [#fY] The table actually provides the weak rate, which is the sum - of all electron capture and positron decay rates times the - appropriate abundances minus a similar rate for the beta decay and - positron capture, [wrate] = [rectot] + [rpdtot] - [redtot] - [rpctot] - - So if electron capture dominates, then [wrate] is positive and this should - be subtracted from :math:`Y_e`. diff --git a/sphinx_docs/source/one_zone_tests.rst b/sphinx_docs/source/one_zone_tests.rst index ec9706a05e..9352a2e626 100644 --- a/sphinx_docs/source/one_zone_tests.rst +++ b/sphinx_docs/source/one_zone_tests.rst @@ -9,6 +9,8 @@ on a single zone to inspect the output directly. ``burn_cell`` ============= +.. index:: ``burn_cell`` + ``burn_cell`` is a simple one-zone burn that will evolve a state with a network for a specified amount of time. This can be used to understand the timescales involved in a reaction sequence or to diff --git a/sphinx_docs/source/preface.rst b/sphinx_docs/source/preface.rst deleted file mode 100644 index efb680fb48..0000000000 --- a/sphinx_docs/source/preface.rst +++ /dev/null @@ -1,30 +0,0 @@ -******* -Preface -******* - -Welcome to the AMReX-Astro Microphysics! - -In this User’s Guide we describe the microphysics modules designed to -enable simulations of stellar explosions. - -The original design was to support the AMReX codes CASTRO and -MAESTRO. These all have a consistent interface and are designed to -provide the users of those codes an easy experience in moving from the -barebones microphysics modules provided in those codes. For the -purposes of this user’s guide, the microphysical components we -currently deal with are the equation of state (EOS) and the nuclear -burning network. - -Microphysics is not a stand-alone code. It is intended to be used in -conjunction with a simulation code. At the moment, the interfaces and -build stubs are compatible with the AMReX codes. In many cases we -will provide test modules that demonstrate a minimal working example -for how to run the modules (leveraging the AMReX build system). The -goal is to make the support more general, and extend to other codes -in the future. - -A number of the routines contained here we authored by other people. -We bundle them here with permission, usually changing the interfaces -to be compatible with our standardized interface. We in particular -thank Frank Timmes for numerous reaction networks and his equation -of state routines. diff --git a/sphinx_docs/source/screening.rst b/sphinx_docs/source/screening.rst index 1d99a925c7..d1739aeb86 100644 --- a/sphinx_docs/source/screening.rst +++ b/sphinx_docs/source/screening.rst @@ -2,6 +2,8 @@ Screening of Reaction Rates *************************** +.. index:: SCREEN_METHOD + Screening of reaction rates can be computed using several different methods, controlled by the make parameter ``SCREEN_METHOD``. For example, @@ -51,4 +53,12 @@ The options are: Runtime Options ---------------- -* ``screening.enable_chabrier1998_quantum_corr = 1`` in the input file enables an additional quantum correction term added to the screening factor when ``SCREEN_METHOD=chabrier1998``. This is disabled by default since ``chabrier1998`` is often used along with ``USE_NSE_NET=TRUE``, and the NSE solver doesn't include quantum corrections. + +.. index:: screening.enable_chabrier1998_quantum_corr + +* ``screening.enable_chabrier1998_quantum_corr = 1`` in the input file + enables an additional quantum correction term added to the screening + factor when ``SCREEN_METHOD=chabrier1998``. This is disabled by + default since ``chabrier1998`` is often used along with + ``USE_NSE_NET=TRUE``, and the NSE solver doesn't include quantum + corrections. diff --git a/sphinx_docs/source/sdc.rst b/sphinx_docs/source/sdc.rst index 3cbf8e7c32..38821a2a10 100644 --- a/sphinx_docs/source/sdc.rst +++ b/sphinx_docs/source/sdc.rst @@ -33,6 +33,7 @@ hydrodynamical sources), and :math:`\Rb(\Uc)` is the reaction source term. +.. index:: USE_TRUE_SDC, USE_SIMPLIFIED_SDC .. note:: diff --git a/sphinx_docs/source/unit_tests.rst b/sphinx_docs/source/unit_tests.rst index a95a18de72..5a36b2c4af 100644 --- a/sphinx_docs/source/unit_tests.rst +++ b/sphinx_docs/source/unit_tests.rst @@ -43,6 +43,8 @@ Tests are divided into three categories: Comprehensive tests =================== +.. index:: test_aprox_rates, test_conductivity, test_eos, test_jac, test_neutrino_cooling, test_react, test_rhs, test_screening_templated, test_sdc + Each of these tests sets up a cube of data, $(\rho, T, X_k)$, with the range of $T$ and $\rho$, and the species to focus on for $X_k$ controlled by options in the input file. @@ -113,6 +115,8 @@ by options in the input file. One-zone tests ============== +.. index:: burn_cell, burn_cell_primordial_chem, burn_cell_sdc, eos_cell, jac_cell, nse_table_cell, test_ase, test_part_func + * ``burn_cell`` : given a $\rho$, $T$, and $X_k$, integrate a reaction network through a specified time @@ -157,6 +161,8 @@ One-zone tests Infrastructure tests ==================== +.. index:: test_linear_algebra, test_nse_interp, test_parameters, test_sdc_vode_rhs + * ``test_linear_algebra`` : create a diagonally dominant matrix, multiply it by a test vector, $x$, diff --git a/unit_test/burn_cell/GNUmakefile b/unit_test/burn_cell/GNUmakefile index 8372650ebb..3940100208 100644 --- a/unit_test/burn_cell/GNUmakefile +++ b/unit_test/burn_cell/GNUmakefile @@ -24,7 +24,7 @@ EOS_DIR := helmholtz # This sets the network directory NETWORK_DIR := aprox13 - +SCREEN_METHOD := screen5 CONDUCTIVITY_DIR := stellar INTEGRATOR_DIR = VODE diff --git a/unit_test/burn_cell/_parameters b/unit_test/burn_cell/_parameters index 9047a84f8e..9dc27e92ef 100644 --- a/unit_test/burn_cell/_parameters +++ b/unit_test/burn_cell/_parameters @@ -19,3 +19,5 @@ 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 71f379471e..43496f1a67 100644 --- a/unit_test/burn_cell/burn_cell.H +++ b/unit_test/burn_cell/burn_cell.H @@ -21,12 +21,15 @@ 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); + if (unit_test_rp::init_species_all_equal) { + massfractions[n-1] = 1.0_rt / static_cast(NumSpec); + } else { + massfractions[n-1] = get_xn(n); - 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]!"); + } } - } // Echo initial conditions at burn and fill burn state input diff --git a/unit_test/test_part_func/ci-benchmarks/part_func.out b/unit_test/test_part_func/ci-benchmarks/part_func.out new file mode 100644 index 0000000000..6bb827da07 --- /dev/null +++ b/unit_test/test_part_func/ci-benchmarks/part_func.out @@ -0,0 +1,9 @@ +Initializing AMReX (24.10-20-gb9d549bcf4a6)... +AMReX (24.10-20-gb9d549bcf4a6) initialized +starting the single zone burn... +reading in network electron-capture / beta-decay tables... +temperature = 5000000000 +Ni56: 1.010868 2.337172328e-11 +Fe52: 1.743116 3.226066771e-10 +spins: 2 1 1 8 1 +AMReX (24.10-20-gb9d549bcf4a6) finalized