summaryrefslogtreecommitdiff
path: root/Fluid_Mechanics_by_John_F._Douglas/Chapter_2.ipynb
blob: 835909e10da7941106ee7f6cd8bf960cbfb37860 (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
{
 "metadata": {
  "name": "",
  "signature": "sha256:56204579c9dff23fd133fce17f3b8e6b8ac01dae9f7f133693b953a21d5ed34c"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 2: Pressure and Head"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.1, Page 30"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "import math\n",
      "\n",
      " #Initializing  the  variables\n",
      "z1  =  0;                                                         #Taking  Ground  as  reference\n",
      "z2  =  -30                                                        #Depth\n",
      "rho  =  1025                                                      #Density\n",
      "g  =  9.81                                                        #Acceleration  due  to  gravity\n",
      "\n",
      " #Calculation\n",
      "pressureIncrease  =  -rho*g*(z2-z1);\n",
      "\n",
      "print \"Increase in Pressure (KN/m2):\",round(pressureIncrease/1000,1)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Increase in Pressure (KN/m2): 301.7\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.2, Page 34"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "import math\n",
      "\n",
      "\n",
      "\n",
      " #Initializing  the  variables\n",
      "p1  =  22.4*10**3                                                    #Initial  Pressure\n",
      "z1  =  11000                                                            #Initial  Height\n",
      "z2  =  15000                                                            #final  Height\n",
      "g  =  9.81                                                                #Acceleration  due  to  gravity\n",
      "R  =  287;                                                                #Gas  Constant\n",
      "T  =  273-56.6                                                        #Temperature  \n",
      "\n",
      " #Calculations\n",
      "p2  =  p1*math.exp(-g*(z2-z1)/(R*T));\n",
      "rho2=p2/(R*T);\n",
      "  \n",
      "print \"Final Pressure (kN/m2):\",round(p2/1000,2)\n",
      "print \"Final Density  (kg/m3):\",round(rho2,3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Final Pressure (kN/m2): 11.91\n",
        "Final Density  (kg/m3): 0.192\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.3, Page 37"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "import math\n",
      "\n",
      "\n",
      " #Initializing  the  variables\n",
      "p1  =  101*10**3                                                      #Initial  Pressure\n",
      "z1  =  0                                                              #Initial  Height\n",
      "z2  =  1200                                                           #Final  Height\n",
      "T1  =  15+273                                                         #Initial  Temperature\n",
      "g  =  9.81                                                            #Acceleration  due  to  gravity\n",
      "gamma  =  1.4                                                         #Heat  capacity  ratio\n",
      "R  =  287                                                                  #Gas  Constant\n",
      "\n",
      " #Calculations\n",
      "p2  =  p1*(1-g*(z2-z1)*(gamma-1)/(gamma*R*T1))**(gamma/(gamma-1));\n",
      "dT_dZ  =  -(g/R)*((gamma-1)/gamma);\n",
      "T2  =  T1  +  dT_dZ*(z2-z1);\n",
      "rho2 = p2/(R*T2);\n",
      "\n",
      "print \"Final Pressure (kN/m2)            :\",round(p2/1000,2)\n",
      "print \"Temprature     (in degree celcius):\",round(T2-273,1)\n",
      "print \"Density        (kg/m^3)           :\",round(rho2,3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Final Pressure (kN/m2)            : 87.33\n",
        "Temprature     (in degree celcius): 3.3\n",
        "Density        (kg/m^3)           : 1.101\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.4, Page 39"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "import math\n",
      "\n",
      "\n",
      "\n",
      " #Initializing  the  variables\n",
      "p1  =  101*10**3                                                      #Initial  Pressure\n",
      "z1  =  0                                                                    #Initial  Height\n",
      "z2  =  7000                                                              #Final  Height\n",
      "T1  =  15+273                                                          #Initial  Temperature\n",
      "g  =  9.81                                                                #Acceleration  due  to  gravity\n",
      "R  =  287                                                                  #Gas  Constant\n",
      "dT  =  6.5/1000                                                      #Rate  of  Variation  of  Temperature\n",
      "\n",
      " #Calculations\n",
      "p2  =  p1*(1-dT*(z2-z1)/T1)**(g/(R*dT));\n",
      "T2  =  T1  -  dT*(z2-z1);\n",
      "rho2  =  p2/(R*T2);\n",
      "\n",
      "\n",
      "print \"Final Pressure (kN/m^2) :\",round(p2/1000,2)\n",
      "print \"Final Density  (kg/m^3 ):\",round(rho2,3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Final Pressure (kN/m^2) : 40.89\n",
        "Final Density  (kg/m^3 ): 0.588\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.5, Page 44"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "import math\n",
      "\n",
      "\n",
      " #Initializing  the  variables\n",
      "p  =  350*10**3;                                         #Gauge  Pressure\n",
      "pAtm  =  101.3*10**3;                                    #Atmospheric  Pressure    \n",
      "rhoW  =  1000;                                           #Density  of  Water\n",
      "sigma  =  13.6;                                          #Relative  Density  of  Mercury\n",
      "g  =  9.81                                               #Acceleration  due  to  gravity\n",
      "\n",
      " #Calculations\n",
      "def Head(rho):\n",
      "    head  =  p/(rho*g);\n",
      "    return head\n",
      "rhoM  =  sigma*rhoW;\n",
      "pAbs  =  p  +  pAtm;\n",
      "\n",
      "print \"\\nPart(a)- Equivalent head of water (m) :\",round(Head(rhoW),2)\n",
      "print \"\\nPart(b)- Equivalent head of water (m) :\",round(Head(rhoM),2)\n",
      "print \"\\nAbsolute pressure (kN/m^2)            :\",pAbs/1000"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "Part(a)- Equivalent head of water (m) : 35.68\n",
        "\n",
        "Part(b)- Equivalent head of water (m) : 2.62\n",
        "\n",
        "Absolute pressure (kN/m^2)            : 451.3\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.6, Page 45"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "import math\n",
      "\n",
      "   \n",
      "\n",
      " #Initializing  the  variables\n",
      "rho  =  10**3;                                  #Density  of  water\n",
      "h  =  2;                                        #Height\n",
      "g  =  9.81;                                     #Acceleration  due  to  gravity\n",
      "\n",
      " #Calculations\n",
      "p=rho*h*g;  \n",
      "\n",
      "print \"Gauge pressure (k/m2) :\",p/1000"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Gauge pressure (k/m2) : 19.62\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.7, Page 46"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "import math\n",
      "\n",
      "\n",
      "\n",
      " #Initializing  the  variables\n",
      "rho  =  0.8*10**3;                                                  #Density  of  fluid\n",
      "rhoM  =  13.6*10**3;                                              #Density  of  manometer  liquid\n",
      "g  =  9.81                                                                #Acceleration  due  to  gravity\n",
      "\n",
      " #Calculations\n",
      "def fluidPressure(h1,h2):\n",
      "    P  =  rhoM*g*h2-rho*g*h1;\n",
      "    return P\n",
      "\n",
      "p1=fluidPressure(0.5,0.9)/1000\n",
      "p2=fluidPressure(0.1,-0.2)/1000\n",
      "\n",
      "print \"!-----Part (a)-----! \\nGauge pressure (kN/m2) :\",round(p1,2)\n",
      "print \"\\n!-----Part (b)-----! \\nGauge pressure (kN/m2) :\",round(p2,2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "!-----Part (a)-----! \n",
        "Gauge pressure (kN/m2) : 116.15\n",
        "\n",
        "!-----Part (b)-----! \n",
        "Gauge pressure (kN/m2) : -27.47\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.8, Page 47"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "import math\n",
      "\n",
      "\n",
      "\n",
      " #Initializing  the  variables\n",
      "rho  =  10**3;                                                          #Density  of  fluid\n",
      "rhoM  =  13.6*10**3;                                              #Density  of  manometer  liquid\n",
      "g  =  9.81;                                                              #Acceleration  due  to  gravity\n",
      "H  =  0.3;                                                                #  Differnce  in  height  =  b-a  as  in  text\n",
      "h  =  0.7;\n",
      "\n",
      " #Calculations\n",
      "result  =  rho*g*H  +  h*g*(rhoM-rho);\n",
      "\n",
      "print \"Pressure difference (kN/m^2):\", round(result/1000,3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Pressure difference (kN/m^2): 89.467\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.9, Page 50"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "import math\n",
      "\n",
      "\n",
      "\n",
      " #Initializing  the  variables\n",
      "rho  =  10**3;                                                          #Density  of  fluid\n",
      "rhoM  =  0.8*10**3;                                                #Density  of  manometer  liquid\n",
      "g  =  9.81;                                                              #Acceleration  due  to  gravity\n",
      "a  =  0.25;\n",
      "b  =  0.15;\n",
      "h  =  0.3;\n",
      " #Calculations\n",
      "def PressureDiff(a,b,h,rho,rhoM):\n",
      "    P  =  rho*g*(b-a)  +  h*g*(rho-rhoM);\n",
      "    return P\n",
      "print \"The presure difference,if the top of the manometer is filled with\"\n",
      "print \"(a) air                          :\",PressureDiff(a,b,h,rho,0)/1000, \" N/m^2\"\n",
      "print \"(b) oil of relative density 0.8. :\",PressureDiff(a,b,h,rho,rhoM), \"N/m^2\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The presure difference,if the top of the manometer is filled with\n",
        "(a) air                          : 1.962  N/m^2\n",
        "(b) oil of relative density 0.8. : -392.4 N/m^2\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.10, Page 54"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "import math\n",
      "\n",
      " #Initializing  the  variables\n",
      "phi  =  30;                                                              #30  degree\n",
      "h  =  1.2  ;                                                              #  Height  of  tank\n",
      "l  =  2;                                                                    #  Length  of  tank\n",
      "\n",
      " #Calculations\n",
      "def SurfaceAngle(a,phi):\n",
      "    g=9.81; # m/s**2    \n",
      "    Theta  =  math.atan(-a*math.cos(math.radians(phi))/(g+a*math.sin(math.radians(phi))));  \n",
      "    return Theta\n",
      "\n",
      " #case  (a)  a  =  4\n",
      "\n",
      "print \"ThetaA      (degree)      :\",round(180 + 180/math.pi*SurfaceAngle(4,phi),2)\n",
      "\n",
      " #Case  (b)  a  =  -  4.5\n",
      "tanThetaR  =  math.tan((SurfaceAngle(-4.5,phi)));\n",
      "\n",
      "print \"\\nThetaR      (degree)      :\",round(SurfaceAngle(-4.5,phi)*180/math.pi,2)\n",
      "\n",
      "Depth  =  h  -  l*tanThetaR/2;\n",
      "print \"\\nMaximum Depth of tank (m) :\",round(Depth,4)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "ThetaA      (degree)      : 163.65\n",
        "\n",
        "ThetaR      (degree)      : 27.27\n",
        "\n",
        "Maximum Depth of tank (m) : 0.6845\n"
       ]
      }
     ],
     "prompt_number": 4
    }
   ],
   "metadata": {}
  }
 ]
}