Cantera  2.3.0
MixedSolventElectrolyte.h
Go to the documentation of this file.
1 /**
2  * @file MixedSolventElectrolyte.h (see \ref thermoprops and class \link
3  * Cantera::MixedSolventElectrolyte MixedSolventElectrolyte \endlink).
4  */
5 
6 // This file is part of Cantera. See License.txt in the top-level directory or
7 // at http://www.cantera.org/license.txt for license and copyright information.
8 
9 #ifndef CT_MIXEDSOLVENTELECTROLYTEVPSSTP_H
10 #define CT_MIXEDSOLVENTELECTROLYTEVPSSTP_H
11 
12 #include "MolarityIonicVPSSTP.h"
13 
14 namespace Cantera
15 {
16 //! MixedSolventElectrolyte is a derived class of GibbsExcessVPSSTP that employs
17 //! the DH and local Margules approximations for the excess Gibbs free energy
18 /*!
19  * @attention This class currently does not have any test cases or examples. Its
20  * implementation may be incomplete, and future changes to Cantera may
21  * unexpectedly cause this class to stop working. If you use this class,
22  * please consider contributing examples or test cases. In the absence of
23  * new tests or examples, this class may be deprecated and removed in a
24  * future version of Cantera. See
25  * https://github.com/Cantera/cantera/issues/267 for additional information.
26  *
27  * MixedSolventElectrolyte derives from class GibbsExcessVPSSTP which is derived
28  * from VPStandardStateTP.
29  *
30  * The independent unknowns are pressure, temperature, and mass fraction.
31  *
32  * ## Specification of Species Standard State Properties
33  *
34  * All species are defined to have standard states that depend upon both the
35  * temperature and the pressure. The Margules approximation assumes symmetric
36  * standard states, where all of the standard state assume that the species are
37  * in pure component states at the temperature and pressure of the solution. I
38  * don't think it prevents, however, some species from being dilute in the
39  * solution.
40  *
41  * ## Specification of Solution Thermodynamic Properties
42  *
43  * The molar excess Gibbs free energy is given by the following formula which is
44  * a sum over interactions *i*. Each of the interactions are binary interactions
45  * involving two of the species in the phase, denoted, *Ai* and *Bi*. This is
46  * the generalization of the Margules formulation for a phase that has more than
47  * 2 species.
48  *
49  * \f[
50  * G^E = \sum_i \left( H_{Ei} - T S_{Ei} \right)
51  * \f]
52  * \f[
53  * H^E_i = n X_{Ai} X_{Bi} \left( h_{o,i} + h_{1,i} X_{Bi} \right)
54  * \f]
55  * \f[
56  * S^E_i = n X_{Ai} X_{Bi} \left( s_{o,i} + s_{1,i} X_{Bi} \right)
57  * \f]
58  *
59  * where n is the total moles in the solution.
60  *
61  * The activity of a species defined in the phase is given by an excess Gibbs
62  * free energy formulation.
63  *
64  * \f[
65  * a_k = \gamma_k X_k
66  * \f]
67  *
68  * where
69  *
70  * \f[
71  * R T \ln( \gamma_k )= \frac{d(n G^E)}{d(n_k)}\Bigg|_{n_i}
72  * \f]
73  *
74  * Taking the derivatives results in the following expression
75  *
76  * \f[
77  * R T \ln( \gamma_k )= \sum_i \left( \left( \delta_{Ai,k} X_{Bi} + \delta_{Bi,k} X_{Ai} - X_{Ai} X_{Bi} \right)
78  * \left( g^E_{o,i} + g^E_{1,i} X_{Bi} \right) +
79  * \left( \delta_{Bi,k} - X_{Bi} \right) X_{Ai} X_{Bi} g^E_{1,i} \right)
80  * \f]
81  * where \f$ g^E_{o,i} = h_{o,i} - T s_{o,i} \f$ and
82  * \f$ g^E_{1,i} = h_{1,i} - T s_{1,i} \f$ and where \f$ X_k \f$ is the mole
83  * fraction of species *k*.
84  *
85  * This object inherits from the class VPStandardStateTP. Therefore, the
86  * specification and calculation of all standard state and reference state
87  * values are handled at that level. Various functional forms for the standard
88  * state are permissible. The chemical potential for species *k* is equal to
89  *
90  * \f[
91  * \mu_k(T,P) = \mu^o_k(T, P) + R T \ln(\gamma_k X_k)
92  * \f]
93  *
94  * The partial molar entropy for species *k* is given by the following relation,
95  *
96  * \f[
97  * \tilde{s}_k(T,P) = s^o_k(T,P) - R \ln( \gamma_k X_k )
98  * - R T \frac{d \ln(\gamma_k) }{dT}
99  * \f]
100  *
101  * The partial molar enthalpy for species *k* is given by
102  *
103  * \f[
104  * \tilde{h}_k(T,P) = h^o_k(T,P) - R T^2 \frac{d \ln(\gamma_k)}{dT}
105  * \f]
106  *
107  * The partial molar volume for species *k* is
108  *
109  * \f[
110  * \tilde V_k(T,P) = V^o_k(T,P) + R T \frac{d \ln(\gamma_k) }{dP}
111  * \f]
112  *
113  * The partial molar Heat Capacity for species *k* is
114  *
115  * \f[
116  * \tilde{C}_{p,k}(T,P) = C^o_{p,k}(T,P) - 2 R T \frac{d \ln( \gamma_k )}{dT}
117  * - R T^2 \frac{d^2 \ln(\gamma_k) }{{dT}^2}
118  * \f]
119  *
120  * ## %Application within Kinetics Managers
121  *
122  * \f$ C^a_k\f$ are defined such that \f$ a_k = C^a_k / C^s_k, \f$ where
123  * \f$ C^s_k \f$ is a standard concentration defined below and \f$ a_k \f$ are
124  * activities used in the thermodynamic functions. These activity (or
125  * generalized) concentrations are used by kinetics manager classes to compute
126  * the forward and reverse rates of elementary reactions. The activity
127  * concentration, \f$ C^a_k \f$, is given by the following expression.
128  *
129  * \f[
130  * C^a_k = C^s_k X_k = \frac{P}{R T} X_k
131  * \f]
132  *
133  * The standard concentration for species *k* is independent of *k* and equal to
134  *
135  * \f[
136  * C^s_k = C^s = \frac{P}{R T}
137  * \f]
138  *
139  * For example, a bulk-phase binary gas reaction between species j and k,
140  * producing a new gas species l would have the following equation for its rate
141  * of progress variable, \f$ R^1 \f$, which has units of kmol m-3 s-1.
142  *
143  * \f[
144  * R^1 = k^1 C_j^a C_k^a = k^1 (C^s a_j) (C^s a_k)
145  * \f]
146  * where
147  * \f[
148  * C_j^a = C^s a_j \mbox{\quad and \quad} C_k^a = C^s a_k
149  * \f]
150  *
151  * \f$ C_j^a \f$ is the activity concentration of species j, and \f$ C_k^a \f$
152  * is the activity concentration of species k. \f$ C^s \f$ is the standard
153  * concentration. \f$ a_j \f$ is the activity of species j which is equal to the
154  * mole fraction of j.
155  *
156  * The reverse rate constant can then be obtained from the law of microscopic
157  * reversibility and the equilibrium expression for the system.
158  *
159  * \f[
160  * \frac{a_j a_k}{ a_l} = K_a^{o,1} = \exp(\frac{\mu^o_l - \mu^o_j - \mu^o_k}{R T} )
161  * \f]
162  *
163  * \f$ K_a^{o,1} \f$ is the dimensionless form of the equilibrium constant,
164  * associated with the pressure dependent standard states \f$ \mu^o_l(T,P) \f$
165  * and their associated activities, \f$ a_l \f$, repeated here:
166  *
167  * \f[
168  * \mu_l(T,P) = \mu^o_l(T, P) + R T \log(a_l)
169  * \f]
170  *
171  * We can switch over to expressing the equilibrium constant in terms of the
172  * reference state chemical potentials
173  *
174  * \f[
175  * K_a^{o,1} = \exp(\frac{\mu^{ref}_l - \mu^{ref}_j - \mu^{ref}_k}{R T} ) * \frac{P_{ref}}{P}
176  * \f]
177  *
178  * The concentration equilibrium constant, \f$ K_c \f$, may be obtained by
179  * changing over to activity concentrations. When this is done:
180  *
181  * \f[
182  * \frac{C^a_j C^a_k}{ C^a_l} = C^o K_a^{o,1} = K_c^1 =
183  * \exp(\frac{\mu^{ref}_l - \mu^{ref}_j - \mu^{ref}_k}{R T} ) * \frac{P_{ref}}{RT}
184  * \f]
185  *
186  * Kinetics managers will calculate the concentration equilibrium constant, \f$
187  * K_c \f$, using the second and third part of the above expression as a
188  * definition for the concentration equilibrium constant.
189  *
190  * For completeness, the pressure equilibrium constant may be obtained as well
191  *
192  * \f[
193  * \frac{P_j P_k}{ P_l P_{ref}} = K_p^1 = \exp(\frac{\mu^{ref}_l - \mu^{ref}_j - \mu^{ref}_k}{R T} )
194  * \f]
195  *
196  * \f$ K_p \f$ is the simplest form of the equilibrium constant for ideal gases.
197  * However, it isn't necessarily the simplest form of the equilibrium constant
198  * for other types of phases; \f$ K_c \f$ is used instead because it is
199  * completely general.
200  *
201  * The reverse rate of progress may be written down as
202  * \f[
203  * R^{-1} = k^{-1} C_l^a = k^{-1} (C^o a_l)
204  * \f]
205  *
206  * where we can use the concept of microscopic reversibility to write the
207  * reverse rate constant in terms of the forward reate constant and the
208  * concentration equilibrium constant, \f$ K_c \f$.
209  *
210  * \f[
211  * k^{-1} = k^1 K^1_c
212  * \f]
213  *
214  * \f$k^{-1} \f$ has units of s-1.
215  *
216  * @ingroup thermoprops
217  */
219 {
220 public:
222 
223  //! Construct and initialize a MixedSolventElectrolyte ThermoPhase object
224  //! directly from an XML input file
225  /*!
226  * @param inputFile Name of the input file containing the phase XML data
227  * to set up the object
228  * @param id ID of the phase in the input file. Defaults to the
229  * empty string.
230  */
231  MixedSolventElectrolyte(const std::string& inputFile,
232  const std::string& id = "");
233 
234  //! Construct and initialize a MixedSolventElectrolyte ThermoPhase object
235  //! directly from an XML database
236  /*!
237  * @param phaseRef XML phase node containing the description of the phase
238  * @param id id attribute containing the name of the phase.
239  * (default is the empty string)
240  */
241  MixedSolventElectrolyte(XML_Node& phaseRef, const std::string& id = "");
242 
245  virtual ThermoPhase* duplMyselfAsThermoPhase() const;
246 
247  virtual std::string type() const {
248  return "MixedSolventElectrolyte";
249  }
250 
251  //! @name Molar Thermodynamic Properties
252  //! @{
253 
254  virtual doublereal enthalpy_mole() const;
255  virtual doublereal entropy_mole() const;
256  virtual doublereal cp_mole() const;
257  virtual doublereal cv_mole() const;
258 
259  /**
260  * @}
261  * @name Activities, Standard States, and Activity Concentrations
262  *
263  * The activity \f$a_k\f$ of a species in solution is related to the
264  * chemical potential by \f[ \mu_k = \mu_k^0(T) + \hat R T \log a_k. \f] The
265  * quantity \f$\mu_k^0(T,P)\f$ is the chemical potential at unit activity,
266  * which depends only on temperature and pressure.
267  * @{
268  */
269 
270  virtual void getActivityCoefficients(doublereal* ac) const;
271 
272  //@}
273  /// @name Partial Molar Properties of the Solution
274  //@{
275 
276  virtual void getChemPotentials(doublereal* mu) const;
277  virtual void getPartialMolarEnthalpies(doublereal* hbar) const;
278  virtual void getPartialMolarEntropies(doublereal* sbar) const;
279  virtual void getPartialMolarCp(doublereal* cpbar) const;
280  virtual void getPartialMolarVolumes(doublereal* vbar) const;
281 
282  //! Get the array of temperature second derivatives of the log activity
283  //! coefficients
284  /*!
285  * units = 1/Kelvin
286  *
287  * @param d2lnActCoeffdT2 Output vector of temperature 2nd derivatives of
288  * the log Activity Coefficients. length = m_kk
289  *
290  */
291  virtual void getd2lnActCoeffdT2(doublereal* d2lnActCoeffdT2) const;
292 
293  //! Get the array of temperature derivatives of the log activity coefficients
294  /*!
295  * This is a virtual function, which first appears in GibbsExcessVPSSTP.
296  *
297  * units = 1/Kelvin
298  *
299  * @param dlnActCoeffdT Output vector of temperature derivatives of the
300  * log Activity Coefficients. length = m_kk
301  */
302  virtual void getdlnActCoeffdT(doublereal* dlnActCoeffdT) const;
303 
304  //! @}
305  //! @name Initialization
306  /// The following methods are used in the process of constructing the phase
307  /// and setting its parameters from a specification in an input file. They
308  /// are not normally used in application programs. To see how they are used,
309  /// see importPhase().
310  /// @{
311 
312  virtual void initThermo();
313  virtual void initThermoXML(XML_Node& phaseNode, const std::string& id);
314 
315  /**
316  * @}
317  * @name Derivatives of Thermodynamic Variables needed for Applications
318  * @{
319  */
320 
321  virtual void getdlnActCoeffds(const doublereal dTds, const doublereal* const dXds, doublereal* dlnActCoeffds) const;
322  virtual void getdlnActCoeffdlnX_diag(doublereal* dlnActCoeffdlnX_diag) const;
323  virtual void getdlnActCoeffdlnN_diag(doublereal* dlnActCoeffdlnN_diag) const;
324  virtual void getdlnActCoeffdlnN(const size_t ld, doublereal* const dlnActCoeffdlnN);
325  //@}
326 
327 private:
328  //! Process an XML node called "binaryNeutralSpeciesParameters"
329  /*!
330  * This node contains all of the parameters necessary to describe the
331  * Margules model for a particular binary interaction. This function reads
332  * the XML file and writes the coefficients it finds to an internal data
333  * structures.
334  *
335  * @param xmlBinarySpecies Reference to the XML_Node named
336  * "binaryNeutralSpeciesParameters" containing the binary interaction
337  */
338  void readXMLBinarySpecies(XML_Node& xmlBinarySpecies);
339 
340  //! Resize internal arrays within the object that depend upon the number
341  //! of binary Margules interaction terms
342  /*!
343  * @param num Number of binary Margules interaction terms
344  */
345  void resizeNumInteractions(const size_t num);
346 
347  //! Initialize lengths of local variables after all species have been
348  //! identified.
349  void initLengths();
350 
351  //! Update the activity coefficients
352  /*!
353  * This function will be called to update the internally stored natural
354  * logarithm of the activity coefficients
355  */
356  void s_update_lnActCoeff() const;
357 
358  //! Update the derivative of the log of the activity coefficients wrt T
359  /*!
360  * This function will be called to update the internally stored derivative
361  * of the natural logarithm of the activity coefficients wrt temperature.
362  */
363  void s_update_dlnActCoeff_dT() const;
364 
365  //! Update the derivative of the log of the activity coefficients
366  //! wrt log(mole fraction)
367  /*!
368  * This function will be called to update the internally stored derivative
369  * of the natural logarithm of the activity coefficients wrt logarithm of
370  * the mole fractions.
371  */
372  void s_update_dlnActCoeff_dlnX_diag() const;
373 
374  //! Update the derivative of the log of the activity coefficients
375  //! wrt log(moles) - diagonal only
376  /*!
377  * This function will be called to update the internally stored diagonal
378  * entries for the derivative of the natural logarithm of the activity
379  * coefficients wrt logarithm of the moles.
380  */
381  void s_update_dlnActCoeff_dlnN_diag() const;
382 
383  //! Update the derivative of the log of the activity coefficients wrt log(moles_m)
384  /*!
385  * This function will be called to update the internally stored derivative
386  * of the natural logarithm of the activity coefficients wrt logarithm of
387  * the mole number of species
388  */
389  void s_update_dlnActCoeff_dlnN() const;
390 
391 protected:
392  //! number of binary interaction expressions
394 
395  //! Enthalpy term for the binary mole fraction interaction of the excess
396  //! Gibbs free energy expression
398 
399  //! Enthalpy term for the ternary mole fraction interaction of the excess
400  //! Gibbs free energy expression
402 
403  //! Enthalpy term for the quaternary mole fraction interaction of the excess
404  //! Gibbs free energy expression
406 
407  //! Entropy term for the binary mole fraction interaction of the excess
408  //! Gibbs free energy expression
410 
411  //! Entropy term for the ternary mole fraction interaction of the excess
412  //! Gibbs free energy expression
414 
415  //! Entropy term for the quaternary mole fraction interaction of the excess
416  //! Gibbs free energy expression
418 
419  //! Enthalpy term for the binary mole fraction interaction of the excess
420  //! Gibbs free energy expression
422 
423  //! Enthalpy term for the ternary mole fraction interaction of the excess
424  //! Gibbs free energy expression
426 
427  //! Enthalpy term for the quaternary mole fraction interaction of the excess
428  //! Gibbs free energy expression
430 
431  //! Entropy term for the binary mole fraction interaction of the excess
432  //! Gibbs free energy expression
434 
435  //! Entropy term for the ternary mole fraction interaction of the excess
436  //! Gibbs free energy expression
438 
439  //! Entropy term for the quaternary mole fraction interaction of the excess
440  //! Gibbs free energy expression
442 
443  //! vector of species indices representing species A in the interaction
444  /*!
445  * Each Margules excess Gibbs free energy term involves two species, A and
446  * B. This vector identifies species A.
447  */
448  std::vector<size_t> m_pSpecies_A_ij;
449 
450  //! vector of species indices representing species B in the interaction
451  /*!
452  * Each Margules excess Gibbs free energy term involves two species, A and
453  * B. This vector identifies species B.
454  */
455  std::vector<size_t> m_pSpecies_B_ij;
456 
457  //! form of the Margules interaction expression
458  /*!
459  * Currently there is only one form.
460  */
462 
463  //! form of the temperature dependence of the Margules interaction expression
464  /*!
465  * Currently there is only one form -> constant wrt temperature.
466  */
468 };
469 
470 }
471 
472 #endif
virtual void getdlnActCoeffdlnN_diag(doublereal *dlnActCoeffdlnN_diag) const
Get the array of log species mole number derivatives of the log activity coefficients.
void s_update_lnActCoeff() const
Update the activity coefficients.
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
virtual void getdlnActCoeffdlnX_diag(doublereal *dlnActCoeffdlnX_diag) const
Get the array of ln mole fraction derivatives of the log activity coefficients - diagonal component o...
virtual void getActivityCoefficients(doublereal *ac) const
Get the array of non-dimensional molar-based activity coefficients at the current solution temperatur...
virtual doublereal cv_mole() const
Molar heat capacity at constant volume. Units: J/kmol/K.
vector_fp m_HE_d_ij
Enthalpy term for the quaternary mole fraction interaction of the excess Gibbs free energy expression...
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:97
vector_fp m_SE_b_ij
Entropy term for the binary mole fraction interaction of the excess Gibbs free energy expression...
virtual void getPartialMolarVolumes(doublereal *vbar) const
Return an array of partial molar volumes for the species in the mixture.
(see Thermodynamic Properties and class MolarityIonicVPSSTP).
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:93
void readXMLBinarySpecies(XML_Node &xmlBinarySpecies)
Process an XML node called "binaryNeutralSpeciesParameters".
virtual void getd2lnActCoeffdT2(doublereal *d2lnActCoeffdT2) const
Get the array of temperature second derivatives of the log activity coefficients. ...
virtual void getdlnActCoeffdT(doublereal *dlnActCoeffdT) const
Get the array of temperature derivatives of the log activity coefficients.
void initLengths()
Initialize lengths of local variables after all species have been identified.
int formTempModel_
form of the temperature dependence of the Margules interaction expression
virtual void getPartialMolarCp(doublereal *cpbar) const
Returns an array of partial molar entropies for the species in the mixture.
vector_fp m_HE_b_ij
Enthalpy term for the binary mole fraction interaction of the excess Gibbs free energy expression...
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id)
Import and initialize a ThermoPhase object using an XML tree.
MixedSolventElectrolyte is a derived class of GibbsExcessVPSSTP that employs the DH and local Margule...
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 ...
vector_fp m_VHE_d_ij
Enthalpy term for the quaternary mole fraction interaction of the excess Gibbs free energy expression...
virtual doublereal enthalpy_mole() const
Molar enthalpy. Units: J/kmol.
void s_update_dlnActCoeff_dlnX_diag() const
Update the derivative of the log of the activity coefficients wrt log(mole fraction) ...
void resizeNumInteractions(const size_t num)
Resize internal arrays within the object that depend upon the number of binary Margules interaction t...
vector_fp m_VHE_b_ij
Enthalpy term for the binary mole fraction interaction of the excess Gibbs free energy expression...
int formMargules_
form of the Margules interaction expression
vector_fp m_VHE_c_ij
Enthalpy term for the ternary mole fraction interaction of the excess Gibbs free energy expression...
virtual void getdlnActCoeffds(const doublereal dTds, const doublereal *const dXds, doublereal *dlnActCoeffds) const
Get the change in activity coefficients wrt changes in state (temp, mole fraction, etc) along a line in parameter space or along a line in physical space.
virtual ThermoPhase * duplMyselfAsThermoPhase() const
Duplication routine for objects which inherit from ThermoPhase.
vector_fp m_VSE_c_ij
Entropy term for the ternary mole fraction interaction of the excess Gibbs free energy expression...
vector_fp m_VSE_d_ij
Entropy term for the quaternary mole fraction interaction of the excess Gibbs free energy expression...
std::vector< size_t > m_pSpecies_B_ij
vector of species indices representing species B in the interaction
vector_fp m_SE_c_ij
Entropy term for the ternary mole fraction interaction of the excess Gibbs free energy expression...
vector_fp m_HE_c_ij
Enthalpy term for the ternary mole fraction interaction of the excess Gibbs free energy expression...
size_t numBinaryInteractions_
number of binary interaction expressions
virtual void getPartialMolarEntropies(doublereal *sbar) const
Returns an array of partial molar entropies for the species in the mixture.
virtual doublereal entropy_mole() const
Molar entropy. Units: J/kmol/K.
std::vector< size_t > m_pSpecies_A_ij
vector of species indices representing species A in the interaction
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
void s_update_dlnActCoeff_dlnN_diag() const
Update the derivative of the log of the activity coefficients wrt log(moles) - diagonal only...
virtual doublereal cp_mole() const
Molar heat capacity at constant pressure. Units: J/kmol/K.
void s_update_dlnActCoeff_dlnN() const
Update the derivative of the log of the activity coefficients wrt log(moles_m)
vector_fp m_SE_d_ij
Entropy term for the quaternary mole fraction interaction of the excess Gibbs free energy expression...
vector_fp m_VSE_b_ij
Entropy term for the binary mole fraction interaction of the excess Gibbs free energy expression...
Namespace for the Cantera kernel.
Definition: application.cpp:29
virtual std::string type() const
String indicating the thermodynamic model implemented.
void s_update_dlnActCoeff_dT() const
Update the derivative of the log of the activity coefficients wrt T.
virtual void getPartialMolarEnthalpies(doublereal *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.