Cantera 2.6.0

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 supercrit 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();
35
36 virtual std::string type() const {
37 return "PureFluid";
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 virtual std::string phaseOfMatter() const;
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 std::string& name) {
60 m_tpx_name = name;
61 }
62
63 virtual bool isPure() const {
64 return true;
65 }
66
67 virtual bool hasPhaseTransition() const {
68 return true;
69 }
70
71 virtual std::vector<std::string> fullStates() const;
72 virtual std::vector<std::string> partialStates() const;
73
74 virtual double minTemp(size_t k=npos) const;
75 virtual double maxTemp(size_t k=npos) const;
76
77 virtual doublereal enthalpy_mole() const;
78 virtual doublereal intEnergy_mole() const;
79 virtual doublereal entropy_mole() const;
80 virtual doublereal gibbs_mole() const;
81 virtual doublereal cp_mole() const;
82 virtual doublereal cv_mole() const;
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 virtual doublereal pressure() const;
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 virtual void setPressure(doublereal p);
99 virtual void setTemperature(const double T);
100 virtual void setDensity(const double rho);
101
102 virtual void getChemPotentials(doublereal* mu) const {
103 mu[0] = gibbs_mole();
104 }
105
106 virtual void getPartialMolarEnthalpies(doublereal* hbar) const;
107 virtual void getPartialMolarEntropies(doublereal* sbar) const;
108 virtual void getPartialMolarIntEnergies(doublereal* ubar) const;
109 virtual void getPartialMolarCp(doublereal* cpbar) const;
110 virtual void getPartialMolarVolumes(doublereal* vbar) const;
111
112 virtual Units standardConcentrationUnits() const;
113 virtual void getActivityConcentrations(doublereal* c) const;
114 virtual doublereal standardConcentration(size_t k=0) const;
115
116 virtual void getActivities(doublereal* a) const;
117
118 virtual doublereal isothermalCompressibility() const;
119 virtual doublereal thermalExpansionCoeff() const;
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
133 virtual void getStandardChemPotentials(doublereal* mu) const;
134 virtual void getEnthalpy_RT(doublereal* hrt) const;
135 virtual void getEntropy_R(doublereal* sr) const;
136 virtual void getGibbs_RT(doublereal* grt) const;
137
138 //! @}
139 /// @name Thermodynamic Values for the Species Reference States
140 /*!
141 * The species reference state for pure fluids is defined as an ideal gas at
142 * the reference pressure and current temperature of the fluid.
143 */
144 //! @{
145
146 virtual void getEnthalpy_RT_ref(doublereal* hrt) const;
147 virtual void getGibbs_RT_ref(doublereal* grt) const;
148 virtual void getGibbs_ref(doublereal* g) const;
149 virtual void getEntropy_R_ref(doublereal* er) const;
150
151 //! @}
152 /**
153 * @name Setting the State
154 *
155 * These methods set all or part of the thermodynamic state.
156 * @{
157 */
158
159 virtual void setState_HP(double h, double p, double tol=1e-9);
160 virtual void setState_UV(double u, double v, double tol=1e-9);
161 virtual void setState_SV(double s, double v, double tol=1e-9);
162 virtual void setState_SP(double s, double p, double tol=1e-9);
163 virtual void setState_ST(double s, double t, double tol=1e-9);
164 virtual void setState_TV(double t, double v, double tol=1e-9);
165 virtual void setState_PV(double p, double v, double tol=1e-9);
166 virtual void setState_UP(double u, double p, double tol=1e-9);
167 virtual void setState_VH(double v, double h, double tol=1e-9);
168 virtual void setState_TH(double t, double h, double tol=1e-9);
169 virtual void setState_SH(double s, double h, double tol=1e-9);
170 //! @}
171 //! @name Critical State Properties
172 //! @{
173
174 virtual doublereal critTemperature() const;
175 virtual doublereal critPressure() const;
176 virtual doublereal critDensity() const;
177
178 //! @}
179 //! @name Saturation properties.
180 //! @{
181
182 virtual doublereal satTemperature(doublereal p) const;
183 virtual doublereal satPressure(doublereal t);
184 virtual doublereal vaporFraction() const;
185
186 virtual void setState_Tsat(doublereal t, doublereal x);
187 virtual void setState_Psat(doublereal p, doublereal x);
188 //! @}
189
190 virtual void initThermo();
191 virtual void getParameters(AnyMap& phaseNode) const;
192 virtual void setParametersFromXML(const XML_Node& eosdata);
193
194 virtual std::string report(bool show_thermo=true,
195 doublereal threshold=1e-14) const;
196
197 virtual bool compatibleWithMultiPhase() const {
198 return false;
199 }
200
201 protected:
202 //! Main call to the tpx level to set the state of the system
203 /*!
204 * @param n Integer indicating which 2 thermo components are held constant
205 * @param x Value of the first component
206 * @param y Value of the second component
207 */
208 void Set(tpx::PropertyPair::type n, double x, double y) const;
209
210 private:
211 //! Pointer to the underlying tpx object Substance that does the work
212 mutable std::unique_ptr<tpx::Substance> m_sub;
213
214 //! Int indicating the type of the fluid
215 /*!
216 * The tpx package uses an int to indicate what fluid is being sought. Used
217 * only if #m_tpx_name is not set.
218 */
219 int m_subflag;
220
221 //! Name for this substance used by the TPX package. If this is not set,
222 //! #m_subflag is used instead.
223 std::string m_tpx_name;
224
225 //! Molecular weight of the substance (kg kmol-1)
226 doublereal m_mw;
227
228 //! flag to turn on some printing.
229 bool m_verbose;
230};
231
232}
233
234#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:399
Cantera::Phase::name
std::string name() const
Return the name of the phase.
Definition: Phase.cpp:70
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::setState_PV
virtual void setState_PV(double p, double v, double tol=1e-9)
Set the pressure (Pa) and specific volume (m^3/kg).
Definition: PureFluidPhase.cpp:355
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:168
Cantera::PureFluidPhase::setState_HP
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.
Definition: PureFluidPhase.cpp:319
Cantera::PureFluidPhase::setState_UV
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).
Definition: PureFluidPhase.cpp:325
Cantera::PureFluidPhase::setState_VH
virtual void setState_VH(double v, double h, double tol=1e-9)
Set the specific volume (m^3/kg) and the specific enthalpy (J/kg)
Definition: PureFluidPhase.cpp:367
Cantera::PureFluidPhase::getGibbs_RT_ref
virtual void getGibbs_RT_ref(doublereal *grt) const
Returns the vector of nondimensional Gibbs Free Energies of the reference state at the current temper...
Definition: PureFluidPhase.cpp:264
Cantera::PureFluidPhase::m_tpx_name
std::string m_tpx_name
Name for this substance used by the TPX package.
Definition: PureFluidPhase.h:223
Cantera::PureFluidPhase::getParameters
virtual void getParameters(AnyMap &phaseNode) const
Store the parameters of a ThermoPhase object such that an identical one could be reconstructed using ...
Definition: PureFluidPhase.cpp:65
Cantera::PureFluidPhase::getActivities
virtual void getActivities(doublereal *a) const
Get the array of non-dimensional activities at the current solution temperature, pressure,...
Definition: PureFluidPhase.cpp:228
Cantera::PureFluidPhase::report
virtual std::string report(bool show_thermo=true, doublereal threshold=1e-14) const
returns a summary of the state of the phase as a string
Definition: PureFluidPhase.cpp:410
Cantera::PureFluidPhase::getGibbs_RT
virtual void getGibbs_RT(doublereal *grt) const
Get the nondimensional Gibbs functions for the species in their standard states at the current T and ...
Definition: PureFluidPhase.cpp:248
Cantera::PureFluidPhase::pressure
virtual doublereal pressure() const
Return the thermodynamic pressure (Pa).
Definition: PureFluidPhase.cpp:145
Cantera::PureFluidPhase::getPartialMolarIntEnergies
virtual void getPartialMolarIntEnergies(doublereal *ubar) const
Return an array of partial molar internal energies for the species in the mixture.
Definition: PureFluidPhase.cpp:198
Cantera::PureFluidPhase::setState_UP
virtual void setState_UP(double u, double p, double tol=1e-9)
Set the specific internal energy (J/kg) and pressure (Pa).
Definition: PureFluidPhase.cpp:361
Cantera::PureFluidPhase::cp_mole
virtual doublereal cp_mole() const
Molar heat capacity at constant pressure. Units: J/kmol/K.
Definition: PureFluidPhase.cpp:135
Cantera::PureFluidPhase::getChemPotentials
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
Definition: PureFluidPhase.h:102
Cantera::PureFluidPhase::getPartialMolarEnthalpies
virtual void getPartialMolarEnthalpies(doublereal *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.
Definition: PureFluidPhase.cpp:188
Cantera::PureFluidPhase::getPartialMolarEntropies
virtual void getPartialMolarEntropies(doublereal *sbar) const
Returns an array of partial molar entropies of the species in the solution.
Definition: PureFluidPhase.cpp:193
Cantera::PureFluidPhase::critPressure
virtual doublereal critPressure() const
Critical pressure (Pa).
Definition: PureFluidPhase.cpp:299
Cantera::PureFluidPhase::enthalpy_mole
virtual doublereal enthalpy_mole() const
Molar enthalpy. Units: J/kmol.
Definition: PureFluidPhase.cpp:115
Cantera::PureFluidPhase::getPartialMolarVolumes
virtual void getPartialMolarVolumes(doublereal *vbar) const
Return an array of partial molar volumes for the species in the mixture.
Definition: PureFluidPhase.cpp:208
Cantera::PureFluidPhase::cv_mole
virtual doublereal cv_mole() const
Molar heat capacity at constant volume. Units: J/kmol/K.
Definition: PureFluidPhase.cpp:140
Cantera::PureFluidPhase::getActivityConcentrations
virtual void getActivityConcentrations(doublereal *c) const
This method returns an array of generalized concentrations.
Definition: PureFluidPhase.cpp:218
Cantera::PureFluidPhase::vaporFraction
virtual doublereal vaporFraction() const
Return the fraction of vapor at the current conditions.
Definition: PureFluidPhase.cpp:391
Cantera::PureFluidPhase::compatibleWithMultiPhase
virtual bool compatibleWithMultiPhase() const
Indicates whether this phase type can be used with class MultiPhase for equilibrium calculations.
Definition: PureFluidPhase.h:197
Cantera::PureFluidPhase::setState_SH
virtual void setState_SH(double s, double h, double tol=1e-9)
Set the specific entropy (J/kg/K) and the specific enthalpy (J/kg)
Definition: PureFluidPhase.cpp:379
Cantera::PureFluidPhase::thermalExpansionCoeff
virtual doublereal thermalExpansionCoeff() const
Return the volumetric thermal expansion coefficient. Units: 1/K.
Definition: PureFluidPhase.cpp:178
Cantera::PureFluidPhase::getPartialMolarCp
virtual void getPartialMolarCp(doublereal *cpbar) const
Return an array of partial molar heat capacities for the species in the mixture.
Definition: PureFluidPhase.cpp:203
Cantera::PureFluidPhase::PureFluidPhase
PureFluidPhase()
Empty Base Constructor.
Definition: PureFluidPhase.cpp:24
Cantera::PureFluidPhase::satTemperature
virtual doublereal satTemperature(doublereal p) const
Return the saturation temperature given the pressure.
Definition: PureFluidPhase.cpp:309
Cantera::PureFluidPhase::getEntropy_R
virtual void getEntropy_R(doublereal *sr) const
Get the array of nondimensional Entropy functions for the standard state species at the current T and...
Definition: PureFluidPhase.cpp:243
Cantera::PureFluidPhase::partialStates
virtual std::vector< std::string > partialStates() const
Return a vector of settable partial property sets within a phase.
Definition: PureFluidPhase.cpp:87
Cantera::PureFluidPhase::setPressure
virtual void setPressure(doublereal p)
sets the thermodynamic pressure (Pa).
Definition: PureFluidPhase.cpp:150
Cantera::PureFluidPhase::entropy_mole
virtual doublereal entropy_mole() const
Molar entropy. Units: J/kmol/K.
Definition: PureFluidPhase.cpp:125
Cantera::PureFluidPhase::hasPhaseTransition
virtual bool hasPhaseTransition() const
Return whether phase represents a substance with phase transitions.
Definition: PureFluidPhase.h:67
Cantera::PureFluidPhase::initThermo
virtual void initThermo()
Initialize the ThermoPhase object after all species have been set up.
Definition: PureFluidPhase.cpp:31
Cantera::PureFluidPhase::critTemperature
virtual doublereal critTemperature() const
Critical temperature (K).
Definition: PureFluidPhase.cpp:294
Cantera::PureFluidPhase::minTemp
virtual double minTemp(size_t k=npos) const
Minimum temperature for which the thermodynamic data for the species or phase are valid.
Definition: PureFluidPhase.cpp:105
Cantera::PureFluidPhase::setState_SP
virtual void setState_SP(double s, double p, double tol=1e-9)
Set the specific entropy (J/kg/K) and pressure (Pa).
Definition: PureFluidPhase.cpp:337
Cantera::PureFluidPhase::getEntropy_R_ref
virtual void getEntropy_R_ref(doublereal *er) const
Returns the vector of nondimensional entropies of the reference state at the current temperature of t...
Definition: PureFluidPhase.cpp:282
Cantera::PureFluidPhase::type
virtual std::string type() const
String indicating the thermodynamic model implemented.
Definition: PureFluidPhase.h:36
Cantera::PureFluidPhase::setState_Tsat
virtual void setState_Tsat(doublereal t, doublereal x)
Set the state to a saturated system at a particular temperature.
Definition: PureFluidPhase.cpp:396
Cantera::PureFluidPhase::gibbs_mole
virtual doublereal gibbs_mole() const
Molar Gibbs function. Units: J/kmol.
Definition: PureFluidPhase.cpp:130
Cantera::PureFluidPhase::isPure
virtual bool isPure() const
Return whether phase represents a pure (single species) substance.
Definition: PureFluidPhase.h:63
Cantera::PureFluidPhase::standardConcentrationUnits
virtual Units standardConcentrationUnits() const
Returns the units of the "standard concentration" for this phase.
Definition: PureFluidPhase.cpp:213
Cantera::PureFluidPhase::setParametersFromXML
virtual void setParametersFromXML(const XML_Node &eosdata)
Set equation of state parameter values from XML entries.
Definition: PureFluidPhase.cpp:71
Cantera::PureFluidPhase::m_mw
doublereal m_mw
Molecular weight of the substance (kg kmol-1)
Definition: PureFluidPhase.h:226
Cantera::PureFluidPhase::setDensity
virtual void setDensity(const double rho)
Set the internally stored density (kg/m^3) of the phase.
Definition: PureFluidPhase.cpp:162
Cantera::PureFluidPhase::m_sub
std::unique_ptr< tpx::Substance > m_sub
Pointer to the underlying tpx object Substance that does the work.
Definition: PureFluidPhase.h:212
Cantera::PureFluidPhase::setSubstance
void setSubstance(const std::string &name)
Set the name of the TPX substance to use for the equation of state.
Definition: PureFluidPhase.h:59
Cantera::PureFluidPhase::getStandardChemPotentials
virtual void getStandardChemPotentials(doublereal *mu) const
Definition: PureFluidPhase.cpp:233
Cantera::PureFluidPhase::setState_Psat
virtual void setState_Psat(doublereal p, doublereal x)
Set the state to a saturated system at a particular pressure.
Definition: PureFluidPhase.cpp:403
Cantera::PureFluidPhase::maxTemp
virtual double maxTemp(size_t k=npos) const
Maximum temperature for which the thermodynamic data for the species are valid.
Definition: PureFluidPhase.cpp:110
Cantera::PureFluidPhase::satPressure
virtual doublereal satPressure(doublereal t)
Return the saturation pressure given the temperature.
Definition: PureFluidPhase.cpp:385
Cantera::PureFluidPhase::fullStates
virtual std::vector< std::string > fullStates() const
Return a vector containing full states defining a phase.
Definition: PureFluidPhase.cpp:81
Cantera::PureFluidPhase::setTemperature
virtual void setTemperature(const double T)
Set the internally stored temperature of the phase (K).
Definition: PureFluidPhase.cpp:156
Cantera::PureFluidPhase::TPX_Substance
tpx::Substance & TPX_Substance()
Returns a reference to the substance object.
Definition: PureFluidPhase.cpp:183
Cantera::PureFluidPhase::getGibbs_ref
virtual void getGibbs_ref(doublereal *g) const
Returns the vector of the Gibbs function of the reference state at the current temperature of the sol...
Definition: PureFluidPhase.cpp:276
Cantera::PureFluidPhase::getEnthalpy_RT
virtual void getEnthalpy_RT(doublereal *hrt) const
Get the nondimensional Enthalpy functions for the species at their standard states at the current T a...
Definition: PureFluidPhase.cpp:238
Cantera::PureFluidPhase::critDensity
virtual doublereal critDensity() const
Critical density (kg/m3).
Definition: PureFluidPhase.cpp:304
Cantera::PureFluidPhase::phaseOfMatter
virtual std::string phaseOfMatter() const
String indicating the mechanical phase of the matter in this Phase.
Definition: PureFluidPhase.cpp:92
Cantera::PureFluidPhase::m_subflag
int m_subflag
Int indicating the type of the fluid.
Definition: PureFluidPhase.h:219
Cantera::PureFluidPhase::setState_TV
virtual void setState_TV(double t, double v, double tol=1e-9)
Set the temperature (K) and specific volume (m^3/kg).
Definition: PureFluidPhase.cpp:349
Cantera::PureFluidPhase::setState_SV
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).
Definition: PureFluidPhase.cpp:331
Cantera::PureFluidPhase::intEnergy_mole
virtual doublereal intEnergy_mole() const
Molar internal energy. Units: J/kmol.
Definition: PureFluidPhase.cpp:120
Cantera::PureFluidPhase::m_verbose
bool m_verbose
flag to turn on some printing.
Definition: PureFluidPhase.h:229
Cantera::PureFluidPhase::getEnthalpy_RT_ref
virtual void getEnthalpy_RT_ref(doublereal *hrt) const
Definition: PureFluidPhase.cpp:253
Cantera::PureFluidPhase::setState_ST
virtual void setState_ST(double s, double t, double tol=1e-9)
Set the specific entropy (J/kg/K) and temperature (K).
Definition: PureFluidPhase.cpp:343
Cantera::PureFluidPhase::isothermalCompressibility
virtual doublereal isothermalCompressibility() const
Returns the isothermal compressibility. Units: 1/Pa.
Definition: PureFluidPhase.cpp:173
Cantera::PureFluidPhase::setState_TH
virtual void setState_TH(double t, double h, double tol=1e-9)
Set the temperature (K) and the specific enthalpy (J/kg)
Definition: PureFluidPhase.cpp:373
Cantera::PureFluidPhase::standardConcentration
virtual doublereal standardConcentration(size_t k=0) const
Return the standard concentration for the kth species.
Definition: PureFluidPhase.cpp:223
Cantera::ThermoPhase
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:102
Cantera::Units
A representation of the units associated with a dimensional quantity.
Definition: Units.h:30
Cantera::XML_Node
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:103
tpx::Substance
Definition: Sub.h:38
Cantera
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:557
Cantera::npos
const size_t npos
index returned by functions to indicate "no position"
Definition: ct_defs.h:192