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