Cantera  3.1.0b1
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
20namespace 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{
32public:
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) {
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
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
195protected:
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
204private:
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
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
Header file for class ThermoPhase, the base class for phases with thermodynamic properties,...
A map of string keys to values whose type can vary at runtime.
Definition AnyMap.h:431
string name() const
Return the name of the phase.
Definition Phase.cpp:20
This phase object consists of a single component that can be a gas, a liquid, a mixed gas-liquid flui...
void Set(tpx::PropertyPair::type n, double x, double y) const
Main call to the tpx level to set the state of the system.
double enthalpy_mole() const override
Molar enthalpy. Units: J/kmol.
double thermalExpansionCoeff() const override
Return the volumetric thermal expansion coefficient. Units: 1/K.
void getPartialMolarEnthalpies(double *hbar) const override
Returns an array of partial molar enthalpies for the species in the mixture.
void getChemPotentials(double *mu) const override
Get the species chemical potentials. Units: J/kmol.
double pressure() const override
Return the thermodynamic pressure (Pa).
vector< string > partialStates() const override
Return a vector of settable partial property sets within a phase.
double critPressure() const override
Critical pressure (Pa).
string m_tpx_name
Name for this substance used by the TPX package.
double critDensity() const override
Critical density (kg/m3).
void getEntropy_R(double *sr) const override
Get the array of nondimensional Entropy functions for the standard state species at the current T and...
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)
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...
void getStandardChemPotentials(double *mu) const override
Get the array of chemical potentials at unit activity for the species at their standard states at the...
double critTemperature() const override
Critical temperature (K).
void getActivities(double *a) const override
Get the array of non-dimensional activities at the current solution temperature, pressure,...
void getParameters(AnyMap &phaseNode) const override
Store the parameters of a ThermoPhase object such that an identical one could be reconstructed using ...
string type() const override
String indicating the thermodynamic model implemented.
void initThermo() override
Initialize the ThermoPhase object after all species have been set up.
vector< string > fullStates() const override
Return a vector containing full states defining a phase.
void getActivityConcentrations(double *c) const override
This method returns an array of generalized concentrations.
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.
void setPressure(double p) override
sets the thermodynamic pressure (Pa).
unique_ptr< tpx::Substance > m_sub
Pointer to the underlying tpx object Substance that does the work.
void getPartialMolarVolumes(double *vbar) const override
Return an array of partial molar volumes for the species in the mixture.
void setState_PV(double p, double v, double tol=1e-9) override
Set the pressure (Pa) and specific volume (m^3/kg).
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)
double vaporFraction() const override
Return the fraction of vapor at the current conditions.
void setState_TH(double t, double h, double tol=1e-9) override
Set the temperature (K) and the specific enthalpy (J/kg)
double cv_mole() const override
Molar heat capacity at constant volume. Units: J/kmol/K.
void setTemperature(const double T) override
Set the internally stored temperature of the phase (K).
void setSubstance(const string &name)
Set the name of the TPX substance to use for the equation of state.
void getEnthalpy_RT(double *hrt) const override
Get the nondimensional Enthalpy functions for the species at their standard states at the current T a...
void getEntropy_R_ref(double *er) const override
Returns the vector of nondimensional entropies of the reference state at the current temperature of t...
double minTemp(size_t k=npos) const override
Minimum temperature for which the thermodynamic data for the species or phase are valid.
bool isPure() const override
Return whether phase represents a pure (single species) substance.
bool hasPhaseTransition() const override
Return whether phase represents a substance with phase transitions.
double isothermalCompressibility() const override
Returns the isothermal compressibility. Units: 1/Pa.
void getGibbs_RT(double *grt) const override
Get the nondimensional Gibbs functions for the species in their standard states at the current T and ...
double intEnergy_mole() const override
Molar internal energy. Units: J/kmol.
void setState_Tsat(double t, double x) override
Set the state to a saturated system at a particular temperature.
double entropy_mole() const override
Molar entropy. Units: J/kmol/K.
void getPartialMolarIntEnergies(double *ubar) const override
Return an array of partial molar internal energies for the species in the mixture.
double cp_mole() const override
Molar heat capacity at constant pressure. Units: J/kmol/K.
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).
PureFluidPhase()=default
Empty Base Constructor.
Units standardConcentrationUnits() const override
Returns the units of the "standard concentration" for this phase.
void getPartialMolarCp(double *cpbar) const override
Return an array of partial molar heat capacities for the species in the mixture.
double gibbs_mole() const override
Molar Gibbs function. Units: J/kmol.
double standardConcentration(size_t k=0) const override
Return the standard concentration for the kth species.
bool compatibleWithMultiPhase() const override
Indicates whether this phase type can be used with class MultiPhase for equilibrium calculations.
double satTemperature(double p) const override
Return the saturation temperature given the pressure.
double m_mw
Molecular weight of the substance (kg kmol-1)
tpx::Substance & TPX_Substance()
Returns a reference to the substance object.
void setState_TV(double t, double v, double tol=1e-9) override
Set the temperature (K) and specific volume (m^3/kg).
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).
void getGibbs_RT_ref(double *grt) const override
Returns the vector of nondimensional Gibbs Free Energies of the reference state at the current temper...
void setState_Psat(double p, double x) override
Set the state to a saturated system at a particular pressure.
void setState_UP(double u, double p, double tol=1e-9) override
Set the specific internal energy (J/kg) and pressure (Pa).
void setState_SP(double s, double p, double tol=1e-9) override
Set the specific entropy (J/kg/K) and pressure (Pa).
void setState_ST(double s, double t, double tol=1e-9) override
Set the specific entropy (J/kg/K) and temperature (K).
void getPartialMolarEntropies(double *sbar) const override
Returns an array of partial molar entropies of the species in the solution.
bool m_verbose
flag to turn on some printing.
double maxTemp(size_t k=npos) const override
Maximum temperature for which the thermodynamic data for the species are valid.
string phaseOfMatter() const override
String indicating the mechanical phase of the matter in this Phase.
void getEnthalpy_RT_ref(double *hrt) const override
Returns the vector of nondimensional enthalpies of the reference state at the current temperature of ...
double satPressure(double t) override
Return the saturation pressure given the temperature.
void setDensity(const double rho) override
Set the internally stored density (kg/m^3) of the phase.
string report(bool show_thermo=true, double threshold=1e-14) const override
returns a summary of the state of the phase as a string
Base class for a phase with thermodynamic properties.
A representation of the units associated with a dimensional quantity.
Definition Units.h:35
Base class from which all pure substances are derived.
Definition Sub.h:37
Namespace for the Cantera kernel.
Definition AnyMap.cpp:595
const size_t npos
index returned by functions to indicate "no position"
Definition ct_defs.h:180