summaryrefslogtreecommitdiff
path: root/A_Textbook_Of_Chemical_Engineering_Thermodynamics/ch5.ipynb
blob: aa03f1120adc95744e823836455f147a702fb0da (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
{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 5 : Some Applications of the Laws of Thermodynamics"
     ]
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.1"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#  To calculate the pressure at exit\n",
      "\n",
      "import math\n",
      "\n",
      "# Variables\n",
      "#Given:\n",
      "u1 = 1; \t\t\t    #entering velocity of water (m/s)\n",
      "d_ent = 0.2; \t\t\t#entrance diameter of reducer (m)\n",
      "d_exit = 0.1; \t\t\t#exit diameter of reducer (m)\n",
      "P_ent = 105; \t\t\t#pressure at entrance (kPa)\n",
      "z = 5; \t\t\t        #distance between entrance and exit (m)\n",
      "g = 9.81; \t\t\t    #acceleration due to gravity \n",
      "den = 1000; \t\t\t#density of water (kg/m**3)\n",
      "\n",
      "# Calculations\n",
      "#To calculate the pressure at exit\n",
      "A1 = (math.pi/4)*d_ent**2; \t\t\t    #cross section area of entrance (m**2)\n",
      "A2 = (math.pi/4)*d_exit**2; \t\t\t#cross section area of exit (m**2)\n",
      "\n",
      "#By the equation of continuity and since density of water remains constant\n",
      "u2 = (A1*u1)/A2;\n",
      "\n",
      "#By Bernoulli's equation between section 1 and 2 (Eq 5.20 Page no. 118)\n",
      "P_exit = (-((u2**2-u1**2)/2)-(g*z)+(P_ent*10**3/den))*(den/10**3)\n",
      "\n",
      "# Results\n",
      "print 'The pressure at exit is %f kPa'%P_exit\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The pressure at exit is 48.450000 kPa\n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.2"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#  To determine quality of steam flowing through the pipe\n",
      "\n",
      "# Variables\n",
      "#Given:\n",
      "P = 1000.; \t\t\t#pressure of saturated steam (kPa)\n",
      "T = 398.; \t\t\t#temperature of escaping steam (K)\n",
      "\n",
      "#Referring steam tables\n",
      "H_vap = 2778.; \t\t\t#enthalpy of saturated vapour at 1000 kPa (kJ/kg)\n",
      "H_liq = 763.; \t\t\t#enthalpy of saturated liquid at 1000 kPa (kJ/kg)\n",
      "H_steam = 2726.; \t\t#enthalpy of superheated steam at 398 K (kJ/kg)\n",
      "H2 = 2726; \t\t\t    #[kJ/kg]\n",
      "\n",
      "# Calculations\n",
      "#No work is done and no heat is exchanged between section 1 and 2\n",
      "#S0% H1 = H2\n",
      "x = (H2-H_vap)/(H_liq-H_vap)\n",
      "\n",
      "# Results\n",
      "print 'The steam contains %f percent liquid'%(x*100)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The steam contains 2.580645 percent liquid\n"
       ]
      }
     ],
     "prompt_number": 24
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.3, Page no:123"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#  To determine the discharge velocity\n",
      "\n",
      "# Variables\n",
      "#Given:\n",
      "m = 10.; \t\t\t#mass flow rate of steam (kg/s)\n",
      "H1 = 3062.; \t\t\t#enthalpy of entering steam (kJ/kg)\n",
      "H2 = 2875.; \t\t\t#enthalpy of discharged steam (kJ/kg)\n",
      "Q = -100./m; \t\t\t#heat loss to the surrounding (kJ/kg)\n",
      "u1 = 0.; \t\t\t#entering velocity of steam\n",
      "\n",
      "# Calculations\n",
      "import math\n",
      "H = H2-H1;\n",
      "u2 = math.sqrt((Q-H)*1000*2)\n",
      "\n",
      "# Results\n",
      "print 'The discharge velocity is %i m/s'%u2\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The discharge velocity is 594 m/s\n"
       ]
      }
     ],
     "prompt_number": 25
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.4, Page no:125"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#  To determine thermodynamic properties at throat and critical pressure\n",
      "\n",
      "# Variables\n",
      "#Given:\n",
      "To = 600.; \t\t\t#temperature of air (K)\n",
      "Po = 2000.; \t\t\t#pressure of air (kPa)\n",
      "gama = 1.4;\n",
      "M = 0.8; \t\t\t#Mach number at throat\n",
      "m = 29.; \t\t\t#molecular mass of air\n",
      "R = 8.314; \t\t\t#ideal gas constant\n",
      "\n",
      "#To determine thermodynamical properties at throat and critical pressure\n",
      "import math\n",
      "\n",
      "# Calculations and Results\n",
      "#(a)\n",
      "#Using equation 5.40 (Page no 123).. u**2 = (M**2)*gama*P*V\n",
      "#Substituting this in eq. 5.39 (Page no. 123) and on rearranging we get\n",
      "P = Po/((1+(((gama-1)/2)*M**2))**(gama/(gama-1)))\n",
      "#Using eq. 5.39 and the relation PoVo = RTo/m\n",
      "u = math.sqrt((2*gama*R*To*1000)/(m*(gama-1))*(1-(P/Po)**((gama-1)/gama)))\n",
      "#Using eq. 3.23 (Page no. 49)\n",
      "T = To*(P/Po)**((gama-1)/gama)\n",
      "#Let d be the density\n",
      "d_o = (Po*m)/(R*To)\n",
      "#Since P*(V**gama) = P/(den**gama) = constant...so\n",
      "d = d_o*((P/Po)**(1/gama))\n",
      "print '(a). At throat'\n",
      "print 'Pressure = %i kPa'%P\n",
      "print 'Temperature = %i K'%T\n",
      "print 'Velocity = %f m/s'%u\n",
      "print 'Density = %f kg/cubic m'%d\n",
      "\n",
      "#(b)\n",
      "#Using eq. 5.42 (Page no.124)\n",
      "Pc = Po*((2/(gama+1))**(gama/(gama-1))) \t\t\t#critical pressure\n",
      "print '(b).'\n",
      "print 'The critical pressure is %f kPa'%Pc\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a). At throat\n",
        "Pressure = 1312 kPa\n",
        "Temperature = 531 K\n",
        "Velocity = 369.641813 m/s\n",
        "Density = 8.603873 kg/cubic m\n",
        "(b).\n",
        "The critical pressure is 1056.563575 kPa\n"
       ]
      }
     ],
     "prompt_number": 26
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.7"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#  To calculate work required and temperature after compression\n",
      "\n",
      "# Variables\n",
      "P1 = 1.; \t\t\t#initial pressure (bar)\n",
      "T1 = 300.; \t\t\t#initial temperature (K)\n",
      "P2 = 10.; \t\t\t#final pressure (bar)\n",
      "gama = 1.3; \t\t\t#gama for CO2\n",
      "V_rate = 100.; \t\t\t#volumetric flow rate (m**3/h)\n",
      "\n",
      "# Calculations and Results\n",
      "#To calculate work required and temperature after compression\n",
      "Ws = (gama/(gama-1))*P1*10**5*(V_rate/3600)*(1-(P2/P1)**((gama-1)/gama))\n",
      "print 'The work required is %f kW'%(-Ws/1000)\n",
      "\n",
      "#Using equation 3.23 (Page no.49)\n",
      "T2 = T1*((P2/P1)**((gama-1)/gama))\n",
      "print 'Temperature of gas after compression is %f K'%T2\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The work required is 8.441024 kW\n",
        "Temperature of gas after compression is 510.376284 K\n"
       ]
      }
     ],
     "prompt_number": 27
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.8"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#  To calculate work required and temperature\n",
      "\n",
      "# Variables\n",
      "P1 = 100.; \t\t\t#initial pressure of saturated steam (kPa)\n",
      "P2 = 500.; \t\t\t#final pressure (kPa)\n",
      "eff = 0.8; \t\t\t#compression efficiency\n",
      "\n",
      "#Referring steam tables\n",
      "#Properties of steam entering the compressor\n",
      "H1 = 2675.5; \t\t\t#enthalpy (kJ/kg)\n",
      "S1 = 7.3594; \t\t\t#entropy (kJ/kg K)\n",
      "\n",
      "#Properties of compressed steam\n",
      "H2 = 3008.; \t\t\t#enthalpy (kJ/kg)\n",
      "S2 = S1; \t\t\t#isentropic compression\n",
      "\n",
      "\n",
      "# Calculations and Results\n",
      "#To calculate work required and temperature\n",
      "\n",
      "Hs = H2-H1;\n",
      "#Using eq. 5.44 (Page no. 128)\n",
      "W_isentropic = -Hs;\n",
      "W_act = W_isentropic/eff;\n",
      "print 'The work required for compression is %f kJ/kg'%-W_act\n",
      "\n",
      "H = Hs/eff; \t\t\t#actual change in enthalpy\n",
      "H_act = H1+H; \t\t\t#actual enthalpy of steam leaving the compressor\n",
      "#From steam tables for superheated steam at 500 kPa and enthalpy of H_act\n",
      "T = 586; \t\t\t#temperature (K)\n",
      "print 'Temperature of exhaust steam is %i K'%T\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The work required for compression is 415.625000 kJ/kg\n",
        "Temperature of exhaust steam is 586 K\n"
       ]
      }
     ],
     "prompt_number": 28
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.9"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#  To determine the least amount of power\n",
      "\n",
      "# Variables\n",
      "#Given:\n",
      "T1 = 288.; \t\t\t#temperature of surrounding (K)\n",
      "T2 = 261.; \t\t\t#temperature of solution (K)\n",
      "Q2 = 1000.; \t\t\t#heat removed (kJ/min)\n",
      "\n",
      "# Calculations\n",
      "#To determine the least amount of power\n",
      "#Using eq. 5.57 (Page no. 137)\n",
      "W = Q2*((T1-T2)/T2 )\t\t\t#power in kJ/min\n",
      "P = (W*1000)/(746.*60) \t\t\t#power in hp\n",
      "\n",
      "# Results\n",
      "print 'Least amount of power necessary is %f hp'%P"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Least amount of power necessary is 2.311177 hp\n"
       ]
      }
     ],
     "prompt_number": 29
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.10"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#  To determine COP heat rejected and lowest temperature\n",
      "\n",
      "# Variables\n",
      "#Given:\n",
      "T = 290.; \t\t\t#operating temperature (K)\n",
      "W = 1000.; \t\t\t#work (J)\n",
      "tof = 3516.67; \t\t\t#ton of refrigeration (W)\n",
      "\n",
      "# Calculations and Results\n",
      "#To determine COP, heat rejected and lowest temperature\n",
      "#(a)\n",
      "Q2 = tof;\n",
      "COP = Q2/W; \t\t\t#coeffecient of performance\n",
      "print '(a). COP is %f'%COP\n",
      "\n",
      "#(b)\n",
      "Q1 = Q2+W; \t\t\t#heat rejected\n",
      "print ' (b). Heat rejected is %f kW'%(Q1/1000.)\n",
      "\n",
      "#(c)\n",
      "#Let T2 be the lowest temperature\n",
      "T2 = T*(Q2/Q1);\n",
      "print ' (c). Lowest possible temperature in refrigerator is %f K'%T2\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a). COP is 3.516670\n",
        " (b). Heat rejected is 4.516670 kW\n",
        " (c). Lowest possible temperature in refrigerator is 225.793405 K\n"
       ]
      }
     ],
     "prompt_number": 30
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.11"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#  To determine COP at given conditions\n",
      "\n",
      "# Variables\n",
      "#Given:\n",
      "T2 = 266.;\n",
      "T1 = 300.; \t\t\t#operating temperatures of vapour compression refrigeration cycle(K)\n",
      "\n",
      "#To determine COP at given conditions\n",
      "#(a)\n",
      "Ha = 656.; \t\t\t#(kJ/kg)\n",
      "Hb = 724.; \t\t\t#(kJ/kg)\n",
      "Hd = 144.; \t\t\t#(kJ/kg)\n",
      "Hc = Hd;\n",
      "\n",
      "# Calculations and Results\n",
      "#Using eq. 5.61 (Page no. 139)\n",
      "COP = (Ha-Hd)/(Hb-Ha);\n",
      "print '(a). COP = %f'%COP\n",
      "\n",
      "#(b)\n",
      "Ha = 652.; \t\t\t#(kJ/kg)\n",
      "Hb = 758.; \t\t\t#(kJ/kg)\n",
      "Hd = 159.; \t\t\t#(kJ/kg)\n",
      "Hc = Hd;\n",
      "eff = 0.75; \t\t\t#efficiency of compressor\n",
      "COP = (Ha-Hd)/((Hb-Ha)*(1./eff));\n",
      "print ' (b). COP = %f'%COP\n",
      "\n",
      "#(c). Ideal Carnot refrigerator\n",
      "COP = T2/(T1-T2);\n",
      "print ' (c). COP = %f'%COP\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a). COP = 7.529412\n",
        " (b). COP = 3.488208\n",
        " (c). COP = 7.823529\n"
       ]
      }
     ],
     "prompt_number": 31
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.12 "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# To determine power requirement and refrigeration capacity in tonnes\n",
      "\n",
      "# Variables\n",
      "#Given:\n",
      "Tin_cool = 288.; \t\t\t#entering temperature of cooling water (K)\n",
      "Tout_cool = 300.; \t\t\t#discharge temperature of cooling water (K)\n",
      "m_c = 0.25; \t\t\t#mass flow rate of coling water (kg/s)\n",
      "m = 0.5; \t\t\t#mass flow rate of ammonia (kg/min)\n",
      "Ha = 1426.; \t\t\t#enthalpy of saturated ammonia vapour at 258 K (kJ/kg)\n",
      "Hd = 281.5; \t\t\t#enthalpy of liquid ammonia at 294 K (kJ/kg)\n",
      "eff = 0.9; \t\t\t#compressor efficiency\n",
      "Cp = 4.2; \t\t\t#specific heat of water (kJ/kg K)\n",
      "tof = 12660.; \t\t\t#ton of refrigeration (kJ/h)\n",
      "\n",
      "# Calculations and Results\n",
      "#To determine the power requirement and refrigeration capacity in tons\n",
      "Q1 = m_c*Cp*(Tout_cool-Tin_cool); \t\t\t#heat rejected by compressor at constant pressure (kJ/s)\n",
      "Q2 = (m/60.)*(Ha-Hd); \t\t\t#heat absorbed (kJ/s)\n",
      "W = Q1-Q2; \t\t\t#work required (kJ/s)\n",
      "P = (W*1000)/(eff*746); \t\t\t#power requirement of compressor (hp)\n",
      "print 'Power requirement of the compressor is %f hp'%P\n",
      "\n",
      "rc = Q2*3600/tof; \t\t\t#refrigeration capacity (ton)\n",
      "print ' Refrigeration capacity is %f ton'%rc\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Power requirement of the compressor is 4.561364 hp\n",
        " Refrigeration capacity is 2.712085 ton\n"
       ]
      }
     ],
     "prompt_number": 32
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.13"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#  To calculate the COP and refrigeration circulation rate\n",
      "\n",
      "# Variables\n",
      "#Given:\n",
      "m1 = 10.; \t\t\t#machine rating (ton)\n",
      "#Since 5 K approach is necessary\n",
      "T1 = 293.+5; \t\t\t#temperature of cooling water (K)\n",
      "T2 = 261.-5; \t\t\t#temperature of cold storage (K)\n",
      "Ha = 181.; \t\t\t#enthalpy of saturated vapour at 256 K (kJ/kg)\n",
      "Sa = 0.714; \t\t\t#entropy of saturated vapour at 256K (kJ/kg K)\n",
      "Hc = 62.; \t\t\t#enthalpy of saturated liquid at 298 K (kJ/kg)\n",
      "Sc = 0.231; \t\t\t#entropy of saturated liquid at 298 K (kJ/kg K)\n",
      "Hb = 206.; \t\t\t#enthalpy of superheated vapour (kJ/kg)\n",
      "Sb = 0.714; \t\t\t#entropy of superheated vapour (kJ/kg)\n",
      "\n",
      "# Calculations and Results\n",
      "#Combining the three relations, we get\n",
      "Sd = Sc; \t\t\t#isentropic process\n",
      "Hd = Ha-(T2*(Sa-Sd));\n",
      "\n",
      "#Using eq. 5.64 (Page no. 141)\n",
      "COP = (Ha-Hd)/((Hb-Hc)-(Ha-Hd));\n",
      "print 'COP = %f'%COP\n",
      "\n",
      "#Using equation 5.63 (Page no. 140)\n",
      "m = (12660*m1)/(Ha-Hd); \t\t\t#refrigerant circulation rate (kg/h)\n",
      "print ' Refrigerant circulation rate is %f kg/h'%m\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "COP = 6.075472\n",
        " Refrigerant circulation rate is 1023.874224 kg/h\n"
       ]
      }
     ],
     "prompt_number": 33
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.14"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#  To determine the COP and air circulation rate\n",
      "\n",
      "# Variables\n",
      "#Given:\n",
      "m1 = 10.; \t\t\t#machine rating (ton)\n",
      "#Assuming 5 K approach in refrigerator and cooler\n",
      "Ta = 261.-5; \t\t\t#temperature of air leaving the refrigerator (K)\n",
      "Tc = 293.+5; \t\t\t#temperature of air leaving the cooler (K)\n",
      "gama = 1.4;\n",
      "Cp = 1.008; \t\t\t#sp. heat of air (kJ/kg K)\n",
      "P1 = 4.052;\n",
      "P2 = 1.013; \t\t\t#operating pressures in bar\n",
      "\n",
      "# Calculations and Results\n",
      "#To determine the COP and air circulation rate\n",
      "#Using eq. 5.66 (Page no. 145)\n",
      "Tb = Ta*(P1/P2)**((gama-1)/gama)\n",
      "Td = (Tc*Ta)/Tb;\n",
      "\n",
      "#Using equation 5.68 (PAge no. 146)\n",
      "COP = Ta/(Tb-Ta)\n",
      "print 'COP = %f'%COP\n",
      "\n",
      "#Considering energy balance in refrigerator [m*Cp*(Ta-Td) = m1*12660]\n",
      "m = (m1*12660)/(Cp*(Ta-Td)) \t\t\t#air circulation rate (kg/h)\n",
      "print ' Air circulation rate is %i kg/h'%m\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "COP = 2.057637\n",
        " Air circulation rate is 2264 kg/h\n"
       ]
      }
     ],
     "prompt_number": 34
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.15"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#  To verify that given heat pump is equivalent to 30 kW pump\n",
      "\n",
      "# Variables\n",
      "#Given:\n",
      "T1 = 300.; \t\t\t#indoor temperatur (K)\n",
      "T2 = 290.; \t\t\t#outside temperature (K)\n",
      "W_input = 1.; \t\t\t#1 kW heat pump\n",
      "W_output = 30.; \t\t\t#given output (kW)\n",
      "\n",
      "# Calculations and Results\n",
      "#To verify that given heat pump is equivalent to 30 kW heater\n",
      "Q2 = (T2/(T1-T2))*W_input; \t\t\t#heat absorbed\n",
      "Q1 = Q2 + W_input; \t\t\t#heat rejected\n",
      "\n",
      "if(Q1==W_output):\n",
      "     print '1 kW pump if operated reversibly% is equivalent to a 30 kW heater'\n",
      "else:\n",
      "     print 'The given heat pump is not equivalent to a 30 kW heater'\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "1 kW pump if operated reversibly% is equivalent to a 30 kW heater\n"
       ]
      }
     ],
     "prompt_number": 35
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.16"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#  To determine the amount of fuel burned\n",
      "\n",
      "# Variables\n",
      "#Given:\n",
      "T1 = 295.; \t\t\t#temperature inside building (K)\n",
      "T2 = 275.; \t\t\t#temperature of outside air (K)\n",
      "eff = 0.25; \t\t\t#overall efficiency of unit\n",
      "Hc = 890.9; \t\t\t#heat of combustion of fuel (kJ/mol)\n",
      "conv = 0.33; \t\t\t#efficiency of conversion of heat of combustion to electricity\n",
      "Q1 = 10**6; \t\t\t#amount of heat to be delivered\n",
      "\n",
      "# Calculations\n",
      "#To determine the amount of fuel burned\n",
      "COP = T1/(T1-T2)\n",
      "W = Q1/COP; \t\t\t#work required to deliver Q1 kJ of heat\n",
      "W_act = W/eff; \t\t\t#actual amount of electrical energy to be supplied\n",
      "W_heat = W_act/conv; \t\t\t#heat energy required as heat of combustion\n",
      "n = W_heat/Hc; \t\t\t#number of moles of fuel burned\n",
      "\n",
      "# Results\n",
      "print 'The amount of fuel burned is %f kmol'%(n/1000)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The amount of fuel burned is 0.922412 kmol\n"
       ]
      }
     ],
     "prompt_number": 36
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.17"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#  To calculate fraction of liquid in inlet stream and temperature\n",
      "\n",
      "# Variables\n",
      "#Given:\n",
      "#Referring steam tables at 2.54 bar\n",
      "H1 = 2717.; \t\t\t#enthalpy of saturated vapour (kJ/kg)\n",
      "H2 = 538.; \t\t\t#enthalpy of saturated liquid (kJ/kg)\n",
      "S1 = 7.05; \t\t\t#entropy of saturated vapour (kJ/kg K)\n",
      "S2 = 1.61; \t\t\t#entropy of saturated liquid (kJ/kg K)\n",
      "\n",
      "H = 2700.; \t\t\t#enthalpy of superheated steam at 1 bar and 385 K (kJ/kg)\n",
      "S = 7.42; \t\t\t#entropy of superheated steam at 1 bar and 385 K (kJ/kg K)\n",
      "\n",
      "# Calculations and Results\n",
      "x = (H-H1)/(H2-H1)\n",
      "#From steam tables\n",
      "T = 401.; \t\t\t#temperature of steam (K)\n",
      "print '(a). For isenthalpic math.expansion'\n",
      "print ' The fraction of liquid in inlet stream is %f'%x\n",
      "print ' The temperature of stream is %i K'%T\n",
      "\n",
      "#(b)..The math.expansion is isentropic\n",
      "#Since entropy of saturated vapour at inlet pressure (S1) is less than entropy of steam leaving the turbine (S)\n",
      "#So% the inlet stream is superheated% therefore\n",
      "x = 0;\n",
      "#From steam tales\n",
      "T = 478.; \t\t\t#temperature of superheated steam having entropy of 7.42 kJ/kg K\n",
      "print '(b). For isentropic math.expansion'\n",
      "print ' The fraction of liquid in inlet stream is %i'%x\n",
      "print ' The temperature of stream is %i K'%T\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a). For isenthalpic math.expansion\n",
        " The fraction of liquid in inlet stream is 0.007802\n",
        " The temperature of stream is 401 K\n",
        "(b). For isentropic math.expansion\n",
        " The fraction of liquid in inlet stream is 0\n",
        " The temperature of stream is 478 K\n"
       ]
      }
     ],
     "prompt_number": 37
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.18"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#  To determine fraction of air liquified and temperature of air\n",
      "\n",
      "# Variables\n",
      "#Given:\n",
      "#Referring Fig. 5.15 (Page no. 151)\n",
      "Hc = 516.; \t\t\t#enthalpy of high pressure gas at 120 bar and 306 K (kJ/kg)\n",
      "Ha = 526.; \t\t\t#enthalpy of low pressure gas at 2 bar and 292 K (kJ/kg)\n",
      "Hf = 121.; \t\t\t#entalpy of saturated liquid at 2 bar (kJ/kg)\n",
      "Hg = 314.; \t\t\t#enthalpy of saturated vapour at 2 bar (kJ/kg)\n",
      "\n",
      "#To determine the fraction of air liquified and temperature of air\n",
      "\n",
      "# Calculations and Results\n",
      "#(a)..\n",
      "#Using equation 5.73 (Page no. 152)\n",
      "x = (Hc-Ha)/(Hf-Ha) \t\t\t#fraction of air liquified\n",
      "print '(a). The fraction of liquified air is %f'%x\n",
      "\n",
      "#(b)..\n",
      "#Taking enthalpy balance around heat exchanger\n",
      "Hd = Hc - (1-x)*(Ha-Hg)\n",
      "#At enthalpy of Hd kJ/kg% from T-S diagram for air\n",
      "T = 167.; \t\t\t#temperature in K\n",
      "print ' (b). Temperature of air on high pressure side of throttle valve is %i K'%T\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a). The fraction of liquified air is 0.024691\n",
        " (b). Temperature of air on high pressure side of throttle valve is 167 K\n"
       ]
      }
     ],
     "prompt_number": 38
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.19"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#  To determine ideal Rankine cycle efficiency thermal efficiency and rate of steam production\n",
      "\n",
      "# Variables\n",
      "#Given:\n",
      "P2 = 2800.; \t\t\t#pressure of superheated steam (kPa)\n",
      "P1 = 5.; \t\t\t#pressure after math.expansion (kPa)\n",
      "e_turbine = 0.85; \t\t\t#isentropic turbine efficiency\n",
      "e_pump = 0.8; \t\t\t#isentropic pump efficiency\n",
      "V = 1.005*10**-3; \t\t\t#specific volume of saturated liquid at 5 kPaHl = \n",
      "\n",
      "#From steam tables:\n",
      "Hl = 138.; \t\t\t#enthalpy of saturated liquid at 5 kPa (kJ/kg)\n",
      "Hv = 2562.; \t\t\t#enthalpy of saturated vapour at 5 kPa (kJ/kg)\n",
      "H3 = 3063.; \t\t\t#enthalpy of superheated steam at 2800 kPa and 598 K (kJ/kg)\n",
      "Sl = 0.4764; \t\t\t#entropy of saturated liquid at 5 kPa (kJ/kg K)\n",
      "Sv = 8.3951; \t\t\t#entropy of saturated vapour at 5 kPa (kJ/kg K)\n",
      "S3 = 6.6875; \t\t\t#entropy of superheated steam at 2800 kPa and 598 K (kJ/kg K)\n",
      " \n",
      "\n",
      "# Calculations and Results\n",
      "#To determine the ideal Rankine cycle efficiency% thermal efficiency and rate of steam production\n",
      "\n",
      "#(a)..The ideal Rankine cycle efficiency for the stated conditions\n",
      "#Referring fig 5.19(b) (Page no. 155) and considering feed water pump\n",
      "Ws = V*(P2-P1) \t\t\t#work done by pump (kJ/kg)\n",
      "H2 = Hl+Ws;\n",
      "#Considering isentropic math.expansion in turbine\n",
      "S4 = S3;\n",
      "x = (S4-Sl)/(Sv-Sl) \t\t\t#fraction of steam that is vapour\n",
      "H4 = Hl + x*(Hv-Hl)\n",
      "\t\t\t#Using eq. 5.80 (Page no. 155)\n",
      "e_r = ((H3-H2)-(H4-Hl))/(H3-H2)\n",
      "print '(a). The ideal Rankine cycle efficiency for the stated conditions is %i percent'%(e_r*100)\n",
      "\n",
      "#(b)..The thermal efficiency of plant\n",
      "W_act = Ws/e_pump; \t\t\t#actual work requirement in pump\n",
      "H_2 = Hl + W_act; \t\t\t#enthalpy of water leaving the feed water pump\n",
      "W_out = e_turbine*(H3-H4) \t\t\t#actual work output\n",
      "H_4 = H3-W_out; \t\t\t#actual enthalpy of steam leaving the turbine\n",
      "e_act = ((H3-H_2)-(H_4-Hl))/(H3-H_2)\n",
      "print ' (b). The actual efficiency is %f percent'%(e_act*100)\n",
      "\n",
      "#(c)..The rate of steam production\n",
      "W_net = e_act*(H3-H_2) \t\t\t#net work output (kJ/kg)\n",
      "rate = (3.6*10**6)/W_net; \t\t\t#steam produced in boiler (kg/h)\n",
      "print ' (c). The rate of steam production is %f kg/h'%(rate)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a). The ideal Rankine cycle efficiency for the stated conditions is 34 percent\n",
        " (b). The actual efficiency is 29.664548 percent\n",
        " (c). The rate of steam production is 4153.943111 kg/h\n"
       ]
      }
     ],
     "prompt_number": 39
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.20"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#  To determine the work output thermal efficiency and rate of steam circulation\n",
      "\n",
      "# Variables\n",
      "#Given:\n",
      "P2 = 7600.; \t\t\t#pressure of superheated steam (kPa)\n",
      "P1 = 5.; \t\t\t#pressure after math.expansion (kPa)\n",
      "V = 1.005*10**-3; \t\t\t#specific volume of saturated liquid (m**3/kg)\n",
      "\n",
      "#From steam tables:\n",
      "H_l1 = 138.; \t\t\t#enthalpy of saturated liquid at 5 kPa (kJ/kg)\n",
      "S_l1 = 0.4764; \t\t\t#entropy of saturated liquid at 5 kPa (kJ/kg K)\n",
      "H_v1 = 2562.; \t\t\t#enthalpy of saturated vapour at 5 kPa (kJ/kg)\n",
      "S_v1 = 8.3951; \t\t\t#entropy of saturated vapour at 5 kPa (kJ/kg K)\n",
      "H_l2 = 830.; \t\t\t#enthalpy of saturated liquid at 1400 kPa(kJ/kg)\n",
      "S_l2 = 2.2842; \t\t\t#entropy of saturated liquid at 1400 kPa (kJ/kg K)\n",
      "H_v2 = 2790.; \t\t\t#enthalpy of saturated vapour at 1400 kPa (kJ/kg)\n",
      "S_v2 = 6.4693; \t\t\t#entropy of saturated vapour at 1400 kPa (kJ/kg K)\n",
      "H5 = 3226.; \t\t\t#enthalpy of superheated steam at 1400 kPa and 658 K\n",
      "S5 = 7.2558; \t\t\t#entropy of superheated steam at 1400 kPa and 658 K\n",
      "H3 = 3150.; \t\t\t#enthalpy of superheated steam at 7600 kPa and 673 K\n",
      "S3 = 6.4022; \t\t\t#entropy of superheated steam at 1400 kPa and 673 K\n",
      "\n",
      "# Calculations and Results\n",
      "#Let the fraction of steam in vapour state be x\n",
      "S4 = S3; \t\t\t#as the math.expansion process is isentropic\n",
      "x = (S4-S_l2)/(S_v2-S_l2)\n",
      "H4 = H_l2 + x*(H_v2-H_l2)\n",
      "W_high = H3-H4;\n",
      "\n",
      "#For low pressure turbine\n",
      "S6 = S5; \t\t\t#isentropic math.expansion\n",
      "x = (S6-S_l1)/(S_v1-S_l1)\n",
      "H6 = H_l1 + x*(H_v1-H_l1)\n",
      "W_low = H5-H6;\n",
      "\n",
      "print '(a)'\n",
      "print ' The work output of high pressure turbine is %i kJ/kg'%W_high\n",
      "print ' The work output of low pressure turbine is %i kJ/kg'%W_low\n",
      "\n",
      "#(b)\n",
      "#Work output of feed pump is [-Ws = intg(VdP)]\n",
      "Ws = V*(P2-P1)\n",
      "H2 = H_l1+Ws;\n",
      "#Using eq. 5.82 (Page no. 159)\n",
      "eff = ((H3-H2)+(H5-H4)-(H6-H_l1))/((H3-H2)+(H5-H4))\n",
      "print ' (b)'\n",
      "print ' Thermal efficiency is %f percent'%(eff*100)\n",
      "\n",
      "#(c)\n",
      "#The numerator of eq. 5.82 gives net work output\n",
      "W_net = (H3-H2)+(H5-H4)-(H6-H_l1)\n",
      "#For 1000 kW of net work output\n",
      "rate = 3.6*10**6/W_net;\n",
      "print ' (c)'\n",
      "print ' The rate of steam circulation is %f kg/h'%rate\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a)\n",
        " The work output of high pressure turbine is 391 kJ/kg\n",
        " The work output of low pressure turbine is 1012 kJ/kg\n",
        " (b)\n",
        " Thermal efficiency is 40.225451 percent\n",
        " (c)\n",
        " The rate of steam circulation is 2577.792156 kg/h\n"
       ]
      }
     ],
     "prompt_number": 40
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.21"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#  To determine fraction of steam withdrawn and thermal efficiency of cycle\n",
      "\n",
      "# Variables\n",
      "#Given:\n",
      "P2 = 2800.; \t\t\t#pressure of superheated steam (kPa)\n",
      "P1 = 275.; \t\t\t#pressure of withdrawn steam (kPa)\n",
      "V = 1.070*10**-3; \t\t\t#specific volume of saturated liquid at 275 kPa\n",
      "\n",
      "#From steam tables:\n",
      "H6 = 138.; \t\t    \t#enthalpy of saturated liquid at 5 kPa\n",
      "S6 = 0.4764; \t\t\t#entropy of saturated liquid at 5 kPa\n",
      "H_v1 = 2562.; \t\t\t#enthalpy of saturated vapour at 5 kPa\n",
      "S_v1 = 8.3951; \t\t\t#entropy of saturated vapour at 5 kPa\n",
      "H1 = 549.; \t\t\t    #enthalpy of saturated liquid at 275 kPa\n",
      "S1 = 1.6408; \t\t\t#entropy of saturated liquid at 275 kPa\n",
      "H_v2 = 2721.; \t\t\t#enthalpy of saturated vapour at 275 kPa\n",
      "S_v2 = 7.0209; \t\t\t#entropy of saturated vapour at 275 kPa\n",
      "H3 = 3063.; \t\t\t#enthalpy of superheated steam at 2800 kPa and 598 K\n",
      "S3 = 6.6875; \t\t\t#entropy of superheated steam at 2800 kPa and 598 K\n",
      "\n",
      "# Calculations and Results\n",
      "#To determine the fraction of steam withdrawn and thermal efficiency of cycle\n",
      "#Referring fig. 5.23 (Page no.161)\n",
      "S4 = S3;            \t\t\t#isentropic math.expansion\n",
      "x = (S4-S1)/(S_v2-S1) \t\t\t#quality of steam\n",
      "H4 = H1 + x*(H_v2-H1)\n",
      "H7 = H6; \t\t\t            #as the power input to the condensate pump is neglegible\n",
      "\n",
      "#Applying energy balance around feed water heater\n",
      "m = (H1-H7)/(H4-H7 )\t\t\t#fraction of steam extracted\n",
      "print 'Fraction of steam withdrawn is %f'%m\n",
      "\n",
      "W_in = V*(P2-P1) \t\t\t#work input to the feed water pump\n",
      "H2 = H1+W_in;\n",
      "#Considering isentropic math.expansion in turbine\n",
      "S5 = S3;\n",
      "x = (S5-S6)/(S_v1-S6)\n",
      "H5 = H6 + x*(H_v1-H6)\n",
      "#Using eq. 5.85 (Page no.162)\n",
      "eff = ((H3-H2)-(1-m)*(H5-H6))/(H3-H2)\n",
      "print ' Thermal efficiency is %f percent'%(eff*100)\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Fraction of steam withdrawn is 0.167865\n",
        " Thermal efficiency is 36.999645 percent\n"
       ]
      }
     ],
     "prompt_number": 41
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.22"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#  To determine mean effective pressure\n",
      "\n",
      "# Variables\n",
      "#Given:\n",
      "r = 8.; \t\t\t#compression ratio\n",
      "T1 = 290.; \t\t\t#temperature at beginning (K)\n",
      "P1 = 100.; \t\t\t#pressure at the beginning (kPa)\n",
      "Q1 = 450.; \t\t\t#heat transferred per cycle (kJ/kg K)\n",
      "Cp = 1.005; \t\t\t#specific heat of air (kJ/kg K)\n",
      "Cv = 0.718; \t\t\t#specific heat of air (kJ/kg K)\n",
      "R = 8.314; \t\t\t#ideal gas constant\n",
      "M = 29.; \t\t\t#molecular wt of air\n",
      "\n",
      "#To determine mean effective pressure\n",
      "#Basis:\n",
      "m = 1.; \t\t\t#mass of air (kg)\n",
      "\n",
      "# Calculations and Results\n",
      "#(a)\n",
      "#Referring fig. 5.24 (Page no. 164)\n",
      "V1 = (m*R*1000*T1)/(M*P1*10**3)\n",
      "\n",
      "#Conditions at state 2\n",
      "V2 = V1/r;\n",
      "gama = Cp/Cv;\n",
      "T2 = T1*(r**(gama-1))\n",
      "P2 = P1*(r**gama )\n",
      "print '(a)'\n",
      "print ' At the end of first process'\n",
      "print ' Temperature = %f K'%T2\n",
      "print ' Pressure = %f kPa'%P2\n",
      "\n",
      "#Conditions at state 3\n",
      "#Constant volume process\n",
      "V3 = V2;\n",
      "T3 = Q1/Cv + T2;\n",
      "P3 = (T3/T2)*P2;\n",
      "print ' At the end of second process'\n",
      "print ' Temperature = %f K'%T3\n",
      "print ' Pressure = %f kPa'%P3\n",
      "\n",
      "#Conditions at state 4\n",
      "T4 = T3/(r**(gama-1))\n",
      "P4 = P3/(r**gama)\n",
      "print ' At the end of third process'\n",
      "print ' Temperature = %f K'%T4\n",
      "print ' Pressure = %f kPa'%P4\n",
      "Q2 = Cv*(T4-T1) \t\t\t#heat rejected during the constant volume process\n",
      "\n",
      "#(b)\n",
      "#Using eq. 5.88 (Page no. 165)\n",
      "eff = 1 - ((1./r)**(gama-1))\n",
      "print ' (b)'\n",
      "print ' Thermal efficiency is %f'%eff\n",
      "\n",
      "#(c)\n",
      "W = Q1-Q2; \t\t\t#work done\n",
      "print ' (c)'\n",
      "print ' Work done is %f kJ/kg'%W\n",
      "\n",
      "#(d)\n",
      "Pm = W/(V1-V2)\n",
      "print ' (d)'\n",
      "print ' Mean effective pressure is %f kPa'%Pm\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a)\n",
        " At the end of first process\n",
        " Temperature = 665.859247 K\n",
        " Pressure = 1836.853096 kPa\n",
        " At the end of second process\n",
        " Temperature = 1292.600195 K\n",
        " Pressure = 3565.793640 kPa\n",
        " At the end of third process\n",
        " Temperature = 562.962905 K\n",
        " Pressure = 194.125140 kPa\n",
        " (b)\n",
        " Thermal efficiency is 0.564473\n",
        " (c)\n",
        " Work done is 254.012634 kJ/kg\n",
        " (d)\n",
        " Mean effective pressure is 349.170259 kPa\n"
       ]
      }
     ],
     "prompt_number": 42
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.23"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#  To determine work done thermal effeciency and mean effective pressure\n",
      "\n",
      "# Variables\n",
      "#Given:\n",
      "r = 15.; \t\t\t#compression ratio\n",
      "P1 = 100.; \t\t\t#pressure in the beginning (kPa)\n",
      "T1 = 300.; \t\t\t#temperature in thebeginning (K)\n",
      "Q1 = 500.; \t\t\t#heat transfer rate (kJ/kg)\n",
      "M = 29.; \t\t\t#molecular wt of air\n",
      "R = 8.314; \t\t\t#ideal gas constant\n",
      "gama = 1.3997214\n",
      "#Specific heats of air (kJ/kg K)\n",
      "Cp = 1.005;\n",
      "Cv = 0.718;\n",
      "\n",
      "# Calculations and Results\n",
      "#To determine work done thermal efficiency and mean effective pressure\n",
      "#(a)\n",
      "#Isentropic compression 1-2\n",
      "V1 = (R*1000*T1)/(M*P1*10**3)\n",
      "T2 = T1*r**(gama-1)\n",
      "P2 = P1*r**gama;\n",
      "V2 = V1/r;\n",
      "print '(a)'\n",
      "print ' At the end of first process'\n",
      "print ' Temperature = %f K'%T2\n",
      "print ' Pressure = %f kPa'%P2\n",
      "\n",
      "#Consatnt pressure heat addition 2-3\n",
      "T3 = Q1/Cp + T2;\n",
      "V3 = (T3/T2)*V2;\n",
      "P3 = P2;\n",
      "print ' At the end of second process'\n",
      "print ' Temperature = %f k'%T3\n",
      "print ' Pressure = %f kPa'%P3\n",
      "\n",
      "#Isentropic math.expansion 3-4\n",
      "V4 = V1;\n",
      "T4 = T3/((V4/V3)**(gama-1))\n",
      "P4 = P3*((V3/V4)**gama)\n",
      "print ' At the end of third process'\n",
      "print ' Temperature = %f K'%T4\n",
      "print ' Pressure = %f kPa'%P4\n",
      "Q2 = Cv*(T4-T1) \t\t\t#heat rejected 4-1\n",
      "\n",
      "#(b)\n",
      "Wnet = Q1-Q2;\n",
      "print ' (b)'\n",
      "print ' Net work done per cycle per kg air is %f kJ/kg'%Wnet\n",
      "\n",
      "#(c)\n",
      "eff = Wnet/Q1; \t\t\t#thermal efficiency\n",
      "print ' (c)'\n",
      "print ' Thermal efficiency is %f'%eff\n",
      "\n",
      "#(d)\n",
      "Pm = Wnet/(V1-V2) \t\t\t#mean effective pressure\n",
      "print ' (d)'\n",
      "print ' Mean effective pressure is %f kPa'%Pm\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a)\n",
        " At the end of first process\n",
        " Temperature = 885.584689 K\n",
        " Pressure = 4427.923445 kPa\n",
        " At the end of second process\n",
        " Temperature = 1383.097127 k\n",
        " Pressure = 4427.923445 kPa\n",
        " At the end of third process\n",
        " Temperature = 559.936687 K\n",
        " Pressure = 186.645562 kPa\n",
        " (b)\n",
        " Net work done per cycle per kg air is 313.365459 kJ/kg\n",
        " (c)\n",
        " Thermal efficiency is 0.626731\n",
        " (d)\n",
        " Mean effective pressure is 390.374167 kPa\n"
       ]
      }
     ],
     "prompt_number": 43
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.24"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#  To determine temperature pressure work and thermal effeciency\n",
      "\n",
      "# Variables\n",
      "#Given:\n",
      "T1 = 300.; \t\t\t#initial temperature (K)\n",
      "P1 = 100.; \t\t\t#initial pressure (kPa)\n",
      "T3 = 1200.; \t\t\t#max temperature (K)\n",
      "P3 = 500.; \t\t\t#max pressure (kPa)\n",
      "Cp = 1.005; \t\t\t#(kJ/kg K)\n",
      "Cv = 0.718; \t\t\t#(kJ/kg K)\n",
      "\n",
      "# Calculations and Results\n",
      "#To determine pressure and temperature work and thermal efficiency\n",
      "gama = Cp/Cv;\n",
      "\n",
      "#(a)\n",
      "P4 = P1;\n",
      "P2 = P3;\n",
      "#Isentropic compression 1-2\n",
      "T2 = T1*((P2/P1)**((gama-1)/gama))\n",
      "print '(a)'\n",
      "print ' At the end of first process'\n",
      "print ' Temperature = %f K'%T2\n",
      "print ' Pressure = %f kPa'%P2\n",
      "\n",
      "#Process 2-3\n",
      "print ' At the end of second process'\n",
      "print ' Temperature = %f K'%T3\n",
      "print ' Pressure = %f kPa'%P3\n",
      "\n",
      "#Isentropic math.expansion 3-4\n",
      "T4 = T3/((P3/P4)**((gama-1)/gama))\n",
      "print ' At the end of third process'\n",
      "print ' Temperature = %f K'%T4\n",
      "print ' Pressure = %f kPa'%P4\n",
      "\n",
      "#(b)\n",
      "W_comp = Cp*(T2-T1) \t\t\t#work required by compressor\n",
      "print ' (b)'\n",
      "print ' Work required by compressor is %f kJ/kg'%W_comp\n",
      "\n",
      "#(c)\n",
      "W_turb = Cp*(T3-T4 )\t\t\t#work done by turbine\n",
      "print ' (c)'\n",
      "print ' Work done by turbine is %f kJ/kg'%W_turb\n",
      "\n",
      "#(d)\n",
      "eff = 1-(P1/P2)**((gama-1)/gama)\n",
      "print ' (d)'\n",
      "print ' Thermal efficiency is %f'%eff\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a)\n",
        " At the end of first process\n",
        " Temperature = 475.037193 K\n",
        " Pressure = 500.000000 kPa\n",
        " At the end of second process\n",
        " Temperature = 1200.000000 K\n",
        " Pressure = 500.000000 kPa\n",
        " At the end of third process\n",
        " Temperature = 757.835397 K\n",
        " Pressure = 100.000000 kPa\n",
        " (b)\n",
        " Work required by compressor is 175.912379 kJ/kg\n",
        " (c)\n",
        " Work done by turbine is 444.375426 kJ/kg\n",
        " (d)\n",
        " Thermal efficiency is 0.368471\n"
       ]
      }
     ],
     "prompt_number": 44
    }
   ],
   "metadata": {}
  }
 ]
}