summaryrefslogtreecommitdiff
path: root/Transport_Phenomena:_A_Unified_Approach/ch7.ipynb
blob: bf3aa618ab2c18bd0541ce893593e426ee672dc2 (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
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 7 : Integral methods of analysis"
     ]
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 7.2 - Page No :273\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "from scipy.integrate import quad \n",
      "\n",
      "\n",
      "# Variables\n",
      "# given\n",
      "id_ = 4.;  \t\t\t #[m] - insid_e diameter\n",
      "h = 2.;  \t\t\t #[m] - water level\n",
      "ro = 0.03;  \t\t\t #[m] - radius of exit hole\n",
      "rt = id_/2.;  \t\t\t #[m] - insid_e radius\n",
      "g = 9.80665;  \t\t\t #[m/sec**2] - gravitational acceleration\n",
      "\n",
      "# Calculations\n",
      "# using the equation dh/h**(1/2) = -((ro**2)/(rt**2))*(2*g)**(1/2)dt and integrating between h = 2 and h = 1\n",
      "def f6(h): \n",
      "\t return (1./h**(1./2))*(1./(-((ro**2)/(rt**2))*(2*g)**(1./2)))\n",
      "\n",
      "t1 =  quad(f6,2,1)[0]\n",
      "\n",
      "# Results\n",
      "print \" Time required to remove half of the contents of the tank is  t = %.2f sec = %.2f min\"%(t1,t1/60);\n",
      "\t\t\t #integrating between h = 2 and h = 0\n",
      "\n",
      "def f7(h): \n",
      "\t return (1./h**(1./2))*(1./(-((ro**2)/(rt**2))*(2*g)**(1./2)))\n",
      "\n",
      "t2 =  quad(f7,2,0)[0]\n",
      "\n",
      "print \" Time required to empty the tank fully is  t = %.1f sec = %.1f min\"%(t2,t2/60);\n",
      "\n",
      "ro2 = (h**2)*math.sqrt(h*h/g)/(10*60)\n",
      "print \" Ro**2 = %.6f m**2\"%ro2\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Time required to remove half of the contents of the tank is  t = 831.37 sec = 13.86 min\n",
        " Time required to empty the tank fully is  t = 2838.5 sec = 47.3 min\n",
        " Ro**2 = 0.004258 m**2\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 7.3 - Page No :274\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "# composition of fuel gas\n",
      "nH2 = 24.;\n",
      "nN2 = 0.5;\n",
      "nCO = 5.9;\n",
      "nH2S = 1.5;\n",
      "nC2H4 = 0.1;\n",
      "nC2H6 = 1;\n",
      "nCH4 = 64;\n",
      "nCO2 = 3.0;\n",
      "\n",
      "# Calculations\n",
      "# calculating the theoritical amount of O2 required\n",
      "nO2theoreq = 12+2.95+2.25+0.30+3.50+128;\n",
      "# since fuel gas is burned with 40% excess O2,then O2 required is\n",
      "nO2req = 1.4*nO2theoreq;\n",
      "nair = nO2req/0.21;  \t\t\t # as amount of O2 in air is 21%\n",
      "nN2air = nair*(0.79);  \t\t\t # as amount of N2 in air is 79%\n",
      "nN2 = nN2+nN2air;\n",
      "nO2 = nO2req-nO2theoreq;\n",
      "nH2O = 24+1.5+0.2+3.0+128;\n",
      "nCO2formed = 72.1;\n",
      "nCO2 = nCO2+nCO2formed;\n",
      "nSO2 = 1.5;\n",
      "ntotal = nSO2+nCO2+nO2+nN2+nH2O;\n",
      "mpSO2 = (nSO2/ntotal)*100;\n",
      "mpCO2 = (nCO2/ntotal)*100;\n",
      "mpO2 = (nO2/ntotal)*100;\n",
      "mpN2 = (nN2/ntotal)*100;\n",
      "mpH2O = (nH2O/ntotal)*100;\n",
      "\n",
      "\n",
      "# Results\n",
      "print \" gas                 N2       O2         H2O         CO2       SO2\";\n",
      "print \" moles              %.1f     %.1f      %.1f        %.1f      %.1f\"%(nN2,nO2,nH2O,nCO2,nSO2);\n",
      "print \" mole percent       %.1f      %.1f       %.1f          %.1f      %.1f\"%(mpN2,mpO2,mpH2O,mpCO2,mpSO2);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " gas                 N2       O2         H2O         CO2       SO2\n",
        " moles              785.2     59.6      156.7        75.1      1.5\n",
        " mole percent       72.8      5.5       14.5          7.0      0.1\n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 7.4 - Page No :280\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "# Variables\n",
      "# given\n",
      "id_ = 6.;  \t\t\t #[inch] - inlet diameter\n",
      "od = 4.;  \t\t\t #[inch] - outlet diameter\n",
      "Q = 10.;  \t\t\t #[ft**3/sec] - water flow rate\n",
      "alpha2 = math.pi/3;  #[radians] - angle of reduction of elbow\n",
      "alpha1 = 0.;\n",
      "p1 = 100.;  \t\t #[psi] - absolute inlet pressure\n",
      "p2 = 29.;  \t\t\t #[psi] - absolute outlet pressure\n",
      "\n",
      "# Calculations\n",
      "S1 = (math.pi*((id_/12)**2))/4.;\n",
      "S2 = (math.pi*((od/12)**2))/4.;\n",
      "U1 = Q/S1;\n",
      "U2 = Q/S2;\n",
      "mu = 6.72*10**-4;  \t #[lb*ft**-1*sec**-1]\n",
      "p = 62.4;  \t\t\t #[lb/ft**3]\n",
      "Nrei = ((id_/12.)*U1*p)/(mu);\n",
      "\n",
      "# Results\n",
      "print \"Nre(inlet) = %.1e\"%Nrei\n",
      "Nreo = round(((od/12)*U2*p)/(mu),-4);\n",
      "print \"Nre(outlet) = %.1e \"%Nreo\n",
      "\n",
      "# thus\n",
      "b = 1.;\n",
      "w1 = p*Q;  \t\t\t #[lb/sec] - mass flow rate\n",
      "w2 = w1;\n",
      "gc = 32.174;\n",
      "\n",
      "# using the equation (w/gc)*((U1)*(math.cos(alpha1))-(U2)*(math.cos(alpha2)))+p1*S1*math.cos(alpha1)-p2*S2*math.cos(alpha2)+Fextx = 0;\n",
      "Fextx = -(w1/gc)*((U1)*(math.cos(alpha1))-(U2)*(math.cos(alpha2)))-p1*144*S1*math.cos(alpha1)+p2*144*S2*math.cos(alpha2);\n",
      "print \"Fext,x = %.0f lb\"%Fextx\n",
      "Fexty = -(w1/gc)*((U1)*(math.sin(alpha1))-(U2)*(math.sin(alpha2)))-p1*144*S1*math.sin(alpha1)+p2*144*S2*math.sin(alpha2);\n",
      "print \"Fext,y = %.0f lb \"%Fexty\n",
      "print \"The forces Fext,x and Fext,y are the forces exerted on the fluid_ by the elbow.\\\n",
      "\\nFext,x acts to the left and Fext,y acts in the positive y direction.\\\n",
      "\\nNote that the elbow is  horizantal,and gravity acts in the z direction\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Nre(inlet) = 2.4e+06\n",
        "Nre(outlet) = 3.6e+06 \n",
        "Fext,x = -2522 lb\n",
        "Fext,y = 2240 lb \n",
        "The forces Fext,x and Fext,y are the forces exerted on the fluid_ by the elbow.\n",
        "Fext,x acts to the left and Fext,y acts in the positive y direction.\n",
        "Note that the elbow is  horizantal,and gravity acts in the z direction\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 7.5 - Page No : 282\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import numpy\n",
      "\n",
      "# Variables\n",
      "Fextx = -2522.;  \t\t\t #[lb] - force in x direction\n",
      "Fexty = 2240.;  \t\t\t #[lb] - force in y direction\n",
      "\n",
      "# Calculations\n",
      "# the force exerted by the elbow on the fluid is the resolution of Fext,x and Fext,y , therefore\n",
      "Fext = ((Fextx)**2+(Fexty)**2)**(1./2);\n",
      "alpha = 180. - 41.6\n",
      "\n",
      "# Results\n",
      "print \" the force has a magnitude of %.0f lb and a direction of %.1f from \\\n",
      "\\nthe positive x directionin the second quadrant\"%(Fext,alpha);\n",
      "\n",
      "# Note : answers in book is wrong. they have used wrong values everywhere. Please check it manually."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " the force has a magnitude of 3373 lb and a direction of 138.4 from \n",
        "the positive x directionin the second quadrant\n"
       ]
      }
     ],
     "prompt_number": 27
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 7.6 - Page No :283\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "id_ = 6.;  \t\t\t #[inch] - inlet diameter\n",
      "od = 4.;  \t\t\t #[inch] - outlet diameter\n",
      "Q = 10.;  \t\t\t #[ft**3/sec] - water flow rate\n",
      "alpha2 = math.pi/3;  #[radians] - angle of reduction of elbow\n",
      "alpha1 = 0.;\n",
      "p1 = 100.;  \t\t #[psi] - absolute inlet pressure\n",
      "p2 = 29.;  \t\t\t #[psi] - absolute outlet pressure\n",
      "patm = 14.7;  \t\t #[psi] - atmospheric pressure\n",
      "p1gauge = p1-patm;\n",
      "p2gauge = p2-patm;\n",
      "S1 = (math.pi*((id_/12.)**2))/4.;\n",
      "S2 = (math.pi*((od/12.)**2))/4.;\n",
      "U1 = Q/S1;\n",
      "U2 = Q/S2;\n",
      "p = 62.4;  \t\t\t #[lb/ft**3]\n",
      "b = 1.;\n",
      "w1 = p*Q;  \t\t\t #[lb/sec] - mass flow rate\n",
      "w2 = w1;\n",
      "gc = 32.174;\n",
      "\n",
      "# Calculations\n",
      "# using the equation Fpress = p1gauge*S1-p2gauge*S2*math.cos(alpha2);\n",
      "Fpressx = p1gauge*144*S1-p2gauge*144*S2*math.cos(alpha2);\n",
      "Fpressy = p1gauge*144*S1*math.sin(alpha1)-p2gauge*144*S2*math.sin(alpha2);\n",
      "wdeltaUx = (w1/gc)*((U2)*(math.cos(alpha2))-(U1)*(math.cos(alpha1)));\n",
      "wdeltaUy = (w1/gc)*((U2)*(math.sin(alpha2))-(U1)*(math.sin(alpha1)));\n",
      "Fextx = wdeltaUx-Fpressx;\n",
      "Fexty = wdeltaUy-Fpressy;\n",
      "Fext = ((Fextx)**2+(Fexty)**2)**(1./2);\n",
      "alpha = 180 - 43.4\n",
      "\n",
      "# Results\n",
      "print \" The force has a magnitude of %.0f lb and a direction of %.1f from the positive x directionin the second \\\n",
      "quadrant\"%(round(Fext,-1),alpha);\n",
      "print \" Also there is a force on the elbow in the z direction owing to the weight of the elbow \\\n",
      " plus the weight of the fluid inside\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The force has a magnitude of 3030 lb and a direction of 136.6 from the positive x directionin the second quadrant\n",
        " Also there is a force on the elbow in the z direction owing to the weight of the elbow  plus the weight of the fluid inside\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 7.7 - Page No :293\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from scipy.integrate import quad \n",
      "# Variables\n",
      "Uo = 1.;  \t\t\t #[m/sec]\n",
      "# using Ux/Uo = y/yo\n",
      "# assuming any particular value of yo will not change the answer,therefore\n",
      "yo = 1;\n",
      "\n",
      "# Calculations\n",
      "def f2(y): \n",
      "\t return (Uo*y)/yo\n",
      "\n",
      "Uxavg =  quad(f2,0,yo)[0]\n",
      "\n",
      "\n",
      "def f3(y): \n",
      "\t return ((Uo*y)/yo)**3\n",
      "\n",
      "Ux3avg =  quad(f3,0,yo)[0]\n",
      "\n",
      "# using the formula alpha = (Uxavg)**3/Ux3avg\n",
      "alpha = (Uxavg)**3/Ux3avg;\n",
      "\n",
      "# Results\n",
      "print \"alpha = \",alpha\n",
      "print \" Note that the kinetic correction factor  alpha has the same final value for \\\n",
      " laminar pipe flow as it has for laminar flow \\nbetween parallel plates.\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "alpha =  0.5\n",
        " Note that the kinetic correction factor  alpha has the same final value for  laminar pipe flow as it has for laminar flow \n",
        "between parallel plates.\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 7.8 - Page No :293\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "Q = 0.03;  \t\t\t #[m**3/sec] - volumetric flow rate\n",
      "id_ = 7.;  \t\t\t #[cm] - insid_e diameter\n",
      "deltaz = -7.;  \t\t #[m] - length of pipe\n",
      "T1 = 25.;  \t\t\t #[degC] - lowere sid_e temperature\n",
      "T2 = 45.;  \t\t\t #[degC] - higher sid_e temperature\n",
      "g = 9.81;  \t\t\t #[m/sec**2] - acceleration due to gravity\n",
      "deltaP = 4.*10**4;   #[N/m**2] - pressure loss due to friction\n",
      "p = 1000.;  \t\t #[kg/m**3] - density of water \n",
      "w = Q*p;\n",
      "C = 4184.;  \t\t #[J/kg*K) - heat capacity of water\n",
      "\n",
      "# Calculations\n",
      "deltaH = w*C*(T2-T1);\n",
      "# using the formula Qh = deltaH+w*g*deltaz\n",
      "Qh = deltaH+w*g*deltaz;\n",
      "\n",
      "# Results\n",
      "print \" the duty on heat exchanger is  Q = %.2e J/sec\"%(Qh);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " the duty on heat exchanger is  Q = 2.51e+06 J/sec\n"
       ]
      }
     ],
     "prompt_number": 56
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 7.10 - Page No :298\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "d = 0.03;  \t\t\t #[m] - diameter\n",
      "g = 9.784;  \t\t #[m/sec] - acceleration due to gravity\n",
      "deltaz = -1.;\n",
      "\n",
      "# using the equation (1/2)*(U3**2/alpha3-U1**2/alpha1)+g*deltaz = 0\n",
      "# assuming\n",
      "alpha1 = 1.;\n",
      "alpha3 = 1.;\n",
      "\n",
      "U1 = 0.;\n",
      "\n",
      "# Calculations\n",
      "U3 = (-2*g*deltaz+(U1**2)/alpha1)**(1/2.);\n",
      "p = 1000.;  \t\t\t #[kg/m**3] - density of water\n",
      "S3 = (math.pi/4)*(d)**2\n",
      "w = p*U3*S3;\n",
      "\n",
      "# Results\n",
      "print \" the mass flow rate is  w = %.2f kg/sec\"%(w);\n",
      "\n",
      "\n",
      "# using deltap = p*((U3**2)/2+g*deltaz)\n",
      "deltap = p*((U3**2)/2+g*deltaz);\n",
      "p1 = 1.01325*10**5;  \t\t\t #[N/m**2] - is equal to atmospheric pressure\n",
      "p2 = p1+deltap;\n",
      "vp = 0.02336*10**5;\n",
      "if p2>vp:\n",
      "    print \" the siphon can operate since the pressure at point 2 is greater than the value at which the liquid boils\";\n",
      "else:\n",
      "    print \" the siphon cant operate since the pressuer at point 2 is less than \\\n",
      "     the value at which the liquid_ boils\";\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " the mass flow rate is  w = 3.13 kg/sec\n",
        " the siphon can operate since the pressure at point 2 is greater than the value at which the liquid boils\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 7.11 - Page No :300\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "sp = 1.45;  \t\t\t # specific gravity of trichloroethylene\n",
      "pwater = 62.4;  \t\t\t #[lb/ft**3] - density of water\n",
      "p = sp*pwater;\n",
      "d1 = 1.049;  \t\t\t #[inch] - density of pipe at point 1\n",
      "d2 = 0.6;  \t\t\t #[inch] - density of pipe at point 2\n",
      "d3 = 1.049;  \t\t\t #[inch] - density of pipe at point 3\n",
      "\n",
      "# Calculations\n",
      "# using the formula U1*S1 = U2*S2; we get U1 = U2*(d2/d1);\n",
      "# then using the bernoulli equation deltap/p = (1/2)*(U2**2-U1**2);\n",
      "deltap = 4.2*(144);  \t\t\t #[lb/ft**2] - pressure difference\n",
      "U2 = ((2*(deltap/p)*(1./(1.-(d2/d1)**4)))**(1./2))*(32.174)**(1./2);\n",
      "\n",
      "# umath.sing the formula w = p*U2*S\n",
      "w = p*U2*((math.pi/4)*(0.6/12)**2);\n",
      "w1 = w/(2.20462);\n",
      "\n",
      "# Results\n",
      "print \" the mass flow rate is  w = %.1f lb/sec or in SI units  w = %.2f kg/sec\"%(w,w1);\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " the mass flow rate is  w = 3.9 lb/sec or in SI units  w = 1.77 kg/sec\n"
       ]
      }
     ],
     "prompt_number": 60
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 7.12 - Page No :301\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "Q = 50/(7.48*60);  \t #[ft/sec] - volumetric flow rate of water\n",
      "d1 = 1.;  \t\t\t #[inch] - diameter of pipe\n",
      "deltaz = -5;  \t\t #[ft] - distance between end of pipe and math.tank\n",
      "g = 32.1;  \t\t\t #[ft/sec] - acceleration due to gravity\n",
      "Cp = 1.;  \t\t\t #[Btu/lb*F] - heat capacity of water\n",
      "p = 62.4;  \t\t\t #[lb/ft**3] - density of water\n",
      "S1 = (math.pi/4)*(d1/12.)**2;\n",
      "U1 = Q/S1;\n",
      "w = p*Q;\n",
      "U2 = 0.;\n",
      "gc = 32.174;\n",
      "\n",
      "# Calculations\n",
      "# using the formula deltaH = (w/2)*((U2)**2-(U1)**2)+w*g*deltaz\n",
      "deltaH = -(w/(2*gc))*((U2)**2-(U1)**2)-w*(g/gc)*deltaz;\n",
      "deltaH = deltaH/778;  \t\t\t # converting from ftlb/sec to Btu/sec\n",
      "deltaT = deltaH/(w*Cp);\n",
      "\n",
      "# Results\n",
      "print \" The rise in temperature is %.5f degF\"%(deltaT);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The rise in temperature is 0.01475 degF\n"
       ]
      }
     ],
     "prompt_number": 62
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 7.13 - Page No :303\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "deltaz = 30.;  \t\t #[ft] - distance between process and the holding math.tank\n",
      "Q = 100.;  \t\t\t #[gpm] - volumetric flow rate of water\n",
      "p1 = 100.;  \t\t #[psig]\n",
      "p2 = 0.;  \t\t\t #[psig]\n",
      "g = 32.1;  \t\t\t #[ft/sec] - acceleration due to gravity\n",
      "sv = 0.0161;  \t\t #[ft**3/lb] - specific volume of water\n",
      "p = 1./sv;  \t\t #[lb/ft**3] - density of water\n",
      "e = 0.77;  \t\t\t # efficiency of centrifugal pump\n",
      "deltap = (p1-p2)*(144);  \t\t\t #[lbf/ft**2]\n",
      "gc = 32.174;\n",
      "\n",
      "# Calculations\n",
      "# using the equation deltap/p+g*(deltaz)+Ws = 0;\n",
      "Wst = -deltap/p-(g/gc)*(deltaz);\n",
      "# using the formula for efficiency e = Ws(theoritical)/Ws(actual)\n",
      "# therefore\n",
      "Wsa = Wst/e;\n",
      "# the calulated shaft work is for a unit mass flow rate of water,therfore for given flow rate multiply it by the flow rate\n",
      "w = (Q*p)/(7.48*60);\n",
      "Wsactual = Wsa*w;\n",
      "power = -Wsactual/(778*0.7070);\n",
      "\n",
      "# Results\n",
      "print \" the required horsepower is %.2f hp\"%(power);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " the required horsepower is 8.55 hp\n"
       ]
      }
     ],
     "prompt_number": 64
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 7.14 - Page No :304\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "p1 = 5.;  \t\t\t #[atm] - initial pressure\n",
      "p2 = 0.75;  \t\t #[atm] - final pressure after expansion through turbine\n",
      "T = 450.;  \t\t\t #[K] - temperature\n",
      "y = 1.4;  \t\t\t # cp/cv for nitrogen\n",
      "# using the equation Ws = -(y/(y-1))*(p1/density1)*((p2/p1)**((y-1)/y)-1)\n",
      "R = 8314.;  \t\t # gas constant\n",
      "\n",
      "# Calculations\n",
      "p1bydensity = R*T;\n",
      "Ws = -(y/(y-1))*(p1bydensity)*((p2/p1)**((y-1)/y)-1);\n",
      "\n",
      "# Results\n",
      "print \" the shaft work of the gas as it expands through the turbine and transmits its molecular \\\n",
      " energy to the rotating blades is \\n Ws = %.2e J/kmol\"%(Ws);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " the shaft work of the gas as it expands through the turbine and transmits its molecular  energy to the rotating blades is \n",
        " Ws = 5.48e+06 J/kmol\n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example  7.15 - Page No :311\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "T = 273.15+25;  \t\t #[K] - temperature\n",
      "R = 8.314;  \t\t\t #[kPa*m**3/kmol*K] - gas constant\n",
      "p = 101.325;  \t\t\t #[kPa] - pressure\n",
      "M = 29.;  \t\t\t     # molecular weight of gas\n",
      "pa = (p*M)/(R*T);\n",
      "sg = 13.45;  \t\t\t # specific gravity\n",
      "pm = sg*1000;\n",
      "g = 9.807;  \t\t\t #[m/sec**2] - acceleration due to gravity\n",
      "deltaz = 15./100;  \t\t #[m]\n",
      "\n",
      "# Calculations\n",
      "# using the equation p2-p1 = deltap = (pm-pa)*g*deltaz\n",
      "deltap = -(pm-pa)*g*deltaz;\n",
      "\n",
      "# Results\n",
      "print \" the pressure drop is %.2e N/m**2\"%(deltap);\n",
      "print \" the minus sign means the upstream pressure p1 is greater than p2, i.e ther is a pressure drop.\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " the pressure drop is -1.98e+04 N/m**2\n",
        " the minus sign means the upstream pressure p1 is greater than p2, i.e ther is a pressure drop.\n"
       ]
      }
     ],
     "prompt_number": 68
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 7.16 - Page No :312\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "T = 536.67;  \t\t\t #[degR]; - temperature\n",
      "R = 10.73;  \t\t\t #[(lbf/in**2*ft**3)*lb*mol**-1*degR] - gas constant\n",
      "p = 14.696;  \t\t\t #[lbf/in**2];\n",
      "g = 9.807*3.2808;  \t\t #[ft/sec**2] - acceleration due to gravity\n",
      "M = 29.;  \t\t\t     # molecular weight of gas\n",
      "\n",
      "# Calculations\n",
      "pa = (p*M)/(R*T);\n",
      "sg = 13.45;  \t\t\t # specific gravity\n",
      "pm = sg*62.4;\n",
      "deltaz = 15/(2.54*12);   #[ft]\n",
      "gc = 32.174;\n",
      "\n",
      "# Results\n",
      "# using the equation p2-p1 = deltap = (pm-pa)*g*deltaz\n",
      "deltap = (pm-pa)*(g/gc)*deltaz;\n",
      "print \"the pressure drop is %.0f lbf/ft**2\"%(deltap);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the pressure drop is 413 lbf/ft**2\n"
       ]
      }
     ],
     "prompt_number": 71
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 7.18 - Page No :315\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "at = 0.049;  \t\t\t #[in**2] - cross sectional area of the manometer tubing\n",
      "aw = 15.5;  \t\t\t #[in**2] - cross sectional area of the well\n",
      "g = 32.174;  \t\t\t #[ft/sec**2] - acceleration due to gravity\n",
      "gc = 32.174;\n",
      "sg = 13.45;  \t\t\t #[ specific garvity of mercury\n",
      "p = 62.4;  \t\t\t     #[lb/ft**3] - density of water;\n",
      "pm = sg*p;\n",
      "deltaz_waterleg = 45.2213;\n",
      "\n",
      "# Calculations\n",
      "# using the equation A(well)*deltaz(well) = A(tube)*deltaz(tube)\n",
      "deltazt = 70.;  \t\t\t #[cm]\n",
      "deltazw = deltazt*(at/aw);\n",
      "deltaz = deltazt+deltazw;\n",
      "deltap_Hg = -pm*(g/gc)*(deltaz/(2.54*12));\n",
      "\n",
      "# Results\n",
      "deltazw = 45.2213;  \t\t\t #[cm]\n",
      "deltap_tap = deltap_Hg+p*(g/gc)*(deltazw/(12*2.54));\n",
      "print \"deltap_tap = %.0f lbf/ft**2\"%(deltap_tap);\n",
      "print \"deltap is negative and therefore p1 is greater than p2\";\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "deltap_tap = -1841 lbf/ft**2\n",
        "deltap is negative and therefore p1 is greater than p2\n"
       ]
      }
     ],
     "prompt_number": 73
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 7.19 - Page No :317\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "p = 749./760;  \t\t\t #[atm]\n",
      "T = 21.+273.15;  \t\t #[K]\n",
      "R = 82.06;  \t\t\t #[atm*cm**3/K] - gas constant\n",
      "v = (R*T)/p;  \t\t\t #[cm**3/mole] - molar volume\n",
      "M = 29.;  \t\t\t     #[g/mole] - molecular weight\n",
      "pair = M/v;\n",
      "m_air = 53.32;  \t\t\t #[g]\n",
      "m_h2o = 50.22;  \t\t\t #[g]\n",
      "ph2o = 0.998;  \t\t\t     #[g/cm**3] - density of water\n",
      "\n",
      "# Calculations\n",
      "V = (m_air-m_h2o)/(ph2o-pair);  \t\t\t #[cm**3]\n",
      "density = m_air/V;\n",
      "\n",
      "# Results\n",
      "print \" The density of coin is  density = %.2f g/cm**3\"%(density);\n",
      "print \" Consulting a handbook it is seen that this result is correct density for gold\";\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The density of coin is  density = 17.15 g/cm**3\n",
        " Consulting a handbook it is seen that this result is correct density for gold\n"
       ]
      }
     ],
     "prompt_number": 75
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 7.20 - Page No :318\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "P = 749./760;  \t\t\t #[atm] - pressure\n",
      "T = 21+273.15;  \t\t #[K] - temperature\n",
      "poak = 38*(1./62.4);  \t #[g/cm**3] - density of oak\n",
      "pbrass = 534/62.4;  \t #[g/cm**3] - density of brass\n",
      "m_brass = 6.7348;  \t\t #[g]\n",
      "pair = 0.001184;  \t\t #[g/cm**3] - density of air\n",
      "\n",
      "# Calculations\n",
      "# using the formula m_oak = m_brass*((1-(pair/pbrass))/(1-(pair/poak)))\n",
      "m_oak = m_brass*((1-(pair/pbrass))/(1-(pair/poak)));\n",
      "\n",
      "# Results\n",
      "print \" True mass of wood = %.3f g\"%(m_oak);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " True mass of wood = 6.747 g\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 7.21 - Page No :320\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "T = 545.67;  \t\t\t #[degR] - temperature\n",
      "R = 1545.;  \t\t\t #[Torr*ft**3/degR*mole] - gas constant\n",
      "M = 29.;  \t\t\t     #[g/mole] - molecular weight\n",
      "g = 9.807;  \t\t\t #[m/sec**2] - acceleration due to gravity\n",
      "gc = 9.807;  \n",
      "po = 760.;  \t\t\t #[Torr] - pressure\n",
      "deltaz = 50.;  \t\t\t #[ft]\n",
      "\n",
      "# Calculations\n",
      "# using the equation p = po*exp(-(g/gc)*M*(deltaz/R*T))\n",
      "p = po*math.e**(-(g/gc)*M*(deltaz/(R*T)));\n",
      "\n",
      "# Results\n",
      "print \" p = %.1f Torr \\nThus, the pressure decrease for an elevation of 50ft is very small\"%(p);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " p = 758.7 Torr \n",
        "Thus, the pressure decrease for an elevation of 50ft is very small\n"
       ]
      }
     ],
     "prompt_number": 78
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 7.22 - Page No :321\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "To = 545.67;  \t\t\t #[degR] -  air temperature at beach level\n",
      "betaa = -0.00357;  \t\t #[degR/ft] - constant\n",
      "R = 1545.;  \t\t\t #[Torr*ft**3/degR*mole] - gas constant\n",
      "M = 29.;\n",
      "deltaz = 25000.;  \t\t #[ft]\n",
      "po =  760.  \n",
      "\n",
      "# Calculations\n",
      "# using the equation ln(p/po) = ((M)/(R*betaa))*ln(To/(To+betaa*deltaz)\n",
      "p = po*math.exp(((M)/(R*betaa))*math.log(To/(To+betaa*deltaz)));\n",
      "\n",
      "# Results\n",
      "print \" Pressure = %.2f Torr\"%(p);\n",
      "# using the equation T = To+betaa*deltaz\n",
      "T = To+betaa*deltaz;\n",
      "print \" Temperature = %.2f degR\"%(T);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Pressure = 297.16 Torr\n",
        " Temperature = 456.42 degR\n"
       ]
      }
     ],
     "prompt_number": 19
    }
   ],
   "metadata": {}
  }
 ]
}