diff --git a/include/cantera/thermo/WaterSSTP.h b/include/cantera/thermo/WaterSSTP.h index 66f4feda7..156081581 100644 --- a/include/cantera/thermo/WaterSSTP.h +++ b/include/cantera/thermo/WaterSSTP.h @@ -20,7 +20,7 @@ namespace Cantera class WaterPropsIAPWS; class WaterProps; //! Class for single-component water. This is designed to cover just the liquid -//! part of water. +//! and supercritical phases of water. /*! * The reference is W. Wagner, A. Pruss, "The IAPWS Formulation 1995 for the * Thermodynamic Properties of Ordinary Water Substance for General and @@ -143,6 +143,8 @@ public: return "Water"; } + virtual std::string phaseOfMatter() const; + //! @name Molar Thermodynamic Properties of the Solution //! @{ @@ -281,8 +283,8 @@ private: bool m_ready; /** - * Since this phase represents a liquid phase, it's an error to - * return a gas-phase answer. However, if the below is true, then + * Since this phase represents a liquid (or supercritical) phase, it is an + * error to return a gas-phase answer. However, if the below is true, then * a gas-phase answer is allowed. This is used to check the thermodynamic * consistency with ideal-gas thermo functions for example. */ diff --git a/interfaces/cython/cantera/test/test_purefluid.py b/interfaces/cython/cantera/test/test_purefluid.py index 271efe62b..2dc44a617 100644 --- a/interfaces/cython/cantera/test/test_purefluid.py +++ b/interfaces/cython/cantera/test/test_purefluid.py @@ -367,9 +367,11 @@ class TestPureFluid(utilities.CanteraTest): # density before updating pressure) w.TP = 300, ct.one_atm dens = w.density - w.TP = 2000, ct.one_atm # supercricial + w.TP = 2000, ct.one_atm # supercritical + self.assertEqual(w.phase_of_matter, "supercritical") w.TP = 300, ct.one_atm # state goes from supercritical -> gas -> liquid self.assertNear(w.density, dens) + self.assertEqual(w.phase_of_matter, "liquid") # test setters for critical conditions w.TP = w.critical_temperature, w.critical_pressure @@ -377,6 +379,9 @@ class TestPureFluid(utilities.CanteraTest): w.TP = 2000, ct.one_atm # uses current density as initial guess w.TP = 273.16, ct.one_atm # uses fixed density as initial guess self.assertNear(w.density, 999.84376) + self.assertEqual(w.phase_of_matter, "liquid") + w.TP = w.T, w.P_sat + self.assertEqual(w.phase_of_matter, "liquid") with self.assertRaisesRegex(ct.CanteraError, "violates model assumptions"): w.TP = 273.1599999, ct.one_atm with self.assertRaisesRegex(ct.CanteraError, "violates model assumptions"): diff --git a/src/thermo/WaterSSTP.cpp b/src/thermo/WaterSSTP.cpp index 8d37e28d3..abbea3d8e 100644 --- a/src/thermo/WaterSSTP.cpp +++ b/src/thermo/WaterSSTP.cpp @@ -44,6 +44,13 @@ WaterSSTP::WaterSSTP(XML_Node& phaseRoot, const std::string& id) : importPhase(phaseRoot, this); } +std::string WaterSSTP::phaseOfMatter() const { + const vector phases = { + "gas", "liquid", "supercritical", "unstable-liquid", "unstable-gas" + }; + return phases[m_sub.phaseState()]; +} + void WaterSSTP::initThermo() { SingleSpeciesTP::initThermo();