Cantera  2.5.1
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 https://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  //! @name Utilities
195  //! @{
196 
197  //! String indicating the mechanical phase of the matter in this Phase.
198  /*!
199  * All derived phases from `MolalityVPSSTP` always represent liquids.
200  */
201  virtual std::string phaseOfMatter() const {
202  return "liquid";
203  }
204 
205  //! Set the pH scale, which determines the scale for single-ion activity
206  //! coefficients.
207  /*!
208  * Single ion activity coefficients are not unique in terms of the
209  * representing actual measurable quantities.
210  *
211  * @param pHscaleType Integer representing the pHscale
212  */
213  void setpHScale(const int pHscaleType);
214 
215  //! Reports the pH scale, which determines the scale for single-ion activity
216  //! coefficients.
217  /*!
218  * Single ion activity coefficients are not unique in terms of the
219  * representing actual measurable quantities.
220  *
221  * @returns the pHscale type
222  */
223  int pHScale() const;
224 
225  //! @}
226  //! @name Utilities for Solvent ID and Molality
227  //! @{
228 
229  /**
230  * Sets the minimum mole fraction in the molality formulation. Note the
231  * molality formulation is singular in the limit that the solvent mole
232  * fraction goes to zero. Numerically, how this limit is treated and
233  * resolved is an ongoing issue within Cantera. The minimum mole fraction
234  * must be in the range 0 to 0.9.
235  *
236  * @param xmolSolventMIN Input double containing the minimum mole fraction
237  */
238  void setMoleFSolventMin(doublereal xmolSolventMIN);
239 
240  //! Returns the minimum mole fraction in the molality formulation.
241  doublereal moleFSolventMin() const;
242 
243  //! Calculates the molality of all species and stores the result internally.
244  /*!
245  * We calculate the vector of molalities of the species in the phase and
246  * store the result internally:
247  * \f[
248  * m_i = \frac{X_i}{1000 * M_o * X_{o,p}}
249  * \f]
250  * where
251  * - \f$ M_o \f$ is the molecular weight of the solvent
252  * - \f$ X_o \f$ is the mole fraction of the solvent
253  * - \f$ X_i \f$ is the mole fraction of the solute.
254  * - \f$ X_{o,p} = \max (X_{o}^{min}, X_o) \f$
255  * - \f$ X_{o}^{min} \f$ = minimum mole fraction of solvent allowed
256  * in the denominator.
257  */
258  void calcMolalities() const;
259 
260  //! This function will return the molalities of the species.
261  /*!
262  * We calculate the vector of molalities of the species in the phase
263  * \f[
264  * m_i = \frac{X_i}{1000 * M_o * X_{o,p}}
265  * \f]
266  * where
267  * - \f$ M_o \f$ is the molecular weight of the solvent
268  * - \f$ X_o \f$ is the mole fraction of the solvent
269  * - \f$ X_i \f$ is the mole fraction of the solute.
270  * - \f$ X_{o,p} = \max (X_{o}^{min}, X_o) \f$
271  * - \f$ X_{o}^{min} \f$ = minimum mole fraction of solvent allowed
272  * in the denominator.
273  *
274  * @param molal Output vector of molalities. Length: m_kk.
275  */
276  void getMolalities(doublereal* const molal) const;
277 
278  //! Set the molalities of the solutes in a phase
279  /*!
280  * Note, the entry for the solvent is not used. We are supplied with the
281  * molalities of all of the solute species. We then calculate the mole
282  * fractions of all species and update the ThermoPhase object.
283  * \f[
284  * m_i = \frac{X_i}{M_o/1000 * X_{o,p}}
285  * \f]
286  * where
287  * - \f$M_o\f$ is the molecular weight of the solvent
288  * - \f$X_o\f$ is the mole fraction of the solvent
289  * - \f$X_i\f$ is the mole fraction of the solute.
290  * - \f$X_{o,p} = \max(X_o^{min}, X_o)\f$
291  * - \f$X_o^{min}\f$ = minimum mole fraction of solvent allowed
292  * in the denominator.
293  *
294  * The formulas for calculating mole fractions are
295  * \f[
296  * L^{sum} = \frac{1}{\tilde{M}_o X_o} = \frac{1}{\tilde{M}_o} + \sum_{i\ne o} m_i
297  * \f]
298  * Then,
299  * \f[
300  * X_o = \frac{1}{\tilde{M}_o L^{sum}}
301  * \f]
302  * \f[
303  * X_i = \frac{m_i}{L^{sum}}
304  * \f]
305  * It is currently an error if the solvent mole fraction is attempted to be
306  * set to a value lower than \f$ X_o^{min} \f$.
307  *
308  * @param molal Input vector of molalities. Length: m_kk.
309  */
310  void setMolalities(const doublereal* const molal);
311 
312  //! Set the molalities of a phase
313  /*!
314  * Set the molalities of the solutes in a phase. Note, the entry for the
315  * solvent is not used.
316  *
317  * @param xMap Composition Map containing the molalities.
318  */
319  void setMolalitiesByName(const compositionMap& xMap);
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 name String containing the information for a composition map.
327  */
328  void setMolalitiesByName(const std::string& name);
329 
330  /**
331  * @}
332  * @name Activities, Standard States, and Activity Concentrations
333  *
334  * The activity \f$a_k\f$ of a species in solution is related to the
335  * chemical potential by \f[ \mu_k = \mu_k^0(T) + \hat R T \log a_k. \f] The
336  * quantity \f$\mu_k^0(T,P)\f$ is the chemical potential at unit activity,
337  * which depends only on temperature and pressure.
338  * @{
339  */
340 
341  /**
342  * We set the convention to molality here.
343  */
344  int activityConvention() const;
345 
346  virtual void getActivityConcentrations(doublereal* c) const;
347  virtual doublereal standardConcentration(size_t k=0) const;
348 
349  //! Get the array of non-dimensional activities (molality based for this
350  //! class and classes that derive from it) at the current solution
351  //! temperature, pressure, and solution concentration.
352  /*!
353  * All standard state properties for molality-based phases are evaluated
354  * consistent with the molality scale. Therefore, this function must return
355  * molality-based activities.
356  *
357  * \f[
358  * a_i^\triangle = \gamma_k^{\triangle} \frac{m_k}{m^\triangle}
359  * \f]
360  *
361  * This function must be implemented in derived classes.
362  *
363  * @param ac Output vector of molality-based activities. Length: m_kk.
364  */
365  virtual void getActivities(doublereal* ac) const;
366 
367  //! Get the array of non-dimensional activity coefficients at
368  //! the current solution temperature, pressure, and solution concentration.
369  /*!
370  * These are mole-fraction based activity coefficients. In this
371  * object, their calculation is based on translating the values
372  * of the molality-based activity coefficients.
373  * See Denbigh p. 278 for a thorough discussion.
374  *
375  * The molar-based activity coefficients \f$ \gamma_k \f$ may be calculated
376  * from the molality-based activity coefficients, \f$ \gamma_k^\triangle \f$
377  * by the following formula.
378  * \f[
379  * \gamma_k = \frac{\gamma_k^\triangle}{X_o}
380  * \f]
381  *
382  * For purposes of establishing a convention, the molar activity coefficient of the
383  * solvent is set equal to the molality-based activity coefficient of the
384  * solvent:
385  *
386  * \f[
387  * \gamma_o = \gamma_o^\triangle
388  * \f]
389  *
390  * Derived classes don't need to overload this function. This function is
391  * handled at this level.
392  *
393  * @param ac Output vector containing the mole-fraction based activity
394  * coefficients. length: m_kk.
395  */
396  virtual void getActivityCoefficients(doublereal* ac) const;
397 
398  //! Get the array of non-dimensional molality based activity coefficients at
399  //! the current solution temperature, pressure, and solution concentration.
400  /*!
401  * See Denbigh p. 278 for a thorough discussion. This class must be
402  * overridden in classes which derive from MolalityVPSSTP. This function
403  * takes over from the molar-based activity coefficient calculation,
404  * getActivityCoefficients(), in derived classes.
405  *
406  * These molality based activity coefficients are scaled according to the
407  * current pH scale. See the Eq3/6 manual for details.
408  *
409  * Activity coefficients for species k may be altered between scales s1 to
410  * s2 using the following formula
411  *
412  * \f[
413  * ln(\gamma_k^{s2}) = ln(\gamma_k^{s1})
414  * + \frac{z_k}{z_j} \left( ln(\gamma_j^{s2}) - ln(\gamma_j^{s1}) \right)
415  * \f]
416  *
417  * where j is any one species. For the NBS scale, j is equal to the Cl-
418  * species and
419  *
420  * \f[
421  * ln(\gamma_{Cl-}^{s2}) = \frac{-A_{\phi} \sqrt{I}}{1.0 + 1.5 \sqrt{I}}
422  * \f]
423  *
424  * @param acMolality Output vector containing the molality based activity
425  * coefficients. length: m_kk.
426  */
427  virtual void getMolalityActivityCoefficients(doublereal* acMolality) const;
428 
429  //! Calculate the osmotic coefficient
430  /*!
431  * \f[
432  * \phi = \frac{- ln(a_o)}{\tilde{M}_o \sum_{i \ne o} m_i}
433  * \f]
434  *
435  * Note there are a few of definitions of the osmotic coefficient floating
436  * around. We use the one defined in (Activity Coefficients in Electrolyte
437  * Solutions, K. S. Pitzer CRC Press, Boca Raton, 1991, p. 85, Eqn. 28).
438  * This definition is most clearly related to theoretical calculation.
439  *
440  * units = dimensionless
441  */
442  virtual double osmoticCoefficient() const;
443 
444  //@}
445 
446  //! Set equation of state parameter values from XML entries.
447  /*!
448  * This method is called by function importPhase() when processing a phase
449  * definition in an input file. It should be overloaded in subclasses to set
450  * any parameters that are specific to that particular phase model.
451  *
452  * The MolalityVPSSTP object defines a new method for setting the
453  * concentrations of a phase. The new method is defined by a block called
454  * "soluteMolalities". If this block is found, the concentrations within
455  * that phase are set to the "name":"molalities pairs found within that XML
456  * block. The solvent concentration is then set to everything else.
457  *
458  * The function first calls the overloaded function,
459  * VPStandardStateTP::setStateFromXML(), to pick up the parent class
460  * behavior.
461  *
462  * usage: Overloaded functions should call this function before carrying out
463  * their own behavior.
464  *
465  * @param state An XML_Node object corresponding to the "state" entry for
466  * this phase in the input file.
467  *
468  * @deprecated The XML input format is deprecated and will be removed in
469  * Cantera 3.0.
470  */
471  virtual void setStateFromXML(const XML_Node& state);
472 
473  //@}
474  //! @name Initialization
475  /// The following methods are used in the process of constructing the phase
476  /// and setting its parameters from a specification in an input file. They
477  /// are not normally used in application programs. To see how they are used,
478  /// see importPhase().
479  //@{
480 
481  virtual bool addSpecies(shared_ptr<Species> spec);
482  virtual void initThermo();
483 
484  //@}
485 
486  //! Set the temperature (K), pressure (Pa), and molalities
487  //!(gmol kg-1) of the solutes
488  /*!
489  * @param t Temperature (K)
490  * @param p Pressure (Pa)
491  * @param molalities Input vector of molalities of the solutes.
492  * Length: m_kk.
493  */
494  void setState_TPM(doublereal t, doublereal p,
495  const doublereal* const molalities);
496 
497  //! Set the temperature (K), pressure (Pa), and molalities.
498  /*!
499  * @param t Temperature (K)
500  * @param p Pressure (Pa)
501  * @param m compositionMap containing the molalities
502  */
503  void setState_TPM(doublereal t, doublereal p, const compositionMap& m);
504 
505  //! Set the temperature (K), pressure (Pa), and molalities.
506  /*!
507  * @param t Temperature (K)
508  * @param p Pressure (Pa)
509  * @param m String which gets translated into a composition
510  * map for the molalities of the solutes.
511  */
512  void setState_TPM(doublereal t, doublereal p, const std::string& m);
513 
514  //! @copydoc ThermoPhase::setState
515  /*!
516  * Additionally uses the keys `molalities` or `M` to set the molalities.
517  */
518  virtual void setState(const AnyMap& state);
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  //! Scaling to be used for output of single-ion species activity
571  //! coefficients.
572  /*!
573  * Index of the species to be used in the single-ion scaling law. This is
574  * the identity of the Cl- species for the PHSCALE_NBS scaling. Either
575  * PHSCALE_PITZER or PHSCALE_NBS
576  */
578 
579  //! Index of the phScale species
580  /*!
581  * Index of the species to be used in the single-ion scaling law. This is
582  * the identity of the Cl- species for the PHSCALE_NBS scaling
583  */
584  size_t m_indexCLM;
585 
586  //! Molecular weight of the Solvent
587  doublereal m_weightSolvent;
588 
589  /*!
590  * In any molality implementation, it makes sense to have a minimum solvent
591  * mole fraction requirement, since the implementation becomes singular in
592  * the xmolSolvent=0 limit. The default is to set it to 0.01. We then modify
593  * the molality definition to ensure that molal_solvent = 0 when
594  * xmol_solvent = 0.
595  */
596  doublereal m_xmolSolventMIN;
597 
598  //! This is the multiplication factor that goes inside log expressions
599  //! involving the molalities of species. It's equal to Wt_0 / 1000, where
600  //! Wt_0 = weight of solvent (kg/kmol)
601  doublereal m_Mnaught;
602 
603  //! Current value of the molalities of the species in the phase. Note this
604  //! vector is a mutable quantity. units are (kg/kmol)
606 };
607 
608 
609 //! Scale to be used for the output of single-ion activity coefficients is that
610 //! used by Pitzer.
611 /*!
612  * This is the internal scale used within the code. One property is that the
613  * activity coefficients for the cation and anion of a single salt will be
614  * equal. This scale is the one presumed by the formulation of the single-ion
615  * activity coefficients described in this report.
616  *
617  * Activity coefficients for species k may be altered between scales s1 to s2
618  * using the following formula
619  *
620  * \f[
621  * ln(\gamma_k^{s2}) = ln(\gamma_k^{s1})
622  * + \frac{z_k}{z_j} \left( ln(\gamma_j^{s2}) - ln(\gamma_j^{s1}) \right)
623  * \f]
624  *
625  * where j is any one species.
626  */
627 const int PHSCALE_PITZER = 0;
628 
629 //! Scale to be used for evaluation of single-ion activity coefficients is that
630 //! used by the NBS standard for evaluation of the pH variable.
631 /*!
632  * This is not the internal scale used within the code.
633  *
634  * Activity coefficients for species k may be altered between scales s1 to s2
635  * using the following formula
636  *
637  * \f[
638  * ln(\gamma_k^{s2}) = ln(\gamma_k^{s1})
639  * + \frac{z_k}{z_j} \left( ln(\gamma_j^{s2}) - ln(\gamma_j^{s1}) \right)
640  * \f]
641  *
642  * where j is any one species. For the NBS scale, j is equal to the Cl- species
643  * and
644  *
645  * \f[
646  * ln(\gamma_{Cl-}^{s2}) = \frac{-A_{\phi} \sqrt{I}}{1.0 + 1.5 \sqrt{I}}
647  * \f]
648  *
649  * This is the NBS pH scale, which is used in all conventional pH measurements.
650  * and is based on the Bates-Guggenheim equations.
651  */
652 const int PHSCALE_NBS = 1;
653 
654 }
655 
656 #endif
Header file for a derived class of ThermoPhase that handles variable pressure standard state methods ...
A map of string keys to values whose type can vary at runtime.
Definition: AnyMap.h:360
virtual void setStateFromXML(const XML_Node &state)
Set equation of state parameter values from XML entries.
virtual void applyphScale(doublereal *acMolality) const
Apply the current phScale to a set of activity Coefficients or activities.
void setMolalitiesByName(const compositionMap &xMap)
Set the molalities of a phase.
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 ...
doublereal moleFSolventMin() const
Returns the minimum mole fraction in the molality formulation.
virtual void getActivityCoefficients(doublereal *ac) const
Get the array of non-dimensional activity coefficients at the current solution temperature,...
void getMolalities(doublereal *const molal) const
This function will return the molalities of the species.
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 setState(const AnyMap &state)
Set the state using an AnyMap containing any combination of properties supported by the thermodynamic...
virtual void getUnscaledMolalityActivityCoefficients(doublereal *acMolality) const
Get the array of unscaled non-dimensional molality based activity coefficients at the current solutio...
virtual void getMolalityActivityCoefficients(doublereal *acMolality) const
Get the array of non-dimensional molality based activity coefficients at the current solution tempera...
size_t m_indexCLM
Index of the phScale species.
virtual size_t findCLMIndex() const
Returns the index of the Cl- species.
virtual double osmoticCoefficient() const
Calculate the osmotic coefficient.
void setMolalities(const doublereal *const molal)
Set the molalities of the solutes in a phase.
virtual void getActivityConcentrations(doublereal *c) const
This method returns an array of generalized concentrations.
int pHScale() const
Reports the pH scale, which determines the scale for single-ion activity coefficients.
void setpHScale(const int pHscaleType)
Set the pH scale, which determines the scale for single-ion activity coefficients.
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 setMoleFSolventMin(doublereal xmolSolventMIN)
Sets the minimum mole fraction in the molality formulation.
virtual std::string phaseOfMatter() const
String indicating the mechanical phase of the matter in this Phase.
int activityConvention() const
We set the convention to molality here.
int m_pHScalingType
Scaling to be used for output of single-ion species activity coefficients.
MolalityVPSSTP()
Default Constructor.
doublereal m_Mnaught
This is the multiplication factor that goes inside log expressions involving the molalities of specie...
void calcMolalities() const
Calculates the molality of all species and stores the result internally.
vector_fp m_molalities
Current value of the molalities of the species in the phase.
virtual void getActivities(doublereal *ac) const
Get the array of non-dimensional activities (molality based for this class and classes that derive fr...
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.
doublereal m_weightSolvent
Molecular weight of the Solvent.
virtual doublereal standardConcentration(size_t k=0) const
Return the standard concentration for the kth species.
std::string name() const
Return the name of the phase.
Definition: Phase.cpp:84
This is a filter class for ThermoPhase that implements some preparatory steps for efficiently handlin...
virtual bool addSpecies(shared_ptr< Species > spec)
Add a Species to this Phase.
Definition: Phase.cpp:833
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:104
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
Definition: ct_defs.h:180
std::map< std::string, double > compositionMap
Map connecting a string name with a double.
Definition: ct_defs.h:172
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:264
const int PHSCALE_PITZER
Scale to be used for the output of single-ion activity coefficients is that used by Pitzer.
const int PHSCALE_NBS
Scale to be used for evaluation of single-ion activity coefficients is that used by the NBS standard ...