Cantera  2.0
IdealGasPhase.h
Go to the documentation of this file.
1 /**
2  * @file IdealGasPhase.h
3  * ThermoPhase object for the ideal gas equation of
4  * state - workhorse for %Cantera (see \ref thermoprops
5  * and class \link Cantera::IdealGasPhase IdealGasPhase\endlink).
6  */
7 
8 // Copyright 2001 California Institute of Technology
9 
10 #ifndef CT_IDEALGASPHASE_H
11 #define CT_IDEALGASPHASE_H
12 
13 //#include "cantera/base/ct_defs.h"
14 #include "mix_defs.h"
15 #include "ThermoPhase.h"
16 #include "SpeciesThermo.h"
17 #include "cantera/base/utilities.h"
18 
19 namespace Cantera
20 {
21 
22 
23 //! Class %IdealGasPhase represents low-density gases that obey the
24 //! ideal gas equation of state.
25 /*!
26  *
27  * %IdealGasPhase derives from class ThermoPhase,
28  * and overloads the virtual methods defined there with ones that
29  * use expressions appropriate for ideal gas mixtures.
30  *
31  * The independent unknowns are density, mass fraction, and temperature.
32  * the #setPressure() function will calculate the density consistent with
33  * the current mass fraction vector and temperature and the desired pressure,
34  * and then set the density.
35  *
36  * <HR>
37  * <H2> Specification of Species Standard State Properties </H2>
38  * <HR>
39  *
40  * It is assumed that the reference state thermodynamics may be
41  * obtained by a pointer to a populated species thermodynamic property
42  * manager class in the base class, ThermoPhase::m_spthermo
43  * (see the base class \link Cantera#SpeciesThermo SpeciesThermo \endlink for a
44  * description of the specification of reference state species thermodynamics functions).
45  * The reference state,
46  * where the pressure is fixed at a single pressure,
47  * is a key species property calculation for the Ideal Gas Equation
48  * of state.
49  *
50  * This class is optimized for speed of execution. All calls to thermodynamic functions
51  * first call internal routines (aka #enthalpy_RT_ref()) which return references
52  * the reference state thermodynamics functions. Within these internal reference
53  * state functions, the function #_updateThermo() is called, that first checks to see
54  * whether the temperature has changed. If it has, it updates the internal reference
55  * state thermo functions by calling the SpeciesThermo object.
56  *
57  * Functions for the calculation of standard state properties for species
58  * at arbitrary pressure are provided in %IdealGasPhase. However, they
59  * are all derived from their reference state counterparts.
60  *
61  * The standard state enthalpy is independent of pressure:
62  *
63  * \f[
64  * h^o_k(T,P) = h^{ref}_k(T)
65  * \f]
66  *
67  * The standard state constant-pressure heat capacity is independent of pressure:
68  *
69  * \f[
70  * Cp^o_k(T,P) = Cp^{ref}_k(T)
71  * \f]
72  *
73  * The standard state entropy depends in the following fashion on pressure:
74  *
75  * \f[
76  * S^o_k(T,P) = S^{ref}_k(T) - R \ln(\frac{P}{P_{ref}})
77  * \f]
78  * The standard state gibbs free energy is obtained from the enthalpy and entropy
79  * functions:
80  *
81  * \f[
82  * \mu^o_k(T,P) = h^o_k(T,P) - S^o_k(T,P) T
83  * \f]
84  *
85  * \f[
86  * \mu^o_k(T,P) = \mu^{ref}_k(T) + R T \ln( \frac{P}{P_{ref}})
87  * \f]
88  *
89  * where
90  * \f[
91  * \mu^{ref}_k(T) = h^{ref}_k(T) - T S^{ref}_k(T)
92  * \f]
93  *
94  * The standard state internal energy is obtained from the enthalpy function also
95  *
96  * \f[
97  * u^o_k(T,P) = h^o_k(T) - R T
98  * \f]
99  *
100  * The molar volume of a species is given by the ideal gas law
101  *
102  * \f[
103  * V^o_k(T,P) = \frac{R T}{P} \mbox{\quad where}
104  * \f]
105  *
106  * R is the molar gas constant. For a complete list of physical constants
107  * used within %Cantera, see \ref physConstants .
108  *
109  * <HR>
110  * <H2> Specification of Solution Thermodynamic Properties </H2>
111  * <HR>
112  *
113  * The activity of a species defined in the phase is given by the ideal gas law:
114  * \f[
115  * a_k = X_k
116  * \f]
117  * where \f$ X_k \f$ is the mole fraction of species <I>k</I>.
118  * The chemical potential for species <I>k</I> is equal to
119  *
120  * \f[
121  * \mu_k(T,P) = \mu^o_k(T, P) + R T \log(X_k)
122  * \f]
123  *
124  * In terms of the reference state, the above can be rewritten
125  *
126  *
127  * \f[
128  * \mu_k(T,P) = \mu^{ref}_k(T, P) + R T \log(\frac{P X_k}{P_{ref}})
129  * \f]
130  *
131  * The partial molar entropy for species <I>k</I> is given by the following relation,
132  *
133  * \f[
134  * \tilde{s}_k(T,P) = s^o_k(T,P) - R \log(X_k) = s^{ref}_k(T) - R \log(\frac{P X_k}{P_{ref}})
135  * \f]
136  *
137  * The partial molar enthalpy for species <I>k</I> is
138  *
139  * \f[
140  * \tilde{h}_k(T,P) = h^o_k(T,P) = h^{ref}_k(T)
141  * \f]
142  *
143  * The partial molar Internal Energy for species <I>k</I> is
144  *
145  * \f[
146  * \tilde{u}_k(T,P) = u^o_k(T,P) = u^{ref}_k(T)
147  * \f]
148  *
149  * The partial molar Heat Capacity for species <I>k</I> is
150  *
151  * \f[
152  * \tilde{Cp}_k(T,P) = Cp^o_k(T,P) = Cp^{ref}_k(T)
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)
164  * concentrations are used
165  * by kinetics manager classes to compute the forward and
166  * reverse rates of elementary reactions.
167  * The activity concentration,\f$ C^a_k \f$,is given by the following expression.
168  *
169  * \f[
170  * C^a_k = C^s_k X_k = \frac{P}{R T} X_k
171  * \f]
172  *
173  * The standard concentration for species <I>k</I> is independent of <I>k</I> and equal to
174  *
175  * \f[
176  * C^s_k = C^s = \frac{P}{R T}
177  * \f]
178  *
179  * For example, a bulk-phase binary gas reaction between species j and k, producing
180  * a new gas species l would have the
181  * following equation for its rate of progress variable, \f$ R^1 \f$, which has
182  * units of kmol m-3 s-1.
183  *
184  * \f[
185  * R^1 = k^1 C_j^a C_k^a = k^1 (C^s a_j) (C^s a_k)
186  * \f]
187  * where
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 rate 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  * <HR>
258  * <H2> Instantiation of the Class </H2>
259  * <HR>
260  *
261  *
262  * The constructor for this phase is located in the default ThermoFactory
263  * for %Cantera. A new %IdealGasPhase may be created by the following code
264  * snippet:
265  *
266  * @code
267  * XML_Node *xc = get_XML_File("silane.xml");
268  * XML_Node * const xs = xc->findNameID("phase", "silane");
269  * ThermoPhase *silane_tp = newPhase(*xs);
270  * IdealGasPhase *silaneGas = dynamic_cast <IdealGasPhase *>(silane_tp);
271  * @endcode
272  *
273  * or by the following constructor:
274  *
275  * @code
276  * XML_Node *xc = get_XML_File("silane.xml");
277  * XML_Node * const xs = xc->findNameID("phase", "silane");
278  * IdealGasPhase *silaneGas = new IdealGasPhase(*xs);
279  * @endcode
280  *
281  * <HR>
282  * <H2> XML Example </H2>
283  * <HR>
284  * An example of an XML Element named phase setting up a IdealGasPhase
285  * object named silane is given below.
286  *
287  * @verbatim
288  <!-- phase silane -->
289  <phase dim="3" id="silane">
290  <elementArray datasrc="elements.xml"> Si H He </elementArray>
291  <speciesArray datasrc="#species_data">
292  H2 H HE SIH4 SI SIH SIH2 SIH3 H3SISIH SI2H6
293  H2SISIH2 SI3H8 SI2 SI3
294  </speciesArray>
295  <reactionArray datasrc="#reaction_data"/>
296  <thermo model="IdealGas"/>
297  <kinetics model="GasKinetics"/>
298  <transport model="None"/>
299  </phase>
300  @endverbatim
301  *
302  * The model attribute "IdealGas" of the thermo XML element identifies the phase as
303  * being of the type handled by the IdealGasPhase object.
304  *
305  * @ingroup thermoprops
306  *
307  */
309 {
310 
311 public:
312 
313  //! Default empty Constructor
314  IdealGasPhase();
315 
316  //! Copy Constructor
317  /*!
318  * Copy constructor for the object. Constructed
319  * object will be a clone of this object, but will
320  * also own all of its data.
321  * This is a wrapper around the assignment operator
322  *
323  * @param right Object to be copied.
324  */
325  IdealGasPhase(const IdealGasPhase& right);
326 
327 
328  //! Assignment operator
329  /*!
330  * Assignment operator for the object. Constructed
331  * object will be a clone of this object, but will
332  * also own all of its data.
333  *
334  * @param right Object to be copied.
335  */
336  IdealGasPhase& operator=(const IdealGasPhase& right);
337 
338  //! Destructor
339  virtual ~IdealGasPhase() {}
340 
341  //! Duplicator from the %ThermoPhase parent class
342  /*!
343  * Given a pointer to a %ThermoPhase object, this function will
344  * duplicate the %ThermoPhase object and all underlying structures.
345  * This is basically a wrapper around the inherited copy constructor.
346  *
347  * @return returns a pointer to a %ThermoPhase object, containing
348  * a copy of the current object
349  */
351 
352  //! Equation of state flag.
353  /*!
354  * Returns the value cIdealGas, defined in mix_defs.h.
355  */
356  virtual int eosType() const {
357  return cIdealGas;
358  }
359 
360  /**
361  * @name Molar Thermodynamic Properties of the Solution ------------------------------
362  * @{
363  */
364 
365 
366  //! Return the Molar enthalpy. Units: J/kmol.
367  /*!
368  * For an ideal gas mixture,
369  * \f[
370  * \hat h(T) = \sum_k X_k \hat h^0_k(T),
371  * \f]
372  * and is a function only of temperature.
373  * The standard-state pure-species enthalpies
374  * \f$ \hat h^0_k(T) \f$ are computed by the species thermodynamic
375  * property manager.
376  *
377  * \see SpeciesThermo
378  */
379  virtual doublereal enthalpy_mole() const {
380  return GasConstant * temperature() *
381  mean_X(&enthalpy_RT_ref()[0]);
382  }
383 
384  /**
385  * Molar internal energy. J/kmol. For an ideal gas mixture,
386  * \f[
387  * \hat u(T) = \sum_k X_k \hat h^0_k(T) - \hat R T,
388  * \f]
389  * and is a function only of temperature.
390  * The reference-state pure-species enthalpies
391  * \f$ \hat h^0_k(T) \f$ are computed by the species thermodynamic
392  * property manager.
393  * @see SpeciesThermo
394  */
395  virtual doublereal intEnergy_mole() const;
396 
397  /**
398  * Molar entropy. Units: J/kmol/K.
399  * For an ideal gas mixture,
400  * \f[
401  * \hat s(T, P) = \sum_k X_k \hat s^0_k(T) - \hat R \log (P/P^0).
402  * \f]
403  * The reference-state pure-species entropies
404  * \f$ \hat s^0_k(T) \f$ are computed by the species thermodynamic
405  * property manager.
406  * @see SpeciesThermo
407  */
408  virtual doublereal entropy_mole() const;
409 
410  /**
411  * Molar Gibbs free Energy for an ideal gas.
412  * Units = J/kmol.
413  */
414  virtual doublereal gibbs_mole() const;
415 
416  /**
417  * Molar heat capacity at constant pressure. Units: J/kmol/K.
418  * For an ideal gas mixture,
419  * \f[
420  * \hat c_p(t) = \sum_k \hat c^0_{p,k}(T).
421  * \f]
422  * The reference-state pure-species heat capacities
423  * \f$ \hat c^0_{p,k}(T) \f$ are computed by the species thermodynamic
424  * property manager.
425  * @see SpeciesThermo
426  */
427  virtual doublereal cp_mole() const;
428 
429  /**
430  * Molar heat capacity at constant volume. Units: J/kmol/K.
431  * For an ideal gas mixture,
432  * \f[ \hat c_v = \hat c_p - \hat R. \f]
433  */
434  virtual doublereal cv_mole() const;
435 
436  //@}
437 
438  /**
439  * @name Mechanical Equation of State ------------------------------------------------
440  * @{
441  */
442 
443  /**
444  * Pressure. Units: Pa.
445  * For an ideal gas mixture,
446  * \f[ P = n \hat R T. \f]
447  */
448  virtual doublereal pressure() const {
449  return GasConstant * molarDensity() * temperature();
450  }
451 
452 
453  //! Set the pressure at constant temperature and composition.
454  /*!
455  * Units: Pa.
456  * This method is implemented by setting the mass density to
457  * \f[
458  * \rho = \frac{P \overline W}{\hat R T }.
459  * \f]
460  *
461  * @param p Pressure (Pa)
462  */
463  virtual void setPressure(doublereal p) {
465  /(GasConstant * temperature()));
466  }
467 
468  //! Returns the isothermal compressibility. Units: 1/Pa.
469  /**
470  * The isothermal compressibility is defined as
471  * \f[
472  * \kappa_T = -\frac{1}{v}\left(\frac{\partial v}{\partial P}\right)_T
473  * \f]
474  * For ideal gases it's equal to the inverse of the pressure
475  */
476  virtual doublereal isothermalCompressibility() const {
477  return 1.0/pressure();
478  }
479 
480  //! Return the volumetric thermal expansion coefficient. Units: 1/K.
481  /*!
482  * The thermal expansion coefficient is defined as
483  * \f[
484  * \beta = \frac{1}{v}\left(\frac{\partial v}{\partial T}\right)_P
485  * \f]
486  * For ideal gases, it's equal to the inverse of the temperature.
487  */
488  virtual doublereal thermalExpansionCoeff() const {
489  return 1.0/temperature();
490  }
491 
492  //@}
493 
494  /**
495  * @name Chemical Potentials and Activities ------------------------------------------
496  *
497  *
498  * The activity \f$a_k\f$ of a species in solution is
499  * related to the chemical potential by
500  * \f[
501  * \mu_k(T,P,X_k) = \mu_k^0(T,P)
502  * + \hat R T \log a_k.
503  * \f]
504  * The quantity \f$\mu_k^0(T,P)\f$ is
505  * the standard state chemical potential at unit activity.
506  * It may depend on the pressure and the temperature. However,
507  * it may not depend on the mole fractions of the species
508  * in the solution.
509  *
510  * The activities are related to the generalized
511  * concentrations, \f$\tilde C_k\f$, and standard
512  * concentrations, \f$C^0_k\f$, by the following formula:
513  *
514  * \f[
515  * a_k = \frac{\tilde C_k}{C^0_k}
516  * \f]
517  * The generalized concentrations are used in the kinetics classes
518  * to describe the rates of progress of reactions involving the
519  * species. Their formulation depends upon the specification
520  * of the rate constants for reaction, especially the units used
521  * in specifying the rate constants. The bridge between the
522  * thermodynamic equilibrium expressions that use a_k and the
523  * kinetics expressions which use the generalized concentrations
524  * is provided by the multiplicative factor of the
525  * standard concentrations.
526  * @{
527  */
528 
529  //! This method returns the array of generalized concentrations.
530  /*!
531  * For an ideal gas mixture, these are simply the actual concentrations.
532  *
533  * @param c Output array of generalized concentrations. The
534  * units depend upon the implementation of the
535  * reaction rate expressions within the phase.
536  */
537  virtual void getActivityConcentrations(doublereal* c) const {
539  }
540 
541  //! Returns the standard concentration \f$ C^0_k \f$, which is used to normalize
542  //! the generalized concentration.
543  /*!
544  * This is defined as the concentration by which the generalized
545  * concentration is normalized to produce the activity.
546  * In many cases, this quantity will be the same for all species in a phase.
547  * Since the activity for an ideal gas mixture is
548  * simply the mole fraction, for an ideal gas \f$ C^0_k = P/\hat R T \f$.
549  *
550  * @param k Optional parameter indicating the species. The default
551  * is to assume this refers to species 0.
552  * @return
553  * Returns the standard Concentration in units of m3 kmol-1.
554  */
555  virtual doublereal standardConcentration(size_t k=0) const;
556 
557  //! Returns the natural logarithm of the standard
558  //! concentration of the kth species
559  /*!
560  * @param k index of the species. (defaults to zero)
561  */
562  virtual doublereal logStandardConc(size_t k=0) const;
563 
564  //! Get the array of non-dimensional activity coefficients at
565  //! the current solution temperature, pressure, and solution concentration.
566  /*!
567  * For ideal gases, the activity coefficients are all equal to one.
568  *
569  * @param ac Output vector of activity coefficients. Length: m_kk.
570  */
571  virtual void getActivityCoefficients(doublereal* ac) const;
572 
573 
574  //@}
575  /// @name Partial Molar Properties of the Solution ----------------------------------
576  //@{
577 
578 
579  //! Get the species chemical potentials. Units: J/kmol.
580  /*!
581  * This function returns a vector of chemical potentials of the
582  * species in solution at the current temperature, pressure
583  * and mole fraction of the solution.
584  *
585  * @param mu Output vector of species chemical
586  * potentials. Length: m_kk. Units: J/kmol
587  */
588  virtual void getChemPotentials(doublereal* mu) const;
589 
590  //! Get the species partial molar enthalpies. Units: J/kmol.
591  /*!
592  * @param hbar Output vector of species partial molar enthalpies.
593  * Length: m_kk. units are J/kmol.
594  */
595  virtual void getPartialMolarEnthalpies(doublereal* hbar) const;
596 
597  //! Get the species partial molar entropies. Units: J/kmol/K.
598  /*!
599  * @param sbar Output vector of species partial molar entropies.
600  * Length = m_kk. units are J/kmol/K.
601  */
602  virtual void getPartialMolarEntropies(doublereal* sbar) const;
603 
604  //! Get the species partial molar enthalpies. Units: J/kmol.
605  /*!
606  * @param ubar Output vector of species partial molar internal energies.
607  * Length = m_kk. units are J/kmol.
608  */
609  virtual void getPartialMolarIntEnergies(doublereal* ubar) const;
610 
611  //! Get the partial molar heat capacities Units: J/kmol/K
612  /*!
613  * @param cpbar Output vector of species partial molar heat capacities at constant pressure.
614  * Length = m_kk. units are J/kmol/K.
615  */
616  virtual void getPartialMolarCp(doublereal* cpbar) const;
617 
618  //! Get the species partial molar volumes. Units: m^3/kmol.
619  /*!
620  * @param vbar Output vector of species partial molar volumes.
621  * Length = m_kk. units are m^3/kmol.
622  */
623  virtual void getPartialMolarVolumes(doublereal* vbar) const;
624 
625  //@}
626  /// @name Properties of the Standard State of the Species in the Solution ----------
627  //@{
628 
629  //! Get the array of chemical potentials at unit activity for the
630  //! species standard states at the current <I>T</I> and <I>P</I> of the solution.
631  /*!
632  * These are the standard state chemical potentials \f$ \mu^0_k(T,P)
633  * \f$. The values are evaluated at the current
634  * temperature and pressure of the solution
635  *
636  * @param mu Output vector of chemical potentials.
637  * Length: m_kk.
638  */
639  virtual void getStandardChemPotentials(doublereal* mu) const;
640 
641  //! Get the nondimensional Enthalpy functions for the species standard states
642  //! at their standard states at the current <I>T</I> and <I>P</I> of the solution.
643  /*!
644  * @param hrt Output vector of nondimensional standard state enthalpies.
645  * Length: m_kk.
646  */
647  virtual void getEnthalpy_RT(doublereal* hrt) const;
648 
649  //! Get the array of nondimensional Entropy functions for the
650  //! species standard states at the current <I>T</I> and <I>P</I> of the solution.
651  /*!
652  * @param sr Output vector of nondimensional standard state entropies.
653  * Length: m_kk.
654  */
655  virtual void getEntropy_R(doublereal* sr) const;
656 
657  //! Get the nondimensional Gibbs functions for the species
658  //! standard states at the current <I>T</I> and <I>P</I> of the solution.
659  /*!
660  * @param grt Output vector of nondimensional standard state gibbs free energies
661  * Length: m_kk.
662  */
663  virtual void getGibbs_RT(doublereal* grt) const;
664 
665  //! Get the Gibbs functions for the standard
666  //! state of the species at the current <I>T</I> and <I>P</I> of the solution
667  /*!
668  * Units are Joules/kmol
669  * @param gpure Output vector of standard state gibbs free energies
670  * Length: m_kk.
671  */
672  virtual void getPureGibbs(doublereal* gpure) const;
673 
674  //! Returns the vector of nondimensional Internal Energies of the standard
675  //! state species at the current <I>T</I> and <I>P</I> of the solution
676  /*!
677  * @param urt output vector of nondimensional standard state internal energies
678  * of the species. Length: m_kk.
679  */
680  virtual void getIntEnergy_RT(doublereal* urt) const;
681 
682  //! Get the nondimensional Heat Capacities at constant
683  //! pressure for the species standard states
684  //! at the current <I>T</I> and <I>P</I> of the solution
685  /*!
686  * @param cpr Output vector of nondimensional standard state heat capacities
687  * Length: m_kk.
688  */
689  virtual void getCp_R(doublereal* cpr) const;
690 
691  //! Get the molar volumes of the species standard states at the current
692  //! <I>T</I> and <I>P</I> of the solution.
693  /*!
694  * units = m^3 / kmol
695  *
696  * @param vol Output vector containing the standard state volumes.
697  * Length: m_kk.
698  */
699  virtual void getStandardVolumes(doublereal* vol) const;
700 
701  //@}
702  /// @name Thermodynamic Values for the Species Reference States ---------------------
703  //@{
704 
705 
706  //! Returns the vector of nondimensional
707  //! enthalpies of the reference state at the current temperature
708  //! of the solution and the reference pressure for the species.
709  /*!
710  * @param hrt Output vector containing the nondimensional reference state
711  * enthalpies. Length: m_kk.
712  */
713  virtual void getEnthalpy_RT_ref(doublereal* hrt) const;
714 
715 #ifdef H298MODIFY_CAPABILITY
716 
717  virtual void modifyOneHf298SS(const int k, const doublereal Hf298New) {
718  m_spthermo->modifyOneHf298(k, Hf298New);
719  m_tlast += 0.0001234;
720  }
721 #endif
722  //! Returns the vector of nondimensional
723  //! Gibbs Free Energies of the reference state at the current temperature
724  //! of the solution and the reference pressure for the species.
725  /*!
726  * @param grt Output vector containing the nondimensional reference state
727  * Gibbs Free energies. Length: m_kk.
728  */
729  virtual void getGibbs_RT_ref(doublereal* grt) const;
730 
731  //! Returns the vector of the
732  //! gibbs function of the reference state at the current temperature
733  //! of the solution and the reference pressure for the species.
734  /*!
735  * units = J/kmol
736  *
737  * @param g Output vector containing the reference state
738  * Gibbs Free energies. Length: m_kk. Units: J/kmol.
739  */
740  virtual void getGibbs_ref(doublereal* g) const;
741 
742  //! Returns the vector of nondimensional
743  //! entropies of the reference state at the current temperature
744  //! of the solution and the reference pressure for each species.
745  /*!
746  * @param er Output vector containing the nondimensional reference state
747  * entropies. Length: m_kk.
748  */
749  virtual void getEntropy_R_ref(doublereal* er) const;
750 
751  //! Returns the vector of nondimensional
752  //! internal Energies of the reference state at the current temperature
753  //! of the solution and the reference pressure for each species.
754  /*!
755  * @param urt Output vector of nondimensional reference state
756  * internal energies of the species.
757  * Length: m_kk
758  */
759  virtual void getIntEnergy_RT_ref(doublereal* urt) const;
760 
761  //! Returns the vector of nondimensional
762  //! constant pressure heat capacities of the reference state
763  //! at the current temperature of the solution
764  //! and reference pressure for each species.
765  /*!
766  * @param cprt Output vector of nondimensional reference state
767  * heat capacities at constant pressure for the species.
768  * Length: m_kk
769  */
770  virtual void getCp_R_ref(doublereal* cprt) const;
771 
772  //! Get the molar volumes of the species standard states at the current
773  //! <I>T</I> and <I>P_ref</I> of the solution.
774  /*!
775  * units = m^3 / kmol
776  *
777  * @param vol Output vector containing the standard state volumes.
778  * Length: m_kk.
779  */
780  virtual void getStandardVolumes_ref(doublereal* vol) const;
781 
782  //@}
783  /// @name NonVirtual Internal methods to Return References to Reference State Thermo
784  //@{
785 
786  //! Returns a reference to the dimensionless reference state enthalpy vector.
787  /*!
788  * This function is part of the layer that checks/recalculates the reference
789  * state thermo functions.
790  */
791  const vector_fp& enthalpy_RT_ref() const {
792  _updateThermo();
793  return m_h0_RT;
794  }
795 
796  //! Returns a reference to the dimensionless reference state Gibbs free energy vector.
797  /*!
798  * This function is part of the layer that checks/recalculates the reference
799  * state thermo functions.
800  */
801  const vector_fp& gibbs_RT_ref() const {
802  _updateThermo();
803  return m_g0_RT;
804  }
805 
806  //! Returns a reference to the exponent of the dimensionless reference state Gibbs Free energy vector.
807  /*!
808  * This function is part of the layer that checks/recalculates the reference
809  * state thermo functions.
810  */
811  const vector_fp& expGibbs_RT_ref() const {
812  _updateThermo();
813  for (size_t k = 0; k != m_kk; k++) {
814  m_expg0_RT[k] = std::exp(m_g0_RT[k]);
815  }
816  return m_expg0_RT;
817  }
818 
819  //! Returns a reference to the dimensionless reference state Entropy vector.
820  /*!
821  * This function is part of the layer that checks/recalculates the reference
822  * state thermo functions.
823  */
824  const vector_fp& entropy_R_ref() const {
825  _updateThermo();
826  return m_s0_R;
827  }
828 
829  //! Returns a reference to the dimensionless reference state Heat Capacity vector.
830  /*!
831  * This function is part of the layer that checks/recalculates the reference
832  * state thermo functions.
833  */
834  const vector_fp& cp_R_ref() const {
835  _updateThermo();
836  return m_cp0_R;
837  }
838 
839  //@}
840 
841  //! Initialize the ThermoPhase object after all species have been set up
842  /*!
843  * @internal Initialize.
844  *
845  * This method performs any initialization required after all
846  * species have been added. For example, it is used to
847  * resize internal work arrays that must have an entry for
848  * each species.
849  * This method is called from ThermoPhase::initThermoXML(),
850  * which is called from importPhase(),
851  * just prior to returning from the function, importPhase().
852  *
853  * @see importCTML.cpp
854  */
855  virtual void initThermo();
856 
857  //!This method is used by the ChemEquil equilibrium solver.
858  /*!
859  * @internal
860  * @name Chemical Equilibrium
861  * @{
862  *
863  * Set mixture to an equilibrium state consistent with specified
864  * element potentials and temperature.
865  * It sets the state such that the chemical potentials satisfy
866  * \f[ \frac{\mu_k}{\hat R T} = \sum_m A_{k,m}
867  * \left(\frac{\lambda_m} {\hat R T}\right) \f] where
868  * \f$ \lambda_m \f$ is the element potential of element m. The
869  * temperature is unchanged. Any phase (ideal or not) that
870  * implements this method can be equilibrated by ChemEquil.
871  *
872  * @param lambda_RT vector of non-dimensional element potentials
873  * \f[ \lambda_m/RT \f].
874  */
875  virtual void setToEquilState(const doublereal* lambda_RT);
876 
877  //@}
878 
879 protected:
880 
881  //! Number of Elements in the phase
882  /*!
883  * This member is defined here, from a call to the Elements ojbect, for speed.
884  */
885  size_t m_mm;
886 
887  //! Minimum temperature for valid species standard state thermo props
888  /*!
889  * This is the minimum temperature at which all species have valid standard
890  * state thermo props defined.
891  */
892  doublereal m_tmin;
893 
894  //! Maximum temperature for valid species standard state thermo props
895  /*!
896  * This is the maximum temperature at which all species have valid standard
897  * state thermo props defined.
898  */
899  doublereal m_tmax;
900 
901  //! Reference state pressure
902  /*!
903  * Value of the reference state pressure in Pascals.
904  * All species must have the same reference state pressure.
905  */
906  doublereal m_p0;
907 
908  //! last value of the temperature processed by reference state
909  mutable doublereal m_tlast;
910 
911  //! Temporary storage for log of p/rt
912  mutable doublereal m_logc0;
913 
914  //! Temporary storage for dimensionless reference state enthalpies
916 
917  //! Temporary storage for dimensionless reference state heat capacities
919 
920  //! Temporary storage for dimensionless reference state gibbs energies
922 
923  //! Temporary storage for dimensionless reference state entropies
924  mutable vector_fp m_s0_R;
925 
926  //! currently unsed
927  /*!
928  * @deprecated
929  */
931 
932  //! Currently unused
933  /*
934  * @deprecated
935  */
936  mutable vector_fp m_pe;
937 
938  //! Temporary array containing internally calculated partial pressures
939  mutable vector_fp m_pp;
940 
941 private:
942 
943  //! Update the species reference state thermodynamic functions
944  /*!
945  * The polynomials for the standard state functions are only
946  * reevaluated if the temperature has changed.
947  *
948  */
949  void _updateThermo() const;
950 
951 };
952 }
953 
954 #endif