| Cantera 3.0.0

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
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 double enthalpy_mole() const override;
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 * @deprecated To be removed after %Cantera 3.0
49 */
50 double enthalpy_mole2() const;
51
52 double intEnergy_mole() const override;
53 double entropy_mole() const override;
54 double gibbs_mole() const override;
55 double cp_mole() const override;
56 double molarVolume() const override;
57 double density() const override;
58
59 //! @}
60 //! @name Properties of the Reference State of the Species in the Solution
61 //! @{
62
63 double refPressure() const {
64 return m_p0;
65 }
66
67 double gibbs_RT_ref() const override;
68 double enthalpy_RT_ref() const override;
69 double entropy_R_ref() const override;
70 double cp_R_ref() const override;
71 double molarVolume_ref() const override;
72
73 //! @}
74 //! @name Mechanical Equation of State Properties
75 //! @{
76
77 void setState_TP(double temp, double pres) override;
78
79 //! @}
80 //! @name Initialization of the Object
81 //! @{
82
83 void setParent(VPStandardStateTP* phase, size_t k) override {
84 m_tp = phase;
85 m_spindex = k;
86 }
87
88 void initThermo() override;
89
90 //! Set enthalpy of formation at Pr, Tr [J/kmol]
91 void setDeltaH0(double dh0);
92
93 //! Set Gibbs free energy of formation at Pr, Tr [J/kmol]
94 void setDeltaG0(double dg0);
95
96 //! Set entropy of formation at Pr, Tr [J/kmol/K]
97 void setS0(double s0);
98
99 //! Set "a" coefficients (array of 4 elements). Units of each coefficient
100 //! are [J/kmol/Pa, J/kmol, J*K/kmol/Pa, J*K/kmol]
101 void set_a(double* a);
102
103 //! Set "c" coefficients (array of 2 elements). Units of each coefficient
104 //! are [J/kmol/K, J*K/kmol]
105 void set_c(double* c);
106 void setOmega(double omega); //!< Set omega [J/kmol]
107
108 void getParameters(AnyMap& eosNode) const override;
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 void reportParams(size_t& kindex, int& type, double* const c, double& minTemp,
137 double& maxTemp, double& refPressure) const override;
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 Eqn. 59 in Johnson et al. @cite johnson1992.
148 */
149 double 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. @cite johnson1992. Actually, there appears to
155 * be an error in the latter. This is a correction.
156 */
157 double 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 * @deprecated To be removed after %Cantera 3.0
164 */
165 double 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 double ag(const double 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 double bg(const double temp, const int ifunc = 0) const;
192
193 //! function g appearing in the formulation
194 /*!
195 * Function @f$ g @f$ (Eqn. 49) appearing in the Johnson et al. @cite johnson1992
196 * formulation.
197 *
198 * @param temp Temperature kelvin
199 * @param pres Pressure (pascal)
200 * @param ifunc parameters specifying the desired information
201 * - 0 function value
202 * - 1 derivative wrt temperature
203 * - 2 2nd derivative wrt temperature
204 * - 3 derivative wrt pressure
205 */
206 double g(const double temp, const double pres, const int ifunc = 0) const;
207
208 //! Difference function f appearing in the formulation
209 /*!
210 * Function @f$ f @f$ (Eqn. 52) appearing in the Johnson et al. @cite johnson1992
211 * formulation of @f$ \omega_j @f$ (Eqn. 46).
212 *
213 * @param temp Temperature kelvin
214 * @param pres Pressure (pascal)
215 * @param ifunc parameters specifying the desired information
216 * - 0 function value
217 * - 1 derivative wrt temperature
218 * - 2 2nd derivative wrt temperature
219 * - 3 derivative wrt pressure
220 */
221 double f(const double temp, const double pres, const int ifunc = 0) const;
222
223 //! Evaluate the Gstar value appearing in the HKFT formulation
224 /*!
225 * @param temp Temperature kelvin
226 * @param pres Pressure (pascal)
227 * @param ifunc parameters specifying the desired information
228 * - 0 function value
229 * - 1 derivative wrt temperature
230 * - 2 2nd derivative wrt temperature
231 * - 3 derivative wrt pressure
232 */
233 double gstar(const double temp, const double pres, 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 double LookupGe(const 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
256 private:
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 */
262 PDSS_Water* m_waterSS = nullptr;
263
264 UnitSystem m_units;
265
266 //! density of standard-state water. internal temporary variable
267 mutable double m_densWaterSS = -1.0;
268
269 //! Pointer to the water property calculator
270 unique_ptr<WaterProps> m_waterProps;
271
272 //! Input value of deltaG of Formation at Tr and Pr (cal gmol-1)
273 /*!
274 * Tr = 298.15 Pr = 1 atm
275 *
276 * This is the delta G for the formation reaction of the
277 * ion from elements in their stable state at Tr, Pr.
278 */
279 double m_deltaG_formation_tr_pr = NAN;
280
281 //! Input value of deltaH of Formation at Tr and Pr (cal gmol-1)
282 /*!
283 * Tr = 298.15 Pr = 1 atm
284 *
285 * This is the delta H for the formation reaction of the
286 * ion from elements in their stable state at Tr, Pr.
287 */
288 double m_deltaH_formation_tr_pr = NAN;
289
290 //! Value of the Absolute Gibbs Free Energy NIST scale at T_r and P_r
291 /*!
292 * This is the NIST scale value of Gibbs free energy at T_r = 298.15
293 * and P_r = 1 atm.
294 *
295 * J kmol-1
296 */
297 double m_Mu0_tr_pr = 0.0;
298
299 //! Input value of S_j at Tr and Pr (cal gmol-1 K-1)
300 /*!
301 * Tr = 298.15 Pr = 1 atm
302 */
303 double m_Entrop_tr_pr = NAN;
304
305 //! Input a1 coefficient (cal gmol-1 bar-1)
306 double m_a1 = 0.0;
307
308 //! Input a2 coefficient (cal gmol-1)
309 double m_a2 = 0.0;
310
311 //! Input a3 coefficient (cal K gmol-1 bar-1)
312 double m_a3 = 0.0;
313
314 //! Input a4 coefficient (cal K gmol-1)
315 double m_a4 = 0.0;
316
317 //! Input c1 coefficient (cal gmol-1 K-1)
318 double m_c1 = 0.0;
319
320 //! Input c2 coefficient (cal K gmol-1)
321 double m_c2 = 0.0;
322
323 //! Input omega_pr_tr coefficient(cal gmol-1)
324 double m_omega_pr_tr = 0.0;
325
326 //! y = dZdT = 1/(esp*esp) desp/dT at 298.15 and 1 bar
327 double m_Y_pr_tr = 0.0;
328
329 //! Z = -1 / relEpsilon at 298.15 and 1 bar
330 double m_Z_pr_tr = 0.0;
331
332 //! Reference pressure is 1 atm in units of bar= 1.0132
333 double m_presR_bar = OneAtm * 1.0E-5;
334
335 //! small value that is not quite zero
336 double m_domega_jdT_prtr = 0.0;
337
338 //! Charge of the ion
339 double m_charge_j = 0.0;
340
341 //! Static variable determining error exiting
342 /*!
343 * If true, then will error exit if there is an inconsistency in DG0, DH0, and DS0.
344 * If not, then will rewrite DH0 to be consistent with the other two.
345 */
346 static int s_InputInconsistencyErrorExit;
347};
348
349}
350
351#endif
PDSS.h
Declarations for the virtual base class PDSS (pressure dependent standard state) which handles calcul...
WaterProps.h
Header for a class used to house several approximation routines for properties of water.
Cantera::AnyMap
A map of string keys to values whose type can vary at runtime.
Definition AnyMap.h:427
Cantera::PDSS_HKFT
Class for pressure dependent standard states corresponding to ionic solutes in electrolyte water.
Definition PDSS_HKFT.h:28
Cantera::PDSS_HKFT::setOmega
void setOmega(double omega)
Set omega [J/kmol].
Definition PDSS_HKFT.cpp:346
Cantera::PDSS_HKFT::molarVolume
double molarVolume() const override
Return the molar volume at standard state.
Definition PDSS_HKFT.cpp:114
Cantera::PDSS_HKFT::s_InputInconsistencyErrorExit
static int s_InputInconsistencyErrorExit
Static variable determining error exiting.
Definition PDSS_HKFT.h:346
Cantera::PDSS_HKFT::m_Y_pr_tr
double m_Y_pr_tr
y = dZdT = 1/(esp*esp) desp/dT at 298.15 and 1 bar
Definition PDSS_HKFT.h:327
Cantera::PDSS_HKFT::m_a4
double m_a4
Input a4 coefficient (cal K gmol-1)
Definition PDSS_HKFT.h:315
Cantera::PDSS_HKFT::setParent
void setParent(VPStandardStateTP *phase, size_t k) override
Set the parent VPStandardStateTP object of this PDSS object.
Definition PDSS_HKFT.h:83
Cantera::PDSS_HKFT::enthalpy_mole
double enthalpy_mole() const override
Return the molar enthalpy in units of J kmol-1.
Definition PDSS_HKFT.cpp:29
Cantera::PDSS_HKFT::m_waterProps
unique_ptr< WaterProps > m_waterProps
Pointer to the water property calculator.
Definition PDSS_HKFT.h:270
Cantera::PDSS_HKFT::deltaS
double deltaS() const
Main routine that actually calculates the entropy difference between the reference state at Tr,...
Definition PDSS_HKFT.cpp:454
Cantera::PDSS_HKFT::f
double f(const double temp, const double pres, const int ifunc=0) const
Difference function f appearing in the formulation.
Definition PDSS_HKFT.cpp:522
Cantera::PDSS_HKFT::deltaH
double deltaH() const
Routine that actually calculates the enthalpy difference between the reference state at Tr,...
Definition PDSS_HKFT.cpp:372
Cantera::PDSS_HKFT::m_spindex
size_t m_spindex
Index of this species within the parent phase.
Definition PDSS_HKFT.h:142
Cantera::PDSS_HKFT::m_densWaterSS
double m_densWaterSS
density of standard-state water. internal temporary variable
Definition PDSS_HKFT.h:267
Cantera::PDSS_HKFT::LookupGe
double LookupGe(const string &elemName)
Function to look up Element Free Energies.
Definition PDSS_HKFT.cpp:617
Cantera::PDSS_HKFT::gibbs_RT_ref
double gibbs_RT_ref() const override
Return the molar Gibbs free energy divided by RT at reference pressure.
Definition PDSS_HKFT.cpp:162
Cantera::PDSS_HKFT::m_tp
VPStandardStateTP * m_tp
Parent VPStandardStateTP (ThermoPhase) object.
Definition PDSS_HKFT.h:141
Cantera::PDSS_HKFT::m_Entrop_tr_pr
double m_Entrop_tr_pr
Input value of S_j at Tr and Pr (cal gmol-1 K-1)
Definition PDSS_HKFT.h:303
Cantera::PDSS_HKFT::m_deltaG_formation_tr_pr
double m_deltaG_formation_tr_pr
Input value of deltaG of Formation at Tr and Pr (cal gmol-1)
Definition PDSS_HKFT.h:279
Cantera::PDSS_HKFT::setDeltaG0
void setDeltaG0(double dg0)
Set Gibbs free energy of formation at Pr, Tr [J/kmol].
Definition PDSS_HKFT.cpp:326
Cantera::PDSS_HKFT::initThermo
void initThermo() override
Initialization routine.
Definition PDSS_HKFT.cpp:213
Cantera::PDSS_HKFT::m_a3
double m_a3
Input a3 coefficient (cal K gmol-1 bar-1)
Definition PDSS_HKFT.h:312
Cantera::PDSS_HKFT::gstar
double gstar(const double temp, const double pres, const int ifunc=0) const
Evaluate the Gstar value appearing in the HKFT formulation.
Definition PDSS_HKFT.cpp:609
Cantera::PDSS_HKFT::m_charge_j
double m_charge_j
Charge of the ion.
Definition PDSS_HKFT.h:339
Cantera::PDSS_HKFT::PDSS_HKFT
PDSS_HKFT()
Default Constructor.
Definition PDSS_HKFT.cpp:23
Cantera::PDSS_HKFT::entropy_R_ref
double entropy_R_ref() const override
Return the molar entropy divided by R at reference pressure.
Definition PDSS_HKFT.cpp:180
Cantera::PDSS_HKFT::deltaG
double deltaG() const
Main routine that actually calculates the Gibbs free energy difference between the reference state at...
Definition PDSS_HKFT.cpp:421
Cantera::PDSS_HKFT::enthalpy_RT_ref
double enthalpy_RT_ref() const override
Return the molar enthalpy divided by RT at reference pressure.
Definition PDSS_HKFT.cpp:171
Cantera::PDSS_HKFT::setS0
void setS0(double s0)
Set entropy of formation at Pr, Tr [J/kmol/K].
Definition PDSS_HKFT.cpp:330
Cantera::PDSS_HKFT::bg
double bg(const double temp, const int ifunc=0) const
Internal formula for the calculation of b_g()
Definition PDSS_HKFT.cpp:508
Cantera::PDSS_HKFT::reportParams
void reportParams(size_t &kindex, int &type, double *const c, double &minTemp, double &maxTemp, double &refPressure) const override
This utility function reports back the type of parameterization and all of the parameters for the spe...
Definition PDSS_HKFT.cpp:650
Cantera::PDSS_HKFT::getParameters
void getParameters(AnyMap &eosNode) const override
Store the parameters needed to reconstruct a copy of this PDSS object.
Definition PDSS_HKFT.cpp:350
Cantera::PDSS_HKFT::m_c2
double m_c2
Input c2 coefficient (cal K gmol-1)
Definition PDSS_HKFT.h:321
Cantera::PDSS_HKFT::m_presR_bar
double m_presR_bar
Reference pressure is 1 atm in units of bar= 1.0132.
Definition PDSS_HKFT.h:333
Cantera::PDSS_HKFT::set_a
void set_a(double *a)
Set "a" coefficients (array of 4 elements).
Definition PDSS_HKFT.cpp:334
Cantera::PDSS_HKFT::intEnergy_mole
double intEnergy_mole() const override
Return the molar internal Energy in units of J kmol-1.
Definition PDSS_HKFT.cpp:43
Cantera::PDSS_HKFT::m_domega_jdT_prtr
double m_domega_jdT_prtr
small value that is not quite zero
Definition PDSS_HKFT.h:336
Cantera::PDSS_HKFT::entropy_mole
double entropy_mole() const override
Return the molar entropy in units of J kmol-1 K-1.
Definition PDSS_HKFT.cpp:48
Cantera::PDSS_HKFT::m_omega_pr_tr
double m_omega_pr_tr
Input omega_pr_tr coefficient(cal gmol-1)
Definition PDSS_HKFT.h:324
Cantera::PDSS_HKFT::enthalpy_mole2
double enthalpy_mole2() const
Return the molar enthalpy in units of J kmol-1.
Definition PDSS_HKFT.cpp:36
Cantera::PDSS_HKFT::g
double g(const double temp, const double pres, const int ifunc=0) const
function g appearing in the formulation
Definition PDSS_HKFT.cpp:556
Cantera::PDSS_HKFT::setState_TP
void setState_TP(double temp, double pres) override
Set the internal temperature and pressure.
Definition PDSS_HKFT.cpp:207
Cantera::PDSS_HKFT::m_Z_pr_tr
double m_Z_pr_tr
Z = -1 / relEpsilon at 298.15 and 1 bar.
Definition PDSS_HKFT.h:330
Cantera::PDSS_HKFT::convertDGFormation
void convertDGFormation()
Translate a Gibbs free energy of formation value to a NIST-based Chemical potential.
Definition PDSS_HKFT.cpp:631
Cantera::PDSS_HKFT::cp_mole
double cp_mole() const override
Return the molar const pressure heat capacity in units of J kmol-1 K-1.
Definition PDSS_HKFT.cpp:58
Cantera::PDSS_HKFT::m_deltaH_formation_tr_pr
double m_deltaH_formation_tr_pr
Input value of deltaH of Formation at Tr and Pr (cal gmol-1)
Definition PDSS_HKFT.h:288
Cantera::PDSS_HKFT::m_a1
double m_a1
Input a1 coefficient (cal gmol-1 bar-1)
Definition PDSS_HKFT.h:306
Cantera::PDSS_HKFT::ag
double ag(const double temp, const int ifunc=0) const
Internal formula for the calculation of a_g()
Definition PDSS_HKFT.cpp:494
Cantera::PDSS_HKFT::density
double density() const override
Return the standard state density at standard state.
Definition PDSS_HKFT.cpp:157
Cantera::PDSS_HKFT::gibbs_mole
double gibbs_mole() const override
Return the molar Gibbs free energy in units of J kmol-1.
Definition PDSS_HKFT.cpp:53
Cantera::PDSS_HKFT::m_c1
double m_c1
Input c1 coefficient (cal gmol-1 K-1)
Definition PDSS_HKFT.h:318
Cantera::PDSS_HKFT::molarVolume_ref
double molarVolume_ref() const override
Return the molar volume at reference pressure.
Definition PDSS_HKFT.cpp:198
Cantera::PDSS_HKFT::m_waterSS
PDSS_Water * m_waterSS
Water standard state calculator.
Definition PDSS_HKFT.h:262
Cantera::PDSS_HKFT::m_Mu0_tr_pr
double m_Mu0_tr_pr
Value of the Absolute Gibbs Free Energy NIST scale at T_r and P_r.
Definition PDSS_HKFT.h:297
Cantera::PDSS_HKFT::set_c
void set_c(double *c)
Set "c" coefficients (array of 2 elements).
Definition PDSS_HKFT.cpp:341
Cantera::PDSS_HKFT::m_a2
double m_a2
Input a2 coefficient (cal gmol-1)
Definition PDSS_HKFT.h:309
Cantera::PDSS_HKFT::setDeltaH0
void setDeltaH0(double dh0)
Set enthalpy of formation at Pr, Tr [J/kmol].
Definition PDSS_HKFT.cpp:322
Cantera::PDSS_HKFT::cp_R_ref
double cp_R_ref() const override
Return the molar heat capacity divided by R at reference pressure.
Definition PDSS_HKFT.cpp:189
Cantera::PDSS_Molar
Base class for PDSS classes which compute molar properties directly.
Definition PDSS.h:477
Cantera::PDSS_Water
Class for the liquid water pressure dependent standard state.
Definition PDSS_Water.h:50
Cantera::PDSS::m_p0
double m_p0
Reference state pressure of the species.
Definition PDSS.h:455
Cantera::PDSS::minTemp
double minTemp() const
return the minimum temperature
Definition PDSS.h:278
Cantera::PDSS::maxTemp
double maxTemp() const
return the minimum temperature
Definition PDSS.h:283
Cantera::UnitSystem
Unit conversion utility.
Definition Units.h:169
Cantera::VPStandardStateTP
This is a filter class for ThermoPhase that implements some preparatory steps for efficiently handlin...
Definition VPStandardStateTP.h:44
Cantera::OneAtm
const double OneAtm
One atmosphere [Pa].
Definition ct_defs.h:96
Cantera
Namespace for the Cantera kernel.
Definition AnyMap.cpp:564