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

Create minimum energy modifier #375

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions singularity-eos/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ register_headers(
eos/modifiers/ramps_eos.hpp
eos/modifiers/shifted_eos.hpp
eos/modifiers/eos_unitsystem.hpp
eos/modifiers/minimum_energy.hpp
eos/eos_base.hpp
eos/eos_eospac.hpp
eos/eos_noble_abel.hpp
Expand Down
13 changes: 12 additions & 1 deletion singularity-eos/eos/eos_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,18 @@ class EosBase {
PORTABLE_ALWAYS_THROW_OR_ABORT(msg);
}

// Default MinInternalEnergyFromDensity behavior is to cause an error
// Default MinInternalEnergyFromDensity behavior is to just return the zero-K isotherm.
// This should be fine for all thermodynamically consistent EOS, but could cause issues
// with EOS that aren't thermodynamically consistent.
Comment on lines +645 to +647
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think as far as default behavior this is just fine.

template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real MinInternalEnergyFromDensity(
const Real rho, Indexer_t &&lambda = static_cast<Real *>(nullptr)) const {
CRTP copy = *(static_cast<CRTP const *>(this));
return copy.InternalEnergyFromDensityTemperature(rho, 0.);
}

// This error is useful for EOS where the zero-K approximation is invalid for whatever
// reason
PORTABLE_FORCEINLINE_FUNCTION
void MinInternalEnergyIsNotEnabled(const char *eosname) const {
// Construct the error message using char* so it works on device
Expand Down
3 changes: 1 addition & 2 deletions singularity-eos/eos/eos_gruneisen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,7 @@ template <typename Indexer_t>
PORTABLE_INLINE_FUNCTION Real
Gruneisen::MinInternalEnergyFromDensity(const Real rho_in, Indexer_t &&lambda) const {
const Real rho = std::min(rho_in, _rho_max);
MinInternalEnergyIsNotEnabled("Gruneisen");
return 0.0;
return EosBase<Gruneisen>::MinInternalEnergyFromDensity(rho);
}
template <typename Indexer_t>
PORTABLE_INLINE_FUNCTION Real Gruneisen::EntropyFromDensityInternalEnergy(
Expand Down
6 changes: 0 additions & 6 deletions singularity-eos/eos/eos_helmholtz.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,12 +501,6 @@ class Helmholtz : public EosBase<Helmholtz> {
thermalqs::pressure | thermalqs::temperature, lambda);
return p;
}
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real MinInternalEnergyFromDensity(
const Real rho, Indexer_t &&lambda = static_cast<Real *>(nullptr)) const {
MinInternalEnergyIsNotEnabled("Helmholtz");
return 0.0;
}

template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real
Expand Down
9 changes: 0 additions & 9 deletions singularity-eos/eos/eos_jwl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ class JWL : public EosBase<JWL> {
const Real rho, const Real sie,
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const;
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real MinInternalEnergyFromDensity(
const Real rho, Indexer_t &&lambda = static_cast<Real *>(nullptr)) const;
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real
EntropyFromDensityTemperature(const Real rho, const Real temperature,
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const;
Expand Down Expand Up @@ -162,12 +159,6 @@ PORTABLE_INLINE_FUNCTION Real JWL::PressureFromDensityInternalEnergy(
return ReferencePressure(rho) + _w * rho * (sie - ReferenceEnergy(rho));
}
template <typename Indexer_t>
PORTABLE_INLINE_FUNCTION Real
JWL::MinInternalEnergyFromDensity(const Real rho, Indexer_t &&lambda) const {
MinInternalEnergyIsNotEnabled("JWL");
return 0.0;
}
template <typename Indexer_t>
PORTABLE_INLINE_FUNCTION Real JWL::EntropyFromDensityInternalEnergy(
const Real rho, const Real sie, Indexer_t &&lambda) const {
EntropyIsNotEnabled("JWL");
Expand Down
9 changes: 0 additions & 9 deletions singularity-eos/eos/eos_mgusup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ class MGUsup : public EosBase<MGUsup> {
const Real rho, const Real sie,
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const;
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real MinInternalEnergyFromDensity(
const Real rho, Indexer_t &&lambda = static_cast<Real *>(nullptr)) const;
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real
EntropyFromDensityTemperature(const Real rho, const Real temp,
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const;
Expand Down Expand Up @@ -312,12 +309,6 @@ PORTABLE_INLINE_FUNCTION Real MGUsup::PressureFromDensityInternalEnergy(
return value;
}
template <typename Indexer_t>
PORTABLE_INLINE_FUNCTION Real
MGUsup::MinInternalEnergyFromDensity(const Real rho, Indexer_t &&lambda) const {
MinInternalEnergyIsNotEnabled("MGUsup");
return 0.0;
}
template <typename Indexer_t>
PORTABLE_INLINE_FUNCTION Real MGUsup::EntropyFromDensityInternalEnergy(
const Real rho, const Real sie, Indexer_t &&lambda) const {
Real eta = 1.0 - robust::ratio(_rho0, rho);
Expand Down
6 changes: 0 additions & 6 deletions singularity-eos/eos/eos_noble_abel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,6 @@ class NobleAbel : public EosBase<NobleAbel> {
return std::max(robust::SMALL(),
robust::ratio(_gm1 * rho * (sie - _qq), 1.0 - _bb * rho));
}
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real MinInternalEnergyFromDensity(
const Real rho, Indexer_t &&lambda = static_cast<Real *>(nullptr)) const {
MinInternalEnergyIsNotEnabled("Noble Abel");
return 0.0;
}

template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real
Expand Down
9 changes: 0 additions & 9 deletions singularity-eos/eos/eos_powermg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ class PowerMG : public EosBase<PowerMG> {
const Real rho, const Real sie,
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const;
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real MinInternalEnergyFromDensity(
const Real rho, Indexer_t &&lambda = static_cast<Real *>(nullptr)) const;
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real
EntropyFromDensityTemperature(const Real rho, const Real temp,
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const;
Expand Down Expand Up @@ -409,12 +406,6 @@ PORTABLE_INLINE_FUNCTION Real PowerMG::PressureFromDensityInternalEnergy(
return value;
}
template <typename Indexer_t>
PORTABLE_INLINE_FUNCTION Real
PowerMG::MinInternalEnergyFromDensity(const Real rho, Indexer_t &&lambda) const {
MinInternalEnergyIsNotEnabled("PowerMG");
return 0.0;
}
template <typename Indexer_t>
PORTABLE_INLINE_FUNCTION Real PowerMG::EntropyFromDensityInternalEnergy(
const Real rho, const Real sie, Indexer_t &&lambda) const {
const Real eta = 1.0 - robust::ratio(_rho0, rho);
Expand Down
7 changes: 0 additions & 7 deletions singularity-eos/eos/eos_sap_polynomial.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,6 @@ class SAP_Polynomial : public EosBase<SAP_Polynomial> {
sie * (_b0 + _b1 * mu + _b2e * mu * mu + _b3 * mu * mu * mu);
}

template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real MinInternalEnergyFromDensity(
const Real rho, Indexer_t &&lambda = static_cast<Real *>(nullptr)) const {
MinInternalEnergyIsNotEnabled("SAP Polynomial");
return 0.0;
};

template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real
EntropyFromDensityTemperature(const Real rho, const Real temperature,
Expand Down
7 changes: 0 additions & 7 deletions singularity-eos/eos/eos_stiff.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,6 @@ class StiffGas : public EosBase<StiffGas> {
return std::max(-_Pinf, _gm1 * rho * (sie - _qq) - (_gm1 + 1.0) * _Pinf);
}

template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real MinInternalEnergyFromDensity(
const Real rho, Indexer_t &&lambda = static_cast<Real *>(nullptr)) const {
MinInternalEnergyIsNotEnabled("StiffGas");
return 0.0;
};

template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real
EntropyFromDensityTemperature(const Real rho, const Real temperature,
Expand Down
9 changes: 0 additions & 9 deletions singularity-eos/eos/eos_vinet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ class Vinet : public EosBase<Vinet> {
PORTABLE_INLINE_FUNCTION Real PressureFromDensityInternalEnergy(
const Real rho, const Real sie,
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const;
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real MinInternalEnergyFromDensity(
const Real rho, Indexer_t &&lambda = static_cast<Real *>(nullptr)) const;
// Entropy added AEM Dec. 2022
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real
Expand Down Expand Up @@ -346,12 +343,6 @@ PORTABLE_INLINE_FUNCTION Real Vinet::PressureFromDensityInternalEnergy(
return output[1];
}
template <typename Indexer_t>
PORTABLE_INLINE_FUNCTION Real
Vinet::MinInternalEnergyFromDensity(const Real rho, Indexer_t &&lambda) const {
MinInternalEnergyIsNotEnabled("Vinet");
return 0.0;
}
template <typename Indexer_t>
PORTABLE_INLINE_FUNCTION Real Vinet::EntropyFromDensityInternalEnergy(
const Real rho, const Real sie, Indexer_t &&lambda) const {
Real temp;
Expand Down
Loading
Loading