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-2021 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 (
92  const PengRobinsonGas<Specie>&,
93  const PengRobinsonGas<Specie>&
94 );
95 
96 template<class Specie>
97 Ostream& operator<<
98 (
99  Ostream&,
100  const PengRobinsonGas<Specie>&
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 dictionary
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  // Selector from dictionary
157  inline static autoPtr<PengRobinsonGas> New
158  (
159  const dictionary& dict
160  );
161 
162 
163  // Member Functions
164 
165  //- Return the instantiated type name
166  static word typeName()
167  {
168  return "PengRobinsonGas<" + word(Specie::typeName_()) + '>';
169  }
170 
171  // Fundamental properties
172 
173 
174  //- Is the equation of state is incompressible i.e. rho != f(p)
175  static const bool incompressible = false;
176 
177  //- Is the equation of state is isochoric i.e. rho = const
178  static const bool isochoric = false;
179 
180  //- Return density [kg/m^3]
181  inline scalar rho(scalar p, scalar T) const;
182 
183  //- Return enthalpy contribution [J/kg]
184  inline scalar H(const scalar p, const scalar T) const;
185 
186  //- Return Cp contribution [J/(kg K]
187  inline scalar Cp(scalar p, scalar T) const;
188 
189  //- Return internal energy contribution [J/kg]
190  inline scalar E(const scalar p, const scalar T) const;
191 
192  //- Return Cv contribution [J/(kg K]
193  inline scalar Cv(scalar p, scalar T) const;
194 
195  //- Return entropy contribution to the integral of Cp/T [J/kg/K]
196  inline scalar Sp(const scalar p, const scalar T) const;
197 
198  //- Return entropy contribution to the integral of Cv/T [J/kg/K]
199  inline scalar Sv(const scalar p, const scalar T) const;
200 
201  //- Return compressibility [s^2/m^2]
202  inline scalar psi(scalar p, scalar T) const;
203 
204  //- Return compression factor []
205  inline scalar Z(scalar p, scalar T) const;
206 
207  //- Return (Cp - Cv) [J/(kg K]
208  inline scalar CpMCv(scalar p, scalar T) const;
209 
210  //- Return volumetric coefficient of thermal expansion [1/T]
211  inline scalar alphav(const scalar p, const scalar T) const;
212 
213 
214  // IO
215 
216  //- Write to Ostream
217  void write(Ostream& os) const;
218 
219  // Member Operators
220 
221  inline void operator+=(const PengRobinsonGas&);
222  inline void operator*=(const scalar);
223 
224 
225  // Friend operators
226 
227  friend PengRobinsonGas operator+ <Specie>
228  (
229  const PengRobinsonGas&,
230  const PengRobinsonGas&
231  );
232 
233  friend PengRobinsonGas operator* <Specie>
234  (
235  const scalar s,
236  const PengRobinsonGas&
237  );
238 
239  friend PengRobinsonGas operator== <Specie>
240  (
241  const PengRobinsonGas&,
242  const PengRobinsonGas&
243  );
244 
245 
246  // Ostream Operator
247 
248  friend Ostream& operator<< <Specie>
249  (
250  Ostream&,
251  const PengRobinsonGas&
252  );
253 };
254 
255 
256 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
257 
258 } // End namespace Foam
259 
260 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
261 
262 #include "PengRobinsonGasI.H"
263 
264 #ifdef NoRepository
265  #include "PengRobinsonGas.C"
266 #endif
267 
268 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
269 
270 #endif
271 
272 // ************************************************************************* //
void write(Ostream &os) const
Write to Ostream.
dictionary dict
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
scalar alphav(const scalar p, const scalar T) const
Return volumetric coefficient of thermal expansion [1/T].
scalar psi(scalar p, scalar T) const
Return compressibility [s^2/m^2].
scalar Z(scalar p, scalar T) const
Return compression factor [].
void operator*=(const scalar)
scalar H(const scalar p, const scalar T) const
Return enthalpy contribution [J/kg].
scalar Sp(const scalar p, const scalar T) const
Return entropy contribution to the integral of Cp/T [J/kg/K].
scalar Cv(scalar p, scalar T) const
Return Cv contribution [J/(kg K].
autoPtr< PengRobinsonGas > clone() const
Construct and return a clone.
scalar rho(scalar p, scalar T) const
Return density [kg/m^3].
scalar Cp(scalar p, scalar T) const
Return Cp contribution [J/(kg K].
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.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
scalar Sv(const scalar p, const scalar T) const
Return entropy contribution to the integral of Cv/T [J/kg/K].
scalar CpMCv(scalar p, scalar T) const
Return (Cp - Cv) [J/(kg K].
A class for handling words, derived from string.
Definition: word.H:59
static autoPtr< PengRobinsonGas > New(const dictionary &dict)
static word typeName()
Return the instantiated type name.
PengRobinsonGas cubic equation of state for gases.
void operator+=(const PengRobinsonGas &)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
PengRobinsonGas(const Specie &sp, const scalar &Tc, const scalar &Vc, const scalar &Zc, const scalar &Pc, const scalar &omega)
Construct from components.
static const bool incompressible
Is the equation of state is incompressible i.e. rho != f(p)
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
static const bool isochoric
Is the equation of state is isochoric i.e. rho = const.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
volScalarField & p
scalar E(const scalar p, const scalar T) const
Return internal energy contribution [J/kg].
Namespace for OpenFOAM.