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

Add is_equilibrium and is_barotropic tests to EOSes #6104

Merged
merged 2 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ class Barotropic3D : public EquationOfState<ColdEquilEos::is_relativistic, 3> {
/// \brief Returns `true` if the EOS is barotropic
bool is_barotropic() const override { return true; }

/// \brief Returns `true` if the EOS is in beta-equilibrium
bool is_equilibrium() const override { return false; }

bool operator==(const Barotropic3D<ColdEquilEos>& rhs) const;

bool operator!=(const Barotropic3D<ColdEquilEos>& rhs) const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,11 @@ class EquationOfState<IsRelativistic, 2> : public PUP::able {
/// \brief Returns `true` if the EOS is barotropic
virtual bool is_barotropic() const = 0;

/// \brief Returns `true` if the EOS is in beta-equilibrium
virtual bool is_equilibrium() const {
return true;
}

/// @{
/*!
* Computes the electron fraction in beta-equilibrium \f$Y_e^{\rm eq}\f$ from
Expand Down Expand Up @@ -571,6 +576,9 @@ class EquationOfState<IsRelativistic, 3> : public PUP::able {
/// \brief Returns `true` if the EOS is barotropic
virtual bool is_barotropic() const = 0;

/// \brief Returns `true` if the EOS is in beta-equilibrium
virtual bool is_equilibrium() const = 0;

/// @{
/*!
* Computes the pressure \f$p\f$ from the rest mass density \f$\rho\f$, the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ class Equilibrium3D : public EquationOfState<EquilEos::is_relativistic, 3> {
/// \brief Returns `true` if the EOS is barotropic
bool is_barotropic() const override { return false; }

/// \brief Returns `true` if the EOS is in beta-equilibrium
bool is_equilibrium() const override { return true; }

bool operator==(const Equilibrium3D<EquilEos>& rhs) const;

bool operator!=(const Equilibrium3D<EquilEos>& rhs) const;
Expand Down
3 changes: 3 additions & 0 deletions src/PointwiseFunctions/Hydro/EquationsOfState/Tabulated3d.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ class Tabulated3D : public EquationOfState<IsRelativistic, 3> {
/// \brief Returns `true` if the EOS is barotropic
bool is_barotropic() const override { return false; }

/// \breif Returns `true` if the EOS is in beta-equilibrium
bool is_equilibrium() const override { return false; }

bool operator==(const Tabulated3D<IsRelativistic>& rhs) const;

bool operator!=(const Tabulated3D<IsRelativistic>& rhs) const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ SPECTRE_TEST_CASE("Unit.PointwiseFunctions.EquationsOfState.Barotropic2D",
CHECK(eos.electron_fraction_upper_bound() == 1.0);
CHECK(eos.temperature_lower_bound() == 0.0);
CHECK(eos.temperature_upper_bound() == std::numeric_limits<double>::max());
CHECK(eos.is_barotropic());
CHECK(eos.is_equilibrium());
{
// DataVector functions
const Scalar<DataVector> rest_mass_density{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ SPECTRE_TEST_CASE("Unit.PointwiseFunctions.EquationsOfState.Barotropic3D",
CHECK(eos.electron_fraction_upper_bound() == 1.0);
CHECK(eos.temperature_lower_bound() == 0.0);
CHECK(eos.temperature_upper_bound() == std::numeric_limits<double>::max());
CHECK(eos.is_barotropic());
CHECK(not eos.is_equilibrium());
{
// DataVector functions
const Scalar<DataVector> rest_mass_density{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ void check_bounds() {
CHECK(max_double == eos.specific_internal_energy_upper_bound(1.0));
CHECK(eos.baryon_mass() ==
approx(hydro::units::geometric::default_baryon_mass));
CHECK(not eos.is_barotropic());
}
} // namespace

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ void check_exact() {
CHECK(*eos.promote_to_2d_eos() == Barotropic2D<Enthalpy<Spectral>>(eos));
CHECK(eos.baryon_mass() ==
approx(hydro::units::geometric::default_baryon_mass));
CHECK(eos.is_barotropic());
}
// Test DataVector functions
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ SPECTRE_TEST_CASE("Unit.PointwiseFunctions.EquationsOfState.Equilibrium3D",
CHECK(eos.electron_fraction_upper_bound() == 1.0);
CHECK(eos.specific_enthalpy_lower_bound() ==
underlying_eos.specific_enthalpy_lower_bound());
CHECK(not eos.is_barotropic());
CHECK(eos.is_equilibrium());

{
const double rest_mass_density = 1e-3;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ void check_exact_polytrope() {
const auto p_kappa_over_rho_sq =
eos.kappa_times_p_over_rho_squared_from_density_and_energy(rho, eps);
CHECK(get(p_kappa_over_rho_sq) == 4.25);
CHECK(not eos.is_barotropic());
}

template <bool IsRelativistic>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ SPECTRE_TEST_CASE("Unit.PointwiseFunctions.EquationsOfState.IdealFluid",
CHECK(eos != other_type_eos);
CHECK(*eos.promote_to_3d_eos() ==
EoS::Equilibrium3D<EoS::IdealFluid<true>>(eos));
CHECK(not eos.is_barotropic());
CHECK(not other_eos.is_barotropic());

TestHelpers::EquationsOfState::check(EoS::IdealFluid<true>{5.0 / 3.0},
"IdealFluid", "ideal_fluid", d_for_size,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,8 @@ SPECTRE_TEST_CASE(
const double poly_exponent_lo = 1.5;
const double poly_constant_lo = 10.0;
const double poly_exponent_hi = 2.0;
//Check if barotropic
CHECK(eos.is_barotropic());

// Relativistic checks
TestHelpers::EquationsOfState::check(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ SPECTRE_TEST_CASE("Unit.PointwiseFunctions.EquationsOfState.PolytropicFluid",
EoS::Barotropic3D<EoS::PolytropicFluid<true>>(eos));
CHECK(*eos.promote_to_2d_eos() ==
EoS::Barotropic2D<EoS::PolytropicFluid<true>>(eos));
CHECK(eos.is_barotropic());
const double d_for_size = std::numeric_limits<double>::signaling_NaN();
const DataVector dv_for_size(5);
TestHelpers::EquationsOfState::check(EoS::PolytropicFluid<true>{100.0, 2.0},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ void check_exact() {
EquationsOfState::Barotropic3D<EquationsOfState::Spectral>(eos));
CHECK(*eos.promote_to_2d_eos() ==
EquationsOfState::Barotropic2D<EquationsOfState::Spectral>(eos));
CHECK(eos.is_barotropic());
// Test DataVector functions
{
const Scalar<DataVector> rho{DataVector{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ SPECTRE_TEST_CASE("Unit.PointwiseFunctions.EquationsOfState.Tabulated3D",
get(eos.sound_speed_squared_from_density_and_temperature(
state[1], state[0], state[2])) <
1.e-12);
CHECK(not eos.is_barotropic());
CHECK(not eos.is_equilibrium());

const auto eps_interp =
eos.specific_internal_energy_from_density_and_temperature(
Expand Down
Loading