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-2020 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 gas equation of state.
29 
30 SourceFiles
31  PengRobinsonGasI.H
32  PengRobinsonGas.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef PengRobinsonGas_H
37 #define PengRobinsonGas_H
38 
39 #include "autoPtr.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 // Forward declaration of friend functions and operators
47 
48 template<class Specie> class PengRobinsonGas;
49 
50 template<class Specie>
51 inline PengRobinsonGas<Specie> operator+
52 (
54  const PengRobinsonGas<Specie>&
55 );
56 
57 template<class Specie>
58 inline PengRobinsonGas<Specie> operator*
59 (
60  const scalar,
61  const PengRobinsonGas<Specie>&
62 );
63 
64 template<class Specie>
65 inline PengRobinsonGas<Specie> operator==
66 (
67  const PengRobinsonGas<Specie>&,
68  const PengRobinsonGas<Specie>&
69 );
70 
71 template<class Specie>
72 Ostream& operator<<
73 (
74  Ostream&,
75  const PengRobinsonGas<Specie>&
76 );
77 
78 
79 
80 /*---------------------------------------------------------------------------*\
81  Class PengRobinsonGas Declaration
82 \*---------------------------------------------------------------------------*/
83 
84 template<class Specie>
85 class PengRobinsonGas
86 :
87  public Specie
88 {
89  // Private Data
90 
91  //- Critical Temperature [K]
92  scalar Tc_;
93 
94  //- Critical volume [m^3/kmol]
95  scalar Vc_;
96 
97  //- Critical compression factor [-]
98  scalar Zc_;
99 
100  //- Critical Pressure [Pa]
101  scalar Pc_;
102 
103  //- Acentric factor [-]
104  scalar omega_;
105 
106 
107 public:
108 
109  // Constructors
110 
111  //- Construct from components
112  inline PengRobinsonGas
113  (
114  const Specie& sp,
115  const scalar& Tc,
116  const scalar& Vc,
117  const scalar& Zc,
118  const scalar& Pc,
119  const scalar& omega
120  );
121 
122  //- Construct from dictionary
124 
125  //- Construct as named copy
126  inline PengRobinsonGas(const word& name, const PengRobinsonGas&);
127 
128  //- Construct and return a clone
129  inline autoPtr<PengRobinsonGas> clone() const;
130 
131  // Selector from dictionary
132  inline static autoPtr<PengRobinsonGas> New
133  (
134  const dictionary& dict
135  );
136 
137 
138  // Member Functions
139 
140  //- Return the instantiated type name
141  static word typeName()
142  {
143  return "PengRobinsonGas<" + word(Specie::typeName_()) + '>';
144  }
145 
146  // Fundamental properties
147 
148 
149  //- Is the equation of state is incompressible i.e. rho != f(p)
150  static const bool incompressible = false;
151 
152  //- Is the equation of state is isochoric i.e. rho = const
153  static const bool isochoric = false;
154 
155  //- Return density [kg/m^3]
156  inline scalar rho(scalar p, scalar T) const;
157 
158  //- Return enthalpy contribution [J/kg]
159  inline scalar H(const scalar p, const scalar T) const;
160 
161  //- Return Cp contribution [J/(kg K]
162  inline scalar Cp(scalar p, scalar T) const;
163 
164  //- Return internal energy contribution [J/kg]
165  inline scalar E(const scalar p, const scalar T) const;
166 
167  //- Return Cv contribution [J/(kg K]
168  inline scalar Cv(scalar p, scalar T) const;
169 
170  //- Return entropy contribution to the integral of Cp/T [J/kg/K]
171  inline scalar Sp(const scalar p, const scalar T) const;
172 
173  //- Return entropy contribution to the integral of Cv/T [J/kg/K]
174  inline scalar Sv(const scalar p, const scalar T) const;
175 
176  //- Return compressibility [s^2/m^2]
177  inline scalar psi(scalar p, scalar T) const;
178 
179  //- Return compression factor []
180  inline scalar Z(scalar p, scalar T) const;
181 
182  //- Return (Cp - Cv) [J/(kg K]
183  inline scalar CpMCv(scalar p, scalar T) const;
184 
185 
186  // IO
187 
188  //- Write to Ostream
189  void write(Ostream& os) const;
190 
191  // Member Operators
192 
193  inline void operator+=(const PengRobinsonGas&);
194  inline void operator*=(const scalar);
195 
196 
197  // Friend operators
198 
199  friend PengRobinsonGas operator+ <Specie>
200  (
201  const PengRobinsonGas&,
202  const PengRobinsonGas&
203  );
204 
205  friend PengRobinsonGas operator* <Specie>
206  (
207  const scalar s,
208  const PengRobinsonGas&
209  );
210 
211  friend PengRobinsonGas operator== <Specie>
212  (
213  const PengRobinsonGas&,
214  const PengRobinsonGas&
215  );
216 
217 
218  // Ostream Operator
219 
220  friend Ostream& operator<< <Specie>
221  (
222  Ostream&,
223  const PengRobinsonGas&
224  );
225 };
226 
227 
228 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
229 
230 } // End namespace Foam
231 
232 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
233 
234 #include "PengRobinsonGasI.H"
235 
236 #ifdef NoRepository
237  #include "PengRobinsonGas.C"
238 #endif
239 
240 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
241 
242 #endif
243 
244 // ************************************************************************* //
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:158
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 gas equation of state.
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.