summaryrefslogtreecommitdiff
path: root/Practical_C_Programming/Chapter_2_3.ipynb
blob: f981ce8e878ad188f17e0e55d2637838e824ae06 (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
{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 2:. Convective Mass Transfer"
     ]
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 2.1,Page number94"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Illustration 2.1\n",
      "#Mass-Transfer Coefficients in a Blood Oxygenator\n",
      "\n",
      "#Variable declaration\n",
      "\n",
      "\t# a-oxygen   b-stagnant water\n",
      "T = 310  \t\t\t\t\t# [K]\n",
      "\t# Since the solubility of oxygen in water at 310 K is extremely low, we are dealing with \tdilute solutions\n",
      "k_L = 3.3*10**-5  \t\t\t\t# [coefficient based on the oxygen concentration \t\t\t\t\t\tdifference in the water, m/s]\n",
      "row = 993  \t\t\t\t\t# [kg/cubic m]\n",
      "M_b = 18  \t\t\t\t\t# [gram/mole]\n",
      "\n",
      "\n",
      "#Calculation\n",
      " \n",
      "\t# Since we are dealing with very dilute solutions\n",
      "\t# Therefore, c = (row/M_avg) = row/M_b\n",
      "c = row/M_b  \t\t\t\t\t# [kmole/cubic m]\n",
      "\t# Using equation 2.10\n",
      "k_x = k_L*c  \t\t\t\t\t# [kmole/square m.s]\n",
      "\n",
      "#Result\n",
      "\n",
      "print\"The mass-transfer coefficient based on the mole fraction of oxygen in the liquid is\",round(k_x,5),\" kmole/square m.s\" \n",
      "\n",
      " "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The mass-transfer coefficient based on the mole fraction of oxygen in the liquid is 0.00182  kmole/square m.s\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 2.2,Page number:95"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Illustration 2.2\n",
      "#Mass-Transfer Coefficient in a Gas Absorber\n",
      "\n",
      "#Variable declaration\n",
      "\n",
      "\t#  a-ammonia   b-air\n",
      "T = 300  \t\t\t\t\t# [K]\n",
      "P = 1  \t\t\t\t\t\t# [atm]\n",
      "y_a1 = 0.8  \t\t\t\t\t# [ammonia mole fraction in the bulk of the gas \t\t\t\t\t\t\tphase]\n",
      "y_a2 = 0.732  \t\t\t\t\t# [ammonia gas-phase mole fraction on interface]\n",
      "N_a = 4.3*10**-4  \t\t\t\t# [ammonia flux,  kmole/square m.s]\n",
      "\n",
      "#Calculations\n",
      "\n",
      "import math\n",
      "\t# Using equation 2.2\n",
      "F_g = N_a/math.log10((1-y_a2)/(1-y_a1))  \t\t# [kmole/square m.s]\n",
      "\n",
      "#Result\n",
      "\n",
      "print\"The mass-transfer coefficient in the gas phase at that point where flux is 4.3*10**-4 is\",round(F_g,5),\" kmole/square m.s\"\n",
      "print\"\\n\\nNOTE:Calculation mistake in book:\\nAnswer written as 1.47*10^-4,Actually,,...it is 1.47*10^-3.Please REDO last calculation manually to check\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The mass-transfer coefficient in the gas phase at that point where flux is 4.3*10**-4 is 0.00338  kmole/square m.s\n",
        "\n",
        "\n",
        "NOTE:Calculation mistake in book:\n",
        "Answer written as 1.47*10^-4,Actually,,...it is 1.47*10^-3.Please REDO last calculation manually to check\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 2.3,Page number:96"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Illustration 2.3\n",
      "#Mass-Transfer Coefficient in a Packed-Bed Distillation Column\n",
      "\n",
      "#Variable declaration\n",
      "\n",
      "\t\t# a-methanol   b-water\n",
      "P = 101.3  \t\t\t\t\t\t# [kPa]\n",
      "y_a1 = 0.707  \t\t\t\t\t\t# [mole fraction at interface]\n",
      "y_a2 = 0.656  \t\t\t\t\t\t# [mole fraction at bulk of the gas]\n",
      "k_g = 1.62*10**-5  \t\t\t\t\t# [mass-transfer coefficient at a point \t\t\t\t\t\t\t in the column, kmole/square m.s.kPa]\n",
      "#Calculations\n",
      "\n",
      "\t# Using equation 2.14\n",
      "k_y = k_g*P  \t\t\t\t\t\t# [kmole/square m.s]\n",
      "\t# Using equation 2.12\n",
      "N_a = k_y*(y_a1-y_a2)  \t\t\t\t\t# [kmole/square m.s]\n",
      "\n",
      "#Result\n",
      "\n",
      "print\"The methanol flux at the point of given mass transfer coefficient is\",round(N_a,7),\"kmole/square m.s\" \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The methanol flux at the point of given mass transfer coefficient is 8.37e-05 kmole/square m.s\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 2.4,Page number:99"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Illustration 2.4\n",
      "# Mass Transfer into a Dilute Stream Flowing Under Forced Convection in a Circular Conduit\n",
      "\n",
      "n = 6  # [number of variables]\n",
      "\n",
      "#Calculations\n",
      "\n",
      "from scipy.optimize import fsolve\n",
      "from numpy import *\n",
      "import math\n",
      "# To determine the number of dimensionless parameters to be formed, we must know the rank, r, of the dimensional matrix.\n",
      "# The dimensional matrix is \n",
      "DM =matrix([[0,0,1,1,0,0],[1,1,-3,-1,2,1],[-1,-1,0,0,-1,-1]]) \n",
      "rk= linalg.matrix_rank(DM)\n",
      "print\"Rank of matrix is \",rk \n",
      "\n",
      "#The numbers in the table represent the exponent of M, L, and t in the dimensional expression of each of the six variables involved. For example, the dimensional expression of p is M/Lt  hence the exponents are 1, -1, and -1\n",
      "\n",
      "# From equation 2.16\n",
      "i = n-rk  # [number of dimensional groups]\n",
      "# Let the dimensional groups are pi1, pi2 and pi3\n",
      "# Therefore pi1 = (D_AB)**a*(row)**b*(D)**c*kc\n",
      "#           pi2 = (D_AB)**d*(row)**e*(D)**f*v\n",
      "#           pi3 = (D_AB)**g*(row)**h*(D)**i*u\n",
      "\n",
      "# Solving for pi1\n",
      "# M**0*L**0*t**0 = 1 = (L**2/t)**a*(M/L**3)**b*(L)**c*(L/t)\n",
      "\n",
      "# Solution of simultaneous equation\n",
      "def F(e):\n",
      "    f1 = 2*e[0]-3*e[1]+e[2]+1 \n",
      "    f2 = -e[0]-1 \n",
      "    f3 = -e[1] \n",
      "    return(f1,f2,f3)\n",
      "\n",
      "\n",
      "# Initial guess:\n",
      "e = [0.1,0.8,0.5] \n",
      "y = fsolve(F,e) \n",
      "a = y[0] \n",
      "b = y[1] \n",
      "c = y[2] \n",
      "print\"The coefficients of pi1 are\",a,round(b),c \n",
      "# Similarly the coefficients of pi2 and pi3 are calculated\n",
      "# Therefore we get pi1 = kc*D/D_AB = Sh i.e. Sherwood Number\n",
      "#                  pi2 = v*D/D_AB = P_ed i.e. Peclet Number\n",
      "#                  pi3 = u/(row*D_AB) = Sc i.e. Schmidt Number\n",
      "\n",
      "# Dividing pi2 by pi3 gives\n",
      "#       pi2/pi3 = D*v*row/u = Re i.e. Renoylds number\n",
      "\n",
      "print\"The result of the dimensional analysis of forced-convection mass transfer in a circular conduit indicates that a correlating relation could be of the form\\n Sh = function(Re,Sc)\\n which is analogous to the heat transfer correlation \\n Nu = function(Re,Pr)\" "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Rank of matrix is  3\n",
        "The coefficients of pi1 are -1.0 0.0 1.0\n",
        "The result of the dimensional analysis of forced-convection mass transfer in a circular conduit indicates that a correlating relation could be of the form\n",
        " Sh = function(Re,Sc)\n",
        " which is analogous to the heat transfer correlation \n",
        " Nu = function(Re,Pr)\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 2.6,Page number:111"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Illustration 2.6\n",
      "#Mass Transfer to Fluid Flow Normal to a Cylinder\n",
      "\n",
      "#Variable declaration\n",
      "\t# a-UF6    b-air\n",
      "M_a = 352  \t\t\t\t\t# [molecular weight of UF6, gram/mole]\n",
      "M_b = 29  \t\t\t\t\t# [gram/mole]\n",
      "d = 0.01  \t\t\t\t\t# [diameter, m]\n",
      "x = 0.1  \t\t\t\t\t# [length exposed to air stream, m]\n",
      "v = 1  \t\t\t\t\t\t# [m/s]\n",
      "Ts = 303  \t\t\t\t\t# [surface temperature of solid, K]\n",
      "P_a = 27  \t\t\t\t\t# [vapor pressure of UF6, kPa]\n",
      "Tb = 325  \t\t\t\t\t# [bulk temperature of solid ,K]\n",
      "P = 101.3  \t\t\t\t\t# [kPa]\n",
      "R = 8.314  \t\t\t\t\t# [cubic m.Pa/mole.K]\n",
      "import math\n",
      "\n",
      "y_a1 = P_a/P  \t\t\t\t\t# [mole fraction at point 1]\n",
      "y_a2 = 0  \t\t\t\t\t# [mole fraction at point 2]\n",
      "\n",
      "\t# Along the mass-transfer path-cylinder surface (point 1) to bulk air (point 2)\n",
      "Tavg = (Ts+Tb)/2  \t\t\t\t# [K]\n",
      "\n",
      "\t# At point 1, the gas is saturated with UF6 vapor, while at point 2 the gas is virtually \tfree of UF6\n",
      "\t# Therefore\n",
      "Pavg = (P_a+0)/2  \t\t\t\t# [average partial pressure, kPa]\n",
      "y_a = Pavg/P  \t\t\t\t\t# [mole fraction of UF6]\n",
      "\n",
      "Mavg = M_a*y_a+M_b*(1-y_a)  \t\t\t# [gram/mole]\n",
      "row_avg = P*Mavg/(R*Tavg)  \t\t\t# [kg/cubic m]\n",
      "\n",
      "\t# Parameter for c-O2, d-N2 and a-UF6\n",
      "yi_c = 0.182 \n",
      "yi_d = 0.685   \n",
      "yi_a = 0.133  \n",
      "Tc_c = 154.6    \t\t\t\t# [K]\n",
      "Tc_d = 126.2   \t\t\t\t\t# [K]\n",
      "Tc_a = 505.8  \t\t\t\t\t# [K]\n",
      "Pc_c = 50.4    \t\t\t\t\t# [bar]\n",
      "Pc_d = 33.9   \t\t\t\t\t# [bar] \n",
      "Pc_a = 46.6   \t\t\t\t\t# [bar]\n",
      "M_c = 32        \t\t\t\t# [gram/mole]\n",
      "M_d  = 28    \t\t\t\t\t# [gram/mole]   \n",
      "M_a  = 352   \t\t\t\t\t# [gram/mole]\n",
      "V_c = 73.4      \t\t\t\t# [cubic cm/mole]\n",
      "V_d  = 89.8   \t\t\t\t\t# [cubic cm/mole]\n",
      "V_a  = 250  \t\t\t\t\t# [cubic cm/mole]\n",
      "Z_c = 0.288     \n",
      "Z_d  = 0.290   \n",
      "Z_a  = 0.277 \n",
      "\n",
      "#Calculations\n",
      "\n",
      "\n",
      "\t# From equation 2.52 and 2.53\n",
      "Tcm = yi_c*Tc_c+yi_d*Tc_d+yi_a*Tc_a  \t\t# [K]\n",
      "Pcm = 10**6*R*Tcm*(yi_c*Z_c+yi_d*Z_d+yi_a*Z_a)/((yi_c*V_c+yi_d*V_d+yi_a*V_a)*100000)  \t# [bar]\n",
      "M_avg = yi_c*M_c+yi_d*M_d+yi_a*M_a  \t\t# [gram/mole]\n",
      "\n",
      "\t# From equation 2.50\n",
      "Em =  0.176*(Tcm/(M_avg**3*Pcm**4))**(1.0/6.0)  \t# [uP]**-1\n",
      "\n",
      "\t# From equation 2.51\n",
      "Trm = Tavg/Tcm \n",
      "f_Trm = (0.807*Trm**0.618)-(0.357*math.exp(-0.449*Trm))+(0.340*math.exp(-4.058*Trm))+0.018  \n",
      "\t# From equation 2.49 \n",
      "u = f_Trm/Em  \t\t\t\t\t\t# [uP]\n",
      "u = u*10**-7  \t\t\t\t\t\t# [viscosity, kg/m.s]\n",
      "\n",
      "Re = d*v*row_avg/u  \t\t\t\t\t# [Renoylds number]\n",
      "\n",
      "\t\t# Diffusivity of UF6 vapors in air at 314 K and 1 atm from equation 1.49\n",
      "D_ab = 0.0904  \t\t\t\t\t\t# [square cm/s]\n",
      "\n",
      "Sc = u/(row_avg*D_ab*10**-4)  \t\t\t\t# [Schmidt number]\n",
      "\n",
      "Sh_avg = 0.43 + 0.532*Re**0.5*Sc**0.31  \t\t# [Sherwood number]\n",
      "\t\t# From equation 1.7\n",
      "c = P/(R*Tavg)  \t\t\t\t\t# [kmole/cubic m]\n",
      "\t\t# From Table 2.1 \n",
      "F_av = Sh_avg*D_ab*c*10**-4/d  \t\t\t\t# [kmole/square m.s]\n",
      "\n",
      "\t\t# From equation 2.2\n",
      "N_avg = F_av*math.log((1-y_a2)/(1-y_a1))  \t\t# [kmole/square m.s]\n",
      "S = 2*math.pi*d**2/4 +math.pi*d*x  \t\t\t# [total surface area of the cylinder, \t\t\t\t\t\t\tsquare m]\n",
      "\n",
      "w_a = N_avg*S*M_a  \t\t\t\t\t# [rate of sublimation of the solid, \t\t\t\t\t\t\tkg/s] \n",
      "\n",
      "#Result\n",
      "print\"Rate of sublimation of a cylinder of UF6 is\",round(w_a,5),\"kg/s\\n\\n\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Rate of sublimation of a cylinder of UF6 is 0.00023 kg/s\n",
        "\n",
        "\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 2.7,Page number:116"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Illustration 2.7\n",
      "#  The Chilton-Colburn Analogy\n",
      "import math\n",
      "#Variable declaration\n",
      "\n",
      "\t# a-benzene      b-nitrogen\n",
      "T = 300  \t\t\t\t\t# [K]\n",
      "P = 101.3  \t\t\t\t\t# [kPa]\n",
      "v =10  \t\t\t\t\t\t# [m/s]\n",
      "R = 8.314  \t\t\t\t\t# [cubic m.Pa/mole.K]\n",
      "\n",
      "\n",
      "n = -0.5 \n",
      "\t# Data on the properties of C02 at 300 K and 1 bar\n",
      "u = 1.5*10**-5  \t\t\t\t# [viscosity, P]\n",
      "Pr = 0.77  \t\t\t\t\t# [Prandtl number]\n",
      "Cp = 853  \t\t\t\t\t# [J/kg.K]\n",
      "\t# Therefore\n",
      "\t# b = 5.086*l**0.5\n",
      "\t#           j_D = j_H = f(Re) = 5.086*(l**0.5)*Re**-0.5\n",
      "\t# From Table 2.1\n",
      "\t#           F = j_D*c*v/Sc**(2/3) = 5.086*(l**0.5)*c*v/(Re**0.5*Sc**(2/3)) = \t\t5.086*(row*v*u)**0.5/(Mavg*Sc**(2.0/3.0))\n",
      "\n",
      "#Calculations\n",
      "\n",
      "\t# Vapor pressure of benzene\n",
      "P_a = math.exp(15.9008-(2788.51/(T-52.36)))  \t# [mm of Hg]\n",
      "P_a = P_a*101.3/760  \t\t\t\t\t# [kPa]\n",
      "\n",
      "\t# Parameter for a-benzene, b-nitrogen \n",
      "yi_a = 0.07      \n",
      "yi_b = 0.93    \n",
      "Tc_a = 562.2     \n",
      "Tc_b = 126.2   \t\t\t\t\t\t# [K]\n",
      "Pc_a = 48.9      \n",
      "Pc_b = 33.9  \t\t\t\t\t\t# [bar]\n",
      "M_a = 78.1       \n",
      "M_b  = 28    \t\t\t\t\t\t# [gram/mole]\n",
      "V_a = 259        \n",
      "V_b  = 89.8  \t\t\t\t\t\t# [cubic cm/mole]\n",
      "Z_a = 0.271      \n",
      "Z_b  = 0.290 \n",
      "sigma_a = 5.349  \n",
      "sigma_b = 3.798  \t\t\t\t\t# [Angstrom]\n",
      "ek_a = 412.3     \n",
      "ek_b = 71.4  \t\t\t\t\t\t# [E/k, K]\n",
      "\n",
      "\n",
      "\t# From equation 2.52 and 2.53\n",
      "Tcm = yi_b*Tc_b+yi_a*Tc_a  \t\t\t\t# [K]\n",
      "Pcm = 10**6*R*Tcm*(yi_b*Z_b+yi_a*Z_a)/((yi_b*V_b+yi_a*V_a)*100000) \t # [bar]\n",
      "M_avg = yi_b*M_b+yi_a*M_a  \t\t\t\t\t\t# [kg/kmole]\n",
      "\n",
      "#RESULT\n",
      "\n",
      "print\"Average molecular weight is\",round(M_avg,1),\"kg/kmole\" \n",
      "\n",
      "row = P*M_avg/(R*T)  \t\t\t\t\t\t\t# [kg/cubic m]\n",
      "\n",
      "#RESULT\n",
      "\n",
      "print\"Density of mixture is\",round(row,2),\"kg/cubic\"\n",
      "\t# From equation 2.50\n",
      "Em =  0.176*(Tcm/(M_avg**3*Pcm**4))**(1.0/6.0)  \t\t\t# [uP]**-1\n",
      "\n",
      "\t# From equation 2.51\n",
      "Trm = T/Tcm \n",
      "f_Trm = (0.807*Trm**0.618)-(0.357*math.exp(-0.449*Trm))+(0.340*math.exp(-4.058*Trm))+0.018  \n",
      "\t# From equation 2.49 \n",
      "u = f_Trm/Em  \t\t\t\t\t\t\t\t# [uP]\n",
      "u = u*10**-7  \t\t\t\t\t\t\t\t# [viscosity, kg/m.s]\n",
      "print\"Average viscosity of mixture is \",round(u,7),\"kg/m.s\\n\\n\" \n",
      "\n",
      "\t# Calculating diffusivity of benzene using equation 1.49\n",
      "D_ab = 0.0986  \t\t\t\t\t\t\t\t# [square cm/s]\n",
      "Sc = u/(row*D_ab*10**-4)  \t\t\t\t\t\t# [Schmidt number]\n",
      "\n",
      "F = 5.086*(row*v*u)**0.5/(M_avg*Sc**(2.0/3.0))  \t\t\t# [kmole/square m.s]\n",
      "\n",
      "\n",
      "#RESULT\n",
      "\n",
      "print\"The required mass transfer coefficient is\",round(F,5),\"kmole/square m.s\" "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Average molecular weight is 31.5 kg/kmole\n",
        "Density of mixture is 1.28 kg/cubic\n",
        "Average viscosity of mixture is  1.64e-05 kg/m.s\n",
        "\n",
        "\n",
        "The required mass transfer coefficient is 0.00196 kmole/square m.s\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 2.8,Page number:120"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Illustration 2.8\n",
      "#Benzene Evaporation Along a Vertical Flat Plate\n",
      "\n",
      "import math\n",
      "#Variable declaration\n",
      "\t#   a-liquid benzene     b-nitrogen\n",
      "T = 300  \t\t\t\t\t\t# [K]\n",
      "l = 3  \t\t\t\t\t\t\t# [length of vertical plate, m]\n",
      "b = 1.5  \t\t\t\t\t\t# [width of vertical plate, m]\n",
      "P = 101.3  \t\t\t\t\t\t# [kPa]\n",
      "v = 5  \t\t\t\t\t\t\t# [velocity across the width of plate, \t\t\t\t\t\t\tm/s]\n",
      "row_a = 0.88  \t\t\t\t\t\t# [gram/cubic cm]\n",
      "\n",
      "\n",
      "y_a1 = 0.139  \t\t\t\t\t\t# [mole fraction of benzene at inner \t\t\t\t\t\t\tedge]\n",
      "y_a2 = 0  \n",
      "\n",
      "\t# The film conditions, and average properties, are identical to those in Example 2.7, \tonly the geometry is different\n",
      "\t# Therefore\n",
      "M_avg = 31.4  \t\t\t\t\t\t# [kg/kmole]\n",
      "row = 1.2  \t\t\t\t\t\t# [kg/cubic m]\n",
      "u = 161*10**-7  \t\t\t\t\t# [kg/m.s]\n",
      "D_ab = 0.0986 \t\t \t\t\t\t# [square cm/s]\n",
      "Sc = 1.3  \t\t\t\t\t\t# [Schmidt Number]\n",
      "Re = row*v*b/u  \t\t\t\t\t# [Renoylds Number]\n",
      "\n",
      "if Re > 4000:\n",
      "    print\"The flow across the plate is turbulent\\n\" \n",
      "elif Re<2000:\n",
      "    print\"The flow across the plate is laminar\\n\" \n",
      "\t#Using equation 2.57\n",
      "Sh_l = 0.036*Re**0.8*Sc**(1.0/3.0)  \n",
      "\n",
      "\t# Nitrogen (component B) does not react with benzene (component A), neither dissolves in \t\tthe liquid  therefore, NB = 0 and siA = 1. The F-form of the mass-transfer coefficient \t\t\tshould be used    \n",
      "F = Sh_l*1.26*D_ab*10**-4/(M_avg*b)  \t\t\t# [kmole/square m.s]\n",
      "N_a = F*math.log((1-y_a2)/(1-y_a1))  \t\t\t# [kmole/square m.s]\n",
      "\n",
      "\t# The total mass rate of evaporation over the surface of the plate\n",
      "S = 1.5*3  \t\t\t\t\t\t# [square m]\n",
      "M_a = 78.1  \t\t\t\t\t\t# [gram/mole]\n",
      "wa = N_a*S*M_a*60*1000  \t\t\t\t# [gram/min]\n",
      "\n",
      "V = wa/row_a  \t\t\t\t\t\t# [volumetric flow rate, ml/min]\n",
      "\n",
      "print\"Liquid benzene should be supplied at the top of the plate at the rate \",round(V),\"ml/min\\nso that evaporation will just prevent it from reaching the bottom of the plate.\" "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The flow across the plate is turbulent\n",
        "\n",
        "Liquid benzene should be supplied at the top of the plate at the rate  1473.0 ml/min\n",
        "so that evaporation will just prevent it from reaching the bottom of the plate.\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 2.9,Page number:123"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Illustration 2.9\n",
      "#Evaporation of a Drop of Water Falling in Air\n",
      "\n",
      "#Variable declaration\n",
      "\t# a-water    b-air\n",
      "dp1 = 10**-3  \t\t\t\t\t# [diameter of spherical drop of water, m]\n",
      "Tair = 323  \t\t\t\t\t# [K]\n",
      "P = 101.3  \t\t\t\t\t# [kPa]\n",
      "Twater = 293  \t\t\t\t\t# [K]\n",
      "R = 8.314  \t\t\t\t\t# [cubic m.Pa/mole.K]\n",
      "M_a = 18.0  \t\t\t\t\t# [gram/mole]\n",
      "M_b = 29.0  \t\t\t\t\t# [gram/mole]\n",
      "import math\n",
      "\n",
      "\n",
      "#Calculation\n",
      "\n",
      "dp2 = (1.0/2.0)**(1.0/3.0)*dp1  \t\t# [m]\n",
      "dp = (dp1+dp2)/2  \t\t\t\t# [m]\n",
      "\n",
      "row_p = 995  \t\t\t\t\t# [density of water, kg/cubic m]\n",
      "row1b = 1.094  \t\t\t\t\t# [density of air, kg/cubic m]\n",
      "u = 1.95*10**-5  \t\t\t\t# [kg/m.s]\n",
      "row_pr = row_p-row1b  \t\t\t\t# [kg/cubic m]\n",
      "g = 9.8  \t\t\t\t\t# [accleration due to gravity, square m/s]\n",
      "\t# Combining equation 2.68 and 2.69\n",
      "Ga = 4*dp**3*row1b*row_pr*g/(3*u**2)  \t\t# [Galileo Number]\n",
      "\n",
      "\t# Relationship between Re and Cd\n",
      "\t# Re/Cd = Re**3/Ga = 3*row**2*vt**3/(4*g*u*row_pr)\n",
      "\n",
      "\t# The following correlation is used to relate Re/Cd, to Ga\n",
      "\t# ln(Re/Cd)**(1/3) = -3.194 + 2.153*ln(Ga)**(1/3) - 0.238*(ln(Ga)**(1/3))**2 + \t0.01068*(ln(Ga)**(1/3))**3\n",
      "\t# Therefore let A = (Re/Cd)\n",
      "A = math.exp(-3.194 + 2.153*math.log(Ga**(1.0/3.0)) - 0.238*(math.log(Ga**(1.0/3.0)))**2 + 0.01068*(math.log(Ga**(1.0/3.0)))**3) \n",
      "\n",
      "\t# Therefore 'vt' will be\n",
      "vt = A*(4*g*row_pr*u/(3*row1b**2))**(1.0/3.0)  \t# [Terminal velocity of particle, m/s]\n",
      "\n",
      "#Result\n",
      "\n",
      "print\"Terminal velocity of particle is\",round(vt,2),\"m/s\"  \n",
      "\n",
      "\n",
      "#Calculation\n",
      "\n",
      "P_w = 2.34  \t\t\t\t\t# [vapor pressure of water, kPa]\n",
      "y_w = P_w/P  \t\t\t\t\t# [mole fraction of water at the inner edge of \t\t\t\t\t\tthe gas film]\n",
      "M_avg = 18*y_w+29*(1-y_w)  \t\t\t# [gram/mole]\n",
      "\n",
      "row2b = P*M_avg/(R*Twater)  \t\t\t# [kg/cubic.m]\n",
      "delta_row = row2b - row1b  \t\t\t# [kg/cubic.m]\n",
      "\n",
      "Tavg = (Tair+Twater)/2  \t\t\t# [K]\n",
      "\t\t# At Temperature equal to Tavg density and viscosity are\n",
      "row3 = 1.14  \t\t\t\t\t# [kg/cubic.m]\n",
      "u1 = 1.92*10**-5  \t\t\t\t# [kg/m.s]\n",
      "\n",
      "Grd = g*row3*delta_row*(dp**3)/(u1**2) \n",
      "\n",
      "\t\t# Diffusivity of water at Tavg and 1 atm is\n",
      "D_ab = 0.242*10**-4  \t\t\t\t# [square m/s]\n",
      "Sc = u1/(row3*D_ab)  \t\t\t\t# [Schmidt Number]\n",
      "Re = dp*row3*vt/u1  \t\t\t\t# [Renoylds Number]\n",
      "\t\n",
      "\t# From equation 2.65 Re is greater than  0.4*Grd**0.5*Sc**(-1/6)\n",
      "\t# Therfore equation 2.64 can be used to calculate mass transfer coefficient\n",
      "\n",
      "Sh = 2+0.552*(Re**0.5)*Sc**(1.0/3.0)  \t\t# [Sherwood Number]\n",
      "\t# From Table 2.1\n",
      "\t# Sh = kc*P_bm*dp/(P*D_ab), since P_bm is almost equal to P\n",
      "\t# Therefore \n",
      "\t# Sh = kc*dp/D_ab \n",
      "kc = Sh*D_ab/dp  \t\t\t\t# [m/s]\n",
      "\n",
      "ca2 = 0  \t\t\t\t\t# [dry air concentration]\n",
      "ca1 = P_w/(R*Twater)  \t\t\t\t# [interface concentration, kmole/cubic.m]\n",
      "\t# Average rate of evaporation \n",
      "wa = math.pi*dp**2*M_a*kc*(ca1-ca2)*1000  \t# [g/s]\n",
      "\n",
      "\t# Amount of water evaporated\n",
      "m = row_p*math.pi*dp1**3/12*1000  \t\t# [g]\n",
      "\t# Time necessary to reduce the volume by 50%\n",
      "t = m/wa  \t\t\t\t\t# [s]\n",
      "\n",
      "D = t*vt  \t\t\t\t\t# [distance of fall, m]\n",
      "\n",
      "#Result\n",
      "\n",
      "print\"The distance of fall is\",round(D),\"m\"  "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Terminal velocity of particle is 3.59 m/s\n",
        "The distance of fall is 90.0 m\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 2.10,Page number:127"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Illustration 2.10\n",
      "#Mass Transfer for a Single Cylinder\n",
      "\n",
      "#Variable declaratiopn\n",
      "\n",
      "\t# Example 2.6 using equation 2.73\n",
      "\t# Values of the dimensionless parameters calculated in Example 2.6\n",
      "Re = 1223  \t\t\t\t# [Renoylds Number]\n",
      "Sc = 0.905  \t\t\t\t# [Schmidt Number]\n",
      "c = 0.039  \t\t\t\t# [molar density, kg/cubic m]\n",
      "v = 1  \t\t\t\t\t# [gas velocity, m/s]\n",
      "\t# Therefore \n",
      "#Calculations\n",
      "\n",
      "Gm = c*v  \t\t\t\t# [kmole/square m.s]\n",
      "\t# From equation 2.9 \n",
      "\t# Kg*P = ky\n",
      "\t# Therefore substituting in equation 2.73 we obtain\n",
      "ky = 0.281*Gm/(Re**0.4*Sc**0.56)  \t# [kmole/square m.s]\n",
      "\t# Now equation 2.73 were obtained under very dilute concentrations\n",
      "\t# Therefore\n",
      "y_bm = 1  \n",
      "\t# From equation 2.6\n",
      "F = ky*y_bm  \t\t\t\t# [kmole/square m.s]\n",
      "\n",
      "#Result\n",
      "\n",
      "print\"Mass transfer coefficient is \",round(F,6),\"kmol/m.^2-s\" \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Mass transfer coefficient is  0.000675 kmol/m.^2-s\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 2.11,Page number:129"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Illustration 2.11\n",
      "#Simultaneous Heat and Mass Transfer in Pipe\n",
      "\n",
      "#Variable declaration\n",
      "\n",
      "# a-water   b-air\n",
      "D = 25.4*10**-3  \t\t\t\t# [diameter of wetted wall tower, m]\n",
      "Gy = 10  \t\t\t\t\t# [mass velocity, kg/square m.s]\n",
      "T1 = 308  \t\t\t\t\t# [K]\n",
      "P = 101.3  \t\t\t\t\t# [kPa]\n",
      "p_a1 = 1.95  \t\t\t\t\t# [partial pressure of water vapor, kPa]\n",
      "R = 8.314  \t\t\t\t\t# [cubic m.Pa/mole.K]\n",
      "M_a = 18  \t\t\t\t\t# [gram/mole]\n",
      "Cpa = 1.88  \t\t\t\t\t# [kJ/kg.K]\n",
      "\n",
      "\n",
      "# Properties of dry air at 308 K and 1 atm pressure are\n",
      "u = 1.92*10**-5  \t\t\t\t# [kg/m.s]\n",
      "row = 1.14  \t\t\t\t\t# [kg/cubic m]\n",
      "D_ab = 0.242*10**-4  \t\t\t\t# [square m/s]\n",
      "Sc = 0.696  \t\t\t\t\t# [Schmidt number]\n",
      "Cp = 1.007  \t\t\t\t\t# [kJ/kg.K]\n",
      "k = 0.027  \t\t\t\t\t# [W/m.K]\n",
      "Pr = 0.7  \t\t\t\t\t# [Prandtl number]\n",
      "\n",
      "\n",
      "#Calculations\n",
      "\n",
      "import math\n",
      "from scipy.optimize import fsolve\n",
      "from numpy import *\n",
      "\n",
      "Re = D*Gy/u  \t\t\t\t\t# [Renoylds number]\n",
      "# From equation 2,74\n",
      "Sh = 0.023*Re**0.83*Sc**0.44  \t\t\t#[Sherwood number]\n",
      "# From Table 2.1\n",
      "kg = Sh*D_ab/(R*T1*D)*1000  \t\t\t# [mole/square m.s.kPa]\n",
      "\n",
      "# To estimate the heat-transfer coefficient, we use the Dittus-Boelter equation for cooling, equation 2.80\n",
      "Nu = 0.023*Re**0.8*Pr**0.3  \t\t\t# [Nusselt number]\n",
      "# From Table 2.1\n",
      "h = Nu*k/D  \t\t\t\t\t# [W/square m.K]\n",
      "\n",
      "T =373.15  \t\t\t\t\t# [K]\n",
      "lambda_a = 40.63  \t\t\t\t# [kJ/mole]\n",
      "Tc = 647.1  \t\t\t\t\t# [K]\n",
      "\n",
      "# Solution of simultaneous equation 2.78 and 2.79\n",
      "def F(e): \n",
      "    f1=kg*(p_a1 - math.exp(16.3872-(3885.7/(e[0]-42.98))))-e[1] \n",
      "    f2=e[1]*M_a*Cpa*(T1-e[0])/(1-exp(-e[1]*M_a*Cpa/h)) + 1000*e[1]*lambda_a*((1-(e[0]/Tc))/(1-(T/Tc)))**0.38 \n",
      "    return(f1,f2)    \n",
      "\n",
      "\n",
      "# Initial guess\n",
      "e = [292,-0.003] \n",
      "y = fsolve(F,e) \n",
      "Ti = y[0] \n",
      "Na = y[1] \n",
      "\n",
      "print\"The temperature of the liquid water and the rate of water evaporation is\",round(Ti),\"K and\",round(Na,3),\" mole/square m.s respectively\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The temperature of the liquid water and the rate of water evaporation is 295.0 K and -0.013  mole/square m.s respectively\n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 2.12,Page number:131"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Illustration 2.12\n",
      "#Air Humidification in Wetted- Wall Column \n",
      "\n",
      "\n",
      "#Variable declaration\n",
      "\t# a-water    b-dry air\n",
      "D = 25.4*10**-3  \t\t\t# [Internal diameter of tower, m]\n",
      "Z = 1.5  \t\t\t\t# [length of the wetted section, m]\n",
      "Gy = 10  \t\t\t\t# [mass velocity of air, kg/square m.s]\n",
      "Tair = 308  \t\t\t\t# [K]\n",
      "Twater = 295  \t\t\t\t# [K]\n",
      "P = 101.3  \t\t\t\t# [kPa]\n",
      "M_a = 18.0  \t\t\t\t# [gram/mole]\n",
      "M_b = 29.0  \t\t\t\t# [gram/mole]\n",
      "R = 8.314  \t\t\t\t# [cubic m.Pa/mole.K]\n",
      "\n",
      "#Calculations\n",
      "\n",
      "import math\n",
      "\n",
      "Pa = 2.64  # [kPa]\n",
      "\n",
      "Gm = Gy/M_b  \t# [Assuming that gas phase is basically dry air, kmole/square m.s]\n",
      "\t\t# The properties of dry air at 308 K and 1 atm are (from example 2.9)\n",
      "row = 1.14  \t\t\t\t# [kg/cubic m]\n",
      "u = 1.92*10**-5  \t\t\t# [kg/m.s]\n",
      "D_ab = 0.242*10**-4  \t\t\t# [square m/s]\n",
      "Sc = 0.692  \t\t\t\t# [Schmidt number]\n",
      "\n",
      "Re = Gy*D/u  \t\t\t\t# [Renoylds number]\n",
      "\n",
      "if Re<35000 and Re>2000:\n",
      "    Sh = 0.023*Re**0.83*Sc**0.44  \t# [Sherwood number]    \n",
      "    print\"Sherwood number is\",round(Sh,1) \n",
      "else:\n",
      "    print\"We cannot use equation 2.74\"\n",
      "\n",
      "c = P/(R*Tair)  \t\t\t# [kmole/cubic m]\n",
      "\t# Now using equation 2.89\n",
      "Pa_out = Pa*(1-math.exp((-4*Sh*Z*c*D_ab)/(Gm*D**2)))  \t\t# [kPa]\n",
      "\n",
      "#Result\n",
      "print\"The partial pressure of water in the air leaving the tower is\",round(Pa_out,2),\"kPa\" "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Sherwood number is 51.6\n",
        "The partial pressure of water in the air leaving the tower is 1.94 kPa\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 2.13,Page number:134"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Illustration 2.13\n",
      "# Air Humidification in a Packed Bed\n",
      "\n",
      "#Variable declaration\n",
      "\t# a-water    b-dry air\n",
      "Gy = 10.0  \t\t\t\t# [kg/square m.s]\n",
      "dp = 3.5*10**-3  \t\t\t# [diameter of spherical glass beads, m]\n",
      "D = 25.4*10**-3 \t\t\t# [Internal diameter of tower, m]\n",
      "Tair = 308  \t\t\t\t# [K]\n",
      "Twater = 295  \t\t\t\t# [K]\n",
      "P = 101.3  \t\t\t\t# [kPa]\n",
      "M_a = 18  \t\t\t\t# [gram/mole]\n",
      "M_b = 29  \t\t\t\t# [gram/mole]\n",
      "R = 8.314  \t\t\t\t# [cubic m.Pa/mole.K]\n",
      "\n",
      "#Calculation\n",
      "\n",
      "import math\n",
      "from scipy.optimize import fsolve\n",
      "\t# The properties of dry air at 308 K and 1 atm are (from example 2.12)\n",
      "row = 1.14  \t\t\t\t# [kg/cubic m]\n",
      "u = 1.92*10**-5  \t\t\t# [kg/m.s]\n",
      "D_ab = 0.242*10**-4  \t\t\t# [square m/s]\n",
      "Sc = 0.692  \t\t\t\t# [Schmidt number]\n",
      "c = 0.04 \t \t\t\t# [mole/cubic m]\n",
      "Gm = 0.345  \t\t\t\t# [kmole/square m.s]\n",
      "\n",
      "Re = Gy*dp/u  \t\t\t\t# [Renoylds number]\n",
      "if Re<2500 and Re>10:\n",
      "    \t\t\t\t\t# Subsituting in equation 2.90\n",
      "    jd = 1.17*Re**-0.415 \n",
      "    print\"Renoylds number is \",Re\n",
      "else:\n",
      "    print \" \"\n",
      "Std = 0.052/(Sc**(2.0/3.0)) \n",
      "\t\t# From Table 2.1 \n",
      "Sh = Std*Re*Sc  \t\t\t# [Sherwood number]\n",
      "\t\t# From equation 2.94\n",
      "e = 0.406+0.571*(dp/D)  \t\t# [bed porosity]\n",
      "e=round(e,3)\n",
      "\t#Illustration 2.13(a) \n",
      "\t# Solution(a)\n",
      "\t# Now Paout = 0.99*Pa\n",
      "\t# Using equation 2.93 to calculate 'Z'\n",
      "def f12(Z):\n",
      "    return(0.99 - 1 + math.exp(-6*(1-e)*Sh*c*Z*D_ab/(Gm*dp**2))) \n",
      "Z = fsolve(f12,0.06) \n",
      "\n",
      "#Result\n",
      "Z=round(Z[0],3)\n",
      "print\"The depth of packing required is\",Z,\"m=\",Z*100,\"cm\" \n",
      "\n",
      "\t#Illustration 2.13(b)\n",
      "\t# Solution(b)\n",
      "\t# From equation 2.95\n",
      "deltaP = (150*(1-e)/Re + 1.75)*((1-e)*(Gy**2)*Z)/(dp*row*e**3)  \t# [Pa]\n",
      "\n",
      "#Result\n",
      "print\"The gas pressure drop through the bed is\",round(deltaP),\"Pa  (Approx) \\nDUE TO LACK OF PRECISION IN CALCULATION IN BOOK.\\niF DONE MANUALLY,THIS ANSWER STANDS CORRECT\"  "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Renoylds number is  1822.91666667\n",
        "The depth of packing required is 0.078 m= 7.8 cm\n",
        "The gas pressure drop through the bed is 15817.0 Pa  (Approx) \n",
        "DUE TO LACK OF PRECISION IN CALCULATION IN BOOK.\n",
        "iF DONE MANUALLY,THIS ANSWER STANDS CORRECT\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 2.14,Page number:138"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Illustration 2.14\n",
      "#Design of a Hollow-Fiber Boiler Feed Water Deaerator\n",
      "\n",
      "#Variable declaration\n",
      "\t# a-oxygen     b-water\n",
      "\t# To design the deaerator, We will use commercially available microporous polypropylene \thollow fibers in a module\n",
      "\n",
      "m = 40000.0  \t\t\t\t\t# [kg/hr]\n",
      "Twater = 298  \t\t\t\t\t# [K]\n",
      "v = 0.1  \t\t\t\t\t# [superficial velocity, m/s]\n",
      "P = 101.3 \t\t\t\t\t# [kPa]\n",
      "V = 40*10**-3  \t\t\t\t\t# [Flow rate of nitrogen, cubic m/min]\n",
      "d = 2.90*10**-4  \t\t\t\t# [Outside diameter of fibres, m]\n",
      "pf = 0.4  \t\t\t\t\t# [Packing factor]\n",
      "a = 46.84*100  \t\t\t\t\t# [surface area per unit volume, m**-1]\n",
      "R = 8.314  \t\t\t\t\t# [cubic m.Pa/mole.K]\n",
      "\n",
      "#Calculation\n",
      "\n",
      "import math\n",
      "\n",
      "dw = 1000  \t\t\t\t\t# [density of water, kg/cubic m]\n",
      "Ql = m/(3600*1000)  \t\t\t\t# [volumetric water flow rate, cubic m/s]\n",
      "\t# Shell diameter\n",
      "D = (4*Ql/(math.pi*v))**0.5  \t\t\t# [Shell diameter, m]\n",
      "\n",
      "\t# the properties of dilute mixtures of oxygen in water at 298 K\n",
      "u = 0.9  \t\t\t\t\t# [cP]\n",
      "\t# Diffusivity from equation 1.53\n",
      "D_ab = 1.93*10**-9  \t\t\t\t# [square m/s]\n",
      "Sc = 467  \t\t\t\t\t# [Schmidt number]\n",
      "\n",
      "Re = d*v*dw/(u*10**-3)  \t\t\t# [Renoylds number]\n",
      "\n",
      "\t# Substituting in equation (2-97) gives\n",
      "Sh = 0.53*(1-1.1*pf)*((1-pf)/pf)**-0.47*(Re**0.53*Sc**0.33) \n",
      "\n",
      "kl = Sh*D_ab/d  \t\t\t\t# [mass-transfer coefficient on the shell side, \t\t\t\t\t\tm/s]\n",
      "\n",
      "\t# From the specified BFW flow rate\n",
      "L = m/(3600*18)  \t\t\t\t# [kmole/s]\n",
      "\t# From ideal gas law\n",
      "V1 = V*P/(Twater*R*60)  \t\t\t# [kmole/s]\n",
      "\t# From the solubility of oxygen in water at 298 K,\n",
      "M = 4.5*10**4 \n",
      "A = L/(M*V1)  \t\t\t\t\t# [Absorption factor]\n",
      "\n",
      "#Result\n",
      "\n",
      "print\"Absorption factor is\",round(A,3) \n",
      "\n",
      "#Calculation\n",
      "\n",
      "\t# For 99% removal of the dissolved oxygen\n",
      "\t# x_in/x_out = b = 100\n",
      "b = 100 \n",
      "c = 55.5 \t\t\t\t\t# [molar density, kmole/cubic m]\n",
      "\t# Substituting in equation 2.99 yields\n",
      "V_T = (L*math.log(b*(1-A)+A))/(kl*a*c*(1-A)) \t # [cubic m]\n",
      "\n",
      "\t# The module length, Z is\n",
      "Z = V_T/(math.pi*D**2.0/4.0) \n",
      "\n",
      "#Result\n",
      "print\"The shell diameter and module length is\",round(D,3),\"m and\",round(Z,2),\" m respectively\"    "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Absorption factor is 0.503\n",
        "The shell diameter and module length is 0.376 m and 2.15  m respectively\n"
       ]
      }
     ],
     "prompt_number": 20
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 2.15,Page number:140"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Example 2.15\n",
      "\n",
      "#Variable declaration\n",
      "d=2.21/100\t\t\t#[m]\n",
      "mu=8.82*10**-6\t\t#[kg/m-s]\n",
      "rho=2.81\t\t#[kg/m**3]\n",
      "\n",
      "c=34.14\t\t\t#[mol/m**3]\n",
      "D=array([2.228/(10**6),2.065/(10**6),1.832/(10**6)])      #Velocities in [m**2/s]\n",
      "\n",
      "\n",
      "#Calculation\n",
      "#Gy=rho*v\t\t\n",
      "#Re=Gy*d/mu\t\t#Reynolds number\n",
      "Re=21750\n",
      "print \"Reynolds number=\",Re\n",
      "Sc=[]\n",
      "Sh=[]\n",
      "F=[]\n",
      "for i in range(0, 3):\n",
      "    sc=mu/(rho*D[i])                   #Schmidt number\n",
      "    Sc.append(sc)\n",
      "    sh=0.023*Re**(0.83)*sc**(0.44)  #Sherwood number\n",
      "    Sh.append(sh)\n",
      "    f=sh*c*D[i]/d                   #Binary mass transfer coefficient in [mol/m^2-s]\n",
      "    F.append(f)\n",
      "print \"Schmidt number are:\"\n",
      "for i in range(0,3):\n",
      "    print round(Sc[i],3)\n",
      "print \"Sherwood number number are:\"\n",
      "for i in range(0,3):\n",
      "    print round(Sh[i],1)\n",
      "print\"Binary mass transfer coefficients are:\"\n",
      "for i in range(0,3):\n",
      "    print round(F[i],3)\n",
      "#After modifying mathcad program of example 1.17,we have\n",
      "N1=-0.0527                          #[mol/m^2-s]\n",
      "N2=0.0395                          #[mol/m^2-s]\n",
      "N3=0.0132                          #[mol/m^2-s]\n",
      "print\"The program yields the following results:\"\n",
      "print \"N1=\",N1,\"mol/m**2-s\"\n",
      "print \"N2=\",N2,\"mol/m**2-s\"\n",
      "print \"N3=\",N3,\"mol/m**2-s\"\n",
      "    "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Reynolds number= 21750\n",
        "Schmidt number are:\n",
        "1.409\n",
        "1.52\n",
        "1.713\n",
        "Sherwood number number are:\n",
        "106.5\n",
        "110.1\n",
        "116.1\n",
        "Binary mass transfer coefficients are:\n",
        "0.367\n",
        "0.351\n",
        "0.328\n",
        "The program yields the following results:\n",
        "N1= -0.0527 mol/m**2-s\n",
        "N2= 0.0395 mol/m**2-s\n",
        "N3= 0.0132 mol/m**2-s\n"
       ]
      }
     ],
     "prompt_number": 36
    }
   ],
   "metadata": {}
  }
 ]
}