Cantera  2.3.0
PDSS_Water.h
Go to the documentation of this file.
1 /**
2  * @file PDSS_Water.h
3  * Implementation of a pressure dependent standard state
4  * virtual function for a Pure Water Phase
5  * (see \ref pdssthermo and class \link Cantera::PDSS_Water PDSS_Water\endlink).
6  */
7 
8 // This file is part of Cantera. See License.txt in the top-level directory or
9 // at http://www.cantera.org/license.txt for license and copyright information.
10 
11 #ifndef CT_PDSS_WATER_H
12 #define CT_PDSS_WATER_H
13 
14 #include "PDSS.h"
15 #include "WaterPropsIAPWS.h"
16 #include "WaterProps.h"
17 
18 namespace Cantera
19 {
20 //! Class for the liquid water pressure dependent
21 //! standard state
22 /*!
23  * Notes:
24  *
25  * Base state for thermodynamic properties:
26  *
27  * The thermodynamic base state for water is set to the NIST basis here by
28  * specifying constants EW_Offset and SW_Offset. These offsets are specified so
29  * that the following properties hold:
30  *
31  * Delta_Hfo_gas(298.15) = -241.826 kJ/gmol
32  * So_gas(298.15, 1bar) = 188.835 J/gmolK
33  *
34  * (http://webbook.nist.gov)
35  *
36  * The "o" here refers to a hypothetical ideal gas state. The way we achieve
37  * this in practice is to evaluate at a very low pressure and then use the
38  * theoretical ideal gas results to scale up to higher pressures:
39  *
40  * Ho(1bar) = H(P0)
41  *
42  * So(1bar) = S(P0) + RT ln(1bar/P0)
43  *
44  * The offsets used in the steam tables are different than NIST's. They assume
45  * u_liq(TP) = 0.0, s_liq(TP) = 0.0, where TP is the triple point conditions.
46  *
47  * @ingroup pdssthermo
48  */
49 class PDSS_Water : public PDSS_Molar
50 {
51 public:
52  //! @name Constructors
53  //! @{
54 
55  //! Bare constructor
56  /*!
57  * eliminate?
58  */
59  PDSS_Water();
60 
61  //! Constructor that initializes the object by examining the XML entries
62  //! from the ThermoPhase object
63  /*!
64  * This function calls the constructPDSS member function.
65  *
66  * @param tp Pointer to the ThermoPhase object pertaining to the phase
67  * @param spindex Species index of the species in the phase
68  */
69  PDSS_Water(VPStandardStateTP* tp, int spindex);
70 
71  //! Constructor that initializes the object by examining the input file
72  //! of the variable pressure ThermoPhase object
73  /*!
74  * This function calls the constructPDSSFile member function.
75  *
76  * @param tp Pointer to the variable pressure ThermoPhase object pertaining to the phase
77  * @param spindex Species index of the species in the phase
78  * @param inputFile String name of the input file
79  * @param id String name of the phase in the input file. The default
80  * is the empty string, in which case the first phase in the
81  * file is used.
82  * @deprecated To be removed after Cantera 2.3.
83  */
84  PDSS_Water(VPStandardStateTP* tp, int spindex,
85  const std::string& inputFile, const std::string& id = "");
86 
87  //! Constructor that initializes the object by examining the input file
88  //! of the variable pressure ThermoPhase object
89  /*!
90  * This function calls the constructPDSSXML member function.
91  *
92  * @param tp Pointer to the ThermoPhase object pertaining to the phase
93  * @param spindex Species index of the species in the phase
94  * @param speciesNode Reference to the species XML tree.
95  * @param phaseRef Reference to the XML tree containing the phase information.
96  * @param spInstalled Is the species already installed.
97  */
98  PDSS_Water(VPStandardStateTP* tp, int spindex, const XML_Node& speciesNode,
99  const XML_Node& phaseRef, bool spInstalled);
100 
101  PDSS_Water(const PDSS_Water& b);
102  PDSS_Water& operator=(const PDSS_Water& b);
103  virtual PDSS* duplMyselfAsPDSS() const;
104 
105  //! @}
106  //! @name Molar Thermodynamic Properties of the Species Standard State in the Solution
107  //! @{
108 
109  // See PDSS.h for documentation of functions overridden from Class PDSS
110 
111  virtual doublereal enthalpy_mole() const;
112  virtual doublereal intEnergy_mole() const;
113  virtual doublereal entropy_mole() const;
114  virtual doublereal gibbs_mole() const;
115  virtual doublereal cp_mole() const;
116  virtual doublereal cv_mole() const;
117  virtual doublereal molarVolume() const;
118  virtual doublereal density() const;
119 
120  //! @}
121  //! @name Properties of the Reference State of the Species in the Solution
122  //! @{
123 
124  //! Returns a reference pressure value that can be safely calculated by the
125  //! underlying real equation of state for water
126  /*!
127  * Note, this function is needed because trying to calculate a one atm value
128  * around the critical point will cause a crash
129  *
130  * @param temp Temperature (Kelvin)
131  */
132  doublereal pref_safe(doublereal temp) const;
133 
134  virtual doublereal gibbs_RT_ref() const;
135  virtual doublereal enthalpy_RT_ref() const;
136  virtual doublereal entropy_R_ref() const;
137  virtual doublereal cp_R_ref() const;
138  virtual doublereal molarVolume_ref() const;
139 
140  //! @}
141  //! @name Mechanical Equation of State Properties
142  //! @{
143 
144  virtual doublereal pressure() const;
145  virtual void setPressure(doublereal pres);
146  virtual void setTemperature(doublereal temp);
147  virtual void setState_TP(doublereal temp, doublereal pres);
148  virtual void setState_TR(doublereal temp, doublereal rho);
149 
150  //! Set the density of the water phase
151  /*!
152  * This is a non-virtual function because it specific to this object.
153  *
154  * @param dens Density of the water (kg/m3)
155  */
156  void setDensity(doublereal dens);
157 
158  virtual doublereal thermalExpansionCoeff() const;
159 
160  //! Return the derivative of the volumetric thermal expansion coefficient.
161  //! Units: 1/K2.
162  /*!
163  * The thermal expansion coefficient is defined as
164  * \f[
165  * \beta = \frac{1}{v}\left(\frac{\partial v}{\partial T}\right)_P
166  * \f]
167  */
168  virtual doublereal dthermalExpansionCoeffdT() const;
169 
170  //! Returns the isothermal compressibility. Units: 1/Pa.
171  /*!
172  * The isothermal compressibility is defined as
173  * \f[
174  * \kappa_T = -\frac{1}{v}\left(\frac{\partial v}{\partial P}\right)_T
175  * \f]
176  * or
177  * \f[
178  * \kappa_T = \frac{1}{\rho}\left(\frac{\partial \rho}{\partial P}\right)_T
179  * \f]
180  */
181  virtual doublereal isothermalCompressibility() const;
182 
183  //! @}
184  //! @name Miscellaneous properties of the standard state
185  //! @{
186 
187  virtual doublereal critTemperature() const;
188  virtual doublereal critPressure() const;
189  virtual doublereal critDensity() const;
190  virtual doublereal satPressure(doublereal t);
191 
192  //! Get a pointer to a changeable WaterPropsIAPWS object
194  return &m_sub;
195  }
196 
197  //! Get a pointer to a changeable WaterPropsIAPWS object
199  return &m_waterProps;
200  }
201 
202  //! @}
203  //! @name Initialization of the Object
204  //! @{
205 
206  //! Internal routine that initializes the underlying water model
207  void constructSet();
208 
209  //! Initialization of a PDSS object using an
210  //! input XML file.
211  /*!
212  * This routine is a precursor to constructPDSSXML(XML_Node*)
213  * routine, which does most of the work.
214  *
215  * @param vptp_ptr Pointer to the Variable pressure ThermoPhase object
216  * @param spindex Species index within the phase
217  * @param inputFile XML file containing the description of the phase
218  * @param id Optional parameter identifying the name of the
219  * phase. If none is given, the first XML
220  * phase element will be used.
221  * @deprecated To be removed after Cantera 2.3.
222  */
223  void constructPDSSFile(VPStandardStateTP* vptp_ptr, int spindex,
224  const std::string& inputFile, const std::string& id);
225 
226  //!Initialization of a PDSS object using an XML tree
227  /*!
228  * This routine is a driver for the initialization of the
229  * object.
230  *
231  * basic logic:
232  * - initThermo() (cascade)
233  * - getStuff from species Part of XML file
234  * - initThermoXML(phaseNode) (cascade)
235  *
236  * @param vptp_ptr Pointer to the Variable pressure ThermoPhase object
237  * @param spindex Species index within the phase
238  * @param phaseNode Reference to the phase Information for the phase
239  * that owns this species.
240  * @param id Optional parameter identifying the name of the
241  * phase. If none is given, the first XML
242  * phase element will be used.
243  */
244  void constructPDSSXML(VPStandardStateTP* vptp_ptr, int spindex,
245  const XML_Node& phaseNode, const std::string& id);
246  //@}
247 
248 private:
249  //! Pointer to the WaterPropsIAPWS object, which does the actual calculations
250  //! for the real equation of state
251  /*!
252  * This object owns m_sub
253  */
255 
256  //! Pointer to the WaterProps object
257  /*!
258  * This class is used to house several approximation
259  * routines for properties of water.
260  *
261  * This object owns m_waterProps, and the WaterPropsIAPWS object used by
262  * WaterProps is m_sub, which is defined above.
263  */
265 
266  //! State of the system - density
267  /*!
268  * Density is the independent variable here, but it's hidden behind the
269  * object's interface.
270  */
271  doublereal m_dens;
272 
273  //! state of the fluid
274  /*!
275  * @code
276  * 0 WATER_GAS
277  * 1 WATER_LIQUID
278  * 2 WATER_SUPERCRIT
279  * 3 WATER_UNSTABLELIQUID
280  * 4 WATER_UNSTABLEGAS
281  * @endcode
282  */
283  int m_iState;
284 
285  /**
286  * Offset constants used to obtain consistency with the NIST database.
287  * This is added to all internal energy and enthalpy results.
288  * units = J kmol-1.
289  */
290  doublereal EW_Offset;
291 
292  /**
293  * Offset constant used to obtain consistency with NIST convention.
294  * This is added to all internal entropy results.
295  * units = J kmol-1 K-1.
296  */
297  doublereal SW_Offset;
298 
299  //! Verbose flag - used?
300  bool m_verbose;
301 
302 public:
303  /**
304  * Since this phase represents a liquid phase, it's an error to
305  * return a gas-phase answer. However, if the below is true, then
306  * a gas-phase answer is allowed. This is used to check the thermodynamic
307  * consistency with ideal-gas thermo functions for example.
308  */
310 };
311 
312 }
313 
314 #endif
doublereal m_dens
State of the system - density.
Definition: PDSS_Water.h:271
virtual doublereal critPressure() const
critical pressure
Definition: PDSS_Water.cpp:337
virtual doublereal pressure() const
Returns the pressure (Pa)
Definition: PDSS_Water.cpp:273
void setDensity(doublereal dens)
Set the density of the water phase.
Definition: PDSS_Water.cpp:347
Class for calculating the equation of state of water.
virtual PDSS * duplMyselfAsPDSS() const
Duplication routine for objects which inherit from PDSS.
Definition: PDSS_Water.cpp:124
virtual doublereal critDensity() const
critical density
Definition: PDSS_Water.cpp:342
WaterPropsIAPWS m_sub
Pointer to the WaterPropsIAPWS object, which does the actual calculations for the real equation of st...
Definition: PDSS_Water.h:254
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:97
virtual doublereal cv_mole() const
Return the molar const volume heat capacity in units of J kmol-1 K-1.
Definition: PDSS_Water.cpp:218
Header for a class used to house several approximation routines for properties of water...
virtual doublereal cp_R_ref() const
Return the molar heat capacity divided by R at reference pressure.
Definition: PDSS_Water.cpp:255
void constructSet()
Internal routine that initializes the underlying water model.
Definition: PDSS_Water.cpp:158
void constructPDSSXML(VPStandardStateTP *vptp_ptr, int spindex, const XML_Node &phaseNode, const std::string &id)
Initialization of a PDSS object using an XML tree.
Definition: PDSS_Water.cpp:129
virtual doublereal isothermalCompressibility() const
Returns the isothermal compressibility. Units: 1/Pa.
Definition: PDSS_Water.cpp:327
Base class for PDSS classes which compute molar properties directly.
Definition: PDSS.h:652
void constructPDSSFile(VPStandardStateTP *vptp_ptr, int spindex, const std::string &inputFile, const std::string &id)
Initialization of a PDSS object using an input XML file.
Definition: PDSS_Water.cpp:135
WaterProps m_waterProps
Pointer to the WaterProps object.
Definition: PDSS_Water.h:264
Declarations for the virtual base class PDSS (pressure dependent standard state) which handles calcul...
virtual doublereal thermalExpansionCoeff() const
Return the volumetric thermal expansion coefficient. Units: 1/K.
Definition: PDSS_Water.cpp:306
bool m_verbose
Verbose flag - used?
Definition: PDSS_Water.h:300
The WaterProps class is used to house several approximation routines for properties of water...
Definition: WaterProps.h:93
virtual void setState_TP(doublereal temp, doublereal pres)
Set the internal temperature and pressure.
Definition: PDSS_Water.cpp:364
WaterPropsIAPWS * getWater()
Get a pointer to a changeable WaterPropsIAPWS object.
Definition: PDSS_Water.h:193
Class for the liquid water pressure dependent standard state.
Definition: PDSS_Water.h:49
virtual doublereal satPressure(doublereal t)
saturation pressure
Definition: PDSS_Water.cpp:390
WaterProps * getWaterProps()
Get a pointer to a changeable WaterPropsIAPWS object.
Definition: PDSS_Water.h:198
virtual doublereal entropy_R_ref() const
Return the molar entropy divided by R at reference pressure.
Definition: PDSS_Water.cpp:246
virtual doublereal entropy_mole() const
Return the molar entropy in units of J kmol-1 K-1.
Definition: PDSS_Water.cpp:203
doublereal pref_safe(doublereal temp) const
Returns a reference pressure value that can be safely calculated by the underlying real equation of s...
Definition: PDSS_Water.cpp:377
This is a filter class for ThermoPhase that implements some prepatory steps for efficiently handling ...
virtual doublereal molarVolume() const
Return the molar volume at standard state.
Definition: PDSS_Water.cpp:223
virtual doublereal cp_mole() const
Return the molar const pressure heat capacity in units of J kmol-1 K-1.
Definition: PDSS_Water.cpp:213
virtual doublereal dthermalExpansionCoeffdT() const
Return the derivative of the volumetric thermal expansion coefficient.
Definition: PDSS_Water.cpp:311
virtual void setState_TR(doublereal temp, doublereal rho)
Set the internal temperature and density.
Definition: PDSS_Water.cpp:370
int m_iState
state of the fluid
Definition: PDSS_Water.h:283
virtual void setTemperature(doublereal temp)
Set the internal temperature.
Definition: PDSS_Water.cpp:358
virtual doublereal gibbs_mole() const
Return the molar Gibbs free energy in units of J kmol-1.
Definition: PDSS_Water.cpp:208
virtual doublereal intEnergy_mole() const
Return the molar internal Energy in units of J kmol-1.
Definition: PDSS_Water.cpp:198
doublereal SW_Offset
Offset constant used to obtain consistency with NIST convention.
Definition: PDSS_Water.h:297
Virtual base class for a species with a pressure dependent standard state.
Definition: PDSS.h:176
virtual doublereal enthalpy_RT_ref() const
Return the molar enthalpy divided by RT at reference pressure.
Definition: PDSS_Water.cpp:237
virtual doublereal molarVolume_ref() const
Return the molar volume at reference pressure.
Definition: PDSS_Water.cpp:264
virtual doublereal critTemperature() const
critical temperature
Definition: PDSS_Water.cpp:332
virtual doublereal gibbs_RT_ref() const
Return the molar Gibbs free energy divided by RT at reference pressure.
Definition: PDSS_Water.cpp:228
virtual void setPressure(doublereal pres)
Sets the pressure in the object.
Definition: PDSS_Water.cpp:279
virtual doublereal density() const
Return the standard state density at standard state.
Definition: PDSS_Water.cpp:353
bool m_allowGasPhase
Since this phase represents a liquid phase, it's an error to return a gas-phase answer.
Definition: PDSS_Water.h:309
Namespace for the Cantera kernel.
Definition: application.cpp:29
doublereal EW_Offset
Offset constants used to obtain consistency with the NIST database.
Definition: PDSS_Water.h:290
PDSS_Water()
Bare constructor.
Definition: PDSS_Water.cpp:15
virtual doublereal enthalpy_mole() const
Return the molar enthalpy in units of J kmol-1.
Definition: PDSS_Water.cpp:193
Headers for a class for calculating the equation of state of water from the IAPWS 1995 Formulation ba...