ePowerThermoI.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) 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 \*---------------------------------------------------------------------------*/
25 
26 #include "ePowerThermo.H"
27 #include "specie.H"
28 
29 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
30 
31 template<class EquationOfState>
33 (
34  const scalar T
35 ) const
36 {
37  if (T < 0)
38  {
40  << "attempt to evaluate ePowerThermo<EquationOfState>"
41  " for negative temperature " << T
42  << abort(FatalError);
43  }
44 }
45 
46 
47 template<class EquationOfState>
49 (
50  const word& name,
51  const ePowerThermo& jt
52 )
53 :
54  EquationOfState(name, jt),
55  c0_(jt.c0_),
56  n0_(jt.n0_),
57  Tref_(jt.Tref_),
58  Hf_(jt.Hf_)
59 {}
60 
61 
62 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
63 
64 template<class EquationOfState>
66 (
67  const EquationOfState& st,
68  const scalar c0,
69  const scalar n0,
70  const scalar Tref,
71  const scalar Hf
72 )
73 :
74  EquationOfState(st),
75  c0_(c0),
76  n0_(n0),
77  Tref_(Tref),
78  Hf_(Hf)
79 {}
80 
81 
82 template<class EquationOfState>
85 {
87  (
89  );
90 }
91 
92 
93 template<class EquationOfState>
96 {
98  (
100  );
101 }
102 
103 
104 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
105 
106 template<class EquationOfState>
108 (
109  const scalar T
110 ) const
111 {
112  return T;
113 }
114 
115 
116 template<class EquationOfState>
117 inline Foam::scalar Foam::ePowerThermo<EquationOfState>::Cv
118 (
119  const scalar p,
120  const scalar T
121 ) const
122 {
123  return c0_*pow(T/Tref_, n0_) + EquationOfState::Cv(p, T);
124 }
125 
126 
127 template<class EquationOfState>
128 inline Foam::scalar Foam::ePowerThermo<EquationOfState>::Es
129 (
130  const scalar p,
131  const scalar T
132 ) const
133 {
134  return
135  c0_*(pow(T, n0_ + 1) - pow(Tstd, n0_ + 1))/(pow(Tref_, n0_)*(n0_ + 1))
136  + EquationOfState::E(p, T);
137 }
138 
139 
140 template<class EquationOfState>
141 inline Foam::scalar Foam::ePowerThermo<EquationOfState>::Ea
142 (
143  const scalar p,
144  const scalar T
145 ) const
146 {
147  return Es(p, T) + Hf();
148 }
149 
150 
151 template<class EquationOfState>
152 inline Foam::scalar Foam::ePowerThermo<EquationOfState>::Hf() const
153 {
154  return Hf_;
155 }
156 
157 
158 template<class EquationOfState>
159 inline Foam::scalar Foam::ePowerThermo<EquationOfState>::S
160 (
161  const scalar p,
162  const scalar T
163 ) const
164 {
165  return
166  c0_*(pow(T, n0_) - pow(Tstd, n0_))/(pow(Tref_, n0_)*n0_)
167  + EquationOfState::Sv(p, T);
168 }
169 
170 
171 template<class EquationOfState>
173 (
174  const scalar T
175 ) const
176 {
177  return
178  c0_*(pow(T, n0_ + 1) - pow(Tstd, n0_ + 1))/(pow(Tref_, n0_)*(n0_ + 1))
179  + Hf() + Pstd/EquationOfState::rho(Pstd, T)
180  - S(Pstd, T)*T;
181 }
182 
183 
184 template<class EquationOfState>
186 (
187  const scalar p,
188  const scalar T
189 ) const
190 {
192  return 0; // + EquationOfState::dCpdT
193 }
194 
195 
196 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
197 
198 template<class EquationOfState>
199 inline void Foam::ePowerThermo<EquationOfState>::operator+=
200 (
202 )
203 {
204  scalar Y1 = this->Y();
205 
206  EquationOfState::operator+=(ct);
207 
208  if (mag(this->Y()) > small)
209  {
210  Y1 /= this->Y();
211  const scalar Y2 = ct.Y()/this->Y();
212 
213  Hf_ = Y1*Hf_ + Y2*ct.Hf_;
214  c0_ = Y1*c0_ + Y2*ct.c0_;
215  n0_ = Y1*n0_ + Y2*ct.n0_;
216  Tref_ = Y1*Tref_ + Y2*ct.Tref_;
217  }
218 }
219 
220 
221 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
222 
223 template<class EquationOfState>
224 inline Foam::ePowerThermo<EquationOfState> Foam::operator+
225 (
228 )
229 {
230  EquationOfState eofs
231  (
232  static_cast<const EquationOfState&>(ct1)
233  + static_cast<const EquationOfState&>(ct2)
234  );
235 
236  if (mag(eofs.Y()) < small)
237  {
239  (
240  eofs,
241  ct1.c0_,
242  ct1.n0_,
243  ct1.Tref_,
244  ct1.Hf_
245  );
246  }
247  else
248  {
250  (
251  eofs,
252  ct1.Y()/eofs.Y()*ct1.c0_
253  + ct2.Y()/eofs.Y()*ct2.c0_,
254  ct1.Y()/eofs.Y()*ct1.n0_
255  + ct2.Y()/eofs.Y()*ct2.n0_,
256  ct1.Y()/eofs.Y()*ct1.Tref_
257  + ct2.Y()/eofs.Y()*ct2.Tref_,
258  ct1.Y()/eofs.Y()*ct1.Hf_
259  + ct2.Y()/eofs.Y()*ct2.Hf_
260  );
261  }
262 }
263 
264 
265 template<class EquationOfState>
266 inline Foam::ePowerThermo<EquationOfState> Foam::operator*
267 (
268  const scalar s,
270 )
271 {
273  (
274  s*static_cast<const EquationOfState&>(ct),
275  ct.c0_,
276  ct.n0_,
277  ct.Tref_,
278  ct.Hf_
279  );
280 }
281 
282 
283 template<class EquationOfState>
284 inline Foam::ePowerThermo<EquationOfState> Foam::operator==
285 (
288 )
289 {
290  EquationOfState eofs
291  (
292  static_cast<const EquationOfState&>(ct1)
293  == static_cast<const EquationOfState&>(ct2)
294  );
295 
297  (
298  eofs,
299  ct2.Y()/eofs.Y()*ct2.c0_
300  - ct1.Y()/eofs.Y()*ct1.c0_,
301  ct2.Y()/eofs.Y()*ct2.n0_
302  - ct1.Y()/eofs.Y()*ct1.n0_,
303  ct2.Y()/eofs.Y()*ct2.Tref_
304  - ct1.Y()/eofs.Y()*ct1.Tref_,
305  ct2.Y()/eofs.Y()*ct2.Hf_
306  - ct1.Y()/eofs.Y()*ct1.Hf_
307  );
308 }
309 
310 
311 // ************************************************************************* //
dictionary dict
scalar Ea(const scalar p, const scalar T) const
Absolute internal energy [J/kg].
scalar limit(const scalar T) const
Limit the temperature to be in the range Tlow_ to Thigh_.
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
scalar Es(const scalar p, const scalar T) const
Definition: HtoEthermo.H:11
const dimensionedScalar & Tstd
Standard temperature.
const volScalarField & Cv
scalar S(const scalar p, const scalar T) const
Entropy [J/kg/K].
Power-function based thermodynamics package templated on EquationOfState.
Definition: ePowerThermo.H:54
static autoPtr< ePowerThermo > New(const dictionary &dict)
Selector from dictionary.
Definition: ePowerThermoI.H:95
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))
autoPtr< ePowerThermo > clone() const
Construct and return a clone.
Definition: ePowerThermoI.H:84
A class for handling words, derived from string.
Definition: word.H:59
scalar dCpdT(const scalar p, const scalar T) const
Temperature derivative of heat capacity at constant pressure.
scalar Hf() const
Enthalpy of formation [J/kg].
errorManip< error > abort(error &err)
Definition: errorManip.H:131
const volScalarField & T
scalar Es(const scalar p, const scalar T) const
Sensible internal energy [J/kg].
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
PtrList< volScalarField > & Y
scalar Cv(const scalar p, const scalar T) const
Heat capacity at constant volume [J/kg/K].
dimensioned< scalar > mag(const dimensioned< Type > &)
const dimensionedScalar & Pstd
Standard pressure.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:366
scalar Gstd(const scalar T) const
Gibbs free energy of the mixture in the standard state [J/kg].