Cantera  2.3.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  WaterSSTP(const WaterSSTP&);
121  WaterSSTP& operator=(const WaterSSTP&);
122  virtual ThermoPhase* duplMyselfAsThermoPhase() const;
123 
124  //! Full constructor for a water phase
125  /*!
126  * @param inputFile String name of the input file
127  * @param id string id of the phase name
128  */
129  explicit WaterSSTP(const std::string& inputFile, const std::string& id = "");
130 
131  //! Full constructor for a water phase
132  /*!
133  * @param phaseRef XML node referencing the water phase.
134  * @param id string id of the phase name
135  */
136  explicit WaterSSTP(XML_Node& phaseRef, const std::string& id = "");
137 
138  virtual int eosType() const {
139  warn_deprecated("WaterSSTP::eosType",
140  "To be removed after Cantera 2.3.");
141  return -1;
142  }
143  virtual std::string type() const {
144  return "Water";
145  }
146 
147  //! @name Molar Thermodynamic Properties of the Solution
148  //! @{
149 
150  virtual doublereal cv_mole() const;
151 
152  //@}
153  /// @name Mechanical Equation of State Properties
154  //@{
155 
156  virtual doublereal pressure() const;
157  virtual void setPressure(doublereal p);
158  virtual doublereal isothermalCompressibility() const;
159  virtual doublereal thermalExpansionCoeff() const;
160 
161  //! Return the derivative of the volumetric thermal expansion coefficient.
162  //! Units: 1/K2.
163  virtual doublereal dthermalExpansionCoeffdT() const;
164 
165  //! @}
166  //! @name Properties of the Standard State of the Species in the Solution
167  //! @{
168 
169  virtual void getStandardChemPotentials(doublereal* gss) const;
170  virtual void getGibbs_RT(doublereal* grt) const;
171  virtual void getEnthalpy_RT(doublereal* hrt) const;
172  virtual void getEntropy_R(doublereal* sr) const;
173  virtual void getCp_R(doublereal* cpr) const;
174  virtual void getIntEnergy_RT(doublereal* urt) const;
175 
176  //@}
177  //! @name Thermodynamic Values for the Species Reference State
178  /*!
179  * All functions in this group need to be overridden, because the
180  * m_spthermo MultiSpeciesThermo function is not adequate for the real
181  * equation of state.
182  */
183  //@{
184 
185  virtual void getEnthalpy_RT_ref(doublereal* hrt) const;
186  virtual void getGibbs_RT_ref(doublereal* grt) const;
187  virtual void getGibbs_ref(doublereal* g) const;
188  virtual void getEntropy_R_ref(doublereal* er) const;
189  virtual void getCp_R_ref(doublereal* cprt) const;
190  virtual void getStandardVolumes_ref(doublereal* vol) const;
191  //! @}
192 
193  virtual doublereal critTemperature() const;
194  virtual doublereal critPressure() const;
195  virtual doublereal critDensity() const;
196 
197  virtual doublereal satPressure(doublereal t);
198 
199  virtual bool compatibleWithMultiPhase() const {
200  return false;
201  }
202 
203  //! Return the fraction of vapor at the current conditions
204  /*!
205  * Below Tcrit, this routine will always return 0, by definition of the
206  * functionality of the routine. Above Tcrit, we query the density to toggle
207  * between 0 and 1.
208  */
209  virtual doublereal vaporFraction() const;
210 
211  //! Set the temperature of the phase
212  /*!
213  * The density and composition of the phase is constant during this
214  * operator.
215  *
216  * @param temp Temperature (Kelvin)
217  */
218  virtual void setTemperature(const doublereal temp);
219 
220  //! Set the density of the phase
221  /*!
222  * The temperature and composition of the phase is constant during this
223  * operator.
224  *
225  * @param dens value of the density in kg m-3
226  */
227  virtual void setDensity(const doublereal dens);
228 
229  virtual void initThermoXML(XML_Node& phaseNode, const std::string& id);
230  virtual void setParametersFromXML(const XML_Node& eosdata);
231 
232  //! Get a pointer to a changeable WaterPropsIAPWS object
234  return &m_sub;
235  }
236 
237  //! Get a pointer to a changeable WaterPropsIAPWS object
239  return m_waterProps.get();
240  }
241 
242 protected:
243  /**
244  * @internal This internal routine must be overridden because it is not
245  * applicable.
246  */
247  void _updateThermo() const;
248 
249 private:
250  //! WaterPropsIAPWS that calculates the real properties of water.
252 
253  //! Pointer to the WaterProps object
254  /*!
255  * This class is used to house several approximation routines for properties
256  * of water. This object owns m_waterProps, and the WaterPropsIAPWS object
257  * used by WaterProps is m_sub, which is defined above.
258  */
259  std::unique_ptr<WaterProps> m_waterProps;
260 
261  //! Molecular weight of Water -> Cantera assumption
262  doublereal m_mw;
263 
264  //! Offset constants used to obtain consistency with the NIST database.
265  /*!
266  * This is added to all internal energy and enthalpy results.
267  * units = J kmol-1.
268  */
269  doublereal EW_Offset;
270 
271  //! Offset constant used to obtain consistency with NIST convention.
272  /*!
273  * This is added to all internal entropy results.
274  * units = J kmol-1 K-1.
275  */
276  doublereal SW_Offset;
277 
278  //! Boolean is true if object has been properly initialized for calculation
279  bool m_ready;
280 
281  /**
282  * Since this phase represents a liquid phase, it's an error to
283  * return a gas-phase answer. However, if the below is true, then
284  * a gas-phase answer is allowed. This is used to check the thermodynamic
285  * consistency with ideal-gas thermo functions for example.
286  */
288 };
289 
290 }
291 
292 #endif
virtual void getEnthalpy_RT_ref(doublereal *hrt) const
Definition: WaterSSTP.cpp:194
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:184
virtual doublereal cv_mole() const
Molar heat capacity at constant volume. Units: J/kmol/K.
Definition: WaterSSTP.cpp:189
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:153
WaterProps * getWaterProps()
Get a pointer to a changeable WaterPropsIAPWS object.
Definition: WaterSSTP.h:238
virtual doublereal critPressure() const
Critical pressure (Pa).
Definition: WaterSSTP.cpp:354
virtual doublereal isothermalCompressibility() const
Returns the isothermal compressibility. Units: 1/Pa.
Definition: WaterSSTP.cpp:322
virtual void setDensity(const doublereal dens)
Set the density of the phase.
Definition: WaterSSTP.cpp:370
virtual ThermoPhase * duplMyselfAsThermoPhase() const
Duplication routine for objects which inherit from ThermoPhase.
Definition: WaterSSTP.cpp:76
virtual void setPressure(doublereal p)
Set the internally stored pressure (Pa) at constant temperature and composition.
Definition: WaterSSTP.cpp:306
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:199
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:301
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
Definition: global.cpp:54
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:241
virtual void setParametersFromXML(const XML_Node &eosdata)
Set equation of state parameter values from XML entries.
Definition: WaterSSTP.cpp:148
WaterSSTP()
Base constructor.
Definition: WaterSSTP.cpp:18
WaterPropsIAPWS m_sub
WaterPropsIAPWS that calculates the real properties of water.
Definition: WaterSSTP.h:251
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:283
virtual std::string type() const
String indicating the thermodynamic model implemented.
Definition: WaterSSTP.h:143
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:93
virtual doublereal critDensity() const
Critical density (kg/m3).
Definition: WaterSSTP.cpp:359
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id)
Import and initialize a ThermoPhase object using an XML tree.
Definition: WaterSSTP.cpp:81
doublereal EW_Offset
Offset constants used to obtain consistency with the NIST database.
Definition: WaterSSTP.h:269
WaterPropsIAPWS * getWater()
Get a pointer to a changeable WaterPropsIAPWS object.
Definition: WaterSSTP.h:233
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:176
virtual doublereal vaporFraction() const
Return the fraction of vapor at the current conditions.
Definition: WaterSSTP.cpp:384
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:163
The WaterProps class is used to house several approximation routines for properties of water...
Definition: WaterProps.h:93
doublereal m_mw
Molecular weight of Water -> Cantera assumption.
Definition: WaterSSTP.h:262
virtual doublereal critTemperature() const
Critical temperature (K).
Definition: WaterSSTP.cpp:349
virtual doublereal dthermalExpansionCoeffdT() const
Return the derivative of the volumetric thermal expansion coefficient.
Definition: WaterSSTP.cpp:332
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:376
virtual doublereal thermalExpansionCoeff() const
Return the volumetric thermal expansion coefficient. Units: 1/K.
Definition: WaterSSTP.cpp:327
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:213
virtual void setTemperature(const doublereal temp)
Set the temperature of the phase.
Definition: WaterSSTP.cpp:364
virtual int eosType() const
Returns the equation of state type flag.
Definition: WaterSSTP.h:138
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:233
doublereal SW_Offset
Offset constant used to obtain consistency with NIST convention.
Definition: WaterSSTP.h:276
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:263
Namespace for the Cantera kernel.
Definition: application.cpp:29
std::unique_ptr< WaterProps > m_waterProps
Pointer to the WaterProps object.
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:168
bool m_allowGasPhase
Since this phase represents a liquid phase, it&#39;s an error to return a gas-phase answer.
Definition: WaterSSTP.h:287
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:158
bool m_ready
Boolean is true if object has been properly initialized for calculation.
Definition: WaterSSTP.h:279
Headers for a class for calculating the equation of state of water from the IAPWS 1995 Formulation ba...