Cantera  2.3.0
MolalityVPSSTP.h
Go to the documentation of this file.
1 /**
2  * @file MolalityVPSSTP.h
3  * Header for intermediate ThermoPhase object for phases which
4  * employ molality based activity coefficient formulations
5  * (see \ref thermoprops
6  * and class \link Cantera::MolalityVPSSTP MolalityVPSSTP\endlink).
7  *
8  * Header file for a derived class of ThermoPhase that handles
9  * variable pressure standard state methods for calculating
10  * thermodynamic properties that are further based upon activities
11  * based on the molality scale. These include most of the methods for
12  * calculating liquid electrolyte thermodynamics.
13  */
14 
15 // This file is part of Cantera. See License.txt in the top-level directory or
16 // at http://www.cantera.org/license.txt for license and copyright information.
17 
18 #ifndef CT_MOLALITYVPSSTP_H
19 #define CT_MOLALITYVPSSTP_H
20 
21 #include "VPStandardStateTP.h"
22 
23 namespace Cantera
24 {
25 
26 /*!
27  * MolalityVPSSTP is a derived class of ThermoPhase that handles variable
28  * pressure standard state methods for calculating thermodynamic properties that
29  * are further based on molality-scaled activities. This category incorporates
30  * most of the methods for calculating liquid electrolyte thermodynamics that
31  * have been developed since the 1970's.
32  *
33  * This class adds additional functions onto the ThermoPhase interface that
34  * handle molality based standard states. The ThermoPhase class includes a
35  * member function, ThermoPhase::activityConvention() that indicates which
36  * convention the activities are based on. The default is to assume activities
37  * are based on the molar convention. However, classes which derive from the
38  * MolalityVPSSTP class return `cAC_CONVENTION_MOLALITY` from this member
39  * function.
40  *
41  * The molality of a solute, \f$ m_i \f$, is defined as
42  *
43  * \f[
44  * m_i = \frac{n_i}{\tilde{M}_o n_o}
45  * \f]
46  * where
47  * \f[
48  * \tilde{M}_o = \frac{M_o}{1000}
49  * \f]
50  *
51  * where \f$ M_o \f$ is the molecular weight of the solvent. The molality has
52  * units of gmol/kg. For the solute, the molality may be considered
53  * as the amount of gmol's of solute per kg of solvent, a natural experimental
54  * quantity.
55  *
56  * The formulas for calculating mole fractions if given the molalities of the
57  * solutes is stated below. First calculate \f$ L^{sum} \f$, an intermediate
58  * quantity.
59  *
60  * \f[
61  * L^{sum} = \frac{1}{\tilde{M}_o X_o} = \frac{1}{\tilde{M}_o} + \sum_{i\ne o} m_i
62  * \f]
63  * Then,
64  * \f[
65  * X_o = \frac{1}{\tilde{M}_o L^{sum}}
66  * \f]
67  * \f[
68  * X_i = \frac{m_i}{L^{sum}}
69  * \f]
70  * where \f$ X_o \f$ is the mole fraction of solvent, and \f$ X_o \f$ is the
71  * mole fraction of solute *i*. Thus, the molality scale and the mole fraction
72  * scale offer a one-to-one mapping between each other, except in the limit of a
73  * zero solvent mole fraction.
74  *
75  * The standard states for thermodynamic objects that derive from MolalityVPSSTP
76  * are on the unit molality basis. Chemical potentials of the solutes, \f$ \mu_k
77  * \f$, and the solvent, \f$ \mu_o \f$, which are based on the molality form,
78  * have the following general format:
79  *
80  * \f[
81  * \mu_k = \mu^{\triangle}_k(T,P) + R T ln(\gamma_k^{\triangle} \frac{m_k}{m^\triangle})
82  * \f]
83  * \f[
84  * \mu_o = \mu^o_o(T,P) + RT ln(a_o)
85  * \f]
86  *
87  * where \f$ \gamma_k^{\triangle} \f$ is the molality based activity coefficient
88  * for species \f$k\f$.
89  *
90  * The chemical potential of the solvent is thus expressed in a different format
91  * than the chemical potential of the solutes. Additionally, the activity of the
92  * solvent, \f$ a_o \f$, is further reexpressed in terms of an osmotic
93  * coefficient, \f$ \phi \f$.
94  * \f[
95  * \phi = \frac{- ln(a_o)}{\tilde{M}_o \sum_{i \ne o} m_i}
96  * \f]
97  *
98  * MolalityVPSSTP::osmoticCoefficient() returns the value of \f$ \phi \f$. Note
99  * there are a few of definitions of the osmotic coefficient floating around. We
100  * use the one defined in (Activity Coefficients in Electrolyte Solutions, K. S.
101  * Pitzer CRC Press, Boca Raton, 1991, p. 85, Eqn. 28). This definition is most
102  * clearly related to theoretical calculation.
103  *
104  * The molar-based activity coefficients \f$ \gamma_k \f$ may be calculated from
105  * the molality-based activity coefficients, \f$ \gamma_k^\triangle \f$ by the
106  * following formula.
107  * \f[
108  * \gamma_k = \frac{\gamma_k^\triangle}{X_o}
109  * \f]
110  * For purposes of establishing a convention, the molar activity coefficient of
111  * the solvent is set equal to the molality-based activity coefficient of the
112  * solvent:
113  * \f[
114  * \gamma_o = \gamma_o^\triangle
115  * \f]
116  *
117  * The molality-based and molarity-based standard states may be related to one
118  * another by the following formula.
119  *
120  * \f[
121  * \mu_k^\triangle(T,P) = \mu_k^o(T,P) + R T \ln(\tilde{M}_o m^\triangle)
122  * \f]
123  *
124  * An important convention is followed in all routines that derive from
125  * MolalityVPSSTP. Standard state thermodynamic functions and reference state
126  * thermodynamic functions return the molality-based quantities. Also all
127  * functions which return activities return the molality-based activities. The
128  * reason for this convention has been discussed in supporting memos. However,
129  * it's important because the term in the equation above is non-trivial. For
130  * example it's equal to 2.38 kcal/gmol for water at 298 K.
131  *
132  * In order to prevent a singularity, this class includes the concept of a
133  * minimum value for the solvent mole fraction. All calculations involving the
134  * formulation of activity coefficients and other non-ideal solution behavior
135  * adhere to this concept of a minimal value for the solvent mole fraction. This
136  * makes sense because these solution behavior were all designed and measured
137  * far away from the zero solvent singularity condition and are not applicable
138  * in that limit.
139  *
140  * This objects add a layer that supports molality. It inherits from
141  * VPStandardStateTP.
142  *
143  * All objects that derive from this are assumed to have molality based standard
144  * states.
145  *
146  * Molality based activity coefficients are scaled according to the current pH
147  * scale. See the Eq3/6 manual for details.
148  *
149  * Activity coefficients for species k may be altered between scales s1 to s2
150  * using the following formula
151  *
152  * \f[
153  * ln(\gamma_k^{s2}) = ln(\gamma_k^{s1})
154  * + \frac{z_k}{z_j} \left( ln(\gamma_j^{s2}) - ln(\gamma_j^{s1}) \right)
155  * \f]
156  *
157  * where j is any one species. For the NBS scale, j is equal to the Cl- species
158  * and
159  *
160  * \f[
161  * ln(\gamma_{Cl-}^{s2}) = \frac{-A_{\phi} \sqrt{I}}{1.0 + 1.5 \sqrt{I}}
162  * \f]
163  *
164  * The Pitzer scale doesn't actually change anything. The pitzer scale is
165  * defined as the raw unscaled activity coefficients produced by the underlying
166  * objects.
167  *
168  * ### SetState Strategy
169  *
170  * The MolalityVPSSTP object does not have a setState strategy concerning the
171  * molalities. It does not keep track of whether the molalities have changed.
172  * It's strictly an interfacial layer that writes the current mole fractions to
173  * the State object. When molalities are needed it recalculates the molalities
174  * from the State object's mole fraction vector.
175  *
176  * @todo Make two solvent minimum fractions. One would be for calculation of the
177  * non-ideal factors. The other one would be for purposes of stoichiometry
178  * evaluation. the stoichiometry evaluation one would be a 1E-13 limit.
179  * Anything less would create problems with roundoff error.
180  */
182 {
183 public:
184  /// Default Constructor
185  /*!
186  * This doesn't do much more than initialize constants with default values
187  * for water at 25C. Water molecular weight comes from the default
188  * elements.xml file. It actually differs slightly from the IAPWS95 value of
189  * 18.015268. However, density conservation and therefore element
190  * conservation is the more important principle to follow.
191  */
192  MolalityVPSSTP();
193 
194  MolalityVPSSTP(const MolalityVPSSTP& b);
195  MolalityVPSSTP& operator=(const MolalityVPSSTP& b);
196  virtual ThermoPhase* duplMyselfAsThermoPhase() const;
197 
198  //! @name Utilities
199  //! @{
200 
201  //! Set the pH scale, which determines the scale for single-ion activity
202  //! coefficients.
203  /*!
204  * Single ion activity coefficients are not unique in terms of the
205  * representing actual measurable quantities.
206  *
207  * @param pHscaleType Integer representing the pHscale
208  */
209  void setpHScale(const int pHscaleType);
210 
211  //! Reports the pH scale, which determines the scale for single-ion activity
212  //! coefficients.
213  /*!
214  * Single ion activity coefficients are not unique in terms of the
215  * representing actual measurable quantities.
216  *
217  * @returns the pHscale type
218  */
219  int pHScale() const;
220 
221  //! @}
222  //! @name Utilities for Solvent ID and Molality
223  //! @{
224 
225  /**
226  * This routine sets the index number of the solvent for the phase.
227  *
228  * Note, having a solvent is a precursor to many things having to do with
229  * molality.
230  *
231  * @param k the solvent index number
232  */
233  void setSolvent(size_t k);
234 
235  //! Returns the solvent index.
236  size_t solventIndex() const;
237 
238  /**
239  * Sets the minimum mole fraction in the molality formulation. Note the
240  * molality formulation is singular in the limit that the solvent mole
241  * fraction goes to zero. Numerically, how this limit is treated and
242  * resolved is an ongoing issue within Cantera. The minimum mole fraction
243  * must be in the range 0 to 0.9.
244  *
245  * @param xmolSolventMIN Input double containing the minimum mole fraction
246  */
247  void setMoleFSolventMin(doublereal xmolSolventMIN);
248 
249  //! Returns the minimum mole fraction in the molality formulation.
250  doublereal moleFSolventMin() const;
251 
252  //! Calculates the molality of all species and stores the result internally.
253  /*!
254  * We calculate the vector of molalities of the species in the phase and
255  * store the result internally:
256  * \f[
257  * m_i = \frac{X_i}{1000 * M_o * X_{o,p}}
258  * \f]
259  * where
260  * - \f$ M_o \f$ is the molecular weight of the solvent
261  * - \f$ X_o \f$ is the mole fraction of the solvent
262  * - \f$ X_i \f$ is the mole fraction of the solute.
263  * - \f$ X_{o,p} = \max (X_{o}^{min}, X_o) \f$
264  * - \f$ X_{o}^{min} \f$ = minimum mole fraction of solvent allowed
265  * in the denominator.
266  */
267  void calcMolalities() const;
268 
269  //! This function will return the molalities of the species.
270  /*!
271  * We calculate the vector of molalities of the species in the phase
272  * \f[
273  * m_i = \frac{X_i}{1000 * M_o * X_{o,p}}
274  * \f]
275  * where
276  * - \f$ M_o \f$ is the molecular weight of the solvent
277  * - \f$ X_o \f$ is the mole fraction of the solvent
278  * - \f$ X_i \f$ is the mole fraction of the solute.
279  * - \f$ X_{o,p} = \max (X_{o}^{min}, X_o) \f$
280  * - \f$ X_{o}^{min} \f$ = minimum mole fraction of solvent allowed
281  * in the denominator.
282  *
283  * @param molal Output vector of molalities. Length: m_kk.
284  */
285  void getMolalities(doublereal* const molal) const;
286 
287  //! Set the molalities of the solutes in a phase
288  /*!
289  * Note, the entry for the solvent is not used. We are supplied with the
290  * molalities of all of the solute species. We then calculate the mole
291  * fractions of all species and update the ThermoPhase object.
292  * \f[
293  * m_i = \frac{X_i}{M_o/1000 * X_{o,p}}
294  * \f]
295  * where
296  * - \f$M_o\f$ is the molecular weight of the solvent
297  * - \f$X_o\f$ is the mole fraction of the solvent
298  * - \f$X_i\f$ is the mole fraction of the solute.
299  * - \f$X_{o,p} = \max(X_o^{min}, X_o)\f$
300  * - \f$X_o^{min}\f$ = minimum mole fraction of solvent allowed
301  * in the denominator.
302  *
303  * The formulas for calculating mole fractions are
304  * \f[
305  * L^{sum} = \frac{1}{\tilde{M}_o X_o} = \frac{1}{\tilde{M}_o} + \sum_{i\ne o} m_i
306  * \f]
307  * Then,
308  * \f[
309  * X_o = \frac{1}{\tilde{M}_o L^{sum}}
310  * \f]
311  * \f[
312  * X_i = \frac{m_i}{L^{sum}}
313  * \f]
314  * It is currently an error if the solvent mole fraction is attempted to be
315  * set to a value lower than \f$ X_o^{min} \f$.
316  *
317  * @param molal Input vector of molalities. Length: m_kk.
318  */
319  void setMolalities(const doublereal* const molal);
320 
321  //! Set the molalities of a phase
322  /*!
323  * Set the molalities of the solutes in a phase. Note, the entry for the
324  * solvent is not used.
325  *
326  * @param xMap Composition Map containing the molalities.
327  */
328  void setMolalitiesByName(const compositionMap& xMap);
329 
330  //! Set the molalities of a phase
331  /*!
332  * Set the molalities of the solutes in a phase. Note, the entry for the
333  * solvent is not used.
334  *
335  * @param name String containing the information for a composition map.
336  */
337  void setMolalitiesByName(const std::string& name);
338 
339  /**
340  * @}
341  * @name Activities, Standard States, and Activity Concentrations
342  *
343  * The activity \f$a_k\f$ of a species in solution is related to the
344  * chemical potential by \f[ \mu_k = \mu_k^0(T) + \hat R T \log a_k. \f] The
345  * quantity \f$\mu_k^0(T,P)\f$ is the chemical potential at unit activity,
346  * which depends only on temperature and pressure.
347  * @{
348  */
349 
350  /**
351  * We set the convention to molality here.
352  */
353  int activityConvention() const;
354 
355  virtual void getActivityConcentrations(doublereal* c) const;
356  virtual doublereal standardConcentration(size_t k=0) const;
357 
358  //! Get the array of non-dimensional activities (molality based for this
359  //! class and classes that derive from it) at the current solution
360  //! temperature, pressure, and solution concentration.
361  /*!
362  * All standard state properties for molality-based phases are evaluated
363  * consistent with the molality scale. Therefore, this function must return
364  * molality-based activities.
365  *
366  * \f[
367  * a_i^\triangle = \gamma_k^{\triangle} \frac{m_k}{m^\triangle}
368  * \f]
369  *
370  * This function must be implemented in derived classes.
371  *
372  * @param ac Output vector of molality-based activities. Length: m_kk.
373  */
374  virtual void getActivities(doublereal* ac) const;
375 
376  //! Get the array of non-dimensional activity coefficients at
377  //! the current solution temperature, pressure, and solution concentration.
378  /*!
379  * These are mole-fraction based activity coefficients. In this
380  * object, their calculation is based on translating the values
381  * of the molality-based activity coefficients.
382  * See Denbigh p. 278 for a thorough discussion.
383  *
384  * The molar-based activity coefficients \f$ \gamma_k \f$ may be calculated
385  * from the molality-based activity coefficients, \f$ \gamma_k^\triangle \f$
386  * by the following formula.
387  * \f[
388  * \gamma_k = \frac{\gamma_k^\triangle}{X_o}
389  * \f]
390  *
391  * For purposes of establishing a convention, the molar activity coefficient of the
392  * solvent is set equal to the molality-based activity coefficient of the
393  * solvent:
394  *
395  * \f[
396  * \gamma_o = \gamma_o^\triangle
397  * \f]
398  *
399  * Derived classes don't need to overload this function. This function is
400  * handled at this level.
401  *
402  * @param ac Output vector containing the mole-fraction based activity
403  * coefficients. length: m_kk.
404  */
405  virtual void getActivityCoefficients(doublereal* ac) const;
406 
407  //! Get the array of non-dimensional molality based activity coefficients at
408  //! the current solution temperature, pressure, and solution concentration.
409  /*!
410  * See Denbigh p. 278 for a thorough discussion. This class must be
411  * overridden in classes which derive from MolalityVPSSTP. This function
412  * takes over from the molar-based activity coefficient calculation,
413  * getActivityCoefficients(), in derived classes.
414  *
415  * These molality based activity coefficients are scaled according to the
416  * current pH scale. See the Eq3/6 manual for details.
417  *
418  * Activity coefficients for species k may be altered between scales s1 to
419  * s2 using the following formula
420  *
421  * \f[
422  * ln(\gamma_k^{s2}) = ln(\gamma_k^{s1})
423  * + \frac{z_k}{z_j} \left( ln(\gamma_j^{s2}) - ln(\gamma_j^{s1}) \right)
424  * \f]
425  *
426  * where j is any one species. For the NBS scale, j is equal to the Cl-
427  * species and
428  *
429  * \f[
430  * ln(\gamma_{Cl-}^{s2}) = \frac{-A_{\phi} \sqrt{I}}{1.0 + 1.5 \sqrt{I}}
431  * \f]
432  *
433  * @param acMolality Output vector containing the molality based activity
434  * coefficients. length: m_kk.
435  */
436  virtual void getMolalityActivityCoefficients(doublereal* acMolality) const;
437 
438  //! Calculate the osmotic coefficient
439  /*!
440  * \f[
441  * \phi = \frac{- ln(a_o)}{\tilde{M}_o \sum_{i \ne o} m_i}
442  * \f]
443  *
444  * Note there are a few of definitions of the osmotic coefficient floating
445  * around. We use the one defined in (Activity Coefficients in Electrolyte
446  * Solutions, K. S. Pitzer CRC Press, Boca Raton, 1991, p. 85, Eqn. 28).
447  * This definition is most clearly related to theoretical calculation.
448  *
449  * units = dimensionless
450  */
451  virtual double osmoticCoefficient() const;
452 
453  //@}
454 
455  //! Set equation of state parameter values from XML entries.
456  /*!
457  * This method is called by function importPhase() when processing a phase
458  * definition in an input file. It should be overloaded in subclasses to set
459  * any parameters that are specific to that particular phase model.
460  *
461  * The MolalityVPSSTP object defines a new method for setting the
462  * concentrations of a phase. The new method is defined by a block called
463  * "soluteMolalities". If this block is found, the concentrations within
464  * that phase are set to the "name":"molalities pairs found within that XML
465  * block. The solvent concentration is then set to everything else.
466  *
467  * The function first calls the overloaded function,
468  * VPStandardStateTP::setStateFromXML(), to pick up the parent class
469  * behavior.
470  *
471  * usage: Overloaded functions should call this function before carrying out
472  * their own behavior.
473  *
474  * @param state An XML_Node object corresponding to the "state" entry for
475  * this phase in the input file.
476  */
477  virtual void setStateFromXML(const XML_Node& state);
478 
479  //@}
480  //! @name Initialization
481  /// The following methods are used in the process of constructing the phase
482  /// and setting its parameters from a specification in an input file. They
483  /// are not normally used in application programs. To see how they are used,
484  /// see importPhase().
485  //@{
486 
487  virtual bool addSpecies(shared_ptr<Species> spec);
488  virtual void initThermo();
489 
490  //@}
491 
492  //! Set the temperature (K), pressure (Pa), and molalities
493  //!(gmol kg-1) of the solutes
494  /*!
495  * @param t Temperature (K)
496  * @param p Pressure (Pa)
497  * @param molalities Input vector of molalities of the solutes.
498  * Length: m_kk.
499  */
500  void setState_TPM(doublereal t, doublereal p,
501  const doublereal* const molalities);
502 
503  //! Set the temperature (K), pressure (Pa), and molalities.
504  /*!
505  * @param t Temperature (K)
506  * @param p Pressure (Pa)
507  * @param m compositionMap containing the molalities
508  */
509  void setState_TPM(doublereal t, doublereal p, const compositionMap& m);
510 
511  //! Set the temperature (K), pressure (Pa), and molalities.
512  /*!
513  * @param t Temperature (K)
514  * @param p Pressure (Pa)
515  * @param m String which gets translated into a composition
516  * map for the molalities of the solutes.
517  */
518  void setState_TPM(doublereal t, doublereal p, const std::string& m);
519 
520  virtual void getdlnActCoeffdlnN(const size_t ld, doublereal* const dlnActCoeffdlnN) {
521  getdlnActCoeffdlnN_numderiv(ld, dlnActCoeffdlnN);
522  }
523 
524  virtual std::string report(bool show_thermo=true,
525  doublereal threshold=1e-14) const;
526 
527 protected:
528  virtual void getCsvReportData(std::vector<std::string>& names,
529  std::vector<vector_fp>& data) const;
530 
531  //! Get the array of unscaled non-dimensional molality based activity
532  //! coefficients at the current solution temperature, pressure, and solution
533  //! concentration.
534  /*!
535  * See Denbigh p. 278 for a thorough discussion. This class must be
536  * overridden in classes which derive from MolalityVPSSTP. This function
537  * takes over from the molar-based activity coefficient calculation,
538  * getActivityCoefficients(), in derived classes.
539  *
540  * @param acMolality Output vector containing the molality based activity
541  * coefficients. length: m_kk.
542  */
543  virtual void getUnscaledMolalityActivityCoefficients(doublereal* acMolality) const;
544 
545  //! Apply the current phScale to a set of activity Coefficients or
546  //! activities
547  /*!
548  * See the Eq3/6 Manual for a thorough discussion.
549  *
550  * @param acMolality input/Output vector containing the molality based
551  * activity coefficients. length: m_kk.
552  */
553  virtual void applyphScale(doublereal* acMolality) const;
554 
555 private:
556  //! Returns the index of the Cl- species.
557  /*!
558  * The Cl- species is special in the sense that its single ion molality-
559  * based activity coefficient is used in the specification of the pH scale
560  * for single ions. Therefore, we need to know what species index is Cl-. If
561  * the species isn't in the species list then this routine returns -1, and
562  * we can't use the NBS pH scale.
563  *
564  * Right now we use a restrictive interpretation. The species must be named
565  * "Cl-". It must consist of exactly one Cl and one E atom.
566  */
567  virtual size_t findCLMIndex() const;
568 
569 protected:
570 
571  //! Index of the solvent. Currently the index of the solvent is hard-coded
572  //! to the value 0
574 
575  //! Scaling to be used for output of single-ion species activity
576  //! coefficients.
577  /*!
578  * Index of the species to be used in the single-ion scaling law. This is
579  * the identity of the Cl- species for the PHSCALE_NBS scaling. Either
580  * PHSCALE_PITZER or PHSCALE_NBS
581  */
583 
584  //! Index of the phScale species
585  /*!
586  * Index of the species to be used in the single-ion scaling law. This is
587  * the identity of the Cl- species for the PHSCALE_NBS scaling
588  */
589  size_t m_indexCLM;
590 
591  //! Molecular weight of the Solvent
592  doublereal m_weightSolvent;
593 
594  /*!
595  * In any molality implementation, it makes sense to have a minimum solvent
596  * mole fraction requirement, since the implementation becomes singular in
597  * the xmolSolvent=0 limit. The default is to set it to 0.01. We then modify
598  * the molality definition to ensure that molal_solvent = 0 when
599  * xmol_solvent = 0.
600  */
601  doublereal m_xmolSolventMIN;
602 
603  //! This is the multiplication factor that goes inside log expressions
604  //! involving the molalities of species. It's equal to Wt_0 / 1000, where
605  //! Wt_0 = weight of solvent (kg/kmol)
606  doublereal m_Mnaught;
607 
608  //! Current value of the molalities of the species in the phase. Note this
609  //! vector is a mutable quantity. units are (kg/kmol)
611 };
612 
613 
614 //! Scale to be used for the output of single-ion activity coefficients is that
615 //! used by Pitzer.
616 /*!
617  * This is the internal scale used within the code. One property is that the
618  * activity coefficients for the cation and anion of a single salt will be
619  * equal. This scale is the one presumed by the formulation of the single-ion
620  * activity coefficients described in this report.
621  *
622  * Activity coefficients for species k may be altered between scales s1 to s2
623  * using the following formula
624  *
625  * \f[
626  * ln(\gamma_k^{s2}) = ln(\gamma_k^{s1})
627  * + \frac{z_k}{z_j} \left( ln(\gamma_j^{s2}) - ln(\gamma_j^{s1}) \right)
628  * \f]
629  *
630  * where j is any one species.
631  */
632 const int PHSCALE_PITZER = 0;
633 
634 //! Scale to be used for evaluation of single-ion activity coefficients is that
635 //! used by the NBS standard for evaluation of the pH variable.
636 /*!
637  * This is not the internal scale used within the code.
638  *
639  * Activity coefficients for species k may be altered between scales s1 to s2
640  * using the following formula
641  *
642  * \f[
643  * ln(\gamma_k^{s2}) = ln(\gamma_k^{s1})
644  * + \frac{z_k}{z_j} \left( ln(\gamma_j^{s2}) - ln(\gamma_j^{s1}) \right)
645  * \f]
646  *
647  * where j is any one species. For the NBS scale, j is equal to the Cl- species
648  * and
649  *
650  * \f[
651  * ln(\gamma_{Cl-}^{s2}) = \frac{-A_{\phi} \sqrt{I}}{1.0 + 1.5 \sqrt{I}}
652  * \f]
653  *
654  * This is the NBS pH scale, which is used in all conventional pH measurements.
655  * and is based on the Bates-Guggenheim equations.
656  */
657 const int PHSCALE_NBS = 1;
658 
659 }
660 
661 #endif
std::map< std::string, doublereal > compositionMap
Map connecting a string name with a double.
Definition: ct_defs.h:149
virtual void getdlnActCoeffdlnN(const size_t ld, doublereal *const dlnActCoeffdlnN)
Get the array of derivatives of the log activity coefficients with respect to the log of the species ...
void setSolvent(size_t k)
This routine sets the index number of the solvent for the phase.
int activityConvention() const
We set the convention to molality here.
virtual size_t findCLMIndex() const
Returns the index of the Cl- species.
doublereal m_Mnaught
This is the multiplication factor that goes inside log expressions involving the molalities of specie...
void setpHScale(const int pHscaleType)
Set the pH scale, which determines the scale for single-ion activity coefficients.
size_t m_indexCLM
Index of the phScale species.
virtual void applyphScale(doublereal *acMolality) const
Apply the current phScale to a set of activity Coefficients or activities.
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:97
virtual doublereal standardConcentration(size_t k=0) const
Return the standard concentration for the kth species.
virtual bool addSpecies(shared_ptr< Species > spec)
doublereal moleFSolventMin() const
Returns the minimum mole fraction in the molality formulation.
virtual std::string report(bool show_thermo=true, doublereal threshold=1e-14) const
returns a summary of the state of the phase as a string
virtual void getMolalityActivityCoefficients(doublereal *acMolality) const
Get the array of non-dimensional molality based activity coefficients at the current solution tempera...
size_t solventIndex() const
Returns the solvent index.
virtual double osmoticCoefficient() const
Calculate the osmotic coefficient.
virtual void getActivityCoefficients(doublereal *ac) const
Get the array of non-dimensional activity coefficients at the current solution temperature, pressure, and solution concentration.
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:93
void setMolalitiesByName(const compositionMap &xMap)
Set the molalities of a phase.
virtual ThermoPhase * duplMyselfAsThermoPhase() const
Duplication routine for objects which inherit from ThermoPhase.
void getMolalities(doublereal *const molal) const
This function will return the molalities of the species.
int pHScale() const
Reports the pH scale, which determines the scale for single-ion activity coefficients.
virtual void getActivities(doublereal *ac) const
Get the array of non-dimensional activities (molality based for this class and classes that derive fr...
const int PHSCALE_NBS
Scale to be used for evaluation of single-ion activity coefficients is that used by the NBS standard ...
virtual void getActivityConcentrations(doublereal *c) const
This method returns an array of generalized concentrations.
const int PHSCALE_PITZER
Scale to be used for the output of single-ion activity coefficients is that used by Pitzer...
This is a filter class for ThermoPhase that implements some prepatory steps for efficiently handling ...
virtual void getUnscaledMolalityActivityCoefficients(doublereal *acMolality) const
Get the array of unscaled non-dimensional molality based activity coefficients at the current solutio...
int m_pHScalingType
Scaling to be used for output of single-ion species activity coefficients.
virtual void setStateFromXML(const XML_Node &state)
Set equation of state parameter values from XML entries.
void setMolalities(const doublereal *const molal)
Set the molalities of the solutes in a phase.
virtual void getCsvReportData(std::vector< std::string > &names, std::vector< vector_fp > &data) const
Fills names and data with the column names and species thermo properties to be included in the output...
void setState_TPM(doublereal t, doublereal p, const doublereal *const molalities)
Set the temperature (K), pressure (Pa), and molalities (gmol kg-1) of the solutes.
vector_fp m_molalities
Current value of the molalities of the species in the phase.
Header file for a derived class of ThermoPhase that handles variable pressure standard state methods ...
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
std::string name() const
Return the name of the phase.
Definition: Phase.cpp:151
doublereal m_weightSolvent
Molecular weight of the Solvent.
void calcMolalities() const
Calculates the molality of all species and stores the result internally.
Namespace for the Cantera kernel.
Definition: application.cpp:29
size_t m_indexSolvent
Index of the solvent.
MolalityVPSSTP()
Default Constructor.
void setMoleFSolventMin(doublereal xmolSolventMIN)
Sets the minimum mole fraction in the molality formulation.