Cantera 2.6.0
WaterSSTP.h
Go to the documentation of this file.
1/**
2 * @file WaterSSTP.h
3 * Declares a ThermoPhase class consisting of pure water (see \ref thermoprops
4 * and class \link Cantera::WaterSSTP WaterSSTP\endlink).
5 */
6
7// This file is part of Cantera. See License.txt in the top-level directory or
8// at https://cantera.org/license.txt for license and copyright information.
9
10#ifndef CT_WATERSSTP_H
11#define CT_WATERSSTP_H
12
13#include "SingleSpeciesTP.h"
16
17namespace Cantera
18{
19
20class WaterPropsIAPWS;
21class WaterProps;
22//! Class for single-component water. This is designed to cover just the liquid
23//! and supercritical phases of water.
24/*!
25 * The reference is W. Wagner, A. Pruss, "The IAPWS Formulation 1995 for the
26 * Thermodynamic Properties of Ordinary Water Substance for General and
27 * Scientific Use," J. Phys. Chem. Ref. Dat, 31, 387, 2002.
28 *
29 * ## Specification of Species Standard State Properties
30 *
31 * The offsets used in the steam tables are different than NIST's. They assume
32 * u_liq(TP) = 0.0, s_liq(TP) = 0.0, where TP is the triple point conditions:
33 *
34 * - u(273.16, rho) = 0.0
35 * - s(273.16, rho) = 0.0
36 * - psat(273.16) = 611.655 Pascal
37 * - rho(273.16, psat) = 999.793 kg m-3
38 *
39 * These "steam table" assumptions are used by the WaterPropsIAPWS class.
40 * Therefore, offsets must be calculated to make the thermodynamic properties
41 * calculated within this class to be consistent with thermo properties within
42 * Cantera.
43 *
44 * The thermodynamic base state for water is set to the NIST basis here by
45 * specifying constants, #EW_Offset and #SW_Offset, one for energy quantities
46 * and one for entropy quantities. The offsets are specified so that the
47 * following properties hold:
48 *
49 * - Delta_Hfo_idealgas(298.15) = -241.826 kJ/gmol
50 * - So_idealgas(298.15, 1bar) = 188.835 J/gmolK
51 *
52 * (From http://webbook.nist.gov)
53 *
54 * The "o" here refers to a hypothetical ideal gas state. The way we achieve
55 * this in practice is to evaluate at a very low pressure and then use the
56 * theoretical ideal gas results to scale up to higher pressures:
57 *
58 * Ho(1bar) = H(P0)
59 *
60 * So(1bar) = S(P0) + RT ln(1bar/P0)
61 *
62 * ## %Application within Kinetics Managers
63 *
64 * This is unimplemented.
65 *
66 * ## XML Example
67 *
68 * *Note: The XML input format is deprecated and will be removed in %Cantera 3.0*
69 *
70 * An example of an XML Element named phase setting up a WaterSSTP object with
71 * id "water" is given below.
72 *
73 * @code
74 * <!-- phase water -->
75 * <phase dim="3" id="water">
76 * <elementArray datasrc="elements.xml">O H </elementArray>
77 * <speciesArray datasrc="#species_data">H2O</speciesArray>
78 * <state>
79 * <temperature units="K">300.0</temperature>
80 * <pressure units="Pa">101325.0</pressure>
81 * </state>
82 * <thermo model="PureLiquidWater"/>
83 * <kinetics model="none"/>
84 * </phase>
85 * @endcode
86 *
87 * Note the model "PureLiquidWater" indicates the usage of the WaterSSTP object.
88 *
89 * @ingroup thermoprops
90 */
92{
93public:
94 //! Full constructor for a water phase
95 /*!
96 * @param inputFile String name of the input file
97 * @param id string id of the phase name
98 */
99 explicit WaterSSTP(const std::string& inputFile="",
100 const std::string& id="");
101
102 //! Full constructor for a water phase
103 /*!
104 * @param phaseRef XML node referencing the water phase.
105 * @param id string id of the phase name
106 *
107 * @deprecated The XML input format is deprecated and will be removed in
108 * Cantera 3.0.
109 */
110 explicit WaterSSTP(XML_Node& phaseRef, const std::string& id = "");
111
112 virtual std::string type() const {
113 return "liquid-water-IAPWS95";
114 }
115
116 virtual std::string phaseOfMatter() const;
117
118 //! @name Molar Thermodynamic Properties of the Solution
119 //! @{
120
121 virtual doublereal cv_mole() const;
122
123 //! @}
124 //! @name Mechanical Equation of State Properties
125 //! @{
126
127 virtual doublereal pressure() const;
128 virtual void setPressure(doublereal p);
129 virtual doublereal isothermalCompressibility() const;
130 virtual doublereal thermalExpansionCoeff() const;
131
132 //! Return the derivative of the volumetric thermal expansion coefficient.
133 //! Units: 1/K2.
134 virtual doublereal dthermalExpansionCoeffdT() const;
135
136 //! @}
137 //! @name Properties of the Standard State of the Species in the Solution
138 //! @{
139
140 virtual void getStandardChemPotentials(doublereal* gss) const;
141 virtual void getGibbs_RT(doublereal* grt) const;
142 virtual void getEnthalpy_RT(doublereal* hrt) const;
143 virtual void getEntropy_R(doublereal* sr) const;
144 virtual void getCp_R(doublereal* cpr) const;
145 virtual void getIntEnergy_RT(doublereal* urt) const;
146
147 //! @}
148 //! @name Thermodynamic Values for the Species Reference State
149 /*!
150 * All functions in this group need to be overridden, because the
151 * m_spthermo MultiSpeciesThermo function is not adequate for the real
152 * equation of state.
153 */
154 //! @{
155
156 virtual void getEnthalpy_RT_ref(doublereal* hrt) const;
157 virtual void getGibbs_RT_ref(doublereal* grt) const;
158 virtual void getGibbs_ref(doublereal* g) const;
159 virtual void getEntropy_R_ref(doublereal* er) const;
160 virtual void getCp_R_ref(doublereal* cprt) const;
161 virtual void getStandardVolumes_ref(doublereal* vol) const;
162 //! @}
163
164 virtual doublereal critTemperature() const;
165 virtual doublereal critPressure() const;
166 virtual doublereal critDensity() const;
167
168 virtual doublereal satPressure(doublereal t);
169
170 virtual bool compatibleWithMultiPhase() const {
171 return false;
172 }
173
174 //! Return the fraction of vapor at the current conditions
175 /*!
176 * Below Tcrit, this routine will always return 0, by definition of the
177 * functionality of the routine. Above Tcrit, we query the density to toggle
178 * between 0 and 1.
179 */
180 virtual doublereal vaporFraction() const;
181
182 //! Set the temperature of the phase
183 /*!
184 * The density and composition of the phase is constant during this
185 * operator.
186 *
187 * @param temp Temperature (Kelvin)
188 */
189 virtual void setTemperature(const doublereal temp);
190
191 //! Set the density of the phase
192 /*!
193 * The temperature and composition of the phase is constant during this
194 * operator.
195 *
196 * @param dens value of the density in kg m-3
197 */
198 virtual void setDensity(const doublereal dens);
199
200 virtual void initThermo();
201 virtual void setParametersFromXML(const XML_Node& eosdata);
202
203 //! Get a pointer to a changeable WaterPropsIAPWS object
205 return &m_sub;
206 }
207
208 //! Get a pointer to a changeable WaterPropsIAPWS object
210 return m_waterProps.get();
211 }
212
213 //! Switch that enables calculations in the gas phase
214 /**
215 * Since this phase represents a liquid (or supercritical) phase, it is an
216 * error to return a gas-phase answer. The sole intended use for this
217 * member function is to check the thermodynamic consistency of the
218 * underlying WaterProps class with ideal-gas thermo functions.
219 */
220 void _allowGasPhase(bool flag) { m_allowGasPhase = flag; }
221
222protected:
223 /**
224 * @internal This internal routine must be overridden because it is not
225 * applicable.
226 */
227 void _updateThermo() const;
228
229private:
230 //! WaterPropsIAPWS that calculates the real properties of water.
232
233 //! Pointer to the WaterProps object
234 /*!
235 * This class is used to house several approximation routines for properties
236 * of water. This object owns m_waterProps, and the WaterPropsIAPWS object
237 * used by WaterProps is m_sub, which is defined above.
238 */
239 std::unique_ptr<WaterProps> m_waterProps;
240
241 //! Molecular weight of Water -> Cantera assumption
242 doublereal m_mw;
243
244 //! Offset constants used to obtain consistency with the NIST database.
245 /*!
246 * This is added to all internal energy and enthalpy results.
247 * units = J kmol-1.
248 */
249 doublereal EW_Offset;
250
251 //! Offset constant used to obtain consistency with NIST convention.
252 /*!
253 * This is added to all internal entropy results.
254 * units = J kmol-1 K-1.
255 */
256 doublereal SW_Offset;
257
258 //! Boolean is true if object has been properly initialized for calculation
260
261 /**
262 * Since this phase represents a liquid (or supercritical) phase, it is an
263 * error to return a gas-phase answer. However, if the below is true, then
264 * a gas-phase answer is allowed. This is used to check the thermodynamic
265 * consistency with ideal-gas thermo functions for example.
266 */
268};
269
270}
271
272#endif
Header for the SingleSpeciesTP class, which is a filter class for ThermoPhase, that eases the constru...
Headers for a class for calculating the equation of state of water from the IAPWS 1995 Formulation ba...
Header for a class used to house several approximation routines for properties of water.
The SingleSpeciesTP class is a filter class for ThermoPhase.
Class for calculating the equation of state of water.
The WaterProps class is used to house several approximation routines for properties of water.
Definition: WaterProps.h:100
Class for single-component water.
Definition: WaterSSTP.h:92
virtual void getGibbs_RT_ref(doublereal *grt) const
Returns the vector of nondimensional Gibbs Free Energies of the reference state at the current temper...
Definition: WaterSSTP.cpp:171
WaterPropsIAPWS m_sub
WaterPropsIAPWS that calculates the real properties of water.
Definition: WaterSSTP.h:231
bool m_ready
Boolean is true if object has been properly initialized for calculation.
Definition: WaterSSTP.h:259
virtual void getGibbs_RT(doublereal *grt) const
Get the nondimensional Gibbs functions for the species in their standard states at the current T and ...
Definition: WaterSSTP.cpp:125
virtual doublereal pressure() const
Return the thermodynamic pressure (Pa).
Definition: WaterSSTP.cpp:259
WaterPropsIAPWS * getWater()
Get a pointer to a changeable WaterPropsIAPWS object.
Definition: WaterSSTP.h:204
virtual doublereal critPressure() const
Critical pressure (Pa).
Definition: WaterSSTP.cpp:320
doublereal EW_Offset
Offset constants used to obtain consistency with the NIST database.
Definition: WaterSSTP.h:249
virtual doublereal cv_mole() const
Molar heat capacity at constant volume. Units: J/kmol/K.
Definition: WaterSSTP.cpp:147
virtual doublereal vaporFraction() const
Return the fraction of vapor at the current conditions.
Definition: WaterSSTP.cpp:355
virtual bool compatibleWithMultiPhase() const
Indicates whether this phase type can be used with class MultiPhase for equilibrium calculations.
Definition: WaterSSTP.h:170
virtual doublereal thermalExpansionCoeff() const
Return the volumetric thermal expansion coefficient. Units: 1/K.
Definition: WaterSSTP.cpp:293
virtual void getCp_R(doublereal *cpr) const
Get the nondimensional Heat Capacities at constant pressure for the species standard states at the cu...
Definition: WaterSSTP.cpp:142
virtual doublereal dthermalExpansionCoeffdT() const
Return the derivative of the volumetric thermal expansion coefficient.
Definition: WaterSSTP.cpp:298
virtual void getEntropy_R(doublereal *sr) const
Get the array of nondimensional Entropy functions for the standard state species at the current T and...
Definition: WaterSSTP.cpp:120
virtual void setPressure(doublereal p)
Set the internally stored pressure (Pa) at constant temperature and composition.
Definition: WaterSSTP.cpp:264
virtual void initThermo()
Initialize the ThermoPhase object after all species have been set up.
Definition: WaterSSTP.cpp:45
virtual void getStandardChemPotentials(doublereal *gss) const
Get the array of chemical potentials at unit activity for the species at their standard states at the...
Definition: WaterSSTP.cpp:133
virtual doublereal critTemperature() const
Critical temperature (K).
Definition: WaterSSTP.cpp:315
virtual void getEntropy_R_ref(doublereal *er) const
Returns the vector of nondimensional entropies of the reference state at the current temperature of t...
Definition: WaterSSTP.cpp:199
virtual std::string type() const
String indicating the thermodynamic model implemented.
Definition: WaterSSTP.h:112
virtual void getIntEnergy_RT(doublereal *urt) const
Returns the vector of nondimensional Internal Energies of the standard state species at the current T...
Definition: WaterSSTP.cpp:115
virtual void setTemperature(const doublereal temp)
Set the temperature of the phase.
Definition: WaterSSTP.cpp:330
virtual void getCp_R_ref(doublereal *cprt) const
Returns the vector of nondimensional constant pressure heat capacities of the reference state at the ...
Definition: WaterSSTP.cpp:221
virtual void setParametersFromXML(const XML_Node &eosdata)
Set equation of state parameter values from XML entries.
Definition: WaterSSTP.cpp:105
doublereal m_mw
Molecular weight of Water -> Cantera assumption.
Definition: WaterSSTP.h:242
virtual void getStandardVolumes_ref(doublereal *vol) const
Get the molar volumes of the species reference states at the current T and P_ref of the solution.
Definition: WaterSSTP.cpp:241
virtual void setDensity(const doublereal dens)
Set the density of the phase.
Definition: WaterSSTP.cpp:341
WaterProps * getWaterProps()
Get a pointer to a changeable WaterPropsIAPWS object.
Definition: WaterSSTP.h:209
void _allowGasPhase(bool flag)
Switch that enables calculations in the gas phase.
Definition: WaterSSTP.h:220
virtual doublereal satPressure(doublereal t)
Return the saturation pressure given the temperature.
Definition: WaterSSTP.cpp:347
doublereal SW_Offset
Offset constant used to obtain consistency with NIST convention.
Definition: WaterSSTP.h:256
WaterSSTP(const std::string &inputFile="", const std::string &id="")
Full constructor for a water phase.
Definition: WaterSSTP.cpp:18
bool m_allowGasPhase
Since this phase represents a liquid (or supercritical) phase, it is an error to return a gas-phase a...
Definition: WaterSSTP.h:267
void _updateThermo() const
virtual void getGibbs_ref(doublereal *g) const
Returns the vector of the Gibbs function of the reference state at the current temperature of the sol...
Definition: WaterSSTP.cpp:191
std::unique_ptr< WaterProps > m_waterProps
Pointer to the WaterProps object.
Definition: WaterSSTP.h:239
virtual void getEnthalpy_RT(doublereal *hrt) const
Get the nondimensional Enthalpy functions for the species at their standard states at the current T a...
Definition: WaterSSTP.cpp:110
virtual doublereal critDensity() const
Critical density (kg/m3).
Definition: WaterSSTP.cpp:325
virtual std::string phaseOfMatter() const
String indicating the mechanical phase of the matter in this Phase.
Definition: WaterSSTP.cpp:38
virtual void getEnthalpy_RT_ref(doublereal *hrt) const
Definition: WaterSSTP.cpp:152
virtual doublereal isothermalCompressibility() const
Returns the isothermal compressibility. Units: 1/Pa.
Definition: WaterSSTP.cpp:288
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:103
Namespace for the Cantera kernel.
Definition: AnyMap.h:29