Skip to content

Commit

Permalink
Merge branch 'doc_burn_cell_sdc' of github.com:zingale/Microphysics i…
Browse files Browse the repository at this point in the history
…nto doc_burn_cell_sdc
  • Loading branch information
zingale committed Feb 14, 2025
2 parents 8feb066 + cf10ab0 commit 9aff213
Show file tree
Hide file tree
Showing 50 changed files with 437 additions and 479 deletions.
20 changes: 11 additions & 9 deletions .github/workflows/dependencies/dependencies_hip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ sudo apt-key add rocm.gpg.key

source /etc/os-release # set UBUNTU_CODENAME: focal or jammy or ...

echo "deb [arch=amd64] https://repo.radeon.com/rocm/apt/${1-latest} ${UBUNTU_CODENAME} main" \
VERSION=${1-6.3.2}

echo "deb [arch=amd64] https://repo.radeon.com/rocm/apt/${VERSION} ${UBUNTU_CODENAME} main" \
| sudo tee /etc/apt/sources.list.d/rocm.list
echo 'export PATH=/opt/rocm/llvm/bin:/opt/rocm/bin:/opt/rocm/profiler/bin:/opt/rocm/opencl/bin:$PATH' \
| sudo tee -a /etc/profile.d/rocm.sh
Expand All @@ -53,16 +55,16 @@ sudo apt-get install -y --no-install-recommends \
libnuma-dev \
libopenmpi-dev \
openmpi-bin \
rocm-dev \
roctracer-dev \
rocprofiler-dev \
rocrand-dev \
rocfft-dev \
rocprim-dev \
rocsparse-dev
rocm-dev${VERSION} \
roctracer-dev${VERSION} \
rocprofiler-dev${VERSION} \
rocrand-dev${VERSION} \
rocfft-dev${VERSION} \
rocprim-dev${VERSION} \
rocsparse-dev${VERSION}

# hiprand-dev is a new package that does not exist in old versions
sudo apt-get install -y --no-install-recommends hiprand-dev || true
sudo apt-get install -y --no-install-recommends hiprand-dev${VERSION} || true

# activate
#
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/hip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ concurrency:

jobs:
hip-compile:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -27,7 +27,7 @@ jobs:
cd ../..
- name: Dependencies
run: .github/workflows/dependencies/dependencies_hip.sh
run: .github/workflows/dependencies/dependencies_hip.sh 6.3.2

- name: compile test_react with HIP (iso7)
run: |
Expand Down
2 changes: 2 additions & 0 deletions Docs/source/comprehensive_tests.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.. _sec:comprehensive_tests:

