Cantera  2.4.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 http://www.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  //! Set the name of the TPX substance to use for the equation of state. This
41  //! function should be called before initThermo().
42  void setSubstance(const std::string& name) {
43  m_tpx_name = name;
44  }
45 
46  virtual double minTemp(size_t k=npos) const;
47  virtual double maxTemp(size_t k=npos) const;
48 
49  virtual doublereal enthalpy_mole() const;
50  virtual doublereal intEnergy_mole() const;
51  virtual doublereal entropy_mole() const;
52  virtual doublereal gibbs_mole() const;
53  virtual doublereal cp_mole() const;
54  virtual doublereal cv_mole() const;
55 
56  //! Return the thermodynamic pressure (Pa).
57  /*!
58  * This method calculates the current pressure consistent with the
59  * independent variables, T, rho.
60  */
61  virtual doublereal pressure() const;
62 
63  //! sets the thermodynamic pressure (Pa).
64  /*!
65  * This method calculates the density that is consistent with the
66  * desired pressure, given the temperature.
67  *
68  * @param p Pressure (Pa)
69  */
70  virtual void setPressure(doublereal p);
71  virtual void setTemperature(const double T);
72  virtual void setDensity(const double rho);
73 
74  virtual void getChemPotentials(doublereal* mu) const {
75  mu[0] = gibbs_mole();
76  }
77 
78  virtual void getPartialMolarEnthalpies(doublereal* hbar) const;
79  virtual void getPartialMolarEntropies(doublereal* sbar) const;
80  virtual void getPartialMolarIntEnergies(doublereal* ubar) const;
81  virtual void getPartialMolarCp(doublereal* cpbar) const;
82  virtual void getPartialMolarVolumes(doublereal* vbar) const;
83 
84  virtual void getActivityConcentrations(doublereal* c) const;
85  virtual doublereal standardConcentration(size_t k=0) const;
86 
87  virtual void getActivities(doublereal* a) const;
88 
89  virtual doublereal isothermalCompressibility() const;
90  virtual doublereal thermalExpansionCoeff() const;
91 
92  //! Returns a reference to the substance object
94 
95  //@}
96  /// @name Properties of the Standard State of the Species in the Solution
97  /*!
98  * The standard state of the pure fluid is defined as the real properties
99  * of the pure fluid at the most stable state of the fluid at the current
100  * temperature and pressure of the solution. With this definition, the
101  * activity of the fluid is always then defined to be equal to one.
102  */
103  //@{
104 
105  virtual void getStandardChemPotentials(doublereal* mu) const;
106  virtual void getEnthalpy_RT(doublereal* hrt) const;
107  virtual void getEntropy_R(doublereal* sr) const;
108  virtual void getGibbs_RT(doublereal* grt) const;
109 
110  //@}
111 
112  /// @name Thermodynamic Values for the Species Reference States
113  /*!
114  * The species reference state for pure fluids is defined as an ideal gas at
115  * the reference pressure and current temperature of the fluid.
116  */
117  //@{
118 
119  virtual void getEnthalpy_RT_ref(doublereal* hrt) const;
120  virtual void getGibbs_RT_ref(doublereal* grt) const;
121  virtual void getGibbs_ref(doublereal* g) const;
122  virtual void getEntropy_R_ref(doublereal* er) const;
123 
124  /**
125  * @name Setting the State
126  *
127  * These methods set all or part of the thermodynamic state.
128  * @{
129  */
130 
131  virtual void setState_HP(double h, double p, double tol=1e-9);
132  virtual void setState_UV(double u, double v, double tol=1e-9);
133  virtual void setState_SV(double s, double v, double tol=1e-9);
134  virtual void setState_SP(double s, double p, double tol=1e-9);
135  virtual void setState_ST(double s, double t, double tol=1e-9);
136  virtual void setState_TV(double t, double v, double tol=1e-9);
137  virtual void setState_PV(double p, double v, double tol=1e-9);
138  virtual void setState_UP(double u, double p, double tol=1e-9);
139  virtual void setState_VH(double v, double h, double tol=1e-9);
140  virtual void setState_TH(double t, double h, double tol=1e-9);
141  virtual void setState_SH(double s, double h, double tol=1e-9);
142  //@}
143 
144  //! @name Critical State Properties
145  //@{
146 
147  virtual doublereal critTemperature() const;
148  virtual doublereal critPressure() const;
149  virtual doublereal critDensity() const;
150 
151  //@}
152 
153  //! @name Saturation properties.
154  //@{
155 
156  virtual doublereal satTemperature(doublereal p) const;
157  virtual doublereal satPressure(doublereal t);
158  virtual doublereal vaporFraction() const;
159 
160  virtual void setState_Tsat(doublereal t, doublereal x);
161  virtual void setState_Psat(doublereal p, doublereal x);
162  //@}
163 
164  virtual void initThermo();
165  virtual void setParametersFromXML(const XML_Node& eosdata);
166 
167  virtual std::string report(bool show_thermo=true,
168  doublereal threshold=1e-14) const;
169 
170  virtual bool compatibleWithMultiPhase() const {
171  return false;
172  }
173 
174 protected:
175  //! Main call to the tpx level to set the state of the system
176  /*!
177  * @param n Integer indicating which 2 thermo components are held constant
178  * @param x Value of the first component
179  * @param y Value of the second component
180  */
181  void Set(tpx::PropertyPair::type n, double x, double y) const;
182 
183 private:
184  //! Pointer to the underlying tpx object Substance that does the work
185  mutable std::unique_ptr<tpx::Substance> m_sub;
186 
187  //! Int indicating the type of the fluid
188  /*!
189  * The tpx package uses an int to indicate what fluid is being sought. Used
190  * only if #m_tpx_name is not set.
191  */
193 
194  //! Name for this substance used by the TPX package. If this is not set,
195  //! #m_subflag is used instead.
196  std::string m_tpx_name;
197 
198  //! Molecular weight of the substance (kg kmol-1)
199  doublereal m_mw;
200 
201  //! flag to turn on some printing.
202  bool m_verbose;
203 };
204 
205 }
206 
207 #endif
virtual void getPartialMolarCp(doublereal *cpbar) const
Return an array of partial molar heat capacities for the species in the mixture.
PureFluidPhase()
Empty Base Constructor.
virtual void setPressure(doublereal p)
sets the thermodynamic pressure (Pa).
virtual void setState_SP(double s, double p, double tol=1e-9)
Set the specific entropy (J/kg/K) and pressure (Pa).
virtual doublereal critPressure() const
Critical pressure (Pa).
bool m_verbose
flag to turn on some printing.
This phase object consists of a single component that can be a gas, a liquid, a mixed gas-liquid flui...
virtual void setState_ST(double s, double t, double tol=1e-9)
Set the specific entropy (J/kg/K) and temperature (K).
virtual void getPartialMolarVolumes(doublereal *vbar) const
Return an array of partial molar volumes for the species in the mixture.
virtual std::string type() const
String indicating the thermodynamic model implemented.
virtual doublereal satTemperature(doublereal p) const
Return the saturation temperature given the pressure.
virtual void setTemperature(const double T)
Set the internally stored temperature of the phase (K).
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
const size_t npos
index returned by functions to indicate "no position"
Definition: ct_defs.h:165
tpx::Substance & TPX_Substance()
Returns a reference to the substance object.
virtual doublereal critDensity() const
Critical density (kg/m3).
virtual bool compatibleWithMultiPhase() const
Indicates whether this phase type can be used with class MultiPhase for equilibrium calculations...
virtual void setState_VH(double v, double h, double tol=1e-9)
Set the specific volume (m^3/kg) and the specific enthalpy (J/kg)
virtual double maxTemp(size_t k=npos) const
Maximum temperature for which the thermodynamic data for the species are valid.
virtual void getPartialMolarEntropies(doublereal *sbar) const
Returns an array of partial molar entropies of the species in the solution.
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:97
int m_subflag
Int indicating the type of the fluid.
doublereal m_mw
Molecular weight of the substance (kg kmol-1)
virtual void getPartialMolarEnthalpies(doublereal *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.
virtual doublereal pressure() const
Return the thermodynamic pressure (Pa).
virtual void setState_PV(double p, double v, double tol=1e-9)
Set the pressure (Pa) and specific volume (m^3/kg).
virtual void getEntropy_R(doublereal *sr) const
Get the array of nondimensional Entropy functions for the standard state species at the current T and...
virtual void setState_Tsat(doublereal t, doublereal x)
Set the state to a saturated system at a particular temperature.
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:93
virtual void getGibbs_RT(doublereal *grt) const
Get the nondimensional Gibbs functions for the species in their standard states at the current T and ...
virtual doublereal cp_mole() const
Molar heat capacity at constant pressure. Units: J/kmol/K.
virtual doublereal intEnergy_mole() const
Molar internal energy. Units: J/kmol.
virtual void setState_Psat(doublereal p, doublereal x)
Set the state to a saturated system at a particular pressure.
virtual doublereal enthalpy_mole() const
Molar enthalpy. Units: J/kmol.
virtual void setState_TH(double t, double h, double tol=1e-9)
Set the temperature (K) and the specific enthalpy (J/kg)
virtual doublereal thermalExpansionCoeff() const
Return the volumetric thermal expansion coefficient. Units: 1/K.
std::unique_ptr< tpx::Substance > m_sub
Pointer to the underlying tpx object Substance that does the work.
virtual doublereal isothermalCompressibility() const
Returns the isothermal compressibility. Units: 1/Pa.
virtual void getEnthalpy_RT_ref(doublereal *hrt) const
virtual double minTemp(size_t k=npos) const
Minimum temperature for which the thermodynamic data for the species or phase are valid...
virtual void getActivityConcentrations(doublereal *c) const
This method returns an array of generalized concentrations.
virtual doublereal vaporFraction() const
Return the fraction of vapor at the current conditions.
virtual doublereal cv_mole() const
Molar heat capacity at constant volume. Units: J/kmol/K.
virtual void getEnthalpy_RT(doublereal *hrt) const
Get the nondimensional Enthalpy functions for the species at their standard states at the current T a...
virtual doublereal gibbs_mole() const
Molar Gibbs function. Units: J/kmol.
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...
virtual void setState_HP(double h, double p, double tol=1e-9)
Set the internally stored specific enthalpy (J/kg) and pressure (Pa) of the phase.
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
virtual void setState_UP(double u, double p, double tol=1e-9)
Set the specific internal energy (J/kg) and pressure (Pa).
virtual void setParametersFromXML(const XML_Node &eosdata)
Set equation of state parameter values from XML entries.
virtual doublereal entropy_mole() const
Molar entropy. Units: J/kmol/K.
virtual void setState_TV(double t, double v, double tol=1e-9)
Set the temperature (K) and specific volume (m^3/kg).
virtual doublereal critTemperature() const
Critical temperature (K).
virtual doublereal standardConcentration(size_t k=0) const
Return the standard concentration for the kth species.
virtual void setDensity(const double rho)
Set the internally stored density (kg/m^3) of the phase.
std::string m_tpx_name
Name for this substance used by the TPX package.
void setSubstance(const std::string &name)
Set the name of the TPX substance to use for the equation of state.
virtual void getStandardChemPotentials(doublereal *mu) const
virtual void getPartialMolarIntEnergies(doublereal *ubar) const
Return an array of partial molar internal energies for the species in the mixture.
virtual void initThermo()
Initialize the ThermoPhase object after all species have been set up.
std::string name() const
Return the name of the phase.
Definition: Phase.cpp:78
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)
void Set(tpx::PropertyPair::type n, double x, double y) const
Main call to the tpx level to set the state of the system.
virtual void getActivities(doublereal *a) const
Get the array of non-dimensional activities at the current solution temperature, pressure, and solution concentration.
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).
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:8
Header file for class ThermoPhase, the base class for phases with thermodynamic properties, and the text for the Module thermoprops (see Thermodynamic Properties and class ThermoPhase).
virtual doublereal satPressure(doublereal t)
Return the saturation pressure given the temperature.
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).
virtual void getGibbs_RT_ref(doublereal *grt) const
Returns the vector of nondimensional Gibbs Free Energies of the reference state at the current temper...
virtual void getEntropy_R_ref(doublereal *er) const
Returns the vector of nondimensional entropies of the reference state at the current temperature of t...