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
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
|
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": [
"Chapter 14 : Chemical reaction equilibrium"
]
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 14.1 Page No : 489"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"\n",
"import math\n",
"\n",
"# Variables\n",
"T = 298.15;\t\t\t #temperature in K\n",
"del_Gf = [-137.327,-228.600,-394.815,0]; #the standard Gibbs free energy of formation of CO(g),H2O(g),CO2(g) and H2(g) in kJ\n",
"n = [1,1,-1,-1] \t\t\t #stoichiometric coefficients of CO(g),H2O(g),CO2(g) and H2(g) respectively (no unit)\n",
"R = 8.314;\t\t\t #universal gas constant in J/molK\n",
"\n",
"# Calculations\n",
"del_G = (n[0]*del_Gf[0])+(n[1]*del_Gf[1])+(n[2]*del_Gf[2])+(n[3]*del_Gf[3]);\n",
"Ka = math.exp((-(del_G*10**3))/(R*T))\n",
"\n",
"# Results\n",
"print 'The standard Gibbs free energy of the water gas shift reaction at 298.15K = %0.3f kJ '%(del_G);\n",
"print 'The equilibrium constant of the water gas shift reaction at 298.15K = %0.3e '%(Ka);\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"The standard Gibbs free energy of the water gas shift reaction at 298.15K = 28.888 kJ \n",
"The equilibrium constant of the water gas shift reaction at 298.15K = 8.685e-06 \n"
]
}
],
"prompt_number": 2
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 14.2 Page No : 490"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"import math\n",
"# Variables\n",
"T = 298.15;\t\t\t #temperature in K\n",
"P_s = 0.16716;\t\t\t #saturation pressure of CH3OH in bar at T\n",
"del_G1 = -166.215\n",
"R = 8.314;\t\t\t #universal gas constant in J/molK\n",
"\n",
"# Calculations\n",
"f_v = 1\n",
"f_l = P_s\n",
"del_G2 = R*T*math.log(f_v/f_l)*10**-3;\t\t\t # Calculations of the value of del_G2 in kJ\n",
"del_G = del_G2+del_G1;\t\t\n",
"\n",
"# Results\n",
"print 'The standard Gibbs free energy of formation of CH3OHg = %0.3f kJ '%(del_G);"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"The standard Gibbs free energy of formation of CH3OHg = -161.781 kJ \n"
]
}
],
"prompt_number": 3
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 14.3 Page No : 491"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"import math\n",
"# Variables\n",
"#The water gas shift reaction is given by: CO2(g)+H2(g)--->CO(g)+H2O(g)\n",
"T1 = 298.15 \t\t\t #initial temperature in K\n",
"Ka1 = 8.685*10**-6;\t\t\t #equilibrium constant for the water-gas shift reaction at T1 (no unit)\n",
"T2 = 1000.\t\t \t #temperature at which the equilibrium constant has to be determined in K\n",
"R = 8.314;\t\t\t #universal gas constant in J/molK\n",
"del_Hf = [-110.532,-241.997,-393.978,0];\t\t\t #the standard enthalpy of formation of CO(g),H2O(g),CO2(g) and H2(g) in kJ\n",
"n = [1,1,-1,-1];\t\t\t #stoichiometric coefficients of CO(g),H2O(g),CO2(g) and H2(g) respectively (no unit)\n",
"\n",
"# Calculations\n",
"#It is assumed that del_H is constant in the temperature range T1 and T2\n",
"del_H = (n[0]*del_Hf[0])+(n[1]*del_Hf[1])+(n[2]*del_Hf[2])+(n[3]*del_Hf[3])\n",
"Ka2 = Ka1*math.exp(((del_H*10**3)/R)*((1./T1)-(1./T2)));\t\t\t \n",
"\n",
"# Results\n",
"print 'The equilibrium constant for the water gas shift reaction at 1000K = %f '%(Ka2);\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"The equilibrium constant for the water gas shift reaction at 1000K = 1.085357 \n"
]
}
],
"prompt_number": 4
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 14.4 Page No : 492"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"import math\n",
"# Variables\n",
"P = 0.1 \t\t\t #pressure in MPa\n",
"T1 = 298.15;\t\t\t #initial temperature in K\n",
"Ka1 = 8.685*10**-6;\t\t\t #equilibrium constant for the water-gas shift reaction at T1 (no unit) (from Example 14.1)\n",
"T2 = 1000. \t\t\t #temperature at which the equilibrium constant is to be found, in K\n",
"del_H = 41.449;\t\t\t #smath.tan(math.radiansard enthalpy of the reaction at T1 in kJ (from Example 14.3)\n",
"a = [28.068,28.850,45.369,27.012];\n",
"b = [4.631*10**-3,12.055*10**-3,8.688*10**-3,3.509*10**-3]\n",
"c = [0,0,0,0];\n",
"d = [0,0,0,0];\n",
"e = [-0.258*10**5,1.006*10**5,-9.619*10**5,0.690*10**5]\n",
"n = [1,1,-1,-1]\n",
"R = 8.314;\t\t\n",
"Ka2_prev = 1.0855\n",
"\n",
"\n",
"# Calculations\n",
"del_a = (n[0]*a[0])+(n[1]*a[1])+(n[2]*a[2])+(n[3]*a[3]);\n",
"del_b = (n[0]*b[0])+(n[1]*b[1])+(n[2]*b[2])+(n[3]*b[3]);\n",
"del_c = (n[0]*c[0])+(n[1]*c[1])+(n[2]*c[2])+(n[3]*c[3]);\n",
"del_d = (n[0]*d[0])+(n[1]*d[1])+(n[2]*d[2])+(n[3]*d[3]);\n",
"del_e = (n[0]*e[0])+(n[1]*e[1])+(n[2]*e[2])+(n[3]*e[3]);\n",
"del_H0 = (del_H*10**3)-((del_a*T1)+((del_b/2)*T1**2)+((del_c/3)*T1**3)+((del_d/4)*T1**4)-(del_e/T1));\n",
"I = (math.log(Ka1))-((1./R)*((-del_H0/T1)+(del_a*math.log(T1))+((del_b/2)*T1)+((del_c/6)*T1**2)+((del_d/12)*T1**3)+((del_e/(2*T1**2)))));\n",
"Ka2 = math.exp(((1./R)*((-del_H0/T2)+(del_a*math.log(T2))+((del_b/2)*T2)+((del_c/6)*T2**2)+((del_d/12)*T2**3)+((del_e/(2*T2**2)))))+I);\n",
"\n",
"\t\t\t # Results\n",
"print 'The equilibrium constant for the water gas shift reaction at 1000K\\\n",
" by taking into account the variation of del_H with temperature = %f '%(Ka2);\n",
"print 'The equilibrium constant for the water gas shift reaction at 1000K without\\\n",
" considering the variation of del_H with temperature as given by Example14.3 = %0.4f '%(Ka2_prev);"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"The equilibrium constant for the water gas shift reaction at 1000K by taking into account the variation of del_H with temperature = 0.664976 \n",
"The equilibrium constant for the water gas shift reaction at 1000K without considering the variation of del_H with temperature as given by Example14.3 = 1.0855 \n"
]
}
],
"prompt_number": 22
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 14.5 page no : 494"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"from sympy import Symbol\n",
"from sympy.solvers import solve\n",
"import math\n",
"\n",
"# variables\n",
"deltaGf = -161.781 # kJ from exa. 14.2\n",
"deltaG298 = deltaGf - (-137.327)\n",
"deltaH298 = -200.660 - (-110.532)\n",
"deltaA = 18.382 - 28.068 - 2 * 27.012\n",
"deltaB = (101.564 - 4.631 - 2 * 3.509) * 10**-3\n",
"deltaC = -28.683 * 10**-6\n",
"deltaD = 0\n",
"deltaE = (0.258 - 2 * 0.690) * 10**5\n",
"T = 298.15\n",
"\n",
"# calculations\n",
"deltaHf298 = -238.648 + 37.988\n",
"deltaH0 = Symbol('deltaH0')\n",
"Eq = deltaH0 + deltaA*T + deltaB*T**2/2 + deltaC*T**3/3 - deltaE/T - deltaH298*1000\n",
"deltaH0 = solve(Eq,deltaH0)[0]/1000\n",
"I = Symbol('I')\n",
"\n",
"Eq1 = deltaH0*1000 - deltaA*T*math.log(T) - deltaB*T**2/2 - deltaC*T**3/6 - deltaD*T**4/12 - deltaE/(2*T) - 8.314 * T * I + 24454\n",
"I = round(solve(Eq1,I)[0],3)\n",
"\n",
"T = 500\n",
"deltaG500 = (deltaH0*1000 - deltaA*T*math.log(T) - deltaB*T**2/2 - deltaC*T**3/6 - deltaD*T**4/12 - deltaE/(2*T) - 8.314 * T * I)/1000\n",
"\n",
"Ka = math.exp(-22048/(8.314*T))\n",
"e = Symbol('e')\n",
"Eq3 = ( (e*(3-2*e)**2) / (1 - e)**3) / 0.4973 -1\n",
"e = round(solve(Eq3,e)[0],4)\n",
"yCH3OH = e/(3-2*e)\n",
"yco = (1-e)/(3-2*e)\n",
"yh2 = (2*(1-e) / (3-2*e))\n",
"\n",
"# Results\n",
"print \"E = %.4f\"%e\n",
"print \"YCH30H = %.4f\"%yCH3OH\n",
"print \"YCO = %.4f\"%yco\n",
"print \"YH2 = %.4f\"%yh2\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"E = 0.0506\n",
"YCH30H = 0.0175\n",
"YCO = 0.3275\n",
"YH2 = 0.6550\n"
]
}
],
"prompt_number": 103
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 14.6, Page 496"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"from sympy.solvers import solve \n",
"from sympy import Symbol \n",
"\n",
"#Variables\n",
"e = Symbol('e')\n",
"\n",
"#Calculations\n",
"x = solve((((e/(3-2*e))/(((1-e)/(3-2*e))*(((2*(1-e))/(3-2*e))**2)))-49.73),e)\n",
"print \"e =\",round(x[0],3)\n",
"ych3oh = x[0]/(3-2*x[0])\n",
"yco = (1-x[0])/(3-2*x[0])\n",
"yh2 = ((2*(1-x[0]))/(3-2*x[0]))\n",
"print \"yCH3OH =\",round(ych3oh,4)\n",
"print \"yCO =\",round(yco,4)\n",
"print \"yH2 =\",round(yh2,4)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"e = 0.801\n",
"yCH3OH = 0.5731\n",
"yCO = 0.1423\n",
"yH2 = 0.2846\n"
]
}
],
"prompt_number": 23
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 14.7 pageno : 497"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"from sympy import Symbol\n",
"from sympy.solvers import solve\n",
"\n",
"# variables\n",
"Ka = 4.973*10**-3 # from example 14.5\n",
"Ky = 25 * Ka # from example 14.5\n",
"\n",
"# calculations\n",
"e = Symbol('e')\n",
"Eq1 = ( (e*(4-e)**2)/(1-e)**3 ) / .1243 - 1\n",
"e = round(solve(Eq1,e)[0],5)\n",
"yCH3OH = e/(8-2*e)\n",
"yco = (1-e)/(8-2*e)\n",
"yh2 = (2*(1-e) / (8-2*e))\n",
"yA = 5/(8-2*e)\n",
"\n",
"# Results\n",
"print \"E = %.5f\"%e\n",
"print \"YCH30H = %.5f\"%yCH3OH\n",
"print \"YCO = %.5f\"%yco\n",
"print \"YH2 = %.5f\"%yh2\n",
"print \"YA = %.5f\"%yA"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"E = 0.00762\n",
"YCH30H = 0.00095\n",
"YCO = 0.12428\n",
"YH2 = 0.24857\n",
"YA = 0.62619\n"
]
}
],
"prompt_number": 2
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 14.8 pageno : 198"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"from sympy import Symbol\n",
"from sympy.solvers import solve\n",
"\n",
"# variables\n",
"Ka = 4.973*10**-3 # example 14.5\n",
"Ky = 25 * Ka # example 14.5\n",
"\n",
"# calculations and results\n",
"e = Symbol('e')\n",
"Eq1= ((e*(1-e))/(1-2*e)**2)/.03108 - 1\n",
"e = solve(Eq1,e)\n",
"print \"part a\"\n",
"print \"e = %.5f and e = %.5f\"%(e[0],e[1])\n",
"print \"The admissible value is e = %.5f\"%e[0]\n",
"\n",
"print \"part b\"\n",
"print \"e = 0.0506 ( from example 14.5 )\"\n",
"\n",
"x = 4\n",
"e = Symbol('e')\n",
"Eq1= ((e/(1-e) ) * ( (5 - 2*e)/ (2-e) )**2)/ 0.4973 - 1\n",
"e = solve(Eq1,e)\n",
"print \"part c\"\n",
"print \"e = %.4f\" %(e[0])"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"part a\n",
"e = 0.02845 and e = 0.97155\n",
"The admissible value is e = 0.02845\n",
"part b\n",
"e = 0.0506 ( from example 14.5 )\n",
"part c"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"\n",
"e = 0.0727\n"
]
}
],
"prompt_number": 134
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 14.9 pageno : 499"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"from sympy import Symbol\n",
"from sympy.solvers import solve\n",
"\n",
"# variables\n",
"Ka = 4.973*10**-3 # example 14.5\n",
"Ky = 25 * Ka # example 14.5\n",
"\n",
"# calculations\n",
"e = Symbol('e')\n",
"Eq1 = (0.02 + e)*(1.51-e)**2 / (1-e)**3 / Ky - 1\n",
"e = solve(Eq1,e)[0]\n",
"\n",
"# Results\n",
"print \"E = %.5f\"%e"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"E = 0.03165\n"
]
}
],
"prompt_number": 138
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 14.10 pageno : 500"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"%matplotlib inline\n",
"\n",
"from matplotlib.pyplot import *\n",
"from sympy import Symbol\n",
"from sympy.solvers import solve\n",
"from scipy.integrate import quad\n",
"import math\n",
"\n",
"# variables\n",
"deltaA = round(28.850 - 27.012 - 0.5 * 30.255,2)\n",
"deltaB = (12.055 - 3.509 - 0.5 * 4.207) * 10**-3\n",
"deltaC = 0\n",
"deltaD = 0\n",
"deltaE = round((1.006 - 0.690 + 0.5 * 1.887),3) * 10**5\n",
"deltaH298 = -241.997\n",
"Ts = [2000,2500,3000,3500,3800]\n",
"deltaHt = []\n",
"deltaGt = []\n",
"Ka = []\n",
"Ea = []\n",
"Eb = []\n",
"\n",
"# Calculations\n",
"T = 298.15\n",
"deltaH0 = Symbol('deltaH0')\n",
"Eq = deltaH0 + deltaA*T + deltaB*T**2/2 + deltaC*T**3/3 + deltaD*T**4/4 - deltaE/T - deltaH298*1000\n",
"deltaH0 = round(solve(Eq,deltaH0)[0]/1000,3)\n",
"I = Symbol('I')\n",
"Eq1 = deltaH0*1000 - deltaA*T*math.log(T) - deltaB*T**2/2 - deltaC*T**3/6 - deltaD*T**4/12 - deltaE/(2*T) - 8.314 * T * I + 228600\n",
"I = round(solve(Eq1,I)[0],3)\n",
"\n",
"def fun1(T1):\n",
" #return 42.1395*(T1 - 298.15) + 5.613*10**-3/2*(T1**2 - 298.15**2) + .2535 * 10**5 * (1./T1 - 1/298.15)\n",
" return 42.1395*T1 + 5.613*10**-3/2 * T1**2 + 0.2535*10**5/T1 - 12898.37\n",
"\n",
"for T in Ts:\n",
" Ht = deltaH0*1000 + deltaA*T + deltaB*T**2/2 + deltaC*T**3/3 + deltaD*T**4/4 - deltaE/T \n",
" Gt = deltaH0*1000 - deltaA*T*math.log(T) - deltaB*T**2/2 - deltaC*T**3/6 - deltaD*T**4/12 - deltaE/(2*T) - 8.314 * T * I \n",
" ka = math.exp(-Gt/(8.314*T))\n",
" e = Symbol('e')\n",
" Eq2 = ( e * (3-e)**(1./2) ) / ( 1-e)**(3./2) / ka - 1\n",
" b = round(solve(Eq2)[0],4)\n",
" a = (quad(fun1,298.15,T)[0]/1000) / -Ht\n",
" deltaHt.append(Ht)\n",
" deltaGt.append(Gt)\n",
" Ka.append(ka)\n",
" Ea.append(a)\n",
" Eb.append(b)\n",
"\n",
"\n",
"# Results \n",
"plot(Ts,Ea,\"g\")\n",
"plot(Ts,Eb,\"b\")\n",
"xlabel(\"T(k)\")\n",
"ylabel(\"E\")\n",
"suptitle(\"Plot of e versus adiabatic reaction temperature\")\n",
"show()\n",
"print \"from plot, it can be seen that both lines are simultaneously satisfied at the point \\\n",
"\\nintersection where e = 0.68 and T = 3440 K\"\n",
"e = 0.68\n",
"T = 3440\n",
"yh2 = (1- e)/(1.5 - 0.5*e)\n",
"yo2 = 0.5*(1-e) / (1.5-0.5*e)\n",
"yh2o = e/(1.5- 0.5*e)\n",
"\n",
"print \"yH2 = %.4f\"%yh2\n",
"print \"yO2 = %.4f\"%yo2\n",
"print \"yH2O = %.4f\"%yh2o"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Populating the interactive namespace from numpy and matplotlib\n"
]
},
{
"output_type": "stream",
"stream": "stderr",
"text": [
"WARNING: pylab import has clobbered these variables: ['solve', 'draw_if_interactive', 'e']\n",
"`%pylab --no-import-all` prevents importing * from pylab and numpy\n"
]
},
{
"metadata": {},
"output_type": "display_data",
"png": "iVBORw0KGgoAAAANSUhEUgAAAYoAAAEhCAYAAABhpec9AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XlYVGX/BvB7QBFMU3MhFRRDk8VhExEUFEvUXNMwNSUV\nLcLUfDNfWyzEyqXSst5SNHDLzD1NBfdRcUFAFLfMUGNRSRAVYp95fn+cHxMIM6HNcFjuz3VxOcuZ\nMzdnjvPleZ5znqMQQggQERHpYCJ3ACIiqt5YKIiISC8WCiIi0ouFgoiI9GKhICIivVgoiIhILxYK\nIzE1NYWrqyvs7OwwbNgwZGdnAwAaNWqk93V//PEHNmzY8MjvN3PmTNjb22P27NmPlbcmWr16NaZN\nmwYACAsLw7p16/QuP2HCBGzdurXS63/4s4iPj8dbb731eGENxJiZ5s+fb5D1GNuaNWtw69YtuWPU\nKSwURtKwYUMkJCTg119/RePGjfHtt98CABQKhd7XXb9+HT/++OMjv194eDguXbqERYsWPVbex6VW\nq6v0/XQJCgpCQECA3mX+ads/7OHPomvXrli6dOlj5dNoNI/1OmNmetiCBQsMsh5D0Le9Vq9ejZs3\nbz7S+qrLflpTsVBUAW9vb1y/fr3MYxqNBtOmTYODgwMcHBywdu1aAMC7776LY8eOwdXVtdwXgK7X\nDB06FDk5OXBzc8OmTZvKvCYnJwdjxoyBs7MzHB0dsXnz5nL5xowZgz179mjvT5gwAdu2bYNarcbU\nqVPh7OwMe3t7fP311wAAlUoFHx8fDB8+HE5OTsjOzsbAgQPh7OwMpVKpzWBjY4O7d+8CAOLi4tCn\nTx8AwMGDB+Hq6qr9KWltlTZ06FC4u7vj2Wef1b4vILUcbG1t0aNHD5w4cUL7+Ny5c7F48WLtMh4e\nHnB0dMSQIUOQk5OjXe7AgQPw9PSEra0ttm/fDgC4ceMGfHx84Orqii5duuDIkSPlPouv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DlzBj/88AMG\nDx6snXG1IkOGDMHWrVtRVFRUhamJDI+FgqiSSp+bumHDBu0Mq6XFxsbCzc0N169fh0KhgJeXV5mL\nxRDVRCwURI9IrVbjwoULePbZZ8s8fuLECQQHB2Pnzp3o0KEDAMDDwwNHjx6VIyaRwbBQED2ijIyM\nMlPQA8Dly5cRFBSEXbt2lZmFs02bNrhx40YVJyQyLBYKosdQuhtKoVCgdevWsLCwwJkzZ8osp9Fo\noFAoqjoekUHVkzsAUU3TokUL5OTkaO8LIdC0aVOEh4fDz88PTzzxBHr37g0AuHXrlvaylEQ1FVsU\nRJVU0jIwNTVFly5dcOXKFe3jCoUCrVq1wq5du/Dmm28iNjYWAHD69Gn06tVLtsxEhsBpxokew+rV\nq5Geno7Zs2frXEaj0cDNzQ1xcXGoV4+Nd6q52KIgegyvvPIKdu/erfc6zrt27YK/vz+LBNV4bFEQ\nEZFebFEQEZFeLBRERKQXCwUREenFQkFERHqxUBARkV4sFEREpNf/ARiuLhNA/r0uAAAAAElFTkSu\nQmCC\n",
"text": [
"<matplotlib.figure.Figure at 0x51ff6d0>"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"from plot, it can be seen that both lines are simultaneously satisfied at the point \n",
"intersection where e = 0.68 and T = 3440 K\n",
"yH2 = 0.2759\n",
"yO2 = 0.1379\n",
"yH2O = 0.5862\n"
]
}
],
"prompt_number": 7
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 14.11 Page No : 506"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"\n",
"from numpy import *\n",
"\n",
"# Variables\n",
"stoichio_matrix = matrix([[-1,-1, 1, 3, 0, 0],[0, -1, -1, 1, 1 ,0],[-1, -2, 0 ,4, 1, 0], \\\n",
" [0,0, 1, 0, -1, 0.5],[-1, 2 ,0, 0, 1, -2],[-1, 1, 1, 1, 0, -1]])\t\t\t #Framing the stoichiometric coefficient matrix\n",
"\n",
"\n",
"# Calculations\n",
"\n",
"r = linalg.matrix_rank(stoichio_matrix)\n",
"\n",
"stoichio_matrix[0] = -stoichio_matrix[0];\n",
"stoichio_matrix[2] = stoichio_matrix[2]+stoichio_matrix[0];\n",
"stoichio_matrix[5:] = stoichio_matrix[5:]+stoichio_matrix[0];\n",
"stoichio_matrix[6:] = stoichio_matrix[6:]+stoichio_matrix[0];\n",
"stoichio_matrix[1] = -stoichio_matrix[1];\n",
"stoichio_matrix[2] = stoichio_matrix[2]+stoichio_matrix[1];\n",
"stoichio_matrix[5:] = stoichio_matrix[5:]-(3*stoichio_matrix[1]);\n",
"stoichio_matrix[6:] = stoichio_matrix[6:]-(2*stoichio_matrix[1]);\n",
"x = stoichio_matrix[:3]\n",
"y = stoichio_matrix[:4];\n",
"stoichio_matrix[:4] = y;\n",
"stoichio_matrix[:3] = x;\n",
"stoichio_matrix[5:] = stoichio_matrix[5:]+(4*stoichio_matrix[3]);\n",
"stoichio_matrix[6:] = stoichio_matrix[6:]+(2*stoichio_matrix[3]);\n",
"\n",
"\n",
"\n",
"# Results\n",
"print ' The stoichiometric coefficient matrix after performing the elementary row operations = ';\n",
"print (stoichio_matrix);\n",
"print ' The number of primary reactions = %d'%(r);\n",
"print ' The non zero rows are 1,2,4'\n",
"print ' The primary reactions are: CH4g)+H2Og)--->COg)+3H2g)%( COg)+H2Og)--->CO2g)+H2g),( CO2g)--->COg)+1./2)O2g)'\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" The stoichiometric coefficient matrix after performing the elementary row operations = \n",
"[[ 1. 1. -1. -3. -0. -0. ]\n",
" [-0. 1. 1. -1. -1. -0. ]\n",
" [ 0. 0. 0. 0. 0. 0. ]\n",
" [ 0. 0. 1. 0. -1. 0.5]\n",
" [-1. 2. 0. 0. 1. -2. ]\n",
" [ 0. -1. 1. 1. -1. 1. ]]\n",
" The number of primary reactions = 3\n",
" The non zero rows are 1,2,4\n",
" The primary reactions are: CH4g)+H2Og)--->COg)+3H2g)%( COg)+H2Og)--->CO2g)+H2g),( CO2g)--->COg)+1./2)O2g)\n"
]
}
],
"prompt_number": 169
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 14.13 pageno : 510"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"from sympy import Symbol\n",
"from sympy.solvers import solve\n",
"\n",
"# variables\n",
"Ka1 = 0.1429\n",
"Ka2 = 2\n",
"\n",
"# calculations and Results\n",
"\n",
"# assume e1 = .3\n",
"e2 = Symbol('e2')\n",
"Eq1 = ((0.3 - e2)*(0.3+e2) /((0.7 - e2) * 0.7)) / 0.1429 -1\n",
"e2 = solve(Eq1)\n",
"print \"E2 = %.1f and %.1f \"%(e2[0],e2[1])\n",
"\n",
"# since negative value is inadmissible. e2 = 0.2\n",
"e2 = round(e2[1],1)\n",
"e1 = Symbol('e1')\n",
"Eq2 = ((e1 + 0.2)*(0.2) /((0.8 - e1) *(e1 - 0.2) ) ) / 2 -1\n",
"e1 = solve(Eq2)\n",
"print \"E1 = %.1f and %.1f \"%(e1[0],e1[1])\n",
"e1 = round(e1[0],1)\n",
"print \"Satisfied results when e1 = %.1f and e2 = %.1f\"%(e1,e2)\n",
"\n",
"yA = (1-e1-e2)/2\n",
"yB = (1-e1)/2\n",
"yC = (e1-e2)/2\n",
"yD = (e1+e2)/2\n",
"yE = e2/2\n",
"\n",
"print \"yA = %.2f\"%yA\n",
"print \"yB = %.2f\"%yB\n",
"print \"yC = %.2f\"%yC\n",
"print \"yD = %.2f\"%yD\n",
"print \"yE = %.2f\"%yE\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"E2 = -0.1 and 0.2 \n",
"E1 = 0.3 and 0.6 \n",
"Satisfied results when e1 = 0.3 and e2 = 0.2\n",
"yA = 0.25\n",
"yB = 0.35\n",
"yC = 0.05\n",
"yD = 0.25\n",
"yE = 0.10\n"
]
}
],
"prompt_number": 214
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 14.14 page no : 515"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"from sympy import Symbol\n",
"from sympy.solvers import solve\n",
"\n",
"# variables\n",
"Kc = 2.92\n",
"\n",
"# Calculations and results\n",
"e = Symbol('e')\n",
"Eq1 = (e*(10+e)/((5-e)*(10-e)))/Kc - 1\n",
"e = round(solve(Eq1)[0],4)\n",
"print \"E = %.4f\"%e\n",
"\n",
"cA = 5-e\n",
"cB = 10-e\n",
"cC = e\n",
"cD = 10+e\n",
"\n",
"print \"CA = %.4f kmol/m*3\"%cA\n",
"print \"CB = %.4f kmol/m*3\"%cB\n",
"print \"CC = %.4f kmol/m*3\"%cC\n",
"print \"CD = %.4f kmol/m*3\"%cD"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"E = 3.0446\n",
"CA = 1.9554 kmol/m*3\n",
"CB = 6.9554 kmol/m*3\n",
"CC = 3.0446 kmol/m*3\n",
"CD = 13.0446 kmol/m*3\n"
]
}
],
"prompt_number": 220
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Example 14.15, Page 517"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"import math\n",
"# Variables\n",
"T = 1200. \t\t\t #temperature in K\n",
"T0 = 298.15 \t\t\t #reference temperature in K\n",
"a = [41.84,45.369,82.34];\n",
"b = [20.25*10**-3,8.688*10**-3,49.75*10**-3];\n",
"c = [0,0,0];\n",
"d = [0,0,0];\n",
"e = [-4.51*10**5,-9.619*10**5,-12.87*10**5];\n",
"del_Gf = [-604.574,-394.815,-1129.515]\n",
"del_Hf = [-635.975,-393.978,-1207.683]\n",
"n = [1,1,-1]\n",
"R = 8.314\n",
"\n",
"# Calculations\n",
"del_G = (n[0]*del_Gf[0])+(n[1]*del_Gf[1])+(n[2]*del_Gf[2]);\n",
"del_H = (n[0]*del_Hf[0])+(n[1]*del_Hf[1])+(n[2]*del_Hf[2]);\n",
"del_a = (n[0]*a[0])+(n[1]*a[1])+(n[2]*a[2]);\n",
"del_b = (n[0]*b[0])+(n[1]*b[1])+(n[2]*b[2]);\n",
"del_c = (n[0]*c[0])+(n[1]*c[1])+(n[2]*c[2]);\n",
"del_d = (n[0]*d[0])+(n[1]*d[1])+(n[2]*d[2]);\n",
"del_e = (n[0]*e[0])+(n[1]*e[1])+(n[2]*e[2]);\n",
"del_H0 = ((del_H*10**3)-((del_a*T0)+((del_b/2)*T0**2)+((del_c/3)*T0**3)+((del_d/4)*T0**4)-(del_e/T0)))*10**-3;\n",
"IR = (1./(T0))*((del_H0*10**3)-(del_a*T0*math.log(T0))-((del_b/2)*T0**2)-((del_c/6)*T0**3)-((del_d/12)*T0**4)-((del_e/2)*(1./T0))-(del_G*10**3));\n",
"del_G_T = ((del_H0*10**3)-(del_a*T*math.log(T))-((del_b/2)*T**2)-((del_c/6)*T**3)-((del_d/12)*T**4)-((del_e/2)*(1./T))-(IR*T))*10**-3;\n",
"Ka = math.exp((-del_G_T*10**3)/(R*T))\n",
"y = 1;\n",
"phi = 1;\n",
"f0 = 1;\n",
"P = (Ka*f0)/(phi*y)\n",
"\n",
"# Results\n",
"print ' The decomposition pressure,P = %f bar '%(P);\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" The decomposition pressure,P = 2.384295 bar \n"
]
}
],
"prompt_number": 6
}
],
"metadata": {}
}
]
}
|