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