| Cantera 3.0.0

Loading...
Searching...
No Matches
PureFluidPhase.h
Go to the documentation of this file.
1/**
2 * @file PureFluidPhase.h
3 *
4 * Header for a ThermoPhase class for a pure fluid phase consisting of
5 * gas, liquid, mixed-gas-liquid and supercritical fluid (see @ref thermoprops
6 * and class @link Cantera::PureFluidPhase PureFluidPhase@endlink).
7 *
8 * It inherits from ThermoPhase, but is built on top of the tpx package.
9 */
10
11// This file is part of Cantera. See License.txt in the top-level directory or
12// at https://cantera.org/license.txt for license and copyright information.
13
14#ifndef CT_EOS_TPX_H
15#define CT_EOS_TPX_H
16
17#include "ThermoPhase.h"
18#include "cantera/tpx/Sub.h"
19
20 namespace Cantera
21{
22//! This phase object consists of a single component that can be a gas, a
23//! liquid, a mixed gas-liquid fluid, or a fluid beyond its critical point
24/*!
25 * The object inherits from ThermoPhase. However, it's built on top of the tpx
26 * package.
27 *
28 * @ingroup thermoprops
29 */
30 class PureFluidPhase : public ThermoPhase
31{
32 public:
33 //! Empty Base Constructor
34 PureFluidPhase() = default;
35
36 string type() const override {
37 return "pure-fluid";
38 }
39
40 //! String indicating the mechanical phase of the matter in this Phase.
41 /*!
42 * Options for the string are:
43 * * `supercritical`
44 * * `gas`
45 * * `liquid`
46 * * `liquid-gas-mix`
47 *
48 * If the temperature or pressure are greater than the critical temperature or
49 * pressure, respectively, the mechanical phase is `supercritical`. If the
50 * underlying tpx::TwoPhase() returns `True`, the mechanical phase is
51 * `liquid-gas-mix`. If the temperature is greater than the saturation temperature
52 * at the current pressure, the mechanical phase is `gas`. Otherwise, the mechanical
53 * phase is `liquid`.
54 */
55 string phaseOfMatter() const override;
56
57 //! Set the name of the TPX substance to use for the equation of state. This
58 //! function should be called before initThermo().
59 void setSubstance(const string& name) {
60 m_tpx_name = name;
61 }
62
63 bool isPure() const override {
64 return true;
65 }
66
67 bool hasPhaseTransition() const override {
68 return true;
69 }
70
71 vector<string> fullStates() const override;
72 vector<string> partialStates() const override;
73
74 double minTemp(size_t k=npos) const override;
75 double maxTemp(size_t k=npos) const override;
76
77 double enthalpy_mole() const override;
78 double intEnergy_mole() const override;
79 double entropy_mole() const override;
80 double gibbs_mole() const override;
81 double cp_mole() const override;
82 double cv_mole() const override;
83
84 //! Return the thermodynamic pressure (Pa).
85 /*!
86 * This method calculates the current pressure consistent with the
87 * independent variables, T, rho.
88 */
89 double pressure() const override;
90
91 //! sets the thermodynamic pressure (Pa).
92 /*!
93 * This method calculates the density that is consistent with the
94 * desired pressure, given the temperature.
95 *
96 * @param p Pressure (Pa)
97 */
98 void setPressure(double p) override;
99 void setTemperature(const double T) override;
100 void setDensity(const double rho) override;
101
102 void getChemPotentials(double* mu) const override{
103 mu[0] = gibbs_mole();
104 }
105
106 void getPartialMolarEnthalpies(double* hbar) const override;
107 void getPartialMolarEntropies(double* sbar) const override;
108 void getPartialMolarIntEnergies(double* ubar) const override;
109 void getPartialMolarCp(double* cpbar) const override;
110 void getPartialMolarVolumes(double* vbar) const override;
111
112 Units standardConcentrationUnits() const override;
113 void getActivityConcentrations(double* c) const override;
114 double standardConcentration(size_t k=0) const override;
115
116 void getActivities(double* a) const override;
117
118 double isothermalCompressibility() const override;
119 double thermalExpansionCoeff() const override;
120
121 //! Returns a reference to the substance object
122 tpx::Substance& TPX_Substance();
123
124 //! @name Properties of the Standard State of the Species in the Solution
125 //!
126 //! The standard state of the pure fluid is defined as the real properties
127 //! of the pure fluid at the most stable state of the fluid at the current
128 //! temperature and pressure of the solution. With this definition, the
129 //! activity of the fluid is always then defined to be equal to one.
130 //! @{
131
132 void getStandardChemPotentials(double* mu) const override;
133 void getEnthalpy_RT(double* hrt) const override;
134 void getEntropy_R(double* sr) const override;
135 void getGibbs_RT(double* grt) const override;
136
137 //! @}
138 //! @name Thermodynamic Values for the Species Reference States
139 //!
140 //! The species reference state for pure fluids is defined as an ideal gas at
141 //! the reference pressure and current temperature of the fluid.
142 //! @{
143
144 void getEnthalpy_RT_ref(double* hrt) const override;
145 void getGibbs_RT_ref(double* grt) const override;
146 void getGibbs_ref(double* g) const override;
147 void getEntropy_R_ref(double* er) const override;
148
149 //! @}
150 //! @name Setting the State
151 //!
152 //! These methods set all or part of the thermodynamic state.
153 //! @{
154
155 void setState_HP(double h, double p, double tol=1e-9) override;
156 void setState_UV(double u, double v, double tol=1e-9) override;
157 void setState_SV(double s, double v, double tol=1e-9) override;
158 void setState_SP(double s, double p, double tol=1e-9) override;
159 void setState_ST(double s, double t, double tol=1e-9) override;
160 void setState_TV(double t, double v, double tol=1e-9) override;
161 void setState_PV(double p, double v, double tol=1e-9) override;
162 void setState_UP(double u, double p, double tol=1e-9) override;
163 void setState_VH(double v, double h, double tol=1e-9) override;
164 void setState_TH(double t, double h, double tol=1e-9) override;
165 void setState_SH(double s, double h, double tol=1e-9) override;
166 //! @}
167 //! @name Critical State Properties
168 //! @{
169
170 double critTemperature() const override;
171 double critPressure() const override;
172 double critDensity() const override;
173
174 //! @}
175 //! @name Saturation properties.
176 //! @{
177
178 double satTemperature(double p) const override;
179 double satPressure(double t) override;
180 double vaporFraction() const override;
181
182 void setState_Tsat(double t, double x) override;
183 void setState_Psat(double p, double x) override;
184 //! @}
185
186 void initThermo() override;
187 void getParameters(AnyMap& phaseNode) const override;
188
189 string report(bool show_thermo=true, double threshold=1e-14) const override;
190
191 bool compatibleWithMultiPhase() const override {
192 return false;
193 }
194
195 protected:
196 //! Main call to the tpx level to set the state of the system
197 /*!
198 * @param n Integer indicating which 2 thermo components are held constant
199 * @param x Value of the first component
200 * @param y Value of the second component
201 */
202 void Set(tpx::PropertyPair::type n, double x, double y) const;
203
204 private:
205 //! Pointer to the underlying tpx object Substance that does the work
206 mutable unique_ptr<tpx::Substance> m_sub;
207
208 //! Name for this substance used by the TPX package
209 string m_tpx_name;
210
211 //! Molecular weight of the substance (kg kmol-1)
212 double m_mw = -1.0;
213
214 //! flag to turn on some printing.
215 bool m_verbose = false;
216};
217
218}
219
220#endif
Sub.h
ThermoPhase.h
Header file for class ThermoPhase, the base class for phases with thermodynamic properties,...
Cantera::AnyMap
A map of string keys to values whose type can vary at runtime.
Definition AnyMap.h:427
Cantera::Phase::name
string name() const
Return the name of the phase.
Definition Phase.cpp:20
Cantera::PureFluidPhase
This phase object consists of a single component that can be a gas, a liquid, a mixed gas-liquid flui...
Definition PureFluidPhase.h:31
Cantera::PureFluidPhase::Set
void Set(tpx::PropertyPair::type n, double x, double y) const
Main call to the tpx level to set the state of the system.
Definition PureFluidPhase.cpp:144
Cantera::PureFluidPhase::enthalpy_mole
double enthalpy_mole() const override
Molar enthalpy. Units: J/kmol.
Definition PureFluidPhase.cpp:91
Cantera::PureFluidPhase::thermalExpansionCoeff
double thermalExpansionCoeff() const override
Return the volumetric thermal expansion coefficient. Units: 1/K.
Definition PureFluidPhase.cpp:154
Cantera::PureFluidPhase::getPartialMolarEnthalpies
void getPartialMolarEnthalpies(double *hbar) const override
Returns an array of partial molar enthalpies for the species in the mixture.
Definition PureFluidPhase.cpp:164
Cantera::PureFluidPhase::getChemPotentials
void getChemPotentials(double *mu) const override
Get the species chemical potentials. Units: J/kmol.
Definition PureFluidPhase.h:102
Cantera::PureFluidPhase::pressure
double pressure() const override
Return the thermodynamic pressure (Pa).
Definition PureFluidPhase.cpp:121
Cantera::PureFluidPhase::partialStates
vector< string > partialStates() const override
Return a vector of settable partial property sets within a phase.
Definition PureFluidPhase.cpp:63
Cantera::PureFluidPhase::critPressure
double critPressure() const override
Critical pressure (Pa).
Definition PureFluidPhase.cpp:275
Cantera::PureFluidPhase::m_tpx_name
string m_tpx_name
Name for this substance used by the TPX package.
Definition PureFluidPhase.h:209
Cantera::PureFluidPhase::critDensity
double critDensity() const override
Critical density (kg/m3).
Definition PureFluidPhase.cpp:280
Cantera::PureFluidPhase::getEntropy_R
void getEntropy_R(double *sr) const override
Get the array of nondimensional Entropy functions for the standard state species at the current T and...
Definition PureFluidPhase.cpp:219
Cantera::PureFluidPhase::setState_SH
void setState_SH(double s, double h, double tol=1e-9) override
Set the specific entropy (J/kg/K) and the specific enthalpy (J/kg)
Definition PureFluidPhase.cpp:355
Cantera::PureFluidPhase::getGibbs_ref
void getGibbs_ref(double *g) const override
Returns the vector of the Gibbs function of the reference state at the current temperature of the sol...
Definition PureFluidPhase.cpp:252
Cantera::PureFluidPhase::getStandardChemPotentials
void getStandardChemPotentials(double *mu) const override
Get the array of chemical potentials at unit activity for the species at their standard states at the...
Definition PureFluidPhase.cpp:209
Cantera::PureFluidPhase::critTemperature
double critTemperature() const override
Critical temperature (K).
Definition PureFluidPhase.cpp:270
Cantera::PureFluidPhase::getActivities
void getActivities(double *a) const override
Get the array of non-dimensional activities at the current solution temperature, pressure,...
Definition PureFluidPhase.cpp:204
Cantera::PureFluidPhase::getParameters
void getParameters(AnyMap &phaseNode) const override
Store the parameters of a ThermoPhase object such that an identical one could be reconstructed using ...
Definition PureFluidPhase.cpp:51
Cantera::PureFluidPhase::type
string type() const override
String indicating the thermodynamic model implemented.
Definition PureFluidPhase.h:36
Cantera::PureFluidPhase::initThermo
void initThermo() override
Initialize the ThermoPhase object after all species have been set up.
Definition PureFluidPhase.cpp:21
Cantera::PureFluidPhase::fullStates
vector< string > fullStates() const override
Return a vector containing full states defining a phase.
Definition PureFluidPhase.cpp:57
Cantera::PureFluidPhase::getActivityConcentrations
void getActivityConcentrations(double *c) const override
This method returns an array of generalized concentrations.
Definition PureFluidPhase.cpp:194
Cantera::PureFluidPhase::setState_HP
void setState_HP(double h, double p, double tol=1e-9) override
Set the internally stored specific enthalpy (J/kg) and pressure (Pa) of the phase.
Definition PureFluidPhase.cpp:295
Cantera::PureFluidPhase::setPressure
void setPressure(double p) override
sets the thermodynamic pressure (Pa).
Definition PureFluidPhase.cpp:126
Cantera::PureFluidPhase::m_sub
unique_ptr< tpx::Substance > m_sub
Pointer to the underlying tpx object Substance that does the work.
Definition PureFluidPhase.h:206
Cantera::PureFluidPhase::getPartialMolarVolumes
void getPartialMolarVolumes(double *vbar) const override
Return an array of partial molar volumes for the species in the mixture.
Definition PureFluidPhase.cpp:184
Cantera::PureFluidPhase::setState_PV
void setState_PV(double p, double v, double tol=1e-9) override
Set the pressure (Pa) and specific volume (m^3/kg).
Definition PureFluidPhase.cpp:331
Cantera::PureFluidPhase::setState_VH
void setState_VH(double v, double h, double tol=1e-9) override
Set the specific volume (m^3/kg) and the specific enthalpy (J/kg)
Definition PureFluidPhase.cpp:343
Cantera::PureFluidPhase::vaporFraction
double vaporFraction() const override
Return the fraction of vapor at the current conditions.
Definition PureFluidPhase.cpp:367
Cantera::PureFluidPhase::setState_TH
void setState_TH(double t, double h, double tol=1e-9) override
Set the temperature (K) and the specific enthalpy (J/kg)
Definition PureFluidPhase.cpp:349
Cantera::PureFluidPhase::cv_mole
double cv_mole() const override
Molar heat capacity at constant volume. Units: J/kmol/K.
Definition PureFluidPhase.cpp:116
Cantera::PureFluidPhase::setTemperature
void setTemperature(const double T) override
Set the internally stored temperature of the phase (K).
Definition PureFluidPhase.cpp:132
Cantera::PureFluidPhase::setSubstance
void setSubstance(const string &name)
Set the name of the TPX substance to use for the equation of state.
Definition PureFluidPhase.h:59
Cantera::PureFluidPhase::getEnthalpy_RT
void getEnthalpy_RT(double *hrt) const override
Get the nondimensional Enthalpy functions for the species at their standard states at the current T a...
Definition PureFluidPhase.cpp:214
Cantera::PureFluidPhase::getEntropy_R_ref
void getEntropy_R_ref(double *er) const override
Returns the vector of nondimensional entropies of the reference state at the current temperature of t...
Definition PureFluidPhase.cpp:258
Cantera::PureFluidPhase::minTemp
double minTemp(size_t k=npos) const override
Minimum temperature for which the thermodynamic data for the species or phase are valid.
Definition PureFluidPhase.cpp:81
Cantera::PureFluidPhase::isPure
bool isPure() const override
Return whether phase represents a pure (single species) substance.
Definition PureFluidPhase.h:63
Cantera::PureFluidPhase::hasPhaseTransition
bool hasPhaseTransition() const override
Return whether phase represents a substance with phase transitions.
Definition PureFluidPhase.h:67
Cantera::PureFluidPhase::isothermalCompressibility
double isothermalCompressibility() const override
Returns the isothermal compressibility. Units: 1/Pa.
Definition PureFluidPhase.cpp:149
Cantera::PureFluidPhase::getGibbs_RT
void getGibbs_RT(double *grt) const override
Get the nondimensional Gibbs functions for the species in their standard states at the current T and ...
Definition PureFluidPhase.cpp:224
Cantera::PureFluidPhase::intEnergy_mole
double intEnergy_mole() const override
Molar internal energy. Units: J/kmol.
Definition PureFluidPhase.cpp:96
Cantera::PureFluidPhase::setState_Tsat
void setState_Tsat(double t, double x) override
Set the state to a saturated system at a particular temperature.
Definition PureFluidPhase.cpp:372
Cantera::PureFluidPhase::entropy_mole
double entropy_mole() const override
Molar entropy. Units: J/kmol/K.
Definition PureFluidPhase.cpp:101
Cantera::PureFluidPhase::getPartialMolarIntEnergies
void getPartialMolarIntEnergies(double *ubar) const override
Return an array of partial molar internal energies for the species in the mixture.
Definition PureFluidPhase.cpp:174
Cantera::PureFluidPhase::cp_mole
double cp_mole() const override
Molar heat capacity at constant pressure. Units: J/kmol/K.
Definition PureFluidPhase.cpp:111
Cantera::PureFluidPhase::setState_SV
void setState_SV(double s, double v, double tol=1e-9) override
Set the specific entropy (J/kg/K) and specific volume (m^3/kg).
Definition PureFluidPhase.cpp:307
Cantera::PureFluidPhase::PureFluidPhase
PureFluidPhase()=default
Empty Base Constructor.
Cantera::PureFluidPhase::standardConcentrationUnits
Units standardConcentrationUnits() const override
Returns the units of the "standard concentration" for this phase.
Definition PureFluidPhase.cpp:189
Cantera::PureFluidPhase::getPartialMolarCp
void getPartialMolarCp(double *cpbar) const override
Return an array of partial molar heat capacities for the species in the mixture.
Definition PureFluidPhase.cpp:179
Cantera::PureFluidPhase::gibbs_mole
double gibbs_mole() const override
Molar Gibbs function. Units: J/kmol.
Definition PureFluidPhase.cpp:106
Cantera::PureFluidPhase::standardConcentration
double standardConcentration(size_t k=0) const override
Return the standard concentration for the kth species.
Definition PureFluidPhase.cpp:199
Cantera::PureFluidPhase::compatibleWithMultiPhase
bool compatibleWithMultiPhase() const override
Indicates whether this phase type can be used with class MultiPhase for equilibrium calculations.
Definition PureFluidPhase.h:191
Cantera::PureFluidPhase::satTemperature
double satTemperature(double p) const override
Return the saturation temperature given the pressure.
Definition PureFluidPhase.cpp:285
Cantera::PureFluidPhase::m_mw
double m_mw
Molecular weight of the substance (kg kmol-1)
Definition PureFluidPhase.h:212
Cantera::PureFluidPhase::TPX_Substance
tpx::Substance & TPX_Substance()
Returns a reference to the substance object.
Definition PureFluidPhase.cpp:159
Cantera::PureFluidPhase::setState_TV
void setState_TV(double t, double v, double tol=1e-9) override
Set the temperature (K) and specific volume (m^3/kg).
Definition PureFluidPhase.cpp:325
Cantera::PureFluidPhase::setState_UV
void setState_UV(double u, double v, double tol=1e-9) override
Set the specific internal energy (J/kg) and specific volume (m^3/kg).
Definition PureFluidPhase.cpp:301
Cantera::PureFluidPhase::getGibbs_RT_ref
void getGibbs_RT_ref(double *grt) const override
Returns the vector of nondimensional Gibbs Free Energies of the reference state at the current temper...
Definition PureFluidPhase.cpp:240
Cantera::PureFluidPhase::setState_Psat
void setState_Psat(double p, double x) override
Set the state to a saturated system at a particular pressure.
Definition PureFluidPhase.cpp:379
Cantera::PureFluidPhase::setState_UP
void setState_UP(double u, double p, double tol=1e-9) override
Set the specific internal energy (J/kg) and pressure (Pa).
Definition PureFluidPhase.cpp:337
Cantera::PureFluidPhase::setState_SP
void setState_SP(double s, double p, double tol=1e-9) override
Set the specific entropy (J/kg/K) and pressure (Pa).
Definition PureFluidPhase.cpp:313
Cantera::PureFluidPhase::setState_ST
void setState_ST(double s, double t, double tol=1e-9) override
Set the specific entropy (J/kg/K) and temperature (K).
Definition PureFluidPhase.cpp:319
Cantera::PureFluidPhase::getPartialMolarEntropies
void getPartialMolarEntropies(double *sbar) const override
Returns an array of partial molar entropies of the species in the solution.
Definition PureFluidPhase.cpp:169
Cantera::PureFluidPhase::m_verbose
bool m_verbose
flag to turn on some printing.
Definition PureFluidPhase.h:215
Cantera::PureFluidPhase::maxTemp
double maxTemp(size_t k=npos) const override
Maximum temperature for which the thermodynamic data for the species are valid.
Definition PureFluidPhase.cpp:86
Cantera::PureFluidPhase::phaseOfMatter
string phaseOfMatter() const override
String indicating the mechanical phase of the matter in this Phase.
Definition PureFluidPhase.cpp:68
Cantera::PureFluidPhase::getEnthalpy_RT_ref
void getEnthalpy_RT_ref(double *hrt) const override
Returns the vector of nondimensional enthalpies of the reference state at the current temperature of ...
Definition PureFluidPhase.cpp:229
Cantera::PureFluidPhase::satPressure
double satPressure(double t) override
Return the saturation pressure given the temperature.
Definition PureFluidPhase.cpp:361
Cantera::PureFluidPhase::setDensity
void setDensity(const double rho) override
Set the internally stored density (kg/m^3) of the phase.
Definition PureFluidPhase.cpp:138
Cantera::PureFluidPhase::report
string report(bool show_thermo=true, double threshold=1e-14) const override
returns a summary of the state of the phase as a string
Definition PureFluidPhase.cpp:386
Cantera::ThermoPhase
Base class for a phase with thermodynamic properties.
Definition ThermoPhase.h:390
Cantera::Units
A representation of the units associated with a dimensional quantity.
Definition Units.h:35
tpx::Substance
Base class from which all pure substances are derived.
Definition Sub.h:37
Cantera
Namespace for the Cantera kernel.
Definition AnyMap.cpp:564
Cantera::npos
const size_t npos
index returned by functions to indicate "no position"
Definition ct_defs.h:195