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