Cantera  2.4.0
IdealMolalSoln.h
Go to the documentation of this file.
1 /**
2  * @file IdealMolalSoln.h
3  * ThermoPhase object for the ideal molal equation of
4  * state (see \ref thermoprops
5  * and class \link Cantera::IdealMolalSoln IdealMolalSoln\endlink).
6  *
7  * Header file for a derived class of ThermoPhase that handles variable pressure
8  * standard state methods for calculating thermodynamic properties that are
9  * further based upon activities on the molality scale. The Ideal molal solution
10  * assumes that all molality-based activity coefficients are equal to one. This
11  * turns out to be highly nonlinear in the limit of the solvent mole fraction
12  * going to zero.
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_IDEALMOLALSOLN_H
19 #define CT_IDEALMOLALSOLN_H
20 
21 #include "MolalityVPSSTP.h"
22 
23 namespace Cantera
24 {
25 
26 /**
27  * This phase is based upon the mixing-rule assumption that all molality-based
28  * activity coefficients are equal to one.
29  *
30  * This is a full instantiation of a ThermoPhase object. The assumption is that
31  * the molality-based activity coefficient is equal to one. This also implies
32  * that the osmotic coefficient is equal to one.
33  *
34  * Note, this does not mean that the solution is an ideal solution. In fact,
35  * there is a singularity in the formulation as the solvent concentration goes
36  * to zero.
37  *
38  * The mechanical equation of state is currently assumed to be that of an
39  * incompressible solution. This may change in the future. Each species has its
40  * own molar volume. The molar volume is a constant.
41  *
42  * Class IdealMolalSoln represents a condensed phase. The phase and the pure
43  * species phases which comprise the standard states of the species are assumed
44  * to have zero volume expansivity and zero isothermal compressibility. Each
45  * species does, however, have constant but distinct partial molar volumes equal
46  * to their pure species molar volumes. The class derives from class
47  * ThermoPhase, and overloads the virtual methods defined there with ones that
48  * use expressions appropriate for incompressible mixtures.
49  *
50  * The standard concentrations can have three different forms.
51  * See setStandardConcentrationModel().
52  *
53  * \f$ V^0_0 \f$ is the solvent standard molar volume. \f$ m^{\Delta} \f$ is a
54  * constant equal to a molality of \f$ 1.0 \quad\mbox{gm kmol}^{-1} \f$.
55  *
56  * The current default is to have mformGC = 2.
57  *
58  * The value and form of the activity concentration will affect reaction rate
59  * constants involving species in this phase.
60  *
61  * <thermo model="IdealMolalSoln">
62  * <standardConc model="solvent_volume" />
63  * <solvent> H2O(l) </solvent>
64  * <activityCoefficients model="IdealMolalSoln" >
65  * <idealMolalSolnCutoff model="polyExp">
66  * <gamma_O_limit> 1.0E-5 </gamma_O_limit>
67  * <gamma_k_limit> 1.0E-5 <gamma_k_limit>
68  * <X_o_cutoff> 0.20 </X_o_cutoff>
69  * <C_0_param> 0.05 </C_0_param>
70  * <slope_f_limit> 0.6 </slope_f_limit>
71  * <slope_g_limit> 0.0 </slope_g_limit>
72  * </idealMolalSolnCutoff>
73  * </activityCoefficients>
74  * </thermo>
75  *
76  * @ingroup thermoprops
77  */
79 {
80 public:
81  /// Constructor
83 
84  //! Constructor for phase initialization
85  /*!
86  * This constructor will initialize a phase, by reading the required
87  * information from an input file.
88  *
89  * @param inputFile Name of the Input file that contains information
90  * about the phase
91  * @param id id of the phase within the input file
92  */
93  IdealMolalSoln(const std::string& inputFile, const std::string& id = "");
94 
95  //! Constructor for phase initialization
96  /*!
97  * This constructor will initialize a phase, by reading the required
98  * information from XML_Node tree.
99  *
100  * @param phaseRef reference for an XML_Node tree that contains
101  * the information necessary to initialize the phase.
102  * @param id id of the phase within the input file
103  */
104  IdealMolalSoln(XML_Node& phaseRef, const std::string& id = "");
105 
106  virtual std::string type() const {
107  return "IdealMolalSoln";
108  }
109 
110  //! @}
111  //! @name Molar Thermodynamic Properties of the Solution
112  //! @{
113 
114  //! Molar enthalpy of the solution. Units: J/kmol.
115  /*!
116  * Returns the amount of enthalpy per mole of solution. For an ideal molal
117  * solution,
118  * \f[
119  * \bar{h}(T, P, X_k) = \sum_k X_k \bar{h}_k(T)
120  * \f]
121  * The formula is written in terms of the partial molar enthalpies.
122  * \f$ \bar{h}_k(T, p, m_k) \f$.
123  * See the partial molar enthalpy function, getPartialMolarEnthalpies(),
124  * for details.
125  *
126  * Units: J/kmol
127  */
128  virtual doublereal enthalpy_mole() const;
129 
130  //! Molar internal energy of the solution: Units: J/kmol.
131  /*!
132  * Returns the amount of internal energy per mole of solution. For an ideal
133  * molal solution,
134  * \f[
135  * \bar{u}(T, P, X_k) = \sum_k X_k \bar{u}_k(T)
136  * \f]
137  * The formula is written in terms of the partial molar internal energy.
138  * \f$ \bar{u}_k(T, p, m_k) \f$.
139  */
140  virtual doublereal intEnergy_mole() const;
141 
142  //! Molar entropy of the solution. Units: J/kmol/K.
143  /*!
144  * Returns the amount of entropy per mole of solution. For an ideal molal
145  * solution,
146  * \f[
147  * \bar{s}(T, P, X_k) = \sum_k X_k \bar{s}_k(T)
148  * \f]
149  * The formula is written in terms of the partial molar entropies.
150  * \f$ \bar{s}_k(T, p, m_k) \f$.
151  * See the partial molar entropies function, getPartialMolarEntropies(),
152  * for details.
153  *
154  * Units: J/kmol/K.
155  */
156  virtual doublereal entropy_mole() const;
157 
158  //! Molar Gibbs function for the solution: Units J/kmol.
159  /*!
160  * Returns the Gibbs free energy of the solution per mole of the solution.
161  *
162  * \f[
163  * \bar{g}(T, P, X_k) = \sum_k X_k \mu_k(T)
164  * \f]
165  *
166  * Units: J/kmol
167  */
168  virtual doublereal gibbs_mole() const;
169 
170  //! Molar heat capacity of the solution at constant pressure. Units: J/kmol/K.
171  /*!
172  * \f[
173  * \bar{c}_p(T, P, X_k) = \sum_k X_k \bar{c}_{p,k}(T)
174  * \f]
175  *
176  * Units: J/kmol/K
177  */
178  virtual doublereal cp_mole() const;
179 
180  //@}
181  /** @name Mechanical Equation of State Properties
182  *
183  * In this equation of state implementation, the density is a function only
184  * of the mole fractions. Therefore, it can't be an independent variable.
185  * Instead, the pressure is used as the independent variable. Functions
186  * which try to set the thermodynamic state by calling setDensity() may
187  * cause an exception to be thrown.
188  */
189  //@{
190 
191 protected:
192  /**
193  * Calculate the density of the mixture using the partial molar volumes and
194  * mole fractions as input
195  *
196  * The formula for this is
197  *
198  * \f[
199  * \rho = \frac{\sum_k{X_k W_k}}{\sum_k{X_k V_k}}
200  * \f]
201  *
202  * where \f$X_k\f$ are the mole fractions, \f$W_k\f$ are the molecular
203  * weights, and \f$V_k\f$ are the pure species molar volumes.
204  *
205  * Note, the basis behind this formula is that in an ideal solution the
206  * partial molar volumes are equal to the pure species molar volumes. We
207  * have additionally specified in this class that the pure species molar
208  * volumes are independent of temperature and pressure.
209  */
210  void calcDensity();
211 
212 public:
213  /**
214  * Overridden setDensity() function is necessary because the density is not
215  * an independent variable.
216  *
217  * This function will now throw an error condition
218  *
219  * @internal May have to adjust the strategy here to make the eos for these
220  * materials slightly compressible, in order to create a condition where
221  * the density is a function of the pressure.
222  *
223  * @param rho Input Density
224  */
225  virtual void setDensity(const doublereal rho);
226 
227  /**
228  * Overridden setMolarDensity() function is necessary because the density
229  * is not an independent variable.
230  *
231  * This function will now throw an error condition.
232  *
233  * @param rho Input Density
234  */
235  virtual void setMolarDensity(const doublereal rho);
236 
237  //! The isothermal compressibility. Units: 1/Pa.
238  /*!
239  * The isothermal compressibility is defined as
240  * \f[
241  * \kappa_T = -\frac{1}{v}\left(\frac{\partial v}{\partial P}\right)_T
242  * \f]
243  *
244  * It's equal to zero for this model, since the molar volume doesn't change
245  * with pressure or temperature.
246  */
247  virtual doublereal isothermalCompressibility() const;
248 
249  //! The thermal expansion coefficient. Units: 1/K.
250  /*!
251  * The thermal expansion coefficient is defined as
252  *
253  * \f[
254  * \beta = \frac{1}{v}\left(\frac{\partial v}{\partial T}\right)_P
255  * \f]
256  *
257  * It's equal to zero for this model, since the molar volume doesn't change
258  * with pressure or temperature.
259  */
260  virtual doublereal thermalExpansionCoeff() const;
261 
262  /**
263  * @}
264  * @name Activities and Activity Concentrations
265  *
266  * The activity \f$a_k\f$ of a species in solution is related to the
267  * chemical potential by \f[ \mu_k = \mu_k^0(T) + \hat R T \log a_k. \f] The
268  * quantity \f$\mu_k^0(T)\f$ is the chemical potential at unit activity,
269  * which depends only on temperature and the pressure.
270  * @{
271  */
272 
273  virtual void getActivityConcentrations(doublereal* c) const;
274  virtual doublereal standardConcentration(size_t k=0) const;
275 
276  /*!
277  * Get the array of non-dimensional activities at the current solution
278  * temperature, pressure, and solution concentration.
279  *
280  * (note solvent is on molar scale)
281  *
282  * @param ac Output activity coefficients. Length: m_kk.
283  */
284  virtual void getActivities(doublereal* ac) const;
285 
286  /*!
287  * Get the array of non-dimensional molality-based activity coefficients at
288  * the current solution temperature, pressure, and solution concentration.
289  *
290  * (note solvent is on molar scale. The solvent molar
291  * based activity coefficient is returned).
292  *
293  * @param acMolality Output Molality-based activity coefficients.
294  * Length: m_kk.
295  */
296  virtual void getMolalityActivityCoefficients(doublereal* acMolality) const;
297 
298  //@}
299  /// @name Partial Molar Properties of the Solution
300  //@{
301 
302  //!Get the species chemical potentials: Units: J/kmol.
303  /*!
304  * This function returns a vector of chemical potentials of the species in
305  * solution.
306  *
307  * \f[
308  * \mu_k = \mu^{o}_k(T,P) + R T \ln(\frac{m_k}{m^\Delta})
309  * \f]
310  * \f[
311  * \mu_w = \mu^{o}_w(T,P) +
312  * R T ((X_w - 1.0) / X_w)
313  * \f]
314  *
315  * \f$ w \f$ refers to the solvent species.
316  * \f$ X_w \f$ is the mole fraction of the solvent.
317  * \f$ m_k \f$ is the molality of the kth solute.
318  * \f$ m^\Delta \f$ is 1 gmol solute per kg solvent.
319  *
320  * Units: J/kmol.
321  *
322  * @param mu Output vector of species chemical potentials. Length: m_kk.
323  */
324  virtual void getChemPotentials(doublereal* mu) const;
325 
326  //! Returns an array of partial molar enthalpies for the species in the
327  //! mixture.
328  /*!
329  * Units (J/kmol). For this phase, the partial molar enthalpies are equal to
330  * the species standard state enthalpies.
331  * \f[
332  * \bar h_k(T,P) = \hat h^{ref}_k(T) + (P - P_{ref}) \hat V^0_k
333  * \f]
334  * The reference-state pure-species enthalpies, \f$ \hat h^{ref}_k(T) \f$,
335  * at the reference pressure,\f$ P_{ref} \f$, are computed by the species
336  * thermodynamic property manager. They are polynomial functions of
337  * temperature.
338  * @see MultiSpeciesThermo
339  *
340  * @param hbar Output vector of partial molar enthalpies.
341  * Length: m_kk.
342  */
343  virtual void getPartialMolarEnthalpies(doublereal* hbar) const;
344 
345  //! Returns an array of partial molar entropies of the species in the
346  //! solution. Units: J/kmol.
347  /*!
348  * Maxwell's equations provide an insight in how to calculate this
349  * (p.215 Smith and Van Ness)
350  * \f[
351  * \frac{d(\mu_k)}{dT} = -\bar{s}_i
352  * \f]
353  * For this phase, the partial molar entropies are equal to the standard
354  * state species entropies plus the ideal molal solution contribution.
355  *
356  * \f[
357  * \bar{s}_k(T,P) = s^0_k(T) - R \ln( \frac{m_k}{m^{\triangle}} )
358  * \f]
359  * \f[
360  * \bar{s}_w(T,P) = s^0_w(T) - R ((X_w - 1.0) / X_w)
361  * \f]
362  *
363  * The subscript, w, refers to the solvent species. \f$ X_w \f$ is the mole
364  * fraction of solvent. The reference-state pure-species entropies,\f$
365  * s^0_k(T) \f$, at the reference pressure, \f$ P_{ref} \f$, are computed by
366  * the species thermodynamic property manager. They are polynomial functions
367  * of temperature.
368  * @see MultiSpeciesThermo
369  *
370  * @param sbar Output vector of partial molar entropies.
371  * Length: m_kk.
372  */
373  virtual void getPartialMolarEntropies(doublereal* sbar) const;
374 
375  // partial molar volumes of the species Units: m^3 kmol-1.
376  /*!
377  * For this solution, the partial molar volumes are equal to the constant
378  * species molar volumes.
379  *
380  * Units: m^3 kmol-1.
381  * @param vbar Output vector of partial molar volumes.
382  */
383  virtual void getPartialMolarVolumes(doublereal* vbar) const;
384 
385  //! Partial molar heat capacity of the solution:. UnitsL J/kmol/K
386  /*!
387  * The kth partial molar heat capacity is equal to the temperature
388  * derivative of the partial molar enthalpy of the kth species in the
389  * solution at constant P and composition (p. 220 Smith and Van Ness).
390  * \f[
391  * \bar{Cp}_k(T,P) = {Cp}^0_k(T)
392  * \f]
393  *
394  * For this solution, this is equal to the reference state heat capacities.
395  *
396  * Units: J/kmol/K
397  *
398  * @param cpbar Output vector of partial molar heat capacities.
399  * Length: m_kk.
400  */
401  virtual void getPartialMolarCp(doublereal* cpbar) const;
402 
403  //@}
404 
405  // -------------- Utilities -------------------------------
406 
407  virtual bool addSpecies(shared_ptr<Species> spec);
408 
409  virtual void initThermoXML(XML_Node& phaseNode, const std::string& id="");
410 
411  virtual void initThermo();
412 
413  //! Set the standard concentration model.
414  /*!
415  * Must be one of 'unity', 'molar_volume', or 'solvent_volume'.
416  * The default is 'solvent_volume'.
417  *
418  * | model | ActivityConc | StandardConc |
419  * | -------------- | -------------------------------- | ------------------ |
420  * | unity | \f$ {m_k}/ { m^{\Delta}}\f$ | \f$ 1.0 \f$ |
421  * | molar_volume | \f$ m_k / (m^{\Delta} V_k)\f$ | \f$ 1.0 / V_k \f$ |
422  * | solvent_volume | \f$ m_k / (m^{\Delta} V^0_0)\f$ | \f$ 1.0 / V^0_0\f$ |
423  */
424  void setStandardConcentrationModel(const std::string& model);
425 
426  //! Set cutoff model. Must be one of 'none', 'poly', or 'polyExp'.
427  void setCutoffModel(const std::string& model);
428 
429  //! Report the molar volume of species k
430  /*!
431  * units - \f$ m^3 kmol^{-1} \f$
432  *
433  * @param k Species index.
434  */
435  double speciesMolarVolume(int k) const;
436 
437  /*!
438  * Fill in a return vector containing the species molar volumes
439  * units - \f$ m^3 kmol^{-1} \f$
440  *
441  * @param smv Output vector of species molar volumes.
442  */
443  void getSpeciesMolarVolumes(double* smv) const;
444  //@}
445 
446 protected:
447  //! Species molar volume \f$ m^3 kmol^{-1} \f$
449 
450  /**
451  * The standard concentrations can have one of three different forms:
452  * 0 = 'unity', 1 = 'molar_volume', 2 = 'solvent_volume'. See
453  * setStandardConcentrationModel().
454  */
455  int m_formGC;
456 
457  //! Cutoff type
459 
460 private:
461  //! vector of size m_kk, used as a temporary holding area.
462  mutable vector_fp m_tmpV;
463 
464  //! Logarithm of the molal activity coefficients
465  /*!
466  * Normally these are all one. However, stability schemes will change that
467  */
469 public:
470  //! value of the solute mole fraction that centers the cutoff polynomials
471  //! for the cutoff =1 process;
472  doublereal IMS_X_o_cutoff_;
473 
474  //! gamma_o value for the cutoff process at the zero solvent point
475  doublereal IMS_gamma_o_min_;
476 
477  //! gamma_k minimum for the cutoff process at the zero solvent point
478  doublereal IMS_gamma_k_min_;
479 
480  //! Parameter in the polyExp cutoff treatment. This is the slope of the f
481  //! function at the zero solvent point. Default value is 0.6
482  doublereal IMS_slopefCut_;
483 
484  //! Parameter in the polyExp cutoff treatment. This is the slope of the g
485  //! function at the zero solvent point. Default value is 0.0
486  doublereal IMS_slopegCut_;
487 
488  //! @name Parameters in the polyExp cutoff treatment having to do with rate
489  //! of exp decay
490  //! @{
491  doublereal IMS_cCut_;
492  doublereal IMS_dfCut_;
493  doublereal IMS_efCut_;
494  doublereal IMS_afCut_;
495  doublereal IMS_bfCut_;
496  doublereal IMS_dgCut_;
497  doublereal IMS_egCut_;
498  doublereal IMS_agCut_;
499  doublereal IMS_bgCut_;
500  //! @}
501 
502 private:
503  //! This function will be called to update the internally stored
504  //! natural logarithm of the molality activity coefficients
505  /*!
506  * Normally the solutes are all zero. However, sometimes they are not,
507  * due to stability schemes.
508  *
509  * gamma_k_molar = gamma_k_molal / Xmol_solvent
510  *
511  * gamma_o_molar = gamma_o_molal
512  */
513  void s_updateIMS_lnMolalityActCoeff() const;
514 
515  //! Calculate parameters for cutoff treatments of activity coefficients
516  /*!
517  * Some cutoff treatments for the activity coefficients actually require
518  * some calculations to create a consistent treatment.
519  *
520  * This routine is called during the setup to calculate these parameters
521  */
522  void calcIMSCutoffParams_();
523 };
524 
525 }
526 
527 #endif
virtual doublereal intEnergy_mole() const
Molar internal energy of the solution: Units: J/kmol.
virtual std::string type() const
String indicating the thermodynamic model implemented.
virtual doublereal standardConcentration(size_t k=0) const
Return the standard concentration for the kth species.
virtual void getPartialMolarVolumes(doublereal *vbar) const
void getSpeciesMolarVolumes(double *smv) const
doublereal IMS_slopefCut_
Parameter in the polyExp cutoff treatment.
doublereal IMS_slopegCut_
Parameter in the polyExp cutoff treatment.
virtual void getPartialMolarEntropies(doublereal *sbar) const
Returns an array of partial molar entropies of the species in the solution.
IdealMolalSoln()
Constructor.
virtual void getActivities(doublereal *ac) const
vector_fp m_tmpV
vector of size m_kk, used as a temporary holding area.
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:97
virtual void getMolalityActivityCoefficients(doublereal *acMolality) const
virtual void getPartialMolarCp(doublereal *cpbar) const
Partial molar heat capacity of the solution:. UnitsL J/kmol/K.
doublereal IMS_gamma_k_min_
gamma_k minimum for the cutoff process at the zero solvent point
virtual void setDensity(const doublereal rho)
Overridden setDensity() function is necessary because the density is not an independent variable...
void setStandardConcentrationModel(const std::string &model)
Set the standard concentration model.
virtual void setMolarDensity(const doublereal rho)
Overridden setMolarDensity() function is necessary because the density is not an independent variable...
virtual doublereal cp_mole() const
Molar heat capacity of the solution at constant pressure. Units: J/kmol/K.
doublereal IMS_gamma_o_min_
gamma_o value for the cutoff process at the zero solvent point
vector_fp m_speciesMolarVolume
Species molar volume .
Header for intermediate ThermoPhase object for phases which employ molality based activity coefficien...
virtual void getActivityConcentrations(doublereal *c) const
This method returns an array of generalized concentrations.
virtual doublereal entropy_mole() const
Molar entropy of the solution. Units: J/kmol/K.
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id="")
Import and initialize a ThermoPhase object using an XML tree.
virtual doublereal thermalExpansionCoeff() const
The thermal expansion coefficient. Units: 1/K.
virtual doublereal enthalpy_mole() const
Molar enthalpy of the solution. Units: J/kmol.
virtual bool addSpecies(shared_ptr< Species > spec)
int IMS_typeCutoff_
Cutoff type.
void s_updateIMS_lnMolalityActCoeff() const
This function will be called to update the internally stored natural logarithm of the molality activi...
void setCutoffModel(const std::string &model)
Set cutoff model. Must be one of &#39;none&#39;, &#39;poly&#39;, or &#39;polyExp&#39;.
int m_formGC
The standard concentrations can have one of three different forms: 0 = &#39;unity&#39;, 1 = &#39;molar_volume&#39;...
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
Definition: ct_defs.h:157
virtual doublereal isothermalCompressibility() const
The isothermal compressibility. Units: 1/Pa.
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials: Units: J/kmol.
virtual void getPartialMolarEnthalpies(doublereal *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.
void calcDensity()
Calculate the density of the mixture using the partial molar volumes and mole fractions as input...
This phase is based upon the mixing-rule assumption that all molality-based activity coefficients are...
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:8
virtual doublereal gibbs_mole() const
Molar Gibbs function for the solution: Units J/kmol.
void calcIMSCutoffParams_()
Calculate parameters for cutoff treatments of activity coefficients.
double speciesMolarVolume(int k) const
Report the molar volume of species k.
doublereal IMS_X_o_cutoff_
value of the solute mole fraction that centers the cutoff polynomials for the cutoff =1 process; ...
vector_fp IMS_lnActCoeffMolal_
Logarithm of the molal activity coefficients.