-
Notifications
You must be signed in to change notification settings - Fork 6
/
nd_numbers.py
436 lines (364 loc) · 12.3 KB
/
nd_numbers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
import numpy as np
def Prandtl(*args, **kwargs):
"""Compute the Prandtl number.
There are 5 modes of operation:
1. ``Prandtl(mu, cp, k)``
2. ``Prandtl(gas)`` where ``gas`` is a Cantera's ``Solution`` object.
3. ``Prandtl(gamma)`` which is a good approximation for both monoatomic and
polyatomic gases. It is derived from Eucken's formula for thermal
conductivity.
4. ``Prandtl(Pe=Pe, Re=Re)`` by providing Peclét and Reynolds numbers.
5. ``Prandtl(Le=Le, Sc=Sc)`` by providing Lewis and Schmidt numbers.
Parameters
----------
mu : float or array_like
Viscosity of the gas.
cp : float or array_like
Specific heat at constant pressure.
k : float or array_like
Thermal conductivity of the gas.
Pe : float or array_like
Peclét number.
Re : float or array_like
Reynolds number.
Le : float or array_like
Lewis number.
Sc : float or array_like
Schmidt number.
gamma : float
Specific heats ratio. Default to None. Must be gamma > 1.
gas : ct.Solution
A Cantera's ``Solution`` object.
Returns
-------
Pr : float or array_like
Prandtl number.
Notes
-----
* Pr -> 0: the thermal boundary layer is much thicker than the flow
boundary layer, which is typical for the flow of liquid metals.
* Pr -> oo: the flow boundary layer is much thicker than the thermal
boundary layer, which is typical for liquids.
* Pr = O(1): the thermal boundary layer has a thickness of the order of
that of the flow boundary layer. This is typical for gases.
Examples
--------
Compute the Prandtl number of air with specific heat ratio of 1.4:
>>> from pygasflow.atd.nd_numbers import Prandtl
>>> Prandtl(1.4)
0.7368421052631579
Compute the Prandtl number of air at T=350K using a Cantera's ``Solution``
object:
>>> import cantera as ct
>>> air = ct.Solution("gri30.yaml")
>>> air.TPX = 350, ct.one_atm, {"N2": 0.79, "O2": 0.21}
>>> Prandtl(air)
0.7139365242266411
Compute the Prandtl number by providing mu, cp, k:
>>> from pygasflow.atd.viscosity import viscosity_air_southerland
>>> from pygasflow.atd.thermal_conductivity import thermal_conductivity_hansen
>>> cp = 1004
>>> mu = viscosity_air_southerland(350)
>>> k = thermal_conductivity_hansen(350)
>>> Prandtl(mu, cp, k)
0.7370392202421769
See Also
--------
Peclet, Lewis, Reynolds, Schmidt
"""
if len(args) == 1:
if isinstance(args[0], (int, float, np.ndarray)):
# eq (4.19)
gamma = args[0]
return 4 * gamma / (9 * gamma - 5)
else:
import cantera as ct
if isinstance(args[0], ct.Solution):
gas = args[0]
return gas.viscosity * gas.cp_mass / gas.thermal_conductivity
raise ValueError(
"When 1 argument is provided, it must be an instance of int, or "
"float, or np.ndarray or ct.Solution"
)
elif len(args) == 3:
# eq (4.19)
mu, cp, k = args
return mu * cp / k
Pe = kwargs.get("Pe", None)
Re = kwargs.get("Re", None)
if (Pe is not None) and (Re is not None):
# eq (4.67)
return Pe / Re
Le = kwargs.get("Le", None)
Sc = kwargs.get("Sc", None)
if (Le is not None) and (Sc is not None):
# eq (4.93)
return Le * Sc
raise ValueError("Combination of parameters not recognized. "
"Please, read the documentation.")
def Knudsen(*args):
"""Compute the Knudsen number.
There are 2 modes of operation:
* ``Knudsen(lambda, L)``
* ``Knudsen(Minf, Reinf_L, gamma)``
Parameters
----------
lambda : float or array_like
Mean free path in the gas.
L : float or array_like
Characteristic length, which must be chosen according to the flow
under consideration.For example, for boundary-layer flow it would be
based on the boundary-layer thickness.
Minf : float or array_like
Free stream Mach number.
Reinf_L : float or array_like
Free stream Reynolds number computed at a characteristic length.
gamma : float
Specific heats ratio. Default to 1.4. Must be gamma > 1.
Returns
-------
Kn : float or array_like
Notes
-----
Knudsen number is employed to distinguish approximately between flow
regimes:
* Kn <= 0.01: continuum flow
* 0.01 <= Kn <= 0.1: continuum flow with slip effects (slip flow and
temperature jumps at a body surface).
* 0.1 <= Kn <= 10: disturbed free molecular flow (gas particles collide
with the body surface and with each other).
* Kn >= 10: free molecular flow (gas particles collide only with the body
surface).
See Also
--------
Reynolds
"""
if len(args) == 2:
# eq (2.13)
_lambda, _L = args
return _lambda / _L
elif len(args) == 3:
# eq (2.16)
Minf, Reinf_L, gamma = args
return np.sqrt(gamma / (2 * np.pi)) * 16 / 5 * Minf / Reinf_L
raise ValueError("Combination of parameters not recognized. "
"Please, read the documentation.")
def Stanton(*args):
"""Compute the Stanton number, which represents a dimensionless form of
the heat flux q_gw.
There are 3 modes of operation:
* Stanton(q_gw, q_inf)
* Stanton(q_gw, rho_inf, v_inf)
* Stanton(q_gw, rho_inf, v_inf, delta_h)
Parameters
----------
q_gw : float or array_like
Heat flux in the gas at the wall. It is the heat transported towards
the surface of the vehicle by diffusion mechanisms.
q_inf : float or array_like
Heat transported towards a flight vehicle:
q_inf = rho_inf * v_inf * h_t
rho_inf : float or array_like
Free stream density.
v_inf : float or array_like
Free stream velocity.
delta_h : float or array_like
Difference between the enthalpy related to the recovery temperature and
the enthalpy related to the wall temperature, hr - hw.
Returns
-------
Sn : float or array_like
"""
if len(args) == 2:
# eq (3.3)
q_gw, q_inf = args
return q_gw / q_inf
elif len(args) == 3:
# eq (3.4)
q_gw, rho_inf, v_inf = args
return 2 * q_gw / (rho_inf * v_inf**3)
elif len(args) == 4:
# eq (3.5)
q_gw, rho_inf, v_inf, delta_h = args
return q_gw / (rho_inf * v_inf * delta_h)
raise ValueError("Combination of parameters not recognized. "
"Please, read the documentation.")
def Strouhal(*args):
"""Compute the Strouhal number.
There are 2 modes of operation:
* ``Strouhal(t_res, t_ref)``
* ``Strouhal(L_ref, t_ref, v_ref)``
Parameters
----------
L_ref : float or array_like
Reference length (for example, the body vehicle length).
t_ref : float or array_like
Reference time.
v_ref : float or array_like
Reference velocity (for example, free stream velocity).
t_res : float or array_like
Residence time, defined as t_res = L_ref / v_ref.
Returns
-------
Sr : float or array_like
Notes
-----
In our applications we speak about steady, quasi-steady, and unsteady
flow problems. The measure for the distinction of these three flow modes is
the Strouhal number, Sr:
* Sr = 0: steady flow.
* Sr -> 0: quasi-steady flow. The residence time is small compared to the
reference time, in which a change of flow parameters happens.
For practical purposes, quasi-steady flow is permitted for Sr <= 0.2.
* Sr = O(1): unsteady flow.
Note: the movement of a flight vehicle may be permitted to be considered
as at least quasi-steady, while at the same time truly unsteady movements
of a control surface may occur. In addition there might be configuration
details, where highly unsteady vortex shedding is present.
"""
if len(args) == 2:
# eq (4.8)
t_res, t_ref = args
return t_res / t_ref
elif len(args) == 3:
# eq (4.6)
L_ref, t_ref, v_ref = args
return L_ref / (t_ref * v_ref)
raise ValueError("Combination of parameters not recognized. "
"Please, read the documentation.")
def Reynolds(rho, u, mu, L=1):
"""Compute the Reynolds number, which is the ratio between the inertial
forces to the viscous forces.
Parameters
----------
rho : float or array_like
Density.
u : float or array_like
Velocity.
mu : float or array_like
Viscosity.
L : float or array_like, optional
Characteristic length. Default to ``L=1``, which computes the unitary
Reynolds number.
Returns
-------
Re : float or array_like
Notes
-----
Reynolds number is the principle similarity parameter governing viscous
phenomena:
* Re -> 0: the molecular transport of momentum is much larger than the
convective transport, the flow is the "creeping" or Stokes flow.
The convective transport can be neglected.
* Re -> oo: the convective transport of momentum is much larger than the
molecular transport, the flow can be considered as inviscid, i. e.
molecular transport can be neglected.
* Re = O(1): the molecular transport of momentum has the same order
of magnitude as the convective transport, the flow is viscous, i. e.
it is boundary-layer, or in general, shear-layer flow.
"""
# eq (4.40)
return rho * u * L / mu
def Peclet(rho, mu, cp, L, k):
"""Compute the Peclét number.
Parameters
----------
rho : float or array_like
Density.
mu : float or array_like
Viscosity.
cp : float or array_like
Specific heat at constant pressure.
L : float or array_like
Characteristic length.
k : float or array_like
Thermal conductivity.
Returns
-------
Pe : float or array_like
Notes
-----
Peclét number relates the molecular transport of heat to the convective
transport. In particular:
* Pe -> 0: the molecular transport of heat is much larger than the
convective transport.
* Pe -> oo: the convective transport of heat is much larger than the
molecular transport.
* Pe = O(1): the molecular transport of heat has the same order of
magnitude as the convective transport.
"""
# eq (4.66)
return rho * mu * cp * L / k
def Lewis(rho, D, cp, k):
"""Compute the Lewis number, which is interpreted as the ratio of 'heat
transport by mass diffusion' to 'heat transport by conduction' in a flow
with chemical non-equilibrium.
Parameters
----------
rho : float or array_like
Density.
D : float or array_like
Mass diffusivity.
cp : float or array_like
Specific heat at constant pressure.
k : float or array_like
Thermal conductivity
Returns
-------
Lw : float or array_like
"""
# eq (4.71)
return rho * D * cp / k
def Eckert(M, gamma=1.4):
"""Compute the Eckert number, which can be interpreted as ratio of
kinetic energy to thermal energy of the flow.
Parameters
----------
M : float or array_like
Mach number.
gamma : float
Specific heats ratio. Default to None. Must be gamma > 1.
Returns
-------
E : float or array_like
"""
# eq (4.73)
return (gamma - 1) * M**2
def Schmidt(*args):
"""Compute the Schmidt number.
There are 2 modes of operation:
* ``Schmidt(Pr, Le)``
* ``Schmidt(rho, mu, D)``
Parameters
----------
Pr : float or array_like
Prandtl number.
Le : float or array_like
Lewis number.
rho : float or array_like
Density.
mu : float or array_like
Viscosity.
D : float or array_like
Mass diffusivity.
Returns
-------
Sc : float or array_like
Notes
-----
* Sc -> 0: the molecular transport of mass is much larger than the
convective transport.
* Sc -> oo: the convective transport of mass is much larger than the
molecular transport.
* Sc = O(1): the molecular transport of mass has the same order of
magnitude as the convective transport.
See Also
--------
Lewis, Prandtl
"""
# eq (4.92)
rho, mu, D = args
return mu / (rho * D)
# eq (4.93)
Pr, Le = args
return Pr / Le