Cantera  2.1.2
RedlichKisterVPSSTP.h
Go to the documentation of this file.
1 /**
2  * @file RedlichKisterVPSSTP.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::RedlichKisterVPSSTP RedlichKisterVPSSTP\endlink).
7  *
8  * Header file for a derived class of ThermoPhase that handles
9  * variable pressure standard state methods for calculating
10  * thermodynamic properties that are further based upon activities
11  * based on the molality scale. These include most of the methods for
12  * calculating liquid electrolyte thermodynamics.
13  */
14 /*
15  * Copyright (2006) Sandia Corporation. Under the terms of
16  * Contract DE-AC04-94AL85000 with Sandia Corporation, the
17  * U.S. Government retains certain rights in this software.
18  */
19 
20 #ifndef CT_REDLICHKISTERVPSSTP_H
21 #define CT_REDLICHKISTERVPSSTP_H
22 
24 #include "cantera/base/Array.h"
25 
26 namespace Cantera
27 {
28 
29 /**
30  * @ingroup thermoprops
31  */
32 
33 //! RedlichKisterVPSSTP is a derived class of GibbsExcessVPSSTP that employs
34 //! the Redlich-Kister approximation for the excess gibbs free energy
35 /*!
36  * %RedlichKisterVPSSTP derives from class GibbsExcessVPSSTP which is derived
37  * from VPStandardStateTP, and overloads the virtual methods defined there with ones that
38  * use expressions appropriate for the Redlich Kister Excess gibbs free energy approximation.
39  *
40  * The independent unknowns are pressure, temperature, and mass fraction.
41  *
42  * Several concepts are introduced. The first concept is there are temporary
43  * variables for holding the species standard state values of Cp, H, S, G, and V at the
44  * last temperature and pressure called. These functions are not recalculated
45  * if a new call is made using the previous temperature and pressure. Currently,
46  * these variables and the calculation method are handled by the VPSSMgr class,
47  * for which VPStandardStateTP owns a pointer to.
48  *
49  * To support the above functionality, pressure and temperature variables,
50  * m_plast_ss and m_tlast_ss, are kept which store the last pressure and temperature
51  * used in the evaluation of standard state properties.
52  *
53  * This class is usually used for nearly incompressible phases. For those phases, it
54  * makes sense to change the equation of state independent variable from
55  * density to pressure. The variable m_Pcurrent contains the current value of the
56  * pressure within the phase.
57  *
58  *
59  * <HR>
60  * <H2> Specification of Species Standard %State Properties </H2>
61  * <HR>
62  *
63  * All species are defined to have standard states that depend upon both
64  * the temperature and the pressure. The Redlich-Kister approximation assumes
65  * symmetric standard states, where all of the standard state assume
66  * that the species are in pure component states at the temperature
67  * and pressure of the solution. I don't think it prevents, however,
68  * some species from being dilute in the solution.
69  *
70  *
71  * <HR>
72  * <H2> Specification of Solution Thermodynamic Properties </H2>
73  * <HR>
74  *
75  * The molar excess Gibbs free energy is given by the following formula which is a sum over interactions <I>i</I>.
76  * Each of the interactions are binary interactions involving two of the species in the phase, denoted, <I>Ai</I>
77  * and <I>Bi</I>.
78  * This is the generalization of the Redlich-Kister formulation for a phase that has more than 2 species.
79  *
80  * \f[
81  * G^E = \sum_{i} G^E_{i}
82  * \f]
83  *
84  * where
85  *
86  * \f[
87  * G^E_{i} = n X_{Ai} X_{Bi} \sum_m \left( A^{i}_m {\left( X_{Ai} - X_{Bi} \right)}^m \right)
88  * \f]
89  *
90  * and where we can break down the gibbs free energy contributions into enthalpy and entropy contributions
91  *
92  * \f[
93  * H^E_i = n X_{Ai} X_{Bi} \sum_m \left( H^{i}_m {\left( X_{Ai} - X_{Bi} \right)}^m \right)
94  * \f]
95  *
96  * \f[
97  * S^E_i = n X_{Ai} X_{Bi} \sum_m \left( S^{i}_m {\left( X_{Ai} - X_{Bi} \right)}^m \right)
98  * \f]
99  *
100  * where n is the total moles in the solution.
101  *
102  * The activity of a species defined in the phase is given by an excess Gibbs free energy formulation.
103  *
104  * \f[
105  * a_k = \gamma_k X_k
106  * \f]
107  *
108  * where
109  *
110  * \f[
111  * R T \ln( \gamma_k )= \frac{d(n G^E)}{d(n_k)}\Bigg|_{n_i}
112  * \f]
113  *
114  * Taking the derivatives results in the following expression
115  * \f[
116  * R T \ln( \gamma_k )= \sum_i \delta_{Ai,k} (1 - X_{Ai}) X_{Bi} \sum_m \left( A^{i}_m {\left( X_{Ai} - X_{Bi} \right)}^m \right)
117  * + \sum_i \delta_{Ai,k} X_{Ai} X_{Bi} \sum_m \left( A^{i}_0 + A^{i}_m {\left( X_{Ai} - X_{Bi} \right)}^{m-1} (1 - X_{Ai} + X_{Bi}) \right)
118  * \f]
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  * <HR>
156  * <H2> %Application within %Kinetics Managers </H2>
157  * <HR>
158  *
159  * \f$ C^a_k\f$ are defined such that \f$ a_k = C^a_k /
160  * C^s_k, \f$ where \f$ C^s_k \f$ is a standard concentration
161  * defined below and \f$ a_k \f$ are activities used in the
162  * thermodynamic functions. These activity (or generalized)
163  * concentrations are used
164  * by kinetics manager classes to compute the forward and
165  * reverse rates of elementary reactions.
166  * The activity concentration,\f$ C^a_k \f$,is given by the following expression.
167  *
168  * \f[
169  * C^a_k = C^s_k X_k = \frac{P}{R T} X_k
170  * \f]
171  *
172  * The standard concentration for species <I>k</I> is independent of <I>k</I> and equal to
173  *
174  * \f[
175  * C^s_k = C^s = \frac{P}{R T}
176  * \f]
177  *
178  * For example, a bulk-phase binary gas reaction between species j and k, producing
179  * a new gas species l would have the
180  * following equation for its rate of progress variable, \f$ R^1 \f$, which has
181  * units of kmol m-3 s-1.
182  *
183  * \f[
184  * R^1 = k^1 C_j^a C_k^a = k^1 (C^s a_j) (C^s a_k)
185  * \f]
186  * where
187  * \f[
188  * C_j^a = C^s a_j \mbox{\quad and \quad} C_k^a = C^s a_k
189  * \f]
190  *
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  * @ingroup thermoprops
258  *
259  */
261 {
262 public:
263  //! Constructor
264  /*!
265  * This doesn't do much more than initialize constants with
266  * default values.
267  */
269 
270  //! Construct and initialize a RedlichKisterVPSSTP ThermoPhase object
271  //! directly from an xml input file
272  /*!
273  *
274  * @param inputFile Name of the input file containing the phase XML data
275  * to set up the object
276  * @param id ID of the phase in the input file. Defaults to the
277  * empty string.
278  */
279  RedlichKisterVPSSTP(const std::string& inputFile, const std::string& id = "");
280 
281  //! Construct and initialize a RedlichKisterVPSSTP ThermoPhase object
282  //! directly from an XML database
283  /*!
284  * @param phaseRef XML phase node containing the description of the phase
285  * @param id id attribute containing the name of the phase.
286  * (default is the empty string)
287  */
288  RedlichKisterVPSSTP(XML_Node& phaseRef, const std::string& id = "");
289 
290  //! Special constructor for a hard-coded problem
291  /*!
292  * @param testProb Hard-coded value. Only the value of 1 is used. It's
293  * for a LiKCl system -> test to predict the eutectic and
294  * liquidus correctly.
295  * @deprecated To be refactored into a standalone test
296  */
297  RedlichKisterVPSSTP(int testProb);
298 
299  //! Copy constructor
300  /*!
301  * @param b class to be copied
302  */
304 
305  //! Assignment operator
306  /*!
307  * @param b class to be copied.
308  */
310 
311  //! Duplication routine for objects which inherit from ThermoPhase.
312  /*!
313  * This virtual routine can be used to duplicate thermophase objects
314  * inherited from ThermoPhase even if the application only has
315  * a pointer to ThermoPhase to work with.
316  */
317  virtual ThermoPhase* duplMyselfAsThermoPhase() const;
318 
319  //! @name Utilities
320  //! @{
321 
322  //! Equation of state type flag.
323  /*!
324  * The ThermoPhase base class returns
325  * zero. Subclasses should define this to return a unique
326  * non-zero value. Known constants defined for this purpose are
327  * listed in mix_defs.h.
328  */
329  virtual int eosType() const;
330 
331  //! @}
332  //! @name Molar Thermodynamic Properties
333  //! @{
334 
335  /// Molar enthalpy. Units: J/kmol.
336  virtual doublereal enthalpy_mole() const;
337 
338  /// Molar entropy. Units: J/kmol.
339  virtual doublereal entropy_mole() const;
340 
341  /// Molar heat capacity at constant pressure. Units: J/kmol/K.
342  virtual doublereal cp_mole() const;
343 
344  /// Molar heat capacity at constant volume. Units: J/kmol/K.
345  virtual doublereal cv_mole() const;
346 
347  /**
348  * @}
349  * @name Activities, Standard States, and Activity Concentrations
350  *
351  * The activity \f$a_k\f$ of a species in solution is
352  * related to the chemical potential by \f[ \mu_k = \mu_k^0(T)
353  * + \hat R T \log a_k. \f] The quantity \f$\mu_k^0(T,P)\f$ is
354  * the chemical potential at unit activity, which depends only
355  * on temperature and pressure.
356  * @{
357  */
358 
359  //! Get the array of non-dimensional molar-based ln activity coefficients at
360  //! the current solution temperature, pressure, and solution concentration.
361  /*!
362  * @param lnac Output vector of ln activity coefficients. Length: m_kk.
363  */
364  virtual void getLnActivityCoefficients(doublereal* lnac) const;
365 
366  //@}
367  /// @name Partial Molar Properties of the Solution
368  //@{
369 
370  //! Get the species chemical potentials. Units: J/kmol.
371  /*!
372  * This function returns a vector of chemical potentials of the
373  * species in solution at the current temperature, pressure
374  * and mole fraction of the solution.
375  *
376  * @param mu Output vector of species chemical
377  * potentials. Length: m_kk. Units: J/kmol
378  */
379  virtual void getChemPotentials(doublereal* mu) const;
380 
381  //! Returns an array of partial molar enthalpies for the species
382  //! in the mixture.
383  /*!
384  * Units (J/kmol)
385  *
386  * For this phase, the partial molar enthalpies are equal to the
387  * standard state enthalpies modified by the derivative of the
388  * molality-based activity coefficient wrt temperature
389  *
390  * \f[
391  * \bar h_k(T,P) = h^o_k(T,P) - R T^2 \frac{d \ln(\gamma_k)}{dT}
392  * \f]
393  *
394  * @param hbar Vector of returned partial molar enthalpies
395  * (length m_kk, units = J/kmol)
396  */
397  virtual void getPartialMolarEnthalpies(doublereal* hbar) const;
398 
399  //! Returns an array of partial molar entropies for the species
400  //! in the mixture.
401  /*!
402  * Units (J/kmol)
403  *
404  * For this phase, the partial molar enthalpies are equal to the
405  * standard state enthalpies modified by the derivative of the
406  * activity coefficient wrt temperature
407  *
408  * \f[
409  * \bar s_k(T,P) = s^o_k(T,P) - R T^2 \frac{d \ln(\gamma_k)}{dT}
410  * - R \ln( \gamma_k X_k)
411  * - R T \frac{d \ln(\gamma_k) }{dT}
412  * \f]
413  *
414  * @param sbar Vector of returned partial molar entropies
415  * (length m_kk, units = J/kmol/K)
416  */
417  virtual void getPartialMolarEntropies(doublereal* sbar) const;
418 
419  //! Returns an array of partial molar entropies for the species
420  //! in the mixture.
421  /*!
422  * Units (J/kmol)
423  *
424  * For this phase, the partial molar enthalpies are equal to the
425  * standard state enthalpies modified by the derivative of the
426  * activity coefficient wrt temperature
427  *
428  * \f[
429  * ???????????????
430  * \bar s_k(T,P) = s^o_k(T,P) - R T^2 \frac{d \ln(\gamma_k)}{dT}
431  * - R \ln( \gamma_k X_k)
432  * - R T \frac{d \ln(\gamma_k) }{dT}
433  * ???????????????
434  * \f]
435  *
436  * @param cpbar Vector of returned partial molar heat capacities
437  * (length m_kk, units = J/kmol/K)
438  */
439  virtual void getPartialMolarCp(doublereal* cpbar) const;
440 
441  //! Return an array of partial molar volumes for the
442  //! species in the mixture. Units: m^3/kmol.
443  /*!
444  * Frequently, for this class of thermodynamics representations,
445  * the excess Volume due to mixing is zero. Here, we set it as
446  * a default. It may be overridden in derived classes.
447  *
448  * @param vbar Output vector of species partial molar volumes.
449  * Length = m_kk. units are m^3/kmol.
450  */
451  virtual void getPartialMolarVolumes(doublereal* vbar) const;
452 
453  //! Get the species electrochemical potentials.
454  /*!
455  * These are partial molar quantities.
456  * This method adds a term \f$ Fz_k \phi_k \f$ to the
457  * to each chemical potential.
458  *
459  * Units: J/kmol
460  *
461  * @param mu output vector containing the species electrochemical potentials.
462  * Length: m_kk., units = J/kmol
463  */
464  void getElectrochemPotentials(doublereal* mu) const;
465 
466  //! Get the array of temperature second derivatives of the log activity coefficients
467  /*!
468  * This function is a virtual class, but it first appears in GibbsExcessVPSSTP
469  * class and derived classes from GibbsExcessVPSSTP.
470  *
471  * units = 1/Kelvin
472  *
473  * @param d2lnActCoeffdT2 Output vector of temperature 2nd derivatives of the
474  * log Activity Coefficients. length = m_kk
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  virtual void getdlnActCoeffdT(doublereal* dlnActCoeffdT) const;
489 
490  /// @}
491  /// @name Initialization
492  /// The following methods are used in the process of constructing
493  /// the phase and setting its parameters from a specification in an
494  /// input file. They are not normally used in application programs.
495  /// To see how they are used, see files importCTML.cpp and
496  /// ThermoFactory.cpp.
497 
498  /*!
499  * @internal Initialize. This method is provided to allow
500  * subclasses to perform any initialization required after all
501  * species have been added. For example, it might be used to
502  * resize internal work arrays that must have an entry for
503  * each species. The base class implementation does nothing,
504  * and subclasses that do not require initialization do not
505  * need to overload this method. When importing a CTML phase
506  * description, this method is called just prior to returning
507  * from function importPhase.
508  *
509  * @see importCTML.cpp
510  */
511  virtual void initThermo();
512 
513  /**
514  * Import and initialize a ThermoPhase object
515  *
516  * @param phaseNode This object must be the phase node of a
517  * complete XML tree
518  * description of the phase, including all of the
519  * species data. In other words while "phase" must
520  * point to an XML phase object, it must have
521  * sibling nodes "speciesData" that describe
522  * the species in the phase.
523  * @param id ID of the phase. If nonnull, a check is done
524  * to see if phaseNode is pointing to the phase
525  * with the correct id.
526  */
527  void initThermoXML(XML_Node& phaseNode, const std::string& id);
528 
529  //! @}
530  //! @name Derivatives of Thermodynamic Variables needed for Applications
531  //! @{
532 
533  //! Get the change in activity coefficients w.r.t. change in state (temp, mole fraction, etc.) along
534  //! a line in parameter space or along a line in physical space
535  /*!
536  *
537  * @param dTds Input of temperature change along the path
538  * @param dXds Input vector of changes in mole fraction along the path. length = m_kk
539  * Along the path length it must be the case that the mole fractions sum to one.
540  * @param dlnActCoeffds Output vector of the directional derivatives of the
541  * log Activity Coefficients along the path. length = m_kk
542  * units are 1/units(s). if s is a physical coordinate then the units are 1/m.
543  */
544  virtual void getdlnActCoeffds(const doublereal dTds, const doublereal* const dXds, doublereal* dlnActCoeffds) const;
545 
546  //! Get the array of log concentration-like derivatives of the
547  //! log activity coefficients - diagonal component
548  /*!
549  * This function is a virtual method. For ideal mixtures
550  * (unity activity coefficients), this can return zero.
551  * Implementations should take the derivative of the
552  * logarithm of the activity coefficient with respect to the
553  * logarithm of the mole fraction.
554  *
555  * units = dimensionless
556  *
557  * @param dlnActCoeffdlnX_diag Output vector of the diagonal component of the log(mole fraction)
558  * derivatives of the log Activity Coefficients.
559  * length = m_kk
560  */
561  virtual void getdlnActCoeffdlnX_diag(doublereal* dlnActCoeffdlnX_diag) const;
562 
563  //! Get the array of derivatives of the log activity coefficients wrt mole numbers - diagonal only
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 concentration-like variable (i.e. mole fraction,
570  * molality, etc.) that represents the standard state.
571  *
572  * units = dimensionless
573  *
574  * @param dlnActCoeffdlnN_diag Output vector of the diagonal entries for the log(mole fraction)
575  * derivatives of the log Activity Coefficients.
576  * length = m_kk
577  */
578  virtual void getdlnActCoeffdlnN_diag(doublereal* dlnActCoeffdlnN_diag) const;
579 
580  //! Get the array of derivatives of the ln activity coefficients with respect to the ln species mole numbers
581  /*!
582  * Implementations should take the derivative of the logarithm of the activity coefficient with respect to a
583  * log of a species mole number (with all other species mole numbers held constant)
584  *
585  * units = 1 / kmol
586  *
587  * dlnActCoeffdlnN[ ld * k + m] will contain the derivative of log act_coeff for the <I>m</I><SUP>th</SUP>
588  * species with respect to the number of moles of the <I>k</I><SUP>th</SUP> species.
589  *
590  * \f[
591  * \frac{d \ln(\gamma_m) }{d \ln( n_k ) }\Bigg|_{n_i}
592  * \f]
593  *
594  * @param ld Number of rows in the matrix
595  * @param dlnActCoeffdlnN Output vector of derivatives of the
596  * log Activity Coefficients. length = m_kk * m_kk
597  */
598  virtual void getdlnActCoeffdlnN(const size_t ld, doublereal* const dlnActCoeffdlnN) ;
599 
600  //@}
601 
602 private:
603  //! Process an XML node called "binaryNeutralSpeciesParameters"
604  /*!
605  * This node contains all of the parameters necessary to describe
606  * the Redlich-Kister model for a particular binary interaction.
607  * This function reads the XML file and writes the coefficients
608  * it finds to an internal data structures.
609  *
610  * @param xmlBinarySpecies Reference to the XML_Node named "binaryNeutralSpeciesParameters"
611  * containing the binary interaction
612  */
613  void readXMLBinarySpecies(XML_Node& xmlBinarySpecies);
614 
615  //! Resize internal arrays within the object that depend upon the number
616  //! of binary Redlich-Kister interaction terms
617  /*!
618  * @param num Number of binary Redlich-Kister interaction terms
619  */
620  void resizeNumInteractions(const size_t num);
621 
622  //! Initialize lengths of local variables after all species have
623  //! been identified.
624  void initLengths();
625 
626  //! Update the activity coefficients
627  /*!
628  * This function will be called to update the internally stored
629  * natural logarithm of the activity coefficients
630  */
631  void s_update_lnActCoeff() const;
632 
633  //! Update the derivative of the log of the activity coefficients wrt T
634  /*!
635  * This function will be called to update the internally stored
636  * derivative of the natural logarithm of the activity coefficients
637  * wrt temperature.
638  */
639  void s_update_dlnActCoeff_dT() const;
640 
641  //! Internal routine that calculates the derivative of the activity coefficients wrt
642  //! the mole fractions.
643  /*!
644  * This routine calculates the the derivative of the activity coefficients wrt to mole fraction
645  * with all other mole fractions held constant. This is strictly not permitted. However, if the
646  * resulting matrix is multiplied by a permissible deltaX vector then everything is ok.
647  *
648  * This is the natural way to handle concentration derivatives in this routine.
649  */
650  void s_update_dlnActCoeff_dX_() const;
651 
652 #ifdef DEBUG_MODE
653 public:
654  //! Utility routine that calculates a literature expression
655  /*!
656  * @param VintOut Output contribution to the voltage corresponding to nonideal term
657  * @param voltsOut Output contribution to the voltage corresponding to nonideal term and mf term
658  */
659  void Vint(double& VintOut, double& voltsOut) ;
660 #endif
661 
662 private:
663  //! Error function
664  /*!
665  * Print an error string and exit
666  *
667  * @param msg Message to be printed
668  */
669  doublereal err(const std::string& msg) const;
670 
671 protected:
672  //! number of binary interaction expressions
674 
675  //! vector of species indices representing species A in the interaction
676  /*!
677  * Each Redlich-Kister excess Gibbs free energy term involves two species, A and B.
678  * This vector identifies species A.
679  */
680  std::vector<size_t> m_pSpecies_A_ij;
681 
682  //! vector of species indices representing species B in the interaction
683  /*!
684  * Each Redlich-Kister excess Gibbs free energy term involves two species, A and B.
685  * This vector identifies species B.
686  */
687  std::vector<size_t> m_pSpecies_B_ij;
688 
689  //! Vector of the length of the polynomial for the interaction.
690  std::vector<size_t> m_N_ij;
691 
692  //! Enthalpy term for the binary mole fraction interaction of the
693  //! excess gibbs free energy expression
694  mutable std::vector< vector_fp> m_HE_m_ij;
695 
696  //! Entropy term for the binary mole fraction interaction of the
697  //! excess gibbs free energy expression
698  mutable std::vector< vector_fp> m_SE_m_ij;
699 
700  //! form of the RedlichKister interaction expression
701  /*!
702  * Currently there is only one form.
703  */
705 
706  //! form of the temperature dependence of the Redlich-Kister interaction expression
707  /*!
708  * Currently there is only one form -> constant wrt temperature.
709  */
711 
712  //! Two dimensional array of derivatives of activity coefficients wrt mole fractions
714 };
715 
716 }
717 
718 #endif
virtual void getdlnActCoeffds(const doublereal dTds, const doublereal *const dXds, doublereal *dlnActCoeffds) const
Get the change in activity coefficients w.r.t.
virtual doublereal cv_mole() const
Molar heat capacity at constant volume. Units: J/kmol/K.
virtual void getdlnActCoeffdT(doublereal *dlnActCoeffdT) const
Get the array of temperature derivatives of the log activity coefficients.
RedlichKisterVPSSTP is a derived class of GibbsExcessVPSSTP that employs the Redlich-Kister approxima...
RedlichKisterVPSSTP & operator=(const RedlichKisterVPSSTP &b)
Assignment operator.
size_t numBinaryInteractions_
number of binary interaction expressions
virtual int eosType() const
Equation of state type flag.
std::vector< vector_fp > m_HE_m_ij
Enthalpy term for the binary mole fraction interaction of the excess gibbs free energy expression...
int formRedlichKister_
form of the RedlichKister interaction expression
virtual void getPartialMolarEntropies(doublereal *sbar) const
Returns an array of partial molar entropies for the species in the mixture.
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:100
int formTempModel_
form of the temperature dependence of the Redlich-Kister interaction expression
Array2D dlnActCoeff_dX_
Two dimensional array of derivatives of activity coefficients wrt mole fractions. ...
A class for 2D arrays stored in column-major (Fortran-compatible) form.
Definition: Array.h:33
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:101
Header file for class Cantera::Array2D.
virtual doublereal cp_mole() const
Molar heat capacity at constant pressure. Units: J/kmol/K.
void s_update_lnActCoeff() const
Update the activity coefficients.
virtual void getPartialMolarCp(doublereal *cpbar) const
Returns an array of partial molar entropies for the species in the mixture.
virtual void getdlnActCoeffdlnX_diag(doublereal *dlnActCoeffdlnX_diag) const
Get the array of log concentration-like derivatives of the log activity coefficients - diagonal compo...
virtual ThermoPhase * duplMyselfAsThermoPhase() const
Duplication routine for objects which inherit from ThermoPhase.
std::vector< size_t > m_pSpecies_B_ij
vector of species indices representing species B in the interaction
Header for intermediate ThermoPhase object for phases which employ gibbs excess free energy based for...
doublereal err(const std::string &msg) const
Error function.
virtual void getdlnActCoeffdlnN_diag(doublereal *dlnActCoeffdlnN_diag) const
Get the array of derivatives of the log activity coefficients wrt mole numbers - diagonal only...
void readXMLBinarySpecies(XML_Node &xmlBinarySpecies)
Process an XML node called "binaryNeutralSpeciesParameters".
void s_update_dlnActCoeff_dT() const
Update the derivative of the log of the activity coefficients wrt T.
virtual doublereal enthalpy_mole() const
Molar enthalpy. Units: J/kmol.
void initLengths()
Initialize lengths of local variables after all species have been identified.
virtual void getLnActivityCoefficients(doublereal *lnac) const
Get the array of non-dimensional molar-based ln activity coefficients at the current solution tempera...
void s_update_dlnActCoeff_dX_() const
Internal routine that calculates the derivative of the activity coefficients wrt the mole fractions...
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
void initThermoXML(XML_Node &phaseNode, const std::string &id)
Import and initialize a ThermoPhase object.
virtual void getPartialMolarEnthalpies(doublereal *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.
void getElectrochemPotentials(doublereal *mu) const
Get the species electrochemical potentials.
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...
void Vint(double &VintOut, double &voltsOut)
Utility routine that calculates a literature expression.
virtual void getPartialMolarVolumes(doublereal *vbar) const
Return an array of partial molar volumes for the species in the mixture.
virtual void getd2lnActCoeffdT2(doublereal *d2lnActCoeffdT2) const
Get the array of temperature second 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 Redlich-Kister interac...
virtual doublereal entropy_mole() const
Molar entropy. Units: J/kmol.
std::vector< size_t > m_N_ij
Vector of the length of the polynomial for the interaction.
std::vector< vector_fp > m_SE_m_ij
Entropy term for the binary mole fraction interaction of the excess gibbs free energy expression...