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