PengRobinsonGas.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2014-2023 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::PengRobinsonGas
26 
27 Description
28  PengRobinsonGas cubic equation of state for gases
29 
30  Coefficient mixing is very inaccurate and not supported, so this equation of
31  state can only be applied to mixtures by using a thermophysical properties
32  model which mixes specie property value.
33 
34 Usage
35  \table
36  Property | Description
37  Tc | Critical temperature [K]
38  Vc | Critical volume [m^3/kmol]
39  Pc | Critical pressure [Pa]
40  omega | Acentric factor [-]
41  \endtable
42 
43  Example specification of the PengRobinsonGas equation of state for methane:
44  \verbatim
45  equationOfState
46  {
47  Tc 190.55;
48  Vc 0.0285;
49  Pc 4.595e6;
50  omega 0.0115;
51 
52  }
53  \endverbatim
54 
55 SourceFiles
56  PengRobinsonGasI.H
57  PengRobinsonGas.C
58 
59 \*---------------------------------------------------------------------------*/
60 
61 #ifndef PengRobinsonGas_H
62 #define PengRobinsonGas_H
63 
64 #include "autoPtr.H"
65 
66 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
67 
68 namespace Foam
69 {
70 
71 // Forward declaration of friend functions and operators
72 
73 template<class Specie> class PengRobinsonGas;
74 
75 template<class Specie>
76 inline PengRobinsonGas<Specie> operator+
77 (
78  const PengRobinsonGas<Specie>&,
79  const PengRobinsonGas<Specie>&
80 );
81 
82 template<class Specie>
83 inline PengRobinsonGas<Specie> operator*
84 (
85  const scalar,
86  const PengRobinsonGas<Specie>&
87 );
88 
89 template<class Specie>
90 inline PengRobinsonGas<Specie> operator==
91 (
94 );
95 
96 template<class Specie>
97 Ostream& operator<<
98 (
99  Ostream&,
101 );
102 
103 
104 
105 /*---------------------------------------------------------------------------*\
106  Class PengRobinsonGas Declaration
107 \*---------------------------------------------------------------------------*/
108 
109 template<class Specie>
110 class PengRobinsonGas
111 :
112  public Specie
113 {
114  // Private Data
115 
116  //- Critical Temperature [K]
117  scalar Tc_;
118 
119  //- Critical volume [m^3/kmol]
120  scalar Vc_;
121 
122  //- Critical compression factor [-]
123  scalar Zc_;
124 
125  //- Critical Pressure [Pa]
126  scalar Pc_;
127 
128  //- Acentric factor [-]
129  scalar omega_;
130 
131 
132 public:
133 
134  // Constructors
135 
136  //- Construct from components
137  inline PengRobinsonGas
138  (
139  const Specie& sp,
140  const scalar& Tc,
141  const scalar& Vc,
142  const scalar& Zc,
143  const scalar& Pc,
144  const scalar& omega
145  );
146 
147  //- Construct from name and dictionary
148  PengRobinsonGas(const word& name, const dictionary& dict);
149 
150  //- Construct as named copy
151  inline PengRobinsonGas(const word& name, const PengRobinsonGas&);
152 
153  //- Construct and return a clone
154  inline autoPtr<PengRobinsonGas> clone() const;
155 
156 
157  // Member Functions
158 
159  //- Return the instantiated type name
160  static word typeName()
161  {
162  return "PengRobinsonGas<" + word(Specie::typeName_()) + '>';
163  }
164 
165  // Fundamental properties
166 
167 
168  //- Is the equation of state is incompressible i.e. rho != f(p)
169  static const bool incompressible = false;
170 
171  //- Is the equation of state is isochoric i.e. rho = const
172  static const bool isochoric = false;
173 
174  //- Return density [kg/m^3]
175  inline scalar rho(scalar p, scalar T) const;
176 
177  //- Return enthalpy contribution [J/kg]
178  inline scalar h(const scalar p, const scalar T) const;
179 
180  //- Return Cp contribution [J/(kg K]
181  inline scalar Cp(scalar p, scalar T) const;
182 
183  //- Return internal energy contribution [J/kg]
184  inline scalar e(const scalar p, const scalar T) const;
185 
186  //- Return Cv contribution [J/(kg K]
187  inline scalar Cv(scalar p, scalar T) const;
188 
189  //- Return entropy contribution to the integral of Cp/T [J/kg/K]
190  inline scalar sp(const scalar p, const scalar T) const;
191 
192  //- Return entropy contribution to the integral of Cv/T [J/kg/K]
193  inline scalar sv(const scalar p, const scalar T) const;
194 
195  //- Return compressibility [s^2/m^2]
196  inline scalar psi(scalar p, scalar T) const;
197 
198  //- Return compression factor []
199  inline scalar Z(scalar p, scalar T) const;
200 
201  //- Return (Cp - Cv) [J/(kg K]
202  inline scalar CpMCv(scalar p, scalar T) const;
203 
204  //- Return volumetric coefficient of thermal expansion [1/T]
205  inline scalar alphav(const scalar p, const scalar T) const;
206 
207 
208  // IO
209 
210  //- Write to Ostream
211  void write(Ostream& os) const;
212 
213  // Member Operators
214 
215  inline void operator+=(const PengRobinsonGas&);
216  inline void operator*=(const scalar);
217 
218 
219  // Friend operators
220 
221  friend PengRobinsonGas operator+ <Specie>
222  (
223  const PengRobinsonGas&,
224  const PengRobinsonGas&
225  );
226 
227  friend PengRobinsonGas operator* <Specie>
228  (
229  const scalar s,
230  const PengRobinsonGas&
231  );
232 
233  friend PengRobinsonGas operator== <Specie>
234  (
236  const PengRobinsonGas&
237  );
238 
239 
240  // Ostream Operator
241 
242  friend Ostream& operator<< <Specie>
243  (
244  Ostream&,
245  const PengRobinsonGas&
246  );
247 };
248 
249 
250 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
251 
252 } // End namespace Foam
253 
254 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
255 
257 
258 #ifdef NoRepository
259  #include "PengRobinsonGas.C"
260 #endif
261 
262 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
263 
264 #endif
265 
266 // ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
PengRobinsonGas cubic equation of state for gases.
scalar Cv(scalar p, scalar T) const
Return Cv contribution [J/(kg K].
scalar psi(scalar p, scalar T) const
Return compressibility [s^2/m^2].
scalar alphav(const scalar p, const scalar T) const
Return volumetric coefficient of thermal expansion [1/T].
static word typeName()
Return the instantiated type name.
scalar e(const scalar p, const scalar T) const
Return internal energy contribution [J/kg].
void write(Ostream &os) const
Write to Ostream.
scalar rho(scalar p, scalar T) const
Return density [kg/m^3].
scalar CpMCv(scalar p, scalar T) const
Return (Cp - Cv) [J/(kg K].
scalar h(const scalar p, const scalar T) const
Return enthalpy contribution [J/kg].
scalar Cp(scalar p, scalar T) const
Return Cp contribution [J/(kg K].
void operator+=(const PengRobinsonGas &)
autoPtr< PengRobinsonGas > clone() const
Construct and return a clone.
static const bool isochoric
Is the equation of state is isochoric i.e. rho = const.
scalar sv(const scalar p, const scalar T) const
Return entropy contribution to the integral of Cv/T [J/kg/K].
scalar sp(const scalar p, const scalar T) const
Return entropy contribution to the integral of Cp/T [J/kg/K].
static const bool incompressible
Is the equation of state is incompressible i.e. rho != f(p)
scalar Z(scalar p, scalar T) const
Return compression factor [].
void operator*=(const scalar)
PengRobinsonGas(const Specie &sp, const scalar &Tc, const scalar &Vc, const scalar &Zc, const scalar &Pc, const scalar &omega)
Construct from components.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Convenience class to handle the input of constant rotational speed. Reads an omega entry with default...
Definition: omega.H:54
A class for handling words, derived from string.
Definition: word.H:62
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Namespace for OpenFOAM.
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
dictionary dict
volScalarField & p