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
|
{
"metadata": {
"name": "ch4_2",
"signature": "sha256:8185298e7063d37f738c422b0f9a0946dd677189cdf544f54e436d8d650cb521"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": [
"Chapter 4 : The Secomd Law and Its Applications"
]
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 4.1 Page Number : 148"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
" \n",
"import math\n",
"\n",
"# Variables\n",
"n = 1000.;\t\t\t#[mol]\n",
"T = 400.;\t\t\t#[K]\n",
"P_1 = 100.;\t\t\t#[kPa]\n",
"P_2 = 1000.;\t\t\t#[kPa]\n",
"R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
"\n",
"# Calculations and Results\n",
"\t\t\t#(a)\n",
"T_surr = 400.;\t\t\t#[K] - surrounding temperature\n",
"\t\t\t# Total change in entropy of the system is given by\n",
"\t\t\t# delta_S_sys = n*(Cp_0*math.log(T_2/T_1) - R*math.log(P_2/P_1))\n",
"\t\t\t# The process being isothermal the first term is zero and the total entropy change of the system is\n",
"delta_S_sys_a = - n*R*math.log(P_2/P_1);\t\t\t#[J/K]\n",
"delta_S_sys_a = delta_S_sys_a*10**(-3);\t\t\t#[kJ/K]\n",
"\n",
"\t\t\t# Since the process is reversible therefore\n",
"Q_sys = T_surr*delta_S_sys_a;\t\t\t#[kJ] - Heat change in the system\n",
"\n",
"Q_surr = - Q_sys;\t\t\t#[kJ] - Heat change in the surrounding\n",
"delta_S_surr_a = Q_surr/T_surr;\t\t\t#[kJ/K]\n",
"\n",
"delta_S_univ_a = delta_S_sys_a + delta_S_surr_a;\t\t\t#[kJ/K]\n",
"\t\t\t# We get delta_S_univ = 0, which is true for a reversible process\n",
"\n",
"print \" a).The entropy change of the gas is given by delta_S_sys = %f kJ/K \"%(delta_S_sys_a);\n",
"print \" The entropy change of the surrounding is delta_S_surr = %f kJ/K \"%(delta_S_surr_a);\n",
"print \" The total entropy change of the gas is delta_S_univ = %f kJ/K \"%(delta_S_univ_a);\n",
"\n",
"\t\t\t#(b)\n",
"T_surr_b = 300.;\t\t\t#[K] - surrounding temperature\n",
"\n",
"delta_S_sys_b = delta_S_sys_a;\n",
"\n",
"\t\t\t# Work done under reversible condition is given by\n",
"\t\t\t# W = integral(P*dV) = integral(((R*T)/V)*dV) = R*T*math.log(V_2/V_1)\n",
"\t\t\t# For ideal gas we have, P1*V1/T1 = P2*V2/T2 or, V2/V1 = P1/P2 (for isothermal conditions)\n",
"W = R*T*math.log(P_1/P_2);\t\t\t#[J/mol]\n",
"W = W*10**(-3);\t\t\t#[kJ/mol]\n",
"\n",
"W = W*(120./100);\t\t\t#[kJ/mol]\n",
"W = W*n;\t\t\t#[kJ] - Total work done for n moles\n",
"\n",
"\t\t\t# Using the first law we have delta_U = Q - W. Now under isothermal conditions for ideal gas, delta_U = 0. Therefore,\n",
"Q = -W;\n",
"\n",
"\t\t\t# Since heat is gained by the surroundings therefore\n",
"delta_S_surr_b = Q/T_surr_b;\t\t\t#[kJ/K]\n",
"\n",
"delta_S_univ_b = delta_S_sys_b + delta_S_surr_b;\t\t\t#[kJ/K]\n",
"\n",
"print \" b).The entropy change of the gas is given by delta_S_sys = %f kJ/K \"%(delta_S_sys_b);\n",
"print \" The entropy change of the surrounding is delta_S_surr = %f kJ/K \"%(delta_S_surr_b);\n",
"print \" The total entropy change of the gas is delta_S_univ = %f kJ/K \"%(delta_S_univ_b);\n",
"\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" a).The entropy change of the gas is given by delta_S_sys = -19.143692 kJ/K \n",
" The entropy change of the surrounding is delta_S_surr = 19.143692 kJ/K \n",
" The total entropy change of the gas is delta_S_univ = 0.000000 kJ/K \n",
" b).The entropy change of the gas is given by delta_S_sys = -19.143692 kJ/K \n",
" The entropy change of the surrounding is delta_S_surr = 30.629908 kJ/K \n",
" The total entropy change of the gas is delta_S_univ = 11.486215 kJ/K \n"
]
}
],
"prompt_number": 1
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 4.2 Page Number : 148"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
" \n",
"# Variables\n",
"T = 400.;\t\t\t#[K] - Temperature\n",
"P_1 = 500.*10**(3);\t\t\t#[Pa] - Initial pressure\n",
"P_2 = 100.*10**(3);\t\t\t#[Pa] - Final pressure\n",
"V_1 = 750.*10**(-6);\t\t\t#[m**(3)] - Initial volume\n",
"W_actual = 0.55*10**(3);\t\t\t#[J] - Actual work done\n",
"R = 8.314;\t\t\t#[J/mol*K] - Universal fas constant\n",
"\n",
"# Calculations\n",
"\t\t\t# Suppose that the surroundings are at 400 K.\n",
"\n",
"\t\t\t# The number of moles is given by\n",
"n = (P_1*V_1)/(R*T);\t\t\t#[mol]\n",
"\t\t\t# The entropy change of ideal gas under isothermal condition is given by\n",
"delta_S_sys = - n*R*math.log(P_2/P_1);\t\t\t#[J/mol]\n",
"\n",
"\t\t\t# The heat supplied to the system in the internally reversible process is\n",
"Q_theot = T*delta_S_sys;\t\t\t#[J]\n",
"\t\t\t# Since the process is isothermal therefore, workdone is given by\n",
"W_theot = Q_theot;\t\t\t#[J] - Theoritical work done\n",
"\t\t\t# Since actual work done by the gas is 0.55 kJ therefore actual heat supplied is also 0.55 kJ because under isothermal conditions delta_U = 0\n",
"Q_actual = W_actual;\n",
"\n",
"# Results\n",
"\t\t\t# Since Q_theot > Q_actual, so the process is irreversible\n",
"print \" Since Q_theot = %f J is greater than Q_actual = %f J\"%(Q_theot,Q_actual);\n",
"print \" Therefore, the process is internally irreversible\"\n",
"\n",
"\n",
"\t\t\t# delta_S_sys = Q/T_b + S_gen\n",
"S_gen = delta_S_sys - (Q_theot/T);\t\t\t#[J/K]\n",
"\t\t\t# The entropy generated may be due to friction and other dissipayive effects or due to non-quasi-static expansion\n",
"\n",
"\n",
"\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" Since Q_theot = 603.539217 J is greater than Q_actual = 550.000000 J\n",
" Therefore, the process is internally irreversible\n"
]
}
],
"prompt_number": 2
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 4.3 Page Number : 150"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
" \n",
"R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
"\t\t\t# For side A\n",
"V_A = 1;\t\t\t#[L] - Volume\n",
"V_A = V_A*10**(-3);\t\t\t#[m**(3)]\n",
"T_A = 300;\t\t\t#[K] - Temperature\n",
"P_A = 2;\t\t\t#[atm] - Pressure\n",
"P_A = P_A*101325;\t\t\t#[Pa]\n",
"\n",
"\t\t\t# For side B\n",
"V_B = 1;\t\t\t#[L] - volume\n",
"V_B = V_B*10**(-3);\t\t\t#[m**(3)]\n",
"T_B = 300;\t\t\t#[K] - Temperature\n",
"P_B = 1;\t\t\t#[atm] - Pressure\n",
"P_B = P_B*101325;\t\t\t#[Pa]\n",
"\n",
"# Calculations and Results\n",
"\t\t\t# From first law final temperature and pressure are given by (example 3.30)\n",
"\t\t\t# T = ((n_A*T_A) + (n_B*T_B))/(n_A + n_B)\n",
"\t\t\t# P = ((P_A*V_A) + (P_A*V_B))/(V_A + V_B)\n",
"\n",
"\t\t\t# Since in this case T_A = T_B, therefore final pressure is given by\n",
"P = ((P_A*V_A) + (P_B*V_B))/(V_A + V_B);\t\t\t#[Pa]\n",
"P = P/101325;\t\t\t#[atm]\n",
"\n",
"print \" The final temperature is %f K\"%(T_A);\n",
"print \" The final pressure is %f atm\"%(P);\n",
"\n",
"\t\t\t# The number of moles of air on each side are\n",
"n_A = (P_A*V_A)/(R*T_A);\t\t\t#[mol]\n",
"n_B = (P_B*V_B)/(R*T_B);\t\t\t#[mol]\n",
"\n",
"delta_S_A = -n_A*R*math.log((P*101325)/P_A);\t\t\t#[J/K] - Entropy change on side A\n",
"delta_S_B = -n_B*R*math.log((P*101325)/P_B);\t\t\t#[J/K] - Entropy change on side B\n",
"delta_S_sys = delta_S_A + delta_S_B;\t\t\t#[J/K] - Total entropy change of system\n",
"\n",
"\t\t\t# Since the system is insulated there is no heat exchange with the surroundings, therefore entropy change of surrounding is zero\n",
"delta_S_surr = 0;\t\t\t#[J/K]\n",
"delta_S_univ = delta_S_sys + delta_S_surr;\t\t\t#[J/K]\n",
"print \" The total increase in entropy is %f J/K\"%(delta_S_univ);\n",
"\n",
"\t\t\t# The entropy change of the system can also be writtten as\n",
"\t\t\t# delta_s_sys = Q/T_b + S_gen\n",
"\t\t\t# Since there is no heat transfer, therefore\n",
"S_gen = delta_S_univ;\t\t\t#[J/K]\n",
"\t\t\t# The process is reversible because of entropy generation due to spontaneous release of piston.\n",
"\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" The final temperature is 300.000000 K\n",
" The final pressure is 1.500000 atm\n",
" The total increase in entropy is 0.057383 J/K\n"
]
}
],
"prompt_number": 3
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 4.4 Page Number : 151"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
" \n",
"V_vessel = 0.2;\t\t\t#[m**(3)] - Volume of the vessel\n",
"P_1 = 10;\t\t\t#[bar] - Initial pressure inside the vessel\n",
"P_1 = P_1*10**(5);\t\t\t#[Pa]\n",
"P_2 = 3.5;\t\t\t#[bar] - Final pressure inside the vessel\n",
"P_2 = P_2*10**(5);\t\t\t#Pa\n",
"T_1 = 250 + 273.15;\t\t\t#[K] - Initial temperature of the vesssel\n",
"R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
"\n",
"# Calculations and Results\n",
"\t\t\t# (a)\n",
"\t\t\t# At 10 bar and 250 C the steam is superheated. From steam table as reported in book we have\n",
"V_1 = 0.2327;\t\t\t#[m**(3)/kg] - specific volume\n",
"U_1 = 2709.9;\t\t\t#[kJ/kg] - specific internal energy\n",
"H_1 = 2942.6;\t\t\t#[kj/kg] - Specific enthalpy\n",
"S_1 = 6.9247;\t\t\t#[kJ/kg-K] - Specific entropy\n",
"\t\t\t# the quantity of steam is given by\n",
"m = V_vessel/V_1;\t\t\t#[kg]\n",
"\n",
"\t\t\t# At final state \n",
"V_2 = 0.2327;\t\t\t#[m**(3)/kg] - Molar volume\n",
"V_liq_2 = 0.001079;\t\t\t# [m**(3)/kg]\n",
"V_vap_2 = 0.5243;\t\t\t# [m**(3)/kg]\n",
"\t\t\t# Since overall volume lies between saturated liquid and saturated vapour therefore the steam is saturated and its dryness fraction at final state is given by\n",
"x = (V_2 - V_liq_2)/(V_vap_2 - V_liq_2);\n",
"\t\t\t# Final temperature = T_sat (at 3 bar) from steam table\n",
"T_final = 138.88;\t\t\t#[C]\n",
"\n",
"\t\t\t# At 3.5 bar saturated conditions \n",
"S_liq = 1.7275;\t\t\t#[kJ/kg-K] - Entropy of saturated liquid\n",
"S_vap = 6.9405;\t\t\t#[kJ/kg-K] - Entropy of saturated vapour\n",
"U_liq = 583.95;\t\t\t#[kJ/kg] - Internal energy of saturated liquid\n",
"U_vap = 2548.9;\t\t\t#[kJ/kg] - Internal energy of saturated vapour\n",
"\t\t\t# Therefore at final state \n",
"U_2 = U_liq*(1 - x) + x*U_vap;\t\t\t#[kJ/kg]\n",
"S_2 = S_liq*(1 - x) + x*S_vap;\t\t\t#[kJ/kg-K]\n",
"Q_1 = m*(U_2 - U_1);\t\t\t#[kJ]\n",
"delta_S_1 = m*(S_2 - S_1);\t\t\t#[kJ/kg-K]\n",
"\n",
"print \" a).The final temperature is %f C\"%(T_final);\n",
"print \" The amount of heat transfer is %f kJ\"%(Q_1);\n",
"print \" The change of entropy is %f kJ/kg-K\"%(delta_S_1);\n",
"\n",
"\t\t\t# (b)\n",
"Y = 1.4;\t\t\t# Ratio of heat capacities for air\n",
"\t\t\t# (P_1*V_1)/T_1 = (P_2*V_2)/T_2 and since V_1 = V_2\n",
"T_2 = (P_2/P_1)*T_1;\t\t\t#[K]\n",
"\n",
"\t\t\t# Since the volume is fixed therefore work done (W) = 0 and from first law we get\n",
"\t\t\t# Q = delta_U = n*Cv_0*(T_2 - T_1)\n",
"Cv_0 = R/(Y - 1);\t\t\t#[J/mol-K] - Heat capacity at constant volume\n",
"Cp_0 = (Y*R)/(Y - 1);\t\t\t#[J/mol-K] - Heat capacity at constant pressure\n",
"n = (P_1*V_vessel)/(R*T_1);\t\t\t#[mol] - No. of moles\n",
"Q_2 = n*Cv_0*(T_2 - T_1);\t\t\t#[J] - Heat change\n",
"Q_2 = Q_2*10**(-3);\t\t\t#[kJ]\n",
"\n",
"delta_S_2 = Cp_0*math.log(T_2/T_1) - R*math.log(P_2/P_1);\t\t\t#[J/mol-K]\n",
"delta_S_2 = n*delta_S_2*10**(-3);\t\t\t#[kJ/K]\n",
"\n",
"print \" b).The final temperature is %f C\"%(T_2);\n",
"print \" The amount of heat transfer is %f kJ\"%(Q_2);\n",
"print \" The change of entropy is %f kJ/K\"%(delta_S_2);\n",
"\n",
"\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" a).The final temperature is 138.880000 C\n",
" The amount of heat transfer is -1079.587621 kJ\n",
" The change of entropy is -2.483450 kJ/kg-K\n",
" b).The final temperature is 183.102500 C\n",
" The amount of heat transfer is -325.000000 kJ\n",
" The change of entropy is -1.003366 kJ/K\n"
]
}
],
"prompt_number": 4
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 4.5 Page Number : 153"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
" \n",
"from math import *\n",
"# Variables\n",
"m = 1000.;\t\t\t#[g] - Mass of fluid\n",
"P_1 = 20.;\t\t\t#[bar] - Initial pressure\n",
"P_1 = P_1*10.**(5);\t\t\t#[Pa]\n",
"P_2 = 2;\t\t\t#[bar] - Final pressure\n",
"P_2 = P_2*10.**(5);\t\t\t#Pa\n",
"T_1 = 250 + 273.15;\t\t\t#[K] - Initial temperature\n",
"n = 1.25;\n",
"R = 8.314;\t\t\t#[J/mol*-] - Universal gas constant\n",
"Y = 1.4;\t\t\t# Index of expansion\n",
"Cv_0 = R/(Y- 1);\t\t\t#[J/mol-K]\n",
"Cp_0 = R + Cv_0;\t\t\t#[J/mol-K]\n",
"\n",
"# Calculations and Results\n",
"\t\t\t#(a)\n",
"\t\t\t# For steam at 20 bar and 250 C, from steam table as reported in the book\n",
"V_1 = 0.11144;\t\t\t#[m**(3)/kg]\n",
"U_1 = 2679.6;\t\t\t#[kJ/kg]\n",
"S_1 = 6.5453;\t\t\t#[kJ/kg-K]\n",
"\t\t\t# P_1*V_1**(n) = P_2*V_2**(n)\n",
"V_2 = ((P_1*V_1**(n))/P_2)**(1/n);\t\t\t#[m**(3)/kg]\n",
"\n",
"\t\t\t# At 2 bar under saturated conditions,from steam table as reported in the book\n",
"V_liq = 0.001061;\t\t\t#[m**(3)/kg]\n",
"V_vap = 0.8857;\t\t\t#[m**(3)/kg]\n",
"x = (V_2 - V_liq)/(V_vap - V_liq);\t\t\t# Dryness fraction\n",
"T_sat = 120.23;\t\t\t#[C] - The final temperature\n",
"U_liq = 504.49;\t\t\t#[kJ/kg] - Internal energy of saturate liquid\n",
"U_vap = 2529.5;\t\t\t#[kJ/kg] - Internal energy of saturate vapour\n",
"\t\t\t# Therefore, internal energy at state 2 is given by\n",
"U_2 = U_liq*(1 - x) + x*U_vap;\t\t\t#[kJ/kg]\n",
"\n",
"\t\t\t# Work transfer is given by\n",
"W = (P_1*V_1 - P_2*V_2)/(n - 1);\t\t\t#[J/kg]\n",
"W = W*10**(-3);\t\t\t#[kJ/kg]\n",
"delta_U = U_2 - U_1;\t\t\t#[kJ/kg]\n",
"\n",
"\t\t\t# From first law, q - W = delta_U\n",
"q = W + delta_U;\t\t\t#[kJ/kg]\n",
"\n",
"\t\t\t# At final state (2 bar saturated), as reported in the book\n",
"S_liq = 1.5301;\t\t\t#[kJ/kg-K] - Entropy of saturated liquid\n",
"S_vap = 7.1271;\t\t\t#[kJ/kg-K] - Entropy of saturated vapour\n",
"\t\t\t# Therefore, entropy at state 2 is given by\n",
"S_2 = S_liq*(1 - x) + x*S_vap;\t\t\t#[kJ/kg-K]\n",
"delta_S = S_2 - S_1;\t\t\t#[kJ/kg-K]\n",
"\n",
"print \" a).The final temperature is %f C\"%(T_sat);\n",
"print \" The work done is equal to %f kJ/kg\"%(W);\n",
"print \" The heat change is equal to %f kJ/kg\"%(q);\n",
"print \" The entropy change is equal to %f kJ/kg-K\"%(delta_S);\n",
"\n",
"\t\t\t#(b)\n",
"\t\t\t# P*V**(n) = constant\n",
"\t\t\t# Since the gas behaves as ideal we can write\n",
"\t\t\t# P_1**(1-n)*T_1**(n) = P_2**(1-n)*T_2**(n)\n",
"T_2 = T_1*(P_1/P_2)**((1-n)/n);\t\t\t#[K]\n",
"\n",
"\t\t\t# Molar volume is given by\n",
"V_2_1 = (R*T_1)/P_1;\t\t\t#[m**(3)/mol] - At state 1\n",
"V_2_2 = (R*T_2)/P_2;\t\t\t#[m**(3)/mol] - At state 2\n",
"\n",
"\t\t\t# Work transfer is given by\n",
"w_2 = ((P_1*V_2_1) - (P_2*V_2_2))/(n-1);\t\t\t#[J/mol]\n",
"Mol_wt_air = 0.21*32 + 0.79*28;\t\t\t#[g/mol] - Molecular weight of air\n",
"n_mole = m/Mol_wt_air;\n",
"\t\t\t# Total work transfer is given by\n",
"W_2 = w_2*n_mole*10**(-3);\t\t\t#[kJ]\n",
"\t\t\t# Internal energy change is given by\n",
"delta_U = n_mole*Cv_0*(T_2 - T_1)*10**(-3);\t\t\t#[kJ]\n",
"\n",
"\t\t\t# Heat transfer is given by\n",
"Q = W_2 + delta_U;\t\t\t#[kJ]\n",
"\n",
"\t\t\t# Entropy change is given by\n",
"delta_S_2 = Cp_0*log(T_2/T_1) - R*log(P_2/P_1);\t\t\t#[J/mol-K]\n",
"delta_S_2 = delta_S_2*n_mole;\t\t\t#[J/mol]\n",
"\n",
"print \" b).The final temperature is %f C\"%(T_2);\n",
"print \" The work done is equal to %f kJ/kg\"%(W_2);\n",
"print \" The total heat change is equal to %f kJ\"%(Q);\n",
"print \" The entropy change is equal to %f J/kg-K\"%(delta_S_2);\n",
"\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" a).The final temperature is 120.230000 C\n",
" The work done is equal to 329.008908 kJ/kg\n",
" The heat change is equal to -238.988250 kJ/kg\n",
" The entropy change is equal to -0.573241 kJ/kg-K\n",
" b).The final temperature is 330.085335 C\n",
" The work done is equal to 222.626855 kJ/kg\n",
" The total heat change is equal to 83.485071 kJ\n",
" The entropy change is equal to 199.136884 J/kg-K\n"
]
}
],
"prompt_number": 4
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 4.6 Page Number : 154"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
" \n",
"# Variables\n",
"m = 1000;\t\t\t#[g] - Mass of fluid\n",
"P_1 = 20;\t\t\t#[bar] - Initial pressure\n",
"P_2 = 2;\t\t\t#[bar] - Final ressure\n",
"T_1 = 250 + 273.15;\t\t\t#[K] - Initial tempearture\n",
"R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n",
"\n",
"\t\t\t# (a).\n",
"\t\t\t# At 20 bar and 250 C as reported in the book\n",
"V_1 = 0.11144;\t\t\t#[m**(3)/kg] - Specific volume\n",
"U_1 = 2679.6;\t\t\t#[kJ/kg] - Specific internal energy\n",
"S_1 = 6.5453;\t\t\t#[kJ/kg-K] - Specific entropy\n",
"S_2 = S_1;\t\t\t# Isentropic expansion\n",
"\n",
"# Calculations and Results\n",
"\t\t\t# At 2 bar under saturated conditions \n",
"S_liq = 1.5301;\t\t\t#[kJ/kg-K]\n",
"S_vap = 7.1271;\t\t\t#[kJ/kg-K]\n",
"U_liq = 504.49;\t\t\t#[kJ/kg-K]\n",
"U_vap = 2529.5;\t\t\t#[kJ/kg-K]\n",
"\t\t\t# Therefore dryness factor can be determined as\n",
"x = (S_1 - S_liq)/(S_vap - S_liq);\n",
"U_2 = U_liq*(1 - x) + x*U_vap;\t\t\t#[kJ/kg] - Specific internal energy at final state\n",
"delta_U = U_2 - U_1;\t\t\t#[kJ/kg] - change in internal energy\n",
"W = - delta_U;\t\t\t# - Work done\n",
"\n",
"\t\t\t# The final saturated temperature at 2 bar from steam table is\n",
"T_2 = 120.23;\t\t\t#[C]\n",
"\n",
"print \" a).The final temperature is %f C\"%(T_2);\n",
"print \" The work done is equal to %f kJ/kg\"%(W);\n",
"\n",
"\t\t\t# (b).\n",
"Y = 1.4;\t\t\t# Index of expansion for air\n",
"Cv_0 = R/(Y-1);\t\t\t#[J/mol*K] - Specific heat capacity at constant volume\n",
"\t\t\t# Ideal gas under isentropic expansion P_1**(1-Y)*T_1**(Y) =P_2**(1-Y)*T_2**(Y)\n",
"T_2_prime = T_1*(P_1/P_2)**((1-Y)/Y);\t\t\t#[K] - Final temperature\n",
"delta_U_prime = Cv_0*(T_2_prime - T_1);\t\t\t#[J/mol] - change in internal energy\n",
"\n",
"\t\t\t# Number of moles is given by\n",
"n = m/28.84;\t\t\t#[mol]\n",
"delta_U_prime = delta_U_prime*n*10**(-3);\t\t\t#[kJ]\n",
"W_prime = - delta_U_prime;\t\t\t# Work done\n",
"\n",
"print \" b).The final temperature is %f C\"%(T_2_prime);\n",
"print \" The work done is equal to %f kJ/kg\"%(W_prime);\n",
"\n",
"\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" a).The final temperature is 120.230000 C\n",
" The work done is equal to 360.596841 kJ/kg\n",
" b).The final temperature is 270.964218 C\n",
" The work done is equal to 181.750398 kJ/kg\n"
]
}
],
"prompt_number": 6
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 4.7 Page Number : 155"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
" \n",
"# Variables\n",
"P_1 = 15.;\t\t\t#[bar] - Initial pressure\n",
"P_2 = 0.15;\t\t\t#[bar] - Final pressure\n",
"\n",
"\t\t\t# We know that during isentropic expansion\n",
"\t\t\t# W = ((P_1*V_1) - (P_2*V_2))/(Y - 1)\n",
"\n",
"\t\t\t# At 15 bar (saturated vapour), from steam table as reported in the book\n",
"V_1 = 0.13177;\t\t\t#[m**(3)/kg]\n",
"U_1 = 2594.5;\t\t\t#[kJ/kg]\n",
"S_1 = 6.4448;\t\t\t#[kJ/kg-K]\n",
"\n",
"\t\t\t# Now at state 2 (P_2 = 0.15 bar),from steam table as reported in the book\n",
"S_2 = S_1;\t\t\t# Isentropic expansion\n",
"S_liq = 0.7549;\t\t\t#[kJ/kg-K]\n",
"S_vap = 8.0085;\t\t\t#[kJ/kg-K]\n",
"U_liq = 225.92;\t\t\t#[kJ/kg]\n",
"U_vap = 2448.7;\t\t\t#[kJ/kg]\n",
"V_liq = 0.001014;\t\t\t#[m**(3)/kg]\n",
"V_vap = 10.02;\t\t\t#[m**(3)/kg]\n",
"\n",
"# Calculations\n",
"\t\t\t# Therefore dryness factor can be calculated as\n",
"x = round((S_1 - S_liq)/(S_vap - S_liq),3);\n",
"U_2 = round(U_liq*(1 - x) + x*U_vap,2);\t\t\t#[kJ/kg] - Specific internal energy at final state\n",
"delta_U = U_2 - U_1;\t\t\t#[kJ/kg] - change in internal energy\n",
"W = - delta_U;\t\t\t# - Work done\n",
"\n",
"\t\t\t# The specific volume at the final state is\n",
"V_2 = round(V_liq*(1 - x) + x*V_vap,3);\t\t\t#[m**(3)/kg]\n",
"\n",
"\t\t\t# From work done under adiabatic conditions we get\n",
"\t\t\t# W = ((P_1*V_1) - (P_2*V_2))/(Y - 1)\n",
"Y = (((P_1*V_1) - (P_2*V_2))*10**2/W) + 1;\n",
"\n",
"# Results\n",
"print \" The index of expansion is given by Y = %.4f\"%(Y);\n",
"\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" The index of expansion is given by Y = 1.1275\n"
]
}
],
"prompt_number": 17
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 4.8 Page Number : 157"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
" \n",
"P_1 = 40;\t\t\t#[bar] - Initial pressure\n",
"T_1 = 500;\t\t\t#[C] - Initial temperature\n",
"Vel_1 = 140;\t\t\t#[m/s] - Initial velocity\n",
"T_2 = 100;\t\t\t#[C] - Final temperature\n",
"Vel_2 = 80;\t\t\t#[m/s] - Final velocity\n",
"W = 746.0;\t\t\t#[kJ/kg] - Work output\n",
"\n",
"# Calculations and Results\n",
"\t\t\t# (a).\n",
"\t\t\t# From steam table as reported in the book\n",
"H_1 = 3445.3;\t\t\t#[kJ/kg]\n",
"H_2 = 2676.1;\t\t\t#[kJ/kg]\n",
"S_1 = 7.0901;\t\t\t#[kJ/kh-K]\n",
"S_2 = 7.3549;\t\t\t#[kJ/kg-K]\n",
"\n",
"\t\t\t# The temperature at which heat exchange take place is given by \n",
"T_b =(T_1 + T_2)/2 + 273.15;\t\t\t#[K]\n",
"\n",
"\t\t\t# From first law in a control volume \n",
"\t\t\t# q - W = delta_H + (delta_V**(2))/2 , therefore\n",
"q = W*10**(3) + (H_2 - H_1)*10**(3) + (Vel_2**(2) - Vel_1**(2))/2;\t\t\t#[J/kg]\n",
"q = q*10**(-3);\t\t\t#[kJ/kg]\n",
"\n",
"S_gen = (S_2 - S_1) - (q/T_b);\t\t\t#[kJ/kg-K]\n",
"\n",
"print \" a).The specific entropy production within turbine is %f kJ/kg-K\"%(S_gen);\n",
"\n",
"\t\t\t#(b)\n",
"\t\t\t# If control volume is too large to include the turbine and the environment then T_b becomes equal to 289 K. In this case\n",
"T_b_prime = 298;\t\t\t#[K]\n",
"\n",
"\t\t\t# The entropy change of the sysytem is given by \n",
"\t\t\t#delta_S = q/T_b + S_gen\n",
"S_gen = (S_2 - S_1) - (q/T_b_prime);\t\t\t#[kJ/kg-K]\n",
"\n",
"print \" b).The specific entropy production within turbine is %f kJ/kg-K\"%(S_gen);\n",
"\n",
"\t\t\t# In the first part only irreversibilities within the turbine are evaluated\n",
"\t\t\t# whereas in part (2) irreversible heat transfer between the turbine cover and environment are also included.\n",
"\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" a).The specific entropy production within turbine is 0.316793 kJ/kg-K\n",
" b).The specific entropy production within turbine is 0.364800 kJ/kg-K\n"
]
}
],
"prompt_number": 8
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 4.9 Page Number : 160"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
" \n",
"P_1 = 1.;\t\t\t#[MPa] - Initial pressure\n",
"T_1 = 200 + 273.15;\t\t\t#[K] - Initial temperature\n",
"P_2 = 8.;\t\t\t#[MPa] - Final pressure\n",
"Y = 1.4;\t\t\t# Index of expansion of gas\n",
"R = 8.314;\t\t\t#[J/mol-K] - Universal gas constant\n",
"\n",
"# Calculations and Results\n",
"\t\t\t#(1)\n",
"\t\t\t# The exit temperature for ideal gas under isentropic conditions is given by \n",
"T_2 = round(T_1*(round((P_2/P_1)**((Y-1)/Y),2)),1);\t\t\t#[K] - Exit temperature\n",
"\n",
"Cp_0 = round(Y*R/(Y-1),1);\t\t\t#[J/mol-K] - Specific heat capacity at constant pressure\n",
"\t\t\t# For isentropic conditions the enthalpy change for ideal gas is given by\n",
"delta_H_s = Cp_0*(T_2 - T_1);\t\t\t#[J/mol]\n",
"\t\t\t# Therefore work is given by\n",
"W = - delta_H_s;\t\t\t#[J/mol]\n",
"\n",
"print \" 1).The exit temperature of steam is %.2f K\"%(T_2);\n",
"print \" The required work is %.2f J/mol\"%(W);\n",
"\n",
"\t\t\t#(2)\n",
"eff = 0.8;\t\t\t# Adiabatic efficiency\n",
"\t\t\t# delta_H_s/delta_H_a = 0.8\n",
"delta_H_a = delta_H_s/eff;\t\t\t#[J/mol] - Actual enthalpy change\n",
"W_a = - delta_H_a;\t\t\t#[J/mol]\n",
"\n",
"\t\t\t# The ideal gas enthalpy is a function only of temperature,therefore actual exit temperature T_2a is given by \n",
"\t\t\t# delta_H_a = Cp_0*(T_2a - T_1)\n",
"T_2a = (delta_H_a/Cp_0) + T_1;\n",
"\n",
"print \" 2).The exit temperature of steam is %.2f K\"%(T_2a);\n",
"print \" The required work is %.2f J/mol\"%(W_a);\n",
"\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" 1).The exit temperature of steam is 856.40 K\n",
" The required work is -11152.58 J/mol\n",
" 2).The exit temperature of steam is 952.21 K\n",
" The required work is -13940.72 J/mol\n"
]
}
],
"prompt_number": 30
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 4.10 Page Number : 161"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
" \n",
"from scipy.optimize import fsolve \n",
"import math \n",
"from scipy.integrate import quad \n",
"\t\t\t\n",
"\n",
"# Variables\n",
"P_1 = 1;\t\t\t#[MPa] - Initial pressure\n",
"T_1 = 200 + 273.15;\t\t\t#[K] - Initial temperature\n",
"P_2 = 8;\t\t\t#[MPa] - Final pressure\n",
"Y = 1.4;\t\t\t# Index of expansion of gas\n",
"R = 1.987;\t\t\t#[cal/mol*K] - Universal gas constant\n",
"\t\t\t# Cp_0 = 7.7 + 0.04594*10**(-2)*T + 0.2521*10**(-5)*T**(2) - 0.8587*10**(-9)*T**(3), here T is in K and Cp_0 is in cal/mol-K\n",
"a = 7.7;\n",
"b = 0.04594*10**(-2);\n",
"c = 0.2521*10**(-5);\n",
"d = - 0.8587*10**(-9);\n",
"\n",
"# Calculations and Results\n",
"\t\t\t# delta_S = integral((Cp_0/T)*dT) - R*math.log(P_2/P_1) = 0\n",
"\t\t\t# delta_S = integral(((a + b*T + c*T**(2) + d*T**(3))/T)*dT) - R*math.log(P_2/P_1) = 0\n",
"\t\t\t# delta_S = a*math.log(T_2/T_1) + b*(T_2 - T_1) + (c/2)*(T_2**(2) - T_1**(2)) + (d/3)*(T_2**(3) - T_1**(3)) - R*math.log(P_2/P_1) = 0\n",
"\t\t\t# Solving for T_2 in the above equation we get\n",
"def f(T_2): \n",
"\t return a*math.log(T_2/T_1)+b*(T_2-T_1)+(c/2)*(T_2**(2)-T_1**(2))+(d/3)*(T_2**(3)-T_1**(3))-R*math.log(P_2/P_1)\n",
"T_2 = fsolve(f,100)\n",
"\n",
"\t\t\t# Now let us calculate the enthalpy change under these conditions \n",
"\n",
"def f0(T): \n",
"\t return 7.7+0.04594*10**(-2)*T+0.2521*10**(-5)*T**(2)-0.8587*10**(-9)*T**(3)\n",
"\n",
"delta_H_s = quad(f0,T_1,T_2)[0]\n",
"\n",
"delta_H_s = delta_H_s*4.184;\t\t\t#[J/mol]\n",
"\t\t\t# Therefore isentropic work done is\n",
"W = - delta_H_s;\n",
"\n",
"print \" 1).The exit temperature of steam is %f K\"%(T_2);\n",
"print \" The required work is %f J/mol\"%(W);\n",
"\n",
"\t\t\t#(2)\n",
"eff = 0.8;\n",
"delta_H_a = delta_H_s/eff;\t\t\t#[J/mol] - Actual enthalpy change\n",
"\t\t\t# Therefore actual work done is given by \n",
"W_a = - delta_H_a;\t\t\t#[J/mol]\n",
"\n",
"\t\t\t# Now we have to determine the exit temperature under actual conditions\n",
"\t\t\t# delta_H_a = integral(Cp_0*dT) from limit T_1 = 473.15 K to T_2\n",
"\t\t\t# On putting the values and simplifying we get\n",
"\t\t\t# 7.7*T_2 + 0.02297*10**(-2)*T_2**(2) + 0.084*10**(-5)*T_2**(3) - 0.214675*10**(-9)*T_2**(4) - 6907.106 = 0\n",
"\n",
"def f1(T_2_prime): \n",
"\t return a*(T_2_prime-T_1)+(b/2)*(T_2_prime**(2)-T_1**(2))+(c/3)*(T_2_prime**(3)-T_1**(3))+(d/4)*(T_2_prime**(4)-T_1**(4))-(delta_H_a/4.184)\n",
"T_2_prime = fsolve(f1,100)\n",
"\n",
"print \" 2).The exit temperature of steam is %f K\"%(T_2_prime);\n",
"print \" The required work is %f J/mol\"%(W_a);\n",
"\n",
"# Answers are vary because of rounding error. Calculations are correct. "
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" 1).The exit temperature of steam is 760.037501 K\n",
" The required work is -10499.128839 J/mol\n",
" 2).The exit temperature of steam is 828.044888 K\n",
" The required work is -13123.911049 J/mol\n"
]
}
],
"prompt_number": 31
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 4.11 Page Number : 162"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
" \n",
"# Variables\n",
"P_1 = 1;\t\t\t#[MPa] - Initial pressure\n",
"T_1 = 200 + 273.15;\t\t\t#[K] - Initial temperature\n",
"P_2 = 8;\t\t\t#[MPa] - Final pressure\n",
"Y = 1.4;\t\t\t# Index of expansion of gas\n",
"\n",
"\t\t\t# At state 1 (1 MPa and 200 C) from steam table as reported in the book\n",
"H_1 = 2827.9;\t\t\t#[kJ/kg]\n",
"S_1 = 6.694;\t\t\t#[kJ/kg]\n",
"\t\t\t# At state 2 (8 MPa)\n",
"S_2 = S_1;\t\t\t# Isentropic process\n",
"\t\t\t# From steam table at 8 MPa and 450 C\n",
"S_21 = 6.5551;\t\t\t#[kJ/kg-K]\n",
"\t\t\t# From steam table at 8 MPa and 500 C\n",
"S_22 = 6.7240;\t\t\t#[kJ/kg-K]\n",
"\t\t\t# Therefore temperature at which entropy of steam is 6.694 kJ/kg-K is given by\n",
"T_2 = 450 + (500-450)/(S_22-S_21)*(S_2-S_21);\t\t\t#[C]\n",
"T_2 = T_2 + 273.15;\t\t\t#[K]\n",
"\n",
"\n",
"# Calculations and Results\n",
"\t\t\t# Enthalpy of steam at 8 MPa and 450 C from steam table as reported in the book \n",
"H_21 = 3272.0;\t\t\t#[kJ/kg]\n",
"\t\t\t# And at 8 MPA and 500 C\n",
"H_22 = 3398.3;\t\t\t#[kJ/kg]\n",
"\t\t\t# Therefore enthalpy of steam at 8 MPa and T_2 \n",
"H_2 = H_21 + ((H_22-H_21)/(500-450))*((T_2-273.15) - 450); \n",
"\t\t\t# Work done is given by \n",
"\t\t\t# W = - delta_H_s\n",
"W = - (H_2 - H_1);\t\t\t#[J/g]\n",
"W = W*18.015;\t\t\t#[J/mol]\n",
"delta_H_s = - W;\n",
"\n",
"print \" 1).The exit temperature of steam is %f K\"%(T_2);\n",
"print \" The required work is %f J/mol\"%(W);\n",
"\n",
"\t\t\t#(2)\n",
"eff = 0.8;\t\t\t# Adiabatic efficiency\n",
"\t\t\t# delta_H_s/delta_H_a = 0.8\n",
"delta_H_a = delta_H_s/eff;\t\t\t#[J/mol] - Actual enthalpy change\n",
"\t\t\t# Therefore actual work done \n",
"W_a = - delta_H_a;\t\t\t#[J/mol]\n",
"\t\t\t# Enthalpy at actual exit conditions is \n",
"H_2_a = H_1 + delta_H_a/18.015;\t\t\t#[kJ/kg]\n",
"\n",
"\t\t\t# Enthalpy of steam at 8 MPa and 500 C from steam table as reported in the book \n",
"H_21_a = 3398.3;\t\t\t#[kJ/kg]\n",
"\t\t\t# And at 8 MPA and 550 C\n",
"H_22_a = 3521.0;\t\t\t#[kJ/kg]\n",
"\t\t\t# Therefore temperature at H_22_a is given by\n",
"T_2_a = 500 + ((550-500)*(H_2_a - H_21_a))/(H_22_a - H_21_a);\t\t\t#[C]\n",
"T_2_a = T_2_a + 273.15;\t\t\t#[K]\n",
"\n",
"print \" 2).The exit temperature of steam is %f K\"%(T_2_a);\n",
"print \" The required work is %f J/mol\"%(W_a);\n",
"\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" 1).The exit temperature of steam is 764.269005 K\n",
" The required work is -9871.618433 J/mol\n",
" 2).The exit temperature of steam is 819.832257 K\n",
" The required work is -12339.523042 J/mol\n"
]
}
],
"prompt_number": 11
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 4.12 Page Number : 163"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
" \n",
"P_1 = 140.;\t\t\t#[kPa] - Initial pressure\n",
"T_1 = 20. + 273.15;\t\t\t#[K] - Initial temperature\n",
"P_2 = 560.;\t\t\t#[kPa] - Final pressure\n",
"eff = 0.75;\t\t\t# Compressor efficiency\n",
"R = 1.987;\t\t\t#[cal/mol*K] - Universal gas constant\n",
"\t\t\t# Cp_0 = 4.750 + 1.200*10**(-2)*T + 0.3030*10**(-5)*T**(2) - 2.630*10**(-9)*T**(3), here T is in K and Cp_0 is in cal/mol-K\n",
"a = 7.7;\n",
"b = 0.04594*10**(-2);\n",
"c = 0.2521*10**(-5);\n",
"d = - 0.8587*10**(-9);\n",
"\n",
"# Calculations and Results\n",
"# At 20 C,as reported in the book\n",
"Cp_0 = 8.46;\t\t\t#[cal/mol-K] - Specific heat capacity at constant pressure\n",
"Cv_0 = Cp_0 - R;\t\t\t#[cal/mol-K] - Specific heat capacity at constant volume\n",
"Y = Cp_0/Cv_0;\t\t\t# Index of expansion\n",
"\n",
"\t\t\t# Assuming 100 % efficiency,for reversible and adiabatic process the final temperature is given by\n",
"\t\t\t# P*V**(Y) = constant or, P*((R*T)/P)**(Y) = constant\n",
"T_2 = ((P_1/P_2)**((1-Y)/Y))*T_1;\t\t\t#[K]\n",
"\n",
"\t\t\t# Since at final temperature the value of heat capacity ratio would have changed \n",
"\t\t\t# So let us determine Y at mean temperature and then calculating final temperature\n",
"T_mean = (T_1 + T_2)/2;\t\t\t#[K]\n",
"\n",
"\t\t\t# At T_mean,as reported in the book\n",
"Cp_0_new = 9.153;\t\t\t#[cal/mol-K]\n",
"Cv_0_new = Cp_0_new - R;\t\t\t#[cal/mol-K]\n",
"Y_new = Cp_0_new/Cv_0_new;\n",
"T_2_new = T_1*((P_1/P_2)**((1-Y_new)/Y_new));\t\t\t#[K]\n",
"\n",
"\t\t\t# The enthalpy change is given by \n",
"\n",
"def f23(T): \n",
"\t return 4.750+1.200*10**(-2)*T+0.3030*10**(-5)*T**(2)-2.630*10**(-9)*T**(3)\n",
"\n",
"delta_H = quad(f23,T_1,T_2_new)[0]\n",
"\n",
"\n",
"\t\t\t#For adiabatic process\n",
"W = - delta_H;\t\t\t#[cal/mol]\n",
"\t\t\t# Now actual work done on the system is given by \n",
"W_a = W/eff;\t\t\t#[cal/mol]\n",
"\n",
"\n",
"\t\t\t# Therefore actual change in enthalpy is - W_a, or\n",
"\t\t\t# - W_a = 4.750*(T_2-T_1) + (1.2*10**(-2)/2)*(T_2**(2)-T_1**(2)) + (0.3030*10**(-5)/3)*(T_2**(3)-T_1**(3)) - (2.63*10**(-9)/4)*(T_2***(4)-T_1**(4));\n",
"\t\t\t# Solving for T_2 in the above equation\n",
"def f1(T_2_prime): \n",
"\t return 4.750*(T_2_prime-T_1)+((1.2*10**(-2))/2)*(T_2_prime**(2)-T_1**(2))+((0.3030*10**(-5))/3)*(T_2_prime**(3)-T_1**(3))-((2.63*10**(-9))/4)*(T_2_prime**(4)-T_1**(4))+W_a\n",
"T_2_prime=fsolve(f1,100)\n",
"\n",
"print \" The required work is %f cal/mol\"%(W_a);\n",
"print \" The discharge temperature of methane is %f K\"%(T_2_prime);\n",
"\n",
"\n",
"\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" The required work is -1254.158148 cal/mol\n",
" The discharge temperature of methane is 427.374758 K\n"
]
}
],
"prompt_number": 12
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 4.13 Page Number : 164"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
" \n",
"P_1 = 10;\t\t\t#[bar] - Initial pressure\n",
"T_1 = 500 + 273.15;\t\t\t#[K] - Initial temperature\n",
"P_2 = 2;\t\t\t#[psia] - Final pressure\n",
"P_2 = P_2/14.5;\t\t\t#[bar]\n",
"P_2 = P_2*10**(2);\t\t\t#[kPa]\n",
"m = 1.8;\t\t\t#[kg/s] - Mass flux\n",
"eff = 0.8;\t\t\t# Efficiency\n",
"\n",
"\t\t\t# At state 1, from steam table\n",
"H_1 = 3478.5;\t\t\t#[kJ/kg]\n",
"S_1 = 7.7622;\t\t\t#[kJ/kg-K]\n",
"S_2 = S_1;\t\t\t# Adiabatic process\n",
"\n",
"\t\t\t# From saturated steam table at 10 kPa\n",
"S_liq_1 = 0.6493;\t\t\t#[kJ/kg-K]\n",
"S_vap_1 = 8.1502;\t\t\t#[kJ/kg-K]\n",
"\t\t\t# From saturated steam table at 15 kPa\n",
"S_liq_2 = 0.7549;\t\t\t#[kJ/kg-K]\n",
"S_vap_2 = 8.0085;\t\t\t#[kJ/kg-K]\n",
"\n",
"# Calculations and Results\n",
"\t\t\t# Threfore at P_2 \n",
"S_liq = S_liq_1 + ((S_liq_2-S_liq_1)/(15-10))*(P_2-10);\n",
"S_vap = S_vap_1 + ((S_vap_2-S_vap_1)/(15-10))*(P_2-10);\n",
"\n",
"\t\t\t# The dryness fraction at exit state is\n",
"x_2 = (S_1-S_liq)/(S_vap-S_liq);\n",
"\t\t\t# The enthalpy at exit to be determined. At 10 kPa\n",
"H_liq_1 = 191.83;\t\t\t#[kJ/kg]\n",
"H_vap_1 = 2584.7;\t\t\t#[kJ/kg]\n",
"\t\t\t# At 15 kPa\n",
"H_liq_2 = 225.94;\t\t\t#[kJ/kg]\n",
"H_vap_2 = 2599.1;\t\t\t#[kJ/kg]\n",
"\t\t\t# Therfore at P_2\n",
"H_liq = H_liq_1 + ((H_liq_2-H_liq_1)/(15-10))*(P_2-10);\n",
"H_vap = H_vap_1 + ((H_vap_2-H_vap_1)/(15-10))*(P_2-10);\n",
"\n",
"\t\t\t# Enthalpy at state 2\n",
"H_2_s = H_liq*(1-x_2) + x_2*H_vap;\t\t\t#[kJ/kg]\n",
"W = m*(H_1 - H_2_s);\t\t\t#[kW]\n",
"\n",
"print \" 1).The power output is %f kW\"%(W);\n",
"\n",
"\t\t\t#(2)\n",
"\t\t\t# If the process is 80 % efficient the enthalpy change is\n",
"\t\t\t# H_1 - H_2_a = eff*(H_1 - H_2_s)\n",
"H_2_a = H_1 - (0.8*(H_1 - H_2_s));\n",
"\n",
"\t\t\t# Now under these conditions temperature and entropy have to be determined. From superheated steam tables,as reported in the book\n",
"\t\t\t# At 10 kPa and 100 C\n",
"H_2_1 = 2687.5;\t\t\t#[kJ/kg]\n",
"S_2_1 = 8.4479;\t\t\t#[kJ/kg-k]\n",
"\t\t\t# At 10 kPa and 150 C\n",
"H_2_2 = 2783.0;\t\t\t#[kJ/kg]\n",
"S_2_2 = 8.6882;\t\t\t#[kJ/kg-k]\n",
"\t\t\t# At 50 kPa and 100 C\n",
"H_3_1 = 2682.5;\t\t\t#[kJ/kg]\n",
"S_3_1 = 7.6947;\t\t\t#[kJ/kg-k]\n",
"\t\t\t# At 50 kPa and 150 C\n",
"H_4_1 = 2780.1;\t\t\t#[kJ/kg]\n",
"S_4_1 = 7.9401;\t\t\t#[kJ/kg-k]\n",
"\t\t\t# Therefore at P_2 and 100 C\n",
"H_prime_1 = H_2_1 + ((H_3_1-H_2_1)/(50-10))*(P_2-10);\t\t\t#[kJ/kg]\n",
"S_prime_1 = S_2_1 + ((S_3_1-S_2_1)/(50-10))*(P_2-10);\t\t\t#[kJ/kg-K]\n",
"\t\t\t# Therefore at P_2 and 150 C\n",
"H_prime_2 = H_2_2 + ((H_4_1-H_2_2)/(50-10))*(P_2-10);\t\t\t#[kJ/kg]\n",
"S_prime_2 = S_2_2 + ((S_4_1-S_2_2)/(50-10))*(P_2-10);\t\t\t#[kJ/kg-K]\n",
"\n",
"\t\t\t# Enthalpy at exit is H_2_a. So at this condition temperature can be nom be determined\n",
"T_exit = ((H_2_a - H_prime_1)/(H_prime_2 - H_prime_1))/(150-100) + 100;\t\t\t#[C]\n",
"\t\t\t# The entropy at exit is\n",
"S_exit = ((H_2_a - H_prime_1)/(H_prime_2 - H_prime_1))/(S_prime_2 - S_prime_1) + S_prime_1;\t\t\t#[kJ/kg-K]\n",
"\n",
"print \" 2).The entropy at exit is %f kJ/kg-K\"%(S_exit);\n",
"print \" The temperature of the exit state is %f C\"%(T_exit);\n",
"\n",
"print \" The irreversibility is advatageous because the exit steam is superheated and therefore\";\n",
"print \" the blades of the turbine are not eroded by water droplets which get formed when the process is isentropic\";\n",
"\n",
"\n",
"\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" 1).The power output is 1753.346828 kW\n",
" 2).The entropy at exit is 8.906311 kJ/kg-K\n",
" The temperature of the exit state is 100.002552 C\n",
" The irreversibility is advatageous because the exit steam is superheated and therefore\n",
" the blades of the turbine are not eroded by water droplets which get formed when the process is isentropic\n"
]
}
],
"prompt_number": 13
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 4.14 Page Number : 166"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
" \n",
"P_1 = 6;\t\t\t#[MPa] - Initial pressure\n",
"T_1 = 500 + 273.15;\t\t\t#[K] - Initial temperature\n",
"P_2 = 10;\t\t\t#[kPa] - Final pressure\n",
"out_qlty = 0.9;\t\t\t# Output quality\n",
"\n",
"\t\t\t# At 6 MPa and 500 C, from steam table as reported in the book\n",
"H_1 = 3422.2;\t\t\t#[kJ/kg]\n",
"S_1 = 6.8803;\t\t\t#[kJ/kg-K]\n",
"S_2 = S_1;\t\t\t# Adiabatic reversible conditions\n",
"\t\t\t# At 10 kPa saturated\n",
"H_liq = 191.83;\t\t\t#[kJ/kg]\n",
"H_vap = 2584.7;\t\t\t#[kJ/kg]\n",
"S_liq = 0.6493;\t\t\t#[kJ/kg-K]\n",
"S_vap = 8.1502;\t\t\t#[kJ/kg-K]\n",
"\n",
"# Calculations and Results\n",
"\t\t\t# The dryness fraction is given by \n",
"x = (S_1-S_liq)/(S_vap-S_liq);\n",
"\n",
"\t\t\t# Now the exit enthalpy is given by\n",
"H_2 = H_liq*(1-x) + x*H_vap;\t\t\t#[kJ/kg]\n",
"W = - (H_2 - H_1);\t\t\t#[kJ/kg] - Under isentropic conditions\n",
"\n",
"\t\t\t# We know that, delta_S = q/T_b + S_gen\n",
"\t\t\t# Since delta_S = 0, therefore under isentropic conditions\n",
"S_gen = 0;\t\t\t#[kJ/kg-K]\n",
"\n",
"\t\t\t# Now for output quality 0.9\n",
"H_2_a = H_liq*(1-out_qlty) + out_qlty*H_vap;\t\t\t#[kJ/kg]\n",
"S_2_a = S_liq*(1-out_qlty) + out_qlty*S_vap;\t\t\t#[kJ/kg]\n",
"W_a = - (H_2_a - H_1);\t\t\t#[kJ/kg]\n",
"delta_S_a = S_2_a - S_1;\t\t\t#[kJ/kg-k]\n",
"\t\t\t# Again, delta_S = q/T_b + S_gen\n",
"\t\t\t# Since q = 0, therefore under isentropic conditions\n",
"S_gen_a = delta_S_a;\t\t\t#[kJ/kg-K\n",
"\t\t\t# Now efficiency is given by eff = delta_H_a/delta_H_s\n",
"eff = W_a/W;\n",
"\n",
"print \" For output quality = 0.9\";\n",
"print \" The work output per unit mass is %f kJ/kg\"%(W_a);\n",
"print \" The entropy generation is given by S_gen = %f kJ/kg-K\"%(S_gen_a);\n",
"print \" The efficiency with respect to reversible adiabatic case is given by eff = %f\"%(eff);\n",
"\n",
"\t\t\t# Now for output quality 1\n",
"out_qlty_1 = 1;\n",
"H_2_a_1 = H_liq*(1-out_qlty_1) + out_qlty_1*H_vap;\t\t\t#[kJ/kg]\n",
"S_2_a_1 = S_liq*(1-out_qlty_1) + out_qlty_1*S_vap;\t\t\t#[kJ/kg]\n",
"W_a_1 = - (H_2_a_1 - H_1);\t\t\t#[kJ/kg]\n",
"delta_S_a_1 = S_2_a_1 - S_1;\t\t\t#[kJ/kg-k]\n",
"\t\t\t# Again, delta_S = q/T_b + S_gen\n",
"\t\t\t# Since q = 0, therefore under isentropic conditions\n",
"S_gen_a_1 = delta_S_a_1;\t\t\t#[kJ/kg-K\n",
"\t\t\t# Now efficiency is given by eff = delta_H_a/delta_H_s\n",
"eff_1 = W_a_1/W;\n",
"\n",
"print \" For output quality = 1.0\";\n",
"print \" The work output per unit mass is %f kJ/kg\"%(W_a_1);\n",
"print \" The entropy generation is given by S_gen = %f kJ/kg-K\"%(S_gen_a_1);\n",
"print \" The efficiency with respect to reversible adiabatic case is given by eff = %f\"%(eff_1);\n",
"\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" For output quality = 0.9\n",
" The work output per unit mass is 1076.787000 kJ/kg\n",
" The entropy generation is given by S_gen = 0.519810 kJ/kg-K\n",
" The efficiency with respect to reversible adiabatic case is given by eff = 0.866551\n",
" For output quality = 1.0\n",
" The work output per unit mass is 837.500000 kJ/kg\n",
" The entropy generation is given by S_gen = 1.269900 kJ/kg-K\n",
" The efficiency with respect to reversible adiabatic case is given by eff = 0.673983\n"
]
}
],
"prompt_number": 14
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 4.15 Page Number : 168"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
" \n",
"P_1 = 3.;\t\t\t#[bar] - Initial pressure\n",
"T_1 = 150. + 273.15;\t\t\t#[K] - Initial temperature\n",
"Vel_1 = 90.;\t\t\t#[m/s] - Initial velocity\n",
"P_2 = 1.;\t\t\t#[bar] - Final pressure\n",
"eff = 0.95;\t\t\t# Adiabatic effciciency of the nozzle\n",
"R = 8.314;\t\t\t#[J/mol*-] - Universal gas constant\n",
"\n",
"\t\t\t# At 3 bar and 150 C, from steam table\n",
"S_1 = 7.0778;\t\t\t#[kJ/kg-K]\n",
"H_1 = 2761.0;\t\t\t#[kJ/kg]\n",
"S_2 = S_1;\t\t\t# \n",
"\n",
"\t\t\t# At 1 bar saturated\n",
"S_liq = 1.3026;\t\t\t#[kJ/kg-K]\n",
"S_vap = 7.3594;\t\t\t#[kJ/kg-K]\n",
"H_liq = 417.46;\t\t\t#[kJ/kg]\n",
"H_vap = 2675.5;\t\t\t#[kJ/kg]\n",
"\n",
"# Calculations and Results\n",
"\t\t\t# The dryness factor of exit steam can be determined as\n",
"x = (S_1-S_liq)/(S_vap-S_liq);\n",
"\t\t\t# Enthalpy of exit steam is given by \n",
"H_2 = H_liq*(1-x) + x*H_vap;\t\t\t#[kJ/kg]\n",
"delta_H_s = H_2 - H_1;\t\t\t#[kJ/kg] - Enthalpy change\n",
"delta_H_a = eff*delta_H_s;\t\t\t#[kJ/kg]\n",
"\n",
"\t\t\t# Assuming no heat exchange with surroundings and since no work is done\n",
"\t\t\t# delta_H + (delta_V**(2))/2 = 0\n",
"delta_Vel_square = 2*(-delta_H_a)*1000;\t\t\t#[m**(2)/s**(2)]\n",
"Vel_2 = (delta_Vel_square + Vel_1**(2))**(1./2);\t\t\t#[m/s]\n",
"\n",
"print \" 1).The final velocity when fluid is steam) is %f m/s\"%(Vel_2);\n",
"\n",
"\t\t\t# (2)\n",
"Y = 1.4;\t\t\t# Index of expansion\n",
"Cp_0 = (Y*R)/(Y-1);\t\t\t#[J/mol-K] - Specific heat capacity at constant pressure\n",
"\n",
"\t\t\t# P_1**(1-Y)*T_1**(Y) = P_2**(1-Y)*T_2**(Y)\n",
"T_2 = T_1*(P_1/P_2)**((1-Y)/Y);\t\t\t#[K]\n",
"delta_H_s_2 = Cp_0*(T_2 - T_1);\t\t\t#[J/mol]\n",
"delta_H_a_2 = eff*delta_H_s_2;\t\t\t#[J/mol]\n",
"delta_H_a_2 = (delta_H_a_2*1000)/28.84;\t\t\t#[J/kg]\n",
"\n",
"delta_Vel_square_2 = 2*(-delta_H_a_2);\t\t\t#[m**(2)/s**(2)]\n",
"Vel_2_2 = (delta_Vel_square_2 + Vel_1**(2))**(1./2);\t\t\t#[m/s]\n",
"\n",
"print \" 2).The final velocity when fluid is air which behaves as an ideal gas) is %f m/s\"%(Vel_2_2);\n",
"\n",
"\n",
"\n",
"\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" 1).The final velocity when fluid is steam) is 608.291583 m/s\n",
" 2).The final velocity when fluid is air which behaves as an ideal gas) is 476.065890 m/s\n"
]
}
],
"prompt_number": 15
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 4.16 Page Number : 169"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
" \n",
"# Variables\n",
"P_1 = 300.;\t\t\t#[kPa] - Initial pressure\n",
"T_1 = 450.;\t\t\t#[K] - Initial temperature\n",
"Vel_1 = 90.;\t\t\t#[m/s] - Initial velocity\n",
"P_2 = 180.;\t\t\t#[kPa] - Final pressure\n",
"eff = 0.95;\t\t\t# Adiabatic effciciency of the nozzle\n",
"R = 8.314;\t\t\t#[J/mol*-] - Universal gas constant\n",
"Cp = 5.19;\t\t\t#[kJ/kg-K] - Specific heat capacity at constant pressure\n",
"\n",
"# Calculations and Results\n",
"\t\t\t#(a)\n",
"\n",
"\n",
"Mol_wt_He = 4;\t\t\t#[g/mol] - Molecular weight of helium\n",
"R_He = R/Mol_wt_He;\t\t\t# 'R' for helium\n",
"Y = Cp/(Cp - R_He);\n",
"\n",
"\t\t\t# Now temperature at exit to be determined\n",
"T_2s = T_1*(P_1/P_2)**((1-Y)/Y);\t\t\t#[K]\n",
"delta_H_2s = Cp*(T_2s - T_1);\t\t\t#[kJ/kg]\n",
"\n",
"\t\t\t# Since no work is done and heat exchange is zero,from first law we get\n",
"\t\t\t# delta_H + delta_Vel**(2)/2 = 0\n",
"delta_Vel_square = 2*(-delta_H_2s)*1000;\t\t\t#[m**(2)/s**(2)]\n",
"Vel_2 = (delta_Vel_square)**(1./2);\t\t\t#[m/s] - ( as Vel_1 << Vel_2)\n",
"\n",
"print \" a).The maximum exit velocity is %f m/s\"%(Vel_2);\n",
"\n",
"\t\t\t#(b)\n",
"T_2a = 373;\t\t\t#[K] - Measured temperature of helium\n",
"delta_H_a = Cp*(T_2a - T_1);\t\t\t#[kJ/kg]\n",
"delta_Vel_square_a = 2*(-delta_H_a)*1000;\t\t\t#[m**(2)/s**(2)]\n",
"Vel_2a = (delta_Vel_square_a)**(1./2);\t\t\t#[m/s] - ( as Vel_1 << Vel_2a)\n",
"\n",
"print \" b).The actual exit velocity is %f m/s\"%(Vel_2a);\n",
"\n",
"\t\t\t#(c)\n",
"delta_S_sys = Cp*math.log(T_2a/T_1) - R_He*math.log(P_2/P_1);\n",
"\t\t\t# we know that delta_S_sys = q/T_b + S_gen and since q = 0, therfore\n",
"S_gen = delta_S_sys;\t\t\t#[kJ/kg-K]\n",
"\n",
"print \" c).The increasse in entropy per unit mass is %f kJ/kg-K\"%(S_gen);\n",
"\n",
"\n",
"\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" a).The maximum exit velocity is 929.607346 m/s\n",
" b).The actual exit velocity is 894.013423 m/s\n",
" c).The increasse in entropy per unit mass is 0.087748 kJ/kg-K\n"
]
}
],
"prompt_number": 16
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 4.17 Page Number : 170"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
" \n",
"P_1 = 1;\t\t\t#[bar] - Initial pressure\n",
"T_1 = 150 + 273.15;\t\t\t#[K] - Initial temperature\n",
"V_2 = 0.28;\t\t\t#[m**(3)/kg] - Final specific volume\n",
"T_2 = T_1;\t\t\t#[K] - Isothermal process\n",
"R = 8.314;\t\t\t#[J/mol-K] - Universal gas constant\n",
"\n",
"\t\t\t# At 1 bar and 150 C, from steam table\n",
"S_1 = 7.6134;\t\t\t#[kJ/kg-K]\n",
"H_1 = 2776.4;\t\t\t#[kJ/kg]\n",
"\n",
"\t\t\t# At 150 C saturated\n",
"V_liq = 0.001091;\t\t\t#[m**(3)/kg]\n",
"V_vap = 0.3928;\t\t\t#[m**(3)/kg]\n",
"H_liq = 632.2;\t\t\t#[kJ/kg]\n",
"H_vap = 2746.5;\t\t\t#[kJ/kg]\n",
"S_liq = 1.8418;\t\t\t#[kJ/kg-K]\n",
"S_vap = 6.8379;\t\t\t#[kJ/kg-K]\n",
"\n",
"# Calculations and Results\n",
"\t\t\t# The dryness factor of exit steam can be determined as\n",
"x = (V_2 - V_liq)/(V_vap - V_liq);\n",
"S_2 = S_liq*(1-x) + x*S_vap;\t\t\t#[kJ/kg-K] -Entropy \n",
"H_2 = H_liq*(1-x) + x*H_vap;\t\t\t#[kJ/kg] -Enthalpy \n",
"delta_H = H_2 - H_1;\t\t\t#[kJ/kg] - Enthalpy change\n",
"delta_S = S_2 - S_1;\t\t\t#[kJ/kg]\n",
"\n",
"\t\t\t# Since the compression is reversible\n",
"q = T_1*delta_S;\t\t\t#[kJ/kg] - Heat transfer\n",
"\t\t\t# From first law q - W = delta_H\n",
"W = q - delta_H;\t\t\t#[kJ/kg]\n",
"\n",
"print \" 1).The amount of heat transfer when fluid is steam) is %f kJ/kg\"%(q)\n",
"print \" The amount of work transfer when fluid is steam) is %f kJ/kg\"%(W)\n",
"\n",
"\t\t\t#(2)\n",
"V_2 = V_2*(28.84/1000);\t\t\t#[m**(3)/mol] - Molar volume at exit\n",
"\t\t\t# Pressure at exit is given by \n",
"P_2 = ((R*T_2)/V_2);\t\t\t#[N/m**(2)]\n",
"P_2 = P_2*10**(-5);\t\t\t#[bar]\n",
"\n",
"\t\t\t# Entropy change is given by, delta_S_2 = Cp*math.log(T_2/T_1) - R*math.log(P_2/P_1), but since T_1 = T_2, therfore\n",
"delta_S_2 = - R*math.log(P_2/P_1);\t\t\t#[J/mol-K]\n",
"\n",
"q_2 = T_1*delta_S_2;\t\t\t#[J/mol] - Heat change\n",
"q_2 = q_2/28.84;\t\t\t#[kJ/kg]\n",
"\n",
"\t\t\t# Enthalpy change is given by, delta_H_2 = Cp*(T_2 - T_1) = 0 (as T_1 = T_2)\n",
"delta_H_2 = 0;\t\t\t#[kJ/kg]\n",
"\n",
"\t\t\t# From first law q - W = delta_H, therefore\n",
"W_2 = q_2 - delta_H_2;\t\t\t#[kJ/kg]\n",
"\n",
"print \" 2).The amount of heat transfer when fluid is ideal gas) is %f kJ/kg\"%(q_2)\n",
"print \" The amount of work transfer when fluid is ideal gas) is %f kJ/kg\"%(W_2)\n",
"\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" 1).The amount of heat transfer when fluid is steam) is -936.947741 kJ/kg\n",
" The amount of work transfer when fluid is steam) is -298.195149 kJ/kg\n",
" 2).The amount of heat transfer when fluid is ideal gas) is -179.526401 kJ/kg\n",
" The amount of work transfer when fluid is ideal gas) is -179.526401 kJ/kg\n"
]
}
],
"prompt_number": 17
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"Example 4.18 Page Number : 171"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
" \n",
"P_1 = 7*10**(5);\t\t\t#[Pa] - Initial pressure\n",
"T_1 = 95 + 273.15;\t\t\t#[K] - Initial temperature\n",
"P_2 = 3.5*10**(5);\t\t\t#[Pa] - Final pressure\n",
"dia = 15*10**(-2);\t\t\t#[m] - Diameter of pipe\n",
"m = 2;\t\t\t#[kg/s] - Mass flow rate\n",
"R = 8.314;\t\t\t#[J/mol-K] - Universal gas constant\n",
"Y = 1.4;\t\t\t# Index of expansion\n",
"Cp_0 = (R*Y)/(Y-1);\t\t\t#[J/mol-K] - Specific heat capacity at constant pressure\n",
"Cp_0 = (Cp_0/28.84)*1000;\t\t\t#[J/kg-K]\n",
"rho_1 = 6.6;\t\t\t#[kg/m**(3)] - Density\n",
"\n",
"# Calculations and Results\n",
"\t\t\t# velocity before throttling is to be determined m = rho*Vol*Area\n",
"V_1 = (R*T_1)/P_1;\t\t\t#[m**(3)/mol] - Specific volume\n",
"V_1 = (V_1/28.84)*1000;\t\t\t#[m**(3)/kg]\n",
"Vel_1 = m/(rho_1*3.14*(dia/2)**(2));\t\t\t#[m/s] - Velocity before throttling\n",
"\n",
"\t\t\t# Let the temperature after throttling be T_2, then\n",
"\t\t\t# Vel_2 = m/(rho_2*Area) = (m*V_2)/(3.14*(dia/2)**(2))\n",
"\t\t\t# From first law, since q = W = 0, we get\n",
"\t\t\t# delta_H + (delta_V**(2))/2 = 0\n",
"\t\t\t#Cp_0*(T_2 - T_1) + (((m*((((R*T_2)/P_2)/28.84)*1000))/(3.14*(dia/2)**(2)))**(2) - (Vel_1)**(2))/2 = 0\n",
"\t\t\t# Solving the above equation for T_2, we get\n",
"def f1(T_2): \n",
"\t return Cp_0*(T_2 - T_1) + (((m*((((R*T_2)/P_2)/28.84)*1000))/(3.14*(dia/2)**(2)))**(2) - (Vel_1)**(2))/2\n",
"T_2 =fsolve(f1,100)\n",
"\t\t\t# Therefore velocity of air downstream of restriction is given by \n",
"Vel_2 = ((m*((((R*T_2)/P_2)/28.84)*1000))/(3.14*(dia/2)**(2)));\t\t\t#[m/s]\n",
"\n",
"print \" The velocity of air downstream of restriction is %f m/s\"%(Vel_2);\n",
"\n",
"delta_T = (T_2 - T_1);\n",
"\t\t\t# Since temperature difference (delta_T) is very small, therefore enthalpy change is also very small\n",
"\n",
"\t\t\t# Entropy change is given by, delta_S = Cp_0*math.log(T_2/T_1) - R*math.log(P_2/P_1), but since T_1 and T_2 are almost equal\n",
"delta_S = - R*math.log(P_2/P_1);\t\t\t#[J/mol-K]\n",
"\n",
"print \" The change in entropy is %f kJ/mol-k\"%(delta_S);\n",
"\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" The velocity of air downstream of restriction is 34.295216 m/s\n",
" The change in entropy is 5.762826 kJ/mol-k\n"
]
}
],
"prompt_number": 18
}
],
"metadata": {}
}
]
}
|