Cantera  2.0
VPSSMgr_Water_HKFT.h
Go to the documentation of this file.
1 /**
2  * @file VPSSMgr_Water_HKFT.h
3  * Declaration file for a derived class that handles the calculation
4  * of standard state thermo properties for real water and
5  * a set of species which have the HKFT equation of state
6  * (see \ref mgrpdssthermocalc and
7  * class \link Cantera::VPSSMgr_Water_HKFT VPSSMgr_Water_HKFT\endlink).
8  */
9 /*
10  * Copyright (2006) Sandia Corporation. Under the terms of
11  * Contract DE-AC04-94AL85000 with Sandia Corporation, the
12  * U.S. Government retains certain rights in this software.
13  */
14 
15 #ifndef CT_VPSSMGR_WATER_HKFT_H
16 #define CT_VPSSMGR_WATER_HKFT_H
17 
18 #include "VPSSMgr.h"
19 
20 namespace Cantera
21 {
22 
23 class SpeciesThermoInterpType;
24 class VPStandardStateTP;
25 class SpeciesThermo;
26 class PDSS;
27 class PDSS_Water;
28 
29 //! Virtual base class for the species thermo manager classes.
30 /*!
31  * This class defines the interface which all subclasses must implement.
32  *
33  * Class %VPSSSpeciesThermo is the base class
34  * for a family of classes that compute properties of a set of
35  * species in their reference state at a range of temperatures.
36  * Note, the pressure dependence of the reference state is not
37  * handled by this particular species standard state model.
38  *
39  * @ingroup mgrpdssthermocalc
40  */
42 {
43 
44 public:
45 
46 
47  //! Constructor
48  /*!
49  * @param vptp_ptr Pointer to the Variable pressure %ThermoPhase object
50  * This object must have already been malloced.
51  *
52  * @param spth Pointer to the optional SpeciesThermo object
53  * that will handle the calculation of the reference
54  * state thermodynamic coefficients.
55  */
57  SpeciesThermo* spth);
58 
59  //! Destructor
60  virtual ~VPSSMgr_Water_HKFT();
61 
62  //! Copy Constructor for the %SpeciesThermo object.
63  /*!
64  * @param right Reference to %SpeciesThermo object to be copied into the
65  * current one.
66  */
68 
69  //! Assignment operator for the %SpeciesThermo object
70  /*!
71  * This is NOT a virtual function.
72  *
73  * @param right Reference to %SpeciesThermo object to be copied into the
74  * current one.
75  */
77 
78  //! Duplication routine for objects which inherit from
79  //! %VPSSSpeciesThermo
80  /*!
81  * This virtual routine can be used to duplicate %VPSSSpeciesThermo objects
82  * inherited from %VPSSSpeciesThermo even if the application only has
83  * a pointer to %VPSSSpeciesThermo to work with.
84  */
85  virtual VPSSMgr* duplMyselfAsVPSSMgr() const;
86 
87  /*!
88  * @name Properties of the Standard State of the Species in the Solution
89  *
90  * Within VPStandardStateTP, these properties are calculated via a common routine,
91  * _updateStandardStateThermo(),
92  * which must be overloaded in inherited objects.
93  * The values are cached within this object, and are not recalculated unless
94  * the temperature or pressure changes.
95  */
96  //@{
97 
98 
99  //@}
100  /// @name Thermodynamic Values for the Species Reference States (VPStandardStateTP)
101  /*!
102  * There are also temporary
103  * variables for holding the species reference-state values of Cp, H, S, and V at the
104  * last temperature and reference pressure called. These functions are not recalculated
105  * if a new call is made using the previous temperature.
106  * All calculations are done within the routine _updateRefStateThermo().
107  */
108  //@{
109 
110  /*!
111  * Returns the vector of nondimensional
112  * enthalpies of the reference state at the current temperature
113  * of the solution and the reference pressure for the species.
114  *
115  * @param hrt Output vector contains the nondimensional enthalpies
116  * of the reference state of the species
117  * length = m_kk, units = dimensionless.
118  */
119  virtual void getEnthalpy_RT_ref(doublereal* hrt) const;
120 
121  /*!
122  * Returns the vector of nondimensional
123  * Gibbs free energies of the reference state at the current temperature
124  * of the solution and the reference pressure for the species.
125  *
126  * @param grt Output vector contains the nondimensional Gibbs free energies
127  * of the reference state of the species
128  * length = m_kk, units = dimensionless.
129  */
130  virtual void getGibbs_RT_ref(doublereal* grt) const ;
131 
132  /*!
133  * Returns the vector of the
134  * gibbs function of the reference state at the current temperature
135  * of the solution and the reference pressure for the species.
136  * units = J/kmol
137  *
138  * @param g Output vector contain the Gibbs free energies
139  * of the reference state of the species
140  * length = m_kk, units = J/kmol.
141  */
142  virtual void getGibbs_ref(doublereal* g) const ;
143 
144 
145  /*!
146  * Returns the vector of nondimensional
147  * entropies of the reference state at the current temperature
148  * of the solution and the reference pressure for the species.
149  *
150  * @param er Output vector contain the nondimensional entropies
151  * of the species in their reference states
152  * length: m_kk, units: dimensionless.
153  */
154  virtual void getEntropy_R_ref(doublereal* er) const ;
155 
156  /*!
157  * Returns the vector of nondimensional
158  * constant pressure heat capacities of the reference state
159  * at the current temperature of the solution
160  * and reference pressure for the species.
161  *
162  * @param cpr Output vector contains the nondimensional heat capacities
163  * of the species in their reference states
164  * length: m_kk, units: dimensionless.
165  */
166  virtual void getCp_R_ref(doublereal* cpr) const ;
167 
168  //! Get the molar volumes of the species reference states at the current
169  //! <I>T</I> and <I>P_ref</I> of the solution.
170  /*!
171  * units = m^3 / kmol
172  *
173  * @param vol Output vector containing the standard state volumes.
174  * Length: m_kk.
175  */
176  virtual void getStandardVolumes_ref(doublereal* vol) const ;
177 
178  //! Set the temperature (K) and pressure (Pa)
179  /*!
180  * This sets the temperature and pressure and triggers
181  * calculation of underlying quantities
182  *
183  * @param T Temperature (K)
184  * @param P Pressure (Pa)
185  */
186  virtual void setState_TP(doublereal T, doublereal P);
187 
188  //! Set the temperature (K)
189  /*!
190  * @param T Temperature (K)
191  */
192  virtual void setState_T(doublereal T);
193 
194  //! Set the pressure (Pa)
195  /*!
196  * @param P Pressure (Pa)
197  */
198  virtual void setState_P(doublereal P);
199 
200  //@}
201  /// @name Setting the Internal State of the System
202  /*!
203  * All calls to change the internal state of the system's T and P
204  * are done through these routines
205  * - setState_TP()
206  * - setState_T()
207  * - setState_P()
208  *
209  * These routine in turn call the following underlying virtual functions
210  *
211  * - _updateRefStateThermo()
212  * - _updateStandardStateThermo()
213  *
214  * An important point to note is that between calls the assumption
215  * that the underlying PDSS objects will retain their set Temperatures
216  * and Pressure CAN NOT BE MADE. For efficiency reasons, we may twiddle
217  * these to get derivatives.
218  */
219  //@{
220 
221  //! Updates the internal reference state thermodynamic vectors at the
222  //! current T of the solution and the reference pressure.
223  /*!
224  * This is called to make sure that the internal thermodynamic members
225  * are up-to-date. It checks against an internal value of m_tempRef
226  * to see whether the values are current.
227  */
228  virtual void updateRefStateThermo() const;
229 
230 private:
231 
232  //! Updates the reference state thermodynamic functions at the current T
233  //! and a calculated Pref that is safe.
234  /*!
235  *
236  * This function is responsible for updating the following internal members
237  *
238  * - m_h0_RT;
239  * - m_cp0_R;
240  * - m_g0_RT;
241  * - m_s0_R;
242  * - m_V0
243  *
244  * It always does the calculation. No checking is ever done to see
245  * if the calculation is necessary.
246  *
247  * m_p0 is calculated within this routine given the value of the temperature.
248  * This is necessary because we are using a real equation of state for
249  * water.
250  *
251  * The state of the system is left at (m_tlast, m_plast) at the end
252  * of the routine.
253  */
254  virtual void _updateRefStateThermo() const;
255 
256  //! Updates the standard state thermodynamic functions at the current T and P of the solution.
257  /*!
258  * @internal
259  *
260  * If m_useTmpStandardStateStorage is true,
261  * this function must be called for every call to functions in this
262  * class. It checks to see whether the temperature or pressure has changed and
263  * thus the ss thermodynamics functions for all of the species
264  * must be recalculated.
265  *
266  * This function is responsible for updating the following internal members,
267  * when m_useTmpStandardStateStorage is true.
268  *
269  * - m_hss_RT;
270  * - m_cpss_R;
271  * - m_gss_RT;
272  * - m_sss_R;
273  * - m_Vss
274  *
275  * If m_useTmpStandardStateStorage is not true, this function may be
276  * required to be called by child classes to update internal member data.
277  *
278  * Note, this will throw an error. It must be reimplemented in derived classes.
279  *
280  */
281  virtual void _updateStandardStateThermo();
282 
283 
284 public:
285 
286  //@}
287  //! @name Utility Methods - Reports on various quantities
288  /*!
289  * The following methods are used in the process of reporting
290  * various states and attributes
291  */
292  //@{
293 
294  //! This utility function reports the type of parameterization
295  //! used for the species with index number index.
296  /*!
297  *
298  * @param index Species index
299  */
300  virtual PDSS_enumType reportPDSSType(int index = -1) const ;
301 
302 
303  //! This utility function reports the type of manager
304  //! for the calculation of ss properties
305  /*!
306  *
307  *
308  */
309  virtual VPSSMgr_enumType reportVPSSMgrType() const ;
310 
311  //@}
312  //! @name Initialization Methods - For Internal use (VPStandardState)
313  /*!
314  * The following methods are used in the process of constructing
315  * the phase and setting its parameters from a specification in an
316  * input file. They are not normally used in application programs.
317  * To see how they are used, see files importCTML.cpp and
318  * ThermoFactory.cpp.
319  */
320  //@{
321 
322  //! @internal Initialize the object
323  /*!
324  * This method is provided to allow
325  * subclasses to perform any initialization required after all
326  * species have been added. For example, it might be used to
327  * resize internal work arrays that must have an entry for
328  * each species. The base class implementation does nothing,
329  * and subclasses that do not require initialization do not
330  * need to overload this method. When importing a CTML phase
331  * description, this method is called just prior to returning
332  * from function importPhase().
333  *
334  * @see importCTML.cpp
335  */
336  virtual void initThermo();
337 
338  //! Finalize the thermo after all species have been entered
339  /*!
340  * This function is the LAST initialization routine to be
341  * called. It's called after createInstallPDSS() has been
342  * called for each species in the phase, and after initThermo()
343  * has been called.
344  * It's called via an inner-to-outer onion shell like manner.
345  *
346  *
347  * @param phaseNode Reference to the phaseNode XML node.
348  * @param id ID of the phase.
349  */
350  virtual void initThermoXML(XML_Node& phaseNode, std::string id);
351 
352  //! Install specific content for species k in the standard-state
353  //! thermodynamic calculator and also create/return a PDSS object
354  //! for that species.
355  /*!
356  * This occurs before matrices are sized appropriately.
357  *
358  * @param k Species index in the phase
359  * @param speciesNode XML Node corresponding to the species
360  * @param phaseNode_ptr Pointer to the XML Node corresponding
361  * to the phase which owns the species
362  */
363  virtual PDSS* createInstallPDSS(size_t k, const XML_Node& speciesNode,
364  const XML_Node* const phaseNode_ptr);
365 
366  //@}
367 
368 private:
369 
370  //! Shallow pointer to the water object
372 
373  //! Last reference temperature calculated
374  /*!
375  * Reference state calculations are totally separated from
376  * standard state calculations.
377  */
378  mutable doublereal m_tlastRef;
379 };
380 //@}
381 }
382 
383 #endif
384