valueMulticomponentMixture.C
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-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 \*---------------------------------------------------------------------------*/
25 
27 
28 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
29 
30 template<class ThermoType>
31 template<class Method, class ... Args>
32 Foam::scalar
35 (
36  Method psiMethod,
37  const Args& ... args
38 ) const
39 {
40  scalar psi = 0;
41 
42  forAll(Y_, i)
43  {
44  psi += Y_[i]*(specieThermos_[i].*psiMethod)(args ...);
45  }
46 
47  return psi;
48 }
49 
50 
51 template<class ThermoType>
52 template<class Method, class ... Args>
53 Foam::scalar
56 (
57  Method psiMethod,
58  const Args& ... args
59 ) const
60 {
61  scalar rPsi = 0;
62 
63  forAll(Y_, i)
64  {
65  rPsi += Y_[i]/(specieThermos_[i].*psiMethod)(args ...);
66  }
67 
68  return 1/rPsi;
69 }
70 
71 
72 template<class ThermoType>
73 Foam::scalar
75 (
76  const scalar T
77 ) const
78 {
79  return T;
80 }
81 
82 
83 template<class ThermoType>
84 template<class Method, class ... Args>
85 Foam::scalar
88 (
89  Method psiMethod,
90  const Args& ... args
91 ) const
92 {
93  scalar psi = 0;
94 
95  forAll(X_, i)
96  {
97  psi += X_[i]*(specieThermos_[i].*psiMethod)(args ...);
98  }
99 
100  return psi;
101 }
102 
103 
104 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
105 
106 template<class ThermoType>
108 (
109  const dictionary& dict
110 )
111 :
112  multicomponentMixture<ThermoType>(dict),
113  thermoMixture_(this->specieThermos()),
114  transportMixture_(this->specieThermos())
115 {}
116 
117 
118 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
119 
120 template<class ThermoType>
121 Foam::scalar
123 {
124  return harmonicMassWeighted(&ThermoType::W);
125 }
126 
127 
128 template<class ThermoType>
129 Foam::scalar
131 (
132  scalar p,
133  scalar T
134 ) const
135 {
136  return harmonicMassWeighted(&ThermoType::rho, p, T);
137 }
138 
139 
140 template<class ThermoType>
141 Foam::scalar
143 (
144  scalar p,
145  scalar T
146 ) const
147 {
148  scalar oneByRho = 0;
149  scalar psiByRho2 = 0;
150 
151  forAll(Y_, i)
152  {
153  const scalar rhoi = specieThermos_[i].rho(p, T);
154  const scalar psii = specieThermos_[i].psi(p, T);
155 
156  oneByRho += Y_[i]/rhoi;
157 
158  if (psii > 0)
159  {
160  psiByRho2 += Y_[i]*psii/sqr(rhoi);
161  }
162  }
163 
164  return psiByRho2/sqr(oneByRho);
165 }
166 
167 
168 template<class ThermoType>
169 Foam::scalar
171 (
172  scalar p,
173  scalar T
174 ) const
175 {
176  return harmonicMassWeighted(&ThermoType::alphav, p, T);
177 }
178 
179 
180 template<class ThermoType>
181 Foam::scalar
183 {
184  return massWeighted(&ThermoType::hf);
185 }
186 
187 
188 #define thermoMixtureFunction(Func) \
189  \
190  template<class ThermoType> \
191  Foam::scalar \
192  Foam::valueMulticomponentMixture<ThermoType>::thermoMixtureType::Func \
193  ( \
194  scalar p, \
195  scalar T \
196  ) const \
197  { \
198  return massWeighted(&ThermoType::Func, p, T); \
199  }
200 
209 
210 
211 template<class ThermoType>
212 Foam::scalar
214 (
215  const scalar he,
216  scalar p,
217  scalar T0
218 ) const
219 {
220  return ThermoType::T
221  (
222  *this,
223  he,
224  p,
225  T0,
226  &thermoMixtureType::he,
227  &thermoMixtureType::Cpv,
229  );
230 }
231 
232 
233 template<class ThermoType>
234 Foam::scalar
236 (
237  const scalar he,
238  scalar p,
239  scalar T0
240 ) const
241 {
242  return ThermoType::T
243  (
244  *this,
245  he,
246  p,
247  T0,
251  );
252 }
253 
254 
255 template<class ThermoType>
256 Foam::scalar
258 (
259  scalar p,
260  scalar T
261 ) const
262 {
263  return moleWeighted(&ThermoType::mu, p, T);
264 }
265 
266 
267 template<class ThermoType>
268 Foam::scalar
270 (
271  scalar p,
272  scalar T
273 ) const
274 {
275  return moleWeighted(&ThermoType::kappa, p, T);
276 }
277 
278 
279 template<class ThermoType>
280 const typename
283 (
284  const scalarFieldListSlice& Y
285 ) const
286 {
287  forAll(Y, i)
288  {
289  thermoMixture_.Y_[i] = Y[i];
290  }
291 
292  return thermoMixture_;
293 }
294 
295 
296 template<class ThermoType>
297 const typename
300 (
301  const scalarFieldListSlice& Y
302 ) const
303 {
304  scalar sumX = 0;
305 
306  forAll(Y, i)
307  {
308  transportMixture_.X_[i] = Y[i]/this->specieThermos()[i].W();
309  sumX += transportMixture_.X_[i];
310  }
311 
312  forAll(Y, i)
313  {
314  transportMixture_.X_[i] /= sumX;
315  }
316 
317  return transportMixture_;
318 }
319 
320 
321 template<class ThermoType>
322 const typename
325 (
326  const scalarFieldListSlice& Y,
327  const thermoMixtureType&
328 ) const
329 {
330  return transportMixture(Y);
331 }
332 
333 
334 // ************************************************************************* //
scalar hs(const scalar p, const scalar T) const
Definition: EtoHthermo.H:11
scalar Cp(const scalar p, const scalar T) const
Definition: EtoHthermo.H:2
scalar ha(const scalar p, const scalar T) const
Definition: EtoHthermo.H:20
scalar es(const scalar p, const scalar T) const
Definition: HtoEthermo.H:11
scalar Cv(const scalar p, const scalar T) const
Definition: HtoEthermo.H:2
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:449
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Foam::multicomponentMixture.
const PtrList< ThermoType > & specieThermos() const
Return the raw specie thermodynamic data.
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].
scalar Tes(const scalar he, const scalar p, const scalar T0) const
Temperature from sensible internal energy.
scalar rho(scalar p, scalar T) const
Return density [kg/m^3].
scalar mu(const scalar p, const scalar T) const
Dynamic viscosity [kg/m/s].
scalar kappa(const scalar p, const scalar T) const
Thermal conductivity [W/m/K].
Thermophysical properties mixing class which applies mass-fraction weighted mixing to thermodynamic p...
valueMulticomponentMixture(const dictionary &)
Construct from a dictionary.
const thermoMixtureType & thermoMixture(const scalarFieldListSlice &) const
Return the mixture for thermodynamic properties.
const transportMixtureType & transportMixture(const scalarFieldListSlice &) const
Return the mixture for transport properties.
const scalar T0
const volScalarField & psi
rho
Definition: pEqn.H:1
void limit(const control &controls, const RdeltaTType &rDeltaT, const RhoType &rho, const volScalarField &psi, const surfaceScalarField &phi, surfaceScalarField &psiPhi, const SpType &Sp, const SuType &Su, const PsiMaxType &psiMax, const PsiMinType &psiMin, const bool returnCorr)
const dimensionedScalar kappa
Coulomb constant: default SI units: [N.m2/C2].
const dimensionedScalar mu
Atomic mass unit.
Namespace for OpenFOAM.
tmp< DimensionedField< typename outerProduct< Type, Type >::type, GeoMesh, Field >> sqr(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
void T(GeometricField< Type, GeoMesh, PrimitiveField1 > &gf, const GeometricField< Type, GeoMesh, PrimitiveField2 > &gf1)
dictionary dict
Foam::argList args(argc, argv)
volScalarField & p
PtrList< volScalarField > & Y
const scalarList W(::W(thermo))
#define thermoMixtureFunction(Func)