feat(surface): major work on implementing surface constraints in a presciption agnostic manner
This commit is contained in:
125
tests/physics/equation_of_state_consumer_contracts.cpp
Normal file
125
tests/physics/equation_of_state_consumer_contracts.cpp
Normal file
@@ -0,0 +1,125 @@
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
import mean_field;
|
||||
import test_helpers;
|
||||
|
||||
namespace {
|
||||
namespace eos = mean_field::eos;
|
||||
|
||||
class DensityClosureEquationOfState final {
|
||||
public:
|
||||
using Relations = eos::RelationCatalog<eos::DensityFromSpecificEnthalpy>;
|
||||
|
||||
[[nodiscard]] constexpr eos::DensityValue evaluate(
|
||||
eos::DensityFromSpecificEnthalpy,
|
||||
const eos::SpecificEnthalpyValue specificEnthalpy
|
||||
) const noexcept {
|
||||
return eos::DensityValue{specificEnthalpy.value()};
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr eos::PartialDerivative<
|
||||
eos::quantity::Density,
|
||||
eos::quantity::SpecificEnthalpy>
|
||||
partialDerivative(
|
||||
eos::DensityFromSpecificEnthalpy,
|
||||
eos::WithRespectTo<eos::quantity::SpecificEnthalpy>,
|
||||
eos::SpecificEnthalpyValue
|
||||
) const noexcept {
|
||||
return eos::PartialDerivative<eos::quantity::Density, eos::quantity::SpecificEnthalpy>{1.0};
|
||||
}
|
||||
};
|
||||
|
||||
class DensityClosureWithoutDerivative final {
|
||||
public:
|
||||
using Relations = eos::RelationCatalog<eos::DensityFromSpecificEnthalpy>;
|
||||
|
||||
[[nodiscard]] constexpr eos::DensityValue evaluate(
|
||||
eos::DensityFromSpecificEnthalpy,
|
||||
const eos::SpecificEnthalpyValue specificEnthalpy
|
||||
) const noexcept {
|
||||
return eos::DensityValue{specificEnthalpy.value()};
|
||||
}
|
||||
};
|
||||
|
||||
class EnthalpyPressureEquationOfState final {
|
||||
public:
|
||||
using Relations = eos::RelationCatalog<eos::PressureFromSpecificEnthalpy>;
|
||||
|
||||
[[nodiscard]] constexpr eos::PressureValue evaluate(
|
||||
eos::PressureFromSpecificEnthalpy,
|
||||
const eos::SpecificEnthalpyValue specificEnthalpy
|
||||
) const noexcept {
|
||||
return eos::PressureValue{2.0 * specificEnthalpy.value()};
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr eos::PartialDerivative<
|
||||
eos::quantity::Pressure,
|
||||
eos::quantity::SpecificEnthalpy>
|
||||
partialDerivative(
|
||||
eos::PressureFromSpecificEnthalpy,
|
||||
eos::WithRespectTo<eos::quantity::SpecificEnthalpy>,
|
||||
eos::SpecificEnthalpyValue
|
||||
) const noexcept {
|
||||
return eos::PartialDerivative<eos::quantity::Pressure, eos::quantity::SpecificEnthalpy>{2.0};
|
||||
}
|
||||
};
|
||||
|
||||
class DensitySeedEquationOfState final {
|
||||
public:
|
||||
using Relations = eos::RelationCatalog<eos::SpecificEnthalpyFromDensity>;
|
||||
|
||||
[[nodiscard]] constexpr eos::SpecificEnthalpyValue evaluate(
|
||||
eos::SpecificEnthalpyFromDensity,
|
||||
const eos::DensityValue density
|
||||
) const noexcept {
|
||||
return eos::SpecificEnthalpyValue{3.0 * density.value()};
|
||||
}
|
||||
};
|
||||
|
||||
class GeneralEquationOfStateWithoutCurrentConsumerRelations final {
|
||||
public:
|
||||
using Relations = eos::RelationCatalog<eos::SpecificEnthalpyFromPressure>;
|
||||
|
||||
[[nodiscard]] constexpr eos::SpecificEnthalpyValue evaluate(
|
||||
eos::SpecificEnthalpyFromPressure,
|
||||
const eos::PressureValue pressure
|
||||
) const noexcept {
|
||||
return eos::SpecificEnthalpyValue{pressure.value()};
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
|
||||
TEST_CASE(
|
||||
"Barotropic Closure EOS Requires Density And Its Enthalpy Derivative",
|
||||
tags::barotropic_closure_equation_of_state_contract
|
||||
) {
|
||||
STATIC_CHECK(eos::BarotropicClosureEquationOfState<eos::Polytrope>);
|
||||
STATIC_CHECK(eos::BarotropicClosureEquationOfState<DensityClosureEquationOfState>);
|
||||
STATIC_CHECK(eos::EquationOfStateModel<DensityClosureWithoutDerivative>);
|
||||
STATIC_CHECK_FALSE(eos::BarotropicClosureEquationOfState<DensityClosureWithoutDerivative>);
|
||||
STATIC_CHECK_FALSE(eos::BarotropicClosureEquationOfState<EnthalpyPressureEquationOfState>);
|
||||
}
|
||||
|
||||
TEST_CASE(
|
||||
"Pressure Force EOS Requires Pressure And Its Enthalpy Derivative",
|
||||
tags::pressure_force_equation_of_state_contract
|
||||
) {
|
||||
STATIC_CHECK(eos::PressureForceEquationOfState<eos::Polytrope>);
|
||||
STATIC_CHECK(eos::PressureForceEquationOfState<EnthalpyPressureEquationOfState>);
|
||||
STATIC_CHECK_FALSE(eos::PressureForceEquationOfState<DensityClosureEquationOfState>);
|
||||
STATIC_CHECK_FALSE(eos::PressureForceEquationOfState<DensityClosureWithoutDerivative>);
|
||||
}
|
||||
|
||||
TEST_CASE(
|
||||
"Structure Seed EOS Requires Enthalpy From Density",
|
||||
tags::structure_seed_equation_of_state_contract
|
||||
) {
|
||||
STATIC_CHECK(eos::StructureSeedEquationOfState<eos::Polytrope>);
|
||||
STATIC_CHECK(eos::StructureSeedEquationOfState<DensitySeedEquationOfState>);
|
||||
STATIC_CHECK_FALSE(eos::StructureSeedEquationOfState<DensityClosureEquationOfState>);
|
||||
|
||||
STATIC_CHECK(eos::EquationOfStateModel<GeneralEquationOfStateWithoutCurrentConsumerRelations>);
|
||||
STATIC_CHECK_FALSE(eos::StructureSeedEquationOfState<GeneralEquationOfStateWithoutCurrentConsumerRelations>);
|
||||
STATIC_CHECK_FALSE(eos::BarotropicClosureEquationOfState<GeneralEquationOfStateWithoutCurrentConsumerRelations>);
|
||||
STATIC_CHECK_FALSE(eos::PressureForceEquationOfState<GeneralEquationOfStateWithoutCurrentConsumerRelations>);
|
||||
}
|
||||
Reference in New Issue
Block a user