Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
5f64360
start of alternate table
zingale Sep 1, 2025
51c061a
add new table
zingale Sep 3, 2025
bc5676d
update
zingale Sep 3, 2025
d76be46
Merge branch 'development' into new_eos_table
zingale Sep 11, 2025
131db1e
fix table rule
zingale Sep 12, 2025
fe4109a
Merge branch 'new_eos_table' of github.com:zingale/Microphysics into …
zingale Sep 12, 2025
676513f
switch to 800 quadrature points
zingale Sep 14, 2025
063df86
add define
zingale Sep 14, 2025
5e93c98
Merge branch 'development' into new_eos_table
zingale Sep 15, 2025
7d0a307
Merge branch 'development' into new_eos_table
zingale Sep 29, 2025
ccb877e
this works with the unevenly spaced table
zingale Sep 29, 2025
68f2aa2
add missing file
zingale Sep 29, 2025
e5c89a5
fix GPU linking
zingale Sep 29, 2025
a43e5a6
Merge branch 'development' into new_eos_table
zingale Oct 15, 2025
b1a3a3a
Merge branch 'new_eos_table' of github.com:zingale/Microphysics into …
zingale Oct 15, 2025
8e840f2
Merge branch 'development' into new_eos_table
zingale Oct 25, 2025
80f2645
Merge branch 'development' into new_eos_table
zingale Oct 31, 2025
3deb389
Merge branch 'development' into new_eos_table
zingale Nov 3, 2025
4db9a0f
Merge branch 'development' into new_eos_table
zingale Jan 5, 2026
c76fd8e
Merge branch 'development' into new_eos_table
zingale Jan 13, 2026
6af607d
Merge branch 'development' into new_eos_table
zingale Jan 17, 2026
201f1af
Merge branch 'development' into new_eos_table
zingale Apr 5, 2026
2dacd5c
Merge branch 'development' into new_eos_table
zingale Jul 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/good_defines.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ SIMPLIFIED_SDC
SINGLE_PRECISION_JACOBIAN
STRANG
TRUE_SDC
USE_NEW_HELMHOLTZ_TABLE
_OPENMP
_WIN32
__cplusplus
Expand Down
34 changes: 32 additions & 2 deletions EOS/helmholtz/actual_eos.H
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
#include <actual_eos_data.H>
#include <cmath>
#include <vector>
#if defined(USE_NEW_HELMHOLTZ_TABLE)
#include <mp_math.H>
#endif

// Frank Timmes Helmholtz based Equation of State
// https://cococubed.com/
Expand Down Expand Up @@ -163,9 +166,15 @@ void apply_electrons (T& state)
amrex::Real din = state.y_e * state.rho;

// hash locate this temperature and density
#if defined(USE_NEW_HELMHOLTZ_TABLE)
// we use the fastmath variant of log
int jat = int((mp::fastlg2(state.T) - tlo) * tstpi) + 1;
int iat = int((mp::fastlg2(din) - dlo) * dstpi) + 1;
#else
int jat = int((std::log10(state.T) - tlo) * tstpi) + 1;
jat = amrex::Clamp(jat, 1, jmax-1) - 1;
int iat = int((std::log10(din) - dlo) * dstpi) + 1;
#endif
jat = amrex::Clamp(jat, 1, jmax-1) - 1;
iat = amrex::Clamp(iat, 1, imax-1) - 1;

amrex::Real fi[36];
Expand Down Expand Up @@ -1314,12 +1323,20 @@ void actual_eos_init ()

for (int j = 0; j < jmax; ++j) {
amrex::Real tsav = tlo + j * tstp;
#if defined(USE_NEW_HELMHOLTZ_TABLE)
t[j] = mp::fastpow2(tsav);
#else
t[j] = std::pow(10.0e0_rt, tsav);
#endif
}

for (int i = 0; i < imax; ++i) {
amrex::Real dsav = dlo + i * dstp;
#if defined(USE_NEW_HELMHOLTZ_TABLE)
d[i] = mp::fastpow2(dsav);
#else
d[i] = std::pow(10.0e0_rt, dsav);
#endif
}

