Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ThermoPhase.h
Go to the documentation of this file.
1 /**
2  * @file ThermoPhase.h
3  * Header file for class ThermoPhase, the base class for phases with
4  * thermodynamic properties, and the text for the Module thermoprops
5  * (see \ref thermoprops and class \link Cantera::ThermoPhase ThermoPhase\endlink).
6  */
7 
8 // Copyright 2002 California Institute of Technology
9 
10 #ifndef CT_THERMOPHASE_H
11 #define CT_THERMOPHASE_H
12 
13 #include "Phase.h"
14 #include "SpeciesThermo.h"
15 
16 namespace Cantera
17 {
18 
19 /*!
20  * @name CONSTANTS - Specification of the Molality convention
21  */
22 //@{
23 //! Standard state uses the molar convention
24 const int cAC_CONVENTION_MOLAR = 0;
25 //! Standard state uses the molality convention
27 //@}
28 
29 /*!
30  * @name CONSTANTS - Specification of the SS convention
31  */
32 //@{
33 //! Standard state uses the molar convention
35 //! Standard state uses the molality convention
36 const int cSS_CONVENTION_VPSS = 1;
37 //! Standard state thermodynamics is obtained from slave ThermoPhase objects
38 const int cSS_CONVENTION_SLAVE = 2;
39 //@}
40 
41 //! Base class for a phase with thermodynamic properties.
42 /*!
43  * Class ThermoPhase is the base class for the family of classes
44  * that represent phases of matter of any type. It defines a
45  * common public interface, and implements a few methods. Most of
46  * the methods, however, are declared virtual and are meant to be
47  * overloaded in derived classes. The standard way used
48  * throughout Cantera to compute properties of phases of matter is
49  * through pointers of type ThermoPhase* that point to objects of
50  * subclasses of ThermoPhase.
51  *
52  * Class ThermoPhase extends class Phase by adding methods to compute
53  * thermodynamic properties in addition to the ones (temperature, density,
54  * composition) that class Phase provides. The distinction is that
55  * the methods declared in ThermoPhase require knowing the
56  * particular equation of state of the phase of interest, while
57  * those of class Phase do not, since they only involve data values
58  * stored within the object.
59  *
60  * Instances of subclasses of ThermoPhase should be created using
61  * the factory class ThermoFactory, not by calling the constructor
62  * directly. This allows new classes to be used with the various
63  * Cantera language interfaces.
64  *
65  * To implement a new equation of state, derive a class from
66  * ThermoPhase and overload the virtual methods in
67  * ThermoPhase. Methods that are not needed can be left
68  * unimplemented, which will cause an exception to be thrown if it
69  * is called.
70  *
71  * Relationship with the kinetics operator:
72  *
73  * Describe activity coefficients.
74  *
75  * Describe K_a, K_p, and K_c, These are three different equilibrium
76  * constants.
77  *
78  * K_a is the calculation of the equilibrium constant from the
79  * standard state Gibbs free energy values. It is by definition
80  * dimensionless.
81  *
82  * K_p is the calculation of the equilibrium constant from the
83  * reference state Gibbs free energy values. It is by definition
84  * dimensionless. The pressure dependence is handled entirely
85  * on the RHS of the equilibrium expression.
86  *
87  * K_c is the equilibrium constant calculated from the
88  * activity concentrations. The dimensions depend on the number
89  * of products and reactants.
90  *
91  * The kinetics manager requires the calculation of K_c for the
92  * calculation of the reverse rate constant
93  *
94  * @ingroup thermoprops
95  * @ingroup phases
96  */
97 class ThermoPhase : public Phase
98 {
99 public:
100  //! Constructor. Note that ThermoPhase is meant to be used as
101  //! a base class, so this constructor should not be called
102  //! explicitly.
103  ThermoPhase();
104 
105  //! Destructor. Deletes the species thermo manager.
106  virtual ~ThermoPhase();
107 
108  //!Copy Constructor for the ThermoPhase object.
109  /*!
110  * @param right ThermoPhase to be copied
111  */
112  ThermoPhase(const ThermoPhase& right);
113 
114  //! Assignment operator
115  /*!
116  * @param right Reference to ThermoPhase object to be copied into the
117  * current one.
118  */
119  ThermoPhase& operator=(const ThermoPhase& right);
120 
121  //! Duplication routine for objects which inherit from ThermoPhase.
122  /*!
123  * This virtual routine can be used to duplicate ThermoPhase objects
124  * inherited from ThermoPhase even if the application only has
125  * a pointer to ThermoPhase to work with.
126  *
127  * These routines are basically wrappers around the derived copy
128  * constructor.
129  */
130  virtual ThermoPhase* duplMyselfAsThermoPhase() const;
131 
132  //! @name Information Methods
133  //! @{
134 
135  //! Equation of state type flag.
136  /*!
137  * The base class returns
138  * zero. Subclasses should define this to return a unique
139  * non-zero value. Constants defined for this purpose are
140  * listed in mix_defs.h.
141  */
142  virtual int eosType() const {
143  return 0;
144  }
145 
146  /**
147  * Returns the reference pressure in Pa. This function is a wrapper
148  * that calls the species thermo refPressure function.
149  */
150  virtual doublereal refPressure() const {
151  return m_spthermo->refPressure();
152  }
153 
154  //! Minimum temperature for which the thermodynamic data for the species
155  //! or phase are valid.
156  /*!
157  * If no argument is supplied, the
158  * value returned will be the lowest temperature at which the
159  * data for \e all species are valid. Otherwise, the value
160  * will be only for species \a k. This function is a wrapper
161  * that calls the species thermo minTemp function.
162  *
163  * @param k index of the species. Default is -1, which will return the max of the min value
164  * over all species.
165  */
166  virtual doublereal minTemp(size_t k = npos) const {
167  return m_spthermo->minTemp(k);
168  }
169 
170  //! Report the 298 K Heat of Formation of the standard state of one species (J kmol-1)
171  /*!
172  * The 298K Heat of Formation is defined as the enthalpy change to create the standard state
173  * of the species from its constituent elements in their standard states at 298 K and 1 bar.
174  *
175  * @param k species index
176  * @return Returns the current value of the Heat of Formation at 298K and 1 bar
177  */
178  doublereal Hf298SS(const int k) const {
179  return m_spthermo->reportOneHf298(k);
180  }
181 
182  //! Modify the value of the 298 K Heat of Formation of one species in the phase (J kmol-1)
183  /*!
184  * The 298K heat of formation is defined as the enthalpy change to create the standard state
185  * of the species from its constituent elements in their standard states at 298 K and 1 bar.
186  *
187  * @param k Species k
188  * @param Hf298New Specify the new value of the Heat of Formation at 298K and 1 bar
189  */
190  virtual void modifyOneHf298SS(const size_t k, const doublereal Hf298New) {
191  m_spthermo->modifyOneHf298(k, Hf298New);
192  m_tlast += 0.0001234;
193  }
194 
195  //! Maximum temperature for which the thermodynamic data for the species
196  //! are valid.
197  /*!
198  * If no argument is supplied, the
199  * value returned will be the highest temperature at which the
200  * data for \e all species are valid. Otherwise, the value
201  * will be only for species \a k. This function is a wrapper
202  * that calls the species thermo maxTemp function.
203  *
204  * @param k index of the species. Default is -1, which will return the min of the max value
205  * over all species.
206  */
207  virtual doublereal maxTemp(size_t k = npos) const {
208  return m_spthermo->maxTemp(k);
209  }
210 
211  //! Returns the chargeNeutralityNecessity boolean
212  /*!
213  * Some phases must have zero net charge in order for their thermodynamics functions to be valid.
214  * If this is so, then the value returned from this function is true.
215  * If this is not the case, then this is false. Now, ideal gases have this parameter set to false,
216  * while solution with molality-based activity coefficients have this parameter set to true.
217  */
220  }
221 
222  //! @}
223  //! @name Molar Thermodynamic Properties of the Solution
224  //! @{
225 
226  /// Molar enthalpy. Units: J/kmol.
227  virtual doublereal enthalpy_mole() const {
228  throw NotImplementedError("ThermoPhase::enthalpy_mole");
229  }
230 
231  /// Molar internal energy. Units: J/kmol.
232  virtual doublereal intEnergy_mole() const {
233  return enthalpy_mole() - pressure()* molarVolume();
234  }
235 
236  /// Molar entropy. Units: J/kmol/K.
237  virtual doublereal entropy_mole() const {
238  throw NotImplementedError("ThermoPhase::entropy_mole");
239  }
240 
241  /// Molar Gibbs function. Units: J/kmol.
242  virtual doublereal gibbs_mole() const {
243  return enthalpy_mole() - temperature()*entropy_mole();
244  }
245 
246  /// Molar heat capacity at constant pressure. Units: J/kmol/K.
247  virtual doublereal cp_mole() const {
248  throw NotImplementedError("ThermoPhase::cp_mole");
249  }
250 
251  /// Molar heat capacity at constant volume. Units: J/kmol/K.
252  virtual doublereal cv_mole() const {
253  throw NotImplementedError("ThermoPhase::cv_mole");
254  }
255 
256  /**
257  * @returns species vibrational specific heat at
258  * constant volume.
259  * @deprecated To be removed after Cantera 2.2.
260  */
261  /// Molar heat capacity at constant volume. Units: J/kmol/K.
262  virtual doublereal cv_vib(int, double) const {
263  throw NotImplementedError("ThermoPhase::cv_vib");
264  }
265 
266  //! @}
267  //! @name Mechanical Properties
268  //! @{
269 
270  //! Return the thermodynamic pressure (Pa).
271  /*!
272  * This method must be overloaded in derived classes. Since the
273  * mass density, temperature, and mass fractions are stored,
274  * this method should use these values to implement the
275  * mechanical equation of state \f$ P(T, \rho, Y_1, \dots,
276  * Y_K) \f$.
277  */
278  virtual doublereal pressure() const {
279  throw NotImplementedError("ThermoPhase::pressure");
280  }
281 
282  //! Set the internally stored pressure (Pa) at constant
283  //! temperature and composition
284  /*!
285  * This method must be reimplemented in derived classes, where it
286  * may involve the solution of a nonlinear equation. Within %Cantera,
287  * the independent variable is the density. Therefore, this function
288  * solves for the density that will yield the desired input pressure.
289  * The temperature and composition are held constant during this process.
290  *
291  * This base class function will print an error, if not overwritten.
292  *
293  * @param p input Pressure (Pa)
294  */
295  virtual void setPressure(doublereal p) {
296  throw NotImplementedError("ThermoPhase::setPressure");
297  }
298 
299  //! Returns the isothermal compressibility. Units: 1/Pa.
300  /*!
301  * The isothermal compressibility is defined as
302  * \f[
303  * \kappa_T = -\frac{1}{v}\left(\frac{\partial v}{\partial P}\right)_T
304  * \f]
305  * or
306  * \f[
307  * \kappa_T = \frac{1}{\rho}\left(\frac{\partial \rho}{\partial P}\right)_T
308  * \f]
309  */
310  virtual doublereal isothermalCompressibility() const {
311  throw NotImplementedError("ThermoPhase::isothermalCompressibility");
312  }
313 
314  //! Return the volumetric thermal expansion coefficient. Units: 1/K.
315  /*!
316  * The thermal expansion coefficient is defined as
317  * \f[
318  * \beta = \frac{1}{v}\left(\frac{\partial v}{\partial T}\right)_P
319  * \f]
320  */
321  virtual doublereal thermalExpansionCoeff() const {
322  throw NotImplementedError("ThermoPhase::thermalExpansionCoeff()");
323  }
324 
325  /**
326  * @}
327  * @name Electric Potential
328  *
329  * The phase may be at some non-zero electrical potential. These methods
330  * set or get the value of the electric potential.
331  */
332  //@{
333 
334  //! Set the electric potential of this phase (V).
335  /*!
336  * This is used by classes InterfaceKinetics and EdgeKinetics to
337  * compute the rates of charge-transfer reactions, and in computing
338  * the electrochemical potentials of the species.
339  *
340  * Each phase may have its own electric potential.
341  *
342  * @param v Input value of the electric potential in Volts
343  */
344  void setElectricPotential(doublereal v) {
345  m_phi = v;
346  }
347 
348  //! Returns the electric potential of this phase (V).
349  /*!
350  * Units are Volts (which are Joules/coulomb)
351  */
352  doublereal electricPotential() const {
353  return m_phi;
354  }
355 
356  /**
357  * @}
358  * @name Activities, Standard States, and Activity Concentrations
359  *
360  * The activity \f$a_k\f$ of a species in solution is related
361  * to the chemical potential by \f[ \mu_k = \mu_k^0(T,P) +
362  * \hat R T \log a_k. \f] The quantity \f$\mu_k^0(T,P)\f$ is
363  * the standard chemical potential at unit activity,
364  * which depends on temperature and pressure,
365  * but not on composition. The activity is dimensionless.
366  * @{
367  */
368 
369 
370  //! This method returns the convention used in specification
371  //! of the activities, of which there are currently two, molar-
372  //! and molality-based conventions.
373  /*!
374  * Currently, there are two activity conventions:
375  * - Molar-based activities
376  * %Unit activity of species at either a hypothetical pure
377  * solution of the species or at a hypothetical
378  * pure ideal solution at infinite dilution
379  * cAC_CONVENTION_MOLAR 0
380  * - default
381  *
382  * - Molality-based activities
383  * (unit activity of solutes at a hypothetical 1 molal
384  * solution referenced to infinite dilution at all
385  * pressures and temperatures).
386  * cAC_CONVENTION_MOLALITY 1
387  */
388  virtual int activityConvention() const;
389 
390  //! This method returns the convention used in specification
391  //! of the standard state, of which there are currently two,
392  //! temperature based, and variable pressure based.
393  /*!
394  * Currently, there are two standard state conventions:
395  * - Temperature-based activities
396  * cSS_CONVENTION_TEMPERATURE 0
397  * - default
398  *
399  * - Variable Pressure and Temperature -based activities
400  * cSS_CONVENTION_VPSS 1
401  *
402  * - Thermodynamics is set via slave ThermoPhase objects with
403  * nothing being carried out at this ThermoPhase object level
404  * cSS_CONVENTION_SLAVE 2
405  */
406  virtual int standardStateConvention() const;
407 
408  //! This method returns an array of generalized concentrations
409  /*!
410  * \f$ C^a_k\f$ are defined such that \f$ a_k = C^a_k /
411  * C^0_k, \f$ where \f$ C^0_k \f$ is a standard concentration
412  * defined below and \f$ a_k \f$ are activities used in the
413  * thermodynamic functions. These activity (or generalized)
414  * concentrations are used
415  * by kinetics manager classes to compute the forward and
416  * reverse rates of elementary reactions. Note that they may
417  * or may not have units of concentration --- they might be
418  * partial pressures, mole fractions, or surface coverages,
419  * for example.
420  *
421  * @param c Output array of generalized concentrations. The
422  * units depend upon the implementation of the
423  * reaction rate expressions within the phase.
424  */
425  virtual void getActivityConcentrations(doublereal* c) const {
426  throw NotImplementedError("ThermoPhase::getActivityConcentrations");
427  }
428 
429  //! Return the standard concentration for the kth species
430  /*!
431  * The standard concentration \f$ C^0_k \f$ used to normalize
432  * the activity (i.e., generalized) concentration. In many cases, this quantity
433  * will be the same for all species in a phase - for example,
434  * for an ideal gas \f$ C^0_k = P/\hat R T \f$. For this
435  * reason, this method returns a single value, instead of an
436  * array. However, for phases in which the standard
437  * concentration is species-specific (e.g. surface species of
438  * different sizes), this method may be called with an
439  * optional parameter indicating the species.
440  *
441  * @param k Optional parameter indicating the species. The default
442  * is to assume this refers to species 0.
443  * @return
444  * Returns the standard concentration. The units are by definition
445  * dependent on the ThermoPhase and kinetics manager representation.
446  */
447  virtual doublereal standardConcentration(size_t k=0) const {
448  throw NotImplementedError("ThermoPhase::standardConcentration");
449  }
450 
451  //! Natural logarithm of the standard concentration of the kth species.
452  /*!
453  * @param k index of the species (defaults to zero)
454  */
455  virtual doublereal logStandardConc(size_t k=0) const;
456 
457  //! Returns the units of the standard and generalized concentrations.
458  /*!
459  * Note they have the same units, as their
460  * ratio is defined to be equal to the activity of the kth
461  * species in the solution, which is unitless.
462  *
463  * This routine is used in print out applications where the
464  * units are needed. Usually, MKS units are assumed throughout
465  * the program and in the XML input files.
466  *
467  * The base ThermoPhase class assigns the default quantities
468  * of (kmol/m3) for all species.
469  * Inherited classes are responsible for overriding the default
470  * values if necessary.
471  *
472  * On return uA contains the powers of the units (MKS assumed)
473  * of the standard concentrations and generalized concentrations
474  * for the kth species.
475  *
476  * @param uA Output vector containing the units
477  * uA[0] = kmol units - default = 1
478  * uA[1] = m units - default = -nDim(), the number of spatial
479  * dimensions in the Phase class.
480  * uA[2] = kg units - default = 0;
481  * uA[3] = Pa(pressure) units - default = 0;
482  * uA[4] = Temperature units - default = 0;
483  * uA[5] = time units - default = 0
484  * @param k species index. Defaults to 0.
485  * @param sizeUA output int containing the size of the vector.
486  * Currently, this is equal to 6.
487  * @deprecated To be removed after Cantera 2.2.
488  */
489  virtual void getUnitsStandardConc(double* uA, int k = 0,
490  int sizeUA = 6) const;
491 
492  //! Get the array of non-dimensional activities at
493  //! the current solution temperature, pressure, and solution concentration.
494  /*!
495  * Note, for molality based formulations, this returns the
496  * molality based activities.
497  *
498  * We resolve this function at this level by calling
499  * on the activityConcentration function. However,
500  * derived classes may want to override this default
501  * implementation.
502  *
503  * @param a Output vector of activities. Length: m_kk.
504  */
505  virtual void getActivities(doublereal* a) const;
506 
507  //! Get the array of non-dimensional molar-based activity coefficients at
508  //! the current solution temperature, pressure, and solution concentration.
509  /*!
510  * @param ac Output vector of activity coefficients. Length: m_kk.
511  */
512  virtual void getActivityCoefficients(doublereal* ac) const {
513  if (m_kk == 1) {
514  ac[0] = 1.0;
515  } else {
516  throw NotImplementedError("ThermoPhase::getActivityCoefficients");
517  }
518  }
519 
520  //! Get the array of non-dimensional molar-based ln activity coefficients at
521  //! the current solution temperature, pressure, and solution concentration.
522  /*!
523  * @param lnac Output vector of ln activity coefficients. Length: m_kk.
524  */
525  virtual void getLnActivityCoefficients(doublereal* lnac) const;
526 
527  //@}
528  /// @name Partial Molar Properties of the Solution
529  //@{
530 
531  /**
532  * Get the array of non-dimensional species chemical potentials
533  * These are partial molar Gibbs free energies.
534  * \f$ \mu_k / \hat R T \f$.
535  * Units: unitless
536  *
537  * @param mu Output vector of dimensionless chemical potentials.
538  * Length: m_kk.
539  */
540  virtual void getChemPotentials_RT(doublereal* mu) const {
541  throw NotImplementedError("ThermoPhase::getChemPotentials_RT");
542  }
543 
544 
545  //! Get the species chemical potentials. Units: J/kmol.
546  /*!
547  * This function returns a vector of chemical potentials of the
548  * species in solution at the current temperature, pressure
549  * and mole fraction of the solution.
550  *
551  * @param mu Output vector of species chemical
552  * potentials. Length: m_kk. Units: J/kmol
553  */
554  virtual void getChemPotentials(doublereal* mu) const {
555  throw NotImplementedError("ThermoPhase::getChemPotentials");
556  }
557 
558  //! Get the species electrochemical potentials.
559  /*!
560  * These are partial molar quantities. This method adds a term \f$ F z_k
561  * \phi_p \f$ to each chemical potential.
562  * The electrochemical potential of species k in a phase p, \f$ \zeta_k \f$,
563  * is related to the chemical potential via
564  * the following equation,
565  *
566  * \f[
567  * \zeta_{k}(T,P) = \mu_{k}(T,P) + F z_k \phi_p
568  * \f]
569  *
570  * @param mu Output vector of species electrochemical
571  * potentials. Length: m_kk. Units: J/kmol
572  */
573  void getElectrochemPotentials(doublereal* mu) const {
574  getChemPotentials(mu);
575  double ve = Faraday * electricPotential();
576  for (size_t k = 0; k < m_kk; k++) {
577  mu[k] += ve*charge(k);
578  }
579  }
580 
581  //! Returns an array of partial molar enthalpies for the species
582  //! in the mixture. Units (J/kmol)
583  /*!
584  * @param hbar Output vector of species partial molar enthalpies.
585  * Length: m_kk. units are J/kmol.
586  */
587  virtual void getPartialMolarEnthalpies(doublereal* hbar) const {
588  throw NotImplementedError("ThermoPhase::getPartialMolarEnthalpies");
589  }
590 
591  //! Returns an array of partial molar entropies of the species in the
592  //! solution. Units: J/kmol/K.
593  /*!
594  * @param sbar Output vector of species partial molar entropies.
595  * Length = m_kk. units are J/kmol/K.
596  */
597  virtual void getPartialMolarEntropies(doublereal* sbar) const {
598  throw NotImplementedError("ThermoPhase::getPartialMolarEntropies");
599  }
600 
601  //! Return an array of partial molar internal energies for the
602  //! species in the mixture. Units: J/kmol.
603  /*!
604  * @param ubar Output vector of species partial molar internal energies.
605  * Length = m_kk. units are J/kmol.
606  */
607  virtual void getPartialMolarIntEnergies(doublereal* ubar) const {
608  throw NotImplementedError("ThermoPhase::getPartialMolarIntEnergies");
609  }
610 
611  //! Return an array of partial molar heat capacities for the
612  //! species in the mixture. Units: J/kmol/K
613  /*!
614  * @param cpbar Output vector of species partial molar heat
615  * capacities at constant pressure.
616  * Length = m_kk. units are J/kmol/K.
617  */
618  virtual void getPartialMolarCp(doublereal* cpbar) const {
619  throw NotImplementedError("ThermoPhase::getPartialMolarCp");
620  }
621 
622  //! Return an array of partial molar volumes for the
623  //! species in the mixture. Units: m^3/kmol.
624  /*!
625  * @param vbar Output vector of species partial molar volumes.
626  * Length = m_kk. units are m^3/kmol.
627  */
628  virtual void getPartialMolarVolumes(doublereal* vbar) const {
629  throw NotImplementedError("ThermoPhase::getPartialMolarVolumes");
630  }
631 
632  //! Return an array of derivatives of partial molar volumes wrt temperature for the
633  //! species in the mixture. Units: m^3/kmol.
634  /*!
635  * The derivative is at constant pressure
636  *
637  * @param d_vbar_dT Output vector of derivatives of species partial molar volumes wrt T.
638  * Length = m_kk. units are m^3/kmol/K.
639  */
640  virtual void getdPartialMolarVolumes_dT(doublereal* d_vbar_dT) const {
641  throw NotImplementedError("ThermoPhase::getdPartialMolarVolumes_dT");
642  }
643 
644  //! Return an array of derivatives of partial molar volumes wrt pressure for the
645  //! species in the mixture. Units: m^3/kmol.
646  /*!
647  * The derivative is at constant temperature
648  *
649  * @param d_vbar_dP Output vector of derivatives of species partial molar volumes wrt P.
650  * Length = m_kk. units are m^3/kmol/Pa.
651  */
652  virtual void getdPartialMolarVolumes_dP(doublereal* d_vbar_dP) const {
653  throw NotImplementedError("ThermoPhase::getdPartialMolarVolumes_dP");
654  }
655 
656  //@}
657  /// @name Properties of the Standard State of the Species in the Solution
658  //@{
659 
660  //! Get the array of chemical potentials at unit activity for the species
661  //! at their standard states at the current <I>T</I> and <I>P</I> of the solution.
662  /*!
663  * These are the standard state chemical potentials \f$ \mu^0_k(T,P)
664  * \f$. The values are evaluated at the current
665  * temperature and pressure of the solution
666  *
667  * @param mu Output vector of chemical potentials.
668  * Length: m_kk.
669  */
670  virtual void getStandardChemPotentials(doublereal* mu) const {
671  throw NotImplementedError("ThermoPhase::getStandardChemPotentials");
672  }
673 
674  //! Get the nondimensional Enthalpy functions for the species
675  //! at their standard states at the current <I>T</I> and <I>P</I> of the solution.
676  /*!
677  * @param hrt Output vector of nondimensional standard state enthalpies.
678  * Length: m_kk.
679  */
680  virtual void getEnthalpy_RT(doublereal* hrt) const {
681  throw NotImplementedError("ThermoPhase::getEnthalpy_RT");
682  }
683 
684  //! Get the array of nondimensional Entropy functions for the
685  //! standard state species at the current <I>T</I> and <I>P</I> of the solution.
686  /*!
687  * @param sr Output vector of nondimensional standard state entropies.
688  * Length: m_kk.
689  */
690  virtual void getEntropy_R(doublereal* sr) const {
691  throw NotImplementedError("ThermoPhase::getEntropy_R");
692  }
693 
694  //! Get the nondimensional Gibbs functions for the species
695  //! in their standard states at the current <I>T</I> and <I>P</I> of the solution.
696  /*!
697  * @param grt Output vector of nondimensional standard state Gibbs free energies
698  * Length: m_kk.
699  */
700  virtual void getGibbs_RT(doublereal* grt) const {
701  throw NotImplementedError("ThermoPhase::getGibbs_RT");
702  }
703 
704  //! Get the Gibbs functions for the standard
705  //! state of the species at the current <I>T</I> and <I>P</I> of the solution
706  /*!
707  * Units are Joules/kmol
708  * @param gpure Output vector of standard state Gibbs free energies
709  * Length: m_kk.
710  */
711  virtual void getPureGibbs(doublereal* gpure) const {
712  throw NotImplementedError("ThermoPhase::getPureGibbs");
713  }
714 
715  //! Returns the vector of nondimensional Internal Energies of the standard
716  //! state species at the current <I>T</I> and <I>P</I> of the solution
717  /*!
718  * @param urt output vector of nondimensional standard state internal energies
719  * of the species. Length: m_kk.
720  */
721  virtual void getIntEnergy_RT(doublereal* urt) const {
722  throw NotImplementedError("ThermoPhase::getIntEnergy_RT");
723  }
724 
725  //! Get the nondimensional Heat Capacities at constant
726  //! pressure for the species standard states
727  //! at the current <I>T</I> and <I>P</I> of the solution
728  /*!
729  * @param cpr Output vector of nondimensional standard state heat capacities
730  * Length: m_kk.
731  */
732  virtual void getCp_R(doublereal* cpr) const {
733  throw NotImplementedError("ThermoPhase::getCp_R");
734  }
735 
736  //! Get the molar volumes of the species standard states at the current
737  //! <I>T</I> and <I>P</I> of the solution.
738  /*!
739  * units = m^3 / kmol
740  *
741  * @param vol Output vector containing the standard state volumes.
742  * Length: m_kk.
743  */
744  virtual void getStandardVolumes(doublereal* vol) const {
745  throw NotImplementedError("ThermoPhase::getStandardVolumes");
746  }
747 
748  //! Get the derivative of the molar volumes of the species standard states wrt temperature at the current
749  //! <I>T</I> and <I>P</I> of the solution.
750  /*!
751  * The derivative is at constant pressure
752  * units = m^3 / kmol / K
753  *
754  * @param d_vol_dT Output vector containing derivatives of standard state volumes wrt T
755  * Length: m_kk.
756  */
757  virtual void getdStandardVolumes_dT(doublereal* d_vol_dT) const {
758  throw NotImplementedError("ThermoPhase::getdStandardVolumes_dT");
759  }
760 
761  //! Get the derivative molar volumes of the species standard states wrt pressure at the current
762  //! <I>T</I> and <I>P</I> of the solution.
763  /*!
764  * The derivative is at constant temperature.
765  * units = m^3 / kmol / Pa
766  *
767  * @param d_vol_dP Output vector containing the derivative of standard state volumes wrt P.
768  * Length: m_kk.
769  */
770  virtual void getdStandardVolumes_dP(doublereal* d_vol_dP) const {
771  throw NotImplementedError("ThermoPhase::getdStandardVolumes_dP");
772  }
773 
774  //@}
775  /// @name Thermodynamic Values for the Species Reference States
776  //@{
777 
778  //! Returns the vector of nondimensional
779  //! enthalpies of the reference state at the current temperature
780  //! of the solution and the reference pressure for the species.
781  /*!
782  * This base function will throw a CanteraException unless
783  * it is overwritten in a derived class.
784  *
785  * @param hrt Output vector containing the nondimensional reference state
786  * enthalpies
787  * Length: m_kk.
788  */
789  virtual void getEnthalpy_RT_ref(doublereal* hrt) const {
790  throw NotImplementedError("ThermoPhase::getEnthalpy_RT_ref");
791  }
792 
793  //! Returns the vector of nondimensional
794  //! Gibbs Free Energies of the reference state at the current temperature
795  //! of the solution and the reference pressure for the species.
796  /*!
797  * @param grt Output vector containing the nondimensional reference state
798  * Gibbs Free energies. Length: m_kk.
799  */
800  virtual void getGibbs_RT_ref(doublereal* grt) const {
801  throw NotImplementedError("ThermoPhase::getGibbs_RT_ref");
802  }
803 
804  //! Returns the vector of the
805  //! Gibbs function of the reference state at the current temperature
806  //! of the solution and the reference pressure for the species.
807  /*!
808  * units = J/kmol
809  *
810  * @param g Output vector containing the reference state
811  * Gibbs Free energies. Length: m_kk. Units: J/kmol.
812  */
813  virtual void getGibbs_ref(doublereal* g) const {
814  throw NotImplementedError("ThermoPhase::getGibbs_ref");
815  }
816 
817  //! Returns the vector of nondimensional
818  //! entropies of the reference state at the current temperature
819  //! of the solution and the reference pressure for each species.
820  /*!
821  * @param er Output vector containing the nondimensional reference state
822  * entropies. Length: m_kk.
823  */
824  virtual void getEntropy_R_ref(doublereal* er) const {
825  throw NotImplementedError("ThermoPhase::getEntropy_R_ref");
826  }
827 
828  //! Returns the vector of nondimensional
829  //! internal Energies of the reference state at the current temperature
830  //! of the solution and the reference pressure for each species.
831  /*!
832  * @param urt Output vector of nondimensional reference state
833  * internal energies of the species.
834  * Length: m_kk
835  */
836  virtual void getIntEnergy_RT_ref(doublereal* urt) const {
837  throw NotImplementedError("ThermoPhase::getIntEnergy_RT_ref");
838  }
839 
840  //! Returns the vector of nondimensional
841  //! constant pressure heat capacities of the reference state
842  //! at the current temperature of the solution
843  //! and reference pressure for each species.
844  /*!
845  * @param cprt Output vector of nondimensional reference state
846  * heat capacities at constant pressure for the species.
847  * Length: m_kk
848  */
849  virtual void getCp_R_ref(doublereal* cprt) const {
850  throw NotImplementedError("ThermoPhase::getCp_R_ref()");
851  }
852 
853  //! Get the molar volumes of the species reference states at the current
854  //! <I>T</I> and <I>P_ref</I> of the solution.
855  /*!
856  * units = m^3 / kmol
857  *
858  * @param vol Output vector containing the standard state volumes.
859  * Length: m_kk.
860  */
861  virtual void getStandardVolumes_ref(doublereal* vol) const {
862  throw NotImplementedError("ThermoPhase::getStandardVolumes_ref");
863  }
864 
865  //! Sets the reference composition
866  /*!
867  * @param x Mole fraction vector to set the reference composition to.
868  * If this is zero, then the reference mole fraction
869  * is set to the current mole fraction vector.
870  */
871  virtual void setReferenceComposition(const doublereal* const x);
872 
873  //! Gets the reference composition
874  /*!
875  * The reference mole fraction is a safe mole fraction.
876  * @param x Mole fraction vector containing the reference composition.
877  */
878  virtual void getReferenceComposition(doublereal* const x) const;
879 
880  //
881  // The methods below are not virtual, and should not
882  // be overloaded.
883  //
884 
885  //@}
886  //! @name Specific Properties
887  //@{
888 
889  /**
890  * Specific enthalpy. Units: J/kg.
891  */
892  doublereal enthalpy_mass() const {
894  }
895 
896  /**
897  * Specific internal energy. Units: J/kg.
898  */
899  doublereal intEnergy_mass() const {
901  }
902 
903  /**
904  * Specific entropy. Units: J/kg/K.
905  */
906  doublereal entropy_mass() const {
908  }
909 
910  /**
911  * Specific Gibbs function. Units: J/kg.
912  */
913  doublereal gibbs_mass() const {
914  return gibbs_mole()/meanMolecularWeight();
915  }
916 
917  /**
918  * Specific heat at constant pressure. Units: J/kg/K.
919  */
920  doublereal cp_mass() const {
921  return cp_mole()/meanMolecularWeight();
922  }
923 
924  /**
925  * Specific heat at constant volume. Units: J/kg/K.
926  */
927  doublereal cv_mass() const {
928  return cv_mole()/meanMolecularWeight();
929  }
930  //@}
931 
932  //! Return the Gas Constant multiplied by the current temperature
933  /*!
934  * The units are Joules kmol-1
935  */
936  doublereal _RT() const {
937  return temperature() * GasConstant;
938  }
939 
940  /**
941  * @name Setting the State
942  *
943  * These methods set all or part of the thermodynamic state.
944  * @{
945  */
946 
947  //! Set the temperature (K), pressure (Pa), and mole fractions.
948  /*!
949  * Note, the mole fractions are set first before the pressure is set.
950  * Setting the pressure may involve the solution of a nonlinear equation.
951  *
952  * @param t Temperature (K)
953  * @param p Pressure (Pa)
954  * @param x Vector of mole fractions.
955  * Length is equal to m_kk.
956  */
957  virtual void setState_TPX(doublereal t, doublereal p, const doublereal* x);
958 
959  //! Set the temperature (K), pressure (Pa), and mole fractions.
960  /*!
961  * Note, the mole fractions are set first before the pressure is set.
962  * Setting the pressure may involve the solution of a nonlinear equation.
963  *
964  * @param t Temperature (K)
965  * @param p Pressure (Pa)
966  * @param x Composition map of mole fractions. Species not in
967  * the composition map are assumed to have zero mole fraction
968  */
969  virtual void setState_TPX(doublereal t, doublereal p, const compositionMap& x);
970 
971  //! Set the temperature (K), pressure (Pa), and mole fractions.
972  /*!
973  * Note, the mole fractions are set first before the pressure is set.
974  * Setting the pressure may involve the solution of a nonlinear equation.
975  *
976  * @param t Temperature (K)
977  * @param p Pressure (Pa)
978  * @param x String containing a composition map of the mole fractions. Species not in
979  * the composition map are assumed to have zero mole fraction
980  */
981  virtual void setState_TPX(doublereal t, doublereal p, const std::string& x);
982 
983  //! Set the internally stored temperature (K), pressure (Pa), and mass fractions of the phase.
984  /*!
985  * Note, the mass fractions are set first before the pressure is set.
986  * Setting the pressure may involve the solution of a nonlinear equation.
987  *
988  * @param t Temperature (K)
989  * @param p Pressure (Pa)
990  * @param y Vector of mass fractions.
991  * Length is equal to m_kk.
992  */
993  virtual void setState_TPY(doublereal t, doublereal p, const doublereal* y);
994 
995  //! Set the internally stored temperature (K), pressure (Pa), and mass fractions of the phase
996  /*!
997  * Note, the mass fractions are set first before the pressure is set.
998  * Setting the pressure may involve the solution of a nonlinear equation.
999  *
1000  * @param t Temperature (K)
1001  * @param p Pressure (Pa)
1002  * @param y Composition map of mass fractions. Species not in
1003  * the composition map are assumed to have zero mass fraction
1004  */
1005  virtual void setState_TPY(doublereal t, doublereal p, const compositionMap& y);
1006 
1007  //! Set the internally stored temperature (K), pressure (Pa), and mass fractions of the phase
1008  /*!
1009  * Note, the mass fractions are set first before the pressure is set.
1010  * Setting the pressure may involve the solution of a nonlinear equation.
1011  *
1012  * @param t Temperature (K)
1013  * @param p Pressure (Pa)
1014  * @param y String containing a composition map of the mass fractions. Species not in
1015  * the composition map are assumed to have zero mass fraction
1016  */
1017  virtual void setState_TPY(doublereal t, doublereal p, const std::string& y);
1018 
1019  //! Set the temperature (K) and pressure (Pa)
1020  /*!
1021  * Setting the pressure may involve the solution of a nonlinear equation.
1022  *
1023  * @param t Temperature (K)
1024  * @param p Pressure (Pa)
1025  */
1026  virtual void setState_TP(doublereal t, doublereal p);
1027 
1028  //! Set the pressure (Pa) and mole fractions.
1029  /*!
1030  * Note, the mole fractions are set first before the pressure is set.
1031  * Setting the pressure may involve the solution of a nonlinear equation.
1032  *
1033  * @param p Pressure (Pa)
1034  * @param x Vector of mole fractions.
1035  * Length is equal to m_kk.
1036  */
1037  virtual void setState_PX(doublereal p, doublereal* x);
1038 
1039  //! Set the internally stored pressure (Pa) and mass fractions.
1040  /*!
1041  * Note, the temperature is held constant during this operation.
1042  * Note, the mass fractions are set first before the pressure is set.
1043  * Setting the pressure may involve the solution of a nonlinear equation.
1044  *
1045  * @param p Pressure (Pa)
1046  * @param y Vector of mass fractions.
1047  * Length is equal to m_kk.
1048  */
1049  virtual void setState_PY(doublereal p, doublereal* y);
1050 
1051  //! Set the internally stored specific enthalpy (J/kg) and pressure (Pa) of the phase.
1052  /*!
1053  * @param h Specific enthalpy (J/kg)
1054  * @param p Pressure (Pa)
1055  * @param tol Optional parameter setting the tolerance of the calculation.
1056  * Important for some applications where numerical Jacobians
1057  * are being calculated.Defaults to 1.0E-4
1058  */
1059  virtual void setState_HP(doublereal h, doublereal p, doublereal tol = 1.e-4);
1060 
1061  //! Set the specific internal energy (J/kg) and specific volume (m^3/kg).
1062  /*!
1063  * This function fixes the internal state of the phase so that
1064  * the specific internal energy and specific volume have the value of the input parameters.
1065  *
1066  * @param u specific internal energy (J/kg)
1067  * @param v specific volume (m^3/kg).
1068  * @param tol Optional parameter setting the tolerance of the calculation.
1069  * Important for some applications where numerical Jacobians
1070  * are being calculated.Defaults to 1.0E-4
1071  */
1072  virtual void setState_UV(doublereal u, doublereal v, doublereal tol = 1.e-4);
1073 
1074  //! Set the specific entropy (J/kg/K) and pressure (Pa).
1075  /*!
1076  * This function fixes the internal state of the phase so that
1077  * the specific entropy and the pressure have the value of the input parameters.
1078  *
1079  * @param s specific entropy (J/kg/K)
1080  * @param p specific pressure (Pa).
1081  * @param tol Optional parameter setting the tolerance of the calculation.
1082  * Defaults to 1.0E-4. Important for some applications where
1083  * numerical Jacobians are being calculated.
1084  */
1085  virtual void setState_SP(doublereal s, doublereal p, doublereal tol = 1.e-4);
1086 
1087  //! Set the specific entropy (J/kg/K) and specific volume (m^3/kg).
1088  /*!
1089  * This function fixes the internal state of the phase so that
1090  * the specific entropy and specific volume have the value of the input parameters.
1091  *
1092  * @param s specific entropy (J/kg/K)
1093  * @param v specific volume (m^3/kg).
1094  * @param tol Optional parameter setting the tolerance of the calculation.
1095  * Defaults to 1.0E-4. Important for some applications where
1096  * numerical Jacobians are being calculated.
1097  */
1098  virtual void setState_SV(doublereal s, doublereal v, doublereal tol = 1.e-4);
1099 
1100  //@}
1101 
1102 private:
1103  //! Carry out work in HP and UV calculations.
1104  /*!
1105  * @param h Specific enthalpy or internal energy (J/kg)
1106  * @param p Pressure (Pa) or specific volume (m^3/kg)
1107  * @param tol Optional parameter setting the tolerance of the calculation.
1108  * Defaults to 1.0E-4. Important for some applications where
1109  * numerical Jacobians are being calculated.
1110  * @param doUV True if solving for UV, false for HP.
1111  */
1112  void setState_HPorUV(doublereal h, doublereal p,
1113  doublereal tol = 1.e-4, bool doUV = false);
1114 
1115  //! Carry out work in SP and SV calculations.
1116  /*!
1117  * @param s Specific entropy (J/kg)
1118  * @param p Pressure (Pa) or specific volume (m^3/kg)
1119  * @param tol Optional parameter setting the tolerance of the calculation.
1120  * Defaults to 1.0E-4. Important for some applications where
1121  * numerical Jacobians are being calculated.
1122  * @param doSV True if solving for SV, false for SP.
1123  */
1124  void setState_SPorSV(doublereal s, doublereal p,
1125  doublereal tol = 1.e-4, bool doSV = false);
1126 
1127  //! Helper function used by setState_HPorUV and setState_SPorSV.
1128  //! Sets the temperature and (if set_p is true) the pressure.
1129  void setState_conditional_TP(doublereal t, doublereal p, bool set_p);
1130 
1131 public:
1132 
1133  /**
1134  * @name Chemical Equilibrium
1135  * Chemical equilibrium.
1136  * @{
1137  */
1138 
1139  //! Equilibrate a ThermoPhase object
1140  /*!
1141  * Set this phase to chemical equilibrium by calling one of several
1142  * equilibrium solvers. The XY parameter indicates what two thermodynamic
1143  * quantities are to be held constant during the equilibration process.
1144  *
1145  * @param XY String representation of what two properties are being
1146  * held constant
1147  * @param solver Name of the solver to be used to equilibrate the phase.
1148  * If solver = 'element_potential', the ChemEquil element potential
1149  * solver will be used. If solver = 'vcs', the VCS solver will be used.
1150  * If solver = 'gibbs', the MultiPhaseEquil solver will be used. If
1151  * solver = 'auto', the solvers will be tried in order if the initial
1152  * solver(s) fail.
1153  * @param rtol Relative tolerance
1154  * @param max_steps Maximum number of steps to take to find the solution
1155  * @param max_iter For the 'gibbs' and 'vcs' solvers, this is the maximum
1156  * number of outer temperature or pressure iterations to take when T
1157  * and/or P is not held fixed.
1158  * @param estimate_equil integer indicating whether the solver should
1159  * estimate its own initial condition. If 0, the initial mole fraction
1160  * vector in the ThermoPhase object is used as the initial condition.
1161  * If 1, the initial mole fraction vector is used if the element
1162  * abundances are satisfied. If -1, the initial mole fraction vector is
1163  * thrown out, and an estimate is formulated.
1164  * @param log_level loglevel Controls amount of diagnostic output.
1165  * log_level=0 suppresses diagnostics, and increasingly-verbose
1166  * messages are written as loglevel increases.
1167  *
1168  * @ingroup equilfunctions
1169  */
1170  void equilibrate(const std::string& XY, const std::string& solver="auto",
1171  double rtol=1e-9, int max_steps=50000, int max_iter=100,
1172  int estimate_equil=0, int log_level=0);
1173 
1174  //!This method is used by the ChemEquil equilibrium solver.
1175  /*!
1176  * It sets the state such that the chemical potentials satisfy
1177  * \f[ \frac{\mu_k}{\hat R T} = \sum_m A_{k,m}
1178  * \left(\frac{\lambda_m} {\hat R T}\right) \f] where
1179  * \f$ \lambda_m \f$ is the element potential of element m. The
1180  * temperature is unchanged. Any phase (ideal or not) that
1181  * implements this method can be equilibrated by ChemEquil.
1182  *
1183  * @param lambda_RT Input vector of dimensionless element potentials
1184  * The length is equal to nElements().
1185  */
1186  virtual void setToEquilState(const doublereal* lambda_RT) {
1187  throw NotImplementedError("ThermoPhase::setToEquilState");
1188  }
1189 
1190  //! Stores the element potentials in the ThermoPhase object
1191  /*!
1192  * Called by the ChemEquil equilibrium solver to transfer the element
1193  * potentials to this object after every successful equilibration routine.
1194  * The element potentials are stored in their dimensionless forms,
1195  * calculated by dividing by RT.
1196  *
1197  * @param lambda Input vector containing the element potentials.
1198  * Length = nElements. Units are Joules/kmol.
1199  */
1200  void setElementPotentials(const vector_fp& lambda);
1201 
1202  //! Returns the element potentials stored in the ThermoPhase object
1203  /*!
1204  * Returns the stored element potentials.
1205  * The element potentials are retrieved from their stored
1206  * dimensionless forms by multiplying by RT.
1207  * @param lambda Output vector containing the element potentials.
1208  * Length = nElements. Units are Joules/kmol.
1209  * @return bool indicating whether there are any valid stored element
1210  * potentials. The calling routine should check this
1211  * bool. In the case that there aren't any, lambda is not
1212  * touched.
1213  */
1214  bool getElementPotentials(doublereal* lambda) const;
1215 
1216  //@}
1217 
1218 
1219  //---------------------------------------------------------
1220  /// @name Critical State Properties.
1221  /// These methods are only implemented by some subclasses, and may
1222  /// be moved out of ThermoPhase at a later date.
1223 
1224  //@{
1225 
1226  /// Critical temperature (K).
1227  virtual doublereal critTemperature() const {
1228  throw NotImplementedError("ThermoPhase::critTemperature");
1229  }
1230 
1231  /// Critical pressure (Pa).
1232  virtual doublereal critPressure() const {
1233  throw NotImplementedError("ThermoPhase::critPressure");
1234  }
1235 
1236  /// Critical volume (m3/kmol).
1237  virtual doublereal critVolume() const {
1238  throw NotImplementedError("ThermoPhase::critVolume");
1239  }
1240 
1241  /// Critical compressibility (unitless).
1242  virtual doublereal critCompressibility() const {
1243  throw NotImplementedError("ThermoPhase::critCompressibility");
1244  }
1245 
1246  /// Critical density (kg/m3).
1247  virtual doublereal critDensity() const {
1248  throw NotImplementedError("ThermoPhase::critDensity");
1249  }
1250 
1251  //@}
1252 
1253  /** @name Saturation Properties.
1254  *
1255  * These methods are only implemented by subclasses that
1256  * implement full liquid-vapor equations of state. They may be
1257  * moved out of ThermoPhase at a later date.
1258  */
1259  //@{
1260 
1261  //! Return the saturation temperature given the pressure
1262  /*!
1263  * @param p Pressure (Pa)
1264  */
1265  virtual doublereal satTemperature(doublereal p) const {
1266  throw NotImplementedError("ThermoPhase::satTemperature");
1267  }
1268 
1269  //! Return the saturation pressure given the temperature
1270  /*!
1271  * @param t Temperature (Kelvin)
1272  */
1273  virtual doublereal satPressure(doublereal t) {
1274  throw NotImplementedError("ThermoPhase::satPressure");
1275  }
1276 
1277  //! Return the fraction of vapor at the current conditions
1278  virtual doublereal vaporFraction() const {
1279  throw NotImplementedError("ThermoPhase::vaprFraction");
1280  }
1281 
1282  //! Set the state to a saturated system at a particular temperature
1283  /*!
1284  * @param t Temperature (kelvin)
1285  * @param x Fraction of vapor
1286  */
1287  virtual void setState_Tsat(doublereal t, doublereal x) {
1288  throw NotImplementedError("ThermoPhase::setState_sat");
1289  }
1290 
1291  //! Set the state to a saturated system at a particular pressure
1292  /*!
1293  * @param p Pressure (Pa)
1294  * @param x Fraction of vapor
1295  */
1296  virtual void setState_Psat(doublereal p, doublereal x) {
1297  throw NotImplementedError("ThermoPhase::setState_sat");
1298  }
1299 
1300  //@}
1301 
1302 
1303  //! @name Initialization Methods - For Internal Use (ThermoPhase)
1304  /*!
1305  * The following methods are used in the process of constructing
1306  * the phase and setting its parameters from a specification in an
1307  * input file. They are not normally used in application programs.
1308  * To see how they are used, see importPhase().
1309  */
1310  //@{
1311 
1312  using Phase::addSpecies;
1313  virtual bool addSpecies(shared_ptr<Species> spec);
1314 
1315  //! Store a reference pointer to the XML tree containing the species data
1316  //! for this phase.
1317  /*!
1318  * This is used to access data needed to construct transport manager later.
1319  * @internal
1320  *
1321  * @param k Species index
1322  * @param data Pointer to the XML_Node data containing
1323  * information about the species in the phase.
1324  */
1325  void saveSpeciesData(const size_t k, const XML_Node* const data);
1326 
1327  //! Return a pointer to the vector of XML nodes containing the species
1328  //! data for this phase.
1329  const std::vector<const XML_Node*> & speciesData() const;
1330 
1331  //! Install a species thermodynamic property manager.
1332  /*!
1333  * The species thermodynamic property manager
1334  * computes properties of the pure species for use in
1335  * constructing solution properties. It is meant for internal
1336  * use, and some classes derived from ThermoPhase may not use
1337  * any species thermodynamic property manager. This method is
1338  * called by function importPhase().
1339  *
1340  * @param spthermo input pointer to the species thermodynamic property
1341  * manager.
1342  *
1343  * @internal
1344  */
1345  void setSpeciesThermo(SpeciesThermo* spthermo);
1346 
1347  //! Return a changeable reference to the calculation manager
1348  //! for species reference-state thermodynamic properties
1349  /*!
1350  *
1351  * @param k Species id. The default is -1, meaning return the default
1352  *
1353  * @internal
1354  */
1355  virtual SpeciesThermo& speciesThermo(int k = -1);
1356 
1357  /**
1358  * @internal
1359  * Initialization of a ThermoPhase object using an ctml file.
1360  *
1361  * This routine is a precursor to initThermoXML(XML_Node*)
1362  * routine, which does most of the work.
1363  * Here we read extra information about the XML description
1364  * of a phase. Regular information about elements and species
1365  * and their reference state thermodynamic information
1366  * have already been read at this point.
1367  * For example, we do not need to call this function for
1368  * ideal gas equations of state.
1369  *
1370  * @param inputFile XML file containing the description of the
1371  * phase
1372  *
1373  * @param id Optional parameter identifying the name of the
1374  * phase. If none is given, the first XML
1375  * phase element encountered will be used.
1376  */
1377  virtual void initThermoFile(const std::string& inputFile,
1378  const std::string& id);
1379 
1380  //!Import and initialize a ThermoPhase object using an XML tree.
1381  /*!
1382  * @internal
1383  *
1384  * Here we read extra information about the XML description
1385  * of a phase. Regular information about elements and species
1386  * and their reference state thermodynamic information
1387  * have already been read at this point.
1388  * For example, we do not need to call this function for
1389  * ideal gas equations of state. This function is called from importPhase()
1390  * after the elements and the species are initialized with
1391  * default ideal solution level data.
1392  *
1393  * The default implementation in ThermoPhase calls the
1394  * virtual function initThermo() and then sets the "state" of the
1395  * phase by looking for an XML element named "state", and then
1396  * interpreting its contents by calling the virtual function
1397  * setStateFromXML().
1398  *
1399  * @param phaseNode This object must be the phase node of a
1400  * complete XML tree
1401  * description of the phase, including all of the
1402  * species data. In other words while "phase" must
1403  * point to an XML phase object, it must have
1404  * sibling nodes "speciesData" that describe
1405  * the species in the phase.
1406  * @param id ID of the phase. If nonnull, a check is done
1407  * to see if phaseNode is pointing to the phase
1408  * with the correct id.
1409  */
1410  virtual void initThermoXML(XML_Node& phaseNode, const std::string& id);
1411 
1412  //! Initialize the ThermoPhase object after all species have been set up
1413  /*!
1414  * @internal Initialize.
1415  *
1416  * This method is provided to allow
1417  * subclasses to perform any initialization required after all
1418  * species have been added. For example, it might be used to
1419  * resize internal work arrays that must have an entry for
1420  * each species. The base class implementation does nothing,
1421  * and subclasses that do not require initialization do not
1422  * need to overload this method. When importing a CTML phase
1423  * description, this method is called from ThermoPhase::initThermoXML(),
1424  * which is called from importPhase(),
1425  * just prior to returning from function importPhase().
1426  */
1427  virtual void initThermo();
1428 
1429  //! Add in species from Slave phases
1430  /*!
1431  * This hook is used for cSS_CONVENTION_SLAVE phases
1432  *
1433  * @param phaseNode XML Element for the phase
1434  */
1435  virtual void installSlavePhases(Cantera::XML_Node* phaseNode);
1436 
1437  //! Set the equation of state parameters
1438  /*!
1439  * @internal
1440  * The number and meaning of these depends on the subclass.
1441  *
1442  * @param n number of parameters
1443  * @param c array of \a n coefficients
1444  */
1445  virtual void setParameters(int n, doublereal* const c) {
1446  }
1447 
1448  //! Get the equation of state parameters in a vector
1449  /*!
1450  * @internal
1451  * The number and meaning of these depends on the subclass.
1452  *
1453  * @param n number of parameters
1454  * @param c array of \a n coefficients
1455  */
1456  virtual void getParameters(int& n, doublereal* const c) const {
1457  }
1458 
1459  //! Set equation of state parameter values from XML entries.
1460  /*!
1461  * This method is called by function importPhase() when processing a phase
1462  * definition in an input file. It should be overloaded in subclasses to set
1463  * any parameters that are specific to that particular phase
1464  * model. Note, this method is called before the phase is
1465  * initialized with elements and/or species.
1466  *
1467  * @param eosdata An XML_Node object corresponding to
1468  * the "thermo" entry for this phase in the input file.
1469  */
1470  virtual void setParametersFromXML(const XML_Node& eosdata) {}
1471 
1472  //! Set the initial state of the phase to the conditions
1473  //! specified in the state XML element.
1474  /*!
1475  *
1476  * This method sets the temperature, pressure, and mole
1477  * fraction vector to a set default value.
1478  *
1479  * @param state AN XML_Node object corresponding to
1480  * the "state" entry for this phase in the
1481  * input file.
1482  */
1483  virtual void setStateFromXML(const XML_Node& state);
1484 
1485  //! @}
1486  //! @name Derivatives of Thermodynamic Variables needed for Applications
1487  //! @{
1488 
1489  //! Get the change in activity coefficients wrt changes in state (temp, mole fraction, etc) along
1490  //! a line in parameter space or along a line in physical space
1491  /*!
1492  *
1493  * @param dTds Input of temperature change along the path
1494  * @param dXds Input vector of changes in mole fraction along the path. length = m_kk
1495  * Along the path length it must be the case that the mole fractions sum to one.
1496  * @param dlnActCoeffds Output vector of the directional derivatives of the
1497  * log Activity Coefficients along the path. length = m_kk
1498  * units are 1/units(s). if s is a physical coordinate then the units are 1/m.
1499  */
1500  virtual void getdlnActCoeffds(const doublereal dTds, const doublereal* const dXds,
1501  doublereal* dlnActCoeffds) const {
1502  throw NotImplementedError("ThermoPhase::getdlnActCoeffds");
1503  }
1504 
1505  //! Get the array of ln mole fraction derivatives of the log activity coefficients - diagonal component only
1506  /*!
1507  * This function is a virtual method. For ideal mixtures
1508  * (unity activity coefficients), this can return zero.
1509  * Implementations should take the derivative of the
1510  * logarithm of the activity coefficient with respect to the
1511  * logarithm of the mole fraction variable
1512  * that represents the standard state.
1513  * This quantity is to be used in conjunction with derivatives of
1514  * that mole fraction variable when the derivative of the chemical
1515  * potential is taken.
1516  *
1517  * units = dimensionless
1518  *
1519  * @param dlnActCoeffdlnX_diag Output vector of derivatives of the
1520  * log Activity Coefficients wrt the mole fractions. length = m_kk
1521  */
1522  virtual void getdlnActCoeffdlnX_diag(doublereal* dlnActCoeffdlnX_diag) const {
1523  throw NotImplementedError("ThermoPhase::getdlnActCoeffdlnX_diag");
1524  }
1525 
1526  //! Get the array of log species mole number derivatives of the log activity coefficients
1527  /*!
1528  * This function is a virtual method.
1529  * For ideal mixtures (unity activity coefficients), this can return zero.
1530  * Implementations should take the derivative of the
1531  * logarithm of the activity coefficient with respect to the
1532  * logarithm of the concentration-like variable (i.e. moles)
1533  * that represents the standard state.
1534  * This quantity is to be used in conjunction with derivatives of
1535  * that species mole number variable when the derivative of the chemical
1536  * potential is taken.
1537  *
1538  * units = dimensionless
1539  *
1540  * @param dlnActCoeffdlnN_diag Output vector of derivatives of the
1541  * log Activity Coefficients. length = m_kk
1542  */
1543  virtual void getdlnActCoeffdlnN_diag(doublereal* dlnActCoeffdlnN_diag) const {
1544  throw NotImplementedError("ThermoPhase::getdlnActCoeffdlnN_diag");
1545  }
1546 
1547  //! Get the array of derivatives of the log activity coefficients with respect to the log of the species mole numbers
1548  /*!
1549  * Implementations should take the derivative of the logarithm of the activity coefficient with respect to a
1550  * species log mole number (with all other species mole numbers held constant). The default treatment in the
1551  * ThermoPhase object is to set this vector to zero.
1552  *
1553  * units = 1 / kmol
1554  *
1555  * dlnActCoeffdlnN[ ld * k + m] will contain the derivative of log act_coeff for the <I>m</I><SUP>th</SUP>
1556  * species with respect to the number of moles of the <I>k</I><SUP>th</SUP> species.
1557  *
1558  * \f[
1559  * \frac{d \ln(\gamma_m) }{d \ln( n_k ) }\Bigg|_{n_i}
1560  * \f]
1561  *
1562  * @param ld Number of rows in the matrix
1563  * @param dlnActCoeffdlnN Output vector of derivatives of the
1564  * log Activity Coefficients. length = m_kk * m_kk
1565  */
1566  virtual void getdlnActCoeffdlnN(const size_t ld, doublereal* const dlnActCoeffdlnN);
1567 
1568  virtual void getdlnActCoeffdlnN_numderiv(const size_t ld, doublereal* const dlnActCoeffdlnN);
1569 
1570  //! @}
1571  //! @name Printing
1572  //! @{
1573 
1574  //! returns a summary of the state of the phase as a string
1575  /*!
1576  * @param show_thermo If true, extra information is printed out
1577  * about the thermodynamic state of the system.
1578  * @param threshold Show information about species with mole fractions
1579  * greater than *threshold*.
1580  */
1581  virtual std::string report(bool show_thermo=true,
1582  doublereal threshold=-1e-14) const;
1583 
1584  //! returns a summary of the state of the phase to a comma separated file.
1585  //! To customize the data included in the report, derived classes should
1586  //! override the getCsvReportData method.
1587  /*!
1588  * @param csvFile ofstream file to print comma separated data for
1589  * the phase
1590  */
1591  virtual void reportCSV(std::ofstream& csvFile) const;
1592 
1593  //@}
1594 
1595 protected:
1596  //! Fills `names` and `data` with the column names and species thermo
1597  //! properties to be included in the output of the reportCSV method.
1598  virtual void getCsvReportData(std::vector<std::string>& names,
1599  std::vector<vector_fp>& data) const;
1600 
1601  //! Pointer to the calculation manager for species
1602  //! reference-state thermodynamic properties
1603  /*!
1604  * This class is called when the reference-state thermodynamic properties
1605  * of all the species in the phase needs to be evaluated.
1606  */
1608 
1609  //! Vector of pointers to the species databases.
1610  /*!
1611  * This is used to access data needed to
1612  * construct the transport manager and other properties
1613  * later in the initialization process.
1614  * We create a copy of the XML_Node data read in here. Therefore, we own this
1615  * data.
1616  */
1617  std::vector<const XML_Node*> m_speciesData;
1618 
1619  //! Stored value of the electric potential for this phase
1620  /*!
1621  * Units are Volts
1622  */
1623  doublereal m_phi;
1624 
1625  /// Vector of element potentials.
1626  /// Length equal to number of elements.
1628 
1629  //! Boolean indicating whether there is a valid set of saved element potentials
1630  //! for this phase
1632 
1633  //! Boolean indicating whether a charge neutrality condition is a necessity
1634  /*!
1635  * Note, the charge neutrality condition is not a necessity for ideal gas phases. There may
1636  * be a net charge in those phases, because the NASA polynomials for ionized species
1637  * in Ideal gases take this condition into account.
1638  * However, liquid phases usually require charge neutrality in order for their derived
1639  * thermodynamics to be valid.
1640  */
1642 
1643  //! Contains the standard state convention
1645 
1646  //! Reference Mole Fraction Composition
1647  /*!
1648  * Occasionally, the need arises to find a safe mole fraction vector to initialize
1649  * the object to. This contains such a vector.
1650  * The algorithm will pick up the mole fraction vector that is applied from
1651  * the state XML file in the input file
1652  */
1653  std::vector<doublereal> xMol_Ref;
1654 
1655  //! last value of the temperature processed by reference state
1656  mutable doublereal m_tlast;
1657 };
1658 
1659 //! typedef for the ThermoPhase class
1661 
1662 }
1663 
1664 #endif
std::map< std::string, doublereal > compositionMap
Map connecting a string name with a double.
Definition: ct_defs.h:149
virtual void setState_HP(doublereal h, doublereal p, doublereal tol=1.e-4)
Set the internally stored specific enthalpy (J/kg) and pressure (Pa) of the phase.
ThermoPhase()
Constructor.
Definition: ThermoPhase.cpp:28
virtual void getGibbs_ref(doublereal *g) const
Returns the vector of the Gibbs function of the reference state at the current temperature of the sol...
Definition: ThermoPhase.h:813
virtual doublereal vaporFraction() const
Return the fraction of vapor at the current conditions.
Definition: ThermoPhase.h:1278
virtual bool addSpecies(shared_ptr< Species > spec)
Add a Species to this Phase.
doublereal electricPotential() const
Returns the electric potential of this phase (V).
Definition: ThermoPhase.h:352
virtual doublereal gibbs_mole() const
Molar Gibbs function. Units: J/kmol.
Definition: ThermoPhase.h:242
virtual void getParameters(int &n, doublereal *const c) const
Get the equation of state parameters in a vector.
Definition: ThermoPhase.h:1456
virtual void getChemPotentials_RT(doublereal *mu) const
Get the array of non-dimensional species chemical potentials These are partial molar Gibbs free energ...
Definition: ThermoPhase.h:540
std::vector< const XML_Node * > m_speciesData
Vector of pointers to the species databases.
Definition: ThermoPhase.h:1617
An error indicating that an unimplemented function has been called.
Definition: ctexceptions.h:213
virtual void getEnthalpy_RT(doublereal *hrt) const
Get the nondimensional Enthalpy functions for the species at their standard states at the current T a...
Definition: ThermoPhase.h:680
virtual void setState_TPX(doublereal t, doublereal p, const doublereal *x)
Set the temperature (K), pressure (Pa), and mole fractions.
virtual void setState_Psat(doublereal p, doublereal x)
Set the state to a saturated system at a particular pressure.
Definition: ThermoPhase.h:1296
void setElectricPotential(doublereal v)
Set the electric potential of this phase (V).
Definition: ThermoPhase.h:344
virtual doublereal cv_vib(int, double) const
Definition: ThermoPhase.h:262
doublereal _RT() const
Return the Gas Constant multiplied by the current temperature.
Definition: ThermoPhase.h:936
virtual void initThermo()
Initialize the ThermoPhase object after all species have been set up.
const size_t npos
index returned by functions to indicate "no position"
Definition: ct_defs.h:165
ThermoPhase & operator=(const ThermoPhase &right)
Assignment operator.
Definition: ThermoPhase.cpp:60
Header file for class Phase.
const int cAC_CONVENTION_MOLAR
Standard state uses the molar convention.
Definition: ThermoPhase.h:24
virtual doublereal maxTemp(size_t k=npos) const =0
Maximum temperature.
void setState_HPorUV(doublereal h, doublereal p, doublereal tol=1.e-4, bool doUV=false)
Carry out work in HP and UV calculations.
virtual void reportCSV(std::ofstream &csvFile) const
returns a summary of the state of the phase to a comma separated file.
const int cSS_CONVENTION_TEMPERATURE
Standard state uses the molar convention.
Definition: ThermoPhase.h:34
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:100
void setState_conditional_TP(doublereal t, doublereal p, bool set_p)
Helper function used by setState_HPorUV and setState_SPorSV.
Virtual base class for the calculation of multiple-species thermodynamic reference-state property man...
virtual void getEntropy_R_ref(doublereal *er) const
Returns the vector of nondimensional entropies of the reference state at the current temperature of t...
Definition: ThermoPhase.h:824
virtual void getStandardVolumes(doublereal *vol) const
Get the molar volumes of the species standard states at the current T and P of the solution...
Definition: ThermoPhase.h:744
Class Phase is the base class for phases of matter, managing the species and elements in a phase...
Definition: Phase.h:92
virtual void getdlnActCoeffdlnX_diag(doublereal *dlnActCoeffdlnX_diag) const
Get the array of ln mole fraction derivatives of the log activity coefficients - diagonal component o...
Definition: ThermoPhase.h:1522
virtual doublereal critTemperature() const
Critical temperature (K).
Definition: ThermoPhase.h:1227
vector_fp m_lambdaRRT
Vector of element potentials.
Definition: ThermoPhase.h:1627
virtual void getStandardChemPotentials(doublereal *mu) const
Get the array of chemical potentials at unit activity for the species at their standard states at the...
Definition: ThermoPhase.h:670
virtual void getPartialMolarVolumes(doublereal *vbar) const
Return an array of partial molar volumes for the species in the mixture.
Definition: ThermoPhase.h:628
virtual doublereal satPressure(doublereal t)
Return the saturation pressure given the temperature.
Definition: ThermoPhase.h:1273
void equilibrate(const std::string &XY, const std::string &solver="auto", double rtol=1e-9, int max_steps=50000, int max_iter=100, int estimate_equil=0, int log_level=0)
Equilibrate a ThermoPhase object.
void saveSpeciesData(const size_t k, const XML_Node *const data)
Store a reference pointer to the XML tree containing the species data for this phase.
doublereal m_tlast
last value of the temperature processed by reference state
Definition: ThermoPhase.h:1656
Pure Virtual base class for the species thermo manager classes.
virtual void setState_PY(doublereal p, doublereal *y)
Set the internally stored pressure (Pa) and mass fractions.
virtual doublereal entropy_mole() const
Molar entropy. Units: J/kmol/K.
Definition: ThermoPhase.h:237
virtual void getEnthalpy_RT_ref(doublereal *hrt) const
Returns the vector of nondimensional enthalpies of the reference state at the current temperature of ...
Definition: ThermoPhase.h:789
virtual void getdlnActCoeffdlnN_diag(doublereal *dlnActCoeffdlnN_diag) const
Get the array of log species mole number derivatives of the log activity coefficients.
Definition: ThermoPhase.h:1543
virtual doublereal standardConcentration(size_t k=0) const
Return the standard concentration for the kth species.
Definition: ThermoPhase.h:447
virtual doublereal thermalExpansionCoeff() const
Return the volumetric thermal expansion coefficient. Units: 1/K.
Definition: ThermoPhase.h:321
doublereal intEnergy_mass() const
Specific internal energy.
Definition: ThermoPhase.h:899
ThermoPhase thermo_t
typedef for the ThermoPhase class
Definition: ThermoPhase.h:1660
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:97
virtual void setReferenceComposition(const doublereal *const x)
Sets the reference composition.
bool m_chargeNeutralityNecessary
Boolean indicating whether a charge neutrality condition is a necessity.
Definition: ThermoPhase.h:1641
virtual void setStateFromXML(const XML_Node &state)
Set the initial state of the phase to the conditions specified in the state XML element.
virtual doublereal intEnergy_mole() const
Molar internal energy. Units: J/kmol.
Definition: ThermoPhase.h:232
virtual void getPureGibbs(doublereal *gpure) const
Get the Gibbs functions for the standard state of the species at the current T and P of the solution...
Definition: ThermoPhase.h:711
virtual void getActivities(doublereal *a) const
Get the array of non-dimensional activities at the current solution temperature, pressure, and solution concentration.
virtual doublereal enthalpy_mole() const
Molar enthalpy. Units: J/kmol.
Definition: ThermoPhase.h:227
virtual doublereal critDensity() const
Critical density (kg/m3).
Definition: ThermoPhase.h:1247
doublereal gibbs_mass() const
Specific Gibbs function.
Definition: ThermoPhase.h:913
virtual void getIntEnergy_RT(doublereal *urt) const
Returns the vector of nondimensional Internal Energies of the standard state species at the current T...
Definition: ThermoPhase.h:721
doublereal entropy_mass() const
Specific entropy.
Definition: ThermoPhase.h:906
doublereal m_phi
Stored value of the electric potential for this phase.
Definition: ThermoPhase.h:1623
doublereal molarVolume() const
Molar volume (m^3/kmol).
Definition: Phase.cpp:673
virtual void getUnitsStandardConc(double *uA, int k=0, int sizeUA=6) const
Returns the units of the standard and generalized concentrations.
virtual ThermoPhase * duplMyselfAsThermoPhase() const
Duplication routine for objects which inherit from ThermoPhase.
virtual void getdStandardVolumes_dT(doublereal *d_vol_dT) const
Get the derivative of the molar volumes of the species standard states wrt temperature at the current...
Definition: ThermoPhase.h:757
virtual doublereal maxTemp(size_t k=npos) const
Maximum temperature for which the thermodynamic data for the species are valid.
Definition: ThermoPhase.h:207
virtual void getdPartialMolarVolumes_dT(doublereal *d_vbar_dT) const
Return an array of derivatives of partial molar volumes wrt temperature for the species in the mixtur...
Definition: ThermoPhase.h:640
bool getElementPotentials(doublereal *lambda) const
Returns the element potentials stored in the ThermoPhase object.
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
Definition: ThermoPhase.h:554
virtual void getGibbs_RT_ref(doublereal *grt) const
Returns the vector of nondimensional Gibbs Free Energies of the reference state at the current temper...
Definition: ThermoPhase.h:800
virtual void getCp_R(doublereal *cpr) const
Get the nondimensional Heat Capacities at constant pressure for the species standard states at the cu...
Definition: ThermoPhase.h:732
doublereal cp_mass() const
Specific heat at constant pressure.
Definition: ThermoPhase.h:920
bool chargeNeutralityNecessary() const
Returns the chargeNeutralityNecessity boolean.
Definition: ThermoPhase.h:218
virtual void setState_SP(doublereal s, doublereal p, doublereal tol=1.e-4)
Set the specific entropy (J/kg/K) and pressure (Pa).
virtual void setState_TPY(doublereal t, doublereal p, const doublereal *y)
Set the internally stored temperature (K), pressure (Pa), and mass fractions of the phase...
doublereal Hf298SS(const int k) const
Report the 298 K Heat of Formation of the standard state of one species (J kmol-1) ...
Definition: ThermoPhase.h:178
virtual void getCsvReportData(std::vector< std::string > &names, std::vector< vector_fp > &data) const
Fills names and data with the column names and species thermo properties to be included in the output...
int m_ssConvention
Contains the standard state convention.
Definition: ThermoPhase.h:1644
virtual doublereal critVolume() const
Critical volume (m3/kmol).
Definition: ThermoPhase.h:1237
virtual doublereal refPressure(size_t k=npos) const =0
The reference-state pressure for species k.
virtual doublereal critCompressibility() const
Critical compressibility (unitless).
Definition: ThermoPhase.h:1242
virtual void getdlnActCoeffds(const doublereal dTds, const doublereal *const dXds, doublereal *dlnActCoeffds) const
Get the change in activity coefficients wrt changes in state (temp, mole fraction, etc) along a line in parameter space or along a line in physical space.
Definition: ThermoPhase.h:1500
virtual void getReferenceComposition(doublereal *const x) const
Gets the reference composition.
virtual void getPartialMolarEntropies(doublereal *sbar) const
Returns an array of partial molar entropies of the species in the solution.
Definition: ThermoPhase.h:597
const int cAC_CONVENTION_MOLALITY
Standard state uses the molality convention.
Definition: ThermoPhase.h:26
doublereal cv_mass() const
Specific heat at constant volume.
Definition: ThermoPhase.h:927
virtual void setState_UV(doublereal u, doublereal v, doublereal tol=1.e-4)
Set the specific internal energy (J/kg) and specific volume (m^3/kg).
virtual void getdStandardVolumes_dP(doublereal *d_vol_dP) const
Get the derivative molar volumes of the species standard states wrt pressure at the current T and P o...
Definition: ThermoPhase.h:770
virtual bool addSpecies(shared_ptr< Species > spec)
Add a Species to this Phase.
Definition: Phase.cpp:844
virtual void getPartialMolarIntEnergies(doublereal *ubar) const
Return an array of partial molar internal energies for the species in the mixture.
Definition: ThermoPhase.h:607
virtual void setState_TP(doublereal t, doublereal p)
Set the temperature (K) and pressure (Pa)
virtual doublereal refPressure() const
Returns the reference pressure in Pa.
Definition: ThermoPhase.h:150
virtual void getStandardVolumes_ref(doublereal *vol) const
Get the molar volumes of the species reference states at the current T and P_ref of the solution...
Definition: ThermoPhase.h:861
virtual doublereal cv_mole() const
Molar heat capacity at constant volume. Units: J/kmol/K.
Definition: ThermoPhase.h:252
virtual doublereal critPressure() const
Critical pressure (Pa).
Definition: ThermoPhase.h:1232
virtual doublereal minTemp(size_t k=npos) const =0
Minimum temperature.
virtual doublereal pressure() const
Return the thermodynamic pressure (Pa).
Definition: ThermoPhase.h:278
virtual void installSlavePhases(Cantera::XML_Node *phaseNode)
Add in species from Slave phases.
virtual doublereal isothermalCompressibility() const
Returns the isothermal compressibility. Units: 1/Pa.
Definition: ThermoPhase.h:310
virtual void setState_SV(doublereal s, doublereal v, doublereal tol=1.e-4)
Set the specific entropy (J/kg/K) and specific volume (m^3/kg).
virtual void getEntropy_R(doublereal *sr) const
Get the array of nondimensional Entropy functions for the standard state species at the current T and...
Definition: ThermoPhase.h:690
doublereal temperature() const
Temperature (K).
Definition: Phase.h:602
virtual void getActivityConcentrations(doublereal *c) const
This method returns an array of generalized concentrations.
Definition: ThermoPhase.h:425
virtual void setPressure(doublereal p)
Set the internally stored pressure (Pa) at constant temperature and composition.
Definition: ThermoPhase.h:295
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id)
Import and initialize a ThermoPhase object using an XML tree.
virtual int standardStateConvention() const
This method returns the convention used in specification of the standard state, of which there are cu...
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
Definition: ct_defs.h:157
void setState_SPorSV(doublereal s, doublereal p, doublereal tol=1.e-4, bool doSV=false)
Carry out work in SP and SV calculations.
virtual void getLnActivityCoefficients(doublereal *lnac) const
Get the array of non-dimensional molar-based ln activity coefficients at the current solution tempera...
virtual int eosType() const
Equation of state type flag.
Definition: ThermoPhase.h:142
doublereal enthalpy_mass() const
Specific enthalpy.
Definition: ThermoPhase.h:892
virtual void getdPartialMolarVolumes_dP(doublereal *d_vbar_dP) const
Return an array of derivatives of partial molar volumes wrt pressure for the species in the mixture...
Definition: ThermoPhase.h:652
virtual std::string report(bool show_thermo=true, doublereal threshold=-1e-14) const
returns a summary of the state of the phase as a string
virtual void setParametersFromXML(const XML_Node &eosdata)
Set equation of state parameter values from XML entries.
Definition: ThermoPhase.h:1470
doublereal meanMolecularWeight() const
The mean molecular weight. Units: (kg/kmol)
Definition: Phase.h:669
const doublereal GasConstant
Universal Gas Constant. [J/kmol/K].
Definition: ct_defs.h:64
virtual void modifyOneHf298SS(const size_t k, const doublereal Hf298New)
Modify the value of the 298 K Heat of Formation of one species in the phase (J kmol-1) ...
Definition: ThermoPhase.h:190
virtual void getActivityCoefficients(doublereal *ac) const
Get the array of non-dimensional molar-based activity coefficients at the current solution temperatur...
Definition: ThermoPhase.h:512
virtual void setState_PX(doublereal p, doublereal *x)
Set the pressure (Pa) and mole fractions.
virtual int activityConvention() const
This method returns the convention used in specification of the activities, of which there are curren...
const int cSS_CONVENTION_VPSS
Standard state uses the molality convention.
Definition: ThermoPhase.h:36
const std::vector< const XML_Node * > & speciesData() const
Return a pointer to the vector of XML nodes containing the species data for this phase.
std::vector< doublereal > xMol_Ref
Reference Mole Fraction Composition.
Definition: ThermoPhase.h:1653
virtual void modifyOneHf298(const size_t k, const doublereal Hf298New)=0
Modify the value of the 298 K Heat of Formation of the standard state of one species in the phase (J ...
virtual void getCp_R_ref(doublereal *cprt) const
Returns the vector of nondimensional constant pressure heat capacities of the reference state at the ...
Definition: ThermoPhase.h:849
virtual void getPartialMolarEnthalpies(doublereal *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.
Definition: ThermoPhase.h:587
virtual doublereal cp_mole() const
Molar heat capacity at constant pressure. Units: J/kmol/K.
Definition: ThermoPhase.h:247
virtual void setParameters(int n, doublereal *const c)
Set the equation of state parameters.
Definition: ThermoPhase.h:1445
void setElementPotentials(const vector_fp &lambda)
Stores the element potentials in the ThermoPhase object.
virtual SpeciesThermo & speciesThermo(int k=-1)
Return a changeable reference to the calculation manager for species reference-state thermodynamic pr...
virtual doublereal logStandardConc(size_t k=0) const
Natural logarithm of the standard concentration of the kth species.
size_t m_kk
Number of species in the phase.
Definition: Phase.h:843
virtual void getdlnActCoeffdlnN(const size_t ld, doublereal *const dlnActCoeffdlnN)
Get the array of derivatives of the log activity coefficients with respect to the log of the species ...
virtual void getPartialMolarCp(doublereal *cpbar) const
Return an array of partial molar heat capacities for the species in the mixture.
Definition: ThermoPhase.h:618
virtual void setToEquilState(const doublereal *lambda_RT)
This method is used by the ChemEquil equilibrium solver.
Definition: ThermoPhase.h:1186
void setSpeciesThermo(SpeciesThermo *spthermo)
Install a species thermodynamic property manager.
virtual void initThermoFile(const std::string &inputFile, const std::string &id)
virtual void setState_Tsat(doublereal t, doublereal x)
Set the state to a saturated system at a particular temperature.
Definition: ThermoPhase.h:1287
virtual ~ThermoPhase()
Destructor. Deletes the species thermo manager.
Definition: ThermoPhase.cpp:38
virtual doublereal satTemperature(doublereal p) const
Return the saturation temperature given the pressure.
Definition: ThermoPhase.h:1265
virtual void getIntEnergy_RT_ref(doublereal *urt) const
Returns the vector of nondimensional internal Energies of the reference state at the current temperat...
Definition: ThermoPhase.h:836
bool m_hasElementPotentials
Boolean indicating whether there is a valid set of saved element potentials for this phase...
Definition: ThermoPhase.h:1631
void getElectrochemPotentials(doublereal *mu) const
Get the species electrochemical potentials.
Definition: ThermoPhase.h:573
SpeciesThermo * m_spthermo
Pointer to the calculation manager for species reference-state thermodynamic properties.
Definition: ThermoPhase.h:1607
virtual doublereal reportOneHf298(const size_t k) const =0
Report the 298 K Heat of Formation of the standard state of one species (J kmol-1) ...
virtual void getGibbs_RT(doublereal *grt) const
Get the nondimensional Gibbs functions for the species in their standard states at the current T and ...
Definition: ThermoPhase.h:700
const int cSS_CONVENTION_SLAVE
Standard state thermodynamics is obtained from slave ThermoPhase objects.
Definition: ThermoPhase.h:38
virtual doublereal minTemp(size_t k=npos) const
Minimum temperature for which the thermodynamic data for the species or phase are valid...
Definition: ThermoPhase.h:166
doublereal charge(size_t k) const
Dimensionless electrical charge of a single molecule of species k The charge is normalized by the the...
Definition: Phase.h:578