summaryrefslogtreecommitdiff
path: root/Thermodynamics:_A_Core_Course/CH5.ipynb
blob: 865af391c8de02796b14dfb4fd954af27039d80d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
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
{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 5:The second Law of Thermodynamics"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.1,Page no:59"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#example 5.1\n",
      "\n",
      "#to find the workdone , heat rejected , and efficiency of the engine\n",
      "#Variable declaration\n",
      "T1=373.0 \t\t\t\t#initial temperature [K]\n",
      "T2=573.0 \t\t\t\t#final temperature [K]\n",
      "Q2=750.0 \t\t\t\t#Heat absorbed by carnot engine[J]\n",
      "\n",
      "#Calculation\n",
      "e=(T2-T1)/T2 \t\t\t#efficiency of the engine\n",
      "W=e*Q2 \t\t\t\t#Workdone by the engine[J]\n",
      "Q1=T1*Q2/T2 \t\t\t#Heat rejected by the engine[J]\n",
      "#Result\n",
      "print\"Efficiency of the engine =\",round(e,3) \n",
      "print\"\\n Workdone by the engine =\",round(W),\"J\"\n",
      "print\"\\n Heat rejected by the engine =\",round(Q1),\"J\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Efficiency of the engine = 0.349\n",
        "\n",
        " Workdone by the engine = 262.0 J\n",
        "\n",
        " Heat rejected by the engine = 488.0 J\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.2,Page no:61"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#example 5.2\n",
      "#to analyse the efficiency of the engine \n",
      "\n",
      "#Variable declaration\n",
      "T1=250.0 #temperature of heat rejection[K]\n",
      "T2=1000.0 #temperature of heat absorption[K]\n",
      "#Calculation\n",
      "e=1-(T1/T2) \n",
      "#Result\n",
      "print\"Efficiency of the corresponding carnot engine =\",e,\"or\",e*100,\"%\"\n",
      "print\" Therefore , the inventors claim of 80% efficiency is absurd.The patent application should be rejected\" \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Efficiency of the corresponding carnot engine = 0.75 or 75.0 %\n",
        " Therefore , the inventors claim of 80% efficiency is absurd.The patent application should be rejected\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.3,Page no:62"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#example 5.3\n",
      "#To find the minimum heat required from heat source to yield the above work\n",
      "#Variable declaration\n",
      "T1=323.0 \t\t\t\t#temperature [K]\n",
      "T2=423.0 \t\t\t\t#temperature [K]\n",
      "W=1.3 \t\t\t\t#work [KJ]\n",
      "#Calculation\n",
      "e=(T2-T1)/T2 \t\t\t#efficiency\n",
      "Q2=W/e \t\t\t\t#minimum heat withdrawal from heat source[KJ]\n",
      "#Result\n",
      "print\"Minimum heat withdrawal from heat source=\",round(Q2,2),\"kJ\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Minimum heat withdrawal from heat source= 5.5 kJ\n"
       ]
      }
     ],
     "prompt_number": 46
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.5,Page no:64"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#example 5.5\n",
      "#to find the molar entropy change \n",
      "#Variable declaration\n",
      "T=298 \t\t\t#Temperature [K]\n",
      "n=1 \t\t\t#no. of moles\n",
      "V1=500 \t\t\t#initial volume [cm3]\n",
      "V2=1000 \t\t#final volume [cm3]\n",
      "R=8.314 \t\t#Universal gas constant [J/mol/K]\n",
      "import math\n",
      "#Calculation\n",
      "S=R*math.log(V2/V1)\t\t#molar entropy change at constant temperature[J/K]\n",
      "#Result\n",
      "print\"Molar entropy change of argon =\",round(S,1),\"J/K\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Molar entropy change of argon = 5.8 J/K\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.6,Page no:64"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#example 5.6 \n",
      "\n",
      "#to find the change in molar entropy when the gas expands isothermally and reversibly\n",
      "#Variable declaration\n",
      "W=1728.0 \t\t\t#Isothermal and reversible work done[J/mol]\n",
      "T=298.0 \t\t\t#Isothermal temperature[K]\n",
      "#Calculation\n",
      "\n",
      "S=W/T \t\t\t#change in molar entropy for isothermal and reversible process\n",
      "#result\n",
      "print\"The change in molar entropy =\",round(S,1),\"JK^-1mol^-1\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The change in molar entropy = 5.8 JK^-1mol^-1\n"
       ]
      }
     ],
     "prompt_number": 47
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.7,Page no:68"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#example 5.7\n",
      "\n",
      "#To find the change in entropy of the surroundings at 298K\n",
      "#Variable declaration\n",
      "H=-92.22 \t\t\t#Standard reaction enthalpy[KJ]\n",
      "T=298 \t\t\t\t#Temperature [K]\n",
      "\n",
      "#Calculation\t\n",
      "\t#standard reaction enthalpy is H.Therefore, heat gained by the surroundings at 298K is -H\n",
      "S=-H*1000/T \t\t\t#Change in entropy[J/K]\n",
      "#Result\n",
      "print\"Change in entropy of the surroundings at 298k =\",round(S,1),\"J/K\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Change in entropy of the surroundings at 298k = 309.5 J/K\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.8,Page no:69"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#example 5.8\n",
      "\n",
      "#To find the change in entropy for argon gas\n",
      "#Variable declaration\n",
      "T1=298.0 \t\t\t\t#Initial Temperature[K]\n",
      "T2=573.0 \t\t\t\t#Final Temperature[K]\n",
      "Cv=29.1 \t\t\t#Specific Heat capacity of argon gas [J/K/mol]\n",
      "n=1 \t\t\t\t#no. of moles\n",
      "\n",
      "import math\n",
      "#calculation\n",
      "S=n*Cv*math.log(T2/T1) \t\t#Change in entropy [J/K]\n",
      "#Result\n",
      "print\"The change in entropy of the argon gas is\",round(S,2),\"J/K\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The change in entropy of the argon gas is 19.03 J/K\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.9,Page no:69"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#example 5.9\n",
      "\n",
      "#To find the total entropy change of solid\n",
      "#Variable declaration\n",
      "T1=276.0 \t\t\t\t#Initial temperature[K]\n",
      "Tf=278.7 \t\t\t#Freezing point temperature[K]\n",
      "Tb=353.3 \t\t\t#Boiling point temperature[K]\n",
      "T2=373.0 \t\t\t\t#Final temperature[K]\n",
      "Hf=9870.0 \t\t\t#Standard enthalpy of fusion[J/mol]\n",
      "Hv=30800.0 \t\t\t#Standard enthalpy of vaporization[J/mol]\n",
      "Cp=136.1 \t\t\t#Specific heat capacity of benzene[J/K/mol]\n",
      "mol_wt=78.0 \t\t\t#molecular weight of benzene[g/mol]\n",
      "mass=200.0\t\t\t#weight of solid benzene[g]\n",
      "print\"Cp doesnot change within this temp limit\" \n",
      "import math\n",
      "#calculation\n",
      "n=mass/mol_wt \t\t\t#no. of moles\n",
      "\n",
      "S1=n*Cp*math.log(Tf/T1) \t#entropy change in heating [J/K]\n",
      "S2=n*Hf/Tf \t\t\t#entropy change in melting[J/K] \n",
      "S3=n*Cp*math.log(Tb/Tf) \t#entropy change in heating[J/K]\n",
      "S4=n*Hv/Tb \t\t\t#entropy change in vaporization[J/K]\n",
      "S5=n*Cp*math.log(T2/Tb) \t#entropy change in heating[J/K]\n",
      "S=S1+S2+S3+S4+S5 \t\t#total entropy change in heating from 276 to 373K\n",
      "#Result\n",
      "print\"Total entropy change in heating 200g benzene from 3 to 100`C is\",round(S,1),\"J/K or\",round(S/1000,3),\"KJ/K\"\n",
      "print\"\\nNOTE:In textbook the value of 'n' is wrongly calculated as 25.64 instead of 2.564,SO there is a error in answer shown in book\" "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Cp doesnot change within this temp limit\n",
        "Total entropy change in heating 200g benzene from 3 to 100`C is 419.4 J/K or 0.419 KJ/K\n",
        "\n",
        "NOTE:In textbook the value of 'n' is wrongly calculated as 25.64 instead of 2.564,SO there is a error in answer shown in book\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.10,Page no:71"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#example 5.10\n",
      "#To find the change in entropy of the gas\n",
      "#Isothermal process\n",
      "#Variable declaration\n",
      "mass=32 \t\t\t#weight of methane gas[gm]\n",
      "P1=6*10**5 \t\t\t#Initial temperature[N/m2]\n",
      "P2=3*10**5 \t\t\t#Final pressure[N/m2]\n",
      "mol_wt=16 \t\t\t#molecular weight of methane gas[g/mol]\n",
      "T=298 \t\t\t\t#Temperature[K]\n",
      "#calculation\t\n",
      "R=8.314 \t\t\t#Universal gas constant[J/K/mol]\n",
      "import math\t\n",
      "n=mass/mol_wt \t\t\t#no. of moles\n",
      "S=n*R*math.log(P1/P2) \t\t#change in entropy of gas[J/K]\n",
      "\n",
      "#Result\n",
      "print\"The change in entropy of the gas is\",round(S,2),\"J/K\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The change in entropy of the gas is 11.53 J/K\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.11,Page no:75"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate:\n",
      "#1.Total no. og possible configuration\n",
      "#2.Probability of getting a configuration\n",
      "#3.Total energy and average energy of the system\n",
      "#4.Change in energy of the system\n",
      "\n",
      "import math\n",
      "#Variable declaration\n",
      "black=2              #No. of black balls\n",
      "white=1              #No. of white ball\n",
      "\n",
      "#CALCULATION\n",
      "\n",
      "#Total no. of config\n",
      "W=math.factorial(black+white)/(math.factorial(black)*math.factorial(white))\n",
      "#Probability of getting a config\n",
      "P=1.0/W\n",
      "#Total and Average energy of system\n",
      "E1=0+1+2\n",
      "E2=E1\n",
      "E3=E2\n",
      "E=E1+E2+E3\n",
      "E_av=E/3\n",
      "#Change in total energy of system\n",
      "E1_dash=1+2+3\n",
      "E2_dash=E1_dash\n",
      "E3_dash=E2_dash\n",
      "E_dash=E1_dash+E2_dash+E3_dash\n",
      "change=E_dash-E\n",
      "\n",
      "#RESULT\n",
      "print\"1.Total No. of possible configuration:\",W\n",
      "print\"2.Probability of getting a configuration=\",P,\"or 1/3\"\n",
      "print\"3.Total energy of system=\",E\n",
      "print\"  Therefore,Average energy=\",E_av\n",
      "print\"4.In this case,Total energy=\",E_dash\n",
      "print\"  Change in total energy of system=\",change"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "1.Total No. of possible configuration: 3\n",
        "2.Probability of getting a configuration= 0.333333333333 or 1/3\n",
        "3.Total energy of system= 9\n",
        "  Therefore,Average energy= 3\n",
        "4.In this case,Total energy= 18\n",
        "  Change in total energy of system= 9\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.12,Page no:77"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#example 5.12\n",
      "\n",
      "#To find the relative number of distinguishable quantum states in 1 mole of water and ice at 273K \n",
      "#Variable declaration\n",
      "n=1.0 \t\t\t#no. of moles\n",
      "T=273.0 \t\t\t#temperature [K]\n",
      "Hf=6000.0 \t\t#enthalpy of fusion at 273K [J/mol]\n",
      "k=1.38*(10**-23) \t#boltzmann constant[J/K]\n",
      "\n",
      "#calculation\n",
      "p=Hf/(k*T)/2.303 \n",
      "print\"\\nTHE RESULT IS 10^24,which is too large to be displayed by ipython \"\n",
      "#w=10**(p) \t\t#w is the relative no. of distinguishable quantum states\n",
      "#Result\n",
      "print\"This value of w is very large to calculate for python,because it's in the range of 10^24\"\n",
      "print\"The relative no. of distinguishable quantum states in 1 mole of water and ice at 273K is 10^24\" \n",
      "print\"\\nTHE RESULT IS 10^24,which is too large to be displayed by ipython \"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "THE RESULT IS 10^24,which is too large to be displayed by ipython \n",
        "This value of w is very large to calculate for python,because it's in the range of 10^24\n",
        "The relative no. of distinguishable quantum states in 1 mole of water and ice at 273K is 10^24\n",
        "\n",
        "THE RESULT IS 10^24,which is too large to be displayed by ipython \n"
       ]
      }
     ],
     "prompt_number": 50
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.13,Page no:86"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#example 5.13\n",
      "\n",
      "#To find the total entropy change of solid\n",
      "#Variable declaration\n",
      "T=300 \t\t\t#temperature[K]\n",
      "n=4 \t\t\t#no. of moles of an ideal gas\n",
      "P1=2.02*10**5 \t\t#initial pressure[N/m2]\n",
      "P2=4.04*10**5 \t\t#final pressure[N/m2]\n",
      "R=8.314 \t\t#Universal gas constant[J/K/mol]\n",
      "import math\n",
      "#calculation\n",
      "G=n*R*T*2.303*math.log10(P2/P1) \t#[J]\n",
      "#Result\n",
      "print\" The change in Gibbs free energy is\",round(G,1),\"J\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The change in Gibbs free energy is 6916.6 J\n"
       ]
      }
     ],
     "prompt_number": 51
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.14,Page no:86"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#example 5.14\n",
      "\n",
      "#To find the work function or Helmholts free energy\n",
      "##Variable declaration\n",
      "n=1 \t\t\t#no. of moles\n",
      "T=300 \t\t\t#temperature[K]\n",
      "V1=2 \t\t\t#initial volume[m3]\n",
      "V2=20 \t\t\t#final volume[m3]\n",
      "R=8.314 \t\t#Universal gas constant[J/K/mol]\n",
      "import math\n",
      "#calculation\n",
      "\t\n",
      "A=-n*R*T*2.303*math.log10(V2/V1) \t#Change in work function[J/mol]\n",
      "#Result\n",
      "print\"The change in Helmholts free energy is\",round(A),\"J/mol\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The change in Helmholts free energy is -5744.0 J/mol\n"
       ]
      }
     ],
     "prompt_number": 52
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.15,Page no:87"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#example 5.15\n",
      "#To find the energy change that can be extracted as heat and work \n",
      "print\"C6H12O6(s) + 6O2(g) --> 6CO2(g) + 6H2O(l)\"\n",
      "#Variable declaration\n",
      "T=298 \t\t\t\t#Temperature[k]\n",
      "R=8.314 \t\t\t#Universal gas constant[J/K/mol]\n",
      "S=182.45 \t\t\t#standard entropy change at 298K [J/K]\n",
      "U=-2808 \t\t\t#change in internal energy at 298K[KJ/mol]\n",
      "\t#reaction is taking place in bomb calorimeter so no volume change \n",
      "\t#therefore U=Q at constant volume\n",
      "#calculation\n",
      "\t\n",
      "A=U-T*S*0.001 \t\t\t#Energy extracted as heat[KJ/mol]\n",
      "Wmax=A \t\t\t\t#work done [KJ/mol]\n",
      "dn=6-6 \t\t\t\t#change in no. of moles\n",
      "H=U+dn*R*T \t\t\t#Change in enthalpy of the bomb calorimeter[KJ]\n",
      "#Result\n",
      "print\"The energy change that can be extracted as heat is\",round(A),\"KJ/mol\"\n",
      "print\"\\nThe energy change that can be extracted as work is\",round(-A),\"KJ/mol\"\n",
      "print\"\\nThe change in enthalpy of bomb calorimeter is\",round(H),\"KJ/mol\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "C6H12O6(s) + 6O2(g) --> 6CO2(g) + 6H2O(l)\n",
        "The energy change that can be extracted as heat is -2862.0 KJ/mol\n",
        "\n",
        "The energy change that can be extracted as work is 2862.0 KJ/mol\n",
        "\n",
        "The change in enthalpy of bomb calorimeter is -2808.0 KJ/mol\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.16,Page no:87"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#example 5.16\n",
      "\n",
      "#To find the helmholts free energy and Gibbs free energy\n",
      "#Variable declaration\n",
      "print\"C8H18(g)+12.5O2(g)-->8CO2(g)+9H2O(l)\" \n",
      "\n",
      "T=298.0 \t\t\t\t#temperature[K]\n",
      "S=421.5 \t\t\t#change in entropy[J/K]\n",
      "H=-5109000.0 \t\t\t#Heat of reaction[J]\n",
      "R=8.314 \t\t\t#Universal gas constant[J/K/mol]\n",
      "dn=8-(1+12.5) \t\t\t#change in no. of moles\n",
      "#calculation\n",
      "\n",
      "U=H \t\t\t\t#[J]\n",
      "A=U-T*S \t\t\t#Change in helmholts free energy[J]\n",
      "G=A+dn*R*T \t\t\t#Change in Gibbs free energy[J]\n",
      "#Result\n",
      "print\"The change in Helmholts free energy is\",round(A),\"J\"\n",
      "print\"\\nThe change in Gibbs free energy is\",round(G),\"J\"\n",
      "print\"The calculation is not precise in book,that's why a slight change in answer\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "C8H18(g)+12.5O2(g)-->8CO2(g)+9H2O(l)\n",
        "The change in Helmholts free energy is -5234607.0 J\n",
        "\n",
        "The change in Gibbs free energy is -5248234.0 J\n",
        "The calculation is not precise in book,that's why a slight change in answer\n"
       ]
      }
     ],
     "prompt_number": 55
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.17,Page no:88"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#example 5.17\n",
      "#To find the Helmholts free energy and Gibbs free energy\n",
      "print\"C3H6(g)+4.5O2(g)-->3CO2(g)+3H2O(l)\" \n",
      "##Variable declaration\n",
      "S=-339.23 \t\t\t#standard change in entropy [J/K]\n",
      "T=298 \t\t\t\t#temperature[K]\n",
      "Hf1=20.42 \t\t\t#enthalpy of formation of C3H6(g)[J]\n",
      "Hf2=-393.51 \t\t\t#enthalpy of formation of CO2(g)[J]\n",
      "Hf3=-285.83 \t\t\t#enthalpy of formation of H2O(l)[J]\n",
      "dn=3-4.5-1 \t\t\t#change in no. of moles\n",
      "R=8.314 \t\t\t#Universal gas constant[J/K/mol]\n",
      "#calculation\n",
      "\n",
      "H=3*Hf2+3*Hf3-Hf1 \t\t#Enthalpy of the reaction[J]\n",
      "U=H-dn*R*0.001*T \t\t#Change in internal energy of the reaction[J]\n",
      "A=U-T*S*0.001 \t\t\t#Helmholts free energy change[J]\n",
      "G=A+dn*R*0.001*T \t\t#Gibbs free energy change[J]\n",
      "#Result\n",
      "print\"The change in Helmholts free energy is\",round(A,2),\"kJ\"\n",
      "print\"\\nThe change in Gibbs free energy is\",round(G,2),\"kJ\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "C3H6(g)+4.5O2(g)-->3CO2(g)+3H2O(l)\n",
        "The change in Helmholts free energy is -1951.16 kJ\n",
        "\n",
        "The change in Gibbs free energy is -1957.35 kJ\n"
       ]
      }
     ],
     "prompt_number": 56
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.19,Page no:92"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#example 5.19\n",
      "#To find the total entropy change\n",
      "print\"CH4(g)+2O2(g)-->CO2(g)+2H2O(l)\"\n",
      "\n",
      "#Variable declaration\n",
      "S1=-242.98 \t\t\t\t#standard entropy change for the combustion reaction[J/K]\n",
      "Hf1=-74.81 \t\t\t\t#Enthalpy of formation of CH4(g)[KJ/mol]\n",
      "Hf2=-393.51 \t\t\t\t#Enthalpy of formation of CO2(g)[KJ/mol]\n",
      "Hf3=-285.83 \t\t\t\t#Enthalpy of formation of H2O(l)[KJ/mol]\n",
      "T=298 \t\t\t\t\t#temperature[K]\n",
      "#calculation\n",
      "\t \n",
      "H=Hf2+2*Hf3-Hf1 \t\t\t#Change in enthalpy of reaction[KJ]\n",
      "S2=-H*1000/T \t\t\t\t#Change in entropy of the surrounding[J/K]\n",
      "Stotal=(S1+S2)*0.001 \t\t\t#Total entropy change \n",
      "#Result\n",
      "print\"The total change in entropy is\",round(Stotal,2),\"KJ/K\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "CH4(g)+2O2(g)-->CO2(g)+2H2O(l)\n",
        "The total change in entropy is 2.74 KJ/K\n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.20,Page no:93"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#example 5.20\n",
      "#To find the spontanity of the reaction\n",
      "print\"2H2(g)+O2(g)-->2H2O(l)\" \n",
      "##Variable declaration\n",
      "Hf1=-285.83 \t\t\t\t#standard enthalpy of formation of H2O(l)[KJ/mol]\n",
      "S=-327 \t\t\t\t\t#Standard entropy change for the same reaction[J/K]\n",
      "T=298 \t\t\t\t\t#temperature[K]\n",
      "\n",
      "#calculation\n",
      "\t\n",
      "H=2*Hf1-0-0 \t\t\t\t#Enthalpy of the reaction[KJ/mol]\n",
      "G=H-T*S*0.001 \t\t\t\t#Change in Gibbs free energy[KJ]\n",
      "#Result\n",
      "print\"The change in Gibbs free energy is\",round(G,2),\"KJ\\n \"\n",
      "print\"As change in Gibbs free energy is negative.Therefore,the reaction is spontaneous\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "2H2(g)+O2(g)-->2H2O(l)\n",
        "The change in Gibbs free energy is -474.21 KJ\n",
        " \n",
        "As change in Gibbs free energy is negative.Therefore,the reaction is spontaneous\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.21,Page no:94"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#example 5.21\n",
      "\n",
      "\n",
      "#To find the standard enthalpy of reaction \n",
      "print\"CH4(g)+2O2(g)-->CO2(g)+2H2O(l)\" \n",
      "#Variable declaration\n",
      "S=-242.98 \t\t\t#standard entropy change for reaction [J/K]\n",
      "T=298 \t\t\t\t#temperature[K]\n",
      "Gf1=-50.72 \t\t\t#standard Gibbs free energy of formation for CH4(g)[KJ/mol]\n",
      "Gf2=-394.36 \t\t\t#standard Gibbs free energy of formation for CO2(g)[KJ/mol]\n",
      "Gf3=-237.13 \t\t\t#standard Gibbs free energy of formation for H2O(l)[KJ/mol]\n",
      "#calculation\n",
      "\n",
      "G=Gf2+2*Gf3-Gf1 \t\t#Standard Gibbs free energy for reaction[KJ/mol]\n",
      "H=G+T*S*0.001 \t\t\t#Standard enthalpy of reaction [KJ]\n",
      "#Result\n",
      "print\"The standard enthalpy of reaction is\",round(H,2),\"kJ\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "CH4(g)+2O2(g)-->CO2(g)+2H2O(l)\n",
        "The standard enthalpy of reaction is -890.31 kJ\n"
       ]
      }
     ],
     "prompt_number": 57
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.22,Page no:94"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#example 5.22\n",
      "#To find the maximum energy that can be extracted as non-expansion work is equal to the change in free energy of the system\n",
      "print\"C6H12O6(s)+6O2(g)-->6CO2(g)+6H2O(l)\"\n",
      "#Variable declaration\n",
      "mass=25.0 \t\t\t#mass of glucose for combustion under standard condition[gm]\n",
      "T=298 \t\t\t\t#temperature[K]\n",
      "Gf1=-910 \t\t\t#Standard Gibbs free energy of formation for C6H12O6[KJ/mol]\n",
      "Gf2=-394.4 \t\t\t#Standard Gibbs free energy of formation for CO2(g)[KJ/mol]\n",
      "Gf3=-237.13 \t\t\t#Standard Gibbs free energy of formation for H2O(l)[KJ/mol]\n",
      "mol_wt=180.0 \t\t\t#molecular weight of glucose[gm/mol]\n",
      "#calculation\n",
      "\t\n",
      "G=6*Gf2+6*Gf3-Gf1\n",
      "n=mass/mol_wt \t\t\t#no. of moles\n",
      "Gactual=G*n \t\t\t#Gibbs free energy for the combustion of 0.139mol of glucose \n",
      "#Result\n",
      "print\"The energy that can be extracted as non-expansion work is\",round(-Gactual),\"KJ\" \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "C6H12O6(s)+6O2(g)-->6CO2(g)+6H2O(l)\n",
        "The energy that can be extracted as non-expansion work is 400.0 KJ\n"
       ]
      }
     ],
     "prompt_number": 21
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.23,Page no:97"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#example 5.23\n",
      "#To find the value of the inversion temperature for the gas\n",
      "#Variable declaration\n",
      "a=1.39*10**-2 \t\t#constant for a vanderwaal's gas[lit2.atm/mol2]\n",
      "b=3.92*10**-2 \t\t#constant for a vanderwaal's gas[lit2.atm/mol2]\n",
      "R=0.082 \t\t#Universal gas constant[lit.atm/deg/mol]\n",
      "#calculation\n",
      "\t\n",
      "Ti=(2*a)/(R*b) \t\t#inversion temperature [K]\n",
      "#Result\n",
      "print\"The inversion temperature for the gas is\",round(Ti,3),\" K\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The inversion temperature for the gas is 8.649  K\n"
       ]
      }
     ],
     "prompt_number": 58
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.26,Page no:100"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#example 5.26\n",
      "#To find the Enthalpy of vaporization of ethylene\n",
      "#Variable declaration\n",
      "T=169.25 \t\t\t#Boiling point[K]\n",
      "R=8.314 \t\t\t#Universal gas constant[J/K/mol]\n",
      "print\"dlnP/dT=He/R*T**2\" \n",
      "print\"dlnP/dT=(2.303*834.13/T**2)+(1.75/T)-(2.30*8.375*10**-3)\" \n",
      "print\"Therefore using these two equations we calculate the He(enthalpy) of ethylene\" \n",
      "#calculation\n",
      "\n",
      "x=(2.303*834.13/T**2)+(1.75/T)-(2.30*8.375*10**-3) #it is dlnP/dT\n",
      "He=R*0.001*T**2*x #Enthalpy of vaporization[J/mol]\n",
      "#Result\n",
      "print\"\\n\\nThe Enthalpy of vaporization of ethylene at its boiling point is\",round(He,3),\"KJ/mol\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "dlnP/dT=He/R*T**2\n",
        "dlnP/dT=(2.303*834.13/T**2)+(1.75/T)-(2.30*8.375*10**-3)\n",
        "Therefore using these two equations we calculate the He(enthalpy) of ethylene\n",
        "\n",
        "\n",
        "The Enthalpy of vaporization of ethylene at its boiling point is 13.846 KJ/mol\n"
       ]
      }
     ],
     "prompt_number": 59
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.27,Page no:101"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#example 5.27\n",
      "#To find the boiling point of b/enzene at 60KPa\n",
      "\n",
      "#Variable declaration\n",
      "P1=101.3 \t\t\t#Initial Pressure[KPa]\n",
      "P2=60 \t\t\t\t#Final Pressure[KPa]\n",
      "He=31.8 \t\t\t#Enthalpy of vaporization[KJ/mol]\n",
      "R=8.314 \t\t\t#Universal gas constant[J/K/mol]\n",
      "T1=353.2 \t\t\t#boiling point of benzene at 101.3KPa[K]\n",
      "import math\n",
      "#calculation\n",
      "\n",
      "x=(T1**-1)-(R*0.001*math.log(P2/P1)/He) \n",
      "T2=x**-1 \t\t\t#Boiling point of benzene at 60KPa\n",
      "#Result\n",
      "print\"The boiling point of benzene at 60KPa is\",round(T2,1),\"K\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The boiling point of benzene at 60KPa is 336.9 K\n"
       ]
      }
     ],
     "prompt_number": 24
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.28,Page no:101"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#example 5.28\n",
      "\n",
      "#To find the molar enthalpy of vapourization\n",
      "##Variable declaration\n",
      "P1=0.016 \t\t\t#Vapour pressure of pure ethanol at 273K[bar]\n",
      "P2=0.470 \t\t\t#Vapour pressure of pure ethanol at 333K[bar]\n",
      "T1=273 \t\t\t\t#initial temperature [K]\n",
      "T2=333 \t\t\t\t#final temperature[K]\n",
      "R=8.314 \t\t\t#Universal gas constant[J/K/mol]\n",
      "P=1.01 \t\t\t\t#vapour pressure at normal boiling point[bar]\n",
      "#calculation\n",
      "import math\n",
      "\t\n",
      "x=(T2**-1)-(T1**-1) \n",
      "He=-R*0.001*math.log(P2/P1)/x \t#molar enthalpy of vaporization[J/mol]\n",
      "t=(T2**-1)-(R*0.001*math.log(P/P2)/He) \n",
      "T=(t**-1)-273 \t\t\t#normal boiling point [C]\n",
      "#Result\n",
      "print\"\\n\\nThe normal boiling point for pure ethanol is \",round(T,1),\"C\"\n",
      "print\"The molar enthalpy of vapourization is\",round(He,2),\"J/mol\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "The normal boiling point for pure ethanol is  77.4 C\n",
        "The molar enthalpy of vapourization is 42.58 J/mol\n"
       ]
      }
     ],
     "prompt_number": 60
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.29,Page no:102"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#example 5.29\n",
      "\n",
      "#To find the vapour pressure of benzene at 298K\n",
      "#Variable declaration\n",
      "T2=353.2 \t\t\t#normal boiling point of benzene at 1.01325bar[K]\n",
      "T1=298\t \t\t\t#temperature [K]\n",
      "R=8.314 \t\t\t#Universal gas constant[J/K/mol]\n",
      "P2=1.01325 \t\t\t#Vapour pressure of benzene[bar]\n",
      "import math\n",
      "\t#benzene obey's Trouton's rule\n",
      "print\" from Troutons rule , \" \n",
      "print\" He/Tb=85J/K/mol\" \n",
      "#calculation\n",
      "\n",
      "He=85*T2 \t\t\t#molar enthalpy of vapourization[J/K/mol]\n",
      "x=(T2**-1)-(T1**-1) \n",
      "t=-He*x/R \n",
      "P1=P2/math.exp(t) \n",
      "#Result\n",
      "print\"\\nThe vapour pressure of benzene at 298K is\",round(P1,3),\" bar\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " from Troutons rule , \n",
        " He/Tb=85J/K/mol\n",
        "\n",
        "The vapour pressure of benzene at 298K is 0.152  bar\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.30,Page no:111"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#example 5.30\n",
      "#To find the degrees of freedom \n",
      "#Variable declaration\n",
      "c=1 \t\t\t#no. of components(only CO2)\n",
      "p=2 \t\t\t#no. of phases(liquid + gas)\n",
      "#calculation\n",
      "\n",
      "F=c-p+2 \t\t#degree of freedom\n",
      "#Result\n",
      "print\"Degrees of freedom is\",F \n",
      "print\"Degrees of freedom 1 means that either pressure or temperature can be varied independently,i.e.when temperature is fixed,pressure is automatically fixed\" "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Degrees of freedom is 1\n",
        "Degrees of freedom 1 means that either pressure or temperature can be varied independently,i.e.when temperature is fixed,pressure is automatically fixed\n"
       ]
      }
     ],
     "prompt_number": 27
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.31,Page no:111"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#example 5.31\n",
      "\n",
      "#To find the values of degrees of freedom\n",
      "#Variable declaration\n",
      "c=1 \t\t\t#no. of components\n",
      "p=1 \t\t\t#no. of phases\n",
      "#calculation\n",
      "\n",
      "F=c-p+2 \t\t#Degrees of freedom\n",
      "#Result\n",
      "print\"Degrees of freedom,F is\",F \n",
      "print\"Degrees of freedom 2 means both the pressure and temperature can be varied independently\" \n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Degrees of freedom,F is 2\n",
        "Degrees of freedom 2 means both the pressure and temperature can be varied independently\n"
       ]
      }
     ],
     "prompt_number": 61
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.32,Page no:113"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#example 5.32\n",
      "\n",
      "#To find the mole fraction of sucrose,so that the vapour pressure of water will be lowered by dP\n",
      "#Variable declaration\n",
      "P=1.75*10**-5 \t\t\t#Vapour pressure of pure water at 293K[torr]\n",
      "dP=1.1*10**-7 \t\t\t#Lowering in vapour pressure of water\n",
      "#calculation\n",
      "\n",
      "x=dP/P \t\t\t\t#mole fraction of sucrose\n",
      "#Result\n",
      "print\"The mole fraction of sucrose is\",round(x,6) \n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The mole fraction of sucrose is 0.006286\n"
       ]
      }
     ],
     "prompt_number": 30
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.33,Page no:114"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#example 5.33\n",
      "\n",
      "#To find the partial vapour pressure of benzene over the solution\n",
      "#Variable declaration\n",
      "P=94.6 \t\t\t\t#The vapour pressure of pure benzene at 298K[torr]\n",
      "n1=20.0 \t\t\t\t#no. of moles of pure benzene\n",
      "n2=5.0 \t\t\t\t#no. of moles of pure naphthalene\n",
      "#calculation\n",
      "\n",
      "x=n1/(n1+n2) \t\t\t#(mole fraction of benzene)\n",
      "p=x*P \t\t\t\t#the partial vapour pressure of benzene[torr]\n",
      "#Result\n",
      "print\"The partial vapour pressure of benzene is\",p,\"torr\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The partial vapour pressure of benzene is 75.68 torr\n"
       ]
      }
     ],
     "prompt_number": 31
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.34,Page no:114"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#example 5.34\n",
      "#To find the reduction in chemical potential\n",
      "#Variable declaration\n",
      "x=0.28 \t\t\t\t#mole fraction of solute\n",
      "R=8.314 \t\t\t#Universal gas constant[J/K/mol]\n",
      "T=298 \t\t\t\t#temperature[K]\n",
      "import math\n",
      "#calculation\n",
      "\n",
      "du=R*T*math.log(1-x) \t\t#reduction in chemical potential[J/mol]\n",
      "#Result\n",
      "print\"The reduction in chemical potential is\",round(-du,1),\"J/mol\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The reduction in chemical potential is 813.9 J/mol\n"
       ]
      }
     ],
     "prompt_number": 32
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.35,Page no:116"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#example 5.35\n",
      "#To find the boiling point of the solution which is made by dissolving 155g of glucose in 1000g of water\n",
      "#Variable declaration\n",
      "Kb=0.51 \t\t\t#ebullioscopic constant of water [K*Kg/mol]\n",
      "n=155.0/180.0 \t\t\t#no. of moles of glucose\n",
      "m=n/1 \t\t\t\t#[mol/Kg]\n",
      "Ti=373.0 \t\t\t\t#Boiling point temperature of water[K]\n",
      "#calculation\n",
      "\n",
      "Tf=(Ti+Kb*m)-273 \t\t#boiling point temperature of the solution[C]\n",
      "#Result\n",
      "print\"The boiling point of the solution is\",round(Tf,2),\"degree C\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The boiling point of the solution is 100.44 degree C\n"
       ]
      }
     ],
     "prompt_number": 62
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.36,Page no:117"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#example 5.36\n",
      "\n",
      "#To find the molar mass of solute(M2)\n",
      "#Variable declaration\n",
      "Ti=5.44 #freezing point of pure benzene[K]\n",
      "Tf=4.63 #freezing point of solution[K]\n",
      "m1=2.12 #mass of the solute[gm]\n",
      "m2=125.0 #mass of the benzene[gm]\n",
      "Kf=5.12 #cryoscopic constant of pure benzene[K*Kg/mol]\n",
      "#calculation\n",
      "\n",
      "dTf=Ti-Tf \t#depression in freezing point[K]\n",
      "M2=(m1*1000*Kf)/(m2*dTf) #molar mass of solute\n",
      "#Result\n",
      "print\"The molar mass of solute is\",round(M2),\"(approx)\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The molar mass of solute is 107.0 (approx)\n"
       ]
      }
     ],
     "prompt_number": 65
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.38,Page no:124"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#example 5.38\n",
      "#To find the Kp value of the above reaction\n",
      "print\"N2(g)+3H2(g)<=>2NH3(g)\"\n",
      "#Variable declaration\n",
      "T=298 \t\t\t#Temperature[K]\n",
      "Gf1=-16450 \t\t#Gibb's free energy of formation for NH3(g)[J/mol]\n",
      "R=8.314 \t\t#Universal gas constant[J/K/mol]\n",
      "import math\t\n",
      "#calculation\n",
      "\t\n",
      "Gf=2*Gf1\t\t\t#Gibb's free energy for the reaction[KJ]\n",
      "x=Gf/R/T\n",
      "Kp=math.exp(-x) \n",
      "#Result\n",
      "print\"The Kp for above reaction is\",round(Kp),\"or 5.85*10^5,in scientific notation(APPROX)\" "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "N2(g)+3H2(g)<=>2NH3(g)\n",
        "The Kp for above reaction is 584861.0 or 5.85*10^5,in scientific notation(APPROX)\n"
       ]
      }
     ],
     "prompt_number": 66
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.39,Page no:124"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#example 5.39\n",
      "#To find the reaction Gibb's energy\n",
      "print\"0.5N2(g)+1.5H2(g)<=>NH3(g)\" \n",
      "#Variable declaration\n",
      "T=298 #Temperature[K]\n",
      "Kp=900 #Equilibrium constant for above reaction\n",
      "P1=0.32 #partial pressure of N2(g)[bar]\n",
      "P2=0.73 #partial pressure of H2(g)[bar]\n",
      "P3=0.98 #partial pressure of NH3(g)[bar]\n",
      "R=8.314 #Universal gas constant[J/K/mol]\n",
      "import math\n",
      "#calculation\n",
      "\n",
      "G=-R*T*math.log(Kp) \n",
      "x=(P1**0.5)*(P2**1.5) \n",
      "p=P3/x \n",
      "Gr=(G+R*T*math.log(p))*0.001 \n",
      "#Result\n",
      "print\"The reaction Gibbs free energy is\",round(Gr*1000),\"J/mol \""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "0.5N2(g)+1.5H2(g)<=>NH3(g)\n",
        "The reaction Gibbs free energy is -14322.0 J/mol \n"
       ]
      }
     ],
     "prompt_number": 37
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.40,Page no:125"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#example 5.40\n",
      "#To find the Kp at 423K temperature\n",
      "print\"N2(g)+3H2(g)<=>2NH3(g)\"\n",
      "\n",
      "#Variable declaration\n",
      "Kp1=5.85*10**5 #equilibrium constant at 298K\n",
      "H1=-46.11 #standard enthalpy of formation of NH3(g)[KJ/mol]\n",
      "T1=298 #Initial temperature[K]\n",
      "T2=423 #Final temperature[K]\n",
      "R=8.314 #Universal gas constant[J/K/mol]\n",
      "#calculation\n",
      "import math\n",
      "\n",
      "H=2*H1 #enthalpy for reaction [KJ]\n",
      "t=(T1**-1)-(T2**-1) \n",
      "x=-H*t/(R*0.001) \n",
      "Kp2=Kp1*math.exp(x) \n",
      "#Result\n",
      "print\"The Equilibrium constant for reaction  at 423K is\",round(Kp2) \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "N2(g)+3H2(g)<=>2NH3(g)\n",
        "The Equilibrium constant for reaction  at 423K is 35004905509.0\n"
       ]
      }
     ],
     "prompt_number": 38
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.41,Page no:128"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#example 5.41\n",
      "#To find the Standard Free energy and equilibrium constant \n",
      "print\"Zn(s)|ZnCl2(aq)||CdSO4(aq)|Cd(s)\"\n",
      "#For Zn(s)|ZnCl2(aq)||CdSO4(aq)|Cd(s)\n",
      "#Variable declaration\n",
      "T=298.0 \t\t\t#Temperature[K]\n",
      "R=8.314 \t\t#Universal gas constant[J/K/mol]\n",
      "E1=-0.7618 \t\t#Standard electrode potential for Zn2+/Zn [volts]\n",
      "E2=-0.403 \t\t#Standard electrode potential for Cd2+/Cd [volts]\n",
      "F=96500.0 \t\t#Faraday's constant[coulomb/mol]\n",
      "n=2.0 \t\t\t#no. of electrons balancing\n",
      "\n",
      "Ei=E2-E1 \t\t#Standard potential for the reaction[volts]\n",
      "#calculation\n",
      "import math\n",
      "Gi=-n*F*Ei \t\t#Standard Gibb's Free Energy [KJ/mol] \n",
      "Ki=math.exp(-Gi/R/T) \t#Equilibrium constant\n",
      "#Result\n",
      "print\"The Free energy for the rection is\",Gi*0.001,\"KJ/mol\"\n",
      "print\"The value of equilibrium constant is\",Ki \n",
      "\n",
      "#To find the standard free energy and equilibrium constant\n",
      "#Variable declaration\n",
      "print\"Cd(s)|CdSO4(aq),Hg2SO4(s)|Hg(l)\" \n",
      "#For Cd(s)|CdSO4(aq),Hg2SO4(s)|Hg(l)\n",
      "E3=0.6141 \t\t#Standard electrode potential for Hg2SO4(s),SO4^2-/Hg(l) [volts]\n",
      "#calculation\n",
      "\n",
      "Eii=E3-E2 \t\t#Standard potantial for the reaction[volts]\n",
      "Gii=-n*F*Eii \t\t#Standard Gibb's free energy[KJ/mol]\n",
      "Kii=math.exp(-Gii/R/T) \t#Equilibrium constant\n",
      "#Result\n",
      "print\"The Free energy for the rection is\",round(Gii*0.001,1),\"KJ/mol\"\n",
      "print\"The value of equilibrium constant is\",Kii\n",
      "print\"PLEASE REDO the last line calculation,It is showing wrong result in my PC\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Zn(s)|ZnCl2(aq)||CdSO4(aq)|Cd(s)\n",
        "The Free energy for the rection is -69.2484 KJ/mol\n",
        "The value of equilibrium constant is 1.37586809667e+12\n",
        "Cd(s)|CdSO4(aq),Hg2SO4(s)|Hg(l)\n",
        "The Free energy for the rection is -196.3 KJ/mol\n",
        "The value of equilibrium constant is 2.56773255559e+34\n",
        "PLEASE REDO the last line calculation,It is showing wrong result in my PC\n"
       ]
      }
     ],
     "prompt_number": 39
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.42,Page no:130"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#example 5.42\n",
      "#To find the overall e.m.f of the above cell\n",
      "#Variable declaration\n",
      "print\"Zn(s)|ZnCl2(soln)||AgCl(s)|Ag-Ag|AgCl(s)|ZnCl2(soln)|Zn(s)\" \n",
      "\n",
      "m1=0.02 \t\t\t#concentration[M]\n",
      "Y1=0.65 \t\t\t#mean ionic activity coefficient\n",
      "m2=1.5 \t\t\t\t#concentration[M]\n",
      "Y2=0.29 \t\t\t#mean ionic activity coefficient \n",
      "R=8.314 \t\t\t#Universal gas constant[J/K/mol]\n",
      "T=298 \t\t\t\t#Temperature [K]\n",
      "F=96500 \t\t\t#Faraday's constant[coulomb/mol]\n",
      "import math\n",
      "#calculation\n",
      "\t\n",
      "E=R*T*(math.log(m2*Y2/m1/Y1))*3/2/F \t#[volts]\n",
      "#Result\n",
      "print\"The overall e.m.f of the cell is\",round(E,4),\"volt\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Zn(s)|ZnCl2(soln)||AgCl(s)|Ag-Ag|AgCl(s)|ZnCl2(soln)|Zn(s)\n",
        "The overall e.m.f of the cell is 0.1352 volt\n"
       ]
      }
     ],
     "prompt_number": 67
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.43,Page no:131"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#example 5.43\n",
      "#To find the e.m.f of the cell\n",
      "#Variable declaration\n",
      "print\"H2(g,1atm)|HCl(aq)|HCl(aq)|H2(g,1atm)\" \n",
      "m1=0.02 \t\t\t#concentration[M]\n",
      "Y1=0.88 \t\t\t#mean ionic activity coefficient\n",
      "m2=1 \t\t\t\t#concentration[M]\n",
      "Y2=0.81 \t\t\t#mean ionic activity coefficient\n",
      "R=8.314 \t\t\t#universal gas constant[J/K/mol]\n",
      "T=298 \t\t\t\t#Temperature[K]\n",
      "F=96487 \t\t\t#Faraday's constant[coulombs/mol]\n",
      "t=0.178 \t\t\t#Tranference number of Cl-1\n",
      "import math\n",
      "#calculation\n",
      "\n",
      "E=-2*t*R*T*(math.log(m1*Y1/m2/Y2))/F \t#e.m.f of the cell[volts]\n",
      "#Result\n",
      "print\"The e.m.f of the cell is\",round(E,3),\" volts\" \n",
      "print\"\\nWrongly calculated in book as 0.351 volt\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "H2(g,1atm)|HCl(aq)|HCl(aq)|H2(g,1atm)\n",
        "The e.m.f of the cell is 0.035  volts\n",
        "\n",
        "Wrongly calculated in book as 0.351 volt\n"
       ]
      }
     ],
     "prompt_number": 41
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.44,Page no:133"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#example 5.44\n",
      "\n",
      "#To find the values of dG,dS and dH\n",
      "print\"The values for reaction that goes on within the cadmium cell\" \n",
      "#Variable declaration\n",
      "n=2 \t\t\t#no. of moles\n",
      "E=1.01463 \t\t#standard cadmium cell potential[volts]\n",
      "d=-5*10**-5 \t\t#i.e d=dE/dT[V/K]\n",
      "F=96500 \t\t#[coulomb/mol]\n",
      "T=298 \t\t\t#Temperature [K]\n",
      "#calculation\n",
      "\n",
      "dG=-n*E*F \t\t#Change in Gibb's free energy[J]\n",
      "dS=n*F*d \t\t#Change in entropy [J/K]\n",
      "dH=dG+T*dS \t\t#change in enthalpy[J]\n",
      "#Result\n",
      "print\" dG=\",dG,\"J\\nWrongly calculated in book as -195815 J\"\n",
      "print\"\\n dS=\",dS,\"J/K\"\n",
      "print\"\\n dH=\",dH,\"J\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The values for reaction that goes on within the cadmium cell\n",
        " dG= -195823.59 J\n",
        "Wrongly calculated in book as -195815 J\n",
        "\n",
        " dS= -9.65 J/K\n",
        "\n",
        " dH= -198699.29 J\n"
       ]
      }
     ],
     "prompt_number": 68
    }
   ],
   "metadata": {}
  }
 ]
}