************************
Comprehensive Unit Tests
************************
Expand Down
4 changes: 2 additions & 2 deletions Docs/source/integrators.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ routine (at the moment this can be ``VODE``, ``BackwardEuler``, ``ForwardEuler``
.. code-block:: c++

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void burner (burn_t& state, Real dt)
void burner (burn_t& state, amrex::Real dt)

The input is a ``burn_t``.

Expand Down Expand Up @@ -198,7 +198,7 @@ be computed as:

.. code-block:: c++

Array1D<Real, 1, NumSpec> y;
amrex::Array1D<amrex::Real, 1, NumSpec> y;
...
for (int i = 1; i <= NumSpec; ++i) {
y(i) = state.xn[i-1] * aion_inv[i-1];
Expand Down
2 changes: 2 additions & 0 deletions Docs/source/one_zone_tests.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.. _sec:one_zone_tests:

**************
One Zone Tests
**************
Expand Down
2 changes: 1 addition & 1 deletion Docs/source/templated_networks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ The main logic for constructing RHS is contained in ``Microphysics/networks/rhs.
.. code:: c++

AMREX_GPU_HOST_DEVICE AMREX_INLINE
void rhs (burn_t& state, Array1D<Real, 1, neqs>& ydot)
void rhs (burn_t& state, amrex::Array1D<amrex::Real, 1, neqs>& ydot)

The basic flow is:

Expand Down
3 changes: 2 additions & 1 deletion Docs/source/transport.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ The interface for these opacities is:
.. code:: c++

AMREX_GPU_HOST_DEVICE AMREX_INLINE
void actual_opacity (Real& kp, Real& kr, Real rho, Real temp, Real rhoYe, Real nu,
void actual_opacity (amrex::Real& kp, amrex::Real& kr,
amrex::Real rho, amrex::Real temp, amrex::Real rhoYe, amrex::Real nu,
bool get_Planck_mean, bool get_Rosseland_mean)

where the boolean ``get_Planck_mean`` and ``get_Rosseland_mean`` specify where those
Expand Down
6 changes: 4 additions & 2 deletions Docs/source/unit_test_runtime_parameters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ Most of the unit tests require a composition to be defined (for the
initial mass-fractions, $X_k$). There are a few ways this can be done
(depending on the test).

* One-zone (``*_cell``) tests usually do one of:

* One-zone (``*_cell``) tests (see :ref:`sec:one_zone_tests`) usually do one of:

* *Explicitly setting the individual mass fractions.* This is
controlled by the parameters ``unit_test.X1``, ``unit_test.X2``, ..., ``unit_test.X35``,
Expand All @@ -45,7 +46,8 @@ initial mass-fractions, $X_k$). There are a few ways this can be done
``unit_test.uniform_xn``. If this is set to ``1``, then each mass fraction
is initialized to ``1 / NumSpec``.

* Comprehensive tests need many different compositions, since they are creating a cube
* Comprehensive tests (see :ref:`sec:comprehensive_tests`) need many different compositions, since they are creating a cube

of varying thermodynamic properties, and thus require a prescription
to create the composition. This is done by setting ``unit_test.primary_species_1``,
``unit_test.primary_species_2``, and ``unit_test.primary_species_3`` to one of the
Expand Down
10 changes: 5 additions & 5 deletions EOS/multigamma/eos_composition.H
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
using namespace amrex::literals;

struct eos_xderivs_t {
Real dedX[NumSpec];
Real dpdX[NumSpec];
Real dhdX[NumSpec];
amrex::Real dedX[NumSpec];
amrex::Real dpdX[NumSpec];
amrex::Real dhdX[NumSpec];
};

// Given a set of mass fractions, calculate quantities that depend
Expand All @@ -32,7 +32,7 @@ void subroutine (T& state)
}
state.mu_e = 1.0_rt / state.y_e;

Real sum = 0.0_rt;
amrex::Real sum = 0.0_rt;
for (int n = 0; n < NumSpec; ++n) {
sum = sum + state.xn[n] * aion_inv[n];
}
Expand All @@ -51,7 +51,7 @@ eos_x_derivs_t composition_derivatives (const T& state)
eos_xderivs_t state_xderivs;

// Get the mass of a nucleon from Avogadro's number.
const Real m_nucleon = 1.0_rt / n_A;
const amrex::Real m_nucleon = 1.0_rt / n_A;

// Composition derivatives

Expand Down
42 changes: 21 additions & 21 deletions EOS/ztwd/actual_eos.H
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ using namespace amrex::literals;

const std::string eos_name = "ztwd";

const Real A = M_PI * amrex::Math::powi<4>(C::m_e) * amrex::Math::powi<5>(C::c_light) / (3.0_rt * amrex::Math::powi<3>(C::hplanck));
const Real B2 = 8.0_rt * M_PI * amrex::Math::powi<3>(C::m_e) * amrex::Math::powi<3>(C::c_light) * C::m_p / (3.0_rt * amrex::Math::powi<3>(C::hplanck));
const Real iter_tol = 1.e-10_rt;
const amrex::Real A = M_PI * amrex::Math::powi<4>(C::m_e) * amrex::Math::powi<5>(C::c_light) / (3.0_rt * amrex::Math::powi<3>(C::hplanck));
const amrex::Real B2 = 8.0_rt * M_PI * amrex::Math::powi<3>(C::m_e) * amrex::Math::powi<3>(C::c_light) * C::m_p / (3.0_rt * amrex::Math::powi<3>(C::hplanck));
const amrex::Real iter_tol = 1.e-10_rt;
const int max_iter = 1000;

inline
Expand All @@ -43,7 +43,7 @@ AMREX_GPU_HOST_DEVICE AMREX_INLINE
bool is_input_valid (I input)
{
static_assert(std::is_same_v<I, eos_input_t>, "input must be an eos_input_t");

amrex::ignore_unused(input);
bool valid = true;

return valid;
Expand All @@ -52,23 +52,23 @@ bool is_input_valid (I input)


AMREX_GPU_HOST_DEVICE AMREX_INLINE
Real pressure (Real x)
amrex::Real pressure (amrex::Real x)
{
return A * (x * (2.0_rt * x * x - 3.0_rt) * std::sqrt(x * x + 1.0_rt) + 3.0_rt * std::asinh(x));
}



AMREX_GPU_HOST_DEVICE AMREX_INLINE
Real enthalpy (Real x, Real B)
amrex::Real enthalpy (amrex::Real x, amrex::Real B)
{
return (8.0_rt * A / B) * std::sqrt(1.0_rt + x * x);
}



AMREX_GPU_HOST_DEVICE AMREX_INLINE
Real dpdx (Real x)
amrex::Real dpdx (amrex::Real x)
{
return A * ((2.0_rt * x * x - 3.0_rt) * std::sqrt(x * x + 1.0_rt) +
x * (4.0_rt * x) * std::sqrt(x * x + 1.0_rt) +
Expand All @@ -79,7 +79,7 @@ Real dpdx (Real x)


AMREX_GPU_HOST_DEVICE AMREX_INLINE
Real dhdx (Real x, Real B)
amrex::Real dhdx (amrex::Real x, amrex::Real B)
{
return enthalpy(x, B) * (x / (x * x + 1.0_rt));
}
Expand All @@ -88,12 +88,12 @@ Real dhdx (Real x, Real B)


AMREX_GPU_HOST_DEVICE AMREX_INLINE
void pres_iter (Real pres, Real& dens, Real B)
void pres_iter (amrex::Real pres, amrex::Real& dens, amrex::Real B)
{

// Starting guess for the iteration.

Real x = 1.0_rt;
amrex::Real x = 1.0_rt;

// We are solving the equation:
// f(x) = p_want - p(x) = 0.
Expand All @@ -104,7 +104,7 @@ void pres_iter (Real pres, Real& dens, Real B)

for (iter = 1; iter <= max_iter; ++iter)
{
Real dx = (pres - pressure(x)) / dpdx(x);
amrex::Real dx = (pres - pressure(x)) / dpdx(x);

x = x + dx;

Expand All @@ -131,32 +131,32 @@ void actual_eos (I input, T& state)
{
static_assert(std::is_same_v<I, eos_input_t>, "input must be an eos_input_t");

Real dens = state.rho;
Real temp = state.T;
amrex::Real dens = state.rho;
amrex::Real temp = state.T;

Real pres = 1.0_rt;
amrex::Real pres = 1.0_rt;
if constexpr (has_pressure<T>::value) {
pres = state.p;
}

Real enth = 1.0_rt;
amrex::Real enth = 1.0_rt;
if constexpr (has_enthalpy<T>::value) {
enth = state.h;
}

Real eint = 1.0_rt;
amrex::Real eint = 1.0_rt;
if constexpr (has_energy<T>::value) {
eint = state.e;
}

Real entr = 1.0_rt;
amrex::Real entr = 1.0_rt;
if constexpr (has_entropy<T>::value) {
entr = state.s;
}

Real B = B2 * state.mu_e;
amrex::Real B = B2 * state.mu_e;

Real x, dxdr;
amrex::Real x, dxdr;

switch (input) {

Expand Down Expand Up @@ -321,8 +321,8 @@ void actual_eos (I input, T& state)
x = std::cbrt(dens / B);
dxdr = (1.0_rt / 3.0_rt) * x / dens;

Real dpdr = dxdr * dpdx(x);
Real dhdr = dxdr * dhdx(x, B);
amrex::Real dpdr = dxdr * dpdx(x);
amrex::Real dhdr = dxdr * dhdx(x, B);

if constexpr (has_pressure<T>::value) {
state.dpdr = dpdr;
Expand Down
4 changes: 1 addition & 3 deletions conductivity/stellar/actual_conductivity.H
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,7 @@ actual_conductivity (T& state)
amrex::Real xkaz = 50.0_rt*xz*xka1 * std::exp(-0.5206_rt*amrex::Math::powi<2>((std::log(state.rho)-d0log)/xkw));
amrex::Real dbar2log = -(4.283_rt + 0.7196_rt*xh) + 3.86_rt*std::log(t6);
amrex::Real dbar1log = -5.296_rt + 4.833_rt*std::log(t6);
if (dbar2log < dbar1log) {
dbar1log = dbar2log;
}
dbar1log = std::min(dbar1log, dbar2log);
oiben2 = std::pow(state.rho/std::exp(dbar1log), 0.67_rt) * std::exp(xkaz);
}

Expand Down
2 changes: 0 additions & 2 deletions integration/nse_update_sdc.H
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#ifndef NSE_UPDATE_H
#define NSE_UPDATE_H

#include <AMReX_Algorithm.H>

#include <iostream>
#include <fstream>
#include <actual_network.H>
Expand Down
4 changes: 2 additions & 2 deletions integration/utils/nonaka_plot.H
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void nonaka_init() {

template <typename BurnT>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void nonaka_rhs(const Real time, const BurnT& state, const YdotNetArray1D& ydot_react) {
void nonaka_rhs(const amrex::Real time, const BurnT& state, const YdotNetArray1D& ydot_react) {

// state: the burn_t corresponding to the current state note:
// state.time is relative to the start of the current burn call,
Expand All @@ -74,7 +74,7 @@ void nonaka_rhs(const Real time, const BurnT& state, const YdotNetArray1D& ydot_
nf.open(nonaka_file, std::ios::app);


Real simulation_time = time + state.reference_time;
amrex::Real simulation_time = time + state.reference_time;

nf << std::setw(FIELD_WIDTH) << simulation_time << " ";

Expand Down
2 changes: 1 addition & 1 deletion networks/aprox21/actual_network.H
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ namespace RHS {

rhs_t data;

switch (rate) {
switch (rate) { // NOLINT(bugprone-switch-missing-default-case)

case P_to_N:
// irpen and irnep in the original aprox21
Expand Down
6 changes: 3 additions & 3 deletions nse_solver/nse_eos.H
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ nse_T_abar_from_e(const amrex::Real rho, const amrex::Real e_in,
amrex::Real &T, amrex::Real &abar,
amrex::Real &mu_p, amrex::Real &mu_n) {

constexpr Real ttol{1.e-8_rt};
constexpr amrex::Real ttol{1.e-8_rt};
constexpr int max_iter{100};

bool converged{false};
Expand Down Expand Up @@ -148,8 +148,8 @@ nse_T_abar_from_e(const amrex::Real rho, const amrex::Real e_in,

// compute the correction to our guess

Real dT = -f / (eos_state.dedT + eos_state.dedA * dabar_dT
+ Ye * eos_state.dedZ * dabar_dT);
amrex::Real dT = -f / (eos_state.dedT + eos_state.dedA * dabar_dT
+ Ye * eos_state.dedZ * dabar_dT);

// update the temperature and abar

Expand Down
9 changes: 4 additions & 5 deletions opacity/breakout/actual_opacity.H
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ AMREX_INLINE
void actual_opacity_init () {}

AMREX_GPU_HOST_DEVICE AMREX_INLINE
void actual_opacity (Real& kp, Real& kr, Real rho, Real temp, Real rhoYe, Real nu,
void actual_opacity (amrex::Real& kp, amrex::Real& kr,
amrex::Real rho, amrex::Real temp, amrex::Real rhoYe, amrex::Real nu,
bool get_Planck_mean, bool get_Rosseland_mean)
{
const Real Ksc = 0.4e0; // Thomson scattering
const Real fac = 1.e-4; // Planck mean is assumed to be fac * Ksc
const amrex::Real Ksc = 0.4e0; // Thomson scattering
const amrex::Real fac = 1.e-4; // Planck mean is assumed to be fac * Ksc

if (get_Planck_mean) {
kp = rhoYe * Ksc * fac;
Expand All @@ -25,5 +26,3 @@ void actual_opacity (Real& kp, Real& kr, Real rho, Real temp, Real rhoYe, Real n
}

#endif


3 changes: 2 additions & 1 deletion opacity/opacity.H
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ void opacity_init ()
}

AMREX_GPU_HOST_DEVICE AMREX_INLINE
void opacity (Real& kp, Real& kr, Real rho, Real temp, Real rhoYe, Real nu,
void opacity (Real& kp, amrex::Real& kr, amrex::Real rho,
amrex::Real temp, amrex::Real rhoYe, amrex::Real nu,
bool get_Planck_mean, bool get_Rosseland_mean)
{
actual_opacity(kp, kr, rho, temp, rhoYe, nu, get_Planck_mean, get_Rosseland_mean);
Expand Down
Loading

0 comments on commit 9aff213

Please sign in to comment.