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