Cantera  3.3.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 the chargeNeutralityNecessity boolean
515 /*!
516 * Some phases must have zero net charge in order for their thermodynamics
517 * functions to be valid. If this is so, then the value returned from this
518 * function is true. If this is not the case, then this is false. Now, ideal
519 * gases have this parameter set to false, while solution with molality-
520 * based activity coefficients have this parameter set to true.
521 */
524 }
525
526 //! @}
527 //! @name Molar Thermodynamic Properties of the Solution
528 //! @{
529
530 //! Molar enthalpy. Units: J/kmol.
531 /**
532 * Returns the amount of enthalpy per mole,
533 * @f[
534 * \hat{h} = \sum_k X_k \hat{h}_k
535 * @f]
536 * @see getPartialMolarEnthalpies()
537 */
538 virtual double enthalpy_mole() const {
540 return mean_X(m_workS);
541 }
542
543 //! Molar internal energy. Units: J/kmol.
544 virtual double intEnergy_mole() const {
545 return enthalpy_mole() - pressure()* molarVolume();
546 }
547
548 //! Molar entropy. Units: J/kmol/K.
549 /**
550 * Returns the amount of entropy per mole,
551 * @f[
552 * \hat{s} = \sum_k X_k \hat{s}_k
553 * @f]
554 * @see getPartialMolarEnthalpies()
555 */
556 virtual double entropy_mole() const {
558 return mean_X(m_workS);
559 }
560
561 //! Molar Gibbs function. Units: J/kmol.
562 /*!
563 * Returns the Gibbs free energy per mole,
564 * @f[
565 * \hat{g} = \sum_k X_k \mu_k
566 * @f]
567 * @see getChemPotentials()
568 */
569 virtual double gibbs_mole() const {
571 return mean_X(m_workS);
572 }
573
574 //! Molar heat capacity at constant pressure and composition [J/kmol/K].
575 /*!
576 * @f[
577 * \hat{c}_p = \sum_k X_k \hat{c}_{p,k}
578 * @f]
579 * @see getPartialMolarCp()
580 */
581 virtual double cp_mole() const {
583 return mean_X(m_workS);
584 }
585
586 //! Molar heat capacity at constant volume and composition [J/kmol/K].
587 virtual double cv_mole() const {
588 throw NotImplementedError("ThermoPhase::cv_mole",
589 "Not implemented for phase type '{}'", type());
590 }
591
592 //! @}
593 //! @name Mechanical Properties
594 //! @{
595
596 //! Returns the isothermal compressibility. Units: 1/Pa.
597 /*!
598 * The isothermal compressibility is defined as
599 * @f[
600 * \kappa_T = -\frac{1}{v}\left(\frac{\partial v}{\partial P}\right)_T
601 * @f]
602 * or
603 * @f[
604 * \kappa_T = \frac{1}{\rho}\left(\frac{\partial \rho}{\partial P}\right)_T
605 * @f]
606 */
607 virtual double isothermalCompressibility() const {
608 throw NotImplementedError("ThermoPhase::isothermalCompressibility",
609 "Not implemented for phase type '{}'", type());
610 }
611
612 //! Return the volumetric thermal expansion coefficient. Units: 1/K.
613 /*!
614 * The thermal expansion coefficient is defined as
615 * @f[
616 * \beta = \frac{1}{v}\left(\frac{\partial v}{\partial T}\right)_P
617 * @f]
618 */
619 virtual double thermalExpansionCoeff() const {
620 throw NotImplementedError("ThermoPhase::thermalExpansionCoeff",
621 "Not implemented for phase type '{}'", type());
622 }
623
624 //! Return the speed of sound. Units: m/s.
625 /*!
626 * The speed of sound is defined as
627 * @f[
628 * c = \sqrt{\left(\frac{\partial P}{\partial\rho}\right)_s}
629 * @f]
630 */
631 virtual double soundSpeed() const {
632 throw NotImplementedError("ThermoPhase::soundSpeed",
633 "Not implemented for phase type '{}'", type());
634 }
635
636 //! @}
637 //! @name Electric Potential
638 //!
639 //! The phase may be at some non-zero electrical potential. These methods
640 //! set or get the value of the electric potential.
641 //! @{
642
643 //! Set the electric potential of this phase (V).
644 /*!
645 * This is used by classes InterfaceKinetics and EdgeKinetics to
646 * compute the rates of charge-transfer reactions, and in computing
647 * the electrochemical potentials of the species.
648 *
649 * Each phase may have its own electric potential.
650 *
651 * @param v Input value of the electric potential in Volts
652 */
653 void setElectricPotential(double v) {
654 m_phi = v;
656 }
657
658 //! Returns the electric potential of this phase (V).
659 /*!
660 * Units are Volts (which are Joules/coulomb)
661 */
662 double electricPotential() const {
663 return m_phi;
664 }
665
666 //! @}
667 //! @name Activities, Standard States, and Activity Concentrations
668 //!
669 //! The activity @f$ a_k @f$ of a species in solution is related to the
670 //! chemical potential by @f[ \mu_k = \mu_k^0(T,P) + \hat R T \ln a_k. @f]
671 //! The quantity @f$ \mu_k^0(T,P) @f$ is the standard chemical potential at
672 //! unit activity, which depends on temperature and pressure, but not on
673 //! composition. The activity is dimensionless.
674 //! @{
675
676 //! This method returns the convention used in specification of the
677 //! activities, of which there are currently two, molar- and molality-based
678 //! conventions.
679 /*!
680 * Currently, there are two activity conventions:
681 * - Molar-based activities
682 * %Unit activity of species at either a hypothetical pure
683 * solution of the species or at a hypothetical
684 * pure ideal solution at infinite dilution
685 * cAC_CONVENTION_MOLAR 0
686 * - default
687 *
688 * - Molality-based activities
689 * (unit activity of solutes at a hypothetical 1 molal
690 * solution referenced to infinite dilution at all
691 * pressures and temperatures).
692 * cAC_CONVENTION_MOLALITY 1
693 */
694 virtual int activityConvention() const;
695
696 //! This method returns the convention used in specification of the standard
697 //! state, of which there are currently two, temperature based, and variable
698 //! pressure based.
699 /*!
700 * Currently, there are two standard state conventions:
701 * - Temperature-based activities
702 * cSS_CONVENTION_TEMPERATURE 0
703 * - default
704 *
705 * - Variable Pressure and Temperature -based activities
706 * cSS_CONVENTION_VPSS 1
707 *
708 * - Thermodynamics is set via slave ThermoPhase objects with
709 * nothing being carried out at this ThermoPhase object level
710 * cSS_CONVENTION_SLAVE 2
711 */
712 virtual int standardStateConvention() const;
713
714 //! Returns the units of the "standard concentration" for this phase
715 /*!
716 * These are the units of the values returned by the functions
717 * getActivityConcentrations() and standardConcentration(), which can
718 * vary between different ThermoPhase-derived classes, or change within
719 * a single class depending on input options. See the documentation for
720 * standardConcentration() for the derived class for specific details.
721 */
722 virtual Units standardConcentrationUnits() const;
723
724 //! This method returns an array of generalized concentrations
725 /*!
726 * @f$ C^a_k @f$ are defined such that @f$ a_k = C^a_k / C^0_k, @f$ where
727 * @f$ C^0_k @f$ is a standard concentration defined below and @f$ a_k @f$
728 * are activities used in the thermodynamic functions. These activity (or
729 * generalized) concentrations are used by kinetics manager classes to
730 * compute the forward and reverse rates of elementary reactions. Note that
731 * they may or may not have units of concentration --- they might be partial
732 * pressures, mole fractions, or surface coverages, for example.
733 *
734 * @param c Output array of generalized concentrations. The units depend
735 * upon the implementation of the reaction rate expressions within
736 * the phase.
737 */
738 virtual void getActivityConcentrations(double* c) const {
739 throw NotImplementedError("ThermoPhase::getActivityConcentrations",
740 "Not implemented for phase type '{}'", type());
741 }
742
743 //! Return the standard concentration for the kth species
744 /*!
745 * The standard concentration @f$ C^0_k @f$ used to normalize the activity
746 * (that is, generalized) concentration. In many cases, this quantity will be
747 * the same for all species in a phase - for example, for an ideal gas @f$
748 * C^0_k = P/\hat R T @f$. For this reason, this method returns a single
749 * value, instead of an array. However, for phases in which the standard
750 * concentration is species-specific (such as surface species of different
751 * sizes), this method may be called with an optional parameter indicating
752 * the species.
753 *
754 * @param k Optional parameter indicating the species. The default
755 * is to assume this refers to species 0.
756 * @return
757 * Returns the standard concentration. The units are by definition
758 * dependent on the ThermoPhase and kinetics manager representation.
759 */
760 virtual double standardConcentration(size_t k=0) const {
761 throw NotImplementedError("ThermoPhase::standardConcentration",
762 "Not implemented for phase type '{}'", type());
763 }
764
765 //! Natural logarithm of the standard concentration of the kth species.
766 /*!
767 * @param k index of the species (defaults to zero)
768 */
769 virtual double logStandardConc(size_t k=0) const;
770
771 //! Get the array of non-dimensional activities at the current solution
772 //! temperature, pressure, and solution concentration.
773 /*!
774 * Note, for molality based formulations, this returns the molality based
775 * activities.
776 *
777 * We resolve this function at this level by calling on the
778 * activityConcentration function. However, derived classes may want to
779 * override this default implementation.
780 *
781 * @param a Output vector of activities. Length: m_kk.
782 */
783 virtual void getActivities(double* a) const;
784
785 //! Get the array of non-dimensional molar-based activity coefficients at
786 //! the current solution temperature, pressure, and solution concentration.
787 /*!
788 * @param ac Output vector of activity coefficients. Length: m_kk.
789 */
790 virtual void getActivityCoefficients(double* ac) const {
791 if (m_kk == 1) {
792 ac[0] = 1.0;
793 } else {
794 throw NotImplementedError("ThermoPhase::getActivityCoefficients",
795 "Not implemented for phase type '{}'", type());
796 }
797 }
798
799 //! Get the array of non-dimensional molar-based ln activity coefficients at
800 //! the current solution temperature, pressure, and solution concentration.
801 /*!
802 * @param lnac Output vector of ln activity coefficients. Length: m_kk.
803 */
804 virtual void getLnActivityCoefficients(double* lnac) const;
805
806 //! @}
807 //! @name Partial Molar Properties of the Solution
808 //! @{
809
810 //! Get the species chemical potentials. Units: J/kmol.
811 /*!
812 * This function returns a vector of chemical potentials of the species in
813 * solution at the current temperature, pressure and mole fraction of the
814 * solution.
815 *
816 * @param mu Output vector of species chemical
817 * potentials. Length: m_kk. Units: J/kmol
818 */
819 virtual void getChemPotentials(double* mu) const {
820 throw NotImplementedError("ThermoPhase::getChemPotentials",
821 "Not implemented for phase type '{}'", type());
822 }
823
824 //! Get the species electrochemical potentials.
825 /*!
826 * These are partial molar quantities. This method adds a term @f$ F z_k
827 * \phi_p @f$ to each chemical potential. The electrochemical potential of
828 * species k in a phase p, @f$ \zeta_k @f$, is related to the chemical
829 * potential via the following equation,
830 *
831 * @f[
832 * \zeta_{k}(T,P) = \mu_{k}(T,P) + F z_k \phi_p
833 * @f]
834 *
835 * @param mu Output vector of species electrochemical
836 * potentials. Length: m_kk. Units: J/kmol
837 */
838 void getElectrochemPotentials(double* mu) const;
839
840 //! Returns an array of partial molar enthalpies for the species
841 //! in the mixture. Units (J/kmol)
842 /*!
843 * @param hbar Output vector of species partial molar enthalpies.
844 * Length: m_kk. units are J/kmol.
845 */
846 virtual void getPartialMolarEnthalpies(double* hbar) const {
847 throw NotImplementedError("ThermoPhase::getPartialMolarEnthalpies",
848 "Not implemented for phase type '{}'", type());
849 }
850
851 //! Returns an array of partial molar entropies of the species in the
852 //! solution. Units: J/kmol/K.
853 /*!
854 * @param sbar Output vector of species partial molar entropies.
855 * Length = m_kk. units are J/kmol/K.
856 */
857 virtual void getPartialMolarEntropies(double* sbar) const {
858 throw NotImplementedError("ThermoPhase::getPartialMolarEntropies",
859 "Not implemented for phase type '{}'", type());
860 }
861
862 //! Return an array of partial molar internal energies for the
863 //! species in the mixture. Units: J/kmol.
864 /*!
865 * @param ubar Output vector of species partial molar internal energies.
866 * Length = m_kk. units are J/kmol.
867 */
868 virtual void getPartialMolarIntEnergies(double* ubar) const {
869 throw NotImplementedError("ThermoPhase::getPartialMolarIntEnergies",
870 "Not implemented for phase type '{}'", type());
871 }
872
873 //! Return an array of partial molar heat capacities for the
874 //! species in the mixture. Units: J/kmol/K
875 /*!
876 * @param cpbar Output vector of species partial molar heat
877 * capacities at constant pressure.
878 * Length = m_kk. units are J/kmol/K.
879 */
880 virtual void getPartialMolarCp(double* cpbar) const {
881 throw NotImplementedError("ThermoPhase::getPartialMolarCp",
882 "Not implemented for phase type '{}'", type());
883 }
884
885 //! Return an array of partial molar volumes for the
886 //! species in the mixture. Units: m^3/kmol.
887 /*!
888 * @param vbar Output vector of species partial molar volumes.
889 * Length = m_kk. units are m^3/kmol.
890 */
891 virtual void getPartialMolarVolumes(double* vbar) const {
892 throw NotImplementedError("ThermoPhase::getPartialMolarVolumes",
893 "Not implemented for phase type '{}'", type());
894 }
895
896 //! @}
897 //! @name Properties of the Standard State of the Species in the Solution
898 //! @{
899
900 //! Get the array of chemical potentials at unit activity for the species at
901 //! their standard states at the current *T* and *P* of the solution.
902 /*!
903 * These are the standard state chemical potentials @f$ \mu^0_k(T,P)
904 * @f$. The values are evaluated at the current temperature and pressure of
905 * the solution
906 *
907 * @param mu Output vector of chemical potentials.
908 * Length: m_kk.
909 */
910 virtual void getStandardChemPotentials(double* mu) const {
911 throw NotImplementedError("ThermoPhase::getStandardChemPotentials",
912 "Not implemented for phase type '{}'", type());
913 }
914
915 //! Get the nondimensional Enthalpy functions for the species at their
916 //! standard states at the current *T* and *P* of the solution.
917 /*!
918 * @param hrt Output vector of nondimensional standard state enthalpies.
919 * Length: m_kk.
920 */
921 virtual void getEnthalpy_RT(double* hrt) const {
922 throw NotImplementedError("ThermoPhase::getEnthalpy_RT",
923 "Not implemented for phase type '{}'", type());
924 }
925
926 //! Get the array of nondimensional Entropy functions for the standard state
927 //! species at the current *T* and *P* of the solution.
928 /*!
929 * @param sr Output vector of nondimensional standard state entropies.
930 * Length: m_kk.
931 */
932 virtual void getEntropy_R(double* sr) const {
933 throw NotImplementedError("ThermoPhase::getEntropy_R",
934 "Not implemented for phase type '{}'", type());
935 }
936
937 //! Get the nondimensional Gibbs functions for the species in their standard
938 //! states at the current *T* and *P* of the solution.
939 /*!
940 * @param grt Output vector of nondimensional standard state Gibbs free
941 * energies. Length: m_kk.
942 */
943 virtual void getGibbs_RT(double* grt) const {
944 throw NotImplementedError("ThermoPhase::getGibbs_RT",
945 "Not implemented for phase type '{}'", type());
946 }
947
948 //! Returns the vector of nondimensional Internal Energies of the standard
949 //! state species at the current *T* and *P* of the solution
950 /*!
951 * @param urt output vector of nondimensional standard state internal energies
952 * of the species. Length: m_kk.
953 */
954 virtual void getIntEnergy_RT(double* urt) const {
955 throw NotImplementedError("ThermoPhase::getIntEnergy_RT",
956 "Not implemented for phase type '{}'", type());
957 }
958
959 //! Get the nondimensional Heat Capacities at constant pressure for the
960 //! species standard states at the current *T* and *P* of the
961 //! solution
962 /*!
963 * @param cpr Output vector of nondimensional standard state heat
964 * capacities. Length: m_kk.
965 */
966 virtual void getCp_R(double* cpr) const {
967 throw NotImplementedError("ThermoPhase::getCp_R",
968 "Not implemented for phase type '{}'", type());
969 }
970
971 //! Get the molar volumes of the species standard states at the current
972 //! *T* and *P* of the solution.
973 /*!
974 * units = m^3 / kmol
975 *
976 * @param vol Output vector containing the standard state volumes.
977 * Length: m_kk.
978 */
979 virtual void getStandardVolumes(double* vol) const {
980 throw NotImplementedError("ThermoPhase::getStandardVolumes",
981 "Not implemented for phase type '{}'", type());
982 }
983
984 //! @}
985 //! @name Thermodynamic Values for the Species Reference States
986 //! @{
987
988 //! Returns the vector of nondimensional enthalpies of the reference state
989 //! at the current temperature of the solution and the reference pressure
990 //! for the species.
991 /*!
992 * @param hrt Output vector containing the nondimensional reference
993 * state enthalpies. Length: m_kk.
994 */
995 virtual void getEnthalpy_RT_ref(double* hrt) const {
996 throw NotImplementedError("ThermoPhase::getEnthalpy_RT_ref",
997 "Not implemented for phase type '{}'", type());
998 }
999
1000 //! Returns the vector of nondimensional Gibbs Free Energies of the
1001 //! reference state at the current temperature of the solution and the
1002 //! reference pressure for the species.
1003 /*!
1004 * @param grt Output vector containing the nondimensional reference state
1005 * Gibbs Free energies. Length: m_kk.
1006 */
1007 virtual void getGibbs_RT_ref(double* grt) const {
1008 throw NotImplementedError("ThermoPhase::getGibbs_RT_ref",
1009 "Not implemented for phase type '{}'", type());
1010 }
1011
1012 //! Returns the vector of the Gibbs function of the reference state at the
1013 //! current temperature of the solution and the reference pressure for the
1014 //! species.
1015 /*!
1016 * @param g Output vector containing the reference state
1017 * Gibbs Free energies. Length: m_kk. Units: J/kmol.
1018 */
1019 virtual void getGibbs_ref(double* g) const {
1020 throw NotImplementedError("ThermoPhase::getGibbs_ref",
1021 "Not implemented for phase type '{}'", type());
1022 }
1023
1024 //! Returns the vector of nondimensional entropies of the reference state at
1025 //! the current temperature of the solution and the reference pressure for
1026 //! each species.
1027 /*!
1028 * @param er Output vector containing the nondimensional reference
1029 * state entropies. Length: m_kk.
1030 */
1031 virtual void getEntropy_R_ref(double* er) const {
1032 throw NotImplementedError("ThermoPhase::getEntropy_R_ref",
1033 "Not implemented for phase type '{}'", type());
1034 }
1035
1036 //! Returns the vector of nondimensional internal Energies of the reference
1037 //! state at the current temperature of the solution and the reference
1038 //! pressure for each species.
1039 /*!
1040 * @param urt Output vector of nondimensional reference state internal
1041 * energies of the species. Length: m_kk
1042 */
1043 virtual void getIntEnergy_RT_ref(double* urt) const {
1044 throw NotImplementedError("ThermoPhase::getIntEnergy_RT_ref",
1045 "Not implemented for phase type '{}'", type());
1046 }
1047
1048 //! Returns the vector of nondimensional constant pressure heat capacities
1049 //! of the reference state at the current temperature of the solution and
1050 //! reference pressure for each species.
1051 /*!
1052 * @param cprt Output vector of nondimensional reference state
1053 * heat capacities at constant pressure for the species.
1054 * Length: m_kk
1055 */
1056 virtual void getCp_R_ref(double* cprt) const {
1057 throw NotImplementedError("ThermoPhase::getCp_R_ref",
1058 "Not implemented for phase type '{}'", type());
1059 }
1060
1061 //! Get the molar volumes of the species reference states at the current
1062 //! *T* and *P_ref* of the solution.
1063 /*!
1064 * units = m^3 / kmol
1065 *
1066 * @param vol Output vector containing the standard state volumes.
1067 * Length: m_kk.
1068 */
1069 virtual void getStandardVolumes_ref(double* vol) const {
1070 throw NotImplementedError("ThermoPhase::getStandardVolumes_ref",
1071 "Not implemented for phase type '{}'", type());
1072 }
1073
1074 // The methods below are not virtual, and should not be overloaded.
1075
1076 //! @}
1077 //! @name Specific Properties
1078 //! @{
1079
1080 //! Specific enthalpy. Units: J/kg.
1081 double enthalpy_mass() const {
1083 }
1084
1085 //! Specific internal energy. Units: J/kg.
1086 double intEnergy_mass() const {
1088 }
1089
1090 //! Specific entropy. Units: J/kg/K.
1091 double entropy_mass() const {
1093 }
1094
1095 //! Specific Gibbs function. Units: J/kg.
1096 double gibbs_mass() const {
1098 }
1099
1100 //! Specific heat at constant pressure and composition [J/kg/K].
1101 double cp_mass() const {
1102 return cp_mole()/meanMolecularWeight();
1103 }
1104
1105 //! Specific heat at constant volume and composition [J/kg/K].
1106 double cv_mass() const {
1107 return cv_mole()/meanMolecularWeight();
1108 }
1109 //! @}
1110
1111 //! Return the Gas Constant multiplied by the current temperature
1112 /*!
1113 * The units are Joules kmol-1
1114 */
1115 double RT() const {
1116 return temperature() * GasConstant;
1117 }
1118
1119 //! @name Setting the State
1120 //! @anchor sec-thermophase-set-state
1121 //!
1122 //! These methods set all or part of the thermodynamic state.
1123 //! @{
1124
1125 //! Set the temperature (K), pressure (Pa), and mole fractions.
1126 /*!
1127 * Note, the mole fractions are set first before the pressure is set.
1128 * Setting the pressure may involve the solution of a nonlinear equation.
1129 *
1130 * @param t Temperature (K)
1131 * @param p Pressure (Pa)
1132 * @param x Vector of mole fractions.
1133 * Length is equal to m_kk.
1134 */
1135 virtual void setState_TPX(double t, double p, const double* x);
1136
1137 //! Set the temperature (K), pressure (Pa), and mole fractions.
1138 /*!
1139 * Note, the mole fractions are set first before the pressure is set.
1140 * Setting the pressure may involve the solution of a nonlinear equation.
1141 *
1142 * @param t Temperature (K)
1143 * @param p Pressure (Pa)
1144 * @param x Composition map of mole fractions. Species not in
1145 * the composition map are assumed to have zero mole fraction
1146 */
1147 virtual void setState_TPX(double t, double p, const Composition& x);
1148
1149 //! Set the temperature (K), pressure (Pa), and mole fractions.
1150 /*!
1151 * Note, the mole fractions are set first before the pressure is set.
1152 * Setting the pressure may involve the solution of a nonlinear equation.
1153 *
1154 * @param t Temperature (K)
1155 * @param p Pressure (Pa)
1156 * @param x String containing a composition map of the mole fractions.
1157 * Species not in the composition map are assumed to have zero
1158 * mole fraction
1159 */
1160 virtual void setState_TPX(double t, double p, const string& x);
1161
1162 //! Set the internally stored temperature (K), pressure (Pa), and mass
1163 //! fractions of the phase.
1164 /*!
1165 * Note, the mass fractions are set first before the pressure is set.
1166 * Setting the pressure may involve the solution of a nonlinear equation.
1167 *
1168 * @param t Temperature (K)
1169 * @param p Pressure (Pa)
1170 * @param y Vector of mass fractions.
1171 * Length is equal to m_kk.
1172 */
1173 virtual void setState_TPY(double t, double p, const double* y);
1174
1175 //! Set the internally stored temperature (K), pressure (Pa), and mass
1176 //! fractions of the phase
1177 /*!
1178 * Note, the mass fractions are set first before the pressure is set.
1179 * Setting the pressure may involve the solution of a nonlinear equation.
1180 *
1181 * @param t Temperature (K)
1182 * @param p Pressure (Pa)
1183 * @param y Composition map of mass fractions. Species not in
1184 * the composition map are assumed to have zero mass fraction
1185 */
1186 virtual void setState_TPY(double t, double p, const Composition& y);
1187
1188 //! Set the internally stored temperature (K), pressure (Pa), and mass
1189 //! fractions of the phase
1190 /*!
1191 * Note, the mass fractions are set first before the pressure is set.
1192 * Setting the pressure may involve the solution of a nonlinear equation.
1193 *
1194 * @param t Temperature (K)
1195 * @param p Pressure (Pa)
1196 * @param y String containing a composition map of the mass fractions.
1197 * Species not in the composition map are assumed to have zero
1198 * mass fraction
1199 */
1200 virtual void setState_TPY(double t, double p, const string& y);
1201
1202 //! Set the temperature (K) and pressure (Pa)
1203 /*!
1204 * Setting the pressure may involve the solution of a nonlinear equation.
1205 *
1206 * @param t Temperature (K)
1207 * @param p Pressure (Pa)
1208 */
1209 virtual void setState_TP(double t, double p);
1210
1211 //! Set the internally stored specific enthalpy (J/kg) and pressure (Pa) of
1212 //! the phase.
1213 /*!
1214 * @param h Specific enthalpy (J/kg)
1215 * @param p Pressure (Pa)
1216 * @param tol Optional parameter setting the tolerance of the calculation.
1217 * Important for some applications where numerical Jacobians
1218 * are being calculated.
1219 */
1220 virtual void setState_HP(double h, double p, double tol=1e-9);
1221
1222 //! Set the specific internal energy (J/kg) and specific volume (m^3/kg).
1223 /*!
1224 * This function fixes the internal state of the phase so that the specific
1225 * internal energy and specific volume have the value of the input
1226 * parameters.
1227 *
1228 * @param u specific internal energy (J/kg)
1229 * @param v specific volume (m^3/kg).
1230 * @param tol Optional parameter setting the tolerance of the calculation.
1231 * Important for some applications where numerical Jacobians
1232 * are being calculated.
1233 */
1234 virtual void setState_UV(double u, double v, double tol=1e-9);
1235
1236 //! Set the specific entropy (J/kg/K) and pressure (Pa).
1237 /*!
1238 * This function fixes the internal state of the phase so that the specific
1239 * entropy and the pressure have the value of the input parameters.
1240 *
1241 * @param s specific entropy (J/kg/K)
1242 * @param p specific pressure (Pa).
1243 * @param tol Optional parameter setting the tolerance of the calculation.
1244 * Important for some applications where numerical Jacobians
1245 * are being calculated.
1246 */
1247 virtual void setState_SP(double s, double p, double tol=1e-9);
1248
1249 //! Set the specific entropy (J/kg/K) and specific volume (m^3/kg).
1250 /*!
1251 * This function fixes the internal state of the phase so that the specific
1252 * entropy and specific volume have the value of the input parameters.
1253 *
1254 * @param s specific entropy (J/kg/K)
1255 * @param v specific volume (m^3/kg).
1256 * @param tol Optional parameter setting the tolerance of the calculation.
1257 * Important for some applications where numerical Jacobians
1258 * are being calculated.
1259 */
1260 virtual void setState_SV(double s, double v, double tol=1e-9);
1261
1262 //! Set the specific entropy (J/kg/K) and temperature (K).
1263 /*!
1264 * This function fixes the internal state of the phase so that the specific
1265 * entropy and temperature have the value of the input parameters.
1266 * This base class function will throw an exception if not overridden.
1267 *
1268 * @param s specific entropy (J/kg/K)
1269 * @param t temperature (K)
1270 * @param tol Optional parameter setting the tolerance of the calculation.
1271 * Important for some applications where numerical Jacobians
1272 * are being calculated.
1273 */
1274 virtual void setState_ST(double s, double t, double tol=1e-9) {
1275 throw NotImplementedError("ThermoPhase::setState_ST",
1276 "Not implemented for phase type '{}'", type());
1277 }
1278
1279 //! Set the temperature (K) and specific volume (m^3/kg).
1280 /*!
1281 * This function fixes the internal state of the phase so that the
1282 * temperature and specific volume have the value of the input parameters.
1283 * This base class function will throw an exception if not overridden.
1284 *
1285 * @param t temperature (K)
1286 * @param v specific volume (m^3/kg)
1287 * @param tol Optional parameter setting the tolerance of the calculation.
1288 * Important for some applications where numerical Jacobians
1289 * are being calculated.
1290 */
1291 virtual void setState_TV(double t, double v, double tol=1e-9) {
1292 throw NotImplementedError("ThermoPhase::setState_TV",
1293 "Not implemented for phase type '{}'", type());
1294 }
1295
1296 //! Set the pressure (Pa) and specific volume (m^3/kg).
1297 /*!
1298 * This function fixes the internal state of the phase so that the
1299 * pressure and specific volume have the value of the input parameters.
1300 * This base class function will throw an exception if not overridden.
1301 *
1302 * @param p pressure (Pa)
1303 * @param v specific volume (m^3/kg)
1304 * @param tol Optional parameter setting the tolerance of the calculation.
1305 * Important for some applications where numerical Jacobians
1306 * are being calculated.
1307 */
1308 virtual void setState_PV(double p, double v, double tol=1e-9) {
1309 throw NotImplementedError("ThermoPhase::setState_PV",
1310 "Not implemented for phase type '{}'", type());
1311 }
1312
1313 //! Set the specific internal energy (J/kg) and pressure (Pa).
1314 /*!
1315 * This function fixes the internal state of the phase so that the specific
1316 * internal energy and pressure have the value of the input parameters.
1317 * This base class function will throw an exception if not overridden.
1318 *
1319 * @param u specific internal energy (J/kg)
1320 * @param p pressure (Pa)
1321 * @param tol Optional parameter setting the tolerance of the calculation.
1322 * Important for some applications where numerical Jacobians
1323 * are being calculated.
1324 */
1325 virtual void setState_UP(double u, double p, double tol=1e-9) {
1326 throw NotImplementedError("ThermoPhase::setState_UP",
1327 "Not implemented for phase type '{}'", type());
1328 }
1329
1330 //! Set the specific volume (m^3/kg) and the specific enthalpy (J/kg)
1331 /*!
1332 * This function fixes the internal state of the phase so that the specific
1333 * volume and the specific enthalpy have the value of the input parameters.
1334 * This base class function will throw an exception if not overridden.
1335 *
1336 * @param v specific volume (m^3/kg)
1337 * @param h specific enthalpy (J/kg)
1338 * @param tol Optional parameter setting the tolerance of the calculation.
1339 * Important for some applications where numerical Jacobians
1340 * are being calculated.
1341 */
1342 virtual void setState_VH(double v, double h, double tol=1e-9) {
1343 throw NotImplementedError("ThermoPhase::setState_VH",
1344 "Not implemented for phase type '{}'", type());
1345 }
1346
1347 //! Set the temperature (K) and the specific enthalpy (J/kg)
1348 /*!
1349 * This function fixes the internal state of the phase so that the
1350 * temperature and specific enthalpy have the value of the input parameters.
1351 * This base class function will throw an exception if not overridden.
1352 *
1353 * @param t temperature (K)
1354 * @param h specific enthalpy (J/kg)
1355 * @param tol Optional parameter setting the tolerance of the calculation.
1356 * Important for some applications where numerical Jacobians
1357 * are being calculated.
1358 */
1359 virtual void setState_TH(double t, double h, double tol=1e-9) {
1360 throw NotImplementedError("ThermoPhase::setState_TH",
1361 "Not implemented for phase type '{}'", type());
1362 }
1363
1364 //! Set the specific entropy (J/kg/K) and the specific enthalpy (J/kg)
1365 /*!
1366 * This function fixes the internal state of the phase so that the
1367 * temperature and pressure have the value of the input parameters.
1368 * This base class function will throw an exception if not overridden.
1369 *
1370 * @param s specific entropy (J/kg/K)
1371 * @param h specific enthalpy (J/kg)
1372 * @param tol Optional parameter setting the tolerance of the calculation.
1373 * Important for some applications where numerical Jacobians
1374 * are being calculated.
1375 */
1376 virtual void setState_SH(double s, double h, double tol=1e-9) {
1377 throw NotImplementedError("ThermoPhase::setState_SH",
1378 "Not implemented for phase type '{}'", type());
1379 }
1380
1381 //! Set the density (kg/m**3) and pressure (Pa) at constant composition
1382 /*!
1383 * This method must be reimplemented in derived classes, where it may
1384 * involve the solution of a nonlinear equation. Within %Cantera, the
1385 * independent variable is the density. Therefore, this function solves for
1386 * the temperature that will yield the desired input pressure and density.
1387 * The composition is held constant during this process.
1388 *
1389 * This base class function will print an error, if not overridden.
1390 *
1391 * @param rho Density (kg/m^3)
1392 * @param p Pressure (Pa)
1393 * @since New in %Cantera 3.0.
1394 */
1395 virtual void setState_DP(double rho, double p) {
1396 throw NotImplementedError("ThermoPhase::setState_DP",
1397 "Not implemented for phase type '{}'", type());
1398 }
1399
1400 //! Set the state using an AnyMap containing any combination of properties
1401 //! supported by the thermodynamic model
1402 /*!
1403 * Accepted keys are:
1404 * * `X` (mole fractions)
1405 * * `Y` (mass fractions)
1406 * * `T` or `temperature`
1407 * * `P` or `pressure` [Pa]
1408 * * `H` or `enthalpy` [J/kg]
1409 * * `U` or `internal-energy` [J/kg]
1410 * * `S` or `entropy` [J/kg/K]
1411 * * `V` or `specific-volume` [m^3/kg]
1412 * * `D` or `density` [kg/m^3]
1413 *
1414 * Composition can be specified as either an AnyMap of species names to
1415 * values or as a composition string. All other values can be given as
1416 * floating point values in Cantera's default units, or as strings with the
1417 * units specified, which will be converted using the Units class.
1418 *
1419 * If no thermodynamic property pair is given, or only one of temperature or
1420 * pressure is given, then 298.15 K and 101325 Pa will be used as necessary
1421 * to fully set the state.
1422 */
1423 virtual void setState(const AnyMap& state);
1424
1425 //! @}
1426 //! @name Set Mixture Composition by Mixture Fraction
1427 //! @{
1428
1429 //! Set the mixture composition according to the
1430 //! mixture fraction = kg fuel / (kg oxidizer + kg fuel)
1431 /*!
1432 * Fuel and oxidizer compositions are given either as
1433 * mole fractions or mass fractions (specified by `basis`)
1434 * and do not need to be normalized. Pressure and temperature are
1435 * kept constant. Elements C, S, H and O are considered for the oxidation.
1436 *
1437 * @param mixFrac mixture fraction (between 0 and 1)
1438 * @param fuelComp composition of the fuel
1439 * @param oxComp composition of the oxidizer
1440 * @param basis either ThermoPhase::molar or ThermoPhase::mass.
1441 * Fuel and oxidizer composition are interpreted
1442 * as mole or mass fractions (default: molar)
1443 */
1444 void setMixtureFraction(double mixFrac, const double* fuelComp,
1445 const double* oxComp, ThermoBasis basis=ThermoBasis::molar);
1446 //! @copydoc ThermoPhase::setMixtureFraction
1447 void setMixtureFraction(double mixFrac, const string& fuelComp,
1448 const string& oxComp, ThermoBasis basis=ThermoBasis::molar);
1449 //! @copydoc ThermoPhase::setMixtureFraction
1450 void setMixtureFraction(double mixFrac, const Composition& fuelComp,
1451 const Composition& oxComp, ThermoBasis basis=ThermoBasis::molar);
1452 //! @}
1453 //! @name Compute Mixture Fraction
1454 //! @{
1455
1456 //! Compute the mixture fraction = kg fuel / (kg oxidizer + kg fuel) for
1457 //! the current mixture given fuel and oxidizer compositions.
1458 /*!
1459 * Fuel and oxidizer compositions are given either as
1460 * mole fractions or mass fractions (specified by `basis`)
1461 * and do not need to be normalized.
1462 * The mixture fraction @f$ Z @f$ can be computed from a single element
1463 * @f[ Z_m = \frac{Z_{\mathrm{mass},m}-Z_{\mathrm{mass},m,\mathrm{ox}}}
1464 * {Z_{\mathrm{mass},\mathrm{fuel}}-Z_{\mathrm{mass},m,\mathrm{ox}}} @f] where
1465 * @f$ Z_{\mathrm{mass},m} @f$ is the elemental mass fraction of element m
1466 * in the mixture, and @f$ Z_{\mathrm{mass},m,\mathrm{ox}} @f$ and
1467 * @f$ Z_{\mathrm{mass},m,\mathrm{fuel}} @f$ are the elemental mass fractions
1468 * of the oxidizer and fuel, or from the Bilger mixture fraction,
1469 * which considers the elements C, S, H and O @cite bilger1979
1470 * @f[ Z_{\mathrm{Bilger}} = \frac{\beta-\beta_{\mathrm{ox}}}
1471 * {\beta_{\mathrm{fuel}}-\beta_{\mathrm{ox}}} @f]
1472 * with @f$ \beta = 2\frac{Z_C}{M_C}+2\frac{Z_S}{M_S}+\frac{1}{2}\frac{Z_H}{M_H}
1473 * -\frac{Z_O}{M_O} @f$
1474 * and @f$ M_m @f$ the atomic weight of element @f$ m @f$.
1475 *
1476 * @param fuelComp composition of the fuel
1477 * @param oxComp composition of the oxidizer
1478 * @param basis either ThermoBasis::molar or ThermoBasis::mass.
1479 * Fuel and oxidizer composition are interpreted
1480 * as mole or mass fractions (default: molar)
1481 * @param element either "Bilger" to compute the mixture fraction
1482 * in terms of the Bilger mixture fraction, or
1483 * an element name, to compute the mixture fraction
1484 * based on a single element (default: "Bilger")
1485 * @returns mixture fraction (kg fuel / kg mixture)
1486 */
1487 double mixtureFraction(const double* fuelComp, const double* oxComp,
1488 ThermoBasis basis=ThermoBasis::molar,
1489 const string& element="Bilger") const;
1490 //! @copydoc ThermoPhase::mixtureFraction
1491 double mixtureFraction(const string& fuelComp, const string& oxComp,
1492 ThermoBasis basis=ThermoBasis::molar,
1493 const string& element="Bilger") const;
1494 //! @copydoc ThermoPhase::mixtureFraction
1495 double mixtureFraction(const Composition& fuelComp, const Composition& oxComp,
1496 ThermoBasis basis=ThermoBasis::molar,
1497 const string& element="Bilger") const;
1498 //! @}
1499 //! @name Set Mixture Composition by Equivalence Ratio
1500 //! @{
1501
1502 //! Set the mixture composition according to the equivalence ratio.
1503 /*!
1504 * Fuel and oxidizer compositions are given either as
1505 * mole fractions or mass fractions (specified by `basis`)
1506 * and do not need to be normalized. Pressure and temperature are
1507 * kept constant. Elements C, S, H and O are considered for the oxidation.
1508 *
1509 * @param phi equivalence ratio
1510 * @param fuelComp composition of the fuel
1511 * @param oxComp composition of the oxidizer
1512 * @param basis either ThermoBasis::mole or ThermoBasis::mass.
1513 * Fuel and oxidizer composition are interpreted
1514 * as mole or mass fractions (default: molar)
1515 */
1516 void setEquivalenceRatio(double phi, const double* fuelComp, const double* oxComp,
1517 ThermoBasis basis=ThermoBasis::molar);
1518 //! @copydoc ThermoPhase::setEquivalenceRatio
1519 void setEquivalenceRatio(double phi, const string& fuelComp,
1520 const string& oxComp, ThermoBasis basis=ThermoBasis::molar);
1521 //! @copydoc ThermoPhase::setEquivalenceRatio
1522 void setEquivalenceRatio(double phi, const Composition& fuelComp,
1523 const Composition& oxComp, ThermoBasis basis=ThermoBasis::molar);
1524 //! @}
1525
1526 //! @name Compute Equivalence Ratio
1527 //! @{
1528
1529 //! Compute the equivalence ratio for the current mixture
1530 //! given the compositions of fuel and oxidizer
1531 /*!
1532 * The equivalence ratio @f$ \phi @f$ is computed from
1533 * @f[ \phi = \frac{Z}{1-Z}\frac{1-Z_{\mathrm{st}}}{Z_{\mathrm{st}}} @f]
1534 * where @f$ Z @f$ is the Bilger mixture fraction @cite bilger1979 of the mixture
1535 * given the specified fuel and oxidizer compositions
1536 * @f$ Z_{\mathrm{st}} @f$ is the mixture fraction at stoichiometric
1537 * conditions. Fuel and oxidizer compositions are given either as
1538 * mole fractions or mass fractions (specified by `basis`)
1539 * and do not need to be normalized.
1540 * Elements C, S, H and O are considered for the oxidation.
1541 * If fuel and oxidizer composition are unknown or not specified,
1542 * use the version that takes no arguments.
1543 *
1544 * @param fuelComp composition of the fuel
1545 * @param oxComp composition of the oxidizer
1546 * @param basis either ThermoPhase::mole or ThermoPhase::mass.
1547 * Fuel and oxidizer composition are interpreted
1548 * as mole or mass fractions (default: molar)
1549 * @returns equivalence ratio
1550 * @see mixtureFraction for the definition of the Bilger mixture fraction
1551 * @see equivalenceRatio() for the computation of @f$ \phi @f$ without arguments
1552 */
1553 double equivalenceRatio(const double* fuelComp, const double* oxComp,
1554 ThermoBasis basis=ThermoBasis::molar) const;
1555 //! @copydoc ThermoPhase::equivalenceRatio
1556 double equivalenceRatio(const string& fuelComp, const string& oxComp,
1557 ThermoBasis basis=ThermoBasis::molar) const;
1558 //! @copydoc ThermoPhase::equivalenceRatio
1559 double equivalenceRatio(const Composition& fuelComp,
1560 const Composition& oxComp, ThermoBasis basis=ThermoBasis::molar) const;
1561 //! @}
1562
1563 //! Compute the equivalence ratio for the current mixture
1564 //! from available oxygen and required oxygen
1565 /*!
1566 * Computes the equivalence ratio @f$ \phi @f$ from
1567 * @f[ \phi =
1568 * \frac{Z_{\mathrm{mole},C} + Z_{\mathrm{mole},S} + \frac{1}{4}Z_{\mathrm{mole},H}}
1569 * {\frac{1}{2}Z_{\mathrm{mole},O}} @f]
1570 * where @f$ Z_{\mathrm{mole},m} @f$ is the elemental mole fraction
1571 * of element @f$ m @f$. In this special case, the equivalence ratio
1572 * is independent of a fuel or oxidizer composition because it only
1573 * considers the locally available oxygen compared to the required oxygen
1574 * for complete oxidation. It is the same as assuming that the oxidizer
1575 * only contains O (and inert elements) and the fuel contains only
1576 * H, C and S (and inert elements). If either of these conditions is
1577 * not met, use the version of this functions which takes the fuel and
1578 * oxidizer compositions as input
1579 *
1580 * @returns equivalence ratio
1581 * @see equivalenceRatio compute the equivalence ratio from specific
1582 * fuel and oxidizer compositions
1583 */
1584 double equivalenceRatio() const;
1585
1586 //! @name Compute Stoichiometric Air to Fuel Ratio
1587 //! @{
1588
1589 //! Compute the stoichiometric air to fuel ratio (kg oxidizer / kg fuel)
1590 //! given fuel and oxidizer compositions.
1591 /*!
1592 * Fuel and oxidizer compositions are given either as
1593 * mole fractions or mass fractions (specified by `basis`)
1594 * and do not need to be normalized.
1595 * Elements C, S, H and O are considered for the oxidation.
1596 * Note that the stoichiometric air to fuel ratio @f$ \mathit{AFR}_{\mathrm{st}} @f$
1597 * does not depend on the current mixture composition. The current air to fuel ratio
1598 * can be computed from @f$ \mathit{AFR} = \mathit{AFR}_{\mathrm{st}}/\phi @f$
1599 * where @f$ \phi @f$ is the equivalence ratio of the current mixture
1600 *
1601 * @param fuelComp composition of the fuel
1602 * @param oxComp composition of the oxidizer
1603 * @param basis either ThermoPhase::mole or ThermoPhase::mass.
1604 * Fuel and oxidizer composition are interpreted
1605 * as mole or mass fractions (default: molar)
1606 * @returns Stoichiometric Air to Fuel Ratio (kg oxidizer / kg fuel)
1607 */
1608 double stoichAirFuelRatio(const double* fuelComp, const double* oxComp,
1609 ThermoBasis basis=ThermoBasis::molar) const;
1610 //! @copydoc ThermoPhase::stoichAirFuelRatio
1611 double stoichAirFuelRatio(const string& fuelComp, const string& oxComp,
1612 ThermoBasis basis=ThermoBasis::molar) const;
1613 //! @copydoc ThermoPhase::stoichAirFuelRatio
1614 double stoichAirFuelRatio(const Composition& fuelComp,
1615 const Composition& oxComp, ThermoBasis basis=ThermoBasis::molar) const;
1616 //! @}
1617
1618 //! Return intermediate or model-specific parameters used by particular
1619 //! derived classes. Specific parameters are described in overridden
1620 //! methods of classes that derive from the base class.
1622 {
1623 return AnyMap();
1624 }
1625
1626private:
1627
1628 //! Carry out work in HP and UV calculations.
1629 /*!
1630 * @param h Specific enthalpy or internal energy (J/kg)
1631 * @param p Pressure (Pa) or specific volume (m^3/kg)
1632 * @param tol Optional parameter setting the tolerance of the calculation.
1633 * Important for some applications where numerical Jacobians
1634 * are being calculated.
1635 * @param doUV True if solving for UV, false for HP.
1636 */
1637 void setState_HPorUV(double h, double p, double tol=1e-9, bool doUV = false);
1638
1639 //! Carry out work in SP and SV calculations.
1640 /*!
1641 * @param s Specific entropy (J/kg)
1642 * @param p Pressure (Pa) or specific volume (m^3/kg)
1643 * @param tol Optional parameter setting the tolerance of the calculation.
1644 * Important for some applications where numerical Jacobians
1645 * are being calculated.
1646 * @param doSV True if solving for SV, false for SP.
1647 */
1648 void setState_SPorSV(double s, double p, double tol=1e-9, bool doSV = false);
1649
1650 //! Helper function used by setState_HPorUV and setState_SPorSV.
1651 //! Sets the temperature and (if set_p is true) the pressure.
1652 void setState_conditional_TP(double t, double p, bool set_p);
1653
1654 //! Helper function for computing the amount of oxygen required for complete
1655 //! oxidation.
1656 /*!
1657 * @param y array of (possibly non-normalized) mass fractions (length m_kk)
1658 * @returns amount of required oxygen in kmol O / kg mixture
1659 */
1660 double o2Required(const double* y) const;
1661
1662 //! Helper function for computing the amount of oxygen
1663 //! available in the current mixture.
1664 /*!
1665 * @param y array of (possibly non-normalized) mass fractions (length m_kk)
1666 * @returns amount of O in kmol O / kg mixture
1667 */
1668 double o2Present(const double* y) const;
1669
1670public:
1671 //! @name Chemical Equilibrium
1672 //!
1673 //! Chemical equilibrium.
1674 //! @{
1675
1676 //! Equilibrate a ThermoPhase object
1677 /*!
1678 * Set this phase to chemical equilibrium by calling one of several
1679 * equilibrium solvers. The XY parameter indicates what two thermodynamic
1680 * quantities are to be held constant during the equilibration process.
1681 *
1682 * @param XY String representation of what two properties are being
1683 * held constant
1684 * @param solver Name of the solver to be used to equilibrate the phase.
1685 * If solver = 'element_potential', the ChemEquil element potential
1686 * solver will be used. If solver = 'vcs', the VCS solver will be used.
1687 * If solver = 'gibbs', the MultiPhaseEquil solver will be used. If
1688 * solver = 'auto', the solvers will be tried in order if the initial
1689 * solver(s) fail.
1690 * @param rtol Relative tolerance
1691 * @param max_steps Maximum number of steps to take to find the solution
1692 * @param max_iter For the 'gibbs' and 'vcs' solvers, this is the maximum
1693 * number of outer temperature or pressure iterations to take when T
1694 * and/or P is not held fixed.
1695 * @param estimate_equil For MultiPhaseEquil solver, an integer indicating
1696 * whether the solver should estimate its own initial condition. If 0,
1697 * the initial mole fraction vector in the ThermoPhase object is used
1698 * as the initial condition. If 1, the initial mole fraction vector is
1699 * used if the element abundances are satisfied. If -1, the initial
1700 * mole fraction vector is thrown out, and an estimate is formulated.
1701 * @param log_level loglevel Controls amount of diagnostic output.
1702 * log_level=0 suppresses diagnostics, and increasingly-verbose
1703 * messages are written as loglevel increases.
1704 *
1705 * @ingroup equilGroup
1706 */
1707 void equilibrate(const string& XY, const string& solver="auto",
1708 double rtol=1e-9, int max_steps=50000, int max_iter=100,
1709 int estimate_equil=0, int log_level=0);
1710
1711 //!This method is used by the ChemEquil equilibrium solver.
1712 /*!
1713 * It sets the state such that the chemical potentials satisfy
1714 * @f[ \frac{\mu_k}{\hat R T} = \sum_m A_{k,m}
1715 * \left(\frac{\lambda_m} {\hat R T}\right) @f] where
1716 * @f$ \lambda_m @f$ is the element potential of element m. The
1717 * temperature is unchanged. Any phase (ideal or not) that
1718 * implements this method can be equilibrated by ChemEquil.
1719 *
1720 * @param mu_RT Input vector of dimensionless chemical potentials
1721 * The length is equal to nSpecies().
1722 */
1723 virtual void setToEquilState(const double* mu_RT) {
1724 throw NotImplementedError("ThermoPhase::setToEquilState");
1725 }
1726
1727 //! Indicates whether this phase type can be used with class MultiPhase for
1728 //! equilibrium calculations. Returns `false` for special phase types which
1729 //! already represent multi-phase mixtures, namely PureFluidPhase.
1730 virtual bool compatibleWithMultiPhase() const {
1731 return true;
1732 }
1733
1734 //! @}
1735 //! @name Critical State Properties
1736 //!
1737 //! These methods are only implemented by subclasses that implement
1738 //! liquid-vapor equations of state.
1739 //! @{
1740
1741 //! Critical temperature (K).
1742 virtual double critTemperature() const {
1743 throw NotImplementedError("ThermoPhase::critTemperature");
1744 }
1745
1746 //! Critical pressure (Pa).
1747 virtual double critPressure() const {
1748 throw NotImplementedError("ThermoPhase::critPressure");
1749 }
1750
1751 //! Critical volume (m3/kmol).
1752 virtual double critVolume() const {
1753 throw NotImplementedError("ThermoPhase::critVolume");
1754 }
1755
1756 //! Critical compressibility (unitless).
1757 virtual double critCompressibility() const {
1758 throw NotImplementedError("ThermoPhase::critCompressibility");
1759 }
1760
1761 //! Critical density (kg/m3).
1762 virtual double critDensity() const {
1763 throw NotImplementedError("ThermoPhase::critDensity");
1764 }
1765
1766 //! @}
1767 //! @name Saturation Properties
1768 //!
1769 //! These methods are only implemented by subclasses that implement full
1770 //! liquid-vapor equations of state.
1771 //! @{
1772
1773 //! Return the saturation temperature given the pressure
1774 /*!
1775 * @param p Pressure (Pa)
1776 */
1777 virtual double satTemperature(double p) const {
1778 throw NotImplementedError("ThermoPhase::satTemperature");
1779 }
1780
1781 //! Return the saturation pressure given the temperature
1782 /*!
1783 * @param t Temperature (Kelvin)
1784 */
1785 virtual double satPressure(double t) {
1786 throw NotImplementedError("ThermoPhase::satPressure");
1787 }
1788
1789 //! Return the fraction of vapor at the current conditions
1790 virtual double vaporFraction() const {
1791 throw NotImplementedError("ThermoPhase::vaporFraction");
1792 }
1793
1794 //! Set the state to a saturated system at a particular temperature
1795 /*!
1796 * @param t Temperature (kelvin)
1797 * @param x Fraction of vapor
1798 */
1799 virtual void setState_Tsat(double t, double x) {
1800 throw NotImplementedError("ThermoPhase::setState_Tsat");
1801 }
1802
1803 //! Set the state to a saturated system at a particular pressure
1804 /*!
1805 * @param p Pressure (Pa)
1806 * @param x Fraction of vapor
1807 */
1808 virtual void setState_Psat(double p, double x) {
1809 throw NotImplementedError("ThermoPhase::setState_Psat");
1810 }
1811
1812 //! Set the temperature, pressure, and vapor fraction (quality).
1813 /*!
1814 * An exception is thrown if the thermodynamic state is not consistent.
1815 *
1816 * For temperatures below the critical temperature, if the vapor fraction is
1817 * not 0 or 1, the pressure and temperature must fall on the saturation
1818 * line.
1819 *
1820 * Above the critical temperature, the vapor fraction must be 1 if the
1821 * pressure is less than the critical pressure. Above the critical pressure,
1822 * the vapor fraction is not defined, and its value is ignored.
1823 *
1824 * @param T Temperature (K)
1825 * @param P Pressure (Pa)
1826 * @param Q vapor fraction
1827 */
1828 void setState_TPQ(double T, double P, double Q);
1829
1830 //! @}
1831 //! @name Initialization Methods - For Internal Use (ThermoPhase)
1832 //!
1833 //! The following methods are used in the process of constructing
1834 //! the phase and setting its parameters from a specification in an
1835 //! input file. They are not normally used in application programs.
1836 //! To see how they are used, see importPhase().
1837 //! @{
1838
1839 bool addSpecies(shared_ptr<Species> spec) override;
1840
1841 void modifySpecies(size_t k, shared_ptr<Species> spec) override;
1842
1843 //! Return a changeable reference to the calculation manager for species
1844 //! reference-state thermodynamic properties
1845 /*!
1846 * @param k Species id. The default is -1, meaning return the default
1847 */
1848 virtual MultiSpeciesThermo& speciesThermo(int k = -1);
1849
1850 virtual const MultiSpeciesThermo& speciesThermo(int k = -1) const;
1851
1852 /**
1853 * Initialize a ThermoPhase object using an input file.
1854 *
1855 * Used to implement constructors for derived classes which take a
1856 * file name and phase name as arguments.
1857 *
1858 * @param inputFile Input file containing the description of the phase. If blank,
1859 * no setup will be performed.
1860 * @param id Optional parameter identifying the name of the phase. If
1861 * blank, the first phase definition encountered will be used.
1862 */
1863 void initThermoFile(const string& inputFile, const string& id);
1864
1865 //! Initialize the ThermoPhase object after all species have been set up
1866 /*!
1867 * This method is provided to allow subclasses to perform any initialization
1868 * required after all species have been added. For example, it might be used
1869 * to resize internal work arrays that must have an entry for each species.
1870 * The base class implementation does nothing, and subclasses that do not
1871 * require initialization do not need to overload this method. Derived
1872 * classes which do override this function should call their parent class's
1873 * implementation of this function as their last action.
1874 *
1875 * When importing from an AnyMap phase description (or from a YAML file),
1876 * setupPhase() adds all the species, stores the input data in #m_input, and then
1877 * calls this method to set model parameters from the data stored in #m_input.
1878 */
1879 virtual void initThermo();
1880
1881 //! Set equation of state parameters from an AnyMap phase description.
1882 //! Phases that need additional parameters from the root node should
1883 //! override this method.
1884 virtual void setParameters(const AnyMap& phaseNode,
1885 const AnyMap& rootNode=AnyMap());
1886
1887 //! Returns the parameters of a ThermoPhase object such that an identical
1888 //! one could be reconstructed using the newThermo(AnyMap&) function.
1889 //! @param withInput If true, include additional input data fields associated
1890 //! with the phase description, such as user-defined fields from a YAML input
1891 //! file, as returned by the input() method.
1892 AnyMap parameters(bool withInput=true) const;
1893
1894 //! Get phase-specific parameters of a Species object such that an
1895 //! identical one could be reconstructed and added to this phase.
1896 /*!
1897 * @param name Name of the species
1898 * @param speciesNode Mapping to be populated with parameters
1899 */
1900 virtual void getSpeciesParameters(const string& name, AnyMap& speciesNode) const {}
1901
1902 //! Access input data associated with the phase description
1903 const AnyMap& input() const;
1904 AnyMap& input();
1905
1906 void invalidateCache() override;
1907
1908 //! @}
1909 //! @name Derivatives of Thermodynamic Variables needed for Applications
1910 //!
1911 //! Derivatives of the activity coefficients are needed to evaluate terms arising
1912 //! in multicomponent transport models for non-ideal systems. While %Cantera does
1913 //! not currently implement such models, these derivatives are provided by a few
1914 //! phase models.
1915 //! @{
1916
1917 //! Get the change in activity coefficients wrt changes in state (temp, mole
1918 //! fraction, etc) along a line in parameter space or along a line in
1919 //! physical space
1920 /*!
1921 * @param dTds Input of temperature change along the path
1922 * @param dXds Input vector of changes in mole fraction along the
1923 * path. length = m_kk Along the path length it must
1924 * be the case that the mole fractions sum to one.
1925 * @param dlnActCoeffds Output vector of the directional derivatives of the
1926 * log Activity Coefficients along the path. length =
1927 * m_kk units are 1/units(s). if s is a physical
1928 * coordinate then the units are 1/m.
1929 */
1930 virtual void getdlnActCoeffds(const double dTds, const double* const dXds,
1931 double* dlnActCoeffds) const {
1932 throw NotImplementedError("ThermoPhase::getdlnActCoeffds");
1933 }
1934
1935 //! Get the array of ln mole fraction derivatives of the log activity
1936 //! coefficients - diagonal component only
1937 /*!
1938 * For ideal mixtures (unity activity coefficients), this can return zero.
1939 * Implementations should take the derivative of the logarithm of the
1940 * activity coefficient with respect to the logarithm of the mole fraction
1941 * variable that represents the standard state. This quantity is to be used
1942 * in conjunction with derivatives of that mole fraction variable when the
1943 * derivative of the chemical potential is taken.
1944 *
1945 * units = dimensionless
1946 *
1947 * @param dlnActCoeffdlnX_diag Output vector of derivatives of the log
1948 * Activity Coefficients wrt the mole fractions. length = m_kk
1949 */
1950 virtual void getdlnActCoeffdlnX_diag(double* dlnActCoeffdlnX_diag) const {
1951 throw NotImplementedError("ThermoPhase::getdlnActCoeffdlnX_diag");
1952 }
1953
1954 //! Get the array of log species mole number derivatives of the log activity
1955 //! coefficients
1956 /*!
1957 * For ideal mixtures (unity activity coefficients), this can return zero.
1958 * Implementations should take the derivative of the logarithm of the
1959 * activity coefficient with respect to the logarithm of the concentration-
1960 * like variable (for example, moles) that represents the standard state. This
1961 * quantity is to be used in conjunction with derivatives of that species
1962 * mole number variable when the derivative of the chemical potential is
1963 * taken.
1964 *
1965 * units = dimensionless
1966 *
1967 * @param dlnActCoeffdlnN_diag Output vector of derivatives of the
1968 * log Activity Coefficients. length = m_kk
1969 */
1970 virtual void getdlnActCoeffdlnN_diag(double* dlnActCoeffdlnN_diag) const {
1971 throw NotImplementedError("ThermoPhase::getdlnActCoeffdlnN_diag");
1972 }
1973
1974 //! Get the array of derivatives of the log activity coefficients with
1975 //! respect to the log of the species mole numbers
1976 /*!
1977 * Implementations should take the derivative of the logarithm of the
1978 * activity coefficient with respect to a species log mole number (with all
1979 * other species mole numbers held constant). The default treatment in the
1980 * ThermoPhase object is to set this vector to zero.
1981 *
1982 * units = 1 / kmol
1983 *
1984 * dlnActCoeffdlnN[ ld * k + m] will contain the derivative of log
1985 * act_coeff for the *m*-th species with respect to the number of moles of
1986 * the *k*-th species.
1987 *
1988 * @f[
1989 * \frac{d \ln(\gamma_m) }{d \ln( n_k ) }\Bigg|_{n_i}
1990 * @f]
1991 *
1992 * When implemented, this method is used within the VCS equilibrium solver to
1993 * calculate the Jacobian elements, which accelerates convergence of the algorithm.
1994 *
1995 * @param ld Number of rows in the matrix
1996 * @param dlnActCoeffdlnN Output vector of derivatives of the
1997 * log Activity Coefficients. length = m_kk * m_kk
1998 */
1999 virtual void getdlnActCoeffdlnN(const size_t ld, double* const dlnActCoeffdlnN);
2000
2001 virtual void getdlnActCoeffdlnN_numderiv(const size_t ld,
2002 double* const dlnActCoeffdlnN);
2003
2004 //! @}
2005 //! @name Printing
2006 //! @{
2007
2008 //! returns a summary of the state of the phase as a string
2009 /*!
2010 * @param show_thermo If true, extra information is printed out
2011 * about the thermodynamic state of the system.
2012 * @param threshold Show information about species with mole fractions
2013 * greater than *threshold*.
2014 */
2015 virtual string report(bool show_thermo=true, double threshold=-1e-14) const;
2016
2017 //! @}
2018
2019 //! Set the link to the Solution object that owns this ThermoPhase
2020 //! @param soln Weak pointer to the parent Solution object
2021 virtual void setSolution(std::weak_ptr<Solution> soln) {
2022 m_soln = soln;
2023 }
2024
2025 //! Get the Solution object containing this ThermoPhase object and linked
2026 //! Kinetics and Transport objects.
2027 //! @since New in %Cantera 3.2.
2028 shared_ptr<Solution> root() const {
2029 return m_soln.lock();
2030 }
2031
2032protected:
2033 //! Store the parameters of a ThermoPhase object such that an identical
2034 //! one could be reconstructed using the newThermo(AnyMap&) function. This
2035 //! does not include user-defined fields available in input().
2036 virtual void getParameters(AnyMap& phaseNode) const;
2037
2038 //! Pointer to the calculation manager for species reference-state
2039 //! thermodynamic properties
2040 /*!
2041 * This class is called when the reference-state thermodynamic properties
2042 * of all the species in the phase needs to be evaluated.
2043 */
2045
2046 //! Data supplied via setParameters. When first set, this may include
2047 //! parameters used by different phase models when initThermo() is called.
2049
2050 //! Stored value of the electric potential for this phase. Units are Volts.
2051 double m_phi = 0.0;
2052
2053 //! Boolean indicating whether a charge neutrality condition is a necessity
2054 /*!
2055 * Note, the charge neutrality condition is not a necessity for ideal gas
2056 * phases. There may be a net charge in those phases, because the NASA
2057 * polynomials for ionized species in Ideal gases take this condition into
2058 * account. However, liquid phases usually require charge neutrality in
2059 * order for their derived thermodynamics to be valid.
2060 */
2062
2063 //! Contains the standard state convention
2065
2066 //! last value of the temperature processed by reference state
2067 mutable double m_tlast = 0.0;
2068
2069 //! reference to Solution
2070 std::weak_ptr<Solution> m_soln;
2071};
2072
2073}
2074
2075#endif
Header for a general species thermodynamic property manager for a phase (see MultiSpeciesThermo).
Header file for class Phase.
Header for unit conversion utilities, which are used to translate user input from input files (See In...
A map of string keys to values whose type can vary at runtime.
Definition AnyMap.h:431
A species thermodynamic property manager for a phase.
virtual double refPressure() const
The reference-state pressure (Pa) for all species.
virtual double minTemp(size_t k=npos) const
Minimum temperature.
virtual double maxTemp(size_t k=npos) const
Maximum temperature.
virtual void modifyOneHf298(const size_t k, const double Hf298New)
Modify the value of the 298 K Heat of Formation of the standard state of one species in the phase (J ...
virtual double reportOneHf298(const size_t k) const
Report the 298 K Heat of Formation of the standard state of one species (J kmol-1)
An error indicating that an unimplemented function has been called.
Class Phase is the base class for phases of matter, managing the species and elements in a phase,...
Definition Phase.h:96
vector< double > m_workS
Vector of size m_kk, used as a temporary holding area.
Definition Phase.h:914
size_t m_kk
Number of species in the phase.
Definition Phase.h:890
double temperature() const
Temperature (K).
Definition Phase.h:598
double meanMolecularWeight() const
The mean molecular weight. Units: (kg/kmol)
Definition Phase.h:691
double mean_X(const double *const Q) const
Evaluate the mole-fraction-weighted mean of an array Q.
Definition Phase.cpp:639
virtual double molarVolume() const
Molar volume (m^3/kmol).
Definition Phase.cpp:604
virtual double pressure() const
Return the thermodynamic pressure (Pa).
Definition Phase.h:616
string name() const
Return the name of the phase.
Definition Phase.cpp:20
Base class for a phase with thermodynamic properties.
int m_ssConvention
Contains the standard state convention.
virtual void getPartialMolarEnthalpies(double *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.
virtual double critTemperature() const
Critical temperature (K).
virtual void setState_HP(double h, double p, double tol=1e-9)
Set the internally stored specific enthalpy (J/kg) and pressure (Pa) of the phase.
double electricPotential() const
Returns the electric potential of this phase (V).
virtual void getEntropy_R(double *sr) const
Get the array of nondimensional Entropy functions for the standard state species at the current T and...
virtual void setState_UV(double u, double v, double tol=1e-9)
Set the specific internal energy (J/kg) and specific volume (m^3/kg).
bool chargeNeutralityNecessary() const
Returns the chargeNeutralityNecessity boolean.
virtual double cp_mole() const
Molar heat capacity at constant pressure and composition [J/kmol/K].
double equivalenceRatio() const
Compute the equivalence ratio for the current mixture from available oxygen and required oxygen.
virtual void setParameters(const AnyMap &phaseNode, const AnyMap &rootNode=AnyMap())
Set equation of state parameters from an AnyMap phase description.
virtual double thermalExpansionCoeff() const
Return the volumetric thermal expansion coefficient. Units: 1/K.
virtual void getEnthalpy_RT_ref(double *hrt) const
Returns the vector of nondimensional enthalpies of the reference state at the current temperature of ...
virtual void getParameters(AnyMap &phaseNode) const
Store the parameters of a ThermoPhase object such that an identical one could be reconstructed using ...
virtual double enthalpy_mole() const
Molar enthalpy. Units: J/kmol.
virtual void setState_TP(double t, double p)
Set the temperature (K) and pressure (Pa)
virtual double standardConcentration(size_t k=0) const
Return the standard concentration for the kth species.
virtual void getCp_R_ref(double *cprt) const
Returns the vector of nondimensional constant pressure heat capacities of the reference state at the ...
virtual void setState_TV(double t, double v, double tol=1e-9)
Set the temperature (K) and specific volume (m^3/kg).
virtual double logStandardConc(size_t k=0) const
Natural logarithm of the standard concentration of the kth species.
double o2Present(const double *y) const
Helper function for computing the amount of oxygen available in the current mixture.
virtual void setState_PV(double p, double v, double tol=1e-9)
Set the pressure (Pa) and specific volume (m^3/kg).
virtual void setState(const AnyMap &state)
Set the state using an AnyMap containing any combination of properties supported by the thermodynamic...
virtual double minTemp(size_t k=npos) const
Minimum temperature for which the thermodynamic data for the species or phase are valid.
virtual void getdlnActCoeffdlnN_diag(double *dlnActCoeffdlnN_diag) const
Get the array of log species mole number derivatives of the log activity coefficients.
virtual void setState_TPX(double t, double p, const double *x)
Set the temperature (K), pressure (Pa), and mole fractions.
void setState_SPorSV(double s, double p, double tol=1e-9, bool doSV=false)
Carry out work in SP and SV calculations.
double RT() const
Return the Gas Constant multiplied by the current temperature.
virtual void getPartialMolarCp(double *cpbar) const
Return an array of partial molar heat capacities for the species in the mixture.
virtual double critPressure() const
Critical pressure (Pa).
virtual void getGibbs_RT_ref(double *grt) const
Returns the vector of nondimensional Gibbs Free Energies of the reference state at the current temper...
virtual double soundSpeed() const
Return the speed of sound. Units: m/s.
virtual void setState_TPY(double t, double p, const double *y)
Set the internally stored temperature (K), pressure (Pa), and mass fractions of the phase.
double m_tlast
last value of the temperature processed by reference state
virtual void setState_ST(double s, double t, double tol=1e-9)
Set the specific entropy (J/kg/K) and temperature (K).
void setState_HPorUV(double h, double p, double tol=1e-9, bool doUV=false)
Carry out work in HP and UV calculations.
double gibbs_mass() const
Specific Gibbs function. Units: J/kg.
virtual void getActivityConcentrations(double *c) const
This method returns an array of generalized concentrations.
double stoichAirFuelRatio(const double *fuelComp, const double *oxComp, ThermoBasis basis=ThermoBasis::molar) const
Compute the stoichiometric air to fuel ratio (kg oxidizer / kg fuel) given fuel and oxidizer composit...
string type() const override
String indicating the thermodynamic model implemented.
AnyMap parameters(bool withInput=true) const
Returns the parameters of a ThermoPhase object such that an identical one could be reconstructed usin...
virtual AnyMap getAuxiliaryData()
Return intermediate or model-specific parameters used by particular derived classes.
bool m_chargeNeutralityNecessary
Boolean indicating whether a charge neutrality condition is a necessity.
virtual string report(bool show_thermo=true, double threshold=-1e-14) const
returns a summary of the state of the phase as a string
virtual void getPartialMolarIntEnergies(double *ubar) const
Return an array of partial molar internal energies for the species in the mixture.
virtual void getIntEnergy_RT(double *urt) const
Returns the vector of nondimensional Internal Energies of the standard state species at the current T...
virtual void getCp_R(double *cpr) const
Get the nondimensional Heat Capacities at constant pressure for the species standard states at the cu...
virtual double maxTemp(size_t k=npos) const
Maximum temperature for which the thermodynamic data for the species are valid.
double m_phi
Stored value of the electric potential for this phase. Units are Volts.
virtual double isothermalCompressibility() const
Returns the isothermal compressibility. Units: 1/Pa.
double mixtureFraction(const double *fuelComp, const double *oxComp, ThermoBasis basis=ThermoBasis::molar, const string &element="Bilger") const
Compute the mixture fraction = kg fuel / (kg oxidizer + kg fuel) for the current mixture given fuel a...
double o2Required(const double *y) const
Helper function for computing the amount of oxygen required for complete oxidation.
virtual double satTemperature(double p) const
Return the saturation temperature given the pressure.
virtual void getdlnActCoeffds(const double dTds, const double *const dXds, double *dlnActCoeffds) const
Get the change in activity coefficients wrt changes in state (temp, mole fraction,...
void getElectrochemPotentials(double *mu) const
Get the species electrochemical potentials.
virtual void getdlnActCoeffdlnN(const size_t ld, double *const dlnActCoeffdlnN)
Get the array of derivatives of the log activity coefficients with respect to the log of the species ...
virtual void getGibbs_RT(double *grt) const
Get the nondimensional Gibbs functions for the species in their standard states at the current T and ...
virtual double critVolume() const
Critical volume (m3/kmol).
virtual void setSolution(std::weak_ptr< Solution > soln)
Set the link to the Solution object that owns this ThermoPhase.
virtual void getActivityCoefficients(double *ac) const
Get the array of non-dimensional molar-based activity coefficients at the current solution temperatur...
virtual string phaseOfMatter() const
String indicating the mechanical phase of the matter in this Phase.
virtual void getStandardVolumes(double *vol) const
Get the molar volumes of the species standard states at the current T and P of the solution.
virtual void setState_Tsat(double t, double x)
Set the state to a saturated system at a particular temperature.
virtual double entropy_mole() const
Molar entropy. Units: J/kmol/K.
void setElectricPotential(double v)
Set the electric potential of this phase (V).
double cv_mass() const
Specific heat at constant volume and composition [J/kg/K].
virtual int activityConvention() const
This method returns the convention used in specification of the activities, of which there are curren...
virtual void initThermo()
Initialize the ThermoPhase object after all species have been set up.
double entropy_mass() const
Specific entropy. Units: J/kg/K.
virtual double critDensity() const
Critical density (kg/m3).
virtual void getGibbs_ref(double *g) const
Returns the vector of the Gibbs function of the reference state at the current temperature of the sol...
virtual MultiSpeciesThermo & speciesThermo(int k=-1)
Return a changeable reference to the calculation manager for species reference-state thermodynamic pr...
virtual void setState_UP(double u, double p, double tol=1e-9)
Set the specific internal energy (J/kg) and pressure (Pa).
void initThermoFile(const string &inputFile, const string &id)
Initialize a ThermoPhase object using an input file.
shared_ptr< Solution > root() const
Get the Solution object containing this ThermoPhase object and linked Kinetics and Transport objects.
virtual void setState_SP(double s, double p, double tol=1e-9)
Set the specific entropy (J/kg/K) and pressure (Pa).
virtual void modifyOneHf298SS(const size_t k, const double Hf298New)
Modify the value of the 298 K Heat of Formation of one species in the phase (J kmol-1)
virtual int standardStateConvention() const
This method returns the convention used in specification of the standard state, of which there are cu...
void modifySpecies(size_t k, shared_ptr< Species > spec) override
Modify the thermodynamic data associated with a species.
virtual void setState_SH(double s, double h, double tol=1e-9)
Set the specific entropy (J/kg/K) and the specific enthalpy (J/kg)
virtual void getdlnActCoeffdlnX_diag(double *dlnActCoeffdlnX_diag) const
Get the array of ln mole fraction derivatives of the log activity coefficients - diagonal component o...
std::weak_ptr< Solution > m_soln
reference to Solution
void invalidateCache() override
Invalidate any cached values which are normally updated only when a change in state is detected.
virtual void getActivities(double *a) const
Get the array of non-dimensional activities at the current solution temperature, pressure,...
void setMixtureFraction(double mixFrac, const double *fuelComp, const double *oxComp, ThermoBasis basis=ThermoBasis::molar)
Set the mixture composition according to the mixture fraction = kg fuel / (kg oxidizer + kg fuel)
virtual void getStandardVolumes_ref(double *vol) const
Get the molar volumes of the species reference states at the current T and P_ref of the solution.
virtual double vaporFraction() const
Return the fraction of vapor at the current conditions.
virtual void resetHf298(const size_t k=npos)
Restore the original heat of formation of one or more species.
virtual void getStandardChemPotentials(double *mu) const
Get the array of chemical potentials at unit activity for the species at their standard states at the...
virtual void getEnthalpy_RT(double *hrt) const
Get the nondimensional Enthalpy functions for the species at their standard states at the current T a...
virtual void getEntropy_R_ref(double *er) const
Returns the vector of nondimensional entropies of the reference state at the current temperature of t...
virtual void getChemPotentials(double *mu) const
Get the species chemical potentials. Units: J/kmol.
double cp_mass() const
Specific heat at constant pressure and composition [J/kg/K].
virtual void setState_TH(double t, double h, double tol=1e-9)
Set the temperature (K) and the specific enthalpy (J/kg)
virtual void getLnActivityCoefficients(double *lnac) const
Get the array of non-dimensional molar-based ln activity coefficients at the current solution tempera...
double intEnergy_mass() const
Specific internal energy. Units: J/kg.
virtual void getSpeciesParameters(const string &name, AnyMap &speciesNode) const
Get phase-specific parameters of a Species object such that an identical one could be reconstructed a...
virtual Units standardConcentrationUnits() const
Returns the units of the "standard concentration" for this phase.
virtual void getIntEnergy_RT_ref(double *urt) const
Returns the vector of nondimensional internal Energies of the reference state at the current temperat...
double Hf298SS(const size_t k) const
Report the 298 K Heat of Formation of the standard state of one species (J kmol-1)
ThermoPhase()=default
Constructor.
virtual bool isIdeal() const
Boolean indicating whether phase is ideal.
virtual double cv_mole() const
Molar heat capacity at constant volume and composition [J/kmol/K].
MultiSpeciesThermo m_spthermo
Pointer to the calculation manager for species reference-state thermodynamic properties.
virtual double satPressure(double t)
Return the saturation pressure given the temperature.
virtual double refPressure() const
Returns the reference pressure in Pa.
virtual double critCompressibility() const
Critical compressibility (unitless).
bool addSpecies(shared_ptr< Species > spec) override
Add a Species to this Phase.
AnyMap m_input
Data supplied via setParameters.
virtual double intEnergy_mole() const
Molar internal energy. Units: J/kmol.
virtual void setState_DP(double rho, double p)
Set the density (kg/m**3) and pressure (Pa) at constant composition.
void setEquivalenceRatio(double phi, const double *fuelComp, const double *oxComp, ThermoBasis basis=ThermoBasis::molar)
Set the mixture composition according to the equivalence ratio.
void setState_TPQ(double T, double P, double Q)
Set the temperature, pressure, and vapor fraction (quality).
virtual void setState_VH(double v, double h, double tol=1e-9)
Set the specific volume (m^3/kg) and the specific enthalpy (J/kg)
virtual void getPartialMolarEntropies(double *sbar) const
Returns an array of partial molar entropies of the species in the solution.
virtual double gibbs_mole() const
Molar Gibbs function. Units: J/kmol.
virtual void setState_SV(double s, double v, double tol=1e-9)
Set the specific entropy (J/kg/K) and specific volume (m^3/kg).
const AnyMap & input() const
Access input data associated with the phase description.
virtual void setState_Psat(double p, double x)
Set the state to a saturated system at a particular pressure.
void setState_conditional_TP(double t, double p, bool set_p)
Helper function used by setState_HPorUV and setState_SPorSV.
virtual void getPartialMolarVolumes(double *vbar) const
Return an array of partial molar volumes for the species in the mixture.
shared_ptr< ThermoPhase > clone() const
Create a new ThermoPhase object using the same species definitions, thermodynamic parameters,...
double enthalpy_mass() const
Specific enthalpy. Units: J/kg.
A representation of the units associated with a dimensional quantity.
Definition Units.h:35
void equilibrate(const string &XY, const string &solver="auto", double rtol=1e-9, int max_steps=50000, int max_iter=100, int estimate_equil=0, int log_level=0)
Equilibrate a ThermoPhase object.
virtual bool compatibleWithMultiPhase() const
Indicates whether this phase type can be used with class MultiPhase for equilibrium calculations.
virtual void setToEquilState(const double *mu_RT)
This method is used by the ChemEquil equilibrium solver.
const double GasConstant
Universal Gas Constant [J/kmol/K].
Definition ct_defs.h:120
Namespace for the Cantera kernel.
Definition AnyMap.cpp:595
const size_t npos
index returned by functions to indicate "no position"
Definition ct_defs.h:180
const int cSS_CONVENTION_VPSS
Standard state uses the molality convention.
const int cAC_CONVENTION_MOLAR
Standard state uses the molar convention.
const int cSS_CONVENTION_TEMPERATURE
Standard state uses the molar convention.
ThermoBasis
Differentiate between mole fractions and mass fractions for input mixture composition.
const int cSS_CONVENTION_SLAVE
Standard state thermodynamics is obtained from slave ThermoPhase objects.
map< string, double > Composition
Map from string names to doubles.
Definition ct_defs.h:177
const int cAC_CONVENTION_MOLALITY
Standard state uses the molality convention.