Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DebyeHuckel.h
Go to the documentation of this file.
1 /**
2  * @file DebyeHuckel.h
3  * Headers for the DebyeHuckel ThermoPhase object, which models dilute
4  * electrolyte solutions
5  * (see \ref thermoprops and \link Cantera::DebyeHuckel DebyeHuckel \endlink) .
6  *
7  * Class DebyeHuckel represents a dilute liquid electrolyte phase which
8  * obeys the Debye Huckel formulation for nonideality.
9  */
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_DEBYEHUCKEL_H
17 #define CT_DEBYEHUCKEL_H
18 
19 #include "MolalityVPSSTP.h"
20 #include "cantera/base/Array.h"
21 
22 namespace Cantera
23 {
24 
25 /*!
26  * @name Formats for the Activity Coefficients
27  *
28  * These are possible formats for the molality-based activity coefficients.
29  */
30 //@{
31 #define DHFORM_DILUTE_LIMIT 0
32 #define DHFORM_BDOT_AK 1
33 #define DHFORM_BDOT_ACOMMON 2
34 #define DHFORM_BETAIJ 3
35 #define DHFORM_PITZER_BETAIJ 4
36 //@}
37 /*
38  * @name Acceptable ways to calculate the value of A_Debye
39  */
40 //@{
41 #define A_DEBYE_CONST 0
42 #define A_DEBYE_WATER 1
43 //@}
44 
45 class WaterProps;
46 class PDSS_Water;
47 
48 /**
49  * @ingroup thermoprops
50  *
51  * Class DebyeHuckel represents a dilute liquid electrolyte phase which
52  * obeys the Debye Huckel formulation for nonideality.
53  *
54  * The concentrations of the ionic species are assumed to obey the electroneutrality
55  * condition.
56  *
57  * <HR>
58  * <H2> Specification of Species Standard State Properties </H2>
59  * <HR>
60  *
61  * The standard states are on the unit molality basis. Therefore, in the
62  * documentation below, the normal \f$ o \f$ superscript is replaced with
63  * the \f$ \triangle \f$ symbol. The reference state symbol is now
64  * \f$ \triangle, ref \f$.
65  *
66  *
67  * It is assumed that the reference state thermodynamics may be
68  * obtained by a pointer to a populated species thermodynamic property
69  * manager class (see ThermoPhase::m_spthermo). How to relate pressure
70  * changes to the reference state thermodynamics is resolved at this level.
71  *
72  * For an incompressible,
73  * stoichiometric substance, the molar internal energy is
74  * independent of pressure. Since the thermodynamic properties
75  * are specified by giving the standard-state enthalpy, the
76  * term \f$ P_0 \hat v\f$ is subtracted from the specified molar
77  * enthalpy to compute the molar internal energy. The entropy is
78  * assumed to be independent of the pressure.
79  *
80  * The enthalpy function is given by the following relation.
81  *
82  * \f[
83  * h^\triangle_k(T,P) = h^{\triangle,ref}_k(T)
84  * + \tilde v \left( P - P_{ref} \right)
85  * \f]
86  *
87  * For an incompressible,
88  * stoichiometric substance, the molar internal energy is
89  * independent of pressure. Since the thermodynamic properties
90  * are specified by giving the standard-state enthalpy, the
91  * term \f$ P_{ref} \tilde v\f$ is subtracted from the specified reference molar
92  * enthalpy to compute the molar internal energy.
93  *
94  * \f[
95  * u^\triangle_k(T,P) = h^{\triangle,ref}_k(T) - P_{ref} \tilde v
96  * \f]
97  *
98  * The standard state heat capacity and entropy are independent
99  * of pressure. The standard state Gibbs free energy is obtained
100  * from the enthalpy and entropy functions.
101  *
102  * The vector Phase::m_speciesSize[] is used to hold the
103  * base values of species sizes. These are defined as the
104  * molar volumes of species at infinite dilution at 300 K and 1 atm
105  * of water. m_speciesSize are calculated during the initialization of the
106  * DebyeHuckel object and are then not touched.
107  *
108  * The current model assumes that an incompressible molar volume for
109  * all solutes. The molar volume for the water solvent, however,
110  * is obtained from a pure water equation of state, waterSS.
111  * Therefore, the water standard state varies with both T and P.
112  * It is an error to request standard state water properties at a T and P
113  * where the water phase is not a stable phase, i.e., beyond its
114  * spinodal curve.
115  *
116  * <HR>
117  * <H2> Specification of Solution Thermodynamic Properties </H2>
118  * <HR>
119  *
120  * Chemical potentials
121  * of the solutes, \f$ \mu_k \f$, and the solvent, \f$ \mu_o \f$, which are based
122  * on the molality form, have the following general format:
123  *
124  * \f[
125  * \mu_k = \mu^{\triangle}_k(T,P) + R T ln(\gamma_k^{\triangle} \frac{m_k}{m^\triangle})
126  * \f]
127  * \f[
128  * \mu_o = \mu^o_o(T,P) + RT ln(a_o)
129  * \f]
130  *
131  * where \f$ \gamma_k^{\triangle} \f$ is the molality based activity coefficient for species
132  * \f$k\f$.
133  *
134  * Individual activity coefficients of ions can not be independently measured. Instead,
135  * only binary pairs forming electroneutral solutions can be measured.
136 
137  *
138  * <H3> Ionic Strength </H3>
139  *
140  * Most of the parameterizations within the model use the ionic strength
141  * as a key variable. The ionic strength, \f$ I\f$ is defined as follows
142  *
143  * \f[
144  * I = \frac{1}{2} \sum_k{m_k z_k^2}
145  * \f]
146  *
147  * \f$ m_k \f$ is the molality of the kth species. \f$ z_k \f$ is the charge
148  * of the kth species. Note, the ionic strength is a defined units quantity.
149  * The molality has defined units of gmol kg-1, and therefore the ionic
150  * strength has units of sqrt( gmol kg-1).
151  *
152  * In some instances, from some authors, a different
153  * formulation is used for the ionic strength in the equations below. The different
154  * formulation is due to the possibility of the existence of weak acids and how
155  * association wrt to the weak acid equilibrium relation affects the calculation
156  * of the activity coefficients via the assumed value of the ionic strength.
157  *
158  * If we are to assume that the association reaction doesn't have an effect
159  * on the ionic strength, then we will want to consider the associated weak
160  * acid as in effect being fully dissociated, when we calculate an effective
161  * value for the ionic strength. We will call this calculated value, the
162  * stoichiometric ionic strength, \f$ I_s \f$, putting a subscript s to denote
163  * it from the more straightforward calculation of \f$ I \f$.
164  *
165  * \f[
166  * I_s = \frac{1}{2} \sum_k{m_k^s z_k^2}
167  * \f]
168  *
169  * Here, \f$ m_k^s \f$ is the value of the molalities calculated assuming that
170  * all weak acid-base pairs are in their fully dissociated states. This calculation may
171  * be simplified by considering that the weakly associated acid may be made up of two
172  * charged species, k1 and k2, each with their own charges, obeying the following relationship:
173  *
174  * \f[
175  * z_k = z_{k1} + z_{k2}
176  * \f]
177  * Then, we may only need to specify one charge value, say, \f$ z_{k1}\f$,
178  * the cation charge number,
179  * in order to get both numbers, since we have already specified \f$ z_k \f$
180  * in the definition of original species.
181  * Then, the stoichiometric ionic strength may be calculated via the following formula.
182  *
183  * \f[
184  * I_s = \frac{1}{2} \left(\sum_{k,ions}{m_k z_k^2}+
185  * \sum_{k,weak_assoc}(m_k z_{k1}^2 + m_k z_{k2}^2) \right)
186  * \f]
187  *
188  * The specification of which species are weakly associated acids is made in the input
189  * file via the
190  * <TT> stoichIsMods </TT> XML block, where the charge for k1 is also specified.
191  * An example is given below:
192  *
193  * @code
194  * <stoichIsMods>
195  * NaCl(aq):-1.0
196  * </stoichIsMods>
197  * @endcode
198  *
199  * Because we need the concept of a weakly associated acid in order to calculated
200  * \f$ I_s \f$ we need to
201  * catalog all species in the phase. This is done using the following categories:
202  *
203  * - <B>cEST_solvent</B> Solvent species (neutral)
204  * - <B>cEST_chargedSpecies</B> Charged species (charged)
205  * - <B>cEST_weakAcidAssociated</B> Species which can break apart into charged species.
206  * It may or may not be charged. These may or
207  * may not be be included in the
208  * species solution vector.
209  * - <B>cEST_strongAcidAssociated</B> Species which always breaks apart into charged species.
210  * It may or may not be charged. Normally, these aren't included
211  * in the speciation vector.
212  * - <B>cEST_polarNeutral </B> Polar neutral species
213  * - <B>cEST_nonpolarNeutral</B> Non polar neutral species
214  *
215  * Polar and non-polar neutral species are differentiated, because some additions
216  * to the activity
217  * coefficient expressions distinguish between these two types of solutes. This is the so-called
218  * salt-out effect.
219  *
220  * The type of species is specified in the <TT>electrolyteSpeciesType</TT> XML block.
221  * Note, this is not
222  * considered a part of the specification of the standard state for the species,
223  * at this time. Therefore,
224  * this information is put under the <TT>activityCoefficient</TT> XML block. An example
225  * is given below
226  *
227  * @code
228  * <electrolyteSpeciesType>
229  * H2L(L):solvent
230  * H+:chargedSpecies
231  * NaOH(aq):weakAcidAssociated
232  * NaCl(aq):strongAcidAssociated
233  * NH3(aq):polarNeutral
234  * O2(aq):nonpolarNeutral
235  * </electrolyteSpeciesType>
236  * @endcode
237  *
238  * Much of the species electrolyte type information is inferred from other information in the
239  * input file. For example, as species which is charged is given the "chargedSpecies" default
240  * category. A neutral solute species is put into the "nonpolarNeutral" category by default.
241  *
242  * The specification of solute activity coefficients depends on the model
243  * assumed for the Debye-Huckel term. The model is set by the
244  * internal parameter #m_formDH. We will now describe each category in its own section.
245  *
246  *
247  * <H3> Debye-Huckel Dilute Limit </H3>
248  *
249  * DHFORM_DILUTE_LIMIT = 0
250  *
251  * This form assumes a dilute limit to DH, and is mainly for informational purposes:
252  * \f[
253  * \ln(\gamma_k^\triangle) = - z_k^2 A_{Debye} \sqrt{I}
254  * \f]
255  * where \f$ I\f$ is the ionic strength
256  * \f[
257  * I = \frac{1}{2} \sum_k{m_k z_k^2}
258  * \f]
259  *
260  * The activity for the solvent water,\f$ a_o \f$, is not independent and must be
261  * determined from the Gibbs-Duhem relation.
262  *
263  * \f[
264  * \ln(a_o) = \frac{X_o - 1.0}{X_o} + \frac{ 2 A_{Debye} \tilde{M}_o}{3} (I)^{3/2}
265  * \f]
266  *
267  *
268  * <H3> Bdot Formulation </H3>
269  *
270  * DHFORM_BDOT_AK = 1
271  *
272  * This form assumes Bethke's format for the Debye Huckel activity coefficient:
273  *
274  * \f[
275  * \ln(\gamma_k^\triangle) = -z_k^2 \frac{A_{Debye} \sqrt{I}}{ 1 + B_{Debye} a_k \sqrt{I}}
276  * + \log(10) B^{dot}_k I
277  * \f]
278  *
279  * Note, this particular form where \f$ a_k \f$ can differ in multielectrolyte
280  * solutions has problems with respect to a Gibbs-Duhem analysis. However,
281  * we include it here because there is a lot of data fit to it.
282  *
283  * The activity for the solvent water,\f$ a_o \f$, is not independent and must be
284  * determined from the Gibbs-Duhem relation. Here, we use:
285  *
286  * \f[
287  * \ln(a_o) = \frac{X_o - 1.0}{X_o}
288  * + \frac{ 2 A_{Debye} \tilde{M}_o}{3} (I)^{1/2}
289  * \left[ \sum_k{\frac{1}{2} m_k z_k^2 \sigma( B_{Debye} a_k \sqrt{I} ) } \right]
290  * - \frac{\log(10)}{2} \tilde{M}_o I \sum_k{ B^{dot}_k m_k}
291  * \f]
292  * where
293  * \f[
294  * \sigma (y) = \frac{3}{y^3} \left[ (1+y) - 2 \ln(1 + y) - \frac{1}{1+y} \right]
295  * \f]
296  *
297  * Additionally, Helgeson's formulation for the water activity is offered as an
298  * alternative.
299  *
300  *
301  * <H3> Bdot Formulation with Uniform Size Parameter in the Denominator </H3>
302  *
303  * DHFORM_BDOT_AUNIFORM = 2
304  *
305  * This form assumes Bethke's format for the Debye-Huckel activity coefficient
306  *
307  * \f[
308  * \ln(\gamma_k^\triangle) = -z_k^2 \frac{A_{Debye} \sqrt{I}}{ 1 + B_{Debye} a \sqrt{I}}
309  * + \log(10) B^{dot}_k I
310  * \f]
311  *
312  * The value of a is determined at the beginning of the calculation, and not changed.
313  *
314  * \f[
315  * \ln(a_o) = \frac{X_o - 1.0}{X_o}
316  * + \frac{ 2 A_{Debye} \tilde{M}_o}{3} (I)^{3/2} \sigma( B_{Debye} a \sqrt{I} )
317  * - \frac{\log(10)}{2} \tilde{M}_o I \sum_k{ B^{dot}_k m_k}
318  * \f]
319  *
320  *
321  * <H3> Beta_IJ formulation </H3>
322  *
323  * DHFORM_BETAIJ = 3
324  *
325  * This form assumes a linear expansion in a virial coefficient form.
326  * It is used extensively in the book by Newmann, "Electrochemistry Systems",
327  * and is the beginning of more complex treatments for stronger electrolytes,
328  * fom Pitzer and from Harvey, Moller, and Weire.
329  *
330  * \f[
331  * \ln(\gamma_k^\triangle) = -z_k^2 \frac{A_{Debye} \sqrt{I}}{ 1 + B_{Debye} a \sqrt{I}}
332  * + 2 \sum_j \beta_{j,k} m_j
333  * \f]
334  *
335  * In the current treatment the binary interaction coefficients, \f$ \beta_{j,k}\f$, are
336  * independent of temperature and pressure.
337  *
338  * \f[
339  * \ln(a_o) = \frac{X_o - 1.0}{X_o}
340  * + \frac{ 2 A_{Debye} \tilde{M}_o}{3} (I)^{3/2} \sigma( B_{Debye} a \sqrt{I} )
341  * - \tilde{M}_o \sum_j \sum_k \beta_{j,k} m_j m_k
342  * \f]
343  *
344  * In this formulation the ionic radius, \f$ a \f$, is a constant. This must be supplied to the
345  * model, in an <DFN> ionicRadius </DFN> XML block.
346  *
347  * The \f$ \beta_{j,k} \f$ parameters are binary interaction parameters. They are supplied to
348  * the object in an <TT> DHBetaMatrix </TT> XML block. There are in principle \f$ N (N-1) /2 \f$
349  * different, symmetric interaction parameters, where \f$ N \f$ are the number of solute species in the
350  * mechanism.
351  * An example is given below.
352  *
353  * An example <TT> activityCoefficients </TT> XML block for this formulation is supplied below
354  *
355  * @code
356  * <activityCoefficients model="Beta_ij">
357  * <!-- A_Debye units = sqrt(kg/gmol) -->
358  * <A_Debye> 1.172576 </A_Debye>
359  * <!-- B_Debye units = sqrt(kg/gmol)/m -->
360  * <B_Debye> 3.28640E9 </B_Debye>
361  * <ionicRadius default="3.042843" units="Angstroms">
362  * </ionicRadius>
363  * <DHBetaMatrix>
364  * H+:Cl-:0.27
365  * Na+:Cl-:0.15
366  * Na+:OH-:0.06
367  * </DHBetaMatrix>
368  * <stoichIsMods>
369  * NaCl(aq):-1.0
370  * </stoichIsMods>
371  * <electrolyteSpeciesType>
372  * H+:chargedSpecies
373  * NaCl(aq):weakAcidAssociated
374  * </electrolyteSpeciesType>
375  * </activityCoefficients>
376  * @endcode
377  *
378  * <H3> Pitzer Beta_IJ formulation </H3>
379  *
380  * DHFORM_PITZER_BETAIJ = 4
381  *
382  * This form assumes an activity coefficient formulation consistent
383  * with a truncated form of Pitzer's formulation. Pitzer's formulation is equivalent
384  * to the formulations above in the dilute limit, where rigorous theory may be applied.
385  *
386  * \f[
387  * \ln(\gamma_k^\triangle) = -z_k^2 \frac{A_{Debye}}{3} \frac{\sqrt{I}}{ 1 + B_{Debye} a \sqrt{I}}
388  * -2 z_k^2 \frac{A_{Debye}}{3} \frac{\ln(1 + B_{Debye} a \sqrt{I})}{ B_{Debye} a}
389  * + 2 \sum_j \beta_{j,k} m_j
390  * \f]
391  *
392  *
393  * \f[
394  * \ln(a_o) = \frac{X_o - 1.0}{X_o}
395  * + \frac{ 2 A_{Debye} \tilde{M}_o}{3} \frac{(I)^{3/2} }{1 + B_{Debye} a \sqrt{I} }
396  * - \tilde{M}_o \sum_j \sum_k \beta_{j,k} m_j m_k
397  * \f]
398  *
399  * <H3> Specification of the Debye Huckel Constants </H3>
400  *
401  * In the equations above, the formulas for \f$ A_{Debye} \f$ and \f$ B_{Debye} \f$
402  * are needed. The DebyeHuckel object uses two methods for specifying these quantities.
403  * The default method is to assume that \f$ A_{Debye} \f$ is a constant, given
404  * in the initialization process, and stored in the
405  * member double, m_A_Debye. Optionally, a full water treatment may be employed that makes
406  * \f$ A_{Debye} \f$ a full function of <I>T</I> and <I>P</I>.
407  *
408  * \f[
409  * A_{Debye} = \frac{F e B_{Debye}}{8 \pi \epsilon R T} {\left( C_o \tilde{M}_o \right)}^{1/2}
410  * \f]
411  * where
412  *
413  * \f[
414  * B_{Debye} = \frac{F} {{(\frac{\epsilon R T}{2})}^{1/2}}
415  * \f]
416  * Therefore:
417  * \f[
418  * A_{Debye} = \frac{1}{8 \pi}
419  * {\left(\frac{2 N_a \rho_o}{1000}\right)}^{1/2}
420  * {\left(\frac{N_a e^2}{\epsilon R T }\right)}^{3/2}
421  * \f]
422  *
423  * where
424  * - \f$ N_a \f$ is Avogadro's number
425  * - \f$ \rho_w \f$ is the density of water
426  * - \f$ e \f$ is the electronic charge
427  * - \f$ \epsilon = K \epsilon_o \f$ is the permittivity of water
428  * - \f$ K \f$ is the dielectric constant of water
429  * - \f$ \epsilon_o \f$ is the permittivity of free space
430  * - \f$ \rho_o \f$ is the density of the solvent in its standard state.
431  *
432  * Nominal value at 298 K and 1 atm = 1.172576 (kg/gmol)<SUP>1/2</SUP> based on:
433  * - \f$ \epsilon / \epsilon_0 \f$ = 78.54 (water at 25C)
434  * - T = 298.15 K
435  * - B_Debye = 3.28640E9 (kg/gmol)<SUP>1/2</SUP> m<SUP>-1</SUP>
436  *
437  * An example of a fixed value implementation is given below.
438  * @code
439  * <activityCoefficients model="Beta_ij">
440  * <!-- A_Debye units = sqrt(kg/gmol) -->
441  * <A_Debye> 1.172576 </A_Debye>
442  * <!-- B_Debye units = sqrt(kg/gmol)/m -->
443  * <B_Debye> 3.28640E9 </B_Debye>
444  * </activityCoefficients>
445  * @endcode
446  *
447  * An example of a variable value implementation is given below.
448  *
449  * @code
450  * <activityCoefficients model="Beta_ij">
451  * <A_Debye model="water" />
452  * <!-- B_Debye units = sqrt(kg/gmol)/m -->
453  * <B_Debye> 3.28640E9 </B_Debye>
454  * </activityCoefficients>
455  * @endcode
456  *
457  * Currently, \f$ B_{Debye} \f$ is a constant in the model, specified either by a default
458  * water value, or through the input file. This may have to be looked at, in the future.
459  *
460  * <HR>
461  * <H2> %Application within Kinetics Managers </H2>
462  * <HR>
463  *
464  * For the time being, we have set the standard concentration for all species in
465  * this phase equal to the default concentration of the solvent at 298 K and 1 atm.
466  * This means that the
467  * kinetics operator essentially works on an activities basis, with units specified
468  * as if it were on a concentration basis.
469  *
470  * For example, a bulk-phase binary reaction between liquid species j and k, producing
471  * a new liquid species l would have the
472  * following equation for its rate of progress variable, \f$ R^1 \f$, which has
473  * units of kmol m-3 s-1.
474  *
475  * \f[
476  * R^1 = k^1 C_j^a C_k^a = k^1 (C_o a_j) (C_o a_k)
477  * \f]
478  * where
479  * \f[
480  * C_j^a = C_o a_j \quad and \quad C_k^a = C_o a_k
481  * \f]
482  *
483  * \f$ C_j^a \f$ is the activity concentration of species j, and
484  * \f$ C_k^a \f$ is the activity concentration of species k. \f$ C_o \f$
485  * is the concentration of water at 298 K and 1 atm. \f$ a_j \f$ is
486  * the activity of species j at the current temperature and pressure
487  * and concentration of the liquid phase. \f$k^1 \f$ has units of m3 kmol-1 s-1.
488  *
489  * The reverse rate constant can then be obtained from the law of microscopic reversibility
490  * and the equilibrium expression for the system.
491  *
492  * \f[
493  * \frac{a_j a_k}{ a_l} = K^{o,1} = \exp(\frac{\mu^o_l - \mu^o_j - \mu^o_k}{R T} )
494  * \f]
495  *
496  * \f$ K^{o,1} \f$ is the dimensionless form of the equilibrium constant.
497  *
498  * \f[
499  * R^{-1} = k^{-1} C_l^a = k^{-1} (C_o a_l)
500  * \f]
501  *
502  * where
503  *
504  * \f[
505  * k^{-1} = k^1 K^{o,1} C_o
506  * \f]
507  *
508  * \f$k^{-1} \f$ has units of s-1.
509  *
510  * Note, this treatment may be modified in the future, as events dictate.
511  *
512  * <HR>
513  * <H2> Instantiation of the Class </H2>
514  * <HR>
515  *
516  * The constructor for this phase is NOT located in the default ThermoFactory
517  * for %Cantera. However, a new DebyeHuckel object may be created by
518  * the following code snippets:
519  *
520  * @code
521  * DebyeHuckel *DH = new DebyeHuckel("DH_NaCl.xml", "NaCl_electrolyte");
522  * @endcode
523  *
524  * or
525  *
526  * @code
527  * XML_Node *xm = get_XML_NameID("phase", "DH_NaCl.xml#NaCl_electrolyte", 0);
528  * DebyeHuckel *dh = new DebyeHuckel(*xm);
529  * @endcode
530  *
531  * or by the following call to importPhase():
532  *
533  * @code
534  * XML_Node *xm = get_XML_NameID("phase", "DH_NaCl.xml#NaCl_electrolyte", 0);
535  * DebyeHuckel dhphase;
536  * importPhase(*xm, &dhphase);
537  * @endcode
538  *
539  * <HR>
540  * <H2> XML Example </H2>
541  * <HR>
542  *
543  * The phase model name for this is called StoichSubstance. It must be supplied
544  * as the model attribute of the thermo XML element entry.
545  * Within the phase XML block,
546  * the density of the phase must be specified. An example of an XML file
547  * this phase is given below.
548  *
549  * @verbatim
550  <phase id="NaCl_electrolyte" dim="3">
551  <speciesArray datasrc="#species_waterSolution">
552  H2O(L) Na+ Cl- H+ OH- NaCl(aq) NaOH(aq)
553  </speciesArray>
554  <state>
555  <temperature units="K"> 300 </temperature>
556  <pressure units="Pa">101325.0</pressure>
557  <soluteMolalities>
558  Na+:3.0
559  Cl-:3.0
560  H+:1.0499E-8
561  OH-:1.3765E-6
562  NaCl(aq):0.98492
563  NaOH(aq):3.8836E-6
564  </soluteMolalities>
565  </state>
566  <!-- thermo model identifies the inherited class
567  from ThermoPhase that will handle the thermodynamics.
568  -->
569  <thermo model="DebyeHuckel">
570  <standardConc model="solvent_volume" />
571  <activityCoefficients model="Beta_ij">
572  <!-- A_Debye units = sqrt(kg/gmol) -->
573  <A_Debye> 1.172576 </A_Debye>
574  <!-- B_Debye units = sqrt(kg/gmol)/m -->
575  <B_Debye> 3.28640E9 </B_Debye>
576  <ionicRadius default="3.042843" units="Angstroms">
577  </ionicRadius>
578  <DHBetaMatrix>
579  H+:Cl-:0.27
580  Na+:Cl-:0.15
581  Na+:OH-:0.06
582  </DHBetaMatrix>
583  <stoichIsMods>
584  NaCl(aq):-1.0
585  </stoichIsMods>
586  <electrolyteSpeciesType>
587  H+:chargedSpecies
588  NaCl(aq):weakAcidAssociated
589  </electrolyteSpeciesType>
590  </activityCoefficients>
591  <solvent> H2O(L) </solvent>
592  </thermo>
593  <elementArray datasrc="elements.xml"> O H Na Cl </elementArray>
594 </phase>
595 @endverbatim
596  *
597  *
598  */
600 {
601 public:
602  //! Default Constructor
603  DebyeHuckel();
604 
605  //! Copy constructor
606  DebyeHuckel(const DebyeHuckel&);
607 
608  //! Assignment operator
610 
611  //! Full constructor for creating the phase.
612  /*!
613  * @param inputFile File name containing the XML description of the phase
614  * @param id id attribute containing the name of the phase.
615  */
616  DebyeHuckel(const std::string& inputFile, const std::string& id = "");
617 
618  //! Full constructor for creating the phase.
619  /*!
620  * @param phaseRef XML phase node containing the description of the phase
621  * @param id id attribute containing the name of the phase.
622  */
623  DebyeHuckel(XML_Node& phaseRef, const std::string& id = "");
624 
625  /// Destructor.
626  virtual ~DebyeHuckel();
627 
628  //! Duplicator from the ThermoPhase parent class
629  /*!
630  * Given a pointer to a ThermoPhase object, this function will
631  * duplicate the ThermoPhase object and all underlying structures.
632  * This is basically a wrapper around the copy constructor.
633  *
634  * @return returns a pointer to a ThermoPhase
635  */
637 
638  //! @name Utilities
639  //! @{
640 
641  /**
642  * Equation of state type flag. The base class returns
643  * zero. Subclasses should define this to return a unique
644  * non-zero value. Constants defined for this purpose are
645  * listed in mix_defs.h.
646  */
647  virtual int eosType() const;
648 
649  //! @}
650  //! @name Molar Thermodynamic Properties of the Solution
651  //! @{
652 
653  /// Molar enthalpy of the solution. Units: J/kmol.
654  virtual doublereal enthalpy_mole() const;
655 
656  /// Molar entropy. Units: J/kmol/K.
657  /**
658  * For an ideal, constant partial molar volume solution mixture with
659  * pure species phases which exhibit zero volume expansivity:
660  * \f[
661  * \hat s(T, P, X_k) = \sum_k X_k \hat s^0_k(T)
662  * - \hat R \sum_k X_k log(X_k)
663  * \f]
664  * The reference-state pure-species entropies
665  * \f$ \hat s^0_k(T,p_{ref}) \f$ are computed by the
666  * species thermodynamic
667  * property manager. The pure species entropies are independent of
668  * temperature since the volume expansivities are equal to zero.
669  * @see SpeciesThermo
670  */
671  virtual doublereal entropy_mole() const;
672 
673  /// Molar Gibbs function. Units: J/kmol.
674  virtual doublereal gibbs_mole() const;
675 
676  /// Molar heat capacity at constant pressure. Units: J/kmol/K.
677  virtual doublereal cp_mole() const;
678 
679  //! Molar heat capacity at constant volume. Units: J/kmol/K.
680  /*
681  * (HKM -> Bump up to Parent object)
682  */
683  virtual doublereal cv_mole() const;
684 
685  //@}
686  /** @name Mechanical Equation of State Properties
687  //@{
688  *
689  * In this equation of state implementation, the density is a
690  * function only of the mole fractions. Therefore, it can't be
691  * an independent variable. Instead, the pressure is used as the
692  * independent variable. Functions which try to set the thermodynamic
693  * state by calling setDensity() may cause an exception to be
694  * thrown.
695  */
696 
697  //! Return the thermodynamic pressure (Pa).
698  /*!
699  * For this incompressible system, we return the internally stored
700  * independent value of the pressure.
701  */
702  virtual doublereal pressure() const;
703 
704  //! Set the internally stored pressure (Pa) at constant
705  //! temperature and composition
706  /*!
707  * This method sets the pressure within the object.
708  * The water model is a completely compressible model.
709  * Also, the dielectric constant is pressure dependent.
710  *
711  * @param p input Pressure (Pa)
712  *
713  * @todo Implement a variable pressure capability
714  */
715  virtual void setPressure(doublereal p);
716 
717 protected:
718  //! Calculate the density of the mixture using the partial
719  //! molar volumes and mole fractions as input
720  /*!
721  * The formula for this is
722  *
723  * \f[
724  * \rho = \frac{\sum_k{X_k W_k}}{\sum_k{X_k V_k}}
725  * \f]
726  *
727  * where \f$X_k\f$ are the mole fractions, \f$W_k\f$ are
728  * the molecular weights, and \f$V_k\f$ are the pure species
729  * molar volumes.
730  *
731  * Note, the basis behind this formula is that in an ideal
732  * solution the partial molar volumes are equal to the pure
733  * species molar volumes. We have additionally specified
734  * in this class that the pure species molar volumes are
735  * independent of temperature and pressure.
736  */
737  virtual void calcDensity();
738 
739 public:
740  //! Set the internally stored density (gm/m^3) of the phase.
741  /*!
742  * Overwritten setDensity() function is necessary because the
743  * density is not an independent variable.
744  *
745  * This function will now throw an error condition
746  *
747  * @internal May have to adjust the strategy here to make
748  * the eos for these materials slightly compressible, in order
749  * to create a condition where the density is a function of
750  * the pressure.
751  *
752  * This function will now throw an error condition if the
753  * input isn't exactly equal to the current density.
754  *
755  * @todo Now have a compressible ss equation for liquid water.
756  * Therefore, this phase is compressible. May still
757  * want to change the independent variable however.
758  *
759  * @param rho Input density (kg/m^3).
760  */
761  void setDensity(const doublereal rho);
762 
763  //! Set the internally stored molar density (kmol/m^3) of the phase.
764  /**
765  * Overwritten setMolarDensity() function is necessary because the
766  * density is not an independent variable.
767  *
768  * This function will now throw an error condition if the input
769  * isn't exactly equal to the current molar density.
770  *
771  * @param conc Input molar density (kmol/m^3).
772  */
773  virtual void setMolarDensity(const doublereal conc);
774 
775  //! Set the temperature (K)
776  /*!
777  * This function sets the temperature, and makes sure that
778  * the value propagates to underlying objects, such as
779  * the water standard state model.
780  *
781  * @param temp Temperature in kelvin
782  */
783  virtual void setTemperature(const doublereal temp);
784 
785  //! Set the temperature (K) and pressure (Pa)
786  /*!
787  * Set the temperature and pressure.
788  *
789  * @param t Temperature (K)
790  * @param p Pressure (Pa)
791  */
792  virtual void setState_TP(doublereal t, doublereal p);
793 
794  /**
795  * @}
796  * @name Activities, Standard States, and Activity Concentrations
797  *
798  * The activity \f$a_k\f$ of a species in solution is
799  * related to the chemical potential by \f[ \mu_k = \mu_k^0(T)
800  * + \hat R T \log a_k. \f] The quantity \f$\mu_k^0(T,P)\f$ is
801  * the chemical potential at unit activity, which depends only
802  * on temperature and the pressure.
803  * Activity is assumed to be molality-based here.
804  * @{
805  */
806 
807  //! This method returns an array of generalized concentrations
808  /*!
809  * \f$ C_k\f$ that are defined such that
810  * \f$ a_k = C_k / C^0_k, \f$ where \f$ C^0_k \f$
811  * is a standard concentration
812  * defined below. These generalized concentrations are used
813  * by kinetics manager classes to compute the forward and
814  * reverse rates of elementary reactions.
815  *
816  * @param c Array of generalized concentrations. The
817  * units depend upon the implementation of the
818  * reaction rate expressions within the phase.
819  */
820  virtual void getActivityConcentrations(doublereal* c) const;
821 
822  //! Return the standard concentration for the kth species
823  /*!
824  * The standard concentration \f$ C^0_k \f$ used to normalize
825  * the activity (i.e., generalized) concentration in
826  * kinetics calculations.
827  *
828  * For the time being, we will use the concentration of pure
829  * solvent for the the standard concentration of all species.
830  * This has the effect of making reaction rates
831  * based on the molality of species proportional to the
832  * molality of the species.
833  *
834  * @param k Optional parameter indicating the species. The default
835  * is to assume this refers to species 0.
836  * @return
837  * Returns the standard Concentration in units of
838  * m<SUP>3</SUP> kmol<SUP>-1</SUP>.
839  */
840  virtual doublereal standardConcentration(size_t k=0) const;
841 
842  //! Returns the units of the standard and generalized concentrations.
843  /*!
844  * Note they have the same units, as their
845  * ratio is defined to be equal to the activity of the kth
846  * species in the solution, which is unitless.
847  *
848  * This routine is used in print out applications where the
849  * units are needed. Usually, MKS units are assumed throughout
850  * the program and in the XML input files.
851  *
852  * The base ThermoPhase class assigns the default quantities
853  * of (kmol/m3) for all species.
854  * Inherited classes are responsible for overriding the default
855  * values if necessary.
856  *
857  * On return uA contains the powers of the units (MKS assumed)
858  * of the standard concentrations and generalized concentrations
859  * for the kth species.
860  *
861  * @param uA Output vector containing the units
862  * uA[0] = kmol units - default = 1
863  * uA[1] = m units - default = -nDim(), the number of spatial
864  * dimensions in the Phase class.
865  * uA[2] = kg units - default = 0;
866  * uA[3] = Pa(pressure) units - default = 0;
867  * uA[4] = Temperature units - default = 0;
868  * uA[5] = time units - default = 0
869  * @param k species index. Defaults to 0.
870  * @param sizeUA output int containing the size of the vector.
871  * Currently, this is equal to 6.
872  * @deprecated To be removed after Cantera 2.2.
873  */
874  virtual void getUnitsStandardConc(double* uA, int k = 0,
875  int sizeUA = 6) const;
876 
877  //! Get the array of non-dimensional activities at
878  //! the current solution temperature, pressure, and solution concentration.
879  /*!
880  *
881  * We resolve this function at this level by calling
882  * on the activityConcentration function. However,
883  * derived classes may want to override this default
884  * implementation.
885  *
886  * (note solvent activity coefficient is on molar scale).
887  *
888  * @param ac Output vector of activities. Length: m_kk.
889  */
890  virtual void getActivities(doublereal* ac) const;
891 
892  //! Get the array of non-dimensional molality-based
893  //! activity coefficients at
894  //! the current solution temperature, pressure, and solution concentration.
895  /*!
896  * note solvent is on molar scale. The solvent molar
897  * based activity coefficient is returned.
898  *
899  * Note, most of the work is done in an internal private routine
900  *
901  * @param acMolality Vector of Molality-based activity coefficients
902  * Length: m_kk
903  */
904  virtual void
905  getMolalityActivityCoefficients(doublereal* acMolality) const;
906 
907  //@}
908  /// @name Partial Molar Properties of the Solution
909  //@{
910 
911  //! Get the species chemical potentials. Units: J/kmol.
912  /*!
913  *
914  * This function returns a vector of chemical potentials of the
915  * species in solution.
916  *
917  * \f[
918  * \mu_k = \mu^{\triangle}_k(T,P) + R T ln(\gamma_k^{\triangle} m_k)
919  * \f]
920  *
921  * @param mu Output vector of species chemical
922  * potentials. Length: m_kk. Units: J/kmol
923  */
924  virtual void getChemPotentials(doublereal* mu) const;
925 
926  //! Returns an array of partial molar enthalpies for the species
927  //! in the mixture. Units (J/kmol)
928  /*!
929  * For this phase, the partial molar enthalpies are equal to the
930  * standard state enthalpies modified by the derivative of the
931  * molality-based activity coefficient wrt temperature
932  *
933  * \f[
934  * \bar h_k(T,P) = h^{\triangle}_k(T,P) - R T^2 \frac{d \ln(\gamma_k^\triangle)}{dT}
935  * \f]
936  * The solvent partial molar enthalpy is equal to
937  * \f[
938  * \bar h_o(T,P) = h^{o}_o(T,P) - R T^2 \frac{d \ln(a_o}{dT}
939  * \f]
940  *
941  * The temperature dependence of the activity coefficients currently
942  * only occurs through the temperature dependence of the Debye constant.
943  *
944  * @param hbar Output vector of species partial molar enthalpies.
945  * Length: m_kk. units are J/kmol.
946  */
947  virtual void getPartialMolarEnthalpies(doublereal* hbar) const;
948 
949  //! Returns an array of partial molar entropies of the species in the
950  //! solution. Units: J/kmol/K.
951  /**
952  * Maxwell's equations provide an insight in how to calculate this
953  * (p.215 Smith and Van Ness)
954  * \f[
955  * \frac{d\mu_i}{dT} = -\bar{s}_i
956  * \f]
957  *
958  * For this phase, the partial molar entropies are equal to the
959  * SS species entropies plus the ideal solution contribution.following
960  * contribution:
961  * \f[
962  * \bar s_k(T,P) = \hat s^0_k(T) - R log(M0 * molality[k])
963  * \f]
964  * \f[
965  * \bar s_{solvent}(T,P) = \hat s^0_{solvent}(T)
966  * - R ((xmolSolvent - 1.0) / xmolSolvent)
967  * \f]
968  *
969  * The reference-state pure-species entropies,\f$ \hat s^0_k(T) \f$,
970  * at the reference pressure, \f$ P_{ref} \f$, are computed by the
971  * species thermodynamic
972  * property manager. They are polynomial functions of temperature.
973  * @see SpeciesThermo
974  *
975  * @param sbar Output vector of species partial molar entropies.
976  * Length = m_kk. units are J/kmol/K.
977  */
978  virtual void getPartialMolarEntropies(doublereal* sbar) const;
979 
980  //! Return an array of partial molar heat capacities for the
981  //! species in the mixture. Units: J/kmol/K
982  /*!
983  * @param cpbar Output vector of species partial molar heat
984  * capacities at constant pressure.
985  * Length = m_kk. units are J/kmol/K.
986  */
987  virtual void getPartialMolarCp(doublereal* cpbar) const;
988 
989  //! Return an array of partial molar volumes for the
990  //! species in the mixture. Units: m^3/kmol.
991  /*!
992  * For this solution, the partial molar volumes are normally
993  * equal to theconstant species molar volumes, except
994  * when the activity coefficients depend on pressure.
995  *
996  * The general relation is
997  *
998  * vbar_i = d(chemPot_i)/dP at const T, n
999  * = V0_i + d(Gex)/dP)_T,M
1000  * = V0_i + RT d(lnActCoeffi)dP _T,M
1001  *
1002  * @param vbar Output vector of species partial molar volumes.
1003  * Length = m_kk. units are m^3/kmol.
1004  */
1005  virtual void getPartialMolarVolumes(doublereal* vbar) const;
1006 
1007  //@}
1008 
1009  /**
1010  * @name Chemical Equilibrium
1011  * @{
1012  */
1013 
1014  //!This method is used by the ChemEquil equilibrium solver.
1015  /*!
1016  * It sets the state such that the chemical potentials satisfy
1017  * \f[ \frac{\mu_k}{\hat R T} = \sum_m A_{k,m}
1018  * \left(\frac{\lambda_m} {\hat R T}\right) \f] where
1019  * \f$ \lambda_m \f$ is the element potential of element m. The
1020  * temperature is unchanged. Any phase (ideal or not) that
1021  * implements this method can be equilibrated by ChemEquil.
1022  *
1023  * @param lambda_RT Input vector of dimensionless element potentials
1024  * The length is equal to nElements().
1025  */
1026  virtual void setToEquilState(const doublereal* lambda_RT) {
1027  throw NotImplementedError("DebyeHuckel::setToEquilState");
1028  }
1029 
1030  //@}
1031 
1032  /*
1033  * -------------- Utilities -------------------------------
1034  */
1035 
1036  //! Initialize the object's internal lengths after species are set
1037  /**
1038  * @internal Initialize. This method is provided to allow
1039  * subclasses to perform any initialization required after all
1040  * species have been added. For example, it might be used to
1041  * resize internal work arrays that must have an entry for
1042  * each species. The base class implementation does nothing,
1043  * and subclasses that do not require initialization do not
1044  * need to overload this method. When importing a CTML phase
1045  * description, this method is called just prior to returning
1046  * from function importPhase().
1047  *
1048  * Cascading call sequence downwards starting with Parent.
1049  *
1050  * @internal
1051  */
1052  virtual void initThermo();
1053 
1054  //! Process the XML file after species are set up.
1055  /*!
1056  * This gets called from importPhase(). It processes the XML file
1057  * after the species are set up. This is the main routine for
1058  * reading in activity coefficient parameters.
1059  *
1060  * @param phaseNode This object must be the phase node of a
1061  * complete XML tree
1062  * description of the phase, including all of the
1063  * species data. In other words while "phase" must
1064  * point to an XML phase object, it must have
1065  * sibling nodes "speciesData" that describe
1066  * the species in the phase.
1067  * @param id ID of the phase. If nonnull, a check is done
1068  * to see if phaseNode is pointing to the phase
1069  * with the correct id.
1070  */
1071  virtual void initThermoXML(XML_Node& phaseNode, const std::string& id);
1072 
1073  //! Return the Debye Huckel constant as a function of temperature
1074  //! and pressure (Units = sqrt(kg/gmol))
1075  /*!
1076  * The default is to assume that it is constant, given
1077  * in the initialization process, and stored in the
1078  * member double, m_A_Debye. Optionally, a full water treatment may be employed that makes
1079  * \f$ A_{Debye} \f$ a full function of T and P.
1080  *
1081  * \f[
1082  * A_{Debye} = \frac{F e B_{Debye}}{8 \pi \epsilon R T} {\left( C_o \tilde{M}_o \right)}^{1/2}
1083  * \f]
1084  * where
1085  * \f[
1086  * B_{Debye} = \frac{F} {{(\frac{\epsilon R T}{2})}^{1/2}}
1087  * \f]
1088  * Therefore:
1089  * \f[
1090  * A_{Debye} = \frac{1}{8 \pi}
1091  * {\left(\frac{2 N_a \rho_o}{1000}\right)}^{1/2}
1092  * {\left(\frac{N_a e^2}{\epsilon R T }\right)}^{3/2}
1093  * \f]
1094  *
1095  * where
1096  * - Units = sqrt(kg/gmol)
1097  * - \f$ N_a \f$ is Avogadro's number
1098  * - \f$ \rho_w \f$ is the density of water
1099  * - \f$ e \f$ is the electronic charge
1100  * - \f$ \epsilon = K \epsilon_o \f$ is the permittivity of water
1101  * - \f$ K \f$ is the dielectric constant of water,
1102  * - \f$ \epsilon_o \f$ is the permittivity of free space.
1103  * - \f$ \rho_o \f$ is the density of the solvent in its standard state.
1104  *
1105  * Nominal value at 298 K and 1 atm = 1.172576 (kg/gmol)<SUP>1/2</SUP>
1106  * based on:
1107  * - \f$ \epsilon / \epsilon_0 \f$ = 78.54 (water at 25C)
1108  * - T = 298.15 K
1109  * - B_Debye = 3.28640E9 (kg/gmol)<SUP>1/2</SUP> m<SUP>-1</SUP>
1110  *
1111  * @param temperature Temperature in kelvin. Defaults to -1, in which
1112  * case the temperature of the phase is assumed.
1113  *
1114  * @param pressure Pressure (Pa). Defaults to -1, in which
1115  * case the pressure of the phase is assumed.
1116  */
1117  virtual double A_Debye_TP(double temperature = -1.0,
1118  double pressure = -1.0) const;
1119 
1120  //! Value of the derivative of the Debye Huckel constant with
1121  //! respect to temperature.
1122  /*!
1123  * This is a function of temperature and pressure. See A_Debye_TP() for
1124  * a definition of \f$ A_{Debye} \f$.
1125  *
1126  * Units = sqrt(kg/gmol) K-1
1127  *
1128  * @param temperature Temperature in kelvin. Defaults to -1, in which
1129  * case the temperature of the phase is assumed.
1130  *
1131  * @param pressure Pressure (Pa). Defaults to -1, in which
1132  * case the pressure of the phase is assumed.
1133  */
1134  virtual double dA_DebyedT_TP(double temperature = -1.0,
1135  double pressure = -1.0) const;
1136 
1137  //! Value of the 2nd derivative of the Debye Huckel constant with
1138  //! respect to temperature as a function of temperature and pressure.
1139  /*!
1140  * This is a function of temperature and pressure. See A_Debye_TP() for
1141  * a definition of \f$ A_{Debye} \f$.
1142  *
1143  * Units = sqrt(kg/gmol) K-2
1144  *
1145  * @param temperature Temperature in kelvin. Defaults to -1, in which
1146  * case the temperature of the phase is assumed.
1147  *
1148  * @param pressure Pressure (Pa). Defaults to -1, in which
1149  * case the pressure of the phase is assumed.
1150  */
1151  virtual double d2A_DebyedT2_TP(double temperature = -1.0,
1152  double pressure = -1.0) const;
1153 
1154  //! Value of the derivative of the Debye Huckel constant with
1155  //! respect to pressure, as a function of temperature and pressure.
1156  /*!
1157  * This is a function of temperature and pressure. See A_Debye_TP() for
1158  * a definition of \f$ A_{Debye} \f$.
1159  *
1160  * Units = sqrt(kg/gmol) Pa-1
1161  *
1162  * @param temperature Temperature in kelvin. Defaults to -1, in which
1163  * case the temperature of the phase is assumed.
1164  *
1165  * @param pressure Pressure (Pa). Defaults to -1, in which
1166  * case the pressure of the phase is assumed.
1167  */
1168  virtual double dA_DebyedP_TP(double temperature = -1.0,
1169  double pressure = -1.0) const;
1170 
1171  //!Reports the ionic radius of the kth species
1172  /*!
1173  * @param k species index.
1174  */
1175  double AionicRadius(int k = 0) const;
1176 
1177  //! Returns the form of the Debye-Huckel parameterization used
1178  int formDH() const {
1179  return m_formDH;
1180  }
1181 
1182  //! Returns a reference to M_Beta_ij
1184  return m_Beta_ij;
1185  }
1186 
1187 private:
1188  //! Static function that implements the non-polar species
1189  //! salt-out modifications.
1190  /*!
1191  * Returns the calculated activity coefficients.
1192  *
1193  * @param IionicMolality Value of the ionic molality (sqrt(gmol/kg))
1194  */
1195  double _nonpolarActCoeff(double IionicMolality) const;
1196 
1197  //! Formula for the osmotic coefficient that occurs in the GWB.
1198  /*!
1199  * It is originally from Helgeson for a variable
1200  * NaCl brine. It's to be used with extreme caution.
1201  */
1202  double _osmoticCoeffHelgesonFixedForm() const;
1203 
1204  //! Formula for the log of the water activity that occurs in the GWB.
1205  /*!
1206  * It is originally from Helgeson for a variable
1207  * NaCl brine. It's to be used with extreme caution.
1208  */
1209  double _lnactivityWaterHelgesonFixedForm() const;
1210  //@}
1211 
1212 protected:
1213  //! form of the Debye-Huckel parameterization used in the model.
1214  /*!
1215  * The options are described at the top of this document,
1216  * and in the general documentation.
1217  * The list is repeated here:
1218  *
1219  * DHFORM_DILUTE_LIMIT = 0 (default)
1220  * DHFORM_BDOT_AK = 1
1221  * DHFORM_BDOT_AUNIFORM = 2
1222  * DHFORM_BETAIJ = 3
1223  * DHFORM_PITZER_BETAIJ = 4
1224  */
1226 
1227  /**
1228  * Format for the generalized concentration:
1229  *
1230  * 0 = unity
1231  * 1 = molar_volume
1232  * 2 = solvent_volume (default)
1233  *
1234  * The generalized concentrations can have three different forms
1235  * depending on the value of the member attribute m_formGC, which
1236  * is supplied in the constructor.
1237  * <TABLE>
1238  * <TR><TD> m_formGC </TD><TD> GeneralizedConc </TD><TD> StandardConc </TD></TR>
1239  * <TR><TD> 0 </TD><TD> X_k </TD><TD> 1.0 </TD></TR>
1240  * <TR><TD> 1 </TD><TD> X_k / V_k </TD><TD> 1.0 / V_k </TD></TR>
1241  * <TR><TD> 2 </TD><TD> X_k / V_N </TD><TD> 1.0 / V_N </TD></TR>
1242  * </TABLE>
1243  *
1244  * The value and form of the generalized concentration will affect
1245  * reaction rate constants involving species in this phase.
1246  *
1247  * (HKM Note: Using option #1 may lead to spurious results and
1248  * has been included only with warnings. The reason is that it
1249  * molar volumes of electrolytes may often be negative. The
1250  * molar volume of H+ is defined to be zero too. Either options
1251  * 0 or 2 are the appropriate choice. Option 0 leads to
1252  * bulk reaction rate constants which have units of s-1.
1253  * Option 2 leads to bulk reaction rate constants for
1254  * bimolecular rxns which have units of m-3 kmol-1 s-1.)
1255  */
1257 
1258  //! Vector containing the electrolyte species type
1259  /*!
1260  * The possible types are:
1261  * - solvent
1262  * - Charged Species
1263  * - weakAcidAssociated
1264  * - strongAcidAssociated
1265  * - polarNeutral
1266  * - nonpolarNeutral
1267  * .
1268  */
1270 
1271  /**
1272  * a_k = Size of the ionic species in the DH formulation
1273  * units = meters
1274  */
1276 
1277  //! Current value of the ionic strength on the molality scale
1278  mutable double m_IionicMolality;
1279 
1280  /**
1281  * Maximum value of the ionic strength allowed in the
1282  * calculation of the activity coefficients.
1283  */
1285 
1286 public:
1287 
1288  /**
1289  * If true, then the fixed for of Helgeson's activity
1290  * for water is used instead of the rigorous form
1291  * obtained from Gibbs-Duhem relation. This should be
1292  * used with caution, and is really only included as a
1293  * validation exercise.
1294  */
1296 protected:
1297 
1298  //! Stoichiometric ionic strength on the molality scale
1299  mutable double m_IionicMolalityStoich;
1300 
1301 public:
1302  /**
1303  * Form of the constant outside the Debye-Huckel term
1304  * called A. It's normally a function of temperature
1305  * and pressure. However, it can be set from the
1306  * input file in order to aid in numerical comparisons.
1307  * Acceptable forms:
1308  *
1309  * A_DEBYE_CONST 0
1310  * A_DEBYE_WATER 1
1311  *
1312  * The A_DEBYE_WATER form may be used for water solvents
1313  * with needs to cover varying temperatures and pressures.
1314  * Note, the dielectric constant of water is a relatively
1315  * strong function of T, and its variability must be
1316  * accounted for,
1317  */
1319 
1320 protected:
1321  //! Current value of the Debye Constant, A_Debye
1322  /**
1323  * A_Debye -> this expression appears on the top of the
1324  * ln actCoeff term in the general Debye-Huckel
1325  * expression
1326  * It depends on temperature and pressure.
1327  *
1328  * A_Debye = (F e B_Debye) / (8 Pi epsilon R T)
1329  *
1330  * Units = sqrt(kg/gmol)
1331  *
1332  * Nominal value(298K, atm) = 1.172576 sqrt(kg/gmol)
1333  * based on:
1334  * epsilon/epsilon_0 = 78.54
1335  * (water at 25C)
1336  * T = 298.15 K
1337  * B_Debye = 3.28640E9 sqrt(kg/gmol)/m
1338  *
1339  * note in Pitzer's nomenclature, A_phi = A_Debye/3.0
1340  */
1341  mutable double m_A_Debye;
1342 
1343  //! Current value of the constant that appears in the denominator
1344  /**
1345  * B_Debye -> this expression appears on the bottom of the
1346  * ln actCoeff term in the general Debye-Huckel
1347  * expression
1348  * It depends on temperature
1349  *
1350  * B_Bebye = F / sqrt( epsilon R T / 2 )
1351  *
1352  * Units = sqrt(kg/gmol) / m
1353  *
1354  * Nominal value = 3.28640E9 sqrt(kg/gmol) / m
1355  * based on:
1356  * epsilon/epsilon_0 = 78.54
1357  * (water at 25C)
1358  * T = 298.15 K
1359  */
1360  double m_B_Debye;
1361 
1362  //! Array of B_Dot values
1363  /**
1364  * This expression is an extension of the Debye-Huckel expression used
1365  * in some formulations to extend DH to higher molalities. B_dot is
1366  * specific to the major ionic pair.
1367  */
1369 
1370  /**
1371  * These are coefficients to describe the increase in activity coeff for
1372  * non-polar molecules due to the electrolyte becoming stronger (the
1373  * so-called salt-out effect)
1374  */
1376 
1377 
1378  //! Pointer to the Water standard state object
1379  /*!
1380  * derived from the equation of state for water.
1381  */
1383 
1384  //! Storage for the density of water's standard state
1385  /*!
1386  * Density depends on temperature and pressure.
1387  */
1389 
1390  //! Pointer to the water property calculator
1392 
1393  //! Temporary array used in equilibrium calculations
1394  mutable vector_fp m_pp;
1395 
1396  //! vector of size m_kk, used as a temporary holding area.
1398 
1399  /**
1400  * Stoichiometric species charge -> This is for calculations
1401  * of the ionic strength which ignore ion-ion pairing into
1402  * neutral molecules. The Stoichiometric species charge is the
1403  * charge of one of the ion that would occur if the species broke
1404  * into two charged ion pairs.
1405  * NaCl -> m_speciesCharge_Stoich = -1;
1406  * HSO4- -> H+ + SO42- = -2
1407  * -> The other charge is calculated.
1408  * For species that aren't ion pairs, it's equal to the
1409  * m_speciesCharge[] value.
1410  */
1412 
1413  /**
1414  * Array of 2D data used in the DHFORM_BETAIJ formulation
1415  * Beta_ij.value(i,j) is the coefficient of the jth species
1416  * for the specification of the chemical potential of the ith
1417  * species.
1418  */
1420 
1421  //! Logarithm of the activity coefficients on the molality scale.
1422  /*!
1423  * mutable because we change this if the composition
1424  * or temperature or pressure changes.
1425  */
1427 
1428  //! Derivative of log act coeff wrt T
1430 
1431  //! 2nd Derivative of log act coeff wrt T
1433 
1434  //! Derivative of log act coeff wrt P
1436 
1437 private:
1438  //! Initialize the internal lengths.
1439  /*!
1440  * This internal function adjusts the lengths of arrays based on
1441  * the number of species.
1442  */
1443  void initLengths();
1444 
1445  //! Calculate the log activity coefficients
1446  /*!
1447  * This function updates the internally stored natural logarithm of the
1448  * molality activity coefficients. This is the main routine for
1449  * implementing the activity coefficient formulation.
1450  */
1451  void s_update_lnMolalityActCoeff() const;
1452 
1453  //! Calculation of temperature derivative of activity coefficient
1454  /*!
1455  * Using internally stored values, this function calculates
1456  * the temperature derivative of the logarithm of the
1457  * activity coefficient for all species in the mechanism.
1458  *
1459  * We assume that the activity coefficients are current in this routine
1460  *
1461  * The solvent activity coefficient is on the molality scale. Its derivative is too.
1462  */
1463  void s_update_dlnMolalityActCoeff_dT() const;
1464 
1465  //! Calculate the temperature 2nd derivative of the activity coefficient
1466  /*!
1467  * Using internally stored values, this function calculates
1468  * the temperature 2nd derivative of the logarithm of the
1469  * activity coefficient for all species in the mechanism.
1470  *
1471  * We assume that the activity coefficients are current in this routine
1472  *
1473  * solvent activity coefficient is on the molality
1474  * scale. Its derivatives are too.
1475  */
1476  void s_update_d2lnMolalityActCoeff_dT2() const;
1477 
1478  //! Calculate the pressure derivative of the activity coefficient
1479  /*!
1480  * Using internally stored values, this function calculates
1481  * the pressure derivative of the logarithm of the
1482  * activity coefficient for all species in the mechanism.
1483  *
1484  * We assume that the activity coefficients, molalities,
1485  * and A_Debye are current.
1486  *
1487  * solvent activity coefficient is on the molality
1488  * scale. Its derivatives are too.
1489  */
1490  void s_update_dlnMolalityActCoeff_dP() const;
1491 };
1492 
1493 }
1494 
1495 #endif
double m_IionicMolalityStoich
Stoichiometric ionic strength on the molality scale.
Definition: DebyeHuckel.h:1299
void s_update_d2lnMolalityActCoeff_dT2() const
Calculate the temperature 2nd derivative of the activity coefficient.
double _lnactivityWaterHelgesonFixedForm() const
Formula for the log of the water activity that occurs in the GWB.
int m_form_A_Debye
Form of the constant outside the Debye-Huckel term called A.
Definition: DebyeHuckel.h:1318
virtual double A_Debye_TP(double temperature=-1.0, double pressure=-1.0) const
Return the Debye Huckel constant as a function of temperature and pressure (Units = sqrt(kg/gmol)) ...
virtual void getPartialMolarCp(doublereal *cpbar) const
Return an array of partial molar heat capacities for the species in the mixture.
virtual doublereal pressure() const
Return the thermodynamic pressure (Pa).
vector_fp m_dlnActCoeffMolaldT
Derivative of log act coeff wrt T.
Definition: DebyeHuckel.h:1429
An error indicating that an unimplemented function has been called.
Definition: ctexceptions.h:213
virtual void getActivityConcentrations(doublereal *c) const
This method returns an array of generalized concentrations.
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
ThermoPhase * duplMyselfAsThermoPhase() const
Duplicator from the ThermoPhase parent class.
virtual doublereal cp_mole() const
Molar heat capacity at constant pressure. Units: J/kmol/K.
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:100
virtual void initThermo()
Initialize the object's internal lengths after species are set.
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...
bool m_useHelgesonFixedForm
If true, then the fixed for of Helgeson's activity for water is used instead of the rigorous form obt...
Definition: DebyeHuckel.h:1295
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...
virtual doublereal entropy_mole() const
Molar entropy. Units: J/kmol/K.
int formDH() const
Returns the form of the Debye-Huckel parameterization used.
Definition: DebyeHuckel.h:1178
virtual doublereal gibbs_mole() const
Molar Gibbs function. Units: J/kmol.
void setDensity(const doublereal rho)
Set the internally stored density (gm/m^3) of the phase.
virtual void getPartialMolarEnthalpies(doublereal *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.
virtual doublereal cv_mole() const
Molar heat capacity at constant volume. Units: J/kmol/K.
virtual void setState_TP(doublereal t, doublereal p)
Set the temperature (K) and pressure (Pa)
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...
DebyeHuckel()
Default Constructor.
Definition: DebyeHuckel.cpp:30
virtual int eosType() const
Equation of state type flag.
Class DebyeHuckel represents a dilute liquid electrolyte phase which obeys the Debye Huckel formulati...
Definition: DebyeHuckel.h:599
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:97
virtual void setTemperature(const doublereal temp)
Set the temperature (K)
Header file for class Cantera::Array2D.
std::vector< int > vector_int
Vector of ints.
Definition: ct_defs.h:159
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. ...
virtual void setToEquilState(const doublereal *lambda_RT)
This method is used by the ChemEquil equilibrium solver.
Definition: DebyeHuckel.h:1026
The WaterProps class is used to house several approximation routines for properties of water...
Definition: WaterProps.h:96
Array2D m_Beta_ij
Array of 2D data used in the DHFORM_BETAIJ formulation Beta_ij.value(i,j) is the coefficient of the j...
Definition: DebyeHuckel.h:1419
void s_update_lnMolalityActCoeff() const
Calculate the log activity coefficients.
vector_fp m_Aionic
a_k = Size of the ionic species in the DH formulation units = meters
Definition: DebyeHuckel.h:1275
Class for the liquid water pressure dependent standard state.
Definition: PDSS_Water.h:51
double _nonpolarActCoeff(double IionicMolality) const
Static function that implements the non-polar species salt-out modifications.
double m_maxIionicStrength
Maximum value of the ionic strength allowed in the calculation of the activity coefficients.
Definition: DebyeHuckel.h:1284
int m_formDH
form of the Debye-Huckel parameterization used in the model.
Definition: DebyeHuckel.h:1225
double m_A_Debye
Current value of the Debye Constant, A_Debye.
Definition: DebyeHuckel.h:1341
vector_fp m_lnActCoeffMolal
Logarithm of the activity coefficients on the molality scale.
Definition: DebyeHuckel.h:1426
PDSS_Water * m_waterSS
Pointer to the Water standard state object.
Definition: DebyeHuckel.h:1382
vector_fp m_B_Dot
Array of B_Dot values.
Definition: DebyeHuckel.h:1368
Array2D & get_Beta_ij()
Returns a reference to M_Beta_ij.
Definition: DebyeHuckel.h:1183
int m_formGC
Format for the generalized concentration:
Definition: DebyeHuckel.h:1256
double _osmoticCoeffHelgesonFixedForm() const
Formula for the osmotic coefficient that occurs in the GWB.
virtual doublereal enthalpy_mole() const
Molar enthalpy of the solution. Units: J/kmol.
void initLengths()
Initialize the internal lengths.
virtual void getPartialMolarEntropies(doublereal *sbar) const
Returns an array of partial molar entropies of the species in the solution.
virtual void calcDensity()
Calculate the density of the mixture using the partial molar volumes and mole fractions as input...
DebyeHuckel & operator=(const DebyeHuckel &)
Assignment operator.
vector_int m_electrolyteSpeciesType
Vector containing the electrolyte species type.
Definition: DebyeHuckel.h:1269
virtual void getPartialMolarVolumes(doublereal *vbar) const
Return an array of partial molar volumes for the species in the mixture.
void s_update_dlnMolalityActCoeff_dT() const
Calculation of temperature derivative of activity coefficient.
vector_fp m_speciesCharge_Stoich
Stoichiometric species charge -> This is for calculations of the ionic strength which ignore ion-ion ...
Definition: DebyeHuckel.h:1411
double m_IionicMolality
Current value of the ionic strength on the molality scale.
Definition: DebyeHuckel.h:1278
doublereal temperature() const
Temperature (K).
Definition: Phase.h:602
double AionicRadius(int k=0) const
Reports the ionic radius of the kth species.
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
vector_fp m_npActCoeff
These are coefficients to describe the increase in activity coeff for non-polar molecules due to the ...
Definition: DebyeHuckel.h:1375
vector_fp m_d2lnActCoeffMolaldT2
2nd Derivative of log act coeff wrt T
Definition: DebyeHuckel.h:1432
vector_fp m_tmpV
vector of size m_kk, used as a temporary holding area.
Definition: DebyeHuckel.h:1397
vector_fp m_pp
Temporary array used in equilibrium calculations.
Definition: DebyeHuckel.h:1394
double m_B_Debye
Current value of the constant that appears in the denominator.
Definition: DebyeHuckel.h:1360
void s_update_dlnMolalityActCoeff_dP() const
Calculate the pressure derivative of the activity coefficient.
WaterProps * m_waterProps
Pointer to the water property calculator.
Definition: DebyeHuckel.h:1391
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id)
Process the XML file after species are set up.
virtual doublereal standardConcentration(size_t k=0) const
Return the standard concentration for the kth species.
virtual void getActivities(doublereal *ac) const
Get the array of non-dimensional activities at the current solution temperature, pressure, and solution concentration.
vector_fp m_dlnActCoeffMolaldP
Derivative of log act coeff wrt P.
Definition: DebyeHuckel.h:1435
virtual void getMolalityActivityCoefficients(doublereal *acMolality) const
Get the array of non-dimensional molality-based activity coefficients at the current solution tempera...
virtual void getUnitsStandardConc(double *uA, int k=0, int sizeUA=6) const
Returns the units of the standard and generalized concentrations.
virtual ~DebyeHuckel()
Destructor.
virtual void setPressure(doublereal p)
Set the internally stored pressure (Pa) at constant temperature and composition.
double m_densWaterSS
Storage for the density of water's standard state.
Definition: DebyeHuckel.h:1388
virtual void setMolarDensity(const doublereal conc)
Set the internally stored molar density (kmol/m^3) of the phase.