Cantera  2.1.2
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 refactored into a standalone test
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 Utilities
331  //! @{
332 
333  //! Equation of state type flag.
334  /*!
335  * The ThermoPhase base class returns
336  * zero. Subclasses should define this to return a unique
337  * non-zero value. Known constants defined for this purpose are
338  * listed in mix_defs.h. The MolalityVPSSTP class also returns
339  * zero, as it is a non-complete class.
340  */
341  virtual int eosType() const;
342 
343  //! @}
344  //! @name Molar Thermodynamic Properties
345  //! @{
346 
347  /// Molar enthalpy. Units: J/kmol.
348  virtual doublereal enthalpy_mole() const;
349 
350  /// Molar entropy. Units: J/kmol.
351  virtual doublereal entropy_mole() const;
352 
353  /// Molar heat capacity at constant pressure. Units: J/kmol/K.
354  virtual doublereal cp_mole() const;
355 
356  /// Molar heat capacity at constant volume. Units: J/kmol/K.
357  virtual doublereal cv_mole() const;
358 
359  /**
360  * @}
361  * @name Activities, Standard States, and Activity Concentrations
362  *
363  * The activity \f$a_k\f$ of a species in solution is
364  * related to the chemical potential by \f[ \mu_k = \mu_k^0(T)
365  * + \hat R T \log a_k. \f] The quantity \f$\mu_k^0(T,P)\f$ is
366  * the chemical potential at unit activity, which depends only
367  * on temperature and pressure.
368  * @{
369  */
370 
371  //! Get the array of non-dimensional molar-based ln activity coefficients at
372  //! the current solution temperature, pressure, and solution concentration.
373  /*!
374  * @param lnac Output vector of ln activity coefficients. Length: m_kk.
375  */
376  virtual void getLnActivityCoefficients(doublereal* lnac) const;
377 
378  //@}
379  /// @name Partial Molar Properties of the Solution
380  //@{
381 
382  //! Get the species chemical potentials. Units: J/kmol.
383  /*!
384  * This function returns a vector of chemical potentials of the
385  * species in solution at the current temperature, pressure
386  * and mole fraction of the solution.
387  *
388  * @param mu Output vector of species chemical
389  * potentials. Length: m_kk. Units: J/kmol
390  */
391  virtual void getChemPotentials(doublereal* mu) const;
392 
393  //! Returns an array of partial molar enthalpies for the species
394  //! in the mixture.
395  /*!
396  * Units (J/kmol)
397  *
398  * For this phase, the partial molar enthalpies are equal to the
399  * standard state enthalpies modified by the derivative of the
400  * molality-based activity coefficient wrt temperature
401  *
402  * \f[
403  * \bar h_k(T,P) = h^o_k(T,P) - R T^2 \frac{d \ln(\gamma_k)}{dT}
404  * \f]
405  *
406  * @param hbar Vector of returned partial molar enthalpies
407  * (length m_kk, units = J/kmol)
408  */
409  virtual void getPartialMolarEnthalpies(doublereal* hbar) const;
410 
411  //! Returns an array of partial molar entropies for the species
412  //! in the mixture.
413  /*!
414  * Units (J/kmol)
415  *
416  * For this phase, the partial molar enthalpies are equal to the
417  * standard state enthalpies modified by the derivative of the
418  * activity coefficient wrt temperature
419  *
420  * \f[
421  * \bar s_k(T,P) = s^o_k(T,P) - R T^2 \frac{d \ln(\gamma_k)}{dT}
422  * - R \ln( \gamma_k X_k)
423  * - R T \frac{d \ln(\gamma_k) }{dT}
424  * \f]
425  *
426  * @param sbar Vector of returned partial molar entropies
427  * (length m_kk, units = J/kmol/K)
428  */
429  virtual void getPartialMolarEntropies(doublereal* sbar) const;
430 
431  //! Returns an array of partial molar entropies for the species
432  //! in the mixture.
433  /*!
434  * Units (J/kmol)
435  *
436  * For this phase, the partial molar enthalpies are equal to the
437  * standard state enthalpies modified by the derivative of the
438  * activity coefficient wrt temperature
439  *
440  * \f[
441  * ???????????????
442  * \bar s_k(T,P) = s^o_k(T,P) - R T^2 \frac{d \ln(\gamma_k)}{dT}
443  * - R \ln( \gamma_k X_k)
444  * - R T \frac{d \ln(\gamma_k) }{dT}
445  * ???????????????
446  * \f]
447  *
448  * @param cpbar Vector of returned partial molar heat capacities
449  * (length m_kk, units = J/kmol/K)
450  */
451  virtual void getPartialMolarCp(doublereal* cpbar) const;
452 
453 
454  //! Return an array of partial molar volumes for the
455  //! species in the mixture. Units: m^3/kmol.
456  /*!
457  * Frequently, for this class of thermodynamics representations,
458  * the excess Volume due to mixing is zero. Here, we set it as
459  * a default. It may be overridden in derived classes.
460  *
461  * @param vbar Output vector of species partial molar volumes.
462  * Length = m_kk. units are m^3/kmol.
463  */
464  virtual void getPartialMolarVolumes(doublereal* vbar) const;
465 
466  //! Get the species electrochemical potentials.
467  /*!
468  * These are partial molar quantities.
469  * This method adds a term \f$ Fz_k \phi_k \f$ to the
470  * to each chemical potential.
471  *
472  * Units: J/kmol
473  *
474  * @param mu output vector containing the species electrochemical potentials.
475  * Length: m_kk., units = J/kmol
476  */
477  void getElectrochemPotentials(doublereal* mu) const;
478 
479  //! Get the array of temperature second derivatives of the log activity coefficients
480  /*!
481  * This function is a virtual class, but it first appears in GibbsExcessVPSSTP
482  * class and derived classes from GibbsExcessVPSSTP.
483  *
484  * units = 1/Kelvin
485  *
486  * @param d2lnActCoeffdT2 Output vector of temperature 2nd derivatives of the
487  * log Activity Coefficients. length = m_kk
488  *
489  */
490  virtual void getd2lnActCoeffdT2(doublereal* d2lnActCoeffdT2) const;
491 
492  //! Get the array of temperature derivatives of the log activity coefficients
493  /*!
494  * This function is a virtual class, but it first appears in GibbsExcessVPSSTP
495  * class and derived classes from GibbsExcessVPSSTP.
496  *
497  * units = 1/Kelvin
498  *
499  * @param dlnActCoeffdT Output vector of temperature derivatives of the
500  * log Activity Coefficients. length = m_kk
501  *
502  */
503  virtual void getdlnActCoeffdT(doublereal* dlnActCoeffdT) const;
504 
505  /// @}
506  /// @name Initialization
507  /// The following methods are used in the process of constructing
508  /// the phase and setting its parameters from a specification in an
509  /// input file. They are not normally used in application programs.
510  /// To see how they are used, see files importCTML.cpp and
511  /// ThermoFactory.cpp.
512  /// @{
513 
514  /*!
515  * @internal Initialize. This method is provided to allow
516  * subclasses to perform any initialization required after all
517  * species have been added. For example, it might be used to
518  * resize internal work arrays that must have an entry for
519  * each species. The base class implementation does nothing,
520  * and subclasses that do not require initialization do not
521  * need to overload this method. When importing a CTML phase
522  * description, this method is called just prior to returning
523  * from function importPhase.
524  *
525  * @see importCTML.cpp
526  */
527  virtual void initThermo();
528 
529  /**
530  * Import and initialize a ThermoPhase object
531  *
532  * @param phaseNode This object must be the phase node of a
533  * complete XML tree
534  * description of the phase, including all of the
535  * species data. In other words while "phase" must
536  * point to an XML phase object, it must have
537  * sibling nodes "speciesData" that describe
538  * the species in the phase.
539  * @param id ID of the phase. If nonnull, a check is done
540  * to see if phaseNode is pointing to the phase
541  * with the correct id.
542  */
543  void initThermoXML(XML_Node& phaseNode, const std::string& id);
544 
545  //! @}
546  //! @name Derivatives of Thermodynamic Variables needed for Applications
547  //! @{
548 
549  //! Get the change in activity coefficients w.r.t. change in state (temp, mole fraction, etc.) along
550  //! a line in parameter space or along a line in physical space
551  /*!
552  *
553  * @param dTds Input of temperature change along the path
554  * @param dXds Input vector of changes in mole fraction along the path. length = m_kk
555  * Along the path length it must be the case that the mole fractions sum to one.
556  * @param dlnActCoeffds Output vector of the directional derivatives of the
557  * log Activity Coefficients along the path. length = m_kk
558  * units are 1/units(s). if s is a physical coordinate then the units are 1/m.
559  */
560  virtual void getdlnActCoeffds(const doublereal dTds, const doublereal* const dXds, doublereal* dlnActCoeffds) const;
561 
562  //! Get the array of log concentration-like derivatives of the
563  //! log activity coefficients - diagonal component
564  /*!
565  * This function is a virtual method. For ideal mixtures
566  * (unity activity coefficients), this can return zero.
567  * Implementations should take the derivative of the
568  * logarithm of the activity coefficient with respect to the
569  * logarithm of the mole fraction.
570  *
571  * units = dimensionless
572  *
573  * @param dlnActCoeffdlnX_diag Output vector of the diagonal component of the log(mole fraction)
574  * derivatives of the log Activity Coefficients.
575  * length = m_kk
576  */
577  virtual void getdlnActCoeffdlnX_diag(doublereal* dlnActCoeffdlnX_diag) const;
578 
579  //! Get the array of derivatives of the log activity coefficients wrt mole numbers - diagonal only
580  /*!
581  * This function is a virtual method. For ideal mixtures
582  * (unity activity coefficients), this can return zero.
583  * Implementations should take the derivative of the
584  * logarithm of the activity coefficient with respect to the
585  * logarithm of the concentration-like variable (i.e. mole fraction,
586  * molality, etc.) that represents the standard state.
587  *
588  * units = dimensionless
589  *
590  * @param dlnActCoeffdlnN_diag Output vector of the diagonal entries for the log(mole fraction)
591  * derivatives of the log Activity Coefficients.
592  * length = m_kk
593  */
594  virtual void getdlnActCoeffdlnN_diag(doublereal* dlnActCoeffdlnN_diag) const;
595 
596  //! Get the array of derivatives of the ln activity coefficients with respect to the ln species mole numbers
597  /*!
598  * Implementations should take the derivative of the logarithm of the activity coefficient with respect to a
599  * log of a species mole number (with all other species mole numbers held constant)
600  *
601  * units = 1 / kmol
602  *
603  * dlnActCoeffdlnN[ ld * k + m] will contain the derivative of log act_coeff for the <I>m</I><SUP>th</SUP>
604  * species with respect to the number of moles of the <I>k</I><SUP>th</SUP> species.
605  *
606  * \f[
607  * \frac{d \ln(\gamma_m) }{d \ln( n_k ) }\Bigg|_{n_i}
608  * \f]
609  *
610  * @param ld Number of rows in the matrix
611  * @param dlnActCoeffdlnN Output vector of derivatives of the
612  * log Activity Coefficients. length = m_kk * m_kk
613  */
614  virtual void getdlnActCoeffdlnN(const size_t ld, doublereal* const dlnActCoeffdlnN) ;
615 
616  //@}
617 
618 private:
619  //! Process an XML node called "binaryNeutralSpeciesParameters"
620  /*!
621  * This node contains all of the parameters necessary to describe
622  * the Margules model for a particular binary interaction.
623  * This function reads the XML file and writes the coefficients
624  * it finds to an internal data structures.
625  *
626  * @param xmlBinarySpecies Reference to the XML_Node named "binaryNeutralSpeciesParameters"
627  * containing the binary interaction
628  */
629  void readXMLBinarySpecies(XML_Node& xmlBinarySpecies);
630 
631  //! Resize internal arrays within the object that depend upon the number
632  //! of binary Margules interaction terms
633  /*!
634  * @param num Number of binary Margules interaction terms
635  */
636  void resizeNumInteractions(const size_t num);
637 
638  //! Initialize lengths of local variables after all species have
639  //! been identified.
640  void initLengths();
641 
642  //! Update the activity coefficients
643  /*!
644  * This function will be called to update the internally stored
645  * natural logarithm of the activity coefficients
646  */
647  void s_update_lnActCoeff() const;
648 
649  //! Update the derivative of the log of the activity coefficients wrt T
650  /*!
651  * This function will be called to update the internally stored
652  * derivative of the natural logarithm of the activity coefficients
653  * wrt temperature.
654  */
655  void s_update_dlnActCoeff_dT() const;
656 
657  //! Update the derivative of the log of the activity coefficients
658  //! wrt log(mole fraction)
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 fractions.
663  */
664  void s_update_dlnActCoeff_dlnX_diag() const;
665 
666  //! Update the derivative of the log of the activity coefficients
667  //! wrt log(moles) - diagonal only
668  /*!
669  * This function will be called to update the internally stored diagonal entries for the
670  * derivative of the natural logarithm of the activity coefficients
671  * wrt logarithm of the moles.
672  */
673  void s_update_dlnActCoeff_dlnN_diag() const;
674 
675  //! Update the derivative of the log of the activity coefficients wrt log(moles_m)
676  /*!
677  * This function will be called to update the internally stored
678  * derivative of the natural logarithm of the activity coefficients
679  * wrt logarithm of the mole number of species
680  */
681  void s_update_dlnActCoeff_dlnN() const;
682 
683 private:
684  //! Error function
685  /*!
686  * Print an error string and exit
687  *
688  * @param msg Message to be printed
689  */
690  doublereal err(const std::string& msg) const;
691 
692 protected:
693  //! number of binary interaction expressions
695 
696  //! Enthalpy term for the binary mole fraction interaction of the
697  //! excess gibbs free energy expression
699 
700  //! Enthalpy term for the ternary mole fraction interaction of the
701  //! excess gibbs free energy expression
703 
704  //! Enthalpy term for the quaternary mole fraction interaction of the
705  //! excess gibbs free energy expression
707 
708  //! Entropy term for the binary mole fraction interaction of the
709  //! excess gibbs free energy expression
711 
712  //! Entropy term for the ternary mole fraction interaction of the
713  //! excess gibbs free energy expression
715 
716  //! Entropy term for the quaternary mole fraction interaction of the
717  //! excess gibbs free energy expression
719 
720  //! Enthalpy term for the binary mole fraction interaction of the
721  //! excess gibbs free energy expression
723 
724  //! Enthalpy term for the ternary mole fraction interaction of the
725  //! excess gibbs free energy expression
727 
728  //! Enthalpy term for the quaternary mole fraction interaction of the
729  //! excess gibbs free energy expression
731 
732  //! Entropy term for the binary mole fraction interaction of the
733  //! excess gibbs free energy expression
735 
736  //! Entropy term for the ternary mole fraction interaction of the
737  //! excess gibbs free energy expression
739 
740  //! Entropy term for the quaternary mole fraction interaction of the
741  //! excess gibbs free energy expression
743 
744  //! vector of species indices representing species A in the interaction
745  /*!
746  * Each Margules excess Gibbs free energy term involves two species, A and B.
747  * This vector identifies species A.
748  */
749  std::vector<size_t> m_pSpecies_A_ij;
750 
751  //! vector of species indices representing species B in the interaction
752  /*!
753  * Each Margules excess Gibbs free energy term involves two species, A and B.
754  * This vector identifies species B.
755  */
756  std::vector<size_t> m_pSpecies_B_ij;
757 
758  //! form of the Margules interaction expression
759  /*!
760  * Currently there is only one form.
761  */
763 
764  //! form of the temperature dependence of the Margules interaction expression
765  /*!
766  * Currently there is only one form -> constant wrt temperature.
767  */
769 };
770 
771 }
772 
773 #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:101
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:165
MargulesVPSSTP()
Constructor.
doublereal err(const std::string &msg) const
Error function.
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.
virtual int eosType() const
Equation of state type flag.
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...