Cantera 2.6.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 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
18namespace Cantera
19{
20class PDSS_Water;
21
22//! Class for pressure dependent standard states corresponding to
23//! ionic solutes in electrolyte water.
24/*!
25 * @ingroup pdssthermo
26 */
27class PDSS_HKFT : public PDSS_Molar
28{
29public:
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 virtual void getParameters(AnyMap& eosNode) const;
109
110 //! This utility function reports back the type of parameterization and
111 //! all of the parameters for the species, index.
112 /*!
113 * The following parameters are reported
114 *
115 * - c[0] = m_deltaG_formation_tr_pr;
116 * - c[1] = m_deltaH_formation_tr_pr;
117 * - c[2] = m_Mu0_tr_pr;
118 * - c[3] = m_Entrop_tr_pr;
119 * - c[4] = m_a1;
120 * - c[5] = m_a2;
121 * - c[6] = m_a3;
122 * - c[7] = m_a4;
123 * - c[8] = m_c1;
124 * - c[9] = m_c2;
125 * - c[10] = m_omega_pr_tr;
126 * .
127 *
128 * @param kindex Species index
129 * @param type Integer type of the standard type
130 * @param c Vector of coefficients used to set the parameters for
131 * the standard state.
132 * @param minTemp output - Minimum temperature
133 * @param maxTemp output - Maximum temperature
134 * @param refPressure output - reference pressure (Pa).
135 */
136 virtual void reportParams(size_t& kindex, int& type, doublereal* const c,
137 doublereal& minTemp, doublereal& maxTemp,
138 doublereal& refPressure) const;
139 //! @}
140
141private:
142 VPStandardStateTP* m_tp; //!< Parent VPStandardStateTP (ThermoPhase) object
143 size_t m_spindex; //!< Index of this species within the parent phase
144
145 //! Main routine that actually calculates the Gibbs free energy difference
146 //! between the reference state at Tr, Pr and T,P
147 /*!
148 * This is eEqn. 59 in Johnson et al. (1992).
149 */
150 doublereal deltaG() const;
151
152 //! Main routine that actually calculates the entropy difference
153 //! between the reference state at Tr, Pr and T,P
154 /*!
155 * This is Eqn. 61 in Johnson et al. (1992). Actually, there appears to
156 * be an error in the latter. This is a correction.
157 */
158 doublereal deltaS() const;
159
160 //! Routine that actually calculates the enthalpy difference
161 //! between the reference state at Tr, Pr and T,P
162 /*!
163 * This is an extra routine that was added to check the arithmetic
164 */
165 doublereal deltaH() const;
166
167 //! Internal formula for the calculation of a_g()
168 /*!
169 * The output of this is in units of Angstroms
170 *
171 * @param temp Temperature (K)
172 * @param ifunc parameters specifying the desired information
173 * - 0 function value
174 * - 1 derivative wrt temperature
175 * - 2 2nd derivative wrt temperature
176 * - 3 derivative wrt pressure
177 */
178 doublereal ag(const doublereal temp, const int ifunc = 0) const;
179
180 //! Internal formula for the calculation of b_g()
181 /*!
182 * the output of this is unitless
183 *
184 * @param temp Temperature (K)
185 * @param ifunc parameters specifying the desired information
186 * - 0 function value
187 * - 1 derivative wrt temperature
188 * - 2 2nd derivative wrt temperature
189 * - 3 derivative wrt pressure
190 */
191 doublereal bg(const doublereal temp, const int ifunc = 0) const;
192
193 //! function g appearing in the formulation
194 /*!
195 * Function g appearing in the Johnson et al formulation
196 *
197 * @param temp Temperature kelvin
198 * @param pres Pressure (pascal)
199 * @param ifunc parameters specifying the desired information
200 * - 0 function value
201 * - 1 derivative wrt temperature
202 * - 2 2nd derivative wrt temperature
203 * - 3 derivative wrt pressure
204 */
205 doublereal g(const doublereal temp, const doublereal pres, const int ifunc = 0) const;
206
207 //! Difference function f appearing in the formulation
208 /*!
209 * Function f appearing in the Johnson et al formulation of omega_j
210 * Eqn. 33 ref
211 *
212 * @param temp Temperature kelvin
213 * @param pres Pressure (pascal)
214 * @param ifunc parameters specifying the desired information
215 * - 0 function value
216 * - 1 derivative wrt temperature
217 * - 2 2nd derivative wrt temperature
218 * - 3 derivative wrt pressure
219 */
220 doublereal f(const doublereal temp, const doublereal pres, const int ifunc = 0) const;
221
222 //! Evaluate the Gstar value appearing in the HKFT formulation
223 /*!
224 * @param temp Temperature kelvin
225 * @param pres Pressure (pascal)
226 * @param ifunc parameters specifying the desired information
227 * - 0 function value
228 * - 1 derivative wrt temperature
229 * - 2 2nd derivative wrt temperature
230 * - 3 derivative wrt pressure
231 */
232 doublereal gstar(const doublereal temp, const doublereal pres,
233 const int ifunc = 0) const;
234
235 //! Function to look up Element Free Energies
236 /*!
237 * This function looks up the argument string in the element database and
238 * returns the associated 298 K Gibbs Free energy of the element in its
239 * stable state.
240 *
241 * @param elemName String. Only the first 3 characters are significant
242 * @return value contains the Gibbs free energy for that element
243 *
244 * @exception CanteraError
245 * If a match is not found, a CanteraError is thrown as well
246 */
247 doublereal LookupGe(const std::string& elemName);
248
249 //! Translate a Gibbs free energy of formation value to a NIST-based Chemical potential
250 /*!
251 * Internally, this function is used to translate the input value,
252 * m_deltaG_formation_tr_pr, to the internally stored value, m_Mu0_tr_pr.
253 */
254 void convertDGFormation();
255
256private:
257 //! Water standard state calculator
258 /*!
259 * derived from the equation of state for water.
260 * This object doesn't own the object. Just a shallow pointer.
261 */
263
264 //! density of standard-state water. internal temporary variable
265 mutable doublereal m_densWaterSS;
266
267 //! Pointer to the water property calculator
268 std::unique_ptr<WaterProps> m_waterProps;
269
270 //! Input value of deltaG of Formation at Tr and Pr (cal gmol-1)
271 /*!
272 * Tr = 298.15 Pr = 1 atm
273 *
274 * This is the delta G for the formation reaction of the
275 * ion from elements in their stable state at Tr, Pr.
276 */
278
279 //! Input value of deltaH of Formation at Tr and Pr (cal gmol-1)
280 /*!
281 * Tr = 298.15 Pr = 1 atm
282 *
283 * This is the delta H for the formation reaction of the
284 * ion from elements in their stable state at Tr, Pr.
285 */
287
288 //! Value of the Absolute Gibbs Free Energy NIST scale at T_r and P_r
289 /*!
290 * This is the NIST scale value of Gibbs free energy at T_r = 298.15
291 * and P_r = 1 atm.
292 *
293 * J kmol-1
294 */
295 doublereal m_Mu0_tr_pr;
296
297 //! Input value of S_j at Tr and Pr (cal gmol-1 K-1)
298 /*!
299 * Tr = 298.15 Pr = 1 atm
300 */
301 doublereal m_Entrop_tr_pr;
302
303 //! Input a1 coefficient (cal gmol-1 bar-1)
304 doublereal m_a1;
305
306 //! Input a2 coefficient (cal gmol-1)
307 doublereal m_a2;
308
309 //! Input a3 coefficient (cal K gmol-1 bar-1)
310 doublereal m_a3;
311
312 //! Input a4 coefficient (cal K gmol-1)
313 doublereal m_a4;
314
315 //! Input c1 coefficient (cal gmol-1 K-1)
316 doublereal m_c1;
317
318 //! Input c2 coefficient (cal K gmol-1)
319 doublereal m_c2;
320
321 //! Input omega_pr_tr coefficient(cal gmol-1)
322 doublereal m_omega_pr_tr;
323
324 //! y = dZdT = 1/(esp*esp) desp/dT at 298.15 and 1 bar
325 doublereal m_Y_pr_tr;
326
327 //! Z = -1 / relEpsilon at 298.15 and 1 bar
328 doublereal m_Z_pr_tr;
329
330 //! Reference pressure is 1 atm in units of bar= 1.0132
331 doublereal m_presR_bar;
332
333 //! small value that is not quite zero
335
336 //! Charge of the ion
337 doublereal m_charge_j;
338
339 //! Static variable determining error exiting
340 /*!
341 * If true, then will error exit if there is an inconsistency in DG0, DH0, and DS0.
342 * If not, then will rewrite DH0 to be consistent with the other two.
343 */
345};
346
347}
348
349#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.
A map of string keys to values whose type can vary at runtime.
Definition: AnyMap.h:399
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:370
static int s_InputInconsistencyErrorExit
Static variable determining error exiting.
Definition: PDSS_HKFT.h:344
virtual void getParameters(AnyMap &eosNode) const
Store the parameters needed to reconstruct a copy of this PDSS object.
Definition: PDSS_HKFT.cpp:457
virtual doublereal cp_R_ref() const
Return the molar heat capacity divided by R at reference pressure.
Definition: PDSS_HKFT.cpp:213
doublereal m_deltaG_formation_tr_pr
Input value of deltaG of Formation at Tr and Pr (cal gmol-1)
Definition: PDSS_HKFT.h:277
size_t m_spindex
Index of this species within the parent phase.
Definition: PDSS_HKFT.h:143
doublereal m_a3
Input a3 coefficient (cal K gmol-1 bar-1)
Definition: PDSS_HKFT.h:310
doublereal m_domega_jdT_prtr
small value that is not quite zero
Definition: PDSS_HKFT.h:334
doublereal m_a4
Input a4 coefficient (cal K gmol-1)
Definition: PDSS_HKFT.h:313
doublereal m_charge_j
Charge of the ion.
Definition: PDSS_HKFT.h:337
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:760
doublereal m_c2
Input c2 coefficient (cal K gmol-1)
Definition: PDSS_HKFT.h:319
doublereal m_c1
Input c1 coefficient (cal gmol-1 K-1)
Definition: PDSS_HKFT.h:316
doublereal deltaH() const
Routine that actually calculates the enthalpy difference between the reference state at Tr,...
Definition: PDSS_HKFT.cpp:479
virtual doublereal cp_mole() const
Return the molar const pressure heat capacity in units of J kmol-1 K-1.
Definition: PDSS_HKFT.cpp:79
VPStandardStateTP * m_tp
Parent VPStandardStateTP (ThermoPhase) object.
Definition: PDSS_HKFT.h:142
virtual doublereal enthalpy_mole() const
Return the molar enthalpy in units of J kmol-1.
Definition: PDSS_HKFT.cpp:51
void setDeltaG0(double dg0)
Set Gibbs free energy of formation at Pr, Tr [J/kmol].
Definition: PDSS_HKFT.cpp:350
virtual void setState_TP(doublereal temp, doublereal pres)
Set the internal temperature and pressure.
Definition: PDSS_HKFT.cpp:231
doublereal m_omega_pr_tr
Input omega_pr_tr coefficient(cal gmol-1)
Definition: PDSS_HKFT.h:322
doublereal m_a2
Input a2 coefficient (cal gmol-1)
Definition: PDSS_HKFT.h:307
doublereal m_densWaterSS
density of standard-state water. internal temporary variable
Definition: PDSS_HKFT.h:265
doublereal m_Entrop_tr_pr
Input value of S_j at Tr and Pr (cal gmol-1 K-1)
Definition: PDSS_HKFT.h:301
PDSS_HKFT()
Default Constructor.
Definition: PDSS_HKFT.cpp:26
doublereal bg(const doublereal temp, const int ifunc=0) const
Internal formula for the calculation of b_g()
Definition: PDSS_HKFT.cpp:617
doublereal g(const doublereal temp, const doublereal pres, const int ifunc=0) const
function g appearing in the formulation
Definition: PDSS_HKFT.cpp:665
doublereal m_Y_pr_tr
y = dZdT = 1/(esp*esp) desp/dT at 298.15 and 1 bar
Definition: PDSS_HKFT.h:325
void setS0(double s0)
Set entropy of formation at Pr, Tr [J/kmol/K].
Definition: PDSS_HKFT.cpp:354
doublereal ag(const doublereal temp, const int ifunc=0) const
Internal formula for the calculation of a_g()
Definition: PDSS_HKFT.cpp:603
doublereal f(const doublereal temp, const doublereal pres, const int ifunc=0) const
Difference function f appearing in the formulation.
Definition: PDSS_HKFT.cpp:631
virtual doublereal entropy_mole() const
Return the molar entropy in units of J kmol-1 K-1.
Definition: PDSS_HKFT.cpp:69
doublereal m_a1
Input a1 coefficient (cal gmol-1 bar-1)
Definition: PDSS_HKFT.h:304
doublereal enthalpy_mole2() const
Return the molar enthalpy in units of J kmol-1.
Definition: PDSS_HKFT.cpp:58
virtual doublereal molarVolume_ref() const
Return the molar volume at reference pressure.
Definition: PDSS_HKFT.cpp:222
virtual void initThermo()
Initialization routine.
Definition: PDSS_HKFT.cpp:237
doublereal m_Z_pr_tr
Z = -1 / relEpsilon at 298.15 and 1 bar.
Definition: PDSS_HKFT.h:328
doublereal m_deltaH_formation_tr_pr
Input value of deltaH of Formation at Tr and Pr (cal gmol-1)
Definition: PDSS_HKFT.h:286
void set_a(double *a)
Set "a" coefficients (array of 4 elements).
Definition: PDSS_HKFT.cpp:358
doublereal LookupGe(const std::string &elemName)
Function to look up Element Free Energies.
Definition: PDSS_HKFT.cpp:726
virtual doublereal molarVolume() const
Return the molar volume at standard state.
Definition: PDSS_HKFT.cpp:138
void setParametersFromXML(const XML_Node &speciesNode)
Initialization routine for the PDSS object based on the speciesNode.
Definition: PDSS_HKFT.cpp:374
virtual doublereal gibbs_mole() const
Return the molar Gibbs free energy in units of J kmol-1.
Definition: PDSS_HKFT.cpp:74
virtual doublereal enthalpy_RT_ref() const
Return the molar enthalpy divided by RT at reference pressure.
Definition: PDSS_HKFT.cpp:195
doublereal deltaS() const
Main routine that actually calculates the entropy difference between the reference state at Tr,...
Definition: PDSS_HKFT.cpp:562
void convertDGFormation()
Translate a Gibbs free energy of formation value to a NIST-based Chemical potential.
Definition: PDSS_HKFT.cpp:740
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:295
virtual doublereal density() const
Return the standard state density at standard state.
Definition: PDSS_HKFT.cpp:181
doublereal m_presR_bar
Reference pressure is 1 atm in units of bar= 1.0132.
Definition: PDSS_HKFT.h:331
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:718
virtual doublereal entropy_R_ref() const
Return the molar entropy divided by R at reference pressure.
Definition: PDSS_HKFT.cpp:204
virtual doublereal gibbs_RT_ref() const
Return the molar Gibbs free energy divided by RT at reference pressure.
Definition: PDSS_HKFT.cpp:186
PDSS_Water * m_waterSS
Water standard state calculator.
Definition: PDSS_HKFT.h:262
doublereal deltaG() const
Main routine that actually calculates the Gibbs free energy difference between the reference state at...
Definition: PDSS_HKFT.cpp:528
std::unique_ptr< WaterProps > m_waterProps
Pointer to the water property calculator.
Definition: PDSS_HKFT.h:268
void set_c(double *c)
Set "c" coefficients (array of 2 elements).
Definition: PDSS_HKFT.cpp:365
virtual doublereal intEnergy_mole() const
Return the molar internal Energy in units of J kmol-1.
Definition: PDSS_HKFT.cpp:64
void setDeltaH0(double dh0)
Set enthalpy of formation at Pr, Tr [J/kmol].
Definition: PDSS_HKFT.cpp:346
Base class for PDSS classes which compute molar properties directly.
Definition: PDSS.h:483
Class for the liquid water pressure dependent standard state.
Definition: PDSS_Water.h:50
doublereal maxTemp() const
return the minimum temperature
Definition: PDSS.h:281
doublereal minTemp() const
return the minimum temperature
Definition: PDSS.h:276
doublereal m_p0
Reference state pressure of the species.
Definition: PDSS.h:461
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:103
Namespace for the Cantera kernel.
Definition: AnyMap.h:29