summaryrefslogtreecommitdiff
path: root/sample_notebooks/PrashantSahu/Chapter_2_Molecular_Diffusion.ipynb
blob: 7df6880b1dac1f4229662091ad7a23aa1d9a3da2 (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
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#Chapter 2 : Molecular Diffusion\n",
    "##Example 2.1 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Molar average velocity of gas mixture is: 0.0303\n",
      "Mass average velocity of gas mixture is: 0.029\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "N2 = 0.05   #mole fraction of Nitrogen denoted as 1\n",
    "H2 = 0.15   #mole fraction of Hydrogen denoted as 2\n",
    "NH3 = 0.76  #mole fraction of Ammonia denoted as 3\n",
    "Ar = 0.04   #mole fraction of Argon denoted as 4\n",
    "u1 = 0.03\n",
    "u2 = 0.035\n",
    "u3 = 0.03\n",
    "u4 = 0.02\n",
    "#Calculating molar average velocity\n",
    "U = N2*u1 + H2*u2 + NH3*u3 + Ar*u4\n",
    "print 'Molar average velocity of gas mixture is: %.4f'%U\n",
    "#Calculating of mass average velocity\n",
    "M1 = 28\n",
    "M2 = 2\n",
    "M3 = 17\n",
    "M4 = 40\n",
    "M = N2*M1 + H2*M2 + NH3*M3 + Ar*M4\n",
    "u = (1/M)*(N2*M1*u1 + H2*M2*u2 + NH3*M3*u3 + Ar*M4*u4)\n",
    "print 'Mass average velocity of gas mixture is: %.3f'%u"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    " ##Example 2.2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false,
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a) Time for complete evaporation is: 15.93 hours\n",
      "(b) Time for disappearance of water is: 8.87 hours\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "import numpy as np\n",
    "\n",
    "#Calcualtion for (a) part\n",
    "#calculating vapor pressure of water at 301K\n",
    "pv = math.exp(13.8573 - (5160.2/301))   #in bar\n",
    "#wet-bulb temperature is 22.5 degree centigrade\n",
    "#calculating mean air-film temperature\n",
    "Tm = ((28+22.5)/2)+273  #in kelvin\n",
    "#calculating diffusion coefficient\n",
    "Dab = ((0.853*(30.48**2))*((298.2/273)**1.75))/(3600*10000)   #in m^2/s\n",
    "l = 2.5e-3     #in m\n",
    "P = 1.013      #in bar\n",
    "R = 0.08317    #Gas constant\n",
    "pAo = math.exp(13.8573 - (5160.2/295.2))    #vapor pressure of water at the wet-bulb temperature, 22.2C\n",
    "pAl = 0.6*round(pv,4)\n",
    "Na = (((round(Dab,7)*P)/(R*298.2*l))*math.log((P-pAl)/(P-round(pAo,3))))*18     #in kg/m^2s\n",
    "#amount of water per m^2 of floor area is\n",
    "thickness = 2e-3\n",
    "Amount = thickness*1    #in m^3 \n",
    "#density of water is 1000kg/m^3\n",
    "#therefore in kg it is\n",
    "amount = Amount*1000\n",
    "Time_for_completion = amount/Na   #in seconds\n",
    "Time_for_completion_hours = Time_for_completion/3600\n",
    "print '(a) Time for complete evaporation is: %.2f'%Time_for_completion_hours,'hours'\n",
    "\n",
    "#Calculation for (b) part\n",
    "water_loss = 0.1   #in kg/m^2.h\n",
    "water_loss_by_evaporation = Na*3600\n",
    "total_water_loss = water_loss + water_loss_by_evaporation\n",
    "time_for_disappearance = amount/total_water_loss\n",
    "print '(b) Time for disappearance of water is: %0.2f'%time_for_disappearance,'hours'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example 2.3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a) The molar flux of Ammonia is:1.922E-05 gmol/cm^2.s\n",
      "(b) and (c)\n",
      "Velocity of A is 0.522 cm/s\n",
      "Velocity of B is 0.000 cm/s\n",
      "Mass average velocity of A is 0.439 cm/s\n",
      "Molar average velocity of A is 0.47 cm/s\n",
      "(d) Molar flux of NH3 is 3.062E-06 gmol/cm^2.s\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYYAAAEPCAYAAABGP2P1AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XmUVOW19/HvthsURAXFSyIiGERABKeADIolojYoojGK\nOI8hGjRZud4Q9I329Zogid6oITGoiENENIqIE8SpNBBEJhFlCKAog68ag4g4gb3vH08B3W0P1d11\n6lRV/z5rndV1qp4+tT3SteuZzd0RERHZZqe4AxARkdyixCAiIhUoMYiISAVKDCIiUoESg4iIVKDE\nICIiFUSaGMzsHjP7wMwW11DmdjNbYWaLzOywKOMREZHaRV1jmAiUVPeimQ0GDnD3TsCPgDsijkdE\nRGoRaWJw978DG2oocgpwX6rsHKClmbWJMiYREalZ3H0MbYE15c7XAvvGFIuIiBB/YgCwSudao0NE\nJEbFMb//OqBdufN9U89VYGZKFiIi9eDulb981yruGsM04HwAM+sNfOLuH1RV0N11uHP99dfHHkOu\nHLoXuhe6FzUf9RVpjcHMHgKOAVqb2RrgeqAJgLuPd/dnzGywma0ENgMXRRmPiIjULtLE4O7D0ygz\nMsoYRESkbuJuSpI6SiQScYeQM3QvdtC92EH3ouGs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SsFtYJiamDSNsxSqS01RjEBGRClRjEBGRCpQYRESkAiUGERGp\nQIlBREQqUGIQEZEKlBhERKSC/wMlMWMmKfP/ywAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x3705ac8>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%matplotlib inline\n",
    "import matplotlib\n",
    "import math\n",
    "import numpy as np\n",
    "from matplotlib import pyplot as plt\n",
    "#calculation for (a) part\n",
    "l = 1         #thickness of air in cm\n",
    "pAo = 0.9     #in atm\n",
    "pAl = 0.1     #in atm\n",
    "Dab = 0.214   #in cm^2/s\n",
    "T = 298       #in K\n",
    "P = 1         #in atm\n",
    "R = 82.1      #in (cm^3)(atm)/(K)(gmol)\n",
    "#calculating molar flux of ammonia\n",
    "Na = ((Dab*P)/(R*T*l))*math.log((P-pAl)/(P-pAo))\n",
    "print '(a) The molar flux of Ammonia is:%0.3E'%Na,'gmol/cm^2.s'\n",
    "\n",
    "#calculation for (b) and (c) part\n",
    "Nb = 0        #air is non-diffusing\n",
    "U = (Na/(P/(R*T)))     #molar average velocity\n",
    "yA = pAo/P\n",
    "yB = pAl/P\n",
    "uA = U/yA           #\n",
    "uB = 0              #since Nb=0\n",
    "Ma = 17\n",
    "Mb = 29\n",
    "M = Ma*yA + Mb*yB\n",
    "u = uA*yA*Ma/M      #since u =(uA*phoA + uB*phoB)/pho\n",
    "print '(b) and (c)'\n",
    "print 'Velocity of A is %0.3f'%uA,'cm/s'\n",
    "print 'Velocity of B is %0.3f'%uB,'cm/s'\n",
    "print 'Mass average velocity of A is %0.3f'%u,'cm/s'\n",
    "print 'Molar average velocity of A is %0.2f'%U,'cm/s'\n",
    "\n",
    "#calculation for (d) part\n",
    "Ca = pAo/(R*T)\n",
    "Ia = Ca*(uA - u)      #molar flux of NH3 relative to an observer moving\n",
    "                      #with the mass average velocity \n",
    "print '(d) Molar flux of NH3 is %0.3E'%Ia,'gmol/cm^2.s'\n",
    "\n",
    "z = []\n",
    "pa =[]\n",
    "for i in np.arange(0,1,0.01):\n",
    "    z.append(i)\n",
    "    \n",
    "for i in range(0,len(z)):\n",
    "    pa.append(1-(0.1*math.exp(2.197*z[i])))\n",
    "    \n",
    "from matplotlib.pyplot import*\n",
    "plot(z,pa);\n",
    "plt.xlabel('z(cm)');\n",
    "plt.ylabel('pA(atm)');"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "##Example 2.4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a) Rate of diffusion of oxygen 7.151E-10 kmol/s\n",
      "(b) The partial pressure gradient of oxygen at midway in diffusion path is: -4.25 bar/m\n",
      "(c)\n",
      "Molar average velocity and diffusion velocities at \"midway\"\n",
      "Molar average velocity in z-direction is 9.9E-05 m/s\n",
      "The diffusion velocity of oxygen 7.9E-04 m/s\n",
      "The diffusion velocity of Nitrogen -9.9E-05 m/s\n",
      "Molar average velocity and diffusion velocities at \"top of tube\"\n",
      "Molar average velocity in z-direction is 9.9E-05 m/s\n",
      "The diffusion velocity of oxygen 3.72E-04 m/s\n",
      "The diffusion velocity of Nitrogen -9.9E-05 m/s\n",
      "Molar average velocity and diffusion velocities at \"bottom of tube\"\n",
      "Molar average velocity in z-direction is 9.9E-05 m/s\n",
      "The diffusion velocity of oxygen is not infinity\n",
      "The diffusion velocity of Nitrogen -9.9E-05 m/s\n",
      "(d)\n",
      "New molar flux of (A) 4.95E-06 kmol/m^2.s\n",
      "New molar flux of (B) 7.19E-06 kmol/m^2.s\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYoAAAEKCAYAAAAMzhLIAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHi1JREFUeJzt3XmUVNW59/HvI42CSDOIoAwCMqioiAM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iEhGShQiIpKREoWIiGSkRCEi\nIhkpUYjUk5lNM7PWOTjP9FycRyRqShQi9WBmQ4AFOZof6GHg7BycRyRSGnAnUov0qN7z0m/bAEuA\nD4FH3f259DGjgEsJk6rNcff/MrP7ge8IawJ0JMzmOxoYCLzu7qPTP9sJeLoYR9BLcVGiEKmDmZUQ\nFkG6CbgZGOzuX5vZHoT5tQ5Kv2/r7t+Y2R+Bbdz9Z2Z2AvAXwsJS84BZwJnuPid97o+Avdx9bQz/\nNJGsqOlJpG63A9PdfRLQudr8QEOARyrfu/s31X7m6fTrXOAzd3/Pw19l7xFWYau0ks1n8hRJnMRO\nCiiSBOl1lbu5+5gaPnZqX+tiQ/q1AlhfbX8Fm//eGcW5hooUEdUoRGphZvsR+h+qrwr3iZm1T28/\nD5xY+d7M2jXgMp2oYW0RkSRRjUKkdhcQpm5/IT11+xvAK4RO6SnuPs/MrgNeNLNNwJuE1QVh81rC\nljUGBzCzHQnrNqt/QhJNndki9WBmZcBJ7n5+Ds51DtDK3X/X6MBEIqSmJ5F6cPcUYSW1XAyUO4mw\ndK1IoqlGISIiGalGISIiGSlRiIhIRkoUIiKSkRKFiIhkpEQhIiIZKVGIiEhG/x/dtbi5bQDtAwAA\nAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x9dd6748>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#calculation of (a) part\n",
    "#given data\n",
    "import math\n",
    "T = 298              #in kelvin\n",
    "P = 1.013            #in bar\n",
    "pAl = 0              #partial pressure of oxygen(A) at liquid surface\n",
    "pAo = 0.21*1.013     #partial pressure of oxygen at open mouth\n",
    "l = 0.05             #length of diffusion path in m\n",
    "Dab = 2.1e-5         #diffusivity in m^2/s\n",
    "R = 0.08317          #in m^3.bar.kmol.K\n",
    "Na = Dab*P*math.log((P-pAl)/(P-pAo))/(R*T*l)       #in kmol/m^2.s\n",
    "area = (math.pi/4)*(0.015)**2\n",
    "rate = area*Na\n",
    "print '(a) Rate of diffusion of oxygen %0.3E'%rate,'kmol/s'\n",
    "z = []\n",
    "pa =[]\n",
    "for i in np.arange(0,1,0.01):\n",
    "    z.append(i)\n",
    "    \n",
    "for i in range(0,len(z)):\n",
    "    pa.append(P-(P-pAo)*math.exp((R*T*Na*z[i])/(Dab*P)))\n",
    "    \n",
    "from matplotlib.pyplot import*\n",
    "plot(z,pa);\n",
    "plt.xlabel('z(cm)');\n",
    "plt.ylabel('pA(atm)');\n",
    "\n",
    "#calculation of (b) part\n",
    "z = 0.025           #diffusion path\n",
    "pA = 0.113          #in bar\n",
    "#we have to find partial pressure gradient of oxygen at mid way of diffusion path\n",
    "#let dpA/dz = ppd\n",
    "ppd = -(R*T*round(Na,8)*(P-pA))/(Dab*P)\n",
    "print '(b) The partial pressure gradient of oxygen at midway in diffusion path is: %0.2f'%ppd,'bar/m'\n",
    "\n",
    "#calculation of (c) part\n",
    "uA = Na*(R*T/pA)     #velocity of oxygen\n",
    "uB = 0               #since nitrogen is non-diffusing hence Nb = 0\n",
    "U = pA*uA/P          #since U=1/C*(uA*Ca + uB*Cb)\n",
    "vAd = uA - U         #diffusion velocity of oxygen\n",
    "vBd = uB - U         #diffusion velocity of nitrogen\n",
    "print '(c)'\n",
    "print 'Molar average velocity and diffusion velocities at \"midway\"'\n",
    "print 'Molar average velocity in z-direction is %0.1E'%U,'m/s'\n",
    "print 'The diffusion velocity of oxygen %0.1E'%vAd,'m/s'\n",
    "print 'The diffusion velocity of Nitrogen %0.1E'%vBd,'m/s'\n",
    "#at z=0(at top of tube)\n",
    "uA = Na*(R*T/pAo)\n",
    "uB = 0\n",
    "U = pAo*uA/P\n",
    "vAd = uA - U\n",
    "vBd = uB - U\n",
    "print 'Molar average velocity and diffusion velocities at \"top of tube\"'\n",
    "print 'Molar average velocity in z-direction is %0.1E'%U,'m/s'\n",
    "print 'The diffusion velocity of oxygen %0.2E'%vAd,'m/s'\n",
    "print 'The diffusion velocity of Nitrogen %0.1E'%vBd,'m/s'\n",
    "#at z=0.05(at bottom of tube)\n",
    "#uA = inf\n",
    "uB = 0\n",
    "U = pAo*uA/P\n",
    "vAd = uA - U\n",
    "vBd = uB - U\n",
    "print 'Molar average velocity and diffusion velocities at \"bottom of tube\"'\n",
    "print 'Molar average velocity in z-direction is %0.1E'%U,'m/s'\n",
    "print 'The diffusion velocity of oxygen is not infinity'\n",
    "print 'The diffusion velocity of Nitrogen %0.1E'%vBd,'m/s'\n",
    "\n",
    "#calculation of (d) part\n",
    "V = -2*U\n",
    "pA = 0.113\n",
    "Nad = round(Na,8) - V*(pA/(R*T))\n",
    "Nbd = 0 - (P - pA)*V/(R*T)\n",
    "print '(d)'\n",
    "print 'New molar flux of (A) %0.2E'%Nad,'kmol/m^2.s'\n",
    "print 'New molar flux of (B) %0.2E'%Nbd,'kmol/m^2.s'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example 2.5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a) The air-film thickness is :0.00193 m\n"
     ]
    }
   ],
   "source": [
    "#given data\n",
    "area = 3*4           #in m^2\n",
    "mperarea = 3.0/12    #in kg/m^2\n",
    "#part (a)\n",
    "P = 1.013            #in bar\n",
    "Dab = 9.95e-6        #in m^2/s\n",
    "R = 0.08317          #in m^3.bar./K.kmol\n",
    "T = 273+27           #in K\n",
    "#let d=1\n",
    "d = 1                #in m\n",
    "pAo = 0.065          #partial pressure of alcohol on liquid surface\n",
    "pAd = 0              #partial pressure over d length of stagnant film of air\n",
    "Na = (Dab*P*math.log((P-pAd)/(P-pAo)))/(R*T*d)     #in kmol/m^2.s\n",
    "Na = Na*60           #in kg/m^2.s\n",
    "flux = mperarea/(5*60)   #since the liquid evaporates completely in 5 minutes\n",
    "#now we have to find the value of d\n",
    "d = Na/flux\n",
    "print '(a) The air-film thickness is :%0.5f'%d,'m'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example 2.6"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a)\n",
      "The steady-state flux is: 3.35E-06 kmol/m^2.s\n",
      "The rate of transport of N2 from vessel 1 to 2: 6.6E-09 kmol/s\n",
      "(b)\n",
      "The flux and the rate of transport of oxygen is: -3.35E-06 kmol/m^2.s\n",
      "(c)\n",
      "Partial pressure at a point 0.05m from vessel 1 is: 1.2 atm\n",
      "(d)\n",
      "Net or total mass flux: -1.340E-05 kmol/m^2.s\n"
     ]
    }
   ],
   "source": [
    "#given data\n",
    "#part (a)\n",
    "Dab = 0.23e-4*0.5*(293.0/316)**1.75     #in m^2/s\n",
    "pA1 = 2*0.8           #in atm\n",
    "pA2 = 2*0.2           #in atm\n",
    "l = 0.15              #in m\n",
    "R = 0.0821            #in m^3.atm./K.kmol\n",
    "T = 293               #in K\n",
    "Ma = 28\n",
    "Mb = 32\n",
    "Na = Dab*(pA1-pA2)/(R*T*l)   #in kmol/m^2.s\n",
    "area = math.pi/4*(0.05)**2     #in m^2\n",
    "rate = area*Na\n",
    "print '(a)'\n",
    "print 'The steady-state flux is: %0.2E'%Na,'kmol/m^2.s'\n",
    "print 'The rate of transport of N2 from vessel 1 to 2: %0.1E'%rate,'kmol/s'\n",
    "\n",
    "#part (b)\n",
    "Nb = -Na\n",
    "print '(b)'\n",
    "print 'The flux and the rate of transport of oxygen is: %0.2E'%Nb,'kmol/m^2.s'\n",
    "\n",
    "#part (c)\n",
    "#let dpA/dz = ppg\n",
    "dz = 0.05               #in m\n",
    "ppg = (pA2 - pA1)/l     #in atm/m\n",
    "pA = pA1 + (ppg)*dz     #in atm\n",
    "print '(c)'\n",
    "print 'Partial pressure at a point 0.05m from vessel 1 is: %0.1f'%pA,'atm'\n",
    "\n",
    "#part (d)\n",
    "nt = Ma*Na + Mb*Nb\n",
    "print '(d)'\n",
    "print 'Net or total mass flux: %0.3E'%nt,'kmol/m^2.s'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example 2.7"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Methanol flux: 4.64e-05 kmol/m^2.s\n",
      "Water flux: -4.06e-05 kmol/m^2.s\n"
     ]
    }
   ],
   "source": [
    "#given data\n",
    "Ha = 274.6*32     #molar latent heat of methanol(a)\n",
    "Hb = 557.7*18     #molar latent heat of water(b)\n",
    "yAl = 0.76        #mole fraction of methanol in the vapour\n",
    "yAo = 0.825       #mole fraction of methanol in the vapour at the liquid-vapour interface\n",
    "P = 1             #in atm\n",
    "l = 1e-3          #in m\n",
    "T =344.2          #in K\n",
    "R = 0.0821        #m^3.atm./K.kmol\n",
    "Dab = 1.816e-5    #in m^2/s\n",
    "Na = Dab*P*math.log((1-0.1247*yAl)/(1-0.1247*yAo))/(0.1247*R*T*l)\n",
    "print 'Methanol flux: %0.2e'%Na,'kmol/m^2.s'\n",
    "Nb = -(Ha/Hb)*Na\n",
    "print 'Water flux: %0.2e'%Nb,'kmol/m^2.s'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example 2.8"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Value of pA1 is 0.937 atm\n"
     ]
    }
   ],
   "source": [
    "#given values\n",
    "import math\n",
    "V1 = 3000      #in cm^3\n",
    "V2 = 4000      #in cm^3\n",
    "Dab = 0.23     #in cm^2/s\n",
    "Dba = 0.23     #in cm^2/s\n",
    "l1 = 4         #in cm\n",
    "d1 = 0.5       #in cm\n",
    "l2 = 2         #in cm\n",
    "d2 = 0.3       #in cm\n",
    "pA3 = 1        #in atm\n",
    "#unknowns\n",
    "# pA1   and   pA2\n",
    "# dpA1bydt = (Dab/V1*l1)*((pA1)-(pA2))*((math.pi*(d1**2))/4)\n",
    "#on integrating using Laplace trandformation\n",
    "# initial conditions\n",
    "t=18000       #in seconds\n",
    "pA1 = 1-0.57*(math.exp((-1.005)*(10**(-6))*t)-math.exp((-7.615)*(10**(-6))*t))\n",
    "print 'Value of pA1 is %0.3f'%pA1,'atm'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "##Example 2.10"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Value of flux of water vapour: 2.96E-05 kmol/m^2.s\n"
     ]
    }
   ],
   "source": [
    "#given values\n",
    "import math\n",
    "y1l = 0           #mol fraction of dry air\n",
    "y10 = (17.53/760) #mol fraction of water\n",
    "l = 1.5           #in mm\n",
    "C = 0.0409        #in kmol/m^3 : calculated by P/RT\n",
    "D12 = 0.923       #Diffusivity of hydrogen over water\n",
    "D13 = 0.267       #Diffusivity of oxygen over water\n",
    "y2 = 0.6          #mole fraction of hydrogen\n",
    "y3 = 0.4          #mole fraction of oxygen\n",
    "D1m = 1/((y2/D12)+(y3/D13))       #calculating mean diffusivity\n",
    "Ni = (D1m*C*1000/(l*10000))*math.log((1-y1l)/(1-y10))\n",
    "print 'Value of flux of water vapour: %0.2E'%Ni,'kmol/m^2.s'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example 2.11"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Flux of ethane 4.804E-05 gmol/cm^2.s\n"
     ]
    }
   ],
   "source": [
    "#given data\n",
    "y1 = 0.4          #mole fraction of ethane(1)\n",
    "y2 = 0.3          #mole fraction of ethylene(2)\n",
    "y3 = 0.3          #mole fraction of hydrogen(3)\n",
    "#calculating D13\n",
    "#The Lennard-Jones parameters are\n",
    "sigma1 = 4.443    #in angstrom\n",
    "sigma2 = 4.163    #in angstrom\n",
    "sigma3 = 2.827    #in angstrom\n",
    "e1byk = 215.7\n",
    "e2byk = 224.7\n",
    "e3byk = 59.7\n",
    "sigma13 = (sigma1 + sigma3)/2     #in angstrom\n",
    "e13byk = (e1byk*e3byk)**0.5\n",
    "kTbye13 = 993/113.5\n",
    "ohmD13 = 0.76      #from collision integral table\n",
    "D13 = ((0.001858)*(993**1.5)*((1.0/30)+(1.0/2))**0.5)/((2)*(sigma13**2)*(ohmD13))\n",
    "#calculating D23\n",
    "sigma23 = (sigma2+sigma3)/2\n",
    "kTbye23 = ((993/224.7)*(993/59.7))*0.5\n",
    "ohmD23 = 0.762\n",
    "D23 = (0.001858*(993**1.5)*((1.0/28)+(1.0/2))**0.5)/(2*(sigma23**2)*ohmD23)\n",
    "D = (D13+D23)/2   #in cm^2/s\n",
    "l = 0.15          #in cm\n",
    "#at z=0 (bulk gas)\n",
    "y10 = 0.6\n",
    "y20 = 0.2\n",
    "y30 = 0.2\n",
    "#at z=l (catalyst surface)\n",
    "y1l = 0.4\n",
    "y2l = 0.3\n",
    "y3l = 0.3\n",
    "C = 2.0/(82.1*993)   #calculated by P/RT\n",
    "N1 = (D*C/l)*math.log((y10+y20)/(y1l+y2l))\n",
    "print 'Flux of ethane %0.3E'%N1,'gmol/cm^2.s'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}