Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PDSS_HKFT.h
Go to the documentation of this file.
1 /**
2  * @file PDSS_HKFT.h
3  * Declarations for the class PDSS_HKFT (pressure dependent standard state)
4  * which handles calculations for a single species in a phase using the
5  * HKFT standard state
6  * (see \ref pdssthermo and class \link Cantera::PDSS_HKFT PDSS_HKFT\endlink).
7  */
8 /*
9  * Copyright (2006) Sandia Corporation. Under the terms of
10  * Contract DE-AC04-94AL85000 with Sandia Corporation, the
11  * U.S. Government retains certain rights in this software.
12  */
13 
14 #ifndef CT_PDSS_HKFT_H
15 #define CT_PDSS_HKFT_H
16 
17 #include "PDSS.h"
18 
19 namespace Cantera
20 {
21 class PDSS_Water;
22 class WaterProps;
23 
24 //! Class for pressure dependent standard states corresponding to
25 //! ionic solutes in electrolyte water.
26 /*!
27  * @ingroup pdssthermo
28  */
29 class PDSS_HKFT : public PDSS_Molar
30 {
31 public:
32  //! @name Constructors
33  //! @{
34 
35  //! Constructor that initializes the object by examining the XML entries
36  //! from the ThermoPhase object
37  /*!
38  * This function calls the constructPDSS member function.
39  *
40  * @param tp Pointer to the ThermoPhase object pertaining to the phase
41  * @param spindex Species index of the species in the phase
42  */
43  PDSS_HKFT(VPStandardStateTP* tp, size_t spindex);
44 
45  //! Copy Constructor
46  /*!
47  * @param b object to be copied
48  */
49  PDSS_HKFT(const PDSS_HKFT& b);
50 
51  //! Assignment operator
52  /*!
53  * @param b Object to be copied
54  */
55  PDSS_HKFT& operator=(const PDSS_HKFT& b);
56 
57  //! Constructor that initializes the object by examining the input file
58  //! of the ThermoPhase object
59  /*!
60  * This function calls the constructPDSSFile member function.
61  *
62  * @param vptp_ptr Pointer to the ThermoPhase object pertaining to the phase
63  * @param spindex Species index of the species in the phase
64  * @param inputFile String name of the input file
65  * @param id String name of the phase in the input file. The default
66  * is the empty string, in which case the first phase in the
67  * file is used.
68  */
69  PDSS_HKFT(VPStandardStateTP* vptp_ptr, size_t spindex,
70  const std::string& inputFile, const std::string& id = "");
71 
72  //! Constructor that initializes the object by examining the input file
73  //! of the ThermoPhase object
74  /*!
75  * This function calls the constructPDSSXML member function.
76  *
77  * @param vptp_ptr Pointer to the ThermoPhase object pertaining to the phase
78  * @param spindex Species index of the species in the phase
79  * @param speciesNode Reference to the species XML tree.
80  * @param phaseRef Reference to the XML tree containing the phase information.
81  * @param spInstalled Boolean indicating whether the species is installed yet
82  * or not.
83  */
84  PDSS_HKFT(VPStandardStateTP* vptp_ptr, size_t spindex, const XML_Node& speciesNode,
85  const XML_Node& phaseRef, bool spInstalled);
86 
87  //! Destructor for the phase
88  virtual ~PDSS_HKFT();
89 
90  virtual PDSS* duplMyselfAsPDSS() const;
91 
92  //! @}
93  //! @name Molar Thermodynamic Properties of the Solution
94  //! @{
95 
96  // See PDSS.h for documentation of functions overridden from Class PDSS
97 
98  virtual doublereal enthalpy_mole() const;
99 
100 #ifdef DEBUG_MODE
101  //! Return the molar enthalpy in units of J kmol-1
102  /*!
103  * Returns the species standard state enthalpy in J kmol-1 at the
104  * current temperature and pressure.
105  *
106  * Note this is just an extra routine to check the arithmetic
107  *
108  * @return returns the species standard state enthalpy in J kmol-1
109  */
110  doublereal enthalpy_mole2() const;
111 #endif
112 
113  virtual doublereal intEnergy_mole() const;
114  virtual doublereal entropy_mole() const;
115  virtual doublereal gibbs_mole() const;
116  virtual doublereal cp_mole() const;
117  virtual doublereal molarVolume() const;
118  virtual doublereal density() const;
119 
120  //! @}
121  //! @name Properties of the Reference State of the Species in the Solution
122  //! @{
123 
124  doublereal refPressure() const {
125  return m_p0;
126  }
127 
128  virtual doublereal gibbs_RT_ref() const;
129  virtual doublereal enthalpy_RT_ref() const;
130  virtual doublereal entropy_R_ref() const;
131  virtual doublereal cp_R_ref() const;
132  virtual doublereal molarVolume_ref() const;
133 
134  //! @}
135  //! @name Mechanical Equation of State Properties
136  //! @{
137 
138  virtual void setState_TP(doublereal temp, doublereal pres);
139 
140  //! @}
141  //! @name Initialization of the Object
142  //! @{
143 
144  virtual void initThermo();
145 
146  //! Initialization of a PDSS object using an input XML file.
147  /*!
148  * This routine is a precursor to constructPDSSXML(XML_Node*)
149  * routine, which does most of the work.
150  *
151  * @param vptp_ptr Pointer to the Variable pressure ThermoPhase object
152  * This object must have already been malloced.
153  * @param spindex Species index within the phase
154  * @param inputFile XML file containing the description of the
155  * phase
156  * @param id Optional parameter identifying the name of the
157  * phase. If none is given, the first XML
158  * phase element will be used.
159  */
160  void constructPDSSFile(VPStandardStateTP* vptp_ptr, size_t spindex,
161  const std::string& inputFile, const std::string& id);
162 
163  //! Initialization of a PDSS object using an XML tree
164  /*!
165  * This routine is a driver for the initialization of the object.
166  *
167  * basic logic:
168  * - initThermo() (cascade)
169  * - getStuff from species Part of XML file
170  * - initThermoXML(phaseNode) (cascade)
171  *
172  * @param vptp_ptr Pointer to the Variable pressure ThermoPhase object
173  * This object must have already been malloced.
174  * @param spindex Species index within the phase
175  * @param speciesNode XML Node containing the species information
176  * @param phaseNode Reference to the phase Information for the phase
177  * that owns this species.
178  * @param spInstalled Boolean indicating whether the species is
179  * already installed.
180  */
181  void constructPDSSXML(VPStandardStateTP* vptp_ptr, size_t spindex,
182  const XML_Node& speciesNode,
183  const XML_Node& phaseNode, bool spInstalled);
184 
185  virtual void initAllPtrs(VPStandardStateTP* vptp_ptr, VPSSMgr* vpssmgr_ptr,
186  SpeciesThermo* spthermo_ptr);
187 
188  //! This utility function reports back the type of parameterization and
189  //! all of the parameters for the species, index.
190  /*!
191  * The following parameters are reported
192  *
193  * - c[0] = m_deltaG_formation_tr_pr;
194  * - c[1] = m_deltaH_formation_tr_pr;
195  * - c[2] = m_Mu0_tr_pr;
196  * - c[3] = m_Entrop_tr_pr;
197  * - c[4] = m_a1;
198  * - c[5] = m_a2;
199  * - c[6] = m_a3;
200  * - c[7] = m_a4;
201  * - c[8] = m_c1;
202  * - c[9] = m_c2;
203  * - c[10] = m_omega_pr_tr;
204  * .
205  *
206  * @param kindex Species index
207  * @param type Integer type of the standard type
208  * @param c Vector of coefficients used to set the
209  * parameters for the standard state.
210  * @param minTemp output - Minimum temperature
211  * @param maxTemp output - Maximum temperature
212  * @param refPressure output - reference pressure (Pa).
213  */
214  virtual void reportParams(size_t& kindex, int& type, doublereal* const c,
215  doublereal& minTemp, doublereal& maxTemp,
216  doublereal& refPressure) const;
217 
218  //@}
219 
220 private:
221  //! Main routine that actually calculates the Gibbs free energy difference
222  //! between the reference state at Tr, Pr and T,P
223  /*!
224  * This is eEqn. 59 in Johnson et al. (1992).
225  */
226  doublereal deltaG() const;
227 
228  //! Main routine that actually calculates the entropy difference
229  //! between the reference state at Tr, Pr and T,P
230  /*!
231  * This is Eqn. 61 in Johnson et al. (1992). Actually, there appears to
232  * be an error in the latter. This is a correction.
233  */
234  doublereal deltaS() const;
235 
236 #ifdef DEBUG_MODE
237  //! Routine that actually calculates the enthalpy difference
238  //! between the reference state at Tr, Pr and T,P
239  /*!
240  * This is an extra routine that was added to check the arithmetic
241  */
242  doublereal deltaH() const;
243 #endif
244 
245  //! Internal formula for the calculation of a_g()
246  /*!
247  * The output of this is in units of Angstroms
248  *
249  * @param temp Temperature (K)
250  *
251  * @param ifunc parameters specifying the desired information
252  * - 0 function value
253  * - 1 derivative wrt temperature
254  * - 2 2nd derivative wrt temperature
255  * - 3 derivative wrt pressure
256  */
257  doublereal ag(const doublereal temp, const int ifunc = 0) const;
258 
259  //! Internal formula for the calculation of b_g()
260  /*!
261  * the output of this is unitless
262  *
263  * @param temp Temperature (K)
264  *
265  * @param ifunc parameters specifying the desired information
266  * - 0 function value
267  * - 1 derivative wrt temperature
268  * - 2 2nd derivative wrt temperature
269  * - 3 derivative wrt pressure
270  */
271  doublereal bg(const doublereal temp, const int ifunc = 0) const;
272 
273  //! function g appearing in the formulation
274  /*!
275  * Function g appearing in the Johnson et al formulation
276  *
277  * @param temp Temperature kelvin
278  * @param pres Pressure (pascal)
279  * @param ifunc parameters specifying the desired information
280  * - 0 function value
281  * - 1 derivative wrt temperature
282  * - 2 2nd derivative wrt temperature
283  * - 3 derivative wrt pressure
284  */
285  doublereal g(const doublereal temp, const doublereal pres, const int ifunc = 0) const;
286 
287  //! Difference function f appearing in the formulation
288  /*!
289  * Function f appearing in the Johnson et al formulation of omega_j
290  * Eqn. 33 ref
291  *
292  * @param temp Temperature kelvin
293  * @param pres Pressure (pascal)
294  * @param ifunc parameters specifying the desired information
295  * - 0 function value
296  * - 1 derivative wrt temperature
297  * - 2 2nd derivative wrt temperature
298  * - 3 derivative wrt pressure
299  */
300  doublereal f(const doublereal temp, const doublereal pres, const int ifunc = 0) const;
301 
302  //! Evaluate the Gstar value appearing in the HKFT formulation
303  /*!
304  * @param temp Temperature kelvin
305  * @param pres Pressure (pascal)
306  * @param ifunc parameters specifying the desired information
307  * - 0 function value
308  * - 1 derivative wrt temperature
309  * - 2 2nd derivative wrt temperature
310  * - 3 derivative wrt pressure
311  */
312  doublereal gstar(const doublereal temp, const doublereal pres,
313  const int ifunc = 0) const;
314 
315  //! Function to look up Element Free Energies
316  /*!
317  * This function looks up the argument string in the element database and
318  * returns the associated 298 K Gibbs Free energy of the element in its
319  * stable state.
320  *
321  * @param elemName String. Only the first 3 characters are significant
322  *
323  * @return value contains the Gibbs free energy for that element
324  *
325  * @exception CanteraError
326  * If a match is not found, a CanteraError is thrown as well
327  */
328  doublereal LookupGe(const std::string& elemName);
329 
330  //! Translate a Gibbs free energy of formation value to a NIST-based Chemical potential
331  /*!
332  * Internally, this function is used to translate the input value,
333  * m_deltaG_formation_tr_pr, to the internally stored value, m_Mu0_tr_pr.
334  */
335  void convertDGFormation();
336 
337 private:
338  //! Water standard state calculator
339  /*!
340  * derived from the equation of state for water.
341  * This object doesn't own the object. Just a shallow pointer.
342  */
344 
345  //! density of standard-state water
346  /*!
347  * internal temporary variable
348  */
349  mutable doublereal m_densWaterSS;
350 
351  //! Pointer to the water property calculator
353 
354  //! Born coefficient for the current ion or species
355  doublereal m_born_coeff_j;
356 
357  //! Electrostatic radii
358  doublereal m_r_e_j;
359 
360  //! Input value of deltaG of Formation at Tr and Pr (cal gmol-1)
361  /*!
362  * Tr = 298.15 Pr = 1 atm
363  *
364  * This is the delta G for the formation reaction of the
365  * ion from elements in their stable state at Tr, Pr.
366  */
368 
369  //! Input value of deltaH of Formation at Tr and Pr (cal gmol-1)
370  /*!
371  * Tr = 298.15 Pr = 1 atm
372  *
373  * This is the delta H for the formation reaction of the
374  * ion from elements in their stable state at Tr, Pr.
375  */
377 
378  //! Value of the Absolute Gibbs Free Energy NIST scale at T_r and P_r
379  /*!
380  * This is the NIST scale value of Gibbs free energy at T_r = 298.15
381  * and P_r = 1 atm.
382  *
383  * J kmol-1
384  */
385  doublereal m_Mu0_tr_pr;
386 
387  //! Input value of S_j at Tr and Pr (cal gmol-1 K-1)
388  /*!
389  * Tr = 298.15 Pr = 1 atm
390  */
391  doublereal m_Entrop_tr_pr;
392 
393  //! Input a1 coefficient (cal gmol-1 bar-1)
394  doublereal m_a1;
395 
396  //! Input a2 coefficient (cal gmol-1)
397  doublereal m_a2;
398 
399  //! Input a3 coefficient (cal K gmol-1 bar-1)
400  doublereal m_a3;
401 
402  //! Input a4 coefficient (cal K gmol-1)
403  doublereal m_a4;
404 
405  //! Input c1 coefficient (cal gmol-1 K-1)
406  doublereal m_c1;
407 
408  //! Input c2 coefficient (cal K gmol-1)
409  doublereal m_c2;
410 
411  //! Input omega_pr_tr coefficient(cal gmol-1)
412  doublereal m_omega_pr_tr;
413 
414  //! y = dZdT = 1/(esp*esp) desp/dT at 298.15 and 1 bar
415  doublereal m_Y_pr_tr;
416 
417  //! Z = -1 / relEpsilon at 298.15 and 1 bar
418  doublereal m_Z_pr_tr;
419 
420  //! Reference pressure is 1 atm in units of bar= 1.0132
421  doublereal m_presR_bar;
422 
423  //! small value that is not quite zero
424  doublereal m_domega_jdT_prtr;
425 
426  //! Charge of the ion
427  doublereal m_charge_j;
428 
429  //! Static variable determining error exiting
430  /*!
431  * If true, then will error exit if there is an inconsistency in DG0, DH0, and DS0.
432  * If not, then will rewrite DH0 to be consistent with the other two.
433  */
435 };
436 
437 }
438 
439 #endif
virtual doublereal enthalpy_mole() const
Return the molar enthalpy in units of J kmol-1.
Definition: PDSS_HKFT.cpp:211
doublereal m_a4
Input a4 coefficient (cal K gmol-1)
Definition: PDSS_HKFT.h:403
doublereal m_densWaterSS
density of standard-state water
Definition: PDSS_HKFT.h:349
virtual doublereal density() const
Return the standard state density at standard state.
Definition: PDSS_HKFT.cpp:400
doublereal f(const doublereal temp, const doublereal pres, const int ifunc=0) const
Difference function f appearing in the formulation.
Definition: PDSS_HKFT.cpp:920
virtual void setState_TP(doublereal temp, doublereal pres)
Set the internal temperature and pressure.
Definition: PDSS_HKFT.cpp:455
doublereal bg(const doublereal temp, const int ifunc=0) const
Internal formula for the calculation of b_g()
Definition: PDSS_HKFT.cpp:906
doublereal m_deltaG_formation_tr_pr
Input value of deltaG of Formation at Tr and Pr (cal gmol-1)
Definition: PDSS_HKFT.h:367
doublereal gstar(const doublereal temp, const doublereal pres, const int ifunc=0) const
Evaluate the Gstar value appearing in the HKFT formulation.
Definition: PDSS_HKFT.cpp:1015
doublereal maxTemp() const
return the minimum temperature
Definition: PDSS.h:365
Virtual base class for the classes that manage the calculation of standard state properties for all t...
Definition: VPSSMgr.h:235
doublereal m_Mu0_tr_pr
Value of the Absolute Gibbs Free Energy NIST scale at T_r and P_r.
Definition: PDSS_HKFT.h:385
doublereal enthalpy_mole2() const
Return the molar enthalpy in units of J kmol-1.
Definition: PDSS_HKFT.cpp:228
doublereal deltaG() const
Main routine that actually calculates the Gibbs free energy difference between the reference state at...
Definition: PDSS_HKFT.cpp:791
doublereal m_c2
Input c2 coefficient (cal K gmol-1)
Definition: PDSS_HKFT.h:409
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:100
virtual doublereal cp_mole() const
Return the molar const pressure heat capacity in units of J kmol-1 K-1.
Definition: PDSS_HKFT.cpp:250
virtual ~PDSS_HKFT()
Destructor for the phase.
Definition: PDSS_HKFT.cpp:201
doublereal m_a3
Input a3 coefficient (cal K gmol-1 bar-1)
Definition: PDSS_HKFT.h:400
doublereal minTemp() const
return the minimum temperature
Definition: PDSS.h:360
doublereal deltaS() const
Main routine that actually calculates the entropy difference between the reference state at Tr...
Definition: PDSS_HKFT.cpp:835
PDSS_HKFT & operator=(const PDSS_HKFT &b)
Assignment operator.
Definition: PDSS_HKFT.cpp:159
doublereal m_omega_pr_tr
Input omega_pr_tr coefficient(cal gmol-1)
Definition: PDSS_HKFT.h:412
Pure Virtual base class for the species thermo manager classes.
doublereal m_Y_pr_tr
y = dZdT = 1/(esp*esp) desp/dT at 298.15 and 1 bar
Definition: PDSS_HKFT.h:415
virtual void initAllPtrs(VPStandardStateTP *vptp_ptr, VPSSMgr *vpssmgr_ptr, SpeciesThermo *spthermo_ptr)
Initialize or Reinitialize all shallow pointers in the object.
Definition: PDSS_HKFT.cpp:538
Base class for PDSS classes which compute molar properties directly.
Definition: PDSS.h:677
static int s_InputInconsistencyErrorExit
Static variable determining error exiting.
Definition: PDSS_HKFT.h:434
doublereal g(const doublereal temp, const doublereal pres, const int ifunc=0) const
function g appearing in the formulation
Definition: PDSS_HKFT.cpp:955
virtual void initThermo()
Initialization routine for all of the shallow pointers.
Definition: PDSS_HKFT.cpp:461
doublereal m_a2
Input a2 coefficient (cal gmol-1)
Definition: PDSS_HKFT.h:397
doublereal m_charge_j
Charge of the ion.
Definition: PDSS_HKFT.h:427
virtual doublereal entropy_mole() const
Return the molar entropy in units of J kmol-1 K-1.
Definition: PDSS_HKFT.cpp:240
Declarations for the virtual base class PDSS (pressure dependent standard state) which handles calcul...
void constructPDSSXML(VPStandardStateTP *vptp_ptr, size_t spindex, const XML_Node &speciesNode, const XML_Node &phaseNode, bool spInstalled)
Initialization of a PDSS object using an XML tree.
Definition: PDSS_HKFT.cpp:547
The WaterProps class is used to house several approximation routines for properties of water...
Definition: WaterProps.h:96
PDSS_HKFT(VPStandardStateTP *tp, size_t spindex)
Constructor that initializes the object by examining the XML entries from the ThermoPhase object...
Definition: PDSS_HKFT.cpp:31
Class for the liquid water pressure dependent standard state.
Definition: PDSS_Water.h:51
doublereal m_deltaH_formation_tr_pr
Input value of deltaH of Formation at Tr and Pr (cal gmol-1)
Definition: PDSS_HKFT.h:376
virtual doublereal entropy_R_ref() const
Return the molar entropy divided by R at reference pressure.
Definition: PDSS_HKFT.cpp:426
doublereal deltaH() const
Routine that actually calculates the enthalpy difference between the reference state at Tr...
Definition: PDSS_HKFT.cpp:729
doublereal m_Entrop_tr_pr
Input value of S_j at Tr and Pr (cal gmol-1 K-1)
Definition: PDSS_HKFT.h:391
virtual doublereal molarVolume_ref() const
Return the molar volume at reference pressure.
Definition: PDSS_HKFT.cpp:446
WaterProps * m_waterProps
Pointer to the water property calculator.
Definition: PDSS_HKFT.h:352
void convertDGFormation()
Translate a Gibbs free energy of formation value to a NIST-based Chemical potential.
Definition: PDSS_HKFT.cpp:1053
virtual doublereal molarVolume() const
Return the molar volume at standard state.
Definition: PDSS_HKFT.cpp:345
doublereal m_presR_bar
Reference pressure is 1 atm in units of bar= 1.0132.
Definition: PDSS_HKFT.h:421
This is a filter class for ThermoPhase that implements some prepatory steps for efficiently handling ...
virtual doublereal enthalpy_RT_ref() const
Return the molar enthalpy divided by RT at reference pressure.
Definition: PDSS_HKFT.cpp:416
doublereal m_domega_jdT_prtr
small value that is not quite zero
Definition: PDSS_HKFT.h:424
virtual doublereal gibbs_RT_ref() const
Return the molar Gibbs free energy divided by RT at reference pressure.
Definition: PDSS_HKFT.cpp:406
virtual void reportParams(size_t &kindex, int &type, doublereal *const c, doublereal &minTemp, doublereal &maxTemp, doublereal &refPressure) const
This utility function reports back the type of parameterization and all of the parameters for the spe...
Definition: PDSS_HKFT.cpp:1075
PDSS_Water * m_waterSS
Water standard state calculator.
Definition: PDSS_HKFT.h:343
doublereal ag(const doublereal temp, const int ifunc=0) const
Internal formula for the calculation of a_g()
Definition: PDSS_HKFT.cpp:892
doublereal LookupGe(const std::string &elemName)
Function to look up Element Free Energies.
Definition: PDSS_HKFT.cpp:1039
doublereal m_Z_pr_tr
Z = -1 / relEpsilon at 298.15 and 1 bar.
Definition: PDSS_HKFT.h:418
Virtual base class for a species with a pressure dependent standard state.
Definition: PDSS.h:193
Class for pressure dependent standard states corresponding to ionic solutes in electrolyte water...
Definition: PDSS_HKFT.h:29
doublereal m_c1
Input c1 coefficient (cal gmol-1 K-1)
Definition: PDSS_HKFT.h:406
virtual PDSS * duplMyselfAsPDSS() const
Duplication routine for objects which inherit from PDSS.
Definition: PDSS_HKFT.cpp:206
virtual doublereal gibbs_mole() const
Return the molar Gibbs free energy in units of J kmol-1.
Definition: PDSS_HKFT.cpp:245
doublereal m_r_e_j
Electrostatic radii.
Definition: PDSS_HKFT.h:358
doublereal m_born_coeff_j
Born coefficient for the current ion or species.
Definition: PDSS_HKFT.h:355
virtual doublereal cp_R_ref() const
Return the molar heat capacity divided by R at reference pressure.
Definition: PDSS_HKFT.cpp:436
doublereal m_p0
Reference state pressure of the species.
Definition: PDSS.h:568
doublereal m_a1
Input a1 coefficient (cal gmol-1 bar-1)
Definition: PDSS_HKFT.h:394
void constructPDSSFile(VPStandardStateTP *vptp_ptr, size_t spindex, const std::string &inputFile, const std::string &id)
Initialization of a PDSS object using an input XML file.
Definition: PDSS_HKFT.cpp:692
virtual doublereal intEnergy_mole() const
Return the molar internal Energy in units of J kmol-1.
Definition: PDSS_HKFT.cpp:235