Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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  * Copyright (2006) Sandia Corporation. Under the terms of
8  * Contract DE-AC04-94AL85000 with Sandia Corporation, the
9  * U.S. Government retains certain rights in this software.
10  */
11 #ifndef CT_WATERSSTP_H
12 #define CT_WATERSSTP_H
13 
14 #include "SingleSpeciesTP.h"
15 
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
23 //! liquid part of water.
24 /*!
25  * The reference is W. Wagner, A. Prub, "The IAPWS Formulation 1995 for the Thermodynamic
26  * Properties of Ordinary Water Substance for General and Scientific Use,"
27  * J. Phys. Chem. Ref. Dat, 31, 387, 2002.
28  *
29  * <HR>
30  * <H2> Specification of Species Standard State Properties </H2>
31  * <HR>
32  *
33  * The offsets used in the steam tables are different than NIST's.
34  * They assume u_liq(TP) = 0.0, s_liq(TP) = 0.0, where TP is the
35  * triple point conditions:
36  *
37  * - u(273.16, rho) = 0.0
38  * - s(273.16, rho) = 0.0
39  * - psat(273.16) = 611.655 Pascal
40  * - rho(273.16, psat) = 999.793 kg m-3
41  *
42  * These "steam table" assumptions are used by the WaterPropsIAPWS class.
43  * Therefore, offsets must be calculated to make the thermodynamic
44  * properties calculated within this class to be consistent with
45  * thermo properties within Cantera.
46  *
47  * The thermodynamic base state for water is set to the NIST basis here
48  * by specifying constants, #EW_Offset and #SW_Offset, one for energy
49  * quantities and one for entropy quantities. The offsets are
50  * specified so that the following properties hold:
51  *
52  * - Delta_Hfo_idealgas(298.15) = -241.826 kJ/gmol
53  * - So_idealgas(298.15, 1bar) = 188.835 J/gmolK
54  *
55  * (From http://webbook.nist.gov)
56  *
57  * The "o" here refers to a hypothetical ideal gas state. The way
58  * we achieve this in practice is to evaluate at a very low pressure
59  * and then use the theoretical ideal gas results to scale up to
60  * higher pressures:
61  *
62  * Ho(1bar) = H(P0)
63  *
64  * So(1bar) = S(P0) + RT ln(1bar/P0)
65  *
66  * <HR>
67  * <H2> %Application within Kinetics Managers </H2>
68  * <HR>
69  *
70  * This is unimplemented.
71  *
72  * <HR>
73  * <H2> Instantiation of the Class </H2>
74  * <HR>
75  *
76  * The constructor for this phase is NOT located in the default ThermoFactory
77  * for %Cantera. However, a new WaterSSTP object may be created by
78  * the following code snippets, combined with an XML file given in the
79  * XML example section.
80  *
81  * @code
82  * WaterSSTP *w = new WaterSSTP("waterSSTPphase.xml","");
83  * @endcode
84  *
85  * or
86  *
87  * @code
88  * XML_Node *xm = get_XML_NameID("phase", "waterSSTPphase.xml#water", 0);
89  * WaterSSTP *w = new WaterSSTP(*xm);
90  * @endcode
91  *
92  * or by the following call to importPhase():
93  *
94  * @code
95  * XML_Node *xm = get_XML_NameID("phase", "waterSSTPphase.xml#water", 0);
96  * WaterSSTP water;
97  * importPhase(*xm, &water);
98  * @endcode
99  *
100  * <HR>
101  * <H2> XML Example </H2>
102  * <HR>
103  *
104  * An example of an XML Element named phase setting up a WaterSSTP object with
105  * id "water" is given below.
106  *
107  * @code
108  * <!-- phase water -->
109  * <phase dim="3" id="water">
110  * <elementArray datasrc="elements.xml">O H </elementArray>
111  * <speciesArray datasrc="#species_data">H2O</speciesArray>
112  * <state>
113  * <temperature units="K">300.0</temperature>
114  * <pressure units="Pa">101325.0</pressure>
115  * </state>
116  * <thermo model="PureLiquidWater"/>
117  * <kinetics model="none"/>
118  * </phase>
119  * @endcode
120  *
121  * Note the model "PureLiquidWater" indicates the usage of the WaterSSTP object.
122  *
123  * @ingroup thermoprops
124  */
126 {
127 public:
128  //! Base constructor
129  WaterSSTP();
130 
131  //! Copy constructor
132  WaterSSTP(const WaterSSTP&);
133 
134  //! Assignment operator
135  WaterSSTP& operator=(const WaterSSTP&);
136 
137  //! Full constructor for a water phase
138  /*!
139  * @param inputFile String name of the input file
140  * @param id string id of the phase name
141  */
142  explicit WaterSSTP(const std::string& inputFile, const std::string& id = "");
143 
144  //! Full constructor for a water phase
145  /*!
146  * @param phaseRef XML node referencing the water phase.
147  * @param id string id of the phase name
148  */
149  explicit WaterSSTP(XML_Node& phaseRef, const std::string& id = "");
150 
151  //! Destructor
152  virtual ~WaterSSTP();
153 
154  //! Duplicator from a ThermoPhase object
156 
157  virtual int eosType() const {
158  return -1;
159  }
160 
161  //! @name Molar Thermodynamic Properties of the Solution
162  //! @{
163 
164  virtual doublereal cv_mole() const;
165 
166  //@}
167  /// @name Mechanical Equation of State Properties
168  //@{
169 
170  virtual doublereal pressure() const;
171  virtual void setPressure(doublereal p);
172 
173  //! Returns the isothermal compressibility. Units: 1/Pa.
174  /*!
175  * The isothermal compressibility is defined as
176  * \f[
177  * \kappa_T = -\frac{1}{v}\left(\frac{\partial v}{\partial P}\right)_T
178  * \f]
179  * or
180  * \f[
181  * \kappa_T = \frac{1}{\rho}\left(\frac{\partial \rho}{\partial P}\right)_T
182  * \f]
183  */
184  virtual doublereal isothermalCompressibility() const;
185 
186  //! Return the volumetric thermal expansion coefficient. Units: 1/K.
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 thermalExpansionCoeff() const;
194 
195  //! Return the derivative of the volumetric thermal expansion coefficient. Units: 1/K2.
196  /*!
197  * The thermal expansion coefficient is defined as
198  * \f[
199  * \beta = \frac{1}{v}\left(\frac{\partial v}{\partial T}\right)_P
200  * \f]
201  */
202  virtual doublereal dthermalExpansionCoeffdT() const;
203 
204  //! @}
205  //! @name Properties of the Standard State of the Species in the Solution
206  //! @{
207 
208  //! Get the Gibbs function for the species
209  //! standard states at the current T and P of the solution.
210  /*!
211  * @param gss Vector of length m_kk, which on return
212  * will contain the
213  * standard state Gibbs function for species <I>k</I>.
214  */
215  virtual void getStandardChemPotentials(doublereal* gss) const;
216 
217  //!Get the nondimensional Gibbs function for the species
218  //! standard states at the current T and P of the solution.
219  /*!
220  * @param grt Vector of length m_kk, which on return
221  * will contain the nondimensional
222  * standard state Gibbs function for species <I>k</I>
223  */
224  virtual void getGibbs_RT(doublereal* grt) const;
225 
226  //! Get the array of nondimensional Enthalpy functions for the standard state species
227  //! at the current <I>T</I> and <I>P</I> of the solution.
228  /*!
229  * @param hrt Vector of length m_kk, which on return
230  * will contain the nondimensional
231  * standard state enthalpy of species <I>k</I>
232  */
233  void getEnthalpy_RT(doublereal* hrt) const;
234 
235  //! Get the nondimensional Entropies for the species
236  //! standard states at the current T and P of the solution.
237  /*!
238  * @param sr Vector of length m_kk, which on return
239  * will contain the nondimensional
240  * standard state entropy for species<I>k</I>
241  */
242  void getEntropy_R(doublereal* sr) const;
243 
244  //! Get the nondimensional heat capacity at constant pressure
245  //! function for the species standard states at the current T and P of the solution.
246  /*!
247  * @param cpr Vector of length m_kk, which on return
248  * will contain the nondimensional
249  * constant pressure heat capacity for species <I>k</I>
250  */
251  virtual void getCp_R(doublereal* cpr) const;
252 
253  //! Returns the vector of nondimensional
254  //! internal Energies of the standard state at the current
255  //! temperature and pressure of the solution for each species.
256  /*!
257  * @param urt Output vector of standard state nondimensional internal energies.
258  * Length: m_kk.
259  */
260  virtual void getIntEnergy_RT(doublereal* urt) const;
261 
262  //@}
263  //! @name Thermodynamic Values for the Species Reference State
264  /*!
265  * All functions in this group need to be overrided, because
266  * the m_spthermo SpeciesThermo function is not adequate for
267  * the real equation of state.
268  */
269  //@{
270 
271  //! Returns the vector of nondimensional
272  //! enthalpies of the reference state at the current temperature
273  //! of the solution and the reference pressure for the species.
274  /*!
275  * @param hrt Output vector containing the nondimensional reference state enthalpies
276  * Length: m_kk.
277  */
278  virtual void getEnthalpy_RT_ref(doublereal* hrt) const;
279 
280  /*!
281  * Returns the vector of nondimensional
282  * enthalpies of the reference state at the current temperature
283  * of the solution and the reference pressure for the species.
284  *
285  * @param grt Output vector containing the nondimensional reference state
286  * Gibbs Free energies. Length: m_kk.
287  */
288  virtual void getGibbs_RT_ref(doublereal* grt) const;
289 
290  /*!
291  * Returns the vector of the Gibbs function of the reference state at the
292  * current temperature of the solution and the reference pressure for the
293  * species. units = J/kmol
294  *
295  * @param g Output vector containing the reference state
296  * Gibbs Free energies. Length: m_kk. Units: J/kmol.
297  */
298  virtual void getGibbs_ref(doublereal* g) const;
299 
300  /*!
301  * Returns the vector of nondimensional
302  * entropies of the reference state at the current temperature
303  * of the solution and the reference pressure for each species.
304  *
305  * @param er Output vector containing the nondimensional reference state
306  * entropies. Length: m_kk.
307  */
308  virtual void getEntropy_R_ref(doublereal* er) const;
309 
310  /*!
311  * Returns the vector of nondimensional
312  * constant pressure heat capacities of the reference state
313  * at the current temperature of the solution
314  * and reference pressure for each species.
315  *
316  * @param cprt Output vector of nondimensional reference state
317  * heat capacities at constant pressure for the species.
318  * Length: m_kk
319  */
320  virtual void getCp_R_ref(doublereal* cprt) const;
321 
322  //! Get the molar volumes of the species reference states at the current
323  //! <I>T</I> and <I>P_ref</I> of the solution.
324  /*!
325  * units = m^3 / kmol
326  *
327  * @param vol Output vector containing the standard state volumes.
328  * Length: m_kk.
329  */
330  virtual void getStandardVolumes_ref(doublereal* vol) const;
331  //! @}
332 
333  /// critical temperature
334  virtual doublereal critTemperature() const;
335 
336  /// critical pressure
337  virtual doublereal critPressure() const;
338 
339  /// critical density
340  virtual doublereal critDensity() const;
341 
342  /// saturation pressure
343  /*!
344  * @param t Temperature (kelvin)
345  */
346  virtual doublereal satPressure(doublereal t);
347 
348  //! Return the fraction of vapor at the current conditions
349  /*!
350  * Below Tcrit, this routine will always return 0, by definition
351  * of the functionality of the routine. Above Tcrit, we query
352  * the density to toggle between 0 and 1.
353  */
354  virtual doublereal vaporFraction() const;
355 
356  //! Set the temperature of the phase
357  /*!
358  * The density and composition of the phase is constant during this
359  * operator.
360  *
361  * @param temp Temperature (Kelvin)
362  */
363  virtual void setTemperature(const doublereal temp);
364 
365  //! Set the density of the phase
366  /*!
367  * The temperature and composition of the phase is constant during this
368  * operator.
369  *
370  * @param dens value of the density in kg m-3
371  */
372  virtual void setDensity(const doublereal dens);
373 
374  //!Import and initialize a ThermoPhase object using an XML tree.
375  /*!
376  * @internal
377  *
378  * Here we read extra information about the XML description
379  * of a phase. Regular information about elements and species
380  * and their reference state thermodynamic information
381  * have already been read at this point.
382  * For example, we do not need to call this function for
383  * ideal gas equations of state. This function is called from importPhase()
384  * after the elements and the species are initialized with
385  * default ideal solution level data.
386  *
387  * The default implementation in ThermoPhase calls the
388  * virtual function initThermo() and then sets the "state" of the
389  * phase by looking for an XML element named "state", and then
390  * interpreting its contents by calling the virtual function
391  * setStateFromXML().
392  *
393  * @param phaseNode This object must be the phase node of a
394  * complete XML tree
395  * description of the phase, including all of the
396  * species data. In other words while "phase" must
397  * point to an XML phase object, it must have
398  * sibling nodes "speciesData" that describe
399  * the species in the phase.
400  * @param id ID of the phase. If nonnull, a check is done
401  * to see if phaseNode is pointing to the phase
402  * with the correct id.
403  */
404  virtual void initThermoXML(XML_Node& phaseNode, const std::string& id);
405 
406  //! Set equation of state parameter values from XML entries.
407  /*!
408  * This method is called by function importPhase() when processing a phase
409  * definition in an input file. It should be overloaded in subclasses to set
410  * any parameters that are specific to that particular phase
411  * model. Note, this method is called before the phase is
412  * initialized with elements and/or species.
413  *
414  * @param eosdata An XML_Node object corresponding to
415  * the "thermo" entry for this phase in the input file.
416  */
417  virtual void setParametersFromXML(const XML_Node& eosdata);
418 
419  //! Get a pointer to a changeable WaterPropsIAPWS object
421  return m_sub;
422  }
423 
424  //! Get a pointer to a changeable WaterPropsIAPWS object
426  return m_waterProps;
427  }
428 
429 protected:
430  /**
431  * @internal
432  * This internal routine must be overwritten because
433  * it is not applicable.
434  */
435  void _updateThermo() const;
436 
437 private:
438  //! Pointer to the WaterPropsIAPWS that calculates the real properties
439  //! of water.
441 
442  //! Pointer to the WaterProps object
443  /*!
444  * This class is used to house several approximation
445  * routines for properties of water.
446  *
447  * This object owns m_waterProps, and the WaterPropsIAPWS object used by
448  * WaterProps is m_sub, which is defined above.
449  */
451 
452  //! Molecular weight of Water -> Cantera assumption
453  doublereal m_mw;
454 
455  //! Offset constants used to obtain consistency with the NIST database.
456  /*!
457  * This is added to all internal energy and enthalpy results.
458  * units = J kmol-1.
459  */
460  doublereal EW_Offset;
461 
462  //! Offset constant used to obtain consistency with NIST convention.
463  /*!
464  * This is added to all internal entropy results.
465  * units = J kmol-1 K-1.
466  */
467  doublereal SW_Offset;
468 
469  //! Boolean is true if object has been properly initialized for calculation
470  bool m_ready;
471 
472  /**
473  * Since this phase represents a liquid phase, it's an error to
474  * return a gas-phase answer. However, if the below is true, then
475  * a gas-phase answer is allowed. This is used to check the thermodynamic
476  * consistency with ideal-gas thermo functions for example.
477  */
479 };
480 
481 }
482 
483 #endif
virtual void getEntropy_R_ref(doublereal *er) const
Definition: WaterSSTP.cpp:289
virtual void getStandardChemPotentials(doublereal *gss) const
Get the Gibbs function for the species standard states at the current T and P of the solution...
Definition: WaterSSTP.cpp:222
WaterProps * getWaterProps()
Get a pointer to a changeable WaterPropsIAPWS object.
Definition: WaterSSTP.h:425
virtual void setDensity(const doublereal dens)
Set the density of the phase.
Definition: WaterSSTP.cpp:419
virtual doublereal pressure() const
Return the thermodynamic pressure (Pa).
Definition: WaterSSTP.cpp:350
virtual void setPressure(doublereal p)
Set the internally stored pressure (Pa) at constant temperature and composition.
Definition: WaterSSTP.cpp:355
Class for calculating the equation of state of water.
virtual ~WaterSSTP()
Destructor.
Definition: WaterSSTP.cpp:100
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:100
virtual void getGibbs_RT(doublereal *grt) const
Get the nondimensional Gibbs function for the species standard states at the current T and P of the s...
Definition: WaterSSTP.cpp:213
WaterProps * m_waterProps
Pointer to the WaterProps object.
Definition: WaterSSTP.h:450
virtual void setParametersFromXML(const XML_Node &eosdata)
Set equation of state parameter values from XML entries.
Definition: WaterSSTP.cpp:193
WaterSSTP()
Base constructor.
Definition: WaterSSTP.cpp:22
virtual void getEnthalpy_RT_ref(doublereal *hrt) const
Returns the vector of nondimensional enthalpies of the reference state at the current temperature of ...
Definition: WaterSSTP.cpp:240
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:97
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id)
Import and initialize a ThermoPhase object using an XML tree.
Definition: WaterSSTP.cpp:106
virtual doublereal cv_mole() const
Molar heat capacity at constant volume. Units: J/kmol/K.
Definition: WaterSSTP.cpp:235
doublereal EW_Offset
Offset constants used to obtain consistency with the NIST database.
Definition: WaterSSTP.h:460
virtual doublereal thermalExpansionCoeff() const
Return the volumetric thermal expansion coefficient. Units: 1/K.
Definition: WaterSSTP.cpp:376
WaterPropsIAPWS * getWater()
Get a pointer to a changeable WaterPropsIAPWS object.
Definition: WaterSSTP.h:420
virtual doublereal critTemperature() const
critical temperature
Definition: WaterSSTP.cpp:398
The WaterProps class is used to house several approximation routines for properties of water...
Definition: WaterProps.h:96
doublereal m_mw
Molecular weight of Water -> Cantera assumption.
Definition: WaterSSTP.h:453
virtual void getIntEnergy_RT(doublereal *urt) const
Returns the vector of nondimensional internal Energies of the standard state at the current temperatu...
Definition: WaterSSTP.cpp:203
virtual int eosType() const
Returns the equation of state type flag.
Definition: WaterSSTP.h:157
WaterSSTP & operator=(const WaterSSTP &)
Assignment operator.
Definition: WaterSSTP.cpp:77
virtual doublereal critDensity() const
critical density
Definition: WaterSSTP.cpp:408
Class for single-component water.
Definition: WaterSSTP.h:125
WaterPropsIAPWS * m_sub
Pointer to the WaterPropsIAPWS that calculates the real properties of water.
Definition: WaterSSTP.h:440
Header for the SingleSpeciesTP class, which is a filter class for ThermoPhase, that eases the constru...
virtual doublereal satPressure(doublereal t)
saturation pressure
Definition: WaterSSTP.cpp:425
virtual doublereal isothermalCompressibility() const
Returns the isothermal compressibility. Units: 1/Pa.
Definition: WaterSSTP.cpp:371
void _updateThermo() const
virtual void setTemperature(const doublereal temp)
Set the temperature of the phase.
Definition: WaterSSTP.cpp:413
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:332
void getEntropy_R(doublereal *sr) const
Get the nondimensional Entropies for the species standard states at the current T and P of the soluti...
Definition: WaterSSTP.cpp:208
doublereal SW_Offset
Offset constant used to obtain consistency with NIST convention.
Definition: WaterSSTP.h:467
void getEnthalpy_RT(doublereal *hrt) const
Get the array of nondimensional Enthalpy functions for the standard state species at the current T an...
Definition: WaterSSTP.cpp:198
virtual void getCp_R(doublereal *cpr) const
Get the nondimensional heat capacity at constant pressure function for the species standard states at...
Definition: WaterSSTP.cpp:230
virtual void getCp_R_ref(doublereal *cprt) const
Definition: WaterSSTP.cpp:312
bool m_allowGasPhase
Since this phase represents a liquid phase, it's an error to return a gas-phase answer.
Definition: WaterSSTP.h:478
virtual doublereal critPressure() const
critical pressure
Definition: WaterSSTP.cpp:403
virtual void getGibbs_RT_ref(doublereal *grt) const
Definition: WaterSSTP.cpp:259
The SingleSpeciesTP class is a filter class for ThermoPhase.
virtual doublereal dthermalExpansionCoeffdT() const
Return the derivative of the volumetric thermal expansion coefficient. Units: 1/K2.
Definition: WaterSSTP.cpp:381
ThermoPhase * duplMyselfAsThermoPhase() const
Duplicator from a ThermoPhase object.
Definition: WaterSSTP.cpp:95
virtual doublereal vaporFraction() const
Return the fraction of vapor at the current conditions.
Definition: WaterSSTP.cpp:433
virtual void getGibbs_ref(doublereal *g) const
Definition: WaterSSTP.cpp:280
bool m_ready
Boolean is true if object has been properly initialized for calculation.
Definition: WaterSSTP.h:470