Began porting the mapping system
This commit is contained in:
@@ -104,24 +104,24 @@ namespace serif::eos::models {
|
||||
};
|
||||
}
|
||||
|
||||
[[nodiscard]] PartialDerivative<Density, SpecificEnthalpy> Polytrope::partial_derivative(DensityFromSpecificEnthalpy, WithRespectTo<SpecificEnthalpy>, const SpecificEnthalpyValue specific_enthalpy) const {
|
||||
[[nodiscard]] PartialDerivative<MassDensity, SpecificEnthalpy> Polytrope::partial_derivative(DensityFromSpecificEnthalpy, WithRespectTo<SpecificEnthalpy>, const SpecificEnthalpyValue specific_enthalpy) const {
|
||||
validate_finite<EOSEvaluationError, SERiFErrorCode::EOS_INVALID_THERMODYNAMIC_INPUT>(specific_enthalpy.value());
|
||||
|
||||
if (specific_enthalpy.value() < 0.0) {
|
||||
// dρ/dh = 0
|
||||
return PartialDerivative<Density, SpecificEnthalpy>{0.0};
|
||||
return PartialDerivative<MassDensity, SpecificEnthalpy>{0.0};
|
||||
}
|
||||
|
||||
if (specific_enthalpy.value() == 0.0) {
|
||||
// dρ/dh = n == 1 -> 1/hs
|
||||
// dρ/dh = else -> 0
|
||||
return PartialDerivative<Density, SpecificEnthalpy>{
|
||||
return PartialDerivative<MassDensity, SpecificEnthalpy>{
|
||||
m_polytropic_index == 1.0 ? 1.0 / m_enthalpy_scale : 0.0
|
||||
};
|
||||
}
|
||||
|
||||
// dρ/dh = (n/hs) * (h/hs)^(n-1)
|
||||
return PartialDerivative<Density, SpecificEnthalpy>{
|
||||
return PartialDerivative<MassDensity, SpecificEnthalpy>{
|
||||
m_polytropic_index / m_enthalpy_scale * std::pow(specific_enthalpy.value() / m_enthalpy_scale, m_polytropic_index - 1.0)
|
||||
};
|
||||
}
|
||||
@@ -133,16 +133,16 @@ namespace serif::eos::models {
|
||||
return PartialDerivative<Pressure, SpecificEnthalpy>{density.value()};
|
||||
}
|
||||
|
||||
[[nodiscard]] PartialDerivative<Pressure, Density> Polytrope::partial_derivative(PressureFromDensity, WithRespectTo<Density>, const DensityValue density) const {
|
||||
[[nodiscard]] PartialDerivative<Pressure, MassDensity> Polytrope::partial_derivative(PressureFromDensity, WithRespectTo<MassDensity>, const DensityValue density) const {
|
||||
validate_nonnegativity<EOSEvaluationError, SERiFErrorCode::EOS_INVALID_THERMODYNAMIC_INPUT>(density.value());
|
||||
|
||||
if (density.value() == 0.0) {
|
||||
// dP/dρ = 0
|
||||
return PartialDerivative<Pressure, Density>{0.0};
|
||||
return PartialDerivative<Pressure, MassDensity>{0.0};
|
||||
}
|
||||
|
||||
// dP/dρ = K * (1 + 1/n) * (ρ)^(1/n)
|
||||
return PartialDerivative<Pressure, Density>{
|
||||
return PartialDerivative<Pressure, MassDensity>{
|
||||
m_polytropic_constant * (1.0 + 1.0 / m_polytropic_index) * std::pow(density.value(), 1.0 / m_polytropic_index)
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user