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