summaryrefslogtreecommitdiff
path: root/sample_notebooks/Suhaib Alam/Ch14.ipynb
blob: f4ee9c8bc2fdc2d55d154a4e72b3b8c8ad317c54 (plain)
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
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter14 - Turbulent Flow in Pipe"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 14.1 page no 148"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 14.1 page no 148\n",
      "\n",
      "\n",
      "\n",
      " Reynolds no R_e = 9769.23 \n"
     ]
    }
   ],
   "source": [
    "print \"Example 14.1 page no 148\\n\\n\" # a liquid flow through a tube\n",
    "meu=0.78e-2#viscosity of liquid,g/cm*s\n",
    "rho=1.50#density,g/cm**3\n",
    "D=2.54#diameter,cm\n",
    "v=20#flow velocity\n",
    "R_e=D*v*rho/meu#reynolds no\n",
    "print \"\\n Reynolds no R_e = %.2f \"%(R_e)#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 14.2 page no 148"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 14.2 page no 148\n",
      "\n",
      "\n",
      "\n",
      " velocity v = 0.28 ft/s\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "print \"Example 14.2 page no 148\\n\\n\" # a fluid is moving through a cylinder in laminar flow\n",
    "meu=6.9216e-4#viscosity of fluid,lb/ft*s\n",
    "rho=62.4#density,lb/ft**3\n",
    "D=1/12#diameter,ft\n",
    "R_e=2100#reynolds no\n",
    "v=R_e*meu/(D*rho)#minimum velocity at which turbulance will appear\n",
    "print \"\\n velocity v = %.2f ft/s\"%(v)#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 14.3 page no 152"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 14.3 page no 152\n",
      "\n",
      "\n",
      "\n",
      " fanning friction factor f_a=0.01 \n",
      "\n",
      " friction factor f_b1=0.01 \n",
      "\n",
      " friction factor f_b2=0.01 \n",
      "\n",
      " friction factor f_c=0.01 \n",
      "\n",
      " friction factor f_d=0.01 \n",
      "\n",
      " friction factor f_e=0.01\n",
      "\n",
      " average friction f_av=0.01 \n"
     ]
    }
   ],
   "source": [
    "from math import log10\n",
    "print \"Example 14.3 page no 152\\n\\n\" # calculate the friction factor by using different equation's\n",
    "R_e=14080#reynolds no\n",
    "K_r=0.004#relative roughness (a) by PAT proposed equation\n",
    "f_a=0.0015+(8*(R_e)**0.30)**-1\n",
    "print \"\\n fanning friction factor f_a=%0.2f \"%(f_a)# equation for 5000<R_e>50000\n",
    "f_b1=0.0786/(R_e)**0.25 \n",
    "print \"\\n friction factor f_b1=%0.2f \"%(f_b1)#  equation for 30000<R_e>1000000\n",
    "f_b2=0.046/(R_e)**0.20\n",
    "print \"\\n friction factor f_b2=%0.2f \"%(f_b2)#  equation for the completely turbulent region \n",
    "f_c=1/(4*(1.14-2*log10(K_r))**2)\n",
    "print \"\\n friction factor f_c=%0.2f \"%(f_c)#  equation given by jain \n",
    "f_d=1/(2.28-4*log10(K_r+21.25/(R_e**.9)))**2\n",
    "print \"\\n friction factor f_d=%0.2f \"%(f_d)#\n",
    "f_e=0.0085 #from figur 14.2\n",
    "print \"\\n friction factor f_e=%0.2f\"%(f_e)#\n",
    "f_av=(f_a+f_b1+f_b2+f_c+f_d+f_e)/6\n",
    "print \"\\n average friction f_av=%0.2f \"%(f_av)#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 14.4 page no 154"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 14.4 page no 154\n",
      "\n",
      "\n",
      "\n",
      " equivalent diameter D_eq_a=3.33 in\n",
      "\n",
      " equivalent diameter D_eq_b=18.00 cm\n",
      "\n",
      " equivalent diameter D_eq_c=10.00 cm\n"
     ]
    }
   ],
   "source": [
    "from math import pi\n",
    "print \"Example 14.4 page no 154\\n\\n\" # for turbulent fluid flow in across section  (a) for a rectangle \n",
    "w=2#width of a rectangle,in\n",
    "h=10#height of rectangle,in\n",
    "S_a=h*w#cross sectional area\n",
    "P_a=2*h+2*w#perimeter of rectangle\n",
    "D_eq_a=4*S_a/P_a#equivalent diameter\n",
    "print \"\\n equivalent diameter D_eq_a=%0.2f in\"%(D_eq_a)# (b) for an annulus \n",
    "d_o=10#outer diameter of annulus\n",
    "d_i=8#inner diameter \n",
    "S_b=pi*(d_o**2-d_i**2)/4#cross sectional area\n",
    "P_b=pi*(d_o-d_i)#perimeter\n",
    "D_eq_b=(4*S_b)/(P_b)#eq. diameter\n",
    "print \"\\n equivalent diameter D_eq_b=%0.2f cm\"%(D_eq_b)# (c) for an half- full circle\n",
    "d_c=10#diameter of circle \n",
    "S_c=pi*d_c**2/8# cross sectional area\n",
    "P_c=pi*d_c/2#perimeter\n",
    "D_eq_c=4*S_c/P_c#eq. diameter\n",
    "print \"\\n equivalent diameter D_eq_c=%0.2f cm\"%(D_eq_c)# "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exampkle 14.5 page no 157"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 14.5 page no 157\n",
      "\n",
      "\n",
      "\n",
      " pipe diameter D=0.29 ft\n",
      "\n",
      "D=0.69 \n",
      "\n",
      " flow velocity v=22.28 ft/s\n"
     ]
    }
   ],
   "source": [
    "print \"Example 14.5 page no 157\\n\\n\" # air is transported through a circular conduit \n",
    "MW=28.9#molecular weight of air \n",
    "R=10.73#gas constant\n",
    "T=500#temperature\n",
    "P=14.75#pressure,psia applying ideal gas law for density\n",
    "rho=P*MW/(R*T)#density \n",
    "rho=0.08#after round off\n",
    "meu=3.54e-7#viscosity of air at 40 degF assume flow is laminar\n",
    "q=8.33#flow rate ,ft**3/s\n",
    "L=800#length of pipe,ft\n",
    "P_1=.1#pressure at starting point\n",
    "P_2=.01#pressure at delivery point \n",
    "D=((128*meu*L*q)/(pi*(P_1-P_2)*144))**(1/4)#diameter\n",
    "print \"\\n pipe diameter D=%0.2f ft\"%(D)# check the flow type\n",
    "meu=1.14e-5\n",
    "R_e1=4*q*rho/(pi*D*meu)#reynolds no print \"\\n reynolds no R_e=%0.2f \"%(R_e)# from R_e we can conclude that laminar flow is not valid\n",
    "P_drop=12.96#pressure drop P_1-P2 in psf\n",
    "f=0.005#fanning friction factor\n",
    "g_c=32.174\n",
    "D=(32*rho*f*L*q**2/(g_c*pi**2*P_drop))**(0.2)#diamter from new assumption strat the second iteration with the newly calculated D\n",
    "k=0.00006/12#roughness factor\n",
    "K_r=k/D#relative roughness \n",
    "C_f=1.321224\n",
    "R_e_n=4*q*rho/(pi*D*meu)#new reynolds no print \"\\n new reynolds no R_e=%0.2f \"%(R_e)#\n",
    "f_n=0.0045#new fanning friction factor\n",
    "D=(((8*rho*f_n*L*q**2)/(g_c*pi**2*P_drop))**(0.2))*C_f#final calculated diameter because last diameter is same with this\n",
    "print \"\\nD=%0.2f \"%(D)# iteration may now be terminated\n",
    "S=pi*(D**2)/4#cross sectional area of pipe\n",
    "v=q/S#flow velocity\n",
    "print \"\\n flow velocity v=%0.2f ft/s\"%(v)##printing mistake in book in the value of meu in the formula of D is first time that's why this deviation in answer"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 14.6 page no 159"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 14.6 page no. 159\n",
      "\n",
      "\n",
      "\n",
      " R_e=106208.60 \n",
      "\n",
      " since R_e is more than 4000 flow is turbulent\n"
     ]
    }
   ],
   "source": [
    "print \"Example 14.6 page no. 159\\n\\n\" # ethyl alcohol is pumped through a horizontal tube\n",
    "rho=789#density .kg/m**3\n",
    "meu=1.1e-3#viscosity ,kg/m-s\n",
    "k=1.5e-6#roughness,m\n",
    "L=60#length of tube,m\n",
    "q=2.778e-3#flow rate \n",
    "g=9.807\n",
    "h_f=30#friction loss\n",
    "A=(L*q**2)/(g*h_f)\n",
    "A=1.574e-7\n",
    "D=0.66*(((k**1.25)*(A**4.75)+meu*(A**5.2)/(q*rho))**.04)\n",
    "D=0.0377 # calculate velocity of alcohol in the tube\n",
    "S=3.14*(D)**2/4#surface area\n",
    "v=q/S#velocity\n",
    "v=3.93#velocity\n",
    "neu=1.395e-6#dynamic viscosity\n",
    "R_e=D*v/neu#reynolds no \n",
    "print \"\\n R_e=%0.2f \"%(R_e)##printing mistake in book\n",
    "print \"\\n since R_e is more than 4000 flow is turbulent\" #"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exanmple 14.7 page no 160"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 14.7 page no 160\n",
      "\n",
      "\n",
      "\n",
      " average velocity v=2.37 m/s\n",
      "\n",
      " S=0.00 \n",
      "\n",
      " flow rate q=1244.02 m**3/s\n",
      "\n",
      " mass flow rate m_dot=1020094.94 kg/s\n",
      "\n",
      " v_max=2.91 m/s\n",
      "\n",
      " length L_c=1.36 m\n"
     ]
    }
   ],
   "source": [
    "print \"Example 14.7 page no 160\\n\\n\" # kerosene flow ina lng ,smooth ,horizontal pipe\n",
    "rho=820#density,kg/m**3\n",
    "D=0.0493#iside diameter of pipe by appendix A.5,m\n",
    "R_e=60000\n",
    "meu=0.0016#viscosity,kg/m.s\n",
    "v=(R_e*meu)/(D*rho)# flow average velocity\n",
    "print \"\\n average velocity v=%0.2f m/s\"%(v)#\n",
    "S=(pi/4)*D**2#cross sectional area\n",
    "print \"\\n S=%0.2f \"%(S)#\n",
    "q=v/S#flow rate \n",
    "print \"\\n flow rate q=%0.2f m**3/s\"%(q)##printing mistake in book\n",
    "m_dot=rho*q#mass flow rate\n",
    "print \"\\n mass flow rate m_dot=%0.2f kg/s\"%(m_dot)##printing mistake in book in the value of v\n",
    "n=7#seventh power apply\n",
    "v_max=v/(2*n**2/((n+1)*(2*n+1)))#maximum velocity\n",
    "print \"\\n v_max=%0.2f m/s\"%(v_max)# check the assumptioon of fully developed flow\n",
    "R_e=60000#reynolds no\n",
    "L_c=4.4*R_e**(1/6)*D#critical length\n",
    "print \"\\n length L_c=%0.2f m\"%(L_c)# since L_c <L th eassumption is valid"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 14.8 page no 161"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " Example 14.8 page no 161\n",
      "\n",
      "\n",
      "\n",
      " fanning friction factor f=0.01 \n",
      "\n",
      " h_f friction loss=1.07 m \n",
      "\n",
      " P_drop_a =0.09 atm\n"
     ]
    }
   ],
   "source": [
    "print \"\\n Example 14.8 page no 161\\n\\n\" # refer to example no 14.7\n",
    "rho=860#density\n",
    "R_e=60000#reynolds no\n",
    "f=.046/R_e**.2#fanning friction factor\n",
    "print \"\\n fanning friction factor f=%0.2f \"%(f)#\n",
    "L=9#length of tube\n",
    "v=2.38#velocity\n",
    "D=.0493#diameter of tube\n",
    "g=9.807\n",
    "h_f=4*f*(L*v**2)/(D*2*g)#friction loss \n",
    "print \"\\n h_f friction loss=%0.2f m \"%(h_f)# applying  bernoulli equation\n",
    "P_drop=rho*g*h_f#pressure drop in pa\n",
    "P_drop_a=P_drop/10**5#pressure drop in atm\n",
    "print \"\\n P_drop_a =%0.2f atm\"%(P_drop_a)#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 14.9 page no 161"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Example 14.9 page no 161\n",
      "\n",
      "\n",
      "\n",
      " Force required to hold pipe F=16.58 N\n"
     ]
    }
   ],
   "source": [
    "print \" Example 14.9 page no 161\\n\\n\" # refer to example 14.7\n",
    "D=0.0493#diameter of tuube\n",
    "S=pi*D**2/4#cross sectional area\\\n",
    "P=8685#pressure\n",
    "F=P*S#force required to hold the pipe,direction is opposite the flow\n",
    "print \"\\n Force required to hold pipe F=%0.2f N\"%(F)# "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 14.10 page no 163"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 14.10 page no 163\n",
      "\n",
      "\n",
      "\n",
      " vz_bar=40.00\n",
      "\n",
      " vz_sqr=4.60\n",
      "\n",
      " intensity of turbulance I=0.05 \n"
     ]
    }
   ],
   "source": [
    "from math import sqrt\n",
    "print \"Example 14.10 page no 163\\n\\n\" # a fluid is moving in the turbulent flw through a pipe   a hot wire anemometer is inserted to measure the local velocity at a given point P in the system  following readings were recorded at equal time interval instantaneous velocities at subsequent time interval\n",
    "vz=[43.4,42.1,42,40.8,38.5,37,37.5,38,39,41.7]\n",
    "vz_bar=0#\n",
    "n=10#\n",
    "i = 0#\n",
    "sums=0#\n",
    "for i in range(0,10):\n",
    "    sums=sums+vz[i]#\n",
    "\n",
    "vz_bar=sums/n#\n",
    "print \"\\n vz_bar=%0.2f\"%(vz_bar)#\n",
    "sigma=0#\n",
    "for i in range(0,10):\n",
    "    sigma=sigma+(vz[i]-vz_bar)**2#\n",
    "    vz_sqr=sigma/10#\n",
    "\n",
    "print \"\\n vz_sqr=%0.2f\"%(vz_sqr)\n",
    "I = sqrt(vz_sqr)/vz_bar#intensity of turbulance\n",
    "print \"\\n intensity of turbulance I=%0.2f \"%(I)#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 14.11 page no 164"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 14.11 page no 164\n",
      "\n",
      "\n",
      "\n",
      " flow rate q_a=0.33 ft**3/min\n",
      " \n",
      " flow rate q_b=0.65 ft**3/min\n",
      "\n",
      " flow rate q_c=0.53 ft**3/min\n"
     ]
    }
   ],
   "source": [
    "print \"Example 14.11 page no 164\\n\\n\" # a fluid is flowing through a pipe\n",
    "D=2#inside diameter of pipe,in\n",
    "v_max=30#maximum velocity,ft/min\n",
    "A=(pi/4)*(D/12)**2#cross sectional area (a) for laminar flow \n",
    "v_a=(1/2)*v_max#average velocity\n",
    "q_a=v_a*A#volumatric flow rate\n",
    "print \"\\n flow rate q_a=%0.2f ft**3/min\"%(q_a)# (b) for plug flow \n",
    "v_b=v_max#average velocity \n",
    "q_b=v_b*A#volumatric flow rate\n",
    "print \" \\n flow rate q_b=%0.2f ft**3/min\"%(q_b)# (c)for turbulent flow\n",
    "v_c=(49/60)*v_max#average velocity\n",
    "q_c=v_c*A#volumatric flow rate\n",
    "print \"\\n flow rate q_c=%0.2f ft**3/min\"%(q_c)#"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}