summaryrefslogtreecommitdiff
path: root/TRANSPORT_PROCESSES_AND_UNIT_OPERATIONS/GeankoplisChapter02.ipynb
blob: 47b8388a2bcdf04b48ad81abb0212cf610abb6c1 (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
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
{
 "metadata": {
  "name": "",
  "signature": "sha256:2983d20baa7ffdc8f712c1d56291b4f0f9e932dcec505cf5db8d7f9e1f38e4b6"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 2: Principles of Momentum Transfer and Overall Balances"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.2-1, Page number 32"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Units and Dimensions of Force\n",
      "# Variable declaration\n",
      "m = 3.                        #Mass of the body (lbm)\n",
      "g_fps = 32.174                #Acceleration due to gravity in fps units (ft/s2)\n",
      "confaclbmtolbf = 32.174       #Conversion factor from lbm to lbf(lbm.ft/lbf.s2)\n",
      "confaclbmtog = 453.59         #Conversion factor from lbm to gram (g/lbm)\n",
      "g_mks = 980.665               #Acceleration due to gravity in mks  units (cm/s2)\n",
      "confaclbtokg = 2.2046         #Conversion factor from lbm to kg (kg/lbm)\n",
      "g_SI = 9.80665                #Acceleration due to gravity in SI units (m/s2)\n",
      "    # Data SI Units \n",
      "#Calculation\n",
      "#(a)\n",
      "    #Fa = m*g_fps*ga\n",
      "Fa = m*g_fps/confaclbmtolbf\n",
      "    #Fb = m*g_mks*mb\n",
      "Fb = m*g_mks*confaclbmtog\n",
      "    #Fc = m*g_si*gc\n",
      "Fc = m*g_SI/confaclbtokg\n",
      "#Result\n",
      "print \"(a) The force in lbf is \",round(Fa,4),\"lbf\"\n",
      "print '(b) The force in dynes is %6.4e'%(Fb),\"dyne\"\n",
      "print \"(c) The force in Newton is \",round(Fc,2),\"N\"\n",
      "print 'The answers are correct because of book uses rounded numbers'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a) The force in lbf is  3.0 lbf\n",
        "(b) The force in dynes is 1.3345e+06 dyne\n",
        "(c) The force in Newton is  13.34 N\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.2-2, Page number 34"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Pressure in Storage Tank\n",
      "# Variable declaration\n",
      "Ht = 3.66             #Height of the tank (m)\n",
      "P  = 1.               #Pressure exerted  (atm)\n",
      "Hto = 3.05            #Height of tank filled with oil (m)\n",
      "Htw = 0.61            #Height of tank filled with water (m)\n",
      "Rho_oil = 917.        #Density of oil (kg/m3)\n",
      "Rho_H2O = 1000.       #Density of H2O (kg/m3)\n",
      "g = 9.8               #Gravitational acceleration (m/s2)\n",
      "    # Data  \n",
      "Patm_psia = 14.696        #Atmospheric pressure (psia)\n",
      "P_pa   = 101325.          #Atmospheric pressure (pa)\n",
      "Ht_ft  = 12.              #Height of the tank (ft)\n",
      "Hto_ft  = 10.             #Height of tank filled with oil (ft)\n",
      "Htw_ft = 2.               #Height of tank filled with water (ft)\n",
      "confacsitofps = 0.06243   #conversion factor for density(kg/m3) to (lbm/ft3)\n",
      "confacft2toin2 = 1./144.  #Conversion factor (ft2) to (in2)  \n",
      "# Calculation\n",
      "    #In fps units\n",
      "    #Pressure exerted by oil in fps units \n",
      "    #P1f = Hto_ft*Rho_oil*confacsitofps*confacft2toin2 + P_psia\n",
      "P1f = (Hto_ft*Rho_oil*confacsitofps*confacft2toin2 + Patm_psia)   \n",
      "    #P2f = Htw_ft*Rho_H2O*confacsitofps*confacft2toin2 + P1f\n",
      "P2f=  Htw_ft*Rho_H2O*confacsitofps*confacft2toin2 + P1f    \n",
      "    #Pressure exerted in SI units\n",
      "#Pressure exerted by oil in SI units \n",
      "P1si =  Hto*Rho_oil*g + P_pa\n",
      "#Pressure exerted by water in SI\n",
      "P2si = Htw*Rho_H2O*g + P1si\n",
      "Pgage = P2f - Patm_psia\n",
      "#Result\n",
      "print \"Pressure exerted by oil in fps \",round(P1f,2),\"psia\"\n",
      "print 'Pressure exerted by oil in SI %6.3e Pa'%(P1si)\n",
      "print \"Pressure exerted by water in fps \",round(P2f,2),\"psia\"\n",
      "print 'Pressure exerted by H2O in SI  %6.3e Pa'%(P2si)\n",
      "print 'Gage pressure at the bottom of tank %5.2f psig'%(Pgage)\n",
      "print 'The answers are correct because of book uses rounded numbers'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Pressure exerted by oil in fps  18.67 psia\n",
        "Pressure exerted by oil in SI 1.287e+05 Pa\n",
        "Pressure exerted by water in fps  19.54 psia\n",
        "Pressure exerted by H2O in SI  1.347e+05 Pa\n",
        "Gage pressure at the bottom of tank  4.84 psig\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.2-3, Page number 36"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Conversion of a pressure to head of a fluid \n",
      "\n",
      "# Variable declaration\n",
      "P = 101325.  #Standard atmospheric pressure (kN/m2)\n",
      "# Data  \n",
      "Rho_H2O = 1000.       #Density of H2O at 4 deg C (kg/m3)\n",
      "Rho_Hg  = 13.5955     #Density of Hg at 0 deg C (g/cm3)\n",
      "g = 9.80665           #Gravitational acceleration (m/s2)\n",
      "Rho_H2O_cgs = 1.      #Density of H2O at 4 deg C (g/cm3)\n",
      "    \n",
      "    # Calculation\n",
      "#Pressure head in terms of H2O\n",
      "    # H_H2O = Pressure/(density of H2O*Gravitational acceleration)\n",
      "H_H2O = P/(Rho_H2O*g)\n",
      "    #H_Hg = Pressure/(density of Hg*Gravitational acceleration)\n",
      "H_Hg = H_H2O*Rho_H2O_cgs/Rho_Hg\n",
      "\n",
      "#Result\n",
      "print \"Pressure head of H2O \",round(H_H2O,2),\"m of water at 4\u00b0C\"\n",
      "print \"Pressure head of Hg \",round(H_Hg,3),\"mmHg\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Pressure head of H2O  10.33 m of water at 4\u00b0C\n",
        "Pressure head of Hg  0.76 mmHg\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.2-4, Page number 37"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Pressure Difference in a Manometer\n",
      "# Variable declaration\n",
      "R_cgs = 32.7    #Reading of manometer (cm)\n",
      "# Data  \n",
      "Rho_H2O = 1000.         #Density of H2O  (g/cm3)\n",
      "Rho_Hg  = 13600.        #Density of Hg  (g/cm3)\n",
      "g = 9.80665             #Gravitational acceleration (m/s2)\n",
      "R_SI = 0.327            #Reading of manometer (m)    \n",
      "    # Calculation\n",
      "#Pressure difference in SI units\n",
      "    #delP = R_SI*(Rho_Hg-Rho_H2O)*g\n",
      "delP = R_SI*(Rho_Hg-Rho_H2O)*g   \n",
      "#Result\n",
      "print ' The pressure difference in SI units  %10.3e'%(delP),\"N/m2\"\n",
      "print 'The answer is correct because of book uses rounded numbers'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The pressure difference in SI units   4.041e+04 N/m2\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.3-1, Page number 41"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Molecular Transport of a Property at Steady State \n",
      "# Variable declaration\n",
      "C1 = 0.0137    #Concentration at point 1 (property/m3)\n",
      "C2 = 0.0072    #Concentration at point 2 (property/m3)\n",
      "z1 = 0         #Distance at point 1 (m)\n",
      "z2 = 0.4       #Distance at point 2 (m)\n",
      "z = 0.2        #Midpoint   (m)\n",
      "delta = 0.013  #Diffusivty (m2/s)\n",
      "# Calculation\n",
      "    #Calculation for part (a)\n",
      "    #Flux = delta*(C1-C2)/(z2-z1)\n",
      "Flux = delta*(C1-C2)/(z2-z1)\n",
      "    #Calculation for part (c)\n",
      "C = C1 +  Flux*(z1-z)/delta \n",
      "#Result\n",
      "print '(a) The flux is  %6.3e property/s.m2'%(Flux)\n",
      "print '(c) The concentration at the midpoint is %6.3e property/m3'%(C)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a) The flux is  2.113e-04 property/s.m2\n",
        "(c) The concentration at the midpoint is 1.045e-02 property/m3\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.4-1, Page number 45"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculation of Shear Stress in a Liquid\n",
      "# Variable declaration\n",
      "confaccgstofps = 0.0020875\n",
      "confaccgstosi = 1/10.\n",
      "dely = 0.5        #The distance between the two plates (cm)\n",
      "delVz = 10.       #The velocity change (cm/s)\n",
      "u = 0.0177        #The viscosity of liquid (g/cm.s)    \n",
      "#Calculation\n",
      "   #Calculation for part (a)\n",
      "    #Calculation of shear stress \n",
      "    #Tyz = u(delVz)/(dely)\n",
      "Tyz_cgs = u*(delVz)/(dely)\n",
      "    #Calculation of Shear Rate\n",
      "    #Shear Rate = delVz/dely\n",
      "Vyz_cgs = delVz/dely\n",
      "    #Calculation for part (b)\n",
      "Tyz_fps = Tyz_cgs*confaccgstofps\n",
      "    #Calculation for part (c)\n",
      "Tyz_SI = Tyz_cgs*confaccgstosi\n",
      "#Result\n",
      "print \"(a)Shear stress in cgs is\",round(Tyz_cgs,4),\"dyne/cm2\"\n",
      "print \"   Shear Rate in cgs is\",round(Vyz_cgs,4),\"1/s\"\n",
      "print '(b)Shear stress in fps %10.3e'%(Tyz_fps),\"lbf/ft2\"\n",
      "print \"   Shear Rate in fps is\",round(Vyz_cgs,4),\"1/s\"\n",
      "print \"(c)Shear stress in SI is\",round(Tyz_SI,4),\"N/m2\"\n",
      "print \"   Shear Rate in SI is\",round(Vyz_cgs,4),\"1/s\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a)Shear stress in cgs is 0.354 dyne/cm2\n",
        "   Shear Rate in cgs is 20.0 1/s\n",
        "(b)Shear stress in fps  7.390e-04 lbf/ft2\n",
        "   Shear Rate in fps is 20.0 1/s\n",
        "(c)Shear stress in SI is 0.0354 N/m2\n",
        "   Shear Rate in SI is 20.0 1/s\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.5-1, Page number 49"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Reynolds Number in a pipe \n",
      "from math import pi\n",
      "\n",
      "# Variable declaration\n",
      "F = 10.                 #The flowrate of water (gal/min)\n",
      "d = 2.067               #The inner diameter of pipe (in)\n",
      "spg = 0.996             #specific gravity,M/M\n",
      "d_SI = 0.0525           #Diameter in SI units (m)\n",
      "mu = 0.8007             #Viscosity, cp\n",
      "\n",
      "#Calculation English units\n",
      "F_fps = F*(1./7.481)*(1./60)\n",
      "d_fps = d/12\n",
      "A = pi*d_fps**2/4\n",
      "V = F_fps/A\n",
      "mu_fps = mu*6.7197e-4    #convert in lbm/ft.s\n",
      "rho = spg*62.43\n",
      "Nre_fps = d_fps*V*rho/(mu_fps)\n",
      "\n",
      "#Calculation SIh units\n",
      "\n",
      "d_SI = d*2.54e-2\n",
      "V_SI = V/3.2808\n",
      "mu_SI = mu*1e-3         #convert in Pa.s\n",
      "rho = spg*1000\n",
      "Nre_SI = d_SI*V_SI*rho/(mu_SI)\n",
      "\n",
      "#Result \n",
      "print 'The reynolds number in fps units is %6.3e'%(Nre_fps)\n",
      "print 'The reynolds number in SI units is  %6.3e'%(Nre_SI)\n",
      "print 'The answers are correct because book uses rounded numbers'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The reynolds number in fps units is 1.903e+04\n",
        "The reynolds number in SI units is  1.903e+04\n",
        "The answers are correct because book uses rounded numbers\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.6-1, Page number 51"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Flow of a Crude Oil and Mass Balance\n",
      "\n",
      "#Variable declaration\n",
      "rho = 892.              #Density of Crude Oil kh/m3\n",
      "F = 1.388e-3            #Total Volumetric flow rate m3/s\n",
      "d1 = 2.067              #Diamete of pipe 1 in inches\n",
      "d3 = 1.610              #Diamete of pipe 3 in inches\n",
      "\n",
      "#Calculations\n",
      "intom = 0.0254                 #conversion factor for in to meter\n",
      "A1 = pi*(d1*intom)**2/4        #Area of pipe 1\n",
      "A3 = pi*(d3*intom)**2/4        #Area of pipe 3\n",
      "m1 = F*rho                     #Mass flow rate of Crude Oil through pipe 1\n",
      "m3 = m1/2                      #Mass flow rate of Crude Oil through pipe 3\n",
      "v1 = m1/(rho*A1)               #velocity of Crude Oil through pipe 1\n",
      "v3 = m3/(rho*A3)               #velocity of Crude Oil through pipe 3\n",
      "G1 = m1/A1                     #Mass flux of cride oil through pipe 1\n",
      "\n",
      "#Result\n",
      "print \"(a) Mass flow rate of Crude Oil through pipe 1:\",round(m1,3), \"kg/s\"\n",
      "print \"    Mass flow rate through pipe 3:\",round(m3,3), \"kg/s\"\n",
      "print \"(b) Velocity of Crude Oil through pipe 1:\",round(v1,3), \"m/s\"\n",
      "print \"    Velocity of Crude Oil through pipe 3:\",round(v3,3), \"m/s\"\n",
      "print \"(c) Mass velocity of Crude Oil through pipe 1:\",round(G1), \"m/s\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a) Mass flow rate of Crude Oil through pipe 1: 1.238 kg/s\n",
        "    Mass flow rate through pipe 3: 0.619 kg/s\n",
        "(b) Velocity of Crude Oil through pipe 1: 0.641 m/s\n",
        "    Velocity of Crude Oil through pipe 3: 0.528 m/s\n",
        "(c) Mass velocity of Crude Oil through pipe 1: 572.0 m/s\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.7-1, Page number 61"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Energy Balance on Steam boiler\n",
      "\n",
      "#Variable Declaration\n",
      "Twin = 18.33         #Inlet temperature of water to boiler, degC\n",
      "Pwin = 137.9         #Inlet pressure of water to boiler, kPa\n",
      "Vwin = 1.52          #Inlet temperature of water to boiler, m/s\n",
      "Hwin = 0.            #Water Inlet height, m\n",
      "Hsout = 15.2         #Height of steam outlet above water inlet, m \n",
      "Psout = 137.9        #Outlet pressure of steam to boiler, kPa\n",
      "Tsout = 148.9        #Inlet temperature of water to boiler, degC\n",
      "Vsout = 9.14         #Inlet temperature of water to boiler, m/s\n",
      "H1 = 76.97           #Entalpy of Incomming water to boiler, kJ/kg\n",
      "H2 = 2771.4          #Entalpy of steam leaving boiler, kJ/kg\n",
      "g = 9.80665          #Gravitational acceleration, m/s2\n",
      "#Calcualtion\n",
      "\n",
      "# Heat Added = Del PE + Del KE + Del Enthalpy\n",
      "Q = (Hsout-Hwin)*g + (Vsout**2-Vwin**2)/2 + (H2-H1)*1000\n",
      "\n",
      "#Result \n",
      "print 'Heat Added per kg of water %5.4e'%(Q),\"J/kg\"\n",
      "print 'The answers are correct because of book uses rounded of numbers'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Heat Added per kg of water 2.6946e+06 J/kg\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.7-2, Page number 62"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Energy Balance on a flow system with a Pump\n",
      "\n",
      "#Variable Declaration\n",
      "F = 0.567            #Water pumped from the tank (m3/min.)\n",
      "E1 = 7450.           #Energy supplied by the pump (W)\n",
      "E2 = 1408000         #Energy lost in heat exchanger (W)\n",
      "Rho = 968.5          #Density of water at 85 deg C (kg/m3)\n",
      "Z1 = 0.              #Height of first second tank (m)\n",
      "Z2 = 20.             #Height of second tank (m)\n",
      "H1 = 355900          #Enthalpy of steam (kJ/kg)\n",
      "delV = 0.            #The kintic energy changes\n",
      "g = 9.80665          #Gravitational acceleration (m/s2)\n",
      "\n",
      "#Calcualtion\n",
      "m1 = F*Rho/60        #Water pumped from the tank (kg/s)\n",
      "Ws = -E1/m1 \n",
      "Q = -E2/m1           \n",
      "\n",
      "    # H2 - H1 + 1/2*delV + g(Z2 - Z1) = Q - Ws\n",
      "    # H2 = Q - Ws + H1 - 1/2*delV - g(Z2 - Z1)\n",
      "H2 = Q - Ws + H1 - 0.5*delV - g*(Z2 - Z1)\n",
      "\n",
      "#Result \n",
      "print 'Heat Added per kg of water %5.3e'%(H2), \"J/kg\"\n",
      "print \"The value of heat added corresponds to  48.41 \u00b0C\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Heat Added per kg of water 2.027e+05 J/kg\n",
        "The value of heat added corresponds to  48.41 \u00b0C\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.7-3, Page number 62"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Energy Balance in flow Calorimeter  \n",
      "#Variable Declaration\n",
      "F = 0.3964           #Flowrate of water entering the calorimeter  (kg/min)\n",
      "E1 = 19.630          #Heat added to the water for complete vaporization  (kW)\n",
      "Z1 = 0.              #Height of first second tank (m)\n",
      "Z2 = 0.              #Height of second tank (m)\n",
      "delV = 0.            #The kintic energy changes\n",
      "g = 9.80665          #Gravitational acceleration  (m/s2)\n",
      "Ws = 0.              #Shaft work\n",
      "H1 = 0               #Initial Enthalpy\n",
      "P1 = 150.            #Pressure at point 2 (kPa)\n",
      "#Calcualtion\n",
      "M1 = F/60            #Flowrate of water entering the calorimeter  (kg/s)\n",
      "    # Q = E1/M1\n",
      "Q = E1/M1\n",
      "    # H2 - H1 + 0.5*delV + g(Z2 - Z1) = Q - Ws\n",
      "    # H2 = Q - Ws + H1 - 1/2*delV - g(Z2 - Z1)\n",
      "H2 = Q - Ws + H1 - 0.5*delV - g*(Z2 - Z1)\n",
      "#Result \n",
      "print \"Heat Added per kg of water\",round(H2), \"J/kg\"\n",
      "print \"The corresponding value of enthalpy from steam table is 2972.7 kJ/kg\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Heat Added per kg of water 2971.0 J/kg\n",
        "The corresponding value of enthalpy from steam table is 2972.7 kJ/kg\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.7-4, Page number 64"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Mechanical-Energy Balance on Pumping System\n",
      "\n",
      "#Variable Declaration\n",
      "P1 = 68900.            #The entrance pressure of fluid (N/m2)\n",
      "E = 155.4              #Energy supplied to the fluid (J/kg)\n",
      "P2 = 137800.           #The exit pressure of fluid (N/m2) \n",
      "Nre = 4000             #Reynolds number \n",
      "Rho_H2O = 998.         #Density of water (kg/m3)\n",
      "z1 = 0                 #Height of entrance pipe (m)\n",
      "z2 = 3.05              #Height of exit pipe (m)\n",
      "alpha = 1              #For turbulent flow value of alpha\n",
      "Ws = -155.4            #Mechanical energy added to the fluid (J/kg)\n",
      "g = 9.806              #Gravitational accleration (m/s2)\n",
      "#Calcualtion\n",
      "    #(V1 - V2)/2*alpha = 0\n",
      "    #F = -Ws + 0 + g*(z1-z2) + (P1 - P2)/Rho_H2O\n",
      "F = -Ws + 0 + g*(z1-z2) + (P1 - P2)/Rho_H2O\n",
      "#Result \n",
      "print \"The frictional losses calculated are \",round(F,1), \"J/kg\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The frictional losses calculated are  56.5 J/kg\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.7-5, Page number 65"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Pump Horsepower in Flow System\n",
      "\n",
      "#Variable Declaration\n",
      "F = 69.1              #Volume of liquid drawn by the pump (gal/min)\n",
      "F_fps = F/(60*7.481)  #Volume of liquid drawn bby the pump (ft3/s)\n",
      "Rho = 114.8           #Density of liquid (lbm/ft3)\n",
      "A1 = 0.05134          #Cross sectional area of suction  pipe (in2)\n",
      "A2 = 0.0233           #Cross sectional area of discharge pipe (in2)\n",
      "z1 = 0.               #Height of suction line (m)\n",
      "z2 = 50.              #Height of discharge pipe (m)\n",
      "f = 10.0              #Frictional losses (ft.lbf/lbm)\n",
      "n = 0.65              #Efficiency of the pump \n",
      "g = 32.174            #Gravitational accleration (m/s2)\n",
      "gc = 32.174           #Conversion factor for mks to fps \n",
      "v1 = 0.               #Velocity of liquid in storage feed tank (m/s)\n",
      "alpha = 1.            #Since the flow is turbulent \n",
      "fc = 550.             #Conversion factor from fps to horse power\n",
      "z3 = 0.           \n",
      "z4 = 0.\n",
      "ga = 144.             #Conversion factor for area from ft2 to in2\n",
      "\n",
      "#Calcualtion\n",
      "    #v2 = flowrate/cross sectional area\n",
      "v2 = F_fps/A2\n",
      "    #(P1-P2)/Rho = 0    \n",
      "    #Ws = (z1-z2)*g/gc + (v1*v1 - v2*v2)/(2*gc) + 0 + f       \n",
      "Ws = (z1-z2)*g/gc + (v1*v1 - v2*v2)/(2*gc) + 0 - f\n",
      "Wp = -Ws/n\n",
      "m = F_fps*Rho \n",
      "P = m*Wp/fc\n",
      "v3 = F_fps/A1\n",
      "v4 = F_fps/A2 \n",
      "    #delP = P4 - P3    \n",
      "delP = Rho*((z4-z3)*g/gc +(v3*v3 - v4*v4)/(2*gc) - Ws - 0. )/ga\n",
      "#Result  \n",
      "print \"Power required by the pump \",round(P,0), \"hp\"\n",
      "print \"Pressure developed is \",round(delP,0),\"lbf/in2\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Power required by the pump  3.0 hp\n",
        "Pressure developed is  48.0 lbf/in2\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.8-2, Page number 73"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Momentum Balance for Horizontal Nozzle \n",
      "from math import pi\n",
      "#Variable Declaration\n",
      "F = 0.03154             #Flowrate of water (m3/s)\n",
      "d1 = 0.0635             #Dia of pipe at section 1 (m)\n",
      "d2 = 0.0286             #Dia of pipe at section 2 (m)\n",
      "Rho_H2O = 1000.         #Density of water (kg/m3)\n",
      "P2 = 0.                 #Pressure (N/m2)\n",
      "#Calcualtion\n",
      "m = F*Rho_H2O\n",
      "A1 = pi*d1**2/4\n",
      "A2 = pi*d2**2/4\n",
      "v1 = F/A1\n",
      "v2 = F/A2\n",
      "P1 = Rho_H2O*((v2**2 - v1**2)/2 + P2/Rho_H2O)\n",
      "Rx = m*(v2-v1) + P2*A2 - P1*A1\n",
      "#Result\n",
      "print \"The resultant force on the nozzle is\",round(Rx,1), \"N\"\n",
      "print 'The answer is correct because of book uses rounded numbers'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The resultant force on the nozzle is -2425.3 N\n",
        "The answer is correct because of book uses rounded numbers\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.8-5, Page number 76"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Force of Free Jet on a Curved,Fixed Vane\n",
      "from math import pi\n",
      "\n",
      "#Variable Declaration\n",
      "V = 30.5            #Velocity of jet stream of water (m/s)\n",
      "Rho_H2O = 1000.     #Density of water (kg/m3)\n",
      "d = 2.54e-2         #Diameter of pipe, m\n",
      "alpha = 60          #Angle made by exit stream, deg\n",
      "\n",
      "A = pi*d**2/4\n",
      "m = V*A*Rho_H2O \n",
      "#Calculation\n",
      "#Rx is the x component of the force\n",
      "    #Rx = m*V*(cos60 - 1)\n",
      "Rx = m*V*(cos(alpha*pi/180)-1)\n",
      "#Ry is the y component of the force\n",
      "    #Ry = m*V*(sin60)\n",
      "Ry = m*V*sin(alpha*pi/180)\n",
      "#Result\n",
      "print \"The force in x direction is \",round(-Rx,1),\"N\"\n",
      "print \"The force in y direction is \",round(-Ry,1),\"N\"\n",
      "print 'The answers are correct because of book uses rounded numbers'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The force in x direction is  235.7 N\n",
        "The force in y direction is  -408.2 N\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.9-1, Page number 82"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Falling Film Velocity and Thickness\n",
      "#Variable Declaration\n",
      "d = 0.0017          #Thickness of the film (m)\n",
      "Rho_oil = 820       #Density of oil (kg/m3)\n",
      "mu = 0.20            #Viscosity of oil (Pa.s)\n",
      "g = 9.806           #Gravitational acceleration (m/s2)\n",
      "\n",
      "#Calculation\n",
      "Gama = Rho_oil*Rho_oil*d**3*g/(3*mu)\n",
      "Nre = 4*Gama/mu\n",
      "Vz = Rho_oil*g*d**2/(3*mu)\n",
      "\n",
      "#Result\n",
      "print \"The mass flowrate per unit width of the wall\",round(Gama,6),\"kg/s.m\"\n",
      "print \"Reynolds number is\",round(Nre,3)\n",
      "print \"The average velocity is\",round(Vz,6),\"m/s\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The mass flowrate of the wall 0.05399 kg/s.m\n",
        "Reynolds number is 1.08\n",
        "The average velocity is 0.03873 m/s\n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.10-1, Page number 85"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Metering of Small Liquid flows \n",
      "from math import pi\n",
      "#Variable Declaration\n",
      "\n",
      "d = 0.00222          #Diameter of capillary (m)\n",
      "l = 0.317            #Length of capillary (m)\n",
      "Rho = 875            #Density of liquid (kg/m3)\n",
      "mu = 0.00113         #Viscosity of liquid (pa.s)\n",
      "h = 0.0655           #Heightof water (m)\n",
      "Rho_H2O = 996        #Density of water (kg/m3)\n",
      "g = 9.80665          #Gravitational acceleration (m/s2)\n",
      "\n",
      "#Calculation\n",
      "delP = h*Rho_H2O*g\n",
      "    #v = delP*d*d/(32*mu*l)\n",
      "    #Flow assumed to be laminar\n",
      "v = delP*d**2/(32*mu*l)\n",
      "F = v*pi*d**2/(4)\n",
      "    #Checking whether the flow is laminar\n",
      "Nre = d*v*Rho/(mu)\n",
      "#Result\n",
      "print 'The pressure drop over capillary is %3.0f N/m2'%(delP)\n",
      "print 'The velocity through capillary is %4.3f m/s'%(v)\n",
      "print 'The mass flowrate through the capillary is %5.3e m3/s'%(F)\n",
      "print 'Reynolds number is %3.0f, Hence flow is laminar'%(Nre)\n",
      "print 'The answers are correct because of book uses rounded numbers'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The pressure drop over capillary is 640 N/m2\n",
        "The velocity through capillary is 0.275 m/s\n",
        "The mass flowrate through the capillary is 1.065e-06 m3/s\n",
        "Reynolds number is 473, Hence flow is laminar\n",
        "The answers are correct because of book uses rounded numbers\n"
       ]
      }
     ],
     "prompt_number": 20
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.10-2, Page number  87"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Use of Friction Factor in Laminar Flow  \n",
      " \n",
      "#Variable Declaration\n",
      "d = 0.00222          #Diameter of capillary (m)\n",
      "l = 0.317            #Length of capillary (m)\n",
      "V = 0.275            #Velocity of liquid (m/s)\n",
      "Rho = 875            #Density of liquid (kg/m3)\n",
      "mu = 0.00113         #Viscosity of liquid (pa.s)\n",
      "h = 0.0655           #Heightof water (m)\n",
      "Rho_H2O = 996        #Density of water (kg/m3)\n",
      "g = 9.80665          #Gravitational acceleration (m/s2)\n",
      "#Calculation\n",
      "Nre = d*V*Rho/(mu)\n",
      "    #f = 16/Nre\n",
      "f = 16/Nre\n",
      "    #delp = 4*f*Rho*l*V*V/(2*D)\n",
      "delp = 4*f*Rho*l*V**2/(2*d)\n",
      "#Result\n",
      "print 'Reynolds number is %3.0f, Hence flow is laminar'%(Nre)\n",
      "print 'friction factor is %0.4f'%(f)\n",
      "print 'The pressure drop through capillary is %3.0f N/m2'%(delp)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Reynolds number is 473, Hence flow is laminar\n",
        "friction factor is 0.0338\n",
        "The pressure drop through capillary is 640 N/m2\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.10-3, Page number  89"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Use of Friction Factor in Turbulent Flow  \n",
      "\n",
      "#Variable Declaration\n",
      "d = 0.0525           #Diameter of capillary (m)\n",
      "l = 36.6             #Length of capillary (m)\n",
      "V = 4.57             #Velocity of liquid (m/s)\n",
      "Rho = 801.           #Density of liquid (kg/m3)\n",
      "mu = 4.46            #Viscosity of liquid (cp)\n",
      "g = 9.806            #Gravitational acceleration (m/s2)\n",
      "e = 0.000046         #Equvivalent Roughness (m)\n",
      "f = 0.0060           #Friction factor \n",
      "#Calculation\n",
      "mu = mu*1e-3         #Convert Viscosity to  (kg/m.s)\n",
      "Nre = d*V*Rho/(mu)\n",
      "    #delp = 4*f*Rho*l*V*V/(2*D)\n",
      "delp = 4*f*Rho*l*V**2/(2*d)\n",
      "    #F = 4*f*l*V*V/(2*d)\n",
      "F = 4*f*l*V**2/(2*d)\n",
      "#Result\n",
      "print 'Reynolds number is %3.0f, Hence flow is turbulent'%(Nre)\n",
      "print 'friction factor from chart is %0.4f'%(f)\n",
      "print \"The friction loss is %3.1f J/kg\" %(F)\n",
      "print 'The answers are correct because of book uses rounded numbers, and varified using calculator'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Reynolds number is 43090, Hence flow is turbulent\n",
        "friction factor from chart is 0.0060\n",
        "The friction loss is 174.7 J/kg\n",
        "The answers are correct because of book uses rounded numbers, and varified using calculator\n"
       ]
      }
     ],
     "prompt_number": 22
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.10-4, Page number 90"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Trial and Error Solution to Calculate Pipe Diameter\n",
      "from scipy.optimize import root\n",
      "from sympy import *\n",
      "from math import pi, log\n",
      "\n",
      "#Variable Declaration\n",
      "l = 305.              #Length of steel pipe (m)\n",
      "mu = 1.55e-3          #Viscosity of fluid (kg/m.s)\n",
      "Q = 150.0             #Rate of flow of fluid (gal/min)\n",
      "g = 9.80665           #Gravitational acceleration, m/s2\n",
      "ep = 4.6e-5           #Roughness of commercial steel pipe, m\n",
      "rho = 1000.           #Density of water, kg/m3\n",
      "z = 6.1               #Head available, m\n",
      "\n",
      "#Calculation\n",
      "Qsi = Q*(1./7.481)*(1./60)*0.02831      #Multipliers in equation are conversion factors for conversion to SI Units\n",
      "Ff = z*g\n",
      "er = 12.\n",
      "x = Symbol('x')\n",
      "D = 0.089\n",
      "while er >= 0.01:\n",
      "    epbyd = ep/D\n",
      "    A = pi*D**2/4.\n",
      "    u = Qsi/A \n",
      "    Re = D*u*rho/mu\n",
      "    sol = solve(1/sqrt(x)+4*(log(epbyd/3.7,10)+1.255/(Re*sqrt(x))),x)\n",
      "    f = sol[0]\n",
      "    d = 4*f*l*u**2/(2*Ff)\n",
      "    er = abs((D-d)/D)\n",
      "    if er > 0.01:\n",
      "        print 'Error %6.5f and diameter calculated %6.5f'%(er, d)\n",
      "        D = float(raw_input(\"Not Converged...:Enter the value of guess diameter  \"))\n",
      "#Result\n",
      "print '\\nConverged...Diameter of the pipe is %4.3f m or %4.3f in'%(D,D*12./0.3048)\n",
      "print 'The value calculated is accurate than answer in book\\nbecause book reads the friction factor from chart whereas\\nequations for friction factor are used in this'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Error 0.11457 and diameter calculated 0.09920\n"
       ]
      },
      {
       "name": "stdout",
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Not Converged...:Enter the value of guess diameter  0.092\n"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Error 0.06269 and diameter calculated 0.08623\n"
       ]
      },
      {
       "name": "stdout",
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Not Converged...:Enter the value of guess diameter  0.093\n"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Error 0.11416 and diameter calculated 0.08238\n"
       ]
      },
      {
       "name": "stdout",
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Not Converged...:Enter the value of guess diameter  0.094\n"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Error 0.16230 and diameter calculated 0.07874\n"
       ]
      },
      {
       "name": "stdout",
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Not Converged...:Enter the value of guess diameter  0.094\n"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Error 0.16230 and diameter calculated 0.07874\n"
       ]
      },
      {
       "name": "stdout",
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Not Converged...:Enter the value of guess diameter  0.098\n"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Error 0.32616 and diameter calculated 0.06604\n"
       ]
      },
      {
       "name": "stdout",
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Not Converged...:Enter the value of guess diameter  0.099\n"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Error 0.36096 and diameter calculated 0.06327\n"
       ]
      },
      {
       "name": "stdout",
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Not Converged...:Enter the value of guess diameter  0.1\n"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Error 0.39363 and diameter calculated 0.06064\n"
       ]
      },
      {
       "name": "stdout",
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Not Converged...:Enter the value of guess diameter  0.14\n"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Error 0.89524 and diameter calculated 0.01467\n"
       ]
      },
      {
       "name": "stdout",
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Not Converged...:Enter the value of guess diameter  0.15\n"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Error 0.92689 and diameter calculated 0.01097\n"
       ]
      },
      {
       "name": "stdout",
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Not Converged...:Enter the value of guess diameter  0.16\n"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Error 0.94777 and diameter calculated 0.00836\n"
       ]
      },
      {
       "name": "stdout",
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Not Converged...:Enter the value of guess diameter  0.091\n"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "Converged...Diameter of the pipe is 0.091 m or 3.583 in\n",
        "The value calculated is accurate than answer in book\n",
        "because book reads the friction factor from chart whereas\n",
        "equations for friction factor are used in this\n"
       ]
      }
     ],
     "prompt_number": 33
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.10-5, Page number  91 "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Flow of Gas in Line and Pressure Drop \n",
      "#Variable Declaration\n",
      "d = 0.010             #Inside diameter of tube (m)\n",
      "G = 9.                #Rate of feed (kg/s.m2)\n",
      "l = 200.              #Length of Tube (m)\n",
      "mu = 0.0000177        #Viscosity of liquid (Pa.s)\n",
      "R = 8314.3            #Gas constant (J/kg.mol.K)\n",
      "P1 = 202650.          #Pressure at entrance (Pa)\n",
      "f = 0.0090            #Friction factor \n",
      "T1 = 25.              #Temperature at inlet (degC)\n",
      "T2 = 298.15           #Temperature at outlet (degC)\n",
      "M = 28.02             #Molecular weight of 1 kmol N2  (kmol)\n",
      "#Calculation\n",
      "Nre = d*G/mu\n",
      "f = 0.079*Nre**(-0.25)   #for smooth pipes\n",
      "P2 = sqrt(P1**(2) - 4*f*l*G**2*R*T2/(d*M))\n",
      "   \n",
      "#Result\n",
      "print \"for Reynolds Number \", round(Nre,2), \"friction factor for smooth pipe is\", round(f,6)\n",
      "print 'The pressure at outlet %6.4e Pa, '%(P2)\n",
      "print 'The answer is correct than the book because of book uses rounded numbers'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "for Reynolds Number  5084.75 friction factor for smooth pipe is 0.009355\n",
        "The pressure at outlet 1.8895e+05 Pa, \n",
        "The answer is correct than the book because of book uses rounded numbers\n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.10-6, Page number  94"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Friction Losses and mechanical energy balance\n",
      "#Variable Declaration\n",
      "Q = 0.223                 #Desired flowrate of water (ft3/s)\n",
      "Rho_fps = 60.52           #Density of water in fps units (lbm/m3)\n",
      "u_fps = 0.000233          #Viscosity of water in fps units (lbm/ft.s)\n",
      "D3 = 0.3353               #Diameter of the third pipe (ft)\n",
      "D4 = 0.1722               #Diameter of the third pipe (ft)\n",
      "A3 = 0.0884               #Area of third pipe (ft2)\n",
      "A4 = 0.0233               #Area of third pipe (ft2)\n",
      "g_fps = 32.174            #Gravitational acceleration in fps units (ft/s2)\n",
      "e = 0.00015               #Roughness factor (ft)\n",
      "f2 = 0.0047               #Fanning friction factor for 4-in pipe\n",
      "f5 = 0.0048               #Fanning friction factor for 2-in pipe\n",
      "delL_4 = 20.              #Length of 4-in pipe (ft)\n",
      "delL_2 = 185.             #Length of 2-in pipe (ft)\n",
      "delP = 0.                 #Since pressure at both end is atmspheric pressure \n",
      "Kf = 0.75\n",
      "alpha = 1.\n",
      "Ws = 0.                   #Shaft work (j)\n",
      "#Calculation\n",
      "V1 = 0.\n",
      "V3 = Q/A3\n",
      "V4 = Q/A4\n",
      "    #\n",
      "    #(1) Contraction losses at tank exit\n",
      "#Kc = 0.55*(1-A3/A1)\n",
      "Kc1 = 0.55\n",
      "hc1 = Kc1*V3**2/(2*g_fps)\n",
      "    #(2) Friction in 4-in pipe \n",
      "Nre2 = D3*V3*Rho_fps/(u_fps)\n",
      "F2 = 4*f2*delL_4*V3**2/(D3*2*g_fps)\n",
      "    #(3) Friction in 4-in elbow\n",
      "hf = Kf*V3**2/(2*g_fps)\n",
      "    #(4) Contraction loss from 4-in to 2-in pipe \n",
      "Kc4 = 0.55*(1-A4/A3)\n",
      "hc4 = Kc4*V4**2/(2*g_fps)\n",
      "    #(5)Friction in 2-in pipe \n",
      "Nre5 = D4*V4*Rho_fps/u_fps\n",
      "F5 = 4*f5*delL_2*V4**2/(D4*2*g_fps)\n",
      "    #(6) Friction in 2-in elbows\n",
      "hc6 = 2*Kf*V4**2/(2*g_fps)\n",
      "    #F = hc1 + F2 + hf + hc4 + F5 + hc6\n",
      "F = hc1 + F2 + hf + hc4 + F5 + hc6\n",
      "    #delH*g_fps = delP/Rho_fps + (V4**2 - V1**2)/(2*alpha*g_fps) + Ws + F\n",
      "    #delH = (delP/Rho_fps + (V4**2 - V1**2)/(2*alpha*g_fps) + Ws + F)/g_fps\n",
      "delH = (delP/Rho_fps + (V4**2 - V1**2)/(2*alpha*g_fps) + Ws + F) \n",
      "#Result\n",
      "print \"The height of water level above the discharge outlet \",round(delH,2),\"ft\"\n",
      "print 'The answer is correct because of book uses rounded numbers'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The height of water level above the discharge outlet  33.74 ft\n",
        "The answer is correct because of book uses rounded numbers\n"
       ]
      }
     ],
     "prompt_number": 24
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.10-7, Page number  97"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Friction Losses with pump in mechanical energy balance\n",
      "#Variable Declaration\n",
      "Q = 0.005                 #Desired flowrate of water (m3/s)\n",
      "Rho = 998.2               #Density of water in fps units (kg/m3)\n",
      "u = 0.001005              #Viscosity of water in fps units (Pa/s)\n",
      "D1 = 0.1023               #Diameter of the third pipe (m)\n",
      "A1 = 0.008291             #Area of pipe (m2)\n",
      "g = 9.806                 #Gravitational acceleration in fps units (ft/s2)\n",
      "e = 0.000046              #Roughness factor (ft)\n",
      "f2 = 0.0051               #Fanning friction factor for 4-in pipe\n",
      "z1 = 0.                   #Height of storage tank (m)\n",
      "z2 = 15.                  #Height of elevated tank (m)\n",
      "delL = 170.               #Length of 4-in pipe (ft)\n",
      "delL_2 = 185.             #Length of 2-in pipe (ft)\n",
      "delP = 0.                 #Since pressure at both end is atmospheric pressure \n",
      "delV2 = 0.\n",
      "Kf = 0.75\n",
      "Kex = 1.             \n",
      "alpha = 1.\n",
      "n = .65                   #Efficiency of the pump\n",
      "#Calculation\n",
      "V1 = Q/A1\n",
      "Nre = D1*V1*Rho/(u)\n",
      "    \n",
      "    #(1) Contraction losses at tank exit\n",
      "#Kc = 0.55*(1-A3/A1)\n",
      "Kc1 = 0.55\n",
      "hc1 = Kc1*V1**2/(2*alpha)\n",
      "    #(2) Friction in straight pipe \n",
      "\n",
      "F2 = 4*f2*delL*V1**2/(D1*2)\n",
      "    #(3) Friction in the two elbows\n",
      "hf = 2*V1**2/(2)\n",
      "    #(4) Expansion loss at tank entrance\n",
      "hc4 = Kex*V1**2/(2)\n",
      "    #F = hc1 + F2 + hf + hc4 \n",
      "F = hc1 + F2 + hf + hc4\n",
      "    #1*(delV2)/(2*alpha) + g*(z2 - z1) +delP/Rho + F + Ws = 0.\n",
      "Ws = -(1*(delV2)/(2*alpha) + g*(z2 - z1) +delP/Rho + F)\n",
      "    #m = Q*Rho\n",
      "m = Q*Rho\n",
      "    #Ws = -n*Wp\n",
      "Wp = Ws/-n\n",
      "    #P = m*Wp\n",
      "P = m*Wp/1000\n",
      "#Result\n",
      "print \"The power required by the pump is \",round(P,3),\"kW\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The power required by the pump is  1.182 kW\n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.10-8, Page number  100"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Entry Length for a Fluid in a Pipe \n",
      "#Variable Declaration\n",
      "d = 0.010                #Diameter of tube (m)\n",
      "V = 0.10                 #Velocity of water (m/s)\n",
      "mu = 0.001005             #Viscosity of water (Pa.s)\n",
      "Rho = 998.2              #Density of water (kg/m3)\n",
      "#Calculation\n",
      "Nre = d*V*Rho/mu\n",
      "    #For laminar flow \n",
      "    #Le = 0.0575*Nre\n",
      "\n",
      "Le_l = 0.0575*Nre*d\n",
      "Le_t = 50*d  \n",
      "#Result\n",
      "print \"Reynolds Number is\",round(Nre,1)\n",
      "print \"For laminar flow the entry length is \",round(Le_l,3),\"m\"\n",
      "print \"For turbulent flow the entry length is \",round(Le_t,4),\"m\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Reynolds Number is 993.2\n",
        "For laminar flow the entry length is  0.571 m\n",
        "For turbulent flow the entry length is  0.5 m\n"
       ]
      }
     ],
     "prompt_number": 25
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.11-1, Page number  102"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Compressible Flow of a gas in a pipe line\n",
      "from math import log, pi\n",
      "#Variable Declaration\n",
      "d = 1.016                #Diameter of pipe (m)\n",
      "G = 2.077                #The molar flow rate of the gas (kg mol/s)\n",
      "mu = 1.04e-5             #Viscosity of methane at 288.8 k (Pa.s)   \n",
      "p2 = 170.3e3             #The pressure at the outlet (Pa)\n",
      "L = 1.609e5              #The length of the pipe (m) \n",
      "R = 8314.34              #Gas constant (N.m/kg.mol.K)\n",
      "T = 288.8                #Temperature of methane gas (K)\n",
      "M = 16.                  #Molecular weight of methane \n",
      "epsilon = 4.6e-5         #Pipe roughness\n",
      "\n",
      "#Calculation\n",
      "A = pi*d**2/4\n",
      "Gm = G*M/A\n",
      "Nre = d*Gm/mu\n",
      "f = 0.0027        #from friction factor chart\n",
      "     #P1**2 - P2**2 = (4*f*L*(G_mass**2)*R*T)/(D*M) + (2*(G**2)*R*T*log(p1/P2)/16)\n",
      "     #P1 = sqrt(P2**2 + (4*f*L*(G_mass**2)*R*T)/(D*M) + (2*(G**2)*R*T*log(p1/P2)/16))\n",
      "er = 1.2\n",
      "p1 = 500.e3\n",
      "while er>0.001:\n",
      "    p1c = sqrt(p2**2 + 4*f*L*Gm**2*R*T/(d*M) + (2*Gm**2*R*T*log(p1/p2)/M))\n",
      "    er = abs(p1-p1c)/p1c\n",
      "    p1 = p1c\n",
      "#Result\n",
      "print 'The final pressure is %10.4e Pa.'%(p1)\n",
      "print 'The answers are correct because of book uses rounded of numbers'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The final pressure is 6.7895e+05 Pa.\n",
        "The answers are correct because of book uses rounded of numbers\n"
       ]
      }
     ],
     "prompt_number": 26
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.11-2, Page number  103"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Maximum Flow for Compressible Flow of a Gas\n",
      "#Variable Declaration\n",
      "R = 8314.              #Gas constant ()\n",
      "T = 288.8              #Temperature of fluid (K)\n",
      "M = 16.\n",
      "P2 = 170300.           #Pressure at discharge tube (Pa)\n",
      "G = 41.          \n",
      "#Calculation\n",
      "Vmax = sqrt(R*T/M)\n",
      "V2 = R*T*G/(P2*M)\n",
      "#Result\n",
      "print \"The maximum velocity in the tube  is \",round(Vmax,1),\"m/s\"\n",
      "print \"The actual velocity is \",round(V2,2),\"m/s\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The maximum velocity in the tube  is  387.4 m/s\n",
        "The actual velocity is  36.13 m/s\n"
       ]
      }
     ]
    }
   ],
   "metadata": {}
  }
 ]
}