Cantera  2.1.2
MixedSolventElectrolyte.h
Go to the documentation of this file.
1 /**
2  * @file MixedSolventElectrolyte.h
3  * Header for intermediate ThermoPhase object for phases which
4  * employ gibbs excess free energy based formulations
5  * (see \ref thermoprops
6  * and class \link Cantera::MargulesVPSSTP MargulesVPSSTP\endlink).
7  *
8  * Header file for a derived class of ThermoPhase that handles
9  * variable pressure standard state methods for calculating
10  * thermodynamic properties that are further based upon activities
11  * based on the molality scale. These include most of the methods for
12  * calculating liquid electrolyte thermodynamics.
13  */
14 /*
15  * Copyright (2006) Sandia Corporation. Under the terms of
16  * Contract DE-AC04-94AL85000 with Sandia Corporation, the
17  * U.S. Government retains certain rights in this software.
18  */
19 
20 #ifndef CT_MIXEDSOLVENTELECTROLYTEVPSSTP_H
21 #define CT_MIXEDSOLVENTELECTROLYTEVPSSTP_H
22 
23 #include "MolarityIonicVPSSTP.h"
24 
25 namespace Cantera
26 {
27 /**
28  * @ingroup thermoprops
29  */
30 
31 //! MixedSolventElectrolyte is a derived class of GibbsExcessVPSSTP that employs
32 //! the DH and local Marguless approximations for the excess gibbs free energy
33 /*!
34  *
35  * MixedSolventElectrolyte derives from class GibbsExcessVPSSTP which is derived
36  * from VPStandardStateTP,
37  * and overloads the virtual methods defined there with ones that
38  * use expressions appropriate for the Margules Excess gibbs free energy
39  * approximation.
40  *
41  * The independent unknowns are pressure, temperature, and mass fraction.
42  *
43  * Several concepts are introduced. The first concept is there are temporary
44  * variables for holding the species standard state values
45  * of Cp, H, S, G, and V at the
46  * last temperature and pressure called. These functions are not recalculated
47  * if a new call is made using the previous temperature and pressure. Currently,
48  * these variables and the calculation method are handled by the VPSSMgr class,
49  * for which VPStandardStateTP owns a pointer to.
50  *
51  * To support the above functionality, pressure and temperature variables,
52  * m_plast_ss and m_tlast_ss, are kept which store the last pressure and temperature
53  * used in the evaluation of standard state properties.
54  *
55  * This class is usually used for nearly incompressible phases. For those phases, it
56  * makes sense to change the equation of state independent variable from
57  * density to pressure. The variable m_Pcurrent contains the current value of the
58  * pressure within the phase.
59  *
60  *
61  * <HR>
62  * <H2> Specification of Species Standard %State Properties </H2>
63  * <HR>
64  *
65  * All species are defined to have standard states that depend upon both
66  * the temperature and the pressure. The Margules approximation assumes
67  * symmetric standard states, where all of the standard state assume
68  * that the species are in pure component states at the temperature
69  * and pressure of the solution. I don't think it prevents, however,
70  * some species from being dilute in the solution.
71  *
72  *
73  * <HR>
74  * <H2> Specification of Solution Thermodynamic Properties </H2>
75  * <HR>
76  *
77  * The molar excess Gibbs free energy is given by the following formula which is a sum over interactions <I>i</I>.
78  * Each of the interactions are binary interactions involving two of the species in the phase, denoted, <I>Ai</I>
79  * and <I>Bi</I>.
80  * This is the generalization of the Margules formulation for a phase
81  * that has more than 2 species.
82  *
83  * \f[
84  * G^E = \sum_i \left( H_{Ei} - T S_{Ei} \right)
85  * \f]
86  * \f[
87  * H^E_i = n X_{Ai} X_{Bi} \left( h_{o,i} + h_{1,i} X_{Bi} \right)
88  * \f]
89  * \f[
90  * S^E_i = n X_{Ai} X_{Bi} \left( s_{o,i} + s_{1,i} X_{Bi} \right)
91  * \f]
92  *
93  * where n is the total moles in the solution.
94  *
95  * The activity of a species defined in the phase is given by an excess
96  * Gibbs free energy formulation.
97  *
98  * \f[
99  * a_k = \gamma_k X_k
100  * \f]
101  *
102  * where
103  *
104  * \f[
105  * R T \ln( \gamma_k )= \frac{d(n G^E)}{d(n_k)}\Bigg|_{n_i}
106  * \f]
107  *
108  * Taking the derivatives results in the following expression
109  *
110  * \f[
111  * R T \ln( \gamma_k )= \sum_i \left( \left( \delta_{Ai,k} X_{Bi} + \delta_{Bi,k} X_{Ai} - X_{Ai} X_{Bi} \right)
112  * \left( g^E_{o,i} + g^E_{1,i} X_{Bi} \right) +
113  * \left( \delta_{Bi,k} - X_{Bi} \right) X_{Ai} X_{Bi} g^E_{1,i} \right)
114  * \f]
115  * where
116  * \f$ g^E_{o,i} = h_{o,i} - T s_{o,i} \f$ and \f$ g^E_{1,i} = h_{1,i} - T s_{1,i} \f$
117  * and where \f$ X_k \f$ is the mole fraction of species <I>k</I>.
118  *
119  * This object inherits from the class VPStandardStateTP. Therefore, the specification and
120  * calculation of all standard state and reference state values are handled at that level. Various functional
121  * forms for the standard state are permissible.
122  * The chemical potential for species <I>k</I> is equal to
123  *
124  * \f[
125  * \mu_k(T,P) = \mu^o_k(T, P) + R T \ln(\gamma_k X_k)
126  * \f]
127  *
128  * The partial molar entropy for species <I>k</I> is given by the following relation,
129  *
130  * \f[
131  * \tilde{s}_k(T,P) = s^o_k(T,P) - R \ln( \gamma_k X_k )
132  * - R T \frac{d \ln(\gamma_k) }{dT}
133  * \f]
134  *
135  * The partial molar enthalpy for species <I>k</I> is given by
136  *
137  * \f[
138  * \tilde{h}_k(T,P) = h^o_k(T,P) - R T^2 \frac{d \ln(\gamma_k)}{dT}
139  * \f]
140  *
141  * The partial molar volume for species <I>k</I> is
142  *
143  * \f[
144  * \tilde V_k(T,P) = V^o_k(T,P) + R T \frac{d \ln(\gamma_k) }{dP}
145  * \f]
146  *
147  * The partial molar Heat Capacity for species <I>k</I> is
148  *
149  * \f[
150  * \tilde{C}_{p,k}(T,P) = C^o_{p,k}(T,P) - 2 R T \frac{d \ln( \gamma_k )}{dT}
151  * - R T^2 \frac{d^2 \ln(\gamma_k) }{{dT}^2}
152  * \f]
153  *
154  * <HR>
155  * <H2> %Application within %Kinetics Managers </H2>
156  * <HR>
157  *
158  * \f$ C^a_k\f$ are defined such that \f$ a_k = C^a_k /
159  * C^s_k, \f$ where \f$ C^s_k \f$ is a standard concentration
160  * defined below and \f$ a_k \f$ are activities used in the
161  * thermodynamic functions. These activity (or generalized)
162  * concentrations are used
163  * by kinetics manager classes to compute the forward and
164  * reverse rates of elementary reactions.
165  * The activity concentration,\f$ C^a_k \f$,is given by the following expression.
166  *
167  * \f[
168  * C^a_k = C^s_k X_k = \frac{P}{R T} X_k
169  * \f]
170  *
171  * The standard concentration for species <I>k</I> is independent of <I>k</I> and equal to
172  *
173  * \f[
174  * C^s_k = C^s = \frac{P}{R T}
175  * \f]
176  *
177  * For example, a bulk-phase binary gas reaction between species j and k, producing
178  * a new gas species l would have the
179  * following equation for its rate of progress variable, \f$ R^1 \f$, which has
180  * units of kmol m-3 s-1.
181  *
182  * \f[
183  * R^1 = k^1 C_j^a C_k^a = k^1 (C^s a_j) (C^s a_k)
184  * \f]
185  * where
186  * \f[
187  * C_j^a = C^s a_j \mbox{\quad and \quad} C_k^a = C^s a_k
188  * \f]
189  *
190  *
191  * \f$ C_j^a \f$ is the activity concentration of species j, and
192  * \f$ C_k^a \f$ is the activity concentration of species k. \f$ C^s \f$
193  * is the standard concentration. \f$ a_j \f$ is
194  * the activity of species j which is equal to the mole fraction of j.
195  *
196  * The reverse rate constant can then be obtained from the law of microscopic reversibility
197  * and the equilibrium expression for the system.
198  *
199  * \f[
200  * \frac{a_j a_k}{ a_l} = K_a^{o,1} = \exp(\frac{\mu^o_l - \mu^o_j - \mu^o_k}{R T} )
201  * \f]
202  *
203  * \f$ K_a^{o,1} \f$ is the dimensionless form of the equilibrium constant, associated with
204  * the pressure dependent standard states \f$ \mu^o_l(T,P) \f$ and their associated activities,
205  * \f$ a_l \f$, repeated here:
206  *
207  * \f[
208  * \mu_l(T,P) = \mu^o_l(T, P) + R T \log(a_l)
209  * \f]
210  *
211  * We can switch over to expressing the equilibrium constant in terms of the reference
212  * state chemical potentials
213  *
214  * \f[
215  * K_a^{o,1} = \exp(\frac{\mu^{ref}_l - \mu^{ref}_j - \mu^{ref}_k}{R T} ) * \frac{P_{ref}}{P}
216  * \f]
217  *
218  * The concentration equilibrium constant, \f$ K_c \f$, may be obtained by changing over
219  * to activity concentrations. When this is done:
220  *
221  * \f[
222  * \frac{C^a_j C^a_k}{ C^a_l} = C^o K_a^{o,1} = K_c^1 =
223  * \exp(\frac{\mu^{ref}_l - \mu^{ref}_j - \mu^{ref}_k}{R T} ) * \frac{P_{ref}}{RT}
224  * \f]
225  *
226  * %Kinetics managers will calculate the concentration equilibrium constant, \f$ K_c \f$,
227  * using the second and third part of the above expression as a definition for the concentration
228  * equilibrium constant.
229  *
230  * For completeness, the pressure equilibrium constant may be obtained as well
231  *
232  * \f[
233  * \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} )
234  * \f]
235  *
236  * \f$ K_p \f$ is the simplest form of the equilibrium constant for ideal gases. However, it isn't
237  * necessarily the simplest form of the equilibrium constant for other types of phases; \f$ K_c \f$ is
238  * used instead because it is completely general.
239  *
240  * The reverse rate of progress may be written down as
241  * \f[
242  * R^{-1} = k^{-1} C_l^a = k^{-1} (C^o a_l)
243  * \f]
244  *
245  * where we can use the concept of microscopic reversibility to
246  * write the reverse rate constant in terms of the
247  * forward reate constant and the concentration equilibrium
248  * constant, \f$ K_c \f$.
249  *
250  * \f[
251  * k^{-1} = k^1 K^1_c
252  * \f]
253  *
254  * \f$k^{-1} \f$ has units of s-1.
255  *
256  * @ingroup thermoprops
257  *
258  */
260 {
261 public:
262  //! Constructor
263  /*!
264  * This doesn't do much more than initialize constants with
265  * default values for water at 25C. Water molecular weight
266  * comes from the default elements.xml file. It actually
267  * differs slightly from the IAPWS95 value of 18.015268. However,
268  * density conservation and therefore element conservation
269  * is the more important principle to follow.
270  */
272 
273  //! Construct and initialize a MixedSolventElectrolyte ThermoPhase object
274  //! directly from an xml input file
275  /*!
276  * @param inputFile Name of the input file containing the phase XML data
277  * to set up the object
278  * @param id ID of the phase in the input file. Defaults to the
279  * empty string.
280  */
281  MixedSolventElectrolyte(const std::string& inputFile,
282  const std::string& id = "");
283 
284  //! Construct and initialize a MixedSolventElectrolyte ThermoPhase object
285  //! directly from an XML database
286  /*!
287  * @param phaseRef XML phase node containing the description of the phase
288  * @param id id attribute containing the name of the phase.
289  * (default is the empty string)
290  */
291  MixedSolventElectrolyte(XML_Node& phaseRef, const std::string& id = "");
292 
293  //! Special constructor for a hard-coded problem
294  /*!
295  * @param testProb Hard-coded value. Only the value of 1 is used. It's
296  * for a LiKCl system -> test to predict the eutectic and
297  * liquidus correctly.
298  * @deprecated To be refactored into a standalone test
299  */
300  MixedSolventElectrolyte(int testProb);
301 
302  //! Copy constructor
303  /*!
304  * @param b class to be copied
305  */
307 
308  //! Assignment operator
309  /*!
310  * @param b class to be copied.
311  */
313 
314  //! Duplication routine for objects which inherit from ThermoPhase.
315  /*!
316  * This virtual routine can be used to duplicate thermophase objects
317  * inherited from ThermoPhase even if the application only has
318  * a pointer to ThermoPhase to work with.
319  */
320  virtual ThermoPhase* duplMyselfAsThermoPhase() const;
321 
322  //! @name Utilities
323  //! @{
324 
325  //! Equation of state type flag.
326  /*!
327  * The ThermoPhase base class returns
328  * zero. Subclasses should define this to return a unique
329  * non-zero value. Known constants defined for this purpose are
330  * listed in mix_defs.h. The MolalityVPSSTP class also returns
331  * zero, as it is a non-complete class.
332  */
333  virtual int eosType() const;
334 
335  //! @}
336  //! @name Molar Thermodynamic Properties
337  //! @{
338 
339  /// Molar enthalpy. Units: J/kmol.
340  virtual doublereal enthalpy_mole() const;
341 
342  /// Molar entropy. Units: J/kmol.
343  virtual doublereal entropy_mole() const;
344 
345  /// Molar heat capacity at constant pressure. Units: J/kmol/K.
346  virtual doublereal cp_mole() const;
347 
348  /// Molar heat capacity at constant volume. Units: J/kmol/K.
349  virtual doublereal cv_mole() const;
350 
351  /**
352  * @}
353  * @name Activities, Standard States, and Activity Concentrations
354  *
355  * The activity \f$a_k\f$ of a species in solution is
356  * related to the chemical potential by \f[ \mu_k = \mu_k^0(T)
357  * + \hat R T \log a_k. \f] The quantity \f$\mu_k^0(T,P)\f$ is
358  * the chemical potential at unit activity, which depends only
359  * on temperature and pressure.
360  * @{
361  */
362 
363  //! Get the array of non-dimensional molar-based activity coefficients at
364  //! the current solution temperature, pressure, and solution concentration.
365  /*!
366  * @param ac Output vector of activity coefficients. Length: m_kk.
367  */
368  virtual void getActivityCoefficients(doublereal* ac) const;
369 
370  //@}
371  /// @name Partial Molar Properties of the Solution
372  //@{
373 
374  //! Get the species chemical potentials. Units: J/kmol.
375  /*!
376  * This function returns a vector of chemical potentials of the
377  * species in solution at the current temperature, pressure
378  * and mole fraction of the solution.
379  *
380  * @param mu Output vector of species chemical
381  * potentials. Length: m_kk. Units: J/kmol
382  */
383  virtual void getChemPotentials(doublereal* mu) const;
384 
385  //! Returns an array of partial molar enthalpies for the species
386  //! in the mixture.
387  /*!
388  * Units (J/kmol)
389  *
390  * For this phase, the partial molar enthalpies are equal to the
391  * standard state enthalpies modified by the derivative of the
392  * molality-based activity coefficient wrt temperature
393  *
394  * \f[
395  * \bar h_k(T,P) = h^o_k(T,P) - R T^2 \frac{d \ln(\gamma_k)}{dT}
396  * \f]
397  *
398  * @param hbar Vector of returned partial molar enthalpies
399  * (length m_kk, units = J/kmol)
400  */
401  virtual void getPartialMolarEnthalpies(doublereal* hbar) const;
402 
403  //! Returns an array of partial molar entropies for the species
404  //! in the mixture.
405  /*!
406  * Units (J/kmol)
407  *
408  * For this phase, the partial molar enthalpies are equal to the
409  * standard state enthalpies modified by the derivative of the
410  * activity coefficient wrt temperature
411  *
412  * \f[
413  * \bar s_k(T,P) = s^o_k(T,P) - R T^2 \frac{d \ln(\gamma_k)}{dT}
414  * - R \ln( \gamma_k X_k)
415  * - R T \frac{d \ln(\gamma_k) }{dT}
416  * \f]
417  *
418  * @param sbar Vector of returned partial molar entropies
419  * (length m_kk, units = J/kmol/K)
420  */
421  virtual void getPartialMolarEntropies(doublereal* sbar) const;
422 
423  //! Returns an array of partial molar entropies for the species
424  //! in the mixture.
425  /*!
426  * Units (J/kmol)
427  *
428  * For this phase, the partial molar enthalpies are equal to the
429  * standard state enthalpies modified by the derivative of the
430  * activity coefficient wrt temperature
431  *
432  * \f[
433  * ???????????????
434  * \bar s_k(T,P) = s^o_k(T,P) - R T^2 \frac{d \ln(\gamma_k)}{dT}
435  * - R \ln( \gamma_k X_k)
436  * - R T \frac{d \ln(\gamma_k) }{dT}
437  * ???????????????
438  * \f]
439  *
440  * @param cpbar Vector of returned partial molar heat capacities
441  * (length m_kk, units = J/kmol/K)
442  */
443  virtual void getPartialMolarCp(doublereal* cpbar) const;
444 
445  //! Return an array of partial molar volumes for the
446  //! species in the mixture. Units: m^3/kmol.
447  /*!
448  * Frequently, for this class of thermodynamics representations,
449  * the excess Volume due to mixing is zero. Here, we set it as
450  * a default. It may be overridden in derived classes.
451  *
452  * @param vbar Output vector of species partial molar volumes.
453  * Length = m_kk. units are m^3/kmol.
454  */
455  virtual void getPartialMolarVolumes(doublereal* vbar) const;
456 
457  //! Get the species electrochemical potentials.
458  /*!
459  * These are partial molar quantities.
460  * This method adds a term \f$ Fz_k \phi_k \f$ to the
461  * to each chemical potential.
462  *
463  * Units: J/kmol
464  *
465  * @param mu output vector containing the species electrochemical potentials.
466  * Length: m_kk., units = J/kmol
467  */
468  void getElectrochemPotentials(doublereal* mu) const;
469 
470  //! Get the array of temperature second derivatives of the log activity coefficients
471  /*!
472  * This function is a virtual class, but it first appears in GibbsExcessVPSSTP
473  * class and derived classes from GibbsExcessVPSSTP.
474  *
475  * units = 1/Kelvin
476  *
477  * @param d2lnActCoeffdT2 Output vector of temperature 2nd derivatives of the
478  * log Activity Coefficients. length = m_kk
479  *
480  */
481  virtual void getd2lnActCoeffdT2(doublereal* d2lnActCoeffdT2) const;
482 
483  //! Get the array of temperature derivatives of the log activity coefficients
484  /*!
485  * This function is a virtual class, but it first appears in GibbsExcessVPSSTP
486  * class and derived classes from GibbsExcessVPSSTP.
487  *
488  * units = 1/Kelvin
489  *
490  * @param dlnActCoeffdT Output vector of temperature derivatives of the
491  * log Activity Coefficients. length = m_kk
492  */
493  virtual void getdlnActCoeffdT(doublereal* dlnActCoeffdT) const;
494 
495  //! @}
496  //! @name Initialization
497  /// The following methods are used in the process of constructing
498  /// the phase and setting its parameters from a specification in an
499  /// input file. They are not normally used in application programs.
500  /// To see how they are used, see files importCTML.cpp and
501  /// ThermoFactory.cpp.
502  /// @{
503 
504  /*!
505  * @internal Initialize. This method is provided to allow
506  * subclasses to perform any initialization required after all
507  * species have been added. For example, it might be used to
508  * resize internal work arrays that must have an entry for
509  * each species. The base class implementation does nothing,
510  * and subclasses that do not require initialization do not
511  * need to overload this method. When importing a CTML phase
512  * description, this method is called just prior to returning
513  * from function importPhase.
514  *
515  * @see importCTML.cpp
516  */
517  virtual void initThermo();
518 
519  /**
520  * Import and initialize a ThermoPhase object
521  *
522  * @param phaseNode This object must be the phase node of a
523  * complete XML tree
524  * description of the phase, including all of the
525  * species data. In other words while "phase" must
526  * point to an XML phase object, it must have
527  * sibling nodes "speciesData" that describe
528  * the species in the phase.
529  * @param id ID of the phase. If nonnull, a check is done
530  * to see if phaseNode is pointing to the phase
531  * with the correct id.
532  */
533  void initThermoXML(XML_Node& phaseNode, const std::string& id);
534 
535  /**
536  * @}
537  * @name Derivatives of Thermodynamic Variables needed for Applications
538  * @{
539  */
540 
541  //! Get the change in activity coefficients w.r.t. change in state (temp, mole fraction, etc.) along
542  //! a line in parameter space or along a line in physical space
543  /*!
544  *
545  * @param dTds Input of temperature change along the path
546  * @param dXds Input vector of changes in mole fraction along the path. length = m_kk
547  * Along the path length it must be the case that the mole fractions sum to one.
548  * @param dlnActCoeffds Output vector of the directional derivatives of the
549  * log Activity Coefficients along the path. length = m_kk
550  * units are 1/units(s). if s is a physical coordinate then the units are 1/m.
551  */
552  virtual void getdlnActCoeffds(const doublereal dTds, const doublereal* const dXds, doublereal* dlnActCoeffds) const;
553 
554  //! Get the array of log concentration-like derivatives of the
555  //! log activity coefficients - diagonal component
556  /*!
557  * This function is a virtual method. For ideal mixtures
558  * (unity activity coefficients), this can return zero.
559  * Implementations should take the derivative of the
560  * logarithm of the activity coefficient with respect to the
561  * logarithm of the mole fraction.
562  *
563  * units = dimensionless
564  *
565  * @param dlnActCoeffdlnX_diag Output vector of the diagonal component of the log(mole fraction)
566  * derivatives of the log Activity Coefficients.
567  * length = m_kk
568  */
569  virtual void getdlnActCoeffdlnX_diag(doublereal* dlnActCoeffdlnX_diag) const;
570 
571  //! Get the array of derivatives of the log activity coefficients wrt mole numbers - diagonal only
572  /*!
573  * This function is a virtual method. For ideal mixtures
574  * (unity activity coefficients), this can return zero.
575  * Implementations should take the derivative of the
576  * logarithm of the activity coefficient with respect to the
577  * logarithm of the concentration-like variable (i.e. mole fraction,
578  * molality, etc.) that represents the standard state.
579  *
580  * units = dimensionless
581  *
582  * @param dlnActCoeffdlnN_diag Output vector of the diagonal entries for the log(mole fraction)
583  * derivatives of the log Activity Coefficients.
584  * length = m_kk
585  */
586  virtual void getdlnActCoeffdlnN_diag(doublereal* dlnActCoeffdlnN_diag) const;
587 
588  //! Get the array of derivatives of the log activity coefficients with respect to the ln species mole numbers
589  /*!
590  * Implementations should take the derivative of the logarithm of the activity coefficient with respect to a
591  * log of a species mole number (with all other species mole numbers held constant)
592  *
593  * units = 1 / kmol
594  *
595  * dlnActCoeffdlnN[ ld * k + m] will contain the derivative of log act_coeff for the <I>m</I><SUP>th</SUP>
596  * species with respect to the number of moles of the <I>k</I><SUP>th</SUP> species.
597  *
598  * \f[
599  * \frac{d \ln(\gamma_m) }{d \ln( n_k ) }\Bigg|_{n_i}
600  * \f]
601  *
602  * @param ld Number of rows in the matrix
603  * @param dlnActCoeffdlnN Output vector of derivatives of the
604  * log Activity Coefficients. length = m_kk * m_kk
605  */
606  virtual void getdlnActCoeffdlnN(const size_t ld, doublereal* const dlnActCoeffdlnN) ;
607  //@}
608 
609 private:
610  //! Process an XML node called "binaryNeutralSpeciesParameters"
611  /*!
612  * This node contains all of the parameters necessary to describe
613  * the Margules model for a particular binary interaction.
614  * This function reads the XML file and writes the coefficients
615  * it finds to an internal data structures.
616  *
617  * @param xmlBinarySpecies Reference to the XML_Node named "binaryNeutralSpeciesParameters"
618  * containing the binary interaction
619  */
620  void readXMLBinarySpecies(XML_Node& xmlBinarySpecies);
621 
622  //! Resize internal arrays within the object that depend upon the number
623  //! of binary Margules interaction terms
624  /*!
625  * @param num Number of binary Margules interaction terms
626  */
627  void resizeNumInteractions(const size_t num);
628 
629  //! Initialize lengths of local variables after all species have
630  //! been identified.
631  void initLengths();
632 
633  //! Update the activity coefficients
634  /*!
635  * This function will be called to update the internally stored
636  * natural logarithm of the activity coefficients
637  */
638  void s_update_lnActCoeff() const;
639 
640  //! Update the derivative of the log of the activity coefficients wrt T
641  /*!
642  * This function will be called to update the internally stored
643  * derivative of the natural logarithm of the activity coefficients
644  * wrt temperature.
645  */
646  void s_update_dlnActCoeff_dT() const;
647 
648  //! Update the derivative of the log of the activity coefficients
649  //! wrt log(mole fraction)
650  /*!
651  * This function will be called to update the internally stored
652  * derivative of the natural logarithm of the activity coefficients
653  * wrt logarithm of the mole fractions.
654  */
655  void s_update_dlnActCoeff_dlnX_diag() const;
656 
657  //! Update the derivative of the log of the activity coefficients
658  //! wrt log(moles) - diagonal only
659  /*!
660  * This function will be called to update the internally stored diagonal entries for the
661  * derivative of the natural logarithm of the activity coefficients
662  * wrt logarithm of the moles.
663  */
664  void s_update_dlnActCoeff_dlnN_diag() const;
665 
666  //! Update the derivative of the log of the activity coefficients wrt log(moles_m)
667  /*!
668  * This function will be called to update the internally stored
669  * derivative of the natural logarithm of the activity coefficients
670  * wrt logarithm of the mole number of species
671  */
672  void s_update_dlnActCoeff_dlnN() const;
673 
674  //! Error function
675  /*!
676  * Print an error string and exit
677  *
678  * @param msg Message to be printed
679  */
680  doublereal err(const std::string& msg) const;
681 
682 protected:
683  //! number of binary interaction expressions
685 
686  //! Enthalpy term for the binary mole fraction interaction of the
687  //! excess gibbs free energy expression
689 
690  //! Enthalpy term for the ternary mole fraction interaction of the
691  //! excess gibbs free energy expression
693 
694  //! Enthalpy term for the quaternary mole fraction interaction of the
695  //! excess gibbs free energy expression
697 
698  //! Entropy term for the binary mole fraction interaction of the
699  //! excess gibbs free energy expression
701 
702  //! Entropy term for the ternary mole fraction interaction of the
703  //! excess gibbs free energy expression
705 
706  //! Entropy term for the quaternary mole fraction interaction of the
707  //! excess gibbs free energy expression
709 
710  //! Enthalpy term for the binary mole fraction interaction of the
711  //! excess gibbs free energy expression
713 
714  //! Enthalpy term for the ternary mole fraction interaction of the
715  //! excess gibbs free energy expression
717 
718  //! Enthalpy term for the quaternary mole fraction interaction of the
719  //! excess gibbs free energy expression
721 
722  //! Entropy term for the binary mole fraction interaction of the
723  //! excess gibbs free energy expression
725 
726  //! Entropy term for the ternary mole fraction interaction of the
727  //! excess gibbs free energy expression
729 
730  //! Entropy term for the quaternary mole fraction interaction of the
731  //! excess gibbs free energy expression
733 
734  //! vector of species indices representing species A in the interaction
735  /*!
736  * Each Margules excess Gibbs free energy term involves two species, A and B.
737  * This vector identifies species A.
738  */
739  std::vector<size_t> m_pSpecies_A_ij;
740 
741  //! vector of species indices representing species B in the interaction
742  /*!
743  * Each Margules excess Gibbs free energy term involves two species, A and B.
744  * This vector identifies species B.
745  */
746  std::vector<size_t> m_pSpecies_B_ij;
747 
748  //! form of the Margules interaction expression
749  /*!
750  * Currently there is only one form.
751  */
753 
754  //! form of the temperature dependence of the Margules interaction expression
755  /*!
756  * Currently there is only one form -> constant wrt temperature.
757  */
759 };
760 
761 }
762 
763 #endif
virtual void getdlnActCoeffdlnN_diag(doublereal *dlnActCoeffdlnN_diag) const
Get the array of derivatives of the log activity coefficients wrt mole numbers - diagonal only...
void s_update_dlnActCoeff_dlnN_diag() const
Update the derivative of the log of the activity coefficients wrt log(moles) - diagonal only...
virtual void getPartialMolarEntropies(doublereal *sbar) const
Returns an array of partial molar entropies for the species in the mixture.
virtual void getPartialMolarEnthalpies(doublereal *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.
void s_update_dlnActCoeff_dlnN() const
Update the derivative of the log of the activity coefficients wrt log(moles_m)
virtual void getd2lnActCoeffdT2(doublereal *d2lnActCoeffdT2) const
Get the array of temperature second derivatives of the log activity coefficients. ...
void s_update_dlnActCoeff_dlnX_diag() const
Update the derivative of the log of the activity coefficients wrt log(mole fraction) ...
void s_update_lnActCoeff() const
Update the activity coefficients.
virtual ThermoPhase * duplMyselfAsThermoPhase() const
Duplication routine for objects which inherit from ThermoPhase.
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:100
vector_fp m_SE_b_ij
Entropy term for the binary mole fraction interaction of the excess gibbs free energy expression...
Header for intermediate ThermoPhase object for phases which employ gibbs excess free energy based for...
virtual doublereal entropy_mole() const
Molar entropy. Units: J/kmol.
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:101
void readXMLBinarySpecies(XML_Node &xmlBinarySpecies)
Process an XML node called "binaryNeutralSpeciesParameters".
virtual void getdlnActCoeffds(const doublereal dTds, const doublereal *const dXds, doublereal *dlnActCoeffds) const
Get the change in activity coefficients w.r.t.
virtual void getPartialMolarCp(doublereal *cpbar) const
Returns an array of partial molar entropies for the species in the mixture.
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 getdlnActCoeffdlnX_diag(doublereal *dlnActCoeffdlnX_diag) const
Get the array of log concentration-like derivatives of the log activity coefficients - diagonal compo...
void s_update_dlnActCoeff_dT() const
Update the derivative of the log of the activity coefficients wrt T.
vector_fp m_HE_b_ij
Enthalpy term for the binary mole fraction interaction of the excess gibbs free energy expression...
void initThermoXML(XML_Node &phaseNode, const std::string &id)
Import and initialize a ThermoPhase object.
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 ln species mole num...
vector_fp m_VHE_d_ij
Enthalpy term for the quaternary mole fraction interaction of the excess gibbs free energy expression...
void resizeNumInteractions(const size_t num)
Resize internal arrays within the object that depend upon the number of binary Margules interaction t...
virtual doublereal cv_mole() const
Molar heat capacity at constant volume. Units: J/kmol/K.
virtual void getActivityCoefficients(doublereal *ac) const
Get the array of non-dimensional molar-based activity coefficients at the current solution temperatur...
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...
doublereal err(const std::string &msg) const
Error function.
virtual void getdlnActCoeffdT(doublereal *dlnActCoeffdT) const
Get the array of temperature derivatives of the log activity coefficients.
void getElectrochemPotentials(doublereal *mu) const
Get the species electrochemical potentials.
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 doublereal enthalpy_mole() const
Molar enthalpy. Units: J/kmol.
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:165
virtual int eosType() const
Equation of state type flag.
virtual doublereal cp_mole() const
Molar heat capacity at constant pressure. Units: J/kmol/K.
vector_fp m_SE_d_ij
Entropy term for the quaternary 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.
MixedSolventElectrolyte & operator=(const MixedSolventElectrolyte &b)
Assignment operator.
vector_fp m_VSE_b_ij
Entropy term for the binary mole fraction interaction of the excess gibbs free energy expression...