Skip to content

Commit

Permalink
Merge branch 'development' into gift_testing
Browse files Browse the repository at this point in the history
  • Loading branch information
zingale authored Aug 1, 2024
2 parents 1140337 + 14b8b0e commit 4db8a56
Show file tree
Hide file tree
Showing 195 changed files with 18,366 additions and 5,933 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cuda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ jobs:
make realclean
make NETWORK_DIR=ignition_reaclib/URCA-simple USE_CUDA=TRUE COMP=gnu USE_MPI=FALSE -j 2
- name: compile test_ase (ase)
- name: compile test_nse_net (ase)
run: |
export PATH=/usr/local/nvidia/bin:/usr/local/cuda/bin:${PATH}
cd unit_test/test_ase
cd unit_test/test_nse_net
make USE_CUDA=TRUE COMP=gnu USE_MPI=FALSE -j 2
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
29 changes: 13 additions & 16 deletions .github/workflows/nse_test.yml → .github/workflows/jac_cell.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: nse_test
name: jac_cell

on: [pull_request]
jobs:
nse_test:
nse_table:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -26,23 +26,20 @@ jobs:
sudo apt-get update -y -qq
sudo apt-get -qq -y install curl cmake jq clang g++>=9.3.0
- name: Compile, test_nse (aprox21)
- name: Compile jac_cell
run: |
cd unit_test/test_nse
make realclean
make NETWORK_DIR=aprox21 -j 4
cd unit_test/jac_cell
make -j 4
- name: Run test_nse (aprox21)
- name: Run jac_cell
run: |
cd unit_test/test_nse
./main3d.gnu.ex inputs_aprox21 amrex.fpe_trap_{invalid,zero,overflow}=1 > test.out
cd unit_test/jac_cell
./main3d.gnu.ex inputs_aprox13 > test.out
- name: Print backtrace
if: ${{ failure() && hashFiles('unit_test/test_nse/Backtrace.0') != '' }}
run: cat unit_test/test_nse/Backtrace.0

- name: Compare to stored output (aprox21)
- name: Compare to stored output
run: |
cd unit_test/test_nse
diff -I "^Initializing AMReX" -I "^AMReX" -I "^reading in reaclib rates" -I "^0x" test.out ci-benchmarks/aprox21_ci.out
cd unit_test/jac_cell
diff -I "^Initializing AMReX" -I "^AMReX" test.out ci-benchmarks/jac_cell_aprox13.out
32 changes: 16 additions & 16 deletions .github/workflows/nse_net.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,42 +26,42 @@ jobs:
sudo apt-get update -y -qq
sudo apt-get -qq -y install curl cmake jq clang g++>=9.3.0
- name: Compile, test_ase (NSE_NET, ase)
- name: Compile, test_nse_net (NSE_NET, ase)
run: |
cd unit_test/test_ase
cd unit_test/test_nse_net
make realclean
make -j 4
- name: Run test_ase (NSE_NET, ase)
- name: Run test_nse_net (NSE_NET, ase)
run: |
cd unit_test/test_ase
cd unit_test/test_nse_net
./main3d.gnu.ex inputs_ase amrex.fpe_trap_{invalid,zero,overflow}=1 > test.out
- name: Print backtrace
if: ${{ failure() && hashFiles('unit_test/test_ase/Backtrace.0') != '' }}
run: cat unit_test/test_ase/Backtrace.0
if: ${{ failure() && hashFiles('unit_test/test_nse_net/Backtrace.0') != '' }}
run: cat unit_test/test_nse_net/Backtrace.0

- name: Compare to stored output (NSE_NET, ase)
run: |
cd unit_test/test_ase
diff -I "^Initializing AMReX" -I "^AMReX" -I "^reading in reaclib rates" test.out ci-benchmarks/ase_nse_net_unit_test.out
cd unit_test/test_nse_net
diff -I "^Initializing AMReX" -I "^AMReX" -I "^reading in reaclib rates" test.out ci-benchmarks/nse_net_unit_test.out
- name: Compile, test_ase/make_table (NSE_NET, ase, make_table)
- name: Compile, test_nse_net/make_table (NSE_NET, ase, make_table)
run: |
cd unit_test/test_ase/make_table
cd unit_test/test_nse_net/make_table
make realclean
make -j 4
- name: Run, test_ase/make_table (NSE_NET, ase, make_table)
- name: Run, test_nse_net/make_table (NSE_NET, ase, make_table)
run: |
cd unit_test/test_ase/make_table
cd unit_test/test_nse_net/make_table
./main3d.gnu.ex amrex.fpe_trap_{invalid,zero,overflow}=1 > test.out
- name: Print backtrace
if: ${{ failure() && hashFiles('unit_test/test_ase/make_table/Backtrace.0') != '' }}
run: cat unit_test/test_ase/make_table/Backtrace.0
if: ${{ failure() && hashFiles('unit_test/test_nse_net/make_table/Backtrace.0') != '' }}
run: cat unit_test/test_nse_net/make_table/Backtrace.0

- name: Compare to stored output (NSE_NET, ase, make_table)
run: |
cd unit_test/test_ase/make_table
diff -I "^Initializing AMReX" -I "^AMReX" -I "^reading in reaclib rates" test.out ci-benchmarks/ase_nse_net_make_table_unit_test.out
cd unit_test/test_nse_net/make_table
diff -I "^Initializing AMReX" -I "^AMReX" -I "^reading in reaclib rates" test.out ci-benchmarks/nse_net_make_table_unit_test.out
20 changes: 0 additions & 20 deletions .github/workflows/nse_table.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,6 @@ jobs:
sudo apt-get update -y -qq
sudo apt-get -qq -y install curl cmake jq clang g++>=9.3.0
- name: Compile, burn_cell (NSE, aprox19)
run: |
cd unit_test/burn_cell
make realclean
make NETWORK_DIR=aprox19 USE_NSE_TABLE=TRUE INTEGRATOR_DIR=VODE -j 4
- name: Run burn_cell (NSE, aprox19)
run: |
cd unit_test/burn_cell
./main3d.gnu.ex inputs_aprox19.nse amrex.fpe_trap_{invalid,zero,overflow}=1 > test.out
- name: Print backtrace
if: ${{ failure() && hashFiles('unit_test/burn_cell/Backtrace.0') != '' }}
run: cat unit_test/burn_cell/Backtrace.0

- name: Compare to stored output (NSE, aprox19)
run: |
cd unit_test/burn_cell
diff -I "^Initializing AMReX" -I "^AMReX" -I "^reading in reaclib rates" test.out ci-benchmarks/aprox19_nse_unit_test.out
- name: Compile, burn_cell_sdc (NSE, aprox19)
run: |
cd unit_test/burn_cell_sdc
Expand Down
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
Loading

0 comments on commit 4db8a56

Please sign in to comment.