Cantera  4.0.0a1
Loading...
Searching...
No Matches
HMWSoln.h
Go to the documentation of this file.
1/**
2 * @file HMWSoln.h
3 * Headers for the HMWSoln ThermoPhase object, which models concentrated
4 * electrolyte solutions
5 * (see @ref thermoprops and @link Cantera::HMWSoln HMWSoln @endlink) .
6 *
7 * Class HMWSoln represents a concentrated liquid electrolyte phase which
8 * obeys the Pitzer formulation for nonideality using molality-based
9 * standard states.
10 */
11
12// This file is part of Cantera. See License.txt in the top-level directory or
13// at https://cantera.org/license.txt for license and copyright information.
14
15#ifndef CT_HMWSOLN_H
16#define CT_HMWSOLN_H
17
18#include "MolalityVPSSTP.h"
19#include "cantera/base/Array.h"
20
21namespace Cantera
22{
23
24//! @name Temperature Dependence of the Pitzer Coefficients
25//!
26//! Note, the temperature dependence of the Gibbs free energy also depends on the
27//! temperature dependence of the standard state and the temperature dependence
28//! of the Debye-Huckel constant, which includes the dielectric constant and the
29//! density. Therefore, this expression defines only part of the temperature
30//! dependence for the mixture thermodynamic functions.
31//!
32//! PITZER_TEMP_CONSTANT
33//! All coefficients are considered constant wrt temperature
34//! PITZER_TEMP_LINEAR
35//! All coefficients are assumed to have a linear dependence
36//! wrt to temperature.
37//! PITZER_TEMP_COMPLEX1
38//! All coefficients are assumed to have a complex functional
39//! based dependence wrt temperature; See:
40//! (Silvester, Pitzer, J. Phys. Chem. 81, 19 1822 (1977)).
41//!
42//! beta0 = q0 + q3(1/T - 1/Tr) + q4(ln(T/Tr)) +
43//! q1(T - Tr) + q2(T**2 - Tr**2)
44//! @{
45
46#define PITZER_TEMP_CONSTANT 0
47#define PITZER_TEMP_LINEAR 1
48#define PITZER_TEMP_COMPLEX1 2
49
50//! @}
51//! @name ways to calculate the value of A_Debye
52//!
53//! These defines determine the way A_Debye is calculated
54//! @{
55
56#define A_DEBYE_CONST 0
57#define A_DEBYE_WATER 1
58//! @}
59
60class WaterProps;
61
62/**
63 * Class HMWSoln represents a dilute or concentrated liquid electrolyte
64 * phase which obeys the Pitzer formulation for nonideality.
65 *
66 * As a prerequisite to the specification of thermodynamic quantities,
67 * The concentrations of the ionic species are assumed to obey the
68 * electroneutrality condition.
69 *
70 * ## Specification of Species Standard State Properties
71 *
72 * The solvent is assumed to be liquid water. A real model for liquid water
73 * (IAPWS 1995 formulation) is used as its standard state. All standard state
74 * properties for the solvent are based on this real model for water, and
75 * involve function calls to the object that handles the real water model,
76 * #Cantera::WaterPropsIAPWS.
77 *
78 * The standard states for solutes are on the unit molality basis. Therefore, in
79 * the documentation below, the normal @f$ o @f$ superscript is replaced with
80 * the @f$ \triangle @f$ symbol. The reference state symbol is now
81 * @f$ \triangle, ref @f$.
82 *
83 * It is assumed that the reference state thermodynamics may be obtained by a
84 * pointer to a populated species thermodynamic property manager class (see
85 * ThermoPhase::m_spthermo). How to relate pressure changes to the reference
86 * state thermodynamics is resolved at this level.
87 *
88 * For solutes that rely on ThermoPhase::m_spthermo, are assumed to have an
89 * incompressible standard state mechanical property. In other words, the molar
90 * volumes are independent of temperature and pressure.
91 *
92 * For these incompressible, standard states, the molar internal energy is
93 * independent of pressure. Since the thermodynamic properties are specified by
94 * giving the standard-state enthalpy, the term @f$ P_0 \hat v @f$ is subtracted
95 * from the specified molar enthalpy to compute the molar internal energy. The
96 * entropy is assumed to be independent of the pressure.
97 *
98 * The enthalpy function is given by the following relation.
99 *
100 * @f[
101 * h^\triangle_k(T,P) = h^{\triangle,ref}_k(T)
102 * + \tilde{v}_k \left( P - P_{ref} \right)
103 * @f]
104 *
105 * For an incompressible, stoichiometric substance, the molar internal energy is
106 * independent of pressure. Since the thermodynamic properties are specified by
107 * giving the standard-state enthalpy, the term @f$ P_{ref} \tilde v @f$ is
108 * subtracted from the specified reference molar enthalpy to compute the molar
109 * internal energy.
110 *
111 * @f[
112 * u^\triangle_k(T,P) = h^{\triangle,ref}_k(T) - P_{ref} \tilde{v}_k
113 * @f]
114 *
115 * The solute standard state heat capacity and entropy are independent of
116 * pressure. The solute standard state Gibbs free energy is obtained from the
117 * enthalpy and entropy functions.
118 *
119 * The current model assumes that an incompressible molar volume for all
120 * solutes. The molar volume for the water solvent, however, is obtained from a
121 * pure water equation of state, waterSS. Therefore, the water standard state
122 * varies with both T and P. It is an error to request standard state water
123 * properties at a T and P where the water phase is not a stable phase, that is,
124 * beyond its spinodal curve.
125 *
126 * ## Specification of Solution Thermodynamic Properties
127 *
128 * Chemical potentials of the solutes, @f$ \mu_k @f$, and the solvent, @f$ \mu_o
129 * @f$, which are based on the molality form, have the following general format:
130 *
131 * @f[
132 * \mu_k = \mu^{\triangle}_k(T,P) + R T \ln(\gamma_k^{\triangle} \frac{m_k}{m^\triangle})
133 * @f]
134 * @f[
135 * \mu_o = \mu^o_o(T,P) + RT \ln(a_o)
136 * @f]
137 *
138 * where @f$ \gamma_k^{\triangle} @f$ is the molality based activity coefficient
139 * for species @f$ k @f$.
140 *
141 * Individual activity coefficients of ions can not be independently measured.
142 * Instead, only binary pairs forming electroneutral solutions can be measured.
143 * This problem leads to a redundancy in the evaluation of species standard
144 * state properties. The redundancy issue is resolved by setting the standard
145 * state chemical potential enthalpy, entropy, and volume for the hydrogen ion,
146 * H+, to zero, for every temperature and pressure. After this convention is
147 * applied, all other standard state properties of ionic species contain
148 * meaningful information.
149 *
150 * ### Ionic Strength
151 *
152 * Most of the parameterizations within the model use the ionic strength as a
153 * key variable. The ionic strength, @f$ I @f$ is defined as follows
154 *
155 * @f[
156 * I = \frac{1}{2} \sum_k{m_k z_k^2}
157 * @f]
158 *
159 * @f$ m_k @f$ is the molality of the kth species. @f$ z_k @f$ is the charge of
160 * the kth species. Note, the ionic strength is a defined units quantity. The
161 * molality has defined units of gmol kg-1, and therefore the ionic strength has
162 * units of sqrt(gmol/kg).
163 *
164 * ### Specification of the Excess Gibbs Free Energy
165 *
166 * Pitzer's formulation may best be represented as a specification of the excess
167 * Gibbs free energy, @f$ G^{ex} @f$, defined as the deviation of the total
168 * Gibbs free energy from that of an ideal molal solution.
169 * @f[
170 * G = G^{id} + G^{ex}
171 * @f]
172 *
173 * The ideal molal solution contribution, not equal to an ideal solution
174 * contribution and in fact containing a singularity at the zero solvent mole
175 * fraction limit, is given below.
176 * @f[
177 * G^{id} = n_o \mu^o_o + \sum_{k\ne o} n_k \mu_k^{\triangle}
178 * + \tilde{M}_o n_o ( RT (\sum{m_i(\ln(m_i)-1)}))
179 * @f]
180 *
181 * From the excess Gibbs free energy formulation, the activity coefficient
182 * expression and the osmotic coefficient expression for the solvent may be
183 * defined, by taking the appropriate derivatives. Using this approach
184 * guarantees that the entire system will obey the Gibbs-Duhem relations.
185 *
186 * Pitzer employs the following general expression for the excess Gibbs free
187 * energy
188 *
189 * @f[
190 * \begin{array}{cclc}
191 * \frac{G^{ex}}{\tilde{M}_o n_o RT} &= &
192 * \left( \frac{4A_{Debye}I}{3b} \right) \ln(1 + b \sqrt{I})
193 * + 2 \sum_c \sum_a m_c m_a B_{ca}
194 * + \sum_c \sum_a m_c m_a Z C_{ca}
195 * \\&&
196 * + \sum_{c < c'} \sum m_c m_{c'} \left[ 2 \Phi_{c{c'}} + \sum_a m_a \Psi_{c{c'}a} \right]
197 * + \sum_{a < a'} \sum m_a m_{a'} \left[ 2 \Phi_{a{a'}} + \sum_c m_c \Psi_{a{a'}c} \right]
198 * \\&&
199 * + 2 \sum_n \sum_c m_n m_c \lambda_{nc} + 2 \sum_n \sum_a m_n m_a \lambda_{na}
200 * + 2 \sum_{n < n'} \sum m_n m_{n'} \lambda_{n{n'}}
201 * + \sum_n m^2_n \lambda_{nn}
202 * \end{array}
203 * @f]
204 *
205 * *a* is a subscript over all anions, *c* is a subscript extending over all
206 * cations, and *i* is a subscript that extends over all anions and cations.
207 * *n* is a subscript that extends only over neutral solute molecules. The
208 * second line contains cross terms where cations affect cations and/or
209 * cation/anion pairs, and anions affect anions or cation/anion pairs. Note part
210 * of the coefficients, @f$ \Phi_{c{c'}} @f$ and @f$ \Phi_{a{a'}} @f$ stem from
211 * the theory of unsymmetrical mixing of electrolytes with different charges.
212 * This theory depends on the total ionic strength of the solution, and
213 * therefore, @f$ \Phi_{c{c'}} @f$ and @f$ \Phi_{a{a'}} @f$ will depend on
214 * *I*, the ionic strength. @f$ B_{ca} @f$ is a strong function of the
215 * total ionic strength, *I*, of the electrolyte. The rest of the coefficients
216 * are assumed to be independent of the molalities or ionic strengths. However,
217 * all coefficients are potentially functions of the temperature and pressure
218 * of the solution.
219 *
220 * *A* is the Debye-Huckel constant. Its specification is described in its
221 * own section below.
222 *
223 * @f$ I @f$ is the ionic strength of the solution, and is given by:
224 *
225 * @f[
226 * I = \frac{1}{2} \sum_k{m_k z_k^2}
227 * @f]
228 *
229 * In contrast to several other Debye-Huckel implementations (see @ref
230 * DebyeHuckel), the parameter @f$ b @f$ in the above equation is a constant that
231 * does not vary with respect to ion identity. This is an important
232 * simplification as it avoids troubles with satisfaction of the Gibbs-Duhem
233 * analysis.
234 *
235 * The function @f$ Z @f$ is given by
236 *
237 * @f[
238 * Z = \sum_i m_i \left| z_i \right|
239 * @f]
240 *
241 * The value of @f$ B_{ca} @f$ is given by the following function
242 *
243 * @f[
244 * B_{ca} = \beta^{(0)}_{ca} + \beta^{(1)}_{ca} g(\alpha^{(1)}_{ca} \sqrt{I})
245 * + \beta^{(2)}_{ca} g(\alpha^{(2)}_{ca} \sqrt{I})
246 * @f]
247 *
248 * where
249 *
250 * @f[
251 * g(x) = 2 \frac{(1 - (1 + x)\exp[-x])}{x^2}
252 * @f]
253 *
254 * The formulation for @f$ B_{ca} @f$ combined with the formulation of the Debye-
255 * Huckel term in the eqn. for the excess Gibbs free energy stems essentially
256 * from an empirical fit to the ionic strength dependent data based over a wide
257 * sampling of binary electrolyte systems. @f$ C_{ca} @f$, @f$ \lambda_{nc} @f$,
258 * @f$ \lambda_{na} @f$, @f$ \lambda_{nn} @f$, @f$ \Psi_{c{c'}a} @f$, @f$
259 * \Psi_{a{a'}c} @f$ are experimentally derived coefficients that may have
260 * pressure and/or temperature dependencies.
261 *
262 * The @f$ \Phi_{c{c'}} @f$ and @f$ \Phi_{a{a'}} @f$ formulations are slightly
263 * more complicated. @f$ b @f$ is a universal constant defined to be equal to
264 * @f$ 1.2\ kg^{1/2}\ gmol^{-1/2} @f$. The exponential coefficient @f$
265 * \alpha^{(1)}_{ca} @f$ is usually fixed at @f$ \alpha^{(1)}_{ca} = 2.0\
266 * kg^{1/2} gmol^{-1/2} @f$ except for 2-2 electrolytes, while other parameters
267 * were fit to experimental data. For 2-2 electrolytes, @f$ \alpha^{(1)}_{ca} =
268 * 1.4\ kg^{1/2}\ gmol^{-1/2} @f$ is used in combination with either @f$
269 * \alpha^{(2)}_{ca} = 12\ kg^{1/2}\ gmol^{-1/2} @f$ or @f$ \alpha^{(2)}_{ca} = k
270 * A_\psi @f$, where *k* is a constant. For electrolytes other than 2-2
271 * electrolytes the @f$ \beta^{(2)}_{ca} g(\alpha^{(2)}_{ca} \sqrt{I}) @f$ term
272 * is not used in the fitting procedure; it is only used for divalent metal
273 * sulfates and other high-valence electrolytes which exhibit significant
274 * association at low ionic strengths.
275 *
276 * The @f$ \beta^{(0)}_{ca} @f$, @f$ \beta^{(1)}_{ca} @f$, @f$ \beta^{(2)}_{ca}
277 * @f$, and @f$ C_{ca} @f$ binary coefficients are referred to as ion-
278 * interaction or Pitzer parameters. These Pitzer parameters may vary with
279 * temperature and pressure but they do not depend on the ionic strength. Their
280 * values and temperature derivatives of their values have been tabulated for a
281 * range of electrolytes
282 *
283 * The @f$ \Phi_{c{c'}} @f$ and @f$ \Phi_{a{a'}} @f$ contributions, which
284 * capture cation-cation and anion-anion interactions, also have an ionic
285 * strength dependence.
286 *
287 * Ternary contributions @f$ \Psi_{c{c'}a} @f$ and @f$ \Psi_{a{a'}c} @f$ have
288 * been measured also for some systems. The success of the Pitzer method lies in
289 * its ability to model nonlinear activity coefficients of complex
290 * multicomponent systems with just binary and minor ternary contributions,
291 * which can be independently measured in binary or ternary subsystems.
292 *
293 * ### Multicomponent Activity Coefficients for Solutes
294 *
295 * The formulas for activity coefficients of solutes may be obtained by taking
296 * the following derivative of the excess Gibbs Free Energy formulation
297 * described above:
298 *
299 * @f[
300 * \ln(\gamma_k^\triangle) = \frac{d\left( \frac{G^{ex}}{M_o n_o RT} \right)}{d(m_k)}\Bigg|_{n_i}
301 * @f]
302 *
303 * In the formulas below the following conventions are used. The subscript *M*
304 * refers to a particular cation. The subscript X refers to a particular anion,
305 * whose activity is being currently evaluated. the subscript *a* refers to a
306 * summation over all anions in the solution, while the subscript *c* refers to
307 * a summation over all cations in the solutions.
308 *
309 * The activity coefficient for a particular cation *M* is given by
310 *
311 * @f[
312 * \ln(\gamma_M^\triangle) = -z_M^2(F) + \sum_a m_a \left( 2 B_{Ma} + Z C_{Ma} \right)
313 * + z_M \left( \sum_a \sum_c m_a m_c C_{ca} \right)
314 * + \sum_c m_c \left[ 2 \Phi_{Mc} + \sum_a m_a \Psi_{Mca} \right]
315 * + \sum_{a < a'} \sum m_a m_{a'} \Psi_{Ma{a'}}
316 * + 2 \sum_n m_n \lambda_{nM}
317 * @f]
318 *
319 * The activity coefficient for a particular anion *X* is given by
320 *
321 * @f[
322 * \ln(\gamma_X^\triangle) = -z_X^2(F) + \sum_a m_c \left( 2 B_{cX} + Z C_{cX} \right)
323 * + \left|z_X \right| \left( \sum_a \sum_c m_a m_c C_{ca} \right)
324 * + \sum_a m_a \left[ 2 \Phi_{Xa} + \sum_c m_c \Psi_{cXa} \right]
325 * + \sum_{c < c'} \sum m_c m_{c'} \Psi_{c{c'}X}
326 * + 2 \sum_n m_n \lambda_{nM}
327 * @f]
328 * where the function @f$ F @f$ is given by
329 *
330 * @f[
331 * F = - A_{\phi} \left[ \frac{\sqrt{I}}{1 + b \sqrt{I}}
332 * + \frac{2}{b} \ln{\left(1 + b\sqrt{I}\right)} \right]
333 * + \sum_a \sum_c m_a m_c B'_{ca}
334 * + \sum_{c < c'} \sum m_c m_{c'} \Phi'_{c{c'}}
335 * + \sum_{a < a'} \sum m_a m_{a'} \Phi'_{a{a'}}
336 * @f]
337 *
338 * We have employed the definition of @f$ A_{\phi} @f$, also used by Pitzer
339 * which is equal to
340 *
341 * @f[
342 * A_{\phi} = \frac{A_{Debye}}{3}
343 * @f]
344 *
345 * In the above formulas, @f$ \Phi'_{c{c'}} @f$ and @f$ \Phi'_{a{a'}} @f$ are the
346 * ionic strength derivatives of @f$ \Phi_{c{c'}} @f$ and @f$ \Phi_{a{a'}} @f$,
347 * respectively.
348 *
349 * The function @f$ B'_{MX} @f$ is defined as:
350 *
351 * @f[
352 * B'_{MX} = \left( \frac{\beta^{(1)}_{MX} h(\alpha^{(1)}_{MX} \sqrt{I})}{I} \right)
353 * \left( \frac{\beta^{(2)}_{MX} h(\alpha^{(2)}_{MX} \sqrt{I})}{I} \right)
354 * @f]
355 *
356 * where @f$ h(x) @f$ is defined as
357 *
358 * @f[
359 * h(x) = g'(x) \frac{x}{2} =
360 * \frac{2\left(1 - \left(1 + x + \frac{x^2}{2} \right)\exp(-x) \right)}{x^2}
361 * @f]
362 *
363 * The activity coefficient for neutral species *N* is given by
364 *
365 * @f[
366 * \ln(\gamma_N^\triangle) = 2 \left( \sum_i m_i \lambda_{iN}\right)
367 * @f]
368 *
369 * ### Activity of the Water Solvent
370 *
371 * The activity for the solvent water,@f$ a_o @f$, is not independent and must
372 * be determined either from the Gibbs-Duhem relation or from taking the
373 * appropriate derivative of the same excess Gibbs free energy function as was
374 * used to formulate the solvent activity coefficients. Pitzer's description
375 * follows the later approach to derive a formula for the osmotic coefficient,
376 * @f$ \phi @f$.
377 *
378 * @f[
379 * \phi - 1 = - \left( \frac{d\left(\frac{G^{ex}}{RT} \right)}{d(\tilde{M}_o n_o)} \right)
380 * \frac{1}{\sum_{i \ne 0} m_i}
381 * @f]
382 *
383 * The osmotic coefficient may be related to the water activity by the following relation:
384 *
385 * @f[
386 * \phi = - \frac{1}{\tilde{M}_o \sum_{i \neq o} m_i} \ln(a_o)
387 * = - \frac{n_o}{\sum_{i \neq o}n_i} \ln(a_o)
388 * @f]
389 *
390 * The result is the following
391 *
392 * @f[
393 * \begin{array}{ccclc}
394 * \phi - 1 &= &
395 * \frac{2}{\sum_{i \ne 0} m_i}
396 * \bigg[ &
397 * - A_{\phi} \frac{I^{3/2}}{1 + b \sqrt{I}}
398 * + \sum_c \sum_a m_c m_a \left( B^{\phi}_{ca} + Z C_{ca}\right)
399 * \\&&&
400 * + \sum_{c < c'} \sum m_c m_{c'} \left[ \Phi^{\phi}_{c{c'}} + \sum_a m_a \Psi_{c{c'}a} \right]
401 * + \sum_{a < a'} \sum m_a m_{a'} \left[ \Phi^{\phi}_{a{a'}} + \sum_c m_c \Psi_{a{a'}c} \right]
402 * \\&&&
403 * + \sum_n \sum_c m_n m_c \lambda_{nc} + \sum_n \sum_a m_n m_a \lambda_{na}
404 * + \sum_{n < n'} \sum m_n m_{n'} \lambda_{n{n'}}
405 * + \frac{1}{2} \left( \sum_n m^2_n \lambda_{nn}\right)
406 * \bigg]
407 * \end{array}
408 * @f]
409 *
410 * It can be shown that the expression
411 *
412 * @f[
413 * B^{\phi}_{ca} = \beta^{(0)}_{ca} + \beta^{(1)}_{ca} \exp{(- \alpha^{(1)}_{ca} \sqrt{I})}
414 * + \beta^{(2)}_{ca} \exp{(- \alpha^{(2)}_{ca} \sqrt{I} )}
415 * @f]
416 *
417 * is consistent with the expression @f$ B_{ca} @f$ in the @f$ G^{ex} @f$
418 * expression after carrying out the derivative wrt @f$ m_M @f$.
419 *
420 * Also taking into account that @f$ {\Phi}_{c{c'}} @f$ and
421 * @f$ {\Phi}_{a{a'}} @f$ has an ionic strength dependence.
422 *
423 * @f[
424 * \Phi^{\phi}_{c{c'}} = {\Phi}_{c{c'}} + I \frac{d{\Phi}_{c{c'}}}{dI}
425 * @f]
426 *
427 * @f[
428 * \Phi^{\phi}_{a{a'}} = \Phi_{a{a'}} + I \frac{d\Phi_{a{a'}}}{dI}
429 * @f]
430 *
431 * ### Temperature and Pressure Dependence of the Pitzer Parameters
432 *
433 * In general most of the coefficients introduced in the previous section may
434 * have a temperature and pressure dependence. The temperature and pressure
435 * dependence of these coefficients strongly influence the value of the excess
436 * Enthalpy and excess Volumes of Pitzer solutions. Therefore, these are readily
437 * measurable quantities. HMWSoln provides several different methods for putting
438 * these dependencies into the coefficients. HMWSoln has an implementation described
439 * by Silvester and Pitzer @cite silvester1977, which was used to fit experimental
440 * data for NaCl over an extensive range, below the critical temperature of
441 * water. They found a temperature functional form for fitting the 3 following
442 * coefficients that describe the Pitzer parameterization for a single salt to
443 * be adequate to describe how the excess Gibbs free energy values for the
444 * binary salt changes with respect to temperature. The following functional
445 * form was used to fit the temperature dependence of the Pitzer Coefficients
446 * for each cation - anion pair, M X.
447 *
448 * @f[
449 * \beta^{(0)}_{MX} = q^{b0}_0
450 * + q^{b0}_1 \left( T - T_r \right)
451 * + q^{b0}_2 \left( T^2 - T_r^2 \right)
452 * + q^{b0}_3 \left( \frac{1}{T} - \frac{1}{T_r}\right)
453 * + q^{b0}_4 \ln \left( \frac{T}{T_r} \right)
454 * @f]
455 * @f[
456 * \beta^{(1)}_{MX} = q^{b1}_0 + q^{b1}_1 \left( T - T_r \right)
457 * + q^{b1}_{2} \left( T^2 - T_r^2 \right)
458 * @f]
459 * @f[
460 * C^{\phi}_{MX} = q^{Cphi}_0
461 * + q^{Cphi}_1 \left( T - T_r \right)
462 * + q^{Cphi}_2 \left( T^2 - T_r^2 \right)
463 * + q^{Cphi}_3 \left( \frac{1}{T} - \frac{1}{T_r}\right)
464 * + q^{Cphi}_4 \ln \left( \frac{T}{T_r} \right)
465 * @f]
466 *
467 * where
468 *
469 * @f[
470 * C^{\phi}_{MX} = 2 {\left| z_M z_X \right|}^{1/2} C_{MX}
471 * @f]
472 *
473 * In later papers, Pitzer has added additional temperature dependencies to all
474 * of the other remaining second and third order virial coefficients. Some of
475 * these dependencies are justified and motivated by theory. Therefore, a
476 * formalism wherein all of the coefficients in the base theory have temperature
477 * dependencies associated with them has been implemented within the HMWSoln
478 * object. Much of the formalism, however, has been unexercised.
479 *
480 * In the HMWSoln object, the temperature dependence of the Pitzer parameters
481 * are specified in the following way.
482 *
483 * - PIZTER_TEMP_CONSTANT - string name "CONSTANT"
484 * - Assumes that all coefficients are independent of temperature
485 * and pressure
486 * - PIZTER_TEMP_COMPLEX1 - string name "COMPLEX" or "COMPLEX1"
487 * - Uses the full temperature dependence for the
488 * @f$ \beta^{(0)}_{MX} @f$ (5 coeffs),
489 * the @f$ \beta^{(1)}_{MX} @f$ (3 coeffs),
490 * and @f$ C^{\phi}_{MX} @f$ (5 coeffs) parameters described above.
491 * - PITZER_TEMP_LINEAR - string name "LINEAR"
492 * - Uses just the temperature dependence for the
493 * @f$ \beta^{(0)}_{MX} @f$, the @f$ \beta^{(1)}_{MX} @f$,
494 * and @f$ C^{\phi}_{MX} @f$ coefficients described above.
495 * There are 2 coefficients for each term.
496 *
497 * The specification of the binary interaction between a cation and an anion is
498 * given by the coefficients, @f$ B_{MX} @f$ and @f$ C_{MX} @f$ The specification
499 * of @f$ B_{MX} @f$ is a function of @f$ \beta^{(0)}_{MX} @f$,
500 * @f$ \beta^{(1)}_{MX} @f$, @f$ \beta^{(2)}_{MX} @f$, @f$ \alpha^{(1)}_{MX} @f$,
501 * and @f$ \alpha^{(2)}_{MX} @f$. @f$ C_{MX} @f$ is calculated from
502 * @f$ C^{\phi}_{MX} @f$ from the formula above.
503 *
504 * The parameters for @f$ \beta^{(0)} @f$ fit the following equation:
505 *
506 * @f[
507 * \beta^{(0)} = q_0^{{\beta}0} + q_1^{{\beta}0} \left( T - T_r \right)
508 * + q_2^{{\beta}0} \left( T^2 - T_r^2 \right)
509 * + q_3^{{\beta}0} \left( \frac{1}{T} - \frac{1}{T_r} \right)
510 * + q_4^{{\beta}0} \ln \left( \frac{T}{T_r} \right)
511 * @f]
512 *
513 * This same `COMPLEX1` temperature dependence given above is used for the
514 * following parameters:
515 * @f$ \beta^{(0)}_{MX} @f$, @f$ \beta^{(1)}_{MX} @f$,
516 * @f$ \beta^{(2)}_{MX} @f$, @f$ \Theta_{cc'} @f$, @f$ \Theta_{aa'} @f$,
517 * @f$ \Psi_{c{c'}a} @f$ and @f$ \Psi_{ca{a'}} @f$.
518 *
519 * ### Like-Charged Binary Ion Parameters and the Mixing Parameters
520 *
521 * The previous section contained the functions, @f$ \Phi_{c{c'}} @f$,
522 * @f$ \Phi_{a{a'}} @f$ and their derivatives wrt the ionic strength, @f$
523 * \Phi'_{c{c'}} @f$ and @f$ \Phi'_{a{a'}} @f$. Part of these terms come from
524 * theory.
525 *
526 * Since like charged ions repel each other and are generally not near each
527 * other, the virial coefficients for same-charged ions are small. However,
528 * Pitzer doesn't ignore these in his formulation. Relatively larger and longer
529 * range terms between like-charged ions exist however, which appear only for
530 * unsymmetrical mixing of same-sign charged ions with different charges. @f$
531 * \Phi_{ij} @f$, where @f$ ij @f$ is either @f$ a{a'} @f$ or @f$ c{c'} @f$ is
532 * given by
533 *
534 * @f[
535 * {\Phi}_{ij} = \Theta_{ij} + \,^E \Theta_{ij}(I)
536 * @f]
537 *
538 * @f$ \Theta_{ij} @f$ is the small virial coefficient expansion term. Dependent
539 * in general on temperature and pressure, its ionic strength dependence is
540 * ignored in Pitzer's approach. @f$ \,^E\Theta_{ij}(I) @f$ accounts for the
541 * electrostatic unsymmetrical mixing effects and is dependent only on the
542 * charges of the ions i, j, the total ionic strength and on the dielectric
543 * constant and density of the solvent. This seems to be a relatively well-
544 * documented part of the theory. They theory below comes from Pitzer summation
545 * (Pitzer) in the appendix. It's also mentioned in Bethke's book (Bethke), and
546 * the equations are summarized in Harvie & Weare @cite harvie1980. Within the code,
547 * @f$ \,^E\Theta_{ij}(I) @f$ is evaluated according to the algorithm described in
548 * Appendix B [Pitzer] as
549 *
550 * @f[
551 * \,^E\Theta_{ij}(I) = \left( \frac{z_i z_j}{4I} \right)
552 * \left( J(x_{ij}) - \frac{1}{2} J(x_{ii})
553 * - \frac{1}{2} J(x_{jj}) \right)
554 * @f]
555 *
556 * where @f$ x_{ij} = 6 z_i z_j A_{\phi} \sqrt{I} @f$ and
557 *
558 * @f[
559 * J(x) = \frac{1}{x} \int_0^{\infty}{\left( 1 + q +
560 * \frac{1}{2} q^2 - e^q \right) y^2 dy}
561 * @f]
562 *
563 * and @f$ q = - (\frac{x}{y}) e^{-y} @f$. @f$ J(x) @f$ is evaluated by
564 * numerical integration.
565 *
566 * The @f$ \Theta_{ij} @f$ term is a constant value, specified for pair of cations
567 * or a pair of anions.
568 *
569 * ### Ternary Pitzer Parameters
570 *
571 * The @f$ \Psi_{c{c'}a} @f$ and @f$ \Psi_{ca{a'}} @f$ terms represent ternary
572 * interactions between two cations and an anion and two anions and a cation,
573 * respectively. In Pitzer's implementation these terms are usually small in
574 * absolute size.
575 *
576 * ### Treatment of Neutral Species
577 *
578 * Binary virial-coefficient-like interactions between two neutral species may
579 * be specified in the @f$ \lambda_{mn} @f$ terms that appear in the formulas
580 * above. Currently these interactions are independent of pressure and ionic strength.
581 * Also, currently, the neutrality of the species are not checked. Therefore, this
582 * interaction may involve charged species in the solution as well.
583 *
584 * An example phase definition specifying a number of the above species interaction
585 * parameters is given in the
586 * [YAML API Reference](../yaml/phases.html#hmw-electrolyte).
587 *
588 * ### Specification of the Debye-Huckel Constant
589 *
590 * In the equations above, the formula for @f$ A_{Debye} @f$ is needed. The
591 * HMWSoln object uses two methods for specifying these quantities. The default
592 * method is to assume that @f$ A_{Debye} @f$ is a constant, given in the
593 * initialization process, and stored in the member double, m_A_Debye.
594 * Optionally, a full water treatment may be employed that makes
595 * @f$ A_{Debye} @f$ a full function of *T* and *P* and creates nontrivial
596 * entries for the excess heat capacity, enthalpy, and excess volumes of
597 * solution.
598 *
599 * @f[
600 * A_{Debye} = \frac{F e B_{Debye}}{8 \pi \epsilon R T} {\left( C_o \tilde{M}_o \right)}^{1/2}
601 * @f]
602 * where
603 *
604 * @f[
605 * B_{Debye} = \frac{F} {{(\frac{\epsilon R T}{2})}^{1/2}}
606 * @f]
607 * Therefore:
608 * @f[
609 * A_{Debye} = \frac{1}{8 \pi}
610 * {\left(\frac{2 N_a \rho_o}{1000}\right)}^{1/2}
611 * {\left(\frac{N_a e^2}{\epsilon R T }\right)}^{3/2}
612 * @f]
613 *
614 * Units = sqrt(kg/gmol)
615 *
616 * where
617 * - @f$ N_a @f$ is Avogadro's number
618 * - @f$ \rho_w @f$ is the density of water
619 * - @f$ e @f$ is the electronic charge
620 * - @f$ \epsilon = K \epsilon_o @f$ is the permittivity of water
621 * - @f$ K @f$ is the dielectric constant of water,
622 * - @f$ \epsilon_o @f$ is the permittivity of free space.
623 * - @f$ \rho_o @f$ is the density of the solvent in its standard state.
624 *
625 * Nominal value at 298 K and 1 atm = 1.172576 (kg/gmol)^(1/2)
626 * based on:
627 * - @f$ \epsilon / \epsilon_0 @f$ = 78.54 (water at 25C)
628 * - T = 298.15 K
629 * - B_Debye = 3.28640E9 (kg/gmol)^(1/2) / m
630 *
631 * ### Temperature and Pressure Dependence of the Activity Coefficients
632 *
633 * Temperature dependence of the activity coefficients leads to nonzero terms
634 * for the excess enthalpy and entropy of solution. This means that the partial
635 * molar enthalpies, entropies, and heat capacities are all non-trivial to
636 * compute. The following formulas are used.
637 *
638 * The partial molar enthalpy, @f$ \bar s_k(T,P) @f$:
639 *
640 * @f[
641 * \bar h_k(T,P) = h^{\triangle}_k(T,P)
642 * - R T^2 \frac{d \ln(\gamma_k^\triangle)}{dT}
643 * @f]
644 * The solvent partial molar enthalpy is equal to
645 * @f[
646 * \bar h_o(T,P) = h^{o}_o(T,P) - R T^2 \frac{d \ln(a_o)}{dT}
647 * = h^{o}_o(T,P)
648 * + R T^2 (\sum_{k \neq o} m_k) \tilde{M_o} (\frac{d \phi}{dT})
649 * @f]
650 *
651 * The partial molar entropy, @f$ \bar s_k(T,P) @f$:
652 *
653 * @f[
654 * \bar s_k(T,P) = s^{\triangle}_k(T,P)
655 * - R \ln( \gamma^{\triangle}_k \frac{m_k}{m^{\triangle}}))
656 * - R T \frac{d \ln(\gamma^{\triangle}_k) }{dT}
657 * @f]
658 * @f[
659 * \bar s_o(T,P) = s^o_o(T,P) - R \ln(a_o)
660 * - R T \frac{d \ln(a_o)}{dT}
661 * @f]
662 *
663 * The partial molar heat capacity, @f$ C_{p,k}(T,P) @f$:
664 *
665 * @f[
666 * \bar C_{p,k}(T,P) = C^{\triangle}_{p,k}(T,P)
667 * - 2 R T \frac{d \ln( \gamma^{\triangle}_k)}{dT}
668 * - R T^2 \frac{d^2 \ln(\gamma^{\triangle}_k) }{{dT}^2}
669 * @f]
670 * @f[
671 * \bar C_{p,o}(T,P) = C^o_{p,o}(T,P)
672 * - 2 R T \frac{d \ln(a_o)}{dT}
673 * - R T^2 \frac{d^2 \ln(a_o)}{{dT}^2}
674 * @f]
675 *
676 * The pressure dependence of the activity coefficients leads to non-zero terms
677 * for the excess Volume of the solution. Therefore, the partial molar volumes
678 * are functions of the pressure derivatives of the activity coefficients.
679 * @f[
680 * \bar V_k(T,P) = V^{\triangle}_k(T,P)
681 * + R T \frac{d \ln(\gamma^{\triangle}_k) }{dP}
682 * @f]
683 * @f[
684 * \bar V_o(T,P) = V^o_o(T,P)
685 * + R T \frac{d \ln(a_o)}{dP}
686 * @f]
687 *
688 * The majority of work for these functions take place in the internal routines
689 * that calculate the first and second derivatives of the log of the activity
690 * coefficients wrt temperature, s_update_dlnMolalityActCoeff_dT(),
691 * s_update_d2lnMolalityActCoeff_dT2(), and the first derivative of the log
692 * activity coefficients wrt pressure, s_update_dlnMolalityActCoeff_dP().
693 *
694 * ## Application within Kinetics Managers
695 *
696 * For the time being, we have set the standard concentration for all solute
697 * species in this phase equal to the default concentration of the solvent at
698 * the system temperature and pressure multiplied by Mnaught (kg solvent / gmol
699 * solvent). The solvent standard concentration is just equal to its standard
700 * state concentration.
701 *
702 * This means that the kinetics operator essentially works on an generalized
703 * concentration basis (kmol / m3), with units for the kinetic rate constant
704 * specified as if all reactants (solvent or solute) are on a concentration
705 * basis (kmol /m3). The concentration will be modified by the activity
706 * coefficients.
707 *
708 * For example, a bulk-phase binary reaction between liquid solute species *j*
709 * and *k*, producing a new liquid solute species *l* would have the following
710 * equation for its rate of progress variable, @f$ R^1 @f$, which has units of
711 * kmol m-3 s-1.
712 *
713 * @f[
714 * R^1 = k^1 C_j^a C_k^a = k^1 (C^o_o \tilde{M}_o a_j) (C^o_o \tilde{M}_o a_k)
715 * @f]
716 *
717 * where
718 *
719 * @f[
720 * C_j^a = C^o_o \tilde{M}_o a_j \quad and \quad C_k^a = C^o_o \tilde{M}_o a_k
721 * @f]
722 *
723 * @f$ C_j^a @f$ is the activity concentration of species *j*, and
724 * @f$ C_k^a @f$ is the activity concentration of species *k*. @f$ C^o_o @f$ is
725 * the concentration of water at 298 K and 1 atm. @f$ \tilde{M}_o @f$ has units
726 * of kg solvent per gmol solvent and is equal to
727 *
728 * @f[
729 * \tilde{M}_o = \frac{M_o}{1000}
730 * @f]
731 *
732 * @f$ a_j @f$ is the activity of species *j* at the current temperature and
733 * pressure and concentration of the liquid phase is given by the molality based
734 * activity coefficient multiplied by the molality of the jth species.
735 *
736 * @f[
737 * a_j = \gamma_j^\triangle m_j = \gamma_j^\triangle \frac{n_j}{\tilde{M}_o n_o}
738 * @f]
739 *
740 * @f$ k^1 @f$ has units of m^3/kmol/s.
741 *
742 * Therefore the generalized activity concentration of a solute species has the following form
743 *
744 * @f[
745 * C_j^a = C^o_o \frac{\gamma_j^\triangle n_j}{n_o}
746 * @f]
747 *
748 * The generalized activity concentration of the solvent has the same units, but it's a simpler form
749 *
750 * @f[
751 * C_o^a = C^o_o a_o
752 * @f]
753 *
754 * The reverse rate constant can then be obtained from the law of microscopic reversibility
755 * and the equilibrium expression for the system.
756 *
757 * @f[
758 * \frac{a_j a_k}{ a_l} = K^{o,1} = \exp(\frac{\mu^o_l - \mu^o_j - \mu^o_k}{R T} )
759 * @f]
760 *
761 * @f$ K^{o,1} @f$ is the dimensionless form of the equilibrium constant.
762 *
763 * @f[
764 * R^{-1} = k^{-1} C_l^a = k^{-1} (C_o \tilde{M}_o a_l)
765 * @f]
766 *
767 * where
768 *
769 * @f[
770 * k^{-1} = k^1 K^{o,1} C_o \tilde{M}_o
771 * @f]
772 *
773 * @f$ k^{-1} @f$ has units of 1/s.
774 *
775 * @ingroup thermoprops
776 */
778{
779public:
780 ~HMWSoln();
781
782 //! Construct and initialize an HMWSoln ThermoPhase object
783 //! directly from an input file
784 /*!
785 * This constructor is a shell that calls the routine initThermo(), with
786 * a reference to the parsed input file to get the info for the phase.
787 *
788 * @param inputFile Name of the input file containing the phase definition
789 * to set up the object. If blank, an empty phase will be
790 * created.
791 * @param id ID of the phase in the input file. Defaults to the
792 * empty string.
793 */
794 explicit HMWSoln(const string& inputFile="", const string& id="");
795
796 //! @name Utilities
797 //! @{
798
799 string type() const override {
800 return "HMW-electrolyte";
801 }
802
803 //! @}
804 //! @name Molar Thermodynamic Properties of the Solution
805 //! @{
806
807 /**
808 * Excess molar enthalpy of the solution from
809 * the mixing process. Units: J/ kmol.
810 *
811 * Note this is kmol of the total solution.
812 */
813 virtual double relative_enthalpy() const;
814
815 /**
816 * Excess molar enthalpy of the solution from
817 * the mixing process on a molality basis.
818 * Units: J/ (kmol add salt).
819 *
820 * Note this is kmol of the guessed at salt composition
821 */
822 virtual double relative_molal_enthalpy() const;
823
824 double cv_mole() const override;
825
826 //! @}
827 //! @name Mechanical Equation of State Properties
828 //!
829 //! In this equation of state implementation, the density is a function
830 //! only of the mole fractions. Therefore, it can't be an independent
831 //! variable. Instead, the pressure is used as the independent variable.
832 //! Functions which try to set the thermodynamic state by calling
833 //! setDensity() will cause an exception to be thrown.
834 //! @{
835
836protected:
837 void calcDensity() override;
838
839public:
840 //! @}
841 //! @name Activities, Standard States, and Activity Concentrations
842 //!
843 //! The activity @f$ a_k @f$ of a species in solution is related to the
844 //! chemical potential by @f[ \mu_k = \mu_k^0(T) + \hat R T \ln a_k. @f] The
845 //! quantity @f$ \mu_k^0(T,P) @f$ is the chemical potential at unit activity,
846 //! which depends only on temperature and the pressure. Activity is assumed
847 //! to be molality-based here.
848 //! @{
849
850 //! This method returns an array of generalized activity concentrations
851 /*!
852 * The generalized activity concentrations, @f$ C_k^a @f$, are defined such
853 * that @f$ a_k = C^a_k / C^0_k, @f$ where @f$ C^0_k @f$ is a standard
854 * concentration defined below. These generalized concentrations are used
855 * by kinetics manager classes to compute the forward and reverse rates of
856 * elementary reactions.
857 *
858 * The generalized activity concentration of a solute species has the
859 * following form
860 *
861 * @f[
862 * C_j^a = C^o_o \frac{\gamma_j^\triangle n_j}{n_o}
863 * @f]
864 *
865 * The generalized activity concentration of the solvent has the same units,
866 * but it's a simpler form
867 *
868 * @f[
869 * C_o^a = C^o_o a_o
870 * @f]
871 *
872 * @param c Array of generalized concentrations. The
873 * units are kmol m-3 for both the solvent and the solute species
874 */
875 void getActivityConcentrations(span<double> c) const override;
876
877 //! Return the standard concentration for the kth species
878 /*!
879 * The standard concentration @f$ C^0_k @f$ used to normalize the activity
880 * (that is, generalized) concentration for use
881 *
882 * We have set the standard concentration for all solute species in this
883 * phase equal to the default concentration of the solvent at the system
884 * temperature and pressure multiplied by Mnaught (kg solvent / gmol
885 * solvent). The solvent standard concentration is just equal to its
886 * standard state concentration.
887 *
888 * @f[
889 * C_j^0 = C^o_o \tilde{M}_o \quad and C_o^0 = C^o_o
890 * @f]
891 *
892 * The consequence of this is that the standard concentrations have unequal
893 * units between the solvent and the solute. However, both the solvent and
894 * the solute activity concentrations will have the same units of kmol/kg^3.
895 *
896 * This means that the kinetics operator essentially works on an generalized
897 * concentration basis (kmol / m3), with units for the kinetic rate constant
898 * specified as if all reactants (solvent or solute) are on a concentration
899 * basis (kmol /m3). The concentration will be modified by the activity
900 * coefficients.
901 *
902 * For example, a bulk-phase binary reaction between liquid solute species
903 * *j* and *k*, producing a new liquid solute species *l* would have the
904 * following equation for its rate of progress variable, @f$ R^1 @f$, which
905 * has units of kmol m-3 s-1.
906 *
907 * @f[
908 * R^1 = k^1 C_j^a C_k^a = k^1 (C^o_o \tilde{M}_o a_j) (C^o_o \tilde{M}_o a_k)
909 * @f]
910 *
911 * where
912 *
913 * @f[
914 * C_j^a = C^o_o \tilde{M}_o a_j \quad and \quad C_k^a = C^o_o \tilde{M}_o a_k
915 * @f]
916 *
917 * @f$ C_j^a @f$ is the activity concentration of species *j*, and
918 * @f$ C_k^a @f$ is the activity concentration of species *k*. @f$ C^o_o @f$
919 * is the concentration of water at 298 K and 1 atm. @f$ \tilde{M}_o @f$ has
920 * units of kg solvent per gmol solvent and is equal to
921 *
922 * @f[
923 * \tilde{M}_o = \frac{M_o}{1000}
924 * @f]
925 *
926 * @f$ a_j @f$ is
927 * the activity of species *j* at the current temperature and pressure
928 * and concentration of the liquid phase is given by the molality based
929 * activity coefficient multiplied by the molality of the jth species.
930 *
931 * @f[
932 * a_j = \gamma_j^\triangle m_j = \gamma_j^\triangle \frac{n_j}{\tilde{M}_o n_o}
933 * @f]
934 *
935 * @f$ k^1 @f$ has units of m^3/kmol/s.
936 *
937 * Therefore the generalized activity concentration of a solute species has
938 * the following form
939 *
940 * @f[
941 * C_j^a = C^o_o \frac{\gamma_j^\triangle n_j}{n_o}
942 * @f]
943 *
944 * The generalized activity concentration of the solvent has the same units,
945 * but it's a simpler form
946 *
947 * @f[
948 * C_o^a = C^o_o a_o
949 * @f]
950 *
951 * @param k Optional parameter indicating the species. The default is to
952 * assume this refers to species 0.
953 * @returns the standard Concentration in units of m^3/kmol.
954 */
955 double standardConcentration(size_t k=0) const override;
956
957 //! Get the array of non-dimensional activities at the current solution
958 //! temperature, pressure, and solution concentration.
959 /*!
960 *
961 * We resolve this function at this level by calling on the
962 * activityConcentration function. However, derived classes may want to
963 * override this default implementation.
964 *
965 * (note solvent is on molar scale).
966 *
967 * @param ac Output vector of activities. Length: m_kk.
968 */
969 void getActivities(span<double> ac) const override;
970
971 //! @}
972 //! @name Partial Molar Properties of the Solution
973 //! @{
974
975 //! Get the species chemical potentials. Units: J/kmol.
976 /*!
977 *
978 * This function returns a vector of chemical potentials of the
979 * species in solution.
980 *
981 * @f[
982 * \mu_k = \mu^{\triangle}_k(T,P) + R T \ln(\gamma_k^{\triangle} m_k)
983 * @f]
984 *
985 * @param mu Output vector of species chemical
986 * potentials. Length: m_kk. Units: J/kmol
987 */
988 void getChemPotentials(span<double> mu) const override;
989
990 //! Returns an array of partial molar enthalpies for the species
991 //! in the mixture. Units (J/kmol)
992 /*!
993 * For this phase, the partial molar enthalpies are equal to the standard
994 * state enthalpies modified by the derivative of the molality-based
995 * activity coefficient wrt temperature
996 *
997 * @f[
998 * \bar h_k(T,P) = h^{\triangle}_k(T,P)
999 * - R T^2 \frac{d \ln(\gamma_k^\triangle)}{dT}
1000 * @f]
1001 * The solvent partial molar enthalpy is equal to
1002 * @f[
1003 * \bar h_o(T,P) = h^{o}_o(T,P) - R T^2 \frac{d \ln(a_o)}{dT}
1004 * = h^{o}_o(T,P)
1005 * + R T^2 (\sum_{k \neq o} m_k) \tilde{M_o} (\frac{d \phi}{dT})
1006 * @f]
1007 *
1008 * @param hbar Output vector of species partial molar enthalpies.
1009 * Length: m_kk. units are J/kmol.
1010 */
1011 void getPartialMolarEnthalpies(span<double> hbar) const override;
1012
1013 //! Returns an array of partial molar entropies of the species in the
1014 //! solution. Units: J/kmol/K.
1015 /*!
1016 * Maxwell's equations provide an answer for how calculate this
1017 * (p.215 Smith and Van Ness)
1018 *
1019 * d(chemPot_i)/dT = -sbar_i
1020 *
1021 * For this phase, the partial molar entropies are equal to the SS species
1022 * entropies plus the ideal solution contribution plus complicated functions
1023 * of the temperature derivative of the activity coefficients.
1024 *
1025 * @f[
1026 * \bar s_k(T,P) = s^{\triangle}_k(T,P)
1027 * - R \ln( \gamma^{\triangle}_k \frac{m_k}{m^{\triangle}}))
1028 * - R T \frac{d \ln(\gamma^{\triangle}_k) }{dT}
1029 * @f]
1030 * @f[
1031 * \bar s_o(T,P) = s^o_o(T,P) - R \ln(a_o)
1032 * - R T \frac{d \ln(a_o)}{dT}
1033 * @f]
1034 *
1035 * @param sbar Output vector of species partial molar entropies.
1036 * Length = m_kk. units are J/kmol/K.
1037 */
1038 void getPartialMolarEntropies(span<double> sbar) const override;
1039
1040 //! Return an array of partial molar volumes for the species in the mixture.
1041 //! Units: m^3/kmol.
1042 /*!
1043 * For this solution, the partial molar volumes are functions of the
1044 * pressure derivatives of the activity coefficients.
1045 *
1046 * @f[
1047 * \bar V_k(T,P) = V^{\triangle}_k(T,P)
1048 * + R T \frac{d \ln(\gamma^{\triangle}_k) }{dP}
1049 * @f]
1050 * @f[
1051 * \bar V_o(T,P) = V^o_o(T,P)
1052 * + R T \frac{d \ln(a_o)}{dP}
1053 * @f]
1054 *
1055 * @param vbar Output vector of species partial molar volumes.
1056 * Length = m_kk. units are m^3/kmol.
1057 */
1058 void getPartialMolarVolumes(span<double> vbar) const override;
1059
1060 //! Return an array of partial molar heat capacities for the species in the
1061 //! mixture. Units: J/kmol/K
1062 /*!
1063 * The following formulas are implemented within the code.
1064 *
1065 * @f[
1066 * \bar C_{p,k}(T,P) = C^{\triangle}_{p,k}(T,P)
1067 * - 2 R T \frac{d \ln( \gamma^{\triangle}_k)}{dT}
1068 * - R T^2 \frac{d^2 \ln(\gamma^{\triangle}_k) }{{dT}^2}
1069 * @f]
1070 * @f[
1071 * \bar C_{p,o}(T,P) = C^o_{p,o}(T,P)
1072 * - 2 R T \frac{d \ln(a_o)}{dT}
1073 * - R T^2 \frac{d^2 \ln(a_o)}{{dT}^2}
1074 * @f]
1075 *
1076 * @param cpbar Output vector of species partial molar heat capacities at
1077 * constant pressure. Length = m_kk. units are J/kmol/K.
1078 */
1079 void getPartialMolarCp(span<double> cpbar) const override;
1080
1081public:
1082 //! @}
1083
1084 //! Get the saturation pressure for a given temperature.
1085 /*!
1086 * Note the limitations of this function. Stability considerations
1087 * concerning multiphase equilibrium are ignored in this calculation.
1088 * Therefore, the call is made directly to the SS of water underneath. The
1089 * object is put back into its original state at the end of the call.
1090 *
1091 * @todo This is probably not implemented correctly. The stability of the
1092 * salt should be added into this calculation. The underlying water
1093 * model may be called to get the stability of the pure water
1094 * solution, if needed.
1095 *
1096 * @param T Temperature (kelvin)
1097 */
1098 double satPressure(double T) override;
1099
1100 /*
1101 * -------------- Utilities -------------------------------
1102 */
1103
1104 void setBinarySalt(const string& sp1, const string& sp2,
1105 span<const double> beta0, span<const double> beta1,
1106 span<const double> beta2, span<const double> Cphi, double alpha1,
1107 double alpha2);
1108 void setTheta(const string& sp1, const string& sp2,
1109 span<const double> theta);
1110 void setPsi(const string& sp1, const string& sp2,
1111 const string& sp3, span<const double> psi);
1112 void setLambda(const string& sp1, const string& sp2,
1113 span<const double> lambda);
1114 void setMunnn(const string& sp, span<const double> munnn);
1115 void setZeta(const string& sp1, const string& sp2,
1116 const string& sp3, span<const double> psi);
1117
1118 void setPitzerTempModel(const string& model);
1119 void setPitzerRefTemperature(double Tref) {
1120 m_TempPitzerRef = Tref;
1121 }
1122
1123 //! Set the A_Debye parameter. If a negative value is provided, enables
1124 //! calculation of A_Debye using the detailed water equation of state.
1125 void setA_Debye(double A);
1126
1127 void setMaxIonicStrength(double Imax) {
1128 m_maxIionicStrength = Imax;
1129 }
1130
1131 void setCroppingCoefficients(double ln_gamma_k_min, double ln_gamma_k_max,
1132 double ln_gamma_o_min, double ln_gamma_o_max);
1133
1134 void initThermo() override;
1135 void getParameters(AnyMap& phaseNode) const override;
1136
1137 //! Value of the Debye Huckel constant as a function of temperature
1138 //! and pressure.
1139 /*!
1140 * A_Debye = (F e B_Debye) / (8 Pi epsilon R T)
1141 *
1142 * Units = sqrt(kg/gmol)
1143 *
1144 * @param temperature Temperature of the derivative calculation
1145 * or -1 to indicate the current temperature
1146 * @param pressure Pressure of the derivative calculation
1147 * or -1 to indicate the current pressure
1148 */
1149 virtual double A_Debye_TP(double temperature = -1.0,
1150 double pressure = -1.0) const;
1151
1152 //! Value of the derivative of the Debye Huckel constant with respect to
1153 //! temperature as a function of temperature and pressure.
1154 /*!
1155 * A_Debye = (F e B_Debye) / (8 Pi epsilon R T)
1156 *
1157 * Units = sqrt(kg/gmol)
1158 *
1159 * @param temperature Temperature of the derivative calculation
1160 * or -1 to indicate the current temperature
1161 * @param pressure Pressure of the derivative calculation
1162 * or -1 to indicate the current pressure
1163 */
1164 virtual double dA_DebyedT_TP(double temperature = -1.0,
1165 double pressure = -1.0) const;
1166
1167 /**
1168 * Value of the derivative of the Debye Huckel constant with respect to
1169 * pressure, as a function of temperature and pressure.
1170 *
1171 * A_Debye = (F e B_Debye) / (8 Pi epsilon R T)
1172 *
1173 * Units = sqrt(kg/gmol)
1174 *
1175 * @param temperature Temperature of the derivative calculation
1176 * or -1 to indicate the current temperature
1177 * @param pressure Pressure of the derivative calculation
1178 * or -1 to indicate the current pressure
1179 */
1180 virtual double dA_DebyedP_TP(double temperature = -1.0,
1181 double pressure = -1.0) const;
1182
1183 /**
1184 * Return Pitzer's definition of A_L. This is basically the
1185 * derivative of the A_phi multiplied by 4 R T**2
1186 *
1187 * A_Debye = (F e B_Debye) / (8 Pi epsilon R T)
1188 * dA_phidT = d(A_Debye)/dT / 3.0
1189 * A_L = dA_phidT * (4 * R * T * T)
1190 *
1191 * Units = sqrt(kg/gmol) (RT)
1192 *
1193 * @param temperature Temperature of the derivative calculation
1194 * or -1 to indicate the current temperature
1195 * @param pressure Pressure of the derivative calculation
1196 * or -1 to indicate the current pressure
1197 */
1198 double ADebye_L(double temperature = -1.0, double pressure = -1.0) const;
1199
1200 /**
1201 * Return Pitzer's definition of A_J. This is basically the temperature
1202 * derivative of A_L, and the second derivative of A_phi
1203 *
1204 * A_Debye = (F e B_Debye) / (8 Pi epsilon R T)
1205 * dA_phidT = d(A_Debye)/dT / 3.0
1206 * A_J = 2 A_L/T + 4 * R * T * T * d2(A_phi)/dT2
1207 *
1208 * Units = sqrt(kg/gmol) (R)
1209 *
1210 * @param temperature Temperature of the derivative calculation
1211 * or -1 to indicate the current temperature
1212 * @param pressure Pressure of the derivative calculation
1213 * or -1 to indicate the current pressure
1214 */
1215 double ADebye_J(double temperature = -1.0, double pressure = -1.0) const;
1216
1217 /**
1218 * Return Pitzer's definition of A_V. This is the derivative wrt pressure of
1219 * A_phi multiplied by - 4 R T
1220 *
1221 * A_Debye = (F e B_Debye) / (8 Pi epsilon R T)
1222 * dA_phidT = d(A_Debye)/dP / 3.0
1223 * A_V = - dA_phidP * (4 * R * T)
1224 *
1225 * Units = sqrt(kg/gmol) (RT) / Pascal
1226 *
1227 * @param temperature Temperature of the derivative calculation
1228 * or -1 to indicate the current temperature
1229 * @param pressure Pressure of the derivative calculation
1230 * or -1 to indicate the current pressure
1231 */
1232 double ADebye_V(double temperature = -1.0, double pressure = -1.0) const;
1233
1234 //! Value of the 2nd derivative of the Debye Huckel constant with respect to
1235 //! temperature as a function of temperature and pressure.
1236 /*!
1237 * A_Debye = (F e B_Debye) / (8 Pi epsilon R T)
1238 *
1239 * Units = sqrt(kg/gmol)
1240 *
1241 * @param temperature Temperature of the derivative calculation
1242 * or -1 to indicate the current temperature
1243 * @param pressure Pressure of the derivative calculation
1244 * or -1 to indicate the current pressure
1245 */
1246 virtual double d2A_DebyedT2_TP(double temperature = -1.0,
1247 double pressure = -1.0) const;
1248
1249 //! Print out all of the input Pitzer coefficients.
1250 void printCoeffs() const;
1251
1252 //! Get the array of unscaled non-dimensional molality based
1253 //! activity coefficients at the current solution temperature,
1254 //! pressure, and solution concentration.
1255 /*!
1256 * See Denbigh p. 278 @cite denbigh1981 for a thorough discussion. This method must
1257 * be overridden in classes which derive from MolalityVPSSTP. This function
1258 * takes over from the molar-based activity coefficient calculation,
1259 * getActivityCoefficients(), in derived classes.
1260 *
1261 * @param acMolality Output vector containing the molality based activity coefficients.
1262 * length: m_kk.
1263 */
1264 void getUnscaledMolalityActivityCoefficients(span<double> acMolality) const override;
1265
1266private:
1267 //! Apply the current phScale to a set of activity Coefficients
1268 /*!
1269 * See the Eq3/6 Manual for a thorough discussion.
1270 */
1271 void s_updateScaling_pHScaling() const;
1272
1273 //! Apply the current phScale to a set of derivatives of the activity
1274 //! Coefficients wrt temperature
1275 /*!
1276 * See the Eq3/6 Manual for a thorough discussion of the need
1277 */
1278 void s_updateScaling_pHScaling_dT() const;
1279
1280 //! Apply the current phScale to a set of 2nd derivatives of the activity
1281 //! Coefficients wrt temperature
1282 /*!
1283 * See the Eq3/6 Manual for a thorough discussion of the need
1284 */
1285 void s_updateScaling_pHScaling_dT2() const;
1286
1287 //! Apply the current phScale to a set of derivatives of the activity
1288 //! Coefficients wrt pressure
1289 /*!
1290 * See the Eq3/6 Manual for a thorough discussion of the need
1291 */
1292 void s_updateScaling_pHScaling_dP() const;
1293
1294 //! Calculate the Chlorine activity coefficient on the NBS scale
1295 /*!
1296 * We assume here that the m_IionicMolality variable is up to date.
1297 */
1298 double s_NBS_CLM_lnMolalityActCoeff() const;
1299
1300 //! Calculate the temperature derivative of the Chlorine activity
1301 //! coefficient on the NBS scale
1302 /*!
1303 * We assume here that the m_IionicMolality variable is up to date.
1304 */
1305 double s_NBS_CLM_dlnMolalityActCoeff_dT() const;
1306
1307 //! Calculate the second temperature derivative of the Chlorine activity
1308 //! coefficient on the NBS scale
1309 /*!
1310 * We assume here that the m_IionicMolality variable is up to date.
1311 */
1313
1314 //! Calculate the pressure derivative of the Chlorine activity coefficient
1315 /*!
1316 * We assume here that the m_IionicMolality variable is up to date.
1317 */
1318 double s_NBS_CLM_dlnMolalityActCoeff_dP() const;
1319
1320private:
1321 /**
1322 * This is the form of the temperature dependence of Pitzer parameterization
1323 * used in the model.
1324 *
1325 * PITZER_TEMP_CONSTANT 0
1326 * PITZER_TEMP_LINEAR 1
1327 * PITZER_TEMP_COMPLEX1 2
1328 */
1329 int m_formPitzerTemp = PITZER_TEMP_CONSTANT;
1330
1331 //! Current value of the ionic strength on the molality scale Associated
1332 //! Salts, if present in the mechanism, don't contribute to the value of the
1333 //! ionic strength in this version of the Ionic strength.
1334 mutable double m_IionicMolality = 0.0;
1335
1336 //! Maximum value of the ionic strength allowed in the calculation of the
1337 //! activity coefficients.
1339
1340 //! Reference Temperature for the Pitzer formulations.
1341 double m_TempPitzerRef = 298.15;
1342
1343public:
1344 /**
1345 * Form of the constant outside the Debye-Huckel term called A. It's
1346 * normally a function of temperature and pressure. However, it can be set
1347 * from the input file in order to aid in numerical comparisons. Acceptable
1348 * forms:
1349 *
1350 * A_DEBYE_CONST 0
1351 * A_DEBYE_WATER 1
1352 *
1353 * The A_DEBYE_WATER form may be used for water solvents with needs to cover
1354 * varying temperatures and pressures. Note, the dielectric constant of
1355 * water is a relatively strong function of T, and its variability must be
1356 * accounted for,
1357 */
1358 int m_form_A_Debye = A_DEBYE_CONST;
1359
1360private:
1361 /**
1362 * A_Debye: this expression appears on the top of the ln actCoeff term in
1363 * the general Debye-Huckel expression It depends on temperature.
1364 * And, therefore, most be recalculated whenever T or P changes.
1365 * This variable is a local copy of the calculation.
1366 *
1367 * A_Debye = (F e B_Debye) / (8 Pi epsilon R T)
1368 *
1369 * where B_Debye = F / sqrt(epsilon R T/2)
1370 * (dw/1000)^(1/2)
1371 *
1372 * A_Debye = (1/ (8 Pi)) (2 Na * dw/1000)^(1/2)
1373 * (e * e / (epsilon * kb * T))^(3/2)
1374 *
1375 * Units = sqrt(kg/gmol)
1376 *
1377 * Nominal value = 1.172576 sqrt(kg/gmol)
1378 * based on:
1379 * epsilon/epsilon_0 = 78.54
1380 * (water at 25C)
1381 * epsilon_0 = 8.854187817E-12 C2 N-1 m-2
1382 * e = 1.60217653 E-19 C
1383 * F = 9.6485309E7 C kmol-1
1384 * R = 8.314472E3 kg m2 s-2 kmol-1 K-1
1385 * T = 298.15 K
1386 * B_Debye = 3.28640E9 sqrt(kg/gmol)/m
1387 * dw = C_0 * M_0 (density of water) (kg/m3)
1388 * = 1.0E3 at 25C
1389 */
1390 mutable double m_A_Debye = 1.172576;
1391
1392 //! Water standard state calculator
1393 /*!
1394 * derived from the equation of state for water.
1395 */
1396 PDSS* m_waterSS = nullptr;
1397
1398 //! Pointer to the water property calculator
1399 unique_ptr<WaterProps> m_waterProps;
1400
1401 /**
1402 * Array of 2D data used in the Pitzer/HMW formulation. Beta0_ij[i][j] is
1403 * the value of the Beta0 coefficient for the ij salt. It will be nonzero
1404 * iff i and j are both charged and have opposite sign. The array is also
1405 * symmetric. counterIJ where counterIJ = m_counterIJ[i][j] is used to
1406 * access this array.
1407 */
1408 mutable vector<double> m_Beta0MX_ij;
1409
1410 //! Derivative of Beta0_ij[i][j] wrt T. Vector index is counterIJ
1411 mutable vector<double> m_Beta0MX_ij_L;
1412
1413 //! Derivative of Beta0_ij[i][j] wrt TT. Vector index is counterIJ
1414 mutable vector<double> m_Beta0MX_ij_LL;
1415
1416 //! Derivative of Beta0_ij[i][j] wrt P. Vector index is counterIJ
1417 mutable vector<double> m_Beta0MX_ij_P;
1418
1419 //! Array of coefficients for Beta0, a variable in Pitzer's papers
1420 /*!
1421 * Column index is counterIJ. m_Beta0MX_ij_coeff.col(counterIJ) is a
1422 * `span` containing the coefficients for the counterIJ interaction.
1423 */
1425
1426 //! Array of 2D data used in the Pitzer/HMW formulation. Beta1_ij[i][j] is
1427 //! the value of the Beta1 coefficient for the ij salt. It will be nonzero
1428 //! iff i and j are both charged and have opposite sign. The array is also
1429 //! symmetric. counterIJ where counterIJ = m_counterIJ[i][j] is used to
1430 //! access this array.
1431 mutable vector<double> m_Beta1MX_ij;
1432
1433 //! Derivative of Beta1_ij[i][j] wrt T. Vector index is counterIJ
1434 mutable vector<double> m_Beta1MX_ij_L;
1435
1436 //! Derivative of Beta1_ij[i][j] wrt TT. Vector index is counterIJ
1437 mutable vector<double> m_Beta1MX_ij_LL;
1438
1439 //! Derivative of Beta1_ij[i][j] wrt P. Vector index is counterIJ
1440 mutable vector<double> m_Beta1MX_ij_P;
1441
1442 //! Array of coefficients for Beta1, a variable in Pitzer's papers
1443 /*!
1444 * Column index is counterIJ. m_Beta1MX_ij_coeff.col(counterIJ) is a
1445 * `span` containing the vector of coefficients for the counterIJ interaction.
1446 */
1448
1449 //! Array of 2D data used in the Pitzer/HMW formulation. Beta2_ij[i][j] is
1450 //! the value of the Beta2 coefficient for the ij salt. It will be nonzero
1451 //! iff i and j are both charged and have opposite sign, and i and j both
1452 //! have charges of 2 or more. The array is also symmetric. counterIJ where
1453 //! counterIJ = m_counterIJ[i][j] is used to access this array.
1454 mutable vector<double> m_Beta2MX_ij;
1455
1456 //! Derivative of Beta2_ij[i][j] wrt T. Vector index is counterIJ
1457 mutable vector<double> m_Beta2MX_ij_L;
1458
1459 //! Derivative of Beta2_ij[i][j] wrt TT. Vector index is counterIJ
1460 mutable vector<double> m_Beta2MX_ij_LL;
1461
1462 //! Derivative of Beta2_ij[i][j] wrt P. Vector index is counterIJ
1463 mutable vector<double> m_Beta2MX_ij_P;
1464
1465 //! Array of coefficients for Beta2, a variable in Pitzer's papers
1466 /*!
1467 * column index is counterIJ. m_Beta2MX_ij_coeff.col(counterIJ) is a
1468 * `span` containing the vector of coefficients for the counterIJ
1469 * interaction. This was added for the YMP database version of the code
1470 * since it contains temperature-dependent parameters for some 2-2
1471 * electrolytes.
1472 */
1474
1475 // Array of 2D data used in the Pitzer/HMW formulation. Alpha1MX_ij[i][j] is
1476 // the value of the alpha1 coefficient for the ij interaction. It will be
1477 // nonzero iff i and j are both charged and have opposite sign. It is
1478 // symmetric wrt i, j. counterIJ where counterIJ = m_counterIJ[i][j] is used
1479 // to access this array.
1480 vector<double> m_Alpha1MX_ij;
1481
1482 //! Array of 2D data used in the Pitzer/HMW formulation. Alpha2MX_ij[i][j]
1483 //! is the value of the alpha2 coefficient for the ij interaction. It will
1484 //! be nonzero iff i and j are both charged and have opposite sign, and i
1485 //! and j both have charges of 2 or more, usually. It is symmetric wrt i, j.
1486 //! counterIJ, where counterIJ = m_counterIJ[i][j], is used to access this
1487 //! array.
1488 vector<double> m_Alpha2MX_ij;
1489
1490 //! Array of 2D data used in the Pitzer/HMW formulation. CphiMX_ij[i][j] is
1491 //! the value of the Cphi coefficient for the ij interaction. It will be
1492 //! nonzero iff i and j are both charged and have opposite sign, and i and j
1493 //! both have charges of 2 or more. The array is also symmetric. counterIJ
1494 //! where counterIJ = m_counterIJ[i][j] is used to access this array.
1495 mutable vector<double> m_CphiMX_ij;
1496
1497 //! Derivative of Cphi_ij[i][j] wrt T. Vector index is counterIJ
1498 mutable vector<double> m_CphiMX_ij_L;
1499
1500 //! Derivative of Cphi_ij[i][j] wrt TT. Vector index is counterIJ
1501 mutable vector<double> m_CphiMX_ij_LL;
1502
1503 //! Derivative of Cphi_ij[i][j] wrt P. Vector index is counterIJ
1504 mutable vector<double> m_CphiMX_ij_P;
1505
1506 //! Array of coefficients for CphiMX, a parameter in the activity
1507 //! coefficient formulation
1508 /*!
1509 * Column index is counterIJ. m_CphiMX_ij_coeff.col(counterIJ) is a
1510 * `span` containing the vector of coefficients for the counterIJ
1511 * interaction.
1512 */
1514
1515 //! Array of 2D data for Theta_ij[i][j] in the Pitzer/HMW formulation.
1516 /*!
1517 * Array of 2D data used in the Pitzer/HMW formulation. Theta_ij[i][j] is
1518 * the value of the theta coefficient for the ij interaction. It will be
1519 * nonzero for charged ions with the same sign. It is symmetric. counterIJ
1520 * where counterIJ = m_counterIJ[i][j] is used to access this array.
1521 *
1522 * HKM Recent Pitzer papers have used a functional form for Theta_ij, which
1523 * depends on the ionic strength.
1524 */
1525 mutable vector<double> m_Theta_ij;
1526
1527 //! Derivative of Theta_ij[i][j] wrt T. Vector index is counterIJ
1528 mutable vector<double> m_Theta_ij_L;
1529
1530 //! Derivative of Theta_ij[i][j] wrt TT. Vector index is counterIJ
1531 mutable vector<double> m_Theta_ij_LL;
1532
1533 //! Derivative of Theta_ij[i][j] wrt P. Vector index is counterIJ
1534 mutable vector<double> m_Theta_ij_P;
1535
1536 //! Array of coefficients for Theta_ij[i][j] in the Pitzer/HMW formulation.
1537 /*!
1538 * Theta_ij[i][j] is the value of the theta coefficient for the ij
1539 * interaction. It will be nonzero for charged ions with the same sign. It
1540 * is symmetric. Column index is counterIJ. counterIJ where counterIJ =
1541 * m_counterIJ[i][j] is used to access this array.
1542 *
1543 * m_Theta_ij_coeff.col(counterIJ) is a `span` containing the vector of
1544 * coefficients for the counterIJ interaction.
1545 */
1547
1548 //! Array of 3D data used in the Pitzer/HMW formulation.
1549 /*!
1550 * Psi_ijk[n] is the value of the psi coefficient for the
1551 * ijk interaction where
1552 *
1553 * n = k + j * m_kk + i * m_kk * m_kk;
1554 *
1555 * It is potentially nonzero everywhere. The first two coordinates are
1556 * symmetric wrt cations, and the last two coordinates are symmetric wrt
1557 * anions.
1558 */
1559 mutable vector<double> m_Psi_ijk;
1560
1561 //! Derivative of Psi_ijk[n] wrt T. See m_Psi_ijk for reference on the
1562 //! indexing into this variable.
1563 mutable vector<double> m_Psi_ijk_L;
1564
1565 //! Derivative of Psi_ijk[n] wrt TT. See m_Psi_ijk for reference on the
1566 //! indexing into this variable.
1567 mutable vector<double> m_Psi_ijk_LL;
1568
1569 //! Derivative of Psi_ijk[n] wrt P. See m_Psi_ijk for reference on the
1570 //! indexing into this variable.
1571 mutable vector<double> m_Psi_ijk_P;
1572
1573 //! Array of coefficients for Psi_ijk[n] in the Pitzer/HMW formulation.
1574 /*!
1575 * Psi_ijk[n] is the value of the psi coefficient for the
1576 * ijk interaction where
1577 *
1578 * n = k + j * m_kk + i * m_kk * m_kk;
1579 *
1580 * It is potentially nonzero everywhere. The first two coordinates are
1581 * symmetric wrt cations, and the last two coordinates are symmetric wrt
1582 * anions.
1583 *
1584 * m_Psi_ijk_coeff.col(n) is a `span` containing the vector of coefficients
1585 * for the n interaction.
1586 */
1588
1589 //! Lambda coefficient for the ij interaction
1590 /*!
1591 * Array of 2D data used in the Pitzer/HMW formulation. Lambda_nj[n][j]
1592 * represents the lambda coefficient for the ij interaction. This is a
1593 * general interaction representing neutral species. The neutral species
1594 * occupy the first index, that is, n. The charged species occupy the j
1595 * coordinate. neutral, neutral interactions are also included here.
1596 */
1598
1599 //! Derivative of Lambda_nj[i][j] wrt T. see m_Lambda_ij
1601
1602 //! Derivative of Lambda_nj[i][j] wrt TT
1604
1605 //! Derivative of Lambda_nj[i][j] wrt P
1607
1608 //! Array of coefficients for Lambda_nj[i][j] in the Pitzer/HMW formulation.
1609 /*!
1610 * Array of 2D data used in the Pitzer/HMW formulation. Lambda_ij[i][j]
1611 * represents the lambda coefficient for the ij interaction. This is a
1612 * general interaction representing neutral species. The neutral species
1613 * occupy the first index, that is, i. The charged species occupy the j
1614 * coordinate. Neutral, neutral interactions are also included here.
1615 *
1616 * n = j + m_kk * i
1617 *
1618 * m_Lambda_nj_coeff.col(n) is a `span` containing the vector of
1619 * coefficients for the (i,j) interaction.
1620 */
1622
1623 //! Mu coefficient for the self-ternary neutral coefficient
1624 /*!
1625 * Array of 2D data used in the Pitzer/HMW formulation. Mu_nnn[i] represents
1626 * the Mu coefficient for the nnn interaction. This is a general interaction
1627 * representing neutral species interacting with itself.
1628 */
1629 mutable vector<double> m_Mu_nnn;
1630
1631 //! Mu coefficient temperature derivative for the self-ternary neutral
1632 //! coefficient
1633 /*!
1634 * Array of 2D data used in the Pitzer/HMW formulation. Mu_nnn_L[i]
1635 * represents the Mu coefficient temperature derivative for the nnn
1636 * interaction. This is a general interaction representing neutral species
1637 * interacting with itself.
1638 */
1639 mutable vector<double> m_Mu_nnn_L;
1640
1641 //! Mu coefficient 2nd temperature derivative for the self-ternary neutral
1642 //! coefficient
1643 /*!
1644 * Array of 2D data used in the Pitzer/HMW formulation. Mu_nnn_L[i]
1645 * represents the Mu coefficient 2nd temperature derivative for the nnn
1646 * interaction. This is a general interaction representing neutral species
1647 * interacting with itself.
1648 */
1649 mutable vector<double> m_Mu_nnn_LL;
1650
1651 //! Mu coefficient pressure derivative for the self-ternary neutral
1652 //! coefficient
1653 /*!
1654 * Array of 2D data used in the Pitzer/HMW formulation. Mu_nnn_L[i]
1655 * represents the Mu coefficient pressure derivative for the nnn
1656 * interaction. This is a general interaction representing neutral species
1657 * interacting with itself.
1658 */
1659 mutable vector<double> m_Mu_nnn_P;
1660
1661 //! Array of coefficients form_Mu_nnn term
1663
1664 //! Logarithm of the activity coefficients on the molality scale.
1665 /*!
1666 * mutable because we change this if the composition or temperature or
1667 * pressure changes. Index is the species index
1668 */
1669 mutable vector<double> m_lnActCoeffMolal_Scaled;
1670
1671 //! Logarithm of the activity coefficients on the molality scale.
1672 /*!
1673 * mutable because we change this if the composition or temperature or
1674 * pressure changes. Index is the species index
1675 */
1676 mutable vector<double> m_lnActCoeffMolal_Unscaled;
1677
1678 //! Derivative of the Logarithm of the activity coefficients on the molality
1679 //! scale wrt T. Index is the species index
1680 mutable vector<double> m_dlnActCoeffMolaldT_Scaled;
1681
1682 //! Derivative of the Logarithm of the activity coefficients on the molality
1683 //! scale wrt T. Index is the species index
1684 mutable vector<double> m_dlnActCoeffMolaldT_Unscaled;
1685
1686 //! Derivative of the Logarithm of the activity coefficients on the molality
1687 //! scale wrt TT. Index is the species index.
1688 mutable vector<double> m_d2lnActCoeffMolaldT2_Scaled;
1689
1690 //! Derivative of the Logarithm of the activity coefficients on the molality
1691 //! scale wrt TT. Index is the species index
1692 mutable vector<double> m_d2lnActCoeffMolaldT2_Unscaled;
1693
1694 //! Derivative of the Logarithm of the activity coefficients on the
1695 //! molality scale wrt P. Index is the species index
1696 mutable vector<double> m_dlnActCoeffMolaldP_Scaled;
1697
1698 //! Derivative of the Logarithm of the activity coefficients on the
1699 //! molality scale wrt P. Index is the species index
1700 mutable vector<double> m_dlnActCoeffMolaldP_Unscaled;
1701
1702 // -------- Temporary Variables Used in the Activity Coeff Calc
1703
1704 //! Cropped and modified values of the molalities used in activity
1705 //! coefficient calculations
1706 mutable vector<double> m_molalitiesCropped;
1707
1708 //! Boolean indicating whether the molalities are cropped or are modified
1709 mutable bool m_molalitiesAreCropped = false;
1710
1711 //! a counter variable for keeping track of symmetric binary
1712 //! interactions amongst the solute species.
1713 /*!
1714 * n = m_kk*i + j
1715 * m_CounterIJ[n] = counterIJ
1716 */
1717 mutable vector<int> m_CounterIJ;
1718
1719 //! This is elambda, MEC
1720 mutable double elambda[17];
1721
1722 //! This is elambda1, MEC
1723 mutable double elambda1[17];
1724
1725 /**
1726 * Various temporary arrays used in the calculation of the Pitzer activity
1727 * coefficients. The subscript, L, denotes the same quantity's derivative
1728 * wrt temperature
1729 */
1730
1731 //! This is the value of g(x) in Pitzer's papers. Vector index is counterIJ
1732 mutable vector<double> m_gfunc_IJ;
1733
1734 //! This is the value of g2(x2) in Pitzer's papers. Vector index is counterIJ
1735 mutable vector<double> m_g2func_IJ;
1736
1737 //! hfunc, was called gprime in Pitzer's paper. However, it's not the
1738 //! derivative of gfunc(x), so I renamed it. Vector index is counterIJ
1739 mutable vector<double> m_hfunc_IJ;
1740
1741 //! hfunc2, was called gprime in Pitzer's paper. However, it's not the
1742 //! derivative of gfunc(x), so I renamed it. Vector index is counterIJ
1743 mutable vector<double> m_h2func_IJ;
1744
1745 //! Intermediate variable called BMX in Pitzer's paper. This is the basic
1746 //! cation - anion interaction. Vector index is counterIJ
1747 mutable vector<double> m_BMX_IJ;
1748
1749 //! Derivative of BMX_IJ wrt T. Vector index is counterIJ
1750 mutable vector<double> m_BMX_IJ_L;
1751
1752 //! Derivative of BMX_IJ wrt TT. Vector index is counterIJ
1753 mutable vector<double> m_BMX_IJ_LL;
1754
1755 //! Derivative of BMX_IJ wrt P. Vector index is counterIJ
1756 mutable vector<double> m_BMX_IJ_P;
1757
1758 //! Intermediate variable called BprimeMX in Pitzer's paper. Vector index is
1759 //! counterIJ
1760 mutable vector<double> m_BprimeMX_IJ;
1761
1762 //! Derivative of BprimeMX wrt T. Vector index is counterIJ
1763 mutable vector<double> m_BprimeMX_IJ_L;
1764
1765 //! Derivative of BprimeMX wrt TT. Vector index is counterIJ
1766 mutable vector<double> m_BprimeMX_IJ_LL;
1767
1768 //! Derivative of BprimeMX wrt P. Vector index is counterIJ
1769 mutable vector<double> m_BprimeMX_IJ_P;
1770
1771 //! Intermediate variable called BphiMX in Pitzer's paper. Vector index is
1772 //! counterIJ
1773 mutable vector<double> m_BphiMX_IJ;
1774
1775 //! Derivative of BphiMX_IJ wrt T. Vector index is counterIJ
1776 mutable vector<double> m_BphiMX_IJ_L;
1777
1778 //! Derivative of BphiMX_IJ wrt TT. Vector index is counterIJ
1779 mutable vector<double> m_BphiMX_IJ_LL;
1780
1781 //! Derivative of BphiMX_IJ wrt P. Vector index is counterIJ
1782 mutable vector<double> m_BphiMX_IJ_P;
1783
1784 //! Intermediate variable called Phi in Pitzer's paper. Vector index is
1785 //! counterIJ
1786 mutable vector<double> m_Phi_IJ;
1787
1788 //! Derivative of m_Phi_IJ wrt T. Vector index is counterIJ
1789 mutable vector<double> m_Phi_IJ_L;
1790
1791 //! Derivative of m_Phi_IJ wrt TT. Vector index is counterIJ
1792 mutable vector<double> m_Phi_IJ_LL;
1793
1794 //! Derivative of m_Phi_IJ wrt P. Vector index is counterIJ
1795 mutable vector<double> m_Phi_IJ_P;
1796
1797 //! Intermediate variable called Phiprime in Pitzer's paper. Vector index is
1798 //! counterIJ
1799 mutable vector<double> m_Phiprime_IJ;
1800
1801 //! Intermediate variable called PhiPhi in Pitzer's paper. Vector index is
1802 //! counterIJ
1803 mutable vector<double> m_PhiPhi_IJ;
1804
1805 //! Derivative of m_PhiPhi_IJ wrt T. Vector index is counterIJ
1806 mutable vector<double> m_PhiPhi_IJ_L;
1807
1808 //! Derivative of m_PhiPhi_IJ wrt TT. Vector index is counterIJ
1809 mutable vector<double> m_PhiPhi_IJ_LL;
1810
1811 //! Derivative of m_PhiPhi_IJ wrt P. Vector index is counterIJ
1812 mutable vector<double> m_PhiPhi_IJ_P;
1813
1814 //! Intermediate variable called CMX in Pitzer's paper. Vector index is
1815 //! counterIJ
1816 mutable vector<double> m_CMX_IJ;
1817
1818 //! Derivative of m_CMX_IJ wrt T. Vector index is counterIJ
1819 mutable vector<double> m_CMX_IJ_L;
1820
1821 //! Derivative of m_CMX_IJ wrt TT. Vector index is counterIJ
1822 mutable vector<double> m_CMX_IJ_LL;
1823
1824 //! Derivative of m_CMX_IJ wrt P. Vector index is counterIJ
1825 mutable vector<double> m_CMX_IJ_P;
1826
1827 //! Intermediate storage of the activity coefficient itself. Vector index is
1828 //! the species index
1829 mutable vector<double> m_gamma_tmp;
1830
1831 //! Logarithm of the molal activity coefficients. Normally these are all
1832 //! one. However, stability schemes will change that
1833 mutable vector<double> IMS_lnActCoeffMolal_;
1834
1835 //! value of the solute mole fraction that centers the cutoff polynomials
1836 //! for the cutoff =1 process;
1837 double IMS_X_o_cutoff_ = 0.2;
1838
1839 //! Parameter in the polyExp cutoff treatment having to do with rate of exp decay
1840 double IMS_cCut_ = 0.05;
1841
1842 //! Parameter in the polyExp cutoff treatment
1843 /*!
1844 * This is the slope of the g function at the zero solvent point
1845 * Default value is 0.0
1846 */
1847 double IMS_slopegCut_ = 0.0;
1848
1849 //! @name Parameters in the polyExp cutoff treatment having to do with rate of exp decay
1850 //! @{
1851 double IMS_dfCut_ = 0.0;
1852 double IMS_efCut_ = 0.0;
1853 double IMS_afCut_ = 0.0;
1854 double IMS_bfCut_ = 0.0;
1855 double IMS_dgCut_ = 0.0;
1856 double IMS_egCut_ = 0.0;
1857 double IMS_agCut_ = 0.0;
1858 double IMS_bgCut_ = 0.0;
1859 //! @}
1860
1861 //! value of the solvent mole fraction that centers the cutoff polynomials
1862 //! for the cutoff =1 process;
1863 double MC_X_o_cutoff_ = 0.0;
1864
1865 //! @name Parameters in the Molality Exp cutoff treatment
1866 //! @{
1867 double MC_dpCut_ = 0.0;
1868 double MC_epCut_ = 0.0;
1869 double MC_apCut_ = 0.0;
1870 double MC_bpCut_ = 0.0;
1871 double MC_cpCut_ = 0.0;
1872 double CROP_ln_gamma_o_min;
1873 double CROP_ln_gamma_o_max;
1874 double CROP_ln_gamma_k_min;
1875 double CROP_ln_gamma_k_max;
1876
1877 //! This is a boolean-type vector indicating whether
1878 //! a species's activity coefficient is in the cropped regime
1879 /*!
1880 * * 0 = Not in cropped regime
1881 * * 1 = In a transition regime where it is altered but there
1882 * still may be a temperature or pressure dependence
1883 * * 2 = In a cropped regime where there is no temperature
1884 * or pressure dependence
1885 */
1886 mutable vector<int> CROP_speciesCropped_;
1887 //! @}
1888
1889 //! Initialize all of the species-dependent lengths in the object
1890 void initLengths();
1891
1892 //! Apply the current phScale to a set of activity Coefficients or
1893 //! activities
1894 /*!
1895 * See the Eq3/6 Manual for a thorough discussion.
1896 *
1897 * @param acMolality input/Output vector containing the molality based
1898 * activity coefficients. length: m_kk.
1899 */
1900 void applyphScale(span<double> acMolality) const override;
1901
1902private:
1903 /**
1904 * This function will be called to update the internally stored
1905 * natural logarithm of the molality activity coefficients
1906 */
1907 void s_update_lnMolalityActCoeff() const;
1908
1909 //! This function calculates the temperature derivative of the
1910 //! natural logarithm of the molality activity coefficients.
1911 /*!
1912 * This function does all of the direct work. The solvent activity
1913 * coefficient is on the molality scale. It's derivative is too.
1914 */
1916
1917 /**
1918 * This function calculates the temperature second derivative of the natural
1919 * logarithm of the molality activity coefficients.
1920 */
1922
1923 /**
1924 * This function calculates the pressure derivative of the
1925 * natural logarithm of the molality activity coefficients.
1926 *
1927 * Assumes that the activity coefficients are current.
1928 */
1930
1931 //! This function will be called to update the internally stored
1932 //! natural logarithm of the molality activity coefficients
1933 /**
1934 * Normally they are all one. However, sometimes they are not,
1935 * due to stability schemes
1936 *
1937 * gamma_k_molar = gamma_k_molal / Xmol_solvent
1938 *
1939 * gamma_o_molar = gamma_o_molal
1940 */
1941 void s_updateIMS_lnMolalityActCoeff() const;
1942
1943private:
1944 //! Calculate the Pitzer portion of the activity coefficients.
1945 /**
1946 * This is the main routine in the whole module. It calculates the molality
1947 * based activity coefficients for the solutes, and the activity of water.
1948 */
1950
1951 //! Calculates the temperature derivative of the natural logarithm of the
1952 //! molality activity coefficients.
1953 /*!
1954 * Public function makes sure that all dependent data is
1955 * up to date, before calling a private function
1956 */
1958
1959 /**
1960 * This function calculates the temperature second derivative of the
1961 * natural logarithm of the molality activity coefficients.
1962 *
1963 * It is assumed that the Pitzer activity coefficient and first derivative
1964 * routine are called immediately preceding the call to this routine.
1965 */
1967
1968 //! Calculates the Pressure derivative of the natural logarithm of the
1969 //! molality activity coefficients.
1970 /*!
1971 * It is assumed that the Pitzer activity coefficient and first derivative
1972 * routine are called immediately preceding the calling of this routine.
1973 */
1975
1976 //! Calculates the Pitzer coefficients' dependence on the temperature.
1977 /*!
1978 * It will also calculate the temperature derivatives of the coefficients,
1979 * as they are important in the calculation of the latent heats and the heat
1980 * capacities of the mixtures.
1981 *
1982 * @param doDerivs If >= 1, then the routine will calculate the first
1983 * derivative. If >= 2, the routine will calculate the first
1984 * and second temperature derivative. default = 2
1985 */
1986 void s_updatePitzer_CoeffWRTemp(int doDerivs = 2) const;
1987
1988 //! Calculate the lambda interactions.
1989 /*!
1990 * Calculate E-lambda terms for charge combinations of like sign, using
1991 * method of Pitzer @cite pitzer1975. This implementation is based on Bethke,
1992 * Appendix 2.
1993 *
1994 * @param is Ionic strength
1995 */
1996 void calc_lambdas(double is) const;
1997 mutable double m_last_is = -1.0;
1998
1999 /**
2000 * Calculate etheta and etheta_prime
2001 *
2002 * This interaction accounts for the mixing effects of like-signed ions with
2003 * different charges. This interaction will be nonzero for species with the
2004 * same charge. this routine is not to be called for neutral species; it
2005 * core dumps or error exits.
2006 *
2007 * MEC implementation routine.
2008 *
2009 * @param z1 charge of the first molecule
2010 * @param z2 charge of the second molecule
2011 * @param[out] etheta return value of etheta
2012 * @param[out] etheta_prime return value of etheta_prime
2013 *
2014 * This routine uses the internal variables, elambda[] and elambda1[].
2015 */
2016 void calc_thetas(int z1, int z2, double& etheta, double& etheta_prime) const;
2017
2018 //! Set up a counter variable for keeping track of symmetric binary
2019 //! interactions amongst the solute species.
2020 /*!
2021 * The purpose of this is to squeeze the ij parameters into a
2022 * compressed single counter.
2023 *
2024 * n = m_kk*i + j
2025 * m_Counter[n] = counter
2026 */
2027 void counterIJ_setup() const;
2028
2029 //! Calculate the cropped molalities
2030 /*!
2031 * This is an internal routine that calculates values of m_molalitiesCropped
2032 * from m_molalities
2033 */
2034 void calcMolalitiesCropped() const;
2035
2036 //! Precalculate the IMS Cutoff parameters for typeCutoff = 2
2037 void calcIMSCutoffParams_();
2038
2039 //! Calculate molality cut-off parameters
2040 void calcMCCutoffParams_();
2041};
2042
2043}
2044
2045#endif
Header file for class Cantera::Array2D.
Header for intermediate ThermoPhase object for phases which employ molality based activity coefficien...
A class for 2D arrays stored in column-major (Fortran-compatible) form.
Definition Array.h:32
Class HMWSoln represents a dilute or concentrated liquid electrolyte phase which obeys the Pitzer for...
Definition HMWSoln.h:778
void calcIMSCutoffParams_()
Precalculate the IMS Cutoff parameters for typeCutoff = 2.
Definition HMWSoln.cpp:1422
vector< double > m_d2lnActCoeffMolaldT2_Unscaled
Derivative of the Logarithm of the activity coefficients on the molality scale wrt TT.
Definition HMWSoln.h:1692
Array2D m_Theta_ij_coeff
Array of coefficients for Theta_ij[i][j] in the Pitzer/HMW formulation.
Definition HMWSoln.h:1546
vector< double > m_Mu_nnn_L
Mu coefficient temperature derivative for the self-ternary neutral coefficient.
Definition HMWSoln.h:1639
vector< double > m_Beta1MX_ij
Array of 2D data used in the Pitzer/HMW formulation.
Definition HMWSoln.h:1431
unique_ptr< WaterProps > m_waterProps
Pointer to the water property calculator.
Definition HMWSoln.h:1399
Array2D m_Beta0MX_ij_coeff
Array of coefficients for Beta0, a variable in Pitzer's papers.
Definition HMWSoln.h:1424
double m_A_Debye
A_Debye: this expression appears on the top of the ln actCoeff term in the general Debye-Huckel expre...
Definition HMWSoln.h:1390
virtual double d2A_DebyedT2_TP(double temperature=-1.0, double pressure=-1.0) const
Value of the 2nd derivative of the Debye Huckel constant with respect to temperature as a function of...
Definition HMWSoln.cpp:1053
vector< double > m_h2func_IJ
hfunc2, was called gprime in Pitzer's paper.
Definition HMWSoln.h:1743
vector< double > m_Phi_IJ_LL
Derivative of m_Phi_IJ wrt TT. Vector index is counterIJ.
Definition HMWSoln.h:1792
vector< double > m_Beta0MX_ij
Array of 2D data used in the Pitzer/HMW formulation.
Definition HMWSoln.h:1408
double IMS_slopegCut_
Parameter in the polyExp cutoff treatment.
Definition HMWSoln.h:1847
Array2D m_Lambda_nj_P
Derivative of Lambda_nj[i][j] wrt P.
Definition HMWSoln.h:1606
void s_updateScaling_pHScaling_dT() const
Apply the current phScale to a set of derivatives of the activity Coefficients wrt temperature.
Definition HMWSoln.cpp:3986
vector< double > m_gfunc_IJ
Various temporary arrays used in the calculation of the Pitzer activity coefficients.
Definition HMWSoln.h:1732
double m_IionicMolality
Current value of the ionic strength on the molality scale Associated Salts, if present in the mechani...
Definition HMWSoln.h:1334
void getPartialMolarEnthalpies(span< double > hbar) const override
Returns an array of partial molar enthalpies for the species in the mixture.
Definition HMWSoln.cpp:208
void calcMCCutoffParams_()
Calculate molality cut-off parameters.
Definition HMWSoln.cpp:1475
Array2D m_Beta2MX_ij_coeff
Array of coefficients for Beta2, a variable in Pitzer's papers.
Definition HMWSoln.h:1473
void s_update_d2lnMolalityActCoeff_dT2() const
This function calculates the temperature second derivative of the natural logarithm of the molality a...
Definition HMWSoln.cpp:2779
vector< double > m_Beta2MX_ij_P
Derivative of Beta2_ij[i][j] wrt P. Vector index is counterIJ.
Definition HMWSoln.h:1463
vector< double > m_Beta0MX_ij_LL
Derivative of Beta0_ij[i][j] wrt TT. Vector index is counterIJ.
Definition HMWSoln.h:1414
int m_form_A_Debye
Form of the constant outside the Debye-Huckel term called A.
Definition HMWSoln.h:1358
vector< double > m_molalitiesCropped
Cropped and modified values of the molalities used in activity coefficient calculations.
Definition HMWSoln.h:1706
vector< double > m_lnActCoeffMolal_Scaled
Logarithm of the activity coefficients on the molality scale.
Definition HMWSoln.h:1669
vector< double > m_CphiMX_ij_P
Derivative of Cphi_ij[i][j] wrt P. Vector index is counterIJ.
Definition HMWSoln.h:1504
vector< double > m_PhiPhi_IJ_L
Derivative of m_PhiPhi_IJ wrt T. Vector index is counterIJ.
Definition HMWSoln.h:1806
vector< double > m_Theta_ij_LL
Derivative of Theta_ij[i][j] wrt TT. Vector index is counterIJ.
Definition HMWSoln.h:1531
vector< double > m_Theta_ij_L
Derivative of Theta_ij[i][j] wrt T. Vector index is counterIJ.
Definition HMWSoln.h:1528
void getPartialMolarCp(span< double > cpbar) const override
Return an array of partial molar heat capacities for the species in the mixture.
Definition HMWSoln.cpp:275
vector< double > m_CphiMX_ij_LL
Derivative of Cphi_ij[i][j] wrt TT. Vector index is counterIJ.
Definition HMWSoln.h:1501
vector< double > m_PhiPhi_IJ_LL
Derivative of m_PhiPhi_IJ wrt TT. Vector index is counterIJ.
Definition HMWSoln.h:1809
Array2D m_Lambda_nj_L
Derivative of Lambda_nj[i][j] wrt T. see m_Lambda_ij.
Definition HMWSoln.h:1600
double s_NBS_CLM_dlnMolalityActCoeff_dT() const
Calculate the temperature derivative of the Chlorine activity coefficient on the NBS scale.
Definition HMWSoln.cpp:4039
vector< double > m_Psi_ijk_L
Derivative of Psi_ijk[n] wrt T.
Definition HMWSoln.h:1563
void getParameters(AnyMap &phaseNode) const override
Store the parameters of a ThermoPhase object such that an identical one could be reconstructed using ...
Definition HMWSoln.cpp:701
string type() const override
String indicating the thermodynamic model implemented.
Definition HMWSoln.h:799
void initThermo() override
Initialize the ThermoPhase object after all species have been set up.
Definition HMWSoln.cpp:528
void s_updateScaling_pHScaling_dP() const
Apply the current phScale to a set of derivatives of the activity Coefficients wrt pressure.
Definition HMWSoln.cpp:4016
void printCoeffs() const
Print out all of the input Pitzer coefficients.
Definition HMWSoln.cpp:3912
vector< double > m_Psi_ijk
Array of 3D data used in the Pitzer/HMW formulation.
Definition HMWSoln.h:1559
vector< double > m_hfunc_IJ
hfunc, was called gprime in Pitzer's paper.
Definition HMWSoln.h:1739
void s_update_dlnMolalityActCoeff_dT() const
This function calculates the temperature derivative of the natural logarithm of the molality activity...
Definition HMWSoln.cpp:2260
void s_update_lnMolalityActCoeff() const
This function will be called to update the internally stored natural logarithm of the molality activi...
Definition HMWSoln.cpp:1194
void applyphScale(span< double > acMolality) const override
Apply the current phScale to a set of activity Coefficients or activities.
Definition HMWSoln.cpp:3956
vector< double > m_Beta1MX_ij_P
Derivative of Beta1_ij[i][j] wrt P. Vector index is counterIJ.
Definition HMWSoln.h:1440
vector< int > CROP_speciesCropped_
This is a boolean-type vector indicating whether a species's activity coefficient is in the cropped r...
Definition HMWSoln.h:1886
vector< double > m_Alpha2MX_ij
Array of 2D data used in the Pitzer/HMW formulation.
Definition HMWSoln.h:1488
double ADebye_V(double temperature=-1.0, double pressure=-1.0) const
Return Pitzer's definition of A_V.
Definition HMWSoln.cpp:1030
vector< double > m_BphiMX_IJ_L
Derivative of BphiMX_IJ wrt T. Vector index is counterIJ.
Definition HMWSoln.h:1776
vector< double > m_Phi_IJ_P
Derivative of m_Phi_IJ wrt P. Vector index is counterIJ.
Definition HMWSoln.h:1795
vector< double > m_BphiMX_IJ_P
Derivative of BphiMX_IJ wrt P. Vector index is counterIJ.
Definition HMWSoln.h:1782
void counterIJ_setup() const
Set up a counter variable for keeping track of symmetric binary interactions amongst the solute speci...
Definition HMWSoln.cpp:1399
vector< double > m_BMX_IJ
Intermediate variable called BMX in Pitzer's paper.
Definition HMWSoln.h:1747
vector< double > m_dlnActCoeffMolaldP_Unscaled
Derivative of the Logarithm of the activity coefficients on the molality scale wrt P.
Definition HMWSoln.h:1700
vector< double > m_CMX_IJ_LL
Derivative of m_CMX_IJ wrt TT. Vector index is counterIJ.
Definition HMWSoln.h:1822
vector< double > m_BMX_IJ_P
Derivative of BMX_IJ wrt P. Vector index is counterIJ.
Definition HMWSoln.h:1756
double cv_mole() const override
Molar heat capacity at constant volume and composition [J/kmol/K].
Definition HMWSoln.cpp:106
vector< double > m_Mu_nnn_P
Mu coefficient pressure derivative for the self-ternary neutral coefficient.
Definition HMWSoln.h:1659
Array2D m_Psi_ijk_coeff
Array of coefficients for Psi_ijk[n] in the Pitzer/HMW formulation.
Definition HMWSoln.h:1587
void getActivities(span< double > ac) const override
Get the array of non-dimensional activities at the current solution temperature, pressure,...
Definition HMWSoln.cpp:155
void setA_Debye(double A)
Set the A_Debye parameter.
Definition HMWSoln.cpp:491
vector< double > IMS_lnActCoeffMolal_
Logarithm of the molal activity coefficients.
Definition HMWSoln.h:1833
int m_formPitzerTemp
This is the form of the temperature dependence of Pitzer parameterization used in the model.
Definition HMWSoln.h:1329
vector< double > m_dlnActCoeffMolaldT_Unscaled
Derivative of the Logarithm of the activity coefficients on the molality scale wrt T.
Definition HMWSoln.h:1684
vector< double > m_BMX_IJ_L
Derivative of BMX_IJ wrt T. Vector index is counterIJ.
Definition HMWSoln.h:1750
virtual double relative_enthalpy() const
Excess molar enthalpy of the solution from the mixing process.
Definition HMWSoln.cpp:54
vector< double > m_Beta0MX_ij_L
Derivative of Beta0_ij[i][j] wrt T. Vector index is counterIJ.
Definition HMWSoln.h:1411
vector< double > m_Beta0MX_ij_P
Derivative of Beta0_ij[i][j] wrt P. Vector index is counterIJ.
Definition HMWSoln.h:1417
void s_updatePitzer_CoeffWRTemp(int doDerivs=2) const
Calculates the Pitzer coefficients' dependence on the temperature.
Definition HMWSoln.cpp:1511
double s_NBS_CLM_lnMolalityActCoeff() const
Calculate the Chlorine activity coefficient on the NBS scale.
Definition HMWSoln.cpp:4031
vector< double > m_Theta_ij
Array of 2D data for Theta_ij[i][j] in the Pitzer/HMW formulation.
Definition HMWSoln.h:1525
vector< double > m_Beta2MX_ij_L
Derivative of Beta2_ij[i][j] wrt T. Vector index is counterIJ.
Definition HMWSoln.h:1457
vector< double > m_Mu_nnn_LL
Mu coefficient 2nd temperature derivative for the self-ternary neutral coefficient.
Definition HMWSoln.h:1649
void s_updatePitzer_dlnMolalityActCoeff_dP() const
Calculates the Pressure derivative of the natural logarithm of the molality activity coefficients.
Definition HMWSoln.cpp:3314
vector< double > m_BphiMX_IJ
Intermediate variable called BphiMX in Pitzer's paper.
Definition HMWSoln.h:1773
Array2D m_Lambda_nj
Lambda coefficient for the ij interaction.
Definition HMWSoln.h:1597
vector< double > m_BprimeMX_IJ
Intermediate variable called BprimeMX in Pitzer's paper.
Definition HMWSoln.h:1760
vector< double > m_Theta_ij_P
Derivative of Theta_ij[i][j] wrt P. Vector index is counterIJ.
Definition HMWSoln.h:1534
vector< double > m_PhiPhi_IJ
Intermediate variable called PhiPhi in Pitzer's paper.
Definition HMWSoln.h:1803
vector< int > m_CounterIJ
a counter variable for keeping track of symmetric binary interactions amongst the solute species.
Definition HMWSoln.h:1717
Array2D m_Mu_nnn_coeff
Array of coefficients form_Mu_nnn term.
Definition HMWSoln.h:1662
virtual double relative_molal_enthalpy() const
Excess molar enthalpy of the solution from the mixing process on a molality basis.
Definition HMWSoln.cpp:66
double ADebye_L(double temperature=-1.0, double pressure=-1.0) const
Return Pitzer's definition of A_L.
Definition HMWSoln.cpp:1019
PDSS * m_waterSS
Water standard state calculator.
Definition HMWSoln.h:1396
void calcDensity() override
Calculate the density of the mixture using the partial molar volumes and mole fractions as input.
Definition HMWSoln.cpp:118
void calc_lambdas(double is) const
Calculate the lambda interactions.
Definition HMWSoln.cpp:3799
double elambda1[17]
This is elambda1, MEC.
Definition HMWSoln.h:1723
vector< double > m_Beta1MX_ij_LL
Derivative of Beta1_ij[i][j] wrt TT. Vector index is counterIJ.
Definition HMWSoln.h:1437
vector< double > m_lnActCoeffMolal_Unscaled
Logarithm of the activity coefficients on the molality scale.
Definition HMWSoln.h:1676
double s_NBS_CLM_dlnMolalityActCoeff_dP() const
Calculate the pressure derivative of the Chlorine activity coefficient.
Definition HMWSoln.cpp:4053
double m_maxIionicStrength
Maximum value of the ionic strength allowed in the calculation of the activity coefficients.
Definition HMWSoln.h:1338
vector< double > m_dlnActCoeffMolaldT_Scaled
Derivative of the Logarithm of the activity coefficients on the molality scale wrt T.
Definition HMWSoln.h:1680
vector< double > m_Beta2MX_ij
Array of 2D data used in the Pitzer/HMW formulation.
Definition HMWSoln.h:1454
void getUnscaledMolalityActivityCoefficients(span< double > acMolality) const override
Get the array of unscaled non-dimensional molality based activity coefficients at the current solutio...
Definition HMWSoln.cpp:172
vector< double > m_BprimeMX_IJ_LL
Derivative of BprimeMX wrt TT. Vector index is counterIJ.
Definition HMWSoln.h:1766
vector< double > m_Phiprime_IJ
Intermediate variable called Phiprime in Pitzer's paper.
Definition HMWSoln.h:1799
void s_updatePitzer_dlnMolalityActCoeff_dT() const
Calculates the temperature derivative of the natural logarithm of the molality activity coefficients.
Definition HMWSoln.cpp:2288
void s_updatePitzer_lnMolalityActCoeff() const
Calculate the Pitzer portion of the activity coefficients.
Definition HMWSoln.cpp:1757
vector< double > m_PhiPhi_IJ_P
Derivative of m_PhiPhi_IJ wrt P. Vector index is counterIJ.
Definition HMWSoln.h:1812
virtual double dA_DebyedT_TP(double temperature=-1.0, double pressure=-1.0) const
Value of the derivative of the Debye Huckel constant with respect to temperature as a function of tem...
Definition HMWSoln.cpp:963
vector< double > m_BprimeMX_IJ_L
Derivative of BprimeMX wrt T. Vector index is counterIJ.
Definition HMWSoln.h:1763
vector< double > m_Phi_IJ
Intermediate variable called Phi in Pitzer's paper.
Definition HMWSoln.h:1786
vector< double > m_BMX_IJ_LL
Derivative of BMX_IJ wrt TT. Vector index is counterIJ.
Definition HMWSoln.h:1753
vector< double > m_d2lnActCoeffMolaldT2_Scaled
Derivative of the Logarithm of the activity coefficients on the molality scale wrt TT.
Definition HMWSoln.h:1688
Array2D m_Lambda_nj_LL
Derivative of Lambda_nj[i][j] wrt TT.
Definition HMWSoln.h:1603
double IMS_X_o_cutoff_
value of the solute mole fraction that centers the cutoff polynomials for the cutoff =1 process;
Definition HMWSoln.h:1837
double IMS_cCut_
Parameter in the polyExp cutoff treatment having to do with rate of exp decay.
Definition HMWSoln.h:1840
void getPartialMolarVolumes(span< double > vbar) const override
Return an array of partial molar volumes for the species in the mixture.
Definition HMWSoln.cpp:262
vector< double > m_BphiMX_IJ_LL
Derivative of BphiMX_IJ wrt TT. Vector index is counterIJ.
Definition HMWSoln.h:1779
void s_updatePitzer_d2lnMolalityActCoeff_dT2() const
This function calculates the temperature second derivative of the natural logarithm of the molality a...
Definition HMWSoln.cpp:2807
vector< double > m_CMX_IJ_L
Derivative of m_CMX_IJ wrt T. Vector index is counterIJ.
Definition HMWSoln.h:1819
Array2D m_Lambda_nj_coeff
Array of coefficients for Lambda_nj[i][j] in the Pitzer/HMW formulation.
Definition HMWSoln.h:1621
vector< double > m_Psi_ijk_LL
Derivative of Psi_ijk[n] wrt TT.
Definition HMWSoln.h:1567
void initLengths()
Initialize all of the species-dependent lengths in the object.
Definition HMWSoln.cpp:1081
vector< double > m_g2func_IJ
This is the value of g2(x2) in Pitzer's papers. Vector index is counterIJ.
Definition HMWSoln.h:1735
void getPartialMolarEntropies(span< double > sbar) const override
Returns an array of partial molar entropies of the species in the solution.
Definition HMWSoln.cpp:227
double standardConcentration(size_t k=0) const override
Return the standard concentration for the kth species.
Definition HMWSoln.cpp:145
vector< double > m_CphiMX_ij
Array of 2D data used in the Pitzer/HMW formulation.
Definition HMWSoln.h:1495
vector< double > m_BprimeMX_IJ_P
Derivative of BprimeMX wrt P. Vector index is counterIJ.
Definition HMWSoln.h:1769
vector< double > m_CMX_IJ
Intermediate variable called CMX in Pitzer's paper.
Definition HMWSoln.h:1816
void s_update_dlnMolalityActCoeff_dP() const
This function calculates the pressure derivative of the natural logarithm of the molality activity co...
Definition HMWSoln.cpp:3290
double MC_X_o_cutoff_
value of the solvent mole fraction that centers the cutoff polynomials for the cutoff =1 process;
Definition HMWSoln.h:1863
double satPressure(double T) override
Get the saturation pressure for a given temperature.
Definition HMWSoln.cpp:295
double m_TempPitzerRef
Reference Temperature for the Pitzer formulations.
Definition HMWSoln.h:1341
void calc_thetas(int z1, int z2, double &etheta, double &etheta_prime) const
Calculate etheta and etheta_prime.
Definition HMWSoln.cpp:3843
void getChemPotentials(span< double > mu) const override
Get the species chemical potentials. Units: J/kmol.
Definition HMWSoln.cpp:188
vector< double > m_Beta2MX_ij_LL
Derivative of Beta2_ij[i][j] wrt TT. Vector index is counterIJ.
Definition HMWSoln.h:1460
double elambda[17]
This is elambda, MEC.
Definition HMWSoln.h:1720
void getActivityConcentrations(span< double > c) const override
This method returns an array of generalized activity concentrations.
Definition HMWSoln.cpp:132
vector< double > m_dlnActCoeffMolaldP_Scaled
Derivative of the Logarithm of the activity coefficients on the molality scale wrt P.
Definition HMWSoln.h:1696
vector< double > m_Mu_nnn
Mu coefficient for the self-ternary neutral coefficient.
Definition HMWSoln.h:1629
vector< double > m_Psi_ijk_P
Derivative of Psi_ijk[n] wrt P.
Definition HMWSoln.h:1571
void s_updateIMS_lnMolalityActCoeff() const
This function will be called to update the internally stored natural logarithm of the molality activi...
Definition HMWSoln.cpp:3869
void calcMolalitiesCropped() const
Calculate the cropped molalities.
Definition HMWSoln.cpp:1258
vector< double > m_CphiMX_ij_L
Derivative of Cphi_ij[i][j] wrt T. Vector index is counterIJ.
Definition HMWSoln.h:1498
double ADebye_J(double temperature=-1.0, double pressure=-1.0) const
Return Pitzer's definition of A_J.
Definition HMWSoln.cpp:1041
void s_updateScaling_pHScaling_dT2() const
Apply the current phScale to a set of 2nd derivatives of the activity Coefficients wrt temperature.
Definition HMWSoln.cpp:4001
Array2D m_Beta1MX_ij_coeff
Array of coefficients for Beta1, a variable in Pitzer's papers.
Definition HMWSoln.h:1447
vector< double > m_CMX_IJ_P
Derivative of m_CMX_IJ wrt P. Vector index is counterIJ.
Definition HMWSoln.h:1825
void s_updateScaling_pHScaling() const
Apply the current phScale to a set of activity Coefficients.
Definition HMWSoln.cpp:3971
vector< double > m_Beta1MX_ij_L
Derivative of Beta1_ij[i][j] wrt T. Vector index is counterIJ.
Definition HMWSoln.h:1434
Array2D m_CphiMX_ij_coeff
Array of coefficients for CphiMX, a parameter in the activity coefficient formulation.
Definition HMWSoln.h:1513
virtual double A_Debye_TP(double temperature=-1.0, double pressure=-1.0) const
Value of the Debye Huckel constant as a function of temperature and pressure.
Definition HMWSoln.cpp:931
virtual double dA_DebyedP_TP(double temperature=-1.0, double pressure=-1.0) const
Value of the derivative of the Debye Huckel constant with respect to pressure, as a function of tempe...
Definition HMWSoln.cpp:987
bool m_molalitiesAreCropped
Boolean indicating whether the molalities are cropped or are modified.
Definition HMWSoln.h:1709
vector< double > m_Phi_IJ_L
Derivative of m_Phi_IJ wrt T. Vector index is counterIJ.
Definition HMWSoln.h:1789
vector< double > m_gamma_tmp
Intermediate storage of the activity coefficient itself.
Definition HMWSoln.h:1829
double s_NBS_CLM_d2lnMolalityActCoeff_dT2() const
Calculate the second temperature derivative of the Chlorine activity coefficient on the NBS scale.
Definition HMWSoln.cpp:4046
MolalityVPSSTP is a derived class of ThermoPhase that handles variable pressure standard state method...
Virtual base class for a species with a pressure dependent standard state.
Definition PDSS.h:140
double temperature() const
Temperature (K).
Definition Phase.h:585
double pressure() const override
Returns the current pressure of the phase.
Namespace for the Cantera kernel.
Definition AnyMap.cpp:595