Cantera  2.5.1
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 
17 namespace Cantera
18 {
19 
20 class WaterPropsIAPWS;
21 class 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  * ## Instantiation of the Class
67  *
68  * A new WaterSSTP object may be created by the following code snippets,
69  * combined with an XML file given in the XML example section.
70  *
71  * @code
72  * ThermoPhase* w = newPhase("waterSSTPphase.xml");
73  * @endcode
74  *
75  * or
76  *
77  * @code
78  * WaterSSTP *w = new WaterSSTP("waterSSTPphase.xml","");
79  * @endcode
80  *
81  * or
82  *
83  * @code
84  * XML_Node *xm = get_XML_NameID("phase", "waterSSTPphase.xml#water", 0);
85  * WaterSSTP *w = new WaterSSTP(*xm);
86  * @endcode
87  *
88  * or by the following call to importPhase():
89  *
90  * @code
91  * XML_Node *xm = get_XML_NameID("phase", "waterSSTPphase.xml#water", 0);
92  * WaterSSTP water;
93  * importPhase(*xm, &water);
94  * @endcode
95  *
96  * ## XML Example
97  *
98  * An example of an XML Element named phase setting up a WaterSSTP object with
99  * id "water" is given below.
100  *
101  * @code
102  * <!-- phase water -->
103  * <phase dim="3" id="water">
104  * <elementArray datasrc="elements.xml">O H </elementArray>
105  * <speciesArray datasrc="#species_data">H2O</speciesArray>
106  * <state>
107  * <temperature units="K">300.0</temperature>
108  * <pressure units="Pa">101325.0</pressure>
109  * </state>
110  * <thermo model="PureLiquidWater"/>
111  * <kinetics model="none"/>
112  * </phase>
113  * @endcode
114  *
115  * Note the model "PureLiquidWater" indicates the usage of the WaterSSTP object.
116  *
117  * @ingroup thermoprops
118  */
120 {
121 public:
122  //! Base constructor
123  WaterSSTP();
124 
125  //! Full constructor for a water phase
126  /*!
127  * @param inputFile String name of the input file
128  * @param id string id of the phase name
129  */
130  explicit WaterSSTP(const std::string& inputFile, const std::string& id = "");
131 
132  //! Full constructor for a water phase
133  /*!
134  * @param phaseRef XML node referencing the water phase.
135  * @param id string id of the phase name
136  *
137  * @deprecated The XML input format is deprecated and will be removed in
138  * Cantera 3.0.
139  */
140  explicit WaterSSTP(XML_Node& phaseRef, const std::string& id = "");
141 
142  virtual std::string type() const {
143  return "liquid-water-IAPWS95";
144  }
145 
146  virtual std::string phaseOfMatter() const;
147 
148  //! @name Molar Thermodynamic Properties of the Solution
149  //! @{
150 
151  virtual doublereal cv_mole() const;
152 
153  //@}
154  /// @name Mechanical Equation of State Properties
155  //@{
156 
157  virtual doublereal pressure() const;
158  virtual void setPressure(doublereal p);
159  virtual doublereal isothermalCompressibility() const;
160  virtual doublereal thermalExpansionCoeff() const;
161 
162  //! Return the derivative of the volumetric thermal expansion coefficient.
163  //! Units: 1/K2.
164  virtual doublereal dthermalExpansionCoeffdT() const;
165 
166  //! @}
167  //! @name Properties of the Standard State of the Species in the Solution
168  //! @{
169 
170  virtual void getStandardChemPotentials(doublereal* gss) const;
171  virtual void getGibbs_RT(doublereal* grt) const;
172  virtual void getEnthalpy_RT(doublereal* hrt) const;
173  virtual void getEntropy_R(doublereal* sr) const;
174  virtual void getCp_R(doublereal* cpr) const;
175  virtual void getIntEnergy_RT(doublereal* urt) const;
176 
177  //@}
178  //! @name Thermodynamic Values for the Species Reference State
179  /*!
180  * All functions in this group need to be overridden, because the
181  * m_spthermo MultiSpeciesThermo function is not adequate for the real
182  * equation of state.
183  */
184  //@{
185 
186  virtual void getEnthalpy_RT_ref(doublereal* hrt) const;
187  virtual void getGibbs_RT_ref(doublereal* grt) const;
188  virtual void getGibbs_ref(doublereal* g) const;
189  virtual void getEntropy_R_ref(doublereal* er) const;
190  virtual void getCp_R_ref(doublereal* cprt) const;
191  virtual void getStandardVolumes_ref(doublereal* vol) const;
192  //! @}
193 
194  virtual doublereal critTemperature() const;
195  virtual doublereal critPressure() const;
196  virtual doublereal critDensity() const;
197 
198  virtual doublereal satPressure(doublereal t);
199 
200  virtual bool compatibleWithMultiPhase() const {
201  return false;
202  }
203 
204  //! Return the fraction of vapor at the current conditions
205  /*!
206  * Below Tcrit, this routine will always return 0, by definition of the
207  * functionality of the routine. Above Tcrit, we query the density to toggle
208  * between 0 and 1.
209  */
210  virtual doublereal vaporFraction() const;
211 
212  //! Set the temperature of the phase
213  /*!
214  * The density and composition of the phase is constant during this
215  * operator.
216  *
217  * @param temp Temperature (Kelvin)
218  */
219  virtual void setTemperature(const doublereal temp);
220 
221  //! Set the density of the phase
222  /*!
223  * The temperature and composition of the phase is constant during this
224  * operator.
225  *
226  * @param dens value of the density in kg m-3
227  */
228  virtual void setDensity(const doublereal dens);
229 
230  virtual void initThermo();
231  virtual void setParametersFromXML(const XML_Node& eosdata);
232 
233  //! Get a pointer to a changeable WaterPropsIAPWS object
235  return &m_sub;
236  }
237 
238  //! Get a pointer to a changeable WaterPropsIAPWS object
240  return m_waterProps.get();
241  }
242 
243  //! Switch that enables calculations in the gas phase
244  /**
245  * Since this phase represents a liquid (or supercritical) phase, it is an
246  * error to return a gas-phase answer. The sole intended use for this
247  * member function is to check the thermodynamic consistency of the
248  * underlying WaterProps class with ideal-gas thermo functions.
249  */
250  void _allowGasPhase(bool flag) { m_allowGasPhase = flag; }
251 
252 protected:
253  /**
254  * @internal This internal routine must be overridden because it is not
255  * applicable.
256  */
257  void _updateThermo() const;
258 
259 private:
260  //! WaterPropsIAPWS that calculates the real properties of water.
262 
263  //! Pointer to the WaterProps object
264  /*!
265  * This class is used to house several approximation routines for properties
266  * of water. This object owns m_waterProps, and the WaterPropsIAPWS object
267  * used by WaterProps is m_sub, which is defined above.
268  */
269  std::unique_ptr<WaterProps> m_waterProps;
270 
271  //! Molecular weight of Water -> Cantera assumption
272  doublereal m_mw;
273 
274  //! Offset constants used to obtain consistency with the NIST database.
275  /*!
276  * This is added to all internal energy and enthalpy results.
277  * units = J kmol-1.
278  */
279  doublereal EW_Offset;
280 
281  //! Offset constant used to obtain consistency with NIST convention.
282  /*!
283  * This is added to all internal entropy results.
284  * units = J kmol-1 K-1.
285  */
286  doublereal SW_Offset;
287 
288  //! Boolean is true if object has been properly initialized for calculation
289  bool m_ready;
290 
291  /**
292  * Since this phase represents a liquid (or supercritical) phase, it is an
293  * error to return a gas-phase answer. However, if the below is true, then
294  * a gas-phase answer is allowed. This is used to check the thermodynamic
295  * consistency with ideal-gas thermo functions for example.
296  */
298 };
299 
300 }
301 
302 #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:120
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:180
WaterSSTP()
Base constructor.
Definition: WaterSSTP.cpp:18
WaterPropsIAPWS m_sub
WaterPropsIAPWS that calculates the real properties of water.
Definition: WaterSSTP.h:261
bool m_ready
Boolean is true if object has been properly initialized for calculation.
Definition: WaterSSTP.h:289
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:134
virtual doublereal pressure() const
Return the thermodynamic pressure (Pa).
Definition: WaterSSTP.cpp:268
WaterProps * getWaterProps()
Get a pointer to a changeable WaterPropsIAPWS object.
Definition: WaterSSTP.h:239
virtual doublereal critPressure() const
Critical pressure (Pa).
Definition: WaterSSTP.cpp:329
doublereal EW_Offset
Offset constants used to obtain consistency with the NIST database.
Definition: WaterSSTP.h:279
virtual doublereal cv_mole() const
Molar heat capacity at constant volume. Units: J/kmol/K.
Definition: WaterSSTP.cpp:156
virtual doublereal vaporFraction() const
Return the fraction of vapor at the current conditions.
Definition: WaterSSTP.cpp:364
virtual bool compatibleWithMultiPhase() const
Indicates whether this phase type can be used with class MultiPhase for equilibrium calculations.
Definition: WaterSSTP.h:200
virtual doublereal thermalExpansionCoeff() const
Return the volumetric thermal expansion coefficient. Units: 1/K.
Definition: WaterSSTP.cpp:302
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:151
virtual doublereal dthermalExpansionCoeffdT() const
Return the derivative of the volumetric thermal expansion coefficient.
Definition: WaterSSTP.cpp:307
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:129
virtual void setPressure(doublereal p)
Set the internally stored pressure (Pa) at constant temperature and composition.
Definition: WaterSSTP.cpp:273
virtual void initThermo()
Initialize the ThermoPhase object after all species have been set up.
Definition: WaterSSTP.cpp:54
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:142
virtual doublereal critTemperature() const
Critical temperature (K).
Definition: WaterSSTP.cpp:324
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:208
virtual std::string type() const
String indicating the thermodynamic model implemented.
Definition: WaterSSTP.h:142
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:124
virtual void setTemperature(const doublereal temp)
Set the temperature of the phase.
Definition: WaterSSTP.cpp:339
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:230
virtual void setParametersFromXML(const XML_Node &eosdata)
Set equation of state parameter values from XML entries.
Definition: WaterSSTP.cpp:114
doublereal m_mw
Molecular weight of Water -> Cantera assumption.
Definition: WaterSSTP.h:272
WaterPropsIAPWS * getWater()
Get a pointer to a changeable WaterPropsIAPWS object.
Definition: WaterSSTP.h:234
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:250
virtual void setDensity(const doublereal dens)
Set the density of the phase.
Definition: WaterSSTP.cpp:350
void _allowGasPhase(bool flag)
Switch that enables calculations in the gas phase.
Definition: WaterSSTP.h:250
virtual doublereal satPressure(doublereal t)
Return the saturation pressure given the temperature.
Definition: WaterSSTP.cpp:356
doublereal SW_Offset
Offset constant used to obtain consistency with NIST convention.
Definition: WaterSSTP.h:286
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:297
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:200
std::unique_ptr< WaterProps > m_waterProps
Pointer to the WaterProps object.
Definition: WaterSSTP.h:269
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:119
virtual doublereal critDensity() const
Critical density (kg/m3).
Definition: WaterSSTP.cpp:334
virtual std::string phaseOfMatter() const
String indicating the mechanical phase of the matter in this Phase.
Definition: WaterSSTP.cpp:47
virtual void getEnthalpy_RT_ref(doublereal *hrt) const
Definition: WaterSSTP.cpp:161
virtual doublereal isothermalCompressibility() const
Returns the isothermal compressibility. Units: 1/Pa.
Definition: WaterSSTP.cpp:297
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:104
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:264