Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generalize in_nse() to work with an eos_t #1424

Merged
merged 4 commits into from
Dec 29, 2023
Merged
Changes from all commits
Commits
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
66 changes: 47 additions & 19 deletions nse_tabular/nse_table_check.H
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,18 @@
#include <extern_parameters.H>

#include <burn_type.H>
#include <eos.H>
#include <eos_type.H>


template <typename T>
AMREX_GPU_HOST_DEVICE AMREX_INLINE
bool in_nse(burn_t& state, const bool relax = false) {
bool in_nse(T& state, const bool relax = false) {

using namespace Species;

Real f = relax ? nse_relax_factor : 1.0_rt;

state.nse = false;
bool nse_check = false;

if (state.rho > f * rho_nse && state.T > f * T_nse) {

Expand All @@ -33,33 +34,60 @@ bool in_nse(burn_t& state, const bool relax = false) {
// and He-group (for us, that is H1, He3, He4)
// also make sure there is not a lot of O16 (O16 burning will dominate then) or Si28

Real Fe_group{};
Real C_group{};
Real He_group{};
Real O_group{};
Real Si_group{};

if constexpr (std::is_same<T, burn_t>::value) {
// for a burn_t, we need to use a different field
// depending on whether we are strang of simplified-SDC

#ifdef STRANG
Real Fe_group = state.xn[Cr48-1] + state.xn[Fe52-1] +
state.xn[Fe54-1] + state.xn[Ni56-1];
Real C_group = state.xn[C12-1] + state.xn[N14-1];
Real He_group = state.xn[H1-1] + state.xn[He3-1] + state.xn[He4-1];
Real O_group = state.xn[O16-1];
Real Si_group = state.xn[Si28-1];
Fe_group = state.xn[Cr48-1] + state.xn[Fe52-1] +
state.xn[Fe54-1] + state.xn[Ni56-1];
C_group = state.xn[C12-1] + state.xn[N14-1];
He_group = state.xn[H1-1] + state.xn[He3-1] + state.xn[He4-1];
O_group = state.xn[O16-1];
Si_group = state.xn[Si28-1];
#else
// we need to get the mass fractions from the conserved state passed in

Real Fe_group = (state.y[SFS+Cr48-1] + state.y[SFS+Fe52-1] +
state.y[SFS+Fe54-1] + state.y[SFS+Ni56-1]) / state.rho;
Real C_group = (state.y[SFS+C12-1] + state.y[SFS+N14-1]) / state.rho;
Real He_group = (state.y[SFS+H1-1] + state.y[SFS+He3-1] + state.y[SFS+He4-1]) / state.rho;
Real O_group = state.y[SFS+O16-1] / state.rho;
Real Si_group = state.y[SFS+Si28-1] / state.rho;
// we need to get the mass fractions from the conserved state passed in

Fe_group = (state.y[SFS+Cr48-1] + state.y[SFS+Fe52-1] +
state.y[SFS+Fe54-1] + state.y[SFS+Ni56-1]) / state.rho;
C_group = (state.y[SFS+C12-1] + state.y[SFS+N14-1]) / state.rho;
He_group = (state.y[SFS+H1-1] + state.y[SFS+He3-1] + state.y[SFS+He4-1]) / state.rho;
O_group = state.y[SFS+O16-1] / state.rho;
Si_group = state.y[SFS+Si28-1] / state.rho;
#endif

} else {

// this covers the various eos_t's
Fe_group = state.xn[Cr48-1] + state.xn[Fe52-1] +
state.xn[Fe54-1] + state.xn[Ni56-1];
C_group = state.xn[C12-1] + state.xn[N14-1];
He_group = state.xn[H1-1] + state.xn[He3-1] + state.xn[He4-1];
O_group = state.xn[O16-1];
Si_group = state.xn[Si28-1];
}

if (Fe_group + He_group > f * He_Fe_nse &&
C_group < C_nse / f &&
O_group < O_nse / f &&
Si_group < Si_nse / f) {
state.nse = true;

nse_check = true;
}

}

if constexpr (std::is_same<T, burn_t>::value) {
state.nse = nse_check;
}

return state.nse;
return nse_check;

}

Expand Down
Loading