Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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  * Copyright (2006) Sandia Corporation. Under the terms of
13  * Contract DE-AC04-94AL85000 with Sandia Corporation, the
14  * U.S. Government retains certain rights in this software.
15  */
16 #ifndef CT_HMWSOLN_H
17 #define CT_HMWSOLN_H
18 
19 #include "MolalityVPSSTP.h"
20 #include "cantera/base/Array.h"
21 
22 namespace Cantera
23 {
24 
25 /**
26  * Major Parameters:
27  * The form of the Pitzer expression refers to the
28  * form of the Gibbs free energy expression. The temperature
29  * dependence of the Pitzer coefficients are handled by
30  * another parameter.
31  *
32  * m_formPitzer = Form of the Pitzer expression
33  *
34  * PITZERFORM_BASE = 0
35  *
36  * Only one form is supported atm. This parameter is included for
37  * future expansion.
38  */
39 #define PITZERFORM_BASE 0
40 
41 /*!
42  * @name Temperature Dependence of the Pitzer Coefficients
43  *
44  * Note, the temperature dependence of the
45  * Gibbs free energy also depends on the temperature dependence
46  * of the standard state and the temperature dependence of the
47  * Debye-Huckel constant, which includes the dielectric constant
48  * and the density. Therefore, this expression defines only part
49  * of the temperature dependence for the mixture thermodynamic
50  * functions.
51  *
52  * PITZER_TEMP_CONSTANT
53  * All coefficients are considered constant wrt temperature
54  * PITZER_TEMP_LINEAR
55  * All coefficients are assumed to have a linear dependence
56  * wrt to temperature.
57  * PITZER_TEMP_COMPLEX1
58  * All coefficients are assumed to have a complex functional
59  * based dependence wrt temperature; See:
60  * (Silvester, Pitzer, J. Phys. Chem. 81, 19 1822 (1977)).
61  *
62  * beta0 = q0 + q3(1/T - 1/Tr) + q4(ln(T/Tr)) +
63  * q1(T - Tr) + q2(T**2 - Tr**2)
64  */
65 //@{
66 #define PITZER_TEMP_CONSTANT 0
67 #define PITZER_TEMP_LINEAR 1
68 #define PITZER_TEMP_COMPLEX1 2
69 //@}
70 
71 /*
72  * @name ways to calculate the value of A_Debye
73  *
74  * These defines determine the way A_Debye is calculated
75  */
76 //@{
77 #define A_DEBYE_CONST 0
78 #define A_DEBYE_WATER 1
79 //@}
80 
81 class WaterProps;
82 
83 /**
84  * Class HMWSoln represents a dilute or concentrated liquid electrolyte
85  * phase which obeys the Pitzer formulation for nonideality.
86  *
87  * As a prerequisite to the specification of thermodynamic quantities,
88  * The concentrations of the ionic species are assumed to obey the
89  * electroneutrality condition.
90  *
91  * <HR>
92  * <H2> Specification of Species Standard State Properties </H2>
93  * <HR>
94  *
95  * The solvent is assumed to be liquid water. A real model for liquid
96  * water (IAPWS 1995 formulation) is used as its standard state.
97  * All standard state properties for the solvent are based on
98  * this real model for water, and involve function calls
99  * to the object that handles the real water model, #Cantera::WaterPropsIAPWS.
100  *
101  * The standard states for solutes are on the unit molality basis.
102  * Therefore, in the documentation below, the normal \f$ o \f$
103  * superscript is replaced with
104  * the \f$ \triangle \f$ symbol. The reference state symbol is now
105  * \f$ \triangle, ref \f$.
106  *
107  *
108  * It is assumed that the reference state thermodynamics may be
109  * obtained by a pointer to a populated species thermodynamic property
110  * manager class (see ThermoPhase::m_spthermo). How to relate pressure
111  * changes to the reference state thermodynamics is resolved at this level.
112  *
113  * For solutes that rely on ThermoPhase::m_spthermo, are assumed to
114  * have an incompressible standard state mechanical property.
115  * In other words, the molar volumes are independent of temperature
116  * and pressure.
117  *
118  * For these incompressible,
119  * standard states, the molar internal energy is
120  * independent of pressure. Since the thermodynamic properties
121  * are specified by giving the standard-state enthalpy, the
122  * term \f$ P_0 \hat v\f$ is subtracted from the specified molar
123  * enthalpy to compute the molar internal energy. The entropy is
124  * assumed to be independent of the pressure.
125  *
126  * The enthalpy function is given by the following relation.
127  *
128  * \f[
129  * h^\triangle_k(T,P) = h^{\triangle,ref}_k(T)
130  * + \tilde{v}_k \left( P - P_{ref} \right)
131  * \f]
132  *
133  * For an incompressible,
134  * stoichiometric substance, the molar internal energy is
135  * independent of pressure. Since the thermodynamic properties
136  * are specified by giving the standard-state enthalpy, the
137  * term \f$ P_{ref} \tilde v\f$ is subtracted from the specified reference molar
138  * enthalpy to compute the molar internal energy.
139  *
140  * \f[
141  * u^\triangle_k(T,P) = h^{\triangle,ref}_k(T) - P_{ref} \tilde{v}_k
142  * \f]
143  *
144  *
145  * The solute standard state heat capacity and entropy are independent
146  * of pressure. The solute standard state Gibbs free energy is obtained
147  * from the enthalpy and entropy functions.
148  *
149  * The vector Phase::m_speciesSize[] is used to hold the
150  * base values of species sizes. These are defined as the
151  * molar volumes of species at infinite dilution at 300 K and 1 atm
152  * of water. m_speciesSize are calculated during the initialization of the
153  * HMWSoln object and are then not touched.
154  *
155  * The current model assumes that an incompressible molar volume for
156  * all solutes. The molar volume for the water solvent, however,
157  * is obtained from a pure water equation of state, waterSS.
158  * Therefore, the water standard state varies with both T and P.
159  * It is an error to request standard state water properties at a T and P
160  * where the water phase is not a stable phase, i.e., beyond its
161  * spinodal curve.
162  *
163  * <HR>
164  * <H2> Specification of Solution Thermodynamic Properties </H2>
165  * <HR>
166  *
167  * Chemical potentials
168  * of the solutes, \f$ \mu_k \f$, and the solvent, \f$ \mu_o \f$, which are based
169  * on the molality form, have the following general format:
170  *
171  * \f[
172  * \mu_k = \mu^{\triangle}_k(T,P) + R T ln(\gamma_k^{\triangle} \frac{m_k}{m^\triangle})
173  * \f]
174  * \f[
175  * \mu_o = \mu^o_o(T,P) + RT ln(a_o)
176  * \f]
177  *
178  * where \f$ \gamma_k^{\triangle} \f$ is the molality based activity coefficient for species
179  * \f$k\f$.
180  *
181  * Individual activity coefficients of ions can not be independently measured. Instead,
182  * only binary pairs forming electroneutral solutions can be measured. This problem
183  * leads to a redundancy in the evaluation of species standard state properties.
184  * The redundancy issue is resolved by setting the standard state chemical potential
185  * enthalpy, entropy, and volume for the hydrogen ion, H+, to zero, for every temperature
186  * and pressure. After this convention is applied, all other standard state
187  * properties of ionic species contain meaningful information.
188  *
189  *
190  * <H3> Ionic Strength </H3>
191  *
192  * Most of the parameterizations within the model use the ionic strength
193  * as a key variable. The ionic strength, \f$ I\f$ is defined as follows
194  *
195  * \f[
196  * I = \frac{1}{2} \sum_k{m_k z_k^2}
197  * \f]
198  *
199  *
200  * \f$ m_k \f$ is the molality of the kth species. \f$ z_k \f$ is the charge
201  * of the kth species. Note, the ionic strength is a defined units quantity.
202  * The molality has defined units of gmol kg-1, and therefore the ionic
203  * strength has units of sqrt( gmol kg<SUP>-1</SUP>).
204  *
205  * In some instances, from some authors, a different
206  * formulation is used for the ionic strength in the equations below. The different
207  * formulation is due to the possibility of the existence of weak acids and how
208  * association wrt to the weak acid equilibrium relation affects the calculation
209  * of the activity coefficients via the assumed value of the ionic strength.
210  *
211  * If we are to assume that the association reaction doesn't have an effect
212  * on the ionic strength, then we will want to consider the associated weak
213  * acid as in effect being fully dissociated, when we calculate an effective
214  * value for the ionic strength. We will call this calculated value, the
215  * stoichiometric ionic strength, \f$ I_s \f$, putting a subscript s to denote
216  * it from the more straightforward calculation of \f$ I \f$.
217  *
218  * \f[
219  * I_s = \frac{1}{2} \sum_k{m_k^s z_k^2}
220  * \f]
221  *
222  * Here, \f$ m_k^s \f$ is the value of the molalities calculated assuming that
223  * all weak acid-base pairs are in their fully dissociated states. This calculation may
224  * be simplified by considering that the weakly associated acid may be made up of two
225  * charged species, k1 and k2, each with their own charges, obeying the following relationship:
226  *
227  * \f[
228  * z_k = z_{k1} + z_{k2}
229  * \f]
230  * Then, we may only need to specify one charge value, say, \f$ z_{k1}\f$,
231  * the cation charge number,
232  * in order to get both numbers, since we have already specified \f$ z_k \f$
233  * in the definition of original species.
234  * Then, the stoichiometric ionic strength may be calculated via the following formula.
235  *
236  * \f[
237  * I_s = \frac{1}{2} \left(\sum_{k,ions}{m_k z_k^2}+
238  * \sum_{k,weak_assoc}(m_k z_{k1}^2 + m_k z_{k2}^2) \right)
239  * \f]
240  *
241  * The specification of which species are weakly associated acids is made in the input
242  * file via the
243  * <TT> stoichIsMods </TT> XML block, where the charge for k1 is also specified.
244  * An example is given below:
245  *
246  * @code
247  * <stoichIsMods>
248  * NaCl(aq):-1.0
249  * </stoichIsMods>
250  * @endcode
251  *
252  *
253  * Because we need the concept of a weakly associated acid in order to calculated
254  * \f$ I_s \f$ we need to
255  * catalog all species in the phase. This is done using the following categories:
256  *
257  * - <B>cEST_solvent</B> : Solvent species (neutral)
258  * - <B>cEST_chargedSpecies</B> Charged species (charged)
259  * - <B>cEST_weakAcidAssociated</B> Species which can break apart into charged species.
260  * It may or may not be charged. These may or
261  * may not be be included in the
262  * species solution vector.
263  * - <B>cEST_strongAcidAssociated</B> Species which always breaks apart into charged species.
264  * It may or may not be charged. Normally, these
265  * aren't included in the speciation vector.
266  * - <B>cEST_polarNeutral </B> Polar neutral species
267  * - <B>cEST_nonpolarNeutral</B> Non polar neutral species
268  *
269  * Polar and non-polar neutral species are differentiated, because some additions
270  * to the activity
271  * coefficient expressions distinguish between these two types of solutes.
272  * This is the so-called salt-out effect.
273  *
274  * The type of species is specified in the <TT>electrolyteSpeciesType</TT> XML block.
275  * Note, this is not
276  * considered a part of the specification of the standard state for the species,
277  * at this time. Therefore,
278  * this information is put under the <TT>activityCoefficient</TT> XML block. An example
279  * is given below
280  *
281  * @code
282  * <electrolyteSpeciesType>
283  * H2L(L):solvent
284  * H+:chargedSpecies
285  * NaOH(aq):weakAcidAssociated
286  * NaCl(aq):strongAcidAssociated
287  * NH3(aq):polarNeutral
288  * O2(aq):nonpolarNeutral
289  * </electrolyteSpeciesType>
290  * @endcode
291  *
292  *
293  * Much of the species electrolyte type information is inferred from other information in the
294  * input file. For example, as species which is charged is given the "chargedSpecies" default
295  * category. A neutral solute species is put into the "nonpolarNeutral" category by default.
296  *
297  *
298  * <H3> Specification of the Excess Gibbs Free Energy </H3>
299  *
300  * Pitzer's formulation may best be represented as a specification of the excess Gibbs
301  * free energy, \f$ G^{ex} \f$, defined as the deviation of the total Gibbs free energy from
302  * that of an ideal molal solution.
303  * \f[
304  * G = G^{id} + G^{ex}
305  * \f]
306  *
307  * The ideal molal solution contribution, not equal to an ideal solution contribution
308  * and in fact containing a singularity at the zero solvent mole fraction limit, is
309  * given below.
310  * \f[
311  * G^{id} = n_o \mu^o_o + \sum_{k\ne o} n_k \mu_k^{\triangle}
312  * + \tilde{M}_o n_o ( RT (\sum{m_i(\ln(m_i)-1)}))
313  * \f]
314  *
315  * From the excess Gibbs free energy formulation, the activity coefficient expression
316  * and the osmotic coefficient expression for the solvent may be defined, by
317  * taking the appropriate derivatives. Using this approach guarantees that the
318  * entire system will obey the Gibbs-Duhem relations.
319  *
320  * Pitzer employs the following general expression for the excess Gibbs free energy
321  *
322  * \f[
323  * \begin{array}{cclc}
324  * \frac{G^{ex}}{\tilde{M}_o n_o RT} &= &
325  * \left( \frac{4A_{Debye}I}{3b} \right) \ln(1 + b \sqrt{I})
326  * + 2 \sum_c \sum_a m_c m_a B_{ca}
327  * + \sum_c \sum_a m_c m_a Z C_{ca}
328  * \\&&
329  * + \sum_{c < c'} \sum m_c m_{c'} \left[ 2 \Phi_{c{c'}} + \sum_a m_a \Psi_{c{c'}a} \right]
330  * + \sum_{a < a'} \sum m_a m_{a'} \left[ 2 \Phi_{a{a'}} + \sum_c m_c \Psi_{a{a'}c} \right]
331  * \\&&
332  * + 2 \sum_n \sum_c m_n m_c \lambda_{nc} + 2 \sum_n \sum_a m_n m_a \lambda_{na}
333  * + 2 \sum_{n < n'} \sum m_n m_{n'} \lambda_{n{n'}}
334  * + \sum_n m^2_n \lambda_{nn}
335  * \end{array}
336  * \f]
337  *
338  * <I>a</I> is a subscript over all anions, <I>c</I> is a subscript extending over all
339  * cations, and <I>i</I> is a subscript that extends over all anions and cations.
340  * <I>n</I> is a subscript that extends only over neutral solute molecules.
341  * The second line contains cross terms where cations affect
342  * cations and/or cation/anion pairs,
343  * and anions affect anions or cation/anion pairs. Note part of the coefficients,
344  * \f$ \Phi_{c{c'}} \f$ and \f$ \Phi_{a{a'}} \f$ stem from the theory
345  * of unsymmetrical mixing of electrolytes with different charges. This
346  * theory depends on the total ionic strength of the solution, and therefore,
347  * \f$ \Phi_{c{c'}} \f$ and \f$ \Phi_{a{a'}} \f$ will depend on <I>I</I>, the
348  * ionic strength. \f$ B_{ca}\f$ is a strong function of the
349  * total ionic strength, <I>I</I>,
350  * of the electrolyte. The rest of the coefficients are assumed to be independent of the
351  * molalities or ionic strengths. However, all coefficients are potentially functions
352  * of the temperature and pressure of the solution.
353  *
354  * <I>A</I> is the Debye-Huckel constant. Its specification is described in its own
355  * section below.
356  *
357  * \f$ I\f$ is the ionic strength of the solution, and is given by:
358  *
359  * \f[
360  * I = \frac{1}{2} \sum_k{m_k z_k^2}
361  * \f]
362  *
363  * In contrast to several other Debye-Huckel implementations (see \ref DebyeHuckel), the
364  * parameter \f$ b\f$ in the above equation is a constant that
365  * does not vary with respect to ion identity. This is an important simplification
366  * as it avoids troubles with satisfaction of the Gibbs-Duhem analysis.
367  *
368  * The function \f$ Z \f$ is given by
369  *
370  * \f[
371  * Z = \sum_i m_i \left| z_i \right|
372  * \f]
373  *
374  * The value of \f$ B_{ca}\f$ is given by the following function
375  *
376  * \f[
377  * B_{ca} = \beta^{(0)}_{ca} + \beta^{(1)}_{ca} g(\alpha^{(1)}_{ca} \sqrt{I})
378  * + \beta^{(2)}_{ca} g(\alpha^{(2)}_{ca} \sqrt{I})
379  * \f]
380  *
381  * where
382  *
383  * \f[
384  * g(x) = 2 \frac{(1 - (1 + x)\exp[-x])}{x^2}
385  * \f]
386  *
387  * The formulation for \f$ B_{ca}\f$ combined with the formulation of the
388  * Debye-Huckel term in the eqn. for the excess Gibbs free energy stems
389  * essentially from an empirical fit to the ionic strength dependent data
390  * based over a wide sampling of binary electrolyte systems. \f$ C_{ca} \f$,
391  * \f$ \lambda_{nc} \f$, \f$ \lambda_{na} \f$, \f$ \lambda_{nn} \f$,
392  * \f$ \Psi_{c{c'}a} \f$, \f$ \Psi_{a{a'}c} \f$ are experimentally derived
393  * coefficients that may have pressure and/or temperature dependencies.
394  *
395  * The \f$ \Phi_{c{c'}} \f$ and \f$ \Phi_{a{a'}} \f$ formulations are
396  * slightly more complicated. \f$ b \f$ is a universal
397  * constant defined to be equal to \f$ 1.2\ kg^{1/2}\ gmol^{-1/2} \f$. The exponential
398  * coefficient \f$ \alpha^{(1)}_{ca} \f$ is usually
399  * fixed at \f$ \alpha^{(1)}_{ca} = 2.0\ kg^{1/2} gmol^{-1/2}\f$
400  * except for 2-2 electrolytes, while other parameters were fit to experimental
401  * data. For 2-2 electrolytes, \f$ \alpha^{(1)}_{ca} = 1.4\ kg^{1/2}\ gmol^{-1/2}\f$
402  * is used in combination with either \f$ \alpha^{(2)}_{ca} = 12\ kg^{1/2}\ gmol^{-1/2}\f$
403  * or \f$ \alpha^{(2)}_{ca} = k A_\psi \f$, where <I>k</I> is a constant. For electrolytes other
404  * than 2-2 electrolytes the \f$ \beta^{(2)}_{ca} g(\alpha^{(2)}_{ca} \sqrt{I}) \f$ term
405  * is not used in the fitting procedure; it is only used for divalent metal
406  * solfates and other high-valence electrolytes which exhibit significant
407  * association at low ionic strengths.
408  *
409  * The \f$ \beta^{(0)}_{ca} \f$, \f$ \beta^{(1)}_{ca}\f$, \f$ \beta^{(2)}_{ca} \f$,
410  * and \f$ C_{ca} \f$ binary coefficients are referred to as ion-interaction or
411  * Pitzer parameters. These Pitzer parameters may vary with temperature and pressure
412  * but they do not depend on the ionic strength. Their values and temperature
413  * derivatives of their values have been tabulated for a range of electrolytes
414  *
415  * The \f$ \Phi_{c{c'}} \f$ and \f$ \Phi_{a{a'}} \f$ contributions, which
416  * capture cation-cation and anion-anion interactions, also have an
417  * ionic strength dependence.
418  *
419  * Ternary contributions \f$ \Psi_{c{c'}a} \f$ and \f$ \Psi_{a{a'}c} \f$
420  * have been measured also for some systems. The success of the Pitzer
421  * method lies in its ability to model nonlinear activity coefficients
422  * of complex multicomponent systems with just binary and minor
423  * ternary contributions, which can be independently measured in
424  * binary or ternary subsystems.
425  *
426  *
427  * <H3> Multicomponent Activity Coefficients for Solutes </H3>
428  *
429  * The formulas for activity coefficients of solutes may be obtained by taking the
430  * following derivative of the excess Gibbs Free Energy formulation described above:
431  *
432  * \f[
433  * \ln(\gamma_k^\triangle) = \frac{d\left( \frac{G^{ex}}{M_o n_o RT} \right)}{d(m_k)}\Bigg|_{n_i}
434  * \f]
435  *
436  * In the formulas below the following conventions are used. The subscript <I>M</I> refers
437  * to a particular cation. The subscript X refers to a particular anion, whose
438  * activity is being currently evaluated. the subscript <I>a</I> refers to a summation
439  * over all anions in the solution, while the subscript <I>c</I> refers to a summation
440  * over all cations in the solutions.
441  *
442  * The activity coefficient for a particular cation <I>M</I> is given by
443  *
444  * \f[
445  * \ln(\gamma_M^\triangle) = -z_M^2(F) + \sum_a m_a \left( 2 B_{Ma} + Z C_{Ma} \right)
446  * + z_M \left( \sum_a \sum_c m_a m_c C_{ca} \right)
447  * + \sum_c m_c \left[ 2 \Phi_{Mc} + \sum_a m_a \Psi_{Mca} \right]
448  * + \sum_{a < a'} \sum m_a m_{a'} \Psi_{Ma{a'}}
449  * + 2 \sum_n m_n \lambda_{nM}
450  * \f]
451  *
452  * The activity coefficient for a particular anion <I>X</I> is given by
453  *
454  * \f[
455  * \ln(\gamma_X^\triangle) = -z_X^2(F) + \sum_a m_c \left( 2 B_{cX} + Z C_{cX} \right)
456  * + \left|z_X \right| \left( \sum_a \sum_c m_a m_c C_{ca} \right)
457  * + \sum_a m_a \left[ 2 \Phi_{Xa} + \sum_c m_c \Psi_{cXa} \right]
458  * + \sum_{c < c'} \sum m_c m_{c'} \Psi_{c{c'}X}
459  * + 2 \sum_n m_n \lambda_{nM}
460  * \f]
461  * where the function \f$ F \f$ is given by
462  *
463  * \f[
464  * F = - A_{\phi} \left[ \frac{\sqrt{I}}{1 + b \sqrt{I}}
465  * + \frac{2}{b} \ln{\left(1 + b\sqrt{I}\right)} \right]
466  * + \sum_a \sum_c m_a m_c B'_{ca}
467  * + \sum_{c < c'} \sum m_c m_{c'} \Phi'_{c{c'}}
468  * + \sum_{a < a'} \sum m_a m_{a'} \Phi'_{a{a'}}
469  * \f]
470  *
471  * We have employed the definition of \f$ A_{\phi} \f$, also used by Pitzer
472  * which is equal to
473  *
474  * \f[
475  * A_{\phi} = \frac{A_{Debye}}{3}
476  * \f]
477  *
478  * In the above formulas, \f$ \Phi'_{c{c'}} \f$ and \f$ \Phi'_{a{a'}} \f$ are the
479  * ionic strength derivatives of \f$ \Phi_{c{c'}} \f$ and \f$ \Phi_{a{a'}} \f$,
480  * respectively.
481  *
482  * The function \f$ B'_{MX} \f$ is defined as:
483  *
484  * \f[
485  * B'_{MX} = \left( \frac{\beta^{(1)}_{MX} h(\alpha^{(1)}_{MX} \sqrt{I})}{I} \right)
486  * \left( \frac{\beta^{(2)}_{MX} h(\alpha^{(2)}_{MX} \sqrt{I})}{I} \right)
487  * \f]
488  *
489  * where \f$ h(x) \f$ is defined as
490  *
491  * \f[
492  * h(x) = g'(x) \frac{x}{2} =
493  * \frac{2\left(1 - \left(1 + x + \frac{x^2}{2} \right)\exp(-x) \right)}{x^2}
494  * \f]
495  *
496  * The activity coefficient for neutral species <I>N</I> is given by
497  *
498  * \f[
499  * \ln(\gamma_N^\triangle) = 2 \left( \sum_i m_i \lambda_{iN}\right)
500  * \f]
501  *
502  *
503  * <H3> Activity of the Water Solvent </H3>
504  *
505  * The activity for the solvent water,\f$ a_o \f$, is not independent and must be
506  * determined either from the Gibbs-Duhem relation or from taking the appropriate derivative
507  * of the same excess Gibbs free energy function as was used to formulate
508  * the solvent activity coefficients. Pitzer's description follows the later approach to
509  * derive a formula for the osmotic coefficient, \f$ \phi \f$.
510  *
511  * \f[
512  * \phi - 1 = - \left( \frac{d\left(\frac{G^{ex}}{RT} \right)}{d(\tilde{M}_o n_o)} \right)
513  * \frac{1}{\sum_{i \ne 0} m_i}
514  * \f]
515  *
516  * The osmotic coefficient may be related to the water activity by the following relation:
517  *
518  * \f[
519  * \phi = - \frac{1}{\tilde{M}_o \sum_{i \neq o} m_i} \ln(a_o)
520  * = - \frac{n_o}{\sum_{i \neq o}n_i} \ln(a_o)
521  * \f]
522  *
523  *
524  * The result is the following
525  *
526  * \f[
527  * \begin{array}{ccclc}
528  * \phi - 1 &= &
529  * \frac{2}{\sum_{i \ne 0} m_i}
530  * \bigg[ &
531  * - A_{\phi} \frac{I^{3/2}}{1 + b \sqrt{I}}
532  * + \sum_c \sum_a m_c m_a \left( B^{\phi}_{ca} + Z C_{ca}\right)
533  * \\&&&
534  * + \sum_{c < c'} \sum m_c m_{c'} \left[ \Phi^{\phi}_{c{c'}} + \sum_a m_a \Psi_{c{c'}a} \right]
535  * + \sum_{a < a'} \sum m_a m_{a'} \left[ \Phi^{\phi}_{a{a'}} + \sum_c m_c \Psi_{a{a'}c} \right]
536  * \\&&&
537  * + \sum_n \sum_c m_n m_c \lambda_{nc} + \sum_n \sum_a m_n m_a \lambda_{na}
538  * + \sum_{n < n'} \sum m_n m_{n'} \lambda_{n{n'}}
539  * + \frac{1}{2} \left( \sum_n m^2_n \lambda_{nn}\right)
540  * \bigg]
541  * \end{array}
542  * \f]
543  *
544  * It can be shown that the expression
545  *
546  * \f[
547  * B^{\phi}_{ca} = \beta^{(0)}_{ca} + \beta^{(1)}_{ca} \exp{(- \alpha^{(1)}_{ca} \sqrt{I})}
548  * + \beta^{(2)}_{ca} \exp{(- \alpha^{(2)}_{ca} \sqrt{I} )}
549  * \f]
550  *
551  * is consistent with the expression \f$ B_{ca} \f$ in the \f$ G^{ex} \f$ expression
552  * after carrying out the derivative wrt \f$ m_M \f$.
553  *
554  * Also taking into account that \f$ {\Phi}_{c{c'}} \f$ and
555  * \f$ {\Phi}_{a{a'}} \f$ has an ionic strength dependence.
556  *
557  * \f[
558  * \Phi^{\phi}_{c{c'}} = {\Phi}_{c{c'}} + I \frac{d{\Phi}_{c{c'}}}{dI}
559  * \f]
560  *
561  * \f[
562  * \Phi^{\phi}_{a{a'}} = \Phi_{a{a'}} + I \frac{d\Phi_{a{a'}}}{dI}
563  * \f]
564  *
565  *
566  * <H3> Temperature and Pressure Dependence of the Pitzer Parameters </H3>
567  *
568  * In general most of the coefficients introduced in the previous section may
569  * have a temperature and pressure dependence. The temperature and pressure
570  * dependence of these coefficients strongly influence the value of the
571  * excess Enthalpy and excess Volumes of Pitzer solutions. Therefore, these
572  * are readily measurable quantities.
573  * HMWSoln provides several
574  * different methods for putting these dependencies into the coefficients.
575  * HMWSoln has an implementation described by Silverter and Pitzer (1977),
576  * which was used to fit experimental data for NaCl over an extensive range,
577  * below the critical temperature of water.
578  * They found a temperature functional form for fitting the 3 following
579  * coefficients that describe the Pitzer parameterization for a single salt
580  * to be adequate to describe how the excess Gibbs free energy values for
581  * the binary salt changes with respect to temperature.
582  * The following functional form
583  * was used to fit the temperature dependence of the Pitzer Coefficients
584  * for each cation - anion pair, M X.
585  *
586  * \f[
587  * \beta^{(0)}_{MX} = q^{b0}_0
588  * + q^{b0}_1 \left( T - T_r \right)
589  * + q^{b0}_2 \left( T^2 - T_r^2 \right)
590  * + q^{b0}_3 \left( \frac{1}{T} - \frac{1}{T_r}\right)
591  * + q^{b0}_4 \ln \left( \frac{T}{T_r} \right)
592  * \f]
593  * \f[
594  * \beta^{(1)}_{MX} = q^{b1}_0 + q^{b1}_1 \left( T - T_r \right)
595  * + q^{b1}_{2} \left( T^2 - T_r^2 \right)
596  * \f]
597  * \f[
598  * C^{\phi}_{MX} = q^{Cphi}_0
599  * + q^{Cphi}_1 \left( T - T_r \right)
600  * + q^{Cphi}_2 \left( T^2 - T_r^2 \right)
601  * + q^{Cphi}_3 \left( \frac{1}{T} - \frac{1}{T_r}\right)
602  * + q^{Cphi}_4 \ln \left( \frac{T}{T_r} \right)
603  * \f]
604  *
605  * where
606  *
607  * \f[
608  * C^{\phi}_{MX} = 2 {\left| z_M z_X \right|}^{1/2} C_{MX}
609  * \f]
610  *
611  * In later papers, Pitzer has added additional temperature dependencies
612  * to all of the other remaining second and third order virial coefficients.
613  * Some of these dependencies are justified and motivated by theory.
614  * Therefore,
615  * a formalism wherein all of the coefficients in the base theory have
616  * temperature dependencies associated with them has been implemented
617  * within the HMWSoln object. Much of the formalism, however,
618  * has been unexercised.
619  *
620  * In the HMWSoln object, the temperature dependence of the Pitzer
621  * parameters are specified in the following way.
622  *
623  * - PIZTER_TEMP_CONSTANT - string name "CONSTANT"
624  * - Assumes that all coefficients are independent of temperature
625  * and pressure
626  * - PIZTER_TEMP_COMPLEX1 - string name "COMPLEX" or "COMPLEX1"
627  * - Uses the full temperature dependence for the
628  * \f$\beta^{(0)}_{MX} \f$ (5 coeffs),
629  * the \f$\beta^{(1)}_{MX} \f$ (3 coeffs),
630  * and \f$ C^{\phi}_{MX} \f$ (5 coeffs) parameters described above.
631  * - PITZER_TEMP_LINEAR - string name "LINEAR"
632  * - Uses just the temperature dependence for the
633  * \f$\beta^{(0)}_{MX} \f$, the \f$\beta^{(1)}_{MX} \f$,
634  * and \f$ C^{\phi}_{MX} \f$ coefficients described above.
635  * There are 2 coefficients for each term.
636  *
637  * The temperature dependence is specified in an attributes field
638  * in the <TT> activityCoefficients </TT> XML block,
639  * called <TT> TempModel </TT>. Permissible values for that
640  * attribute are <TT> CONSTANT, COMPLEX1</TT>, and <TT> LINEAR.</TT>
641  *
642  * The specification of the binary interaction between a cation and
643  * an anion is given by the coefficients, \f$ B_{MX}\f$ and
644  * \f$ C_{MX}\f$
645  * The specification of \f$ B_{MX}\f$ is a function of
646  * \f$\beta^{(0)}_{MX} \f$, \f$\beta^{(1)}_{MX} \f$,
647  * \f$\beta^{(2)}_{MX} \f$, \f$\alpha^{(1)}_{MX} \f$, and
648  * \f$\alpha^{(2)}_{MX} \f$.
649  * \f$ C_{MX}\f$ is calculated from \f$C^{\phi}_{MX} \f$
650  * from the formula above.
651  * All of the underlying coefficients are specified in the
652  * XML element block <TT> binarySaltParameters </TT>, which
653  * has the attribute <TT> cation </TT> and <TT> anion </TT>
654  * to identify the interaction. XML elements named
655  * <TT> beta0, beta1, beta2, Cphi, Alpha1, Alpha2 </TT>
656  * within each <TT> binarySaltParameters </TT> block
657  * specify the parameters. Within each of these blocks
658  * multiple parameters describing temperature or pressure
659  * dependence are serially listed in the order that they
660  * appear in the equation in this document. An example of
661  * the <TT> beta0 </TT> block that fits the <TT> COMPLEX1 </TT> temperature
662  * dependence given above is
663  *
664  * @code
665  <binarySaltParameters cation="Na+" anion="OH-">
666  <beta0> q0, q1, q2, q3, q4 </beta0>
667  </binarySaltParameters>
668  @endcode
669  *
670  * The parameters for \f$ \beta^{(0)}\f$ fit the following equation:
671  *
672  * \f[
673  * \beta^{(0)} = q_0^{{\beta}0} + q_1^{{\beta}0} \left( T - T_r \right)
674  * + q_2^{{\beta}0} \left( T^2 - T_r^2 \right)
675  * + q_3^{{\beta}0} \left( \frac{1}{T} - \frac{1}{T_r} \right)
676  * + q_4^{{\beta}0} \ln \left( \frac{T}{T_r} \right)
677  * \f]
678  *
679  * This same <TT> COMPLEX1 </TT> temperature
680  * dependence given above is used for the following parameters:
681  * \f$ \beta^{(0)}_{MX} \f$, \f$ \beta^{(1)}_{MX} \f$,
682  * \f$ \beta^{(2)}_{MX} \f$, \f$ \Theta_{cc'} \f$, \f$\Theta_{aa'} \f$,
683  * \f$ \Psi_{c{c'}a} \f$ and \f$ \Psi_{ca{a'}} \f$.
684  *
685  *
686  * <H3> Like-Charged Binary Ion Parameters and the Mixing Parameters </H3>
687  *
688  * The previous section contained the functions, \f$ \Phi_{c{c'}} \f$,
689  * \f$ \Phi_{a{a'}} \f$ and their derivatives wrt the
690  * ionic strength, \f$ \Phi'_{c{c'}} \f$ and \f$ \Phi'_{a{a'}} \f$.
691  * Part of these terms come from theory.
692  *
693  * Since like charged ions repel each other and are generally
694  * not near each other, the virial coefficients for same-charged ions
695  * are small. However, Pitzer doesn't ignore these in his
696  * formulation. Relatively larger and longer range terms between
697  * like-charged ions exist however, which appear only for
698  * unsymmetrical mixing of same-sign charged ions with different
699  * charges. \f$ \Phi_{ij} \f$, where \f$ ij \f$ is either \f$ a{a'} \f$
700  * or \f$ c{c'} \f$ is given by
701  *
702  * \f[
703  * {\Phi}_{ij} = \Theta_{ij} + \,^E \Theta_{ij}(I)
704  * \f]
705  *
706  * \f$ \Theta_{ij} \f$ is the small virial coefficient expansion term.
707  * Dependent in general on temperature and pressure, its ionic
708  * strength dependence is ignored in Pitzer's approach.
709  * \f$ \,^E\Theta_{ij}(I) \f$ accounts for the electrostatic
710  * unsymmetrical mixing effects and is dependent only on the
711  * charges of the ions i, j, the total ionic strength and on
712  * the dielectric constant and density of the solvent.
713  * This seems to be a relatively well-documented part of the theory.
714  * They theory below comes from Pitzer summation (Pitzer) in the
715  * appendix. It's also mentioned in Bethke's book (Bethke), and
716  * the equations are summarized in Harvie & Weare (1980).
717  * Within the code, \f$ \,^E\Theta_{ij}(I) \f$ is evaluated according
718  * to the algorithm described in Appendix B [Pitzer] as
719  *
720  * \f[
721  * \,^E\Theta_{ij}(I) = \left( \frac{z_i z_j}{4I} \right)
722  * \left( J(x_{ij}) - \frac{1}{2} J(x_{ii})
723  * - \frac{1}{2} J(x_{jj}) \right)
724  * \f]
725  *
726  * where \f$ x_{ij} = 6 z_i z_j A_{\phi} \sqrt{I} \f$ and
727  *
728  * \f[
729  * J(x) = \frac{1}{x} \int_0^{\infty}{\left( 1 + q +
730  * \frac{1}{2} q^2 - e^q \right) y^2 dy}
731  * \f]
732  *
733  * and \f$ q = - (\frac{x}{y}) e^{-y} \f$. \f$ J(x) \f$ is evaluated by
734  * numerical integration.
735  *
736  * The \f$ \Theta_{ij} \f$ term is a constant that is specified
737  * by the XML element <TT> thetaCation </TT> and
738  * <TT> thetaAnion </TT>, which
739  * has the attribute <TT> cation1 </TT>, <TT> cation2 </TT> and
740  * <TT> anion1 </TT>, <TT> anion2 </TT> respectively
741  * to identify the interaction. No temperature or
742  * pressure dependence of this parameter is currently allowed.
743  * An example of the block is presented below.
744  *
745  * @code
746  <thetaCation cation1="Na+" cation2="H+">
747  <Theta> 0.036 </Theta>
748  </thetaCation>
749  @endcode
750  *
751  *
752  * <H3> Ternary Pitzer Parameters </H3>
753  *
754  * The \f$ \Psi_{c{c'}a} \f$ and \f$ \Psi_{ca{a'}} \f$ terms
755  * represent ternary interactions between two cations and
756  * an anion and two anions and a cation, respectively.
757  * In Pitzer's implementation these terms are usually small
758  * in absolute size. Currently these parameters do not have
759  * any dependence on temperature, pressure, or ionic strength.
760  *
761  * Their values are input using the XML element
762  * <TT> psiCommonCation </TT> and <TT> psiCommonAnion </TT>.
763  * The species id's are specified in attribute fields in
764  * the XML element. The fields <TT>cation</TT>,
765  * <TT> anion1</TT>, and <TT> anion2</TT>
766  * are used for <TT>psiCommonCation</TT>. The fields <TT> anion</TT>,
767  * <TT>cation1</TT> and <TT>cation2</TT> are used for
768  * <TT> psiCommonAnion</TT>. An example block is given below.
769  * The <TT> Theta </TT> field below is a duplicate of the
770  * <TT> thetaAnion </TT> field mentioned above. The two fields
771  * are input into the same block for convenience, and because
772  * their data are highly correlated, in practice.
773  * It is an error for the
774  * two blocks to specify different information about
775  * thetaAnion (or thetaCation) in different blocks. It's
776  * ok to specify duplicate but consistent information
777  * in multiple blocks.
778  *
779  * @code
780  <psiCommonCation cation="Na+" anion1="Cl-" anion2="OH-">
781  <Theta> -0.05 </Theta>
782  <Psi> -0.006 </Psi>
783  </psiCommonCation>
784  @endcode
785  *
786  * <H3> Treatment of Neutral Species </H3>
787  *
788  * Binary virial-coefficient-like interactions between two neutral
789  * species may be specified in the \f$ \lambda_{mn} \f$ terms
790  * that appear in the formulas above.
791  * Currently these interactions are independent of temperature,
792  * pressure, and ionic strength. Also, currently, the neutrality
793  * of the species are not checked. Therefore, this interaction
794  * may involve charged species in the solution as well.
795  * The identity of the species is specified by the
796  * <TT>species1</TT> and <TT>species2</TT> attributes to the XML
797  * <TT>lambdaNeutral</TT> node. These terms are symmetrical;
798  * <TT>species1</TT> and <TT>species2</TT> may be reversed and
799  * the term will be the same. An example is given below.
800  *
801  * @code
802  <lambdaNeutral species1="CO2" species2="CH4">
803  <lambda> 0.05 </lambda>
804  </lambdaNeutral>
805  @endcode
806  *
807  * <H3> Example of the Specification of Parameters for the Activity
808  * Coefficients </H3>
809  *
810  * An example is given below.
811  *
812  * An example <TT> activityCoefficients </TT> XML block for this
813  * formulation is supplied below
814  *
815  * @verbatim
816  <activityCoefficients model="Pitzer" TempModel="complex1">
817  <!-- Pitzer Coefficients
818  These coefficients are from Pitzer's main
819  paper, in his book.
820  -->
821  <A_Debye model="water" />
822  <ionicRadius default="3.042843" units="Angstroms">
823  </ionicRadius>
824  <binarySaltParameters cation="Na+" anion="Cl-">
825  <beta0> 0.0765, 0.008946, -3.3158E-6,
826  -777.03, -4.4706
827  </beta0>
828  <beta1> 0.2664, 6.1608E-5, 1.0715E-6, 0.0, 0.0 </beta1>
829  <beta2> 0.0, 0.0, 0.0, 0.0, 0.0 </beta2>
830  <Cphi> 0.00127, -4.655E-5, 0.0,
831  33.317, 0.09421
832  </Cphi>
833  <Alpha1> 2.0 </Alpha1>
834  </binarySaltParameters>
835 
836  <binarySaltParameters cation="H+" anion="Cl-">
837  <beta0> 0.1775, 0.0, 0.0, 0.0, 0.0 </beta0>
838  <beta1> 0.2945, 0.0, 0.0, 0.0, 0.0 </beta1>
839  <beta2> 0.0, 0.0, 0.0, 0.0, 0.0 </beta2>
840  <Cphi> 0.0008, 0.0, 0.0, 0.0, 0.0 </Cphi>
841  <Alpha1> 2.0 </Alpha1>
842  </binarySaltParameters>
843 
844  <binarySaltParameters cation="Na+" anion="OH-">
845  <beta0> 0.0864, 0.0, 0.0, 0.0, 0.0 </beta0>
846  <beta1> 0.253, 0.0, 0.0 0.0, 0.0 </beta1>
847  <beta2> 0.0 0.0, 0.0, 0.0, 0.0 </beta2>
848  <Cphi> 0.0044, 0.0, 0.0, 0.0, 0.0 </Cphi>
849  <Alpha1> 2.0 </Alpha1>
850  </binarySaltParameters>
851 
852  <thetaAnion anion1="Cl-" anion2="OH-">
853  <Theta> -0.05, 0.0, 0.0, 0.0, 0.0 </Theta>
854  </thetaAnion>
855 
856  <psiCommonCation cation="Na+" anion1="Cl-" anion2="OH-">
857  <Theta> -0.05, 0.0, 0.0, 0.0, 0.0 </Theta>
858  <Psi> -0.006 </Psi>
859  </psiCommonCation>
860 
861  <thetaCation cation1="Na+" cation2="H+">
862  <Theta> 0.036, 0.0, 0.0, 0.0, 0.0 </Theta>
863  </thetaCation>
864 
865  <psiCommonAnion anion="Cl-" cation1="Na+" cation2="H+">
866  <Theta> 0.036, 0.0, 0.0, 0.0, 0.0 </Theta>
867  <Psi> -0.004 </Psi>
868  </psiCommonAnion>
869 
870  </activityCoefficients>
871  @endverbatim
872  *
873  *
874  * <H3> Specification of the Debye-Huckel Constant </H3>
875  *
876  * In the equations above, the formula for \f$ A_{Debye} \f$
877  * is needed. The HMWSoln object uses two methods for specifying these quantities.
878  * The default method is to assume that \f$ A_{Debye} \f$ is a constant, given
879  * in the initialization process, and stored in the
880  * member double, m_A_Debye. Optionally, a full water treatment may be employed that makes
881  * \f$ A_{Debye} \f$ a full function of <I>T</I> and <I>P</I> and creates nontrivial entries for
882  * the excess heat capacity, enthalpy, and excess volumes of solution.
883  *
884  * \f[
885  * A_{Debye} = \frac{F e B_{Debye}}{8 \pi \epsilon R T} {\left( C_o \tilde{M}_o \right)}^{1/2}
886  * \f]
887  * where
888  *
889  * \f[
890  * B_{Debye} = \frac{F} {{(\frac{\epsilon R T}{2})}^{1/2}}
891  * \f]
892  * Therefore:
893  * \f[
894  * A_{Debye} = \frac{1}{8 \pi}
895  * {\left(\frac{2 N_a \rho_o}{1000}\right)}^{1/2}
896  * {\left(\frac{N_a e^2}{\epsilon R T }\right)}^{3/2}
897  * \f]
898  *
899  * Units = sqrt(kg/gmol)
900  *
901  * where
902  * - \f$ N_a \f$ is Avogadro's number
903  * - \f$ \rho_w \f$ is the density of water
904  * - \f$ e \f$ is the electronic charge
905  * - \f$ \epsilon = K \epsilon_o \f$ is the permittivity of water
906  * - \f$ K \f$ is the dielectric constant of water,
907  * - \f$ \epsilon_o \f$ is the permittivity of free space.
908  * - \f$ \rho_o \f$ is the density of the solvent in its standard state.
909  *
910  * Nominal value at 298 K and 1 atm = 1.172576 (kg/gmol)<SUP>1/2</SUP>
911  * based on:
912  * - \f$ \epsilon / \epsilon_0 \f$ = 78.54 (water at 25C)
913  * - T = 298.15 K
914  * - B_Debye = 3.28640E9 (kg/gmol)<SUP>1/2</SUP> m<SUP>-1</SUP>
915  *
916  * An example of a fixed value implementation is given below.
917  * @code
918  * <activityCoefficients model="Pitzer">
919  * <!-- A_Debye units = sqrt(kg/gmol) -->
920  * <A_Debye> 1.172576 </A_Debye>
921  * <!-- object description continues -->
922  * </activityCoefficients>
923  * @endcode
924  *
925  * An example of a variable value implementation within the HMWSoln object is given below.
926  * The model attribute, "water", triggers the full implementation.
927  *
928  * @code
929  * <activityCoefficients model="Pitzer">
930  * <!-- A_Debye units = sqrt(kg/gmol) -->
931  * <A_Debye model="water" />
932  * <!-- object description continues -->
933  * </activityCoefficients>
934  * @endcode
935  *
936  *
937  * <H3> Temperature and Pressure Dependence of the Activity Coefficients </H3>
938  *
939  * Temperature dependence of the activity coefficients leads to nonzero terms
940  * for the excess enthalpy and entropy of solution. This means that the
941  * partial molar enthalpies, entropies, and heat capacities are all
942  * non-trivial to compute. The following formulas are used.
943  *
944  * The partial molar enthalpy, \f$ \bar s_k(T,P) \f$:
945  *
946  * \f[
947  * \bar h_k(T,P) = h^{\triangle}_k(T,P)
948  * - R T^2 \frac{d \ln(\gamma_k^\triangle)}{dT}
949  * \f]
950  * The solvent partial molar enthalpy is equal to
951  * \f[
952  * \bar h_o(T,P) = h^{o}_o(T,P) - R T^2 \frac{d \ln(a_o)}{dT}
953  * = h^{o}_o(T,P)
954  * + R T^2 (\sum_{k \neq o} m_k) \tilde{M_o} (\frac{d \phi}{dT})
955  * \f]
956  *
957  * The partial molar entropy, \f$ \bar s_k(T,P) \f$:
958  *
959  * \f[
960  * \bar s_k(T,P) = s^{\triangle}_k(T,P)
961  * - R \ln( \gamma^{\triangle}_k \frac{m_k}{m^{\triangle}}))
962  * - R T \frac{d \ln(\gamma^{\triangle}_k) }{dT}
963  * \f]
964  * \f[
965  * \bar s_o(T,P) = s^o_o(T,P) - R \ln(a_o)
966  * - R T \frac{d \ln(a_o)}{dT}
967  * \f]
968  *
969  * The partial molar heat capacity, \f$ C_{p,k}(T,P)\f$:
970  *
971  * \f[
972  * \bar C_{p,k}(T,P) = C^{\triangle}_{p,k}(T,P)
973  * - 2 R T \frac{d \ln( \gamma^{\triangle}_k)}{dT}
974  * - R T^2 \frac{d^2 \ln(\gamma^{\triangle}_k) }{{dT}^2}
975  * \f]
976  * \f[
977  * \bar C_{p,o}(T,P) = C^o_{p,o}(T,P)
978  * - 2 R T \frac{d \ln(a_o)}{dT}
979  * - R T^2 \frac{d^2 \ln(a_o)}{{dT}^2}
980  * \f]
981  *
982  * The pressure dependence of the activity coefficients leads to non-zero terms
983  * for the excess Volume of the solution.
984  * Therefore, the partial molar volumes are functions
985  * of the pressure derivatives of the activity coefficients.
986  * \f[
987  * \bar V_k(T,P) = V^{\triangle}_k(T,P)
988  * + R T \frac{d \ln(\gamma^{\triangle}_k) }{dP}
989  * \f]
990  * \f[
991  * \bar V_o(T,P) = V^o_o(T,P)
992  * + R T \frac{d \ln(a_o)}{dP}
993  * \f]
994  *
995  * The majority of work for these functions take place in the internal
996  * routines that calculate the first and second derivatives of the log
997  * of the activity coefficients wrt temperature,
998  * s_update_dlnMolalityActCoeff_dT(), s_update_d2lnMolalityActCoeff_dT2(),
999  * and the first
1000  * derivative of the log activity coefficients wrt pressure,
1001  * s_update_dlnMolalityActCoeff_dP().
1002  *
1003  * <HR>
1004  * <H2> %Application within Kinetics Managers </H2>
1005  * <HR>
1006  *
1007  * For the time being, we have set the standard concentration for all solute
1008  * species in
1009  * this phase equal to the default concentration of the solvent at the system temperature
1010  * and pressure multiplied by Mnaught (kg solvent / gmol solvent). The solvent
1011  * standard concentration is just equal to its standard state concentration.
1012  *
1013  *
1014  * This means that the
1015  * kinetics operator essentially works on an generalized concentration basis (kmol / m3),
1016  * with units for the kinetic rate constant specified
1017  * as if all reactants (solvent or solute) are on a concentration basis (kmol /m3).
1018  * The concentration will be modified by the activity coefficients.
1019  *
1020  * For example, a bulk-phase binary reaction between liquid solute species
1021  * <I>j</I> and <I>k</I>, producing
1022  * a new liquid solute species <I>l</I> would have the
1023  * following equation for its rate of progress variable, \f$ R^1 \f$, which has
1024  * units of kmol m-3 s-1.
1025  *
1026  * \f[
1027  * 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)
1028  * \f]
1029  *
1030  * where
1031  *
1032  * \f[
1033  * 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
1034  * \f]
1035  *
1036  * \f$ C_j^a \f$ is the activity concentration of species <I>j</I>, and
1037  * \f$ C_k^a \f$ is the activity concentration of species <I>k</I>. \f$ C^o_o \f$
1038  * is the concentration of water at 298 K and 1 atm. \f$ \tilde{M}_o \f$
1039  * has units of kg solvent per gmol solvent and is equal to
1040  *
1041  * \f[
1042  * \tilde{M}_o = \frac{M_o}{1000}
1043  * \f]
1044  *
1045  * \f$ a_j \f$ is
1046  * the activity of species <I>j</I> at the current temperature and pressure
1047  * and concentration of the liquid phase is given by the molality based
1048  * activity coefficient multiplied by the molality of the jth species.
1049  *
1050  * \f[
1051  * a_j = \gamma_j^\triangle m_j = \gamma_j^\triangle \frac{n_j}{\tilde{M}_o n_o}
1052  * \f]
1053  *
1054  * \f$k^1 \f$ has units of m<SUP>3</SUP> kmol<SUP>-1</SUP> s<SUP>-1</SUP>.
1055  *
1056  * Therefore the generalized activity concentration of a solute species has the following form
1057  *
1058  * \f[
1059  * C_j^a = C^o_o \frac{\gamma_j^\triangle n_j}{n_o}
1060  * \f]
1061  *
1062  * The generalized activity concentration of the solvent has the same units, but it's a simpler form
1063  *
1064  * \f[
1065  * C_o^a = C^o_o a_o
1066  * \f]
1067  *
1068  * The reverse rate constant can then be obtained from the law of microscopic reversibility
1069  * and the equilibrium expression for the system.
1070  *
1071  * \f[
1072  * \frac{a_j a_k}{ a_l} = K^{o,1} = \exp(\frac{\mu^o_l - \mu^o_j - \mu^o_k}{R T} )
1073  * \f]
1074  *
1075  * \f$ K^{o,1} \f$ is the dimensionless form of the equilibrium constant.
1076  *
1077  * \f[
1078  * R^{-1} = k^{-1} C_l^a = k^{-1} (C_o \tilde{M}_o a_l)
1079  * \f]
1080  *
1081  * where
1082  *
1083  * \f[
1084  * k^{-1} = k^1 K^{o,1} C_o \tilde{M}_o
1085  * \f]
1086  *
1087  * \f$ k^{-1} \f$ has units of s<SUP>-1</SUP>.
1088  *
1089  * Note, this treatment may be modified in the future, as events dictate.
1090  *
1091  * <HR>
1092  * <H2> Instantiation of the Class </H2>
1093  * <HR>
1094  *
1095  * The constructor for this phase is now located in the default ThermoFactory
1096  * for %Cantera. The following code snippet may be used to initialize the phase
1097  * using the default construction technique within %Cantera.
1098  *
1099  * @code
1100  * ThermoPhase *HMW = newPhase("HMW_NaCl.xml", "NaCl_electrolyte");
1101  * @endcode
1102  *
1103  *
1104  * A new HMWSoln object may be created by the following code snippets:
1105  *
1106  * @code
1107  * HMWSoln *HMW = new HMWSoln("HMW_NaCl.xml", "NaCl_electrolyte");
1108  * @endcode
1109  *
1110  * or
1111  *
1112  * @code
1113  * XML_Node *xm = get_XML_NameID("phase", "HMW_NaCl.xml#NaCl_electrolyte", 0);
1114  * HMWSoln *dh = new HMWSoln(*xm);
1115  * @endcode
1116  *
1117  * or by the following call to importPhase():
1118  *
1119  * @code
1120  * XML_Node *xm = get_XML_NameID("phase", "HMW_NaCl.xml#NaCl_electrolyte", 0);
1121  * HMWSoln dhphase;
1122  * importPhase(*xm, &dhphase);
1123  * @endcode
1124  *
1125  *
1126  * <HR>
1127  * <H2> XML Example </H2>
1128  * <HR>
1129  *
1130  * The phase model name for this is called StoichSubstance. It must be supplied
1131  * as the model attribute of the thermo XML element entry.
1132  * Within the phase XML block,
1133  * the density of the phase must be specified. An example of an XML file
1134  * this phase is given below.
1135  *
1136  * @verbatim
1137  <phase id="NaCl_electrolyte" dim="3">
1138  <speciesArray datasrc="#species_waterSolution">
1139  H2O(L) Na+ Cl- H+ OH-
1140  </speciesArray>
1141  <state>
1142  <temperature units="K"> 300 </temperature>
1143  <pressure units="Pa">101325.0</pressure>
1144  <soluteMolalities>
1145  Na+:3.0
1146  Cl-:3.0
1147  H+:1.0499E-8
1148  OH-:1.3765E-6
1149  </soluteMolalities>
1150  </state>
1151  <!-- thermo model identifies the inherited class
1152  from ThermoPhase that will handle the thermodynamics.
1153  -->
1154  <thermo model="HMW">
1155  <standardConc model="solvent_volume" />
1156  <activityCoefficients model="Pitzer" TempModel="complex1">
1157  <!-- Pitzer Coefficients
1158  These coefficients are from Pitzer's main
1159  paper, in his book.
1160  -->
1161  <A_Debye model="water" />
1162  <ionicRadius default="3.042843" units="Angstroms">
1163  </ionicRadius>
1164  <binarySaltParameters cation="Na+" anion="Cl-">
1165  <beta0> 0.0765, 0.008946, -3.3158E-6,
1166  -777.03, -4.4706
1167  </beta0>
1168  <beta1> 0.2664, 6.1608E-5, 1.0715E-6 </beta1>
1169  <beta2> 0.0 </beta2>
1170  <Cphi> 0.00127, -4.655E-5, 0.0,
1171  33.317, 0.09421
1172  </Cphi>
1173  <Alpha1> 2.0 </Alpha1>
1174  </binarySaltParameters>
1175 
1176  <binarySaltParameters cation="H+" anion="Cl-">
1177  <beta0> 0.1775, 0.0, 0.0, 0.0, 0.0</beta0>
1178  <beta1> 0.2945, 0.0, 0.0 </beta1>
1179  <beta2> 0.0 </beta2>
1180  <Cphi> 0.0008, 0.0, 0.0, 0.0, 0.0 </Cphi>
1181  <Alpha1> 2.0 </Alpha1>
1182  </binarySaltParameters>
1183 
1184  <binarySaltParameters cation="Na+" anion="OH-">
1185  <beta0> 0.0864, 0.0, 0.0, 0.0, 0.0 </beta0>
1186  <beta1> 0.253, 0.0, 0.0 </beta1>
1187  <beta2> 0.0 </beta2>
1188  <Cphi> 0.0044, 0.0, 0.0, 0.0, 0.0 </Cphi>
1189  <Alpha1> 2.0 </Alpha1>
1190  </binarySaltParameters>
1191 
1192  <thetaAnion anion1="Cl-" anion2="OH-">
1193  <Theta> -0.05 </Theta>
1194  </thetaAnion>
1195 
1196  <psiCommonCation cation="Na+" anion1="Cl-" anion2="OH-">
1197  <Theta> -0.05 </Theta>
1198  <Psi> -0.006 </Psi>
1199  </psiCommonCation>
1200 
1201  <thetaCation cation1="Na+" cation2="H+">
1202  <Theta> 0.036 </Theta>
1203  </thetaCation>
1204 
1205  <psiCommonAnion anion="Cl-" cation1="Na+" cation2="H+">
1206  <Theta> 0.036 </Theta>
1207  <Psi> -0.004 </Psi>
1208  </psiCommonAnion>
1209 
1210  </activityCoefficients>
1211 
1212  <solvent> H2O(L) </solvent>
1213  </thermo>
1214  <elementArray datasrc="elements.xml"> O H Na Cl </elementArray>
1215  <kinetics model="none" >
1216  </kinetics>
1217 </phase>
1218 @endverbatim
1219  *
1220  *
1221  *
1222  * @ingroup thermoprops
1223  *
1224  */
1225 class HMWSoln : public MolalityVPSSTP
1226 {
1227 
1228 public:
1229 
1230  //! Default Constructor
1231  HMWSoln();
1232 
1233  //! Construct and initialize an HMWSoln ThermoPhase object
1234  //! directly from an ASCII input file
1235  /*!
1236  * This constructor is a shell that calls the routine initThermo(), with
1237  * a reference to the XML database to get the info for the phase.
1238  *
1239  * @param inputFile Name of the input file containing the phase XML data
1240  * to set up the object
1241  * @param id ID of the phase in the input file. Defaults to the
1242  * empty string.
1243  */
1244  HMWSoln(const std::string& inputFile, const std::string& id = "");
1245 
1246  //! Construct and initialize an HMWSoln ThermoPhase object
1247  //! directly from an XML database
1248  /*!
1249  * @param phaseRef XML phase node containing the description of the phase
1250  * @param id id attribute containing the name of the phase.
1251  * (default is the empty string)
1252  */
1253  HMWSoln(XML_Node& phaseRef, const std::string& id = "");
1254 
1255  //! Copy Constructor
1256  /*!
1257  * Copy constructor for the object. Constructed
1258  * object will be a clone of this object, but will
1259  * also own all of its data.
1260  * This is a wrapper around the assignment operator
1261  *
1262  * @param right Object to be copied.
1263  */
1264  HMWSoln(const HMWSoln& right);
1265 
1266  //! Assignment operator
1267  /*!
1268  * Assignment operator for the object. Constructed
1269  * object will be a clone of this object, but will
1270  * also own all of its data.
1271  *
1272  * @param right Object to be copied.
1273  */
1274  HMWSoln& operator=(const HMWSoln& right);
1275 
1276  //! Destructor.
1277  virtual ~HMWSoln();
1278 
1279  //! Duplicator from the ThermoPhase parent class
1280  /*!
1281  * Given a pointer to a ThermoPhase object, this function will
1282  * duplicate the ThermoPhase object and all underlying structures.
1283  * This is basically a wrapper around the copy constructor.
1284  *
1285  * @return returns a pointer to a ThermoPhase
1286  */
1288 
1289  //! Import, construct, and initialize a HMWSoln phase
1290  //! specification from an XML tree into the current object.
1291  /*
1292  * This routine is a precursor to constructPhaseXML(XML_Node*)
1293  * routine, which does most of the work.
1294  *
1295  * @param inputfile XML file containing the description of the phase
1296  *
1297  * @param id Optional parameter identifying the name of the
1298  * phase. If none is given, the first XML
1299  * phase element will be used.
1300  */
1301  void constructPhaseFile(std::string inputFile, std::string id);
1302 
1303  //! Import and initialize a HMWSoln phase specification in an XML tree
1304  //! into the current object.
1305  /*!
1306  * Here we read an XML description of the phase. We import descriptions of
1307  * the elements that make up the species in a phase. We import information
1308  * about the species, including their reference state thermodynamic
1309  * polynomials. We then freeze the state of the species.
1310  *
1311  * Then, we read the species molar volumes from the XML tree to finish the
1312  * initialization.
1313  *
1314  * @param phaseNode This object must be the phase node of a complete XML tree
1315  * description of the phase, including all of the
1316  * species data. In other words while "phase" must
1317  * point to an XML phase object, it must have
1318  * sibling nodes "speciesData" that describe
1319  * the species in the phase.
1320  *
1321  * @param id ID of the phase. If nonnull, a check is done
1322  * to see if phaseNode is pointing to the phase
1323  * with the correct id.
1324  */
1325  void constructPhaseXML(XML_Node& phaseNode, std::string id);
1326 
1327  //! @name Utilities
1328  //! @{
1329 
1330  virtual int eosType() const;
1331 
1332  //! @}
1333  //! @name Molar Thermodynamic Properties of the Solution
1334  //! @{
1335 
1336  /// Molar enthalpy. Units: J/kmol.
1337  /**
1338  * Molar enthalpy of the solution. Units: J/kmol.
1339  * (HKM -> Bump up to Parent object)
1340  */
1341  virtual doublereal enthalpy_mole() const;
1342 
1343  /**
1344  * Excess molar enthalpy of the solution from
1345  * the mixing process. Units: J/ kmol.
1346  *
1347  * Note this is kmol of the total solution.
1348  */
1349  virtual doublereal relative_enthalpy() const;
1350 
1351  /**
1352  * Excess molar enthalpy of the solution from
1353  * the mixing process on a molality basis.
1354  * Units: J/ (kmol add salt).
1355  *
1356  * Note this is kmol of the guessed at salt composition
1357  */
1358  virtual doublereal relative_molal_enthalpy() const;
1359 
1360  /// Molar entropy. Units: J/kmol/K.
1361  /**
1362  * Molar entropy of the solution. Units: J/kmol/K.
1363  * For an ideal, constant partial molar volume solution mixture with
1364  * pure species phases which exhibit zero volume expansivity:
1365  * \f[
1366  * \hat s(T, P, X_k) = \sum_k X_k \hat s^0_k(T)
1367  * - \hat R \sum_k X_k log(X_k)
1368  * \f]
1369  * The reference-state pure-species entropies
1370  * \f$ \hat s^0_k(T,p_{ref}) \f$ are computed by the
1371  * species thermodynamic
1372  * property manager. The pure species entropies are independent of
1373  * temperature since the volume expansivities are equal to zero.
1374  * @see SpeciesThermo
1375  *
1376  * (HKM -> Bump up to Parent object)
1377  */
1378  virtual doublereal entropy_mole() const;
1379 
1380  /// Molar Gibbs function. Units: J/kmol.
1381  /*
1382  * (HKM -> Bump up to Parent object)
1383  */
1384  virtual doublereal gibbs_mole() const;
1385 
1386  /// Molar heat capacity at constant pressure. Units: J/kmol/K.
1387  virtual doublereal cp_mole() const;
1388 
1389  /// Molar heat capacity at constant volume. Units: J/kmol/K.
1390  /*
1391  * (HKM -> Bump up to Parent object)
1392  */
1393  virtual doublereal cv_mole() const;
1394 
1395  //!@}
1396  //! @name Mechanical Equation of State Properties
1397  /*!
1398  * In this equation of state implementation, the density is a function
1399  * only of the mole fractions. Therefore, it can't be an independent
1400  * variable. Instead, the pressure is used as the independent variable.
1401  * Functions which try to set the thermodynamic state by calling
1402  * setDensity() may cause an exception to be thrown.
1403  */
1404  //!@{
1405 
1406  /**
1407  * Pressure. Units: Pa.
1408  * For this incompressible system, we return the internally stored
1409  * independent value of the pressure.
1410  */
1411  virtual doublereal pressure() const;
1412 
1413  //! Set the internally stored pressure (Pa) at constant
1414  //! temperature and composition
1415  /*!
1416  * This method sets the pressure within the object.
1417  * The water model is a completely compressible model.
1418  * Also, the dielectric constant is pressure dependent.
1419  *
1420  * @param p input Pressure (Pa)
1421  *
1422  * @todo Implement a variable pressure capability
1423  */
1424  virtual void setPressure(doublereal p);
1425 
1426 protected:
1427  /**
1428  * Calculate the density of the mixture using the partial
1429  * molar volumes and mole fractions as input
1430  *
1431  * The formula for this is
1432  *
1433  * \f[
1434  * \rho = \frac{\sum_k{X_k W_k}}{\sum_k{X_k V_k}}
1435  * \f]
1436  *
1437  * where \f$X_k\f$ are the mole fractions, \f$W_k\f$ are
1438  * the molecular weights, and \f$V_k\f$ are the pure species
1439  * molar volumes.
1440  *
1441  * Note, the basis behind this formula is that in an ideal
1442  * solution the partial molar volumes are equal to the pure
1443  * species molar volumes. We have additionally specified
1444  * in this class that the pure species molar volumes are
1445  * independent of temperature and pressure.
1446  *
1447  * NOTE: This is a non-virtual function, which is not a
1448  * member of the ThermoPhase base class.
1449  */
1450  void calcDensity();
1451 
1452 public:
1453  //! Returns the current value of the density
1454  /*!
1455  * @return value of the density. Units: kg/m^3
1456  */
1457  virtual doublereal density() const;
1458 
1459  //! Set the internally stored density (kg/m^3) of the phase.
1460  /*!
1461  * Overwritten setDensity() function is necessary because the
1462  * density is not an independent variable.
1463  *
1464  * This function will now throw an error condition.
1465  *
1466  * Note, in general, setting the phase density is now a nonlinear
1467  * calculation. P and T are the fundamental variables. This
1468  * routine should be revamped to do the nonlinear problem.
1469  *
1470  * @todo May have to adjust the strategy here to make
1471  * the eos for these materials slightly compressible, in order
1472  * to create a condition where the density is a function of
1473  * the pressure.
1474  * @todo Now have a compressible ss equation for liquid water.
1475  * Therefore, this phase is compressible. May still
1476  * want to change the independent variable however.
1477  *
1478  * @param rho Input density (kg/m^3).
1479  */
1480  void setDensity(const doublereal rho);
1481 
1482  //! Set the internally stored molar density (kmol/m^3) for the phase.
1483  /**
1484  * Overwritten setMolarDensity() function is necessary because of the
1485  * underlying water model.
1486  *
1487  * This function will now throw an error condition if the input
1488  * isn't exactly equal to the current molar density.
1489  *
1490  * @param conc Input molar density (kmol/m^3).
1491  */
1492  void setMolarDensity(const doublereal conc);
1493 
1494  //! Set the temperature (K)
1495  /*!
1496  * This function sets the temperature, and makes sure that
1497  * the value propagates to underlying objects, such as
1498  * the water standard state model.
1499  *
1500  * @todo Make Phase::setTemperature a virtual function
1501  *
1502  * @param temp Temperature in kelvin
1503  */
1504  virtual void setTemperature(const doublereal temp);
1505 
1506  //! Set the temperature (K) and pressure (Pa)
1507  /*!
1508  * Set the temperature and pressure.
1509  *
1510  * @param t Temperature (K)
1511  * @param p Pressure (Pa)
1512  */
1513  virtual void setState_TP(doublereal t, doublereal p);
1514 
1515  /**
1516  * @}
1517  * @name Potential Energy
1518  *
1519  * Species may have an additional potential energy due to the
1520  * presence of external gravitation or electric fields. These
1521  * methods allow specifying a potential energy for individual
1522  * species.
1523  * @{
1524  */
1525 
1526  /**
1527  * @}
1528  * @name Activities, Standard States, and Activity Concentrations
1529  *
1530  * The activity \f$a_k\f$ of a species in solution is
1531  * related to the chemical potential by \f[ \mu_k = \mu_k^0(T)
1532  * + \hat R T \log a_k. \f] The quantity \f$\mu_k^0(T,P)\f$ is
1533  * the chemical potential at unit activity, which depends only
1534  * on temperature and the pressure.
1535  * Activity is assumed to be molality-based here.
1536  * @{
1537  */
1538 
1539  //! This method returns an array of generalized activity concentrations
1540  /*!
1541  * The generalized activity concentrations, \f$ C_k^a\f$, are defined such that
1542  * \f$ a_k = C^a_k / C^0_k, \f$ where \f$ C^0_k \f$
1543  * is a standard concentration
1544  * defined below. These generalized concentrations are used
1545  * by kinetics manager classes to compute the forward and
1546  * reverse rates of elementary reactions.
1547  *
1548  * The generalized activity concentration of a solute species has the following form
1549  *
1550  * \f[
1551  * C_j^a = C^o_o \frac{\gamma_j^\triangle n_j}{n_o}
1552  * \f]
1553  *
1554  * The generalized activity concentration of the solvent has the same units, but it's a simpler form
1555  *
1556  * \f[
1557  * C_o^a = C^o_o a_o
1558  * \f]
1559  *
1560  * @param c Array of generalized concentrations. The
1561  * units are kmol m-3 for both the solvent and the solute species
1562  */
1563  virtual void getActivityConcentrations(doublereal* c) const;
1564 
1565  //! Return the standard concentration for the kth species
1566  /*!
1567  * The standard concentration \f$ C^0_k \f$ used to normalize
1568  * the activity (i.e., generalized) concentration for use
1569  *
1570  * We have set the standard concentration for all solute species in
1571  * this phase equal to the default concentration of the solvent at the system temperature
1572  * and pressure multiplied by Mnaught (kg solvent / gmol solvent). The solvent
1573  * standard concentration is just equal to its standard state concentration.
1574  *
1575  * \f[
1576  * C_j^0 = C^o_o \tilde{M}_o \quad and C_o^0 = C^o_o
1577  * \f]
1578  *
1579  * The consequence of this is that the standard concentrations have unequal units
1580  * between the solvent and the solute. However, both the solvent and the solute
1581  * activity concentrations will have the same units of kmol kg<SUP>-3</SUP>.
1582  *
1583  * This means that the
1584  * kinetics operator essentially works on an generalized concentration basis (kmol / m3),
1585  * with units for the kinetic rate constant specified
1586  * as if all reactants (solvent or solute) are on a concentration basis (kmol /m3).
1587  * The concentration will be modified by the activity coefficients.
1588  *
1589  * For example, a bulk-phase binary reaction between liquid solute species
1590  * <I>j</I> and <I>k</I>, producing
1591  * a new liquid solute species <I>l</I> would have the
1592  * following equation for its rate of progress variable, \f$ R^1 \f$, which has
1593  * units of kmol m-3 s-1.
1594  *
1595  * \f[
1596  * 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)
1597  * \f]
1598  *
1599  * where
1600  *
1601  * \f[
1602  * 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
1603  * \f]
1604  *
1605  * \f$ C_j^a \f$ is the activity concentration of species <I>j</I>, and
1606  * \f$ C_k^a \f$ is the activity concentration of species <I>k</I>. \f$ C^o_o \f$
1607  * is the concentration of water at 298 K and 1 atm. \f$ \tilde{M}_o \f$
1608  * has units of kg solvent per gmol solvent and is equal to
1609  *
1610  * \f[
1611  * \tilde{M}_o = \frac{M_o}{1000}
1612  * \f]
1613  *
1614  * \f$ a_j \f$ is
1615  * the activity of species <I>j</I> at the current temperature and pressure
1616  * and concentration of the liquid phase is given by the molality based
1617  * activity coefficient multiplied by the molality of the jth species.
1618  *
1619  * \f[
1620  * a_j = \gamma_j^\triangle m_j = \gamma_j^\triangle \frac{n_j}{\tilde{M}_o n_o}
1621  * \f]
1622  *
1623  * \f$k^1 \f$ has units of m<SUP>3</SUP> kmol<SUP>-1</SUP> s<SUP>-1</SUP>.
1624  *
1625  * Therefore the generalized activity concentration of a solute species has the following form
1626  *
1627  * \f[
1628  * C_j^a = C^o_o \frac{\gamma_j^\triangle n_j}{n_o}
1629  * \f]
1630  *
1631  * The generalized activity concentration of the solvent has the same units, but it's a simpler form
1632  *
1633  * \f[
1634  * C_o^a = C^o_o a_o
1635  * \f]
1636  *
1637  * @param k Optional parameter indicating the species. The default
1638  * is to assume this refers to species 0.
1639  * @return
1640  * Returns the standard Concentration in units of
1641  * m<SUP>3</SUP> kmol<SUP>-1</SUP>.
1642  *
1643  * @param k Species index
1644  */
1645  virtual doublereal standardConcentration(size_t k=0) const;
1646 
1647  //! Returns the units of the standard and generalized concentrations.
1648  /*!
1649  * Note they have the same units, as their
1650  * ratio is defined to be equal to the activity of the kth
1651  * species in the solution, which is unitless.
1652  *
1653  * This routine is used in print out applications where the
1654  * units are needed. Usually, MKS units are assumed throughout
1655  * the program and in the XML input files.
1656  *
1657  * The base ThermoPhase class assigns the default quantities
1658  * of (kmol/m3) for all species.
1659  * Inherited classes are responsible for overriding the default
1660  * values if necessary.
1661  *
1662  * @param uA Output vector containing the units
1663  * uA[0] = kmol units - default = 1
1664  * uA[1] = m units - default = -nDim(), the number of spatial
1665  * dimensions in the Phase class.
1666  * uA[2] = kg units - default = 0;
1667  * uA[3] = Pa(pressure) units - default = 0;
1668  * uA[4] = Temperature units - default = 0;
1669  * uA[5] = time units - default = 0
1670  * @param k species index. Defaults to 0.
1671  * @param sizeUA output int containing the size of the vector.
1672  * Currently, this is equal to 6.
1673  * @deprecated To be removed after Cantera 2.2.
1674  */
1675  virtual void getUnitsStandardConc(double* uA, int k = 0,
1676  int sizeUA = 6) const;
1677 
1678  //! Get the array of non-dimensional activities at
1679  //! the current solution temperature, pressure, and solution concentration.
1680  /*!
1681  *
1682  * We resolve this function at this level by calling
1683  * on the activityConcentration function. However,
1684  * derived classes may want to override this default
1685  * implementation.
1686  *
1687  * (note solvent is on molar scale).
1688  *
1689  * @param ac Output vector of activities. Length: m_kk.
1690  */
1691  virtual void getActivities(doublereal* ac) const;
1692 
1693  //! @}
1694  //! @name Partial Molar Properties of the Solution
1695  //! @{
1696 
1697  //! Get the species chemical potentials. Units: J/kmol.
1698  /*!
1699  *
1700  * This function returns a vector of chemical potentials of the
1701  * species in solution.
1702  *
1703  * \f[
1704  * \mu_k = \mu^{\triangle}_k(T,P) + R T ln(\gamma_k^{\triangle} m_k)
1705  * \f]
1706  *
1707  * @param mu Output vector of species chemical
1708  * potentials. Length: m_kk. Units: J/kmol
1709  */
1710  virtual void getChemPotentials(doublereal* mu) const;
1711 
1712  //! Returns an array of partial molar enthalpies for the species
1713  //! in the mixture. Units (J/kmol)
1714  /*!
1715  * For this phase, the partial molar enthalpies are equal to the
1716  * standard state enthalpies modified by the derivative of the
1717  * molality-based activity coefficient wrt temperature
1718  *
1719  * \f[
1720  * \bar h_k(T,P) = h^{\triangle}_k(T,P)
1721  * - R T^2 \frac{d \ln(\gamma_k^\triangle)}{dT}
1722  * \f]
1723  * The solvent partial molar enthalpy is equal to
1724  * \f[
1725  * \bar h_o(T,P) = h^{o}_o(T,P) - R T^2 \frac{d \ln(a_o)}{dT}
1726  * = h^{o}_o(T,P)
1727  * + R T^2 (\sum_{k \neq o} m_k) \tilde{M_o} (\frac{d \phi}{dT})
1728  * \f]
1729  *
1730  * @param hbar Output vector of species partial molar enthalpies.
1731  * Length: m_kk. units are J/kmol.
1732  */
1733  virtual void getPartialMolarEnthalpies(doublereal* hbar) const;
1734 
1735 
1736  //! Returns an array of partial molar entropies of the species in the
1737  //! solution. Units: J/kmol/K.
1738  /*!
1739  * Maxwell's equations provide an answer for how calculate this
1740  * (p.215 Smith and Van Ness)
1741  *
1742  * d(chemPot_i)/dT = -sbar_i
1743  *
1744  * For this phase, the partial molar entropies are equal to the
1745  * SS species entropies plus the ideal solution contribution
1746  * plus complicated functions of the
1747  * temperature derivative of the activity coefficients.
1748  *
1749  * \f[
1750  * \bar s_k(T,P) = s^{\triangle}_k(T,P)
1751  * - R \ln( \gamma^{\triangle}_k \frac{m_k}{m^{\triangle}}))
1752  * - R T \frac{d \ln(\gamma^{\triangle}_k) }{dT}
1753  * \f]
1754  * \f[
1755  * \bar s_o(T,P) = s^o_o(T,P) - R \ln(a_o)
1756  * - R T \frac{d \ln(a_o)}{dT}
1757  * \f]
1758  *
1759  * @param sbar Output vector of species partial molar entropies.
1760  * Length = m_kk. units are J/kmol/K.
1761  */
1762  virtual void getPartialMolarEntropies(doublereal* sbar) const;
1763 
1764  //! Return an array of partial molar volumes for the
1765  //! species in the mixture. Units: m^3/kmol.
1766  /*!
1767  * For this solution, the partial molar volumes are functions
1768  * of the pressure derivatives of the activity coefficients.
1769  *
1770  * \f[
1771  * \bar V_k(T,P) = V^{\triangle}_k(T,P)
1772  * + R T \frac{d \ln(\gamma^{\triangle}_k) }{dP}
1773  * \f]
1774  * \f[
1775  * \bar V_o(T,P) = V^o_o(T,P)
1776  * + R T \frac{d \ln(a_o)}{dP}
1777  * \f]
1778  *
1779  * @param vbar Output vector of species partial molar volumes.
1780  * Length = m_kk. units are m^3/kmol.
1781  */
1782  virtual void getPartialMolarVolumes(doublereal* vbar) const;
1783 
1784  //! Return an array of partial molar heat capacities for the
1785  //! species in the mixture. Units: J/kmol/K
1786  /*!
1787  * The following formulas are implemented within the code.
1788  *
1789  * \f[
1790  * \bar C_{p,k}(T,P) = C^{\triangle}_{p,k}(T,P)
1791  * - 2 R T \frac{d \ln( \gamma^{\triangle}_k)}{dT}
1792  * - R T^2 \frac{d^2 \ln(\gamma^{\triangle}_k) }{{dT}^2}
1793  * \f]
1794  * \f[
1795  * \bar C_{p,o}(T,P) = C^o_{p,o}(T,P)
1796  * - 2 R T \frac{d \ln(a_o)}{dT}
1797  * - R T^2 \frac{d^2 \ln(a_o)}{{dT}^2}
1798  * \f]
1799  *
1800  * @param cpbar Output vector of species partial molar heat
1801  * capacities at constant pressure.
1802  * Length = m_kk. units are J/kmol/K.
1803  */
1804  virtual void getPartialMolarCp(doublereal* cpbar) const;
1805 
1806 public:
1807  //! @}
1808  //! @name Chemical Equilibrium
1809  //! @{
1810 
1811  //!This method is used by the ChemEquil equilibrium solver.
1812  /*!
1813  * It sets the state such that the chemical potentials satisfy
1814  * \f[ \frac{\mu_k}{\hat R T} = \sum_m A_{k,m}
1815  * \left(\frac{\lambda_m} {\hat R T}\right) \f] where
1816  * \f$ \lambda_m \f$ is the element potential of element m. The
1817  * temperature is unchanged. Any phase (ideal or not) that
1818  * implements this method can be equilibrated by ChemEquil.
1819  *
1820  * @param lambda_RT Input vector of dimensionless element potentials
1821  * The length is equal to nElements().
1822  */
1823  virtual void setToEquilState(const doublereal* lambda_RT) {
1825  throw NotImplementedError("HMWSoln::setToEquilState");
1826  }
1827 
1828  //@}
1829 
1830  //! Get the saturation pressure for a given temperature.
1831  /*!
1832  * Note the limitations of this function. Stability considerations
1833  * concerning multiphase equilibrium are ignored in this
1834  * calculation. Therefore, the call is made directly to the SS of
1835  * water underneath. The object is put back into its original
1836  * state at the end of the call.
1837  *
1838  * @todo This is probably not implemented correctly. The stability
1839  * of the salt should be added into this calculation. The
1840  * underlying water model may be called to get the stability
1841  * of the pure water solution, if needed.
1842  *
1843  * @param T Temperature (kelvin)
1844  */
1845  virtual doublereal satPressure(doublereal T);
1846 
1847  /*
1848  * -------------- Utilities -------------------------------
1849  */
1850 
1851  //! Internal initialization required after all species have
1852  //! been added
1853  /*!
1854  * @internal Initialize. This method is provided to allow
1855  * subclasses to perform any initialization required after all
1856  * species have been added. For example, it might be used to
1857  * resize internal work arrays that must have an entry for
1858  * each species. The base class implementation does nothing,
1859  * and subclasses that do not require initialization do not
1860  * need to overload this method. When importing a CTML phase
1861  * description, this method is called just prior to returning
1862  * from function importPhase().
1863  */
1864  virtual void initThermo();
1865 
1866  //! Initialize the phase parameters from an XML file.
1867  /*!
1868  * This gets called from importPhase(). It processes the XML file
1869  * after the species are set up. This is the main routine for
1870  * reading in activity coefficient parameters.
1871  *
1872  * @param phaseNode This object must be the phase node of a
1873  * complete XML tree
1874  * description of the phase, including all of the
1875  * species data. In other words while "phase" must
1876  * point to an XML phase object, it must have
1877  * sibling nodes "speciesData" that describe
1878  * the species in the phase.
1879  * @param id ID of the phase. If nonnull, a check is done
1880  * to see if phaseNode is pointing to the phase
1881  * with the correct id.
1882  */
1883  virtual void initThermoXML(XML_Node& phaseNode, const std::string& id);
1884 
1885  //! Value of the Debye Huckel constant as a function of temperature
1886  //! and pressure.
1887  /*!
1888  * A_Debye = (F e B_Debye) / (8 Pi epsilon R T)
1889  *
1890  * Units = sqrt(kg/gmol)
1891  *
1892  * @param temperature Temperature of the derivative calculation
1893  * or -1 to indicate the current temperature
1894  *
1895  * @param pressure Pressure of the derivative calculation
1896  * or -1 to indicate the current pressure
1897  */
1898  virtual double A_Debye_TP(double temperature = -1.0,
1899  double pressure = -1.0) const;
1900 
1901  //! Value of the derivative of the Debye Huckel constant with
1902  //! respect to temperature as a function of temperature
1903  //! and pressure.
1904  /*!
1905  * A_Debye = (F e B_Debye) / (8 Pi epsilon R T)
1906  *
1907  * Units = sqrt(kg/gmol)
1908  *
1909  * @param temperature Temperature of the derivative calculation
1910  * or -1 to indicate the current temperature
1911  *
1912  * @param pressure Pressure of the derivative calculation
1913  * or -1 to indicate the current pressure
1914  */
1915  virtual double dA_DebyedT_TP(double temperature = -1.0,
1916  double pressure = -1.0) const;
1917 
1918  /**
1919  * Value of the derivative of the Debye Huckel constant with
1920  * respect to pressure, as a function of temperature
1921  * and pressure.
1922  *
1923  * A_Debye = (F e B_Debye) / (8 Pi epsilon R T)
1924  *
1925  * Units = sqrt(kg/gmol)
1926  *
1927  * @param temperature Temperature of the derivative calculation
1928  * or -1 to indicate the current temperature
1929  *
1930  * @param pressure Pressure of the derivative calculation
1931  * or -1 to indicate the current pressure
1932  */
1933  virtual double dA_DebyedP_TP(double temperature = -1.0,
1934  double pressure = -1.0) const;
1935 
1936  /**
1937  * Return Pitzer's definition of A_L. This is basically the
1938  * derivative of the A_phi multiplied by 4 R T**2
1939  *
1940  * A_Debye = (F e B_Debye) / (8 Pi epsilon R T)
1941  * dA_phidT = d(A_Debye)/dT / 3.0
1942  * A_L = dA_phidT * (4 * R * T * T)
1943  *
1944  * Units = sqrt(kg/gmol) (RT)
1945  *
1946  * @param temperature Temperature of the derivative calculation
1947  * or -1 to indicate the current temperature
1948  *
1949  * @param pressure Pressure of the derivative calculation
1950  * or -1 to indicate the current pressure
1951  */
1952  double ADebye_L(double temperature = -1.0,
1953  double pressure = -1.0) const;
1954 
1955  /**
1956  * Return Pitzer's definition of A_J. This is basically the
1957  * temperature derivative of A_L, and the second derivative
1958  * of A_phi
1959  *
1960  * A_Debye = (F e B_Debye) / (8 Pi epsilon R T)
1961  * dA_phidT = d(A_Debye)/dT / 3.0
1962  * A_J = 2 A_L/T + 4 * R * T * T * d2(A_phi)/dT2
1963  *
1964  * Units = sqrt(kg/gmol) (R)
1965  *
1966  * @param temperature Temperature of the derivative calculation
1967  * or -1 to indicate the current temperature
1968  *
1969  * @param pressure Pressure of the derivative calculation
1970  * or -1 to indicate the current pressure
1971  */
1972  double ADebye_J(double temperature = -1.0,
1973  double pressure = -1.0) const;
1974 
1975  /**
1976  * Return Pitzer's definition of A_V. This is the
1977  * derivative wrt pressure of A_phi multiplied by - 4 R T
1978  *
1979  * A_Debye = (F e B_Debye) / (8 Pi epsilon R T)
1980  * dA_phidT = d(A_Debye)/dP / 3.0
1981  * A_V = - dA_phidP * (4 * R * T)
1982  *
1983  * Units = sqrt(kg/gmol) (RT) / Pascal
1984  *
1985  * @param temperature Temperature of the derivative calculation
1986  * or -1 to indicate the current temperature
1987  *
1988  * @param pressure Pressure of the derivative calculation
1989  * or -1 to indicate the current pressure
1990  */
1991  double ADebye_V(double temperature = -1.0,
1992  double pressure = -1.0) const;
1993 
1994  //! Value of the 2nd derivative of the Debye Huckel constant with
1995  //! respect to temperature as a function of temperature
1996  //! and pressure.
1997  /*!
1998  * A_Debye = (F e B_Debye) / (8 Pi epsilon R T)
1999  *
2000  * Units = sqrt(kg/gmol)
2001  *
2002  * @param temperature Temperature of the derivative calculation
2003  * or -1 to indicate the current temperature
2004  *
2005  * @param pressure Pressure of the derivative calculation
2006  * or -1 to indicate the current pressure
2007  */
2008  virtual double d2A_DebyedT2_TP(double temperature = -1.0,
2009  double pressure = -1.0) const;
2010 
2011  //! Reports the ionic radius of the kth species
2012  /*!
2013  * @param k Species index
2014  */
2015  double AionicRadius(int k = 0) const;
2016 
2017  /**
2018  * formPitzer():
2019  *
2020  * Returns the form of the Pitzer parameterization used
2021  */
2022  int formPitzer() const {
2023  return m_formPitzer;
2024  }
2025 
2026  //! Print out all of the input Pitzer coefficients.
2027  void printCoeffs() const;
2028 
2029  //! Get the array of unscaled non-dimensional molality based
2030  //! activity coefficients at the current solution temperature,
2031  //! pressure, and solution concentration.
2032  /*!
2033  * See Denbigh p. 278 for a thorough discussion. This class must be overwritten in
2034  * classes which derive from MolalityVPSSTP. This function takes over from the
2035  * molar-based activity coefficient calculation, getActivityCoefficients(), in
2036  * derived classes.
2037  *
2038  * @param acMolality Output vector containing the molality based activity coefficients.
2039  * length: m_kk.
2040  */
2041  void getUnscaledMolalityActivityCoefficients(doublereal* acMolality) const;
2042 
2043 private:
2044 
2045  //! Apply the current phScale to a set of activity Coefficients
2046  /*!
2047  * See the Eq3/6 Manual for a thorough discussion.
2048  */
2049  void s_updateScaling_pHScaling() const;
2050 
2051  //! Apply the current phScale to a set of derivatives of the activity Coefficients
2052  //! wrt temperature
2053  /*!
2054  * See the Eq3/6 Manual for a thorough discussion of the need
2055  */
2056  void s_updateScaling_pHScaling_dT() const;
2057 
2058  //! Apply the current phScale to a set of 2nd derivatives of the activity Coefficients
2059  //! wrt temperature
2060  /*!
2061  * See the Eq3/6 Manual for a thorough discussion of the need
2062  */
2063  void s_updateScaling_pHScaling_dT2() const;
2064 
2065  //! Apply the current phScale to a set of derivatives of the activity Coefficients
2066  //! wrt pressure
2067  /*!
2068  * See the Eq3/6 Manual for a thorough discussion of the need
2069  */
2070  void s_updateScaling_pHScaling_dP() const;
2071 
2072  //! Calculate the Chlorine activity coefficient on the NBS scale
2073  /*!
2074  * We assume here that the m_IionicMolality variable is up to date.
2075  */
2076  doublereal s_NBS_CLM_lnMolalityActCoeff() const;
2077 
2078  //! Calculate the temperature derivative of the Chlorine activity coefficient
2079  //! on the NBS scale
2080  /*!
2081  * We assume here that the m_IionicMolality variable is up to date.
2082  */
2083  doublereal s_NBS_CLM_dlnMolalityActCoeff_dT() const;
2084 
2085  //! Calculate the second temperature derivative of the Chlorine activity coefficient
2086  //! on the NBS scale
2087  /*!
2088  * We assume here that the m_IionicMolality variable is up to date.
2089  */
2090  doublereal s_NBS_CLM_d2lnMolalityActCoeff_dT2() const;
2091 
2092  //! Calculate the pressure derivative of the Chlorine activity coefficient
2093  /*!
2094  * We assume here that the m_IionicMolality variable is up to date.
2095  */
2096  doublereal s_NBS_CLM_dlnMolalityActCoeff_dP() const;
2097 
2098  //@}
2099 
2100 private:
2101 
2102  /**
2103  * This is the form of the Pitzer parameterization
2104  * used in this model.
2105  * The options are described at the top of this document,
2106  * and in the general documentation.
2107  * The list is repeated here:
2108  *
2109  * PITZERFORM_BASE = 0 (only one supported atm)
2110  */
2112 
2113  /**
2114  * This is the form of the temperature dependence of Pitzer
2115  * parameterization used in the model.
2116  *
2117  * PITZER_TEMP_CONSTANT 0
2118  * PITZER_TEMP_LINEAR 1
2119  * PITZER_TEMP_COMPLEX1 2
2120  */
2122 
2123  /**
2124  * Format for the generalized concentration:
2125  *
2126  * 0 = unity
2127  * 1 = molar_volume
2128  * 2 = solvent_volume (default)
2129  *
2130  * The generalized concentrations can have three different forms
2131  * depending on the value of the member attribute m_formGC, which
2132  * is supplied in the constructor.
2133  * <TABLE>
2134  * <TR><TD> m_formGC </TD><TD> GeneralizedConc </TD><TD> StandardConc </TD></TR>
2135  * <TR><TD> 0 </TD><TD> X_k </TD><TD> 1.0 </TD></TR>
2136  * <TR><TD> 1 </TD><TD> X_k / V_k </TD><TD> 1.0 / V_k </TD></TR>
2137  * <TR><TD> 2 </TD><TD> X_k / V_N </TD><TD> 1.0 / V_N </TD></TR>
2138  * </TABLE>
2139  *
2140  * The value and form of the generalized concentration will affect
2141  * reaction rate constants involving species in this phase.
2142  *
2143  * (HKM Note: Using option #1 may lead to spurious results and
2144  * has been included only with warnings. The reason is that it
2145  * molar volumes of electrolytes may often be negative. The
2146  * molar volume of H+ is defined to be zero too. Either options
2147  * 0 or 2 are the appropriate choice. Option 0 leads to
2148  * bulk reaction rate constants which have units of s-1.
2149  * Option 2 leads to bulk reaction rate constants for
2150  * bimolecular rxns which have units of m-3 kmol-1 s-1.)
2151  */
2153 
2154  //! Vector containing the electrolyte species type
2155  /*!
2156  * The possible types are:
2157  * - solvent
2158  * - Charged Species
2159  * - weakAcidAssociated
2160  * - strongAcidAssociated
2161  * - polarNeutral
2162  * - nonpolarNeutral .
2163  */
2165 
2166  /**
2167  * a_k = Size of the ionic species in the DH formulation
2168  * units = meters
2169  */
2171 
2172  /**
2173  * Current value of the ionic strength on the molality scale
2174  * Associated Salts, if present in the mechanism,
2175  * don't contribute to the value of the ionic strength
2176  * in this version of the Ionic strength.
2177  */
2178  mutable double m_IionicMolality;
2179 
2180  /**
2181  * Maximum value of the ionic strength allowed in the
2182  * calculation of the activity coefficients.
2183  */
2185 
2186  //! Reference Temperature for the Pitzer formulations.
2188 
2189  /**
2190  * Stoichiometric ionic strength on the molality scale.
2191  * This differs from m_IionicMolality in the sense that
2192  * associated salts are treated as unassociated salts,
2193  * when calculating the Ionic strength by this method.
2194  */
2195  mutable double m_IionicMolalityStoich;
2196 
2197 public:
2198  /**
2199  * Form of the constant outside the Debye-Huckel term
2200  * called A. It's normally a function of temperature
2201  * and pressure. However, it can be set from the
2202  * input file in order to aid in numerical comparisons.
2203  * Acceptable forms:
2204  *
2205  * A_DEBYE_CONST 0
2206  * A_DEBYE_WATER 1
2207  *
2208  * The A_DEBYE_WATER form may be used for water solvents
2209  * with needs to cover varying temperatures and pressures.
2210  * Note, the dielectric constant of water is a relatively
2211  * strong function of T, and its variability must be
2212  * accounted for,
2213  */
2215 
2216 private:
2217  /**
2218  * A_Debye -> this expression appears on the top of the
2219  * ln actCoeff term in the general Debye-Huckel
2220  * expression
2221  * It depends on temperature. And, therefore,
2222  * most be recalculated whenever T or P changes.
2223  * This variable is a local copy of the calculation.
2224  *
2225  * A_Debye = (F e B_Debye) / (8 Pi epsilon R T)
2226  *
2227  * where B_Debye = F / sqrt(epsilon R T/2)
2228  * (dw/1000)^(1/2)
2229  *
2230  * A_Debye = (1/ (8 Pi)) (2 Na * dw/1000)^(1/2)
2231  * (e * e / (epsilon * kb * T))^(3/2)
2232  *
2233  * Units = sqrt(kg/gmol)
2234  *
2235  * Nominal value = 1.172576 sqrt(kg/gmol)
2236  * based on:
2237  * epsilon/epsilon_0 = 78.54
2238  * (water at 25C)
2239  * epsilon_0 = 8.854187817E-12 C2 N-1 m-2
2240  * e = 1.60217653 E-19 C
2241  * F = 9.6485309E7 C kmol-1
2242  * R = 8.314472E3 kg m2 s-2 kmol-1 K-1
2243  * T = 298.15 K
2244  * B_Debye = 3.28640E9 sqrt(kg/gmol)/m
2245  * dw = C_0 * M_0 (density of water) (kg/m3)
2246  * = 1.0E3 at 25C
2247  */
2248  mutable double m_A_Debye;
2249 
2250  //! Water standard state calculator
2251  /*!
2252  * derived from the equation of state for water.
2253  */
2255 
2256  //! density of standard-state water
2257  /*!
2258  * internal temporary variable
2259  */
2261 
2262  //! Pointer to the water property calculator
2264 
2265  //! Temporary array used in equilibrium calculations
2266  mutable vector_fp m_pp;
2267 
2268  //! vector of size m_kk, used as a temporary holding area.
2270 
2271  /**
2272  * Stoichiometric species charge -> This is for calculations
2273  * of the ionic strength which ignore ion-ion pairing into
2274  * neutral molecules. The Stoichiometric species charge is the
2275  * charge of one of the ion that would occur if the species broke
2276  * into two charged ion pairs.
2277  * NaCl -> m_speciesCharge_Stoich = -1;
2278  * HSO4- -> H+ + SO42- = -2
2279  * -> The other charge is calculated.
2280  * For species that aren't ion pairs, its equal to the
2281  * m_speciesCharge[] value.
2282  */
2284 
2285  /**
2286  * Array of 2D data used in the Pitzer/HMW formulation.
2287  * Beta0_ij[i][j] is the value of the Beta0 coefficient
2288  * for the ij salt. It will be nonzero iff i and j are
2289  * both charged and have opposite sign. The array is also
2290  * symmetric.
2291  * counterIJ where counterIJ = m_counterIJ[i][j]
2292  * is used to access this array.
2293  */
2295 
2296  //! Derivative of Beta0_ij[i][j] wrt T
2297  /*!
2298  * vector index is counterIJ
2299  */
2301 
2302  //! Derivative of Beta0_ij[i][j] wrt TT
2303  /*!
2304  * vector index is counterIJ
2305  */
2307 
2308  //! Derivative of Beta0_ij[i][j] wrt P
2309  /*!
2310  * vector index is counterIJ
2311  */
2313 
2314  //! Array of coefficients for Beta0, a variable in Pitzer's papers
2315  /*!
2316  * column index is counterIJ
2317  * m_Beta0MX_ij_coeff.ptrColumn(counterIJ) is a double* containing
2318  * the vector of coefficients for the counterIJ interaction.
2319  */
2321 
2322  /*!
2323  * Array of 2D data used in the Pitzer/HMW formulation.
2324  * Beta1_ij[i][j] is the value of the Beta1 coefficient
2325  * for the ij salt. It will be nonzero iff i and j are
2326  * both charged and have opposite sign. The array is also
2327  * symmetric.
2328  * counterIJ where counterIJ = m_counterIJ[i][j]
2329  * is used to access this array.
2330  */
2332 
2333  //! Derivative of Beta1_ij[i][j] wrt T
2334  /*!
2335  * vector index is counterIJ
2336  */
2338 
2339  //! Derivative of Beta1_ij[i][j] wrt TT
2340  /*!
2341  * vector index is counterIJ
2342  */
2344 
2345  //! Derivative of Beta1_ij[i][j] wrt P
2346  /*!
2347  * vector index is counterIJ
2348  */
2350 
2351  //! Array of coefficients for Beta1, a variable in Pitzer's papers
2352  /*!
2353  * column index is counterIJ
2354  * m_Beta1MX_ij_coeff.ptrColumn(counterIJ) is a double* containing
2355  * the vector of coefficients for the counterIJ interaction.
2356  */
2358 
2359  /**
2360  * Array of 2D data used in the Pitzer/HMW formulation.
2361  * Beta2_ij[i][j] is the value of the Beta2 coefficient
2362  * for the ij salt. It will be nonzero iff i and j are
2363  * both charged and have opposite sign, and i and j
2364  * both have charges of 2 or more. The array is also
2365  * symmetric.
2366  * counterIJ where counterIJ = m_counterIJ[i][j]
2367  * is used to access this array.
2368  */
2370 
2371  //! Derivative of Beta2_ij[i][j] wrt T
2372  /*!
2373  * vector index is counterIJ
2374  */
2376 
2377  //! Derivative of Beta2_ij[i][j] wrt TT
2378  /*!
2379  * vector index is counterIJ
2380  */
2382 
2383  //! Derivative of Beta2_ij[i][j] wrt P
2384  /*!
2385  * vector index is counterIJ
2386  */
2388 
2389  //! Array of coefficients for Beta2, a variable in Pitzer's papers
2390  /*!
2391  * column index is counterIJ
2392  * m_Beta2MX_ij_coeff.ptrColumn(counterIJ) is a double* containing
2393  * the vector of coefficients for the counterIJ interaction.
2394  * This was added for the YMP database version of the code since it
2395  * contains temperature-dependent parameters for some 2-2 electrolytes.
2396  */
2398 
2399  /**
2400  * Array of 2D data used in the Pitzer/HMW formulation.
2401  * Alpha1MX_ij[i][j] is the value of the alpha1 coefficient
2402  * for the ij interaction. It will be nonzero iff i and j are
2403  * both charged and have opposite sign.
2404  * It is symmetric wrt i, j.
2405  * counterIJ where counterIJ = m_counterIJ[i][j]
2406  * is used to access this array.
2407  */
2409 
2410  /**
2411  * Array of 2D data used in the Pitzer/HMW formulation.
2412  * Alpha2MX_ij[i][j] is the value of the alpha2 coefficient
2413  * for the ij interaction. It will be nonzero iff i and j are
2414  * both charged and have opposite sign, and i and j
2415  * both have charges of 2 or more, usually.
2416  * It is symmetric wrt i, j.
2417  * counterIJ, where counterIJ = m_counterIJ[i][j],
2418  * is used to access this array.
2419  */
2421 
2422  /**
2423  * Array of 2D data used in the Pitzer/HMW formulation.
2424  * CphiMX_ij[i][j] is the value of the Cphi coefficient
2425  * for the ij interaction. It will be nonzero iff i and j are
2426  * both charged and have opposite sign, and i and j
2427  * both have charges of 2 or more. The array is also
2428  * symmetric.
2429  * counterIJ where counterIJ = m_counterIJ[i][j]
2430  * is used to access this array.
2431  */
2433 
2434  //! Derivative of Cphi_ij[i][j] wrt T
2435  /*!
2436  * vector index is counterIJ
2437  */
2439 
2440  //! Derivative of Cphi_ij[i][j] wrt TT
2441  /*!
2442  * vector index is counterIJ
2443  */
2445 
2446  //! Derivative of Cphi_ij[i][j] wrt P
2447  /*!
2448  * vector index is counterIJ
2449  */
2451 
2452  //! Array of coefficients for CphiMX, a parameter in the activity
2453  //! coefficient formulation
2454  /*!
2455  * Column index is counterIJ
2456  * m_CphiMX_ij_coeff.ptrColumn(counterIJ) is a double* containing
2457  * the vector of coefficients for the counterIJ interaction.
2458  */
2460 
2461  //! Array of 2D data for Theta_ij[i][j] in the Pitzer/HMW formulation.
2462  /*!
2463  * Array of 2D data used in the Pitzer/HMW formulation.
2464  * Theta_ij[i][j] is the value of the theta coefficient
2465  * for the ij interaction. It will be nonzero for charged
2466  * ions with the same sign. It is symmetric.
2467  * counterIJ where counterIJ = m_counterIJ[i][j]
2468  * is used to access this array.
2469  *
2470  * HKM Recent Pitzer papers have used a functional form
2471  * for Theta_ij, which depends on the ionic strength.
2472  */
2474 
2475  //! Derivative of Theta_ij[i][j] wrt T
2476  /*!
2477  * vector index is counterIJ
2478  */
2480 
2481  //! Derivative of Theta_ij[i][j] wrt TT
2482  /*!
2483  * vector index is counterIJ
2484  */
2486 
2487  //! Derivative of Theta_ij[i][j] wrt P
2488  /*!
2489  * vector index is counterIJ
2490  */
2492 
2493  //! Array of coefficients for Theta_ij[i][j] in the Pitzer/HMW formulation.
2494  /*!
2495  * Theta_ij[i][j] is the value of the theta coefficient
2496  * for the ij interaction. It will be nonzero for charged
2497  * ions with the same sign. It is symmetric.
2498  * Column index is counterIJ.
2499  * counterIJ where counterIJ = m_counterIJ[i][j]
2500  * is used to access this array.
2501  *
2502  * m_Theta_ij_coeff.ptrColumn(counterIJ) is a double* containing
2503  * the vector of coefficients for the counterIJ interaction.
2504  */
2506 
2507  //! Array of 3D data used in the Pitzer/HMW formulation.
2508  /*!
2509  * Psi_ijk[n] is the value of the psi coefficient for the
2510  * ijk interaction where
2511  *
2512  * n = k + j * m_kk + i * m_kk * m_kk;
2513  *
2514  * It is potentially nonzero everywhere.
2515  * The first two coordinates are symmetric wrt cations,
2516  * and the last two coordinates are symmetric wrt anions.
2517  */
2519 
2520  //! Derivative of Psi_ijk[n] wrt T
2521  /*!
2522  * see m_Psi_ijk for reference on the indexing into this variable.
2523  */
2525 
2526  //! Derivative of Psi_ijk[n] wrt TT
2527  /*!
2528  * see m_Psi_ijk for reference on the indexing into this variable.
2529  */
2531 
2532  //! Derivative of Psi_ijk[n] wrt P
2533  /*!
2534  * see m_Psi_ijk for reference on the indexing into this variable.
2535  */
2537 
2538  //! Array of coefficients for Psi_ijk[n] in the Pitzer/HMW formulation.
2539  /*!
2540  * Psi_ijk[n] is the value of the psi coefficient for the
2541  * ijk interaction where
2542  *
2543  * n = k + j * m_kk + i * m_kk * m_kk;
2544  *
2545  * It is potentially nonzero everywhere.
2546  * The first two coordinates are symmetric wrt cations,
2547  * and the last two coordinates are symmetric wrt anions.
2548  *
2549  *
2550  * m_Psi_ijk_coeff.ptrColumn(n) is a double* containing
2551  * the vector of coefficients for the n interaction.
2552  */
2554 
2555  //! Lambda coefficient for the ij interaction
2556  /*!
2557  * Array of 2D data used in the Pitzer/HMW formulation.
2558  * Lambda_nj[n][j] represents the lambda coefficient for the
2559  * ij interaction. This is a general interaction representing
2560  * neutral species. The neutral species occupy the first
2561  * index, i.e., n. The charged species occupy the j coordinate.
2562  * neutral, neutral interactions are also included here.
2563  */
2565 
2566  //! Derivative of Lambda_nj[i][j] wrt T. see m_Lambda_ij
2568 
2569  //! Derivative of Lambda_nj[i][j] wrt TT
2571 
2572  //! Derivative of Lambda_nj[i][j] wrt P
2574 
2575  //! Array of coefficients for Lambda_nj[i][j] in the Pitzer/HMW formulation.
2576  /*!
2577  * Lambda_ij[i][j] is the value of the theta coefficient
2578  * for the ij interaction.
2579  * Array of 2D data used in the Pitzer/HMW formulation.
2580  * Lambda_ij[i][j] represents the lambda coefficient for the
2581  * ij interaction. This is a general interaction representing
2582  * neutral species. The neutral species occupy the first
2583  * index, i.e., i. The charged species occupy the j coordinate.
2584  * Neutral, neutral interactions are also included here.
2585  *
2586  * n = j + m_kk * i
2587  *
2588  * m_Lambda_ij_coeff.ptrColumn(n) is a double* containing
2589  * the vector of coefficients for the (i,j) interaction.
2590  */
2592 
2593  //! Mu coefficient for the self-ternary neutral coefficient
2594  /*!
2595  * Array of 2D data used in the Pitzer/HMW formulation.
2596  * Mu_nnn[i] represents the Mu coefficient for the
2597  * nnn interaction. This is a general interaction representing
2598  * neutral species interacting with itself.
2599  */
2601 
2602  //! Mu coefficient temperature derivative for the self-ternary neutral coefficient
2603  /*!
2604  * Array of 2D data used in the Pitzer/HMW formulation.
2605  * Mu_nnn_L[i] represents the Mu coefficient temperature derivative for the
2606  * nnn interaction. This is a general interaction representing
2607  * neutral species interacting with itself.
2608  */
2610 
2611  //! Mu coefficient 2nd temperature derivative for the self-ternary neutral coefficient
2612  /*!
2613  * Array of 2D data used in the Pitzer/HMW formulation.
2614  * Mu_nnn_L[i] represents the Mu coefficient 2nd temperature derivative for the
2615  * nnn interaction. This is a general interaction representing
2616  * neutral species interacting with itself.
2617  */
2619 
2620  //! Mu coefficient pressure derivative for the self-ternary neutral coefficient
2621  /*!
2622  * Array of 2D data used in the Pitzer/HMW formulation.
2623  * Mu_nnn_L[i] represents the Mu coefficient pressure derivative for the
2624  * nnn interaction. This is a general interaction representing
2625  * neutral species interacting with itself.
2626  */
2628 
2629  //! Array of coefficients form_Mu_nnn term
2631 
2632  //! Logarithm of the activity coefficients on the molality
2633  //! scale.
2634  /*!
2635  * mutable because we change this if the composition
2636  * or temperature or pressure changes.
2637  *
2638  * index is the species index
2639  */
2641 
2642  //! Logarithm of the activity coefficients on the molality
2643  //! scale.
2644  /*!
2645  * mutable because we change this if the composition
2646  * or temperature or pressure changes.
2647  *
2648  * index is the species index
2649  */
2651 
2652  //! Derivative of the Logarithm of the activity coefficients on the molality
2653  //! scale wrt T
2654  /*!
2655  * index is the species index
2656  */
2658 
2659  //! Derivative of the Logarithm of the activity coefficients on the molality
2660  //! scale wrt T
2661  /*!
2662  * index is the species index
2663  */
2665 
2666  //! Derivative of the Logarithm of the activity coefficients on the molality
2667  //! scale wrt TT
2668  /*!
2669  * index is the species index
2670  */
2672 
2673  //! Derivative of the Logarithm of the activity coefficients on the molality
2674  //! scale wrt TT
2675  /*!
2676  * index is the species index
2677  */
2679 
2680  //! Derivative of the Logarithm of the activity coefficients on the
2681  //! molality scale wrt P
2682  /*!
2683  * index is the species index
2684  */
2686 
2687  //! Derivative of the Logarithm of the activity coefficients on the
2688  //! molality scale wrt P
2689  /*!
2690  * index is the species index
2691  */
2693 
2694  /*
2695  * -------- Temporary Variables Used in the Activity Coeff Calc
2696  */
2697 
2698  //! Cropped and modified values of the molalities used in activity
2699  //! coefficient calculations
2701 
2702  //! Boolean indicating whether the molalities are cropped or are modified
2704 
2705  //! a counter variable for keeping track of symmetric binary
2706  //! interactions amongst the solute species.
2707  /*!
2708  * n = m_kk*i + j
2709  * m_CounterIJ[n] = counterIJ
2710  */
2712 
2713  //! This is elambda, MEC
2714  mutable double elambda[17];
2715 
2716  //! This is elambda1, MEC
2717  mutable double elambda1[17];
2718 
2719  /**
2720  * Various temporary arrays used in the calculation of
2721  * the Pitzer activity coefficients.
2722  * The subscript, L, denotes the same quantity's derivative
2723  * wrt temperature
2724  */
2725 
2726  //! This is the value of g(x) in Pitzer's papers
2727  /*!
2728  * vector index is counterIJ
2729  */
2731 
2732  //! This is the value of g2(x2) in Pitzer's papers
2733  /*!
2734  * vector index is counterIJ
2735  */
2737 
2738  //! hfunc, was called gprime in Pitzer's paper. However,
2739  //! it's not the derivative of gfunc(x), so I renamed it.
2740  /*!
2741  * vector index is counterIJ
2742  */
2744 
2745  //! hfunc2, was called gprime in Pitzer's paper. However,
2746  //! it's not the derivative of gfunc(x), so I renamed it.
2747  /*!
2748  * vector index is counterIJ
2749  */
2751 
2752  //! Intermediate variable called BMX in Pitzer's paper
2753  //! This is the basic cation - anion interaction
2754  /*!
2755  * vector index is counterIJ
2756  */
2758 
2759  //! Derivative of BMX_IJ wrt T
2760  /*!
2761  * vector index is counterIJ
2762  */
2764 
2765  //! Derivative of BMX_IJ wrt TT
2766  /*!
2767  * vector index is counterIJ
2768  */
2770 
2771  //! Derivative of BMX_IJ wrt P
2772  /*!
2773  * vector index is counterIJ
2774  */
2776 
2777  //! Intermediate variable called BprimeMX in Pitzer's paper
2778  /*!
2779  * vector index is counterIJ
2780  */
2782 
2783  //! Derivative of BprimeMX wrt T
2784  /*!
2785  * vector index is counterIJ
2786  */
2788 
2789  //! Derivative of BprimeMX wrt TT
2790  /*!
2791  * vector index is counterIJ
2792  */
2794 
2795  //! Derivative of BprimeMX wrt P
2796  /*!
2797  * vector index is counterIJ
2798  */
2800 
2801  //! Intermediate variable called BphiMX in Pitzer's paper
2802  /*!
2803  * vector index is counterIJ
2804  */
2806 
2807  //! Derivative of BphiMX_IJ wrt T
2808  /*!
2809  * vector index is counterIJ
2810  */
2812 
2813  //! Derivative of BphiMX_IJ wrt TT
2814  /*!
2815  * vector index is counterIJ
2816  */
2818 
2819  //! Derivative of BphiMX_IJ wrt P
2820  /*!
2821  * vector index is counterIJ
2822  */
2824 
2825  //! Intermediate variable called Phi in Pitzer's paper
2826  /*!
2827  * vector index is counterIJ
2828  */
2830 
2831  //! Derivative of m_Phi_IJ wrt T
2832  /*!
2833  * vector index is counterIJ
2834  */
2836 
2837  //! Derivative of m_Phi_IJ wrt TT
2838  /*!
2839  * vector index is counterIJ
2840  */
2842 
2843  //! Derivative of m_Phi_IJ wrt P
2844  /*!
2845  * vector index is counterIJ
2846  */
2848 
2849  //! Intermediate variable called Phiprime in Pitzer's paper
2850  /*!
2851  * vector index is counterIJ
2852  */
2854 
2855  //! Intermediate variable called PhiPhi in Pitzer's paper
2856  /*!
2857  * vector index is counterIJ
2858  */
2860 
2861  //! Derivative of m_PhiPhi_IJ wrt T
2862  /*!
2863  * vector index is counterIJ
2864  */
2866 
2867  //! Derivative of m_PhiPhi_IJ wrt TT
2868  /*!
2869  * vector index is counterIJ
2870  */
2872 
2873  //! Derivative of m_PhiPhi_IJ wrt P
2874  /*!
2875  * vector index is counterIJ
2876  */
2878 
2879  //! Intermediate variable called CMX in Pitzer's paper
2880  /*!
2881  * vector index is counterIJ
2882  */
2884 
2885  //! Derivative of m_CMX_IJ wrt T
2886  /*!
2887  * vector index is counterIJ
2888  */
2890 
2891  //! Derivative of m_CMX_IJ wrt TT
2892  /*!
2893  * vector index is counterIJ
2894  */
2896 
2897  //! Derivative of m_CMX_IJ wrt P
2898  /*!
2899  * vector index is counterIJ
2900  */
2902 
2903  //! Intermediate storage of the activity coefficient itself
2904  /*!
2905  * vector index is the species index
2906  */
2908 
2909  //! Logarithm of the molal activity coefficients
2910  /*!
2911  * Normally these are all one. However, stability schemes will change that
2912  */
2914 
2915  //! IMS Cutoff type
2917 
2918  //! value of the solute mole fraction that centers the cutoff polynomials
2919  //! for the cutoff =1 process;
2920  doublereal IMS_X_o_cutoff_;
2921 
2922  //! gamma_o value for the cutoff process at the zero solvent point
2923  doublereal IMS_gamma_o_min_;
2924 
2925  //! gamma_k minimum for the cutoff process at the zero solvent point
2926  doublereal IMS_gamma_k_min_;
2927 
2928  //! Parameter in the polyExp cutoff treatment having to do with rate of exp decay
2929  doublereal IMS_cCut_;
2930 
2931  //! Parameter in the polyExp cutoff treatment
2932  /*!
2933  * This is the slope of the f function at the zero solvent point
2934  * Default value is 0.6
2935  */
2936  doublereal IMS_slopefCut_;
2937 
2938  //! Parameter in the polyExp cutoff treatment
2939  /*!
2940  * This is the slope of the g function at the zero solvent point
2941  * Default value is 0.0
2942  */
2943  doublereal IMS_slopegCut_;
2944 
2945  //! @name Parameters in the polyExp cutoff treatment having to do with rate of exp decay
2946  //! @{
2947  doublereal IMS_dfCut_;
2948  doublereal IMS_efCut_;
2949  doublereal IMS_afCut_;
2950  doublereal IMS_bfCut_;
2951  doublereal IMS_dgCut_;
2952  doublereal IMS_egCut_;
2953  doublereal IMS_agCut_;
2954  doublereal IMS_bgCut_;
2955  //! @}
2956 
2957  //! value of the solvent mole fraction that centers the cutoff polynomials
2958  //! for the cutoff =1 process;
2959  doublereal MC_X_o_cutoff_;
2960 
2961  //! gamma_o value for the cutoff process at the zero solvent point
2962  doublereal MC_X_o_min_;
2963 
2964  //! Parameter in the Molality Exp cutoff treatment
2965  /*!
2966  * This is the slope of the p function at the zero solvent point
2967  * Default value is 0.0
2968  */
2969  doublereal MC_slopepCut_;
2970 
2971  //! @name Parameters in the Molality Exp cutoff treatment
2972  //! @{
2973  doublereal MC_dpCut_;
2974  doublereal MC_epCut_;
2975  doublereal MC_apCut_;
2976  doublereal MC_bpCut_;
2977  doublereal MC_cpCut_;
2978  doublereal CROP_ln_gamma_o_min;
2979  doublereal CROP_ln_gamma_o_max;
2980  doublereal CROP_ln_gamma_k_min;
2981  doublereal CROP_ln_gamma_k_max;
2982 
2983  //! This is a boolean-type vector indicating whether
2984  //! a species's activity coefficient is in the cropped regime
2985  /*!
2986  * * 0 = Not in cropped regime
2987  * * 1 = In a transition regime where it is altered but there
2988  * still may be a temperature or pressure dependence
2989  * * 2 = In a cropped regime where there is no temperature
2990  * or pressure dependence
2991  */
2992  mutable std::vector<int> CROP_speciesCropped_;
2993  //! @}
2994 
2995  //! Initialize all of the species-dependent lengths in the object
2996  void initLengths();
2997 
2998  //! Apply the current phScale to a set of activity Coefficients or
2999  //! activities
3000  /*!
3001  * See the Eq3/6 Manual for a thorough discussion.
3002  *
3003  * @param acMolality input/Output vector containing the molality based
3004  * activity coefficients. length: m_kk.
3005  */
3006  virtual void applyphScale(doublereal* acMolality) const;
3007 
3008 private:
3009  /*
3010  * This function will be called to update the internally stored
3011  * natural logarithm of the molality activity coefficients
3012  */
3013  void s_update_lnMolalityActCoeff() const;
3014 
3015  //! This function calculates the temperature derivative of the
3016  //! natural logarithm of the molality activity coefficients.
3017  /*!
3018  * This function does all of the direct work. The solvent activity
3019  * coefficient is on the molality scale. It's derivative is too.
3020  */
3021  void s_update_dlnMolalityActCoeff_dT() const;
3022 
3023  /**
3024  * This function calculates the temperature second derivative
3025  * of the natural logarithm of the molality activity
3026  * coefficients.
3027  */
3028  void s_update_d2lnMolalityActCoeff_dT2() const;
3029 
3030  /**
3031  * This function calculates the pressure derivative of the
3032  * natural logarithm of the molality activity coefficients.
3033  *
3034  * Assumes that the activity coefficients are current.
3035  */
3036  void s_update_dlnMolalityActCoeff_dP() const;
3037 
3038  //! This function will be called to update the internally stored
3039  //! natural logarithm of the molality activity coefficients
3040  /*
3041  * Normally they are all one. However, sometimes they are not,
3042  * due to stability schemes
3043  *
3044  * gamma_k_molar = gamma_k_molal / Xmol_solvent
3045  *
3046  * gamma_o_molar = gamma_o_molal
3047  */
3048  void s_updateIMS_lnMolalityActCoeff() const;
3049 
3050 private:
3051  //! Calculate the Pitzer portion of the activity coefficients.
3052  /**
3053  * This is the main routine in the whole module. It calculates the
3054  * molality based activity coefficients for the solutes, and
3055  * the activity of water.
3056  */
3057  void s_updatePitzer_lnMolalityActCoeff() const;
3058 
3059  //! Calculates the temperature derivative of the
3060  //! natural logarithm of the molality activity coefficients.
3061  /*!
3062  * Public function makes sure that all dependent data is
3063  * up to date, before calling a private function
3064  */
3066 
3067  /**
3068  * This function calculates the temperature second derivative of the
3069  * natural logarithm of the molality activity coefficients.
3070  *
3071  * It is assumed that the Pitzer activity coefficient and first derivative
3072  * routine are called immediately preceding the call to this routine.
3073  */
3075 
3076  //! Calculates the Pressure derivative of the
3077  //! natural logarithm of the molality activity coefficients.
3078  /*!
3079  * It is assumed that the Pitzer activity coefficient and first derivative
3080  * routine are called immediately preceding the calling of this routine.
3081  */
3083 
3084  //! Calculates the Pitzer coefficients' dependence on the temperature.
3085  /*!
3086  * It will also calculate the temperature
3087  * derivatives of the coefficients, as they are important
3088  * in the calculation of the latent heats and the
3089  * heat capacities of the mixtures.
3090  *
3091  * @param doDerivs If >= 1, then the routine will calculate
3092  * the first derivative. If >= 2, the
3093  * routine will calculate the first and second
3094  * temperature derivative.
3095  * default = 2
3096  */
3097  void s_updatePitzer_CoeffWRTemp(int doDerivs = 2) const;
3098 
3099  //! Calculate the lambda interactions.
3100  /*!
3101  *
3102  * Calculate E-lambda terms for charge combinations of like sign, using
3103  * method of Pitzer (1975). This implementation is based on Bethke,
3104  * Appendix 2.
3105  *
3106  * @param is Ionic strength
3107  */
3108  void calc_lambdas(double is) const;
3109  mutable doublereal m_last_is;
3110 
3111  /**
3112  * Calculate etheta and etheta_prime
3113  *
3114  * This interaction accounts for the mixing effects of like-signed ions
3115  * with different charges. This interaction will be nonzero for species
3116  * with the same charge. this routine is not to be called for neutral
3117  * species; it core dumps or error exits.
3118  *
3119  * MEC implementation routine.
3120  *
3121  * @param z1 charge of the first molecule
3122  * @param z2 charge of the second molecule
3123  * @param etheta return pointer containing etheta
3124  * @param etheta_prime Return pointer containing etheta_prime.
3125  *
3126  * This routine uses the internal variables,
3127  * elambda[] and elambda1[].
3128  *
3129  * There is no prohibition against calling
3130  *
3131  */
3132  void calc_thetas(int z1, int z2,
3133  double* etheta, double* etheta_prime) const;
3134 
3135  //! Set up a counter variable for keeping track of symmetric binary
3136  //! interactions amongst the solute species.
3137  /*!
3138  * The purpose of this is to squeeze the ij parameters into a
3139  * compressed single counter.
3140  *
3141  * n = m_kk*i + j
3142  * m_Counter[n] = counter
3143  */
3144  void counterIJ_setup() const;
3145 
3146  //! Calculate the cropped molalities
3147  /*!
3148  * This is an internal routine that calculates values
3149  * of m_molalitiesCropped from m_molalities
3150  */
3151  void calcMolalitiesCropped() const;
3152 
3153  //! Process an XML node called "binarySaltParameters"
3154  /*!
3155  * This node contains all of the parameters necessary to describe
3156  * the Pitzer model for that particular binary salt.
3157  * This function reads the XML file and writes the coefficients
3158  * it finds to an internal data structures.
3159  *
3160  * @param BinSalt reference to the XML_Node named binarySaltParameters
3161  * containing the
3162  * anion - cation interaction
3163  */
3164  void readXMLBinarySalt(XML_Node& BinSalt);
3165 
3166  //! Process an XML node called "thetaAnion"
3167  /*!
3168  * This node contains all of the parameters necessary to describe
3169  * the binary interactions between two anions.
3170  *
3171  * @param BinSalt reference to the XML_Node named thetaAnion
3172  * containing the
3173  * anion - anion interaction
3174  */
3175  void readXMLThetaAnion(XML_Node& BinSalt);
3176 
3177  //! Process an XML node called "thetaCation"
3178  /*!
3179  * This node contains all of the parameters necessary to describe
3180  * the binary interactions between two cations.
3181  *
3182  * @param BinSalt reference to the XML_Node named thetaCation
3183  * containing the
3184  * cation - cation interaction
3185  */
3186  void readXMLThetaCation(XML_Node& BinSalt);
3187 
3188  //! Process an XML node called "psiCommonAnion"
3189  /*!
3190  * This node contains all of the parameters necessary to describe
3191  * the ternary interactions between one anion and two cations.
3192  *
3193  * @param BinSalt reference to the XML_Node named psiCommonAnion
3194  * containing the
3195  * anion - cation1 - cation2 interaction
3196  */
3197  void readXMLPsiCommonAnion(XML_Node& BinSalt);
3198 
3199  //! Process an XML node called "psiCommonCation"
3200  /*!
3201  * This node contains all of the parameters necessary to describe
3202  * the ternary interactions between one cation and two anions.
3203  *
3204  * @param BinSalt reference to the XML_Node named psiCommonCation
3205  * containing the
3206  * cation - anion1 - anion2 interaction
3207  */
3208  void readXMLPsiCommonCation(XML_Node& BinSalt);
3209 
3210  //! Process an XML node called "lambdaNeutral"
3211  /*!
3212  * This node contains all of the parameters necessary to describe
3213  * the binary interactions between one neutral species and
3214  * any other species (neutral or otherwise) in the mechanism.
3215  *
3216  * @param BinSalt reference to the XML_Node named lambdaNeutral
3217  * containing multiple
3218  * Neutral - species interactions
3219  */
3220  void readXMLLambdaNeutral(XML_Node& BinSalt);
3221 
3222  //! Process an XML node called "MunnnNeutral"
3223  /*!
3224  * This node contains all of the parameters necessary to describe
3225  * the self-ternary interactions for one neutral species.
3226  *
3227  * @param BinSalt reference to the XML_Node named Munnn
3228  * containing the self-ternary interaction
3229  */
3230  void readXMLMunnnNeutral(XML_Node& BinSalt);
3231 
3232  //! Process an XML node called "zetaCation"
3233  /*!
3234  * This node contains all of the parameters necessary to describe
3235  * the ternary interactions between one neutral, one cation, and one anion.
3236  *
3237  * @param BinSalt reference to the XML_Node named psiCommonCation
3238  * containing the
3239  * neutral - cation - anion interaction
3240  */
3241  void readXMLZetaCation(const XML_Node& BinSalt);
3242 
3243  //! Process an XML node called "croppingCoefficients"
3244  //! for the cropping coefficients values
3245  /*!
3246  * @param acNode Activity Coefficient XML Node
3247  */
3248  void readXMLCroppingCoefficients(const XML_Node& acNode);
3249 
3250  //! Precalculate the IMS Cutoff parameters for typeCutoff = 2
3251  void calcIMSCutoffParams_();
3252 
3253  //! Calculate molality cut-off parameters
3254  void calcMCCutoffParams_();
3255 
3256  //! Utility function to assign an integer value from a string
3257  //! for the ElectrolyteSpeciesType field.
3258  /*!
3259  * @param estString string name of the electrolyte species type
3260  */
3261  static int interp_est(const std::string& estString);
3262 
3263 public:
3264  /*!
3265  * Turn on copious debug printing when this
3266  * is true and DEBUG_MODE is turned on.
3267  */
3268  mutable int m_debugCalc;
3269 
3270  //! Return int specifying the amount of debug printing
3271  /*!
3272  * This will return 0 if DEBUG_MODE is not turned on
3273  */
3274  int debugPrinting();
3275 };
3276 
3277 }
3278 
3279 #endif
vector_fp m_Theta_ij_P
Derivative of Theta_ij[i][j] wrt P.
Definition: HMWSoln.h:2491
vector_fp m_BMX_IJ_L
Derivative of BMX_IJ wrt T.
Definition: HMWSoln.h:2763
vector_fp m_PhiPhi_IJ_P
Derivative of m_PhiPhi_IJ wrt P.
Definition: HMWSoln.h:2877
void s_updateIMS_lnMolalityActCoeff() const
This function will be called to update the internally stored natural logarithm of the molality activi...
Definition: HMWSoln.cpp:4968
vector_fp m_CphiMX_ij_LL
Derivative of Cphi_ij[i][j] wrt TT.
Definition: HMWSoln.h:2444
void s_update_dlnMolalityActCoeff_dP() const
This function calculates the pressure derivative of the natural logarithm of the molality activity co...
Definition: HMWSoln.cpp:4109
virtual doublereal pressure() const
Pressure.
Definition: HMWSoln.cpp:517
vector_fp m_Theta_ij_L
Derivative of Theta_ij[i][j] wrt T.
Definition: HMWSoln.h:2479
vector_fp m_speciesCharge_Stoich
Stoichiometric species charge -> This is for calculations of the ionic strength which ignore ion-ion ...
Definition: HMWSoln.h:2283
void readXMLBinarySalt(XML_Node &BinSalt)
Process an XML node called "binarySaltParameters".
WaterProps * m_waterProps
Pointer to the water property calculator.
Definition: HMWSoln.h:2263
vector_fp m_CMX_IJ_P
Derivative of m_CMX_IJ wrt P.
Definition: HMWSoln.h:2901
vector_fp m_gfunc_IJ
Various temporary arrays used in the calculation of the Pitzer activity coefficients.
Definition: HMWSoln.h:2730
vector_fp m_Beta2MX_ij_L
Derivative of Beta2_ij[i][j] wrt T.
Definition: HMWSoln.h:2375
vector_fp m_d2lnActCoeffMolaldT2_Unscaled
Derivative of the Logarithm of the activity coefficients on the molality scale wrt TT...
Definition: HMWSoln.h:2678
doublereal s_NBS_CLM_lnMolalityActCoeff() const
Calculate the Chlorine activity coefficient on the NBS scale.
Definition: HMWSoln.cpp:5208
doublereal MC_X_o_cutoff_
value of the solvent mole fraction that centers the cutoff polynomials for the cutoff =1 process; ...
Definition: HMWSoln.h:2959
vector_fp IMS_lnActCoeffMolal_
Logarithm of the molal activity coefficients.
Definition: HMWSoln.h:2913
Array2D m_Lambda_nj_coeff
Array of coefficients for Lambda_nj[i][j] in the Pitzer/HMW formulation.
Definition: HMWSoln.h:2591
An error indicating that an unimplemented function has been called.
Definition: ctexceptions.h:213
double m_maxIionicStrength
Maximum value of the ionic strength allowed in the calculation of the activity coefficients.
Definition: HMWSoln.h:2184
void readXMLLambdaNeutral(XML_Node &BinSalt)
Process an XML node called "lambdaNeutral".
void readXMLThetaAnion(XML_Node &BinSalt)
Process an XML node called "thetaAnion".
vector_fp m_Beta1MX_ij_LL
Derivative of Beta1_ij[i][j] wrt TT.
Definition: HMWSoln.h:2343
vector_fp m_Mu_nnn_L
Mu coefficient temperature derivative for the self-ternary neutral coefficient.
Definition: HMWSoln.h:2609
virtual doublereal cv_mole() const
Molar heat capacity at constant volume. Units: J/kmol/K.
Definition: HMWSoln.cpp:503
vector_fp m_dlnActCoeffMolaldP_Unscaled
Derivative of the Logarithm of the activity coefficients on the molality scale wrt P...
Definition: HMWSoln.h:2692
Array2D m_Beta0MX_ij_coeff
Array of coefficients for Beta0, a variable in Pitzer's papers.
Definition: HMWSoln.h:2320
double ADebye_J(double temperature=-1.0, double pressure=-1.0) const
Return Pitzer's definition of A_J.
Definition: HMWSoln.cpp:958
vector_fp m_Beta2MX_ij_P
Derivative of Beta2_ij[i][j] wrt P.
Definition: HMWSoln.h:2387
virtual void getPartialMolarCp(doublereal *cpbar) const
Return an array of partial molar heat capacities for the species in the mixture.
Definition: HMWSoln.cpp:806
vector_fp m_Beta2MX_ij
Array of 2D data used in the Pitzer/HMW formulation.
Definition: HMWSoln.h:2369
Array2D m_Lambda_nj_P
Derivative of Lambda_nj[i][j] wrt P.
Definition: HMWSoln.h:2573
void readXMLMunnnNeutral(XML_Node &BinSalt)
Process an XML node called "MunnnNeutral".
vector_fp m_PhiPhi_IJ
Intermediate variable called PhiPhi in Pitzer's paper.
Definition: HMWSoln.h:2859
vector_fp m_Phi_IJ_L
Derivative of m_Phi_IJ wrt T.
Definition: HMWSoln.h:2835
int IMS_typeCutoff_
IMS Cutoff type.
Definition: HMWSoln.h:2916
vector_fp m_dlnActCoeffMolaldT_Scaled
Derivative of the Logarithm of the activity coefficients on the molality scale wrt T...
Definition: HMWSoln.h:2657
void setMolarDensity(const doublereal conc)
Set the internally stored molar density (kmol/m^3) for the phase.
Definition: HMWSoln.cpp:562
vector_fp m_BMX_IJ_P
Derivative of BMX_IJ wrt P.
Definition: HMWSoln.h:2775
vector_fp m_Beta0MX_ij_L
Derivative of Beta0_ij[i][j] wrt T.
Definition: HMWSoln.h:2300
double elambda[17]
This is elambda, MEC.
Definition: HMWSoln.h:2714
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:100
vector_fp m_dlnActCoeffMolaldP_Scaled
Derivative of the Logarithm of the activity coefficients on the molality scale wrt P...
Definition: HMWSoln.h:2685
int debugPrinting()
Return int specifying the amount of debug printing.
Definition: HMWSoln.cpp:5237
vector_fp m_Mu_nnn_P
Mu coefficient pressure derivative for the self-ternary neutral coefficient.
Definition: HMWSoln.h:2627
void readXMLPsiCommonAnion(XML_Node &BinSalt)
Process an XML node called "psiCommonAnion".
void s_updateScaling_pHScaling() const
Apply the current phScale to a set of activity Coefficients.
Definition: HMWSoln.cpp:5148
virtual void updateStandardStateThermo() const
Updates the standard state thermodynamic functions at the current T and P of the solution.
Array2D m_Lambda_nj_L
Derivative of Lambda_nj[i][j] wrt T. see m_Lambda_ij.
Definition: HMWSoln.h:2567
void setDensity(const doublereal rho)
Set the internally stored density (kg/m^3) of the phase.
Definition: HMWSoln.cpp:552
vector_fp m_BprimeMX_IJ_P
Derivative of BprimeMX wrt P.
Definition: HMWSoln.h:2799
void calcMCCutoffParams_()
Calculate molality cut-off parameters.
double AionicRadius(int k=0) const
Reports the ionic radius of the kth species.
Definition: HMWSoln.cpp:997
vector_fp m_CphiMX_ij_P
Derivative of Cphi_ij[i][j] wrt P.
Definition: HMWSoln.h:2450
doublereal s_NBS_CLM_d2lnMolalityActCoeff_dT2() const
Calculate the second temperature derivative of the Chlorine activity coefficient on the NBS scale...
Definition: HMWSoln.cpp:5223
virtual doublereal relative_enthalpy() const
Excess molar enthalpy of the solution from the mixing process.
Definition: HMWSoln.cpp:432
void calcIMSCutoffParams_()
Precalculate the IMS Cutoff parameters for typeCutoff = 2.
vector_fp m_Psi_ijk_L
Derivative of Psi_ijk[n] wrt T.
Definition: HMWSoln.h:2524
void readXMLZetaCation(const XML_Node &BinSalt)
Process an XML node called "zetaCation".
void s_update_d2lnMolalityActCoeff_dT2() const
This function calculates the temperature second derivative of the natural logarithm of the molality a...
Definition: HMWSoln.cpp:3338
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id)
Initialize the phase parameters from an XML file.
vector_fp m_lnActCoeffMolal_Unscaled
Logarithm of the activity coefficients on the molality scale.
Definition: HMWSoln.h:2650
vector_fp m_Theta_ij
Array of 2D data for Theta_ij[i][j] in the Pitzer/HMW formulation.
Definition: HMWSoln.h:2473
vector_fp m_hfunc_IJ
hfunc, was called gprime in Pitzer's paper.
Definition: HMWSoln.h:2743
double elambda1[17]
This is elambda1, MEC.
Definition: HMWSoln.h:2717
virtual doublereal relative_molal_enthalpy() const
Excess molar enthalpy of the solution from the mixing process on a molality basis.
Definition: HMWSoln.cpp:445
vector_fp m_Beta1MX_ij_P
Derivative of Beta1_ij[i][j] wrt P.
Definition: HMWSoln.h:2349
vector_fp m_BprimeMX_IJ_LL
Derivative of BprimeMX wrt TT.
Definition: HMWSoln.h:2793
vector_fp m_PhiPhi_IJ_LL
Derivative of m_PhiPhi_IJ wrt TT.
Definition: HMWSoln.h:2871
ThermoPhase * duplMyselfAsThermoPhase() const
Duplicator from the ThermoPhase parent class.
Definition: HMWSoln.cpp:398
void readXMLPsiCommonCation(XML_Node &BinSalt)
Process an XML node called "psiCommonCation".
doublereal IMS_cCut_
Parameter in the polyExp cutoff treatment having to do with rate of exp decay.
Definition: HMWSoln.h:2929
virtual void setTemperature(const doublereal temp)
Set the temperature (K)
Definition: HMWSoln.cpp:568
vector_fp m_Psi_ijk_LL
Derivative of Psi_ijk[n] wrt TT.
Definition: HMWSoln.h:2530
double m_IionicMolality
Current value of the ionic strength on the molality scale Associated Salts, if present in the mechani...
Definition: HMWSoln.h:2178
vector_fp m_Phi_IJ
Intermediate variable called Phi in Pitzer's paper.
Definition: HMWSoln.h:2829
vector_fp m_BphiMX_IJ
Intermediate variable called BphiMX in Pitzer's paper.
Definition: HMWSoln.h:2805
Array2D m_CphiMX_ij_coeff
Array of coefficients for CphiMX, a parameter in the activity coefficient formulation.
Definition: HMWSoln.h:2459
vector_fp m_Beta1MX_ij
Definition: HMWSoln.h:2331
void s_updateScaling_pHScaling_dP() const
Apply the current phScale to a set of derivatives of the activity Coefficients wrt pressure...
Definition: HMWSoln.cpp:5193
vector_fp m_tmpV
vector of size m_kk, used as a temporary holding area.
Definition: HMWSoln.h:2269
virtual doublereal standardConcentration(size_t k=0) const
Return the standard concentration for the kth species.
Definition: HMWSoln.cpp:617
int formPitzer() const
formPitzer():
Definition: HMWSoln.h:2022
A class for 2D arrays stored in column-major (Fortran-compatible) form.
Definition: Array.h:29
Header for intermediate ThermoPhase object for phases which employ molality based activity coefficien...
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:97
void getUnscaledMolalityActivityCoefficients(doublereal *acMolality) const
Get the array of unscaled non-dimensional molality based activity coefficients at the current solutio...
Definition: HMWSoln.cpp:674
HMWSoln()
Default Constructor.
Definition: HMWSoln.cpp:31
vector_fp m_lnActCoeffMolal_Scaled
Logarithm of the activity coefficients on the molality scale.
Definition: HMWSoln.h:2640
Header file for class Cantera::Array2D.
virtual void getActivities(doublereal *ac) const
Get the array of non-dimensional activities at the current solution temperature, pressure, and solution concentration.
Definition: HMWSoln.cpp:653
std::vector< int > vector_int
Vector of ints.
Definition: ct_defs.h:159
doublereal MC_X_o_min_
gamma_o value for the cutoff process at the zero solvent point
Definition: HMWSoln.h:2962
vector_fp m_Phi_IJ_P
Derivative of m_Phi_IJ wrt P.
Definition: HMWSoln.h:2847
PDSS * m_waterSS
Water standard state calculator.
Definition: HMWSoln.h:2254
vector_fp m_Alpha1MX_ij
Array of 2D data used in the Pitzer/HMW formulation.
Definition: HMWSoln.h:2408
virtual void setPressure(doublereal p)
Set the internally stored pressure (Pa) at constant temperature and composition.
Definition: HMWSoln.cpp:522
vector_fp m_Phiprime_IJ
Intermediate variable called Phiprime in Pitzer's paper.
Definition: HMWSoln.h:2853
virtual void getPartialMolarEntropies(doublereal *sbar) const
Returns an array of partial molar entropies of the species in the solution.
Definition: HMWSoln.cpp:743
vector_fp m_h2func_IJ
hfunc2, was called gprime in Pitzer's paper.
Definition: HMWSoln.h:2750
void readXMLCroppingCoefficients(const XML_Node &acNode)
Process an XML node called "croppingCoefficients" for the cropping coefficients values.
vector_fp m_Psi_ijk_P
Derivative of Psi_ijk[n] wrt P.
Definition: HMWSoln.h:2536
void counterIJ_setup() const
Set up a counter variable for keeping track of symmetric binary interactions amongst the solute speci...
Definition: HMWSoln.cpp:1381
vector_fp m_CMX_IJ_L
Derivative of m_CMX_IJ wrt T.
Definition: HMWSoln.h:2889
virtual void getPartialMolarVolumes(doublereal *vbar) const
Return an array of partial molar volumes for the species in the mixture.
Definition: HMWSoln.cpp:788
bool m_molalitiesAreCropped
Boolean indicating whether the molalities are cropped or are modified.
Definition: HMWSoln.h:2703
vector_fp m_dlnActCoeffMolaldT_Unscaled
Derivative of the Logarithm of the activity coefficients on the molality scale wrt T...
Definition: HMWSoln.h:2664
Array2D m_Psi_ijk_coeff
Array of coefficients for Psi_ijk[n] in the Pitzer/HMW formulation.
Definition: HMWSoln.h:2553
void s_updateScaling_pHScaling_dT() const
Apply the current phScale to a set of derivatives of the activity Coefficients wrt temperature...
Definition: HMWSoln.cpp:5163
void s_updatePitzer_dlnMolalityActCoeff_dT() const
Calculates the temperature derivative of the natural logarithm of the molality activity coefficients...
Definition: HMWSoln.cpp:2596
virtual void initThermo()
Internal initialization required after all species have been added.
vector_fp m_Mu_nnn
Mu coefficient for the self-ternary neutral coefficient.
Definition: HMWSoln.h:2600
vector_fp m_molalitiesCropped
Cropped and modified values of the molalities used in activity coefficient calculations.
Definition: HMWSoln.h:2700
The WaterProps class is used to house several approximation routines for properties of water...
Definition: WaterProps.h:96
vector_fp m_Beta2MX_ij_LL
Derivative of Beta2_ij[i][j] wrt TT.
Definition: HMWSoln.h:2381
vector_fp m_CMX_IJ_LL
Derivative of m_CMX_IJ wrt TT.
Definition: HMWSoln.h:2895
virtual void getUnitsStandardConc(double *uA, int k=0, int sizeUA=6) const
Returns the units of the standard and generalized concentrations.
Definition: HMWSoln.cpp:627
Array2D m_Beta2MX_ij_coeff
Array of coefficients for Beta2, a variable in Pitzer's papers.
Definition: HMWSoln.h:2397
Array2D m_Lambda_nj_LL
Derivative of Lambda_nj[i][j] wrt TT.
Definition: HMWSoln.h:2570
void s_updatePitzer_lnMolalityActCoeff() const
Calculate the Pitzer portion of the activity coefficients.
Definition: HMWSoln.cpp:1678
double ADebye_V(double temperature=-1.0, double pressure=-1.0) const
Return Pitzer's definition of A_V.
Definition: HMWSoln.cpp:947
doublereal IMS_slopegCut_
Parameter in the polyExp cutoff treatment.
Definition: HMWSoln.h:2943
doublereal IMS_slopefCut_
Parameter in the polyExp cutoff treatment.
Definition: HMWSoln.h:2936
vector_fp m_Beta0MX_ij_LL
Derivative of Beta0_ij[i][j] wrt TT.
Definition: HMWSoln.h:2306
int m_form_A_Debye
Form of the constant outside the Debye-Huckel term called A.
Definition: HMWSoln.h:2214
virtual doublereal entropy_mole() const
Molar entropy. Units: J/kmol/K.
Definition: HMWSoln.cpp:485
void s_update_dlnMolalityActCoeff_dT() const
This function calculates the temperature derivative of the natural logarithm of the molality activity...
Definition: HMWSoln.cpp:2561
void s_updatePitzer_dlnMolalityActCoeff_dP() const
Calculates the Pressure derivative of the natural logarithm of the molality activity coefficients...
Definition: HMWSoln.cpp:4133
vector_int m_CounterIJ
a counter variable for keeping track of symmetric binary interactions amongst the solute species...
Definition: HMWSoln.h:2711
doublereal MC_slopepCut_
Parameter in the Molality Exp cutoff treatment.
Definition: HMWSoln.h:2969
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:5178
vector_fp m_CMX_IJ
Intermediate variable called CMX in Pitzer's paper.
Definition: HMWSoln.h:2883
virtual doublereal enthalpy_mole() const
Molar enthalpy. Units: J/kmol.
Definition: HMWSoln.cpp:425
double m_TempPitzerRef
Reference Temperature for the Pitzer formulations.
Definition: HMWSoln.h:2187
vector_fp m_CphiMX_ij_L
Derivative of Cphi_ij[i][j] wrt T.
Definition: HMWSoln.h:2438
void calc_lambdas(double is) const
Calculate the lambda interactions.
Definition: HMWSoln.cpp:4876
static int interp_est(const std::string &estString)
Utility function to assign an integer value from a string for the ElectrolyteSpeciesType field...
void constructPhaseXML(XML_Node &phaseNode, std::string id)
Import and initialize a HMWSoln phase specification in an XML tree into the current object...
void calc_thetas(int z1, int z2, double *etheta, double *etheta_prime) const
Calculate etheta and etheta_prime.
Definition: HMWSoln.cpp:4934
vector_fp m_BphiMX_IJ_L
Derivative of BphiMX_IJ wrt T.
Definition: HMWSoln.h:2811
vector_fp m_g2func_IJ
This is the value of g2(x2) in Pitzer's papers.
Definition: HMWSoln.h:2736
void constructPhaseFile(std::string inputFile, std::string id)
Import, construct, and initialize a HMWSoln phase specification from an XML tree into the current obj...
void readXMLThetaCation(XML_Node &BinSalt)
Process an XML node called "thetaCation".
double m_densWaterSS
density of standard-state water
Definition: HMWSoln.h:2260
Array2D m_Lambda_nj
Lambda coefficient for the ij interaction.
Definition: HMWSoln.h:2564
virtual ~HMWSoln()
Destructor.
Definition: HMWSoln.cpp:392
vector_fp m_Phi_IJ_LL
Derivative of m_Phi_IJ wrt TT.
Definition: HMWSoln.h:2841
int m_formPitzer
This is the form of the Pitzer parameterization used in this model.
Definition: HMWSoln.h:2111
doublereal IMS_gamma_k_min_
gamma_k minimum for the cutoff process at the zero solvent point
Definition: HMWSoln.h:2926
vector_fp m_Alpha2MX_ij
Array of 2D data used in the Pitzer/HMW formulation.
Definition: HMWSoln.h:2420
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:848
vector_int m_electrolyteSpeciesType
Vector containing the electrolyte species type.
Definition: HMWSoln.h:2164
vector_fp m_Beta0MX_ij
Array of 2D data used in the Pitzer/HMW formulation.
Definition: HMWSoln.h:2294
vector_fp m_BprimeMX_IJ_L
Derivative of BprimeMX wrt T.
Definition: HMWSoln.h:2787
doublereal IMS_gamma_o_min_
gamma_o value for the cutoff process at the zero solvent point
Definition: HMWSoln.h:2923
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:880
vector_fp m_BMX_IJ_LL
Derivative of BMX_IJ wrt TT.
Definition: HMWSoln.h:2769
doublereal temperature() const
Temperature (K).
Definition: Phase.h:602
int m_formGC
Format for the generalized concentration:
Definition: HMWSoln.h:2152
double m_A_Debye
A_Debye -> this expression appears on the top of the ln actCoeff term in the general Debye-Huckel exp...
Definition: HMWSoln.h:2248
std::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:2992
void initLengths()
Initialize all of the species-dependent lengths in the object.
Definition: HMWSoln.cpp:1006
virtual void getActivityConcentrations(doublereal *c) const
This method returns an array of generalized activity concentrations.
Definition: HMWSoln.cpp:604
doublereal s_NBS_CLM_dlnMolalityActCoeff_dT() const
Calculate the temperature derivative of the Chlorine activity coefficient on the NBS scale...
Definition: HMWSoln.cpp:5216
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:157
Virtual base class for a species with a pressure dependent standard state.
Definition: PDSS.h:193
double ADebye_L(double temperature=-1.0, double pressure=-1.0) const
Return Pitzer's definition of A_L.
Definition: HMWSoln.cpp:936
virtual doublereal gibbs_mole() const
Molar Gibbs function. Units: J/kmol.
Definition: HMWSoln.cpp:491
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:904
virtual void applyphScale(doublereal *acMolality) const
Apply the current phScale to a set of activity Coefficients or activities.
Definition: HMWSoln.cpp:5134
void calcDensity()
Calculate the density of the mixture using the partial molar volumes and mole fractions as input...
Definition: HMWSoln.cpp:527
vector_fp m_gamma_tmp
Intermediate storage of the activity coefficient itself.
Definition: HMWSoln.h:2907
virtual int eosType() const
Equation of state type flag.
Definition: HMWSoln.cpp:403
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
Definition: HMWSoln.cpp:689
doublereal IMS_X_o_cutoff_
value of the solute mole fraction that centers the cutoff polynomials for the cutoff =1 process; ...
Definition: HMWSoln.h:2920
void calcMolalitiesCropped() const
Calculate the cropped molalities.
Definition: HMWSoln.cpp:1228
vector_fp m_Psi_ijk
Array of 3D data used in the Pitzer/HMW formulation.
Definition: HMWSoln.h:2518
vector_fp m_pp
Temporary array used in equilibrium calculations.
Definition: HMWSoln.h:2266
Class HMWSoln represents a dilute or concentrated liquid electrolyte phase which obeys the Pitzer for...
Definition: HMWSoln.h:1225
vector_fp m_BMX_IJ
Intermediate variable called BMX in Pitzer's paper This is the basic cation - anion interaction...
Definition: HMWSoln.h:2757
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:970
virtual void setState_TP(doublereal t, doublereal p)
Set the temperature (K) and pressure (Pa)
Definition: HMWSoln.cpp:573
double m_IionicMolalityStoich
Stoichiometric ionic strength on the molality scale.
Definition: HMWSoln.h:2195
vector_fp m_BprimeMX_IJ
Intermediate variable called BprimeMX in Pitzer's paper.
Definition: HMWSoln.h:2781
void s_updatePitzer_CoeffWRTemp(int doDerivs=2) const
Calculates the Pitzer coefficients' dependence on the temperature.
Definition: HMWSoln.cpp:1404
virtual void setToEquilState(const doublereal *lambda_RT)
This method is used by the ChemEquil equilibrium solver.
Definition: HMWSoln.h:1823
vector_fp m_d2lnActCoeffMolaldT2_Scaled
Derivative of the Logarithm of the activity coefficients on the molality scale wrt TT...
Definition: HMWSoln.h:2671
vector_fp m_CphiMX_ij
Array of 2D data used in the Pitzer/HMW formulation.
Definition: HMWSoln.h:2432
virtual doublereal density() const
Returns the current value of the density.
Definition: HMWSoln.cpp:547
int m_formPitzerTemp
This is the form of the temperature dependence of Pitzer parameterization used in the model...
Definition: HMWSoln.h:2121
void printCoeffs() const
Print out all of the input Pitzer coefficients.
Definition: HMWSoln.cpp:5078
HMWSoln & operator=(const HMWSoln &right)
Assignment operator.
Definition: HMWSoln.cpp:234
vector_fp m_Beta1MX_ij_L
Derivative of Beta1_ij[i][j] wrt T.
Definition: HMWSoln.h:2337
vector_fp m_Theta_ij_LL
Derivative of Theta_ij[i][j] wrt TT.
Definition: HMWSoln.h:2485
void s_updatePitzer_d2lnMolalityActCoeff_dT2() const
This function calculates the temperature second derivative of the natural logarithm of the molality a...
Definition: HMWSoln.cpp:3371
Array2D m_Theta_ij_coeff
Array of coefficients for Theta_ij[i][j] in the Pitzer/HMW formulation.
Definition: HMWSoln.h:2505
virtual doublereal cp_mole() const
Molar heat capacity at constant pressure. Units: J/kmol/K.
Definition: HMWSoln.cpp:497
virtual doublereal satPressure(doublereal T)
Get the saturation pressure for a given temperature.
Definition: HMWSoln.cpp:837
Array2D m_Mu_nnn_coeff
Array of coefficients form_Mu_nnn term.
Definition: HMWSoln.h:2630
doublereal s_NBS_CLM_dlnMolalityActCoeff_dP() const
Calculate the pressure derivative of the Chlorine activity coefficient.
Definition: HMWSoln.cpp:5230
vector_fp m_Mu_nnn_LL
Mu coefficient 2nd temperature derivative for the self-ternary neutral coefficient.
Definition: HMWSoln.h:2618
vector_fp m_Aionic
a_k = Size of the ionic species in the DH formulation units = meters
Definition: HMWSoln.h:2170
vector_fp m_BphiMX_IJ_P
Derivative of BphiMX_IJ wrt P.
Definition: HMWSoln.h:2823
Array2D m_Beta1MX_ij_coeff
Array of coefficients for Beta1, a variable in Pitzer's papers.
Definition: HMWSoln.h:2357
vector_fp m_PhiPhi_IJ_L
Derivative of m_PhiPhi_IJ wrt T.
Definition: HMWSoln.h:2865
virtual void getPartialMolarEnthalpies(doublereal *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.
Definition: HMWSoln.cpp:717
vector_fp m_Beta0MX_ij_P
Derivative of Beta0_ij[i][j] wrt P.
Definition: HMWSoln.h:2312
vector_fp m_BphiMX_IJ_LL
Derivative of BphiMX_IJ wrt TT.
Definition: HMWSoln.h:2817