Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MargulesVPSSTP.h
Go to the documentation of this file.
1 /**
2  * @file MargulesVPSSTP.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 #ifndef CT_MARGULESVPSSTP_H
20 #define CT_MARGULESVPSSTP_H
21 
22 #include "GibbsExcessVPSSTP.h"
23 
24 namespace Cantera
25 {
26 
27 /**
28  * @ingroup thermoprops
29  */
30 
31 //! MargulesVPSSTP is a derived class of GibbsExcessVPSSTP that employs
32 //! the Margules approximation for the excess Gibbs free energy
33 /*!
34  *
35  * MargulesVPSSTP 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  * \f$ C_j^a \f$ is the activity concentration of species j, and
191  * \f$ C_k^a \f$ is the activity concentration of species k. \f$ C^s \f$
192  * is the standard concentration. \f$ a_j \f$ is
193  * the activity of species j which is equal to the mole fraction of j.
194  *
195  * The reverse rate constant can then be obtained from the law of microscopic reversibility
196  * and the equilibrium expression for the system.
197  *
198  * \f[
199  * \frac{a_j a_k}{ a_l} = K_a^{o,1} = \exp(\frac{\mu^o_l - \mu^o_j - \mu^o_k}{R T} )
200  * \f]
201  *
202  * \f$ K_a^{o,1} \f$ is the dimensionless form of the equilibrium constant, associated with
203  * the pressure dependent standard states \f$ \mu^o_l(T,P) \f$ and their associated activities,
204  * \f$ a_l \f$, repeated here:
205  *
206  * \f[
207  * \mu_l(T,P) = \mu^o_l(T, P) + R T \log(a_l)
208  * \f]
209  *
210  * We can switch over to expressing the equilibrium constant in terms of the reference
211  * state chemical potentials
212  *
213  * \f[
214  * K_a^{o,1} = \exp(\frac{\mu^{ref}_l - \mu^{ref}_j - \mu^{ref}_k}{R T} ) * \frac{P_{ref}}{P}
215  * \f]
216  *
217  * The concentration equilibrium constant, \f$ K_c \f$, may be obtained by changing over
218  * to activity concentrations. When this is done:
219  *
220  * \f[
221  * \frac{C^a_j C^a_k}{ C^a_l} = C^o K_a^{o,1} = K_c^1 =
222  * \exp(\frac{\mu^{ref}_l - \mu^{ref}_j - \mu^{ref}_k}{R T} ) * \frac{P_{ref}}{RT}
223  * \f]
224  *
225  * %Kinetics managers will calculate the concentration equilibrium constant, \f$ K_c \f$,
226  * using the second and third part of the above expression as a definition for the concentration
227  * equilibrium constant.
228  *
229  * For completeness, the pressure equilibrium constant may be obtained as well
230  *
231  * \f[
232  * \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} )
233  * \f]
234  *
235  * \f$ K_p \f$ is the simplest form of the equilibrium constant for ideal gases. However, it isn't
236  * necessarily the simplest form of the equilibrium constant for other types of phases; \f$ K_c \f$ is
237  * used instead because it is completely general.
238  *
239  * The reverse rate of progress may be written down as
240  * \f[
241  * R^{-1} = k^{-1} C_l^a = k^{-1} (C^o a_l)
242  * \f]
243  *
244  * where we can use the concept of microscopic reversibility to
245  * write the reverse rate constant in terms of the
246  * forward reate constant and the concentration equilibrium
247  * constant, \f$ K_c \f$.
248  *
249  * \f[
250  * k^{-1} = k^1 K^1_c
251  * \f]
252  *
253  * \f$k^{-1} \f$ has units of s-1.
254  *
255  * @ingroup thermoprops
256  */
258 {
259 
260 public:
261  //! Constructor
262  /*!
263  * This doesn't do much more than initialize constants with
264  * default values for water at 25C. Water molecular weight
265  * comes from the default elements.xml file. It actually
266  * differs slightly from the IAPWS95 value of 18.015268. However,
267  * density conservation and therefore element conservation
268  * is the more important principle to follow.
269  */
270  MargulesVPSSTP();
271 
272  //! Construct and initialize a MargulesVPSSTP ThermoPhase object
273  //! directly from an XML input file
274  /*!
275  * Working constructors
276  *
277  * The two constructors below are the normal way
278  * the phase initializes itself. They are shells that call
279  * the routine initThermo(), with a reference to the
280  * XML database to get the info for the phase.
281  *
282  * @param inputFile Name of the input file containing the phase XML data
283  * to set up the object
284  * @param id ID of the phase in the input file. Defaults to the
285  * empty string.
286  */
287  MargulesVPSSTP(const std::string& inputFile, const std::string& id = "");
288 
289  //! Construct and initialize a MargulesVPSSTP ThermoPhase object
290  //! directly from an XML database
291  /*!
292  * @param phaseRef XML phase node containing the description of the phase
293  * @param id id attribute containing the name of the phase.
294  * (default is the empty string)
295  */
296  MargulesVPSSTP(XML_Node& phaseRef, const std::string& id = "");
297 
298  //! Special constructor for a hard-coded problem
299  /*!
300  * @param testProb Hard-coded value. Only the value of 1 is used. It's
301  * for a LiKCl system test to predict the eutectic and
302  * liquidus correctly.
303  * @deprecated To be removed after Cantera 2.2.
304  */
305  MargulesVPSSTP(int testProb);
306 
307  //! Copy constructor
308  /*!
309  * Note this stuff will not work until the underlying phase
310  * has a working copy constructor
311  *
312  * @param b class to be copied
313  */
314  MargulesVPSSTP(const MargulesVPSSTP& b);
315 
316  //! Assignment operator
317  /*!
318  * @param b class to be copied.
319  */
321 
322  //! Duplication routine for objects which inherit from ThermoPhase.
323  /*!
324  * This virtual routine can be used to duplicate ThermoPhase objects
325  * inherited from ThermoPhase even if the application only has
326  * a pointer to ThermoPhase to work with.
327  */
328  virtual ThermoPhase* duplMyselfAsThermoPhase() const;
329 
330  //! @name Molar Thermodynamic Properties
331  //! @{
332 
333  /// Molar enthalpy. Units: J/kmol.
334  virtual doublereal enthalpy_mole() const;
335 
336  /// Molar entropy. Units: J/kmol.
337  virtual doublereal entropy_mole() const;
338 
339  /// Molar heat capacity at constant pressure. Units: J/kmol/K.
340  virtual doublereal cp_mole() const;
341 
342  /// Molar heat capacity at constant volume. Units: J/kmol/K.
343  virtual doublereal cv_mole() const;
344 
345  /**
346  * @}
347  * @name Activities, Standard States, and Activity Concentrations
348  *
349  * The activity \f$a_k\f$ of a species in solution is
350  * related to the chemical potential by \f[ \mu_k = \mu_k^0(T)
351  * + \hat R T \log a_k. \f] The quantity \f$\mu_k^0(T,P)\f$ is
352  * the chemical potential at unit activity, which depends only
353  * on temperature and pressure.
354  * @{
355  */
356 
357  //! Get the array of non-dimensional molar-based ln activity coefficients at
358  //! the current solution temperature, pressure, and solution concentration.
359  /*!
360  * @param lnac Output vector of ln activity coefficients. Length: m_kk.
361  */
362  virtual void getLnActivityCoefficients(doublereal* lnac) const;
363 
364  //@}
365  /// @name Partial Molar Properties of the Solution
366  //@{
367 
368  //! Get the species chemical potentials. Units: J/kmol.
369  /*!
370  * This function returns a vector of chemical potentials of the
371  * species in solution at the current temperature, pressure
372  * and mole fraction of the solution.
373  *
374  * @param mu Output vector of species chemical
375  * potentials. Length: m_kk. Units: J/kmol
376  */
377  virtual void getChemPotentials(doublereal* mu) const;
378 
379  //! Returns an array of partial molar enthalpies for the species
380  //! in the mixture.
381  /*!
382  * Units (J/kmol)
383  *
384  * For this phase, the partial molar enthalpies are equal to the
385  * standard state enthalpies modified by the derivative of the
386  * molality-based activity coefficient wrt temperature
387  *
388  * \f[
389  * \bar h_k(T,P) = h^o_k(T,P) - R T^2 \frac{d \ln(\gamma_k)}{dT}
390  * \f]
391  *
392  * @param hbar Vector of returned partial molar enthalpies
393  * (length m_kk, units = J/kmol)
394  */
395  virtual void getPartialMolarEnthalpies(doublereal* hbar) const;
396 
397  //! Returns an array of partial molar entropies for the species
398  //! in the mixture.
399  /*!
400  * Units (J/kmol)
401  *
402  * For this phase, the partial molar enthalpies are equal to the
403  * standard state enthalpies modified by the derivative of the
404  * activity coefficient wrt temperature
405  *
406  * \f[
407  * \bar s_k(T,P) = s^o_k(T,P) - R T^2 \frac{d \ln(\gamma_k)}{dT}
408  * - R \ln( \gamma_k X_k)
409  * - R T \frac{d \ln(\gamma_k) }{dT}
410  * \f]
411  *
412  * @param sbar Vector of returned partial molar entropies
413  * (length m_kk, units = J/kmol/K)
414  */
415  virtual void getPartialMolarEntropies(doublereal* sbar) const;
416 
417  //! Returns an array of partial molar entropies for the species
418  //! in the mixture.
419  /*!
420  * Units (J/kmol)
421  *
422  * For this phase, the partial molar enthalpies are equal to the
423  * standard state enthalpies modified by the derivative of the
424  * activity coefficient wrt temperature
425  *
426  * \f[
427  * ???????????????
428  * \bar s_k(T,P) = s^o_k(T,P) - R T^2 \frac{d \ln(\gamma_k)}{dT}
429  * - R \ln( \gamma_k X_k)
430  * - R T \frac{d \ln(\gamma_k) }{dT}
431  * ???????????????
432  * \f]
433  *
434  * @param cpbar Vector of returned partial molar heat capacities
435  * (length m_kk, units = J/kmol/K)
436  */
437  virtual void getPartialMolarCp(doublereal* cpbar) const;
438 
439 
440  //! Return an array of partial molar volumes for the
441  //! species in the mixture. Units: m^3/kmol.
442  /*!
443  * Frequently, for this class of thermodynamics representations,
444  * the excess Volume due to mixing is zero. Here, we set it as
445  * a default. It may be overridden in derived classes.
446  *
447  * @param vbar Output vector of species partial molar volumes.
448  * Length = m_kk. units are m^3/kmol.
449  */
450  virtual void getPartialMolarVolumes(doublereal* vbar) const;
451 
452  //! Get the species electrochemical potentials.
453  /*!
454  * These are partial molar quantities.
455  * This method adds a term \f$ Fz_k \phi_k \f$ to the
456  * to each chemical potential.
457  *
458  * Units: J/kmol
459  *
460  * @param mu output vector containing the species electrochemical potentials.
461  * Length: m_kk., units = J/kmol
462  */
463  void getElectrochemPotentials(doublereal* mu) const;
464 
465  //! Get the array of temperature second derivatives of the log activity coefficients
466  /*!
467  * This function is a virtual class, but it first appears in GibbsExcessVPSSTP
468  * class and derived classes from GibbsExcessVPSSTP.
469  *
470  * units = 1/Kelvin
471  *
472  * @param d2lnActCoeffdT2 Output vector of temperature 2nd derivatives of the
473  * log Activity Coefficients. length = m_kk
474  *
475  */
476  virtual void getd2lnActCoeffdT2(doublereal* d2lnActCoeffdT2) const;
477 
478  //! Get the array of temperature derivatives of the log activity coefficients
479  /*!
480  * This function is a virtual class, but it first appears in GibbsExcessVPSSTP
481  * class and derived classes from GibbsExcessVPSSTP.
482  *
483  * units = 1/Kelvin
484  *
485  * @param dlnActCoeffdT Output vector of temperature derivatives of the
486  * log Activity Coefficients. length = m_kk
487  *
488  */
489  virtual void getdlnActCoeffdT(doublereal* dlnActCoeffdT) const;
490 
491  /// @}
492  /// @name Initialization
493  /// The following methods are used in the process of constructing
494  /// the phase and setting its parameters from a specification in an
495  /// input file. They are not normally used in application programs.
496  /// To see how they are used, see importPhase()
497  /// @{
498 
499  /*!
500  * @internal Initialize. This method is provided to allow
501  * subclasses to perform any initialization required after all
502  * species have been added. For example, it might be used to
503  * resize internal work arrays that must have an entry for
504  * each species. The base class implementation does nothing,
505  * and subclasses that do not require initialization do not
506  * need to overload this method. When importing a CTML phase
507  * description, this method is called just prior to returning
508  * from function importPhase().
509  */
510  virtual void initThermo();
511 
512  /**
513  * Import and initialize a ThermoPhase object
514  *
515  * @param phaseNode This object must be the phase node of a
516  * complete XML tree
517  * description of the phase, including all of the
518  * species data. In other words while "phase" must
519  * point to an XML phase object, it must have
520  * sibling nodes "speciesData" that describe
521  * the species in the phase.
522  * @param id ID of the phase. If nonnull, a check is done
523  * to see if phaseNode is pointing to the phase
524  * with the correct id.
525  */
526  void initThermoXML(XML_Node& phaseNode, const std::string& id);
527 
528  //! @}
529  //! @name Derivatives of Thermodynamic Variables needed for Applications
530  //! @{
531 
532  //! Get the change in activity coefficients w.r.t. change in state (temp, mole fraction, etc.) along
533  //! a line in parameter space or along a line in physical space
534  /*!
535  *
536  * @param dTds Input of temperature change along the path
537  * @param dXds Input vector of changes in mole fraction along the path. length = m_kk
538  * Along the path length it must be the case that the mole fractions sum to one.
539  * @param dlnActCoeffds Output vector of the directional derivatives of the
540  * log Activity Coefficients along the path. length = m_kk
541  * units are 1/units(s). if s is a physical coordinate then the units are 1/m.
542  */
543  virtual void getdlnActCoeffds(const doublereal dTds, const doublereal* const dXds, doublereal* dlnActCoeffds) const;
544 
545  //! Get the array of log concentration-like derivatives of the
546  //! log activity coefficients - diagonal component
547  /*!
548  * This function is a virtual method. For ideal mixtures
549  * (unity activity coefficients), this can return zero.
550  * Implementations should take the derivative of the
551  * logarithm of the activity coefficient with respect to the
552  * logarithm of the mole fraction.
553  *
554  * units = dimensionless
555  *
556  * @param dlnActCoeffdlnX_diag Output vector of the diagonal component of the log(mole fraction)
557  * derivatives of the log Activity Coefficients.
558  * length = m_kk
559  */
560  virtual void getdlnActCoeffdlnX_diag(doublereal* dlnActCoeffdlnX_diag) const;
561 
562  //! Get the array of derivatives of the log activity coefficients wrt mole numbers - diagonal only
563  /*!
564  * This function is a virtual method. For ideal mixtures
565  * (unity activity coefficients), this can return zero.
566  * Implementations should take the derivative of the
567  * logarithm of the activity coefficient with respect to the
568  * logarithm of the concentration-like variable (i.e. mole fraction,
569  * molality, etc.) that represents the standard state.
570  *
571  * units = dimensionless
572  *
573  * @param dlnActCoeffdlnN_diag Output vector of the diagonal entries for the log(mole fraction)
574  * derivatives of the log Activity Coefficients.
575  * length = m_kk
576  */
577  virtual void getdlnActCoeffdlnN_diag(doublereal* dlnActCoeffdlnN_diag) const;
578 
579  //! Get the array of derivatives of the ln activity coefficients with respect to the ln species mole numbers
580  /*!
581  * Implementations should take the derivative of the logarithm of the activity coefficient with respect to a
582  * log of a species mole number (with all other species mole numbers held constant)
583  *
584  * units = 1 / kmol
585  *
586  * dlnActCoeffdlnN[ ld * k + m] will contain the derivative of log act_coeff for the <I>m</I><SUP>th</SUP>
587  * species with respect to the number of moles of the <I>k</I><SUP>th</SUP> species.
588  *
589  * \f[
590  * \frac{d \ln(\gamma_m) }{d \ln( n_k ) }\Bigg|_{n_i}
591  * \f]
592  *
593  * @param ld Number of rows in the matrix
594  * @param dlnActCoeffdlnN Output vector of derivatives of the
595  * log Activity Coefficients. length = m_kk * m_kk
596  */
597  virtual void getdlnActCoeffdlnN(const size_t ld, doublereal* const dlnActCoeffdlnN) ;
598 
599  //@}
600 
601 private:
602  //! Process an XML node called "binaryNeutralSpeciesParameters"
603  /*!
604  * This node contains all of the parameters necessary to describe
605  * the Margules model for a particular binary interaction.
606  * This function reads the XML file and writes the coefficients
607  * it finds to an internal data structures.
608  *
609  * @param xmlBinarySpecies Reference to the XML_Node named "binaryNeutralSpeciesParameters"
610  * containing the binary interaction
611  */
612  void readXMLBinarySpecies(XML_Node& xmlBinarySpecies);
613 
614  //! Resize internal arrays within the object that depend upon the number
615  //! of binary Margules interaction terms
616  /*!
617  * @param num Number of binary Margules interaction terms
618  */
619  void resizeNumInteractions(const size_t num);
620 
621  //! Initialize lengths of local variables after all species have
622  //! been identified.
623  void initLengths();
624 
625  //! Update the activity coefficients
626  /*!
627  * This function will be called to update the internally stored
628  * natural logarithm of the activity coefficients
629  */
630  void s_update_lnActCoeff() const;
631 
632  //! Update the derivative of the log of the activity coefficients wrt T
633  /*!
634  * This function will be called to update the internally stored
635  * derivative of the natural logarithm of the activity coefficients
636  * wrt temperature.
637  */
638  void s_update_dlnActCoeff_dT() const;
639 
640  //! Update the derivative of the log of the activity coefficients
641  //! wrt log(mole fraction)
642  /*!
643  * This function will be called to update the internally stored
644  * derivative of the natural logarithm of the activity coefficients
645  * wrt logarithm of the mole fractions.
646  */
647  void s_update_dlnActCoeff_dlnX_diag() const;
648 
649  //! Update the derivative of the log of the activity coefficients
650  //! wrt log(moles) - diagonal only
651  /*!
652  * This function will be called to update the internally stored diagonal entries for the
653  * derivative of the natural logarithm of the activity coefficients
654  * wrt logarithm of the moles.
655  */
656  void s_update_dlnActCoeff_dlnN_diag() const;
657 
658  //! Update the derivative of the log of the activity coefficients wrt log(moles_m)
659  /*!
660  * This function will be called to update the internally stored
661  * derivative of the natural logarithm of the activity coefficients
662  * wrt logarithm of the mole number of species
663  */
664  void s_update_dlnActCoeff_dlnN() const;
665 
666 protected:
667  //! number of binary interaction expressions
669 
670  //! Enthalpy term for the binary mole fraction interaction of the
671  //! excess Gibbs free energy expression
673 
674  //! Enthalpy term for the ternary mole fraction interaction of the
675  //! excess Gibbs free energy expression
677 
678  //! Enthalpy term for the quaternary mole fraction interaction of the
679  //! excess Gibbs free energy expression
681 
682  //! Entropy term for the binary mole fraction interaction of the
683  //! excess Gibbs free energy expression
685 
686  //! Entropy term for the ternary mole fraction interaction of the
687  //! excess Gibbs free energy expression
689 
690  //! Entropy term for the quaternary mole fraction interaction of the
691  //! excess Gibbs free energy expression
693 
694  //! Enthalpy term for the binary mole fraction interaction of the
695  //! excess Gibbs free energy expression
697 
698  //! Enthalpy term for the ternary mole fraction interaction of the
699  //! excess Gibbs free energy expression
701 
702  //! Enthalpy term for the quaternary mole fraction interaction of the
703  //! excess Gibbs free energy expression
705 
706  //! Entropy term for the binary mole fraction interaction of the
707  //! excess Gibbs free energy expression
709 
710  //! Entropy term for the ternary mole fraction interaction of the
711  //! excess Gibbs free energy expression
713 
714  //! Entropy term for the quaternary mole fraction interaction of the
715  //! excess Gibbs free energy expression
717 
718  //! vector of species indices representing species A in the interaction
719  /*!
720  * Each Margules excess Gibbs free energy term involves two species, A and B.
721  * This vector identifies species A.
722  */
723  std::vector<size_t> m_pSpecies_A_ij;
724 
725  //! vector of species indices representing species B in the interaction
726  /*!
727  * Each Margules excess Gibbs free energy term involves two species, A and B.
728  * This vector identifies species B.
729  */
730  std::vector<size_t> m_pSpecies_B_ij;
731 
732  //! form of the Margules interaction expression
733  /*!
734  * Currently there is only one form.
735  */
737 
738  //! form of the temperature dependence of the Margules interaction expression
739  /*!
740  * Currently there is only one form -> constant wrt temperature.
741  */
743 };
744 
745 }
746 
747 #endif
int formMargules_
form of the Margules interaction expression
vector_fp m_VSE_c_ij
Entropy term for the ternary mole fraction interaction of the excess Gibbs free energy expression...
void readXMLBinarySpecies(XML_Node &xmlBinarySpecies)
Process an XML node called "binaryNeutralSpeciesParameters".
vector_fp m_VSE_d_ij
Entropy term for the quaternary mole fraction interaction of the excess Gibbs free energy expression...
vector_fp m_HE_b_ij
Enthalpy term for the binary mole fraction interaction of the excess Gibbs free energy expression...
vector_fp m_VHE_d_ij
Enthalpy term for the quaternary mole fraction interaction of the excess Gibbs free energy expression...
virtual doublereal entropy_mole() const
Molar entropy. Units: J/kmol.
void initThermoXML(XML_Node &phaseNode, const std::string &id)
Import and initialize a ThermoPhase object.
std::vector< size_t > m_pSpecies_A_ij
vector of species indices representing species A in the interaction
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
virtual void getd2lnActCoeffdT2(doublereal *d2lnActCoeffdT2) const
Get the array of temperature second derivatives of the log activity coefficients. ...
size_t numBinaryInteractions_
number of binary interaction expressions
virtual void getdlnActCoeffdlnN(const size_t ld, doublereal *const dlnActCoeffdlnN)
Get the array of derivatives of the ln activity coefficients with respect to the ln species mole numb...
virtual void getdlnActCoeffdT(doublereal *dlnActCoeffdT) const
Get the array of temperature derivatives of the log activity coefficients.
void resizeNumInteractions(const size_t num)
Resize internal arrays within the object that depend upon the number of binary Margules interaction t...
void initLengths()
Initialize lengths of local variables after all species have been identified.
virtual void getPartialMolarCp(doublereal *cpbar) const
Returns an array of partial molar entropies for the species in the mixture.
virtual void getdlnActCoeffds(const doublereal dTds, const doublereal *const dXds, doublereal *dlnActCoeffds) const
Get the change in activity coefficients w.r.t.
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:97
vector_fp m_SE_d_ij
Entropy term for the quaternary mole fraction interaction of the excess Gibbs free energy expression...
virtual ThermoPhase * duplMyselfAsThermoPhase() const
Duplication routine for objects which inherit from ThermoPhase.
vector_fp m_SE_b_ij
Entropy term for the binary mole fraction interaction of the excess Gibbs free energy expression...
void s_update_dlnActCoeff_dlnN() const
Update the derivative of the log of the activity coefficients wrt log(moles_m)
void getElectrochemPotentials(doublereal *mu) const
Get the species electrochemical potentials.
virtual doublereal enthalpy_mole() const
Molar enthalpy. Units: J/kmol.
Header for intermediate ThermoPhase object for phases which employ Gibbs excess free energy based for...
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.
vector_fp m_VHE_b_ij
Enthalpy term for the binary mole fraction interaction of the excess Gibbs free energy expression...
void s_update_dlnActCoeff_dlnN_diag() const
Update the derivative of the log of the activity coefficients wrt log(moles) - diagonal only...
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
virtual void getLnActivityCoefficients(doublereal *lnac) const
Get the array of non-dimensional molar-based ln activity coefficients at the current solution tempera...
vector_fp m_VSE_b_ij
Entropy term for the binary 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
virtual void getdlnActCoeffdlnX_diag(doublereal *dlnActCoeffdlnX_diag) const
Get the array of log concentration-like derivatives of the log activity coefficients - diagonal compo...
MargulesVPSSTP & operator=(const MargulesVPSSTP &b)
Assignment operator.
vector_fp m_VHE_c_ij
Enthalpy term for the ternary mole fraction interaction of the excess Gibbs free energy expression...
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
MargulesVPSSTP()
Constructor.
void s_update_lnActCoeff() const
Update the activity coefficients.
vector_fp m_SE_c_ij
Entropy term for the ternary 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.
MargulesVPSSTP is a derived class of GibbsExcessVPSSTP that employs the Margules approximation for th...
vector_fp m_HE_c_ij
Enthalpy term for the ternary mole fraction interaction of the excess Gibbs free energy expression...
int formTempModel_
form of the temperature dependence of the Margules interaction expression
virtual doublereal cp_mole() const
Molar heat capacity at constant pressure. Units: J/kmol/K.
void s_update_dlnActCoeff_dT() const
Update the derivative of the log of the activity coefficients wrt T.
void s_update_dlnActCoeff_dlnX_diag() const
Update the derivative of the log of the activity coefficients wrt log(mole fraction) ...
virtual doublereal cv_mole() const
Molar heat capacity at constant volume. Units: J/kmol/K.
virtual void getdlnActCoeffdlnN_diag(doublereal *dlnActCoeffdlnN_diag) const
Get the array of derivatives of the log activity coefficients wrt mole numbers - diagonal only...