summaryrefslogtreecommitdiff
path: root/_Engineering_Thermodynamics_by__O._Singh/chapter8_3.ipynb
blob: 5088b9af6719b144389ec5a917e6a205a474b5a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#Chapter 8:Vapour Power Cycles"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 8.1;pg no: 260"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 8.1, Page:260  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 8 Example 1\n",
      "T-S representation for carnot cycle operating between pressure of 7 MPa and 7KPa is shown in fig.\n",
      "enthalpy at state 2,h2= hg at 7 MPa\n",
      "from steam table,h=2772.1 KJ/kg\n",
      "entropy at state 2,s2=sg at 7MPa\n",
      "from steam table,s2=5.8133 KJ/kg K\n",
      "enthalpy and entropy at state 3,\n",
      "from steam table,h3=hf at 7 MPa =1267 KJ/kg and s3=sf at 7 MPa=3.1211 KJ/kg K\n",
      "for process 2-1,s1=s2.Let dryness fraction at state 1 be x1 \n",
      "from steam table, sf at 7 KPa=0.5564 KJ/kg K,sfg at 7 KPa=7.7237 KJ/kg K\n",
      "s1=s2=sf+x1*sfg\n",
      "so x1= 0.68\n",
      "from steam table,hf at 7 KPa=162.60 KJ/kg,hfg at 7 KPa=2409.54 KJ/kg\n",
      "enthalpy at state 1,h1 in KJ/kg= 1802.53\n",
      "let dryness fraction at state 4 be x4\n",
      "for process 4-3,s4=s3=sf+x4*sfg\n",
      "so x4= 0.33\n",
      "enthalpy at state 4,h4 in KJ/kg= 962.81\n",
      "thermal efficiency=net work/heat added\n",
      "expansion work per kg=(h2-h1) in KJ/kg 969.57\n",
      "compression work per kg=(h3-h4) in KJ/kg(+ve) 304.19\n",
      "heat added per kg=(h2-h3) in KJ/kg(-ve) 1505.1\n",
      "net work per kg=(h2-h1)-(h3-h4) in KJ/kg 665.38\n",
      "thermal efficiency 0.44\n",
      "in percentage 44.21\n",
      "so thermal efficiency=44.21%\n",
      "turbine work=969.57 KJ/kg(+ve)\n",
      "compression work=304.19 KJ/kg(-ve)\n"
     ]
    }
   ],
   "source": [
    "#cal of thermal efficiency,turbine work,compression work\n",
    "#intiation of all variables\n",
    "# Chapter 8\n",
    "print\"Example 8.1, Page:260  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 8 Example 1\")\n",
    "print(\"T-S representation for carnot cycle operating between pressure of 7 MPa and 7KPa is shown in fig.\")\n",
    "print(\"enthalpy at state 2,h2= hg at 7 MPa\")\n",
    "print(\"from steam table,h=2772.1 KJ/kg\")\n",
    "h2=2772.1;\n",
    "print(\"entropy at state 2,s2=sg at 7MPa\")\n",
    "print(\"from steam table,s2=5.8133 KJ/kg K\")\n",
    "s2=5.8133;\n",
    "print(\"enthalpy and entropy at state 3,\")\n",
    "print(\"from steam table,h3=hf at 7 MPa =1267 KJ/kg and s3=sf at 7 MPa=3.1211 KJ/kg K\")\n",
    "h3=1267;\n",
    "s3=3.1211;\n",
    "print(\"for process 2-1,s1=s2.Let dryness fraction at state 1 be x1 \")\n",
    "s1=s2;\n",
    "print(\"from steam table, sf at 7 KPa=0.5564 KJ/kg K,sfg at 7 KPa=7.7237 KJ/kg K\")\n",
    "sf=0.5564;\n",
    "sfg=7.7237;\n",
    "print(\"s1=s2=sf+x1*sfg\")\n",
    "x1=(s2-sf)/sfg\n",
    "print(\"so x1=\"),round(x1,2) \n",
    "x1=0.6806;#approx.\n",
    "print(\"from steam table,hf at 7 KPa=162.60 KJ/kg,hfg at 7 KPa=2409.54 KJ/kg\")\n",
    "hf=162.60;\n",
    "hfg=2409.54;\n",
    "h1=hf+x1*hfg\n",
    "print(\"enthalpy at state 1,h1 in KJ/kg=\"),round(h1,2)\n",
    "print(\"let dryness fraction at state 4 be x4\")\n",
    "print(\"for process 4-3,s4=s3=sf+x4*sfg\")\n",
    "s4=s3;\n",
    "x4=(s4-sf)/sfg\n",
    "print(\"so x4=\"),round(x4,2)\n",
    "x4=0.3321;#approx.\n",
    "h4=hf+x4*hfg\n",
    "print(\"enthalpy at state 4,h4 in KJ/kg=\"),round(h4,2)\n",
    "print(\"thermal efficiency=net work/heat added\")\n",
    "(h2-h1)\n",
    "print(\"expansion work per kg=(h2-h1) in KJ/kg\"),round((h2-h1),2)\n",
    "(h3-h4)\n",
    "print(\"compression work per kg=(h3-h4) in KJ/kg(+ve)\"),round((h3-h4),2)\n",
    "(h2-h3)\n",
    "print(\"heat added per kg=(h2-h3) in KJ/kg(-ve)\"),round((h2-h3),2)\n",
    "(h2-h1)-(h3-h4)\n",
    "print(\"net work per kg=(h2-h1)-(h3-h4) in KJ/kg\"),round((h2-h1)-(h3-h4),2)\n",
    "((h2-h1)-(h3-h4))/(h2-h3)\n",
    "print(\"thermal efficiency\"),round(((h2-h1)-(h3-h4))/(h2-h3),2)\n",
    "print(\"in percentage\"),round((((h2-h1)-(h3-h4))/(h2-h3))*100,2)\n",
    "print(\"so thermal efficiency=44.21%\")\n",
    "print(\"turbine work=969.57 KJ/kg(+ve)\")\n",
    "print(\"compression work=304.19 KJ/kg(-ve)\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 8.2;pg no: 261"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 8.2, Page:261  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 8 Example 2\n",
      "from steam tables,at 5 MPa,hf_5MPa=1154.23 KJ/kg,sf_5MPa=2.92 KJ/kg K\n",
      "hg_5MPa=2794.3 KJ/kg,sg_5MPa=5.97 KJ/kg K\n",
      "from steam tables,at 5 Kpa,hf_5KPa=137.82 KJ/kg,sf_5KPa=0.4764 KJ/kg K\n",
      "hg_5KPa=2561.5 KJ/kg,sg_5KPa=8.3951 KJ/kg K,vf_5KPa=0.001005 m^3/kg\n",
      "as process 2-3 is isentropic,so s2=s3\n",
      "and s3=sf_5KPa+x3*sfg_5KPa=s2=sg_5MPa\n",
      "so x3= 0.69\n",
      "hence enthalpy at 3,\n",
      "h3 in KJ/kg= 1819.85\n",
      "enthalpy at 2,h2=hg_5KPa=2794.3 KJ/kg\n",
      "process 1-4 is isentropic,so s1=s4\n",
      "s1=sf_5KPa+x4*(sg_5KPa-sf_5KPa)\n",
      "so x4= 0.31\n",
      "enthalpy at 4,h4 in KJ/kg= 884.31\n",
      "enthalpy at 1,h1 in KJ/kg= 1154.23\n",
      "carnot cycle(1-2-3-4-1) efficiency:\n",
      "n_carnot=net work/heat added\n",
      "n_carnot 0.43\n",
      "in percentage 42.96\n",
      "so n_carnot=42.95%\n",
      "In rankine cycle,1-2-3-5-6-1,\n",
      "pump work,h6-h5=vf_5KPa*(p6-p5)in KJ/kg 5.02\n",
      "h5 KJ/kg= 137.82\n",
      "hence h6 in KJ/kg 142.84\n",
      "net work in rankine cycle=(h2-h3)-(h6-h5)in KJ/kg 969.43\n",
      "heat added=(h2-h6)in KJ/kg 2651.46\n",
      "rankine cycle efficiency(n_rankine)= 0.37\n",
      "in percentage 36.56\n",
      "so n_rankine=36.56%\n"
     ]
    }
   ],
   "source": [
    "#cal of n_carnot,n_rankine\n",
    "#intiation of all variables\n",
    "# Chapter 8\n",
    "print\"Example 8.2, Page:261  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 8 Example 2\")\n",
    "print(\"from steam tables,at 5 MPa,hf_5MPa=1154.23 KJ/kg,sf_5MPa=2.92 KJ/kg K\")\n",
    "print(\"hg_5MPa=2794.3 KJ/kg,sg_5MPa=5.97 KJ/kg K\")\n",
    "hf_5MPa=1154.23;\n",
    "sf_5MPa=2.92;\n",
    "hg_5MPa=2794.3;\n",
    "sg_5MPa=5.97;\n",
    "print(\"from steam tables,at 5 Kpa,hf_5KPa=137.82 KJ/kg,sf_5KPa=0.4764 KJ/kg K\")\n",
    "print(\"hg_5KPa=2561.5 KJ/kg,sg_5KPa=8.3951 KJ/kg K,vf_5KPa=0.001005 m^3/kg\")\n",
    "hf_5KPa=137.82;\n",
    "sf_5KPa=0.4764;\n",
    "hg_5KPa=2561.5;\n",
    "sg_5KPa=8.3951;\n",
    "vf_5KPa=0.001005;\n",
    "print(\"as process 2-3 is isentropic,so s2=s3\")\n",
    "print(\"and s3=sf_5KPa+x3*sfg_5KPa=s2=sg_5MPa\")\n",
    "s2=sg_5MPa;\n",
    "s3=s2;\n",
    "x3=(s3-sf_5KPa)/(sg_5KPa-sf_5KPa)\n",
    "print(\"so x3=\"),round(x3,2)\n",
    "x3=0.694;#approx.\n",
    "print(\"hence enthalpy at 3,\")\n",
    "h3=hf_5KPa+x3*(hg_5KPa-hf_5KPa)\n",
    "print(\"h3 in KJ/kg=\"),round(h3,2)\n",
    "print(\"enthalpy at 2,h2=hg_5KPa=2794.3 KJ/kg\")\n",
    "print(\"process 1-4 is isentropic,so s1=s4\")\n",
    "s1=sf_5MPa;\n",
    "print(\"s1=sf_5KPa+x4*(sg_5KPa-sf_5KPa)\")\n",
    "x4=(s1-sf_5KPa)/(sg_5KPa-sf_5KPa)\n",
    "print(\"so x4=\"),round(x4,2)\n",
    "x4=0.308;#approx.\n",
    "h4=hf_5KPa+x4*(hg_5KPa-hf_5KPa)\n",
    "print(\"enthalpy at 4,h4 in KJ/kg=\"),round(h4,2)\n",
    "h1=hf_5MPa\n",
    "h2=hg_5MPa;\n",
    "n_carnot=((h2-h3)-(h1-h4))/(h2-h1)\n",
    "print(\"enthalpy at 1,h1 in KJ/kg=\"),round(h1,2)\n",
    "print(\"carnot cycle(1-2-3-4-1) efficiency:\")\n",
    "print(\"n_carnot=net work/heat added\")\n",
    "print(\"n_carnot\"),round(n_carnot,2)\n",
    "print(\"in percentage\"),round(n_carnot*100,2)\n",
    "print(\"so n_carnot=42.95%\")\n",
    "print(\"In rankine cycle,1-2-3-5-6-1,\")\n",
    "p6=5000;#boiler pressure in KPa\n",
    "p5=5;#condenser pressure in KPa\n",
    "vf_5KPa*(p6-p5)\n",
    "print(\"pump work,h6-h5=vf_5KPa*(p6-p5)in KJ/kg\"),round(vf_5KPa*(p6-p5),2)\n",
    "h5=hf_5KPa;\n",
    "print(\"h5 KJ/kg=\"),round(hf_5KPa,2)\n",
    "h6=h5+(vf_5KPa*(p6-p5))\n",
    "print(\"hence h6 in KJ/kg\"),round(h6,2)\n",
    "(h2-h3)-(h6-h5)\n",
    "print(\"net work in rankine cycle=(h2-h3)-(h6-h5)in KJ/kg\"),round((h2-h3)-(h6-h5),2)\n",
    "(h2-h6)\n",
    "print(\"heat added=(h2-h6)in KJ/kg\"),round((h2-h6),2)\n",
    "n_rankine=((h2-h3)-(h6-h5))/(h2-h6)\n",
    "print(\"rankine cycle efficiency(n_rankine)=\"),round(n_rankine,2)\n",
    "print(\"in percentage\"),round(n_rankine*100,2)\n",
    "print(\"so n_rankine=36.56%\")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 8.3;pg no: 263"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 90,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 8.3, Page:263  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 8 Example 3\n",
      "from steam tables,h2=hg_40bar=3092.5 KJ/kg\n",
      "s2=sg_40bar=6.5821 KJ/kg K\n",
      "h4=hf_0.05bar=137.82 KJ/kg,hfg=2423.7 KJ/kg \n",
      "s4=sf_0.05bar=0.4764 KJ/kg K,sfg=7.9187 KJ/kg K\n",
      "v4=vf_0.05bar=0.001005 m^3/kg\n",
      "let the dryness fraction at state 3 be x3,\n",
      "for ideal process,2-3,s2=s3\n",
      "s2=s3=6.5821=sf_0.05bar+x3*sfg_0.05bar\n",
      "so x3= 0.77\n",
      "h3=hf_0.05bar+x3*hfg_0.05bar in KJ/kg\n",
      "for pumping process,\n",
      "h1-h4=v4*deltap=v4*(p1-p4)\n",
      "so h1=h4+v4*(p1-p4) in KJ/kg 141.83\n",
      "pump work per kg of steam in KJ/kg 4.01\n",
      "net work per kg of steam =(expansion work-pump work)per kg of steam\n",
      "=(h2-h3)-(h1-h4) in KJ/kg= 1081.75\n",
      "cycle efficiency=net work/heat added 0.37\n",
      "in percentage 36.66\n",
      "so net work per kg of steam=1081.74 KJ/kg\n",
      "cycle efficiency=36.67%\n",
      "pump work per kg of steam=4.02 KJ/kg\n"
     ]
    }
   ],
   "source": [
    "#cal of net work per kg of steam,cycle efficiency,pump work per kg of steam\n",
    "#intiation of all variables\n",
    "# Chapter 8\n",
    "print\"Example 8.3, Page:263  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 8 Example 3\")\n",
    "print(\"from steam tables,h2=hg_40bar=3092.5 KJ/kg\")\n",
    "h2=3092.5;\n",
    "print(\"s2=sg_40bar=6.5821 KJ/kg K\")\n",
    "s2=6.5821;\n",
    "print(\"h4=hf_0.05bar=137.82 KJ/kg,hfg=2423.7 KJ/kg \")\n",
    "h4=137.82;\n",
    "hfg=2423.7;\n",
    "print(\"s4=sf_0.05bar=0.4764 KJ/kg K,sfg=7.9187 KJ/kg K\")\n",
    "s4=0.4764;\n",
    "sfg=7.9187;\n",
    "print(\"v4=vf_0.05bar=0.001005 m^3/kg\")\n",
    "v4=0.001005;\n",
    "print(\"let the dryness fraction at state 3 be x3,\")\n",
    "print(\"for ideal process,2-3,s2=s3\")\n",
    "s3=s2;\n",
    "print(\"s2=s3=6.5821=sf_0.05bar+x3*sfg_0.05bar\")\n",
    "x3=(s2-s4)/(sfg)\n",
    "print(\"so x3=\"),round(x3,2)\n",
    "x3=0.7711;#approx.\n",
    "print(\"h3=hf_0.05bar+x3*hfg_0.05bar in KJ/kg\")\n",
    "h3=h4+x3*hfg\n",
    "print(\"for pumping process,\")\n",
    "print(\"h1-h4=v4*deltap=v4*(p1-p4)\")\n",
    "p1=40*100;#pressure of steam enter in turbine in mPa\n",
    "p4=0.05*100;#pressure of steam leave turbine in mPa\n",
    "h1=h4+v4*(p1-p4)\n",
    "print(\"so h1=h4+v4*(p1-p4) in KJ/kg\"),round(h1,2)\n",
    "(h1-h4)\n",
    "print(\"pump work per kg of steam in KJ/kg\"),round((h1-h4),2)\n",
    "print(\"net work per kg of steam =(expansion work-pump work)per kg of steam\")\n",
    "(h2-h3)-(h1-h4)\n",
    "print(\"=(h2-h3)-(h1-h4) in KJ/kg=\"),round((h2-h3)-(h1-h4),2)\n",
    "print(\"cycle efficiency=net work/heat added\"),round(((h2-h3)-(h1-h4))/(h2-h1),2)\n",
    "print(\"in percentage\"),round(((h2-h3)-(h1-h4))*100/(h2-h1),2)\n",
    "print(\"so net work per kg of steam=1081.74 KJ/kg\")\n",
    "print(\"cycle efficiency=36.67%\")\n",
    "print(\"pump work per kg of steam=4.02 KJ/kg\")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 8.4;pg no: 264"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 8.4, Page:264  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 8 Example 4\n",
      "Let us assume that the condensate leaves condenser as saturated liquid and the expansion in turbine and pumping processes are isentropic.\n",
      "from steam tables,h2=h_20MPa=3238.2 KJ/kg\n",
      "s2=6.1401 KJ/kg K\n",
      "h5=h_0.005MPa in KJ/kg\n",
      "from steam tables,at 0.005 MPa,hf=137.82 KJ/kg,hfg=2423.7 KJ/kg,sf=0.4764 KJ/kg K,sfg=7.9187 KJ/kg K\n",
      "h5=hf+0.9*hfg in KJ/kg 2319.15\n",
      "s5 in KJ/kg K= 7.6\n",
      "h6=hf=137.82 KJ/kg\n",
      "it is given that temperature at state 4 is 500 degree celcius and due to isentropic processes s4=s5=7.6032 KJ/kg K.The state 4 can be conveniently located on mollier chart by the intersection of 500 degree celcius constant temperature line and entropy value of 7.6032 KJ/kg K and the pressure and enthalpy obtained.but these shall be approximate.\n",
      "The state 4 can also be located by interpolation using steam table.The entropy value of 7.6032 KJ/kg K lies between the superheated steam states given under,p=1.20 MPa,s at 1.20 MPa=7.6027 KJ/kg K\n",
      "p=1.40 MPa,s at 1.40 MPa=7.6027 KJ/kg K\n",
      "by interpolation state 4 lies at pressure=\n",
      "=1.399,approx.=1.40 MPa\n",
      "thus,steam leaves HP turbine at 1.40 MPa\n",
      "enthalpy at state 4,h4=3474.1 KJ/kg\n",
      "for process 2-33,s2=s3=6.1401 KJ/kg K.The state 3 thus lies in wet region as s3<sg at 1.40 MPa.Let dryness fraction at state 3 be x3.\n",
      "s3=sf+x3*sfg\n",
      "from staem tables,at 1.4 MPa,sf=2.2842 KJ/kg K,sfg=4.1850 KJ/kg K\n",
      "so x3 0.92\n",
      "h3 in KJ/kg 2635.89\n",
      "from steam tables,at 1.4 MPa,hf=830.3 KJ/kg,hfg=1959.7 KJ/kg\n",
      "enthalpy at 1,h1=h6+v6*(p1-p6) in KJ/kg\n",
      "h1=hf at 0.005MPa+vf at 0.005MPa*(p1-p6)\n",
      "from steam tables, at 0.005 MPa,h6=137.82 KJ/kg,v6=0.001005 m^3/kg\n",
      "net work per kg steam in KJ/kg= 1737.16\n",
      "heat added per kg of steam in KJ/kg= 3080.29\n",
      "thermal efficiency=net work/heat added 0.56\n",
      "in percentage 56.4\n",
      "pressure of steam leaving HP turbine=1.40 MPa\n",
      "thermal efficiency=56.39%\n"
     ]
    }
   ],
   "source": [
    "#cal of maximum possible work\n",
    "#intiation of all variables\n",
    "# Chapter 8\n",
    "print\"Example 8.4, Page:264  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 8 Example 4\")\n",
    "print(\"Let us assume that the condensate leaves condenser as saturated liquid and the expansion in turbine and pumping processes are isentropic.\")\n",
    "print(\"from steam tables,h2=h_20MPa=3238.2 KJ/kg\")\n",
    "h2=3238.2;\n",
    "print(\"s2=6.1401 KJ/kg K\")\n",
    "s2=6.1401;\n",
    "print(\"h5=h_0.005MPa in KJ/kg\")\n",
    "print(\"from steam tables,at 0.005 MPa,hf=137.82 KJ/kg,hfg=2423.7 KJ/kg,sf=0.4764 KJ/kg K,sfg=7.9187 KJ/kg K\")\n",
    "hf=137.82;\n",
    "hfg=2423.7;\n",
    "sf=0.4764;\n",
    "sfg=7.9187;\n",
    "h5=hf+0.9*hfg\n",
    "print(\"h5=hf+0.9*hfg in KJ/kg\"),round(h5,2)\n",
    "s5=sf+0.9*sfg\n",
    "print(\"s5 in KJ/kg K=\"),round(s5,2)\n",
    "print(\"h6=hf=137.82 KJ/kg\")\n",
    "h6=137.82;\n",
    "print(\"it is given that temperature at state 4 is 500 degree celcius and due to isentropic processes s4=s5=7.6032 KJ/kg K.The state 4 can be conveniently located on mollier chart by the intersection of 500 degree celcius constant temperature line and entropy value of 7.6032 KJ/kg K and the pressure and enthalpy obtained.but these shall be approximate.\")\n",
    "print(\"The state 4 can also be located by interpolation using steam table.The entropy value of 7.6032 KJ/kg K lies between the superheated steam states given under,p=1.20 MPa,s at 1.20 MPa=7.6027 KJ/kg K\")\n",
    "print(\"p=1.40 MPa,s at 1.40 MPa=7.6027 KJ/kg K\")\n",
    "print(\"by interpolation state 4 lies at pressure=\")\n",
    "1.20+((1.40-1.20)/(7.6027-7.6759))*(7.6032-7.6759)\n",
    "print(\"=1.399,approx.=1.40 MPa\")\n",
    "print(\"thus,steam leaves HP turbine at 1.40 MPa\")\n",
    "print(\"enthalpy at state 4,h4=3474.1 KJ/kg\")\n",
    "h4=3474.1;\n",
    "print(\"for process 2-33,s2=s3=6.1401 KJ/kg K.The state 3 thus lies in wet region as s3<sg at 1.40 MPa.Let dryness fraction at state 3 be x3.\")\n",
    "s3=s2;\n",
    "print(\"s3=sf+x3*sfg\")\n",
    "print(\"from staem tables,at 1.4 MPa,sf=2.2842 KJ/kg K,sfg=4.1850 KJ/kg K\")\n",
    "sf=2.2842;\n",
    "sfg=4.1850;\n",
    "x3=(s3-sf)/sfg\n",
    "print(\"so x3\"),round(x3,2)\n",
    "hf=830.3;\n",
    "hfg=1959.7;\n",
    "h3=hf+x3*hfg\n",
    "print(\"h3 in KJ/kg\"),round(h3,2)\n",
    "print(\"from steam tables,at 1.4 MPa,hf=830.3 KJ/kg,hfg=1959.7 KJ/kg\")\n",
    "print(\"enthalpy at 1,h1=h6+v6*(p1-p6) in KJ/kg\")\n",
    "print(\"h1=hf at 0.005MPa+vf at 0.005MPa*(p1-p6)\")\n",
    "print(\"from steam tables, at 0.005 MPa,h6=137.82 KJ/kg,v6=0.001005 m^3/kg\")\n",
    "h6=137.82;\n",
    "v6=0.001005;\n",
    "p1=20*1000;#steam entering HP turbine in KPa\n",
    "p6=0.005*1000;#condensor pressure in KPa\n",
    "h1=h6+v6*(p1-p6)\n",
    "W_net=(h2-h3)+(h4-h5)-(h1-h6)\n",
    "print(\"net work per kg steam in KJ/kg=\"),round(W_net,2)\n",
    "Q=(h2-h1)\n",
    "print(\"heat added per kg of steam in KJ/kg=\"),round(Q,2)\n",
    "#thermal efficiency=W_net/Q\n",
    "print(\"thermal efficiency=net work/heat added\"),round(W_net/Q,2)\n",
    "print(\"in percentage\"),round(W_net/Q*100,2)\n",
    "print(\"pressure of steam leaving HP turbine=1.40 MPa\")\n",
    "print(\"thermal efficiency=56.39%\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 8.5;pg no: 266"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 92,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 8.5, Page:266  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 8 Example 5\n",
      "from steam table,at inlet to turbine,\n",
      "h2=h_10MPa,700oc\n",
      "h2=3870.5 KJ/kg,s2=7.1687 KJ/kg K\n",
      "for process 2-3,s2=s3 and s3<sf at 0.005 MPa so state 3 lies in wet region .Let dryness fraction at state 3 be x3.\n",
      "s3=7.1687=sf at 0.005 MPa+x3*sfg at 0.005 MPa\n",
      "from steam tables,at 0.005 MPa,sf=0.4764 KJ/kg K,sfg=7.9187 KJ/kg\n",
      "so x3 0.85\n",
      "h3=hf at 0.005 MPa+x3*hfg at 0.005 MPa\n",
      "from steam tables,at 0.005 MPa,hf=137.82 KJ/kg,hfg=2423.7 KJ/kg\n",
      "so h3 in KJ/kg= 2185.85\n",
      "h4=hf at 0.005 MPa\n",
      "for pumping process,(h1-h4)=v4*(p1-p4)\n",
      "from steam tables,v4=vf at 0.005 MPa=0.001005 m^3/kg\n",
      "h1 in KJ/kg= 138.82\n",
      "net output per kg of steam,w_net in KJ/kg= 1683.65\n",
      "mass flow rate of steam,ms in kg/s 29.7\n",
      "by heat balance on condenser,for mass flow rate of water being mw kg/s\n",
      "(h3-h4)*ms=mw*Cpw*(Tw_out-Tw_in)\n",
      "so mw in kg/s= 969.79\n",
      "the heat added per kg of steam (q_add) in KJ/kg= 3731.68\n",
      "thermal efficiency= 0.45\n",
      "in percentage 45.12\n",
      "ratio of heat supplied and rejected= 1.82\n",
      "mass of flow rate of steam=29.69 kg/s\n",
      "mass flow rate of condenser cooling water=969.79 kg/s\n",
      "thermal efficiency=45.12%\n",
      "ratio of heat supplied and rejected=1.822\n"
     ]
    }
   ],
   "source": [
    "#cal of mass of flow rate of steam,mass flow rate of condenser cooling water,thermal efficiency,ratio of heat supplied and rejected\n",
    "#intiation of all variables\n",
    "# Chapter 8\n",
    "print\"Example 8.5, Page:266  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 8 Example 5\")\n",
    "P=50*10**3;#output of plant in KW\n",
    "Cpw=4.18;#specific heat of water in KJ/kg K\n",
    "Tw_in=15;#cooling water entering condenser temperature in degree celcius\n",
    "Tw_out=30;#cooling water leaving condenser temperature in degree celcius\n",
    "print(\"from steam table,at inlet to turbine,\")\n",
    "print(\"h2=h_10MPa,700oc\")\n",
    "print(\"h2=3870.5 KJ/kg,s2=7.1687 KJ/kg K\")\n",
    "h2=3870.5;\n",
    "s2=7.1687;\n",
    "s3=s2;\n",
    "print(\"for process 2-3,s2=s3 and s3<sf at 0.005 MPa so state 3 lies in wet region .Let dryness fraction at state 3 be x3.\")\n",
    "print(\"s3=7.1687=sf at 0.005 MPa+x3*sfg at 0.005 MPa\")\n",
    "print(\"from steam tables,at 0.005 MPa,sf=0.4764 KJ/kg K,sfg=7.9187 KJ/kg\")\n",
    "sf=0.4764;\n",
    "sfg=7.9187;\n",
    "x3=(s3-sf)/sfg\n",
    "print(\"so x3\"),round(x3,2)\n",
    "x3=0.845;#approx.\n",
    "print(\"h3=hf at 0.005 MPa+x3*hfg at 0.005 MPa\")\n",
    "print(\"from steam tables,at 0.005 MPa,hf=137.82 KJ/kg,hfg=2423.7 KJ/kg\")\n",
    "hf=137.82;\n",
    "hfg=2423.7;\n",
    "h3=hf+x3*hfg\n",
    "print(\"so h3 in KJ/kg=\"),round(h3,2)\n",
    "print(\"h4=hf at 0.005 MPa\")\n",
    "h4=hf;\n",
    "print(\"for pumping process,(h1-h4)=v4*(p1-p4)\")\n",
    "print(\"from steam tables,v4=vf at 0.005 MPa=0.001005 m^3/kg\")\n",
    "v4=0.001005;\n",
    "p1=10;#pressure of steam leave boiler in MPa\n",
    "p4=0.005;#pressure of steam leave turbine in MPa\n",
    "h1=h4+v4*(p1-p4)*100\n",
    "print(\"h1 in KJ/kg=\"),round(h1,2)\n",
    "w_net=(h2-h3)-(h1-h4)\n",
    "print(\"net output per kg of steam,w_net in KJ/kg=\"),round(w_net,2)\n",
    "ms=P/w_net\n",
    "print(\"mass flow rate of steam,ms in kg/s\"),round(ms,2)\n",
    "ms=29.69;#approx.\n",
    "print(\"by heat balance on condenser,for mass flow rate of water being mw kg/s\")\n",
    "print(\"(h3-h4)*ms=mw*Cpw*(Tw_out-Tw_in)\")\n",
    "mw=(h3-h4)*ms/(Cpw*(Tw_out-Tw_in))\n",
    "print(\"so mw in kg/s=\"),round(mw,2)\n",
    "q_add=(h2-h1)\n",
    "print(\"the heat added per kg of steam (q_add) in KJ/kg=\"),round(q_add,2)\n",
    "w_net/q_add\n",
    "print(\"thermal efficiency=\"),round(w_net/q_add,2)\n",
    "print(\"in percentage\"),round(w_net*100/q_add,2)\n",
    "(h2-h1)/(h3-h4)\n",
    "print(\"ratio of heat supplied and rejected=\"),round((h2-h1)/(h3-h4),2)\n",
    "print(\"mass of flow rate of steam=29.69 kg/s\")\n",
    "print(\"mass flow rate of condenser cooling water=969.79 kg/s\")\n",
    "print(\"thermal efficiency=45.12%\")\n",
    "print(\"ratio of heat supplied and rejected=1.822\")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 8.6;pg no: 267"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 8.6, Page:267  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 8 Example 6\n",
      "case (a) When there is no feed water heater\n",
      "Thermal efficiency of cycle=((h2-h3)-(h1-h4))/(h2-h1)\n",
      "from steam tables,h2=h at 200 bar,650oc=3675.3 KJ/kg,s2=s at 200 bar,650oc=6.6582 KJ/kg K,h4=hf at 0.05 bar=137.82 KJ/kg,v4=vf at 0.05 bar=0.001005 m^3/kg\n",
      "hf at 0.05 bar=137.82 KJ/kg,hfg at 0.05 bar=2423.7 KJ/kg,sf at 0.05 bar=0.4764 KJ/kg K,sfg at 0.05 bar=7.9187 KJ/kg K\n",
      "For process 2-3,s2=s3.Let dryness fraction at 3 be x3.\n",
      "s3=6.6582=sf at 0.05 bar+x3*sfg at 0.05 bar\n",
      "so x3= 0.78\n",
      "h3=hf at 0.05 bar+x3*hfg at 0.05 bar in KJ/kg\n",
      "For pumping process 4-1,\n",
      "h1-h4=v4*deltap\n",
      "h1= in KJ/kg= 157.87\n",
      "Thermal efficiency of cycle= 0.46\n",
      "in percentage 46.18\n",
      "case (b) When there is only one feed water heater working at 8 bar\n",
      "here,let mass of steam bled for feed heating be m kg\n",
      "For process 2-6,s2=s6=6.6582 KJ/kg K\n",
      "Let dryness fraction at state 6 be x6\n",
      "s6=sf at 8 bar+x6*sfg at 8 bar\n",
      "from steam tables,hf at 8 bar=721.11 KJ/kg,vf at 8 bar=0.001115 m^3/kg,hfg at 8 bar=2048 KJ/kg,sf at 8 bar=2.0462 KJ/kg K,sfg at 8 bar=4.6166 KJ/kg K\n",
      "substituting entropy values,x6= 1.0\n",
      "h6=hf at at 8 bar+x6*hfg at 8 bar in KJ/kg\n",
      "Assuming the state of fluid leaving open feed water heater to be saturated liquid at 8 bar.h7=hf at 8 bar=721.11 KJ/kg\n",
      "For process 4-5,h5 in KJ/kg 138.62\n",
      "Applying energy balance at open feed water heater,\n",
      "m*h6+(1-m)*h5=1*h7\n",
      "so m= in kg 0.22\n",
      "For process 7-1,h1 in KJ/kg= 742.52\n",
      "here h7=hf at 8 bar,v7=vf at 8 bar\n",
      "Thermal efficiency of cycle=0.4976\n",
      "in percentage=49.76\n",
      "case (c) When there are two feed water heaters working at 40 bar and 4 bar\n",
      "here, let us assume the mass of steam at 40 bar,4 bar to be m1 kg and m2 kg respectively.\n",
      "2-10-9-3,s2=s10=s9=s3=6.6582 KJ/kg K\n",
      "At state 10.s10>sg at 40 bar(6.0701 KJ/kg K)so state 10 lies in superheated region at 40 bar pressure.\n",
      "From steam table by interpolation,T10=370.6oc,so h10=3141.81 KJ/kg\n",
      "Let dryness fraction at state 9 be x9 so,\n",
      "s9=6.6582=sf at 4 bar+x9*sfg at 4 bar\n",
      "from steam tables,at 4 bar,sf=1.7766 KJ/kg K,sfg=5.1193 KJ/kg K\n",
      "x9=(s9-sf)/sfg 0.95\n",
      "h9=hf at 4 bar+x9*hfg at 4 bar in KJ/kg\n",
      "from steam tables,at 4 bar,hf=604.74 KJ/kg,hfg=2133.8 KJ/kg\n",
      "Assuming the state of fluid leaving open feed water heater to be saturated liquid at respective pressures i.e.\n",
      "h11=hf at 4 bar=604.74 KJ/kg,v11=0.001084 m^3/kg=vf at 4 bar\n",
      "h13=hf at 40 bar=1087.31 KJ/kg,v13=0.001252 m^3/kg=vf at40 bar\n",
      "For process 4-8,i.e in CEP.\n",
      "h8 in KJ/kg= 138.22\n",
      "For process 11-12,i.e in FP2,\n",
      "h12=h11+v11*(40-4)*10^2 in KJ/kg 608.64\n",
      "For process 13-1_a i.e. in FP1,h1_a= in KJ/kg= 1107.34\n",
      "m1*3141.81+(1-m1)*608.64=1087.31\n",
      "so m1=(1087.31-608.64)/(3141.81-608.64)in kg\n",
      "Applying energy balance  on open feed water heater 1 (OFWH1)\n",
      "m1*h10+(1-m1)*h12)=1*h13\n",
      "so m1 in kg= 0.19\n",
      "Applying energy balance on open feed water heater 2 (OFWH2)\n",
      "m2*h9+(1-m1-m2)*h8=(1-m1)*h11\n",
      "so m2 in kg= 0.15\n",
      "Thermal efficiency of cycle,n= 0.51\n",
      "W_CEP in KJ/kg steam from boiler= 0.26\n",
      "W_FP1=(h1_a-h13)in KJ/kg of steam from boiler 20.0\n",
      "W_FP2 in KJ/kg of steam from boiler= 3.17\n",
      "W_CEP+W_FP1+W_FP2 in KJ/kg of steam from boiler= 23.46\n",
      "n= 0.51\n",
      "in percentage 51.37\n",
      "so cycle thermal efficiency,na=46.18%\n",
      "nb=49.76%\n",
      "nc=51.37%\n",
      "hence it is obvious that efficiency increases with increase in number of feed heaters.\n"
     ]
    }
   ],
   "source": [
    "#cal of maximum possible work\n",
    "#intiation of all variables\n",
    "# Chapter 8\n",
    "print\"Example 8.6, Page:267  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 8 Example 6\")\n",
    "print(\"case (a) When there is no feed water heater\")\n",
    "print(\"Thermal efficiency of cycle=((h2-h3)-(h1-h4))/(h2-h1)\")\n",
    "print(\"from steam tables,h2=h at 200 bar,650oc=3675.3 KJ/kg,s2=s at 200 bar,650oc=6.6582 KJ/kg K,h4=hf at 0.05 bar=137.82 KJ/kg,v4=vf at 0.05 bar=0.001005 m^3/kg\")\n",
    "h2=3675.3;\n",
    "s2=6.6582;\n",
    "h4=137.82;\n",
    "v4=0.001005;\n",
    "print(\"hf at 0.05 bar=137.82 KJ/kg,hfg at 0.05 bar=2423.7 KJ/kg,sf at 0.05 bar=0.4764 KJ/kg K,sfg at 0.05 bar=7.9187 KJ/kg K\")\n",
    "hf=137.82;\n",
    "hfg=2423.7;\n",
    "sf=0.4764;\n",
    "sfg=7.9187;\n",
    "print(\"For process 2-3,s2=s3.Let dryness fraction at 3 be x3.\")\n",
    "s3=s2;\n",
    "print(\"s3=6.6582=sf at 0.05 bar+x3*sfg at 0.05 bar\")\n",
    "x3=(s3-sf)/sfg\n",
    "print(\"so x3=\"),round(x3,2)\n",
    "x3=0.781;#approx.\n",
    "print(\"h3=hf at 0.05 bar+x3*hfg at 0.05 bar in KJ/kg\")\n",
    "h3=hf+x3*hfg\n",
    "print(\"For pumping process 4-1,\")\n",
    "print(\"h1-h4=v4*deltap\")\n",
    "h1=h4+v4*(200-0.5)*10**2\n",
    "print(\"h1= in KJ/kg=\"),round(h1,2)\n",
    "((h2-h3)-(h1-h4))/(h2-h1)\n",
    "print(\"Thermal efficiency of cycle=\"),round(((h2-h3)-(h1-h4))/(h2-h1),2)\n",
    "print(\"in percentage\"),round(((h2-h3)-(h1-h4))*100/(h2-h1),2)\n",
    "print(\"case (b) When there is only one feed water heater working at 8 bar\")\n",
    "print(\"here,let mass of steam bled for feed heating be m kg\")\n",
    "print(\"For process 2-6,s2=s6=6.6582 KJ/kg K\")\n",
    "s6=s2;\n",
    "print(\"Let dryness fraction at state 6 be x6\")\n",
    "print(\"s6=sf at 8 bar+x6*sfg at 8 bar\")\n",
    "print(\"from steam tables,hf at 8 bar=721.11 KJ/kg,vf at 8 bar=0.001115 m^3/kg,hfg at 8 bar=2048 KJ/kg,sf at 8 bar=2.0462 KJ/kg K,sfg at 8 bar=4.6166 KJ/kg K\")\n",
    "hf=721.11;\n",
    "vf=0.001115;\n",
    "hfg=2048;\n",
    "sf=2.0462;\n",
    "sfg=4.6166;\n",
    "x6=(s6-sf)/sfg\n",
    "print(\"substituting entropy values,x6=\"),round(x6,2)\n",
    "x6=0.999;#approx.\n",
    "print(\"h6=hf at at 8 bar+x6*hfg at 8 bar in KJ/kg\")\n",
    "h6=hf+x6*hfg\n",
    "print(\"Assuming the state of fluid leaving open feed water heater to be saturated liquid at 8 bar.h7=hf at 8 bar=721.11 KJ/kg\")\n",
    "h7=721.11;\n",
    "h5=h4+v4*(8-.05)*10**2\n",
    "print(\"For process 4-5,h5 in KJ/kg\"),round(h5,2)\n",
    "print(\"Applying energy balance at open feed water heater,\")\n",
    "print(\"m*h6+(1-m)*h5=1*h7\")\n",
    "m=(h7-h5)/(h6-h5)\n",
    "print(\"so m= in kg\"),round(m,2)\n",
    "h7=hf;\n",
    "v7=vf;\n",
    "h1=h7+v7*(200-8)*10**2\n",
    "print(\"For process 7-1,h1 in KJ/kg=\"),round(h1,2)\n",
    "print(\"here h7=hf at 8 bar,v7=vf at 8 bar\")\n",
    "#TE=((h2-h6)+(1-m)*(h6-h3)-((1-m)*(h5-h4)+(h1-h7))/(h2-h1)\n",
    "print(\"Thermal efficiency of cycle=0.4976\")\n",
    "print(\"in percentage=49.76\")\n",
    "print(\"case (c) When there are two feed water heaters working at 40 bar and 4 bar\")\n",
    "print(\"here, let us assume the mass of steam at 40 bar,4 bar to be m1 kg and m2 kg respectively.\")\n",
    "print(\"2-10-9-3,s2=s10=s9=s3=6.6582 KJ/kg K\")\n",
    "s3=s2;\n",
    "s9=s3;\n",
    "s10=s9;\n",
    "print(\"At state 10.s10>sg at 40 bar(6.0701 KJ/kg K)so state 10 lies in superheated region at 40 bar pressure.\")\n",
    "print(\"From steam table by interpolation,T10=370.6oc,so h10=3141.81 KJ/kg\")\n",
    "T10=370.6;\n",
    "h10=3141.81;\n",
    "print(\"Let dryness fraction at state 9 be x9 so,\") \n",
    "print(\"s9=6.6582=sf at 4 bar+x9*sfg at 4 bar\")\n",
    "print(\"from steam tables,at 4 bar,sf=1.7766 KJ/kg K,sfg=5.1193 KJ/kg K\")\n",
    "sf=1.7766;\n",
    "sfg=5.1193;\n",
    "x9=(s9-sf)/sfg\n",
    "print(\"x9=(s9-sf)/sfg\"),round(x9,2)\n",
    "x9=0.9536;#approx.\n",
    "print(\"h9=hf at 4 bar+x9*hfg at 4 bar in KJ/kg\")\n",
    "print(\"from steam tables,at 4 bar,hf=604.74 KJ/kg,hfg=2133.8 KJ/kg\")\n",
    "hf=604.74;\n",
    "hfg=2133.8;\n",
    "h9=hf+x9*hfg \n",
    "print(\"Assuming the state of fluid leaving open feed water heater to be saturated liquid at respective pressures i.e.\")\n",
    "print(\"h11=hf at 4 bar=604.74 KJ/kg,v11=0.001084 m^3/kg=vf at 4 bar\")\n",
    "h11=604.74;\n",
    "v11=0.001084;\n",
    "print(\"h13=hf at 40 bar=1087.31 KJ/kg,v13=0.001252 m^3/kg=vf at40 bar\")\n",
    "h13=1087.31;\n",
    "v13=0.001252;\n",
    "print(\"For process 4-8,i.e in CEP.\")\n",
    "h8=h4+v4*(4-0.05)*10**2\n",
    "print(\"h8 in KJ/kg=\"),round(h8,2)\n",
    "print(\"For process 11-12,i.e in FP2,\")\n",
    "h12=h11+v11*(40-4)*10**2\n",
    "print(\"h12=h11+v11*(40-4)*10^2 in KJ/kg\"),round(h12,2)\n",
    "h1_a=h13+v13*(200-40)*10**2\n",
    "print(\"For process 13-1_a i.e. in FP1,h1_a= in KJ/kg=\"),round(h1_a,2)\n",
    "print(\"m1*3141.81+(1-m1)*608.64=1087.31\")\n",
    "print(\"so m1=(1087.31-608.64)/(3141.81-608.64)in kg\")\n",
    "m1=(1087.31-608.64)/(3141.81-608.64)\n",
    "print(\"Applying energy balance  on open feed water heater 1 (OFWH1)\")\n",
    "print(\"m1*h10+(1-m1)*h12)=1*h13\")\n",
    "m1=(h13-h12)/(h10-h12)\n",
    "print(\"so m1 in kg=\"),round(m1,2)\n",
    "print(\"Applying energy balance on open feed water heater 2 (OFWH2)\")\n",
    "print(\"m2*h9+(1-m1-m2)*h8=(1-m1)*h11\")\n",
    "m2=(1-m1)*(h11-h8)/(h9-h8)\n",
    "print(\"so m2 in kg=\"),round(m2,2)\n",
    "W_CEP=(1-m1-m2)*(h8-h4)\n",
    "W_FP1=(h1_a-h13)\n",
    "W_FP2=(1-m1)*(h12-h11)\n",
    "n=(((h2-h10)+(1-m1)*(h10-h9)+(1-m1-m2)*(h9-h3))-(W_CEP+W_FP1+W_FP2))/(h2-h1_a)\n",
    "print(\"Thermal efficiency of cycle,n=\"),round(n,2)\n",
    "print(\"W_CEP in KJ/kg steam from boiler=\"),round(W_CEP,2)\n",
    "print(\"W_FP1=(h1_a-h13)in KJ/kg of steam from boiler\"),round(W_FP1)\n",
    "print(\"W_FP2 in KJ/kg of steam from boiler=\"),round(W_FP2,2)\n",
    "W_CEP+W_FP1+W_FP2\n",
    "print(\"W_CEP+W_FP1+W_FP2 in KJ/kg of steam from boiler=\"),round(W_CEP+W_FP1+W_FP2,2)\n",
    "n=(((h2-h10)+(1-m1)*(h10-h9)+(1-m1-m2)*(h9-h3))-(W_CEP+W_FP1+W_FP2))/(h2-h1_a)\n",
    "print(\"n=\"),round(n,2)\n",
    "print(\"in percentage\"),round(n*100,2)\n",
    "print(\"so cycle thermal efficiency,na=46.18%\")\n",
    "print(\"nb=49.76%\")\n",
    "print(\"nc=51.37%\")\n",
    "print(\"hence it is obvious that efficiency increases with increase in number of feed heaters.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 8.7;pg no: 272"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 94,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 8.7, Page:272  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 8 Example 7\n",
      "from steam tables,\n",
      "h2=h at 50 bar,500oc=3433.8 KJ/kg,s2=s at 50 bar,500oc=6.9759 KJ/kg K\n",
      "s3=s2=6.9759 KJ/kg K\n",
      "by interpolation from steam tables,\n",
      "T3=183.14oc at 5 bar,h3=2818.03 KJ/kg,h4= h at 5 bar,400oc=3271.9 KJ/kg,s4= s at 5 bar,400oc=7.7938 KJ/kg K\n",
      "for expansion process 4-5,s4=s5=7.7938 KJ/kg K\n",
      "let dryness fraction at state 5 be x5\n",
      "s5=sf at 0.05 bar+x5*sfg at 0.05 bar\n",
      "from steam tables,at 0.05 bar,sf=0.4764 KJ/kg K,sfg=7.9187 KJ/kg K\n",
      "so x5= 0.92\n",
      "h5=hf at 0.05 bar+x5*hfg at 0.05 bar in KJ/kg\n",
      "from steam tables,hf at 0.05 bar=137.82 KJ/kg,hfg at 0.05 bar=2423.7 KJ/kg\n",
      "h6=hf at 0.05 bar=137.82 KJ/kg\n",
      "v6=vf at 0.05 bar=0.001005 m^3/kg\n",
      "for process 6-1 in feed pump,h1 in KJ/kg= 142.84\n",
      "cycle efficiency=W_net/Q_add\n",
      "Wt in KJ/kg= 1510.35\n",
      "W_pump=(h1-h6)in KJ/kg 5.02\n",
      "W_net=Wt-W_pump in KJ/kg 1505.33\n",
      "Q_add in KJ/kg= 3290.96\n",
      "cycle efficiency= 0.4574\n",
      "in percentage= 45.74\n",
      "we know ,1 hp=0.7457 KW\n",
      "specific steam consumption in kg/hp hr= 1.78\n",
      "work ratio=net work/positive work 0.9967\n",
      "so cycle efficiency=45.74%,specific steam consumption =1.78 kg/hp hr,work ratio=0.9967\n"
     ]
    }
   ],
   "source": [
    "#cal of cycle efficiency,specific steam consumption,work ratio\n",
    "#intiation of all variables\n",
    "# Chapter 8\n",
    "print\"Example 8.7, Page:272  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 8 Example 7\")\n",
    "print(\"from steam tables,\")\n",
    "print(\"h2=h at 50 bar,500oc=3433.8 KJ/kg,s2=s at 50 bar,500oc=6.9759 KJ/kg K\")\n",
    "h2=3433.8;\n",
    "s2=6.9759;\n",
    "print(\"s3=s2=6.9759 KJ/kg K\")\n",
    "s3=s2;\n",
    "print(\"by interpolation from steam tables,\")\n",
    "print(\"T3=183.14oc at 5 bar,h3=2818.03 KJ/kg,h4= h at 5 bar,400oc=3271.9 KJ/kg,s4= s at 5 bar,400oc=7.7938 KJ/kg K\")\n",
    "T3=183.14;\n",
    "h3=2818.03;\n",
    "h4=3271.9;\n",
    "s4=7.7938;\n",
    "print(\"for expansion process 4-5,s4=s5=7.7938 KJ/kg K\")\n",
    "s5=s4;\n",
    "print(\"let dryness fraction at state 5 be x5\")\n",
    "print(\"s5=sf at 0.05 bar+x5*sfg at 0.05 bar\")\n",
    "print(\"from steam tables,at 0.05 bar,sf=0.4764 KJ/kg K,sfg=7.9187 KJ/kg K\")\n",
    "sf=0.4764;\n",
    "sfg=7.9187;\n",
    "x5=(s5-sf)/sfg\n",
    "print(\"so x5=\"),round(x5,2)\n",
    "x5=0.924;#approx.\n",
    "print(\"h5=hf at 0.05 bar+x5*hfg at 0.05 bar in KJ/kg\")\n",
    "print(\"from steam tables,hf at 0.05 bar=137.82 KJ/kg,hfg at 0.05 bar=2423.7 KJ/kg\")\n",
    "hf=137.82;\n",
    "hfg=2423.7;\n",
    "h5=hf+x5*hfg \n",
    "print(\"h6=hf at 0.05 bar=137.82 KJ/kg\")\n",
    "h6=137.82;\n",
    "print(\"v6=vf at 0.05 bar=0.001005 m^3/kg\")\n",
    "v6=0.001005;\n",
    "p1=50.;#steam generation pressure in bar\n",
    "p6=0.05;#steam entering temperature in turbine in bar\n",
    "h1=h6+v6*(p1-p6)*100\n",
    "print(\"for process 6-1 in feed pump,h1 in KJ/kg=\"),round(h1,2)\n",
    "print(\"cycle efficiency=W_net/Q_add\")\n",
    "Wt=(h2-h3)+(h4-h5)\n",
    "print(\"Wt in KJ/kg=\"),round(Wt,2)\n",
    "W_pump=(h1-h6)\n",
    "print(\"W_pump=(h1-h6)in KJ/kg\"),round(W_pump,2)\n",
    "W_net=Wt-W_pump\n",
    "print(\"W_net=Wt-W_pump in KJ/kg\"),round(W_net,2)\n",
    "Q_add=(h2-h1)\n",
    "print(\"Q_add in KJ/kg=\"),round(Q_add,2)\n",
    "print(\"cycle efficiency=\"),round(W_net/Q_add,4)\n",
    "W_net*100/Q_add\n",
    "print(\"in percentage=\"),round(W_net*100/Q_add,2)\n",
    "print(\"we know ,1 hp=0.7457 KW\")\n",
    "print(\"specific steam consumption in kg/hp hr=\"),round(0.7457*3600/W_net,2)\n",
    "print(\"work ratio=net work/positive work\"),round(W_net/Wt,4)\n",
    "print(\"so cycle efficiency=45.74%,specific steam consumption =1.78 kg/hp hr,work ratio=0.9967\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 8.8;pg no: 273"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 95,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 8.8, Page:273  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 8 Example 8\n",
      "from steam tables,at state 2,h2=3301.8 KJ/kg,s2=6.7193 KJ/kg K\n",
      "h5=hf at 0.05 bar=137.82 KJ/kg,v5= vf at 0.05 bar=0.001005 m^3/kg\n",
      "Let mass of steam bled for feed heating be m kg/kg of steam generated in boiler.Let us also assume that condensate leaves closed feed water heater as saturated liquid i.e\n",
      "h8=hf at 3 bar=561.47 KJ/kg\n",
      "for process 2-3-4,s2=s3=s4=6.7193 KJ/kg K\n",
      "Let dryness fraction at state 3 and state 4 be x3 and x4 respectively.\n",
      "s3=6.7193=sf at 3 bar+x3* sfg at 3 bar\n",
      "from steam tables,sf=1.6718 KJ/kg K,sfg=5.3201 KJ/kg K\n",
      "so x3= 0.95\n",
      "s4=6.7193=sf at 0.05 bar+x4* sfg at 0.05 bar\n",
      "from steam tables,at 0.05 bar,sf=0.4764 KJ/kg K,sfg=7.9187 KJ/kg K\n",
      "so x4= 0.79\n",
      "thus,h3=hf at 3 bar+x3* hfg at 3 bar in KJ/kg\n",
      "here  from steam tables,at 3 bar,hf_3bar=561.47 KJ/kg,hfg_3bar=2163.8 KJ/kg K\n",
      "h4=hf at 0.05 bar+x4*hfg at 0.05 bar in KJ/kg\n",
      "from steam tables,at 0.05 bar,hf=137.82 KJ/kg,hfg=2423.7 KJ/kg\n",
      "assuming process across trap to be of throttling type so,h8=h9=561.47 KJ/kg.Assuming v5=v6,\n",
      "pumping work=(h7-h6)=v5*(p1-p5)in KJ/kg\n",
      "for mixing process between condenser and feed pump,\n",
      "(1-m)*h5+m*h9=1*h6\n",
      "h6=m(h9-h5)+h5\n",
      "we get,h6=137.82+m*423.65\n",
      "therefore h7=h6+6.02=143.84+m*423.65\n",
      "Applying energy balance at closed feed water heater;\n",
      "m*h3+(1-m)*h7=m*h8+(Cp*T_cond)\n",
      "so (m*2614.92)+(1-m)*(143.84+m*423.65)=m*561.47+480.7\n",
      "so m=0.144 kg\n",
      "steam bled for feed heating=0.144 kg/kg steam generated\n",
      "The net power output,W_net in KJ/kg steam generated= 1167.27\n",
      "mass of steam required to be generated in kg/s= 26.23\n",
      "or in kg/hr\n",
      "so capacity of boiler required=94428 kg/hr\n",
      "overall thermal efficiency=W_net/Q_add\n",
      "here Q_add in KJ/kg= 3134.56\n",
      "overall thermal efficiency= 0.37\n",
      "in percentage= 37.24\n",
      "so overall thermal efficiency=37.24%\n"
     ]
    }
   ],
   "source": [
    "#cal of mass of steam bled for feed heating,capacity of boiler required,overall thermal efficiency\n",
    "#intiation of all variables\n",
    "# Chapter 8\n",
    "print\"Example 8.8, Page:273  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 8 Example 8\")\n",
    "T_cond=115;#condensate temperature in degree celcius\n",
    "Cp=4.18;#specific heat at constant pressure in KJ/kg K\n",
    "P=30*10**3;#actual alternator output in KW\n",
    "n_boiler=0.9;#boiler efficiency\n",
    "n_alternator=0.98;#alternator efficiency\n",
    "print(\"from steam tables,at state 2,h2=3301.8 KJ/kg,s2=6.7193 KJ/kg K\")\n",
    "h2=3301.8;\n",
    "s2=6.7193;\n",
    "print(\"h5=hf at 0.05 bar=137.82 KJ/kg,v5= vf at 0.05 bar=0.001005 m^3/kg\")\n",
    "h5=137.82;\n",
    "v5=0.001005;\n",
    "print(\"Let mass of steam bled for feed heating be m kg/kg of steam generated in boiler.Let us also assume that condensate leaves closed feed water heater as saturated liquid i.e\")\n",
    "print(\"h8=hf at 3 bar=561.47 KJ/kg\")\n",
    "h8=561.47;\n",
    "print(\"for process 2-3-4,s2=s3=s4=6.7193 KJ/kg K\")\n",
    "s3=s2;\n",
    "s4=s3;\n",
    "print(\"Let dryness fraction at state 3 and state 4 be x3 and x4 respectively.\")\n",
    "print(\"s3=6.7193=sf at 3 bar+x3* sfg at 3 bar\")\n",
    "print(\"from steam tables,sf=1.6718 KJ/kg K,sfg=5.3201 KJ/kg K\")\n",
    "sf_3bar=1.6718;\n",
    "sfg_3bar=5.3201;\n",
    "x3=(s3-sf_3bar)/sfg_3bar\n",
    "print(\"so x3=\"),round(x3,2)\n",
    "x3=0.949;#approx.\n",
    "print(\"s4=6.7193=sf at 0.05 bar+x4* sfg at 0.05 bar\")\n",
    "print(\"from steam tables,at 0.05 bar,sf=0.4764 KJ/kg K,sfg=7.9187 KJ/kg K\")\n",
    "sf=0.4764;\n",
    "sfg=7.9187;\n",
    "x4=(s4-sf)/sfg\n",
    "print(\"so x4=\"),round(x4,2)\n",
    "x4=0.788;#approx.\n",
    "print(\"thus,h3=hf at 3 bar+x3* hfg at 3 bar in KJ/kg\")\n",
    "print(\"here  from steam tables,at 3 bar,hf_3bar=561.47 KJ/kg,hfg_3bar=2163.8 KJ/kg K\")\n",
    "hf_3bar=561.47;\n",
    "hfg_3bar=2163.8;\n",
    "h3=hf_3bar+x3*hfg_3bar \n",
    "print(\"h4=hf at 0.05 bar+x4*hfg at 0.05 bar in KJ/kg\")\n",
    "print(\"from steam tables,at 0.05 bar,hf=137.82 KJ/kg,hfg=2423.7 KJ/kg\")\n",
    "hf=137.82;\n",
    "hfg=2423.7;\n",
    "h4=hf+x4*hfg\n",
    "print(\"assuming process across trap to be of throttling type so,h8=h9=561.47 KJ/kg.Assuming v5=v6,\")\n",
    "h9=h8;\n",
    "v6=v5;\n",
    "print(\"pumping work=(h7-h6)=v5*(p1-p5)in KJ/kg\")\n",
    "p1=60;#pressure of steam in high pressure turbine in bar\n",
    "p5=0.05;#pressure of steam in low pressure turbine in bar\n",
    "v5*(p1-p5)*100\n",
    "print(\"for mixing process between condenser and feed pump,\")\n",
    "print(\"(1-m)*h5+m*h9=1*h6\")\n",
    "print(\"h6=m(h9-h5)+h5\")\n",
    "print(\"we get,h6=137.82+m*423.65\")\n",
    "print(\"therefore h7=h6+6.02=143.84+m*423.65\")\n",
    "print(\"Applying energy balance at closed feed water heater;\")\n",
    "print(\"m*h3+(1-m)*h7=m*h8+(Cp*T_cond)\")\n",
    "print(\"so (m*2614.92)+(1-m)*(143.84+m*423.65)=m*561.47+480.7\")\n",
    "print(\"so m=0.144 kg\")\n",
    "m=0.144;\n",
    "h6=137.82+m*423.65;\n",
    "h7=143.84+m*423.65;\n",
    "print(\"steam bled for feed heating=0.144 kg/kg steam generated\")\n",
    "W_net=(h2-h3)+(1-m)*(h3-h4)-(1-m)*(h7-h6)\n",
    "print(\"The net power output,W_net in KJ/kg steam generated=\"),round(W_net,2)\n",
    "P/(n_alternator*W_net)\n",
    "print(\"mass of steam required to be generated in kg/s=\"),round(P/(n_alternator*W_net),2)\n",
    "print(\"or in kg/hr\")\n",
    "26.23*3600\n",
    "print(\"so capacity of boiler required=94428 kg/hr\")\n",
    "print(\"overall thermal efficiency=W_net/Q_add\")\n",
    "Q_add=(h2-Cp*T_cond)/n_boiler\n",
    "print(\"here Q_add in KJ/kg=\"),round(Q_add,2) \n",
    "W_net/Q_add\n",
    "print(\"overall thermal efficiency=\"),round(W_net/Q_add,2)\n",
    "W_net*100/Q_add\n",
    "print(\"in percentage=\"),round(W_net*100/Q_add,2)\n",
    "print(\"so overall thermal efficiency=37.24%\")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 8.9;pg no: 275"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 96,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 8.9, Page:275  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 8 Example 9\n",
      "At inlet to first turbine stage,h2=3230.9 KJ/kg,s2=6.9212 KJ/kg K\n",
      "For ideal expansion process,s2=s3\n",
      "By interpolation,T3=190.97 degree celcius from superheated steam tables at 6 bar,h3=2829.63 KJ/kg\n",
      "actual stste at exit of first stage,h3_a in KJ/kg= 2909.88\n",
      "actual state 3_a shall be at 232.78 degree celcius,6 bar,so s3_a KJ/kg K= 7.1075\n",
      "for second stage,s3_a=s4;By interpolation,s4=7.1075=sf at 1 bar+x4*sfg at 1 bar\n",
      "from steam tables,at 1 bar,sf=1.3026 KJ/kg K,sfg=6.0568 KJ/kg K\n",
      "so x4= 0.96\n",
      "h4=hf at 1 bar+x4*hfg at 1 bar in KJ/kg\n",
      "from steam tables,at 1 bar,hf=417.46 KJ/kg,hfg=2258.0 KJ/kg\n",
      "actual enthalpy at exit from second stage,h4_a in KJ/kg= 2646.48\n",
      "actual dryness fraction,x4_a=>h4_a=hf at 1 bar+x4_a*hfg at 1 bar\n",
      "so x4_a= 0.99\n",
      "x4_a=0.987,actual entropy,s4_a=7.2806 KJ/kg K\n",
      "for third stage,s4_a=7.2806=sf at 0.075 bar+x5*sfg at 0.075 bar\n",
      "from steam tables,at 0.075 bar,sf=0.5764 KJ/kg K,sfg=7.6750 KJ/kg K\n",
      "so x5= 0.87\n",
      "h5=2270.43 KJ/kg\n",
      "actual enthalpy at exit from third stage,h5_a in KJ/kg= 2345.64\n",
      "Let mass of steam bled out be m1 and m2 kg at 6 bar,1 bar respectively.\n",
      "By heat balance on first closed feed water heater,(see schematic arrangement)\n",
      "h11=hf at 6 bar=670.56 KJ\n",
      "m1*h3_a+h10=m1*h11+4.18*150\n",
      "(m1*2829.63)+h10=(m1*670.56)+627\n",
      "h10+2159.07*m1=627\n",
      "By heat balance on second closed feed water heater,(see schematic arrangement)\n",
      "h7=hf at 1 bar=417.46 KJ/kg\n",
      "m2*h4+(1-m1-m2)*4.18*38=(m1+m2)*h7+4.18*95*(1-m1-m2)\n",
      "m2*2646.4+(1-m1-m2)*158.84=((m1+m2)*417.46)+(397.1*(1-m1-m2))\n",
      "m2*2467.27-m1*179.2-238.26=0\n",
      "heat balance at point of mixing,\n",
      "h10=(m1+m2)*h8+(1-m1-m2)*4.18*95\n",
      "neglecting pump work,h7=h8\n",
      "h10=m2*417.46+(1-m1-m2)*397.1\n",
      "substituting h10 and solving we get,m1=0.1293 kg and m2=0.1059 kg/kg of steam generated\n",
      "Turbine output per kg of steam generated,Wt in KJ/kg of steam generated= 780.445\n",
      "Rate of steam generation required in kg/s= 19.22\n",
      "in kg/hr\n",
      "capacity of drain pump i.e. FP shown in layout in kg/hr= 16273.96\n",
      "so capacity of drain pump=16273.96 kg/hr\n"
     ]
    }
   ],
   "source": [
    "#cal of capacity of drain pump\n",
    "#intiation of all variables\n",
    "# Chapter 8\n",
    "print\"Example 8.9, Page:275  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 8 Example 9\")\n",
    "P=15*10**3;#turbine output in KW\n",
    "print(\"At inlet to first turbine stage,h2=3230.9 KJ/kg,s2=6.9212 KJ/kg K\")\n",
    "h2=3230.9;\n",
    "s2=6.9212;\n",
    "print(\"For ideal expansion process,s2=s3\")\n",
    "s3=s2;\n",
    "print(\"By interpolation,T3=190.97 degree celcius from superheated steam tables at 6 bar,h3=2829.63 KJ/kg\")\n",
    "T3=190.97;\n",
    "h3=2829.63;\n",
    "h3_a=h2-0.8*(h2-h3)\n",
    "print(\"actual stste at exit of first stage,h3_a in KJ/kg=\"),round(h3_a,2)\n",
    "s3_a=7.1075;\n",
    "print(\"actual state 3_a shall be at 232.78 degree celcius,6 bar,so s3_a KJ/kg K=\"),round(s3_a,4)\n",
    "print(\"for second stage,s3_a=s4;By interpolation,s4=7.1075=sf at 1 bar+x4*sfg at 1 bar\")\n",
    "s4=7.1075;\n",
    "print(\"from steam tables,at 1 bar,sf=1.3026 KJ/kg K,sfg=6.0568 KJ/kg K\")\n",
    "sf=1.3026;\n",
    "sfg=6.0568;\n",
    "x4=(s4-sf)/sfg\n",
    "print(\"so x4=\"),round(x4,2)\n",
    "x4=0.958;#approx.\n",
    "print(\"h4=hf at 1 bar+x4*hfg at 1 bar in KJ/kg\")\n",
    "print(\"from steam tables,at 1 bar,hf=417.46 KJ/kg,hfg=2258.0 KJ/kg\")\n",
    "hf=417.46;\n",
    "hfg=2258.0;\n",
    "h4=hf+x4*hfg\n",
    "h4_a=h3_a-.8*(h3_a-h4)\n",
    "print(\"actual enthalpy at exit from second stage,h4_a in KJ/kg=\"),round(h4_a,2)\n",
    "print(\"actual dryness fraction,x4_a=>h4_a=hf at 1 bar+x4_a*hfg at 1 bar\")\n",
    "x4_a=(h4_a-hf)/hfg\n",
    "print(\"so x4_a=\"),round(x4_a,2)\n",
    "print(\"x4_a=0.987,actual entropy,s4_a=7.2806 KJ/kg K\")\n",
    "s4_a=7.2806;\n",
    "print(\"for third stage,s4_a=7.2806=sf at 0.075 bar+x5*sfg at 0.075 bar\")\n",
    "print(\"from steam tables,at 0.075 bar,sf=0.5764 KJ/kg K,sfg=7.6750 KJ/kg K\")\n",
    "sf=0.5764;\n",
    "sfg=7.6750;\n",
    "x5=(s4_a-sf)/sfg\n",
    "print(\"so x5=\"),round(x5,2)\n",
    "x5=0.8735;#approx.\n",
    "print(\"h5=2270.43 KJ/kg\")\n",
    "h5=2270.43;\n",
    "h5_a=h4_a-0.8*(h4_a-h5)\n",
    "print(\"actual enthalpy at exit from third stage,h5_a in KJ/kg=\"),round(h5_a,2)\n",
    "print(\"Let mass of steam bled out be m1 and m2 kg at 6 bar,1 bar respectively.\")\n",
    "print(\"By heat balance on first closed feed water heater,(see schematic arrangement)\")\n",
    "print(\"h11=hf at 6 bar=670.56 KJ\")\n",
    "h11=670.56;\n",
    "print(\"m1*h3_a+h10=m1*h11+4.18*150\")\n",
    "print(\"(m1*2829.63)+h10=(m1*670.56)+627\")\n",
    "print(\"h10+2159.07*m1=627\")\n",
    "print(\"By heat balance on second closed feed water heater,(see schematic arrangement)\")\n",
    "print(\"h7=hf at 1 bar=417.46 KJ/kg\")\n",
    "h7=417.46;\n",
    "print(\"m2*h4+(1-m1-m2)*4.18*38=(m1+m2)*h7+4.18*95*(1-m1-m2)\")\n",
    "print(\"m2*2646.4+(1-m1-m2)*158.84=((m1+m2)*417.46)+(397.1*(1-m1-m2))\")\n",
    "print(\"m2*2467.27-m1*179.2-238.26=0\")\n",
    "print(\"heat balance at point of mixing,\")\n",
    "print(\"h10=(m1+m2)*h8+(1-m1-m2)*4.18*95\")\n",
    "print(\"neglecting pump work,h7=h8\")\n",
    "print(\"h10=m2*417.46+(1-m1-m2)*397.1\")\n",
    "print(\"substituting h10 and solving we get,m1=0.1293 kg and m2=0.1059 kg/kg of steam generated\")\n",
    "m1=0.1293;\n",
    "m2=0.1059;\n",
    "Wt=(h2-h3_a)+(1-m1)*(h3_a-h4_a)+(1-m1-m2)*(h4_a-h5_a)\n",
    "print(\"Turbine output per kg of steam generated,Wt in KJ/kg of steam generated=\"),round(Wt,3)\n",
    "P/Wt\n",
    "print(\"Rate of steam generation required in kg/s=\"),round(P/Wt,2)\n",
    "print(\"in kg/hr\")\n",
    "P*3600/Wt\n",
    "(m1+m2)*69192\n",
    "print(\"capacity of drain pump i.e. FP shown in layout in kg/hr=\"),round((m1+m2)*69192,2)\n",
    "print(\"so capacity of drain pump=16273.96 kg/hr\")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 8.10;pg no: 277"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 97,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 8.10, Page:277  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 8 Example 10\n",
      "at inlet to HP turbine,h2=3287.1 KJ/kg,s2=6.6327 KJ/kg K\n",
      "By interpolation state 3 i.e. for isentropic expansion betweeen 2-3 lies at 328.98oc at 30 bar.h3=3049.48 KJ/kg\n",
      "actual enthapy at 3_a,h3_a in KJ/kg= 3097.0\n",
      "enthalpy at inlet to LP turbine,h4=3230.9 KJ/kg,s4=6.9212 KJ K\n",
      "for ideal expansion from 4-6,s4=s6.Let dryness fraction at state 6 be x6.\n",
      "s6=6.9212=sf at 0.075 bar+x6* sfg at 0.075 bar in KJ/kg K\n",
      "from steam tables,at 0.075 bar,sf=0.5764 KJ/kg K,sfg=7.6750 KJ/kg K\n",
      "so x6= 0.83\n",
      "h6=hf at 0.075 bar+x6*hfg at 0.075 bar in KJ/kg K\n",
      "from steam tables,at 0.075 bar,hf=168.79 KJ/kg,hfg=2406.0 KJ/kg\n",
      "for actual expansion process in LP turbine.\n",
      "h6_a=h4-0.85*(h4-h6) in KJ/kg 2319.4\n",
      "Ideally,enthalpy at bleed point can be obtained by locating state 5 using s5=s4.The pressure at bleed point shall be saturation pressure corresponding to the 140oc i.e from steam tables.Let dryness fraction at state 5 be x5.\n",
      "s5_a=6.9212=sf at 140oc+x5*sfg at 140oc\n",
      "from steam tables,at 140oc,sf=1.7391 KJ/kg K,sfg=5.1908 KJ/kg K\n",
      "so x5= 1.0\n",
      "h5=hf at 140oc+x5*hfg at 140oc in KJ/kg\n",
      "from steam tables,at 140oc,hf=589.13 KJ/kg,hfg=2144.7 KJ/kg\n",
      "actual enthalpy,h5_a in KJ/kg= 2790.16\n",
      "enthalpy at exit of open feed water heater,h9=hf at 30 bar=1008.42 KJ/kg\n",
      "specific volume at inlet of CEP,v7=0.001008 m^3/kg\n",
      "enthalpy at inlet of CEP,h7=168.79 KJ/kg\n",
      "for pumping process 7-8,h8 in KJ/kg= 169.15\n",
      "Applying energy balance at open feed water heater.Let mass of bled steam be m kg per kg of steam generated.\n",
      "m*h5+(1-m)*h8=h9\n",
      "so m in kg /kg of steam generated= 0.33\n",
      "For process on feed pump,9-1,v9=vf at 140oc=0.00108 m^3/kg\n",
      "h1= in KJ/kg= 1015.59\n",
      "Net work per kg of steam generated,W_net=in KJ/kg steam generated= 938.83\n",
      "heat added per kg of steam generated,q_add in KJ/kg of steam generated= 2405.41\n",
      "Thermal efficiency,n= 0.39\n",
      "in percentage= 39.03\n",
      "so thermal efficiency=39.03%%\n",
      "NOTE=>In this question there is some calculation mistake while calculating W_net and q_add in book, which is corrected above and the answers may vary.\n"
     ]
    }
   ],
   "source": [
    "#cal of cycle efficiency\n",
    "#intiation of all variables\n",
    "# Chapter 8\n",
    "print\"Example 8.10, Page:277  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 8 Example 10\")\n",
    "print(\"at inlet to HP turbine,h2=3287.1 KJ/kg,s2=6.6327 KJ/kg K\")\n",
    "h2=3287.1;\n",
    "s2=6.6327;\n",
    "print(\"By interpolation state 3 i.e. for isentropic expansion betweeen 2-3 lies at 328.98oc at 30 bar.h3=3049.48 KJ/kg\")\n",
    "h3=3049.48;\n",
    "h3_a=h2-0.80*(h2-h3)\n",
    "print(\"actual enthapy at 3_a,h3_a in KJ/kg=\"),round(h3_a,2)\n",
    "print(\"enthalpy at inlet to LP turbine,h4=3230.9 KJ/kg,s4=6.9212 KJ K\")\n",
    "h4=3230.9;\n",
    "s4=6.9212;\n",
    "print(\"for ideal expansion from 4-6,s4=s6.Let dryness fraction at state 6 be x6.\")\n",
    "s6=s4;\n",
    "print(\"s6=6.9212=sf at 0.075 bar+x6* sfg at 0.075 bar in KJ/kg K\")\n",
    "print(\"from steam tables,at 0.075 bar,sf=0.5764 KJ/kg K,sfg=7.6750 KJ/kg K\")\n",
    "sf=0.5764;\n",
    "sfg=7.6750;\n",
    "x6=(s6-sf)/sfg\n",
    "print(\"so x6=\"),round(x6,2)\n",
    "x6=0.827;#approx.\n",
    "print(\"h6=hf at 0.075 bar+x6*hfg at 0.075 bar in KJ/kg K\")\n",
    "print(\"from steam tables,at 0.075 bar,hf=168.79 KJ/kg,hfg=2406.0 KJ/kg\")\n",
    "hf=168.79;\n",
    "hfg=2406.0;\n",
    "h6=hf+x6*hfg\n",
    "print(\"for actual expansion process in LP turbine.\")\n",
    "h6_a=h4-0.85*(h4-h6)\n",
    "print(\"h6_a=h4-0.85*(h4-h6) in KJ/kg\"),round(h6_a,2)\n",
    "print(\"Ideally,enthalpy at bleed point can be obtained by locating state 5 using s5=s4.The pressure at bleed point shall be saturation pressure corresponding to the 140oc i.e from steam tables.Let dryness fraction at state 5 be x5.\")\n",
    "p5=3.61;\n",
    "s5=s4;\n",
    "print(\"s5_a=6.9212=sf at 140oc+x5*sfg at 140oc\")\n",
    "print(\"from steam tables,at 140oc,sf=1.7391 KJ/kg K,sfg=5.1908 KJ/kg K\")\n",
    "sf=1.7391;\n",
    "sfg=5.1908;\n",
    "x5=(s5-sf)/sfg\n",
    "print(\"so x5=\"),round(x5,2)\n",
    "x5=0.99;#approx.\n",
    "print(\"h5=hf at 140oc+x5*hfg at 140oc in KJ/kg\")\n",
    "print(\"from steam tables,at 140oc,hf=589.13 KJ/kg,hfg=2144.7 KJ/kg\")\n",
    "hf=589.13;\n",
    "hfg=2144.7;\n",
    "h5=hf+x5*hfg\n",
    "h5_a=h4-0.85*(h4-h5)\n",
    "print(\"actual enthalpy,h5_a in KJ/kg=\"),round(h5_a,2)\n",
    "print(\"enthalpy at exit of open feed water heater,h9=hf at 30 bar=1008.42 KJ/kg\")\n",
    "h9=1008.42;\n",
    "print(\"specific volume at inlet of CEP,v7=0.001008 m^3/kg\")\n",
    "v7=0.001008;\n",
    "print(\"enthalpy at inlet of CEP,h7=168.79 KJ/kg\")\n",
    "h7=168.79;\n",
    "h8=h7+v7*(3.61-0.075)*10**2\n",
    "print(\"for pumping process 7-8,h8 in KJ/kg=\"),round(h8,2)\n",
    "print(\"Applying energy balance at open feed water heater.Let mass of bled steam be m kg per kg of steam generated.\")\n",
    "print(\"m*h5+(1-m)*h8=h9\")\n",
    "m=(h9-h8)/(h5-h8)\n",
    "print(\"so m in kg /kg of steam generated=\"),round(m,2)\n",
    "print(\"For process on feed pump,9-1,v9=vf at 140oc=0.00108 m^3/kg\")\n",
    "v9=0.00108;\n",
    "h1=h9+v9*(70-3.61)*10**2\n",
    "print(\"h1= in KJ/kg=\"),round(h1,2) \n",
    "W_net=(h2-h3_a)+(h4-h5_a)+(1-m)*(h5_a-h6_a)-((1-m)*(h8-h7)+(h1-h9))\n",
    "print(\"Net work per kg of steam generated,W_net=in KJ/kg steam generated=\"),round(W_net,2)\n",
    "q_add=(h2-h1)+(h4-h3_a)\n",
    "print(\"heat added per kg of steam generated,q_add in KJ/kg of steam generated=\"),round(q_add,2)\n",
    "n=W_net/q_add\n",
    "print(\"Thermal efficiency,n=\"),round(n,2)\n",
    "n=n*100\n",
    "print(\"in percentage=\"),round(n,2)\n",
    "print(\"so thermal efficiency=39.03%%\")\n",
    "print(\"NOTE=>In this question there is some calculation mistake while calculating W_net and q_add in book, which is corrected above and the answers may vary.\")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 8.11;pg no: 279"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 98,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 8.11, Page:279  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 8 Example 11\n",
      "Enthalpy of steam entering ST1,h2=3308.6 KJ/kg,s2=6.3443 KJ/kg K\n",
      "for isentropic expansion 2-3-4-5,s2=s3=s4=s5\n",
      "Let dryness fraction of states 3,4 and 5 be x3,x4 and x5\n",
      "s3=6.3443=sf at 10 bar+x3*sfg at 10 bar\n",
      "so x3=(s3-sf)/sfg\n",
      "from steam tables,at 10 bar,sf=2.1387 KJ/kg K,sfg=4.4478 KJ/kg K\n",
      "h3=hf+x3*hfg in KJ/kg\n",
      "from steam tables,hf=762.81 KJ/kg,hfg=2015.3 KJ/kg\n",
      "s4=6.3443=sf at 1.5 bar+x4*sfg at 1.5 bar\n",
      "so x4=(s4-sf)/sfg\n",
      "from steam tables,at 1.5 bar,sf=1.4336 KJ/kg K,sfg=5.7897 KJ/kg K\n",
      "so h4=hf+x4*hfg in KJ/kg\n",
      "from steam tables,at 1.5 bar,hf=467.11 KJ/kg,hfg=2226.5 KJ/kg\n",
      "s5=6.3443=sf at 0.05 bar+x5*sfg at 0.05 bar\n",
      "so x5=(s5-sf)/sfg\n",
      "from steam tables,at 0.05 bar,sf=0.4764 KJ/kg K,sfg=7.9187 KJ/kg K\n",
      "h5=hf+x5*hfg in KJ/kg\n",
      "from steam tables,at 0.05 bar,hf=137.82 KJ/kg,hfg=2423.7 KJ/kg\n",
      "h6=hf at 0.05 bar=137.82 KJ/kg\n",
      "v6=vf at 0.05 bar=0.001005 m^3/kg\n",
      "h7=h6+v6*(1.5-0.05)*10^2 in KJ/kg\n",
      "h8=hf at 1.5 bar=467.11 KJ/kg\n",
      "v8=0.001053 m^3/kg=vf at 1.5 bar\n",
      "h9=h8+v8*(150-1.5)*10^2 in KJ/kg\n",
      "h10=hf at 150 bar=1610.5 KJ/kg\n",
      "v10=0.001658 m^3/kg=vf at 150 bar\n",
      "h12=h10+v10*(150-10)*10^2 in KJ/kg\n",
      "Let mass of steam bled out at 10 bar,1.5 bar be m1 and m2 per kg of steam generated.\n",
      "Heat balance on closed  feed water heater yields,\n",
      "m1*h3+(1-m)*h9=m1*h10+(1-m1)*4.18*150\n",
      "so m1=(4.18*150-h9)/(h3-h9-h10+4.18*150)in kg/kg of steam generated.\n",
      "heat balance on open feed water can be given as under,\n",
      "m2*h4+(1-m1-m2)*h7=(1-m1)*h8\n",
      "so m2=((1-m1)*(h8-h7))/(h4-h7)in kg/kg of steam\n",
      "for mass flow rate of 300 kg/s=>m1=36 kg/s,m2=39 kg/s\n",
      "For mixing after closed feed water heater,\n",
      "h1=(4.18*150)*(1-m1)+m1*h12 in KJ/kg\n",
      "Net work output per kg of steam generated=W_ST1+W_ST2+W_ST3-{W_CEP+W_FP+W_FP2}\n",
      "W_net=(h2-h3)+(1-m1)*(h3-h4)+(1-m1-m2)*(h4-h5)-{(1-m1-m2)*(h7-h6)+(1-m1)*(h9-h8)+(m1*(h12-h10))}in KJ/kg of steam generated.\n",
      "heat added per kg of steam generated,q_add=(h2-h1) in KJ/kg\n",
      "cycle thermal efficiency,n=W_net/q_add 0.48\n",
      "in percentage 47.59\n",
      "Net power developed in KW=1219*300 in KW 365700.0\n",
      "cycle thermal efficiency=47.6%\n",
      "Net power developed=365700 KW\n"
     ]
    }
   ],
   "source": [
    "#cal of cycle thermal efficiency,Net power developed\n",
    "#intiation of all variables\n",
    "# Chapter 8\n",
    "print\"Example 8.11, Page:279  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 8 Example 11\")\n",
    "print(\"Enthalpy of steam entering ST1,h2=3308.6 KJ/kg,s2=6.3443 KJ/kg K\")\n",
    "h2=3308.6;\n",
    "s2=6.3443;\n",
    "print(\"for isentropic expansion 2-3-4-5,s2=s3=s4=s5\")\n",
    "s3=s2;\n",
    "s4=s3;\n",
    "s5=s4;\n",
    "print(\"Let dryness fraction of states 3,4 and 5 be x3,x4 and x5\")\n",
    "print(\"s3=6.3443=sf at 10 bar+x3*sfg at 10 bar\")\n",
    "print(\"so x3=(s3-sf)/sfg\")\n",
    "print(\"from steam tables,at 10 bar,sf=2.1387 KJ/kg K,sfg=4.4478 KJ/kg K\")\n",
    "sf=2.1387;\n",
    "sfg=4.4478;\n",
    "x3=(s3-sf)/sfg\n",
    "x3=0.945;#approx.\n",
    "print(\"h3=hf+x3*hfg in KJ/kg\")\n",
    "print(\"from steam tables,hf=762.81 KJ/kg,hfg=2015.3 KJ/kg\")\n",
    "hf=762.81;\n",
    "hfg=2015.3;\n",
    "h3=hf+x3*hfg\n",
    "print(\"s4=6.3443=sf at 1.5 bar+x4*sfg at 1.5 bar\")\n",
    "print(\"so x4=(s4-sf)/sfg\")\n",
    "print(\"from steam tables,at 1.5 bar,sf=1.4336 KJ/kg K,sfg=5.7897 KJ/kg K\")\n",
    "sf=1.4336;\n",
    "sfg=5.7897;\n",
    "x4=(s4-sf)/sfg\n",
    "x4=0.848;#approx.\n",
    "print(\"so h4=hf+x4*hfg in KJ/kg\")\n",
    "print(\"from steam tables,at 1.5 bar,hf=467.11 KJ/kg,hfg=2226.5 KJ/kg\")\n",
    "hf=467.11;\n",
    "hfg=2226.5;\n",
    "h4=hf+x4*hfg\n",
    "print(\"s5=6.3443=sf at 0.05 bar+x5*sfg at 0.05 bar\")\n",
    "print(\"so x5=(s5-sf)/sfg\")\n",
    "print(\"from steam tables,at 0.05 bar,sf=0.4764 KJ/kg K,sfg=7.9187 KJ/kg K\")\n",
    "sf=0.4764;\n",
    "sfg=7.9187;\n",
    "x5=(s5-sf)/sfg\n",
    "x5=0.739;#approx.\n",
    "print(\"h5=hf+x5*hfg in KJ/kg\")\n",
    "print(\"from steam tables,at 0.05 bar,hf=137.82 KJ/kg,hfg=2423.7 KJ/kg\")\n",
    "hf=137.82;\n",
    "hfg=2423.7;\n",
    "h5=hf+x5*hfg \n",
    "print(\"h6=hf at 0.05 bar=137.82 KJ/kg\")\n",
    "h6=137.82;\n",
    "print(\"v6=vf at 0.05 bar=0.001005 m^3/kg\")\n",
    "v6=0.001005;\n",
    "print(\"h7=h6+v6*(1.5-0.05)*10^2 in KJ/kg\")\n",
    "h7=h6+v6*(1.5-0.05)*10**2\n",
    "print(\"h8=hf at 1.5 bar=467.11 KJ/kg\")\n",
    "h8=467.11; \n",
    "print(\"v8=0.001053 m^3/kg=vf at 1.5 bar\")\n",
    "v8=0.001053;\n",
    "print(\"h9=h8+v8*(150-1.5)*10^2 in KJ/kg\")\n",
    "h9=h8+v8*(150-1.5)*10**2\n",
    "print(\"h10=hf at 150 bar=1610.5 KJ/kg\")\n",
    "h10=1610.5; \n",
    "print(\"v10=0.001658 m^3/kg=vf at 150 bar\")\n",
    "v10=0.001658;\n",
    "print(\"h12=h10+v10*(150-10)*10^2 in KJ/kg\")\n",
    "h12=h10+v10*(150-10)*10**2\n",
    "print(\"Let mass of steam bled out at 10 bar,1.5 bar be m1 and m2 per kg of steam generated.\")\n",
    "print(\"Heat balance on closed  feed water heater yields,\")\n",
    "print(\"m1*h3+(1-m)*h9=m1*h10+(1-m1)*4.18*150\")\n",
    "print(\"so m1=(4.18*150-h9)/(h3-h9-h10+4.18*150)in kg/kg of steam generated.\")\n",
    "m1=(4.18*150-h9)/(h3-h9-h10+4.18*150)\n",
    "print(\"heat balance on open feed water can be given as under,\")\n",
    "print(\"m2*h4+(1-m1-m2)*h7=(1-m1)*h8\")\n",
    "print(\"so m2=((1-m1)*(h8-h7))/(h4-h7)in kg/kg of steam\")\n",
    "m2=((1-m1)*(h8-h7))/(h4-h7)\n",
    "print(\"for mass flow rate of 300 kg/s=>m1=36 kg/s,m2=39 kg/s\")\n",
    "print(\"For mixing after closed feed water heater,\")\n",
    "print(\"h1=(4.18*150)*(1-m1)+m1*h12 in KJ/kg\")\n",
    "h1=(4.18*150)*(1-m1)+m1*h12\n",
    "print(\"Net work output per kg of steam generated=W_ST1+W_ST2+W_ST3-{W_CEP+W_FP+W_FP2}\")\n",
    "print(\"W_net=(h2-h3)+(1-m1)*(h3-h4)+(1-m1-m2)*(h4-h5)-{(1-m1-m2)*(h7-h6)+(1-m1)*(h9-h8)+(m1*(h12-h10))}in KJ/kg of steam generated.\")\n",
    "W_net=(h2-h3)+(1-m1)*(h3-h4)+(1-m1-m2)*(h4-h5)-((1-m1-m2)*(h7-h6)+(1-m1)*(h9-h8)+(m1*(h12-h10)))\n",
    "print(\"heat added per kg of steam generated,q_add=(h2-h1) in KJ/kg\")\n",
    "q_add=(h2-h1)\n",
    "n=W_net/q_add\n",
    "print(\"cycle thermal efficiency,n=W_net/q_add\"),round(n,2)\n",
    "print(\"in percentage\"),round(n*100,2)\n",
    "print(\"Net power developed in KW=1219*300 in KW\"),round(1219*300,2)\n",
    "print(\"cycle thermal efficiency=47.6%\")\n",
    "print(\"Net power developed=365700 KW\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 8.12;pg no: 282"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 99,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 8.12, Page:282  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 8 Example 12\n",
      "At inlet to HPT,h2=3373.7 KJ/kg,s2=6.5966 KJ/kg K\n",
      "For isentropic expansion between 2-3-4-5,s2=s3=s4=s5\n",
      "state 3 lies in superheated region as s3>sg at 20 bar.By interpolation from superheated steam table,T3=261.6oc.Enthalpy at 3,h3=2930.57 KJ/kg\n",
      "since s4<sg at 4 bar so state 4 and 5 lies in wet region.\n",
      "Let dryness fraction at state 4 ans 5 be x4 and x5.\n",
      "s4=6.5966=sf at 4 bar+x4*sfg at 4 bar\n",
      "from steam tables,at 4 bar,sf=1.7766 KJ/kg K,sfg=5.1193 KJ/kg K\n",
      "x4=(s4-sf)/sfg\n",
      "h4=hf at 4 bar+x4*hfg at 4 bar in KJ/kg\n",
      "from steam tables,at 4 bar,hf=604.74 KJ/kg,hfg=2133.8 KJ/kg\n",
      "for state 5,\n",
      "s5=6.5966=sf at 0.075 bar+x5*sfg at 0.075 bar\n",
      "from steam tables,at 0.075 bar,sf=0.5764 KJ/kg K,sfg=7.6750 KJ/kg K\n",
      "x5=(s5-sf)/sfg\n",
      "h5=hf at 0.075 bar+x5*hfg at 0.075 bar in KJ/kg\n",
      "from steam tables,at 0.075 bar,hf=168.76 KJ/kg,hfg=2406.0 KJ/kg\n",
      "Let mass of steam bled at 20 bar be m1 and m2 per kg of steam generated.\n",
      "h10=hf at 20 bar=908.76 KJ/kg,h8=hf at 4 bar=604.74 KJ/kg\n",
      "At trap h10=h11=908.79 KJ/kg\n",
      "At condensate extraction pump,(CEP),h7-h6=v6*(4-0.075)*10^2 in KJ/kg\n",
      "here v6=vf at 0.075 bar=0.001008 m^3/kg,h6=hf at 0.075 bar=168.79 KJ/kg\n",
      "so h7=h6+v6*(4-0.075)*10^2 in KJ/kg\n",
      "At feed pump,(FP),h9-h8=v8*(20-4)*10^2 in KJ/kg\n",
      "here v8=vf at 4 bar=0.001084 m^3/kg,h8=hf at 4 bar=604.74 KJ/kg\n",
      "so h9=h8+v8*(20-4)*10^2 in KJ/kg\n",
      "Let us apply heat balance at closed feed water heater,\n",
      "m1*h3+h9=m1*h10+4.18*200\n",
      "so m1=(4.18*200-h9)/(h3-h10) in kg\n",
      "Applying heat balance at open feed water,\n",
      "m1*h11+m2*h4+(1-m1-m2)*h7=h8\n",
      "so m2=(h8-m1*h11-h7+m1*h7)/(h4-h7) in kg\n",
      "Net work per kg steam generated,\n",
      "w_net=(h2-h3)+(1-m1)*(h3-h4)+(1-m1-m2)*(h4-h5)-{(1-m1-m2)*(h7-h6)+(h9-h8)} in KJ/kg\n",
      "Heat added per kg steam generated,q_add=(h2-h1) in KJ/kg\n",
      "Thermal efficiency=w_net/q_add 0.45\n",
      "in percentage 44.78\n",
      "steam generation rate=P/w_net in kg/s 87.99\n",
      "so thermal efficiency=44.78%\n",
      "steam generation rate=87.99 kg/s\n",
      "a> For the reheating introduced at 20 bar up to 400oc.The modified cycle representation is shown on T-S diagram by 1-2-3-3_a-4_a-5_a-6-7-8-9-10-11\n",
      "At state 2,h2=3373.7 KJ/kg,s2=6.5966 KJ/kg K\n",
      "At state 3,h3=2930.57 KJ/kg\n",
      "At state 3_a,h3_a=3247.6 KJ/kg,s3_a=7.1271 KJ/kg K\n",
      "At state 4_a and 5_a,s3_a=s4_a=s5_a=7.1271 KJ/kg K\n",
      "From steam tables by interpolation state 4_a is seen to be at 190.96oc at 4 bar,h4_a=2841.02 KJ/kg\n",
      "Let dryness fraction at state 5_a be x5,\n",
      "s5_a=7.1271=sf at 0.075 bar+x5_a*sfg at 0.075 bar\n",
      "from steam tables,at 0.075 bar,sf=0.5764 KJ/kg K,sfg=7.6750 KJ/kg K\n",
      "so x5_a=(s5_a-sf)/sfg\n",
      "h5_a=hf at 0.075 bar+x5_a*hfg at 0.075 bar in KJ/kg\n",
      "from steam tables,at 0.075 bar,hf=168.76 KJ/kg,hfg=2406.0 KJ/kg\n",
      "Let mass of bled steam at 20 bar and 4 bar be m1_a,m2_a per kg of steam generated.Applying heat balance at closed feed water heater.\n",
      "m1_a*h3+h9=m1*h10+4.18*200\n",
      "so m1_a=(4.18*200-h9)/(h3-h10) in kg\n",
      "Applying heat balance at open feed water heater,\n",
      "m1_a*h11+m2_a*h4_a+(1-m1_a-m2_a)*h7=h8\n",
      "so m2_a=(h8-m1_a*h11-h7+m1_a*h7)/(h4_a-h7) in kg\n",
      "Net work per kg steam generated\n",
      "w_net=(h2-h3)+(1-m1_a)*(h3_a-h4_a)+(1-m1_a-m2_a)*(h4_a-h5_a)-{(1-m1_a-m2_a)*(h7-h6)+(h9-h8)}in KJ/kg\n",
      "Heat added per kg steam generated,q_add=(h2-h1)+(1-m1_a)*(h3_a-h3)in KJ/kg\n",
      "Thermal efficiency,n= 0.45\n",
      "in percentage 45.04\n",
      "% increase in thermal efficiency due to reheating= 0.56\n",
      "so thermal efficiency of reheat cycle=45.03%\n",
      "% increase in efficiency due to reheating=0.56%\n"
     ]
    }
   ],
   "source": [
    "#cal of thermal efficiency,steam generation rate\n",
    "#intiation of all variables\n",
    "# Chapter 8\n",
    "print\"Example 8.12, Page:282  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 8 Example 12\")\n",
    "P=100*10**3;#net power output in KW\n",
    "print(\"At inlet to HPT,h2=3373.7 KJ/kg,s2=6.5966 KJ/kg K\")\n",
    "h2=3373.7;\n",
    "s2=6.5966;\n",
    "print(\"For isentropic expansion between 2-3-4-5,s2=s3=s4=s5\")\n",
    "s3=s2;\n",
    "s4=s3;\n",
    "s5=s4;\n",
    "print(\"state 3 lies in superheated region as s3>sg at 20 bar.By interpolation from superheated steam table,T3=261.6oc.Enthalpy at 3,h3=2930.57 KJ/kg\")\n",
    "T3=261.6;\n",
    "h3=2930.57;\n",
    "print(\"since s4<sg at 4 bar so state 4 and 5 lies in wet region.\")\n",
    "print(\"Let dryness fraction at state 4 ans 5 be x4 and x5.\")\n",
    "print(\"s4=6.5966=sf at 4 bar+x4*sfg at 4 bar\")\n",
    "print(\"from steam tables,at 4 bar,sf=1.7766 KJ/kg K,sfg=5.1193 KJ/kg K\")\n",
    "sf=1.7766;\n",
    "sfg=5.1193;\n",
    "print(\"x4=(s4-sf)/sfg\")\n",
    "x4=(s4-sf)/sfg\n",
    "x4=0.941;#approx.\n",
    "print(\"h4=hf at 4 bar+x4*hfg at 4 bar in KJ/kg\")\n",
    "print(\"from steam tables,at 4 bar,hf=604.74 KJ/kg,hfg=2133.8 KJ/kg\")\n",
    "hf=604.74;\n",
    "hfg=2133.8;\n",
    "h4=hf+x4*hfg\n",
    "print(\"for state 5,\")\n",
    "print(\"s5=6.5966=sf at 0.075 bar+x5*sfg at 0.075 bar\")\n",
    "print(\"from steam tables,at 0.075 bar,sf=0.5764 KJ/kg K,sfg=7.6750 KJ/kg K\")\n",
    "sf=0.5764;\n",
    "sfg=7.6750;\n",
    "print(\"x5=(s5-sf)/sfg\")\n",
    "x5=(s5-sf)/sfg\n",
    "x5=0.784;#approx.\n",
    "print(\"h5=hf at 0.075 bar+x5*hfg at 0.075 bar in KJ/kg\")\n",
    "print(\"from steam tables,at 0.075 bar,hf=168.76 KJ/kg,hfg=2406.0 KJ/kg\")\n",
    "hf=168.76;\n",
    "hfg=2406.0;\n",
    "h5=hf+x5*hfg\n",
    "print(\"Let mass of steam bled at 20 bar be m1 and m2 per kg of steam generated.\")\n",
    "print(\"h10=hf at 20 bar=908.76 KJ/kg,h8=hf at 4 bar=604.74 KJ/kg\")\n",
    "h10=908.76;\n",
    "h8=604.74;\n",
    "print(\"At trap h10=h11=908.79 KJ/kg\")\n",
    "h11=h10;\n",
    "print(\"At condensate extraction pump,(CEP),h7-h6=v6*(4-0.075)*10^2 in KJ/kg\")\n",
    "print(\"here v6=vf at 0.075 bar=0.001008 m^3/kg,h6=hf at 0.075 bar=168.79 KJ/kg\")\n",
    "v6=0.001008;\n",
    "h6=168.79;\n",
    "print(\"so h7=h6+v6*(4-0.075)*10^2 in KJ/kg\")\n",
    "h7=h6+v6*(4-0.075)*10**2\n",
    "print(\"At feed pump,(FP),h9-h8=v8*(20-4)*10^2 in KJ/kg\")\n",
    "print(\"here v8=vf at 4 bar=0.001084 m^3/kg,h8=hf at 4 bar=604.74 KJ/kg\")\n",
    "v8=0.001084;\n",
    "h8=604.74;\n",
    "print(\"so h9=h8+v8*(20-4)*10^2 in KJ/kg\")\n",
    "h9=h8+v8*(20-4)*10**2\n",
    "print(\"Let us apply heat balance at closed feed water heater,\")\n",
    "print(\"m1*h3+h9=m1*h10+4.18*200\")\n",
    "print(\"so m1=(4.18*200-h9)/(h3-h10) in kg\")\n",
    "m1=(4.18*200-h9)/(h3-h10)\n",
    "m1=0.114;#approx.\n",
    "print(\"Applying heat balance at open feed water,\")\n",
    "print(\"m1*h11+m2*h4+(1-m1-m2)*h7=h8\")\n",
    "print(\"so m2=(h8-m1*h11-h7+m1*h7)/(h4-h7) in kg\")\n",
    "m2=(h8-m1*h11-h7+m1*h7)/(h4-h7)\n",
    "m2=0.144;#approx.\n",
    "print(\"Net work per kg steam generated,\")\n",
    "print(\"w_net=(h2-h3)+(1-m1)*(h3-h4)+(1-m1-m2)*(h4-h5)-{(1-m1-m2)*(h7-h6)+(h9-h8)} in KJ/kg\")\n",
    "w_net=(h2-h3)+(1-m1)*(h3-h4)+(1-m1-m2)*(h4-h5)-((1-m1-m2)*(h7-h6)+(h9-h8)) \n",
    "print(\"Heat added per kg steam generated,q_add=(h2-h1) in KJ/kg\")\n",
    "h1=4.18*200;\n",
    "q_add=(h2-h1)\n",
    "print(\"Thermal efficiency=w_net/q_add\"),round(w_net/q_add,2)\n",
    "print(\"in percentage\"),round(w_net*100/q_add,2)\n",
    "print(\"steam generation rate=P/w_net in kg/s\"),round(P/w_net,2)\n",
    "print(\"so thermal efficiency=44.78%\")\n",
    "print(\"steam generation rate=87.99 kg/s\")\n",
    "print(\"a> For the reheating introduced at 20 bar up to 400oc.The modified cycle representation is shown on T-S diagram by 1-2-3-3_a-4_a-5_a-6-7-8-9-10-11\")\n",
    "print(\"At state 2,h2=3373.7 KJ/kg,s2=6.5966 KJ/kg K\")\n",
    "h2=3373.7;\n",
    "s2=6.5966;\n",
    "print(\"At state 3,h3=2930.57 KJ/kg\")\n",
    "h3=2930.57;\n",
    "print(\"At state 3_a,h3_a=3247.6 KJ/kg,s3_a=7.1271 KJ/kg K\")\n",
    "h3_a=3247.6;\n",
    "s3_a=7.1271;\n",
    "print(\"At state 4_a and 5_a,s3_a=s4_a=s5_a=7.1271 KJ/kg K\")\n",
    "s4_a=s3_a;\n",
    "s5_a=s4_a;\n",
    "print(\"From steam tables by interpolation state 4_a is seen to be at 190.96oc at 4 bar,h4_a=2841.02 KJ/kg\")\n",
    "h4_a=2841.02;\n",
    "print(\"Let dryness fraction at state 5_a be x5,\")\n",
    "print(\"s5_a=7.1271=sf at 0.075 bar+x5_a*sfg at 0.075 bar\")\n",
    "print(\"from steam tables,at 0.075 bar,sf=0.5764 KJ/kg K,sfg=7.6750 KJ/kg K\")\n",
    "print(\"so x5_a=(s5_a-sf)/sfg\")\n",
    "x5_a=(s5_a-sf)/sfg\n",
    "x5_a=0.853;#approx.\n",
    "print(\"h5_a=hf at 0.075 bar+x5_a*hfg at 0.075 bar in KJ/kg\")\n",
    "print(\"from steam tables,at 0.075 bar,hf=168.76 KJ/kg,hfg=2406.0 KJ/kg\")\n",
    "h5_a=hf+x5_a*hfg\n",
    "print(\"Let mass of bled steam at 20 bar and 4 bar be m1_a,m2_a per kg of steam generated.Applying heat balance at closed feed water heater.\")\n",
    "print(\"m1_a*h3+h9=m1*h10+4.18*200\")\n",
    "print(\"so m1_a=(4.18*200-h9)/(h3-h10) in kg\")\n",
    "m1_a=(4.18*200-h9)/(h3-h10)\n",
    "m1_a=0.114;#approx.\n",
    "print(\"Applying heat balance at open feed water heater,\")\n",
    "print(\"m1_a*h11+m2_a*h4_a+(1-m1_a-m2_a)*h7=h8\")\n",
    "print(\"so m2_a=(h8-m1_a*h11-h7+m1_a*h7)/(h4_a-h7) in kg\")\n",
    "m2_a=(h8-m1_a*h11-h7+m1_a*h7)/(h4_a-h7)\n",
    "m2_a=0.131;#approx.\n",
    "print(\"Net work per kg steam generated\")\n",
    "print(\"w_net=(h2-h3)+(1-m1_a)*(h3_a-h4_a)+(1-m1_a-m2_a)*(h4_a-h5_a)-{(1-m1_a-m2_a)*(h7-h6)+(h9-h8)}in KJ/kg\")\n",
    "w_net=(h2-h3)+(1-m1_a)*(h3_a-h4_a)+(1-m1_a-m2_a)*(h4_a-h5_a)-((1-m1_a-m2_a)*(h7-h6)+(h9-h8))\n",
    "print(\"Heat added per kg steam generated,q_add=(h2-h1)+(1-m1_a)*(h3_a-h3)in KJ/kg\")\n",
    "q_add=(h2-h1)+(1-m1_a)*(h3_a-h3)\n",
    "n=w_net/q_add\n",
    "print(\"Thermal efficiency,n=\"),round(n,2)\n",
    "print(\"in percentage\"),round(n*100,2)\n",
    "print(\"% increase in thermal efficiency due to reheating=\"),round((0.4503-0.4478)*100/0.4478,2)\n",
    "print(\"so thermal efficiency of reheat cycle=45.03%\")\n",
    "print(\"% increase in efficiency due to reheating=0.56%\")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 8.13;pg no: 286"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 100,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 8.13, Page:286  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 8 Example 13\n",
      "For mercury cycle,\n",
      "insentropic heat drop=349-234.5 in KJ/kg Hg\n",
      "actual heat drop=0.85*114.5 in KJ/kg Hg\n",
      "Heat rejected in condenser=(349-97.325-35)in KJ/kg\n",
      "heat added in boiler=349-35 in KJ/kg\n",
      "For steam cycle,\n",
      "Enthalpy of steam generated=h at 40 bar,0.98 dry=2767.13 KJ/kg\n",
      "Enthalpy of inlet to steam turbine,h2=h at 40 bar,450oc=3330.3 KJ/kg\n",
      "Entropy of steam at inlet to steam turbine,s2=6.9363 KJ/kg K\n",
      "Therefore,heat added in condenser of mercury cycle=h at 40 bar,0.98 dry-h_feed at 40 bar in KJ/kg\n",
      "Therefore,mercury required per kg of steam=2140.13/heat rejected in condenser in kg per kg of steam\n",
      "for isentropic expansion,s2=s3=s4=s5=6.9363 KJ/kg K\n",
      "state 3 lies in superheated region,by interpolation the state can be given by,temperature 227.07oc at 8 bar,h3=2899.23 KJ/kg\n",
      "state 4 lies in wet region,say with dryness fraction x4\n",
      "s4=6.9363=sf at 1 bar+x4*sfg at 1 bar\n",
      "so x4=(s4-sf)/sfg\n",
      "from steam tables,at 1 bar,sf=1.3026 KJ/kg K,sfg=6.0568 KJ/kg K\n",
      "h4=hf at 1 bar+x4*hfg at 1 bar in KJ/kg\n",
      "from steam tables,at 1 bar,hf=417.46 KJ/kg,hfg=2258.0 KJ/kg\n",
      "Let state 5 lie in wet region with dryness fraction x5,\n",
      "s5=6.9363=sf at 0.075 bar+x5*sfg at 0.075 bar\n",
      "so x5=(s5-sf)/sfg\n",
      "from steam tables,at 0.075 bar,sf=0.5764 KJ/kg K,sfg=7.6750 KJ/kg K\n",
      "h5=hf+x5*hfg in KJ/kg\n",
      "from steam tables,at 0.075 bar,hf=168.79 KJ/kg,hfg=2406.0 KJ/kg\n",
      "Let mass of steam bled at 8 bar and 1 bar be m1 and m2 per kg of steam generated.\n",
      "h7=h6+v6*(1-0.075)*10^2 in KJ/kg\n",
      "from steam tables,at 0.075 bar,h6=hf=168.79 KJ/kg,v6=vf=0.001008 m^3/kg\n",
      "h9=hf at 1 bar=417.46 KJ/kg,h13=hf at 8 bar=721.11 KJ/kg\n",
      "Applying heat balance on CFWH1,T1=150oc and also T15=150oc\n",
      "m1*h3+(1-m1)*h12=m1*h13+(4.18*150)*(1-m1)\n",
      "(m1-2899.23)+(1-m1)*h12=(m1*721.11)+627*(1-m1)\n",
      "Applying heat balance on CFEH2,T11=90oc\n",
      "m2*h4+(1-m1-m2)*h7=m2*h9+(1-m1-m2)*4.18*90\n",
      "(m2*2517.4)+(1-m1-m2)*168.88=(m2*417.46)+376.2*(1-m1-m2)\n",
      "Heat balance at mixing between CFWH1 and CFWH2,\n",
      "(1-m1-m2)*4.18*90+m2*h10=(1-m1)*h12\n",
      "376.2*(1-m1-m2)+m2*h10=(1-m1)*h12\n",
      "For pumping process,9-10,h10=h9+v9*(8-1)*10^2 in KJ/kg\n",
      "from steam tables,h9=hf at 1 bar=417.46 KJ/kg,v9=vf at 1 bar=0.001043 m^3/kg\n",
      "solving above equations,we get\n",
      "m1=0.102 kg per kg steam generated\n",
      "m2=0.073 kg per kg steam generated\n",
      "pump work in process 13-14,h14-h13=v13*(40-8)*10^2\n",
      "so h14-h13 in KJ/kg\n",
      "Total heat supplied(q_add)=(9.88*314)+(3330.3-2767.13) in KJ/kg of steam\n",
      "net work per kg of steam,w_net=w_mercury+w_steam\n",
      "w_net=(9.88*97.325)+{(h2-h3)+(1-m1)*(h3-h4)+(1-m1-m2)*(h4-h5)-(1-m1-m2)*(h4-h6)-m2*(h10-h9)-m1*(h14-h13)} in KJ/kg\n",
      "thermal efficiency of binary vapour cycle=w_net/q_add 0.55\n",
      "in percentage 55.36\n",
      "so thermal efficiency=55.36%\n",
      "NOTE=>In this question there is some mistake in formula used for w_net which is corrected above.\n"
     ]
    }
   ],
   "source": [
    "#cal of thermal efficiency\n",
    "#intiation of all variables\n",
    "# Chapter 8\n",
    "print\"Example 8.13, Page:286  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 8 Example 13\")\n",
    "print(\"For mercury cycle,\")\n",
    "print(\"insentropic heat drop=349-234.5 in KJ/kg Hg\")\n",
    "349-234.5\n",
    "print(\"actual heat drop=0.85*114.5 in KJ/kg Hg\")\n",
    "0.85*114.5\n",
    "print(\"Heat rejected in condenser=(349-97.325-35)in KJ/kg\")\n",
    "(349-97.325-35)\n",
    "print(\"heat added in boiler=349-35 in KJ/kg\")\n",
    "349-35\n",
    "print(\"For steam cycle,\")\n",
    "print(\"Enthalpy of steam generated=h at 40 bar,0.98 dry=2767.13 KJ/kg\")\n",
    "h=2767.13;\n",
    "print(\"Enthalpy of inlet to steam turbine,h2=h at 40 bar,450oc=3330.3 KJ/kg\")\n",
    "h2=3330.3;\n",
    "print(\"Entropy of steam at inlet to steam turbine,s2=6.9363 KJ/kg K\")\n",
    "s2=6.9363;\n",
    "print(\"Therefore,heat added in condenser of mercury cycle=h at 40 bar,0.98 dry-h_feed at 40 bar in KJ/kg\")\n",
    "h-4.18*150\n",
    "print(\"Therefore,mercury required per kg of steam=2140.13/heat rejected in condenser in kg per kg of steam\")\n",
    "2140.13/216.675\n",
    "print(\"for isentropic expansion,s2=s3=s4=s5=6.9363 KJ/kg K\")\n",
    "s3=s2;\n",
    "s4=s3;\n",
    "s5=s4;\n",
    "print(\"state 3 lies in superheated region,by interpolation the state can be given by,temperature 227.07oc at 8 bar,h3=2899.23 KJ/kg\")\n",
    "h3=2899.23;\n",
    "print(\"state 4 lies in wet region,say with dryness fraction x4\")\n",
    "print(\"s4=6.9363=sf at 1 bar+x4*sfg at 1 bar\")\n",
    "print(\"so x4=(s4-sf)/sfg\")\n",
    "print(\"from steam tables,at 1 bar,sf=1.3026 KJ/kg K,sfg=6.0568 KJ/kg K\")\n",
    "sf=1.3026;\n",
    "sfg=6.0568;\n",
    "x4=(s4-sf)/sfg\n",
    "x4=0.93;#approx.\n",
    "print(\"h4=hf at 1 bar+x4*hfg at 1 bar in KJ/kg\")\n",
    "print(\"from steam tables,at 1 bar,hf=417.46 KJ/kg,hfg=2258.0 KJ/kg\")\n",
    "hf=417.46;\n",
    "hfg=2258.0;\n",
    "h4=hf+x4*hfg\n",
    "print(\"Let state 5 lie in wet region with dryness fraction x5,\")\n",
    "print(\"s5=6.9363=sf at 0.075 bar+x5*sfg at 0.075 bar\")\n",
    "print(\"so x5=(s5-sf)/sfg\")\n",
    "print(\"from steam tables,at 0.075 bar,sf=0.5764 KJ/kg K,sfg=7.6750 KJ/kg K\")\n",
    "sf=0.5764;\n",
    "sfg=7.6750;\n",
    "x5=(s5-sf)/sfg\n",
    "x5=0.828;#approx.\n",
    "print(\"h5=hf+x5*hfg in KJ/kg\")\n",
    "print(\"from steam tables,at 0.075 bar,hf=168.79 KJ/kg,hfg=2406.0 KJ/kg\")\n",
    "hf=168.79;\n",
    "hfg=2406.0;\n",
    "h5=hf+x5*hfg\n",
    "print(\"Let mass of steam bled at 8 bar and 1 bar be m1 and m2 per kg of steam generated.\")\n",
    "print(\"h7=h6+v6*(1-0.075)*10^2 in KJ/kg\")\n",
    "print(\"from steam tables,at 0.075 bar,h6=hf=168.79 KJ/kg,v6=vf=0.001008 m^3/kg\")\n",
    "h6=168.79;\n",
    "v6=0.001008;\n",
    "h7=h6+v6*(1-0.075)*10**2\n",
    "print(\"h9=hf at 1 bar=417.46 KJ/kg,h13=hf at 8 bar=721.11 KJ/kg\")\n",
    "h9=417.46;\n",
    "h13=721.11;\n",
    "print(\"Applying heat balance on CFWH1,T1=150oc and also T15=150oc\")\n",
    "T1=150;\n",
    "T15=150;\n",
    "print(\"m1*h3+(1-m1)*h12=m1*h13+(4.18*150)*(1-m1)\")\n",
    "print(\"(m1-2899.23)+(1-m1)*h12=(m1*721.11)+627*(1-m1)\")\n",
    "print(\"Applying heat balance on CFEH2,T11=90oc\")\n",
    "T11=90;\n",
    "print(\"m2*h4+(1-m1-m2)*h7=m2*h9+(1-m1-m2)*4.18*90\")\n",
    "print(\"(m2*2517.4)+(1-m1-m2)*168.88=(m2*417.46)+376.2*(1-m1-m2)\")\n",
    "print(\"Heat balance at mixing between CFWH1 and CFWH2,\")\n",
    "print(\"(1-m1-m2)*4.18*90+m2*h10=(1-m1)*h12\")\n",
    "print(\"376.2*(1-m1-m2)+m2*h10=(1-m1)*h12\")\n",
    "print(\"For pumping process,9-10,h10=h9+v9*(8-1)*10^2 in KJ/kg\")\n",
    "print(\"from steam tables,h9=hf at 1 bar=417.46 KJ/kg,v9=vf at 1 bar=0.001043 m^3/kg\")\n",
    "h9=417.46;\n",
    "v9=0.001043;\n",
    "h10=h9+v9*(8-1)*10**2 \n",
    "print(\"solving above equations,we get\")\n",
    "print(\"m1=0.102 kg per kg steam generated\")\n",
    "print(\"m2=0.073 kg per kg steam generated\")\n",
    "m1=0.102;\n",
    "m2=0.073;\n",
    "print(\"pump work in process 13-14,h14-h13=v13*(40-8)*10^2\")\n",
    "print(\"so h14-h13 in KJ/kg\")\n",
    "v13=0.001252;\n",
    "v13*(40-8)*10**2\n",
    "print(\"Total heat supplied(q_add)=(9.88*314)+(3330.3-2767.13) in KJ/kg of steam\")\n",
    "q_add=(9.88*314)+(3330.3-2767.13)\n",
    "print(\"net work per kg of steam,w_net=w_mercury+w_steam\")\n",
    "print(\"w_net=(9.88*97.325)+{(h2-h3)+(1-m1)*(h3-h4)+(1-m1-m2)*(h4-h5)-(1-m1-m2)*(h4-h6)-m2*(h10-h9)-m1*(h14-h13)} in KJ/kg\")\n",
    "w_net=(9.88*97.325)+((h2-h3)+(1-m1)*(h3-h4)+(1-m1-m2)*(h4-h5)-(1-m1-m2)*(h7-h6)-m2*(h10-h9)-m1*4.006)\n",
    "print(\"thermal efficiency of binary vapour cycle=w_net/q_add\"),round(w_net/q_add,2)\n",
    "print(\"in percentage\"),round(w_net*100/q_add,2)\n",
    "print(\"so thermal efficiency=55.36%\")\n",
    "print(\"NOTE=>In this question there is some mistake in formula used for w_net which is corrected above.\")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 8.14;pg no: 288"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 101,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 8.14, Page:288  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 8 Example 14\n",
      "This is a mixed pressure turbine so the output of turbine shall be sum of the contributions by HP and LP steam streams.\n",
      "For HP:at inlet of HP steam=>h1=3023.5 KJ/kg,s1=6.7664 KJ/kg K\n",
      "ideally, s2=s1=6.7664 KJ/kg K\n",
      "s2=sf at 0.075 bar +x3* sfg at 0.075 bar\n",
      "from steam tables,at 0.075 bar,sf=0.5764 KJ/kg K,sfg=7.6750 KJ/kg K\n",
      "so x3=(s2-sf)/sfg\n",
      "h_3HP=hf at 0.075 bar+x3*hfg at 0.075 bar in KJ/kg\n",
      "from steam tables,at 0.075 bar,hf=168.79 KJ/kg,hfg=2406.0 KJ/kg\n",
      "actual enthalpy drop in HP(h_HP)=(h1-h_3HP)*n in KJ/kg\n",
      "for LP:at inlet of LP steam\n",
      "h2=2706.7 KJ/kg,s2=7.1271 KJ/kg K\n",
      "Enthalpy at exit,h_3LP=2222.34 KJ/kg\n",
      "actual enthalpy drop in LP(h_LP)=(h2-h_3LP)*n in KJ/kg\n",
      "HP steam consumption at full load=P*0.7457/h_HP in kg/s\n",
      "HP steam consumption at no load=0.10*(P*0.7457/h_HP)in kg/s\n",
      "LP steam consumption at full load=P*0.7457/h_LP in kg/s\n",
      "LP steam consumption at no load=0.10*(P*0.7457/h_LP)in kg/s\n",
      "The problem can be solved geometrically by drawing willans line as per scale on graph paper and finding out the HP stream requirement for getting 1000 hp if LP stream is available at 1.5 kg/s.\n",
      "or,Analytically the equation for willans line can be obtained for above full load and no load conditions for HP and LP seperately.\n",
      "Willians line for HP:y=m*x+C,here y=steam consumption,kg/s\n",
      "x=load,hp\n",
      "y_HP=m_HP*x+C_HP\n",
      "0.254=m_HP*0+C_HP\n",
      "so C_HP=0.254\n",
      "2.54=m_HP*2500+C_HP\n",
      "so m_HP=(2.54-C_HP)/2500\n",
      "so y_HP=9.144*10^-4*x_HP+0.254\n",
      "Willans line for LP:y_LP=m_LP*x_LP+C_LP\n",
      "0.481=m_LP*0+C_LP\n",
      "so C_LP=0.481\n",
      "4.81=m_LP*2500+C_LP\n",
      "so m_LP=(4.81-C_LP)/2500\n",
      "so y_LP=1.732*10^-3*x_LP+0.481\n",
      "Total output(load) from mixed turbine,x=x_HP+x_LP\n",
      "For load of 1000 hp to be met by mixed turbine,let us find out the load shared by LP for steam flow rate of 1.5 kg/s\n",
      "from y_LP=1.732*10^-3*x_LP+0.481,\n",
      "x_LP=(y_LP-0.481)/1.732*10^-3\n",
      "since by 1.5 kg/s of LP steam only 588.34 hp output contribution is made so remaining(1000-588.34)=411.66 hp,411.66 hp should be contributed by HP steam.By willans line for HP turbine,\n",
      "from y_HP=9.144*10^-4*x_HP+C_HP in kg/s 0.63\n",
      "so HP steam requirement=0.63 kg/s\n"
     ]
    }
   ],
   "source": [
    "#cal of HP steam required\n",
    "#intiation of all variables\n",
    "# Chapter 8\n",
    "print\"Example 8.14, Page:288  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 8 Example 14\")\n",
    "n=0.8;#efficiency of both HP and LP turbine\n",
    "P=2500;#output in hp\n",
    "print(\"This is a mixed pressure turbine so the output of turbine shall be sum of the contributions by HP and LP steam streams.\")\n",
    "print(\"For HP:at inlet of HP steam=>h1=3023.5 KJ/kg,s1=6.7664 KJ/kg K\")\n",
    "h1=3023.5;\n",
    "s1=6.7664;\n",
    "print(\"ideally, s2=s1=6.7664 KJ/kg K\")\n",
    "s2=s1;\n",
    "print(\"s2=sf at 0.075 bar +x3* sfg at 0.075 bar\")\n",
    "print(\"from steam tables,at 0.075 bar,sf=0.5764 KJ/kg K,sfg=7.6750 KJ/kg K\")\n",
    "sf=0.5764;\n",
    "sfg=7.6750;\n",
    "print(\"so x3=(s2-sf)/sfg\")\n",
    "x3=(s2-sf)/sfg\n",
    "x3=0.806;#approx.\n",
    "print(\"h_3HP=hf at 0.075 bar+x3*hfg at 0.075 bar in KJ/kg\")\n",
    "print(\"from steam tables,at 0.075 bar,hf=168.79 KJ/kg,hfg=2406.0 KJ/kg\")\n",
    "hf=168.79;\n",
    "hfg=2406.0; \n",
    "h_3HP=hf+x3*hfg\n",
    "print(\"actual enthalpy drop in HP(h_HP)=(h1-h_3HP)*n in KJ/kg\")\n",
    "h_HP=(h1-h_3HP)*n\n",
    "print(\"for LP:at inlet of LP steam\")\n",
    "print(\"h2=2706.7 KJ/kg,s2=7.1271 KJ/kg K\")\n",
    "h2=2706.7;\n",
    "s2=7.1271;\n",
    "print(\"Enthalpy at exit,h_3LP=2222.34 KJ/kg\")\n",
    "h_3LP=2222.34;\n",
    "print(\"actual enthalpy drop in LP(h_LP)=(h2-h_3LP)*n in KJ/kg\")\n",
    "h_LP=(h2-h_3LP)*n\n",
    "print(\"HP steam consumption at full load=P*0.7457/h_HP in kg/s\")\n",
    "P*0.7457/h_HP\n",
    "print(\"HP steam consumption at no load=0.10*(P*0.7457/h_HP)in kg/s\")\n",
    "0.10*(P*0.7457/h_HP)\n",
    "print(\"LP steam consumption at full load=P*0.7457/h_LP in kg/s\")\n",
    "P*0.7457/h_LP\n",
    "print(\"LP steam consumption at no load=0.10*(P*0.7457/h_LP)in kg/s\")\n",
    "0.10*(P*0.7457/h_LP)\n",
    "print(\"The problem can be solved geometrically by drawing willans line as per scale on graph paper and finding out the HP stream requirement for getting 1000 hp if LP stream is available at 1.5 kg/s.\")\n",
    "print(\"or,Analytically the equation for willans line can be obtained for above full load and no load conditions for HP and LP seperately.\")\n",
    "print(\"Willians line for HP:y=m*x+C,here y=steam consumption,kg/s\")\n",
    "print(\"x=load,hp\")\n",
    "print(\"y_HP=m_HP*x+C_HP\")\n",
    "print(\"0.254=m_HP*0+C_HP\")\n",
    "print(\"so C_HP=0.254\")\n",
    "C_HP=0.254;\n",
    "print(\"2.54=m_HP*2500+C_HP\")\n",
    "print(\"so m_HP=(2.54-C_HP)/2500\")\n",
    "m_HP=(2.54-C_HP)/2500\n",
    "print(\"so y_HP=9.144*10^-4*x_HP+0.254\")\n",
    "print(\"Willans line for LP:y_LP=m_LP*x_LP+C_LP\")\n",
    "print(\"0.481=m_LP*0+C_LP\")\n",
    "print(\"so C_LP=0.481\")\n",
    "C_LP=0.481;\n",
    "print(\"4.81=m_LP*2500+C_LP\")\n",
    "print(\"so m_LP=(4.81-C_LP)/2500\")\n",
    "m_LP=(4.81-C_LP)/2500\n",
    "print(\"so y_LP=1.732*10^-3*x_LP+0.481\")\n",
    "print(\"Total output(load) from mixed turbine,x=x_HP+x_LP\")\n",
    "print(\"For load of 1000 hp to be met by mixed turbine,let us find out the load shared by LP for steam flow rate of 1.5 kg/s\")\n",
    "y_LP=1.5;\n",
    "print(\"from y_LP=1.732*10^-3*x_LP+0.481,\")\n",
    "print(\"x_LP=(y_LP-0.481)/1.732*10^-3\")\n",
    "x_LP=(y_LP-0.481)/(1.732*10**-3)\n",
    "print(\"since by 1.5 kg/s of LP steam only 588.34 hp output contribution is made so remaining(1000-588.34)=411.66 hp,411.66 hp should be contributed by HP steam.By willans line for HP turbine,\")\n",
    "x_HP=411.66;\n",
    "y_HP=9.144*10**-4*x_HP+C_HP\n",
    "print(\"from y_HP=9.144*10^-4*x_HP+C_HP in kg/s\"),round(y_HP,2)\n",
    "print(\"so HP steam requirement=0.63 kg/s\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 8.15;pg no: 289"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 102,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 8.15, Page:289  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 8 Example 15\n",
      "Let us carry out analysis for 1 kg of steam generated in boiler.\n",
      "Enthalpy at inlet to HPT,h2=2960.7 KJ/kg,s2=6.3615 KJ/kg K\n",
      "state at 3  i.e. exit from HPT can be identified by s2=s3=6.3615 KJ/kg K\n",
      "Let dryness fraction be x3,s3=6.3615=sf at 2 bar+x3*sfg at 2 bar\n",
      "so x3= 0.86\n",
      "from stem tables,at 2 bar,sf=1.5301 KJ/kg K,sfg=5.5970 KJ/kg K\n",
      "h3=2404.94 KJ/kg\n",
      "If one kg of steam is generated in bolier then at exit of HPT,0.5 kg goes into process heater and 0.5 kg goes into separator\n",
      "mass of moisture retained in separator(m)=(1-x3)*0.5 kg\n",
      "Therefore,mass of steam entering LPT(m_LP)=0.5-m kg\n",
      "Total mass of water entering hot well at 8(i.e. from process heater and drain from separator)=(0.5+0.685)=0.5685 kg\n",
      "Let us assume the temperature of water leaving hotwell be T oc.Applying heat balance for mixing;\n",
      "(0.5685*4.18*90)+(0.4315*4.18*40)=(1*4.18*T)\n",
      "so T in degree celcius= 68.425\n",
      "so temperature of water leaving hotwell=68.425 degree celcius\n",
      "Applying heat balanced on trap\n",
      "0.5*h7+0.0685*hf at 2 bar=(0.5685*4.18*90)\n",
      "so h7=((0.5685*4.18*90)-(0.0685*hf))/0.5 in KJ/kg\n",
      "from steam tables,at 2 bar,hf=504.70 KJ/kg\n",
      "Therefore,heat transferred in process heater in KJ/kg steam generated= 1023.172\n",
      "so heat transferred per kg steam generated=1023.175 KJ/kg steam generated\n",
      "For state 10 at exit of LPT,s10=s3=s2=6.3615 KJ/kg K\n",
      "Let dryness fraction be x10\n",
      "s10=6.3615=sf at 0.075 bar+x10*sfg at 0.075 bar\n",
      "from steam tables,at 0.075 bar,sf=0.5764 KJ/kg K,sfg=7.6750 KJ/kg K\n",
      "so x10=(s10-sf)/sfg\n",
      "h10=hf at 0.075 bar+x10*hfg at 0.075 bar\n",
      "from steam tables,at 0.075 bar,hf=168.79 KJ/kg,hfg=2406.0 KJ/kg\n",
      "so h10=hf+x10*hfg in KJ/kg \n",
      "net work output,neglecting pump work per kg of steam generated,\n",
      "w_net=(h2-h3)*1+0.4315*(h3-h10) in KJ/kg steam generated\n",
      "Heat added in boiler per kg steam generated,q_add in KJ/kg= 2674.68\n",
      "thermal efficiency=w_net/q_add 0.28\n",
      "in percentage 27.59\n",
      "so Thermal efficiency=27.58%\n"
     ]
    }
   ],
   "source": [
    "#cal of thermal efficiency,heat transferred and temperature\n",
    "#intiation of all variables\n",
    "# Chapter 8\n",
    "print\"Example 8.15, Page:289  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 8 Example 15\")\n",
    "print(\"Let us carry out analysis for 1 kg of steam generated in boiler.\")\n",
    "print(\"Enthalpy at inlet to HPT,h2=2960.7 KJ/kg,s2=6.3615 KJ/kg K\")\n",
    "h2=2960.7;\n",
    "s2=6.3615;\n",
    "print(\"state at 3  i.e. exit from HPT can be identified by s2=s3=6.3615 KJ/kg K\")\n",
    "s3=s2;\n",
    "print(\"Let dryness fraction be x3,s3=6.3615=sf at 2 bar+x3*sfg at 2 bar\")\n",
    "sf=1.5301;\n",
    "sfg=5.5970;\n",
    "x3=(s3-sf)/sfg\n",
    "print(\"so x3=\"),round(x3,2)\n",
    "print(\"from stem tables,at 2 bar,sf=1.5301 KJ/kg K,sfg=5.5970 KJ/kg K\")\n",
    "x3=0.863;#approx.\n",
    "print(\"h3=2404.94 KJ/kg\")\n",
    "h3=2404.94;\n",
    "print(\"If one kg of steam is generated in bolier then at exit of HPT,0.5 kg goes into process heater and 0.5 kg goes into separator\")\n",
    "print(\"mass of moisture retained in separator(m)=(1-x3)*0.5 kg\")\n",
    "m=(1-x3)*0.5\n",
    "print(\"Therefore,mass of steam entering LPT(m_LP)=0.5-m kg\")\n",
    "m_LP=0.5-m\n",
    "print(\"Total mass of water entering hot well at 8(i.e. from process heater and drain from separator)=(0.5+0.685)=0.5685 kg\")\n",
    "print(\"Let us assume the temperature of water leaving hotwell be T oc.Applying heat balance for mixing;\")\n",
    "print(\"(0.5685*4.18*90)+(0.4315*4.18*40)=(1*4.18*T)\")\n",
    "T=((0.5685*4.18*90)+(0.4315*4.18*40))/4.18\n",
    "print(\"so T in degree celcius=\"),round(T,3)\n",
    "print(\"so temperature of water leaving hotwell=68.425 degree celcius\")\n",
    "print(\"Applying heat balanced on trap\")\n",
    "print(\"0.5*h7+0.0685*hf at 2 bar=(0.5685*4.18*90)\")\n",
    "print(\"so h7=((0.5685*4.18*90)-(0.0685*hf))/0.5 in KJ/kg\")\n",
    "print(\"from steam tables,at 2 bar,hf=504.70 KJ/kg\")\n",
    "hf=504.70;\n",
    "h7=((0.5685*4.18*90)-(0.0685*hf))/0.5\n",
    "print(\"Therefore,heat transferred in process heater in KJ/kg steam generated=\"),round(0.5*(h3-h7),3)\n",
    "print(\"so heat transferred per kg steam generated=1023.175 KJ/kg steam generated\")\n",
    "print(\"For state 10 at exit of LPT,s10=s3=s2=6.3615 KJ/kg K\")\n",
    "s10=s3;\n",
    "print(\"Let dryness fraction be x10\")\n",
    "print(\"s10=6.3615=sf at 0.075 bar+x10*sfg at 0.075 bar\")\n",
    "print(\"from steam tables,at 0.075 bar,sf=0.5764 KJ/kg K,sfg=7.6750 KJ/kg K\")\n",
    "sf=0.5764;\n",
    "sfg=7.6750;\n",
    "print(\"so x10=(s10-sf)/sfg\")\n",
    "x10=(s10-sf)/sfg\n",
    "x10=0.754;#approx.\n",
    "print(\"h10=hf at 0.075 bar+x10*hfg at 0.075 bar\")\n",
    "print(\"from steam tables,at 0.075 bar,hf=168.79 KJ/kg,hfg=2406.0 KJ/kg\")\n",
    "hf=168.79;\n",
    "hfg=2406.0;\n",
    "print(\"so h10=hf+x10*hfg in KJ/kg \")\n",
    "h10=hf+x10*hfg \n",
    "print(\"net work output,neglecting pump work per kg of steam generated,\")\n",
    "print(\"w_net=(h2-h3)*1+0.4315*(h3-h10) in KJ/kg steam generated\")\n",
    "w_net=(h2-h3)*1+0.4315*(h3-h10) \n",
    "q_add=(h2-4.18*68.425)\n",
    "print(\"Heat added in boiler per kg steam generated,q_add in KJ/kg=\"),round(q_add,2)\n",
    "w_net/q_add\n",
    "print(\"thermal efficiency=w_net/q_add\"),round(w_net/q_add,2)\n",
    "print(\"in percentage\"),round(w_net*100/q_add,2)\n",
    "print(\"so Thermal efficiency=27.58%\")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 8.16;pg no: 291"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 103,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 8.16, Page:291  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 8 Example 16\n",
      "from steam tables,h1=3530.9 KJ/kg,s1=6.9486 KJ/kg K\n",
      "Assuming isentropic expansion in nozzle,s1=s2=6.9486\n",
      "Letdryness fraction at state 2,x2=0.864\n",
      "s2=sf at 0.2 bar+x2*sfg at 0.2 bar\n",
      "from steam tables,sf=0.8320 KJ/kg K,sfg=7.0766 KJ/kg K\n",
      "so x2= 0.86\n",
      "hence,h2=hf at 0.2 bar+x2*hfg at 0.2 bar in KJ/kg\n",
      "from steam tables,hf at 0.2 bar=251.4 KJ/kg,hfg at 0.2 bar=2358.3 KJ/kg\n",
      "considering pump work to be of isentropic type,deltah_34=v3*deltap_34\n",
      "from steam table,v3=vf at 0.2 bar=0.001017 m^3/kg\n",
      "or deltah_34 in KJ/kg= 7.1\n",
      "pump work,Wp in KJ/kg= 7.1\n",
      "turbine work,Wt=deltah_12=(h1-h2)in KJ/kg\n",
      "net work(W_net)=Wt-Wp in KJ/kg\n",
      "power produced(P)=mass flow rate*W_net in KJ/s\n",
      "so net power=43.22 MW\n",
      "heat supplied in boiler(Q)=(h1-h4) in KJ/kg\n",
      "enthalpy at state 4,h4=h3+deltah_34 in KJ/kg\n",
      "total heat supplied to boiler(Q)=m*(h1-h4)in KJ/s 114534.05\n",
      "thermal efficiency=net work/heat supplied=W_net/Q 0.38\n",
      "in percentage 37.73\n",
      "so thermal efficiency=37.73%\n"
     ]
    }
   ],
   "source": [
    "#cal of thermal efficiency,net power\n",
    "#intiation of all variables\n",
    "# Chapter 8\n",
    "print\"Example 8.16, Page:291  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 8 Example 16\")\n",
    "m=35;#mass flow rate in kg/s\n",
    "print(\"from steam tables,h1=3530.9 KJ/kg,s1=6.9486 KJ/kg K\")\n",
    "h1=3530.9;\n",
    "s1=6.9486;\n",
    "print(\"Assuming isentropic expansion in nozzle,s1=s2=6.9486\")\n",
    "s2=s1;\n",
    "print(\"Letdryness fraction at state 2,x2=0.864\")\n",
    "print(\"s2=sf at 0.2 bar+x2*sfg at 0.2 bar\")\n",
    "print(\"from steam tables,sf=0.8320 KJ/kg K,sfg=7.0766 KJ/kg K\")\n",
    "sf=0.8320;\n",
    "sfg=7.0766;\n",
    "x2=(s2-sf)/sfg\n",
    "print(\"so x2=\"),round(x2,2)\n",
    "x2=0.864;#approx.\n",
    "print(\"hence,h2=hf at 0.2 bar+x2*hfg at 0.2 bar in KJ/kg\")\n",
    "print(\"from steam tables,hf at 0.2 bar=251.4 KJ/kg,hfg at 0.2 bar=2358.3 KJ/kg\")\n",
    "hf=251.4;\n",
    "hfg=2358.3;\n",
    "h2=hf+x2*hfg\n",
    "print(\"considering pump work to be of isentropic type,deltah_34=v3*deltap_34\")\n",
    "print(\"from steam table,v3=vf at 0.2 bar=0.001017 m^3/kg\")\n",
    "v3=0.001017;\n",
    "p3=70;#;pressure of steam entering turbine in bar\n",
    "p4=0.20;#condenser pressure in bar\n",
    "deltah_34=v3*(p3-p4)*100\n",
    "print(\"or deltah_34 in KJ/kg=\"),round(deltah_34,2)\n",
    "Wp=deltah_34\n",
    "print(\"pump work,Wp in KJ/kg=\"),round(Wp,2)\n",
    "print(\"turbine work,Wt=deltah_12=(h1-h2)in KJ/kg\")\n",
    "Wt=(h1-h2)\n",
    "print(\"net work(W_net)=Wt-Wp in KJ/kg\")\n",
    "W_net=Wt-Wp\n",
    "print(\"power produced(P)=mass flow rate*W_net in KJ/s\")\n",
    "P=m*W_net\n",
    "print(\"so net power=43.22 MW\")\n",
    "print(\"heat supplied in boiler(Q)=(h1-h4) in KJ/kg\")\n",
    "print(\"enthalpy at state 4,h4=h3+deltah_34 in KJ/kg\")\n",
    "h3=hf;\n",
    "h4=h3+deltah_34 \n",
    "Q=m*(h1-h4)\n",
    "print(\"total heat supplied to boiler(Q)=m*(h1-h4)in KJ/s\"),round(Q,2)\n",
    "print(\"thermal efficiency=net work/heat supplied=W_net/Q\"),round(P/Q,2)\n",
    "print(\"in percentage\"),round(P*100/Q,2)\n",
    "print(\"so thermal efficiency=37.73%\")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 8.17;pg no: 292"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 104,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 8.1, Page:292  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 8 Example 17\n",
      "from steam tables,h1=3625.3 KJ/s,s1=6.9029 KJ/kg K\n",
      "due to isentropic expansion,s1=s2=s3=6.9029 KJ/kg K\n",
      "at state 2,i.e at pressure of 2 MPa and entropy 6.9029 KJ/kg K\n",
      "by interpolating state for s2 between 2 MPa,300 degree celcius and 2 MPa,350 degree celcius from steam tables,\n",
      "h2=3105.08 KJ/kg \n",
      "for state 3,i.e at pressure of 0.01 MPa entropy,s3 lies in wet region as s3<sg at 0.01 MPa.Let dryness fraction be x3 at this state\n",
      "s3=sf at 0.01 MPa+x3*sfg at 0.01 MPa\n",
      "from steam tables,sf at 0.01 MPa=0.6493 KJ/kg K,sfg at 0.01 MPa=7.5009 KJ/kg K\n",
      "so x3= 0.83\n",
      "enthalpy at state 3,h3= hf at 0.01 MPa+x3*hfg at 0.01 MPa in KJ/kg\n",
      "from steam tables,at 0.01 MPa,hf=191.83 KJ/kg,hfg=2392.8 KJ/kg\n",
      "let the mass of steam bled be mb per kg of steam from exit of HP for regenerative feed heating.\n",
      "Considering state at exit from feed heater being saturated liquid the enthalpy at exit of feed heater will be,hf at 2 MPa\n",
      "h6=hf at 2 MPa=908.79 KJ/kg\n",
      "for adiabatic mixing in feed heater,for one kg of steam leaving boiler,the heat balance yields,\n",
      "(1-mb)*h5+mb*h2=h6\n",
      "while neglecting pump work,\n",
      "h5=h4=hf at 0.01MPa=191.83 KJ/kg\n",
      "substituting in heat balance on the feed heater,\n",
      "(1-mb)*h5+mb*h2=h6\n",
      "so mb in kg per kg of steam entering HP turbine= 0.25\n",
      "steam bled per kg of steam passing through HP stage=0.246 kg\n",
      "let mass of steam leaving boiler be m kg/s\n",
      "output(P)=m*(h1-h2)+m*(1-mb)*(h2-h3)\n",
      "so m in kg/s= 8.25\n",
      "neglecting pump work,h7=h6=908.79 KJ/kg\n",
      "heat supplied to boiler,Q_71 in KJ/s= 22411.21\n",
      "so heat added=22411.21 KJ/s\n"
     ]
    }
   ],
   "source": [
    "#cal of heat added,steam bled\n",
    "#intiation of all variables\n",
    "# Chapter 8\n",
    "print\"Example 8.1, Page:292  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 8 Example 17\")\n",
    "P=10*10**3;#output in KW\n",
    "print(\"from steam tables,h1=3625.3 KJ/s,s1=6.9029 KJ/kg K\")\n",
    "h1=3625.3;\n",
    "s1=6.9029;\n",
    "print(\"due to isentropic expansion,s1=s2=s3=6.9029 KJ/kg K\")\n",
    "s2=s1;\n",
    "s3=s2;\n",
    "print(\"at state 2,i.e at pressure of 2 MPa and entropy 6.9029 KJ/kg K\")\n",
    "print(\"by interpolating state for s2 between 2 MPa,300 degree celcius and 2 MPa,350 degree celcius from steam tables,\")\n",
    "print(\"h2=3105.08 KJ/kg \")\n",
    "h2=3105.08;\n",
    "print(\"for state 3,i.e at pressure of 0.01 MPa entropy,s3 lies in wet region as s3<sg at 0.01 MPa.Let dryness fraction be x3 at this state\")\n",
    "print(\"s3=sf at 0.01 MPa+x3*sfg at 0.01 MPa\")\n",
    "print(\"from steam tables,sf at 0.01 MPa=0.6493 KJ/kg K,sfg at 0.01 MPa=7.5009 KJ/kg K\")\n",
    "sf=0.6493;\n",
    "sfg=7.5009;\n",
    "x3=(s3-sf)/sfg\n",
    "print(\"so x3=\"),round(x3,2)\n",
    "x3=0.834;#approx.\n",
    "print(\"enthalpy at state 3,h3= hf at 0.01 MPa+x3*hfg at 0.01 MPa in KJ/kg\")\n",
    "print(\"from steam tables,at 0.01 MPa,hf=191.83 KJ/kg,hfg=2392.8 KJ/kg\")\n",
    "hf=191.83;\n",
    "hfg=2392.8;\n",
    "h3=hf+x3*hfg\n",
    "print(\"let the mass of steam bled be mb per kg of steam from exit of HP for regenerative feed heating.\")\n",
    "print(\"Considering state at exit from feed heater being saturated liquid the enthalpy at exit of feed heater will be,hf at 2 MPa\")\n",
    "print(\"h6=hf at 2 MPa=908.79 KJ/kg\")\n",
    "h6=908.79;\n",
    "print(\"for adiabatic mixing in feed heater,for one kg of steam leaving boiler,the heat balance yields,\")\n",
    "print(\"(1-mb)*h5+mb*h2=h6\")\n",
    "print(\"while neglecting pump work,\")\n",
    "print(\"h5=h4=hf at 0.01MPa=191.83 KJ/kg\")\n",
    "h4=191.83;\n",
    "h5=h4;\n",
    "print(\"substituting in heat balance on the feed heater,\")\n",
    "print(\"(1-mb)*h5+mb*h2=h6\")\n",
    "mb=(h6-h5)/(h2-h5)\n",
    "print(\"so mb in kg per kg of steam entering HP turbine=\"),round((h6-h5)/(h2-h5),2)\n",
    "mb=0.246;#approx.\n",
    "print(\"steam bled per kg of steam passing through HP stage=0.246 kg\")\n",
    "print(\"let mass of steam leaving boiler be m kg/s\")\n",
    "print(\"output(P)=m*(h1-h2)+m*(1-mb)*(h2-h3)\")\n",
    "m=P/((h1-h2)+(1-mb)*(h2-h3))\n",
    "print(\"so m in kg/s=\"),round(m,2)\n",
    "m=8.25;#approx.\n",
    "print(\"neglecting pump work,h7=h6=908.79 KJ/kg\")\n",
    "h7=h6;\n",
    "Q_71=m*(h1-h7)\n",
    "print(\"heat supplied to boiler,Q_71 in KJ/s=\"),round(Q_71,2)\n",
    "print(\"so heat added=22411.21 KJ/s\")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##example 8.18;pg no: 294"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example 8.18, Page:294  \n",
      " \n",
      "\n",
      "Engineering Thermodynamics by Onkar Singh Chapter 8 Example 18\n",
      "from steam tables,at inlet to first stage of turbine,h1=h at 100 bar,500oc=3373.7 KJ/kg,s1=s at 100 bar,500oc=6.5966 KJ/kg\n",
      "Due to isentropic expansion,s1=s6=s2 and s3=s8=s4\n",
      "State at 6 i.e bleed state from HP turbine,temperature by interpolation from steam table =261.6oc.\n",
      "At inlet to second stage of turbine,h6=2930.572 KJ/kg\n",
      "h3=h at 10 bar,500oc=3478.5 KJ/kg,s3=s at 10 bar,500oc=7.7622 KJ/kg K\n",
      "At exit from first stage of turbine i.e. at 10 bar and entropy of 6.5966 KJ/kg K,Temperature by interpolation from steam table at 10 bar and entropy of 6.5966 KJ/kg K\n",
      "T2=181.8oc,h2=2782.8 KJ/kg\n",
      "state at 8,i.e bleed state from second stage of expansion,i.e at 4 bar and entropy of 7.7622 KJ/kg K,Temperature by interpolation from steam table,T8=358.98oc=359oc\n",
      "h8=3188.7 KJ/kg\n",
      "state at 4 i.e. at condenser pressure of 0.1 bar and entropy of 7.7622 KJ/kg K,the state lies in wet region.So let the dryness fraction be x4.\n",
      "s4=sf at 0.1 bar+x4*sfg at 0.1 bar\n",
      "from steam tables,at 0.1 bar,sf=0.6493 KJ/kg K,sfg=7.5009 KJ/kg K\n",
      "so x4= 0.95\n",
      "h4=hf at 0.1 bar+x4*hfg at 0.1 bar in KJ/kg \n",
      "from steam tables,at 0.1 bar,hf=191.83 KJ/kg,hfg=2392.8 KJ/kg\n",
      "given,h4=2464.99 KJ/kg,h11=856.8 KJ/kg,h9=hf at 4 bar=604.74 KJ/kg\n",
      "considering pump work,the net output can be given as,\n",
      "W_net=W_HPT+W_LPT-(W_CEP+W_FP)\n",
      "where,W_HPT={(h1-h6)+(1-m6)*(h6-h2)}per kg of steam from boiler.\n",
      "W_LPT={(1-m6)+(h3-h8)*(1-m6-m8)*(h8-h4)}per kg of steam from boiler.\n",
      "for closed feed water heater,energy balance yields;\n",
      "m6*h6+h10=m6*h7+h11\n",
      "assuming condensate leaving closed feed water heater to be saturated liquid,\n",
      "h7=hf at 20 bar=908.79 KJ/kg\n",
      "due to throttline,h7=h7_a=908.79 KJ/kg\n",
      "for open feed water heater,energy balance yields,\n",
      "m6*h7_a+m8*h8+(1-m6-m8)*h5=h9\n",
      "for condensate extraction pump,h5-h4_a=v4_a*deltap\n",
      "h5-hf at 0.1 bar=vf at 0.1 bar*(4-0.1)*10^2 \n",
      "from steam tables,at 0.1 bar,hf=191.83 KJ/kg,vf=0.001010 m^3/kg\n",
      "so h5 in KJ/kg= 192.22\n",
      "for feed pump,h10-h9=v9*deltap\n",
      "h10=h9+vf at 4 bar*(100-4)*10^2 in KJ/kg\n",
      "from steam tables,at 4 bar,hf=604.74 KJ/kg,vf=0.001084 m^3/kg \n",
      "substituting in energy balance upon closed feed water heater,\n",
      "m6 in kg per kg of steam from boiler= 0.12\n",
      "substituting in energy balance upon feed water heater,\n",
      "m8 in kg per kg of steam from boiler= 0.109\n",
      "Let the mass of steam entering first stage of turbine be m kg,then\n",
      "W_HPT=m*{(h1-h6)+(1-m6)*(h6-h2)}\n",
      "W_HPT/m= 573.24\n",
      "so W_HPT=m*573.24 KJ\n",
      "also,W_LPT={(1-m6)*(h3-h8)+(1-m6-m8)*(h8-h4)}per kg of steam from boiler\n",
      "W_LPT/m= 813.42\n",
      "so W_LPT=m*813.42 KJ\n",
      "pump works(negative work)\n",
      "W_CEP=m*(1-m6-m8)*(h5-h4_a)\n",
      "W_CEP/m=\n",
      "so W_CEP=m* 0.304\n",
      "W_FP=m*(h10-h9)\n",
      "W_FP/m= 10.41\n",
      "so W_FP=m*10.41\n",
      "net output,\n",
      "W_net=W_HPT+W_LPT-W_CEP-W_FP \n",
      "so 50*10^3=(573.24*m+813.42*m-0.304*m-10.41*m)\n",
      "so m in kg/s= 36.34\n",
      "heat supplied in boiler,Q_add in KJ/s= 91460.71\n",
      "Thermal efficenncy= 0.55\n",
      "in percentage 54.67\n",
      "so mass of steam bled at 20 bar=0.119 kg per kg of steam entering first stage\n",
      "mass of steam bled at 4 bar=0.109 kg per kg of steam entering first stage\n",
      "mass of steam entering first stage=36.33 kg/s\n",
      "thermal efficiency=54.66%\n",
      "NOTE=>In this question there is some caclulation mistake while calculating m6 in book,which is corrected above so some answers may vary.\n"
     ]
    }
   ],
   "source": [
    "#cal of thermal efficiency,mass of steam\n",
    "#intiation of all variables\n",
    "# Chapter 8\n",
    "print\"Example 8.18, Page:294  \\n \\n\"\n",
    "print(\"Engineering Thermodynamics by Onkar Singh Chapter 8 Example 18\")\n",
    "W_net=50*10**3;#net output of turbine in KW\n",
    "print(\"from steam tables,at inlet to first stage of turbine,h1=h at 100 bar,500oc=3373.7 KJ/kg,s1=s at 100 bar,500oc=6.5966 KJ/kg\")\n",
    "h1=3373.7;\n",
    "s1=6.5966;\n",
    "print(\"Due to isentropic expansion,s1=s6=s2 and s3=s8=s4\")\n",
    "s2=s1;\n",
    "s6=s2;\n",
    "print(\"State at 6 i.e bleed state from HP turbine,temperature by interpolation from steam table =261.6oc.\")\n",
    "print(\"At inlet to second stage of turbine,h6=2930.572 KJ/kg\")\n",
    "h6=2930.572;\n",
    "print(\"h3=h at 10 bar,500oc=3478.5 KJ/kg,s3=s at 10 bar,500oc=7.7622 KJ/kg K\")\n",
    "h3=3478.5;\n",
    "s3=7.7622;\n",
    "s4=s3;\n",
    "s8=s4;\n",
    "print(\"At exit from first stage of turbine i.e. at 10 bar and entropy of 6.5966 KJ/kg K,Temperature by interpolation from steam table at 10 bar and entropy of 6.5966 KJ/kg K\")\n",
    "print(\"T2=181.8oc,h2=2782.8 KJ/kg\")\n",
    "T2=181.8;\n",
    "h2=2782.8;\n",
    "print(\"state at 8,i.e bleed state from second stage of expansion,i.e at 4 bar and entropy of 7.7622 KJ/kg K,Temperature by interpolation from steam table,T8=358.98oc=359oc\")\n",
    "T8=359;\n",
    "print(\"h8=3188.7 KJ/kg\")\n",
    "h8=3188.7;\n",
    "print(\"state at 4 i.e. at condenser pressure of 0.1 bar and entropy of 7.7622 KJ/kg K,the state lies in wet region.So let the dryness fraction be x4.\")\n",
    "print(\"s4=sf at 0.1 bar+x4*sfg at 0.1 bar\")\n",
    "print(\"from steam tables,at 0.1 bar,sf=0.6493 KJ/kg K,sfg=7.5009 KJ/kg K\")\n",
    "sf=0.6493;\n",
    "sfg=7.5009; \n",
    "x4=(s4-sf)/sfg\n",
    "print(\"so x4=\"),round(x4,2)\n",
    "x4=0.95;#approx.\n",
    "print(\"h4=hf at 0.1 bar+x4*hfg at 0.1 bar in KJ/kg \")\n",
    "print(\"from steam tables,at 0.1 bar,hf=191.83 KJ/kg,hfg=2392.8 KJ/kg\")\n",
    "hf=191.83;\n",
    "hfg=2392.8;\n",
    "h4=hf+x4*hfg\n",
    "print(\"given,h4=2464.99 KJ/kg,h11=856.8 KJ/kg,h9=hf at 4 bar=604.74 KJ/kg\")\n",
    "h4=2464.99;\n",
    "h11=856.8;\n",
    "h9=604.74;\n",
    "print(\"considering pump work,the net output can be given as,\")\n",
    "print(\"W_net=W_HPT+W_LPT-(W_CEP+W_FP)\")\n",
    "print(\"where,W_HPT={(h1-h6)+(1-m6)*(h6-h2)}per kg of steam from boiler.\")\n",
    "print(\"W_LPT={(1-m6)+(h3-h8)*(1-m6-m8)*(h8-h4)}per kg of steam from boiler.\")\n",
    "print(\"for closed feed water heater,energy balance yields;\")\n",
    "print(\"m6*h6+h10=m6*h7+h11\")\n",
    "print(\"assuming condensate leaving closed feed water heater to be saturated liquid,\")\n",
    "print(\"h7=hf at 20 bar=908.79 KJ/kg\")\n",
    "h7=908.79; \n",
    "print(\"due to throttline,h7=h7_a=908.79 KJ/kg\")\n",
    "h7_a=h7;\n",
    "print(\"for open feed water heater,energy balance yields,\")\n",
    "print(\"m6*h7_a+m8*h8+(1-m6-m8)*h5=h9\")\n",
    "print(\"for condensate extraction pump,h5-h4_a=v4_a*deltap\")\n",
    "print(\"h5-hf at 0.1 bar=vf at 0.1 bar*(4-0.1)*10^2 \")\n",
    "print(\"from steam tables,at 0.1 bar,hf=191.83 KJ/kg,vf=0.001010 m^3/kg\")\n",
    "hf=191.83;\n",
    "vf=0.001010; \n",
    "h5=hf+vf*(4-0.1)*10**2\n",
    "print(\"so h5 in KJ/kg=\"),round(h5,2)\n",
    "print(\"for feed pump,h10-h9=v9*deltap\")\n",
    "print(\"h10=h9+vf at 4 bar*(100-4)*10^2 in KJ/kg\")\n",
    "print(\"from steam tables,at 4 bar,hf=604.74 KJ/kg,vf=0.001084 m^3/kg \")\n",
    "hf=604.74;\n",
    "vf=0.001084;\n",
    "h10=h9+vf*(100-4)*10**2\n",
    "print(\"substituting in energy balance upon closed feed water heater,\")\n",
    "m6=(h11-h10)/(h6-h7)\n",
    "print(\"m6 in kg per kg of steam from boiler=\"),round(m6,3)\n",
    "print(\"substituting in energy balance upon feed water heater,\")\n",
    "m8=(h9-m6*h7_a+m6*h5-h5)/(h8-h5)\n",
    "print(\"m8 in kg per kg of steam from boiler=\"),round(m8,3)\n",
    "print(\"Let the mass of steam entering first stage of turbine be m kg,then\")\n",
    "{(h1-h6)+(1-m6)*(h6-h2)}\n",
    "print(\"W_HPT=m*{(h1-h6)+(1-m6)*(h6-h2)}\")\n",
    "print(\"W_HPT/m=\"),round(((h1-h6)+(1-m6)*(h6-h2)),2)\n",
    "print(\"so W_HPT=m*573.24 KJ\")\n",
    "print(\"also,W_LPT={(1-m6)*(h3-h8)+(1-m6-m8)*(h8-h4)}per kg of steam from boiler\")\n",
    "{(1-m6)*(h3-h8)+(1-m6-m8)*(h8-h4)}\n",
    "print(\"W_LPT/m=\"),round(((1-m6)*(h3-h8)+(1-m6-m8)*(h8-h4)),2)\n",
    "print(\"so W_LPT=m*813.42 KJ\")\n",
    "print(\"pump works(negative work)\")\n",
    "print(\"W_CEP=m*(1-m6-m8)*(h5-h4_a)\")\n",
    "h4_a=191.83;#h4_a=hf at 0.1 bar\n",
    "print(\"W_CEP/m=\")\n",
    "(1-m6-m8)*(h5-h4_a)\n",
    "print(\"so W_CEP=m* 0.304\")\n",
    "print(\"W_FP=m*(h10-h9)\")\n",
    "print(\"W_FP/m=\"),round((h10-h9),2)\n",
    "print(\"so W_FP=m*10.41\")\n",
    "print(\"net output,\")\n",
    "print(\"W_net=W_HPT+W_LPT-W_CEP-W_FP \")\n",
    "print(\"so 50*10^3=(573.24*m+813.42*m-0.304*m-10.41*m)\")\n",
    "m=W_net/(573.24+813.42-0.304-10.41)\n",
    "print(\"so m in kg/s=\"),round(m,2)\n",
    "Q_add=m*(h1-h11)\n",
    "print(\"heat supplied in boiler,Q_add in KJ/s=\"),round(m*(h1-h11),2)\n",
    "print(\"Thermal efficenncy=\"),round(W_net/Q_add,2)\n",
    "print(\"in percentage\"),round(W_net*100/Q_add,2)\n",
    "print(\"so mass of steam bled at 20 bar=0.119 kg per kg of steam entering first stage\")\n",
    "print(\"mass of steam bled at 4 bar=0.109 kg per kg of steam entering first stage\")\n",
    "print(\"mass of steam entering first stage=36.33 kg/s\")\n",
    "print(\"thermal efficiency=54.66%\")\n",
    "print(\"NOTE=>In this question there is some caclulation mistake while calculating m6 in book,which is corrected above so some answers may vary.\")\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}