Cantera  2.3.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 "mix_defs.h"
19 #include "cantera/tpx/Sub.h"
20 
21 namespace Cantera
22 {
23 //! This phase object consists of a single component that can be a gas, a
24 //! liquid, a mixed gas-liquid fluid, or a fluid beyond its critical point
25 /*!
26  * The object inherits from ThermoPhase. However, it's built on top of the tpx
27  * package.
28  *
29  * @ingroup thermoprops
30  */
32 {
33 public:
34  //! Empty Base Constructor
36 
37  PureFluidPhase(const PureFluidPhase& right);
38  PureFluidPhase& operator=(const PureFluidPhase& right);
39  virtual ThermoPhase* duplMyselfAsThermoPhase() const;
40 
41  //! Equation of state type
42  //! @deprecated To be removed after Cantera 2.3.
43  virtual int eosType() const {
44  warn_deprecated("PureFluidPhase::eosType",
45  "To be removed after Cantera 2.3.");
46  return cPureFluid;
47  }
48  virtual std::string type() const {
49  return "PureFluid";
50  }
51 
52  virtual doublereal enthalpy_mole() const;
53  virtual doublereal intEnergy_mole() const;
54  virtual doublereal entropy_mole() const;
55  virtual doublereal gibbs_mole() const;
56  virtual doublereal cp_mole() const;
57  virtual doublereal cv_mole() const;
58 
59  //! Return the thermodynamic pressure (Pa).
60  /*!
61  * This method calculates the current pressure consistent with the
62  * independent variables, T, rho.
63  */
64  virtual doublereal pressure() const;
65 
66  //! sets the thermodynamic pressure (Pa).
67  /*!
68  * This method calculates the density that is consistent with the
69  * desired pressure, given the temperature.
70  *
71  * @param p Pressure (Pa)
72  */
73  virtual void setPressure(doublereal p);
74 
75  virtual void getChemPotentials(doublereal* mu) const {
76  mu[0] = gibbs_mole();
77  }
78 
79  virtual void getPartialMolarEnthalpies(doublereal* hbar) const;
80  virtual void getPartialMolarEntropies(doublereal* sbar) const;
81  virtual void getPartialMolarIntEnergies(doublereal* ubar) const;
82  virtual void getPartialMolarCp(doublereal* cpbar) const;
83  virtual void getPartialMolarVolumes(doublereal* vbar) const;
84 
85  virtual void getActivityConcentrations(doublereal* c) const;
86  virtual doublereal standardConcentration(size_t k=0) const;
87 
88  virtual void getActivities(doublereal* a) const;
89 
90  virtual doublereal isothermalCompressibility() const;
91  virtual doublereal thermalExpansionCoeff() const;
92 
93  //! Returns a reference to the substance object
95 
96  //@}
97  /// @name Properties of the Standard State of the Species in the Solution
98  /*!
99  * The standard state of the pure fluid is defined as the real properties
100  * of the pure fluid at the most stable state of the fluid at the current
101  * temperature and pressure of the solution. With this definition, the
102  * activity of the fluid is always then defined to be equal to one.
103  */
104  //@{
105 
106  virtual void getStandardChemPotentials(doublereal* mu) const;
107  virtual void getEnthalpy_RT(doublereal* hrt) const;
108  virtual void getEntropy_R(doublereal* sr) const;
109  virtual void getGibbs_RT(doublereal* grt) const;
110 
111  //@}
112 
113  /// @name Thermodynamic Values for the Species Reference States
114  /*!
115  * The species reference state for pure fluids is defined as an ideal gas at
116  * the reference pressure and current temperature of the fluid.
117  */
118  //@{
119 
120  virtual void getEnthalpy_RT_ref(doublereal* hrt) const;
121  virtual void getGibbs_RT_ref(doublereal* grt) const;
122  virtual void getGibbs_ref(doublereal* g) const;
123  virtual void getEntropy_R_ref(doublereal* er) const;
124 
125  /**
126  * @name Setting the State
127  *
128  * These methods set all or part of the thermodynamic state.
129  * @{
130  */
131 
132  virtual void setState_HP(double h, double p, double tol=1e-9);
133  virtual void setState_UV(double u, double v, double tol=1e-9);
134  virtual void setState_SV(double s, double v, double tol=1e-9);
135  virtual void setState_SP(double s, double p, double tol=1e-9);
136  virtual void setState_ST(double s, double t, double tol=1e-9);
137  virtual void setState_TV(double t, double v, double tol=1e-9);
138  virtual void setState_PV(double p, double v, double tol=1e-9);
139  virtual void setState_UP(double u, double p, double tol=1e-9);
140  virtual void setState_VH(double v, double h, double tol=1e-9);
141  virtual void setState_TH(double t, double h, double tol=1e-9);
142  virtual void setState_SH(double s, double h, double tol=1e-9);
143  //@}
144 
145  //! @name Critical State Properties
146  //@{
147 
148  virtual doublereal critTemperature() const;
149  virtual doublereal critPressure() const;
150  virtual doublereal critDensity() const;
151 
152  //@}
153 
154  //! @name Saturation properties.
155  //@{
156 
157  virtual doublereal satTemperature(doublereal p) const;
158  virtual doublereal satPressure(doublereal t);
159  virtual doublereal vaporFraction() const;
160 
161  virtual void setState_Tsat(doublereal t, doublereal x);
162  virtual void setState_Psat(doublereal p, doublereal x);
163  //@}
164 
165  virtual void initThermo();
166  virtual void setParametersFromXML(const XML_Node& eosdata);
167 
168  virtual std::string report(bool show_thermo=true,
169  doublereal threshold=1e-14) const;
170 
171  virtual bool compatibleWithMultiPhase() const {
172  return false;
173  }
174 
175 protected:
176  //! Main call to the tpx level to set the state of the system
177  /*!
178  * @param n Integer indicating which 2 thermo components are held constant
179  * @param x Value of the first component
180  * @param y Value of the second component
181  */
182  void Set(tpx::PropertyPair::type n, double x, double y) const;
183 
184  //! Sets the state using a TPX::TV call
185  void setTPXState() const;
186 
187 private:
188  //! Pointer to the underlying tpx object Substance that does the work
189  mutable std::unique_ptr<tpx::Substance> m_sub;
190 
191  //! Int indicating the type of the fluid
192  /*!
193  * The tpx package uses an int to indicate what fluid is being sought.
194  */
196 
197  //! Molecular weight of the substance (kg kmol-1)
198  doublereal m_mw;
199 
200  //! flag to turn on some printing.
201  bool m_verbose;
202 };
203 
204 }
205 
206 #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 std::string report(bool show_thermo=true, doublereal threshold=1e-14) const
returns a summary of the state of the phase as a string
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 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.
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
Definition: global.cpp:54
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.
virtual int eosType() const
Equation of state type.
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 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 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.
virtual ThermoPhase * duplMyselfAsThermoPhase() const
Duplication routine for objects which inherit from ThermoPhase.
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: application.cpp:29
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...
void setTPXState() const
Sets the state using a TPX::TV call.