adiabaticPerfectFluidI.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) 2013-2018 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 \*---------------------------------------------------------------------------*/
25 
26 #include "adiabaticPerfectFluid.H"
27 
28 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
29 
30 template<class Specie>
32 (
33  const Specie& sp,
34  const scalar p0,
35  const scalar rho0,
36  const scalar gamma,
37  const scalar B
38 )
39 :
40  Specie(sp),
41  p0_(p0),
42  rho0_(rho0),
43  gamma_(gamma),
44  B_(B)
45 {}
46 
47 
48 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
49 
50 template<class Specie>
52 (
53  const word& name,
55 )
56 :
57  Specie(name, pf),
58  p0_(pf.p0_),
59  rho0_(pf.rho0_),
60  gamma_(pf.gamma_),
61  B_(pf.B_)
62 {}
63 
64 
65 template<class Specie>
68 {
70  (
72  );
73 }
74 
75 
76 template<class Specie>
79 (
80  const dictionary& dict
81 )
82 {
84  (
86  );
87 }
88 
89 
90 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
91 
92 template<class Specie>
94 (
95  scalar p,
96  scalar T
97 ) const
98 {
99  return rho0_*pow((p + B_)/(p0_ + B_), 1.0/gamma_);
100 }
101 
102 
103 template<class Specie>
104 inline Foam::scalar Foam::adiabaticPerfectFluid<Specie>::H
105 (
106  scalar p,
107  scalar T
108 ) const
109 {
110  // ***HGW This needs to be added, it is not 0
111  return 0;
112 }
113 
114 
115 template<class Specie>
116 inline Foam::scalar Foam::adiabaticPerfectFluid<Specie>::Cp
117 (
118  scalar p,
119  scalar T
120 ) const
121 {
122  return 0;
123 }
124 
125 
126 template<class Specie>
127 inline Foam::scalar Foam::adiabaticPerfectFluid<Specie>::E
128 (
129  scalar p,
130  scalar T
131 ) const
132 {
133  // ***HGW This needs to be added, it is H - p/rho
134  return 0;
135 }
136 
137 
138 template<class Specie>
139 inline Foam::scalar Foam::adiabaticPerfectFluid<Specie>::Cv
140 (
141  scalar p,
142  scalar T
143 ) const
144 {
145  return 0;
146 }
147 
148 
149 template<class Specie>
150 inline Foam::scalar Foam::adiabaticPerfectFluid<Specie>::S
151 (
152  scalar p,
153  scalar T
154 ) const
155 {
156  scalar n = 1 - 1.0/gamma_;
157  return
158  -pow(p0_ + B_, 1.0/gamma_)*(pow((p + B_), n) - pow((Pstd + B_), n))
159  /(rho0_*T*n);
160 }
161 
162 
163 template<class Specie>
165 (
166  scalar p,
167  scalar T
168 ) const
169 {
170  return
171  (rho0_/(gamma_*(p0_ + B_)))
172  *pow((p + B_)/(p0_ + B_), 1.0/gamma_ - 1.0);
173 }
174 
175 
176 template<class Specie>
177 inline Foam::scalar Foam::adiabaticPerfectFluid<Specie>::Z(scalar, scalar) const
178 {
179  return 1;
180 }
181 
182 
183 template<class Specie>
185 (
186  scalar p,
187  scalar T
188 ) const
189 {
190  return 0;
191 }
192 
193 
194 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
195 
196 template<class Specie>
197 inline void Foam::adiabaticPerfectFluid<Specie>::operator+=
198 (
200 )
201 {
202  scalar Y1 = this->Y();
203  Specie::operator+=(pf);
204 
205  if (mag(this->Y()) > small)
206  {
207  Y1 /= this->Y();
208  const scalar Y2 = pf.Y()/this->Y();
209 
210  p0_ = Y1*p0_ + Y2*pf.p0_;
211  rho0_ = Y1*rho0_ + Y2*pf.rho0_;
212  gamma_ = Y1*gamma_ + Y2*pf.gamma_;
213  B_ = Y1*B_ + Y2*pf.B_;
214  }
215 }
216 
217 
218 template<class Specie>
220 {
221  Specie::operator*=(s);
222 }
223 
224 
225 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
226 
227 template<class Specie>
228 inline Foam::adiabaticPerfectFluid<Specie> Foam::operator+
229 (
232 )
233 {
234  Specie sp
235  (
236  static_cast<const Specie&>(pf1)
237  + static_cast<const Specie&>(pf2)
238  );
239 
240  if (mag(sp.Y()) < small)
241  {
243  (
244  sp,
245  pf1.p0_,
246  pf1.rho0_,
247  pf1.gamma_,
248  pf1.B_
249  );
250  }
251  else
252  {
253  const scalar Y1 = pf1.Y()/sp.Y();
254  const scalar Y2 = pf2.Y()/sp.Y();
255 
257  (
258  sp,
259  Y1*pf1.p0_ + Y2*pf2.p0_,
260  Y1*pf1.rho0_ + Y2*pf2.rho0_,
261  Y1*pf1.gamma_ + Y2*pf2.gamma_,
262  Y1*pf1.B_ + Y2*pf2.B_
263  );
264  }
265 }
266 
267 
268 template<class Specie>
269 inline Foam::adiabaticPerfectFluid<Specie> Foam::operator*
270 (
271  const scalar s,
273 )
274 {
276  (
277  s*static_cast<const Specie&>(pf),
278  pf.p0_,
279  pf.rho0_,
280  pf.gamma_,
281  pf.B_
282  );
283 }
284 
285 
286 template<class Specie>
287 inline Foam::adiabaticPerfectFluid<Specie> Foam::operator==
288 (
291 )
292 {
293  Specie sp
294  (
295  static_cast<const Specie&>(pf1)
296  == static_cast<const Specie&>(pf2)
297  );
298 
299  const scalar Y1 = pf1.Y()/sp.Y();
300  const scalar Y2 = pf2.Y()/sp.Y();
301 
303  (
304  sp,
305  Y2*pf2.p0_ - Y1*pf1.p0_,
306  Y2*pf2.rho0_ - Y1*pf1.rho0_,
307  Y2*pf2.gamma_ - Y1*pf1.gamma_,
308  Y2*pf2.B_ - Y1*pf1.B_
309  );
310 }
311 
312 
313 // ************************************************************************* //
scalar Z(scalar p, scalar T) const
Return compression factor [].
dictionary dict
scalar E(const scalar p, const scalar T) const
Return internal energy departure [J/kg].
static autoPtr< adiabaticPerfectFluid > New(const dictionary &dict)
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
adiabaticPerfectFluid(const Specie &sp, const scalar p0, const scalar rho0, const scalar gamma, const scalar B)
Construct from components.
scalar psi(scalar p, scalar T) const
Return compressibility rho/p [s^2/m^2].
scalar S(const scalar p, const scalar T) const
Return entropy [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 Cp(scalar p, scalar T) const
Return Cp departure [J/(kg K].
A class for handling words, derived from string.
Definition: word.H:59
scalar CpMCv(scalar p, scalar T) const
Return (Cp - Cv) [J/(kg K].
const dimensionedScalar Pstd
Standard pressure.
scalar H(const scalar p, const scalar T) const
Return enthalpy departure [J/kg].
autoPtr< adiabaticPerfectFluid > clone() const
Construct and return a clone.
scalar rho(scalar p, scalar T) const
Return density [kg/m^3].
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
Adiabatic perfect fluid equation of state.
PtrList< volScalarField > & Y
scalar Cv(scalar p, scalar T) const
Return Cv departure [J/(kg K].
dimensioned< scalar > mag(const dimensioned< Type > &)
label n
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52