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