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