Cantera  3.1.0a1
Loading...
Searching...
No Matches
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 double enthalpy_mole() const override;
39
40 double intEnergy_mole() const override;
41 double entropy_mole() const override;
42 double gibbs_mole() const override;
43 double cp_mole() const override;
44 double molarVolume() const override;
45 double density() const override;
46
47 //! @}
48 //! @name Properties of the Reference State of the Species in the Solution
49 //! @{
50
51 double refPressure() const {
52 return m_p0;
53 }
54
55 double gibbs_RT_ref() const override;
56 double enthalpy_RT_ref() const override;
57 double entropy_R_ref() const override;
58 double cp_R_ref() const override;
59 double molarVolume_ref() const override;
60
61 //! @}
62 //! @name Mechanical Equation of State Properties
63 //! @{
64
65 void setState_TP(double temp, double pres) override;
66
67 //! @}
68 //! @name Initialization of the Object
69 //! @{
70
71 void setParent(VPStandardStateTP* phase, size_t k) override {
72 m_tp = phase;
73 m_spindex = k;
74 }
75
76 void initThermo() override;
77
78 //! Set enthalpy of formation at Pr, Tr [J/kmol]
79 void setDeltaH0(double dh0);
80
81 //! Set Gibbs free energy of formation at Pr, Tr [J/kmol]
82 void setDeltaG0(double dg0);
83
84 //! Set entropy of formation at Pr, Tr [J/kmol/K]
85 void setS0(double s0);
86
87 //! Set "a" coefficients (array of 4 elements). Units of each coefficient
88 //! are [J/kmol/Pa, J/kmol, J*K/kmol/Pa, J*K/kmol]
89 void set_a(double* a);
90
91 //! Set "c" coefficients (array of 2 elements). Units of each coefficient
92 //! are [J/kmol/K, J*K/kmol]
93 void set_c(double* c);
94 void setOmega(double omega); //!< Set omega [J/kmol]
95
96 void getParameters(AnyMap& eosNode) const override;
97 //! @}
98
99private:
100 VPStandardStateTP* m_tp; //!< Parent VPStandardStateTP (ThermoPhase) object
101 size_t m_spindex; //!< Index of this species within the parent phase
102
103 //! Main routine that actually calculates the Gibbs free energy difference
104 //! between the reference state at Tr, Pr and T,P
105 /*!
106 * This is Eqn. 59 in Johnson et al. @cite johnson1992.
107 */
108 double deltaG() const;
109
110 //! Main routine that actually calculates the entropy difference
111 //! between the reference state at Tr, Pr and T,P
112 /*!
113 * This is Eqn. 61 in Johnson et al. @cite johnson1992. Actually, there appears to
114 * be an error in the latter. This is a correction.
115 */
116 double deltaS() const;
117
118 //! Internal formula for the calculation of a_g()
119 /*!
120 * The output of this is in units of Angstroms
121 *
122 * @param temp Temperature (K)
123 * @param ifunc parameters specifying the desired information
124 * - 0 function value
125 * - 1 derivative wrt temperature
126 * - 2 2nd derivative wrt temperature
127 * - 3 derivative wrt pressure
128 */
129 double ag(const double temp, const int ifunc = 0) const;
130
131 //! Internal formula for the calculation of b_g()
132 /*!
133 * the output of this is unitless
134 *
135 * @param temp Temperature (K)
136 * @param ifunc parameters specifying the desired information
137 * - 0 function value
138 * - 1 derivative wrt temperature
139 * - 2 2nd derivative wrt temperature
140 * - 3 derivative wrt pressure
141 */
142 double bg(const double temp, const int ifunc = 0) const;
143
144 //! function g appearing in the formulation
145 /*!
146 * Function @f$ g @f$ (Eqn. 49) appearing in the Johnson et al. @cite johnson1992
147 * formulation.
148 *
149 * @param temp Temperature kelvin
150 * @param pres Pressure (pascal)
151 * @param ifunc parameters specifying the desired information
152 * - 0 function value
153 * - 1 derivative wrt temperature
154 * - 2 2nd derivative wrt temperature
155 * - 3 derivative wrt pressure
156 */
157 double g(const double temp, const double pres, const int ifunc = 0) const;
158
159 //! Difference function f appearing in the formulation
160 /*!
161 * Function @f$ f @f$ (Eqn. 52) appearing in the Johnson et al. @cite johnson1992
162 * formulation of @f$ \omega_j @f$ (Eqn. 46).
163 *
164 * @param temp Temperature kelvin
165 * @param pres Pressure (pascal)
166 * @param ifunc parameters specifying the desired information
167 * - 0 function value
168 * - 1 derivative wrt temperature
169 * - 2 2nd derivative wrt temperature
170 * - 3 derivative wrt pressure
171 */
172 double f(const double temp, const double pres, const int ifunc = 0) const;
173
174 //! Evaluate the Gstar value appearing in the HKFT formulation
175 /*!
176 * @param temp Temperature kelvin
177 * @param pres Pressure (pascal)
178 * @param ifunc parameters specifying the desired information
179 * - 0 function value
180 * - 1 derivative wrt temperature
181 * - 2 2nd derivative wrt temperature
182 * - 3 derivative wrt pressure
183 */
184 double gstar(const double temp, const double pres, const int ifunc = 0) const;
185
186 //! Function to look up Element Free Energies
187 /*!
188 * This function looks up the argument string in the element database and
189 * returns the associated 298 K Gibbs Free energy of the element in its
190 * stable state.
191 *
192 * @param elemName String. Only the first 3 characters are significant
193 * @return value contains the Gibbs free energy for that element
194 *
195 * @exception CanteraError
196 * If a match is not found, a CanteraError is thrown as well
197 */
198 double LookupGe(const string& elemName);
199
200 //! Translate a Gibbs free energy of formation value to a NIST-based Chemical potential
201 /*!
202 * Internally, this function is used to translate the input value,
203 * m_deltaG_formation_tr_pr, to the internally stored value, m_Mu0_tr_pr.
204 */
205 void convertDGFormation();
206
207private:
208 //! Water standard state calculator
209 /*!
210 * derived from the equation of state for water.
211 * This object doesn't own the object. Just a shallow pointer.
212 */
214
215 UnitSystem m_units;
216
217 //! density of standard-state water. internal temporary variable
218 mutable double m_densWaterSS = -1.0;
219
220 //! Pointer to the water property calculator
221 unique_ptr<WaterProps> m_waterProps;
222
223 //! Input value of deltaG of Formation at Tr and Pr (cal gmol-1)
224 /*!
225 * Tr = 298.15 Pr = 1 atm
226 *
227 * This is the delta G for the formation reaction of the
228 * ion from elements in their stable state at Tr, Pr.
229 */
231
232 //! Input value of deltaH of Formation at Tr and Pr (cal gmol-1)
233 /*!
234 * Tr = 298.15 Pr = 1 atm
235 *
236 * This is the delta H for the formation reaction of the
237 * ion from elements in their stable state at Tr, Pr.
238 */
240
241 //! Value of the Absolute Gibbs Free Energy NIST scale at T_r and P_r
242 /*!
243 * This is the NIST scale value of Gibbs free energy at T_r = 298.15
244 * and P_r = 1 atm.
245 *
246 * J kmol-1
247 */
248 double m_Mu0_tr_pr = 0.0;
249
250 //! Input value of S_j at Tr and Pr (cal gmol-1 K-1)
251 /*!
252 * Tr = 298.15 Pr = 1 atm
253 */
254 double m_Entrop_tr_pr = NAN;
255
256 //! Input a1 coefficient (cal gmol-1 bar-1)
257 double m_a1 = 0.0;
258
259 //! Input a2 coefficient (cal gmol-1)
260 double m_a2 = 0.0;
261
262 //! Input a3 coefficient (cal K gmol-1 bar-1)
263 double m_a3 = 0.0;
264
265 //! Input a4 coefficient (cal K gmol-1)
266 double m_a4 = 0.0;
267
268 //! Input c1 coefficient (cal gmol-1 K-1)
269 double m_c1 = 0.0;
270
271 //! Input c2 coefficient (cal K gmol-1)
272 double m_c2 = 0.0;
273
274 //! Input omega_pr_tr coefficient(cal gmol-1)
275 double m_omega_pr_tr = 0.0;
276
277 //! y = dZdT = 1/(esp*esp) desp/dT at 298.15 and 1 bar
278 double m_Y_pr_tr = 0.0;
279
280 //! Z = -1 / relEpsilon at 298.15 and 1 bar
281 double m_Z_pr_tr = 0.0;
282
283 //! Reference pressure is 1 atm in units of bar= 1.0132
284 double m_presR_bar = OneAtm * 1.0E-5;
285
286 //! small value that is not quite zero
287 double m_domega_jdT_prtr = 0.0;
288
289 //! Charge of the ion
290 double m_charge_j = 0.0;
291
292 //! Static variable determining error exiting
293 /*!
294 * If true, then will error exit if there is an inconsistency in DG0, DH0, and DS0.
295 * If not, then will rewrite DH0 to be consistent with the other two.
296 */
298};
299
300}
301
302#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:427
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].
double molarVolume() const override
Return the molar volume at standard state.
static int s_InputInconsistencyErrorExit
Static variable determining error exiting.
Definition PDSS_HKFT.h:297
double m_Y_pr_tr
y = dZdT = 1/(esp*esp) desp/dT at 298.15 and 1 bar
Definition PDSS_HKFT.h:278
double m_a4
Input a4 coefficient (cal K gmol-1)
Definition PDSS_HKFT.h:266
void setParent(VPStandardStateTP *phase, size_t k) override
Set the parent VPStandardStateTP object of this PDSS object.
Definition PDSS_HKFT.h:71
double enthalpy_mole() const override
Return the molar enthalpy in units of J kmol-1.
Definition PDSS_HKFT.cpp:29
unique_ptr< WaterProps > m_waterProps
Pointer to the water property calculator.
Definition PDSS_HKFT.h:221
double deltaS() const
Main routine that actually calculates the entropy difference between the reference state at Tr,...
double f(const double temp, const double pres, const int ifunc=0) const
Difference function f appearing in the formulation.
size_t m_spindex
Index of this species within the parent phase.
Definition PDSS_HKFT.h:101
double m_densWaterSS
density of standard-state water. internal temporary variable
Definition PDSS_HKFT.h:218
double LookupGe(const string &elemName)
Function to look up Element Free Energies.
double gibbs_RT_ref() const override
Return the molar Gibbs free energy divided by RT at reference pressure.
VPStandardStateTP * m_tp
Parent VPStandardStateTP (ThermoPhase) object.
Definition PDSS_HKFT.h:100
double m_Entrop_tr_pr
Input value of S_j at Tr and Pr (cal gmol-1 K-1)
Definition PDSS_HKFT.h:254
double m_deltaG_formation_tr_pr
Input value of deltaG of Formation at Tr and Pr (cal gmol-1)
Definition PDSS_HKFT.h:230
void setDeltaG0(double dg0)
Set Gibbs free energy of formation at Pr, Tr [J/kmol].
void initThermo() override
Initialization routine.
double m_a3
Input a3 coefficient (cal K gmol-1 bar-1)
Definition PDSS_HKFT.h:263
double gstar(const double temp, const double pres, const int ifunc=0) const
Evaluate the Gstar value appearing in the HKFT formulation.
double m_charge_j
Charge of the ion.
Definition PDSS_HKFT.h:290
PDSS_HKFT()
Default Constructor.
Definition PDSS_HKFT.cpp:23
double entropy_R_ref() const override
Return the molar entropy divided by R at reference pressure.
double deltaG() const
Main routine that actually calculates the Gibbs free energy difference between the reference state at...
double enthalpy_RT_ref() const override
Return the molar enthalpy divided by RT at reference pressure.
void setS0(double s0)
Set entropy of formation at Pr, Tr [J/kmol/K].
double bg(const double temp, const int ifunc=0) const
Internal formula for the calculation of b_g()
void getParameters(AnyMap &eosNode) const override
Store the parameters needed to reconstruct a copy of this PDSS object.
double m_c2
Input c2 coefficient (cal K gmol-1)
Definition PDSS_HKFT.h:272
double m_presR_bar
Reference pressure is 1 atm in units of bar= 1.0132.
Definition PDSS_HKFT.h:284
void set_a(double *a)
Set "a" coefficients (array of 4 elements).
double intEnergy_mole() const override
Return the molar internal Energy in units of J kmol-1.
Definition PDSS_HKFT.cpp:36
double m_domega_jdT_prtr
small value that is not quite zero
Definition PDSS_HKFT.h:287
double entropy_mole() const override
Return the molar entropy in units of J kmol-1 K-1.
Definition PDSS_HKFT.cpp:41
double m_omega_pr_tr
Input omega_pr_tr coefficient(cal gmol-1)
Definition PDSS_HKFT.h:275
double g(const double temp, const double pres, const int ifunc=0) const
function g appearing in the formulation
void setState_TP(double temp, double pres) override
Set the internal temperature and pressure.
double m_Z_pr_tr
Z = -1 / relEpsilon at 298.15 and 1 bar.
Definition PDSS_HKFT.h:281
void convertDGFormation()
Translate a Gibbs free energy of formation value to a NIST-based Chemical potential.
double cp_mole() const override
Return the molar const pressure heat capacity in units of J kmol-1 K-1.
Definition PDSS_HKFT.cpp:51
double m_deltaH_formation_tr_pr
Input value of deltaH of Formation at Tr and Pr (cal gmol-1)
Definition PDSS_HKFT.h:239
double m_a1
Input a1 coefficient (cal gmol-1 bar-1)
Definition PDSS_HKFT.h:257
double ag(const double temp, const int ifunc=0) const
Internal formula for the calculation of a_g()
double density() const override
Return the standard state density at standard state.
double gibbs_mole() const override
Return the molar Gibbs free energy in units of J kmol-1.
Definition PDSS_HKFT.cpp:46
double m_c1
Input c1 coefficient (cal gmol-1 K-1)
Definition PDSS_HKFT.h:269
double molarVolume_ref() const override
Return the molar volume at reference pressure.
PDSS_Water * m_waterSS
Water standard state calculator.
Definition PDSS_HKFT.h:213
double m_Mu0_tr_pr
Value of the Absolute Gibbs Free Energy NIST scale at T_r and P_r.
Definition PDSS_HKFT.h:248
void set_c(double *c)
Set "c" coefficients (array of 2 elements).
double m_a2
Input a2 coefficient (cal gmol-1)
Definition PDSS_HKFT.h:260
void setDeltaH0(double dh0)
Set enthalpy of formation at Pr, Tr [J/kmol].
double cp_R_ref() const override
Return the molar heat capacity divided by R at reference pressure.
Base class for PDSS classes which compute molar properties directly.
Definition PDSS.h:426
Class for the liquid water pressure dependent standard state.
Definition PDSS_Water.h:50
double m_p0
Reference state pressure of the species.
Definition PDSS.h:404
Unit conversion utility.
Definition Units.h:169
This is a filter class for ThermoPhase that implements some preparatory steps for efficiently handlin...
const double OneAtm
One atmosphere [Pa].
Definition ct_defs.h:96
Namespace for the Cantera kernel.
Definition AnyMap.cpp:564