summaryrefslogtreecommitdiff
path: root/Chemical_Engineering_Thermodynamics_by_P_Ahuja/ch16_1.ipynb
blob: 1053ca6c4f0fba110fd7f7d4ce509e3b79451ccb (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
{
 "metadata": {
  "name": "ch16_1",
  "signature": "sha256:a00a89ec39a5812cdf143d7f00f601a0bb401404f1638737e2689f71d07acb65"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 16 : Other Phase Equilibria"
     ]
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 16.1  Page Number : 564"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import math \n",
      "\n",
      "# Variables\t\t\t\n",
      "T = 0 + 273.15;\t\t\t#[K] - Temperature\n",
      "P = 20*10**(5);\t\t\t#[Pa] - Pressure\n",
      "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
      "\n",
      "\t\t\t#componenet 1 : methane (1)\n",
      "\t\t\t#componenet 2 : methanol (2)\n",
      "\n",
      "H_constant = 1022;\t\t\t#[bar] - Henry's law constant\n",
      "H_constant = H_constant*10**(5);\t\t\t#[Pa]\n",
      "\n",
      "\t\t\t# The second virial coefficients are\n",
      "B_11 = -53.9;\t\t\t#[cm**(3)/mol]\n",
      "B_11 = B_11*10**(-6);\t\t\t#[m**(3)/mol]\n",
      "B_12 = -166;\t\t\t#[cm**(3)/mol]\n",
      "B_12 = B_12*10**(-6);\t\t\t#[m**(3)/mol]\n",
      "B_22 = -4068;\t\t\t#[cm**(3)/mol]\n",
      "B_22 = B_22*10**(-6);\t\t\t#[m**(3)/mol]\n",
      "\n",
      "den_meth = 0.8102;\t\t\t#[g/cm**(3)] - Density of methanol at 0 C\n",
      "Mol_wt_meth = 32.04;\t\t\t# Molecular weight of methanol\n",
      "P_2_sat = 0.0401;\t\t\t#[bar] - Vapour pressure of methanol at 0 C\n",
      "\n",
      "# Calculations\n",
      "\t\t\t#The molar volume of methanol can be calculated as\n",
      "V_2_liq = (1/(den_meth/Mol_wt_meth))*10**(-6);\t\t\t#[m**(3)/mol]\n",
      "\n",
      "\t\t\t#The phase equilibrium equation of the components at high pressure\n",
      "\t\t\t#y1*phi_1*P = x_1*H_1\n",
      "\t\t\t#y2*phi_2*P = x_2*H_2\n",
      "\n",
      "\t\t\t#Since methane follows Henry's law therefore methanol follows the lewis-Rnadall rule\n",
      "\t\t\t#f_2 is the fugacity of the compressed liquid which is calculated using\n",
      "\t\t\t#f_2 = f_2_sat*math.exp[V_2_liq*(P - P_sat_2)/(R*T)]\n",
      "\t\t\t#where f_2_sat can be calculated using virial equation \n",
      "\t\t\t# math.log(phi_2_sat) = math.log(f_2_sat/P_2_sat) = (B_22*P_2_sat)/(R*T)\n",
      "\n",
      "f_2_sat = P_2_sat*math.exp((B_22*P_2_sat*10**(5))/(R*T));\t\t\t#[bar]\n",
      "\n",
      "\t\t\t#Putting the value of 'f_2_sat' in the math.expression of f_2 , we get\n",
      "f_2 = f_2_sat*math.exp(V_2_liq*(P - P_2_sat*10**(5))/(R*T));\t\t\t#[bar]\n",
      "\n",
      "\t\t\t#Now let us calculate the fugacity coefficients of the species in the vapour mixture\n",
      "del_12 = 2*B_12 - B_11 - B_22;\t\t\t#[m**(3)/mol]\n",
      "\n",
      "\t\t\t#math.log(phi_1) = (P/(R*T))*(B_11 + y2**(2)*del_12)\n",
      "\t\t\t#math.log(phi_2) = (P/(R*T))*(B_22 + y1**(2)*del_12)\n",
      "\n",
      "\n",
      "\t\t\t#The calculation procedure is to assume a value of y1, calculate 'phi_1' and 'phi_2' and calculate 'x_1' and 'x_2' from the phase equilibrium equations and see whether x_1 + x_2 = 1,if not then another value of y1 is assumed.\n",
      "\n",
      "y2 = 0.1;\n",
      "error=10;\n",
      "\n",
      "while(error>0.001):\n",
      "    y1=1-y2;\n",
      "    phi_1 = math.exp((P/(R*T))*((B_11 + y2**(2)*del_12)));\n",
      "    phi_2 = math.exp((P/(R*T))*((B_22 + y1**(2)*del_12)));\n",
      "    x_1 = (y1*phi_1*P)/H_constant;\n",
      "    x_2 = (y2*phi_2*P)/(f_2*10**(5));\n",
      "    x = x_1 + x_2;\n",
      "    error=abs(1-x);\n",
      "    y2=y2 - 0.000001;\n",
      "\n",
      "# Results\n",
      "print \" The solubility of methane in methanol is given by x1 = %f\"%(x_1);\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The solubility of methane in methanol is given by x1 = 0.018614\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 16.2  Page Number : 566"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import math \n",
      "from scipy.integrate import quad \n",
      "\n",
      "# Variables\n",
      "x_C2H6_1 = 0.33*10**(-4);\t\t\t# Solubility of ethane in water at 25 C and 1 bar\n",
      "\n",
      "\t\t\t#componenet 1 : ethane (1)\n",
      "\t\t\t#componenet 2 : water (2)\n",
      "\n",
      "\t\t\t# Z = 1 - 7.63*10**(3)*P - 7.22*10**(-5)*P**(2)\n",
      "\n",
      "\t\t\t#The phase equilibrium equation of ethane is\n",
      "\t\t\t#f_1_V = x_1*H_1\n",
      "\t\t\t#since vapour is pure gas,  f_1_V = x_1*H_1   or, phi_1*P = x_1*H_1,  where 'phi_1' is fugacity coefficient of pure ethane\n",
      "\t\t\t# math.log(phi) = integral('Z-1)/P) from limit '0' to 'P'\n",
      "\n",
      "P1 = 0;\n",
      "P2 = 1;\n",
      "P3 = 35;\n",
      "\n",
      "# Calculations\n",
      "def f51(P): \n",
      "\t return (1-7.63*10**(-3)*P-7.22*10**(-5)*P**(2)-1)/P\n",
      "\n",
      "intgral =  quad(f51,P1,P2)[0]\n",
      "\n",
      "phi_1_1 = math.exp(intgral);\t\t\t# - Fugacity coefficient of ethane at 1 bar\n",
      "f_1_1 = phi_1_1*P2;\t\t\t#[bar] - Fugacity of ethane at 1 bar\n",
      "\n",
      "\t\t\t#Similarly\n",
      "\n",
      "def f52(P): \n",
      "\t return (1-7.63*10**(-3)*P-7.22*10**(-5)*P**(2)-1)/P\n",
      "\n",
      "intgral_1 =  quad(f52,P1,P3)[0]\n",
      "\n",
      "phi_1_35 = math.exp(intgral_1);\t\t\t# Fugacity coefficient of ethane at 35 bar\n",
      "f_1_35 = phi_1_35*P3;\t\t\t#[bar] - Fugacity of ethane at 35 bar\n",
      "\n",
      "\t\t\t# At ethane pressure of 1 bar ,  x_C2H6_1*H_1 = phi_1_1\n",
      "H_1 = phi_1_1/x_C2H6_1;\t\t\t#[bar] - Henry's constant\n",
      "\n",
      "\t\t\t# At ethane pressure of 35 bar ,  x_C2H6_35*H_1 = phi_1_35\n",
      "x_C2H6_35 = f_1_35/H_1;\t\t\t# Solubility of ethane at 35 bar pressure\n",
      "\n",
      "# Results\n",
      "print \"The solubility of ethane at 35 bar is given by   x_C2H6 = %e \"%(x_C2H6_35);\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The solubility of ethane at 35 bar is given by   x_C2H6 = 8.525648e-04 \n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 16.4  Page Number : 571"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "from scipy.optimize import fsolve \n",
      "import math \n",
      "\n",
      "# Variables\n",
      "T = 200;\t\t\t#[K]\n",
      "R = 8.314;\t\t\t#[J/mol*K] - universal gas constant\n",
      "\t\t\t# G_E = A*x_1*x_2\n",
      "A = 4000;\t\t\t#[J/mol]\n",
      "x_1 = 0.6;\t\t\t# Mle fraction of feed composition\n",
      "\n",
      "# Calculations and Results\n",
      "\t\t\t# Since A is given to be independent of temperature\n",
      "UCST = A/(2*R);\t\t\t#[K] - Upper critical solution temperature\n",
      "print \" The UCST of the system is %f K\"%(UCST);\n",
      "\n",
      "\t\t\t# Since the given temperature is less than UCST therefore two phase can get formed at the given temperature.\n",
      "\n",
      "\t\t\t# x1_alpha = 1 - x1_beta\n",
      "\t\t\t# We know that,  x1_alpha*Y_1_alpha = x2_alpha*Y_2_alpha\n",
      "\t\t\t# x1_alpha*math.exp[(A/(R*T))*(x2_alpha)**(2)] = (1 - x1_alpha)*math.exp[(A/(R*T))*(x1_alpha)**(2)]\n",
      "\t\t\t# where use has beeen made of the fact that x1_alpha = 1 - x1_beta and x2_beta = 1 - x1_beta = x1_alpha .Taking math.logarithm of both side we get\n",
      "\t\t\t# math.log(x1_alpha) + (A/(R*T))*(1 - x1_alpha)**(2) = math.log(1 - x1_alpha) + (A/(R*T))*x1_alpha**(2)\n",
      "\t\t\t# math.log(x1_alpha/(1-x1_alpha)) = (A/(R*T))*(2*x1_alpha - 1)\n",
      "\n",
      "def f(x1_alpha): \n",
      "\t return  math.log(x1_alpha/(1-x1_alpha)) - (A/(R*T))*(2*x1_alpha - 1)\n",
      "x1_alpha = fsolve(f,0.1)\n",
      "x1_beta = fsolve(f,0.9)\n",
      "\t\t\t# Because of symmetry 1 - x1_beta = x1_alpha\n",
      "\n",
      "\t\t\t# It can be seen that the equation,  math.log(x1/(1-x1)) = (A/(R*T))*(2*x1 - 1) has two roots.\n",
      "\t\t\t\n",
      "print \" The composition of two liquid phases in equilibrium is given by x1_alpha = %f and x1_beta = %f\"%(x1_alpha,x1_beta);\n",
      "\n",
      "z1 = 0.6;\n",
      "\t\t\t# z1 = x1_alpha*alpha + x1_beta*beta\n",
      "\t\t\t# beta = 1 - alpha\n",
      "alpha = (z1-x1_beta)/(x1_alpha-x1_beta);\t\t\t#[mol]\n",
      "Beta = 1 - alpha;\t\t\t#[mol]\n",
      "print \" The relative amount of phases is given by alpha = %f mol and beta = %f mol\"%(alpha,Beta);\n",
      "\n",
      "\t\t\t# the relative amounts of the phases changes with the  feed composition \n",
      "\n",
      "\t\t\t#math.log(x1/(1-x1)) = (A/(R*T))*(2*x1 - 1)\n",
      "\t\t\t\n",
      "\n",
      "print \" math.logx1/1-x1 = A/R*T*2*x1 - 1\";\n",
      "print \" If the above equation has two real roots of x1 one for phase alpha and the other for phase beta then two liquid phases get formed\";\n",
      "print \" and if it has no  real roots then a homogeneous liquid mixture is obtained\";\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The UCST of the system is 240.558095 K\n",
        " The composition of two liquid phases in equilibrium is given by x1_alpha = 0.169102 and x1_beta = 0.830898\n",
        " The relative amount of phases is given by alpha = 0.348896 mol and beta = 0.651104 mol\n",
        " math.logx1/1-x1 = A/R*T*2*x1 - 1\n",
        " If the above equation has two real roots of x1 one for phase alpha and the other for phase beta then two liquid phases get formed\n",
        " and if it has no  real roots then a homogeneous liquid mixture is obtained\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 16.5  Page Number : 573"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "# Variables\n",
      "T = 300;\t\t\t#[K]\n",
      "R = 8.314;\t\t\t#[J/mol*K] - universal gas constant\n",
      "A = 7000;\t\t\t#[J/mol]\n",
      "\n",
      "\t\t\t# math.log(x_1/(1-x_1)) = (A/(R*T))*(2*x_1-1)\n",
      "\n",
      "# Calculations\n",
      "def f(x_1): \n",
      "\t return math.log(x_1/(1-x_1))-((A/(R*T))*(2*x_1-1))\n",
      "\n",
      "x1_alpha=fsolve(f,0.1)\n",
      "\n",
      "x1_beta=1-x1_alpha;\n",
      "\n",
      "# Results\n",
      "print \"The equilibrium compositin of the two liquid phase system is given by x1_alpha \\t = %f  x1_beta \\t = %f\"%(x1_alpha,x1_beta);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The equilibrium compositin of the two liquid phase system is given by x1_alpha \t = 0.091897  x1_beta \t = 0.908103\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 16.7  Page Number : 579"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
      "M_wt_meth = 32;\t\t\t# Molecular weight of methanol \n",
      "M_wt_water = 18;\t\t\t# Molecular weight of water \n",
      "m_meth = 0.01;\t\t\t#[g] - Mass of methanol added per cm**(3) of solution\n",
      "\n",
      "\n",
      "den_sol = 1;\t\t\t#[g/cm**(3)]\n",
      "\n",
      "# Calculations\n",
      "\t\t\t#The mole fraction of solute is given by\n",
      "\t\t\t#x_2 = (moles of solute in cm**(3) of solution)/(moles of solute + moles of water) in 1 cm**(3) of solution\n",
      "x_2 = (m_meth/M_wt_meth)/((m_meth/M_wt_meth)+((1-m_meth)/M_wt_water));\n",
      "\n",
      "\t\t\t#We know that heat of fusion of water is\n",
      "H_fus = -80;\t\t\t#[cal/g] - Enthalpy change of fusion at 0 C\n",
      "H_fus = H_fus*4.186*M_wt_water;\t\t\t#[J/mol]\n",
      "\n",
      "\t\t\t#Therefore freezing point depression is given by\n",
      "\t\t\t# T - T_m = (R*(T**(2))*x_2)/H_fus\n",
      "T_f = 273.15;\t\t\t#[K] - Freezing point of water\n",
      "delta_T_f = (R*(T_f**(2))*x_2)/H_fus;\t\t\t#[K]\n",
      "\n",
      "# Results\n",
      "print \"The depression in freezing point is given by  delta_T = %f K\"%(delta_T_f);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The depression in freezing point is given by  delta_T = -0.581403 K\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 16.8  Page Number : 580"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "# Variables\n",
      "R = 8.314;\t\t\t#[J/mol*K] - universal gas constant\n",
      "T_f = 273.15;\t\t\t#[K] - Freezing point of water\n",
      "m_water = 100;\t\t\t#[g] - Mass of water\n",
      "m_NaCl = 3.5;\t\t\t#[g] - Mass of NaCl\n",
      "M_wt_water = 18.015;\t\t\t# Molecular weight of water \n",
      "M_wt_NaCl = 58.5;\t\t\t# Molecular weight of NaCl\n",
      "mol_water = m_water/M_wt_water;\t\t\t#[mol] - Moles of water\n",
      "mol_NaCl = m_NaCl/M_wt_NaCl;\t\t\t#[mol] - Moles of NaCl\n",
      "\n",
      "H_fus = -80;\t\t\t#[cal/g] - Enthalpy change of fusion at 0 C\n",
      "H_fus = H_fus*4.186*M_wt_water;\t\t\t#[J/mol]\n",
      "\n",
      "# Calculations\n",
      "\t\t\t#Mole fraction of the solute (NaCl) is given by\n",
      "x_2 = mol_NaCl/(mol_NaCl+mol_water);\n",
      "\n",
      "\n",
      "x_2_act = 2*x_2;\t\t\t# Actual mole fraction\n",
      "\n",
      "\t\t\t#Now depression in freezing point is given by\n",
      "\t\t\t# T - T_m = (R*(T**(2))*x_2_act)/H_fus\n",
      "delta_T_f = (R*(T_f**(2))*x_2_act)/H_fus;\t\t\t#[C]\n",
      "\n",
      "\t\t\t#Thus freezing point of seawater = depression in freezing point\n",
      "\n",
      "# Results\n",
      "print \"The freezing point of seawater is  %f C\"%(delta_T_f);\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The freezing point of seawater is  -2.192853 C\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 16.10  Page Number : 583"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "# Variables\n",
      "R = 8.314;\t\t\t#[J/mol*K] - universal gas constant\n",
      "T_b = 373.15;\t\t\t#[K] - Boiling point of water\n",
      "m_water = 100.;\t\t\t#[g] - Mass of water\n",
      "m_C12H22 = 5.;\t\t\t#[g] - Mass of glucise (C12H22)\n",
      "M_wt_water = 18.015;\t\t\t# Molecular weight of water \n",
      "M_wt_C12H22 = 342.30;\t\t\t# Molecular weight of C12H22\n",
      "mol_water = m_water/M_wt_water;\t\t\t#[mol] - Moles of water\n",
      "mol_C12H22 = m_C12H22/M_wt_C12H22;\t\t\t#[mol] - Moles of C12H22\n",
      "\n",
      "# Calculations\n",
      "H_vap = 540.;\t\t\t#[cal/g] - Enthalpy change of vaporisation\n",
      "H_vap = H_vap*4.186*M_wt_water;\t\t\t#[J/mol]\n",
      "\n",
      "\t\t\t#Mole fraction of the solute (C12H22) is given by\n",
      "x_2 = mol_C12H22/(mol_C12H22+mol_water);\n",
      "\n",
      "\t\t\t#The boiling point elevation is given by\n",
      "\t\t\t# T - T_b = (R*T_b**(2)*x_2**(2))/H_vap**(2)\n",
      "\n",
      "delta_T_b = (R*T_b**(2)*x_2)/(H_vap);\n",
      "\n",
      "# Results\n",
      "print \"The elevation in boiling point is given by  delta_T = %f C\"%(delta_T_b)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The elevation in boiling point is given by  delta_T = 0.074611 C\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 16.11  Page Number : 584"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "# Variables\n",
      "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
      "T = 25 + 273.15;\t\t\t#[K] - Surrounding temperature \n",
      "den_water = 1000.;\t\t\t#[kg/m**(3)] - Density of water\n",
      "m_water = 100.;\t\t\t#[g] - Mass of water\n",
      "m_C12H22 = 5.;\t\t\t#[g] - Mass of glucise (C12H22)\n",
      "M_wt_water = 18.015;\t\t\t# Molecular weight of water \n",
      "M_wt_C12H22 = 342.30;\t\t\t# Molecular weight of C12H22\n",
      "mol_water = m_water/M_wt_water;\t\t\t#[mol] - Moles of water\n",
      "mol_C12H22 = m_C12H22/M_wt_C12H22;\t\t\t#[mol] - Moles of C12H22\n",
      "\n",
      "# Calculations\n",
      "\t\t\t#Mole fraction of the water is given by\n",
      "x_1 = mol_water/(mol_C12H22+mol_water);\n",
      "\n",
      "\t\t\t#Molar volume of water can be calculated as\n",
      "V_l_water = (1./den_water)*M_wt_water*10**(-3);\t\t\t#[m**(3)/mol]\n",
      "\n",
      "\t\t\t#The osmotic pressure is given by\n",
      "pi = -(R*T*math.log(x_1))/V_l_water;\t\t\t#[N/m**(2)]\n",
      "pi = pi*10**(-5);\t\t\t#[bar]\n",
      "\n",
      "# Results\n",
      "print \"The osmotic pressure of the mixture is %f bar\"%(pi);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The osmotic pressure of the mixture is 3.616073 bar\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 16.12  Page Number : 585"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "R = 8.314;\t\t\t#[J/mol*K] - universal gas constant\n",
      "T = 25 + 273.15;\t\t\t#[K] - Surrounding temperature\n",
      "den_water = 1000.;\t\t\t#[kg/m**(3)] - Density of water\n",
      "m_water = 100.;\t\t\t#[g] - Mass of water\n",
      "m_NaCl = 3.5;\t\t\t#[g] - Mass of NaCl\n",
      "M_wt_water = 18.015;\t\t\t# Molecular weight of water \n",
      "M_wt_NaCl = 58.5;\t\t\t# Molecular weight of NaCl\n",
      "mol_water = m_water/M_wt_water;\t\t\t#[mol] - Moles of water\n",
      "mol_NaCl = m_NaCl/M_wt_NaCl;\t\t\t#[mol] - Moles of NaCl\n",
      "\n",
      "# Calculations\n",
      "H_fus = -80.;\t\t\t#[cal/g] - Enthalpy change of fusion at 0 C\n",
      "H_fus = H_fus*4.186*M_wt_water;\t\t\t#[J/mol]\n",
      "\n",
      "\t\t\t#Mole fraction of the solute (NaCl) is given by\n",
      "x_2 = mol_NaCl/(mol_NaCl+mol_water);\n",
      "\n",
      "\n",
      "x_2_act = 2*x_2;\t\t\t# Actual mole fraction\n",
      "\n",
      "x_1 = 1 - x_2_act;\n",
      "\n",
      "\t\t\t#Molar volume of water can be calculated as\n",
      "V_l_water = (1/den_water)*M_wt_water*10**(-3);\t\t\t#[m**(3)/mol]\n",
      "\n",
      "\t\t\t#The osmotic pressure is given by\n",
      "pi = -(R*T*math.log(x_1))/V_l_water;\t\t\t#[N/m**(2)]\n",
      "pi = pi*10**(-5);\t\t\t#[bar]\n",
      "\n",
      "\n",
      "# Results\n",
      "print \"The minimum pressure to desalinate sea water is %f bar\"%(pi);\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The minimum pressure to desalinate sea water is 29.662232 bar\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 16.13  Page Number : 586"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "# Variables\n",
      "R = 8.314;\t\t\t#[J/mol*K] - universal gas constant\n",
      "T = 173.15;\t\t\t#[K] - Surrounding temperature\n",
      "P = 60;\t\t\t#[bar]\n",
      "P = P*10**(5);\t\t\t#[Pa] \n",
      "\n",
      "\t\t\t#componenet 1 : CO2 (1)\n",
      "\t\t\t#componenet 2 : H2 (2)\n",
      "P_1_sat = 0.1392;\t\t\t#[bar] - Vapour pressre of pure solid CO2\n",
      "P_1_sat = P_1_sat*10**(5);\t\t\t#[bar]\n",
      "V_s_1 = 27.6;\t\t\t#[cm**(3)/mol] - Molar volume of solid CO2\n",
      "V_s_1 = V_s_1*10**(-6);\t\t\t#[m**(3)/mol]\n",
      "n_1 = 0.01;\t\t\t#[mol] - Initial number of moles of CO2\n",
      "n_2 = 0.99;\t\t\t#[mol] - Initial number of moles of H2\n",
      "\n",
      "\t\t\t#Let us determine the fugacity of solid CO2 (1) at 60 C and 173.15 K\n",
      "\t\t\t# f_1 = f_1_sat*math.exp(V_s_1*(P-P_1_sat)/(R*T))\n",
      "\n",
      "# Calculations\n",
      "\t\t\t#Since vapour pressure of pure solid CO2 is very small, therefore\n",
      "f_1_sat = P_1_sat;\n",
      "f_1 = f_1_sat*math.exp(V_s_1*(P-P_1_sat)/(R*T));\n",
      "\n",
      "\t\t\t#Since gas phase is ideal therefore\n",
      "\t\t\t# y1*P = f_1\n",
      "y1 = f_1/P;\n",
      "\n",
      "\t\t\n",
      "\t\t\t#Number of moles of CO2 in vapour phase at equilibrium can be calculated as\n",
      "\t\t\t#y1 = (n_1_eq/(n_1_eq + n_2)). Therefore\n",
      "n_1_eq = n_2*y1/(1-y1);\n",
      "\n",
      "\t\t\t#Therefore moles of CO2 precipitated is\n",
      "n_ppt = n_1 - n_1_eq;\t\t\t#[mol]\n",
      "\n",
      "# Results\n",
      "print \"The moles of CO2 precipitated is %f mol\"%(n_ppt);\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The moles of CO2 precipitated is 0.007417 mol\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 16.14  Page Number : 586"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "# Variables\n",
      "R = 8.314;\t\t\t#[J/mol*K] - universal gas constant\n",
      "T = 350.;\t\t\t#[K] - Surrounding temperature\n",
      "\n",
      "\t\t\t#componenet 1 : organic solid (1)\n",
      "\t\t\t#componenet 2 : CO2 (2)\n",
      "\n",
      "P_1_sat = 133.3;\t\t\t#[N/m**(2)] - Vapour pressre of organic solid\n",
      "V_s_1 = 200.;\t\t\t#[cm**(3)/mol] - Molar volume of organic solid\n",
      "V_s_1 = V_s_1*10.**(-6);\t\t\t#[m**(3)/mol]\n",
      "\n",
      "\t\t\t#/At 350 K, the values of the coefficients \n",
      "B_11 = -500.;\t\t\t#[cm**(3)/mol]\n",
      "B_22 = -85.;\t\t\t#[cm****(3)/mol]\n",
      "B_12 = -430.;\t\t\t#[cm**(3)/mol]\n",
      "\n",
      "# Calculations\n",
      "\t\t\t#From phase equilibrium equation of component 1, we get\n",
      "\t\t\t# y1*P*phi_1 = f_1\n",
      "\t\t\t# f_1 = f_1_sat*math.exp(V_s_1*(P-P_1_sat)/(R*T))\n",
      "\n",
      "\t\t\t#Since vapour pressure of organic solid is very small, therefore\n",
      "f_1_sat = P_1_sat;\n",
      "\n",
      "\t\t\t# Now let us determine the fugacity coefficient of organic solid in the vapour mixture.\n",
      "\t\t\t# math.log(phi_1) = (P/(R*T))*(B_11 + y2**(2)*del_12) \n",
      "del_12 = (2*B_12 - B_11 - B_22)*10**(-6);\t\t\t#[m**(3)/mol]\n",
      "\n",
      "\t\t\t#It is given that the partial pressure of component 1 in the vapour mixture is 1333 N?m**(2)\n",
      "\t\t\t# y1*P = 1333 N/m**(2) or, y1 = 1333/P\n",
      "\t\t\t# y2 = 1- 1333/P\n",
      "\t\t\t# math.log(phi_1) = (P/(R*T))*(B_11 + (1- 1333/P)**(2)*del_12)\n",
      "\n",
      "\t\t\t#The phase equilibrium equation becomes\n",
      "\t\t\t# y1*P*phi_1 = f_1_sat*math.exp(V_s_1*(P-P_1_sat)/(R*T))\n",
      "\t\t\t#Taking math.log on both side we have\n",
      "\t\t\t# math.log(y1*P) + math.log(phi_1) = math.log(f_1_sat) + (V_s_1*(P-P_1_sat)/(R*T))\n",
      "\t\t\t# (V_s_1*(P-P_1_sat)/(R*T)) - math.log(phi_1) = math.log(1333/133.3) = math.log(10)\n",
      "\n",
      "\t\t\t#substituting for math.log(phi_1) from previous into the above equation we get\n",
      "\t\t\t# (V_s_1*(P-P_1_sat)/(R*T)) - (P/(R*T))*(B_11 + (1- 1333/P)**(2)*del_12) - math.log(10) = 0\n",
      "\t\t\t# On simplification we get,\n",
      "\t\t\t# 975*P**(2) - 6.7*10**(9)*P + 4.89*10**(8) = 0\n",
      "\t\t\t# Solving the above qyadratic equation using shreedharcharya rule\n",
      "\n",
      "P3 = (6.7*10**(9) + ((-6.7*10**(9))**(2)-4*975*4.98*10**(8))**(1./2))/(2*975);\t\t\t#[Pa]\n",
      "P4 = (6.7*10**(9) - ((-6.7*10**(9))**(2)-4*975*4.98*10**(8))**(1./2))/(2*975);\t\t\t#[Pa]\n",
      "\t\t\t# The second value is not possible, therefore pressure of the system is P3\n",
      "P3 = P3*10**(-5);\t\t\t#[bar]\n",
      "\n",
      "# Results\n",
      "print \" The total pressure of the system is %f bar\"%(P3);\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The total pressure of the system is 68.717948 bar\n"
       ]
      }
     ],
     "prompt_number": 11
    }
   ],
   "metadata": {}
  }
 ]
}