Skip to content

Commit

Permalink
merge development
Browse files Browse the repository at this point in the history
  • Loading branch information
Piyush Sharda authored and Piyush Sharda committed Aug 22, 2024
2 parents e59827a + 8ce3375 commit f36abc6
Show file tree
Hide file tree
Showing 128 changed files with 15,939 additions and 3,357 deletions.
1 change: 1 addition & 0 deletions .github/workflows/good_defines.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ALLOW_GPU_PRINTF
ALLOW_JACOBIAN_CACHING
AMREX_USE_CUDA
AMREX_USE_GPU
Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/jac_cell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: jac_cell

on: [pull_request]
jobs:
nse_table:
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 jac_cell
run: |
cd unit_test/jac_cell
make -j 4
- name: Run jac_cell
run: |
cd unit_test/jac_cell
./main3d.gnu.ex inputs_aprox13 > test.out
- name: Compare to stored output
run: |
cd unit_test/jac_cell
diff -I "^Initializing AMReX" -I "^AMReX" test.out ci-benchmarks/jac_cell_aprox13.out
51 changes: 51 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,54 @@
# 24.08

* autodiff is now used with the templated reaction networks (#1614)
+ some autodiff clean-ups and derivative fixes (#1604, #1612,
#1613, #1616, #1619, #1633)

* we can now output warnings from GPUs if you compile with
`USE_GPU_PRINTF=TRUE` (#1629, #1635)

* documentation improvements (#1570, #1628)

* a new jacobian unit (`jac_cell`) test was added that compares the
numerical and analytic Jacobians (#1618)

* support for Strang + NSE has been removed. NSE only works with
SDC now (#1549, #1621)

* the network `CNO_He_burn` was added for explosive H/He burning
(#1622)

* code clean-ups (#1582, #1602, #1609, #1623, #1624, #1625, #1626,
#1627, #1631, #1639)

* `test_nse_net` now also tests the NSE EOS interface (#1621)

* the self-consistent NSE + SDC update has been synced with the
tabular NSE implementation (#1569, #1607, #1617)

* `test_jac` was not correctly evaluating the numerical Jacobian
(#1615)

* the `fast_atan` function is now more accurate (#1611)

* `test_ase` was renamed `test_nse_net` and the old `test_nse` was
removed (#1610)

* the old `test_screening` unit test was removed (#1608)

* the RKC integrator now supports NSE bailout (#1544)

* a second temperature check for tabular NSE was added -- above this
temperature we don't consider composition (#1547)

* a SDC+NSE unit test was added (#1548)

* a fast log and fast pow approximation was added (#1591)

* the primordial_chem network now uses the fast math routines (#1605)

* fix potential Inf in constexpr linear algebra (#1603)

# 24.07

* added an autodiff library and converted all of the screening
Expand Down
6 changes: 2 additions & 4 deletions EOS/breakout/actual_eos.H
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,15 @@
#include <network.H>
#include <actual_eos_data.H>

using namespace eos_rp;

const std::string eos_name = "breakout";

inline
void actual_eos_init ()
{

// constant ratio of specific heats
if (eos_gamma > 0.e0_rt) {
gamma_const = eos_gamma;
if (eos_rp::eos_gamma > 0.e0_rt) {
gamma_const = eos_rp::eos_gamma;
} else {
gamma_const = 5.0_rt / 3.0_rt;
}
Expand Down
24 changes: 11 additions & 13 deletions EOS/gamma_law/actual_eos.H
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
#include <fundamental_constants.H>
#include <cmath>

using namespace eos_rp;

// This is a constant gamma equation of state, using an ideal gas.
//
// The gas may either be completely ionized or completely neutral.
Expand All @@ -22,7 +20,7 @@ inline
void actual_eos_init() {

// constant ratio of specific heats
if (eos_gamma <= 0.0) {
if (eos_rp::eos_gamma <= 0.0) {
amrex::Error("gamma_const cannot be < 0");
}

Expand Down Expand Up @@ -56,7 +54,7 @@ void actual_eos (I input, T& state)
const amrex::Real m_nucleon = C::m_u;

if constexpr (has_xn<T>::value) {
if (eos_assume_neutral) {
if (eos_rp::eos_assume_neutral) {
state.mu = state.abar;
} else {
amrex::Real sum = 0.0;
Expand Down Expand Up @@ -88,7 +86,7 @@ void actual_eos (I input, T& state)
// h = e + p/rho = (p/rho)*[1 + 1/(gamma-1)] = (p/rho)*gamma/(gamma-1)

if constexpr (has_enthalpy<T>::value) {
state.T = (state.h * state.mu * m_nucleon / C::k_B)*(eos_gamma - 1.0)/eos_gamma;
state.T = (state.h * state.mu * m_nucleon / C::k_B)*(eos_rp::eos_gamma - 1.0)/eos_rp::eos_gamma;
}

break;
Expand Down Expand Up @@ -127,7 +125,7 @@ void actual_eos (I input, T& state)
// e = k T / [(mu m_nucleon)*(gamma-1)]

if constexpr (has_energy<T>::value) {
state.T = state.e * state.mu * m_nucleon * (eos_gamma - 1.0) / C::k_B;
state.T = state.e * state.mu * m_nucleon * (eos_rp::eos_gamma - 1.0) / C::k_B;
}

break;
Expand Down Expand Up @@ -162,7 +160,7 @@ void actual_eos (I input, T& state)
// Solve for temperature and density

if constexpr (has_pressure<T>::value && has_enthalpy<T>::value) {
state.rho = state.p / state.h * eos_gamma / (eos_gamma - 1.0);
state.rho = state.p / state.h * eos_rp::eos_gamma / (eos_rp::eos_gamma - 1.0);
state.T = state.p * state.mu * m_nucleon / (C::k_B * state.rho);
}

Expand Down Expand Up @@ -199,7 +197,7 @@ void actual_eos (I input, T& state)
// Compute the pressure simply from the ideal gas law, and the
// specific internal energy using the gamma-law EOS relation.
amrex::Real pressure = state.rho * state.T * C::k_B / (state.mu * m_nucleon);
amrex::Real energy = pressure / (eos_gamma - 1.0) * rhoinv;
amrex::Real energy = pressure / (eos_rp::eos_gamma - 1.0) * rhoinv;
if constexpr (has_pressure<T>::value) {
state.p = pressure;
}
Expand Down Expand Up @@ -256,17 +254,17 @@ void actual_eos (I input, T& state)
state.cv = state.dedT;

if constexpr (has_pressure<T>::value) {
state.cp = eos_gamma * state.cv;
state.cp = eos_rp::eos_gamma * state.cv;

state.gam1 = eos_gamma;
state.gam1 = eos_rp::eos_gamma;

state.dpdr_e = state.dpdr - state.dpdT * state.dedr * (1.0 / state.dedT);
state.dpde = state.dpdT * (1.0 / state.dedT);

// sound speed
state.cs = std::sqrt(eos_gamma * state.p * rhoinv);
state.cs = std::sqrt(eos_rp::eos_gamma * state.p * rhoinv);
if constexpr (has_G<T>::value) {
state.G = 0.5 * (1.0 + eos_gamma);
state.G = 0.5 * (1.0 + eos_rp::eos_gamma);
}
}
}
Expand All @@ -278,7 +276,7 @@ void actual_eos (I input, T& state)
state.dedA = - state.e * (1.0 / state.abar);
}

if (eos_assume_neutral) {
if (eos_rp::eos_assume_neutral) {
if constexpr (has_dpdZ<T>::value) {
state.dpdZ = 0.0;
}
Expand Down
24 changes: 11 additions & 13 deletions EOS/helmholtz/actual_eos.H
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
#include <cmath>
#include <vector>

using namespace eos_rp;

// Frank Timmes Helmholtz based Equation of State
// https://cococubed.com/

Expand Down Expand Up @@ -156,9 +154,9 @@ void apply_electrons (T& state)

// hash locate this temperature and density
int jat = int((std::log10(state.T) - tlo) * tstpi) + 1;
jat = amrex::max(1, amrex::min(jat, jmax-1)) - 1;
jat = std::clamp(jat, 1, jmax-1) - 1;
int iat = int((std::log10(din) - dlo) * dstpi) + 1;
iat = amrex::max(1, amrex::min(iat, imax-1)) - 1;
iat = std::clamp(iat, 1, imax-1) - 1;

amrex::Real fi[36];

Expand Down Expand Up @@ -576,8 +574,8 @@ void apply_radiation (T& state)
// on prad, this will result in the radiation term effectively vanishing below the
// cutoff density. For simplicity we ignore the effect this has on the derivatives.

if (prad_limiter_rho_c > 0.0e0_rt && prad_limiter_delta_rho > 0.0e0_rt) {
prad = prad * 0.5e0_rt * (1.0e0_rt + std::tanh((state.rho - prad_limiter_rho_c) / prad_limiter_delta_rho));
if (eos_rp::prad_limiter_rho_c > 0.0e0_rt && eos_rp::prad_limiter_delta_rho > 0.0e0_rt) {
prad = prad * 0.5e0_rt * (1.0e0_rt + std::tanh((state.rho - eos_rp::prad_limiter_rho_c) / eos_rp::prad_limiter_delta_rho));
}

amrex::Real dpraddd = 0.0e0_rt;
Expand Down Expand Up @@ -1005,7 +1003,7 @@ void single_iter_update (T& state, int var, int dvar,
amrex::Real xnew = x - (v - v_want) / dvdx;

// Don't let the temperature/density change by more than a factor of two
xnew = amrex::max(0.5_rt * x, amrex::min(xnew, 2.0_rt * x));
xnew = std::clamp(xnew, 0.5_rt * x, 2.0_rt * x);

// Don't let us freeze/evacuate
xnew = amrex::max(smallx, xnew);
Expand Down Expand Up @@ -1120,8 +1118,8 @@ void double_iter_update (T& state, int var1, int var2,

// Don't let the temperature or density change by more
// than a factor of two
tnew = amrex::max(0.5e0_rt * told, amrex::min(tnew, 2.0e0_rt * told));
rnew = amrex::max(0.5e0_rt * rold, amrex::min(rnew, 2.0e0_rt * rold));
tnew = std::clamp(tnew, 0.5e0_rt * told, 2.0e0_rt * told);
rnew = std::clamp(rnew, 0.5e0_rt * rold, 2.0e0_rt * rold);

// Don't let us freeze or evacuate
tnew = amrex::max(EOSData::mintemp, tnew);
Expand Down Expand Up @@ -1310,10 +1308,10 @@ void actual_eos_init ()

// Read in the runtime parameters

input_is_constant = eos_input_is_constant;
do_coulomb = use_eos_coulomb;
ttol = eos_ttol;
dtol = eos_dtol;
input_is_constant = eos_rp::eos_input_is_constant;
do_coulomb = eos_rp::use_eos_coulomb;
ttol = eos_rp::eos_ttol;
dtol = eos_rp::eos_dtol;

// read the helmholtz free energy table

Expand Down
16 changes: 7 additions & 9 deletions EOS/multigamma/actual_eos.H
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
#include <cmath>
#include <actual_eos_data.H>

using namespace eos_rp;

const std::string eos_name = "multigamma";

inline
Expand All @@ -26,24 +24,24 @@ void actual_eos_init ()
// that can override the default gammas for a few named species.

for (int n = 0; n < NumSpec; ++n) {
gammas[n] = eos_gamma_default;
gammas[n] = eos_rp::eos_gamma_default;
}

int idx;

idx = network_spec_index(species_a_name);
idx = network_spec_index(eos_rp::species_a_name);
if (idx >= 0) {
gammas[idx] = species_a_gamma;
gammas[idx] = eos_rp::species_a_gamma;
}

idx = network_spec_index(species_b_name);
idx = network_spec_index(eos_rp::species_b_name);
if (idx >= 0) {
gammas[idx] = species_b_gamma;
gammas[idx] = eos_rp::species_b_gamma;
}

idx = network_spec_index(species_c_name);
idx = network_spec_index(eos_rp::species_c_name);
if (idx >= 0) {
gammas[idx] = species_c_gamma;
gammas[idx] = eos_rp::species_c_gamma;
}

}
Expand Down
14 changes: 6 additions & 8 deletions EOS/polytrope/actual_eos.H
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
#include <eos_type.H>
#include <actual_eos_data.H>

using namespace eos_rp;

const std::string eos_name = "polytrope";

inline
Expand All @@ -41,9 +39,9 @@ void actual_eos_init ()
// 1: Non-relativistic, fully degenerate electron gas
// 2: Relativistic, fully degenerate electron gas

if (polytrope_type > 0) {
mu_e = polytrope_mu_e;
polytrope = polytrope_type;
if (eos_rp::polytrope_type > 0) {
mu_e = eos_rp::polytrope_mu_e;
polytrope = eos_rp::polytrope_type;

if (polytrope == 1) {
gamma_const = 5.0_rt / 3.0_rt;
Expand All @@ -59,9 +57,9 @@ void actual_eos_init ()
amrex::Error("EOS: Polytrope type currently not defined");
}
}
else if (polytrope_gamma > 0.0_rt && polytrope_K > 0.0_rt) {
gamma_const = polytrope_gamma;
K_const = polytrope_K;
else if (eos_rp::polytrope_gamma > 0.0_rt && eos_rp::polytrope_K > 0.0_rt) {
gamma_const = eos_rp::polytrope_gamma;
K_const = eos_rp::polytrope_K;
mu_e = 2.0_rt; // This will not be used
}
else {
Expand Down
4 changes: 1 addition & 3 deletions EOS/primordial_chem/actual_eos.H
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
#include <cmath>
#include <actual_eos_data.H>

using namespace eos_rp;

const std::string eos_name = "multigamma";

inline
Expand All @@ -23,7 +21,7 @@ void actual_eos_init ()
// Set the gammas & masses for the species

for (int n = 0; n < NumSpec; ++n) {
gammas[n] = eos_gamma_default;
gammas[n] = eos_rp::eos_gamma_default;
spmasses[n] = 1.67353251819e-24;
}

Expand Down
Loading

0 comments on commit f36abc6

Please sign in to comment.