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

Compute thermodynamic derivatives and implement dens+pres mode in primordial chem EOS #1302

Merged
merged 10 commits into from
Aug 4, 2023
3 changes: 2 additions & 1 deletion EOS/gamma_law/actual_eos.H
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,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.
Real pressure = state.rho * state.T * (C::k_B / (state.mu * m_nucleon));
Real pressure = state.rho * state.T * C::k_B / (state.mu * m_nucleon);
psharda marked this conversation as resolved.
Show resolved Hide resolved
Real energy = pressure / (eos_gamma - 1.0) * rhoinv;
if constexpr (has_pressure<T>::value) {
state.p = pressure;
Expand Down Expand Up @@ -265,6 +265,7 @@ void actual_eos (I input, T& state)

// sound speed
state.cs = std::sqrt(eos_gamma * state.p * rhoinv);
state.G = 0.5 * (1.0 + eos_gamma);
}
}

Expand Down
23 changes: 19 additions & 4 deletions EOS/primordial_chem/actual_eos.H
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,16 @@ void actual_eos (I input, T& state)

case eos_input_rp:
// dens, pressure, and xmass are inputs
#ifndef AMREX_USE_GPU
amrex::Error("eos_input_rp is not supported");
#endif

break;
if constexpr (has_pressure<T>::value) {
dens = state.rho;

// stop the integration if the pressure < 0
AMREX_ASSERT(state.p > 0.);
psharda marked this conversation as resolved.
Show resolved Hide resolved
eint = state.p * sum_gammasinv / dens;
temp = eint / (sum_gammasinv * gasconstant * sum_Abarinv);
}
break;

case eos_input_ps:
// pressure, entropy, and xmass are inputs
Expand Down Expand Up @@ -269,11 +274,21 @@ void actual_eos (I input, T& state)
if constexpr (has_pressure<T>::value) {
Real pressure = state.rho * eint / sum_gammasinv;
state.p = pressure;

state.dpdT = pressure / temp;
state.dpdr = pressure / dens;
state.cs = std::sqrt((1.0 + 1.0/sum_gammasinv) * state.p /state.rho);
psharda marked this conversation as resolved.
Show resolved Hide resolved
state.G = 0.5 * (1.0 + (1.0 + 1.0/sum_gammasinv));
}

Real dedT = sum_gammasinv * sum_Abarinv * gasconstant;
Real dedr = 0.0_rt;
if constexpr (has_energy<T>::value) {
state.dedT = dedT;
state.dedr = dedr;
if constexpr (has_pressure<T>::value) {
state.dpde = state.dpdT / state.dedT;
}
}

}
Expand Down
2 changes: 2 additions & 0 deletions interfaces/eos_type.H
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ struct eos_t:eos_base_t {
amrex::Real dsdr{};
amrex::Real dpde{};
amrex::Real dpdr_e{};
amrex::Real G{}; // fundmental derivative (Thompson 1971)

amrex::Real cv{};
amrex::Real cp{};
Expand Down Expand Up @@ -145,6 +146,7 @@ struct chem_eos_t:eos_base_t {
amrex::Real dpdr_e{};
amrex::Real dedT{};
amrex::Real dedr{};
amrex::Real G{};

amrex::Real mu{};
amrex::Real cs{};
Expand Down