Cantera  2.4.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  * @deprecated To be removed after Cantera 2.4.
218  */
220 {
221 public:
223 
224  //! Construct and initialize a MixedSolventElectrolyte ThermoPhase object
225  //! directly from an XML input file
226  /*!
227  * @param inputFile Name of the input file containing the phase XML data
228  * to set up the object
229  * @param id ID of the phase in the input file. Defaults to the
230  * empty string.
231  */
232  MixedSolventElectrolyte(const std::string& inputFile,
233  const std::string& id = "");
234 
235  //! Construct and initialize a MixedSolventElectrolyte ThermoPhase object
236  //! directly from an XML database
237  /*!
238  * @param phaseRef XML phase node containing the description of the phase
239  * @param id id attribute containing the name of the phase.
240  * (default is the empty string)
241  */
242  MixedSolventElectrolyte(XML_Node& phaseRef, const std::string& id = "");
243 
244  virtual std::string type() const {
245  return "MixedSolventElectrolyte";
246  }
247 
248  //! @name Molar Thermodynamic Properties
249  //! @{
250 
251  virtual doublereal enthalpy_mole() const;
252  virtual doublereal entropy_mole() const;
253  virtual doublereal cp_mole() const;
254  virtual doublereal cv_mole() const;
255 
256  /**
257  * @}
258  * @name Activities, Standard States, and Activity Concentrations
259  *
260  * The activity \f$a_k\f$ of a species in solution is related to the
261  * chemical potential by \f[ \mu_k = \mu_k^0(T) + \hat R T \log a_k. \f] The
262  * quantity \f$\mu_k^0(T,P)\f$ is the chemical potential at unit activity,
263  * which depends only on temperature and pressure.
264  * @{
265  */
266 
267  virtual void getActivityCoefficients(doublereal* ac) const;
268 
269  //@}
270  /// @name Partial Molar Properties of the Solution
271  //@{
272 
273  virtual void getChemPotentials(doublereal* mu) const;
274  virtual void getPartialMolarEnthalpies(doublereal* hbar) const;
275  virtual void getPartialMolarEntropies(doublereal* sbar) const;
276  virtual void getPartialMolarCp(doublereal* cpbar) const;
277  virtual void getPartialMolarVolumes(doublereal* vbar) const;
278 
279  //! Get the array of temperature second derivatives of the log activity
280  //! coefficients
281  /*!
282  * units = 1/Kelvin
283  *
284  * @param d2lnActCoeffdT2 Output vector of temperature 2nd derivatives of
285  * the log Activity Coefficients. length = m_kk
286  *
287  */
288  virtual void getd2lnActCoeffdT2(doublereal* d2lnActCoeffdT2) const;
289 
290  //! Get the array of temperature derivatives of the log activity coefficients
291  /*!
292  * This is a virtual function, which first appears in GibbsExcessVPSSTP.
293  *
294  * units = 1/Kelvin
295  *
296  * @param dlnActCoeffdT Output vector of temperature derivatives of the
297  * log Activity Coefficients. length = m_kk
298  */
299  virtual void getdlnActCoeffdT(doublereal* dlnActCoeffdT) const;
300 
301  //! @}
302  //! @name Initialization
303  /// The following methods are used in the process of constructing the phase
304  /// and setting its parameters from a specification in an input file. They
305  /// are not normally used in application programs. To see how they are used,
306  /// see importPhase().
307  /// @{
308 
309  virtual void initThermo();
310  virtual void initThermoXML(XML_Node& phaseNode, const std::string& id);
311 
312  /**
313  * @}
314  * @name Derivatives of Thermodynamic Variables needed for Applications
315  * @{
316  */
317 
318  virtual void getdlnActCoeffds(const doublereal dTds, const doublereal* const dXds, doublereal* dlnActCoeffds) const;
319  virtual void getdlnActCoeffdlnX_diag(doublereal* dlnActCoeffdlnX_diag) const;
320  virtual void getdlnActCoeffdlnN_diag(doublereal* dlnActCoeffdlnN_diag) const;
321  virtual void getdlnActCoeffdlnN(const size_t ld, doublereal* const dlnActCoeffdlnN);
322  //@}
323 
324 private:
325  //! Process an XML node called "binaryNeutralSpeciesParameters"
326  /*!
327  * This node contains all of the parameters necessary to describe the
328  * Margules model for a particular binary interaction. This function reads
329  * the XML file and writes the coefficients it finds to an internal data
330  * structures.
331  *
332  * @param xmlBinarySpecies Reference to the XML_Node named
333  * "binaryNeutralSpeciesParameters" containing the binary interaction
334  */
335  void readXMLBinarySpecies(XML_Node& xmlBinarySpecies);
336 
337  //! Resize internal arrays within the object that depend upon the number
338  //! of binary Margules interaction terms
339  /*!
340  * @param num Number of binary Margules interaction terms
341  */
342  void resizeNumInteractions(const size_t num);
343 
344  //! Initialize lengths of local variables after all species have been
345  //! identified.
346  void initLengths();
347 
348  //! Update the activity coefficients
349  /*!
350  * This function will be called to update the internally stored natural
351  * logarithm of the activity coefficients
352  */
353  void s_update_lnActCoeff() const;
354 
355  //! Update the derivative of the log of the activity coefficients wrt T
356  /*!
357  * This function will be called to update the internally stored derivative
358  * of the natural logarithm of the activity coefficients wrt temperature.
359  */
360  void s_update_dlnActCoeff_dT() const;
361 
362  //! Update the derivative of the log of the activity coefficients
363  //! wrt log(mole fraction)
364  /*!
365  * This function will be called to update the internally stored derivative
366  * of the natural logarithm of the activity coefficients wrt logarithm of
367  * the mole fractions.
368  */
369  void s_update_dlnActCoeff_dlnX_diag() const;
370 
371  //! Update the derivative of the log of the activity coefficients
372  //! wrt log(moles) - diagonal only
373  /*!
374  * This function will be called to update the internally stored diagonal
375  * entries for the derivative of the natural logarithm of the activity
376  * coefficients wrt logarithm of the moles.
377  */
378  void s_update_dlnActCoeff_dlnN_diag() const;
379 
380  //! Update the derivative of the log of the activity coefficients wrt log(moles_m)
381  /*!
382  * This function will be called to update the internally stored derivative
383  * of the natural logarithm of the activity coefficients wrt logarithm of
384  * the mole number of species
385  */
386  void s_update_dlnActCoeff_dlnN() const;
387 
388 protected:
389  //! number of binary interaction expressions
391 
392  //! Enthalpy term for the binary mole fraction interaction of the excess
393  //! Gibbs free energy expression
395 
396  //! Enthalpy term for the ternary mole fraction interaction of the excess
397  //! Gibbs free energy expression
399 
400  //! Enthalpy term for the quaternary mole fraction interaction of the excess
401  //! Gibbs free energy expression
403 
404  //! Entropy term for the binary mole fraction interaction of the excess
405  //! Gibbs free energy expression
407 
408  //! Entropy term for the ternary mole fraction interaction of the excess
409  //! Gibbs free energy expression
411 
412  //! Entropy term for the quaternary mole fraction interaction of the excess
413  //! Gibbs free energy expression
415 
416  //! Enthalpy term for the binary mole fraction interaction of the excess
417  //! Gibbs free energy expression
419 
420  //! Enthalpy term for the ternary mole fraction interaction of the excess
421  //! Gibbs free energy expression
423 
424  //! Enthalpy term for the quaternary mole fraction interaction of the excess
425  //! Gibbs free energy expression
427 
428  //! Entropy term for the binary mole fraction interaction of the excess
429  //! Gibbs free energy expression
431 
432  //! Entropy term for the ternary mole fraction interaction of the excess
433  //! Gibbs free energy expression
435 
436  //! Entropy term for the quaternary mole fraction interaction of the excess
437  //! Gibbs free energy expression
439 
440  //! vector of species indices representing species A in the interaction
441  /*!
442  * Each Margules excess Gibbs free energy term involves two species, A and
443  * B. This vector identifies species A.
444  */
445  std::vector<size_t> m_pSpecies_A_ij;
446 
447  //! vector of species indices representing species B in the interaction
448  /*!
449  * Each Margules excess Gibbs free energy term involves two species, A and
450  * B. This vector identifies species B.
451  */
452  std::vector<size_t> m_pSpecies_B_ij;
453 
454  //! form of the Margules interaction expression
455  /*!
456  * Currently there is only one form.
457  */
459 
460  //! form of the temperature dependence of the Margules interaction expression
461  /*!
462  * Currently there is only one form -> constant wrt temperature.
463  */
465 };
466 
467 }
468 
469 #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).
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.
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: AnyMap.cpp:8
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.