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