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