From 7c38ef472ed03b81ba88ede077653fff0dbc7cf9 Mon Sep 17 00:00:00 2001 From: Guillaume Giudicelli Date: Thu, 26 Dec 2024 21:39:59 +0100 Subject: [PATCH] Add support for T(p,h) in a few gas FPs by adding it as a Newton inversion of h(p,T) in HelmhotzFP refs #29620 --- .../fluidproperties/HelmholtzFluidProperties.h | 2 ++ .../fluidproperties/HelmholtzFluidProperties.C | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/modules/fluid_properties/include/fluidproperties/HelmholtzFluidProperties.h b/modules/fluid_properties/include/fluidproperties/HelmholtzFluidProperties.h index 7dc902495606..9769b0e69c4c 100644 --- a/modules/fluid_properties/include/fluidproperties/HelmholtzFluidProperties.h +++ b/modules/fluid_properties/include/fluidproperties/HelmholtzFluidProperties.h @@ -55,6 +55,8 @@ class HelmholtzFluidProperties : public SinglePhaseFluidProperties virtual Real h_from_p_T(Real pressure, Real temperature) const override; virtual void h_from_p_T(Real p, Real T, Real & h, Real & dh_dp, Real & dh_dT) const override; + virtual Real T_from_p_h(Real pressure, Real enthalpy) const override; + /** * Pressure as a function of density and temperature * diff --git a/modules/fluid_properties/src/fluidproperties/HelmholtzFluidProperties.C b/modules/fluid_properties/src/fluidproperties/HelmholtzFluidProperties.C index e01035794b73..42c6521ee9b9 100644 --- a/modules/fluid_properties/src/fluidproperties/HelmholtzFluidProperties.C +++ b/modules/fluid_properties/src/fluidproperties/HelmholtzFluidProperties.C @@ -216,6 +216,24 @@ HelmholtzFluidProperties::h_from_p_T( molarMass(); } +Real +HelmholtzFluidProperties::T_from_p_h(Real pressure, Real enthalpy) const +{ + auto lambda = [&](Real pressure, Real current_T, Real & new_h, Real & dh_dp, Real & dh_dT) + { h_from_p_T(pressure, current_T, new_h, dh_dp, dh_dT); }; + Real T = FluidPropertiesUtils::NewtonSolve( + pressure, enthalpy, _T_initial_guess, _tolerance, lambda, name() + "::T_from_p_h") + .first; + // check for nans + if (std::isnan(T)) + mooseError("Conversion from enthalpy (h = ", + enthalpy, + ") and pressure (p = ", + pressure, + ") to temperature failed to converge."); + return T; +} + Real HelmholtzFluidProperties::p_from_rho_T(Real density, Real temperature) const {