feat(quadrature): quadrature system brought over
Ported and dramatically cleaned up the quadrature system. This includes centralizing all field definitions
This commit is contained in:
@@ -2,11 +2,14 @@
|
||||
#include "serif/utils/misc/finite.hpp"
|
||||
#include "serif/eos/exceptions.hpp"
|
||||
|
||||
#include "serif/utils/error/codes.hpp"
|
||||
|
||||
namespace serif::eos::models {
|
||||
using utils::misc::validate_finite;
|
||||
using utils::misc::validate_greater_than;
|
||||
using utils::misc::validate_less_than;
|
||||
using utils::misc::validate_nonnegativity;
|
||||
using utils::errors::SERiFErrorCode;
|
||||
|
||||
using namespace dimensions;
|
||||
using namespace relations;
|
||||
@@ -17,10 +20,10 @@ namespace serif::eos::models {
|
||||
m_polytropic_index(n),
|
||||
m_polytropic_constant(K),
|
||||
m_enthalpy_scale((n + 1.0) * K) {
|
||||
validate_finite<EOSEvaluationError>(m_polytropic_index, EOSEvaluationErrorCode::outside_domain);
|
||||
validate_greater_than<EOSEvaluationError>(m_polytropic_index, 1.0, EOSEvaluationErrorCode::outside_domain);
|
||||
validate_finite<EOSEvaluationError>(m_polytropic_constant, EOSEvaluationErrorCode::outside_domain);
|
||||
validate_greater_than<EOSEvaluationError>(m_polytropic_constant, 0.0, EOSEvaluationErrorCode::outside_domain);
|
||||
validate_finite<EOSEvaluationError, SERiFErrorCode::EOS_OUTSIDE_DOMAIN>(m_polytropic_index);
|
||||
validate_greater_than<EOSEvaluationError, SERiFErrorCode::EOS_OUTSIDE_DOMAIN>(m_polytropic_index, 1.0);
|
||||
validate_finite<EOSEvaluationError, SERiFErrorCode::EOS_OUTSIDE_DOMAIN>(m_polytropic_constant);
|
||||
validate_greater_than<EOSEvaluationError, SERiFErrorCode::EOS_OUTSIDE_DOMAIN>(m_polytropic_constant, 0.0);
|
||||
}
|
||||
|
||||
[[nodiscard]] double Polytrope::polytropic_index() const noexcept {
|
||||
@@ -36,7 +39,7 @@ namespace serif::eos::models {
|
||||
}
|
||||
|
||||
[[nodiscard]] PressureValue Polytrope::evaluate(PressureFromDensity, const DensityValue density) const {
|
||||
validate_nonnegativity<EOSEvaluationError>(density.value(), EOSEvaluationErrorCode::invalid_thermodynamic_input);
|
||||
validate_nonnegativity<EOSEvaluationError, SERiFErrorCode::EOS_INVALID_THERMODYNAMIC_INPUT>(density.value());
|
||||
|
||||
if (density.value() == 0.0) {
|
||||
// P = 0
|
||||
@@ -50,7 +53,7 @@ namespace serif::eos::models {
|
||||
}
|
||||
|
||||
[[nodiscard]] SpecificEnthalpyValue Polytrope::evaluate(SpecificEnthalpyFromDensity, const DensityValue density) const {
|
||||
validate_nonnegativity<EOSEvaluationError>(density.value(), EOSEvaluationErrorCode::invalid_thermodynamic_input);
|
||||
validate_nonnegativity<EOSEvaluationError, SERiFErrorCode::EOS_INVALID_THERMODYNAMIC_INPUT>(density.value());
|
||||
if (density.value() == 0.0) {
|
||||
// h = 0
|
||||
return SpecificEnthalpyValue{0.0};
|
||||
@@ -63,7 +66,7 @@ namespace serif::eos::models {
|
||||
}
|
||||
|
||||
[[nodiscard]] DensityValue Polytrope::evaluate(DensityFromSpecificEnthalpy, SpecificEnthalpyValue specific_enthalpy) const {
|
||||
validate_finite<EOSEvaluationError>(specific_enthalpy.value(), EOSEvaluationErrorCode::invalid_thermodynamic_input);
|
||||
validate_finite<EOSEvaluationError, SERiFErrorCode::EOS_INVALID_THERMODYNAMIC_INPUT>(specific_enthalpy.value());
|
||||
|
||||
if (specific_enthalpy.value() <= 0.0) {
|
||||
// ρ = 0
|
||||
@@ -86,7 +89,7 @@ namespace serif::eos::models {
|
||||
}
|
||||
|
||||
[[nodiscard]] SpecificEnthalpyValue Polytrope::evaluate(SpecificEnthalpyFromPressure, PressureValue pressure) const {
|
||||
validate_nonnegativity<EOSEvaluationError>(pressure.value(), EOSEvaluationErrorCode::invalid_thermodynamic_input);
|
||||
validate_nonnegativity<EOSEvaluationError, SERiFErrorCode::EOS_INVALID_THERMODYNAMIC_INPUT>(pressure.value());
|
||||
if (pressure.value() == 0.0) {
|
||||
// h = 0
|
||||
return SpecificEnthalpyValue{0.0};
|
||||
@@ -102,7 +105,7 @@ namespace serif::eos::models {
|
||||
}
|
||||
|
||||
[[nodiscard]] PartialDerivative<Density, SpecificEnthalpy> Polytrope::partial_derivative(DensityFromSpecificEnthalpy, WithRespectTo<SpecificEnthalpy>, const SpecificEnthalpyValue specific_enthalpy) const {
|
||||
validate_finite<EOSEvaluationError>(specific_enthalpy.value(), EOSEvaluationErrorCode::invalid_thermodynamic_input);
|
||||
validate_finite<EOSEvaluationError, SERiFErrorCode::EOS_INVALID_THERMODYNAMIC_INPUT>(specific_enthalpy.value());
|
||||
|
||||
if (specific_enthalpy.value() < 0.0) {
|
||||
// dρ/dh = 0
|
||||
@@ -131,7 +134,7 @@ namespace serif::eos::models {
|
||||
}
|
||||
|
||||
[[nodiscard]] PartialDerivative<Pressure, Density> Polytrope::partial_derivative(PressureFromDensity, WithRespectTo<Density>, const DensityValue density) const {
|
||||
validate_nonnegativity<EOSEvaluationError>(density.value(), EOSEvaluationErrorCode::invalid_thermodynamic_input);
|
||||
validate_nonnegativity<EOSEvaluationError, SERiFErrorCode::EOS_INVALID_THERMODYNAMIC_INPUT>(density.value());
|
||||
|
||||
if (density.value() == 0.0) {
|
||||
// dP/dρ = 0
|
||||
|
||||
Reference in New Issue
Block a user