// it does not work on all machines (for GPUs) broadcast to other
Expand All @@ -1336,7 +1353,12 @@ void actual_eos_init ()

// open the table
std::ifstream table;

#if defined(USE_NEW_HELMHOLTZ_TABLE)
table.open("helm_table_fastmath_p128_q800.dat");
#else
table.open("helm_table.dat");
#endif

if (!table.is_open()) {
// the table was not present or we could not open it; abort
Expand Down Expand Up @@ -1465,10 +1487,18 @@ void actual_eos_init ()

// Set up the minimum and maximum possible densities.

#if defined(USE_NEW_HELMHOLTZ_TABLE)
EOSData::mintemp = mp::fastpow2(tlo);
EOSData::maxtemp = mp::fastpow2(thi);
EOSData::mindens = mp::fastpow2(dlo);
EOSData::maxdens = mp::fastpow2(dhi);
#else
EOSData::mintemp = std::pow(10.e0_rt, tlo);
EOSData::maxtemp = std::pow(10.e0_rt, thi);
EOSData::mindens = std::pow(10.e0_rt, dlo);
EOSData::maxdens = std::pow(10.e0_rt, dhi);
#endif

}


Expand Down
29 changes: 29 additions & 0 deletions EOS/helmholtz/actual_eos_data.H
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
#include <AMReX.H>
#include <AMReX_REAL.H>

#if defined(USE_NEW_HELMHOLTZ_TABLE)
#include <fundamental_constants.H>
#endif

namespace helmholtz
{

Expand All @@ -14,6 +18,22 @@ namespace helmholtz

// for the tables

#if defined(USE_NEW_HELMHOLTZ_TABLE)
constexpr int imax = 421;
constexpr int jmax = 161;

// these are log_2 using the fastlog approximation
constexpr amrex::Real tlo = 9.953125_rt;
constexpr amrex::Real thi = 36.4551915228366851806640625_rt;
constexpr amrex::Real tstp = (thi - tlo) / (static_cast<amrex::Real>(jmax-1));
constexpr amrex::Real tstpi = 1.0e0_rt / tstp;
constexpr amrex::Real dlo = -33.2820130816_rt;
constexpr amrex::Real dhi = 36.4551915228366851806640625_rt;
constexpr amrex::Real dstp = (dhi - dlo) / (static_cast<amrex::Real>(imax-1));
constexpr amrex::Real dstpi = 1.0e0_rt / dstp;

#else

constexpr int imax = 541;
constexpr int jmax = 201;

Expand All @@ -25,6 +45,7 @@ namespace helmholtz
constexpr amrex::Real dhi = 15.0e0_rt;
constexpr amrex::Real dstp = (dhi - dlo) / (static_cast<amrex::Real>(imax-1));
constexpr amrex::Real dstpi = 1.0e0_rt / dstp;
#endif

extern AMREX_GPU_MANAGED amrex::Real d[imax];
extern AMREX_GPU_MANAGED amrex::Real t[jmax];
Expand Down Expand Up @@ -55,11 +76,19 @@ namespace helmholtz
extern AMREX_GPU_MANAGED amrex::Real ddi_sav[imax];
extern AMREX_GPU_MANAGED amrex::Real dd2i_sav[imax];

#if defined(USE_NEW_HELMHOLTZ_TABLE)
constexpr amrex::Real h = C::hplanck;
constexpr amrex::Real avo_eos = C::n_A;
constexpr amrex::Real kerg = C::k_B;
constexpr amrex::Real amu = C::m_u;
#else
// 2006 CODATA physical constants
constexpr amrex::Real h = 6.6260689633e-27;
constexpr amrex::Real avo_eos = 6.0221417930e23;
constexpr amrex::Real kerg = 1.380650424e-16;
constexpr amrex::Real amu = 1.66053878283e-24;
#endif

}

#endif
Loading
Loading