mirror of
https://github.com/Cantera/cantera.git
synced 2025-02-25 18:55:29 -06:00
[thermo] Implement phaseOfMatter for WaterSSTP class
This commit is contained in:
committed by
Ray Speth
parent
fe7bd2101f
commit
1880e2402c
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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"):
|
||||
|
||||
@@ -44,6 +44,13 @@ WaterSSTP::WaterSSTP(XML_Node& phaseRoot, const std::string& id) :
|
||||
importPhase(phaseRoot, this);
|
||||
}
|
||||
|
||||
std::string WaterSSTP::phaseOfMatter() const {
|
||||
const vector<std::string> phases = {
|
||||
"gas", "liquid", "supercritical", "unstable-liquid", "unstable-gas"
|
||||
};
|
||||
return phases[m_sub.phaseState()];
|
||||
}
|
||||
|
||||
void WaterSSTP::initThermo()
|
||||
{
|
||||
SingleSpeciesTP::initThermo();
|
||||
|
||||
Reference in New Issue
Block a user