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