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