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