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
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
|
{
"metadata": {
"name": "",
"signature": "sha256:e354b0525ce1aff27214eb76f8a2c9be56cfff2939a8a4b8688a7fe1cea4959c"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": [
"Chapter 17 : Chemical Reactions Equilibria"
]
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 17.2 Page Number : 598"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
" \n",
"from scipy.optimize import fsolve \n",
"import math \n",
"\n",
"\n",
"# Variables\n",
"P = 1;\t\t\t#[atm] - Reactor pressure\n",
"T = 749;\t\t\t#[K] - Reactor temperature\n",
"K = 74;\t\t\t# Equlibrium constant\n",
"\n",
"\t\t\t# SO2 + (1/2)*O2 - SO3\n",
"\n",
"# Calculations and Results\n",
"Kp = P**(1);\n",
"Ky = K/Kp;\n",
"\n",
"\t\t\t#(1)\n",
"\t\t\t# Initial number of moles of the components are\n",
"n_SO2_1_in = 12;\n",
"n_O2_1_in = 9;\n",
"n_SO3_1_in = 0;\n",
"\n",
"\t\t\t# Let the reaction coordinate at equilibrium for the reaction be X\n",
"\t\t\t# At equilibrium, the moles of the components be\n",
"\t\t\t# n_SO2_1_eq = 12 - X\n",
"\t\t\t# n_O2_1_eq = 9 - 0.5*X\n",
"\t\t\t# n_SO3_1_eq = X\n",
"\t\t\t# Total moles = 21 - 0.5*X\n",
"\n",
"\t\t\t# The mole fractions of the components at equilibrium are\n",
"\t\t\t# y_SO3 = X/(21-0.5*X)\n",
"\t\t\t# y_SO2 = (12-X)/(21-0.5*X)\n",
"\t\t\t# y_O2 = (9-0.5*X)/(21-0.5*X)\n",
"\n",
"\t\t\t# Ky = y_SO3/(y_SO2*y_O2**(2))\n",
"\t\t\t# Ky = (X*(21-0.5*X)**(1/2))/((12-X)*(9-0.5*X)**(1/2))\n",
"def f(X): \n",
"\t return Ky-(X*(21-0.5*X)**(1./2))/((12-X)*(9-0.5*X)**(1./2))\n",
"X_1 = fsolve(f,11)\n",
"\n",
"y_SO3_1 = X_1/(21-0.5*X_1);\n",
"y_SO2_1 = (12-X_1)/(21-0.5*X_1);\n",
"y_O2_1 = (9-0.5*X_1)/(21-0.5*X_1);\n",
"\n",
"print \" 1).The moles of SO3 formed = %f mol\"%(X_1);\n",
"print \" The mole fractions at equilibrium are y_S03 = %f y_SO2 = %f and y_O2 = %f\"%(y_SO3_1,y_SO2_1,y_O2_1);\n",
"\n",
"\t\t\t#(2)\n",
"\t\t\t# Initial number of moles of the components are\n",
"n_SO2_2_in = 24;\n",
"n_O2_2_in = 18;\n",
"n_SO3_2_in = 0;\n",
"\n",
"\t\t\t# At equilibrium, the moles of the components be\n",
"\t\t\t# n_SO2_1_eq = 24 - X\n",
"\t\t\t# n_O2_1_eq = 18 - 0.5*X\n",
"\t\t\t# n_SO3_1_eq = X\n",
"\t\t\t# Total moles = 42 - 0.5*X\n",
"\n",
"\t\t\t# The mole fractions of the components at equilibrium are\n",
"\t\t\t# y_SO3 = X/(42-0.5*X)\n",
"\t\t\t# y_SO2 = (24-X)/(42-0.5*X)\n",
"\t\t\t# y_O2 = (18-0.5*X)/(42-0.5*X)\n",
"\n",
"\t\t\t# Ky = y_SO3/(y_SO2*y_O2**(2))\n",
"\t\t\t# Ky = (X*(42-0.5*X)**(1/2))/((24-X)*(18-0.5*X)**(1/2))\n",
"def f1(X): \n",
"\t return Ky-(X*(42-0.5*X)**(1./2))/((24-X)*(18-0.5*X)**(1./2))\n",
"X_2 = fsolve(f1,22)\n",
"\n",
"y_SO3_2 = X_2/(42-0.5*X_2);\n",
"y_SO2_2 = (24-X_2)/(42-0.5*X_2);\n",
"y_O2_2 = (18-0.5*X_2)/(42-0.5*X_2);\n",
"print \" 2).The moles of SO3 formed = %f mol\"%(X_2);\n",
"print \" The mole fractions at equilibrium are y_S03 = %f, y_SO2 = %f and y_O2 = %f\"%(y_SO3_2,y_SO2_2,y_O2_2);\n",
"\n",
"\t\t\t#(3)\n",
"\t\t\t# Initial number of moles of the components are\n",
"n_SO2_3_in = 12;\n",
"n_O2_3_in = 9;\n",
"n_SO3_3_in = 0;\n",
"n_N2 = 79;\n",
"\n",
"\t\t\t# At equilibrium, the moles of the components be\n",
"\t\t\t# n_SO2_1_eq = 12 - X\n",
"\t\t\t# n_O2_1_eq = 9 - 0.5*X\n",
"\t\t\t# n_SO3_1_eq = X\n",
"\t\t\t# Total moles = 100 - 0.5*X\n",
"\n",
"\t\t\t# The mole fractions of the components at equilibrium are\n",
"\t\t\t# y_SO3 = X/(100-0.5*X)\n",
"\t\t\t# y_SO2 = (12-X)/(100-0.5*X)\n",
"\t\t\t# y_O2 = (9-0.5*X)/(100-0.5*X)\n",
"\n",
"\t\t\t# Ky = y_SO3/(y_SO2*y_O2**(2))\n",
"\t\t\t# Ky = (X*(100-0.5*X)**(1/2))/((12-X)*(9-0.5*X)**(1/2))\n",
"def f2(X): \n",
"\t return Ky-(X*(100-0.5*X)**(1./2))/((12-X)*(9-0.5*X)**(1./2))\n",
"X_3 = fsolve(f2,10)\n",
"\n",
"y_SO3_3 = X_3/(100-0.5*X_3);\n",
"y_SO2_3 = (12-X_3)/(100-0.5*X_3);\n",
"y_O2_3 = (9-0.5*X_3)/(100-0.5*X_3);\n",
"\n",
"print \" 3).The moles of SO3 formed = %f mol\"%(X_3);\n",
"print \" The mole fractions at equilibrium are y_S03 = %f y_SO2 = %f and y_O2 = %f\"%(y_SO3_3,y_SO2_3,y_O2_3);\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" 1).The moles of SO3 formed = 11.655537 mol\n",
" The mole fractions at equilibrium are y_S03 = 0.768215 y_SO2 = 0.022704 and y_O2 = 0.209081\n",
" 2).The moles of SO3 formed = 23.311074 mol\n",
" The mole fractions at equilibrium are y_S03 = 0.768215, y_SO2 = 0.022704 and y_O2 = 0.209081\n",
" 3).The moles of SO3 formed = 11.202213 mol\n",
" The mole fractions at equilibrium are y_S03 = 0.118669 y_SO2 = 0.008451 and y_O2 = 0.036006\n"
]
}
],
"prompt_number": 1
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 17.3 Page Number : 599"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
" \n",
"# Variables\n",
"T = 600;\t\t\t#[K] - Reactor temperature\n",
"P = 300;\t\t\t#[atm] - Reactor pressure\n",
"K = 0.91*10**(-4);\t\t\t# Equilibrium constant\n",
"\n",
"\t\t\t# The fugacity coefficients of the components are\n",
"phi_CO = 1.0;\n",
"phi_H2 = 1.2;\n",
"phi_CH3OH = 0.47;\n",
"\n",
"\t\t\t# CO + 2*H2 - CH3OH \n",
"\n",
"\t\t\t# For gas phase reactions the smath.tan(math.radiansard state is pure ideal gas and thus fi_0 = 1 atm and thus\n",
"\t\t\t# ai_cap = fi_cap/fi_0 = yi*P*phi_i_cap/1\n",
"\t\t\t# Thus K = Ky*Kp*K_phi\n",
"# Calculations and Results \n",
"Kp = P**(1-3);\n",
"K_phi = phi_CH3OH/(phi_CO*phi_H2**(2));\n",
"Ky = K/(Kp*K_phi);\n",
"\n",
"\t\t\t# Let the reaction coordinate at equilibrium for the reaction be X\n",
"\t\t\t# At equilibrium ,the moles of the components be \n",
"\t\t\t# n_CO = 1 - X\n",
"\t\t\t# n_H2 = 3 - 2*X\n",
"\t\t\t# n_CH3OH = X\n",
"\t\t\t# Total moles = 4 - 2*X\n",
"\n",
"\t\t\t# The mole fractions of the components at equilibrium are\n",
"\t\t\t# y_CO = (1-X)/(4-2*X)\n",
"\t\t\t# y_H2 = (3-2*X)/(4-2*X)\n",
"\t\t\t# y_CH3OH = (X)/(4-2*X)\n",
"\n",
"\t\t\t# Ky = y_CH3OH/(y_CO*y_H2**(2)) = (X/(4-2*X))/(((1-X)/(4-2*X))*((3-2*X)/(4-2*X))**(2))\n",
"def f(X): \n",
"\t return Ky-(X/(4-2*X))/(((1-X)/(4-2*X))*((3-2*X)/(4-2*X))**(2))\n",
"X = fsolve(f,0.1)\n",
"\n",
"\t\t\t# Therefore at equilibrium \n",
"y_CO = (1-X)/(4-2*X);\n",
"y_H2 = (3-2*X)/(4-2*X);\n",
"y_CH3OH = (X)/(4-2*X);\n",
"\n",
"print \" The mole fractions at equilibrium are y_CO = %f y_H2 = %f and y_CH3OH = %f\"%(y_CO,y_H2,y_CH3OH);\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" The mole fractions at equilibrium are y_CO = 0.051857 y_H2 = 0.551857 and y_CH3OH = 0.396286\n"
]
}
],
"prompt_number": 2
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 17.4 Page Number : 600"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
" \n",
"# Variables\t\t\n",
"T = 600;\t\t\t#[K] - Reactor temperature\n",
"P = 4;\t\t\t#[atm] - Reactor pressure\n",
"K = 1.175;\t\t\t# Equilibrium constant\n",
"\n",
"\t\t\t# (1/2)*N2 + (3/2)*H_2 - NH3\n",
"\n",
"\t\t\t# Initial number of moles of the components are\n",
"n_N2 = 1;\n",
"n_H2 = 3;\n",
"n_HN3 = 0;\n",
"\n",
"# Calculations and Results\n",
"\t\t\t# Let the reaction coordinate at equilibrium for the reaction be X.\n",
"\t\t\t# At equilibrium ,the moles of the components be \n",
"\t\t\t# n_N2 = 1 - 0.5*X\n",
"\t\t\t# n_H2 = 3 - 1.5*X\n",
"\t\t\t# n_NH3 = X\n",
"\t\t\t# Total moles = 4 - X\n",
"\n",
"\t\t\t# We have, K = Ky*Kp\n",
"Kp = P**(1-2);\t\t\t#[atm**(-1)]\n",
"Ky = K/(Kp);\n",
"\n",
"\t\t\t# Ky = y_NH3/(y_N2**(1/2)*y_H2**(3/2)) = (X/(4-X))/(((1-0.5*X)/(4-X))**(1/2)*((3-1.5*X)/(4-X))**(3/2))\n",
"\t\t\t# Solving the above equation we get\n",
"def f(X): \n",
"\t return Ky - (X/(4-X))/(((1-0.5*X)/(4-X))**(1./2)*((3-1.5*X)/(4-X))**(3./2))\n",
"X = fsolve(f,0.1)\n",
"\n",
"y_NH3 = X/(4-X);\t\t\t# Mole fraction of NH3 at equilibrium\n",
"\n",
"print \" The value of Kp = %f and Ky = %f \"%(Kp,Ky);\n",
"print \" The mole fractions of NH3 at equilibrium is %f\"%(y_NH3);\n",
"\n",
"\t\t\t# If reaction carried out at constant temperature and volume\n",
"\n",
"\t\t\t# We know that for ideal gas, P*V = n*R*T and thus P is directly proportional to n at constant V and T.\n",
"\t\t\t# Let P = k*n\n",
"\t\t\t# Initially P = 4 atm and n = 4 moles, thus K = 1 and we get p = n, where P is in atm. \n",
"\t\t\t# Thus at equilibrium P = 4 - X\n",
"\n",
"\t\t\t# Ky = K/Kp = 1.175*P = 1.175*(4 - X)\n",
"\t\t\t# (X/(4-X))/(((1-0.5*X)/(4-X))**(1/2)*((3-1.5*X)/(4-X))**(3/2)) = 1.175*(4 - X)\n",
"\t\t\t# Solving the above equation we get\n",
"def f1(X): \n",
"\t return (X/(4-X))/(((1-0.5*X)/(4-X))**(1./2)*((3-1.5*X)/(4-X))**(3./2))-1.175*(4-X)\n",
"X_prime = fsolve(f1,1)\n",
"\n",
"\t\t\t# Therefore at equilibrium \n",
"P_prime = 4 - X_prime;\n",
"y_NH3_prime = X_prime/(4-X_prime);\n",
"\n",
"print \" If reaction is carried out at constant temperature and volumethen\"\n",
"print \" The equilibrium pressure is %f atm\"%(P_prime);\n",
"print \" The equilibrium mole fractions of NH3 in the reactor is %f\"%(y_NH3_prime);\n",
"\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" The value of Kp = 0.250000 and Ky = 4.700000 \n",
" The mole fractions of NH3 at equilibrium is 0.454388\n",
" If reaction is carried out at constant temperature and volumethen"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"\n",
" The equilibrium pressure is 2.863057 atm\n",
" The equilibrium mole fractions of NH3 in the reactor is 0.397108\n"
]
}
],
"prompt_number": 3
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 17.5 Page Number : 601"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
" \n",
"# Variables\n",
"T = 400;\t\t\t#[K] - Reactor temperature\n",
"P = 1;\t\t\t#[atm] - Reactor pressure\n",
"K = 1.52;\t\t\t# Equilibrium constant\n",
"y_H2 = 0.4;\t\t\t# Equilibrium mole fraction of hydrogen\n",
"\n",
"# Calculations\n",
"\t\t\t# CO(g) + 2*H_2(g) - CH3OH(g)\n",
"\n",
"\t\t\t# K = y_CH3OH/(y_CO*y_H2**(2)*P**(2))\n",
"\t\t\t# Let total number of moles at equilibrium be 1\n",
"\t\t\t# y_CH3OH = 0.6 - y_CO;\n",
"\t\t\t# (0.6 - y_CO)/y_CO = K*P**(2)*y_H2**(2)\n",
"\n",
"y_CO = 0.6/(1 + K*P**(2)*y_H2**(2));\n",
"y_CH3OH = 0.6 - y_CO;\n",
"\n",
"\n",
"# Results\n",
"print \" The mole fractions are y_CO = %f and y_CH3OH = %f \"%(y_CO,y_CH3OH);"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" The mole fractions are y_CO = 0.482625 and y_CH3OH = 0.117375 \n"
]
}
],
"prompt_number": 4
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 17.6 Page Number : 602"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
" \n",
"\n",
"# Variables\n",
"T = 749.;\t\t\t#[K] - Reactor temperature\n",
"P = 1.;\t\t\t#[atm] - Reactor pressure\n",
"K = 74.;\n",
"\n",
"# Calculations and Results\n",
"Kp = P**(-1./2);\t\t\t#[atm**(-1/2)]\n",
"Ky = K/Kp;\n",
"\n",
"\t\t\t# SO2 + (1/2)*O2 - SO3\n",
"\n",
"\t\t\t# Initial number of moles of the components are\n",
"n_SO2_1_in = 10;\n",
"n_O2_1_in = 8;\n",
"n_SO3_1_in = 0;\n",
"\n",
"\t\t\t# Let the reaction coordinate at equilibrium for the reaction be X\n",
"\t\t\t# At equilibrium, the moles of the components be\n",
"\t\t\t# n_SO2_1_eq = 10 - X\n",
"\t\t\t# n_O2_1_eq = 8 - 0.5*X\n",
"\t\t\t# SO3_1_eq = X\n",
"\t\t\t# Total moles = 18 - 0.5*X\n",
"\n",
"\t\t\t# The mole fractions of the components at equilibrium are\n",
"\t\t\t# y_SO3 = X/(18-0.5*X)\n",
"\t\t\t# y_SO2 = (10-X)/(18-0.5*X)\n",
"\t\t\t# y_O2 = (8-0.5*X)/(18-0.5*X)\n",
"\n",
"\t\t\t# Ky = y_SO3/(y_SO2*y_O2**(2))\n",
"\t\t\t# Ky = (X*(18-0.5*X)**(1/2))/((10-X)*(8-0.5*X)**(1/2))\n",
"def f(X): \n",
"\t return Ky-(X*(18-0.5*X)**(1./2))/((10-X)*(8-0.5*X)**(1./2))\n",
"X_1 = fsolve(f,11)\n",
"\n",
"n_SO3 = X_1;\n",
"n_SO2 = 10 - X_1;\n",
"n_O2 = 8 - 0.5*X_1;\n",
"\n",
"print \" 1).The moles of the components at equilibrium are n_SO3 = %f mol n_SO2 = %f mol and n_O2 = %f mol\"%(n_SO3,n_SO2,n_O2);\n",
"\n",
"\t\t\t# Now for the reaction\n",
"\t\t\t# 2*SO2 + O2 - 2*SO3\n",
"\n",
"\t\t\t# The equilibrium constant for this reaction is KP**(2)\n",
"Ky_prime = Ky**(2);\n",
"\n",
"\t\t\t# At equilibrium, the moles of the components be\n",
"\t\t\t# n_SO2_1_eq = 10 - 2*X\n",
"\t\t\t# n_O2_1_eq = 8 - X\n",
"\t\t\t# SO3_1_eq = 2*X\n",
"\t\t\t# Total moles = 18 - X\n",
"\n",
"\t\t\t# The mole fractions of the components at equilibrium are\n",
"\t\t\t# y_SO3 = 2*X/(18-X)\n",
"\t\t\t# y_SO2 = (10-2*X)/(18-X)\n",
"\t\t\t# y_O2 = (8- X)/(18-X)\n",
"\n",
"\t\t\t# Ky_prime = y_SO3**(2)/(y_SO2**(2)*y_O2)\n",
"\t\t\t# Ky_prime = ((2*X)**(2)*(18-X))/((10-2*X)**(2)*(8-X))\n",
"def f1(X): \n",
"\t return Ky_prime-((2*X)**(2)*(18-X))/(((10-2*X)**(2))*(8-X))\n",
"X_2 = fsolve(f1,6)\n",
"\n",
"n_SO3_prime = 2*X_2;\n",
"n_SO2_prime = 10 - 2*X_2;\n",
"n_O2_prime = 8 - X_2;\n",
"\n",
"print \" 2).The moles of the components at equilibrium are n_SO3 = %f mol n_SO2 = %f mol and n_O2 = %f mol\"%(n_SO3_prime,n_SO2_prime,n_O2_prime);\n",
"print \" Thus the number of moles remains the same irrespective of the stoichoimetry of the reaction\"\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" 1).The moles of the components at equilibrium are n_SO3 = 9.730824 mol n_SO2 = 0.269176 mol and n_O2 = 3.134588 mol\n",
" 2).The moles of the components at equilibrium are n_SO3 = 9.730824 mol n_SO2 = 0.269176 mol and n_O2 = 3.134588 mol\n",
" Thus the number of moles remains the same irrespective of the stoichoimetry of the reaction\n"
]
}
],
"prompt_number": 5
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 17.7 Page Number : 603"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
" \n",
"\n",
"# Variables\n",
"T = 500;\t\t\t#[K]\n",
"\t\t\t# For the reaction, 0.5*A2 + 0.5*B2 - AB\n",
"delta_G = -4200;\t\t\t#[J/mol]\n",
"R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
"\n",
"\t\t\t#(1)\n",
"\t\t\t# A2 + B2 - 2*AB\n",
"\n",
"# Calculations and Results\n",
"\t\t\t# We know delta_G_rkn_0 = -R*T*math.log(K) \n",
"delta_G_1 = 2*delta_G;\n",
"K_1 = math.exp(-delta_G_1/(R*T));\t\t\t# Equilibrium constant at 500 K for the above reaction\n",
"\t\t\t# As can be seen the reaction is not affected by pressure and therefore K = Ky as Kp = 1 \n",
"Ky = K_1;\n",
"\n",
"\t\t\t# Initial number of moles of the components are\n",
"n_A2_1_in = 0.5;\n",
"n_B2_1_in = 0.5;\n",
"n_AB_1_in = 0;\n",
"\n",
"\t\t\t# Let the reaction coordinate at equilibrium for the reaction be X\n",
"\t\t\t# At equilibrium, the moles of the components be\n",
"\t\t\t# n_A2_1_eq = 0.5 - X\n",
"\t\t\t# n_B2_1_eq = 0.5- X\n",
"\t\t\t# n_AB_1_eq = 2*X\n",
"\t\t\t# Total moles = 1\n",
"\n",
"\t\t\t# Ky = (2*X)**(2)/(0.5-X)**(2)\n",
"def f(X): \n",
"\t return Ky-(2*X)**(2)/(0.5-X)**(2)\n",
"X_1 = fsolve(f,0.2)\n",
"\n",
"\t\t\t# The mole fractions of the components at equilibrium are\n",
"y_A2_1 = 0.5 - X_1;\n",
"y_B2_1 = 0.5- X_1;\n",
"y_AB_1 = 2*X_1;\n",
"\n",
"print \" 1).The mole fractions at equilibrium are y_A2 = %f y_B2 = %f and y_AB = %f\"%(y_A2_1,y_B2_1,y_AB_1);\n",
"\n",
"\t\t\t#(2)\n",
"\t\t\t# 0.5*A2 + 0.5*B2 - AB\n",
"\n",
"\t\t\t# We know delta_G_rkn_0 = -R*T*math.log(K) \n",
"delta_G_2 = delta_G;\n",
"K_2 = math.exp(-delta_G_2/(R*T));\t\t\t# Equilibrium constant at 500 K for the above reaction\n",
"\n",
"\t\t\t# As can be seen the reaction is not affected by pressure and therefore K = Ky as Kp = 1 \n",
"Ky_2 = K_2;\n",
"\n",
"\t\t\t# Initial number of moles of the components are\n",
"n_A2_2_in = 0.5;\n",
"n_B2_2_in = 0.5;\n",
"n_AB_2_in = 0;\n",
"\n",
"\t\t\t# Let the reaction coordinate at equilibrium for the reaction be X\n",
"\t\t\t# At equilibrium, the moles of the components be\n",
"\t\t\t# n_A2_2_eq = 0.5 - 0.5*X\n",
"\t\t\t# n_B2_2_eq = 0.5- 0.5*X\n",
"\t\t\t# n_AB_2_eq = X\n",
"\t\t\t# Total moles = 1\n",
"\n",
"\t\t\t# Ky = y_AB/(y_A2**(1/2)*y_B2**(1/2))\n",
"\t\t\t# Ky = X/(0.5 - 0.5*X)\n",
"X_2 = 0.5*Ky_2/(1+0.5*Ky_2);\n",
"\n",
"\t\t\t# The mole fractions of the components at equilibrium are\n",
"y_A2_2 = 0.5 - 0.5*X_2;\n",
"y_B2_2 = 0.5- 0.5*X_2;\n",
"y_AB_2 = X_2;\n",
"\n",
"print \" 2).The mole fractions at equilibrium are y_A2 = %f y_B2 = %f and y_AB = %f\"%(y_A2_2,y_B2_2,y_AB_2);\n",
"\n",
"\t\t\t#(3)\n",
"\t\t\t# 2*AB - A2 + B2\n",
"\n",
"K_3 = 1/K_1;\t\t\t# Equilibrium constant at 500 K for the above reaction\n",
"\t\t\t# As can be seen the reaction is not affected by pressure and therefore K = Ky as Kp = 1 \n",
"Ky_3 = K_3;\n",
"\n",
"\t\t\t# Initial number of moles of the components are\n",
"n_AB_3_in = 1;\n",
"n_A2_3_in = 0;\n",
"n_B2_3_in = 0;\n",
"\n",
"\t\t\t# Let the reaction coordinate at equilibrium for the reaction be X\n",
"\t\t\t# At equilibrium, the moles of the components be\n",
"\t\t\t# n_AB_3_eq = 1 - X\n",
"\t\t\t# n_A2_3_eq = X/2\n",
"\t\t\t# n_B2_3_eq = X/2\n",
"\t\t\t# Total moles = 1\n",
"\n",
"\t\t\t# Ky = (X/2)**(2)/(1-X)**(2)\n",
"def f1(X): \n",
"\t return Ky_3-(X/2)**(2)/(1-X)**(2)\n",
"X_3 = fsolve(f1,0.4)\n",
"\n",
"\t\t\t# The mole fractions of the components at equilibrium are\n",
"y_A2_3 = X_3/2;\n",
"y_B2_3 = X_3/2;\n",
"y_AB_3 = 1-X_3;\n",
"\n",
"print \" 3).The mole fractions at equilibrium are y_A2 = %f y_B2 = %f and y_AB = %f\"%(y_A2_3,y_B2_3,y_AB_3);"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" 1).The mole fractions at equilibrium are y_A2 = 0.210680 y_B2 = 0.210680 and y_AB = 0.578641\n",
" 2).The mole fractions at equilibrium are y_A2 = 0.210680 y_B2 = 0.210680 and y_AB = 0.578641\n",
" 3).The mole fractions at equilibrium are y_A2 = 0.210680 y_B2 = 0.210680 and y_AB = 0.578641\n"
]
}
],
"prompt_number": 7
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 17.9 Page Number : 606"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
" \n",
"\n",
"from scipy.optimize import fsolve \n",
"import math \n",
"from scipy.integrate import quad \n",
"\t\t\n",
"\n",
"# Variables\n",
"R = 1.987;\t\t\t#[cal/mol-K]\n",
"\n",
"delta_H_SO2_298 = -70.96;\t\t\t#[kcal/mol] - Enthalpy of formation of S02 at 298.15 K\n",
"delta_H_SO3_298 = -94.45;\t\t\t#[kcal/mol] - Enthalpy of formation of S03 at 298.15 K\n",
"delta_G_SO2_298 = -71.79;\t\t\t#[kcal/mol] - Gibbs free energy change for formation of SO2 at 298.15 K\n",
"delta_G_SO3_298 = -88.52;\t\t\t#[kcal/mol] - Gibbs free energy change for formation of SO3 at 298.15 K\n",
"\n",
"\t\t\t# Cp_0 = a + b*T + c*T**(2) + d*T**(3)\n",
"\n",
"a_SO2 = 6.157;\n",
"a_SO3 = 3.918;\n",
"a_O2 = 6.085;\n",
"b_SO2 = 1.384*10**(-2);\n",
"b_SO3 = 3.483*10**(-2);\n",
"b_O2 = 0.3631*10**(-2);\n",
"c_SO2 = -0.9103*10**(-5);\n",
"c_SO3 = -2.675*10**(-5);\n",
"c_O2 = -0.1709*10**(-5);\n",
"d_SO2 = 2.057*10**(-9);\n",
"d_SO3 = 7.744*10**(-9);\n",
"d_O2 = 0.3133*10**(-9);\n",
"\n",
"\t\t\t#(1)\n",
"T_1 = 298.15;\t\t\t#[K]\n",
"\n",
"# Calculations and Results\n",
"delta_H_rkn_298 = delta_H_SO3_298 - delta_H_SO2_298;\t\t\t#[kcal]\n",
"delta_H_rkn_298 = delta_H_rkn_298*10**(3);\t\t\t#[cal]\n",
"delta_G_rkn_298 = delta_G_SO3_298 - delta_G_SO2_298;\t\t\t#[kcal]\n",
"delta_G_rkn_298 = delta_G_rkn_298*10**(3);\t\t\t#[cal]\n",
"\n",
"delta_a = a_SO3 - a_SO2 - (a_O2/2);\n",
"delta_b = b_SO3 - b_SO2 - (b_O2/2);\n",
"delta_c = c_SO3 - c_SO2 - (c_O2/2);\n",
"delta_d = d_SO3 - d_SO2 - (d_O2/2);\n",
"\n",
"\n",
"def f60(T): \n",
"\t return delta_a+(delta_b*T)+(delta_c*T**(2))+(delta_d*T**(3))\n",
"\n",
"\t\t\t# delta_H_rkn_T = delta_H_rkn_298 + quad(f60,T_1,T)[0]\n",
"\n",
"\t\t\t# On simplification we get\n",
"\t\t\t# delta_H_rkn_T = -22630.14 - 5.2815*T + 0.9587*10**(-2)*T**(2) - 0.5598*10**(-5)*T**(3) + 1.3826*10**(-9)*T**(4)\n",
"\n",
"print \" 1.The math.expression for delta_H_rkn_T as a function of T is given by\";\n",
"print \" delta_H_rkn_T = -22630.14 - 5.2815*T + 0.9587*10**-2*T**2 - 0.5598*10**-5*T**3 + 1.3826*10**-9*T**4\";\n",
"\n",
"\t\t\t#(2)\n",
"\n",
"\n",
"\t\t\t#def f61(T): \n",
"\t\t\t#\t return K_T/K_298) = integrate(delta_H_rkn_T/T**(2)\n",
"\n",
"\t\t\t# R*math.log(K_T/K_298) = quad(f61,T_1,T)[0]\n",
"\n",
"\t\t\t# First let us calculate K_298.\n",
"\t\t\t# delta_G_rkn_T = - R*T*math.log(K)\n",
"K_298 = math.exp(-delta_G_rkn_298/(R*T_1));\n",
"\n",
"\t\t\t# On substituting the values and simplifying we get the math.expression\n",
"\t\t\t# math.log(K) = 3.87 + 11380.10/T - 2.6580*math.log(T) + 0.4825*10**(-2)*T - 0.1409*10**(-5)*T**(2) + 0.2320*10**(-9)*T**(3)\n",
"\n",
"print \" 2.The math.expression for math.logK as a function of T is given by\";\n",
"print \" math.logK = 3.87 + 11380.10/T - 2.6580*math.logT + 0.4825*10**-2*T - 0.1409*10**-5*T**2 + 0.2320*10**-9*T**3\";\n",
"\n",
"\t\t\t#(3)\n",
"P = 1;\t\t\t#[atm]\n",
"T = 880;\t\t\t#[K]\n",
"K = math.exp(3.87 + 11380.10/T - 2.6580*math.log(T) + 0.4825*10**(-2)*T - 0.1409*10**(-5)*T**(2) + 0.2320*10**(-9)*T**(3));\n",
"Kp = P**(-1./2);\t\t\t#[atm**(-1/2)]\n",
"Ky = K/Kp;\n",
"\n",
"\t\t\t# Let the reaction coordinate at equilibrium for the reaction be X\n",
"\t\t\t# At equilibrium, the moles of the components be\n",
"\t\t\t# n_SO2_eq = 1 - X\n",
"\t\t\t# n_O2_eq = 0.5- 0.5*X\n",
"\t\t\t# n_SO3_1_eq = X\n",
"\t\t\t# Total moles = 1.5-0.5*X\n",
"\n",
"\t\t\t# Ky = (X*(1.5-0.5*X)**(1/2))/((1-X)*(0.5-0.5*X)**(1/2))\n",
"def f(X): \n",
"\t return Ky - (X*(1.5-0.5*X)**(1./2))/((1-X)*(0.5-0.5*X)**(1./2))\n",
"X = fsolve(f,0.8)\n",
"\n",
"\t\t\t# The mole fraction of SO3 at equilibrium is given by\n",
"y_SO3 = X/(1.5-0.5*X);\n",
"\n",
"print \" 3).The mole fraction of SO3 at equilibrium is given by y_SO3 = %f\"%(y_SO3);\n",
"\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" 1.The math.expression for delta_H_rkn_T as a function of T is given by\n",
" delta_H_rkn_T = -22630.14 - 5.2815*T + 0.9587*10**-2*T**2 - 0.5598*10**-5*T**3 + 1.3826*10**-9*T**4\n",
" 2.The math.expression for math.logK as a function of T is given by\n",
" math.logK = 3.87 + 11380.10/T - 2.6580*math.logT + 0.4825*10**-2*T - 0.1409*10**-5*T**2 + 0.2320*10**-9*T**3\n",
" 3).The mole fraction of SO3 at equilibrium is given by y_SO3 = 0.649167\n"
]
}
],
"prompt_number": 8
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 17.10 Page Number : 609"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
" \n",
"\n",
"from numpy import *\n",
"\n",
"# Variables\n",
"\t\t\t# (1/2)*N2 + (1/2)*O2 - NO\n",
"\n",
"R = 1.987;\t\t\t#[cal/mol-K]\n",
"\n",
"delta_H_NO_298 = 21.600;\t\t\t#[kcal/mol] - Enthalpy of formation of S02 at 298.15 K\n",
"delta_G_NO_298 = 20.719;\t\t\t#[kcal/mol] - Gibbs free energy change for formation of SO2 at 298.15 K\n",
"\n",
"\t\t\t# Cp_0 = a + b*T + c*T**(2) + d*T**(3)\n",
"\n",
"a_N2 = 6.157;\n",
"a_O2 = 6.085;\n",
"a_NO = 6.461;\n",
"b_N2 = -0.03753*10**(-2);\n",
"b_O2 = 0.3631*10**(-2);\n",
"b_NO = 0.2358*10**(-2);\n",
"c_N2 = 0.1930*10**(-5);\n",
"c_O2 = -0.1709*10**(-5);\n",
"c_NO = -0.07705*10**(-5);\n",
"d_N2 = -0.6861*10**(-9);\n",
"d_O2 = 0.3133*10**(-9);\n",
"d_NO = 0.08729*10**(-9);\n",
"\n",
"\t\t\t#(1)\n",
"T_1 = 298.15;\t\t\t#[K]\n",
"\n",
"# Calculations and Results\n",
"delta_H_rkn_298 = delta_H_NO_298;\t\t\t#[kcal]\n",
"delta_H_rkn_298 = delta_H_rkn_298*10**(3);\t\t\t#[cal]\n",
"delta_G_rkn_298 = delta_G_NO_298;\t\t\t#[kcal]\n",
"delta_G_rkn_298 = delta_G_rkn_298*10**(3);\t\t\t#[cal]\n",
"\n",
"delta_a = a_NO - (a_N2/2) - (a_O2/2);\n",
"delta_b = b_NO - (b_N2/2) - (b_O2/2);\n",
"delta_c = c_NO - (c_N2/2) - (c_O2/2);\n",
"delta_d = d_NO - (d_N2/2) - (d_O2/2);\n",
"\n",
"\n",
"def f49(T): \n",
"\t return delta_a+(delta_b*T)+(delta_c*T**(2))+(delta_d*T**(3))\n",
"\n",
"\t\t\t# delta_H_rkn_T = delta_H_rkn_298 + quad(f49,T_1,T)[0]\n",
"\n",
"\t\t\t# On simplification we get\n",
"\t\t\t# delta_H_rkn_T = 21584.63 - 0.033*T + 0.0365*10**(-2)*T**(2) - 0.0293*10**(-5)*T**(3) + 0.0685*10**(-9)*T**(4)\n",
"\n",
"print \" The math.expression for delta_H_rkn_T as a function of T is given by\";\n",
"print \" delta_H_rkn_T = 21584.63 - 0.033*T + 0.0365*10**-2*T**2 - 0.0293*10**-5*T**3 + 0.0685*10**-9*T**4\";\n",
"\n",
"\t\t\t# Now let us calculate K_298 (at 298 K)\n",
"\t\t\t# We know delta_G_rkn_298 = -R*T*math.log(K_298) \n",
"K_298 = math.exp(-delta_G_rkn_298/(R*T_1));\t\t\t# Equilibrium constant at 298.15 K\n",
"\n",
"\n",
"\t\t\t#def f50(T): \n",
"\t\t\t#\t return K_2/K_1) = integrate(delta_H_rkn_298/(R*T**(2))\n",
"\n",
"\t\t\t# math.log(K_2/K_1) = quad(f50,T_1,T)[0]\n",
"\n",
"\t\t\t# On substituting the values and simplifying we get the math.expression\n",
"\t\t\t# math.log(K) = 1.5103 - 10862.92/T - 0.0166*math.log(T) + 1.84*10**(-4)*T - 7.35*10**(-8)*T**(2) + 1.15*10**(-11)*T**(3)\n",
"\n",
"print \" The math.expression for math.logK as a function of T is given by\";\n",
"print \" math.logK = 1.5103 - 10862.92/T - 0.0166*math.logT + 1.84*10**-4*T - 7.35*10**-8*T**2 + 1.15*10**-11*T**3\"\n",
"\n",
"T = [500,1000,1500,2000,2500];\n",
"K = zeros(5);\n",
"\n",
"print \" T K \\t\\t\\t K \";\n",
"\n",
"for i in range(5):\n",
" K[i] = math.exp(1.5103-10862.92/T[i] - 0.0166*math.log(T[i]) + 1.84*10**(-4)*T[i] - 7.35*10**(-8)*T[i]**(2) + 1.15*10**(-11)*T[i]**(3));\n",
" \n",
" print \" %f \\t\\t %e \"%(T[i],K[i]);\n",
"\n",
"\n",
"\t\t\t# It can be seen that for endothermic reactions equilibrium constant increases with temperature.\n",
"print \" It can be seen that for endothermic reactions equilibrium constant increases with temperature\";\n",
"\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" The math.expression for delta_H_rkn_T as a function of T is given by\n",
" delta_H_rkn_T = 21584.63 - 0.033*T + 0.0365*10**-2*T**2 - 0.0293*10**-5*T**3 + 0.0685*10**-9*T**4\n",
" The math.expression for math.logK as a function of T is given by\n",
" math.logK = 1.5103 - 10862.92/T - 0.0166*math.logT + 1.84*10**-4*T - 7.35*10**-8*T**2 + 1.15*10**-11*T**3\n",
" T K \t\t\t K \n",
" 500.000000 \t\t 1.615470e-09 \n",
" 1000.000000 \t\t 8.737610e-05 \n",
" 1500.000000 \t\t 3.333913e-03 \n",
" 2000.000000 \t\t 2.062328e-02 \n",
" 2500.000000 \t\t 6.176400e-02 \n",
" It can be seen that for endothermic reactions equilibrium constant increases with temperature\n"
]
}
],
"prompt_number": 9
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 17.11 Page Number : 611"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
" \n",
"\n",
"# Variables\n",
"\t\t\t# SO2 + (1/2)*O2 - SO3\n",
"R = 8.314;\t\t\t#[J/mol-K]\n",
"\n",
"K_800 = 0.0319;\t\t\t# Equilibrium constant at 800 K\n",
"K_900 = 0.153;\t\t\t# Equilibrium constant at 900 K\n",
"T_1 = 800.;\t\t\t#[K]\n",
"T_2 = 900.;\t\t\t#[K]\n",
"\n",
"# Calculations\n",
"\t\t\t# We have the relation \n",
"\t\t\t# math.log(K_2/K_1) = -(delta_H_rkn/R)*(1/T_2 - 1/T_1)\n",
"\t\t\t# math.log(K_900/K_800) = -(delta_H_rkn_850/R)*(1/T_2 - 1/T_1)\n",
"delta_H_rkn_850 = -R*math.log(K_900/K_800)/(1/T_2 - 1/T_1);\t\t\t#[J]\n",
"delta_H_rkn_850 = delta_H_rkn_850*10**(-3);\t\t\t#[kJ]\n",
"\n",
"# Results\n",
"print \" The mean standard enthalpy change of reaction in the region 800 t0 900 is given by delta_H_rkn_850 = %f KJ\"%(delta_H_rkn_850);\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" The mean standard enthalpy change of reaction in the region 800 t0 900 is given by delta_H_rkn_850 = 93.851672 KJ\n"
]
}
],
"prompt_number": 2
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 17.13 Page Number : 611"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
" \n",
"\n",
"# Variables\n",
"T_1 = 298.15;\t\t\t#[K]\n",
"T = 2600;\t\t\t#[K]\n",
"R = 1.987;\t\t\t#[cal/mol-K] - Universal gas constant\n",
"\n",
"\t\t\t# Cp_0 = a + b*T + c*T**(2) + d*T**(3)\n",
"delta_H_CO_298 = -26.416;\t\t\t#[kcal/mol] - Enthalpy of formation of CO at 298.15 K\n",
"delta_G_CO_298 = -32.808;\t\t\t#[kcal/mol] - Gibbs free energy change for formation of CO at 298.15 K\n",
"delta_H_CO2_298 = -94.052;\t\t\t#[kcal/mol] - Enthalpy of formation of C02 at 298.15 K\n",
"delta_G_CO2_298 = -94.260;\t\t\t#[kcal/mol] - Gibbs free energy change for formation of CO2 at 298.15 K\n",
"\n",
"\t\t\t# CO + (1/2)*O2 - CO2\n",
"\n",
"a_CO = 6.726;\n",
"a_O2 = 6.0685;\n",
"a_CO2 = 5.316;\n",
"b_CO = 0.04001*10**(-2);\n",
"b_O2 = 0.3631*10**(-2);\n",
"b_CO2 = 1.4285*10**(-2);\n",
"c_CO = 0.1283*10**(-5);\n",
"c_O2 = -0.1709*10**(-5);\n",
"c_CO2 = -0.8362*10**(-5);\n",
"d_CO = -0.5307*10**(-9);\n",
"d_O2 = 0.3133*10**(-9);\n",
"d_CO2 = 1.784*10**(-9);\n",
"\n",
"# Calculations and Results\n",
"delta_H_rkn_298 = delta_H_CO2_298 - delta_H_CO_298;\t\t\t#[kcal]\n",
"delta_H_rkn_298 = delta_H_rkn_298*10**(3);\t\t\t#[cal]\n",
"delta_G_rkn_298 = delta_G_CO2_298 - delta_G_CO_298;\t\t\t#[kcal]\n",
"delta_G_rkn_298 = delta_G_rkn_298*10**(3);\t\t\t#[cal]\n",
"\n",
"delta_a = a_CO2 - (a_CO) - (a_O2/2);\n",
"delta_b = b_CO2 - (b_CO) - (b_O2/2);\n",
"delta_c = c_CO2 - (c_CO) - (c_O2/2);\n",
"delta_d = d_CO2 - (d_CO) - (d_O2/2);\n",
"\n",
"\n",
"def f47(T): \n",
"\t return delta_a+(delta_b*T)+(delta_c*T**(2))+(delta_d*T**(3))\n",
"\n",
"\t\t\t# delta_H_rkn_T = delta_H_rkn_298 + quad(f47,T_1,T)[0]\n",
"\n",
"\t\t\t# On simplification we get\n",
"delta_H_rkn_T = -66773.56 - 4.45*T + 0.605*10**(-2)*T**(2) - 0.29*10**(-5)*T**(3) + 0.54*10**(-9)*T**(4);\n",
"\n",
"\n",
"\t\t\t#def f48(T): \n",
"\t\t\t#\t return K/K_298) = integrate(delta_H_rkn_T/(R*T**(2))\n",
"\n",
"\t\t\t# math.log(K/K_298) = quad(f48,T_1,T)[0]\n",
"\n",
"\n",
"\t\t\t# We know that delta_G_rkn_T = -R*T*math.log(K)\n",
"\t\t\t# At 298.15 K\n",
"K_298 = math.exp(-delta_G_rkn_298/(R*T_1) );\n",
"\n",
"\t\t\t# Therfore on simplification we get\n",
"\t\t\t#math.log(K) = 2.94 + 33605.2/T - 2.24*math.log(T) + 0.304*10(-2)*T - 0.073*10**(-5)*T**(2) + 0.09*10**(-9)*T**(3)\n",
"K = math.exp(2.94 + 33605.2/T - 2.24*math.log(T) + 0.304*10**(-2)*T - 0.073*10**(-5)*T**(2) + 0.09*10**(-9)*T**(3));\n",
"\n",
"print \" The value of equilibrium constant at 2600 K is given by K_298 = %f\"%(K);\n",
"\n",
"\n",
"\t\t\t#(a)\n",
"P_1 = 1;\t\t\t#[atm]\n",
"Kp_1 = P_1**(-1./2);\n",
"Ky_1 = K/Kp_1;\n",
"\n",
"\t\t\t# Let the reaction coordinate at equilibrium for the reaction be X\n",
"\t\t\t# At equilibrium, the moles of the components be\n",
"\t\t\t# n_CO_1_eq = 1 - X\n",
"\t\t\t# n_02_1_eq = 0.5- 0.5X\n",
"\t\t\t# n_CO2_1_eq = X\n",
"\t\t\t# Total moles = 1.5 - 0.5*X\n",
"\n",
"\t\t\t# Ky = y_CO2/(y_CO**(1/2)*y_CO)\n",
"\t\t\t#ky = (X*(1.5-0.5*X)**(1/2))/((1-X)*(0.5-0.5*X)**(1/2))\n",
"\n",
"def f(X): \n",
"\t return Ky_1-(X*(1.5-0.5*X)**(1./2))/((1-X)*(0.5-0.5*X)**(1./2))\n",
"X_1 = fsolve(f,0.9)\n",
"\n",
"y_CO2_1 = X_1/(1.5-0.5*X_1);\n",
"y_CO_1 = (1-X_1)/(1.5-0.5*X_1);\n",
"y_O2_1 = (0.5-0.5*X_1)/(1.5-0.5*X_1);\n",
"\n",
"print \" a).The equilibrium composition at 1 atm) is given by y_CO2 = %f y_CO = %f and y_O2 = %f\"%(y_CO2_1,y_CO_1,y_O2_1);\n",
"\n",
"\t\t\t#(b)\n",
"P_2 = 10;\t\t\t#[atm]\n",
"Kp_2 = P_2**(-1./2);\n",
"Ky_2 = K/Kp_2;\n",
"\n",
"\t\t\t# Ky = y_CO2/(y_CO**(1/2)*y_CO)\n",
"\t\t\t#ky = (X*(1.5-0.5*X)**(1/2))/((1-X)*(0.5-0.5*X)**(1/2))\n",
"\n",
"def f1(X): \n",
"\t return Ky_2-(X*(1.5-0.5*X)**(1./2))/((1-X)*(0.5-0.5*X)**(1./2))\n",
"X_2 = fsolve(f1,0.9)\n",
"\n",
"y_CO2_2 = X_2/(1.5-0.5*X_2);\n",
"y_CO_2 = (1-X_2)/(1.5-0.5*X_2);\n",
"y_O2_2 = (0.5-0.5*X_2)/(1.5-0.5*X_2);\n",
"\n",
"print \" b).The equilibrium composition at 10 atm) is given by y_CO2 = %f y_CO = %f and y_O2 = %f\"%(y_CO2_2,y_CO_2,y_O2_2);\n",
"\n",
"\t\t\t#(c)\n",
"P_3 = 1;\t\t\t#[atm]\n",
"Kp_3 = P_3**(-1./2);\n",
"Ky_3 = K/Kp_3;\n",
"\n",
"\t\t\t# Ky = y_CO2/(y_CO**(1/2)*y_CO)\n",
"\t\t\t#ky = (X*(1.5-0.5*X)**(1/2))/((1-X)*(0.5-0.5*X)**(1/2))\n",
"\n",
"\t\t\t# At equilibrium, the moles of the components be\n",
"\t\t\t# n_CO_3_eq = 1 - X\n",
"\t\t\t# n_02_3_eq = 0.5- 0.5X\n",
"\t\t\t# n_CO2_3_eq = X\n",
"\t\t\t# n_N2_eq = 1;\n",
"\t\t\t# Total moles = 2.5 - 0.5*X\n",
"\n",
"def f2(X): \n",
"\t return Ky_3-(X*(2.5-0.5*X)**(1./2))/((1-X)*(0.5-0.5*X)**(1./2))\n",
"X_3 = fsolve(f2,0.9)\n",
"\n",
"y_CO2_3 = X_3/(2.5-0.5*X_3);\n",
"y_CO_3 = (1-X_3)/(2.5-0.5*X_3);\n",
"y_O2_3 = (0.5-0.5*X_3)/(2.5-0.5*X_3);\n",
"y_N2 = 1./(2.5-0.5*X_3);\n",
"\n",
"print \" c).The equilibrium composition at 1 atm and 1 mol N2) is given by y_CO2 = %f y_CO = %f y_O2 = %f and y_N2 = %f\"%(y_CO2_3,y_CO_3,y_O2_3,y_N2);\n",
"\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" The value of equilibrium constant at 2600 K is given by K_298 = 16.484152\n",
" a).The equilibrium composition at 1 atm) is given by y_CO2 = 0.757531 y_CO = 0.161646 and y_O2 = 0.080823\n",
" b).The equilibrium composition at 10 atm) is given by y_CO2 = 0.876008 y_CO = 0.082662 and y_O2 = 0.041331\n",
" c).The equilibrium composition at 1 atm and 1 mol N2) is given by y_CO2 = 0.373822 y_CO = 0.100943 y_O2 = 0.050471 and y_N2 = 0.474764\n"
]
}
],
"prompt_number": 12
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 17.14 Page Number : 614"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
" \n",
"\n",
"# Variables\n",
"T = 25 + 298.15;\t\t\t#[K] - Temperature\n",
"R = 8.314;\t\t\t#[J/mol-K]\n",
"delta_G_298 = -1000;\t\t\t#[J] - Gibbs free energy change at 298 K\n",
"\n",
"\t\t\t# G_E/(R*T) = x_1*x_2\n",
"# Calculations and Results\n",
"\t\t\t# We know that delta_G_rkn = - R*T*math.log(K), therefore\n",
"K = math.exp(-delta_G_298/(R*T));\n",
"\n",
"\t\t\t#(1)\n",
"\t\t\t# Let x_1 is the mole fraction of A and x_2 be the mole fraction of B\n",
"\t\t\t# If A and B form an ideal mixture then,\n",
"Ky = 1;\n",
"\t\t\t# and K = Kx = x_2/x_1\n",
"\t\t\t# and at equilibrium x_2/x_1 = K\n",
"\t\t\t# (1-x_1)/x_1 = K\n",
"x_1 = 1/(1+K);\n",
"\n",
"print \" 1).The equilibrium composition for ideal behaviour) is given by x_1 = %f\"%(x_1);\n",
"\n",
"\t\t\t#(2)\n",
"\t\t\t# The activity coefficients are given by\n",
"\t\t\t# math.log(Y1) = [del(n*G_E/(R*T))/del(n_1)]_T,P,n_2 = x_2**(2)\n",
"\t\t\t# similarly, math.log(Y2) = x_1**(2)\n",
"\n",
"\t\t\t# The equilibrium constant for the liquid phase reaction is given by\n",
"\t\t\t# K = Kx*Ky = (x_2*Y2)/(x_1*Y1) = (x_2*math.exp(x_1**(2)))/(x_1*math.exp(x_2**(2)))\n",
"\t\t\t# Solving the above equation we get\n",
"\n",
"def f2(x_1): \n",
"\t return K -((1-x_1)*math.exp(x_1**(2)))/(x_1*math.exp((1-x_1)**(2)))\n",
"x_1_prime = fsolve(f2,0.9)\n",
"\n",
"print \" 2).The equilibrium composition for non-ideal behaviour) is given by x_1 = %f\"%(x_1_prime);\n",
"\n",
"\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" 1).The equilibrium composition for ideal behaviour) is given by x_1 = 0.408008\n",
" 2).The equilibrium composition for non-ideal behaviour) is given by x_1 = 0.328409\n"
]
}
],
"prompt_number": 13
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 17.15 Page Number : 615"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
" \n",
"\n",
"# Variables\t\t\t\n",
"T_1 = 298.15;\t\t\t#[K] - Smath.tan(math.radiansard reaction temperature\n",
"T_2 = 373.;\t\t\t#[K] - Reaction temperature\n",
"P = 1.;\t\t\t#[atm]\n",
"R = 1.987;\t\t\t#[cal/mol-K] - Universal gas constant\n",
"\n",
"\t\t\t# CH3COOH (l) + C2H5OH (l) - CH3COOC2H5 (l) + H2O (l)\n",
"\n",
"delta_H_CH3COOH_298 = -116.2*10**(3.);\t\t\t# [cal/mol]\n",
"delta_H_C2H5OH_298 = -66.35*10**(3.);\t\t\t# [cal/mol]\n",
"delta_H_CH3COOC2H5_298 = -110.72*10**(3.);\t\t\t# [cal/mol]\n",
"delta_H_H2O_298 = -68.3174*10**(3.);\t\t\t# [cal/mol]\n",
"\n",
"delta_G_CH3COOH_298 = -93.56*10**(3.);\t\t\t# [cal/mol]\n",
"delta_G_C2H5OH_298 = -41.76*10**(3.);\t\t\t# [cal/mol]\n",
"delta_G_CH3COOC2H5_298 = -76.11*10**(3.);\t\t\t# [cal/mol]\n",
"delta_G_H2O_298 = -56.6899*10**(3.);\t\t\t# [cal/mol]\n",
"\n",
"# Calculations and Results\n",
"delta_H_rkn_298 = delta_H_CH3COOC2H5_298 + delta_H_H2O_298 - delta_H_CH3COOH_298 - delta_H_C2H5OH_298;\t\t\t#[cal/mol]\n",
"delta_G_rkn_298 = delta_G_CH3COOC2H5_298 + delta_G_H2O_298 - delta_G_CH3COOH_298 - delta_G_C2H5OH_298;\t\t\t#[cal/mol]\n",
"\n",
"\t\t\t# We know that delta_G_rkn_T = -R*T*math.log(K)\n",
"\t\t\t# At 298.15 K\n",
"K_298 = math.exp(-delta_G_rkn_298/(R*T_1) );\n",
"\n",
"\t\t\t# We know that dmath.log(K)/dT = delta_H_rkn/(R*T**(2))\n",
"\t\t\t# If delta_H_rkn is assumed constant we get\n",
"\t\t\t# math.log(K_2/K_1) = (-delta_H_rkn/R)*(1/T_2 - 1/T_1)\n",
"\t\t\t# math.log(K_373/K_298) = (-delta_H_rkn_298/R)*(1/T_2 - 1/T_1)\n",
"\n",
"K_373 = math.exp(math.log(K_298) + (-delta_H_rkn_298/R)*(1./T_2 - 1./T_1));\n",
"\t\t\t# Note that the equilibrium constant value rises becauses the reaction is endothermic\n",
"\n",
"print \" The value of equilibrium constant at 373 K is K_373 = %f\"%(K_373);\n",
"\n",
"\t\t\t# Let the reaction coordinate at equilibrium for the reaction be X\n",
"\t\t\t# At equilibrium, the moles of the components be\n",
"\t\t\t# n_CH3COOH = 1 - X\n",
"\t\t\t# n_C2H5OH = 1 - X\n",
"\t\t\t# n_CH3COOC2H5 = X\n",
"\t\t\t# n_H20 = X\n",
"\t\t\t# Total moles = 2\n",
"\n",
"\t\t\t# Kx = (x_CH3COOH*x_C2H5OH)/(x_CH3COOC2H5*x_H2O)\n",
"\t\t\t# Assuming the liquid mixture to be ideal,that is Ky = 1, therefore K_x = K\n",
"K_x = K_373;\n",
"\t\t\t# X**(2)/(1-X)**(2) = K_x\n",
"X = (K_x)**(1./2)/(1+(K_x)**(1./2));\n",
"\n",
"\t\t\t# The mole fraction of ethyl acetate is given by\n",
"x_CH3COOC2H5 = X/2;\n",
"\n",
"print \" The mole fraction of ethyl acetate in the equilibrium reaction mixture is given by x_CH3COOC2H5 = %f\"%(x_CH3COOC2H5);\n",
"\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" The value of equilibrium constant at 373 K is K_373 = 0.046697\n",
" The mole fraction of ethyl acetate in the equilibrium reaction mixture is given by x_CH3COOC2H5 = 0.088848\n"
]
}
],
"prompt_number": 14
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 17.16 Page Number : 617"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
" \n",
"\n",
"# Variables\n",
"\t\t\t# CaCO3 (s1) - CaO (s2) + CO2 (g)\n",
"T_1 = 898 + 273.15;\t\t\t#[K]\n",
"T_2 = 700 + 273.15;\t\t\t#[K]\n",
"R = 8.314;\t\t\t#[J/mol-K] - Universal gas constant\n",
"\n",
"P_CO2_T_1 = 1;\t\t\t#[atm] - Decomposition pressure of CO2 over CaCO3 at 898 C\n",
"P_CO2_T_2 = 0.0333;\t\t\t#[atm] - Decomposition pressure of CO2 over CaCO3 at 700 C\n",
"\n",
"\t\t\t# The equilibrium constant of the reaction is given by\n",
"\t\t\t# K = (a_CO2*a_CaO)/a_CaCO3\n",
"\n",
"\t\t\t# Since the pressure is small therefore carbon dioxide can be assumed to behave as ideal gas and thus\n",
"\t\t\t# a_CO2 = y_CO2*P/1 = P_CO2\n",
"\n",
"\t\t\t# The activity of CaO is (CaO is pure)\n",
"\t\t\t# a_CaO = f_CaO/f_0_CaO = exp[V_CaO*(P - P_0)/(R*T)] = 1 (since pressure is low)\n",
"\n",
"\t\t\t# The activity of CaCO3 is (CaCO3 is pure)\n",
"\t\t\t# a_CaCO3 = f_CaCO3/f_0_CaCO3 = exp[V_CaCO3*(P - P_0)/(R*T)] = 1 (since pressure is low)\n",
"\n",
"\t\t\t#Since pressures are around 1 atm,therefore Poynting factors are also near 1, and thus activity of CaO and CaCO3 is unity and equilibrium constant is given by\n",
"\t\t\t#K = P_CO2 , therefore\n",
"# Calculations \n",
"\t\t\t# At 898 C\n",
"K_T_1 = P_CO2_T_1;\n",
"delta_G_T_1 = -R*T_1*math.log(K_T_1);\n",
"\n",
"\t\t\t# At 700 C\n",
"K_T_2 = P_CO2_T_2;\n",
"delta_G_T_2 = -R*T_2*math.log(K_T_2);\n",
"\n",
"# Results\n",
"print \" The value of delta_G_rkn at 700 C is %f J\"%(delta_G_T_1);\n",
"print \" The value of delta_G_rkn at 898 C is %f J\"%(delta_G_T_2);\n",
"\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" The value of delta_G_rkn at 700 C is -0.000000 J\n",
" The value of delta_G_rkn at 898 C is 27526.397496 J\n"
]
}
],
"prompt_number": 15
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 17.17 Page Number : 618"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
" \n",
"\n",
"# Variables\n",
"T = 700 + 273.15;\t\t\t#[K]\n",
"K = 7.403;\t\t\t# Equilibrium constant for the reaction at 700 C\n",
"\n",
"\t\t\t# CH4 - C (s) + 2*H2 \n",
"\n",
"\t\t\t# The equilibrium constant of the reaction is given by\n",
"\t\t\t# K = (a_C*a_H2**(2))/a_CH4\n",
"\n",
"\t\t\t# Since carbon is pure therefore its activity is given by\n",
"\t\t\t# a_C = f/f_0 = 1 as pressure is 1 atm.\n",
"\t\t\t# Since the pressure is low,therefore the gas phase can be taken to be ideal,therefore\n",
"\t\t\t# K = (y_H2**(2)*P**(2))/(y_CH4*P) = y_H2**(2)/y_CH4 (as P = 1 atm)\n",
"Ky = K;\t\t\t# (Kp = 1 atm)\n",
"\n",
"\t\t\t# Initial moles of the species are\n",
"n_CH4 = 1;\n",
"n_H2 = 0;\n",
"n_C = 0;\n",
"\n",
"\t\t\t# Let the reaction coordinate at equilibrium for the reaction be X\n",
"\t\t\t# Moles at equilibrium be\n",
"\t\t\t# n_CH4_eq = 1 -X\n",
"\t\t\t# n_H2_eq = 2*x\n",
"\t\t\t# n_C_eq = X\n",
"\n",
"\t\t\t# Moles present in gas phase\n",
"\t\t\t# n_CH4_gas = 1 -X\n",
"\t\t\t# n_H2_gas = 2*x\n",
"\t\t\t# Total moles = 1 + X\n",
"\n",
"\t\t\t# gas phase mole fraction \n",
"\t\t\t# y_CH4_gas = (1 -X)/(1+X)\n",
"\t\t\t# y_H2_gas = 2*x/(1+X)\n",
"\n",
"# Calculations and Results\n",
"# Ky = y_H2_gas**(2)/y_CH4_gaS\n",
"X = (K/(4+K))**(1./2);\n",
"\n",
"print \" The number of moles of carbon black formed from one mole of methane is %f mol\"%(X);\n",
"\n",
"\t\t\t# Therefore mole fraction of components in the gas phase at equilibrium is \n",
"y_CH4 = (1-X)/(1+X);\n",
"y_H2 = 2*X/(1+X);\n",
"\n",
"print \" The mole fraction of components in the gas phase at equilibrium is given by y_CH4 = %f and y_H2 = %f \"%(y_CH4,y_H2);\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" The number of moles of carbon black formed from one mole of methane is 0.805739 mol\n",
" The mole fraction of components in the gas phase at equilibrium is given by y_CH4 = 0.107580 and y_H2 = 0.892420 \n"
]
}
],
"prompt_number": 3
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 17.18 Page Number : 619"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
" \n",
"# Variables \n",
"T_1 = 298.15;\t\t\t#[K] - Smath.tan(math.radiansard reaction temperature\n",
"T_2 = 1042;\t\t\t#[K] - Reaction temperature\n",
"R = 1.987;\t\t\t#[cal/mol-K] - Universal gas constant\n",
"\n",
"\t\t\t# CaCO3 (s1) - CaO (s2) + CO2 (g)\n",
"\n",
"delta_H_CaCO3_298 = -289.5;\t\t\t#[kcal/mol] - Enthalpy of formation of CaCO3 at 298.15 K\n",
"delta_H_CaO_298 = -151.7;\t\t\t#[kcal/mol] - Enthalpy of formation of CaO at 298.15 K\n",
"delta_H_CO2_298 = -94.052;\t\t\t#[kcal/mol] - Enthalpy of formation of CO2 at 298.15 K\n",
"delta_G_CaCO3_298 = -270.8;\t\t\t#[kcal/mol] - Gibbs free energy change for formation of CaCO3 at 298.15 K\n",
"delta_G_CaO_298 = -144.3;\t\t\t#[kcal/mol] - Gibbs free energy change for formation of CaO at 298.15 K\n",
"delta_G_CO2_298 = -94.260;\t\t\t#[kcal/mol] - Gibbs free energy change for formation of CO2 at 298.15 K\n",
"\n",
"\t\t\t# The smath.tan(math.radiansard heat capacity data as a function of temperature are given below\n",
"\t\t\t# Cp_CO2 = 5.316 + 1.4285*10**(2)*T - 0.8362*10**(-5)*T**(2) + 1.784*10**(-9)*T**(3)\n",
"\t\t\t# Cp_CaO = 12.129 + 0.88*10**(-3)*T - 2.08*10**(5)*T**(-2)\n",
"\t\t\t# Cp_CaCO3 = 24.98 + 5.240*10**(-3)*T - 6.199*10**(5)*T**(-2)\n",
"\t\t\t# Therefore Cp_0 is given by\n",
"\t\t\t# Cp_0 = Cp_CO2 + Cp_CaO - Cp_CaCO3\n",
"\t\t\t# Cp_0 = -7.535 + 9.925*10**(-3)*T - 0.8362*10**(-5)*T**(2) + 1.784*10**(-9)*T**(3) + 4.119*10**(5)*T**(-2)\n",
"# Calculations and Results\n",
"\t\t\t# The smath.tan(math.radiansard enthalpy change of the reaction at 298.15 K is given by\n",
"delta_H_rkn_298 = delta_H_CO2_298 + delta_H_CaO_298 - delta_H_CaCO3_298;\t\t\t#[kcal]\n",
"delta_H_rkn_298 = delta_H_rkn_298*10**(3);\t\t\t#[cal]\n",
"delta_G_rkn_298 = delta_G_CO2_298 + delta_G_CaO_298 - delta_G_CaCO3_298;\t\t\t#[kcal]\n",
"delta_G_rkn_298 = delta_G_rkn_298*10**(3);\t\t\t#[cal]\n",
"\n",
"\t\t\t# The smath.tan(math.radiansard enthalpy change of the reaction at temperature T is given by\n",
"\n",
"def f7(T): \n",
"\t return -7.535 + 9.925*10**(-3)*T - 0.8362*10**(-5)*T**(2) + 1.784*10**(-9)*T**(3) + 4.119*10**(5)*T**(-2)\n",
"\n",
"\t\t\t# delta_H_rkn_T = delta_H_rkn_298 + quad(f7,T_1,T)[0]\n",
"\n",
"\t\t\t# On simplification we get\n",
"\t\t\t# delta_H_rkn_T = 47005.3 - 7.535*T + 4.9625*10**(-3)*T**(2) - 0.2787*10**(-5)*T**(3) + 0.446*10**(-9)*T**(4) - 4.119*10**(5)*T**(-1)\n",
"\n",
"\n",
"\n",
"\t\t\t#def f8(T): \n",
"\t\t\t#\t return K_2/K_1) = integrate(delta_H_rkn_T/(R*T**(2))\n",
"\n",
"\t\t\t# math.log(K_2/K_1) = quad(f8,T_1,T)[0]\n",
"\n",
"\n",
"def f9(T): \n",
"\t return (47005.3-7.535*T+4.9625*10**(-3)*T**(2)-0.2787*10**(-5)*T**(3)+0.446*10**(-9)*T**(4) - 4.119*10**(5)*T**(-1))/T**(2)\n",
"\n",
"math.log_K2_K1 = quad(f9,T_1,T_2)[0];\t\t\t# math.log(K_2/K_1)[0]\n",
"\n",
"\n",
"\t\t\t# We know that delta_G_rkn_T = -R*T*math.log(K)\n",
"\t\t\t# At 298.15 K\n",
"K_298 = math.exp(-delta_G_rkn_298/(R*T_1) );\n",
"\n",
"\t\t\t# Putting the values in the above math.expression we get\n",
"\t\t\t# math.log(K_1042/K_298) = math.log_K2_K1/R\n",
"K_1042 = K_298*math.exp(math.log_K2_K1/R);\n",
"\n",
"print \" The value of equilibrium constant at 1042 K is K_1042 = %f\"%(K_1042);\n",
"\n",
"\t\t\t# Since for the given reaction K = P_CO2,where P is in atm, therefore,\n",
"P_CO2 = K_1042;\n",
"\t\t\t# and thus decomposition takes place till the partial pressure of CO2 reaches 0.095 atm\n",
"\t\t\t# After that the decomposition in the closed vessel stops as equilibrium is achieved.\n",
"\n",
"print \" The equilibrium pressure of CO2 is P_CO2 = %f atm \"%(P_CO2);\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" The value of equilibrium constant at 1042 K is K_1042 = 0.095017\n",
" The equilibrium pressure of CO2 is P_CO2 = 0.095017 atm \n"
]
}
],
"prompt_number": 17
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 17.19 Page Number : 620"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
" \n",
"\n",
"# Variables \n",
"T_1 = 298.15;\t\t\t#[k] - Smath.tan(math.radiansard reaction temperature\n",
"T_2 = 1200;\t\t\t#[K] - Reaction temperature\n",
"R = 1.987;\t\t\t#[cal/mol-K] - Universal gas consatnt\n",
"\n",
"\t\t\t# C (s) + CO2 (g) - 2*CO2 (g) \t\t\t# Reaction 1\n",
"\t\t\t# CO2 + H2 - CO + H2O \t\t\t# Reacction 2\n",
"\n",
"K_1 = 63;\t\t\t# Equilibrium constant for the first reaction\n",
"K_2 = 1.4;\t\t\t# Equilibrium constant for the secind reaction\n",
"\n",
"delta_G_H2O_298 = -54640;\t\t\t#[cal/mol] - Smath.tan(math.radiansard Gibbs free energy of formation of water vapour\n",
"delta_H_H2O_298 = -57800;\t\t\t#[cal/mol] - Smath.tan(math.radiansard enthalpy change of formation of water vapour\n",
"delta_G_rkn_298 = delta_G_H2O_298;\n",
"\n",
"\t\t\t# The smath.tan(math.radiansard heat capacity data of the components in cal/mol-K are given below\n",
"\t\t\t# Cp_H2 = 6.947 - 0.2*10**(-3)*T + 4.8*10**(-7)*T**(2)\n",
"\t\t\t# Cp_O2 = 6.148 + 3.1*10**(-3)*T - 9.2*10**(-7)*T**(2)\n",
"\t\t\t# Cp_H2O = 7.256 + 2.3*10**(-3)*T + 2.8*10**(-7)*T**(2)\n",
"\n",
"\t\t\t# Let us consider two more reactions\n",
"\t\t\t# C (s) + (1/2)*O2 - CO \t\t\t# Reaction 3\n",
"\t\t\t# H2 + (1/2)*O2 - H2O \t\t\t# Reaction 4\n",
"\n",
"\t\t\t# Considering the above 4 reactions, it can be shown that reaction (3) = reaction (1) + reaction (4) - reaction (2)\n",
"\t\t\t# Thus, delta_G_rkn_3 = delta_G_rkn_1 + delta_G_rkn_4 - delta_G_rkn_2\n",
"\t\t\t# or, -R*T*math.log(K_3) = -R*T*math.log(K_1) + -R*T*math.log(K_4) - -R*T*math.log(K_2)\n",
"\t\t\t# K_3 = (K_1*K_4/K_2)\n",
"\n",
"\t\t\t# Now we have to determine K_4 at 1200 K.\n",
"\t\t\t# The smath.tan(math.radiansard enthalpy change of reaction (4) as a fuction of temperature is given by\n",
"\t\t\t# delta_H_rkn_T = -57020 - 2.765*T + 0.475*10**(-3)*T**(2) + 8.67*10**(-8)*T**(3);\n",
"\n",
"\n",
"\t\t\t#def f2(T): \n",
"\t\t\t#\t return K_4_2/K_4_1) = integrate(delta_H_rkn_T/(R*T**(2))\n",
"\n",
"\t\t\t# math.log(K_4_2/K_4_1) = quad(f2,T_1,T)[0]\n",
"\n",
"# Calculations\n",
"def f3(T): \n",
"\t return (-57020-2.765*T+0.475*10**(-3)*T**(2)+8.67*10**(-8)*T**(3))/T**(2)\n",
"\n",
"math.log_K2_K1_4 = quad(f3,T_1,T_2)[0]\n",
"\n",
"\n",
"\t\t\t# We know that delta_G_rkn_T = -R*T*math.log(K)\n",
"\t\t\t# At 298.15 K\n",
"K_4_298 = math.exp(-delta_G_rkn_298/(R*T_1) );\n",
"\n",
"\t\t\t# Putting the values in the above math.expression we get\n",
"\t\t\t# math.log(K_4_1200/K_4_298) = math.log_K2_K1_R/R\n",
"K_4_1200 = K_4_298*math.exp(math.log_K2_K1_4/R);\n",
"K_4 = K_4_1200;\n",
"\n",
"\t\t\t# Therefore the equilibrium constant for reaction (3) at 1200 K is given by\n",
"K_3 = (K_1*K_4)/K_2;\n",
"\n",
"# Results\n",
"print \" The equilibrium constant at 1200 K for the given reaction is K = %e\"%(K_3);\n",
"\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" The equilibrium constant at 1200 K for the given reaction is K = 3.622432e+09\n"
]
}
],
"prompt_number": 18
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 17.20 Page Number : 622"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
" \n",
"# Variables\n",
"delta_G_H2O_298 = -237.034;\t\t\t#[kJ/mol] - Smath.tan(math.radiansard Gibbs free energy of formation of H2O (l) at 298 K\n",
"F = 96485;\t\t\t#[C/mol] - Faraday constant\n",
"\n",
"\t\t\t#(1)\n",
"\t\t\t# For the reaction\n",
"\t\t\t# H2 (g) + (1/2)*O2 (g) - H2O (l)\n",
"n = 2;\t\t\t# Number of electrons transferred in the reaction\n",
"\n",
"# Calculations and Results\n",
"\t\t\t# The smath.tan(math.radiansard Gibbs free energy change of the reaction is given by\n",
"\t\t\t# delta_G_rkn = delta_G_for_H2O(l) - delta_G_for_H2(g) - (1/2/)*delta_G_for_O2(g)\n",
"\t\t\t# Since delta_G_for_H2 = 0 and delta_G_for_O2 = 0 (pure components)\n",
"delta_G_rkn = delta_G_H2O_298;\t\t\t#[kJ]\n",
"delta_G_rkn = delta_G_rkn*10**(3);\t\t\t#[J]\n",
"\n",
"\t\t\t# delta_G_rkn = -n*F*E_0\n",
"\t\t\t# Thus smath.tan(math.radiansard equilibrium cell voltage is given by\n",
"E_0 = - delta_G_rkn/(n*F);\t\t\t#/[V]\n",
"\n",
"print \" 1).The standard equilibrium cell voltage is %f V\"%(E_0);\n",
"\n",
"\t\t\t#(2)\n",
"\t\t\t# For the reaction\n",
"\t\t\t# 2*H2 (g) + O2 (g) - 2*H2O (l)\n",
"n_prime = 4;\t\t\t# Number of electrons transferred in the reaction\n",
"\n",
"\t\t\t# The smath.tan(math.radiansard Gibbs free energy change of the reaction is given by\n",
"\t\t\t# delta_G_rkn = 2*delta_G_for_H2O(l) - 2*delta_G_for_H2(g) - delta_G_for_O2(g)\n",
"\t\t\t# Since delta_G_for_H2 = 0 and delta_G_for_O2 = 0 (pure components)\n",
"delta_G_rkn_prime = 2*delta_G_H2O_298;\t\t\t#[kJ]\n",
"delta_G_rkn_prime = delta_G_rkn_prime*10**(3);\t\t\t#[J]\n",
"\n",
"\t\t\t# delta_G_rkn = -n*F*E_0\n",
"\t\t\t# Thus smath.tan(math.radiansard equilibrium cell voltage is given by\n",
"E_0_prime = - delta_G_rkn_prime/(n_prime*F);\t\t\t#/[V]\n",
"\n",
"print \" 2).The standard equilibrium cell voltage is %f V\"%(E_0_prime);\n",
"\n",
"\t\t\t# Thus the result obtained is same for both the reactions\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" 1).The standard equilibrium cell voltage is 1.228346 V\n",
" 2).The standard equilibrium cell voltage is 1.228346 V\n"
]
}
],
"prompt_number": 5
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 17.21 Page Number : 624"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
" \n",
"# Variables\t\t\t\n",
"P = 2;\t\t\t# Number of phases\n",
"C = 5;\t\t\t# Number of components\n",
"\n",
"# Calculations\t\n",
" \t\t# First we write chemical equations for formation of each component from basic elements\n",
"\t\t\t# C + 2*H2 = CH4 \t\t\t# (reaction 1) \n",
"\t\t\t# H2 + (1/2)*O2 = H20 \t\t\t# (reaction 2)\n",
"\t\t\t# C + (1/2)*O2 = CO \t\t\t# (reaction 3)\n",
"\t\t\t# C + O2 = CO2 \t\t\t# (reaction 4)\n",
"\n",
"\t\t\t# We do not have C in the equilibrium reaction mixture, therefore we have to eliminate it.\n",
"\t\t\t# Substituting for C from reaction (1) into reactions (3) and (4) we get the following set of reactions\n",
"\t\t\t# H2 + (1/2)*O2 = H20\n",
"\t\t\t# CH4 - 2*H2 + (1/2)*O2 = CO\n",
"\t\t\t# CH4 - 2*H2 + O2 = CO2\n",
"\n",
"\t\t\t# or,\n",
"\t\t\t# H2 + (1/2)*O2 = H2O\n",
"\t\t\t# CH4 + (1/2)*O2 = CO + 2*H2\n",
"\t\t\t# CH4 + O2 = CO2 + 2*H2\n",
"\n",
"\t\t\t# We do not have O2 in the equilibrium reaction mixture,therefore we have to eliminateit\n",
"\t\t\t# Substituting for O2 from the first reaction of the above set into seecond and third reactions of the above set we get the following set of reactions.\n",
"\t\t\t# CH4 + H2O - H2 = CO + 2*H2\n",
"\t\t\t# CH4 + 2*H20 - 2*H2 = CO2 + 2*H2 \n",
"\n",
"\t\t\t# Therefore one set of independent reactions is\n",
"\t\t\t# CH4 + H20 = CO + 3*H2\n",
"\t\t\t# CH4 + 2*H2O = CO2 + 4*H2\n",
"\n",
"\t\t\t# Another set of independent reactions can be obtained by substituting for CH4 from the first reaction into second and we get\n",
"\t\t\t# CH4 + H2O = CO + 3*H2\n",
"\t\t\t# CO + 3*H2 - H2O + 2*H2O = CO2 4*H2\n",
"\n",
"\t\t\t# Or, \n",
"\t\t\t# CH4 + H2O = CO + 3*H2\n",
"\t\t\t# CO + H2O = CO2 + H2\n",
"\t\t\t# This is another set of independent reactions. Thus whatever be the set of independent reactions, the number of independent reactions are two\n",
"\t\t\t# If different set of reactions are considered, then we get different equilibrium constants,different reaction coordinates but the final composition will be same\n",
"\t\t\t# Thus only 2 independent reactions occur,therefore \n",
"r = 2;\n",
"\n",
"\t\t\t# and the number of degree of freedom becomes,\n",
"F = r - P + C;\n",
"\n",
"# Results\n",
"print \" The number of independent chemical reactions are %f \"%(r);\n",
"\n",
"print \" The first set of independent reactions are given below\";\n",
"print \" CH4 + H20 = CO + 3*H2\";\n",
"print \" CH4 + 2*H2O = CO2 + 4*H2\";\n",
"\n",
"print \" The second set of independent reactions are given below\";\n",
"print \" CH4 + H20 = CO + 3*H2\";\n",
"print \" CO + H2O = CO2 + H2\";\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" The number of independent chemical reactions are 2.000000 \n",
" The first set of independent reactions are given below\n",
" CH4 + H20 = CO + 3*H2\n",
" CH4 + 2*H2O = CO2 + 4*H2\n",
" The second set of independent reactions are given below\n",
" CH4 + H20 = CO + 3*H2\n",
" CO + H2O = CO2 + H2\n"
]
}
],
"prompt_number": 20
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 17.22 Page Number : 626"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
" \n",
"# Variables\t\t\t\n",
"T = 400.;\t\t\t#[K] - Temperature\n",
"P = 1.;\t\t\t#[atm] - Pressure\n",
"R = 1.987;\t\t\t#[cal/mol-K] - Universal gas consatnt\n",
"\n",
"delta_G_n_pentane_400 = 9600.;\t\t\t#[cal/mol] - Smath.tan(math.radiansard Gibbs free energy of formation of n-pentane at 400 K\n",
"delta_G_iso_pentane_400 = 8200.;\t\t\t#[cal/mol] - Smath.tan(math.radiansard Gibbs free energy of formation of iso-pentane at 400 K\n",
"delta_G_neo_pentane_400 = 9000.;\t\t\t#[cal/mol] - Smath.tan(math.radiansard Gibbs free energy of formation of neo-pentane at 400 K\n",
"\n",
"\t\t\t# The three reactions for the formation of these isomers can be written as follows\n",
"\t\t\t# 5*C + 6*H2 = n-pentane\n",
"\t\t\t# 5*C + 6*H2 = iso-pentane\n",
"\t\t\t# 5*C + 6*H2 = neo-pentane\n",
"\n",
"\t\t\t# We can eliminate elemental carbon and hydrogen as they are not present in equilibrium reaction mixture and get the following two sets of independent reactions\n",
"\t\t\t# n-pentane = iso-pentane \n",
"\t\t\t# n-pentane = neo-pentane \n",
"\n",
"\t\t\t# or,\n",
"\t\t\t# iso-pentane = n-pentane \n",
"\t\t\t# iso-pentane = neo-pentane \n",
"\n",
"\t\t\t# or,\n",
"\t\t\t# noe-pentane = iso-pentane \n",
"\t\t\t# neo-pentane = n-pentane \n",
"# Calculations and Results\n",
"\t\t\t# Let us take the following set of independent reactions\n",
"\t\t\t# iso-pentane = n-pentane \t\t\t# (reaction 1)\n",
"delta_G_rkn_1 = delta_G_n_pentane_400 - delta_G_iso_pentane_400;\t\t\t#[cal]\n",
"K_1 = math.exp(-delta_G_rkn_1/(R*T));\n",
"\t\t\t# iso-pentane = neo-pentane \t\t\t# (reaction 2)\n",
"delta_G_rkn_2 = delta_G_neo_pentane_400 - delta_G_iso_pentane_400;\t\t\t#[cal]\n",
"K_2 = math.exp(-delta_G_rkn_2/(R*T));\n",
"\n",
"\t\t\t# Let the initial number of moles be\n",
"\t\t\t# n_iso_pentane = 1\n",
"\t\t\t# n_n_pentane = 0\n",
"\t\t\t# n_neo_pentane = 0\n",
"\n",
"\t\t\t# Let the reaction coordinate at equilibrium for the two reaction be X_1 and X_2 respectively\n",
"\t\t\t# At equilibrium, the moles of the components be\n",
"\t\t\t# n_iso_pentane_eq = 1 - X_1 - X_2\n",
"\t\t\t# n_n_pentane_eq = X_1\n",
"\t\t\t# n_neo_pentane_eq = X_2\n",
"\t\t\t# Total moles = 1 \n",
"\n",
"\t\t\t# Pressure has no effect on these reactions ( P = 1 atm) and therefore\n",
"Ky_1 = K_1;\n",
"Ky_2 = K_2;\n",
"\n",
"\t\t\t# From reaction (1), we get\n",
"\t\t\t# Ky_1 = X_1/(1-X_1-X_2)\n",
"\n",
"\t\t\t# From reaction (2), we get\n",
"\t\t\t# Ky_2 = X_2/(1-X_1-X_2)\n",
"\n",
"\t\t\t# Putting the value of X_1 from first equation into the second we get\n",
"\t\t\t# X_1 = (Ky_1*(1-X_2))/(1+Ky_1)\n",
"\t\t\t# Now putting it into the second equation we grt\n",
"\t\t\t# Ky_2 = X_2/(1-((Ky_1*(1-X_2))/(1+Ky_1))-X_2)\n",
"\t\t\t# Now solving for X_2\n",
"def f(X_2): \n",
"\t return Ky_2 - X_2/(1-((Ky_1*(1-X_2))/(1+Ky_1))-X_2)\n",
"X_2 = fsolve(f,0.8)\n",
"\n",
"\t\t\t# Therefore X_1 can be calculated as\n",
"X_1 = (Ky_1*(1-X_2))/(1+Ky_1);\n",
"\n",
"\t\t\t# Finally the mole fractions of the components at equilibrium\n",
"y_n_pentane = X_1;\n",
"y_neo_pentane = X_2;\n",
"y_iso_pentane = 1 -X_1 - X_2;\n",
"\n",
"print \" The equilibrium composition is given by y_n_pentane = %f y_neo_pentane = %f and y_iso_pentane = %f\"%(y_n_pentane,y_neo_pentane,y_iso_pentane);\n",
"\n",
"\t\t\t# Let us consider another set of independent reactions\n",
"\n",
"\t\t\t# n-pentane = iso-pentane \t\t\t# (reaction 3)\n",
"delta_G_rkn_3 = delta_G_iso_pentane_400 - delta_G_n_pentane_400;\t\t\t#[cal]\n",
"K_3 = math.exp(-delta_G_rkn_3/(R*T));\n",
"\t\t\t# n-pentane = neo-pentane \t\t\t# (reaction 4)\n",
"delta_G_rkn_4 = delta_G_neo_pentane_400 - delta_G_n_pentane_400;\t\t\t#[cal]\n",
"K_4 = math.exp(-delta_G_rkn_4/(R*T));\n",
"\n",
"\t\t\t# Let the initial number of moles be\n",
"\t\t\t# n_n_pentane = 1\n",
"\t\t\t# n_iso_pentane = 0\n",
"\t\t\t# n_neo_pentane = 0\n",
"\n",
"\t\t\t# Let the reaction coordinate at equilibrium for the two reaction be X_3 and X_4 respectively\n",
"\t\t\t# At equilibrium, the moles of the components be\n",
"\t\t\t# n_n_pentane_eq = 1 - X_3 - X_4\n",
"\t\t\t# n_iso_pentane_eq = X_4\n",
"\t\t\t# n_neo_pentane_eq = X_4\n",
"\t\t\t# Total moles = 1 \n",
"\n",
"\t\t\t# Pressure has no effect on these reactions (P = 1 atm) and therefore\n",
"Ky_3 = K_3;\n",
"Ky_4 = K_4;\n",
"\n",
"\t\t\t# From reaction (3), we get\n",
"\t\t\t# Ky_3 = X_3/(1-X_3-X_4)\n",
"\n",
"\t\t\t# From reaction (4), we get\n",
"\t\t\t# Ky_4 = X_4/(1-X_3-X_4)\n",
"\n",
"\t\t\t# Putting the value of X_3 from first equation into the second we get\n",
"\t\t\t# X_3 = (Ky_3*(1-X_4))/(1+Ky_3)\n",
"\t\t\t# Now putting it into the second equation we grt\n",
"\t\t\t# Ky_4 = X_4/(1-((Ky_1*(1-X_4))/(1+Ky_3))-X_4)\n",
"\t\t\t# Now solving for X_4\n",
"def f1(X_4): \n",
"\t return Ky_4 - X_4/(1-((Ky_3*(1-X_4))/(1+Ky_3))-X_4)\n",
"X_4 = fsolve(f1,0.8)\n",
"\n",
"\t\t\t# Therefore X_3 can be calculated as\n",
"X_3 = (Ky_3*(1-X_4))/(1+Ky_3);\n",
"\n",
"\t\t\t# Finally the mole fractions of the components at equilibrium\n",
"y_n_pentane1 = 1 - X_3 - X_4;\n",
"y_neo_pentane1 = X_4;\n",
"y_iso_pentane1 = X_3;\n",
"\n",
"\t\t\t# The final composition does not depend on the set of reactions considered. \n",
"\n",
"print \" For another set of independent reactions considered\";\n",
"print \" The equilibrium composition is given by y_n_pentane = %f y_neo_pentane = %f and y_iso_pentane = %f\"%(y_n_pentane1,y_neo_pentane1,y_iso_pentane1);\n",
"print \" Thus the final composition does not depend on the set of reactions considered\";\n",
"print \" The number of independent reactions taking place is two\";\n",
"\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" The equilibrium composition is given by y_n_pentane = 0.111753 y_neo_pentane = 0.237745 and y_iso_pentane = 0.650501\n",
" For another set of independent reactions considered\n",
" The equilibrium composition is given by y_n_pentane = 0.111753 y_neo_pentane = 0.237745 and y_iso_pentane = 0.650501\n",
" Thus the final composition does not depend on the set of reactions considered\n",
" The number of independent reactions taking place is two\n"
]
}
],
"prompt_number": 21
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 17.23 Page Number : 628"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
" \n",
"T = 600;\t\t\t#[K] - Temperature\n",
"P = 1;\t\t\t#[atm] - Pressure\n",
"R = 1.987;\t\t\t#[cal/mol-K] - Universal gas consatnt\n",
"\n",
"\t\t\t# CH4 + H2O = CO + 3*H2 \t\t\t# (Reaction 1)\n",
"\t\t\t# CO + H2O = CO2 + H2 \t\t\t# (Reaction 2)\n",
"\n",
"K_1 = 0.574;\t\t\t# Equilibrium constant of first reaction\n",
"K_2 = 2.21;\t\t\t# Equilibrium constant of second reaction\n",
"\n",
"\t\t\t# Initial number of moles of the components are\n",
"\t\t\t# n_CH4 = 1\n",
"\t\t\t# n_H2O = 5\n",
"\t\t\t# n_CO = 0\n",
"\t\t\t# n_H2 = O\n",
"\t\t\t# n_CO2 = 0\n",
"\n",
"\t\t\t# Let the reaction coordinate at equilibrium for the two reaction be X_1 and X_2 respectively\n",
"\t\t\t# At equilibrium, the moles of the components be\n",
"\t\t\t# n_CH4_eq = 1 - X_1\n",
"\t\t\t# n_H20_eq = 5 - X_1 - X_2\n",
"\t\t\t# n_CO_eq = X_1 - X_2\n",
"\t\t\t# n_H2_eq = 3*X_1 + X_2\n",
"\t\t\t# n_CO2_eq = X_2\n",
"\t\t\t# Total moles = 6 + 2*X_1\n",
"\n",
"\t\t\t# Since the pressure is 1 atm, K = Kp, Ky = K\n",
"Ky_1 = K_1;\n",
"Ky_2 = K_2;\n",
"\n",
"\t\t\t# From reaction (1), we get\n",
"\t\t\t# Ky_1 = ((X_1-X_2)*(3*X_1+X_2)**(3))/((1-X_1)*(5-X_1-X_2)*(6+2*X_1)**(2))\n",
"\n",
"\t\t\t# From reaction (2), we get\n",
"\t\t\t# Ky_2 = (X_2*(3*X_1+X_2))/((X_1-X_2)*(5-X_1-X_2))\n",
"\n",
"# Calculations\n",
"\t\t\t# Let us assume a value of X_1\n",
"X_1 = 0.1;\n",
"def f(X_2): \n",
"\t return Ky_1-((X_1-X_2)*(3*X_1+X_2)**(3))/((1-X_1)*(5-X_1-X_2)*(6+2*X_1)**(2))\n",
"\n",
"def f1(X_1_prime): \n",
"\t return Ky_2-(X_2_prime*(3*X_1_prime+X_2_prime))/((X_1_prime-X_2_prime)*(5-X_1_prime-X_2_prime))\n",
"\n",
"fault = 10;\n",
"while(fault>0.05):\n",
" X_2 = fsolve(f,0.8)\n",
" X_2_prime = X_2;\n",
" X_1_prime = fsolve(f1,0.8)\n",
" fault=abs(X_1 - X_1_prime);\n",
" X_1 = X_1 + 0.001;\n",
"\n",
"n_CH4 = 1 - X_1;\n",
"n_H20 = 5 - X_1 - X_2;\n",
"n_CO = X_1 - X_2;\n",
"n_H2 = 3*X_1 + X_2;\n",
"n_CO2 = X_2;\n",
"Total_moles = 6 + 2*X_1;\n",
"\n",
"# Results\n",
"print \" The equilibrium composition of the resulting mixture is given by\";\n",
"print \" n_CH4 = % f mol n_H2O = %f mol n_CO = %f mol n_H2 = %f mol and n_CO2 = %f mol\"%(n_CH4,n_H20,n_CO,n_H2,n_CO2);\n",
"print \" The total number of moles is %f mol\"%(Total_moles);\n",
"\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" The equilibrium composition of the resulting mixture is given by\n",
" n_CH4 = 0.089000 mol n_H2O = 3.471420 mol n_CO = 0.293420 mol n_H2 = 3.350580 mol and n_CO2 = 0.617580 mol\n",
" The total number of moles is 7.822000 mol\n"
]
},
{
"output_type": "stream",
"stream": "stderr",
"text": [
"/home/jovina/virtualenvs/scipy/local/lib/python2.7/site-packages/scipy/optimize/minpack.py:236: RuntimeWarning: The iteration is not making good progress, as measured by the \n",
" improvement from the last ten iterations.\n",
" warnings.warn(msg, RuntimeWarning)\n",
"/home/jovina/virtualenvs/scipy/local/lib/python2.7/site-packages/scipy/optimize/minpack.py:236: RuntimeWarning: The iteration is not making good progress, as measured by the \n",
" improvement from the last five Jacobian evaluations.\n",
" warnings.warn(msg, RuntimeWarning)\n"
]
}
],
"prompt_number": 6
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 17.24 Page Number : 631"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
" \n",
"T = 600 + 273.15;\t\t\t#[K] - Reaction temperature\n",
"P = 1;\t\t\t#[atm] - Reaction pressure\n",
"\n",
"\t\t\t# The Gibbs free energy of formation of various species at 873.15 K are\n",
"delta_G_CH4_RT = -2.82;\t\t\t# delta_G_CH4/(R*T)\n",
"delta_G_H2O_RT = -29.73;\t\t\t# delta_G_CH4/(R*T)\n",
"delta_G_CO_RT = -27.51;\t\t\t# delta_G_CH4/(R*T)\n",
"delta_G_H2_RT = -1.46;\t\t\t# delta_G_CH4/(R*T)\n",
"delta_G_CO2_RT = -56.68;\t\t\t# delta_G_CH4/(R*T)\n",
"\n",
"# Calculations\t\t\n",
" \t# Initial number of moles of the components are\n",
"\t\t\t# n_CH4 = 1\n",
"\t\t\t# n_H2O = 5\n",
"\t\t\t# n_CO = 0\n",
"\t\t\t# n_H2 = O\n",
"\t\t\t# n_CO2 = 0\n",
"\n",
"\t\t\t# The del(F)/del(n_i) = 0 equations for CH4 (1), H2O (2), CO (3), H2 (4) and CO2 (5) becomes\n",
"\t\t\t# delta_G_1_T + R*T*math.log((n_1*P)/n) + lambda_C + 4*lambda_H = 0\n",
"\t\t\t# delta_G_2_T + R*T*math.log((n_2*P)/n) + 2*lambda_C + lambda_O = 0\n",
"\t\t\t# delta_G_3_T + R*T*math.log((n_3*P)/n) + lambda_c + lambda_O = 0\n",
"\t\t\t# delta_G_4_T + R*T*math.log((n_4*P)/n) + 2*lambda_H = 0\n",
"\t\t\t# delta_G_5_T + R*T*math.log((n_5*P)/n) + lambda_C + 2*lambda_O = 0\n",
"\n",
"\t\t\t# Where n is the total number of moles in the equilibrium reaction mixture. Dividing the above equations by R*T we get\n",
"\t\t\t# delta_G_1_T/(R*T) + math.log((n_1*P)/n) + lambda_C/(R*T) + 4*lambda_H/(R*T) = 0\n",
"\t\t\t# delta_G_2_T/(R*T) + math.log((n_2*P)/n) + 2*lambda_C/(R*T) + lambda_O/(R*T) = 0\n",
"\t\t\t# delta_G_3_T/(R*T) + math.log((n_3*P)/n) + lambda_c/(R*T) + lambda_O/(R*T) = 0\n",
"\t\t\t# delta_G_4_T/(R*T) + math.log((n_4*P)/n) + 2*lambda_H/(R*T) = 0\n",
"\t\t\t# delta_G_5_T/(R*T) + math.log((n_5*P)/n) + lambda_C/(R*T) + 2*lambda_O/(R*T) = 0\n",
"\n",
"\t\t\t# Substituting the values of delta_G_i_T/(R*T) in the above equations,the full set of equations (including elemental balance) becomes\n",
"\t\t\t# -2.82 + math.log(n_1/n) + lambda_C/(R*T) + 4*lambda_H/(R*T) = 0\n",
"\t\t\t# -29.73 + math.log(n_2/n) + 2*lambda_H/(R*T) + lambda_O/(R*T) = 0\n",
"\t\t\t# -27.51 + math.log(n_3/n) + lambda_C/(R*T) + lambda_O/(R*T) = 0\n",
"\t\t\t# -1.46 + math.log(n_4/n) + 2*lambda_H/(R*T) = 0\n",
"\t\t\t# -56.68 + math.log(n_5/n) + lambda_C/(R*T) + 2*lambda_O/(R*T) = 0\n",
"\n",
"\t\t\t# The constraint equations are\n",
"\t\t\t# n_1 + n_3 + n_5 = 1 \t\t\t# (moles of C in the reaction mixture = 1)\n",
"\t\t\t# 4*n_1 + 2*n_2 + 2*n_4 = 14 \t\t\t# (moles of H in the reaction mixture = 14)\n",
"\t\t\t# n_2 + n_3 + 2*n_5 = 5 \t\t\t# (moles of O in the raection mixture = 5)\n",
"\n",
"\t\t\t# The total moles are given by\n",
"\t\t\t# n = n_1 + n_2 + n_3 + n_4 + n_5\n",
"\n",
"def solution(x):\n",
" f = [0,0,0,0,0,0,0,0,0]\n",
" f[0]= -2.82 + math.log(x[0]/x[5]) + x[6] + 4*x[7];\n",
" f[1] = -29.73 + math.log(x[1]/x[5]) + 2*x[7] + x[8];\n",
" f[2] = -27.51 + math.log(x[2]/x[5]) + x[6] + x[8];\n",
" f[3] = -1.46 + math.log(x[3]/x[5]) + 2*x[7];\n",
" f[4] = -56.68 + math.log(x[4]/x[5]) + x[6] + 2*x[8];\n",
" f[5] = x[0] + x[2] +x[4] - 1;\n",
" f[6] = 4*x[0] + 2*x[1] + 2*x[3] - 14;\n",
" f[7] = x[1] + x[2] +2*x[4] - 5;\n",
" f[8] = x[0]+ x[1] + x[2] + x[3] + x[4] - x[5]; \n",
" return f\n",
"\n",
"\n",
"x = [0.01,3.5,0.2,3.0,0.5,5.0,2.0,1.0,25.0];\n",
"y = fsolve(solution,x)\n",
"\n",
"# Results\n",
"print \" n_1 = %f mol\"%(y[0]);\n",
"print \" n_2 = %f mol\"%(y[1]);\n",
"print \" n_3 = %f mol\"%(y[2]);\n",
"print \" n_4 = %f mol\"%(y[3]);\n",
"print \" n_5 = %f mol\"%(y[4]);\n",
"print \" n = %f mol\"%(y[5]);\n",
"print \" lambda_C/RT = %f\"%(y[6]);\n",
"print \" lambda_H/RT = %f\"%(y[7]);\n",
"print \" lambda_O/RT = %f\"%(y[8]);\n",
"\n",
"print \" The Lagrange multiplier values do not have any physical significance\";\n",
"\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" n_1 = 0.091556 mol\n",
" n_2 = 3.442034 mol\n",
" n_3 = 0.258922 mol\n",
" n_4 = 3.374855 mol\n",
" n_5 = 0.649522 mol\n",
" n = 7.816888 mol\n",
" lambda_C/RT = 2.667225\n",
" lambda_H/RT = 1.149967\n",
" lambda_O/RT = 28.250290\n",
" The Lagrange multiplier values do not have any physical significance\n"
]
}
],
"prompt_number": 23
},
{
"cell_type": "code",
"collapsed": false,
"input": [],
"language": "python",
"metadata": {},
"outputs": []
}
],
"metadata": {}
}
]
}
|