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