Cantera  2.5.1
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 https://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 #include "WaterProps.h"
17 
18 namespace Cantera
19 {
20 class PDSS_Water;
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  //! Default Constructor
31  PDSS_HKFT();
32 
33  //! @name Molar Thermodynamic Properties of the Solution
34  //! @{
35 
36  // See PDSS.h for documentation of functions overridden from Class PDSS
37 
38  virtual doublereal enthalpy_mole() const;
39 
40  //! Return the molar enthalpy in units of J kmol-1
41  /*!
42  * Returns the species standard state enthalpy in J kmol-1 at the
43  * current temperature and pressure.
44  *
45  * Note this is just an extra routine to check the arithmetic
46  *
47  * @returns the species standard state enthalpy in J kmol-1
48  */
49  doublereal enthalpy_mole2() const;
50 
51  virtual doublereal intEnergy_mole() const;
52  virtual doublereal entropy_mole() const;
53  virtual doublereal gibbs_mole() const;
54  virtual doublereal cp_mole() const;
55  virtual doublereal molarVolume() const;
56  virtual doublereal density() const;
57 
58  //! @}
59  //! @name Properties of the Reference State of the Species in the Solution
60  //! @{
61 
62  doublereal refPressure() const {
63  return m_p0;
64  }
65 
66  virtual doublereal gibbs_RT_ref() const;
67  virtual doublereal enthalpy_RT_ref() const;
68  virtual doublereal entropy_R_ref() const;
69  virtual doublereal cp_R_ref() const;
70  virtual doublereal molarVolume_ref() const;
71 
72  //! @}
73  //! @name Mechanical Equation of State Properties
74  //! @{
75 
76  virtual void setState_TP(doublereal temp, doublereal pres);
77 
78  //! @}
79  //! @name Initialization of the Object
80  //! @{
81 
82  void setParent(VPStandardStateTP* phase, size_t k) {
83  m_tp = phase;
84  m_spindex = k;
85  }
86 
87  virtual void initThermo();
88 
89  //! Set enthalpy of formation at Pr, Tr [J/kmol]
90  void setDeltaH0(double dh0);
91 
92  //! Set Gibbs free energy of formation at Pr, Tr [J/kmol]
93  void setDeltaG0(double dg0);
94 
95  //! Set entropy of formation at Pr, Tr [J/kmol/K]
96  void setS0(double s0);
97 
98  //! Set "a" coefficients (array of 4 elements). Units of each coefficient
99  //! are [J/kmol/Pa, J/kmol, J*K/kmol/Pa, J*K/kmol]
100  void set_a(double* a);
101 
102  //! Set "c" coefficients (array of 2 elements). Units of each coefficient
103  //! are [J/kmol/K, J*K/kmol]
104  void set_c(double* c);
105  void setOmega(double omega); //!< Set omega [J/kmol]
106 
107  void setParametersFromXML(const XML_Node& speciesNode);
108 
109  //! This utility function reports back the type of parameterization and
110  //! all of the parameters for the species, index.
111  /*!
112  * The following parameters are reported
113  *
114  * - c[0] = m_deltaG_formation_tr_pr;
115  * - c[1] = m_deltaH_formation_tr_pr;
116  * - c[2] = m_Mu0_tr_pr;
117  * - c[3] = m_Entrop_tr_pr;
118  * - c[4] = m_a1;
119  * - c[5] = m_a2;
120  * - c[6] = m_a3;
121  * - c[7] = m_a4;
122  * - c[8] = m_c1;
123  * - c[9] = m_c2;
124  * - c[10] = m_omega_pr_tr;
125  * .
126  *
127  * @param kindex Species index
128  * @param type Integer type of the standard type
129  * @param c Vector of coefficients used to set the parameters for
130  * the standard state.
131  * @param minTemp output - Minimum temperature
132  * @param maxTemp output - Maximum temperature
133  * @param refPressure output - reference pressure (Pa).
134  */
135  virtual void reportParams(size_t& kindex, int& type, doublereal* const c,
136  doublereal& minTemp, doublereal& maxTemp,
137  doublereal& refPressure) const;
138  //@}
139 
140 private:
141  VPStandardStateTP* m_tp; //!< Parent VPStandardStateTP (ThermoPhase) object
142  size_t m_spindex; //!< Index of this species within the parent phase
143 
144  //! Main routine that actually calculates the Gibbs free energy difference
145  //! between the reference state at Tr, Pr and T,P
146  /*!
147  * This is eEqn. 59 in Johnson et al. (1992).
148  */
149  doublereal deltaG() const;
150 
151  //! Main routine that actually calculates the entropy difference
152  //! between the reference state at Tr, Pr and T,P
153  /*!
154  * This is Eqn. 61 in Johnson et al. (1992). Actually, there appears to
155  * be an error in the latter. This is a correction.
156  */
157  doublereal deltaS() const;
158 
159  //! Routine that actually calculates the enthalpy difference
160  //! between the reference state at Tr, Pr and T,P
161  /*!
162  * This is an extra routine that was added to check the arithmetic
163  */
164  doublereal deltaH() const;
165 
166  //! Internal formula for the calculation of a_g()
167  /*!
168  * The output of this is in units of Angstroms
169  *
170  * @param temp Temperature (K)
171  * @param ifunc parameters specifying the desired information
172  * - 0 function value
173  * - 1 derivative wrt temperature
174  * - 2 2nd derivative wrt temperature
175  * - 3 derivative wrt pressure
176  */
177  doublereal ag(const doublereal temp, const int ifunc = 0) const;
178 
179  //! Internal formula for the calculation of b_g()
180  /*!
181  * the output of this is unitless
182  *
183  * @param temp Temperature (K)
184  * @param ifunc parameters specifying the desired information
185  * - 0 function value
186  * - 1 derivative wrt temperature
187  * - 2 2nd derivative wrt temperature
188  * - 3 derivative wrt pressure
189  */
190  doublereal bg(const doublereal temp, const int ifunc = 0) const;
191 
192  //! function g appearing in the formulation
193  /*!
194  * Function g appearing in the Johnson et al formulation
195  *
196  * @param temp Temperature kelvin
197  * @param pres Pressure (pascal)
198  * @param ifunc parameters specifying the desired information
199  * - 0 function value
200  * - 1 derivative wrt temperature
201  * - 2 2nd derivative wrt temperature
202  * - 3 derivative wrt pressure
203  */
204  doublereal g(const doublereal temp, const doublereal pres, const int ifunc = 0) const;
205 
206  //! Difference function f appearing in the formulation
207  /*!
208  * Function f appearing in the Johnson et al formulation of omega_j
209  * Eqn. 33 ref
210  *
211  * @param temp Temperature kelvin
212  * @param pres Pressure (pascal)
213  * @param ifunc parameters specifying the desired information
214  * - 0 function value
215  * - 1 derivative wrt temperature
216  * - 2 2nd derivative wrt temperature
217  * - 3 derivative wrt pressure
218  */
219  doublereal f(const doublereal temp, const doublereal pres, const int ifunc = 0) const;
220 
221  //! Evaluate the Gstar value appearing in the HKFT formulation
222  /*!
223  * @param temp Temperature kelvin
224  * @param pres Pressure (pascal)
225  * @param ifunc parameters specifying the desired information
226  * - 0 function value
227  * - 1 derivative wrt temperature
228  * - 2 2nd derivative wrt temperature
229  * - 3 derivative wrt pressure
230  */
231  doublereal gstar(const doublereal temp, const doublereal pres,
232  const int ifunc = 0) const;
233 
234  //! Function to look up Element Free Energies
235  /*!
236  * This function looks up the argument string in the element database and
237  * returns the associated 298 K Gibbs Free energy of the element in its
238  * stable state.
239  *
240  * @param elemName String. Only the first 3 characters are significant
241  * @return value contains the Gibbs free energy for that element
242  *
243  * @exception CanteraError
244  * If a match is not found, a CanteraError is thrown as well
245  */
246  doublereal LookupGe(const std::string& elemName);
247 
248  //! Translate a Gibbs free energy of formation value to a NIST-based Chemical potential
249  /*!
250  * Internally, this function is used to translate the input value,
251  * m_deltaG_formation_tr_pr, to the internally stored value, m_Mu0_tr_pr.
252  */
253  void convertDGFormation();
254 
255 private:
256  //! Water standard state calculator
257  /*!
258  * derived from the equation of state for water.
259  * This object doesn't own the object. Just a shallow pointer.
260  */
262 
263  //! density of standard-state water. internal temporary variable
264  mutable doublereal m_densWaterSS;
265 
266  //! Pointer to the water property calculator
267  std::unique_ptr<WaterProps> m_waterProps;
268 
269  //! Input value of deltaG of Formation at Tr and Pr (cal gmol-1)
270  /*!
271  * Tr = 298.15 Pr = 1 atm
272  *
273  * This is the delta G for the formation reaction of the
274  * ion from elements in their stable state at Tr, Pr.
275  */
277 
278  //! Input value of deltaH of Formation at Tr and Pr (cal gmol-1)
279  /*!
280  * Tr = 298.15 Pr = 1 atm
281  *
282  * This is the delta H for the formation reaction of the
283  * ion from elements in their stable state at Tr, Pr.
284  */
286 
287  //! Value of the Absolute Gibbs Free Energy NIST scale at T_r and P_r
288  /*!
289  * This is the NIST scale value of Gibbs free energy at T_r = 298.15
290  * and P_r = 1 atm.
291  *
292  * J kmol-1
293  */
294  doublereal m_Mu0_tr_pr;
295 
296  //! Input value of S_j at Tr and Pr (cal gmol-1 K-1)
297  /*!
298  * Tr = 298.15 Pr = 1 atm
299  */
300  doublereal m_Entrop_tr_pr;
301 
302  //! Input a1 coefficient (cal gmol-1 bar-1)
303  doublereal m_a1;
304 
305  //! Input a2 coefficient (cal gmol-1)
306  doublereal m_a2;
307 
308  //! Input a3 coefficient (cal K gmol-1 bar-1)
309  doublereal m_a3;
310 
311  //! Input a4 coefficient (cal K gmol-1)
312  doublereal m_a4;
313 
314  //! Input c1 coefficient (cal gmol-1 K-1)
315  doublereal m_c1;
316 
317  //! Input c2 coefficient (cal K gmol-1)
318  doublereal m_c2;
319 
320  //! Input omega_pr_tr coefficient(cal gmol-1)
321  doublereal m_omega_pr_tr;
322 
323  //! y = dZdT = 1/(esp*esp) desp/dT at 298.15 and 1 bar
324  doublereal m_Y_pr_tr;
325 
326  //! Z = -1 / relEpsilon at 298.15 and 1 bar
327  doublereal m_Z_pr_tr;
328 
329  //! Reference pressure is 1 atm in units of bar= 1.0132
330  doublereal m_presR_bar;
331 
332  //! small value that is not quite zero
333  doublereal m_domega_jdT_prtr;
334 
335  //! Charge of the ion
336  doublereal m_charge_j;
337 
338  //! Static variable determining error exiting
339  /*!
340  * If true, then will error exit if there is an inconsistency in DG0, DH0, and DS0.
341  * If not, then will rewrite DH0 to be consistent with the other two.
342  */
344 };
345 
346 }
347 
348 #endif
Declarations for the virtual base class PDSS (pressure dependent standard state) which handles calcul...
Header for a class used to house several approximation routines for properties of water.
Class for pressure dependent standard states corresponding to ionic solutes in electrolyte water.
Definition: PDSS_HKFT.h:28
void setOmega(double omega)
Set omega [J/kmol].
Definition: PDSS_HKFT.cpp:369
static int s_InputInconsistencyErrorExit
Static variable determining error exiting.
Definition: PDSS_HKFT.h:343
virtual doublereal cp_R_ref() const
Return the molar heat capacity divided by R at reference pressure.
Definition: PDSS_HKFT.cpp:212
doublereal m_deltaG_formation_tr_pr
Input value of deltaG of Formation at Tr and Pr (cal gmol-1)
Definition: PDSS_HKFT.h:276
size_t m_spindex
Index of this species within the parent phase.
Definition: PDSS_HKFT.h:142
doublereal m_a3
Input a3 coefficient (cal K gmol-1 bar-1)
Definition: PDSS_HKFT.h:309
doublereal m_domega_jdT_prtr
small value that is not quite zero
Definition: PDSS_HKFT.h:333
doublereal m_a4
Input a4 coefficient (cal K gmol-1)
Definition: PDSS_HKFT.h:312
doublereal m_charge_j
Charge of the ion.
Definition: PDSS_HKFT.h:336
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:737
doublereal m_c2
Input c2 coefficient (cal K gmol-1)
Definition: PDSS_HKFT.h:318
doublereal m_c1
Input c1 coefficient (cal gmol-1 K-1)
Definition: PDSS_HKFT.h:315
doublereal deltaH() const
Routine that actually calculates the enthalpy difference between the reference state at Tr,...
Definition: PDSS_HKFT.cpp:456
virtual doublereal cp_mole() const
Return the molar const pressure heat capacity in units of J kmol-1 K-1.
Definition: PDSS_HKFT.cpp:78
VPStandardStateTP * m_tp
Parent VPStandardStateTP (ThermoPhase) object.
Definition: PDSS_HKFT.h:141
virtual doublereal enthalpy_mole() const
Return the molar enthalpy in units of J kmol-1.
Definition: PDSS_HKFT.cpp:50
void setDeltaG0(double dg0)
Set Gibbs free energy of formation at Pr, Tr [J/kmol].
Definition: PDSS_HKFT.cpp:349
virtual void setState_TP(doublereal temp, doublereal pres)
Set the internal temperature and pressure.
Definition: PDSS_HKFT.cpp:230
doublereal m_omega_pr_tr
Input omega_pr_tr coefficient(cal gmol-1)
Definition: PDSS_HKFT.h:321
doublereal m_a2
Input a2 coefficient (cal gmol-1)
Definition: PDSS_HKFT.h:306
doublereal m_densWaterSS
density of standard-state water. internal temporary variable
Definition: PDSS_HKFT.h:264
doublereal m_Entrop_tr_pr
Input value of S_j at Tr and Pr (cal gmol-1 K-1)
Definition: PDSS_HKFT.h:300
PDSS_HKFT()
Default Constructor.
Definition: PDSS_HKFT.cpp:25
doublereal bg(const doublereal temp, const int ifunc=0) const
Internal formula for the calculation of b_g()
Definition: PDSS_HKFT.cpp:594
doublereal g(const doublereal temp, const doublereal pres, const int ifunc=0) const
function g appearing in the formulation
Definition: PDSS_HKFT.cpp:642
doublereal m_Y_pr_tr
y = dZdT = 1/(esp*esp) desp/dT at 298.15 and 1 bar
Definition: PDSS_HKFT.h:324
void setS0(double s0)
Set entropy of formation at Pr, Tr [J/kmol/K].
Definition: PDSS_HKFT.cpp:353
doublereal ag(const doublereal temp, const int ifunc=0) const
Internal formula for the calculation of a_g()
Definition: PDSS_HKFT.cpp:580
doublereal f(const doublereal temp, const doublereal pres, const int ifunc=0) const
Difference function f appearing in the formulation.
Definition: PDSS_HKFT.cpp:608
virtual doublereal entropy_mole() const
Return the molar entropy in units of J kmol-1 K-1.
Definition: PDSS_HKFT.cpp:68
doublereal m_a1
Input a1 coefficient (cal gmol-1 bar-1)
Definition: PDSS_HKFT.h:303
doublereal enthalpy_mole2() const
Return the molar enthalpy in units of J kmol-1.
Definition: PDSS_HKFT.cpp:57
virtual doublereal molarVolume_ref() const
Return the molar volume at reference pressure.
Definition: PDSS_HKFT.cpp:221
virtual void initThermo()
Initialization routine.
Definition: PDSS_HKFT.cpp:236
doublereal m_Z_pr_tr
Z = -1 / relEpsilon at 298.15 and 1 bar.
Definition: PDSS_HKFT.h:327
doublereal m_deltaH_formation_tr_pr
Input value of deltaH of Formation at Tr and Pr (cal gmol-1)
Definition: PDSS_HKFT.h:285
void set_a(double *a)
Set "a" coefficients (array of 4 elements).
Definition: PDSS_HKFT.cpp:357
doublereal LookupGe(const std::string &elemName)
Function to look up Element Free Energies.
Definition: PDSS_HKFT.cpp:703
virtual doublereal molarVolume() const
Return the molar volume at standard state.
Definition: PDSS_HKFT.cpp:137
void setParametersFromXML(const XML_Node &speciesNode)
Initialization routine for the PDSS object based on the speciesNode.
Definition: PDSS_HKFT.cpp:373
virtual doublereal gibbs_mole() const
Return the molar Gibbs free energy in units of J kmol-1.
Definition: PDSS_HKFT.cpp:73
virtual doublereal enthalpy_RT_ref() const
Return the molar enthalpy divided by RT at reference pressure.
Definition: PDSS_HKFT.cpp:194
doublereal deltaS() const
Main routine that actually calculates the entropy difference between the reference state at Tr,...
Definition: PDSS_HKFT.cpp:539
void convertDGFormation()
Translate a Gibbs free energy of formation value to a NIST-based Chemical potential.
Definition: PDSS_HKFT.cpp:717
void setParent(VPStandardStateTP *phase, size_t k)
Set the parent VPStandardStateTP object of this PDSS object.
Definition: PDSS_HKFT.h:82
doublereal m_Mu0_tr_pr
Value of the Absolute Gibbs Free Energy NIST scale at T_r and P_r.
Definition: PDSS_HKFT.h:294
virtual doublereal density() const
Return the standard state density at standard state.
Definition: PDSS_HKFT.cpp:180
doublereal m_presR_bar
Reference pressure is 1 atm in units of bar= 1.0132.
Definition: PDSS_HKFT.h:330
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:695
virtual doublereal entropy_R_ref() const
Return the molar entropy divided by R at reference pressure.
Definition: PDSS_HKFT.cpp:203
virtual doublereal gibbs_RT_ref() const
Return the molar Gibbs free energy divided by RT at reference pressure.
Definition: PDSS_HKFT.cpp:185
PDSS_Water * m_waterSS
Water standard state calculator.
Definition: PDSS_HKFT.h:261
doublereal deltaG() const
Main routine that actually calculates the Gibbs free energy difference between the reference state at...
Definition: PDSS_HKFT.cpp:505
std::unique_ptr< WaterProps > m_waterProps
Pointer to the water property calculator.
Definition: PDSS_HKFT.h:267
void set_c(double *c)
Set "c" coefficients (array of 2 elements).
Definition: PDSS_HKFT.cpp:364
virtual doublereal intEnergy_mole() const
Return the molar internal Energy in units of J kmol-1.
Definition: PDSS_HKFT.cpp:63
void setDeltaH0(double dh0)
Set enthalpy of formation at Pr, Tr [J/kmol].
Definition: PDSS_HKFT.cpp:345
Base class for PDSS classes which compute molar properties directly.
Definition: PDSS.h:492
Class for the liquid water pressure dependent standard state.
Definition: PDSS_Water.h:50
doublereal maxTemp() const
return the minimum temperature
Definition: PDSS.h:285
doublereal minTemp() const
return the minimum temperature
Definition: PDSS.h:280
doublereal m_p0
Reference state pressure of the species.
Definition: PDSS.h:470
This is a filter class for ThermoPhase that implements some preparatory steps for efficiently handlin...
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:104
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:264