GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/common/dimensionlessnumbers.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 10 24 41.7%
Functions: 2 2 100.0%
Branches: 5 42 11.9%

Line Branch Exec Source
1 // -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 // vi: set et ts=4 sw=4 sts=4:
3 //
4 // SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5 // SPDX-License-Identifier: GPL-3.0-or-later
6 //
7 /*!
8 * \file
9 * \ingroup Core
10 * \brief Collection of functions, calculating dimensionless numbers.
11 *
12 * All the input to the dimensionless numbers has to be provided as function arguments.
13 * Rendering this collection generic in the sense that it can be used by any model.
14 */
15 #ifndef DUMUX_COMMON_DIMENSIONLESS_NUMBERS_HH
16 #define DUMUX_COMMON_DIMENSIONLESS_NUMBERS_HH
17
18 #include <cmath>
19 #include <iostream>
20
21 #include <dune/common/exceptions.hh>
22 #include <dune/common/math.hh>
23
24 namespace Dumux {
25
26 /*!
27 * \brief A container for possible values of the property for selecting which Nusselt parametrization to choose.
28 * The actual value is set via the property NusseltFormulation
29 */
30 enum class NusseltFormulation
31 {
32 dittusBoelter, WakaoKaguei, VDI
33 };
34
35 /*!
36 * \brief A container for possible values of the property for selecting which Sherwood parametrization to choose.
37 * The actual value is set via the property SherwoodFormulation
38 */
39 enum class SherwoodFormulation
40 {
41 WakaoKaguei
42 };
43
44 /*!
45 * \ingroup Core
46 * \brief Collection of functions which calculate dimensionless numbers.
47 * Each number has it's own function.
48 * All the parameters for the calculation have to be handed over.
49 * Rendering this collection generic in the sense that it can be used by any model.
50 */
51 template <class Scalar>
52 class DimensionlessNumbers
53 {
54
55 public:
56 /*!
57 * \brief Calculate the Reynolds Number [-] (Re).
58 *
59 * The Reynolds number is a measure for the relation of inertial to viscous forces.
60 * The bigger the value, the more important inertial (as compared to viscous) effects become.
61 * According to Bear [Dynamics of fluids in porous media (1972)] Darcy's law is valid for Re<1.
62 *
63 * Source for Reynolds number definition: http://en.wikipedia.org/wiki/Reynolds_number
64 *
65 * \param darcyMagVelocity The absolute value of the darcy velocity. In the context of box models this
66 * leads to a problem: the velocities are defined on the faces while other things (storage, sources, output)
67 * are defined for the volume/vertex. Therefore, some sort of decision needs to be made which velocity to put
68 * into this function (e.g.: face-area weighted average). [m/s]
69 * \param charcteristicLength Typically, in the context of porous media flow, the mean grain size is taken as the characteristic length
70 * for calculation of Re. [m]
71 * \param kinematicViscosity Is defined as the dynamic (or absolute) viscos ity divided by the density.
72 * http://en.wikipedia.org/wiki/Viscosity#Dynamic_viscosity. [m^2/s]
73 *
74 * \return The Reynolds Number as calculated from the input parameters
75 */
76 static Scalar reynoldsNumber(const Scalar darcyMagVelocity,
77 const Scalar charcteristicLength,
78 const Scalar kinematicViscosity)
79 {
80
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 31948673 times.
35701513 return darcyMagVelocity * charcteristicLength / kinematicViscosity ;
81 }
82
83 /*!
84 * \brief Calculate the Prandtl Number [-] (Pr).
85 *
86 * The Prandtl Number is a measure for the relation of viscosity and thermal diffusivity (temperaturleitfaehigkeit).
87 *
88 * It is defined as
89 * \f[
90 * \textnormal{Pr}= \frac{\nu}{\alpha} = \frac{c_p \mu}{\lambda}\, ,
91 * \f]
92 * with kinematic viscosity\f$\nu\f$, thermal diffusivity \f$\alpha\f$, heat capacity \f$c_p\f$,
93 * dynamic viscosity \f$\mu\f$ and thermal conductivity \f$\lambda\f$.
94 * Therefore, Pr is a material specific property (i.e.: not a function of flow directly
95 * but only of temperature, pressure and fluid).
96 *
97 * source for Prandtl number definition: http://en.wikipedia.org/wiki/Prandtl_number
98 *
99 * \param dynamicViscosity Dynamic (absolute) viscosity over density.
100 * http://en.wikipedia.org/wiki/Viscosity#Dynamic_viscosity [m^2/s]
101 * \param heatCapacity Heat capacity at constant pressure.
102 * Specifies the energy change for a given temperature change [J / (kg K)]
103 * \param thermalConductivity Conductivity to heat. Specifies how well matter transfers energy without moving. [W/(m K)]
104 * \return The Prandtl Number as calculated from the input parameters.
105 */
106 static Scalar prandtlNumber(const Scalar dynamicViscosity,
107 const Scalar heatCapacity,
108 const Scalar thermalConductivity)
109 {
110 2964303 return dynamicViscosity * heatCapacity / thermalConductivity;
111 }
112
113 /*!
114 * \brief Calculate the Nusselt Number [-] (Nu).
115 *
116 * The Nusselt Number is a measure for the relation of convective- to conductive heat exchange.
117 *
118 * The Nusselt number is defined as Nu = h d / k,
119 * with h= heat transfer coefficient, d=characteristic length, k=heat conductivity(stagnant).
120 * However, the heat transfer coefficient from one phase to another is typically not known.
121 * Therefore, Nusselt numbers are usually given as *empirical* Nu(Reynolds, Prandtl) for a given flow
122 * field --forced convection-- and *empirical* Nu(Rayleigh, Prandtl) for flow caused by temperature
123 * differences --free convection--. The fluid characteristics enter via the Prandtl number.
124 *
125 * This function implements an *empirical* correlation for the case of porous media flow
126 * (packed bed flow as the chemical engineers call it).
127 *
128 * source for Nusselt number definition: http://en.wikipedia.org/wiki/Nusselt_number
129 * source for further empirical correlations for Nusselt Numbers:
130 * VDI-Gesellschaft, VDI-Waermeatlas, VDI-Verlag Duesseldorf, 2006
131 *
132 * \param reynoldsNumber Dimensionless number relating inertial and viscous forces [-].
133 * \param prandtlNumber Dimensionless number relating viscosity and thermal diffusivity (temperaturleitfaehigkeit) [-].
134 * \param porosity The fraction of the porous medium which is void space.
135 * \param formulation Switch for deciding which parametrization of the Nusselt number is to be used.
136 * Set via the property NusseltFormulation.
137 * \return The Nusselt number as calculated from the input parameters [-].
138 */
139 2964303 static Scalar nusseltNumberForced(const Scalar reynoldsNumber,
140 const Scalar prandtlNumber,
141 const Scalar porosity,
142 NusseltFormulation formulation)
143 {
144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2964303 times.
2964303 if (formulation == NusseltFormulation::dittusBoelter){
145 /* example: very common and simple case: flow straight circular pipe, only convection (no boiling),
146 * 10000<Re<120000, 0.7<Pr<120, far from pipe entrance, smooth surface of pipe ...
147 * Dittus, F.W and Boelter, L.M.K, Heat Transfer in Automobile Radiators of the Tubular Type,
148 * Publications in Engineering, Vol. 2, pages 443-461, 1930
149 */
150 using std::pow;
151 return 0.023 * pow(reynoldsNumber, 0.8) * pow(prandtlNumber,0.33);
152 }
153
154
1/2
✓ Branch 0 taken 2964303 times.
✗ Branch 1 not taken.
2964303 else if (formulation == NusseltFormulation::WakaoKaguei){
155 /* example: flow through porous medium *single phase*, fit to many different data
156 * Wakao and Kaguei, Heat and mass Transfer in Packed Beds, Gordon and Breach Science Publishers, page 293
157 */
158 using std::pow;
159 2964303 return 2. + 1.1 * pow(prandtlNumber,(1./3.)) * pow(reynoldsNumber, 0.6);
160 }
161
162 else if (formulation == NusseltFormulation::VDI){
163 /* example: VDI Waermeatlas 10. Auflage 2006, flow in packed beds, page Gj1, see also other sources and limitations therein.
164 * valid for 0.1<Re<10000, 0.6<Pr/Sc<10000, packed beds of perfect spheres.
165 *
166 */
167 using std::sqrt;
168 using std::pow;
169 using Dune::power;
170 Scalar numerator = 0.037 * pow(reynoldsNumber,0.8) * prandtlNumber ;
171 Scalar reToMin01 = pow(reynoldsNumber,-0.1);
172 Scalar prTo23 = pow(prandtlNumber, (2./3. ) ) ; // MIND THE pts! :-( otherwise the integer exponent version is chosen
173 Scalar denominator = 1+ 2.443 * reToMin01 * (prTo23 -1.) ;
174
175 Scalar nusseltTurbular = numerator / denominator;
176 Scalar nusseltLaminar = 0.664 * sqrt(reynoldsNumber) * pow(prandtlNumber, (1./3.) );
177 Scalar nusseltSingleSphere = 2 + sqrt( power(nusseltLaminar,2) + power(nusseltTurbular,2));
178
179 Scalar funckyFactor = 1 + 1.5 * (1.-porosity); // for spheres of same size
180 Scalar nusseltNumber = funckyFactor * nusseltSingleSphere ;
181
182 return nusseltNumber;
183 }
184
185 else {
186 DUNE_THROW(Dune::NotImplemented, "wrong index");
187 }
188 }
189
190
191 /*!
192 * \brief Calculate the Schmidt Number [-] (Sc).
193 *
194 * The Schmidt Number is a measure for the relation of viscosity and mass diffusivity.
195 *
196 * It is defined as
197 * \f[
198 * \textnormal{Sc}= \frac{\nu}{D} = \frac{\mu}{\rho D}\, ,
199 * \f]
200 * with kinematic viscosity\f$\nu\f$, diffusion coefficient \f$D\f$, dynamic viscosity
201 * \f$\mu\f$ and mass density\f$\rho\f$. Therefore, Sc is a material specific property
202 * (i.e.: not a function of flow directly but only of temperature, pressure and fluid).
203 *
204 * source for Schmidt number definition: http://en.wikipedia.org/wiki/Schmidt_number
205 *
206 * \param dynamicViscosity Dynamic (absolute) viscosity over density.
207 * http://en.wikipedia.org/wiki/Viscosity#Dynamic_viscosity [m^2/s]
208 * \param massDensity Mass density of the considered phase. [kg / m^3]
209 * \param diffusionCoefficient Measure for how well a component can move through a phase due to a concentration gradient. [m^2/s]
210 * \return The Schmidt Number as calculated from the input parameters.
211 */
212 static Scalar schmidtNumber(const Scalar dynamicViscosity,
213 const Scalar massDensity,
214 const Scalar diffusionCoefficient)
215 {
216 2361016 return dynamicViscosity / (massDensity * diffusionCoefficient);
217 }
218
219 /*!
220 * \brief Calculate the Sherwood Number [-] (Sh).
221 *
222 * The Sherwood Number is a measure for the relation of convective- to diffusive mass exchange.
223 *
224 * The Sherwood number is defined as Sh = K L/D,
225 * with K= mass transfer coefficient, L=characteristic length, D=mass diffusivity (stagnant).
226 *
227 * However, the mass transfer coefficient from one phase to another is typically not known.
228 * Therefore, Sherwood numbers are usually given as *empirical* Sh(Reynolds, Schmidt) for a given flow
229 * field (and fluid).
230 *
231 * Often, even the Sherwood number is not known. By means of the Chilton-Colburn analogy it can be deduced
232 * from the Nusselt number. According to the Chilton-Colburn analogy in a known Nusselt correltion one
233 * basically replaces Pr with Sc and Nu with Sh. For some very special cases this is actually accurate.
234 * (Source: Course Notes, Waerme- und Stoffuebertragung, Prof. Hans Hasse, Uni Stuttgart)
235 *
236 * This function implements an *empirical* correlation for the case of porous media flow
237 * (packed bed flow as the chemical engineers call it).
238 *
239 * source for Sherwood number definition: http://en.wikipedia.org/wiki/Sherwood_number
240 *
241 * \param schmidtNumber Dimensionless number relating viscosity and mass diffusivity [-].
242 * \param reynoldsNumber Dimensionless number relating inertial and viscous forces [-].
243 * \param formulation Switch for deciding which parametrization of the Sherwood number is to be used.
244 * Set via the property SherwoodFormulation.
245 * \return The Nusselt number as calculated from the input parameters [-].
246 */
247
248 2361016 static Scalar sherwoodNumber(const Scalar reynoldsNumber,
249 const Scalar schmidtNumber,
250 SherwoodFormulation formulation)
251 {
252
1/2
✓ Branch 0 taken 2361016 times.
✗ Branch 1 not taken.
2361016 if (formulation == SherwoodFormulation::WakaoKaguei){
253 /* example: flow through porous medium *single phase*
254 * Wakao and Kaguei, Heat and mass Transfer in Packed Beds, Gordon and Breach Science Publishers, page 156
255 */
256 using std::cbrt;
257 using std::pow;
258 2361016 return 2. + 1.1 * cbrt(schmidtNumber) * pow(reynoldsNumber, 0.6);
259 }
260
261 else {
262 DUNE_THROW(Dune::NotImplemented, "wrong index");
263 }
264 }
265
266
267 /*!
268 * \brief Calculate the thermal diffusivity alpha [m^2/s].
269 *
270 * The thermal diffusivity is a measure for how fast "temperature (not heat!) spreads".
271 * It is defined as \f$\alpha = \frac{k}{\rho c_p}\f$
272 * with \f$\alpha\f$: \f$k\f$: thermal conductivity [W/mK], \f$\rho\f$: density [kg/m^3],
273 * \f$c_p\f$: cpecific heat capacity at constant pressure [J/kgK].
274 *
275 * Source for thermal diffusivity definition: http://en.wikipedia.org/wiki/Thermal_diffusivity
276 *
277 * \param thermalConductivity A material property defining how well heat is transported via conduction [W/(mK)].
278 * \param phaseDensity The density of the phase for which the thermal diffusivity is to be calculated [kg/m^3].
279 * \param heatCapacity A measure for how a much a material changes temperature for a given change of energy (at p=const.) [J/(kgm^3)].
280 * \return The thermal diffusivity as calculated from the input parameters [m^2/s].
281 */
282 static Scalar thermalDiffusivity(const Scalar & thermalConductivity ,
283 const Scalar & phaseDensity ,
284 const Scalar & heatCapacity)
285 {
286 return thermalConductivity / (phaseDensity * heatCapacity);
287 }
288
289 };
290
291 } // end namespace Dumux
292
293 #endif
294