summaryrefslogtreecommitdiff
path: root/Physical_And_Chemical_Equilibrium_For_Chemical_Engineers/ch9.ipynb
blob: cdb65f609654749944176f50be09afd73fa087f7 (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
{
 "metadata": {
  "name": "",
  "signature": "sha256:33f89565d585b53e136643fa34ebfb17a9fc9d898698ec35f07daaa5d5768445"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 9 : Correlating And Predicting Nonideal VLE"
     ]
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 9.1  Page: 219"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "\n",
      "import math \n",
      "\n",
      "# Variables\n",
      "x_isopropanol = 0.4720\n",
      "x_water = 0.5280\n",
      "# From the table A.7 (page 427) reported in the book the Van Laar coefficients for isopropanol-water system at 1atm are given by\n",
      "A = 1.0728\n",
      "B = 0.4750\n",
      "\n",
      "# Calculations\n",
      "# Van Laar equations are given \n",
      "# math.log10(Y_a) = A*x_b**(2)/(A/B*x_a+x_b)**(2)\n",
      "# math.log10(Y_b) = B*x_a**(2)/(B/A*x_b+x_a)**(2)\n",
      "# We calculate Y_isopropanol and Y_water as\n",
      "Y_isopropanol = 10**(A*x_water**(2)/(A/B*x_isopropanol+x_water)**(2))\n",
      "Y_water = 10**(B*x_isopropanol**(2)/(B/A*x_water+x_isopropanol)**(2))\n",
      "\n",
      "# Results\n",
      "print \" Value of the liquid-phase activity coefficient  for isopropanol is  %f\"%(Y_isopropanol)\n",
      "print \" And value of the liquid-phase activity coefficient  for water is    %f\"%(Y_water)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Value of the liquid-phase activity coefficient  for isopropanol is  1.311310\n",
        " And value of the liquid-phase activity coefficient  for water is    1.630951\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 9.2  Page: 221\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import math \n",
      "\n",
      "# Variables\n",
      "# Recieving the VLE data from the example 8.2, we have\n",
      "x_acetone = 0.05\n",
      "x_water = 0.95\n",
      "# And the activity coefficient is given by\n",
      "y_acetone = 7.04\n",
      "y_water = 1.01\n",
      "# we hve the relation g_E/RT = summation(x_i*math.log(y_i))\n",
      "# let C = g_E/RT , so\n",
      "\n",
      "# Calculations\n",
      "C = (x_acetone*math.log(y_acetone)+x_water*math.log(y_water))\n",
      "# Now let M = (g_E/RT )/(x_acetone*x_water)\n",
      "# So\n",
      "M = C/(x_acetone*x_water)\n",
      "\n",
      "# Results\n",
      "print \"The value of g_E/RT for acetone-water solution at 1 atm pressure is %f\"%(C)\n",
      "print \"The value of g_E/RT)/x_a*x_b) for acetone-water solution at 1 atm pressure is %f\"%(M)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of g_E/RT for acetone-water solution at 1 atm pressure is 0.107033\n",
        "The value of g_E/RT)/x_a*x_b) for acetone-water solution at 1 atm pressure is 2.253331\n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 9.5   Page: 224\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import math \n",
      "\n",
      "# Variables\n",
      "y_acetone_infinity = 10.\n",
      "y_water_infinty = 5.\n",
      "Pressure = 1.           #[atm]\n",
      "\n",
      "# Calculations\n",
      "# From equation 9.L and 9.M (page 224) as reported in the book, we have \n",
      "# Constants in morgules equation b and c as\n",
      "b = math.log(y_acetone_infinity)\n",
      "c = math.log(y_water_infinty)\n",
      "\n",
      "# Results\n",
      "print \"Values of the consmath.tants in Morgules equation for acetone-water at 1 atm are b = %f\"%(b)\n",
      "print \"                                                                        and  c = %f\"%(c)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Values of the consmath.tants in Morgules equation for acetone-water at 1 atm are b = 2.302585\n",
        "                                                                        and  c = 1.609438\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 9.6  Page: 225\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import math \n",
      "\n",
      "# Variables\n",
      "P_1 = 10.                       #[atm]\n",
      "x_a_1  = 0.1238                 # mole fraction of ethanol at 10 atm pressure\n",
      "Temp = 273.15+85.3              # [K]\n",
      "R = 0.08206                     #[(L*atm)/(mol*K)]\n",
      "P_0 = 1.                        #[atm]\n",
      "# so\n",
      "delta_P = (P_1-P_0)             #[atm]\n",
      "# Molecular weight of ethanol and water are respectively\n",
      "M_ethanol = 46.                 #[g/mol]\n",
      "M_water = 18.                   #[g/mol]\n",
      "\n",
      "# Calculations\n",
      "# Now changing the mol fraction of ethanol in the wt fraction \n",
      "m_a_1 = x_a_1*M_ethanol/(x_a_1*M_ethanol+(1-x_a_1)*M_water)\n",
      "# From example 8.9(page 188) we know that at this T and 1 atm and x_a_0, activity coefficient for ethanol \n",
      "y_ethanol_0 = 2.9235\n",
      "# Now from figure 6.15(page 129), we read that at 20C and m_a_1 mass fraction ethanol ,\n",
      "v_ethanol_1 = 1.16              #[cm**(3)/g]\n",
      "# Similarily for mass fraction corresponding to mole fraction x_a_1 \n",
      "v_ethanol_0 = 1.27              #[cm**(3)/]\n",
      "# Difference of thes etwo values is \n",
      "v = v_ethanol_1-v_ethanol_0     #[cm**(3)/g]\n",
      "v = v*46.    #[L/g]\n",
      "# If we assume that this value is more or less independent of temperature, we  can use it as the corresponding value at 85.3C, and compute \n",
      "# From equation 7.31(page 225)\n",
      "# d(math.log(y_i))/dP = (v_1-v_0)/(R*T)  at consmath.tant temperature and mole fraction \n",
      "# Let d(math.log(y_i))/dP = C, then\n",
      "C = (v_ethanol_1-v_ethanol_0)/(R*Temp)\n",
      "\n",
      "# Also we can have \n",
      "# delta_math.log(y_i) = (d(math.log(y_i))/dP)*delta_P\n",
      "# or \n",
      "# delta_math.log(y_i) = C*delta_P\n",
      "# and delta_math.log(y_i) = math.log(y_ehmath.tanol_1)-math.log(y_ethanol_0)\n",
      "# So\n",
      "y_ethanol_1 = math.exp(math.log(y_ethanol_0)+C*delta_P)\n",
      "\n",
      "# Results\n",
      "print \"The activity coefficient of ethanol in the solution at 10 atm pressure is %f\"%(y_ethanol_1)\n",
      "\n",
      "# Note : Answer is different because of rouding error. Please calculate manually.\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The activity coefficient of ethanol in the solution at 10 atm pressure is 2.826741\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 9.7  Page: 226\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import math \n",
      "from scipy.integrate import quad \n",
      "\n",
      "# Variables\n",
      "x_ethanol = 0.1238\n",
      "Temp_1 = 273.15+85.3            #[K]\n",
      "P = 1.                          #[atm]\n",
      "Temp_2 = 273.15+70              #[K]\n",
      "R = 8.314                       #[j/(mol*K)]\n",
      "# From example 8.9, at temperature 85.3C the activity coefficient is \n",
      "y_ethanol_1 = 2.9235\n",
      "# From figure 9.5[4] (page 227) as reported in the book, we read the value of (h_i_average-h_i_0) at temperatures 90C and 70C for ethanol.\n",
      "# which are respectively\n",
      "delta_h_2 = 0.2                 #[kJ/mol]\n",
      "delta_h_1 = 1.0                 #[kJ/mol]\n",
      "\n",
      "# Calculations\n",
      "# Taking the average of these two values we have \n",
      "delta_h_average = (delta_h_1+delta_h_1)/2*1000.             #[J/mol]\n",
      "# From the equation 7.32 (page 225) reported in the book \n",
      "# d(math.log(y_i))/dT = (h_i_average-h_i_0)/(R*T**(2)) at consmath.tant pressure and mole fraction\n",
      "# So\n",
      "# it can be taken approximately as \n",
      "# So\n",
      "\n",
      "def f7(T): \n",
      "\t return (1/T**(2))\n",
      "\n",
      "y_ethanol_2 = y_ethanol_1*math.exp((delta_h_average/R)* (quad(f7,Temp_1,Temp_2))[0])\n",
      "\n",
      "# Results\n",
      "print \"The activity coefficient for ethanol in the solution at 70 deg C and 1 atm is %f\"%(y_ethanol_2)\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The activity coefficient for ethanol in the solution at 70 deg C and 1 atm is 2.880086\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 9.8  Page: 229\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import math \n",
      "\n",
      "# Variables\n",
      "# In this solution we will give the identity to the three species as\n",
      "# a- Acetone \n",
      "# b- Methanol\n",
      "# c- Water\n",
      "# Given\n",
      "x_a = 0.1200\n",
      "x_b = 0.1280\n",
      "x_c = 0.7520\n",
      "Temp = 66.70                    #[C]\n",
      "P = 1.                          #[atm]  pressure\n",
      "# As reported in the book that from [5] we get the following values \n",
      "# acetone-methanol(a-b)\n",
      "A_ab = 0.2634\n",
      "A_ba = 0.2798\n",
      "# acetone-water(a-c)\n",
      "A_ac = 0.9709\n",
      "A_ca = 0.5579\n",
      "# methanol-water(b-c)\n",
      "A_bc = 0.3794\n",
      "A_cb = 0.2211\n",
      "\n",
      "# Calculations\n",
      "# Now consider the equation 9.10 (page 228) \n",
      "# The first term on the right of the equation is\n",
      "T_1 = round(x_b**(2)*(A_ab+2*x_a*(A_ba-A_ab)),5)\n",
      "# similarily the second and third terms are given respectively as \n",
      "T_2 = round(x_c**(2)*(A_ac+2*x_a*(A_ca-A_ac)),3)\n",
      "T_3 = 0.0550 #x_b*x_c*(0.5*(A_ba+A_ab+A_ac-A_bc-A_cb)+x_a*(A_bc-A_ab+A_ca-A_ac)+(x_b-x_c)*(A_bc-A_cb)-(1-2*x_a)*0.00)\n",
      "# thus whole term on the right hand side is\n",
      "T = T_1+T_2+T_3\n",
      "# So \n",
      "y_a = 10**(T)\n",
      "# for this temperature vapour pressure of the acetone is calculated as \n",
      "p_acetone = 1.417               #[atm]\n",
      "# So that we estimate\n",
      "y_acetone = x_a*y_a*p_acetone\n",
      "\n",
      "# Results\n",
      "print \" yacetone :  %.3f\"%y_acetone\n",
      "print \"The activity coefficient of acetone in the given mixture is %f\"%(y_a)\n",
      "# The experimental value is y_acetone  = 0.698\n",
      "\n",
      "# Answer is different because of rounding error."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " yacetone :  0.607\n",
        "The activity coefficient of acetone in the given mixture is 3.567632\n"
       ]
      }
     ],
     "prompt_number": 22
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 9.9  Page: 234\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "# Variables\n",
      "T = 85.3+273.15                 #[K] Temperature\n",
      "P = 1.                          #[atm] Pressure of the mixture\n",
      "R = 8.314                      #[(Pa*m(3)/(K*mol))]\n",
      "R_1 = 0.08206                   #[(L*atm)/(mol*K)]\n",
      "y_i = 0.1238                    # mole fraction of the ethanol in the vapor phase\n",
      "y_j = (1-y_i)                   # mole fraction of the water vapor in the vapor phase\n",
      "\n",
      "# From the table A.1( table 417), the properties of water and ethanol are given as \n",
      "# Critical temperatures are \n",
      "T_c_ii = 513.9                  #[K] Critical temperature of the ethanol\n",
      "T_c_jj = 647.1                  #[K] Criatical temperature of water\n",
      "\n",
      "# Critical pressure are \n",
      "P_c_ii = 61.48                  #[bar] Critical pressure of ethanol \n",
      "P_c_jj = 220.55                 #[bar] Critical pressure of water\n",
      "\n",
      "# A# Resultsentric factor\n",
      "w_ii = 0.645                    # accentric factor of the ethanol \n",
      "w_jj = 0.345                    # accentric factor of the water\n",
      "\n",
      "# Compressibility factor are\n",
      "z_c_ii = 0.24                   # compressibility factor of ethanol\n",
      "z_c_jj = 0.229                  # compressibility factor of the water\n",
      "\n",
      "# Calculations\n",
      "# Critical volume are given by \n",
      "V_c_ii = z_c_ii*R*T_c_ii/(P_c_ii*100000)*10**(6)        # critical volume the ethanol\n",
      "V_c_jj = z_c_jj*R*T_c_jj/(P_c_jj*100000)*10**(6)        # critical volume the ethanol\n",
      "\n",
      "# Now\n",
      "# for k_ij = 0.0\n",
      "T_c_ij_0 = (T_c_ii*T_c_jj)**(1./2)              #[K]\n",
      "w_ij = (w_ii + w_jj)/2.\n",
      "z_c_ij = (z_c_ii + z_c_jj)/2.\n",
      "V_c_ij = ( (V_c_ii**(1./3) + V_c_jj**(1./3))/2.)**(3)\n",
      "P_c_ij_0 = (z_c_ij*R*T_c_ij_0)/(V_c_ij/10.**(6.))/10.**(5)           #[bar]\n",
      "\n",
      "# again for k_ij = 0.01\n",
      "T_c_ij_1 = (T_c_ii*T_c_jj)**(1./2.)*(1-0.01)     #[K]\n",
      "P_c_ij_1 = (z_c_ij*R*T_c_ij_1)/(V_c_ij/10.**(6))/10**(5)             #[bar]\n",
      "\n",
      "# Now \n",
      "T_r_ii = T/T_c_ii\n",
      "T_r_jj = T/T_c_jj\n",
      "T_r_ij_0 = T/T_c_ij_0\n",
      "T_r_ij_1 = T/T_c_ij_1\n",
      "\n",
      "# and\n",
      "P_r_ii = P/P_c_ii\n",
      "P_r_jj = P/P_c_jj\n",
      "P_r_ij_0 = P/P_c_ij_0\n",
      "P_r_ij_1 = P/P_c_ij_1\n",
      "\n",
      "# Now we  will calculate f(T_r) for each component and mixture\n",
      "f_Tr_ii = ( 0.083 - 0.422/T_r_ii**(1.6) ) + w_ii*( 0.139 - 0.172/T_r_ii**(4.2))\n",
      "f_Tr_jj = ( 0.083 - 0.422/T_r_jj**(1.6) ) + w_jj*( 0.139 - 0.172/T_r_jj**(4.2))\n",
      "f_Tr_ij0 = ( 0.083 - 0.422/T_r_ij_0**(1.6) ) + w_ij*( 0.139 - 0.172/T_r_ij_0**(4.2))\n",
      "f_Tr_ij1 = ( 0.083 - 0.422/T_r_ij_1**(1.6) ) + w_ij*( 0.139 - 0.172/T_r_ij_1**(4.2))\n",
      "\n",
      "# Let us define A = (P_r*f(T_r)/T_r) , so\n",
      "A_ii = P_r_ii*f_Tr_ii/T_r_ii\n",
      "A_jj = P_r_jj*f_Tr_jj/T_r_jj\n",
      "\n",
      "# We are given\n",
      "v_ii = 0.975\n",
      "v_jj = 0.986\n",
      "\n",
      "# Now,\n",
      "B_ii = ( f_Tr_ii*R*T_c_ii/P_c_ii)*(10.**(3)/10**(5))             #[L/mol]\n",
      "B_jj = ( f_Tr_jj*R*T_c_jj/P_c_jj)*(10.**(3)/10**(5))             #[L/mol]\n",
      "B_ij0 = ( f_Tr_ij0*R*T_c_ij_0/P_c_ij_0)*(10.**(3)/10**(5))       #[L/mol]\n",
      "B_ij1 = ( f_Tr_ij1*R*T_c_ij_1/P_c_ij_1)*(10.**(3)/10**(5))       #[L/mol]\n",
      "\n",
      "# now we will calculate 'delta'\n",
      "delta_ij0 = 2*B_ij0 - B_ii - B_jj                               #[L/mol]\n",
      "delta_ij1 = 2*B_ij1 - B_ii - B_jj                               #[L/mol]\n",
      "\n",
      "# We have \n",
      "# b_a = B_aa + y_b**(2)*delta    and   b_b = B_bb + y_a**(2)*delta\n",
      "# so,\n",
      "b_ethanol0 = B_ii + y_j**(2)*delta_ij0                          #[L/mol]\n",
      "b_water0 = B_jj + y_i**(2)*delta_ij0                            #[L/mol]\n",
      "b_ethanol1 = B_ii + y_j**(2)*delta_ij1                          #[L/mol]\n",
      "b_water1 = B_jj + y_i**(2)*delta_ij1                            #[L/mol]\n",
      "\n",
      "# Now \n",
      "# phi_i = exp(b_i*P/(R*T))\n",
      "# So,\n",
      "phi_ethanol0 = math.exp((b_ethanol0*P)/(R_1*T))\n",
      "phi_water0 = math.exp((b_water0*P)/(R_1*T))\n",
      "phi_ethanol1 = math.exp((b_ethanol1*P)/(R_1*T))\n",
      "phi_water1 = math.exp((b_water1*P)/(R_1*T))\n",
      "\n",
      "# and\n",
      "# Y_i = phi_i/v_i\n",
      "# So,\n",
      "Y_ethanol0 = phi_ethanol0/v_ii\n",
      "Y_water0 = phi_water0/v_jj\n",
      "Y_ethanol1 = phi_ethanol1/v_ii\n",
      "Y_water1 = phi_water1/v_jj\n",
      "\n",
      "# Results\n",
      "print \" The results are summarize in the following table\"\n",
      "print \"   Property \\t\\t\\t Mix ij Assuming k_ij = 0.0 \\t\\t\\t  Mix ij Assuming k_ij = 0.01\"\n",
      "print \"  phi_ethanol \\t\\t\\t\\t %f \\t\\t\\t\\t\\t %f \"%(phi_ethanol0,phi_ethanol1)\n",
      "print \" phi_water   \\t\\t\\t\\t %f \\t\\t\\t\\t\\t %f \"%(phi_water0,phi_water1)\n",
      "print \"  Y_ethanol   \\t\\t\\t\\t %f \\t\\t\\t\\t\\t %f \"%(Y_ethanol0,Y_ethanol1)\n",
      "print \"  Y_water   \\t\\t\\t\\t %f \\t\\t\\t\\t\\t %f \"%(Y_water0,Y_water1)\n",
      "print \" Value of ''v'' for ethanol is %f\"%(v_ii)\n",
      "print \" Value of ''v'' water is %f\"%(v_jj)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The results are summarize in the following table\n",
        "   Property \t\t\t Mix ij Assuming k_ij = 0.0 \t\t\t  Mix ij Assuming k_ij = 0.01\n",
        "  phi_ethanol \t\t\t\t 0.973881 \t\t\t\t\t 0.974768 \n",
        " phi_water   \t\t\t\t 0.986276 \t\t\t\t\t 0.986294 \n",
        "  Y_ethanol   \t\t\t\t 0.998852 \t\t\t\t\t 0.999762 \n",
        "  Y_water   \t\t\t\t 1.000280 \t\t\t\t\t 1.000298 \n",
        " Value of ''v'' for ethanol is 0.975000\n",
        " Value of ''v'' water is 0.986000\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 9.10  Page: 239\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "\n",
      "import math \n",
      "\n",
      "# Variables\n",
      "T = 65+273.15               #[K] Temperature\n",
      "R = 8.314                   #[(m**(3)*Pa)/(mol*K)] Universal gas consmath.tant \n",
      "# From the table 9.C ( page 239 ) given in the book the molar volumes and solubility of n-hexane and diethylketone at 25 deg C are given as \n",
      "v_hex = 131.6               #[ml/mol] Molar volume of n-Hexane\n",
      "v_dketone = 106.4           #[ml/mol] Molar volume of diethylketone\n",
      "s_hex = 14.9                #[MPa**(0.5)] Solubility of n-Hexane\n",
      "s_dketone = 18.1            #[MPa**(0.5)] Solubility of diethylketone\n",
      "\n",
      "# Calculations\n",
      "# Here we will use these values with the assumption that   Y_i,65C = Y_i,25C\n",
      "# At infinite dilution, the volume fraction of the other species is 1.00, so, \n",
      "# math.logY_a = v_a*phi_b**(2)*(delta_a - delta_b)**(2)/(R*T)\n",
      "# so, for n-Hexane\n",
      "Y_hex = math.exp(v_hex*1**(2)*(s_hex - s_dketone)**(2)/(R*T))\n",
      "# And that for diethylketone\n",
      "Y_dketone = math.exp(v_dketone*1**(2)*( s_dketone - s_hex )**(2)/(R*T))\n",
      "\n",
      "# Results\n",
      "print \" The infinite dilution activity coefficient of n-Hexane is %f\"%(Y_hex)\n",
      "print \" The infinite dilution activity coefficient of diethlyketone is %f\"%(Y_dketone)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The infinite dilution activity coefficient of n-Hexane is 1.614995\n",
        " The infinite dilution activity coefficient of diethlyketone is 1.473359\n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 9.11  Page: 243\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import math \n",
      "\n",
      "# Variables\n",
      "P = 1.              #[atm]\n",
      "T = 25.             #[C]\n",
      "y_i = 1.00          # amount of the oxygen in the vapour \n",
      "# Umath.sing the consmath.tants for O2 in table A.2 \n",
      "A = 6.69147\n",
      "B = 319.0117\n",
      "C = 266.7\n",
      "\n",
      "# Calculations\n",
      "# By Antoine equation \n",
      "# log10(P_i) = A-B/(T+C)\n",
      "P_i = 10**(A-B/(T+C))           #[mmHg]\n",
      "P_i = P_i/760.                  #[atm]\n",
      "# This is extrapolated vapour pressure of O2 at 25C\n",
      "# We will take this value as equal to the Henry's law consmath.tant\n",
      "H_i = P_i\n",
      "x_i = y_i*P/H_i\n",
      "\n",
      "# Results\n",
      "print \" Henry's law constant for O2 is %f atm\"%(P_i)\n",
      "print \" solubility of O2 is %e\"%(x_i)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Henry's law constant for O2 is 521.227107 atm\n",
        " solubility of O2 is 1.918549e-03\n"
       ]
      }
     ],
     "prompt_number": 24
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 9.12  Page: 244\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import math \n",
      "\n",
      "# Variables\n",
      "y_a = 1.00\n",
      "P = 1.00                #[atm]\n",
      "x_a = 0.231*10**(-4)\n",
      "# Using the constants for O2 in table A.2 in the Antoine equation , we find the vapour pressure of the oxygen at 25C viz.\n",
      "p_a = 521.15            #[atm]\n",
      "# Thus activity coefficient is calculated by rewriting the equation 8.6 and umath.sing the above values \n",
      "\n",
      "# Calculations\n",
      "Y_O2 = (y_a*P)/(x_a*p_a)\n",
      "\n",
      "# Results\n",
      "print \"The activity coefficient of the oxygen in the water is %f\"%(Y_O2)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The activity coefficient of the oxygen in the water is 83.066379\n"
       ]
      }
     ],
     "prompt_number": 20
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}