Files
MeanField_SERiF/tests/include/serif/tests/equations/barotropic_eos.hpp
Emily Boudreaux cb20faeb3d test(tests): added test suite
The test suite is extensive. Note that LLMs were used to aid in the development of the test suite. All LLM generated code was manually reviewed.
2026-11-09 13:53:17 -05:00

42 lines
2.4 KiB
C++

#pragma once
#include <cmath>
#include "serif/dimensions/partial.hpp"
#include "serif/dimensions/type_alias.hpp"
#include "serif/eos/relations/relations.hpp"
namespace serif::tests::equations {
/** @brief A nonpolytropic barotrope P = rho^2 + rho^4 with no enthalpy relation or polytropic parameters. */
struct MixedPowerBarotrope final {
using Relations = eos::relations::RelationCatalog<eos::relations::PressureFromDensity,
eos::relations::DensityFromPressure, eos::relations::PressurePotentialFromDensity>;
double gauge = 0.0;
/** @brief Evaluate the independently specified pressure law at the tested nonnegative densities. */
[[nodiscard]] dimensions::PressureValue evaluate(eos::relations::PressureFromDensity, const dimensions::DensityValue density) const {
const double squared_density = density.value() * density.value();
return dimensions::PressureValue{squared_density + squared_density * squared_density};
}
/** @brief Invert the pressure law using the rationalized positive root. */
[[nodiscard]] dimensions::DensityValue evaluate(eos::relations::DensityFromPressure, const dimensions::PressureValue pressure) const {
return dimensions::DensityValue{std::sqrt(2.0 * pressure.value() / (1.0 + std::sqrt(1.0 + 4.0 * pressure.value())))};
}
/** @brief Integrate P_rho/rho and expose an arbitrary additive constant. */
[[nodiscard]] dimensions::BarotropicPressurePotentialValue evaluate(
eos::relations::PressurePotentialFromDensity, const dimensions::DensityValue density) const {
return dimensions::BarotropicPressurePotentialValue{2.0 * density.value() +
(4.0 / 3.0) * density.value() * density.value() * density.value() + gauge};
}
/** @brief Supply the only thermodynamic derivative required by the density equation. */
[[nodiscard]] dimensions::PartialDerivative<dimensions::Pressure, dimensions::MassDensity> partial_derivative(
eos::relations::PressureFromDensity, dimensions::WithRespectTo<dimensions::MassDensity>, const dimensions::DensityValue density) const {
return dimensions::PartialDerivative<dimensions::Pressure, dimensions::MassDensity>{
2.0 * density.value() + 4.0 * density.value() * density.value() * density.value()};
}
};
}