Cantera  2.5.1
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  */
31 {
32 public:
33  //! Empty Base Constructor
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
123 
124  //@}
125  /// @name Properties of the Standard State of the Species in the Solution
126  /*!
127  * The standard state of the pure fluid is defined as the real properties
128  * of the pure fluid at the most stable state of the fluid at the current
129  * temperature and pressure of the solution. With this definition, the
130  * activity of the fluid is always then defined to be equal to one.
131  */
132  //@{
133 
134  virtual void getStandardChemPotentials(doublereal* mu) const;
135  virtual void getEnthalpy_RT(doublereal* hrt) const;
136  virtual void getEntropy_R(doublereal* sr) const;
137  virtual void getGibbs_RT(doublereal* grt) const;
138 
139  //@}
140 
141  /// @name Thermodynamic Values for the Species Reference States
142  /*!
143  * The species reference state for pure fluids is defined as an ideal gas at
144  * the reference pressure and current temperature of the fluid.
145  */
146  //@{
147 
148  virtual void getEnthalpy_RT_ref(doublereal* hrt) const;
149  virtual void getGibbs_RT_ref(doublereal* grt) const;
150  virtual void getGibbs_ref(doublereal* g) const;
151  virtual void getEntropy_R_ref(doublereal* er) const;
152 
153  /**
154  * @name Setting the State
155  *
156  * These methods set all or part of the thermodynamic state.
157  * @{
158  */
159 
160  virtual void setState_HP(double h, double p, double tol=1e-9);
161  virtual void setState_UV(double u, double v, double tol=1e-9);
162  virtual void setState_SV(double s, double v, double tol=1e-9);
163  virtual void setState_SP(double s, double p, double tol=1e-9);
164  virtual void setState_ST(double s, double t, double tol=1e-9);
165  virtual void setState_TV(double t, double v, double tol=1e-9);
166  virtual void setState_PV(double p, double v, double tol=1e-9);
167  virtual void setState_UP(double u, double p, double tol=1e-9);
168  virtual void setState_VH(double v, double h, double tol=1e-9);
169  virtual void setState_TH(double t, double h, double tol=1e-9);
170  virtual void setState_SH(double s, double h, double tol=1e-9);
171  //@}
172 
173  //! @name Critical State Properties
174  //@{
175 
176  virtual doublereal critTemperature() const;
177  virtual doublereal critPressure() const;
178  virtual doublereal critDensity() const;
179 
180  //@}
181 
182  //! @name Saturation properties.
183  //@{
184 
185  virtual doublereal satTemperature(doublereal p) const;
186  virtual doublereal satPressure(doublereal t);
187  virtual doublereal vaporFraction() const;
188 
189  virtual void setState_Tsat(doublereal t, doublereal x);
190  virtual void setState_Psat(doublereal p, doublereal x);
191  //@}
192 
193  virtual void initThermo();
194  virtual void setParametersFromXML(const XML_Node& eosdata);
195 
196  virtual std::string report(bool show_thermo=true,
197  doublereal threshold=1e-14) const;
198 
199  virtual bool compatibleWithMultiPhase() const {
200  return false;
201  }
202 
203 protected:
204  //! Main call to the tpx level to set the state of the system
205  /*!
206  * @param n Integer indicating which 2 thermo components are held constant
207  * @param x Value of the first component
208  * @param y Value of the second component
209  */
210  void Set(tpx::PropertyPair::type n, double x, double y) const;
211 
212 private:
213  //! Pointer to the underlying tpx object Substance that does the work
214  mutable std::unique_ptr<tpx::Substance> m_sub;
215 
216  //! Int indicating the type of the fluid
217  /*!
218  * The tpx package uses an int to indicate what fluid is being sought. Used
219  * only if #m_tpx_name is not set.
220  */
222 
223  //! Name for this substance used by the TPX package. If this is not set,
224  //! #m_subflag is used instead.
225  std::string m_tpx_name;
226 
227  //! Molecular weight of the substance (kg kmol-1)
228  doublereal m_mw;
229 
230  //! flag to turn on some printing.
231  bool m_verbose;
232 };
233 
234 }
235 
236 #endif
Cantera::PureFluidPhase::getChemPotentials
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
Definition: PureFluidPhase.h:102
Cantera::PureFluidPhase::critDensity
virtual doublereal critDensity() const
Critical density (kg/m3).
Definition: PureFluidPhase.cpp:299
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:326
Cantera::PureFluidPhase::critTemperature
virtual doublereal critTemperature() const
Critical temperature (K).
Definition: PureFluidPhase.cpp:289
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:105
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:198
Cantera::PureFluidPhase::satTemperature
virtual doublereal satTemperature(doublereal p) const
Return the saturation temperature given the pressure.
Definition: PureFluidPhase.cpp:304
Cantera::PureFluidPhase::getStandardChemPotentials
virtual void getStandardChemPotentials(doublereal *mu) const
Definition: PureFluidPhase.cpp:228
Cantera::PureFluidPhase::fullStates
virtual std::vector< std::string > fullStates() const
Return a vector containing full states defining a phase.
Definition: PureFluidPhase.cpp:76
Cantera::PureFluidPhase::TPX_Substance
tpx::Substance & TPX_Substance()
Returns a reference to the substance object.
Definition: PureFluidPhase.cpp:178
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:350
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:238
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:391
Cantera::PureFluidPhase::m_verbose
bool m_verbose
flag to turn on some printing.
Definition: PureFluidPhase.h:231
Cantera::PureFluidPhase::compatibleWithMultiPhase
virtual bool compatibleWithMultiPhase() const
Indicates whether this phase type can be used with class MultiPhase for equilibrium calculations.
Definition: PureFluidPhase.h:199
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:362
Cantera::PureFluidPhase::cp_mole
virtual doublereal cp_mole() const
Molar heat capacity at constant pressure. Units: J/kmol/K.
Definition: PureFluidPhase.cpp:130
Cantera::PureFluidPhase::satPressure
virtual doublereal satPressure(doublereal t)
Return the saturation pressure given the temperature.
Definition: PureFluidPhase.cpp:380
Cantera::PureFluidPhase::intEnergy_mole
virtual doublereal intEnergy_mole() const
Molar internal energy. 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:203
Cantera::PureFluidPhase::getActivityConcentrations
virtual void getActivityConcentrations(doublereal *c) const
This method returns an array of generalized concentrations.
Definition: PureFluidPhase.cpp:213
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:405
Cantera::PureFluidPhase::setTemperature
virtual void setTemperature(const double T)
Set the internally stored temperature of the phase (K).
Definition: PureFluidPhase.cpp:151
Cantera::PureFluidPhase::enthalpy_mole
virtual doublereal enthalpy_mole() const
Molar enthalpy. Units: J/kmol.
Definition: PureFluidPhase.cpp:110
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:243
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:188
Cantera::Phase::name
std::string name() const
Return the name of the phase.
Definition: Phase.cpp:84
Cantera::PureFluidPhase::hasPhaseTransition
virtual bool hasPhaseTransition() const
Return whether phase represents a substance with phase transitions.
Definition: PureFluidPhase.h:67
Cantera::PureFluidPhase::m_subflag
int m_subflag
Int indicating the type of the fluid.
Definition: PureFluidPhase.h:221
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:368
Cantera::PureFluidPhase::PureFluidPhase
PureFluidPhase()
Empty Base Constructor.
Definition: PureFluidPhase.cpp:25
Cantera::PureFluidPhase::thermalExpansionCoeff
virtual doublereal thermalExpansionCoeff() const
Return the volumetric thermal expansion coefficient. Units: 1/K.
Definition: PureFluidPhase.cpp:173
Cantera::PureFluidPhase::standardConcentration
virtual doublereal standardConcentration(size_t k=0) const
Return the standard concentration for the kth species.
Definition: PureFluidPhase.cpp:218
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:183
Cantera::PureFluidPhase::standardConcentrationUnits
virtual Units standardConcentrationUnits() const
Returns the units of the "standard concentration" for this phase.
Definition: PureFluidPhase.cpp:208
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:338
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:214
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::setState_Psat
virtual void setState_Psat(doublereal p, doublereal x)
Set the state to a saturated system at a particular pressure.
Definition: PureFluidPhase.cpp:398
Cantera::PureFluidPhase::type
virtual std::string type() const
String indicating the thermodynamic model implemented.
Definition: PureFluidPhase.h:36
Cantera::PureFluidPhase::vaporFraction
virtual doublereal vaporFraction() const
Return the fraction of vapor at the current conditions.
Definition: PureFluidPhase.cpp:386
Cantera::PureFluidPhase::gibbs_mole
virtual doublereal gibbs_mole() const
Molar Gibbs function. Units: J/kmol.
Definition: PureFluidPhase.cpp:125
Cantera::PureFluidPhase::getEnthalpy_RT_ref
virtual void getEnthalpy_RT_ref(doublereal *hrt) const
Definition: PureFluidPhase.cpp:248
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:356
Cantera::XML_Node
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:103
Cantera::PureFluidPhase::setDensity
virtual void setDensity(const double rho)
Set the internally stored density (kg/m^3) of the phase.
Definition: PureFluidPhase.cpp:157
Cantera::PureFluidPhase::pressure
virtual doublereal pressure() const
Return the thermodynamic pressure (Pa).
Definition: PureFluidPhase.cpp:140
Cantera::ThermoPhase
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:101
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:314
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:277
Cantera::PureFluidPhase::setParametersFromXML
virtual void setParametersFromXML(const XML_Node &eosdata)
Set equation of state parameter values from XML entries.
Definition: PureFluidPhase.cpp:66
Cantera::PureFluidPhase::initThermo
virtual void initThermo()
Initialize the ThermoPhase object after all species have been set up.
Definition: PureFluidPhase.cpp:32
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:344
tpx::Substance
Definition: Sub.h:37
Cantera::PureFluidPhase::m_tpx_name
std::string m_tpx_name
Name for this substance used by the TPX package.
Definition: PureFluidPhase.h:225
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:233
Cantera::PureFluidPhase::phaseOfMatter
virtual std::string phaseOfMatter() const
String indicating the mechanical phase of the matter in this Phase.
Definition: PureFluidPhase.cpp:87
Sub.h
Cantera::PureFluidPhase::entropy_mole
virtual doublereal entropy_mole() const
Molar entropy. Units: J/kmol/K.
Definition: PureFluidPhase.cpp:120
Cantera::PureFluidPhase::critPressure
virtual doublereal critPressure() const
Critical pressure (Pa).
Definition: PureFluidPhase.cpp:294
Cantera::PureFluidPhase::cv_mole
virtual doublereal cv_mole() const
Molar heat capacity at constant volume. Units: J/kmol/K.
Definition: PureFluidPhase.cpp:135
Cantera::Units
A representation of the units associated with a dimensional quantity.
Definition: Units.h:29
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:30
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:193
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:259
Cantera::PureFluidPhase::isPure
virtual bool isPure() const
Return whether phase represents a pure (single species) substance.
Definition: PureFluidPhase.h:63
Cantera::npos
const size_t npos
index returned by functions to indicate "no position"
Definition: ct_defs.h:188
Cantera::PureFluidPhase::isothermalCompressibility
virtual doublereal isothermalCompressibility() const
Returns the isothermal compressibility. Units: 1/Pa.
Definition: PureFluidPhase.cpp:168
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:374
Cantera::PureFluidPhase::m_mw
doublereal m_mw
Molecular weight of the substance (kg kmol-1)
Definition: PureFluidPhase.h:228
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:100
Cantera
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:263
Cantera::PureFluidPhase::setPressure
virtual void setPressure(doublereal p)
sets the thermodynamic pressure (Pa).
Definition: PureFluidPhase.cpp:145
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:332
Cantera::PureFluidPhase::partialStates
virtual std::vector< std::string > partialStates() const
Return a vector of settable partial property sets within a phase.
Definition: PureFluidPhase.cpp:82
ThermoPhase.h
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:320
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:271
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:163
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:223