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