Cantera  2.1.2
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  //! Initialize the ThermoPhase object after all species have been set up
407  /*!
408  * @internal Initialize.
409  *
410  * This method is provided to allow
411  * subclasses to perform any initialization required after all
412  * species have been added. For example, it might be used to
413  * resize internal work arrays that must have an entry for
414  * each species. The base class implementation does nothing,
415  * and subclasses that do not require initialization do not
416  * need to overload this method. When importing a CTML phase
417  * description, this method is called from ThermoPhase::initThermoXML(),
418  * which is called from importPhase(),
419  * just prior to returning from function importPhase().
420  *
421  * @see importCTML.cpp
422  */
423  virtual void initThermo();
424 
425  //! Set equation of state parameter values from XML entries.
426  /*!
427  * This method is called by function importPhase() in
428  * file importCTML.cpp when processing a phase definition in
429  * an input file. It should be overloaded in subclasses to set
430  * any parameters that are specific to that particular phase
431  * model. Note, this method is called before the phase is
432  * initialized with elements and/or species.
433  *
434  * @param eosdata An XML_Node object corresponding to
435  * the "thermo" entry for this phase in the input file.
436  */
437  virtual void setParametersFromXML(const XML_Node& eosdata);
438 
439  //! Get a pointer to a changeable WaterPropsIAPWS object
441  return m_sub;
442  }
443 
444  //! Get a pointer to a changeable WaterPropsIAPWS object
446  return m_waterProps;
447  }
448 
449 protected:
450  /**
451  * @internal
452  * This internal routine must be overwritten because
453  * it is not applicable.
454  */
455  void _updateThermo() const;
456 
457 private:
458  //! Pointer to the WaterPropsIAPWS that calculates the real properties
459  //! of water.
461 
462  //! Pointer to the WaterProps object
463  /*!
464  * This class is used to house several approximation
465  * routines for properties of water.
466  *
467  * This object owns m_waterProps, and the WaterPropsIAPWS object used by
468  * WaterProps is m_sub, which is defined above.
469  */
471 
472  //! Molecular weight of Water -> Cantera assumption
473  doublereal m_mw;
474 
475  //! Offset constants used to obtain consistency with the NIST database.
476  /*!
477  * This is added to all internal energy and enthalpy results.
478  * units = J kmol-1.
479  */
480  doublereal EW_Offset;
481 
482  //! Offset constant used to obtain consistency with NIST convention.
483  /*!
484  * This is added to all internal entropy results.
485  * units = J kmol-1 K-1.
486  */
487  doublereal SW_Offset;
488 
489  //! Boolean is true if object has been properly initialized for calculation
490  bool m_ready;
491 
492  /**
493  * Since this phase represents a liquid phase, it's an error to
494  * return a gas-phase answer. However, if the below is true, then
495  * a gas-phase answer is allowed. This is used to check the thermodynamic
496  * consistency with ideal-gas thermo functions for example.
497  */
499 };
500 
501 }
502 
503 #endif
virtual void getEntropy_R_ref(doublereal *er) const
Definition: WaterSSTP.cpp:315
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:245
WaterProps * getWaterProps()
Get a pointer to a changeable WaterPropsIAPWS object.
Definition: WaterSSTP.h:445
virtual void setDensity(const doublereal dens)
Set the density of the phase.
Definition: WaterSSTP.cpp:447
virtual doublereal pressure() const
Return the thermodynamic pressure (Pa).
Definition: WaterSSTP.cpp:376
virtual void setPressure(doublereal p)
Set the internally stored pressure (Pa) at constant temperature and composition.
Definition: WaterSSTP.cpp:382
Class for calculating the equation of state of water.
virtual ~WaterSSTP()
Destructor.
Definition: WaterSSTP.cpp:105
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:235
WaterProps * m_waterProps
Pointer to the WaterProps object.
Definition: WaterSSTP.h:470
virtual void setParametersFromXML(const XML_Node &eosdata)
Set equation of state parameter values from XML entries.
Definition: WaterSSTP.cpp:211
WaterSSTP()
Base constructor.
Definition: WaterSSTP.cpp:23
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:266
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:101
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id)
Import and initialize a ThermoPhase object using an XML tree.
Definition: WaterSSTP.cpp:117
virtual doublereal cv_mole() const
Molar heat capacity at constant volume. Units: J/kmol/K.
Definition: WaterSSTP.cpp:261
doublereal EW_Offset
Offset constants used to obtain consistency with the NIST database.
Definition: WaterSSTP.h:480
virtual doublereal thermalExpansionCoeff() const
Return the volumetric thermal expansion coefficient. Units: 1/K.
Definition: WaterSSTP.cpp:403
WaterPropsIAPWS * getWater()
Get a pointer to a changeable WaterPropsIAPWS object.
Definition: WaterSSTP.h:440
virtual doublereal critTemperature() const
critical temperature
Definition: WaterSSTP.cpp:425
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:473
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:223
virtual int eosType() const
Returns the equation of state type flag.
Definition: WaterSSTP.h:157
WaterSSTP & operator=(const WaterSSTP &)
Assignment operator.
Definition: WaterSSTP.cpp:81
virtual doublereal critDensity() const
critical density
Definition: WaterSSTP.cpp:435
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:460
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:454
virtual doublereal isothermalCompressibility() const
Returns the isothermal compressibility. Units: 1/Pa.
Definition: WaterSSTP.cpp:398
void _updateThermo() const
virtual void initThermo()
Initialize the ThermoPhase object after all species have been set up.
Definition: WaterSSTP.cpp:111
virtual void setTemperature(const doublereal temp)
Set the temperature of the phase.
Definition: WaterSSTP.cpp:440
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:358
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:229
doublereal SW_Offset
Offset constant used to obtain consistency with NIST convention.
Definition: WaterSSTP.h:487
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:216
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:255
virtual void getCp_R_ref(doublereal *cprt) const
Definition: WaterSSTP.cpp:338
bool m_allowGasPhase
Since this phase represents a liquid phase, it's an error to return a gas-phase answer.
Definition: WaterSSTP.h:498
virtual doublereal critPressure() const
critical pressure
Definition: WaterSSTP.cpp:430
virtual void getGibbs_RT_ref(doublereal *grt) const
Definition: WaterSSTP.cpp:285
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:408
ThermoPhase * duplMyselfAsThermoPhase() const
Duplicator from a ThermoPhase object.
Definition: WaterSSTP.cpp:100
virtual doublereal vaporFraction() const
Return the fraction of vapor at the current conditions.
Definition: WaterSSTP.cpp:462
virtual void getGibbs_ref(doublereal *g) const
Definition: WaterSSTP.cpp:306
bool m_ready
Boolean is true if object has been properly initialized for calculation.
Definition: WaterSSTP.h:490