Cantera  3.1.0a1
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 https://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/Units.h"
17 #include "cantera/base/AnyMap.h"
18 
19 namespace Cantera
20 {
21 
22 /**
23  * @defgroup thermoprops Thermodynamic Properties
24  *
25  * These classes are used to compute the thermodynamic properties of phases of matter.
26  * The main base class for describing thermodynamic properties of phases within %Cantera
27  * is called ThermoPhase. %ThermoPhase is a large class that describes the interface
28  * within %Cantera to thermodynamic functions for a phase.
29  *
30  * ## Categorizing the Different ThermoPhase Objects
31  *
32  * ThermoPhase objects may be cataloged into four general bins.
33  *
34  * The first type are those whose underlying species have a reference state associated
35  * with them. The reference state describes the thermodynamic functions for a species at
36  * a single reference pressure, @f$ p_0 @f$. The thermodynamic functions are specified
37  * via derived objects of the SpeciesThermoInterpType object class, and usually consist
38  * of polynomials in temperature such as the NASA polynomial or the Shomate polynomial.
39  * Calculators for these reference states, which manage the calculation for all of the
40  * species in a phase, are all derived from the virtual base class
41  * SpeciesThermoInterpType. Calculators are needed because the actual calculation of the
42  * reference state thermodynamics has been shown to be relatively expensive. A great
43  * deal of work has gone into devising efficient schemes for calculating the
44  * thermodynamic polynomials of a set of species in a phase, in particular gas species
45  * in ideal gas phases whose reference state thermodynamics is specified by NASA
46  * polynomials.
47  *
48  * The reference state thermodynamics combined with the mixing rules and an assumption
49  * about the pressure dependence yields the thermodynamic functions for the phase.
50  * Expressions involving the specification of the fugacities of species would fall into
51  * this category of %ThermoPhase objects. Note, however, that at this time, we do not
52  * have any nontrivial examples of these types of phases. In general, the independent
53  * variables that completely describe the state of the system for this class are
54  * temperature, the phase density, and @f$ N - 1 @f$ species mole or mass fractions.
55  * Additionally, if the phase involves charged species, the phase electric potential is
56  * an added independent variable. Examples of this first class of %ThermoPhase models,
57  * which includes the IdealGasPhase object, the most commonly used object with %Cantera,
58  * include:
59  *
60  * - IdealGasPhase
61  * - StoichSubstance
62  * - SurfPhase
63  * - EdgePhase
64  * - LatticePhase
65  * - LatticeSolidPhase
66  * - PureFluidPhase
67  * - IdealSolidSolnPhase
68  * - VPStandardStateTP
69  *
70  * The second class of objects are all derivatives of the VPStandardStateTP class listed
71  * above. These classes assume that there exists a standard state for each species in
72  * the phase, where the thermodynamic functions are specified as a function of
73  * temperature and pressure. Standard state objects for each species are all derived
74  * from the PDSS virtual base class. In turn, these standard states may employ reference
75  * state calculation to aid in their calculations. However, there are some PDSS objects
76  * which do not employ reference state calculations. An example of this is real equation
77  * of state for liquid water used within the calculation of brine thermodynamics. In
78  * general, the independent variables that completely describe the state of the system
79  * for this class are temperature, the phase pressure, and @f$ N - 1 @f$ species mole or
80  * mass fractions or molalities. The standard state thermodynamics combined with the
81  * mixing rules yields the thermodynamic functions for the phase. Mixing rules are given
82  * in terms of specifying the molar-base activity coefficients or activities. Lists of
83  * phases which belong to this group are given below
84  *
85  * - IdealSolnGasVPSS
86  * - MolalityVPSSTP
87  *
88  * Note, the ideal gas and ideal solution approximations are lumped together in the
89  * class IdealSolnGasVPSS, because at this level they look alike having the same mixing
90  * rules with respect to the specification of the excess thermodynamic properties.
91  *
92  * The third class of objects are all derivatives of the MolalityVPSSTP object. They
93  * assume that the standard states are temperature and pressure dependent but they also
94  * assume that the standard states are molality-based. In other words, they assume that
95  * the standard state of the solute species are in a pseudo state of 1 molality but at
96  * infinite dilution. A solvent must be specified in these calculations, defined as the
97  * first species in the phase, and its standard state is the pure solvent state. Phases
98  * which belong to this group include:
99  *
100  * - DebyeHuckel
101  * - IdealMolalSoln
102  * - HMWSoln
103  *
104  * The fourth class of %ThermoPhase objects are stoichiometric phases. Stoichiometric
105  * phases are phases which consist of one and only one species. The class
106  * SingleSpeciesTP is the base class for these substances. Within the class, the general
107  * %ThermoPhase interface is dumbed down so that phases consisting of one species may be
108  * succinctly described. These phases may have PDSS classes or SpeciesThermoInterpType
109  * calculators associated with them. In general, the independent variables that
110  * completely describe the state of the system for this class are temperature and either
111  * the phase density or the phase pressure. Classes in this group include:
112  *
113  * - StoichSubstance
114  * - WaterSSTP
115  *
116  * ## Creating ThermoPhase objects
117  *
118  * Instances of subclasses of ThermoPhase should be created using the factory methods
119  * newThermo(const string&, const string&), newThermo(const AnyMap&, const AnyMap&), or
120  * newThermoModel(). This allows new classes to be used with the various %Cantera
121  * language interfaces.
122  *
123  * ## Defining new thermodynamic models
124  *
125  * To implement a new equation of state, derive a class from ThermoPhase or a relevant
126  * existing derived class and overload the virtual methods in ThermoPhase. Methods that
127  * are not needed can be left unimplemented, which will cause an exception to be thrown
128  * if they are called.
129  */
130 
131 //! @name CONSTANTS - Specification of the Molality convention
132 //! @{
133 
134 //! Standard state uses the molar convention
135 const int cAC_CONVENTION_MOLAR = 0;
136 //! Standard state uses the molality convention
138 
139 //! @}
140 //! @name CONSTANTS - Specification of the SS convention
141 //! @{
142 
143 //! Standard state uses the molar convention
145 //! Standard state uses the molality convention
146 const int cSS_CONVENTION_VPSS = 1;
147 //! Standard state thermodynamics is obtained from slave ThermoPhase objects
148 const int cSS_CONVENTION_SLAVE = 2;
149 //! @}
150 
151 //! Differentiate between mole fractions and mass fractions for input mixture
152 //! composition
153 enum class ThermoBasis
154 {
155  mass,
156  molar
157 };
158 
159 //! Base class for a phase with thermodynamic properties.
160 /*!
161  * Class ThermoPhase is the base class for the family of classes that represent
162  * phases of matter of any type. It defines a common public interface, and
163  * implements a few methods. Most of the methods, however, are declared virtual
164  * and are meant to be overloaded in derived classes. The standard way used
165  * throughout %Cantera to compute properties of phases of matter is through
166  * pointers of type `ThermoPhase*` that point to objects of subclasses of
167  * ThermoPhase.
168  *
169  * Class ThermoPhase extends class Phase by adding methods to compute
170  * thermodynamic properties in addition to the ones that are used to define the
171  * state of a substance (temperature, density/pressure and composition). The
172  * distinction is that the methods declared in ThermoPhase require knowing the
173  * particular equation of state of the phase of interest, while those of class
174  * Phase do not, since they only involve data values stored within the object.
175  *
176  * ## Calculating and accessing thermodynamic properties
177  *
178  * The calculation of thermodynamic functions within %ThermoPhase is broken down roughly
179  * into two or more steps. First, the standard state properties of all of the species
180  * are calculated at the current temperature and at either the current pressure or at a
181  * reference pressure. If the calculation is carried out at a reference pressure instead
182  * of at the current pressure the calculation is called a "reference state properties"
183  * calculation, just to make the distinction (even though it may be considered to be a
184  * fixed-pressure standard-state calculation). The next step is to adjust the reference
185  * state calculation to the current pressure. The thermodynamic functions then are
186  * considered to be at the standard state of each species. Lastly the mixing
187  * contributions are added to arrive at the thermodynamic functions for the solution.
188  *
189  * The %ThermoPhase class provides interfaces to thermodynamic properties calculated for
190  * the reference state of each species, the standard state values for each species, the
191  * thermodynamic functions for solution values, both on a per mole of solution basis
192  * (such as ThermoPhase::enthalpy_mole()), on a per kg of solution basis, and on a
193  * partial molar basis for each species (such as
194  * ThermoPhase::getPartialMolarEnthalpies). At each level, functions for the enthalpy,
195  * entropy, Gibbs free energy, internal energy, and volume are provided. So, 5 levels
196  * (reference state, standard state, partial molar, per mole of solution, and per mass
197  * of solution) and 5 functions multiplied together makes 25 possible functions. That's
198  * why %ThermoPhase is such a large class.
199  *
200  * ## Setting the State of the phase
201  *
202  * Typically, the way the ThermoPhase object works is that there are a set of functions
203  * that set the state of the phase via setting the internal independent variables. Then,
204  * there are another set of functions that query the thermodynamic functions evaluated
205  * at the current %State of the phase. Internally, most of the intermediate work
206  * generally occurs at the point where the internal state of the system is set and not
207  * at the time when individual thermodynamic functions are queried (though the actual
208  * breakdown in work is dependent on the individual derived ThermoPhase object).
209  * Therefore, for efficiency, the user should lump together queries of thermodynamic
210  * functions after setting the state. Moreover, in setting the state, if the density is
211  * the independent variable, the following order should be used:
212  *
213  * - Set the temperature
214  * - Set the mole or mass fractions or set the molalities
215  * - set the pressure.
216  *
217  * For classes which inherit from VPStandardStateTP, the above order may be used, or the
218  * following order may be used. It's not important.
219  *
220  * - Set the temperature
221  * - Set the pressure
222  * - Set the mole or mass fractions or set the molalities
223  *
224  * See the @ref sec-thermophase-set-state "list of methods" that can be used to set
225  * the complete state of ThermoPhase objects.
226  *
227  * ## Treatment of the phase potential and the electrochemical potential of a species
228  *
229  * The electrochemical potential of species k in a phase p, @f$ \zeta_k @f$, is related
230  * to the chemical potential as:
231  *
232  * @f[
233  * \zeta_{k}(T,P) = \mu_{k}(T,P) + z_k \phi_p
234  * @f]
235  *
236  * where @f$ \nu_k @f$ is the charge of species k, and @f$ \phi_p @f$ is the electric
237  * potential of phase p.
238  *
239  * The potential @f$ \phi_p @f$ is tracked and internally stored within the base
240  * ThermoPhase object. It constitutes a specification of the internal state of the
241  * phase; it's the third state variable, the first two being temperature and density
242  * (or, pressure, for incompressible equations of state). It may be set with the
243  * function, setElectricPotential(), and may be queried with the function
244  * electricPotential().
245  *
246  * Note, the overall electrochemical potential of a phase may not be changed by the
247  * potential because many phases enforce charge neutrality:
248  *
249  * @f[
250  * 0 = \sum_k z_k X_k
251  * @f]
252  *
253  * Whether charge neutrality is necessary for a phase is also specified within the
254  * ThermoPhase object, by the function call chargeNeutralityNecessary(). Note, that it
255  * is not necessary for the ideal gas phase, currently. However, it is necessary for
256  * liquid phases such as DebyeHuckel and HMWSoln for the proper specification of the
257  * chemical potentials.
258  *
259  * This equation, when applied to the @f$ \zeta_k @f$ equation described above, results
260  * in a zero net change in the effective Gibbs free energy of the phase. However,
261  * specific charged species in the phase may increase or decrease their electrochemical
262  * potentials, which will have an effect on interfacial reactions involving charged
263  * species, when there is a potential drop between phases. This effect is used within
264  * the InterfaceKinetics and EdgeKinetics classes.
265  *
266  * ## Specification of Activities and Activity Conventions
267  *
268  * The activity @f$ a_k @f$ and activity coefficient @f$ \gamma_k @f$ of a species in
269  * solution is related to the chemical potential by
270  *
271  * @f[
272  * \mu_k = \mu_k^0(T,P) + \hat R T \ln a_k = \mu_k^0(T,P) + \hat R T \ln x_k \gamma_k
273  * @f]
274  *
275  * The quantity @f$ \mu_k^0(T,P) @f$ is the standard chemical potential at unit
276  * activity, which depends on the temperature and pressure, but not on the composition.
277  * The activity is dimensionless. Within liquid electrolytes it's common to use a
278  * molality convention, where solute species employ the molality-based activity
279  * coefficients:
280  *
281  * @f[
282  * \mu_k = \mu_k^\triangle(T,P) + R T \ln a_k^{\triangle} =
283  * \mu_k^\triangle(T,P) + R T \ln \frac{\gamma_k^{\triangle} m_k}{m^\triangle}
284  * @f]
285  *
286  * And the solvent employs the convention
287  * @f[
288  * \mu_o = \mu^o_o(T,P) + RT \ln a_o
289  * @f]
290  *
291  * where @f$ a_o @f$ is often redefined in terms of the osmotic coefficient @f$ \phi
292  * @f$:
293  *
294  * @f[
295  * \phi = \frac{- \ln a_o}{\tilde{M}_o \sum_{i \ne o} m_i}
296  * @f]
297  *
298  * ThermoPhase classes which employ the molality based convention are all derived from
299  * the MolalityVPSSTP class. See the class description for further information on its
300  * capabilities.
301  *
302  * The activity convention used by a ThermoPhase object may be queried via the
303  * activityConvention() function. A zero means molar based, while a one
304  * means molality based.
305  *
306  * The function getActivities() returns a vector of activities. Whether these are
307  * molar-based or molality-based depends on the value of activityConvention().
308  *
309  * The function getActivityCoefficients() always returns molar-based activity
310  * coefficients regardless of the activity convention used. The function
311  * MolalityVPSSTP::getMolalityActivityCoefficients() returns molality
312  * based activity coefficients for those ThermoPhase objects derived
313  * from the MolalityVPSSTP class. The function MolalityVPSSTP::osmoticCoefficient()
314  * returns the osmotic coefficient.
315 
316  * ## Activity Concentrations: Relationship of ThermoPhase to Kinetics Expressions
317  *
318  * %Cantera can handle both thermodynamics and kinetics mechanisms. Reversible kinetics
319  * mechanisms within %Cantera must be compatible with thermodynamics in the sense that
320  * at equilibrium, or at infinite times, the concentrations of species must conform to
321  * thermodynamics. This means that for every valid reversible kinetics reaction in a
322  * mechanism, it must be reducible to an expression involving the ratio of the product
323  * activity to the reactant activities being equal to the exponential of the
324  * dimensionless standard state gibbs free energies of reaction. Irreversible kinetics
325  * reactions do not have this requirement; however, their usage can yield unexpected and
326  * inconsistent results in many situations.
327  *
328  * The actual units used in a kinetics expression depend on the context or the relative
329  * field of study. For example, in gas phase kinetics, species in kinetics expressions
330  * are expressed in terms of concentrations, for example, gmol cm-3. In solid phase
331  * studies, however, kinetics is usually expressed in terms of unitless activities,
332  * which most often equate to solid phase mole fractions. In order to accommodate
333  * variability here, %Cantera has come up with the idea of activity concentrations,
334  * @f$ C^a_k @f$. Activity concentrations are the expressions used directly in kinetics
335  * expressions. These activity (or generalized) concentrations are used by kinetics
336  * manager classes to compute the forward and reverse rates of elementary reactions.
337  * Note that they may or may not have units of concentration --- they might be partial
338  * pressures, mole fractions, or surface coverages, The activity concentrations for
339  * species *k*, @f$ C^a_k @f$, are related to the activity for species *k*, @f$ a_k @f$,
340  * via the expression:
341  *
342  * @f[
343  * a_k = C^a_k / C^0_k
344  * @f]
345  *
346  * @f$ C^0_k @f$ are called standard concentrations. They serve as multiplicative
347  * factors between the activities and the generalized concentrations. Standard
348  * concentrations may be different for each species. They may depend on both the
349  * temperature and the pressure. However, they may not depend on the composition of the
350  * phase. For example, for the IdealGasPhase object the standard concentration is
351  * defined as
352  *
353  * @f[
354  * C^0_k = \frac{P}{RT}
355  * @f]
356  *
357  * while in many solid phase kinetics problems,
358  *
359  * @f[
360  * C^0_k = 1.0
361  * @f]
362  *
363  * is employed making the units for activity concentrations in solids unitless.
364  *
365  * ThermoPhase member functions dealing with this concept include
366  * getActivityConcentrations(), which provides a vector of the current activity
367  * concentrations. The function standardConcentration() returns the standard
368  * concentration of the kth species. The function logStandardConc(), returns the natural
369  * log of the kth standard concentration. The function standardConcentrationUnits()
370  * returns the units of the standard concentration.
371  *
372  * ### Equilibrium constants
373  *
374  * - @f$ K_a @f$ is the equilibrium constant defined in terms of the standard state
375  * Gibbs free energy values. It is by definition dimensionless.
376  *
377  * - @f$ K_p @f$ is the equilibrium constant defined in terms of the reference state
378  * Gibbs free energy values. It is by definition dimensionless. The pressure
379  * dependence is handled entirely on the RHS of the equilibrium expression.
380  *
381  * - @f$ K_c @f$ is the equilibrium constant defined in terms of the activity
382  * concentrations. The dimensions depend on the number of products and reactants.
383  *
384  * The kinetics manager requires the calculation of @f$ K_c @f$ for the calculation of
385  * the reverse rate constant.
386  *
387  * @ingroup thermoprops
388  */
389 class ThermoPhase : public Phase
390 {
391 public:
392  //! Constructor. Note that ThermoPhase is meant to be used as a base class,
393  //! so this constructor should not be called explicitly.
394  ThermoPhase() = default;
395 
396  //! @name Information Methods
397  //! @{
398 
399  string type() const override {
400  return "none";
401  }
402 
403  //! Boolean indicating whether phase is ideal
404  virtual bool isIdeal() const {
405  return false;
406  }
407 
408  //! String indicating the mechanical phase of the matter in this Phase.
409  /*!
410  * Options for the string are:
411  * * `unspecified`
412  * * `supercritical`
413  * * `gas`
414  * * `liquid`
415  * * `solid`
416  * * `solid-liquid-mix`
417  * * `solid-gas-mix`
418  * * `liquid-gas-mix`
419  * * `solid-liquid-gas-mix`
420  *
421  * `unspecified` is the default and should be used when the Phase does not
422  * distinguish between mechanical phases or does not have enough information to
423  * determine which mechanical phase(s) are present.
424  *
425  * @todo Needs to be implemented for all phase types. Currently only implemented for
426  * PureFluidPhase.
427  */
428  virtual string phaseOfMatter() const {
429  return "unspecified";
430  }
431 
432  /**
433  * Returns the reference pressure in Pa. This function is a wrapper
434  * that calls the species thermo refPressure function.
435  */
436  virtual double refPressure() const {
437  return m_spthermo.refPressure();
438  }
439 
440  //! Minimum temperature for which the thermodynamic data for the species
441  //! or phase are valid.
442  /*!
443  * If no argument is supplied, the value returned will be the lowest
444  * temperature at which the data for @e all species are valid. Otherwise,
445  * the value will be only for species @e k. This function is a wrapper that
446  * calls the species thermo minTemp function.
447  *
448  * @param k index of the species. Default is -1, which will return the max
449  * of the min value over all species.
450  */
451  virtual double minTemp(size_t k = npos) const {
452  return m_spthermo.minTemp(k);
453  }
454 
455  //! Report the 298 K Heat of Formation of the standard state of one species
456  //! (J kmol-1)
457  /*!
458  * The 298K Heat of Formation is defined as the enthalpy change to create
459  * the standard state of the species from its constituent elements in their
460  * standard states at 298 K and 1 bar.
461  *
462  * @param k species index
463  * @returns the current value of the Heat of Formation at 298K
464  * and 1 bar
465  */
466  double Hf298SS(const size_t k) const {
467  return m_spthermo.reportOneHf298(k);
468  }
469 
470  //! Modify the value of the 298 K Heat of Formation of one species in the
471  //! phase (J kmol-1)
472  /*!
473  * The 298K heat of formation is defined as the enthalpy change to create
474  * the standard state of the species from its constituent elements in their
475  * standard states at 298 K and 1 bar.
476  *
477  * @param k Species k
478  * @param Hf298New Specify the new value of the Heat of Formation at
479  * 298K and 1 bar
480  */
481  virtual void modifyOneHf298SS(const size_t k, const double Hf298New) {
482  m_spthermo.modifyOneHf298(k, Hf298New);
483  invalidateCache();
484  }
485 
486  //! Restore the original heat of formation of one or more species
487  /*!
488  * Resets changes made by modifyOneHf298SS(). If the species index is not
489  * specified, the heats of formation for all species are restored.
490  */
491  virtual void resetHf298(const size_t k=npos);
492 
493  //! Maximum temperature for which the thermodynamic data for the species
494  //! are valid.
495  /*!
496  * If no argument is supplied, the value returned will be the highest
497  * temperature at which the data for @e all species are valid. Otherwise,
498  * the value will be only for species @e k. This function is a wrapper that
499  * calls the species thermo maxTemp function.
500  *
501  * @param k index of the species. Default is -1, which will return the min
502  * of the max value over all species.
503  */
504  virtual double maxTemp(size_t k = npos) const {
505  return m_spthermo.maxTemp(k);
506  }
507 
508  //! Returns the chargeNeutralityNecessity boolean
509  /*!
510  * Some phases must have zero net charge in order for their thermodynamics
511  * functions to be valid. If this is so, then the value returned from this
512  * function is true. If this is not the case, then this is false. Now, ideal
513  * gases have this parameter set to false, while solution with molality-
514  * based activity coefficients have this parameter set to true.
515  */
518  }
519 
520  //! @}
521  //! @name Molar Thermodynamic Properties of the Solution
522  //! @{
523 
524  //! Molar enthalpy. Units: J/kmol.
525  virtual double enthalpy_mole() const {
526  throw NotImplementedError("ThermoPhase::enthalpy_mole");
527  }
528 
529  //! Molar internal energy. Units: J/kmol.
530  virtual double intEnergy_mole() const {
531  return enthalpy_mole() - pressure()* molarVolume();
532  }
533 
534  //! Molar entropy. Units: J/kmol/K.
535  virtual double entropy_mole() const {
536  throw NotImplementedError("ThermoPhase::entropy_mole");
537  }
538 
539  //! Molar Gibbs function. Units: J/kmol.
540  virtual double gibbs_mole() const {
541  return enthalpy_mole() - temperature()*entropy_mole();
542  }
543 
544  //! Molar heat capacity at constant pressure. Units: J/kmol/K.
545  virtual double cp_mole() const {
546  throw NotImplementedError("ThermoPhase::cp_mole");
547  }
548 
549  //! Molar heat capacity at constant volume. Units: J/kmol/K.
550  virtual double cv_mole() const {
551  throw NotImplementedError("ThermoPhase::cv_mole");
552  }
553 
554  //! @}
555  //! @name Mechanical Properties
556  //! @{
557 
558  //! Returns the isothermal compressibility. Units: 1/Pa.
559  /*!
560  * The isothermal compressibility is defined as
561  * @f[
562  * \kappa_T = -\frac{1}{v}\left(\frac{\partial v}{\partial P}\right)_T
563  * @f]
564  * or
565  * @f[
566  * \kappa_T = \frac{1}{\rho}\left(\frac{\partial \rho}{\partial P}\right)_T
567  * @f]
568  */
569  virtual double isothermalCompressibility() const {
570  throw NotImplementedError("ThermoPhase::isothermalCompressibility");
571  }
572 
573  //! Return the volumetric thermal expansion coefficient. Units: 1/K.
574  /*!
575  * The thermal expansion coefficient is defined as
576  * @f[
577  * \beta = \frac{1}{v}\left(\frac{\partial v}{\partial T}\right)_P
578  * @f]
579  */
580  virtual double thermalExpansionCoeff() const {
581  throw NotImplementedError("ThermoPhase::thermalExpansionCoeff");
582  }
583 
584  //! Return the speed of sound. Units: m/s.
585  /*!
586  * The speed of sound is defined as
587  * @f[
588  * c = \sqrt{\left(\frac{\partial P}{\partial\rho}\right)_s}
589  * @f]
590  */
591  virtual double soundSpeed() const {
592  throw NotImplementedError("ThermoPhase::soundSpeed");
593  }
594 
595  //! @}
596  //! @name Electric Potential
597  //!
598  //! The phase may be at some non-zero electrical potential. These methods
599  //! set or get the value of the electric potential.
600  //! @{
601 
602  //! Set the electric potential of this phase (V).
603  /*!
604  * This is used by classes InterfaceKinetics and EdgeKinetics to
605  * compute the rates of charge-transfer reactions, and in computing
606  * the electrochemical potentials of the species.
607  *
608  * Each phase may have its own electric potential.
609  *
610  * @param v Input value of the electric potential in Volts
611  */
612  void setElectricPotential(double v) {
613  m_phi = v;
614  invalidateCache();
615  }
616 
617  //! Returns the electric potential of this phase (V).
618  /*!
619  * Units are Volts (which are Joules/coulomb)
620  */
621  double electricPotential() const {
622  return m_phi;
623  }
624 
625  //! @}
626  //! @name Activities, Standard States, and Activity Concentrations
627  //!
628  //! The activity @f$ a_k @f$ of a species in solution is related to the
629  //! chemical potential by @f[ \mu_k = \mu_k^0(T,P) + \hat R T \ln a_k. @f]
630  //! The quantity @f$ \mu_k^0(T,P) @f$ is the standard chemical potential at
631  //! unit activity, which depends on temperature and pressure, but not on
632  //! composition. The activity is dimensionless.
633  //! @{
634 
635  //! This method returns the convention used in specification of the
636  //! activities, of which there are currently two, molar- and molality-based
637  //! conventions.
638  /*!
639  * Currently, there are two activity conventions:
640  * - Molar-based activities
641  * %Unit activity of species at either a hypothetical pure
642  * solution of the species or at a hypothetical
643  * pure ideal solution at infinite dilution
644  * cAC_CONVENTION_MOLAR 0
645  * - default
646  *
647  * - Molality-based activities
648  * (unit activity of solutes at a hypothetical 1 molal
649  * solution referenced to infinite dilution at all
650  * pressures and temperatures).
651  * cAC_CONVENTION_MOLALITY 1
652  */
653  virtual int activityConvention() const;
654 
655  //! This method returns the convention used in specification of the standard
656  //! state, of which there are currently two, temperature based, and variable
657  //! pressure based.
658  /*!
659  * Currently, there are two standard state conventions:
660  * - Temperature-based activities
661  * cSS_CONVENTION_TEMPERATURE 0
662  * - default
663  *
664  * - Variable Pressure and Temperature -based activities
665  * cSS_CONVENTION_VPSS 1
666  *
667  * - Thermodynamics is set via slave ThermoPhase objects with
668  * nothing being carried out at this ThermoPhase object level
669  * cSS_CONVENTION_SLAVE 2
670  */
671  virtual int standardStateConvention() const;
672 
673  //! Returns the units of the "standard concentration" for this phase
674  /*!
675  * These are the units of the values returned by the functions
676  * getActivityConcentrations() and standardConcentration(), which can
677  * vary between different ThermoPhase-derived classes, or change within
678  * a single class depending on input options. See the documentation for
679  * standardConcentration() for the derived class for specific details.
680  */
681  virtual Units standardConcentrationUnits() const;
682 
683  //! This method returns an array of generalized concentrations
684  /*!
685  * @f$ C^a_k @f$ are defined such that @f$ a_k = C^a_k / C^0_k, @f$ where
686  * @f$ C^0_k @f$ is a standard concentration defined below and @f$ a_k @f$
687  * are activities used in the thermodynamic functions. These activity (or
688  * generalized) concentrations are used by kinetics manager classes to
689  * compute the forward and reverse rates of elementary reactions. Note that
690  * they may or may not have units of concentration --- they might be partial
691  * pressures, mole fractions, or surface coverages, for example.
692  *
693  * @param c Output array of generalized concentrations. The units depend
694  * upon the implementation of the reaction rate expressions within
695  * the phase.
696  */
697  virtual void getActivityConcentrations(double* c) const {
698  throw NotImplementedError("ThermoPhase::getActivityConcentrations");
699  }
700 
701  //! Return the standard concentration for the kth species
702  /*!
703  * The standard concentration @f$ C^0_k @f$ used to normalize the activity
704  * (that is, generalized) concentration. In many cases, this quantity will be
705  * the same for all species in a phase - for example, for an ideal gas @f$
706  * C^0_k = P/\hat R T @f$. For this reason, this method returns a single
707  * value, instead of an array. However, for phases in which the standard
708  * concentration is species-specific (such as surface species of different
709  * sizes), this method may be called with an optional parameter indicating
710  * the species.
711  *
712  * @param k Optional parameter indicating the species. The default
713  * is to assume this refers to species 0.
714  * @return
715  * Returns the standard concentration. The units are by definition
716  * dependent on the ThermoPhase and kinetics manager representation.
717  */
718  virtual double standardConcentration(size_t k=0) const {
719  throw NotImplementedError("ThermoPhase::standardConcentration");
720  }
721 
722  //! Natural logarithm of the standard concentration of the kth species.
723  /*!
724  * @param k index of the species (defaults to zero)
725  */
726  virtual double logStandardConc(size_t k=0) const;
727 
728  //! Get the array of non-dimensional activities at the current solution
729  //! temperature, pressure, and solution concentration.
730  /*!
731  * Note, for molality based formulations, this returns the molality based
732  * activities.
733  *
734  * We resolve this function at this level by calling on the
735  * activityConcentration function. However, derived classes may want to
736  * override this default implementation.
737  *
738  * @param a Output vector of activities. Length: m_kk.
739  */
740  virtual void getActivities(double* a) const;
741 
742  //! Get the array of non-dimensional molar-based activity coefficients at
743  //! the current solution temperature, pressure, and solution concentration.
744  /*!
745  * @param ac Output vector of activity coefficients. Length: m_kk.
746  */
747  virtual void getActivityCoefficients(double* ac) const {
748  if (m_kk == 1) {
749  ac[0] = 1.0;
750  } else {
751  throw NotImplementedError("ThermoPhase::getActivityCoefficients");
752  }
753  }
754 
755  //! Get the array of non-dimensional molar-based ln activity coefficients at
756  //! the current solution temperature, pressure, and solution concentration.
757  /*!
758  * @param lnac Output vector of ln activity coefficients. Length: m_kk.
759  */
760  virtual void getLnActivityCoefficients(double* lnac) const;
761 
762  //! @}
763  //! @name Partial Molar Properties of the Solution
764  //! @{
765 
766  //! Get the species chemical potentials. Units: J/kmol.
767  /*!
768  * This function returns a vector of chemical potentials of the species in
769  * solution at the current temperature, pressure and mole fraction of the
770  * solution.
771  *
772  * @param mu Output vector of species chemical
773  * potentials. Length: m_kk. Units: J/kmol
774  */
775  virtual void getChemPotentials(double* mu) const {
776  throw NotImplementedError("ThermoPhase::getChemPotentials");
777  }
778 
779  //! Get the species electrochemical potentials.
780  /*!
781  * These are partial molar quantities. This method adds a term @f$ F z_k
782  * \phi_p @f$ to each chemical potential. The electrochemical potential of
783  * species k in a phase p, @f$ \zeta_k @f$, is related to the chemical
784  * potential via the following equation,
785  *
786  * @f[
787  * \zeta_{k}(T,P) = \mu_{k}(T,P) + F z_k \phi_p
788  * @f]
789  *
790  * @param mu Output vector of species electrochemical
791  * potentials. Length: m_kk. Units: J/kmol
792  */
793  void getElectrochemPotentials(double* mu) const;
794 
795  //! Returns an array of partial molar enthalpies for the species
796  //! in the mixture. Units (J/kmol)
797  /*!
798  * @param hbar Output vector of species partial molar enthalpies.
799  * Length: m_kk. units are J/kmol.
800  */
801  virtual void getPartialMolarEnthalpies(double* hbar) const {
802  throw NotImplementedError("ThermoPhase::getPartialMolarEnthalpies");
803  }
804 
805  //! Returns an array of partial molar entropies of the species in the
806  //! solution. Units: J/kmol/K.
807  /*!
808  * @param sbar Output vector of species partial molar entropies.
809  * Length = m_kk. units are J/kmol/K.
810  */
811  virtual void getPartialMolarEntropies(double* sbar) const {
812  throw NotImplementedError("ThermoPhase::getPartialMolarEntropies");
813  }
814 
815  //! Return an array of partial molar internal energies for the
816  //! species in the mixture. Units: J/kmol.
817  /*!
818  * @param ubar Output vector of species partial molar internal energies.
819  * Length = m_kk. units are J/kmol.
820  */
821  virtual void getPartialMolarIntEnergies(double* ubar) const {
822  throw NotImplementedError("ThermoPhase::getPartialMolarIntEnergies");
823  }
824 
825  //! Return an array of partial molar heat capacities for the
826  //! species in the mixture. Units: J/kmol/K
827  /*!
828  * @param cpbar Output vector of species partial molar heat
829  * capacities at constant pressure.
830  * Length = m_kk. units are J/kmol/K.
831  */
832  virtual void getPartialMolarCp(double* cpbar) const {
833  throw NotImplementedError("ThermoPhase::getPartialMolarCp");
834  }
835 
836  //! Return an array of partial molar volumes for the
837  //! species in the mixture. Units: m^3/kmol.
838  /*!
839  * @param vbar Output vector of species partial molar volumes.
840  * Length = m_kk. units are m^3/kmol.
841  */
842  virtual void getPartialMolarVolumes(double* vbar) const {
843  throw NotImplementedError("ThermoPhase::getPartialMolarVolumes");
844  }
845 
846  //! @}
847  //! @name Properties of the Standard State of the Species in the Solution
848  //! @{
849 
850  //! Get the array of chemical potentials at unit activity for the species at
851  //! their standard states at the current *T* and *P* of the solution.
852  /*!
853  * These are the standard state chemical potentials @f$ \mu^0_k(T,P)
854  * @f$. The values are evaluated at the current temperature and pressure of
855  * the solution
856  *
857  * @param mu Output vector of chemical potentials.
858  * Length: m_kk.
859  */
860  virtual void getStandardChemPotentials(double* mu) const {
861  throw NotImplementedError("ThermoPhase::getStandardChemPotentials");
862  }
863 
864  //! Get the nondimensional Enthalpy functions for the species at their
865  //! standard states at the current *T* and *P* of the solution.
866  /*!
867  * @param hrt Output vector of nondimensional standard state enthalpies.
868  * Length: m_kk.
869  */
870  virtual void getEnthalpy_RT(double* hrt) const {
871  throw NotImplementedError("ThermoPhase::getEnthalpy_RT");
872  }
873 
874  //! Get the array of nondimensional Entropy functions for the standard state
875  //! species at the current *T* and *P* of the solution.
876  /*!
877  * @param sr Output vector of nondimensional standard state entropies.
878  * Length: m_kk.
879  */
880  virtual void getEntropy_R(double* sr) const {
881  throw NotImplementedError("ThermoPhase::getEntropy_R");
882  }
883 
884  //! Get the nondimensional Gibbs functions for the species in their standard
885  //! states at the current *T* and *P* of the solution.
886  /*!
887  * @param grt Output vector of nondimensional standard state Gibbs free
888  * energies. Length: m_kk.
889  */
890  virtual void getGibbs_RT(double* grt) const {
891  throw NotImplementedError("ThermoPhase::getGibbs_RT");
892  }
893 
894  //! Get the Gibbs functions for the standard state of the species at the
895  //! current *T* and *P* of the solution
896  /*!
897  * Units are Joules/kmol
898  * @param gpure Output vector of standard state Gibbs free energies.
899  * Length: m_kk.
900  */
901  virtual void getPureGibbs(double* gpure) const {
902  throw NotImplementedError("ThermoPhase::getPureGibbs");
903  }
904 
905  //! Returns the vector of nondimensional Internal Energies of the standard
906  //! state species at the current *T* and *P* of the solution
907  /*!
908  * @param urt output vector of nondimensional standard state internal energies
909  * of the species. Length: m_kk.
910  */
911  virtual void getIntEnergy_RT(double* urt) const {
912  throw NotImplementedError("ThermoPhase::getIntEnergy_RT");
913  }
914 
915  //! Get the nondimensional Heat Capacities at constant pressure for the
916  //! species standard states at the current *T* and *P* of the
917  //! solution
918  /*!
919  * @param cpr Output vector of nondimensional standard state heat
920  * capacities. Length: m_kk.
921  */
922  virtual void getCp_R(double* cpr) const {
923  throw NotImplementedError("ThermoPhase::getCp_R");
924  }
925 
926  //! Get the molar volumes of the species standard states at the current
927  //! *T* and *P* of the solution.
928  /*!
929  * units = m^3 / kmol
930  *
931  * @param vol Output vector containing the standard state volumes.
932  * Length: m_kk.
933  */
934  virtual void getStandardVolumes(double* vol) const {
935  throw NotImplementedError("ThermoPhase::getStandardVolumes");
936  }
937 
938  //! @}
939  //! @name Thermodynamic Values for the Species Reference States
940  //! @{
941 
942  //! Returns the vector of nondimensional enthalpies of the reference state
943  //! at the current temperature of the solution and the reference pressure
944  //! for the species.
945  /*!
946  * @param hrt Output vector containing the nondimensional reference
947  * state enthalpies. Length: m_kk.
948  */
949  virtual void getEnthalpy_RT_ref(double* hrt) const {
950  throw NotImplementedError("ThermoPhase::getEnthalpy_RT_ref");
951  }
952 
953  //! Returns the vector of nondimensional Gibbs Free Energies of the
954  //! reference state at the current temperature of the solution and the
955  //! reference pressure for the species.
956  /*!
957  * @param grt Output vector containing the nondimensional reference state
958  * Gibbs Free energies. Length: m_kk.
959  */
960  virtual void getGibbs_RT_ref(double* grt) const {
961  throw NotImplementedError("ThermoPhase::getGibbs_RT_ref");
962  }
963 
964  //! Returns the vector of the Gibbs function of the reference state at the
965  //! current temperature of the solution and the reference pressure for the
966  //! species.
967  /*!
968  * @param g Output vector containing the reference state
969  * Gibbs Free energies. Length: m_kk. Units: J/kmol.
970  */
971  virtual void getGibbs_ref(double* g) const {
972  throw NotImplementedError("ThermoPhase::getGibbs_ref");
973  }
974 
975  //! Returns the vector of nondimensional entropies of the reference state at
976  //! the current temperature of the solution and the reference pressure for
977  //! each species.
978  /*!
979  * @param er Output vector containing the nondimensional reference
980  * state entropies. Length: m_kk.
981  */
982  virtual void getEntropy_R_ref(double* er) const {
983  throw NotImplementedError("ThermoPhase::getEntropy_R_ref");
984  }
985 
986  //! Returns the vector of nondimensional internal Energies of the reference
987  //! state at the current temperature of the solution and the reference
988  //! pressure for each species.
989  /*!
990  * @param urt Output vector of nondimensional reference state internal
991  * energies of the species. Length: m_kk
992  */
993  virtual void getIntEnergy_RT_ref(double* urt) const {
994  throw NotImplementedError("ThermoPhase::getIntEnergy_RT_ref");
995  }
996 
997  //! Returns the vector of nondimensional constant pressure heat capacities
998  //! of the reference state at the current temperature of the solution and
999  //! reference pressure for each species.
1000  /*!
1001  * @param cprt Output vector of nondimensional reference state
1002  * heat capacities at constant pressure for the species.
1003  * Length: m_kk
1004  */
1005  virtual void getCp_R_ref(double* cprt) const {
1006  throw NotImplementedError("ThermoPhase::getCp_R_ref");
1007  }
1008 
1009  //! Get the molar volumes of the species reference states at the current
1010  //! *T* and *P_ref* of the solution.
1011  /*!
1012  * units = m^3 / kmol
1013  *
1014  * @param vol Output vector containing the standard state volumes.
1015  * Length: m_kk.
1016  */
1017  virtual void getStandardVolumes_ref(double* vol) const {
1018  throw NotImplementedError("ThermoPhase::getStandardVolumes_ref");
1019  }
1020 
1021  // The methods below are not virtual, and should not be overloaded.
1022 
1023  //! @}
1024  //! @name Specific Properties
1025  //! @{
1026 
1027  //! Specific enthalpy. Units: J/kg.
1028  double enthalpy_mass() const {
1030  }
1031 
1032  //! Specific internal energy. Units: J/kg.
1033  double intEnergy_mass() const {
1035  }
1036 
1037  //! Specific entropy. Units: J/kg/K.
1038  double entropy_mass() const {
1039  return entropy_mole()/meanMolecularWeight();
1040  }
1041 
1042  //! Specific Gibbs function. Units: J/kg.
1043  double gibbs_mass() const {
1044  return gibbs_mole()/meanMolecularWeight();
1045  }
1046 
1047  //! Specific heat at constant pressure. Units: J/kg/K.
1048  double cp_mass() const {
1049  return cp_mole()/meanMolecularWeight();
1050  }
1051 
1052  //! Specific heat at constant volume. Units: J/kg/K.
1053  double cv_mass() const {
1054  return cv_mole()/meanMolecularWeight();
1055  }
1056  //! @}
1057 
1058  //! Return the Gas Constant multiplied by the current temperature
1059  /*!
1060  * The units are Joules kmol-1
1061  */
1062  double RT() const {
1063  return temperature() * GasConstant;
1064  }
1065 
1066  //! @name Setting the State
1067  //! @anchor sec-thermophase-set-state
1068  //!
1069  //! These methods set all or part of the thermodynamic state.
1070  //! @{
1071 
1072  //! Set the temperature (K), pressure (Pa), and mole fractions.
1073  /*!
1074  * Note, the mole fractions are set first before the pressure is set.
1075  * Setting the pressure may involve the solution of a nonlinear equation.
1076  *
1077  * @param t Temperature (K)
1078  * @param p Pressure (Pa)
1079  * @param x Vector of mole fractions.
1080  * Length is equal to m_kk.
1081  */
1082  virtual void setState_TPX(double t, double p, const double* x);
1083 
1084  //! Set the temperature (K), pressure (Pa), and mole fractions.
1085  /*!
1086  * Note, the mole fractions are set first before the pressure is set.
1087  * Setting the pressure may involve the solution of a nonlinear equation.
1088  *
1089  * @param t Temperature (K)
1090  * @param p Pressure (Pa)
1091  * @param x Composition map of mole fractions. Species not in
1092  * the composition map are assumed to have zero mole fraction
1093  */
1094  virtual void setState_TPX(double t, double p, const Composition& x);
1095 
1096  //! Set the temperature (K), pressure (Pa), and mole fractions.
1097  /*!
1098  * Note, the mole fractions are set first before the pressure is set.
1099  * Setting the pressure may involve the solution of a nonlinear equation.
1100  *
1101  * @param t Temperature (K)
1102  * @param p Pressure (Pa)
1103  * @param x String containing a composition map of the mole fractions.
1104  * Species not in the composition map are assumed to have zero
1105  * mole fraction
1106  */
1107  virtual void setState_TPX(double t, double p, const string& x);
1108 
1109  //! Set the internally stored temperature (K), pressure (Pa), and mass
1110  //! fractions of the phase.
1111  /*!
1112  * Note, the mass fractions are set first before the pressure is set.
1113  * Setting the pressure may involve the solution of a nonlinear equation.
1114  *
1115  * @param t Temperature (K)
1116  * @param p Pressure (Pa)
1117  * @param y Vector of mass fractions.
1118  * Length is equal to m_kk.
1119  */
1120  virtual void setState_TPY(double t, double p, const double* y);
1121 
1122  //! Set the internally stored temperature (K), pressure (Pa), and mass
1123  //! fractions of the phase
1124  /*!
1125  * Note, the mass fractions are set first before the pressure is set.
1126  * Setting the pressure may involve the solution of a nonlinear equation.
1127  *
1128  * @param t Temperature (K)
1129  * @param p Pressure (Pa)
1130  * @param y Composition map of mass fractions. Species not in
1131  * the composition map are assumed to have zero mass fraction
1132  */
1133  virtual void setState_TPY(double t, double p, const Composition& y);
1134 
1135  //! Set the internally stored temperature (K), pressure (Pa), and mass
1136  //! fractions of the phase
1137  /*!
1138  * Note, the mass fractions are set first before the pressure is set.
1139  * Setting the pressure may involve the solution of a nonlinear equation.
1140  *
1141  * @param t Temperature (K)
1142  * @param p Pressure (Pa)
1143  * @param y String containing a composition map of the mass fractions.
1144  * Species not in the composition map are assumed to have zero
1145  * mass fraction
1146  */
1147  virtual void setState_TPY(double t, double p, const string& y);
1148 
1149  //! Set the temperature (K) and pressure (Pa)
1150  /*!
1151  * Setting the pressure may involve the solution of a nonlinear equation.
1152  *
1153  * @param t Temperature (K)
1154  * @param p Pressure (Pa)
1155  */
1156  virtual void setState_TP(double t, double p);
1157 
1158  //! Set the internally stored specific enthalpy (J/kg) and pressure (Pa) of
1159  //! the phase.
1160  /*!
1161  * @param h Specific enthalpy (J/kg)
1162  * @param p Pressure (Pa)
1163  * @param tol Optional parameter setting the tolerance of the calculation.
1164  * Important for some applications where numerical Jacobians
1165  * are being calculated.
1166  */
1167  virtual void setState_HP(double h, double p, double tol=1e-9);
1168 
1169  //! Set the specific internal energy (J/kg) and specific volume (m^3/kg).
1170  /*!
1171  * This function fixes the internal state of the phase so that the specific
1172  * internal energy and specific volume have the value of the input
1173  * parameters.
1174  *
1175  * @param u specific internal energy (J/kg)
1176  * @param v specific volume (m^3/kg).
1177  * @param tol Optional parameter setting the tolerance of the calculation.
1178  * Important for some applications where numerical Jacobians
1179  * are being calculated.
1180  */
1181  virtual void setState_UV(double u, double v, double tol=1e-9);
1182 
1183  //! Set the specific entropy (J/kg/K) and pressure (Pa).
1184  /*!
1185  * This function fixes the internal state of the phase so that the specific
1186  * entropy and the pressure have the value of the input parameters.
1187  *
1188  * @param s specific entropy (J/kg/K)
1189  * @param p specific pressure (Pa).
1190  * @param tol Optional parameter setting the tolerance of the calculation.
1191  * Important for some applications where numerical Jacobians
1192  * are being calculated.
1193  */
1194  virtual void setState_SP(double s, double p, double tol=1e-9);
1195 
1196  //! Set the specific entropy (J/kg/K) and specific volume (m^3/kg).
1197  /*!
1198  * This function fixes the internal state of the phase so that the specific
1199  * entropy and specific volume have the value of the input parameters.
1200  *
1201  * @param s specific entropy (J/kg/K)
1202  * @param v specific volume (m^3/kg).
1203  * @param tol Optional parameter setting the tolerance of the calculation.
1204  * Important for some applications where numerical Jacobians
1205  * are being calculated.
1206  */
1207  virtual void setState_SV(double s, double v, double tol=1e-9);
1208 
1209  //! Set the specific entropy (J/kg/K) and temperature (K).
1210  /*!
1211  * This function fixes the internal state of the phase so that the specific
1212  * entropy and temperature have the value of the input parameters.
1213  * This base class function will throw an exception if not overridden.
1214  *
1215  * @param s specific entropy (J/kg/K)
1216  * @param t temperature (K)
1217  * @param tol Optional parameter setting the tolerance of the calculation.
1218  * Important for some applications where numerical Jacobians
1219  * are being calculated.
1220  */
1221  virtual void setState_ST(double s, double t, double tol=1e-9) {
1222  throw NotImplementedError("ThermoPhase::setState_ST");
1223  }
1224 
1225  //! Set the temperature (K) and specific volume (m^3/kg).
1226  /*!
1227  * This function fixes the internal state of the phase so that the
1228  * temperature and specific volume have the value of the input parameters.
1229  * This base class function will throw an exception if not overridden.
1230  *
1231  * @param t temperature (K)
1232  * @param v specific volume (m^3/kg)
1233  * @param tol Optional parameter setting the tolerance of the calculation.
1234  * Important for some applications where numerical Jacobians
1235  * are being calculated.
1236  */
1237  virtual void setState_TV(double t, double v, double tol=1e-9) {
1238  throw NotImplementedError("ThermoPhase::setState_TV");
1239  }
1240 
1241  //! Set the pressure (Pa) and specific volume (m^3/kg).
1242  /*!
1243  * This function fixes the internal state of the phase so that the
1244  * pressure and specific volume have the value of the input parameters.
1245  * This base class function will throw an exception if not overridden.
1246  *
1247  * @param p pressure (Pa)
1248  * @param v specific volume (m^3/kg)
1249  * @param tol Optional parameter setting the tolerance of the calculation.
1250  * Important for some applications where numerical Jacobians
1251  * are being calculated.
1252  */
1253  virtual void setState_PV(double p, double v, double tol=1e-9) {
1254  throw NotImplementedError("ThermoPhase::setState_PV");
1255  }
1256 
1257  //! Set the specific internal energy (J/kg) and pressure (Pa).
1258  /*!
1259  * This function fixes the internal state of the phase so that the specific
1260  * internal energy and pressure have the value of the input parameters.
1261  * This base class function will throw an exception if not overridden.
1262  *
1263  * @param u specific internal energy (J/kg)
1264  * @param p pressure (Pa)
1265  * @param tol Optional parameter setting the tolerance of the calculation.
1266  * Important for some applications where numerical Jacobians
1267  * are being calculated.
1268  */
1269  virtual void setState_UP(double u, double p, double tol=1e-9) {
1270  throw NotImplementedError("ThermoPhase::setState_UP");
1271  }
1272 
1273  //! Set the specific volume (m^3/kg) and the specific enthalpy (J/kg)
1274  /*!
1275  * This function fixes the internal state of the phase so that the specific
1276  * volume and the specific enthalpy have the value of the input parameters.
1277  * This base class function will throw an exception if not overridden.
1278  *
1279  * @param v specific volume (m^3/kg)
1280  * @param h specific enthalpy (J/kg)
1281  * @param tol Optional parameter setting the tolerance of the calculation.
1282  * Important for some applications where numerical Jacobians
1283  * are being calculated.
1284  */
1285  virtual void setState_VH(double v, double h, double tol=1e-9) {
1286  throw NotImplementedError("ThermoPhase::setState_VH");
1287  }
1288 
1289  //! Set the temperature (K) and the specific enthalpy (J/kg)
1290  /*!
1291  * This function fixes the internal state of the phase so that the
1292  * temperature and specific enthalpy have the value of the input parameters.
1293  * This base class function will throw an exception if not overridden.
1294  *
1295  * @param t temperature (K)
1296  * @param h specific enthalpy (J/kg)
1297  * @param tol Optional parameter setting the tolerance of the calculation.
1298  * Important for some applications where numerical Jacobians
1299  * are being calculated.
1300  */
1301  virtual void setState_TH(double t, double h, double tol=1e-9) {
1302  throw NotImplementedError("ThermoPhase::setState_TH");
1303  }
1304 
1305  //! Set the specific entropy (J/kg/K) and the specific enthalpy (J/kg)
1306  /*!
1307  * This function fixes the internal state of the phase so that the
1308  * temperature and pressure have the value of the input parameters.
1309  * This base class function will throw an exception if not overridden.
1310  *
1311  * @param s specific entropy (J/kg/K)
1312  * @param h specific enthalpy (J/kg)
1313  * @param tol Optional parameter setting the tolerance of the calculation.
1314  * Important for some applications where numerical Jacobians
1315  * are being calculated.
1316  */
1317  virtual void setState_SH(double s, double h, double tol=1e-9) {
1318  throw NotImplementedError("ThermoPhase::setState_SH");
1319  }
1320 
1321  //! Set the density (kg/m**3) and pressure (Pa) at constant composition
1322  /*!
1323  * This method must be reimplemented in derived classes, where it may
1324  * involve the solution of a nonlinear equation. Within %Cantera, the
1325  * independent variable is the density. Therefore, this function solves for
1326  * the temperature that will yield the desired input pressure and density.
1327  * The composition is held constant during this process.
1328  *
1329  * This base class function will print an error, if not overridden.
1330  *
1331  * @param rho Density (kg/m^3)
1332  * @param p Pressure (Pa)
1333  * @since New in %Cantera 3.0.
1334  */
1335  virtual void setState_DP(double rho, double p) {
1336  throw NotImplementedError("ThermoPhase::setState_DP");
1337  }
1338 
1339  //! Set the state using an AnyMap containing any combination of properties
1340  //! supported by the thermodynamic model
1341  /*!
1342  * Accepted keys are:
1343  * * `X` (mole fractions)
1344  * * `Y` (mass fractions)
1345  * * `T` or `temperature`
1346  * * `P` or `pressure` [Pa]
1347  * * `H` or `enthalpy` [J/kg]
1348  * * `U` or `internal-energy` [J/kg]
1349  * * `S` or `entropy` [J/kg/K]
1350  * * `V` or `specific-volume` [m^3/kg]
1351  * * `D` or `density` [kg/m^3]
1352  *
1353  * Composition can be specified as either an AnyMap of species names to
1354  * values or as a composition string. All other values can be given as
1355  * floating point values in Cantera's default units, or as strings with the
1356  * units specified, which will be converted using the Units class.
1357  *
1358  * If no thermodynamic property pair is given, or only one of temperature or
1359  * pressure is given, then 298.15 K and 101325 Pa will be used as necessary
1360  * to fully set the state.
1361  */
1362  virtual void setState(const AnyMap& state);
1363 
1364  //! @}
1365  //! @name Set Mixture Composition by Mixture Fraction
1366  //! @{
1367 
1368  //! Set the mixture composition according to the
1369  //! mixture fraction = kg fuel / (kg oxidizer + kg fuel)
1370  /*!
1371  * Fuel and oxidizer compositions are given either as
1372  * mole fractions or mass fractions (specified by `basis`)
1373  * and do not need to be normalized. Pressure and temperature are
1374  * kept constant. Elements C, S, H and O are considered for the oxidation.
1375  *
1376  * @param mixFrac mixture fraction (between 0 and 1)
1377  * @param fuelComp composition of the fuel
1378  * @param oxComp composition of the oxidizer
1379  * @param basis either ThermoPhase::molar or ThermoPhase::mass.
1380  * Fuel and oxidizer composition are interpreted
1381  * as mole or mass fractions (default: molar)
1382  */
1383  void setMixtureFraction(double mixFrac, const double* fuelComp,
1384  const double* oxComp, ThermoBasis basis=ThermoBasis::molar);
1385  //! @copydoc ThermoPhase::setMixtureFraction
1386  void setMixtureFraction(double mixFrac, const string& fuelComp,
1387  const string& oxComp, ThermoBasis basis=ThermoBasis::molar);
1388  //! @copydoc ThermoPhase::setMixtureFraction
1389  void setMixtureFraction(double mixFrac, const Composition& fuelComp,
1390  const Composition& oxComp, ThermoBasis basis=ThermoBasis::molar);
1391  //! @}
1392  //! @name Compute Mixture Fraction
1393  //! @{
1394 
1395  //! Compute the mixture fraction = kg fuel / (kg oxidizer + kg fuel) for
1396  //! the current mixture given fuel and oxidizer compositions.
1397  /*!
1398  * Fuel and oxidizer compositions are given either as
1399  * mole fractions or mass fractions (specified by `basis`)
1400  * and do not need to be normalized.
1401  * The mixture fraction @f$ Z @f$ can be computed from a single element
1402  * @f[ Z_m = \frac{Z_{\mathrm{mass},m}-Z_{\mathrm{mass},m,\mathrm{ox}}}
1403  * {Z_{\mathrm{mass},\mathrm{fuel}}-Z_{\mathrm{mass},m,\mathrm{ox}}} @f] where
1404  * @f$ Z_{\mathrm{mass},m} @f$ is the elemental mass fraction of element m
1405  * in the mixture, and @f$ Z_{\mathrm{mass},m,\mathrm{ox}} @f$ and
1406  * @f$ Z_{\mathrm{mass},m,\mathrm{fuel}} @f$ are the elemental mass fractions
1407  * of the oxidizer and fuel, or from the Bilger mixture fraction,
1408  * which considers the elements C, S, H and O @cite bilger1979
1409  * @f[ Z_{\mathrm{Bilger}} = \frac{\beta-\beta_{\mathrm{ox}}}
1410  * {\beta_{\mathrm{fuel}}-\beta_{\mathrm{ox}}} @f]
1411  * with @f$ \beta = 2\frac{Z_C}{M_C}+2\frac{Z_S}{M_S}+\frac{1}{2}\frac{Z_H}{M_H}
1412  * -\frac{Z_O}{M_O} @f$
1413  * and @f$ M_m @f$ the atomic weight of element @f$ m @f$.
1414  *
1415  * @param fuelComp composition of the fuel
1416  * @param oxComp composition of the oxidizer
1417  * @param basis either ThermoBasis::molar or ThermoBasis::mass.
1418  * Fuel and oxidizer composition are interpreted
1419  * as mole or mass fractions (default: molar)
1420  * @param element either "Bilger" to compute the mixture fraction
1421  * in terms of the Bilger mixture fraction, or
1422  * an element name, to compute the mixture fraction
1423  * based on a single element (default: "Bilger")
1424  * @returns mixture fraction (kg fuel / kg mixture)
1425  */
1426  double mixtureFraction(const double* fuelComp, const double* oxComp,
1427  ThermoBasis basis=ThermoBasis::molar,
1428  const string& element="Bilger") const;
1429  //! @copydoc ThermoPhase::mixtureFraction
1430  double mixtureFraction(const string& fuelComp, const string& oxComp,
1431  ThermoBasis basis=ThermoBasis::molar,
1432  const string& element="Bilger") const;
1433  //! @copydoc ThermoPhase::mixtureFraction
1434  double mixtureFraction(const Composition& fuelComp, const Composition& oxComp,
1435  ThermoBasis basis=ThermoBasis::molar,
1436  const string& element="Bilger") const;
1437  //! @}
1438  //! @name Set Mixture Composition by Equivalence Ratio
1439  //! @{
1440 
1441  //! Set the mixture composition according to the equivalence ratio.
1442  /*!
1443  * Fuel and oxidizer compositions are given either as
1444  * mole fractions or mass fractions (specified by `basis`)
1445  * and do not need to be normalized. Pressure and temperature are
1446  * kept constant. Elements C, S, H and O are considered for the oxidation.
1447  *
1448  * @param phi equivalence ratio
1449  * @param fuelComp composition of the fuel
1450  * @param oxComp composition of the oxidizer
1451  * @param basis either ThermoBasis::mole or ThermoBasis::mass.
1452  * Fuel and oxidizer composition are interpreted
1453  * as mole or mass fractions (default: molar)
1454  */
1455  void setEquivalenceRatio(double phi, const double* fuelComp, const double* oxComp,
1456  ThermoBasis basis=ThermoBasis::molar);
1457  //! @copydoc ThermoPhase::setEquivalenceRatio
1458  void setEquivalenceRatio(double phi, const string& fuelComp,
1459  const string& oxComp, ThermoBasis basis=ThermoBasis::molar);
1460  //! @copydoc ThermoPhase::setEquivalenceRatio
1461  void setEquivalenceRatio(double phi, const Composition& fuelComp,
1462  const Composition& oxComp, ThermoBasis basis=ThermoBasis::molar);
1463  //! @}
1464 
1465  //! @name Compute Equivalence Ratio
1466  //! @{
1467 
1468  //! Compute the equivalence ratio for the current mixture
1469  //! given the compositions of fuel and oxidizer
1470  /*!
1471  * The equivalence ratio @f$ \phi @f$ is computed from
1472  * @f[ \phi = \frac{Z}{1-Z}\frac{1-Z_{\mathrm{st}}}{Z_{\mathrm{st}}} @f]
1473  * where @f$ Z @f$ is the Bilger mixture fraction @cite bilger1979 of the mixture
1474  * given the specified fuel and oxidizer compositions
1475  * @f$ Z_{\mathrm{st}} @f$ is the mixture fraction at stoichiometric
1476  * conditions. Fuel and oxidizer compositions are given either as
1477  * mole fractions or mass fractions (specified by `basis`)
1478  * and do not need to be normalized.
1479  * Elements C, S, H and O are considered for the oxidation.
1480  * If fuel and oxidizer composition are unknown or not specified,
1481  * use the version that takes no arguments.
1482  *
1483  * @param fuelComp composition of the fuel
1484  * @param oxComp composition of the oxidizer
1485  * @param basis either ThermoPhase::mole or ThermoPhase::mass.
1486  * Fuel and oxidizer composition are interpreted
1487  * as mole or mass fractions (default: molar)
1488  * @returns equivalence ratio
1489  * @see mixtureFraction for the definition of the Bilger mixture fraction
1490  * @see equivalenceRatio() for the computation of @f$ \phi @f$ without arguments
1491  */
1492  double equivalenceRatio(const double* fuelComp, const double* oxComp,
1493  ThermoBasis basis=ThermoBasis::molar) const;
1494  //! @copydoc ThermoPhase::equivalenceRatio
1495  double equivalenceRatio(const string& fuelComp, const string& oxComp,
1496  ThermoBasis basis=ThermoBasis::molar) const;
1497  //! @copydoc ThermoPhase::equivalenceRatio
1498  double equivalenceRatio(const Composition& fuelComp,
1499  const Composition& oxComp, ThermoBasis basis=ThermoBasis::molar) const;
1500  //! @}
1501 
1502  //! Compute the equivalence ratio for the current mixture
1503  //! from available oxygen and required oxygen
1504  /*!
1505  * Computes the equivalence ratio @f$ \phi @f$ from
1506  * @f[ \phi =
1507  * \frac{Z_{\mathrm{mole},C} + Z_{\mathrm{mole},S} + \frac{1}{4}Z_{\mathrm{mole},H}}
1508  * {\frac{1}{2}Z_{\mathrm{mole},O}} @f]
1509  * where @f$ Z_{\mathrm{mole},m} @f$ is the elemental mole fraction
1510  * of element @f$ m @f$. In this special case, the equivalence ratio
1511  * is independent of a fuel or oxidizer composition because it only
1512  * considers the locally available oxygen compared to the required oxygen
1513  * for complete oxidation. It is the same as assuming that the oxidizer
1514  * only contains O (and inert elements) and the fuel contains only
1515  * H, C and S (and inert elements). If either of these conditions is
1516  * not met, use the version of this functions which takes the fuel and
1517  * oxidizer compositions as input
1518  *
1519  * @returns equivalence ratio
1520  * @see equivalenceRatio compute the equivalence ratio from specific
1521  * fuel and oxidizer compositions
1522  */
1523  double equivalenceRatio() const;
1524 
1525  //! @name Compute Stoichiometric Air to Fuel Ratio
1526  //! @{
1527 
1528  //! Compute the stoichiometric air to fuel ratio (kg oxidizer / kg fuel)
1529  //! given fuel and oxidizer compositions.
1530  /*!
1531  * Fuel and oxidizer compositions are given either as
1532  * mole fractions or mass fractions (specified by `basis`)
1533  * and do not need to be normalized.
1534  * Elements C, S, H and O are considered for the oxidation.
1535  * Note that the stoichiometric air to fuel ratio @f$ \mathit{AFR}_{\mathrm{st}} @f$
1536  * does not depend on the current mixture composition. The current air to fuel ratio
1537  * can be computed from @f$ \mathit{AFR} = \mathit{AFR}_{\mathrm{st}}/\phi @f$
1538  * where @f$ \phi @f$ is the equivalence ratio of the current mixture
1539  *
1540  * @param fuelComp composition of the fuel
1541  * @param oxComp composition of the oxidizer
1542  * @param basis either ThermoPhase::mole or ThermoPhase::mass.
1543  * Fuel and oxidizer composition are interpreted
1544  * as mole or mass fractions (default: molar)
1545  * @returns Stoichiometric Air to Fuel Ratio (kg oxidizer / kg fuel)
1546  */
1547  double stoichAirFuelRatio(const double* fuelComp, const double* oxComp,
1548  ThermoBasis basis=ThermoBasis::molar) const;
1549  //! @copydoc ThermoPhase::stoichAirFuelRatio
1550  double stoichAirFuelRatio(const string& fuelComp, const string& oxComp,
1551  ThermoBasis basis=ThermoBasis::molar) const;
1552  //! @copydoc ThermoPhase::stoichAirFuelRatio
1553  double stoichAirFuelRatio(const Composition& fuelComp,
1554  const Composition& oxComp, ThermoBasis basis=ThermoBasis::molar) const;
1555  //! @}
1556 
1557 private:
1558 
1559  //! Carry out work in HP and UV calculations.
1560  /*!
1561  * @param h Specific enthalpy or internal energy (J/kg)
1562  * @param p Pressure (Pa) or specific volume (m^3/kg)
1563  * @param tol Optional parameter setting the tolerance of the calculation.
1564  * Important for some applications where numerical Jacobians
1565  * are being calculated.
1566  * @param doUV True if solving for UV, false for HP.
1567  */
1568  void setState_HPorUV(double h, double p, double tol=1e-9, bool doUV = false);
1569 
1570  //! Carry out work in SP and SV calculations.
1571  /*!
1572  * @param s Specific entropy (J/kg)
1573  * @param p Pressure (Pa) or specific volume (m^3/kg)
1574  * @param tol Optional parameter setting the tolerance of the calculation.
1575  * Important for some applications where numerical Jacobians
1576  * are being calculated.
1577  * @param doSV True if solving for SV, false for SP.
1578  */
1579  void setState_SPorSV(double s, double p, double tol=1e-9, bool doSV = false);
1580 
1581  //! Helper function used by setState_HPorUV and setState_SPorSV.
1582  //! Sets the temperature and (if set_p is true) the pressure.
1583  void setState_conditional_TP(double t, double p, bool set_p);
1584 
1585  //! Helper function for computing the amount of oxygen required for complete
1586  //! oxidation.
1587  /*!
1588  * @param y array of (possibly non-normalized) mass fractions (length m_kk)
1589  * @returns amount of required oxygen in kmol O / kg mixture
1590  */
1591  double o2Required(const double* y) const;
1592 
1593  //! Helper function for computing the amount of oxygen
1594  //! available in the current mixture.
1595  /*!
1596  * @param y array of (possibly non-normalized) mass fractions (length m_kk)
1597  * @returns amount of O in kmol O / kg mixture
1598  */
1599  double o2Present(const double* y) const;
1600 
1601 public:
1602  //! @name Chemical Equilibrium
1603  //!
1604  //! Chemical equilibrium.
1605  //! @{
1606 
1607  //! Equilibrate a ThermoPhase object
1608  /*!
1609  * Set this phase to chemical equilibrium by calling one of several
1610  * equilibrium solvers. The XY parameter indicates what two thermodynamic
1611  * quantities are to be held constant during the equilibration process.
1612  *
1613  * @param XY String representation of what two properties are being
1614  * held constant
1615  * @param solver Name of the solver to be used to equilibrate the phase.
1616  * If solver = 'element_potential', the ChemEquil element potential
1617  * solver will be used. If solver = 'vcs', the VCS solver will be used.
1618  * If solver = 'gibbs', the MultiPhaseEquil solver will be used. If
1619  * solver = 'auto', the solvers will be tried in order if the initial
1620  * solver(s) fail.
1621  * @param rtol Relative tolerance
1622  * @param max_steps Maximum number of steps to take to find the solution
1623  * @param max_iter For the 'gibbs' and 'vcs' solvers, this is the maximum
1624  * number of outer temperature or pressure iterations to take when T
1625  * and/or P is not held fixed.
1626  * @param estimate_equil For MultiPhaseEquil solver, an integer indicating
1627  * whether the solver should estimate its own initial condition. If 0,
1628  * the initial mole fraction vector in the ThermoPhase object is used
1629  * as the initial condition. If 1, the initial mole fraction vector is
1630  * used if the element abundances are satisfied. If -1, the initial
1631  * mole fraction vector is thrown out, and an estimate is formulated.
1632  * @param log_level loglevel Controls amount of diagnostic output.
1633  * log_level=0 suppresses diagnostics, and increasingly-verbose
1634  * messages are written as loglevel increases.
1635  *
1636  * @ingroup equilGroup
1637  */
1638  void equilibrate(const string& XY, const string& solver="auto",
1639  double rtol=1e-9, int max_steps=50000, int max_iter=100,
1640  int estimate_equil=0, int log_level=0);
1641 
1642  //!This method is used by the ChemEquil equilibrium solver.
1643  /*!
1644  * It sets the state such that the chemical potentials satisfy
1645  * @f[ \frac{\mu_k}{\hat R T} = \sum_m A_{k,m}
1646  * \left(\frac{\lambda_m} {\hat R T}\right) @f] where
1647  * @f$ \lambda_m @f$ is the element potential of element m. The
1648  * temperature is unchanged. Any phase (ideal or not) that
1649  * implements this method can be equilibrated by ChemEquil.
1650  *
1651  * @param mu_RT Input vector of dimensionless chemical potentials
1652  * The length is equal to nSpecies().
1653  */
1654  virtual void setToEquilState(const double* mu_RT) {
1655  throw NotImplementedError("ThermoPhase::setToEquilState");
1656  }
1657 
1658  //! Indicates whether this phase type can be used with class MultiPhase for
1659  //! equilibrium calculations. Returns `false` for special phase types which
1660  //! already represent multi-phase mixtures, namely PureFluidPhase.
1661  virtual bool compatibleWithMultiPhase() const {
1662  return true;
1663  }
1664 
1665  //! @}
1666  //! @name Critical State Properties
1667  //!
1668  //! These methods are only implemented by subclasses that implement
1669  //! liquid-vapor equations of state.
1670  //! @{
1671 
1672  //! Critical temperature (K).
1673  virtual double critTemperature() const {
1674  throw NotImplementedError("ThermoPhase::critTemperature");
1675  }
1676 
1677  //! Critical pressure (Pa).
1678  virtual double critPressure() const {
1679  throw NotImplementedError("ThermoPhase::critPressure");
1680  }
1681 
1682  //! Critical volume (m3/kmol).
1683  virtual double critVolume() const {
1684  throw NotImplementedError("ThermoPhase::critVolume");
1685  }
1686 
1687  //! Critical compressibility (unitless).
1688  virtual double critCompressibility() const {
1689  throw NotImplementedError("ThermoPhase::critCompressibility");
1690  }
1691 
1692  //! Critical density (kg/m3).
1693  virtual double critDensity() const {
1694  throw NotImplementedError("ThermoPhase::critDensity");
1695  }
1696 
1697  //! @}
1698  //! @name Saturation Properties
1699  //!
1700  //! These methods are only implemented by subclasses that implement full
1701  //! liquid-vapor equations of state.
1702  //! @{
1703 
1704  //! Return the saturation temperature given the pressure
1705  /*!
1706  * @param p Pressure (Pa)
1707  */
1708  virtual double satTemperature(double p) const {
1709  throw NotImplementedError("ThermoPhase::satTemperature");
1710  }
1711 
1712  //! Return the saturation pressure given the temperature
1713  /*!
1714  * @param t Temperature (Kelvin)
1715  */
1716  virtual double satPressure(double t) {
1717  throw NotImplementedError("ThermoPhase::satPressure");
1718  }
1719 
1720  //! Return the fraction of vapor at the current conditions
1721  virtual double vaporFraction() const {
1722  throw NotImplementedError("ThermoPhase::vaporFraction");
1723  }
1724 
1725  //! Set the state to a saturated system at a particular temperature
1726  /*!
1727  * @param t Temperature (kelvin)
1728  * @param x Fraction of vapor
1729  */
1730  virtual void setState_Tsat(double t, double x) {
1731  throw NotImplementedError("ThermoPhase::setState_Tsat");
1732  }
1733 
1734  //! Set the state to a saturated system at a particular pressure
1735  /*!
1736  * @param p Pressure (Pa)
1737  * @param x Fraction of vapor
1738  */
1739  virtual void setState_Psat(double p, double x) {
1740  throw NotImplementedError("ThermoPhase::setState_Psat");
1741  }
1742 
1743  //! Set the temperature, pressure, and vapor fraction (quality).
1744  /*!
1745  * An exception is thrown if the thermodynamic state is not consistent.
1746  *
1747  * For temperatures below the critical temperature, if the vapor fraction is
1748  * not 0 or 1, the pressure and temperature must fall on the saturation
1749  * line.
1750  *
1751  * Above the critical temperature, the vapor fraction must be 1 if the
1752  * pressure is less than the critical pressure. Above the critical pressure,
1753  * the vapor fraction is not defined, and its value is ignored.
1754  *
1755  * @param T Temperature (K)
1756  * @param P Pressure (Pa)
1757  * @param Q vapor fraction
1758  */
1759  void setState_TPQ(double T, double P, double Q);
1760 
1761  //! @}
1762  //! @name Initialization Methods - For Internal Use (ThermoPhase)
1763  //!
1764  //! The following methods are used in the process of constructing
1765  //! the phase and setting its parameters from a specification in an
1766  //! input file. They are not normally used in application programs.
1767  //! To see how they are used, see importPhase().
1768  //! @{
1769 
1770  bool addSpecies(shared_ptr<Species> spec) override;
1771 
1772  void modifySpecies(size_t k, shared_ptr<Species> spec) override;
1773 
1774  //! Return a changeable reference to the calculation manager for species
1775  //! reference-state thermodynamic properties
1776  /*!
1777  * @param k Species id. The default is -1, meaning return the default
1778  */
1779  virtual MultiSpeciesThermo& speciesThermo(int k = -1);
1780 
1781  virtual const MultiSpeciesThermo& speciesThermo(int k = -1) const;
1782 
1783  /**
1784  * Initialize a ThermoPhase object using an input file.
1785  *
1786  * Used to implement constructors for derived classes which take a
1787  * file name and phase name as arguments.
1788  *
1789  * @param inputFile Input file containing the description of the phase. If blank,
1790  * no setup will be performed.
1791  * @param id Optional parameter identifying the name of the phase. If
1792  * blank, the first phase definition encountered will be used.
1793  */
1794  void initThermoFile(const string& inputFile, const string& id);
1795 
1796  //! Initialize the ThermoPhase object after all species have been set up
1797  /*!
1798  * This method is provided to allow subclasses to perform any initialization
1799  * required after all species have been added. For example, it might be used
1800  * to resize internal work arrays that must have an entry for each species.
1801  * The base class implementation does nothing, and subclasses that do not
1802  * require initialization do not need to overload this method. Derived
1803  * classes which do override this function should call their parent class's
1804  * implementation of this function as their last action.
1805  *
1806  * When importing from an AnyMap phase description (or from a YAML file),
1807  * setupPhase() adds all the species, stores the input data in #m_input, and then
1808  * calls this method to set model parameters from the data stored in #m_input.
1809  */
1810  virtual void initThermo();
1811 
1812  //! Set equation of state parameters from an AnyMap phase description.
1813  //! Phases that need additional parameters from the root node should
1814  //! override this method.
1815  virtual void setParameters(const AnyMap& phaseNode,
1816  const AnyMap& rootNode=AnyMap());
1817 
1818  //! Returns the parameters of a ThermoPhase object such that an identical
1819  //! one could be reconstructed using the newThermo(AnyMap&) function.
1820  //! @param withInput If true, include additional input data fields associated
1821  //! with the phase description, such as user-defined fields from a YAML input
1822  //! file, as returned by the input() method.
1823  AnyMap parameters(bool withInput=true) const;
1824 
1825  //! Get phase-specific parameters of a Species object such that an
1826  //! identical one could be reconstructed and added to this phase.
1827  /*!
1828  * @param name Name of the species
1829  * @param speciesNode Mapping to be populated with parameters
1830  */
1831  virtual void getSpeciesParameters(const string& name, AnyMap& speciesNode) const {}
1832 
1833  //! Access input data associated with the phase description
1834  const AnyMap& input() const;
1835  AnyMap& input();
1836 
1837  void invalidateCache() override;
1838 
1839  //! @}
1840  //! @name Derivatives of Thermodynamic Variables needed for Applications
1841  //!
1842  //! Derivatives of the activity coefficients are needed to evaluate terms arising
1843  //! in multicomponent transport models for non-ideal systems. While %Cantera does
1844  //! not currently implement such models, these derivatives are provided by a few
1845  //! phase models.
1846  //! @{
1847 
1848  //! Get the change in activity coefficients wrt changes in state (temp, mole
1849  //! fraction, etc) along a line in parameter space or along a line in
1850  //! physical space
1851  /*!
1852  * @param dTds Input of temperature change along the path
1853  * @param dXds Input vector of changes in mole fraction along the
1854  * path. length = m_kk Along the path length it must
1855  * be the case that the mole fractions sum to one.
1856  * @param dlnActCoeffds Output vector of the directional derivatives of the
1857  * log Activity Coefficients along the path. length =
1858  * m_kk units are 1/units(s). if s is a physical
1859  * coordinate then the units are 1/m.
1860  */
1861  virtual void getdlnActCoeffds(const double dTds, const double* const dXds,
1862  double* dlnActCoeffds) const {
1863  throw NotImplementedError("ThermoPhase::getdlnActCoeffds");
1864  }
1865 
1866  //! Get the array of ln mole fraction derivatives of the log activity
1867  //! coefficients - diagonal component only
1868  /*!
1869  * For ideal mixtures (unity activity coefficients), this can return zero.
1870  * Implementations should take the derivative of the logarithm of the
1871  * activity coefficient with respect to the logarithm of the mole fraction
1872  * variable that represents the standard state. This quantity is to be used
1873  * in conjunction with derivatives of that mole fraction variable when the
1874  * derivative of the chemical potential is taken.
1875  *
1876  * units = dimensionless
1877  *
1878  * @param dlnActCoeffdlnX_diag Output vector of derivatives of the log
1879  * Activity Coefficients wrt the mole fractions. length = m_kk
1880  */
1881  virtual void getdlnActCoeffdlnX_diag(double* dlnActCoeffdlnX_diag) const {
1882  throw NotImplementedError("ThermoPhase::getdlnActCoeffdlnX_diag");
1883  }
1884 
1885  //! Get the array of log species mole number derivatives of the log activity
1886  //! coefficients
1887  /*!
1888  * For ideal mixtures (unity activity coefficients), this can return zero.
1889  * Implementations should take the derivative of the logarithm of the
1890  * activity coefficient with respect to the logarithm of the concentration-
1891  * like variable (for example, moles) that represents the standard state. This
1892  * quantity is to be used in conjunction with derivatives of that species
1893  * mole number variable when the derivative of the chemical potential is
1894  * taken.
1895  *
1896  * units = dimensionless
1897  *
1898  * @param dlnActCoeffdlnN_diag Output vector of derivatives of the
1899  * log Activity Coefficients. length = m_kk
1900  */
1901  virtual void getdlnActCoeffdlnN_diag(double* dlnActCoeffdlnN_diag) const {
1902  throw NotImplementedError("ThermoPhase::getdlnActCoeffdlnN_diag");
1903  }
1904 
1905  //! Get the array of derivatives of the log activity coefficients with
1906  //! respect to the log of the species mole numbers
1907  /*!
1908  * Implementations should take the derivative of the logarithm of the
1909  * activity coefficient with respect to a species log mole number (with all
1910  * other species mole numbers held constant). The default treatment in the
1911  * ThermoPhase object is to set this vector to zero.
1912  *
1913  * units = 1 / kmol
1914  *
1915  * dlnActCoeffdlnN[ ld * k + m] will contain the derivative of log
1916  * act_coeff for the *m*-th species with respect to the number of moles of
1917  * the *k*-th species.
1918  *
1919  * @f[
1920  * \frac{d \ln(\gamma_m) }{d \ln( n_k ) }\Bigg|_{n_i}
1921  * @f]
1922  *
1923  * When implemented, this method is used within the VCS equilibrium solver to
1924  * calculate the Jacobian elements, which accelerates convergence of the algorithm.
1925  *
1926  * @param ld Number of rows in the matrix
1927  * @param dlnActCoeffdlnN Output vector of derivatives of the
1928  * log Activity Coefficients. length = m_kk * m_kk
1929  */
1930  virtual void getdlnActCoeffdlnN(const size_t ld, double* const dlnActCoeffdlnN);
1931 
1932  virtual void getdlnActCoeffdlnN_numderiv(const size_t ld,
1933  double* const dlnActCoeffdlnN);
1934 
1935  //! @}
1936  //! @name Printing
1937  //! @{
1938 
1939  //! returns a summary of the state of the phase as a string
1940  /*!
1941  * @param show_thermo If true, extra information is printed out
1942  * about the thermodynamic state of the system.
1943  * @param threshold Show information about species with mole fractions
1944  * greater than *threshold*.
1945  */
1946  virtual string report(bool show_thermo=true, double threshold=-1e-14) const;
1947 
1948  //! @}
1949 
1950 protected:
1951  //! Store the parameters of a ThermoPhase object such that an identical
1952  //! one could be reconstructed using the newThermo(AnyMap&) function. This
1953  //! does not include user-defined fields available in input().
1954  virtual void getParameters(AnyMap& phaseNode) const;
1955 
1956  //! Pointer to the calculation manager for species reference-state
1957  //! thermodynamic properties
1958  /*!
1959  * This class is called when the reference-state thermodynamic properties
1960  * of all the species in the phase needs to be evaluated.
1961  */
1963 
1964  //! Data supplied via setParameters. When first set, this may include
1965  //! parameters used by different phase models when initThermo() is called.
1967 
1968  //! Stored value of the electric potential for this phase. Units are Volts.
1969  double m_phi = 0.0;
1970 
1971  //! Boolean indicating whether a charge neutrality condition is a necessity
1972  /*!
1973  * Note, the charge neutrality condition is not a necessity for ideal gas
1974  * phases. There may be a net charge in those phases, because the NASA
1975  * polynomials for ionized species in Ideal gases take this condition into
1976  * account. However, liquid phases usually require charge neutrality in
1977  * order for their derived thermodynamics to be valid.
1978  */
1980 
1981  //! Contains the standard state convention
1983 
1984  //! last value of the temperature processed by reference state
1985  mutable double m_tlast = 0.0;
1986 };
1987 
1988 }
1989 
1990 #endif
Header for a general species thermodynamic property manager for a phase (see MultiSpeciesThermo).
Header file for class Phase.
Header for unit conversion utilities, which are used to translate user input from input files (See In...
A map of string keys to values whose type can vary at runtime.
Definition: AnyMap.h:427
A species thermodynamic property manager for a phase.
virtual double refPressure() const
The reference-state pressure (Pa) for all species.
virtual double minTemp(size_t k=npos) const
Minimum temperature.
virtual double maxTemp(size_t k=npos) const
Maximum temperature.
virtual void modifyOneHf298(const size_t k, const double Hf298New)
Modify the value of the 298 K Heat of Formation of the standard state of one species in the phase (J ...
virtual double reportOneHf298(const size_t k) const
Report the 298 K Heat of Formation of the standard state of one species (J kmol-1)
An error indicating that an unimplemented function has been called.
Definition: ctexceptions.h:195
Class Phase is the base class for phases of matter, managing the species and elements in a phase,...
Definition: Phase.h:95
size_t m_kk
Number of species in the phase.
Definition: Phase.h:842
double temperature() const
Temperature (K).
Definition: Phase.h:562
double meanMolecularWeight() const
The mean molecular weight. Units: (kg/kmol)
Definition: Phase.h:655
virtual double molarVolume() const
Molar volume (m^3/kmol).
Definition: Phase.cpp:581
virtual double pressure() const
Return the thermodynamic pressure (Pa).
Definition: Phase.h:580
string name() const
Return the name of the phase.
Definition: Phase.cpp:20
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:390
int m_ssConvention
Contains the standard state convention.
Definition: ThermoPhase.h:1982
virtual void getPartialMolarEnthalpies(double *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.
Definition: ThermoPhase.h:801
virtual double critTemperature() const
Critical temperature (K).
Definition: ThermoPhase.h:1673
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.
double electricPotential() const
Returns the electric potential of this phase (V).
Definition: ThermoPhase.h:621
virtual void getEntropy_R(double *sr) const
Get the array of nondimensional Entropy functions for the standard state species at the current T and...
Definition: ThermoPhase.h:880
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).
bool chargeNeutralityNecessary() const
Returns the chargeNeutralityNecessity boolean.
Definition: ThermoPhase.h:516
virtual double cp_mole() const
Molar heat capacity at constant pressure. Units: J/kmol/K.
Definition: ThermoPhase.h:545
double equivalenceRatio() const
Compute the equivalence ratio for the current mixture from available oxygen and required oxygen.
virtual void setParameters(const AnyMap &phaseNode, const AnyMap &rootNode=AnyMap())
Set equation of state parameters from an AnyMap phase description.
virtual double thermalExpansionCoeff() const
Return the volumetric thermal expansion coefficient. Units: 1/K.
Definition: ThermoPhase.h:580
virtual void getEnthalpy_RT_ref(double *hrt) const
Returns the vector of nondimensional enthalpies of the reference state at the current temperature of ...
Definition: ThermoPhase.h:949
virtual void getParameters(AnyMap &phaseNode) const
Store the parameters of a ThermoPhase object such that an identical one could be reconstructed using ...
virtual double enthalpy_mole() const
Molar enthalpy. Units: J/kmol.
Definition: ThermoPhase.h:525
virtual void setState_TP(double t, double p)
Set the temperature (K) and pressure (Pa)
virtual double standardConcentration(size_t k=0) const
Return the standard concentration for the kth species.
Definition: ThermoPhase.h:718
virtual void getCp_R_ref(double *cprt) const
Returns the vector of nondimensional constant pressure heat capacities of the reference state at the ...
Definition: ThermoPhase.h:1005
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:1237
virtual double logStandardConc(size_t k=0) const
Natural logarithm of the standard concentration of the kth species.
Definition: ThermoPhase.cpp:55
double o2Present(const double *y) const
Helper function for computing the amount of oxygen available in the current mixture.
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:1253
virtual void setState(const AnyMap &state)
Set the state using an AnyMap containing any combination of properties supported by the thermodynamic...
virtual double minTemp(size_t k=npos) const
Minimum temperature for which the thermodynamic data for the species or phase are valid.
Definition: ThermoPhase.h:451
virtual void getdlnActCoeffdlnN_diag(double *dlnActCoeffdlnN_diag) const
Get the array of log species mole number derivatives of the log activity coefficients.
Definition: ThermoPhase.h:1901
virtual void setState_TPX(double t, double p, const double *x)
Set the temperature (K), pressure (Pa), and mole fractions.
Definition: ThermoPhase.cpp:85
void setState_SPorSV(double s, double p, double tol=1e-9, bool doSV=false)
Carry out work in SP and SV calculations.
double RT() const
Return the Gas Constant multiplied by the current temperature.
Definition: ThermoPhase.h:1062
virtual void getPartialMolarCp(double *cpbar) const
Return an array of partial molar heat capacities for the species in the mixture.
Definition: ThermoPhase.h:832
virtual double critPressure() const
Critical pressure (Pa).
Definition: ThermoPhase.h:1678
virtual void getGibbs_RT_ref(double *grt) const
Returns the vector of nondimensional Gibbs Free Energies of the reference state at the current temper...
Definition: ThermoPhase.h:960
virtual double soundSpeed() const
Return the speed of sound. Units: m/s.
Definition: ThermoPhase.h:591
virtual void setState_TPY(double t, double p, const double *y)
Set the internally stored temperature (K), pressure (Pa), and mass fractions of the phase.
double m_tlast
last value of the temperature processed by reference state
Definition: ThermoPhase.h:1985
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:1221
void setState_HPorUV(double h, double p, double tol=1e-9, bool doUV=false)
Carry out work in HP and UV calculations.
double gibbs_mass() const
Specific Gibbs function. Units: J/kg.
Definition: ThermoPhase.h:1043
virtual void getActivityConcentrations(double *c) const
This method returns an array of generalized concentrations.
Definition: ThermoPhase.h:697
double stoichAirFuelRatio(const double *fuelComp, const double *oxComp, ThermoBasis basis=ThermoBasis::molar) const
Compute the stoichiometric air to fuel ratio (kg oxidizer / kg fuel) given fuel and oxidizer composit...
string type() const override
String indicating the thermodynamic model implemented.
Definition: ThermoPhase.h:399
AnyMap parameters(bool withInput=true) const
Returns the parameters of a ThermoPhase object such that an identical one could be reconstructed usin...
bool m_chargeNeutralityNecessary
Boolean indicating whether a charge neutrality condition is a necessity.
Definition: ThermoPhase.h:1979
virtual void getPureGibbs(double *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:901
virtual string report(bool show_thermo=true, double threshold=-1e-14) const
returns a summary of the state of the phase as a string
virtual void getPartialMolarIntEnergies(double *ubar) const
Return an array of partial molar internal energies for the species in the mixture.
Definition: ThermoPhase.h:821
virtual void getIntEnergy_RT(double *urt) const
Returns the vector of nondimensional Internal Energies of the standard state species at the current T...
Definition: ThermoPhase.h:911
virtual void getCp_R(double *cpr) const
Get the nondimensional Heat Capacities at constant pressure for the species standard states at the cu...
Definition: ThermoPhase.h:922
virtual double maxTemp(size_t k=npos) const
Maximum temperature for which the thermodynamic data for the species are valid.
Definition: ThermoPhase.h:504
double m_phi
Stored value of the electric potential for this phase. Units are Volts.
Definition: ThermoPhase.h:1969
virtual double isothermalCompressibility() const
Returns the isothermal compressibility. Units: 1/Pa.
Definition: ThermoPhase.h:569
double mixtureFraction(const double *fuelComp, const double *oxComp, ThermoBasis basis=ThermoBasis::molar, const string &element="Bilger") const
Compute the mixture fraction = kg fuel / (kg oxidizer + kg fuel) for the current mixture given fuel a...
double o2Required(const double *y) const
Helper function for computing the amount of oxygen required for complete oxidation.
virtual double satTemperature(double p) const
Return the saturation temperature given the pressure.
Definition: ThermoPhase.h:1708
virtual void getdlnActCoeffds(const double dTds, const double *const dXds, double *dlnActCoeffds) const
Get the change in activity coefficients wrt changes in state (temp, mole fraction,...
Definition: ThermoPhase.h:1861
void getElectrochemPotentials(double *mu) const
Get the species electrochemical potentials.
Definition: ThermoPhase.cpp:76
virtual void getdlnActCoeffdlnN(const size_t ld, double *const dlnActCoeffdlnN)
Get the array of derivatives of the log activity coefficients with respect to the log of the species ...
virtual void getGibbs_RT(double *grt) const
Get the nondimensional Gibbs functions for the species in their standard states at the current T and ...
Definition: ThermoPhase.h:890
virtual double critVolume() const
Critical volume (m3/kmol).
Definition: ThermoPhase.h:1683
virtual void getActivityCoefficients(double *ac) const
Get the array of non-dimensional molar-based activity coefficients at the current solution temperatur...
Definition: ThermoPhase.h:747
virtual string phaseOfMatter() const
String indicating the mechanical phase of the matter in this Phase.
Definition: ThermoPhase.h:428
virtual void getStandardVolumes(double *vol) const
Get the molar volumes of the species standard states at the current T and P of the solution.
Definition: ThermoPhase.h:934
virtual void setState_Tsat(double t, double x)
Set the state to a saturated system at a particular temperature.
Definition: ThermoPhase.h:1730
virtual double entropy_mole() const
Molar entropy. Units: J/kmol/K.
Definition: ThermoPhase.h:535
void setElectricPotential(double v)
Set the electric potential of this phase (V).
Definition: ThermoPhase.h:612
double cv_mass() const
Specific heat at constant volume. Units: J/kg/K.
Definition: ThermoPhase.h:1053
virtual int activityConvention() const
This method returns the convention used in specification of the activities, of which there are curren...
Definition: ThermoPhase.cpp:39
virtual void initThermo()
Initialize the ThermoPhase object after all species have been set up.
double entropy_mass() const
Specific entropy. Units: J/kg/K.
Definition: ThermoPhase.h:1038
virtual double critDensity() const
Critical density (kg/m3).
Definition: ThermoPhase.h:1693
virtual void getGibbs_ref(double *g) const
Returns the vector of the Gibbs function of the reference state at the current temperature of the sol...
Definition: ThermoPhase.h:971
virtual MultiSpeciesThermo & speciesThermo(int k=-1)
Return a changeable reference to the calculation manager for species reference-state thermodynamic pr...
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:1269
void initThermoFile(const string &inputFile, const string &id)
Initialize a ThermoPhase object using an input file.
virtual void setState_SP(double s, double p, double tol=1e-9)
Set the specific entropy (J/kg/K) and pressure (Pa).
virtual void modifyOneHf298SS(const size_t k, const double Hf298New)
Modify the value of the 298 K Heat of Formation of one species in the phase (J kmol-1)
Definition: ThermoPhase.h:481
virtual int standardStateConvention() const
This method returns the convention used in specification of the standard state, of which there are cu...
Definition: ThermoPhase.cpp:44
void modifySpecies(size_t k, shared_ptr< Species > spec) override
Modify the thermodynamic data associated with a species.
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:1317
virtual void getdlnActCoeffdlnX_diag(double *dlnActCoeffdlnX_diag) const
Get the array of ln mole fraction derivatives of the log activity coefficients - diagonal component o...
Definition: ThermoPhase.h:1881
void invalidateCache() override
Invalidate any cached values which are normally updated only when a change in state is detected.
virtual void getActivities(double *a) const
Get the array of non-dimensional activities at the current solution temperature, pressure,...
Definition: ThermoPhase.cpp:60
void setMixtureFraction(double mixFrac, const double *fuelComp, const double *oxComp, ThermoBasis basis=ThermoBasis::molar)
Set the mixture composition according to the mixture fraction = kg fuel / (kg oxidizer + kg fuel)
virtual void getStandardVolumes_ref(double *vol) const
Get the molar volumes of the species reference states at the current T and P_ref of the solution.
Definition: ThermoPhase.h:1017
virtual double vaporFraction() const
Return the fraction of vapor at the current conditions.
Definition: ThermoPhase.h:1721
virtual void resetHf298(const size_t k=npos)
Restore the original heat of formation of one or more species.
Definition: ThermoPhase.cpp:28
virtual void getStandardChemPotentials(double *mu) const
Get the array of chemical potentials at unit activity for the species at their standard states at the...
Definition: ThermoPhase.h:860
virtual void getEnthalpy_RT(double *hrt) const
Get the nondimensional Enthalpy functions for the species at their standard states at the current T a...
Definition: ThermoPhase.h:870
virtual void getEntropy_R_ref(double *er) const
Returns the vector of nondimensional entropies of the reference state at the current temperature of t...
Definition: ThermoPhase.h:982
virtual void getChemPotentials(double *mu) const
Get the species chemical potentials. Units: J/kmol.
Definition: ThermoPhase.h:775
double cp_mass() const
Specific heat at constant pressure. Units: J/kg/K.
Definition: ThermoPhase.h:1048
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:1301
virtual void getLnActivityCoefficients(double *lnac) const
Get the array of non-dimensional molar-based ln activity coefficients at the current solution tempera...
Definition: ThermoPhase.cpp:68
double intEnergy_mass() const
Specific internal energy. Units: J/kg.
Definition: ThermoPhase.h:1033
virtual void getSpeciesParameters(const string &name, AnyMap &speciesNode) const
Get phase-specific parameters of a Species object such that an identical one could be reconstructed a...
Definition: ThermoPhase.h:1831
virtual Units standardConcentrationUnits() const
Returns the units of the "standard concentration" for this phase.
Definition: ThermoPhase.cpp:49
virtual void getIntEnergy_RT_ref(double *urt) const
Returns the vector of nondimensional internal Energies of the reference state at the current temperat...
Definition: ThermoPhase.h:993
double 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:466
ThermoPhase()=default
Constructor.
virtual bool isIdeal() const
Boolean indicating whether phase is ideal.
Definition: ThermoPhase.h:404
virtual double cv_mole() const
Molar heat capacity at constant volume. Units: J/kmol/K.
Definition: ThermoPhase.h:550
MultiSpeciesThermo m_spthermo
Pointer to the calculation manager for species reference-state thermodynamic properties.
Definition: ThermoPhase.h:1962
virtual double satPressure(double t)
Return the saturation pressure given the temperature.
Definition: ThermoPhase.h:1716
virtual double refPressure() const
Returns the reference pressure in Pa.
Definition: ThermoPhase.h:436
virtual double critCompressibility() const
Critical compressibility (unitless).
Definition: ThermoPhase.h:1688
bool addSpecies(shared_ptr< Species > spec) override
Add a Species to this Phase.
AnyMap m_input
Data supplied via setParameters.
Definition: ThermoPhase.h:1966
virtual double intEnergy_mole() const
Molar internal energy. Units: J/kmol.
Definition: ThermoPhase.h:530
virtual void setState_DP(double rho, double p)
Set the density (kg/m**3) and pressure (Pa) at constant composition.
Definition: ThermoPhase.h:1335
void setEquivalenceRatio(double phi, const double *fuelComp, const double *oxComp, ThermoBasis basis=ThermoBasis::molar)
Set the mixture composition according to the equivalence ratio.
void setState_TPQ(double T, double P, double Q)
Set the temperature, pressure, and vapor fraction (quality).
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:1285
virtual void getPartialMolarEntropies(double *sbar) const
Returns an array of partial molar entropies of the species in the solution.
Definition: ThermoPhase.h:811
virtual double gibbs_mole() const
Molar Gibbs function. Units: J/kmol.
Definition: ThermoPhase.h:540
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).
const AnyMap & input() const
Access input data associated with the phase description.
virtual void setState_Psat(double p, double x)
Set the state to a saturated system at a particular pressure.
Definition: ThermoPhase.h:1739
void setState_conditional_TP(double t, double p, bool set_p)
Helper function used by setState_HPorUV and setState_SPorSV.
virtual void getPartialMolarVolumes(double *vbar) const
Return an array of partial molar volumes for the species in the mixture.
Definition: ThermoPhase.h:842
double enthalpy_mass() const
Specific enthalpy. Units: J/kg.
Definition: ThermoPhase.h:1028
A representation of the units associated with a dimensional quantity.
Definition: Units.h:35
void equilibrate(const string &XY, const 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 bool compatibleWithMultiPhase() const
Indicates whether this phase type can be used with class MultiPhase for equilibrium calculations.
Definition: ThermoPhase.h:1661
virtual void setToEquilState(const double *mu_RT)
This method is used by the ChemEquil equilibrium solver.
Definition: ThermoPhase.h:1654
const double GasConstant
Universal Gas Constant [J/kmol/K].
Definition: ct_defs.h:120
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:564
const size_t npos
index returned by functions to indicate "no position"
Definition: ct_defs.h:180
const int cSS_CONVENTION_VPSS
Standard state uses the molality convention.
Definition: ThermoPhase.h:146
const int cAC_CONVENTION_MOLAR
Standard state uses the molar convention.
Definition: ThermoPhase.h:135
const int cSS_CONVENTION_TEMPERATURE
Standard state uses the molar convention.
Definition: ThermoPhase.h:144
ThermoBasis
Differentiate between mole fractions and mass fractions for input mixture composition.
Definition: ThermoPhase.h:154
const int cSS_CONVENTION_SLAVE
Standard state thermodynamics is obtained from slave ThermoPhase objects.
Definition: ThermoPhase.h:148
map< string, double > Composition
Map from string names to doubles.
Definition: ct_defs.h:177
const int cAC_CONVENTION_MOLALITY
Standard state uses the molality convention.
Definition: ThermoPhase.h:137