summaryrefslogtreecommitdiff
path: root/TRANSPORT_PROCESSES_AND_UNIT_OPERATIONS/GeankoplisChapter06.ipynb
blob: 0ae5054684d2eb5435d1fb826a340a3a24be991a (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
{
 "metadata": {
  "name": "",
  "signature": "sha256:4a12202353f3cb1cbe50fd7930d91773aa80f5f97a640a6132154b29fdca09cb"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 6: Principles of Mass Transfer"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.1-1, Page number 384"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Molecular Diffusion of Helium in Nitrogen\n",
      "\n",
      "#Variable declaration\n",
      "z1 = 0.0                             #Location of one end of pipe, m\n",
      "z2 = 0.2                             #Location of other end of pipe, m\n",
      "T = 298                              #Temeperature of gas, K\n",
      "pA1 = 0.6                            #Partial pressure of Helium at end 1, atm\n",
      "pA2 = 0.2                            #Partial pressure of Helium at end 2, atm\n",
      "DAB = 0.687e-4                       #Diffusivity of Helium in Nitrogen,  m2/s\n",
      "P = 1.                               #Total pressure, atm\n",
      "R = 82.057e-3                        #Gas Constant,m3.atm/(kmol.K)\n",
      "\n",
      "#Calculation SI Units\n",
      "JAz = DAB*(pA1-pA2)/(R*T*(z2-z1))\n",
      "\n",
      "#Result\n",
      "print 'Flux of Helium through the Nitrogen in SI units: %5.2e'%(JAz), \"kmol/(m2.s)\"\n",
      "\n",
      "#Variable declaration cgs Units\n",
      "z1 = 0.0                             #Location of one end of pipe, m\n",
      "z2 = 20                              #Location of other end of pipe, m\n",
      "DAB = 0.687                          #Diffusivity of Helium in Nitrogen,  cm2/s\n",
      "R = 82.057                           #Gas Constant,cm3.atm/(gmol.K)\n",
      "\n",
      "#Calculation cgs Units\n",
      "JAz = DAB*(pA1-pA2)/(R*T*(z2-z1))\n",
      "\n",
      "#Result\n",
      "print 'Flux of Helium through the Nitrogen in cgs units: %5.2e'%(JAz), \"gmol/(cm2.s)\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Flux of Helium through the Nitrogen in SI units: 5.62e-06 kmol/(m2.s)\n",
        "Flux of Helium through the Nitrogen in cgs units: 5.62e-07 gmol/(cm2.s)\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.2-1, Page Number 386"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Equimolar Counterdiffusion\n",
      "\n",
      "#Variable declaration\n",
      "z1 = 0.0                             #Location of one end of pipe, m\n",
      "z2 = 0.1                             #Location of other end of pipe, m\n",
      "T = 298                              #Temeperature of gas, K\n",
      "pA1 = 1.013e4                        #Partial pressure of Ammonia at end 1, Pa\n",
      "pA2 = 0.507e4                        #Partial pressure of Ammonia at end 2, Pa\n",
      "DAB = 0.23e-4                        #Diffusivity of Ammonia in Nitrogen,  m2/s\n",
      "P = 1.0132e5                         #Total pressure, Pa\n",
      "R = 8314.3                           #Gas Constant,m3.Pa/(kmol.K)\n",
      "\n",
      "#Calculation\n",
      "\n",
      "JAz = DAB*(pA1-pA2)/(R*T*(z2-z1))\n",
      "pB1 = P - pA1\n",
      "pB2 = P - pA2\n",
      "JBz = DAB*(pB1-pB2)/(R*T*(z2-z1))\n",
      "#Result\n",
      "\n",
      "print 'Flux of Ammonia through the Nitrogen:%10.2e '%(JAz), \"kmolA/(m2.s)\"\n",
      "print 'Flux of Nitrogen through the Ammonia:%10.2e '%(JBz), \"kmolB/(m2.s)\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Flux of Ammonia through the Nitrogen:  4.70e-07  kmolA/(m2.s)\n",
        "Flux of Nitrogen through the Ammonia: -4.70e-07  kmolB/(m2.s)\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.2-2, Page number 389"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Diffusion of Water Through Stagnant, Nondiffusing Air\n",
      "from math import log\n",
      "\n",
      "#Variable declaration English Units\n",
      "z1 = 0.0                             #Location of one end of pipe, ft\n",
      "z2 = 0.5                             #Location of other end of pipe, ft\n",
      "T = 68                               #Temeperature of gas, \u00b0F\n",
      "DAB = 0.25e-4                        #Diffusivity of Water in Air,  m2/s\n",
      "p0w = 17.54                          #Vapor pressure of Water at 68 \u00b0F, mmHg\n",
      "R = 0.73                             #Gas Constant, ft3.atm/(lbmol.\u00b0R)\n",
      "P = 1.\n",
      "\n",
      "#Calculation English units\n",
      "DAB = DAB*3.875e4\n",
      "p0w = p0w/760\n",
      "pA1 = p0w\n",
      "pA2 = 0.\n",
      "T = T + 460.\n",
      "\n",
      "pB1 = P - pA1\n",
      "pB2 = P - pA2\n",
      "pBM = (pB2-pB1)/log(pB2/pB1)\n",
      "NA = DAB*P*(pA1-pA2)/(R*T*(z2-z1)*pBM)\n",
      "#Result\n",
      "print 'Rate of evaporation of water at steady state:English Units %10.3e'%(NA), \"lbmol/(ft2.hr)\"\n",
      "\n",
      "#Variable declaration SI Units\n",
      "z1 = 0.0                             #Location of one end of pipe, m\n",
      "z2 = 0.1524                          #Location of other end of pipe, m\n",
      "T = 293                              #Temeperature of gas, K\n",
      "p0w = 17.54                          #Vapor pressure of Water at 293 K, mmHg\n",
      "DAB = 0.25e-4                        #Diffusivity of Water in Air,  m2/s\n",
      "P = 1.01325e5                        #Total pressure, Pa\n",
      "R = 8314.3                           #Gas Constant,m3.Pa/(kmol.K)\n",
      "\n",
      "#Calculation SI units\n",
      "\n",
      "p0wSI = p0w*P/760\n",
      "pA1 = p0wSI\n",
      "pA2 = 0.\n",
      "JAz = DAB*(pA1-pA2)/(R*T*(z2-z1))\n",
      "\n",
      "pB1 = P - pA1\n",
      "pB2 = P - pA2\n",
      "pBM = (pB2-pB1)/log(pB2/pB1)\n",
      "NA = DAB*P*(pA1-pA2)/(R*T*(z2-z1)*pBM)\n",
      "\n",
      "#Result\n",
      "print 'Rate of evaporation of water at steady state SI Units:%10.3e'%(NA), \"kmol/(m2.s)\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Rate of evaporation of water at steady state:English Units  1.174e-04 lbmol/(ft2.hr)\n",
        "Rate of evaporation of water at steady state SI Units: 1.593e-07 kmol/(m2.s)\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.2-4, Page number 392"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Evaporation of Napthalene Sphere\n",
      "\n",
      "# Variable declaration\n",
      "r = 2.            #Radius of Napthalene ball, mm\n",
      "Tair = 318.       #Ambient temperature of air, K\n",
      "Tball = 318.      #Temperature of the Napthalene ball, K\n",
      "p0N = 0.555       #Vapor pressure of Napthalene at 318K, mmHg\n",
      "DAB = 6.92e-6     #Diffusion Coefficient, m2/s\n",
      "P = 101325.       #Atmospheric pressure, Pa \n",
      "R = 8314.         #Gas constant, m3.Pa/(kmol.K)\n",
      "\n",
      "# Calculation\n",
      "pA1 = p0N*P/760\n",
      "r = r/1000\n",
      "pA2 = 0.\n",
      "pB1 = P - pA1\n",
      "pB2 = P- pA2\n",
      "pBM = (pB1+pB2)/2.\n",
      "NA = DAB*P*(pA1-pA2)/(R*Tair*r*pBM)\n",
      "   \n",
      "#Result\n",
      "print 'Rate of evaporation of Napthalene from surface is:%10.3e'%(NA),\"kmol A/(m2.s)\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Rate of evaporation of Napthalene from surface is: 9.687e-08 kmol A/(m2.s)\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.2-5, Page number 397"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Estimation of diffusivity of a Gas Mixture\n",
      "from math import sqrt\n",
      "\n",
      "# Variable declaration\n",
      "P = 1.                    #Pressure in atmosphere\n",
      "MA = 74.1                 #Molecular weight of Butanol\n",
      "MB = 29.                  #Molecular weight of Air\n",
      "T1 = 0.                   #Temperature, deg C\n",
      "T2 = 25.9                 #Temperature, deg C\n",
      "T3 = 0.                   #Temperature, deg C\n",
      "P3 = 2.\n",
      "# Calculation\n",
      "def BinaryDiffusivity(P,T):\n",
      "    dab =  1.0e-7*T**1.75*sqrt(1./MA+1./MB)/(P*(SvA**(1./3)+ SvB**(1./3))**2)\n",
      "    print \"The binary diffusivity Butanol in Air at\",round(P,2),\"&\",T,'K is %5.3e'%(dab),\"m2/s\"  \n",
      "    return dab\n",
      "\n",
      "#Atomic Diffusion volumes using table 6.2-2 pp-396\n",
      "SvA = 4*16.5+10*1.98+1*5.48\n",
      "SvB = 20.1\n",
      "T1 = 273 + T1\n",
      "DAB1 = BinaryDiffusivity(P,T1)\n",
      "T2 = 273 + T2\n",
      "DAB2 = BinaryDiffusivity(P,T2)\n",
      "DAB3 = DAB1*(1./2.)\n",
      "print 'The binary diffusivity Butanol in Air at %3.1f & %4.1f K is %5.3e m2/s'%(P3,T1,DAB3)\n",
      "#OR\n",
      "#DAB3 = BinaryDiffusivity(P3,T1)\n",
      "#Result\n",
      "print 'The answers different than book because of book uses rounded numbers'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The binary diffusivity Butanol in Air at 1.0 & 273.0 K is 7.701e-06 m2/s\n",
        "The binary diffusivity Butanol in Air at 1.0 & 298.9 K is 9.025e-06 m2/s\n",
        "The binary diffusivity Butanol in Air at 2.0 & 273.0 K is 3.851e-06 m2/s\n",
        "The answers different than book because of book uses rounded numbers\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.3-1, Page number 399"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Diffusion of Ethanol(A) through Water(B)\n",
      "\n",
      "#Variable declaration\n",
      "\n",
      "T = 298                 #Temperature of solution, K\n",
      "rho1 = 972.8            #Density of solution at 16.8% wt, kg/m3\n",
      "rho2 = 998.1            #Density of solution at 6.8% wt, kg/m3\n",
      "DAB = 0.740e-9          #Diffusivity of Ethanol, m2/s\n",
      "MA = 46.05              #Molecular wt of ethanol\n",
      "MB = 18.02              #Molecular wt of Water\n",
      "xw1 = 16.8              #weight % of Ethanol at 1\n",
      "xw2 = 6.8               #weight % of Ethanol at 2\n",
      "z1 = 0.                 #Location 1, m\n",
      "z2 = 2.e-3              #Location 2, m\n",
      "#Calculation\n",
      "\n",
      "xmA1 = xw1/MA/(xw1/MA+(100-xw1)/MB)\n",
      "xmA2 = xw2/MA/(xw2/MA+(100-xw2)/MB)\n",
      "xmB1 = 1. - xmA1\n",
      "xmB2 = 1. - xmA2\n",
      "MW1 = MA*xmA1 + MB*xmB1\n",
      "MW2 = MA*xmA2 + MB*xmB2\n",
      "Cav = (rho1/MW1+rho2/MW2)/2.\n",
      "xBM = (xmB1+xmB2)/2.\n",
      "NA = DAB*Cav*(xmA1-xmA2)/(xBM*(z2-z1))\n",
      "\n",
      "#Result\n",
      "print 'Steady State flux of Ethanol: %4.3e'%(NA), \"kgmol/(m2.s)\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Steady State flux of Ethanol: 8.998e-07 kmol/(m2.s)\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.3-2, Page number 402"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Prediction of Liquid Diffusivity \n",
      "from math import sqrt\n",
      "#Variable declaration\n",
      "T1 = 25                #Temperature of solution, degC\n",
      "T2 = 50                #Temperature of solution, degC\n",
      "mu25B = 0.8937e-3      #Viscosity of Water at 25 degC, Pa.s\n",
      "mu50B = 0.5494e-3      #Viscosity of Water at 50 degC, Pa.s\n",
      "MB = 18.02\n",
      "\n",
      "\n",
      "#Calculation\n",
      "mvA = 3*0.0148 + 6*0.0037 + 1*0.0074\n",
      "si =  2.6\n",
      "\n",
      "def LiquidDiffusivity(muB,T):\n",
      "    dab = 1.173e-16*sqrt(si*MB)*T/(muB*mvA**0.6)\n",
      "    print 'Liquid diffusivity of Acetone in Water at %5.3f \u00b0C is %5.3e m2/s' %(T,dab)\n",
      "    return \n",
      "\n",
      "LiquidDiffusivity(mu25B,T1+273)\n",
      "LiquidDiffusivity(mu50B,T2+273)\n",
      "#Result\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Liquid diffusivity of Acetone in Water at 298.000 \u00b0C is 1.277e-09 m2/s\n",
        "Liquid diffusivity of Acetone in Water at 323.000 \u00b0C is 2.251e-09 m2/s\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.4-1, Page number 405"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Prediction of Diffusivity of Albumin\n",
      "\n",
      "#Variable declaration\n",
      "T = 298            #Temperature, K\n",
      "MA = 67500         #Molecular Weight of Albumin\n",
      "muw298 = 0.8937e-3 #Viscosity of water at 298 K, Pa.s\n",
      "\n",
      "#Calculations\n",
      "DAB = 9.4e-15*T/(muw298*MA**(1./3))\n",
      "\n",
      "#Result\n",
      "print 'Diffusivity of Albumin in Water at 298 K %3.2e m2/s'%(DAB)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Diffusivity of Albumin in Water at 298 K 7.70e-11 m2/s\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.4-2, Page number 407"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Diffusion of urea in Agar\n",
      "\n",
      "#Variable Declaration\n",
      "CA1 = 0.2               #Concentration at one end of tube\n",
      "CA2 = 0.0               #Concentration at other end of tube\n",
      "z1 = 0.0\n",
      "z2 = 0.04               #Location of other end of tube from end 1\n",
      "DAB = 0.727e-9          #Diffusivity of urea \n",
      "\n",
      "#Calculation\n",
      "NA = DAB*(CA1-CA2)/(z2-z1)\n",
      "\n",
      "#Result\n",
      "print 'Steady State Flux of urea through agar solution:%4.3e kgmol/(m2.s)'%(NA)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Steady State Flux of urea through agar solution:3.635e-09 kmol/(m2.s)\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.5-1, Page number 409"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Diffusion of H2 through Neoprene Membrance\n",
      "\n",
      "#Variable Declaration\n",
      "\n",
      "T = 17                      #Temnperature of hydrogen, deg C\n",
      "pH21 = 0.01                 #Partial pressure of H2 on one end of membrane, atm\n",
      "z = 0.5                     #Membrane thickness, mm\n",
      "pH22 = 0.0                  #Partial pressure of H2 on other end of membrane, atm\n",
      "S = 0.051                   #Solubility of H2 in Neoprene, [m3 at STP/(m3solid.atm)]\n",
      "DAB = 1.03e-10              #Diffusivity at 17 deg C, m2/s\n",
      "\n",
      "#Calculations\n",
      "cA1 = S*pH21/22.414\n",
      "cA2 = S*pH22/22.414\n",
      "NA = DAB*(cA1-cA2)/(z/1000.)\n",
      "\n",
      "#Results\n",
      "print 'concentrations at face 1 and face 2 are %3.2e and %3.2e kgmol H2/m3 solid respectively'%(cA1,cA2)\n",
      "print 'Steady State Flux of Hydrogen through Neoprene membrane:%5.2e'%(NA),\"kgmol H2/(m2.s)\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "concentrations at face 1 and face 2 are 2.28e-05 and 0.00e+00 kgmol H2/m3 solid respectively\n",
        "Steady State Flux of Hydrogen through Neoprene membrane:4.69e-12 kgmol H2/(m2.s)\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.5-2, Page number 411"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Diffusion through a Packaging Film using Permeability\n",
      "\n",
      "#Variable Declaration\n",
      "z = 0.00015            #Thickness of the pkg film, m\n",
      "T = 30.                #Temperature of the film, deg C\n",
      "pO21 = 0.21            #Partial pressure of O2 outside the film, atm\n",
      "pO22 = 0.01            #Partial pressure of O2 inside the film, atm\n",
      "PM = 4.17e-12          #Permeability of the film m3 solute STP/(s.m2.atm/m)\n",
      "\n",
      "#Calcualtions\n",
      "NA = PM*(pO21-pO22)/(22.414*z)\n",
      "\n",
      "#Result\n",
      "print 'Diffusional flux of the Oxygen through the polyethylene film:%10.3e kgmol/(m2.s)'%(NA)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Diffusional flux of the Oxygen through the polyethylene film: 2.481e-10 kgmol/(m2.s)\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.5-3, Page number 412"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Diffusion of KCl in porous Silica\n",
      "\n",
      "#Variable Declaration\n",
      "z = 0.002                  #Thickness of Silica, m\n",
      "DAB = 1.87e-9              #Diffusivity of KCl in water, m2/s\n",
      "cA1 = 0.1                  #Concentration of KCl, kmol/m3\n",
      "cA2 = 0.0                  #Concentration of KCl on other side of Silica\n",
      "epps = 0.3                 #Porosity of  Silica\n",
      "tau = 4.0                  #Tortuosity\n",
      "\n",
      "#Calculation\n",
      "NA = epps*DAB*(cA1-cA2)/(tau*z)\n",
      "\n",
      "#Results\n",
      "print 'Diffusional flux of the KCl through the Porous Silica: %5.2e kmol/(m2.s)'%(NA)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Diffusional flux of the KCl through the Porous Silica: 7.01e-09 kmol/(m2.s)\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.6-1, Page number 416"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Numerical Method for Convection and Steady State Diffusion\n",
      "import numpy as np\n",
      "\n",
      "#Variable Declaration\n",
      "ci = 6.00e-3           #Inside concentration, kmol/m3\n",
      "kc = 2.0e-7            #Outside convective coefficient, m/s\n",
      "cinf = 2.00e-3         #Outside concentration, kmol/m3\n",
      "DAB = 1.0e-9           #Diffusivity in solid, m2/s\n",
      "dx = dy = 0.005        #Grid size in x and y directions, m\n",
      "K = 1.0                #Distribution coefficient\n",
      "\n",
      "#Calculations\n",
      "kdxbyD = kc*dx/DAB\n",
      "\n",
      "#Index used are one less as in book\n",
      "c1 = np.zeros(5)\n",
      "c2 = np.zeros(5)\n",
      "c3 = np.zeros(5)\n",
      "\n",
      "\n",
      "cinf = cinf*1e3\n",
      "ci = ci*1e3\n",
      "np.set_printoptions(precision=2)\n",
      "\n",
      "#Initializations\n",
      "c1[2] = c1[3] = ci\n",
      "c2[1] = 3.8\n",
      "c1[1] = c2[2] = c2[4] = 4.2\n",
      "c2[3] = 4.4\n",
      "c3[0] = 2.5\n",
      "c3[1] = c2[0] = 2.7\n",
      "c3[2] = c3[4] = 3.0\n",
      "c3[3] = 3.2\n",
      "\n",
      "for j in range(3):\n",
      "    N22 = c1[1]+c3[1]+c2[0]+c2[2]-4*c2[1]\n",
      "    c2[1] = (c1[1]+ c3[1]+c2[0]+c2[2])/4\n",
      "    N23 = c2[1]+c2[3]+c1[2]+c3[2]-4*c2[2]\n",
      "    c2[2] = c2[4] = c1[1] = (c2[1]+c2[3]+c1[2]+c3[2])/4\n",
      "    N24 = c2[2]+c2[4]+c1[3]+c3[3]-4*c2[3]\n",
      "    c2[3] = (c2[2]+c2[4]+c1[3]+c3[3])/4\n",
      "    N31 = kdxbyD*cinf + (c2[0]+c3[1])/2 - (kdxbyD+1)*c3[0]  \n",
      "    c3[0] = (kdxbyD*cinf + (c2[0]+c3[1])/2)/(kdxbyD+1) \n",
      "    N32 = kdxbyD*cinf + (2*c2[1]+c3[0]+c3[2])/2 - (kdxbyD+2)*c3[1]\n",
      "    c3[1] = c2[0] =(kdxbyD*cinf + (2*c2[1]+c3[0]+c3[2])/2)/(kdxbyD+2)\n",
      "    N33 = kdxbyD*cinf + (2*c2[2]+c3[1]+c3[3])/2-(kdxbyD+2)*c3[2]\n",
      "    c3[2] = c3[4] = (kdxbyD*cinf + (2*c2[2]+c3[1]+c3[3])/2)/(kdxbyD+2)\n",
      "    N34 = kdxbyD*cinf + (2*c2[3]+c3[2]+c3[4])/2 -(kdxbyD+2)*c3[3]\n",
      "    c3[3] = (kdxbyD*cinf + (2*c2[3]+c3[2]+c3[4])/2)/(kdxbyD+2)\n",
      "    \n",
      "    \n",
      "c1[0] = c3[2]\n",
      "c1[4] = c1[2]\n",
      "\n",
      "No = kc*(dx*1.)*((c3[0]-cinf)/2+(c3[1]-cinf)+(c3[2]-cinf)+(c3[3]-cinf)/2)*1e-3\n",
      "Ni = DAB*(dx*1.)*((c1[2]-c2[2])+(c1[3]-c2[3])/2)*1e-3/dy\n",
      "#Results\n",
      "print \"Concentration Values at nodes are as follows\"\n",
      "print \"C    1     2     3     4 \"\n",
      "print 1,c1[:4]\n",
      "print 2,c2[:4]\n",
      "print 3,c3[:4]\n",
      "\n",
      "print '\\nThe average flux is %6.3e kmol/s'%((Ni+No)*.5)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Concentration Values at nodes are as follows\n",
        "C    1     2     3     4 \n",
        "1 [ 3.06  4.23  6.    6.  ]\n",
        "2 [ 2.73  3.48  4.23  4.41]\n",
        "3 [ 2.36  2.73  3.06  3.15]\n",
        "\n",
        "The average flux is 2.554e-12 kmol/s\n"
       ]
      }
     ],
     "prompt_number": 47
    }
   ],
   "metadata": {}
  }
 ]
}