summaryrefslogtreecommitdiff
path: root/Chemical_Engineering_Thermodynamics_by_P_Ahuja/ch14_1.ipynb
blob: 6e9336a97e1c4b251a065409c71c068f5de47a4d (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": "ch14_1",
  "signature": "sha256:98f2e1e0f1c561d3ee302fd629093b7572c8b263613f73036059e7020f90d8cc"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 14 : Activity Coefficients Models for Liquid Mixtures"
     ]
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 14.4  Page Number : 461"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import math\n",
      "\n",
      "# Variables,\n",
      "T = 300;\t\t\t#[K] - Temperature\n",
      "b = 100;\t\t\t#[cal/mol]\n",
      "R = 1.987;\t\t\t#[cal/mol*K] - Universal gas constant\n",
      "# R*T*math.log(Y_1) = b*x_2**(2)\n",
      "# R*T*math.log(Y_2) = b*x_1**(2)\n",
      "\n",
      "#For equimolar mixture\n",
      "x_1 = 0.5;\t\t\t#Mole fraction of component 1\n",
      "x_2 = 0.5;\t\t\t#Mole fraction of component 2\n",
      "\n",
      "# Calculations and Results\n",
      "#The excess Gibbs free energy is given by\n",
      "# G_excess = R*T*(x_1*math.log(Y_1) + x_2*math.log(Y_2)) = b*x_1*x_2**(2) + b*x_2*x_1**(2) = b*x_1*(x_1 + x_2) = b*x_1*x_2\n",
      "G_excess = b*x_1*x_2;\t\t\t#[cal/mol]\n",
      "\n",
      "#The ideal Gibbs free energy change of mixing is given by,\n",
      "delta_G_id_mix = R*T*(x_1*math.log(x_1)+x_2*math.log(x_2));\t\t\t#[cal/mol]\n",
      "\n",
      "#The Gibbs free energy of mixing is given by\n",
      "delta_G_mix = delta_G_id_mix + G_excess;\t\t\t#[cal/mol]\n",
      "\n",
      "\n",
      "# delta_S_mix = delta_S_id_mix = - R*sum(x_i*math.log(x_i))\n",
      "\n",
      "#delta_G_mix = delta_H_mix - T*delta_S_mix = delta_H_mix + R*T*(x_1*math.log(x_1)+x_2*math.log(x_2))\n",
      "delta_H_mix = b*x_1*x_2;\t\t\t#[cal/mol]\n",
      "\n",
      "print \"The value of Gibbs free energy change for equimolar mixture formation is %f cal/mol\"%(delta_G_mix);\n",
      "print \"The value of enthalpy change for equimolar mixture formation is %f cal/mol\"%(delta_H_mix);\n",
      "\n",
      "#Work required for separation of mixture into pure components is\n",
      "W = delta_G_mix;\n",
      "print \"The least amount of work required for separation at 300 K is %f cal/mol\"%(W);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of Gibbs free energy change for equimolar mixture formation is -388.185034 cal/mol\n",
        "The value of enthalpy change for equimolar mixture formation is 25.000000 cal/mol\n",
        "The least amount of work required for separation at 300 K is -388.185034 cal/mol\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 14.10  Page Number : 466"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import math \n",
      "from numpy import zeros\n",
      "from scipy.stats import linregress\n",
      "\n",
      "# Variables,\n",
      "T = 25 +173.15;\t\t\t#[K] - Temperature\n",
      "x_1=[0.0115,0.0160,0.0250,0.0300,0.0575,0.1125,0.1775,0.2330,0.4235,0.5760,0.6605,0.7390,0.8605,0.9250,0.9625];\n",
      "y_1=[8.0640,7.6260,7.2780,7.2370,5.9770,4.5434,3.4019,2.8023,1.7694,1.3780,1.2302,1.1372,1.0478,1.0145,1.0070];\n",
      "y_2=[1.0037,1.0099,1.0102,1.0047,1.0203,1.0399,1.1051,1.1695,1.4462,1.8520,2.2334,2.6886,3.7489,4.8960,5.6040];\n",
      "\n",
      "x_2 = zeros(15);\t\t\t# x_2 = (1 - x_1)\n",
      "G_RT = zeros(15);\t\t\t# G_RT = G_excess/(R*T)\n",
      "x1x2_G_RT = zeros(15);\t\t\t# x1x2_G_RT = (x_1*x_2/(G_excess/(R*T)))\n",
      "G_RTx1x2 = zeros(15);\t\t\t# G_RTx1x1 = G_excess/(R*T*x_1*x_2)\n",
      "\n",
      "# Calculations and Results\n",
      "for i in range(15):\n",
      "    x_2[i]=(1-x_1[i]);\n",
      "    G_RT[i]=(x_1[i]*math.log(y_1[i]))+(x_2[i]*math.log(y_2[i]));\n",
      "    x1x2_G_RT[i]=(x_1[i]*x_2[i])/G_RT[i];\n",
      "    G_RTx1x2[i]=1/x1x2_G_RT[i];\n",
      "\n",
      "\n",
      "slop,intr,sig,d,e=linregress(x_1,x1x2_G_RT);\n",
      "\n",
      "A = 1/intr;\n",
      "B = 1/(slop+(1/A));\n",
      "print \" The value of van Laar parameters are A = %f and B = %f\"%(A,B);\n",
      "\n",
      "# Now from Margules equation\n",
      "# G_RTx1x2 = G_excess/(R*T*x_1*x_2) = B1*x_1 + A1*x_1 = A1 + (B1 - A1)*x_1\n",
      "#slope = (B1 - A1) and intercept = A1\n",
      "\n",
      "# Again employing the concept of linear regression of the data ( x_1 , G_RTx1x2 ) to find the value of intercept and slope of the above equation\n",
      "#Let slope = slop1 and intercept = intr1\n",
      "\n",
      "slop1,intr1,sig1,d,e=linregress(x_1,G_RTx1x2);\n",
      "\n",
      "A1 = intr1;\n",
      "B1 = slop1 + A1;\n",
      "print \" The value of Margules parameters are A = %f and B = %f\"%(A1,B1);\n",
      "\n",
      "print \" Because of the higher value of correlation factor for Van Laar model it fits the data better.\"\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The value of van Laar parameters are A = 2.271326 and B = 1.781420\n",
        " The value of Margules parameters are A = 2.293274 and B = 1.746000\n",
        " Because of the higher value of correlation factor for Van Laar model it fits the data better.\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 14.11  Page Number : 470"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "# Variables,\n",
      "T = 60 + 273.15;\t\t\t#[K] - Temperature\n",
      "R = 1.987;\t\t\t#[cal/mol*K] - Universal gas constant\n",
      "#component 1 = acetone\n",
      "#component 2 = water\n",
      "x_1 = 0.3;\t\t\t# Mole fraction of component 1\n",
      "x_2 = 1 - x_1;\t\t\t#Mole fraction of component 2\n",
      "V_mol_1 = 74.05;\t\t\t#[cm**(3)/mol] - Molar volume of pure component 1\n",
      "V_mol_2 = 18.07;\t\t\t#[cm**(3)/mol] - Molar volume of pure component 2\n",
      "\n",
      "#for Wilson equation\n",
      "a_12 = 291.27;\t\t\t#[cal/mol]\n",
      "a_21 = 1448.01;\t\t\t#[cal/mol]\n",
      "\n",
      "#For NRTL\n",
      "b_12 = 631.05;\t\t\t#[cal/mol]\n",
      "b_21 = 1197.41;\t\t\t#[cal/mol]\n",
      "alpha = 0.5343;\n",
      "\n",
      "# Calculations and Results\n",
      "#Froom wilson equation\n",
      "A_12=(V_mol_2/V_mol_1)*(math.exp(-a_12/(R*T)));\n",
      "A_21 = (V_mol_1/V_mol_2)*(math.exp(-a_21/(R*T)));\n",
      "Beta = A_12/(x_1+x_2*A_12) - A_21/(x_2+x_1*A_21);\n",
      "#math.log(Y1) = -math.log(x_1 + x_2*A_12) + x_2*Beta; \n",
      "Y1 = math.exp(-math.log(x_1+x_2*A_12)+x_2*Beta);\n",
      "#similarly for Y2\n",
      "Y2 = math.exp(-math.log(x_2+x_1*A_21)-x_1*Beta);\n",
      "print \"The value of activity coefficients for Wilson equation are Y1 = %f \\t and \\t Y2 = %f\"%(Y1,Y2);\n",
      "\n",
      "#From NRTL equation,\n",
      "t_12 = b_12/(R*T);\n",
      "t_21 = b_21/(R*T);\n",
      "G_12 = math.exp(-alpha*t_12);\n",
      "G_21 = math.exp(-alpha*t_21);\n",
      "\n",
      "#math.log(Y1) = x_1**(2)*[t_12*(G_12/(x_1+x_2*G_12))**(2) + (G_12*t_12)/((G_12/(x_1+x_2*G_12))**(2))]\n",
      "Y1_prime = math.exp(x_2**(2)*(t_21*(G_21/(x_1+x_2*G_21))**(2)+(G_12*t_12)/(((x_2+x_1*G_12))**(2))));\n",
      "#Similarly for Y2\n",
      "Y2_prime = math.exp(x_1**(2)*(t_12*(G_12/(x_2+x_1*G_12))**(2)+(G_21*t_21)/(((x_1+x_2*G_21))**(2))));\n",
      "\n",
      "print \"The value of activity coefficients for NRTL equation are Y1 = %f \\t and \\t Y2 = %f\"%(Y1_prime,Y2_prime);\n",
      "\n",
      "\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of activity coefficients for Wilson equation are Y1 = 2.172258 \t and \t Y2 = 1.254121\n",
        "The value of activity coefficients for NRTL equation are Y1 = 2.143030 \t and \t Y2 = 1.262506\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 14.12  Page Number : 474"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "# Variables \n",
      "T = 307;\t\t\t#[K]\n",
      "x_1 = 0.047;\n",
      "x_2 = 1 - x_1;\n",
      "\n",
      "# The subgroups in the  two components are\n",
      "# Acetone (1) : 1 CH3, 1 CH3CO\n",
      "# n-pentane (2) : 2 CH3, 3 CH2\n",
      "\n",
      "#Group volume (Rk) and surface area (Qk) parameters of the subgroup are\n",
      "k_CH3 = 1;\n",
      "k_CH2 = 2;\n",
      "k_CH3CO = 19;\n",
      "Rk_CH3 = 0.9011;\n",
      "Rk_CH2 = 0.6744;\n",
      "Rk_CH3CO = 1.6724;\n",
      "Qk_CH3 = 0.848;\n",
      "Qk_CH2 = 0.540;\n",
      "Qk_CH3CO = 1.4880;\n",
      "\n",
      "# Interaction parameters of the subgroups in kelvin (K) are\n",
      "a_1_1 = 0;\n",
      "a_1_2 = 0;\n",
      "a_1_19 = 476.40;\n",
      "a_2_1 = 0;\n",
      "a_2_2 = 0;\n",
      "a_2_19 = 476.40;\n",
      "a_19_1 = 26.76;\n",
      "a_19_2 = 26.76;\n",
      "a_19_19 = 0;\n",
      "\n",
      "# Calculations\n",
      "r_1 = 1*Rk_CH3 + 1*Rk_CH3CO;\n",
      "r_2 = 2*Rk_CH3 + 3*Rk_CH2;\n",
      "q_1 = 1*Qk_CH3 + 1*Qk_CH3CO;\n",
      "q_2 = 2*Qk_CH3 + 3*Qk_CH2;\n",
      "\n",
      "J_1 = r_1/(r_1*x_1+r_2*x_2);\n",
      "J_2 = r_2/(r_1*x_1+r_2*x_2);\n",
      "L_1 = q_1/(q_1*x_1+q_2*x_2);\n",
      "L_2 = q_2/(q_1*x_1+q_2*x_2);\n",
      "t_1_1 = math.exp(-a_1_1/T);\n",
      "t_1_2 = math.exp(-a_1_2/T);\n",
      "t_1_19 = math.exp(-a_1_19/T);\n",
      "t_2_1 = math.exp(-a_2_1/T);\n",
      "t_2_2 = math.exp(-a_2_2/T);\n",
      "t_2_19 = math.exp(-a_2_19/T);\n",
      "t_19_1 = math.exp(-a_19_1/T);\n",
      "t_19_2 = math.exp(-a_19_2/T);\n",
      "t_19_19 = math.exp(-a_19_19/T);\n",
      "\n",
      "e_1_1 = 1*Qk_CH3/q_1;\n",
      "e_2_1 = 0;\n",
      "e_19_1 = (1*Qk_CH3CO/q_1);\n",
      "e_1_2 = 2*Qk_CH3/q_2;\n",
      "e_2_2 = 3*Qk_CH2/q_2;\n",
      "e_19_2 = 0;\n",
      "\n",
      "B_1_1 = e_1_1*t_1_1 + e_2_1*t_2_1 + e_19_1*t_19_1;\n",
      "B_1_2 = e_1_1*t_1_2 + e_2_1*t_2_2 + e_19_1*t_19_2;\n",
      "B_1_19 = e_1_1*t_1_19 + e_2_1*t_2_19 + e_19_1*t_19_19;\n",
      "B_2_1 = e_1_2*t_1_1 + e_2_2*t_2_1 + e_19_2*t_19_1;\n",
      "B_2_2 = e_1_2*t_1_2 + e_2_2*t_2_2 + e_19_2*t_19_2;\n",
      "B_2_19 = e_1_2*t_1_19 + e_2_2*t_2_19 + e_19_2*t_19_19;\n",
      "\n",
      "theta_1 = (x_1*q_1*e_1_1 + x_2*q_2*e_1_2)/(x_1*q_1 + x_2*q_2);\n",
      "theta_2 = (x_1*q_1*e_2_1 + x_2*q_2*e_2_2)/(x_1*q_1 + x_2*q_2);\n",
      "theta_19 = (x_1*q_1*e_19_1 + x_2*q_2*e_19_2)/(x_1*q_1 + x_2*q_2);\n",
      "\n",
      "s_1 = theta_1*t_1_1 + theta_2*t_2_1 + theta_19*t_19_1;\n",
      "s_2 = theta_1*t_1_2 + theta_2*t_2_2 + theta_19*t_19_2;\n",
      "s_19 = theta_1*t_1_19 + theta_2*t_2_19 + theta_19*t_19_19;\n",
      "\n",
      "# math.log(Y1_C) = 1 - J_1 + math.log(J_1) - 5*q_1*(1- (J_1/L_1) + math.log(J_1/L_1))\n",
      "# math.log(Y2_C) = 1 - J_2 + math.log(J_2) - 5*q_2*(1- (J_2/L_2) + math.log(J_2/L_2))\n",
      "Y1_C = math.exp(1 - J_1 + math.log(J_1) - 5*q_1*(1- (J_1/L_1) + math.log(J_1/L_1)));\n",
      "Y2_C = math.exp(1 - J_2 + math.log(J_2) - 5*q_2*(1- (J_2/L_2) + math.log(J_2/L_2)));\n",
      "\n",
      "# For species 1\n",
      "summation_theta_k_1 = theta_1*(B_1_1/s_1) + theta_2*(B_1_2/s_2) + theta_19*(B_1_19/s_19);\n",
      "summation_e_ki_1 = e_1_1*math.log(B_1_1/s_1) + e_2_1*math.log(B_1_2/s_2) + e_19_1*math.log(B_1_19/s_19);\n",
      "\n",
      "# For species 2\n",
      "summation_theta_k_2 = theta_1*(B_2_1/s_1) + theta_2*(B_2_2/s_2) + theta_19*(B_2_19/s_19);\n",
      "summation_e_ki_2 = e_1_2*math.log(B_2_1/s_1) + e_2_2*math.log(B_2_2/s_2) + e_19_2*math.log(B_2_19/s_19);\n",
      "\n",
      "# math.log(Y1_R) = q_1(1 - summation_theta_k_1 + summation_e_ki_1)\n",
      "# math.log(Y2_R) = q_2(1 - summation_theta_k_2 + summation_e_ki_2)\n",
      "Y1_R = math.exp(q_1*(1 - summation_theta_k_1 + summation_e_ki_1));\n",
      "Y2_R = math.exp(q_2*(1 - summation_theta_k_2 + summation_e_ki_2));\n",
      "\n",
      "# math.log(Y1) = math.log(Y1_C) + math.log(Y1_R)\n",
      "# math.log(Y2) = math.log(Y2_C) + math.log(Y2_R)\n",
      "Y1 = math.exp(math.log(Y1_C) + math.log(Y1_R));\n",
      "Y2 = math.exp(math.log(Y2_C) + math.log(Y2_R));\n",
      "\n",
      "# Results\n",
      "print \" The activity coefficients are Y1 = %f  and  Y2 = %f\"%(Y1,Y2);\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The activity coefficients are Y1 = 4.992034  and  Y2 = 1.005260\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 14.13  Page Number : 481"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "# Variables,\n",
      "T = 25 + 273.15;\t\t\t#[K] - Temperature\n",
      "R = 1.987;\t\t\t#[cal/mol*K] - Universal gas constant\n",
      "#component 1 = chloroform\n",
      "#component 2 = carbon tetrachloride\n",
      "x_1 = 0.5;\t\t\t#Mole fraction of component 1 \t\t\t#Equimolar mixture\n",
      "x_2 = 0.5;\t\t\t#Mole fraction of component 2\n",
      "V_mol_1 = 81;\t\t\t#[cm**(3)/mol] - Molar volume of pure component 1\n",
      "V_mol_2 = 97;\t\t\t#[cm**(3)/mol] - Molar volume of pure component 2\n",
      "del_1 = 9.2;\t\t\t#[(cal/cm**(3))**(1/2)] - Mole fraction of component 1\n",
      "del_2 = 8.6;\t\t\t#[(cal/cm**(3))**(1/2)] - Mole fraction of component 2\n",
      "\n",
      "# Calculations\n",
      "#Scatchard - Hilderbrand model\n",
      "phi_1 = (x_1*V_mol_1)/(x_1*V_mol_1+x_2*V_mol_2);\n",
      "phi_2 = (x_2*V_mol_2)/(x_1*V_mol_1+x_2*V_mol_2);\n",
      "\n",
      "#math.log(Y1) = (V_mol_1/(R*T))*phi_1**(2)*(del_1-del_2)**(2)\n",
      "Y1 = math.exp((V_mol_1/(R*T))*(phi_1**(2))*((del_1-del_2)**(2)));\n",
      "\n",
      "#Similarly, for Y2\n",
      "Y2 = math.exp((V_mol_2/(R*T))*(phi_2**(2))*((del_1-del_2)**(2)));\n",
      "\n",
      "# Results\n",
      "print \"The value of activity coefficients for Scatchard-Hilderbrand model are Y1 = %f \\t and \\t Y2 = %f\"%(Y1,Y2);\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of activity coefficients for Scatchard-Hilderbrand model are Y1 = 1.010245 \t and \t Y2 = 1.017658\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 14.14  Page Number : 485"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "# Variables,\n",
      "T = 25 + 273.15;\t\t\t#[K] - Temperature\n",
      "mol_HCl = 0.001;\t\t\t#[mol/kg] - Molality of HCl\n",
      "A = 0.510;\t\t\t#[(kg/mol)**(1/2)]\n",
      "Z_positive = 1;\t\t\t#Stoichiometric coefficient of 'H' ion\n",
      "Z_negative = -1;\t\t\t#Stoichiometric coefficient of 'Cl' ion\n",
      "m_H_positive = mol_HCl;\t\t\t#\n",
      "m_Cl_negative = mol_HCl;\n",
      "\n",
      "# Calculations and Results\n",
      "# I = 1/2*[((Z_positive)**(2))*m_H_positive + ((Z_negative)**(2))*m_Cl_negative]\n",
      "I = 1./2*(((Z_positive)**(2))*m_H_positive + ((Z_negative)**(2))*m_Cl_negative);\n",
      "\n",
      "#Using Debye-Huckel limiting law wee get,\n",
      "# math.log(Y1) = -A*(abs(Z_positive*Z_negative))*(I**(1/2)))\n",
      "Y = 10**(-A*(abs(Z_positive*Z_negative))*(I**(1./2)));\n",
      "print \"The mean activity coefficient at 25 C using Debye-Huckel limiting law is Y = %f\"%(Y);\n",
      "\n",
      "#Using Debye-Huckel extended model we get\n",
      "#math.log(Y_prime) = (-A*(abs(Z_positive*Z_negative))*(I**(1/2)))/(1 + (I**(1/2)));\n",
      "Y_prime = 10**((-A*(abs(Z_positive*Z_negative))*(I**(1./2)))/(1 + (I**(1./2))));\n",
      "print \"The mean activity coefficient at 25 C using Debye-Huckel extended model is Y = %f\"%(Y_prime);\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The mean activity coefficient at 25 C using Debye-Huckel limiting law is Y = 0.963546\n",
        "The mean activity coefficient at 25 C using Debye-Huckel extended model is Y = 0.964643\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 14.15  Page Number : 485"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "# Variables,\n",
      "T = 25 + 273.15;\t\t\t#[K] - Temperature\n",
      "mol_CaCl2 = 0.001;\t\t\t#[mol/kg] - Molality of HCl\n",
      "A = 0.510;\t\t\t#[(kg/mol)**(1/2)]\n",
      "Z_positive = 2;\t\t\t#Stoichiometric coefficient of 'Ca' ion\n",
      "Z_negative = -1;\t\t\t#Stoichiometric coefficient of 'Cl' ion\n",
      "m_Ca_positive = mol_CaCl2;\n",
      "m_Cl_negative = 2*mol_CaCl2;\n",
      "\n",
      "# Calculations\n",
      "# I = 1/2*[((Z_positive)**(2))*m_Ca_positive + ((Z_negative)**(2))*m_Cl_negative]\n",
      "I = 1./2*(((Z_positive)**(2))*m_Ca_positive + ((Z_negative)**(2))*m_Cl_negative);\n",
      "\n",
      "#Using Debye-Huckel limiting law wee get,\n",
      "# math.log(Y1) = -A*(abs(Z_positive*Z_negative))*(I**(1/2)))\n",
      "Y = 10**(-A*(abs(Z_positive*Z_negative))*(I**(1./2)));\n",
      "\n",
      "# Results\n",
      "print \"The mean activity coefficient at 25 C using Debye-Huckel limiting law is Y = %f\"%(Y);\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The mean activity coefficient at 25 C using Debye-Huckel limiting law is Y = 0.879290\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 14.17  Page Number : 488"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "# Variables,\n",
      "T = 50 + 273.15;\t\t\t#[K] - Temperature\n",
      "R=8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
      "x_1 = 0.3;\t\t\t# Mole fraction of component 1\n",
      "x_2 = (1-x_1);\t\t\t# Mole fraction of component 2\n",
      "#Increment of 1% means Y2 = 1.01*Y1\n",
      "\n",
      "# Calculations\n",
      "#Excess volume of the mixture is given by,\n",
      "V_excess = 4*x_1*x_2;\t\t\t#[cm**(3)/mol]\n",
      "#Amd threfore\n",
      "V_1_excess = 4*x_2*x_2*10**(-6);\t\t\t#[m**(3)/mol] - Exces volume of component 1\n",
      "V_2_excess = 4*x_1*x_1*10**(-6);\t\t\t#[m**(3)/mol] - Exces volume of component 2\n",
      "\n",
      "#We have from equation 14.89 of the book,\n",
      "#V_i_excess/(R*T) = (del_math.log(Y_i)/del_P)_T,x\n",
      "\n",
      "#Rearranging above equation\n",
      "#d(math.log(Y1)) = (V1_excess/(R*T))dP\n",
      "#Integrating the above equation at constant 'T' and 'x' in the limit from 'Y1' to '1.01*Y1' in the LHS and from 'P' to 'P+delta_P' in the RHS\n",
      "#On simplification we get\n",
      "#math.log(1.01*Y1/Y1) = (V_1_exces/(R*T))*delta_P\n",
      "delta_P = math.log(1.01)/(V_1_excess/(R*T));\t\t\t#[N/m**(2)]\n",
      "delta_P = delta_P*10**(-6);\t\t\t#[MPa]\n",
      "\n",
      "# Results\n",
      "print \"The required pressure to increase the activity coefficient by 1%% is %f MPa\"%(delta_P);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The required pressure to increase the activity coefficient by 1% is 13.639411 MPa\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 14.21  Page Number : 490"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "# Variables\n",
      "T = 293.15;\t\t\t#[K] - Temperature\n",
      "R=8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
      "A = 1280;\t\t\t#[J/mol]\n",
      "\n",
      "#(dA/dT)_P,x = del_A (say)\n",
      "dA_dT = -7.0;\t\t\t#[J/mol-K]\n",
      "\n",
      "#For equilomar mixture,\n",
      "x_1 = 0.5;\t\t\t# Mole fraction of component 1\n",
      "x_2 = 0.5;\t\t\t# Mole fraction of component 2\n",
      "\n",
      "# Calculations\n",
      "#math.log(Y1) =  (A/(R*T))*x_2**(2)\n",
      "#math.log(Y2) =  (A/(R*T))*x_1**(2)\n",
      "Y1 = math.exp((A/(R*T))*x_2**(2));\n",
      "Y2 = math.exp((A/(R*T))*x_1**(2));\n",
      "\n",
      "#G_excess/(R*T*) = x_1*math.log(Y1) + x_2*math.log(Y2) = (A/(R*T))*x_1*x_2\n",
      "G_excess = A*x_1*x_2;\t\t\t#[J/mol] - Excess Gibbs free energy\n",
      "\n",
      "#H_excess/(R*T**(2)) = -[d/dT(G_excess/(R*T))]_P,x\n",
      "#H_excess/(R*T**(2)) = -((x_1*x_2)/R)*[d/dT(A/T)]_P,x\n",
      "#On simplification  and putting the values we get\n",
      "H_excess = A*x_1*x_2 - T*dA_dT*x_1*x_2;\t\t\t#[J/mol] - Excess enthalpy\n",
      "\n",
      "#Now excess entropy is given by\n",
      "S_excess = (H_excess - G_excess)/T;\t\t\t#[J/mol-K] - Excess entropy\n",
      "\n",
      "# Results\n",
      "print \"For equimolar mixture\";\n",
      "print \"Excess Gibbs free energy G_excess) is %f J/mol\"%(G_excess);\n",
      "print \"Excess enthalpy H_excess) is %f J/mol\"%(H_excess);\n",
      "print \"Excess entropy S_excess) is %f J/mol\"%(S_excess);\n",
      "print \"The value of activity coefficient Y1 is %f\"%(Y1);\n",
      "print \"The value of activity coefficient Y2 is %f\"%(Y2);\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "For equimolar mixture\n",
        "Excess Gibbs free energy G_excess) is 320.000000 J/mol\n",
        "Excess enthalpy H_excess) is 833.012500 J/mol\n",
        "Excess entropy S_excess) is 1.750000 J/mol\n",
        "The value of activity coefficient Y1 is 1.140305\n",
        "The value of activity coefficient Y2 is 1.140305\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 14.22  Page Number : 491"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "# Given\n",
      "T = 60 + 273.15;\t\t\t#[K] - Temperature\n",
      "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
      "\n",
      "# math.log(Y1_inf) = math.log(Y2_inf) = 0.15 + 10/T\n",
      "\n",
      "\n",
      "# From van L# Variablesr equation \n",
      "# A = math.log(Y1_inf) and B = math.log(Y2_inf) and since it is given that math.log(Y1_inf) = math.log(Y2_inf), therefore A = B\n",
      "#(x_1*x_2)/(G_excess/R*T) = x_1/B + x_2/A = X_1/A + x_2/A = 1/A\n",
      "# G_excess/(R*T) = A*x_1*x_2\n",
      "\n",
      "# For equilomar mixture,\n",
      "x_1 = 0.5;\t\t\t# Mole fraction of component 1\n",
      "x_2 = 0.5;\t\t\t# Mole fraction of component 2\n",
      "\n",
      "# Calculations and Results\n",
      "# Expression for A can be written as\n",
      "# A = 0.15 + 10/T, where T is in C. Therefore\n",
      "A = 0.15 + 10/(T - 273.15);\n",
      "# Differentiating it with respect to temprature we get\n",
      "dA_dT = - 10/((T-273.15)**(2));\n",
      "\n",
      "# The excess Gibbs free energy can be calculated as\n",
      "G_excess = A*x_1*x_2*(R*T);\t\t\t#[J/mol]\n",
      "\n",
      "# The ideal Gibbs free energy change can  be calculated as\n",
      "delta_G_id_mix = R*T*(x_1*math.log(x_1) + x_2*math.log(x_2));\t\t\t#[J/mol]\n",
      "\n",
      "# Finally we have,\n",
      "delta_G_mix = G_excess + delta_G_id_mix;\t\t\t#[J/mol]\n",
      "\n",
      "print \"The Gibbs free energy change of mixing for equimolar mixture is %f J/mol\"%(delta_G_mix);\n",
      "\n",
      "\n",
      "# Now let us determine the excess enthalpy. We know that\n",
      "# H_excess/(R*T**(2)) = -[d/dT(G_excess/R*T)]_P,x = - x_1*x_2*[d/dT(A)]_P,x\n",
      "# Therefore at 'T' = 60 C the excess enthalpy is given by\n",
      "H_excess = -R*(T**(2))*x_1*x_2*dA_dT;\t\t\t#[J/mol]\n",
      "\n",
      "delta_H_id_mix = 0;\t\t\t#[J/mol] - Enthalpy change of mixing for ideal solution is zero.\n",
      "\n",
      "#Thus enthalpy change of mixing for an equimolar mixture at 333.15 K is given by\n",
      "delta_H_mix = delta_H_id_mix + H_excess;\t\t\t#[J/mol]\n",
      "\n",
      "\n",
      "print \"The enthalpy change of mixing for equimolar mixture is %f J/mol\"%(delta_H_mix);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The Gibbs free energy change of mixing for equimolar mixture is -1700.608815 J/mol\n",
        "The enthalpy change of mixing for equimolar mixture is 640.806876 J/mol\n"
       ]
      }
     ],
     "prompt_number": 12
    }
   ],
   "metadata": {}
  }
 ]
}