summaryrefslogtreecommitdiff
path: root/A_TEXTBOOK_OF_ELECTRICAL_TECHNOLOGY_(VOL-III)_by_B.L.Thareja/chapter50.ipynb
blob: 695fb3bfb597f3b5bf53f68ba160c8d3bb95098a (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
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# CHAPTER 50 : Tariffs and Economic Considerations"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.1 , PAGE NO :- 1946"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Total annual charge on installation = Rs. 28572.0\n"
     ]
    }
   ],
   "source": [
    "'''Find the total annual charge on an installation costing Rs. 500,000 to buy and install, the estimated life being 30 years\n",
    "and negligible scrap value. Interest is 4% compounded annually.'''\n",
    "\n",
    "import math as m\n",
    "\n",
    "Q = 5e+5        #(installation cost)\n",
    "r = 0.04        #(rate of interest)\n",
    "\n",
    "q = Q*(r/(1+r))/(m.pow(1+r,30) - 1)\n",
    "\n",
    "#Hence, total annual charge on installation is\n",
    "charge = r*Q + q        # (As P=Q)\n",
    "\n",
    "print \"Total annual charge on installation = Rs.\",round(charge)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.2 , PAGE NO :- 1946"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Annual Deposit for Straight-line depriciation method = Rs. 28500.0\n",
      "Annual Deposit for Sink fund method = Rs. 22515.0\n"
     ]
    }
   ],
   "source": [
    "'''A power plant having initial cost of Rs. 2.5 lakhs has an estimated salvage value of Rs. 30,000 at the end of its\n",
    "useful life of 20 years. What will be the annual deposit necessary if it is calculated by :\n",
    "(i) straight-line depreciation method.\n",
    "(ii) sinking-fund method with compound interest at 7%.'''\n",
    "\n",
    "import math as m\n",
    "\n",
    "P = 250000.0       #Rs     (Initial investment)\n",
    "Q = P - 30000.0      #Rs     (Replacement cost)\n",
    "r = 0.07           #       (Interest rate)\n",
    "n = 20.0             #       (Number of years)\n",
    "\n",
    "#(i)straight-line depriciation method\n",
    "\n",
    "#Annual depriciation\n",
    "q= Q/n\n",
    "\n",
    "deposit1 = r*P + q\n",
    "\n",
    "\n",
    "#(ii)sinking fund method\n",
    "\n",
    "#Annual depriciation\n",
    "q= Q*(r/(1+r))/(m.pow(1+r,n) - 1)\n",
    "\n",
    "deposit2 = r*P + q\n",
    "\n",
    "print \"Annual Deposit for Straight-line depriciation method = Rs.\",round(deposit1)\n",
    "print \"Annual Deposit for Sink fund method = Rs.\",round(deposit2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.3 , PAGE NO :- 1947"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Annual Deposit for Straight-line depriciation method = Rs. 300000.0\n",
      "Annual Deposit for Sink fund method = Rs. 373375.0\n"
     ]
    }
   ],
   "source": [
    "'''A plant initially costing Rs. 5 lakhs has an estimated salvage value of Rs. 1 lakh at the end of its useful life of 20 years.\n",
    "What will be its valuation half-way through its life (a) on the basis of straight-line depreciation and\n",
    "(b) on the sinking-fund basis at 8% compounded annually?'''\n",
    "\n",
    "import math as m\n",
    "\n",
    "P = 500000.0       #Rs     (Initial investment)\n",
    "Q = P - 100000.0      #Rs     (Replacement cost)\n",
    "r = 0.08           #       (Interest rate)\n",
    "n = 20.0             #       (Number of years)\n",
    "\n",
    "#(i)straight-line depriciation method\n",
    "\n",
    "#Annual depriciation in 10 years\n",
    "q= Q/2\n",
    "\n",
    "#Value after 10 years\n",
    "value1 = P - q\n",
    "\n",
    "\n",
    "#(ii)sinking fund method\n",
    "\n",
    "#Annual depriciation\n",
    "q= Q*(r/(1+r))/(m.pow(1+r,n) - 1)\n",
    "\n",
    "#Value after 10 years i.e n/2 years\n",
    "value2 = P -  q*((1+r)/r)*(m.pow(1+r,n/2) - 1)\n",
    "\n",
    "print \"Annual Deposit for Straight-line depriciation method = Rs.\",round(value1)\n",
    "print \"Annual Deposit for Sink fund method = Rs.\",round(value2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.4 , PAGE NO :- 1955"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Total connected load = 2600.0 W\n",
      "Monthly energy consumption = 252.0 kWh\n",
      "Load factor = 0.23\n"
     ]
    }
   ],
   "source": [
    "'''A consumer has the following connected load : 10 lamps of 60 W each and two heaters of 1000 W each. His maximum demand is 1500 W.\n",
    "On the average, he uses 8 lamps for 5 hours a day and each heater for 3 hours a day. Find his total load, montly energy\n",
    "consumption and load factor.'''\n",
    "\n",
    "\n",
    "#Total connected load is\n",
    "con_load = 10*60.0 + 2*1000.0     #W    \n",
    "\n",
    "#Daily energy consumption is\n",
    "enrgy = 8*60.0*5 + 2*1000.0*3     #Wh     \n",
    "\n",
    "#Monthly energy consumption is\n",
    "menrgy = enrgy*30.0/1000.0          #kWh\n",
    "\n",
    "#Load factor  = Avg load/Max load is\n",
    "lf = menrgy*1000/(1500.0*24*30)\n",
    "\n",
    "print \"Total connected load =\" ,con_load ,\"W\"\n",
    "print \"Monthly energy consumption =\",menrgy ,\"kWh\"\n",
    "print \"Load factor =\",round(lf,2) \n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.5 , PAGE NO :- 1955"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Capacity of substation =  1656.0 kW\n"
     ]
    }
   ],
   "source": [
    "'''The load survey of a small town gives the following categories of expected loads.\n",
    "              Type               Load in kW             % D.F.                   Group D.F.\n",
    "1.    Residential lighting           1000                 60                         3\n",
    "2.    Commercial lighting            300                  75                        1.5\n",
    "3.    Street lighting                50                   100                       1.0\n",
    "4.    Domestic power                 300                  50                        1.5\n",
    "5.    Industrial power               1800                 55                        1.2\n",
    "What should be the kVA capacity of the S/S assuming a station p.f. of 0.8 lagging ?'''\n",
    "\n",
    "#Using Demand factor = Max demand/Connected load \n",
    "#(i) Residential lighting\n",
    "maxd1 = 1000.0*(60.0/100.0)        #kW    (Max demand)\n",
    "grpd1 = maxd1/3.0                  #kW    (Max demand of group)\n",
    "\n",
    "#(ii) Commercial lighting\n",
    "maxd2 = 300.0*(75.0/100.0)        #kW    (Max demand)\n",
    "grpd2 = maxd2/1.5                  #kW    (Max demand of group)\n",
    "\n",
    "#(iii) Street lighting\n",
    "maxd3 = 50.0*(100.0/100.0)        #kW    (Max demand)\n",
    "grpd3 = maxd3/1.0                  #kW    (Max demand of group)\n",
    "\n",
    "#(iv)  Domestic Power\n",
    "maxd4 = 300.0*(50.0/100.0)        #kW    (Max demand)\n",
    "grpd4 = maxd4/1.5                  #kW    (Max demand of group)\n",
    "\n",
    "#(v)   Industrial Power  \n",
    "maxd5 = 1800.0*(55.0/100.0)        #kW    (Max demand)\n",
    "grpd5 = maxd5/1.2                  #kW    (Max demand of group)\n",
    "\n",
    "#Total maximum demand is\n",
    "tot = grpd1 + grpd2 + grpd3 + grpd4 + grpd5    #kW\n",
    "\n",
    "#KVA capacity of substation is\n",
    "capacity = tot/0.8                  #kW\n",
    "\n",
    "print \"Capacity of substation = \",round(capacity),\"kW\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.6 , PAGE NO :- 1956"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Load factor = 0.46\n",
      "Daily bill of consumer = Rs 17.5\n"
     ]
    }
   ],
   "source": [
    "'''A consumer has the following load-schedule for a day :\n",
    "From midnight (12 p.m.) to 6 a.m. = 200 W ;\n",
    "From 6 a.m. to 12 noon = 3000 W\n",
    "From 12 noon to 1 p.m. = 100 W ;\n",
    "From 1 p.m. to 4 p.m. = 4000 W\n",
    "From 4 p.m. to 9 p.m. = 2000 W ;\n",
    "From 9 p.m. to mid-night (12 p.m.) = 1000 W\n",
    "\n",
    "Find the load factor.\n",
    "If the tariff is 50 paisa per kW of max. demand plus 35 paisa per kWh, find the daily bill the consumer has to pay.'''\n",
    "\n",
    "\n",
    "maxp = 4000.0    #W   (Maximum power)\n",
    "\n",
    "#Total consumption is\n",
    "enrgy = 6*200.0 + 6*3000.0 + 1*100.0 + 3*4000.0 + 5*2000.0 + 3*1000.0         #W\n",
    "\n",
    "#Average power\n",
    "pwer = enrgy/24       #kW\n",
    "\n",
    "#Daily load factor = Average Power/Max Power\n",
    "lf = pwer/maxp\n",
    "\n",
    "#Max Demand charge.\n",
    "charge1 = (maxp/1000)*0.5     #Rs\n",
    "\n",
    "#Consumption charge\n",
    "charge2 = (enrgy/1000)*0.35   #Rs\n",
    "\n",
    "#Total Bill\n",
    "bill = charge1 + charge2      #Rs\n",
    "\n",
    "print \"Load factor =\",round(lf,2)\n",
    "print \"Daily bill of consumer = Rs\",round(bill,1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.7 , PAGE NO :- 1956"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Demand factor = 0.47\n",
      "Average Power = 7020.0 W.\n",
      "Load factor = 0.35\n"
     ]
    }
   ],
   "source": [
    "'''A generating station has a connected load of 43,000 kW and a maximum demand of 20,000 kW, the units generated being\n",
    "61,500,000 for the year. Calculate the load factor and demand factor for this case.'''\n",
    "\n",
    "\n",
    "maxp = 20000.0                  #W      (Maximum Demand)\n",
    "conn = 43000.0                  #W      (Connected load)\n",
    "\n",
    "#Demand factor = Max demand/Connected load\n",
    "df = maxp/conn\n",
    "\n",
    "#Average power\n",
    "pwer = 61500000/(365*24)            #W\n",
    "\n",
    "#Load factor = Avg Power/Max Power\n",
    "lf = pwer/maxp\n",
    "\n",
    "print \"Demand factor =\",round(df,2)\n",
    "print \"Average Power =\",round(pwer,2),\"W.\"\n",
    "print \"Load factor =\",round(lf,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.8 , PAGE NO :- 1956"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "load factor = 0.21\n"
     ]
    }
   ],
   "source": [
    "'''A 100 MW power station delivers 100 MW for 2 hours, 50 MW for 6 hours and is shut down for the rest of each day.\n",
    "It is also shut down for maintenance for 45 days each year.Calculate its annual load factor.'''\n",
    "\n",
    "#Given\n",
    "days = 365 - 45      #    (Operating days)\n",
    "maxp = 100.0         #MW  (Maximum demand)\n",
    "\n",
    "#Energy consumption in  a year\n",
    "enrgy = (100.0*2 + 50.0*6)*days    #MWh\n",
    "\n",
    "#Load factor = Total Energy Consumption/(Max demand*24*no of days)\n",
    "lf = enrgy/(maxp*24*days)\n",
    "\n",
    "print \"load factor =\",round(lf,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.9 , PAGE NO :- 1956"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Cost per unit = 1.6 paise\n"
     ]
    }
   ],
   "source": [
    "'''Differentiate between fixed and running charges in the operation of a power company.\n",
    "Calculate the cost per kWh delivered from the generating station whose\n",
    "\n",
    "(i) capital cost = Rs. 10^6      ,     (ii) annual cost of fuel = Rs. 10^5      , (iii) wages and taxes = Rs. 5*10^5\n",
    "(iv) maximum demand laod = 10,000 kW     ,      (v) rate of interest and depreciation = 10%    ,  (vi) annual load factor = 50%.\n",
    "Total number of hours in a year is 8,760.'''\n",
    "\n",
    "#Given\n",
    "maxp = 10000.0       #kW     (Maximum demand)\n",
    "Avgload = 0.5*maxp   #kW     (Average load)\n",
    "\n",
    "#Total energy consumption\n",
    "enrgy = Avgload*8760.0     #kWh\n",
    "\n",
    "#Total Annual Charge\n",
    "charge = (1.0e+5 + 5.0e+5) + (10.0e+5)*(10.0/100)   #Rs\n",
    "\n",
    "#Cost per unit\n",
    "cost = charge/enrgy*100.0      #paise\n",
    "print \"Cost per unit =\",round(cost,2),\"paise\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.10 , PAGE NO :- 1957"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Peak demand of the city sub-station = 113.1 kW.\n"
     ]
    }
   ],
   "source": [
    "'''A new colony of 200 houses is being established, with each house having an average connected load of 2 kW. The business\n",
    "centre of the colony will have a total connected load of 200 kW. Find the peak demand of the city sub-station given the\n",
    "following data.\n",
    "                               Demand factor        Group D.F.     Peak D.F.\n",
    "Residential load                      50%             3.2            1.5\n",
    "Business load                         60%             1.4            1.2     .'''\n",
    "\n",
    "\n",
    "#Given\n",
    "dem_res = 0.5           #   (demand factor Residential load)\n",
    "dem_bus = 0.6           #   (demand factor Business load)\n",
    "gf_res  = 3.2           #   (Group demand factor Residential load)\n",
    "gf_bus  = 1.4           #   (Group demand factor Business load)\n",
    "pk_res  = 1.5           #   (Peak demand factor Residential load)\n",
    "pk_bus  = 1.2           #   (Peak demand factor Business load)\n",
    "\n",
    "#######Residential Load##########\n",
    "\n",
    "\n",
    "#Demand factor = Max demand/Connected load\n",
    "\n",
    "maxp_res = dem_res*2.0      #kW   (Max demand of each house)\n",
    "\n",
    "#Group D.F  = Sum of individual max demand/Actual max demand   is\n",
    "maxtot_res = (200*maxp_res)/gf_res       #kW   (Actual max demand)\n",
    "\n",
    "#Peak D.F =  Max demand of consumer/Max demand during Peak time is\n",
    "maxpeak_res = maxtot_res/pk_res          #kW   (Max demand during Peak time)\n",
    "\n",
    "\n",
    "\n",
    "########Business Load############\n",
    "\n",
    "\n",
    "#Demand factor = Max demand/Connected load\n",
    "\n",
    "maxp_bus = dem_bus*200.0     #kW   (Max demand of Commercial Load)\n",
    "\n",
    "#Group D.F  = Sum of individual max demand/Actual max demand   is\n",
    "maxtot_bus = maxp_bus/gf_bus       #kW   (Actual max demand)\n",
    "\n",
    "#Peak D.F =  Max demand of consumer/Max demand during Peak time is\n",
    "maxpeak_bus = maxtot_bus/pk_bus          #kW   (Max demand during Peak time)\n",
    "\n",
    "\n",
    "#Total Max demand during Peak time\n",
    "peaktot = maxpeak_bus + maxpeak_res       #kW\n",
    "\n",
    "print \"Peak demand of the city sub-station =\",round(peaktot,2),\"kW.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.11 , PAGE NO :- 1957"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Maximum demand of Substation = 3636.36 kW\n",
      "kVA capacity of transformer = 4545.45 kVA\n"
     ]
    }
   ],
   "source": [
    "'''In Fig. 50.6 is shown the distribution network from main sub-station. There are four feeders connected to each load centre\n",
    "sub-station. The connected loads of different feeders and their maximum demands are as follows :\n",
    "Feeder No.             Connected load, kW                Maximum Demand, kW\n",
    "1.                            150                              125\n",
    "2.                            150                              125\n",
    "3.                            500                              350\n",
    "4.                            750                              600\n",
    "If the actual demand on each load centre is 1000 kW, what is the diversity factor on the feeders?If load centres B, C and D are\n",
    "similar to A and the diversity factor between different load centres is 1.1, calculate the maximum demand of the main sub-station.\n",
    "What would be the kVA capacity of the transformer required at the main sub-station if the overall p.f. at the main sub-station\n",
    "is 0.8 ?'''\n",
    "\n",
    "#Maximum Demands\n",
    "fed1 = 125.0              #kW   (feeder 1)\n",
    "fed2 = 125.0             #kW   (feeder 2)\n",
    "fed3 = 350.0              #kW   (feeder 3)\n",
    "fed4 = 600.0              #kW   (feeder 4)\n",
    "df_load = 1.1             #     (Diversity Factor of load centres) \n",
    "\n",
    "#Diversity factor of feeders is\n",
    "df_fed = (fed1 + fed2 + fed3 + fed4)/1000.0         #(df = Individual Max demand/Simultaneous Max demand)\n",
    "\n",
    "#Simultaneous Max demand of  load centres  = Total Individual Max demand/D.F of load centres    is  \n",
    "maxp =  (4*1000.0)/df_load              #kW\n",
    "\n",
    "#KVA capacity of transformer is\n",
    "capacity = maxp/0.8                     #kW\n",
    "\n",
    "print \"Maximum demand of Substation =\",round(maxp,2),\"kW\"\n",
    "print \"kVA capacity of transformer =\",round(capacity,2),\"kVA\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.12 , PAGE NO :- 1958"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Units generated per year = 4.809e+07 kWh\n",
      "Diversity Factor = 1.29\n"
     ]
    }
   ],
   "source": [
    "'''If a generating station had a maximum load for the year of 18,000 kW and a load factor of 30.5% and the maximum loads on\n",
    "the sub-stations were 7,500, 5,000, 3,400, 4,600 and 2,800 kW, calculate the units generated for the year and the\n",
    "diversity factor.'''\n",
    "\n",
    "\n",
    "#Given\n",
    "lf = 0.305                                     #    (load factor)\n",
    "maxp = 18000.0                                 #kW  (Maximum demand)\n",
    "sum_max = 7500.0+5000+3400+4600+2800.0         #kW  (Sum of individual max demand)\n",
    "\n",
    "\n",
    "\n",
    "# Average Power consumption is                (Using Load factor = Avg load/Max load)\n",
    "avg_pwer = lf*maxp        #kW\n",
    "\n",
    "#Energy generated per year\n",
    "enrgy = avg_pwer*8760     #kWh\n",
    "\n",
    "#Diversity factor = Sum of Individual Max demand/Simultaneous Max demand\n",
    "df = sum_max/maxp\n",
    "\n",
    "print 'Units generated per year = %1.3e kWh' %enrgy\n",
    "print \"Diversity Factor =\",round(df,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.13 , PAGE NO :- 1958"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Maximum demand = 20.0 MW.\n",
      "Annual energy supllied = 1.05e+08 kWh\n",
      "Installed capacity = 30.000000 MW . With 2 -- 10 MW generators and 2 -- 5 MW generators.\n"
     ]
    }
   ],
   "source": [
    "'''A power station is supplying four regions of load whose peak loads are 10MW,5 MW, 8 MW and 7 MW. the diversity factor of the \n",
    "load at the station is 1.5 and the average annual load factor is 60%. Calculate the maximum demand on the station and the annual\n",
    "energy supplied from the station. Suggest the installed capacity and the number of units taking all aspects into account.'''\n",
    "\n",
    "#Given\n",
    "df = 1.5                   #     (diversity factor)\n",
    "lf = 0.6                   #     (load factor)\n",
    "sum_max = 10.0+5+8+7.0     #MW   (Sum of individual max. load)\n",
    "\n",
    "#Max demand  is                           (Using Diversity factor =  Sum of individual max. demand/Simultaneous Max. demand)\n",
    "maxdem = sum_max/df       #MW\n",
    "\n",
    "#Average load is                          (Using Load factor = Avg load/Max. load)\n",
    "avg_load = lf*maxdem      #MW\n",
    "\n",
    "#Total Energy consumption in a year is\n",
    "enrgy = avg_load*8760*1000.0   #kWh\n",
    "\n",
    "#Considering 50% more for future use\n",
    "install = maxdem*1.5      #MW   (installed capacity)\n",
    "\n",
    "print \"Maximum demand =\",round(maxdem,2),\"MW.\"\n",
    "print \"Annual energy supllied = %1.2e kWh\" %enrgy\n",
    "print \"Installed capacity = %f MW . With 2 -- 10 MW generators and 2 -- 5 MW generators.\" %install"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.14 , PAGE NO :- 1959"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Generating cost per unit is 3.15 paise.\n"
     ]
    }
   ],
   "source": [
    "'''The capital cost of 30 MW generating station is Rs. 15*10^6. The annual expenses incurred on account of fuel, taxes,\n",
    "salaries and maintenance amount to Rs. 1.25*10^6. The station operates at an annual load factor of 35%. Determine the\n",
    "generating cost per unit delivered, assuming rate of interest 5% and rate of depreciation 6%.'''\n",
    "\n",
    "#Given\n",
    "lf = 0.35             #          (load factor)\n",
    "maxp = 30.0*1000      #kW        (max power)\n",
    "mntnce = 1.25e+6      #Rs        (maintainance cost) \n",
    "cost = 15.0e+6        #Rs        (capital cost) \n",
    "\n",
    "#load factor = Avg load/Max load . Therefore , Avg Load is\n",
    "avg_load = lf*maxp       #kW\n",
    "\n",
    "#Units produced per year\n",
    "units = avg_load*8760    #kWh\n",
    "\n",
    "dep = 0.11*cost          #(Depriciation + Interest cost)\n",
    "\n",
    "#Total cost per year\n",
    "tot_cost = dep + mntnce  #Rs\n",
    "\n",
    "#Cost per unit\n",
    "cost_unit = tot_cost/units*100     #Paise/kWh\n",
    "\n",
    "print \"Generating cost per unit is\",round(cost_unit,2),\"paise.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.15 , PAGE NO :- 1959"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Fixed charge(100% load factor) =  4.11 paise.\n",
      "Fixed charge(25% load factor) =   16.44 paise.\n"
     ]
    }
   ],
   "source": [
    "'''A generating plant has a maximum capacity of 100 kW and costs Rs.300,000.The fixed charges are 12% consisting of 5% interest,\n",
    "5% depreciation and 2% taxes etc. Find the fixed charges per kWh generated if load factor is (i) 100% and (ii) 25%.'''\n",
    "\n",
    "#Annual fixed charges are\n",
    "charge1 = 300.0e+3*(12.0/100)       #Rs\n",
    "\n",
    "#Number of kWh generated per year with 100% load factor are\n",
    "units1 = 100.0*8760*1                #kWh\n",
    "\n",
    "#Number of kWh generated per year with 25% load factor are\n",
    "units2 = 100.0*8760*0.25             #kWh\n",
    "\n",
    "#Fixed charges per unit is\n",
    "\n",
    "cost1 = charge1/units1*100      #paise        (100% load factor)\n",
    "cost2 = charge1/units2*100      #paise        (25% load factor)\n",
    "\n",
    "print \"Fixed charge(100% load factor) = \",round(cost1,2),\"paise.\"\n",
    "print \"Fixed charge(25% load factor) =  \",round(cost2,2),\"paise.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.16 , PAGE NO :- 1959"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a = 80000.0\n",
      "b =  900.0\n",
      "c =  0.00025\n"
     ]
    }
   ],
   "source": [
    "'''The annual working cost of a thermal station is represented by the formula Rs. (a + b kW + c kWh) where a, b and c are constants\n",
    "for that particular station, kW is the total installed capacity and kWh is the energy produced per annum.\n",
    "\n",
    "Determine the values of a, b and c for a 100 MW station having annual load factor of 55% and for which\n",
    "(i) capital cost of buildings and equipment is Rs. 90 million\n",
    "(ii) the annual cost of fuel, oil,taxation and wages and salaries of operating staff is Rs. 1,20,000\n",
    "(iii) interest and depreciation on buildings and equipment are 10% p.a.\n",
    "(iv) annual cost of orginasation, interest on cost of site etc. is Rs. 80,000.'''\n",
    "\n",
    "\n",
    "#Given\n",
    "lf = 0.55         #     (load factor)\n",
    "cap = 100.0e+3    #kW   (capacity of station)\n",
    "\n",
    "#As a represents the fixed-cost,b semi-fixed cost and c the running cost.\n",
    "\n",
    "a = 80000.0       #Rs       (Given)\n",
    "\n",
    "\n",
    "#Now, b*kW minimum demand = semi-fixed cost\n",
    "b = 90.0e+6/cap\n",
    "\n",
    "\n",
    "#Total units generated per annum = (max demand in kW)*(load factor)*8760 \n",
    "units = cap*lf*8760      #kWh\n",
    "\n",
    "# Now,  c*(no. of units) = 120000.0 . Therefore,\n",
    "c = 120000.0/units\n",
    "\n",
    "print \"a =\",round(a,2)\n",
    "print \"b = \",round(b,2)\n",
    "print \"c = \",round(c,5)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.17 , PAGE NO :- 1960"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Limiting value of water evaporated = 6.0 kg.\n",
      "Coal consumption per hour on no-load is = 750.0 kg.\n"
     ]
    }
   ],
   "source": [
    "'''In a steam generating station, the relation between the water evaporated W kg and coal consumed C kg and power in kW\n",
    "generated per 8-hour shift is as follows :\n",
    "W = 28,000 + 5.4 kWh; C = 6000 + 0.9 kWh\n",
    "What would be the limiting value of the water evaporated per kg of coal consumed as the station output increases ?\n",
    "Also, calculate the amount of coal required per hour to keep the station running at no-load.'''\n",
    "\n",
    "\n",
    "#For an 8-hour shift,Wt of water evaporated per kg of coal consumed is\n",
    "# W/C =  28000 + 5.4kWh/6000 + 0.9kWh\n",
    "\n",
    "#Limiting value will approach\n",
    "lim = 5.4/0.9\n",
    "print \"Limiting value of water evaporated =\",lim,\"kg.\"\n",
    "\n",
    "#Since at no load there is no generation of power\n",
    "#Coal consumption per 8 hour shift is 6000.0 kg\n",
    "#Coal consumption per hour on no-load is\n",
    "cons = 6000.0/8\n",
    "print \"Coal consumption per hour on no-load is =\",round(cons,2),\"kg.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.18 , PAGE NO :- 1960"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Cost per kWh(unit) delivered = 4.28 paise.\n"
     ]
    }
   ],
   "source": [
    "'''Estimate the generating cost per kWh delivered from a generating station from the following data :\n",
    "Plant capacity = 50 MW ; annual load factor = 40%; capital cost = Rs. 3.60 crores; annual cost\n",
    "of wages, taxation etc. = Rs. 4 lakhs; cost of fuel, lubrication, maintenance etc. = 2.0 paise per kWh\n",
    "generated, interest 5% per annum, depreciation 5% per annum of initial value.'''\n",
    "\n",
    "#Given\n",
    "maxp = 50.0e+3          #kW    (Plant capacity)\n",
    "lf = 0.4                  #      (load factor)\n",
    "\n",
    "#Average power over a year is = Max. power * load factor\n",
    "\n",
    "avg_p = maxp*lf           #kW\n",
    "\n",
    "#Units produced per year\n",
    "units = avg_p*8760        #kWh\n",
    "\n",
    "#Depriciation + Interest    (5 + 5 = 10% of capital cost)\n",
    "charge1 = (10.0/100)*3.60e+7   #Rs\n",
    "\n",
    "#Annual wage and taxation\n",
    "charge2 = 4.0e+5          #Rs\n",
    "\n",
    "#Total cost/year =\n",
    "tot_charge= charge1 + charge2   #Rs\n",
    "\n",
    "\n",
    "#Cost per unit\n",
    "cost = tot_charge/units*100         #paise\n",
    "\n",
    "#Cost per kWh(unit) delivered = base cost + maintenance cost\n",
    "tot_cost = cost + 2.0               #paise\n",
    "\n",
    "print \"Cost per kWh(unit) delivered =\",round(tot_cost,2),\"paise.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.19 , PAGE NO :- 1960"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Cost per kWh generated =  5.67 Paise.\n",
      "Cost per kW is = 268.2 Rs.\n"
     ]
    }
   ],
   "source": [
    "'''The following data relate to a 1000 kW thermal station :\n",
    "Cost of Plant = Rs. 1,200 per kW                              Interest, insurance and taxes = 5% p.a.\n",
    "Depreciation = 5% p.a.                                        Cost of primary distribution system = Rs. 4,00,000\n",
    "Interest, insurance, taxes and depreciaton = 5% p.a.          Cost of coal including transportation = Rs. 40 per tonne\n",
    "Operating cost = Rs. 4,00,000 p.a.                            Plant maintenance cost : fixed = Rs. 20,000 p.a.\n",
    "variable = Rs. 30,000 p.a.                                    Installed plant capacity = 10,000  kW\n",
    "Maximum demand = 9,000 kW                                     Annual load factor = 60%\n",
    "Consumption of coal = 25,300 tonne\n",
    "Find the cost of power generation per kilowatt per year, the cost per kilowatt-hour generated\n",
    "and the total cost of generation per kilowatt-hour. Transmission/primary distribution is chargeable\n",
    "to generation.'''\n",
    "\n",
    "\n",
    "#Given\n",
    "maxp = 9000.0              #kW     (Maximum demand)\n",
    "lf = 0.6                    #       (load factor)\n",
    "#Fixed cost\n",
    "costp = 400000.0            #Rs     (cost of primary distribution)\n",
    "costplant = 1200.0*10000.0   #Rs     (Total cost of plant)\n",
    "mntnce = 20000.0            #Rs     (Maintenance cost)\n",
    "\n",
    "#Variable cost\n",
    "fuel = 25300.0*40.0          #Rs     (fuel cost)\n",
    "var_mntnce = 30000.0         #Rs     (variable maintenance cost)\n",
    "op_cost = 400000.0           #Rs     (operating cost)\n",
    "\n",
    "\n",
    "#Total fixed cost is\n",
    "fixed = costplant*(10.0/100) + mntnce + costp*(5.0/100)  #Rs \n",
    "\n",
    "#Total variable cost is\n",
    "var = op_cost + fuel + var_mntnce                        #Rs\n",
    "\n",
    "#Total cost is\n",
    "cost_tot = fixed + var                                   #Rs\n",
    "\n",
    "#Average demand (kWh) = Load factor * Max demand *(no. of hours in a year)\n",
    "avg_p = lf*maxp*8760           #kWh\n",
    "\n",
    "#Cost per kWh generated = Total annual cost/units produced in a year\n",
    "cost = cost_tot/avg_p*100.0    #paise\n",
    "\n",
    "#Since installed capacity is 10000.0 kW , cost per kW is\n",
    "cost_kw = cost_tot/10000.0     #Rs\n",
    "\n",
    "print \"Cost per kWh generated = \",round(cost,2),\"Paise.\"\n",
    "print \"Cost per kW is =\",round(cost_kw,2),\"Rs.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.20 , PAGE NO :- 1961"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Annual Bill =  13768.0 Rs.\n",
      "Cost/kWh  (i) =  7.81 paise .\n",
      "Cost/kWh (ii) =  7.81 paise .\n",
      "Cost/kWh (iii)=  9.07 paise .\n"
     ]
    }
   ],
   "source": [
    "'''Consumer has an annual consumption of 176,400 kWh. The charge is Rs. 120 per kW of maximum demand plus 4 paisa\n",
    "per kWh.\n",
    "(i) Find the annual bill and the overall cost per kWh if the load factor is 36%.\n",
    "(ii) What is the overall cost per kWh, if the consumption were reduced 25% with the same load factor ?\n",
    "(iii) What is the overall cost per kWh, if the load factor is 27% with the same consumption as in (i) '''\n",
    "\n",
    "\n",
    "#Given\n",
    "an_con = 176400.0           #kWh           (Annual consumption)\n",
    "lf = 0.36                   #              (load factor)\n",
    "\n",
    "###(i)###\n",
    "#Average demand  = annual consumption/No of hours in a year is\n",
    "avg_dem = an_con/8760       #kW\n",
    "\n",
    "#Maximum demand = Avg demand/Load factor\n",
    "maxp = avg_dem/lf           #kW\n",
    "\n",
    "#Total bill = charge due to maximum demand + 4 paise per kWh\n",
    "bill = maxp*120.0 + 0.04*an_con     #Rs\n",
    "\n",
    "#Cost/kWh = annual bill/annual consumption(in kWh)\n",
    "cost = bill/an_con*100              #paise\n",
    "\n",
    "print \"Annual Bill = \",round(bill),\"Rs.\"\n",
    "print \"Cost/kWh  (i) = \",round(cost,2),\"paise .\"\n",
    "\n",
    "\n",
    "\n",
    "###(ii)###\n",
    "an_con = 176400.0 * (0.75)          #kWh           (Annual consumption is 75% only)\n",
    "lf = 0.36                           #              (load factor)\n",
    "\n",
    "#Average demand  = annual consumption/No of hours in a year is\n",
    "avg_dem = an_con/8760       #kW\n",
    "\n",
    "#Maximum demand = Avg demand/Load factor\n",
    "maxp = avg_dem/lf           #kW\n",
    "\n",
    "#Total bill = charge due to maximum demand + 4 paise per kWh\n",
    "bill = maxp*120.0 + 0.04*an_con     #Rs\n",
    "\n",
    "#Cost/kWh = annual bill/annual consumption(in kWh)\n",
    "cost = bill/an_con*100              #paise\n",
    "\n",
    "print \"Cost/kWh (ii) = \",round(cost,2),\"paise .\"\n",
    "\n",
    "\n",
    "###(iii)###\n",
    "an_con = 176400.0                   #kWh           (Annual consumption)\n",
    "lf = 0.27                           #              (changed load factor)\n",
    "\n",
    "#Average demand  = annual consumption/No of hours in a year is\n",
    "avg_dem = an_con/8760       #kW\n",
    "\n",
    "#Maximum demand = Avg demand/Load factor\n",
    "maxp = avg_dem/lf           #kW\n",
    "\n",
    "#Total bill = charge due to maximum demand + 4 paise per kWh\n",
    "bill = maxp*120.0 + 0.04*an_con     #Rs\n",
    "\n",
    "#Cost/kWh = annual bill/annual consumption(in kWh)\n",
    "cost = bill/an_con*100              #paise\n",
    "\n",
    "print \"Cost/kWh (iii)= \",round(cost,2),\"paise .\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.21 , PAGE NO :- 1964"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "load factor = 0.71\n",
      "capacity factor = 0.61\n",
      "daily fuel requirement = 125.84 tonne.\n"
     ]
    }
   ],
   "source": [
    "'''A power station has a load cycle as under :\n",
    "\n",
    "260 MW for 6 hr    ; 200 MW for 8 hr     ; 160 MW for 4 hr     ; 100 MW for 6 hr\n",
    "If the power station is equipped with 4 sets of 75 MW each, calculate the load factor and the\n",
    "capacity factor from the above data. Calculate the daily fuel requirement if the calorific value of the\n",
    "oil used were 10,000 kcal/kg and the average heat rate of the station were 2,860 kcal/kWh.'''\n",
    "\n",
    "\n",
    "#Given\n",
    "maxp = 260.0        #MW                 (Maximum demand)\n",
    "heat = 2860.0       #kcal/kWh           (Heat rate of station)\n",
    "cal = 100000.0       #kcal/kg            (calorific value)\n",
    "\n",
    "#Energy consumed per day\n",
    "enrgy = maxp*6 + 200.0*8 + 160.0*4 + 100.0*6             #MW\n",
    "\n",
    "#Daily load factor = Energy consumed/Max demand*24 is\n",
    "lf = enrgy/(maxp*24)\n",
    "\n",
    "#Installed capacity is\n",
    "cap = (75.0)*4                 #MW\n",
    "\n",
    "#Capacity factor = Energy consumed/Installed capacity*24 is\n",
    "cf = enrgy/(cap*24)\n",
    "\n",
    "#Heat produced in station in kcal\n",
    "heat_p = heat*enrgy*1000.0     #kcal\n",
    "\n",
    "#Daily fuel requirement is\n",
    "fuel = (heat_p/cal)/1000.0       #tonne\n",
    "\n",
    "print \"load factor =\",round(lf,2)\n",
    "print \"capacity factor =\",round(cf,2)\n",
    "print \"daily fuel requirement =\",round(fuel,2),\"tonne.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.22 , PAGE NO :- 1964"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "load factor =  0.57\n",
      "utilization factor = 0.73\n"
     ]
    }
   ],
   "source": [
    "'''A generating station has two 50 MW units each running for 8,500 hours in a year and one 30 MW unit running for\n",
    "1,250 hours in one year. The station output is 650 * 10^6 kWh per year. Calculate\n",
    "(i) station load factor, (ii) the utilization factor.'''\n",
    "\n",
    "#Given\n",
    "\n",
    "#Output of power station(Energy used)\n",
    "enrgy = 650.0e+6           #kWh\n",
    "\n",
    "#Maximum demand\n",
    "maxp = 2*50.0 + 30.0       #MW\n",
    "maxp = maxp*1000.0         #kW\n",
    "\n",
    "#Total energy produced in kWh is\n",
    "enrgy_pro = 2*(50.0e+3)*(8500.0) + (30.0e+3)*1250.0     #kWh\n",
    "\n",
    "#Annual load factor  = Energy consumed/Max demand*8760 is\n",
    "lf = enrgy/(maxp*8760)\n",
    "\n",
    "#Utilization factor = Energy consumed/Energy produced\n",
    "uf = enrgy/enrgy_pro\n",
    "\n",
    "print \"load factor = \",round(lf,2)\n",
    "print \"utilization factor =\",round(uf,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.23 , PAGE NO :- 1965"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Installed Capacity =  50.0 MW\n",
      "Plant factor =  0.48\n",
      "Maximum demand =  40000.0 kW\n",
      "Load factor =  0.6\n",
      "Utilization factor =  0.8\n"
     ]
    }
   ],
   "source": [
    "'''The yearly duration curve of a certain plant may be considered as a straight line from 40,000 kW to 8,000 kW.\n",
    "To meet this load, three turbo-generators, two rated at 20,000 kW each and one at 10,000 kW are installed.\n",
    "Determine (a) the installed capacity, (b) plant factor,(c) maximum demand, (d) load factor and (e) utilization factor.'''\n",
    "\n",
    "\n",
    "#(a) Installed capacity is\n",
    "cap = 2*20.0 + 10.0          #MW\n",
    "\n",
    "#(b)plant factor\n",
    "\n",
    "#Average demand\n",
    "avg_dem = (40000.0 + 8000.0)/2  #kW\n",
    "\n",
    "#Plant factor = Average demand/Installed capacity\n",
    "pf = avg_dem/(cap*1000.0)\n",
    "\n",
    "#(c) Maximum demand\n",
    "maxp = 40000.0               #kW   (Given)\n",
    "\n",
    "#(d)load factor = Avg demand/Max demand\n",
    "lf = avg_dem/maxp\n",
    "\n",
    "#(e)Utilization factor = Max demand/Plant capacity\n",
    "uf = maxp/(cap*1000.0)\n",
    "\n",
    "print \"Installed Capacity = \",round(cap),\"MW\"\n",
    "print \"Plant factor = \",round(pf,2)\n",
    "print \"Maximum demand = \",maxp,\"kW\"\n",
    "print \"Load factor = \",round(lf,2)\n",
    "print \"Utilization factor = \",round(uf,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.24 , PAGE NO :- 1965"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Maximum demand of Run of River =  40.0 MW.\n",
      "Maximum demand of Reservoir    =  40.0 MW.\n",
      "Maximum demand of Steam        =  80.0 MW.\n",
      "Load factor(Run of river) =  1.0\n",
      "Load factor(Reservoir)    =  0.25\n",
      "Load factor(Steam)        =  0.88\n"
     ]
    }
   ],
   "source": [
    "'''The load duration curve of a system is as shown in Fig. 50.10. The system is\n",
    "supplied by three stations; a steam station, a run-of-river station and a reservoir hydro-electric\n",
    "station. The ratios of number of units supplied by the three stations are as below :\n",
    "Steam       :     Run of river       :      Reservoir\n",
    "7           :           4            :          1\n",
    "The run-of-river station is capable of generating power continuosuly and works as a peak load\n",
    "station. Estimate the maximum demand on each station and also the load factor of each station.'''\n",
    "\n",
    "\n",
    "from sympy import Symbol,Eq,solve\n",
    "\n",
    "#Let 100% time be 1 year = 8760 hours\n",
    "\n",
    "#Area under curve is energy produced in a year\n",
    "enrgy = (0.5*(160-80)*8760.0 + 80*8760.0)*1000.0        #kWh\n",
    "\n",
    "#For the given ratio ,units supplied by each station is\n",
    "steam = enrgy*(7.0/12)               #kWh           (Steam station)\n",
    "runriv = enrgy*(4.0/12)              #kWh           (Run of river station)\n",
    "reservoir = enrgy*(1.0/12)           #kWh           (Reservoir)\n",
    "\n",
    "#Maximum demand of run of river is\n",
    "max_ror =  runriv/(8760.0*1000.0)            #MW      (From figure)\n",
    "\n",
    "#For Maximum demand of Reservoir,\n",
    "x = Symbol('x')            #(As shown in figure)\n",
    "\n",
    "#No of hours reservoir will work is\n",
    "y = x/80*(8760)\n",
    "\n",
    "#Area under the reservoir curve(Energy produced) is\n",
    "area = 0.5*(y)*(x)*1000.0            #kWh\n",
    "\n",
    "eq = Eq(area,reservoir)\n",
    "x = solve(eq)\n",
    "max_res =  x[1]                               #MW\n",
    "#Maximum demand of steam station is\n",
    "max_steam = 160.0 - max_ror - max_res         #MW\n",
    "\n",
    "#Load factors of each station   load factor = Energy produced/Max demand*8760\n",
    "\n",
    "#Run of River operates continously\n",
    "lf_ror = 1.0\n",
    "#Load factor Reservoir\n",
    "lf_res = reservoir/(max_res*1000*8760)\n",
    "#Load factor Steam\n",
    "lf_steam = steam/(max_steam*1000*8760)\n",
    "\n",
    "\n",
    "print \"Maximum demand of Run of River = \",round(max_ror,2),\"MW.\"\n",
    "print \"Maximum demand of Reservoir    = \",round(max_res,2),\"MW.\"\n",
    "print \"Maximum demand of Steam        = \",round(max_steam,2),\"MW.\"\n",
    "\n",
    "print \"Load factor(Run of river) = \",round(lf_ror,2)\n",
    "print \"Load factor(Reservoir)    = \",round(lf_res,2)\n",
    "print \"Load factor(Steam)        = \",round(lf_steam,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.25 , PAGE NO :- 1966"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Load factor = 0.34\n"
     ]
    }
   ],
   "source": [
    "'''A load having a maximum value of 150 MW can be supplied by either a hydroelectric plant or a steam power plant.\n",
    "The costs are as follows :\n",
    "Capital cost of steam plant             = Rs. 700 per kW installed\n",
    "Capital cost of hydro-electric plant    = Rs. 1,600 per kW installed\n",
    "Operating cost of steam plant           = Rs. 0.03 per kWh\n",
    "Operating cost of hydro-electric plant  = Rs. 0.006 per kWh\n",
    "Interest on capital cost 8 per cent. Calculate the minimum load factor above which the hydroelectric plant will be\n",
    "more economical.'''\n",
    "\n",
    "\n",
    "from sympy import Symbol,solve,Eq\n",
    "\n",
    "#Given\n",
    "maxp = 150.0e+3         #kW\n",
    "\n",
    "#Let x be the total number of units generated per annum\n",
    "x = Symbol('x')\n",
    "\n",
    "##     Steam plant     ##\n",
    "\n",
    "#Capital cost is\n",
    "cap_stm = 700.0*(maxp)      #Rs\n",
    "#Interest charges\n",
    "charge1 = cap_stm*(8.0/100)     #Rs \n",
    "\n",
    "#Fixed charge/unit\n",
    "fxd_stm = charge1/x             #Rs \n",
    "\n",
    "#Total cost per kWh for steam plant is\n",
    "cost_stm = fxd_stm + 0.03       #Rs\n",
    "\n",
    "\n",
    "##     Hydro-electric plant     ##\n",
    "\n",
    "#Capital cost is\n",
    "cap_hyd = 1600.0*(maxp)      #Rs\n",
    "#Interest charges\n",
    "charge1 = cap_hyd*(8.0/100)     #Rs \n",
    "\n",
    "#Fixed charge/unit\n",
    "fxd_hyd = charge1/x             #Rs \n",
    "\n",
    "#Total cost per kWh for steam plant is\n",
    "cost_hyd = fxd_hyd + 0.006       #Rs\n",
    "\n",
    "\n",
    "#Let us find out x when both cost will be equal\n",
    "eq = Eq(cost_hyd,cost_stm)\n",
    "x = solve(eq)\n",
    "x1 = x[0]\n",
    "\n",
    "#If units generated are more than x1 then cost of hydro-electricity will be cheaper\n",
    "\n",
    "#Load factor = Energy produced/Max demand*8760\n",
    "\n",
    "lf = x1/(maxp*8760)\n",
    "\n",
    "print \"Load factor =\",round(lf,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.26 , PAGE NO :- 1967"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Overall cost/kWh for (a) =  10.97 paise.\n",
      "Overall cost/kWh for (b) =  10.71 paise.\n",
      "Overall cost/kWh for (c) =  11.21 paise.\n",
      "Overall cost/kWh for steam station with 90% load factor =  6.9 paise.\n",
      "Overall cost/kWh for steam station with 90% load factor =  4.87 paise.\n"
     ]
    }
   ],
   "source": [
    "'''A power system having maximum demand of 100 MW has a load 30% and is to be supplied by either of the following schemes :\n",
    "(a) a steam station in conjunction with a hydro-electric station, the latter supplying 100 * 10^6\n",
    "    units per annum with a max. output of 40 MW,\n",
    "(b) a steam station capable of supply the whole load,\n",
    "(c) a hydro station capable of supplying the whole load,\n",
    "Compare the overall cost per unit generated assuming the following data :\n",
    "                                                Steam                       Hydro\n",
    "Capital cost / kW                               Rs. 1,250                   Rs. 2,500\n",
    "Interest and depreciation on the capital cost     12%                         10%\n",
    "Operating cost/kWh                              5 paise                     1.5 paise\n",
    "Transmission cost/kWh                           Negligible                  0.2 paise\n",
    "Show how overall cost would be affected in case (ii) and (iii) above if the system load factor\n",
    "were improved to 90 per cent.'''\n",
    "\n",
    "\n",
    "#Average power consumption is\n",
    "avg_pwr = 100.0*0.3*1000.0                  #kW\n",
    "\n",
    "#Units generated in a year = Power*time(no of hours in a year)\n",
    "units = avg_pwr*(8760)                      #kWh\n",
    "\n",
    "#----------------------------------------------------------------------------------------------#\n",
    "#(a)Steam station in conjunction with Hydro station\n",
    "\n",
    "hyd_units = 100.0e+6                 #kWh     (units supplied by hydro station)\n",
    "stm_units = units - hyd_units        #kWh     (units supplied by steam station)\n",
    "hyd_max = 40.0e+3                    #kW      (max. output of Hydro station)\n",
    "stm_max = 100.0e+3 - hyd_max         #kW      (max. output of Steam station)\n",
    "\n",
    "\n",
    "#(i)Steam station\n",
    "cap_cost = stm_max*(1250)            #Rs      (capital cost)\n",
    "fxd_charge = (12.0/100)*cap_cost     #Rs      (fixed charge: interest & depreciation)\n",
    "op_charge = (5.0/100)*stm_units      #Rs      (operating charge)\n",
    "stm_cost = fxd_charge + op_charge    #Rs      (total steam charges)\n",
    "\n",
    "#(ii)Hydro station\n",
    "cap_cost = hyd_max*(2500)            #Rs      (capital cost)\n",
    "fxd_charge = (10.0/100)*cap_cost     #Rs      (fixed charges: interest & depreciation)\n",
    "op_charge = (1.5/100)*hyd_units      #Rs      (operating charges)\n",
    "tr_charge = (0.2/100)*hyd_units      #Rs      (transmission charges)\n",
    "hyd_cost = fxd_charge + op_charge + tr_charge    #Rs      (total hydro charges)\n",
    "\n",
    "#Total cost\n",
    "tot_cost = stm_cost + hyd_cost       #Rs      (total cost) \n",
    "#Overal cost per kWh\n",
    "cost_kwh = tot_cost/units*100        #paisa\n",
    "print \"Overall cost/kWh for (a) = \",round(cost_kwh,2),\"paise.\"\n",
    "\n",
    "#------------------------------------------------------------------------------------------------#\n",
    "#(b)Steam station alone\n",
    "stm_max = 100.0e+3                   #kW      (max. output of Steam station)\n",
    "stm_units = units                    #kWh     (units supplied by Steam station)\n",
    "\n",
    "cap_cost = stm_max*(1250)            #Rs      (capital cost)\n",
    "fxd_charge = (12.0/100)*cap_cost     #Rs      (fixed charge: interest & depreciation)\n",
    "op_charge = (5.0/100)*stm_units      #Rs      (operating charge)\n",
    "stm_cost = fxd_charge + op_charge    #Rs      (total steam charges)\n",
    "stm_fxdkWh = fxd_charge/stm_units*100#paise   (fixed charge per unit)\n",
    "#Overal cost per kWh\n",
    "cost_kwh = stm_cost/stm_units*100        #paisa\n",
    "print \"Overall cost/kWh for (b) = \",round(cost_kwh,2),\"paise.\"\n",
    "\n",
    "#------------------------------------------------------------------------------------------------#\n",
    "#(c)Hydro station alone\n",
    "hyd_max = 100.0e+3                   #kW      (max. output of Hydro station)\n",
    "hyd_units = units                    #kWh     (units supplied by Hydro station)\n",
    "\n",
    "cap_cost = hyd_max*(2500)            #Rs      (capital cost)\n",
    "fxd_charge = (10.0/100)*cap_cost     #Rs      (fixed charges: interest & depreciation)\n",
    "op_charge = (1.5/100)*hyd_units      #Rs      (operating charges)\n",
    "tr_charge = (0.2/100)*hyd_units      #Rs      (transmission charges)\n",
    "hyd_cost = fxd_charge + op_charge + tr_charge    #Rs      (total hydro charges)\n",
    "hyd_fxdkWh = fxd_charge/hyd_units*100#paise   (fixed charge per unit)\n",
    "#Overall cost per kWh\n",
    "cost_kwh = hyd_cost/hyd_units*100        #paisa\n",
    "print \"Overall cost/kWh for (c) = \",round(cost_kwh,2),\"paise.\"\n",
    "\n",
    "#-------------------------------------------------------------------------------------------------#\n",
    "#(d)As load factor is made 3 times. No. of units generated are 3 times and therefore fixed price\n",
    "#decrease to 1/3 times the previous price\n",
    "\n",
    "#(i)Steam station\n",
    "cost_kwh = stm_fxdkWh/3 + 5.0    #paise      (new total steam cost per kWh)\n",
    "print \"Overall cost/kWh for steam station with 90% load factor = \",round(cost_kwh,2),\"paise.\"\n",
    "#(ii)Hydro station\n",
    "cost_kwh = hyd_fxdkWh/3  + 1.5 + 0.2   #paise      (new total hydro cost per kWh)\n",
    "print \"Overall cost/kWh for steam station with 90% load factor = \",round(cost_kwh,2),\"paise.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.27 , PAGE NO :- 1969"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Generation cost is = Rs ( 154.25 kW +  0.0119 )kWh.\n"
     ]
    }
   ],
   "source": [
    "'''The capital cost of a hydro-power station of 50,000 kW capacity is Rs. 1,200 per kW. The annual charge on investment\n",
    "including depreciation etc. is 10%. A royality of Rs. 1 per kW per year and Rs. 0.01 per kWh generated is to be paid for\n",
    "using the river water for generation of power. The maximum demand is 40,000 kW and the yearly load factor is 80%.\n",
    "Salaries,maintenance charges and supplies etc. total Rs. 6,50,000. If 20% of this expense is also chargeable\n",
    "as fixed charges, determine the generation cost in the form of A per kW plus B per kWh.'''\n",
    "\n",
    "\n",
    "maxp = 40000.0         #kW       (Maximum demand)\n",
    "#Capital cost of station = Cost/kW *(Capacity of plant in kW)\n",
    "cap_cost = 1200.0*50000.0                #Rs\n",
    "\n",
    "#Annual charge on investment includin depriciation\n",
    "anl_charge = (10.0/100)*cap_cost         #Rs\n",
    "\n",
    "#Total running charge\n",
    "run_charge = (80.0/100)*650000.0         #Rs \n",
    "\n",
    "#Fixed charges\n",
    "fxd_charge = (20.0/100)*650000.0         #Rs\n",
    "\n",
    "#Cost per Max demand kW due to fixed charge is\n",
    "cost_md1 = (anl_charge + fxd_charge)/maxp               #Rs\n",
    "#Cost per Max demand kW due to royalty is\n",
    "cost_md2 = 1.0                           #Rs\n",
    "#Total Cost per Max demand kW is\n",
    "cost_md = cost_md1 + cost_md2            #Rs\n",
    "\n",
    "\n",
    "#Total number of unit generated per annum = Max demand*load factor*(No of hours)\n",
    "units = maxp*0.8*8760                    #kWh\n",
    "\n",
    "#Cost per unit due to running charges\n",
    "cost_unit = run_charge/units             #Rs\n",
    "#Royalty cost\n",
    "cost_roy = 0.01                          #Rs\n",
    "#Total cost per unit is\n",
    "cost_tot = cost_unit + cost_roy          #Rs\n",
    "\n",
    "print \"Generation cost is = Rs (\",round(cost_md,2),\"kW + \",round(cost_tot,4),\")kWh.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## EXAMPLE 50.28 , PAGE NO :- 1969"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "load factor = 0.472\n",
      "generating cost = Rs. 41314200.0\n"
     ]
    }
   ],
   "source": [
    "'''The capital costs of steam and water power stations are Rs. 1,200 and Rs. 2,100 per kW of the installed capacity.\n",
    "The corresponding running costs are 5 paise and 3.2 paise per kWh respectively.The reserve capacity in the case of the\n",
    "steam station is to be 25% and that for the water power station is to be 33.33% of the installed capacity.At what\n",
    "load factor would the overall cost per kWh be the same in both cases ? Assume interest and depreciation charges\n",
    "on the capital to be 9% for the thermal and 7.5% for the hydro-electric station. What would be the cost of generating\n",
    "500 million kWh at this load factor ? '''\n",
    "\n",
    "from sympy import Symbol,Eq,solve\n",
    "\n",
    "#Let x be the maximum demand in kWh and y the load factor\n",
    "x = Symbol('x')\n",
    "y = Symbol('y')\n",
    "#Total number of units produced\n",
    "units = x*y*8760.0                #kWh\n",
    "\n",
    "\n",
    "######         Steam station        ######\n",
    "\n",
    "#Installed capacity\n",
    "capacity = 1.25*x                #kW  (including reserve capacity)\n",
    "#Capital cost\n",
    "cap_cost = capacity*1200.0        #Rs\n",
    "#Annual depreciation\n",
    "anl_charge = (9.0/100)*cap_cost   #Rs\n",
    "#Annual running cost\n",
    "run_charge = (8760*x*y)*(5.0/100) #Rs\n",
    "#Total annual cost\n",
    "cost_stm = run_charge + anl_charge\n",
    "#Total cost/unit\n",
    "stmcost_unt = cost_stm/units\n",
    "\n",
    "######         Hydro station       ######\n",
    "\n",
    "#Installed capacity\n",
    "capacity = 1.33*x                #kW  (including reserve capacity)\n",
    "#Capital cost\n",
    "cap_cost = capacity*2100.0        #Rs\n",
    "#Annual depreciation\n",
    "anl_charge = (7.5/100)*cap_cost   #Rs\n",
    "#Annual running cost\n",
    "run_charge = (8760*x*y)*(3.2/100) #Rs\n",
    "#Total annual cost\n",
    "cost_hyd = run_charge + anl_charge    #Rs\n",
    "#Total cost/unit\n",
    "hydcost_unt = cost_hyd/units         #Rs\n",
    "\n",
    "#To solve we will assume a value of x\n",
    "x = 10\n",
    "eq = Eq(hydcost_unt,stmcost_unt)\n",
    "y  = solve(eq)\n",
    "y1 = y[0]\n",
    "for key in y1:\n",
    "    y1 = y1.get(key);\n",
    "#Maximum demand is\n",
    "x = 500.0e+6/(8760.0*y1)          #kW\n",
    "\n",
    "#Calculating cost\n",
    "capacity = 1.25*x\n",
    "cap_cost = capacity*1200.0\n",
    "anl_charge = (9.0/100)*cap_cost\n",
    "run_charge = (8760*x*y1)*(5.0/100)\n",
    "cost_stm = run_charge + anl_charge        #Rs\n",
    "print \"load factor =\",round(y1,3)\n",
    "print \"generating cost = Rs.\",round(cost_stm,-1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## EXAMPLE 50.29 , PAGE NO :- 1970"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hydro cost/kWh = 13.56 paise.\n",
      "Steam cost/kWh = 11.85 paise.\n",
      "Steam is economical for lf = 0.1\n",
      "Hydro cost/kWh = 3.51 paise.\n",
      "Steam cost/kWh = 6.37 paise.\n",
      "Hydro is economical for lf = 0.5\n"
     ]
    }
   ],
   "source": [
    "'''In a particular area, both steam and hydro-stations are equally possible. It has been estimated that capital cost and the running\n",
    "costs of these two types will be as follows:\n",
    "          Capital cost/kW            Running cost/kWh             Interest\n",
    "Hydro :      Rs. 2,200                   1 Paise                     5%\n",
    "Steam :      Rs. 1,200                   5 Paise                     5%\n",
    "If expected average load factor is only 10%, which is economical to operate : steam or hydro?\n",
    "If the load factor is 50%, would there be any change in the choice ? If so, indicate with calculation.'''\n",
    "\n",
    "from sympy import Symbol\n",
    "\n",
    "#Let x be the capacity of power station in kW.\n",
    "x = Symbol('x')\n",
    "#------------------------------------------------------------------------#\n",
    "#Case I :-   Load factor = 10%\n",
    "lf1 = 0.1\n",
    "#Total units generated per annum\n",
    "units = x*lf1*(8760)                          #kWh\n",
    "\n",
    "#(a) Hydro Station\n",
    "#--------------------------------#\n",
    "cap_cost = 2200.0*x                           #Rs        (Capital cost)\n",
    "fxd_charge = (5.0/100)*cap_cost               #Rs        (Fixed cost)\n",
    "run_charge = (1.0/100)*units                  #Rs        (Running cost  ->   given, 1 unit costs 1 paisa)\n",
    "tot_charge = fxd_charge + run_charge          #Rs        (Total charge)\n",
    "hyd_costkwh = tot_charge/units*100               #paise     (Cost per kWh)\n",
    "\n",
    "#(b) Steam Station\n",
    "#--------------------------------#\n",
    "cap_cost = 1200.0*x                           #Rs        (Capital cost)\n",
    "fxd_charge = (5.0/100)*cap_cost               #Rs        (Fixed cost)\n",
    "run_charge = (5.0/100)*units                  #Rs        (Running cost  ->   given, 1 unit costs 5 paisa)\n",
    "tot_charge = fxd_charge + run_charge          #Rs        (Total charge)\n",
    "stm_costkwh = tot_charge/units*100               #paise     (Cost per kWh)\n",
    "\n",
    "print \"Hydro cost/kWh =\",round(hyd_costkwh,2),\"paise.\"\n",
    "print \"Steam cost/kWh =\",round(stm_costkwh,2),\"paise.\"\n",
    "\n",
    "if (hyd_costkwh >= stm_costkwh) :\n",
    "    print \"Steam is economical for lf =\",round(lf1,2)\n",
    "else:\n",
    "    print \"Hydro is economical for lf =\",round(lf1,2)\n",
    "\n",
    "#-----------------------------------------------------------------------------------------------------------#\n",
    "\n",
    "#Case II :-   Load factor = 50%\n",
    "lf2 = 0.5\n",
    "#Total units generated per annum\n",
    "units = x*lf2*(8760)                          #kWh\n",
    "\n",
    "#(a) Hydro Station\n",
    "#--------------------------------#\n",
    "cap_cost = 2200.0*x                           #Rs        (Capital cost)\n",
    "fxd_charge = (5.0/100)*cap_cost               #Rs        (Fixed cost)\n",
    "run_charge = (1.0/100)*units                  #Rs        (Running cost  ->   given, 1 unit costs 1 paisa)\n",
    "tot_charge = fxd_charge + run_charge          #Rs        (Total charge)\n",
    "hyd_costkwh = tot_charge/units*100               #paise     (Cost per kWh)\n",
    "\n",
    "#(b) Steam Station\n",
    "#--------------------------------#\n",
    "cap_cost = 1200.0*x                           #Rs        (Capital cost)\n",
    "fxd_charge = (5.0/100)*cap_cost               #Rs        (Fixed cost)\n",
    "run_charge = (5.0/100)*units                  #Rs        (Running cost  ->   given, 1 unit costs 5 paisa)\n",
    "tot_charge = fxd_charge + run_charge          #Rs        (Total charge)\n",
    "stm_costkwh = tot_charge/units*100               #paise     (Cost per kWh)\n",
    "\n",
    "print \"Hydro cost/kWh =\",round(hyd_costkwh,2),\"paise.\"\n",
    "print \"Steam cost/kWh =\",round(stm_costkwh,2),\"paise.\"\n",
    "\n",
    "if (hyd_costkwh >= stm_costkwh) :\n",
    "    print \"Steam is economical for lf =\",round(lf2,2)\n",
    "else:\n",
    "    print \"Hydro is economical for lf =\",round(lf2,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.30 , PAGE NO :- 1971"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a = 50000.0\n",
      "b = 0.833\n",
      "c = 0.000342\n"
     ]
    }
   ],
   "source": [
    "'''The annual working cost of a thermal station can be represented by a formula Rs. (a + b kW + c kWh) where a, b and c\n",
    "are constants for a particular station, kW is the total installed capactiy and kWh the energy produced per annum.\n",
    "Explain the significance of the constants a, b and c and the factors on which their values depend.\n",
    "Determine the values of a, b and c for a 60 MW station operating with annual load factor of 40% for which :\n",
    "(i) capital cost of buildings and equipment is Rs. 5 * 10^5\n",
    "(ii) the annual cost of fuel, oil, taxation and wages and salaries of operating staff is Rs.90,000\n",
    "(iii) the interest and depreciation on buildings and equipment are 10% per annum\n",
    "(iv) annual cost of organisation and interest on cost of site etc. is Rs. 50,000.'''\n",
    "\n",
    "#Constant a is fixed cost i.e annual ineterest cost\n",
    "a = 50000.0\n",
    "\n",
    "#Constand b is semi-fixed cost such that\n",
    "#b*(Max demand in kW) = annual interest on capital cost\n",
    "b = 0.1*5.0e+5/(60.0e+3)\n",
    "\n",
    "#Constant c is running cost such that\n",
    "#c*(units in kWh) = annual fuel cost etc.\n",
    "\n",
    "avg_pwr = 0.5*(60.0e+3)         #kW      (Average power)\n",
    "units = avg_pwr*8760.0          #kWh     (No of units produced)\n",
    "c = 90000.0/units\n",
    "print \"a =\",a\n",
    "print \"b =\",round(b,3)\n",
    "print \"c =\",round(c,6)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.31 , PAGE NO :- 1972"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Total cost = 133.75 Rs\n",
      "Cost per unit(kWh) is =  35.67 paise\n"
     ]
    }
   ],
   "source": [
    "'''Compute the cost of electrical energy and average cost for consuming 375 kWh under ' block rate tariff ' as under :\n",
    "First 50 kWh at 60 paisa per kWh ; next 50 kWh at 50 paisa per kWh; next 50 kWh at 40 paisa per kWh; next 50 kWh at 30 paisa per kWh.\n",
    "Excess over 200 kWh at 25 paisa per kWh.'''\n",
    "\n",
    "#Energy charge for first 50 kWh is\n",
    "cost1 = 0.6*50.0         #Rs\n",
    "#Energy charge for next 50 kWh is\n",
    "cost2 = 0.5*50.0         #Rs\n",
    "#Energy charge for next 50 kWh is\n",
    "cost3 = 0.4*50.0         #Rs\n",
    "#Energy charge for next 50 kWh is\n",
    "cost4 = 0.3*50.0         #Rs\n",
    "#Energy charge for the rest (375-200) kWh is\n",
    "cost5 = 0.25*(375.0 - 200.0)        #Rs\n",
    "#Total cost is\n",
    "tot_cost = cost1 + cost2 + cost3 + cost4 + cost5       #Rs\n",
    "\n",
    "#Cost/kWh = Total cost/No of units\n",
    "cost_unit = tot_cost/375.0 * 100         #paisa\n",
    "\n",
    "print \"Total cost =\",round(tot_cost,2),\"Rs\"\n",
    "print \"Cost per unit(kWh) is = \",round(cost_unit,2),\"paise\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.32 , PAGE NO :- 1972"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Cost of generating is =  5.37 paise.\n"
     ]
    }
   ],
   "source": [
    "'''The output of a generating station is 390 * 10^6 units per annum and installed capacity is 80,000 kW. If the annual fixed \n",
    "charges are Rs. 18 per kW of isntalled plant and running charges are 5 paisa per kWh, what is the cost per unit at the generating\n",
    "station ?'''\n",
    "\n",
    "#Given\n",
    "cap = 80000.0            #kW        (installed capacity)\n",
    "units = 390.0e+6         #kWh       (no of units produced)\n",
    "\n",
    "#Annual Fixed charge is\n",
    "anl_charge = cap*18.0        #Rs\n",
    "\n",
    "#Fixed charge per kW is\n",
    "fxd_charge = anl_charge/units*100    #paise\n",
    "\n",
    "#Running charges per kW is\n",
    "run_charge = 5.0                     #paise\n",
    "\n",
    "#Cost of generating  station  is\n",
    "gen_cost = run_charge + fxd_charge   #paise\n",
    "\n",
    "print \"Cost of generating is = \",round(gen_cost,2),\"paise.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.33 , PAGE NO :- 1973"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Cost of generation per kWh(load factor 100%) =  2.97 paise.\n",
      "Cost of generation per kWh(load factor 100%) =  7.72 paise.\n"
     ]
    }
   ],
   "source": [
    "'''A power station has an installed capacity of 20 MW. The capital cost of station\n",
    "is Rs. 800 per kW. The fixed costs are 13% of the cost of investment. On full-load at 100% load factor,\n",
    "the variable costs of the station per year are 1.5 times the fixed cost. Assume no reserve capacity and\n",
    "variable cost to be proportional to the energy produced, find the cost of generation per kWh at load\n",
    "factors of 100% and 20%. Comment on the results.'''\n",
    "\n",
    "#Given\n",
    "capacity = 20000.0       #kW    (installed capacity)\n",
    "lf1 = 1.0                #      (load factor 1)\n",
    "lf2 = 0.2                #      (load factor 2)\n",
    "\n",
    "#Capital cost of station is\n",
    "cap_cost = capacity*(800.0)           #Rs\n",
    "\n",
    "#(a) At 100% load factor\n",
    "fxd_cost = (13.0/100)*cap_cost        #Rs     (fixed cost)\n",
    "var_cost = 1.5*fxd_cost               #Rs     (variable cost)\n",
    "\n",
    "#Total operating cost is\n",
    "tot_cost = fxd_cost + var_cost        #Rs\n",
    "\n",
    "#Total no. of units generated  = (Max.demand*8760)*(load factor)\n",
    "units = capacity*8760*lf1             #kWh\n",
    "#Cost of unit per kWh generated is\n",
    "cost_kwh = tot_cost/units*100         #paise\n",
    "\n",
    "#error in the answer of book\n",
    "print \"Cost of generation per kWh(load factor 100%) = \",round(cost_kwh,2),\"paise.\"\n",
    "\n",
    "#(a) At 20% load factor\n",
    "fxd_cost = (13.0/100)*cap_cost        #Rs     (fixed cost)\n",
    "#Since variable cost is propotional to load\n",
    "var_cost = 0.2*(1.5*fxd_cost)         #Rs     (variable cost)\n",
    "\n",
    "#Total operating cost is\n",
    "tot_cost = fxd_cost + var_cost        #Rs\n",
    "\n",
    "#Total no. of units generated  = (Max.demand*8760)*(load factor)\n",
    "units = capacity*8760*lf2            #kWh\n",
    "#Cost of unit per kWh generated is\n",
    "cost_kwh = tot_cost/units*100         #paise\n",
    "\n",
    "print \"Cost of generation per kWh(load factor 100%) = \",round(cost_kwh,2),\"paise.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.34 , PAGE NO :- 1973"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Annual running charge/kWh is =  1.38 paise.\n"
     ]
    }
   ],
   "source": [
    "'''The annual output of a generating sub-station is 525.6 * 10^6 kWh and the average load factor is 60%. If annual fixed charges are\n",
    "Rs. 20 per kW installed plant and the annual running charges are 1 paisa per kWh, what would be the cost per kWh at the bus bars ?'''\n",
    "\n",
    "#Given\n",
    "enrgy = 525.6e+6         #kWh      (Energy produced)\n",
    "lf = 0.6                 #         (Load factor)  \n",
    "\n",
    "#Average power supplied per annum = Energy produced/(No of hours in a year)\n",
    "avg_pwr = enrgy/8760               #kW\n",
    "#Maximum demand = average power/load factor is\n",
    "maxp = avg_pwr/lf       #kW\n",
    "\n",
    "#Annual fixed charges\n",
    "charge = 20.0*maxp          #Rs\n",
    "\n",
    "#Fixed charge/kWh\n",
    "fxd_charge = charge/enrgy*100  #paise\n",
    "\n",
    "#Running charge/kWh\n",
    "run_charge = 1.0              #paise\n",
    "\n",
    "#Annual running charge/kWh is\n",
    "cost = fxd_charge + run_charge  #paise\n",
    "print \"Annual running charge/kWh is = \",round(cost,2),\"paise.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.35 , PAGE NO :- 1974"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "M.D charges = Rs. 5162.0\n",
      "Monthly Bill = Rs. 14163.0\n",
      "Load factor =  0.61\n",
      "Power factor =  0.6\n"
     ]
    }
   ],
   "source": [
    "'''A certain factory working 24 hours a day is charged at Rs. 10 per kVA of max.demand plus 5 paisa per kV ARh. The meters record\n",
    "for a month of 30 days; 135,200 kWh, 180,020 kV ARh and maximum demand 310 kW. Calculate\n",
    "(i) M.D. charges,        (ii) monthly bill,         (iii) load factor,        (iv) average power factor.'''\n",
    "\n",
    "import math as m\n",
    "\n",
    "#Given\n",
    "act_nrgy = 135200.0                      #kWh       (Active energy consumed in a month)\n",
    "re_nrgy = 180020.0                       #kVARh     (Reactive energy consumed in a month)\n",
    "maxp = 310.0                             #kW        (Maximum demand)   \n",
    "\n",
    "#Average power\n",
    "avgact_pwr = act_nrgy/(24*30)               #kW     (Active)\n",
    "avgre_pwr = re_nrgy/(24*30)                 #kVAR   (Reactive) \n",
    "#Now, tan(theta) = kVAR/kW\n",
    "theta = m.atan(avgre_pwr/avgact_pwr)\n",
    "\n",
    "#Maximum demand in kVA is\n",
    "md_kva = maxp/(m.cos(theta))\n",
    "\n",
    "#(i)Maximum demand charge is\n",
    "md_charge = md_kva*10.0             #Rs\n",
    "\n",
    "#(ii)Monthly bill\n",
    "#Reactive energy charges\n",
    "re_charge = (5.0/100)*re_nrgy       #Rs\n",
    "mon_bill = re_charge + md_charge    #Rs   (Monthly bill)\n",
    "\n",
    "#(iii)Load factor = Avg Demand/Max demand is\n",
    "lf = avgact_pwr/maxp\n",
    "\n",
    "#(iv)Average power factor\n",
    "pf = m.cos(theta)\n",
    "\n",
    "print \"M.D charges = Rs.\",round(md_charge)\n",
    "print \"Monthly Bill = Rs.\",round(mon_bill)\n",
    "print \"Load factor = \",round(lf,2)\n",
    "print \"Power factor = \",round(pf,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.36 , PAGE NO :- 1974"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "overall cost/unit =  6.37 Paise.\n",
      "Two-part tariff = Rs 146.67 per kW +  1.77 paise per kWh.\n"
     ]
    }
   ],
   "source": [
    "'''The cost data of a power supply company is as follows :\n",
    "Station maximum demand = 50 MW ;      station load factor = 60% ;    Reserve capacity = 20% ; capital cost = Rs. 2,000 per kW;\n",
    "interest and depreciation = 12% ;     salaries (annual) = Rs. 5 × 105;   fuel cost (annual) = Rs. 5 × 106 ; \n",
    "maintenance and repairs (annual) Rs. 2 × 105 ;      losses indistribution = 8% ;    load diversity factor = 1.7.\n",
    "Calculate the average cost per unit and the two-part tariff, assuming 80 per cent of salaries and repair and maintenace cost\n",
    "to be fixed.'''\n",
    "\n",
    "#Station capacity \n",
    "stn_cap = (1 + 20.0/100)*50                        #MW\n",
    "#Average power\n",
    "avg_pwr = stn_cap * 0.6*1000                       #kW \n",
    "#Capital investment\n",
    "cap_inv =   stn_cap*1000 * 2000                    #Rs\n",
    "#Interest + depreciation cost\n",
    "charge1=  0.12*cap_inv                             #Rs\n",
    "#Total cost both fixed and running\n",
    "cost_tot= charge1 + 5.0e+5 + 5e+6 + 2e+5           #Rs\n",
    "#No. of units generated annually \n",
    "units = 8760*avg_pwr\n",
    "#overall cost/unit \n",
    "cost_uni = cost_tot/units*100                      #Paise.\n",
    "print \"overall cost/unit = \",round(cost_uni,2),\"Paise.\"\n",
    "#----------------------------------------------------------------------------------------------#\n",
    "#Fixed charges\n",
    "#Annual interest and depreciation \n",
    "charge1 = charge1\n",
    "#80% of salaries \n",
    "charge2 = 0.8 * 5e+5                                #Rs\n",
    "#80% of repair and maintenance cost \n",
    "charge3 = 0.8 * 2e+5                                #Rs\n",
    "#Total fixed charges                                #Rs\n",
    "charge_tot = charge1 + charge2 + charge3            #Rs \n",
    "#Aggregate maximum demand of all consumers = Max. demand on generating station * diversity factor\n",
    "max_dem = 60*1000*1.7                               #kW\n",
    "#annual cost/kW of maximum demand \n",
    "cost =  charge_tot/max_dem                          #Rs \n",
    "\n",
    "#-----------------------------------------------------------------------------------------------#\n",
    "#Running Charges\n",
    "#Cost of fuel \n",
    "charge1 = 50e+5 \n",
    "#20% of salaries \n",
    "charge2 = 0.2 * 5e+5                                #Rs\n",
    "#20% of repair and maintenance cost \n",
    "charge3 = 0.2 * 2e+5                                #Rs\n",
    "#Total running charges\n",
    "charge_run =  charge1 + charge2 + charge3           #Rs\n",
    "#Cost per unit delivered (considering 8% losses)\n",
    "cost_uni = charge_run/(0.92*units)*100              #Paise\n",
    "print \"Two-part tariff = Rs\",round(cost,2),\"per kW + \",round(cost_uni,2),\"paise per kWh.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.37 , PAGE NO :- 1975"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Two-part tariff = Rs. 91.18 kW + Paise. 1.32 kWh\n"
     ]
    }
   ],
   "source": [
    "'''A certain electric supply undertaking having a maximum demand of 110 MW generates 400 * 10^6 kWh per year.The supply\n",
    "undertaking supplies power to consumers having an aggregate demand of 170 MW. The annual expenses including capital charges are :\n",
    "Fuel                                     = Rs. 5 * 10^6\n",
    "Fixed expenses connected with generation = Rs. 7 * 10^6\n",
    "Transmission and distribution expenses   = Rs. 8 * 10^6\n",
    "Determine a two-part tariff for the consumers on the basis of actual cost.\n",
    "Assume 90% of the fuel cost as variable charges and transmission and distrbution losses as 15% of energy generated.'''\n",
    "\n",
    "\n",
    "#Given\n",
    "maxp  = 170.0e+3           #kW        (Maximum demand)\n",
    "units = 400.0e+6           #kWh       (Number of units generated)\n",
    "fxd_charge = 7.0e+6        #Rs        (Fixed charges)\n",
    "tr_charge = 8.0e+6         #Rs        (Transmission and distribution charges)\n",
    "fuel_charge = (10.0/100)*5.0e+6                    #Rs\n",
    "#Total cost\n",
    "tot_charge = fxd_charge + tr_charge + fuel_charge  #Rs\n",
    "#Cost per kW of Max. demand\n",
    "cost_kw = tot_charge/maxp                       #Rs\n",
    "\n",
    "#Running charges = 90% of fuel cost\n",
    "run_charge = (90.0/100)*5.0e+6                  #Rs\n",
    "#Units consumed after losses\n",
    "units_con = (1 - 15.0/100)*units                #kWh\n",
    "#Cost per kWh of energy\n",
    "cost_kwh = run_charge/units_con*100             #Paise\n",
    "\n",
    "print \"Two-part tariff = Rs.\",round(cost_kw,2),\"kW + Paise.\",round(cost_kwh,2),\"kWh\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.38 , PAGE NO :- 1975"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Total annual bill is = Rs. 58257.0\n"
     ]
    }
   ],
   "source": [
    "'''Customer is offered power at Rs. 80 per annum per kVA of maximum demand plus 8 paisa per unit metered.\n",
    "He proposes to install a motor to carry his estimated maximum demand of 300 b.h.p. (223.8 kW). The motor available has a power\n",
    "factor of 0.85 at full-load. How many units will he require at 20% load factor and what willl be his annual bill ? '''\n",
    "\n",
    "#Given\n",
    "mot_eff = 90.0/100                #           (motor efficiency)\n",
    "maxp = 223.8/mot_eff              #kW         (full-load power intake)\n",
    "lf = 0.2                          #           (load factor)\n",
    "\n",
    "#Avg demand = Max demand * Load factor\n",
    "avg_dem = maxp*lf                 #kW\n",
    "#Annual consumption is\n",
    "units = avg_dem*8760               #kWh\n",
    "#Cost of units consumed per annum\n",
    "cost1 = units*(8.0/100)            #Rs\n",
    "\n",
    "#Maximum kVA of demand is\n",
    "max_kva = maxp/0.85               #kVA\n",
    "#Cost per kVA of Maximum demand is\n",
    "cost2 = max_kva*(80.0)             #Rs\n",
    "\n",
    "#Total annual bill is\n",
    "tot_cost = cost1 + cost2\n",
    "print \"Total annual bill is = Rs.\",round(tot_cost)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.39 , PAGE NO :- 1975"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Annual energy bill = Rs. 1475000.0\n",
      "Annual savings = Rs. 155000.0\n"
     ]
    }
   ],
   "source": [
    "'''How two-part tariff is modified for penalising low p.f. consumers ?\n",
    "An industry consumes 4 million kWh/year with a maximum demand of 1000 kW at 0.8 p.f. What is its load factor ?\n",
    "(a) Calculate the annual energy charges if tariff in force is as under :\n",
    "    Max. demand charge = Rs. 5 per kVA per month. Energy charges = Rs. 0.35 per kWh\n",
    "(b) Also calculate reduction in this bill if the maximum demand is reduced to 900 kW at 0.9 p.f. lagging.'''\n",
    "\n",
    "#Given\n",
    "units = 4.0e+6            #kWh          (No. of units generated)\n",
    "maxp = 1000.0             #kW           (Maximum demand)\n",
    "avg_dem = units/8760      #kW           (Average demand)\n",
    "\n",
    "#Load factor = Avg demand/Max demand\n",
    "lf = avg_dem/maxp\n",
    "#Max kVA demand is\n",
    "max_kVA = maxp/0.8           #kVA\n",
    "#--------------------------------------------#\n",
    "#(a)\n",
    "#Charge per kVA is\n",
    "charge = 5.0*12              #Rs\n",
    "#Annual charge per kVA is\n",
    "cost1 = charge*max_kVA       #Rs\n",
    "#Annual charge per unit is\n",
    "cost2 = 0.35*units           #Rs\n",
    "#Total energy bill is\n",
    "tot_bill  = cost1 + cost2    #Rs\n",
    "print \"Annual energy bill = Rs.\",tot_bill\n",
    "#--------------------------------------------#\n",
    "#(b)\n",
    "maxp = 900.0                 #kW        (New Maximum demand)\n",
    "#Since load factor remains same\n",
    "#Average load = Max demad * load factor\n",
    "avg_dem = maxp*lf           #kW\n",
    "#No of units generated in a year are\n",
    "units = avg_dem*8760        #kWh\n",
    "\n",
    "#Max kVA demand is\n",
    "max_kVA = maxp/0.9           #kVA\n",
    "#Annual charge per kVA is\n",
    "cost1 = charge*max_kVA       #Rs\n",
    "#Annual charge per unit is\n",
    "cost2 = 0.35*units           #Rs\n",
    "#Total energy bill is\n",
    "tot_bill2  = cost1 + cost2    #Rs\n",
    "#Total savings\n",
    "savings = tot_bill - tot_bill2  #Rs\n",
    "print \"Annual savings = Rs.\",savings"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## EXAMPLE 50.40 , PAGE NO :- 1976"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Number of units taken per annum =  1300.0 kWh.\n"
     ]
    }
   ],
   "source": [
    "'''A supply is offered on the basis of fixed charges of Rs. 30 per annum plus 3 paise per unit or alternatively,\n",
    "at the rate of 6 paisa per unit for the first 400 units per annum and 5 paise per unit for all the additional units.\n",
    "Find the number of units taken per annum for which the cost under these two tariffs becomes the same.'''\n",
    "\n",
    "\n",
    "from sympy import Symbol,Eq,solve\n",
    "#Let x kWh be the annual consumption of the consumer\n",
    "x = Symbol('x')\n",
    "\n",
    "#Cost under tariff 1\n",
    "cost1 = 30.0 + (3.0/100)*x                      #Rs\n",
    "#Cost under tariff 2\n",
    "cost2 = (6.0/100)*400.0 + (5.0/100)*(x-400.0)   #Rs\n",
    "\n",
    "#Since charge in both cases are equal\n",
    "eq = Eq(cost1,cost2)\n",
    "x = solve(eq)\n",
    "x1 = x[0]\n",
    "print \"Number of units taken per annum = \",round(x1,2),\"kWh.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.41 , PAGE NO :- 1976"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Cost per unit at unity p.f =  7.42 paise\n",
      "Cost per unit at 0.7 p.f =  8.89 paise\n"
     ]
    }
   ],
   "source": [
    "'''If power is charged for at the rate of Rs. 75 per kVA of maximum demand and 4 paisa per unit, what is the cost per unit at\n",
    "25% yearly load factor (a) for unity power factor demand and (b) for 0.7 power factor demand.'''\n",
    "\n",
    "#Given\n",
    "lf = 0.25                #      (load factor)\n",
    "charge = 75.0            #Rs    (Cost per kVA of max. demand)\n",
    "\n",
    "#(a) At unity power factor\n",
    "#Max. demand charge per unit\n",
    "cost1 = charge/(8760*0.25)*100        #paise\n",
    "#Cost per unit\n",
    "tot_cost = cost1 + 4.0                #paise\n",
    "print \"Cost per unit at unity p.f = \",round(tot_cost,2),\"paise\"\n",
    "\n",
    "#(b) At 0.7 power factor\n",
    "#Max. demand charge per unit\n",
    "cost2 = charge/(8760*0.25*0.7)*100        #paise\n",
    "#Cost per unit\n",
    "tot_cost = cost2 + 4.0                #paise\n",
    "print \"Cost per unit at 0.7 p.f = \",round(tot_cost,2),\"paise\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.42 , PAGE NO :- 1976"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Total savings in annual bill = Rs.  69.44\n",
      "Total cost per unit at 0.6 load factor =  11.19 paise.\n",
      "Total cost per unit at 0.8 load factor =  10.89 paise.\n",
      "Cost per unit is reduced with increase in lf.\n"
     ]
    }
   ],
   "source": [
    "'''Explain different methods of tariff. A tariff in force is Rs. 50 per kVA of max. demand per year plus 10 p per kWh.\n",
    "A consumer has a max. demand of 10 kW with a load factor of 60% and p.f. 0.8 lag.\n",
    "(i)  Calculate saving in his annual bill if he improves p.f. to 0.9 lag.\n",
    "(ii) Show the effect of improving load factor to 80% with the same max. demand and p.f. 0.8 lag\n",
    "on the total cost per kWh.'''\n",
    "\n",
    "#Given\n",
    "maxp = 10.0         #kW      (Maximum demand)\n",
    "\n",
    "#(i)\n",
    "max_kva = maxp/0.8  #kVA     (Maximum demand in kVA)\n",
    "#Maximum demand charges\n",
    "charge1 = max_kva*(50.0)          #Rs\n",
    "\n",
    "max_kva2 = maxp/0.9 #kVA     (Maximum demand in kVA at 0.9 pf)\n",
    "#Maximum demand charges\n",
    "charge2 = max_kva2*(50.0)          #Rs\n",
    "\n",
    "#Since energy consumed is same,savings is due to reduction in M.D charges\n",
    "savings = charge1 - charge2        #Rs\n",
    "print \"Total savings in annual bill = Rs. \",round(savings,2)\n",
    "#------------------------------------------------------------------------------------------------------#\n",
    "#(ii)\n",
    "lf = 0.6                           #(load factor)\n",
    "#Avg demand = Max. demand * load factor\n",
    "avg_dem = maxp*lf                  #kW\n",
    "#No. of units consumed\n",
    "units = avg_dem*8760               #kWh\n",
    "#M.D charge per unit consumed\n",
    "md_unit = charge1/units*100.0      #Paise\n",
    "#Total charges\n",
    "tot_cost1 = 10.0 + md_unit          #paise\n",
    "\n",
    "print \"Total cost per unit at 0.6 load factor = \",round(tot_cost1,2),\"paise.\"\n",
    "\n",
    "lf = 0.8                           #(load factor)\n",
    "#Avg demand = Max. demand * load factor\n",
    "avg_dem = maxp*lf                  #kW\n",
    "#No. of units consumed\n",
    "units = avg_dem*8760               #kWh\n",
    "#M.D charge per unit consumed\n",
    "md_unit = charge1/units*100.0      #Paise\n",
    "#Total charges\n",
    "tot_cost2 = 10.0 + md_unit          #paise\n",
    "\n",
    "print \"Total cost per unit at 0.8 load factor = \",round(tot_cost2,2),\"paise.\"\n",
    "\n",
    "if (tot_cost1 > tot_cost2):\n",
    "    print \"Cost per unit is reduced with increase in lf.\"\n",
    "else:\n",
    "    print \"Cost per unit is increase with increase in lf.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.43 , PAGE NO :- 1977"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Annual charges in (a) = Rs. 8154.0\n",
      "Annual charges in (b) = Rs. 8608.0\n",
      "(a) is economical.\n"
     ]
    }
   ],
   "source": [
    "'''A consumer has a maximum demand (M.D.) of 20 kW at 0.8 p.f. lagging and an annual load factor of 60%. There are two\n",
    "alternative tariffs (i) Rs. 200 per kVA of M.D. plus 3p per kWh consumed and (ii) Rs. 50 per kVA of M.D. plus 7p per kWh\n",
    "consumed. Determine which of the tariffs will be economical for him.'''\n",
    "\n",
    "\n",
    "#Given\n",
    "maxp = 20.0        #kW             (Maximum demand)\n",
    "lf = 0.6           #               (load factor)\n",
    "\n",
    "#Maximum demand in kVA\n",
    "max_kva = maxp/0.8      #kVA\n",
    "#Average power = Max. demand * load factor\n",
    "avg_pwr = maxp*lf       #kW\n",
    "#Energy consumed in a year\n",
    "units = avg_pwr*8760        #kWh\n",
    "#(a)\n",
    "charge1 = 200.0*max_kva     #Rs      (Max. demand charge)\n",
    "charge2 = (3.0/100)*units   #Rs      (Units consumption charge)\n",
    "#Total charges\n",
    "tot_costa = charge1 + charge2    #Rs\n",
    "print \"Annual charges in (a) = Rs.\",round(tot_costa)\n",
    "\n",
    "#(b)\n",
    "charge1 = 50*max_kva     #Rs      (Max. demand charge)\n",
    "charge2 = (7.0/100)*units   #Rs      (Units consumption charge)\n",
    "#Total charges\n",
    "tot_costb = charge1 + charge2    #Rs\n",
    "print \"Annual charges in (b) = Rs.\",round(tot_costb)\n",
    "\n",
    "if (tot_costa > tot_costb):\n",
    "    print \"(b) is economical.\"\n",
    "else:\n",
    "    print \"(a) is economical.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## EXAMPLE 50.44 , PAGE NO :- 1977"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Load Factor =  0.55\n"
     ]
    }
   ],
   "source": [
    "'''Determine the load factor at which the cost of supplying a unit of electricity from a Diesel station and from a steam\n",
    "station is the same if the respective annual fixed and running charges are as follows.\n",
    "Station                    Fixed charges                        Running charges\n",
    "Diesel                     Rs. 300 per kW                       25 paise/kWh\n",
    "Steam                      Rs. 1200 per kW                      6.25 paise/kWh .'''\n",
    "\n",
    "from sympy import Symbol,Eq,solve\n",
    "#(i)Diesel Station\n",
    "#Suppose that the energy supplied in one year is one unit(1 kWh)\n",
    "#Annual average power is\n",
    "avg_pwr = 1.0/8760      #kW\n",
    "\n",
    "#Annual load factor(L) = Annual average power/Annual max. demand\n",
    "L = Symbol('L')\n",
    "maxp = avg_pwr/L      #kW\n",
    "fxd_charge = 300.0*(maxp)*100         #Paise\n",
    "run_charge = 25.0                     #Paise\n",
    "#Total charge\n",
    "tot_charge1 = fxd_charge + run_charge  #Paise\n",
    "#(ii)Steam Station\n",
    "fxd_charge = 1200.0*(maxp)*100         #Paise\n",
    "run_charge = 6.25                      #Paise\n",
    "#Total charge\n",
    "tot_charge2 = fxd_charge + run_charge  #Paise\n",
    "\n",
    "eq = Eq(tot_charge1,tot_charge2)\n",
    "L = solve(eq)         \n",
    "L1 = L[0]\n",
    "print \"Load Factor = \",round(L1,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.45 , PAGE NO :- 1978"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Total charge per unit =  6.69 paise.\n",
      "Total Savings = Rs. 525.0\n"
     ]
    }
   ],
   "source": [
    "'''A factory has a maximum load of 300 kW at 0.72 p.f. with an annual consumption of 40,000 units, the tariff is\n",
    "Rs. 4.50 per kVA of maximum demand plus 2 paisa/unit. Find out the average price per unit. What will be the annual\n",
    "saving if the power factor be improved to units ? '''\n",
    "\n",
    "#Given\n",
    "maxp = 300.0            #kW            (Maximum demand)\n",
    "pf = 0.72               #              (Power factor)\n",
    "units = 40000.0         #kWh           (No of units consumed)\n",
    "#Maximum demand in kVA\n",
    "max_kva = maxp/pf       #kVA\n",
    "\n",
    "#Max. KVA demand charge\n",
    "charge1 = 4.5*max_kva   #Rs\n",
    "#M.D charge per unit\n",
    "md_unit = charge1/units*100   #paise\n",
    "\n",
    "#Total charge per unit\n",
    "tot_charge = md_unit + 2.0    #paise\n",
    "print \"Total charge per unit = \",round(tot_charge,2),\"paise.\"\n",
    "\n",
    "#Maximum demand in kVA at unity power factor\n",
    "max_kva = maxp       #kVA\n",
    "\n",
    "#Max. KVA demand charge\n",
    "charge2 = 4.5*max_kva   #Rs\n",
    "\n",
    "#Total savings is\n",
    "saving = charge1 - charge2  #Rs\n",
    "print \"Total Savings = Rs.\",saving"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.46 , PAGE NO :- 1978"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Total cost/hr for lamp 1 =  0.49 paise.\n",
      "Total cost/hr for lamp 2 =  0.61 paise.\n",
      "Therefore,Lamp 1 is advantageous.\n",
      "Both lamp will be equally advantageous at load factor  = 0.282\n"
     ]
    }
   ],
   "source": [
    "'''There is a choice of two lamps, one costs Rs. 1.2 and takes 100 W and the other costs Rs. 5.0 and takes 30 W ;\n",
    "each gives the same candle power and has the same useful life of 1000 hours. Which will prove more economical with\n",
    "electrical energy at Rs. 60 per annum per kW of maximum demand plus 3 paise per unit ? At what load factor would\n",
    "they be equally advantageous? '''\n",
    "\n",
    "from sympy import Symbol,Eq,solve\n",
    "\n",
    "#(i)First Lamp\n",
    "#Initial cost per hour\n",
    "charge11 = 120.0/1000                   #Paise\n",
    "#Maximum demand/hr\n",
    "maxp = 0.1                             #kW\n",
    "#Maximum demand charge/hr\n",
    "charge21 = (60.0*maxp/8760)*100          #Paise\n",
    "#Energy charge/hr\n",
    "charge31 = 3*maxp                        #Paise\n",
    "\n",
    "#Total cost/hr\n",
    "tot_cost1 = charge11 + charge21 + charge31 #Paise\n",
    "\n",
    "print \"Total cost/hr for lamp 1 = \",round(tot_cost1,2),\"paise.\"\n",
    "#-----------------------------------------------------------------------------#\n",
    "\n",
    "#(ii)Second Lamp\n",
    "#Initial cost per hour\n",
    "charge12 = 500.0/1000                   #Paise\n",
    "#Maximum demand/hr\n",
    "maxp = 0.03                             #kW\n",
    "#Maximum demand charge/hr\n",
    "charge22 = (60.0*maxp/8760)*100          #Paise\n",
    "#Energy charge/hr\n",
    "charge32 = 3*maxp                        #Paise\n",
    "\n",
    "#Total cost/hr\n",
    "tot_cost2 = charge12 + charge22 + charge32 #Paise\n",
    "print \"Total cost/hr for lamp 2 = \",round(tot_cost2,2),\"paise.\"\n",
    "\n",
    "if (tot_cost1 > tot_cost2):\n",
    "    print \"Therefore,Lamp 2 is advantageous.\"\n",
    "else:\n",
    "    print \"Therefore,Lamp 1 is advantageous.\"\n",
    "\n",
    "#As Maximum demand charge will only vary with load factor and it varies inversely\n",
    "#with maximum demand charge\n",
    "\n",
    "x = Symbol('x')\n",
    "tot_cost1 = charge11 + charge21/x + charge31 #Paise\n",
    "tot_cost2 = charge12 + charge22/x + charge32 #Paise\n",
    "\n",
    "eq = Eq(tot_cost1,tot_cost2)\n",
    "x = solve(eq)\n",
    "x1 = x[0]\n",
    "print \"Both lamp will be equally advantageous at load factor  =\",round(x1,3)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## EXAMPLE 50.47 , PAGE NO :- 1979"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Annual Load factor =  0.437\n"
     ]
    }
   ],
   "source": [
    "'''The following data refers to a public undertaking which supplies electric energy to its consumers at a fixed tariff of 11.37 \n",
    "paise per unit.Total installed capacity = 344 MVA ; Total capital investment = Rs. 22.4 crores;\n",
    "Annual recurring expenses = Rs. 9.4 crores ; Interest charge = 6% ; depreciation charge = 5%\n",
    "Estimate the annual load factor at which the system should operate so that there is neither profit nor loss to the undertaking.\n",
    "Assume distribution losses at 7.84% and the average system p.f. at 0.86.'''\n",
    "\n",
    "from sympy import Symbol,solve,Eq\n",
    "#Given\n",
    "capacity = 344.0e+3            #kVA          (installed capacity)\n",
    "cap_cost = 22.4e+7             #Rs           (capital cost)\n",
    "pf = 0.86                      #             (power factor)\n",
    "\n",
    "#Load factor (L) = No of kWh (units)supplied/Max. no of kWh(units) that can be supplied\n",
    "L = Symbol('L')\n",
    "units = (capacity*pf)*8760*L    #kWh         (No. of units supplied)\n",
    "#Considering distribution losses,actual units supplied are\n",
    "units = (1-7.84/100)*units      #kWh\n",
    "#Total amount for consumption of units\n",
    "cost1 = units*(11.37/100)     #Rs\n",
    "\n",
    "\n",
    "\n",
    "#Fixed charges\n",
    "charge1 = (11.0/100)*cap_cost      #Rs (interest and depreciation cost)\n",
    "charge2 = 9.4e+7                   #Rs\n",
    "cost2 = charge1 + charge2          #Rs\n",
    "#As both charges should be equal for no profit no gain\n",
    "eq = Eq(cost1,cost2)\n",
    "L = solve(eq)\n",
    "L1 = L[0]\n",
    "print \"Annual Load factor = \",round(L1,3)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## EXAMPLE 50.48 , PAGE NO :- 1979"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Cost per unit for Steam station =  8.81 Paise.\n",
      "Cost per unit for Nuclear station =  8.09 Paise.\n",
      "Load factor =  0.34\n"
     ]
    }
   ],
   "source": [
    "'''An area has a M.D. of 250 MW and a load factor of 45%. Calculate the overall cost per unit generated by\n",
    "(i) steam power station with 30 per cent reserve generating capacity and\n",
    "(ii) nuclear station with no reserve capacity.\n",
    "Steam station :         Capital cost per kW = Rs. 1000 ; interest and depreciation on capital costs =15% ;\n",
    "                        operating cost per unit = 5 paise.\n",
    "\n",
    "Nucelar station :       Capital cost per kW = Rs. 2000 ; interest and depreciation on capital cost =12% ;\n",
    "                        operating cost per unit = 2 paise.\n",
    "For which load factor will the overall cost in the two cases become equal ?'''\n",
    "\n",
    "from sympy import Symbol,solve,Eq\n",
    "\n",
    "#(i)Steam station\n",
    "#Installed capacity of steam station with 30% reserve capacity\n",
    "capacity1 = (250.0e+3)*(1 + 30.0/100)                #kW\n",
    "#Average power  = Max. demand * load factor\n",
    "avg_pwr = capacity1*0.45                              #kW\n",
    "#No. of units produced in a year\n",
    "units = avg_pwr*8760                                #kWh\n",
    "#Capital investment\n",
    "cap_cost = 1000.0*capacity1                          #Rs\n",
    "#Annual interest and depreciation\n",
    "charge1 = (0.15)*cap_cost                           #Rs\n",
    "#Fixed charge/unit\n",
    "cost_unit = charge1/units*100                       #Paise\n",
    "#Overall cost per unit\n",
    "tot_cost = cost_unit + 5.0                          #Paise\n",
    "print \"Cost per unit for Steam station = \",round(tot_cost,2),\"Paise.\"\n",
    "#-------------------------------------------------------------------------------------------------------------#\n",
    "\n",
    "#(ii)Nuclear station\n",
    "#Installed capacity of steam station with 30% reserve capacity\n",
    "capacity2 = (250.0e+3)                               #kW\n",
    "#Average power  = Max. demand * load factor\n",
    "avg_pwr = capacity2*0.45                              #kW\n",
    "#No. of units produced in a year\n",
    "units = avg_pwr*8760                                #kWh\n",
    "#Capital investment\n",
    "cap_cost = 2000.0*capacity2                          #Rs\n",
    "#Annual interest and depreciation\n",
    "charge2 = (0.12)*cap_cost                           #Rs\n",
    "#Fixed charge/unit\n",
    "cost_unit = charge2/units*100                       #Paise\n",
    "#Overall cost per unit\n",
    "tot_cost = cost_unit + 2                          #Paise\n",
    "print \"Cost per unit for Nuclear station = \",round(tot_cost,2),\"Paise.\"\n",
    "#---------------------------------------------------------------------------------------------------------------#\n",
    "\n",
    "#Let L be the load factor\n",
    "L = Symbol('L')\n",
    "\n",
    "#Cost per unit of steam station is\n",
    "stm_cost = charge1/(capacity1*8760*L)*100  + 5     #Paise\n",
    "\n",
    "#Cost per unit of nuclear station is\n",
    "nuc_cost = charge2/(capacity2*8760*L)*100  + 2     #Paise\n",
    "\n",
    "#As overall cost should be equal\n",
    "eq = Eq(stm_cost,nuc_cost)\n",
    "L  = solve(eq)\n",
    "L1 = L[0]\n",
    "print \"Load factor = \",round(L1,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.49 , PAGE NO :- 1980"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Annual Bill = Rs. 900.0\n",
      "Equivalent flat rate =  9.23 Paise.\n"
     ]
    }
   ],
   "source": [
    "'''The maximum demand of a customer is 25 amperes at 220 volt and his total energy consumption is 9750 kWh. If the\n",
    "energy is charged at the rate of 20 paise per kWh for 500 hours' use of the maximum demand plus 5 paise power unit\n",
    "for all additional units, estimate his annual bill and the equivalent flat rate.'''\n",
    "\n",
    "#Given\n",
    "maxp = 25.0*220.0/1000           #kW    (Max. demand)\n",
    "units = maxp*500.0               #kWh   (No. of units consumed)\n",
    "charge1 = units*(20.0/100)       #Rs    (Max. demand charge)\n",
    "\n",
    "#Units to be charged at lower rate\n",
    "units2 = 9750.0 - units          #kWh\n",
    "charge2 = units2*(5.0/100)       #Rs    (Charge)\n",
    "\n",
    "#Annual Bill is\n",
    "bill = charge1 + charge2         #Rs\n",
    "\n",
    "#Equivalent flat rate\n",
    "rate = bill/9750.0*100           #Paise\n",
    "print \"Annual Bill = Rs.\",bill\n",
    "print \"Equivalent flat rate = \",round(rate,2),\"Paise.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.50 , PAGE NO :- 1980"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Amount that can be borrowed  = Rs. 125000.0\n"
     ]
    }
   ],
   "source": [
    "'''A workshop having a number of induction motors has a maximum demand of 750 kW with a power factor of 0.75 and a\n",
    "load factor of 35%. If the tariff is Rs. 75 per annum per kVA of maximum demand plus 3 paise per unit, estimate what\n",
    "expenditure would it pay to incur to raise the power factor of 0.9.'''\n",
    "\n",
    "#Given\n",
    "maxp = 750.0           #kW      (Maximum demand)\n",
    "max_kva = maxp/0.75    #kVA     (Maximum demand in kVA)\n",
    "\n",
    "#Max. demand charge\n",
    "charge1 = max_kva*75  #Rs\n",
    "\n",
    "#If pf = 0.9\n",
    "max_kva2 = maxp/0.9    #kVA     (Maximum demand in kVA)\n",
    "\n",
    "#Max. demand charge\n",
    "charge2 = max_kva2*75  #Rs\n",
    "\n",
    "#Difference of amounts in one year\n",
    "cost = charge1 - charge2     #Rs\n",
    "\n",
    "#Assuming interest of 10% . The capital cost that can be put to increase power factor is\n",
    "# cost = (10.0/100)*cap_cost\n",
    "\n",
    "cap_cost = (100.0/10)*cost   #Rs\n",
    "print \"Amount that can be borrowed  = Rs.\",cap_cost"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.51 , PAGE NO :- 1981"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Public supply charges per unit =  6.3 Paise.\n",
      "Private supply charges per unit =  6.69 Paise.\n"
     ]
    }
   ],
   "source": [
    "'''The owner of a new factory is comparing a private oil-engine generating station with public supply. Calculate the average\n",
    "price per unit his supply would cost him in each case, using the following data :\n",
    "\n",
    "Max. demand, 600 kW; load factor, 30% ; supply tariff, Rs. 70 per kW of maximum demand plus 3 paise per unit;\n",
    "capital cost of plant required for public supply, Rs. 105; capital cost of plant required for private generating station,\n",
    "Rs. 4 * 10^5 ; cost of fuel, Rs. 80 per tonne ; consumption of fuel oil; 0.3 kg per unit generated. Other work costs for\n",
    "private plant are as follows : lubricating oil,stores and water = 0.35 paise per unit generated ; wages 1.1 paise ;\n",
    "repairs and maintenance 0.3 paise per unit.'''\n",
    "\n",
    "\n",
    "#Given\n",
    "maxp = 600.0            #kW    (Maximum demand)\n",
    "lf = 0.3                #      (load factor)\n",
    "\n",
    "avg_pwr =  maxp * lf    #kW    (Average demand = Max demand * load factor)\n",
    "units = avg_pwr*8760    #kWh   (Energy consumption)\n",
    "\n",
    "#(i)Public supply\n",
    "fxd_charge = 70.0*maxp  #Rs    (Fixed annual charges)\n",
    "cap_charge = (10.0/100)*1.0e+5 #Rs  (Capital annual charges)\n",
    "\n",
    "tot_charge = fxd_charge + cap_charge #Rs         (Total annual charges)\n",
    "fxdcost_unit = tot_charge/units*100    #Paise      (Fixed cost per unit)\n",
    "totcost_unit = fxdcost_unit + 3.0       #Paise      (Total cost per unit)\n",
    "print \"Public supply charges per unit = \",round(totcost_unit,2),\"Paise.\"\n",
    "#--------------------------------------------------------------------------------------------------#\n",
    "#(ii)Private supply\n",
    "cap_charge = (10.0/100)*4.0e+5 #Rs  (Capital annual charges)\n",
    "fxdcost_unit = cap_charge/units*100    #Paise      (Fixed cost per unit)\n",
    "oilcost_unit = (80.0/1000)*(0.3)*100   #Paise      (Oil cost per unit)\n",
    "runcost_unit = 0.35 + 0.3 + 1.1        #Paise      (Running cost per unit)\n",
    "totcost_unit = runcost_unit + oilcost_unit + fxdcost_unit  #Paise      (Total cost per unit)\n",
    "print \"Private supply charges per unit = \",round(totcost_unit,2),\"Paise.\"\n",
    "#--------------------------------------------------------------------------------------------------#\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.52 , PAGE NO :- 1981"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Therefore minimum charges are Rs 4.17 per kW and 4.0 paise per kWh consumed.\n"
     ]
    }
   ],
   "source": [
    "'''Calculate the minimum two-part tariff to be charged to the consumers of a supply undertaking from the following data :\n",
    "Generating cost per kWh; 3.6 paise ; Generating cost per kW of maximum demand, Rs. 50 Total energy generated per year ;\n",
    "4,380 * 10^4 kWh Load factor at the generating station, 50%             Annual charges for distribution Rs. 125,000\n",
    "Diversity factor for the distribution network, 1.25                     Total loss between station and consumer, 10%.'''\n",
    "\n",
    "#Given\n",
    "units = 4380.0e+4                         #kWh      (No of units consumed in a year)\n",
    "lf = 0.5                                  #         (Load factor)\n",
    "df = 1.25                                 #         (Diversity factor)\n",
    "avg_pwr = units/8760                      #kW       (Average generating power)\n",
    "maxp = avg_pwr/lf                         #kW       (Max. load on generator   , lf = Avg Power/Max Power)\n",
    "\n",
    "#Annual fixed charges are\n",
    "charges = maxp*50                         #Rs\n",
    "#Total fixed charges are\n",
    "tot_charges = charges + 125000            #Rs\n",
    "#Consumer's Max demand is\n",
    "max_dem = maxp*df                         #kW\n",
    "\n",
    "#Cost per kW of Max demand is\n",
    "cost_kw = tot_charges/max_dem             #Rs\n",
    "#Monthly cost per kW of maximum demand is\n",
    "cost_kw = cost_kw/12                      #Rs\n",
    "\n",
    "\n",
    "#Since there are 10% losses ,energy reached to consumers per kWh is\n",
    "units =   1*(1-0.1)                  #kWh\n",
    "#Charges per kWh generated is\n",
    "charge1 = 3.6/units                  #Paise\n",
    "print \"Therefore minimum charges are Rs\",round(cost_kw,2),\"per kW and\",round(charge1,2),\"paise per kWh consumed.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.53 , PAGE NO :- 1982"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "High-voltage is cheaper by =  618.75 Rs.\n"
     ]
    }
   ],
   "source": [
    "'''Two systems of tariffs are available for a factory working 8 hours a day for 300 working days in a year.\n",
    "(a) High-voltage supply at 5 paise per unit plus Rs. 4.50 per month per kVA of maximum demand.\n",
    "(b) Low-voltage supply at Rs. 5 per month per kVA of maximum demand plus 5.5 paise per unit.\n",
    "     The factory has an average load of 200 kW at 0.8 power factor and a maximum demand of\n",
    "     250 kW at the same p.f.\n",
    "The high-voltage equipment costs Rs. 50 per kVA and losses can be taken as 4 per cent. Interest and depreciation charges\n",
    "are 12 per cent. Calculate the difference in the annual cost between the two systems.'''\n",
    "\n",
    "#Given\n",
    "maxp = 250.0                    #kW           (Maximum demand)\n",
    "avg_dem = 200.0                 #kW           (Average demand)\n",
    "pf = 0.8                        #             (power factor)\n",
    "max_kva = maxp/pf               #kVA          (Maximum demand in kVA)\n",
    "max_kva = (100.0/96)*max_kva    #kVA          (considering losses)\n",
    "#(a)\n",
    "#Annual interest on capital investment\n",
    "charge1 = max_kva*50.0*0.12                  #Rs\n",
    "\n",
    "#Annual charge due to kVA max. demand is\n",
    "charge2 = max_kva*12*4.5                     #Rs\n",
    "\n",
    "#Annual charge due to kWh consumption\n",
    "charge3 = avg_dem*(100.0/96)*(5.0/100)*8*300 #Rs\n",
    "\n",
    "#Total charges\n",
    "tot_chargesa = charge1 + charge2 + charge3    #Rs\n",
    "#------------------------------------------------------------------#\n",
    "#(b)\n",
    "#Annual charge due to kVA max. demand is\n",
    "charge1 = maxp/pf*12*5                    #Rs\n",
    "\n",
    "#Annual charge due to kWh consumption\n",
    "charge2 = avg_dem*(5.5/100)*8*300         #Rs\n",
    "\n",
    "#Total charges\n",
    "tot_chargesb = charge1 + charge2           #Rs\n",
    "\n",
    "#Hence high-voltage is cheaper by\n",
    "cost = tot_chargesb - tot_chargesa         #Rs\n",
    "\n",
    "print \"High-voltage is cheaper by = \",round(cost,2),\"Rs.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## EXAMPLE 50.54 , PAGE NO :- 1982"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Number of units consumed =  2400.0 units.\n"
     ]
    }
   ],
   "source": [
    "'''Estimate what the consumption must be in order to justify the following maximum demand tariff in preference to the flat\n",
    "rate if the maximum demand is 6 kW.On Maximum Demand Tariff. A  max. demand rate of 37 paise per unit for the first 200 hr. at the\n",
    "maximum demand rate plus 3 paisa for all units in excess.Flat-rate tariff, 20 paise per unit.'''\n",
    "\n",
    "from sympy import Symbol,solve,Eq\n",
    "#Let x = number of units to be consumed (within a specific period)\n",
    "x = Symbol('x')\n",
    "\n",
    "#Units consumed at max. demand rate\n",
    "units = 6 * 200.0            #kWh\n",
    "#Units in excess of the max. demand units\n",
    "excess = (x - 1200)          #kWh  \n",
    "#Cost of max. demand units is\n",
    "cost = units*37              #Paise\n",
    "#Cost of excess units\n",
    "cost_excss = 3.0*(excess)    #Paise\n",
    "#Total cost on tariff\n",
    "tot_cost1 = cost + cost_excss #Paise\n",
    "\n",
    "\n",
    "#Flat rate tariff\n",
    "tot_cost2 = 20*x              #Paise\n",
    "\n",
    "eq = Eq(tot_cost1,tot_cost2)\n",
    "x  = solve(eq)\n",
    "x1 = x[0]\n",
    "print \"Number of units consumed = \",round(x1,2),\"units.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.55 , PAGE NO :- 1986"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Current density =  41.12 A/cm^2\n"
     ]
    }
   ],
   "source": [
    "'''If the cost of an overhead line is Rs. 2000 A (where A is the cross-sectional area in cm^2) and if the interest and depreciation\n",
    "charges on the line are 8%, estimate the most economical current density to use for a transmission requiring full-load current for\n",
    "60% of the year.The cost of generating electric energy is 5 paise/kWh. The resistance of a conductor one kilometre long and \n",
    "1 cm^2 cross-section is 0.18 ohm.'''\n",
    "\n",
    "from sympy import Symbol,solve,Eq\n",
    "\n",
    "#Given\n",
    "A = 1.0                           #cm^2\n",
    "R = 0.18                          #ohm\n",
    "#Let the current through the overhead line be I\n",
    "I = Symbol('I')\n",
    "#Power loss in line is\n",
    "loss = 2*(I*I)*R/1000             #kW\n",
    "\n",
    "#No. of units consumed\n",
    "units = loss*(0.6)*(365*24)       #kWh\n",
    "\n",
    "#Annual charges\n",
    "charge = units*0.05               #Rs\n",
    "\n",
    "#Interest and depreciation charges\n",
    "charge2 = (8.0/100)*2000         #Rs\n",
    "\n",
    "#Equating two charges\n",
    "eq = Eq(charge,charge2)\n",
    "I = solve(eq)\n",
    "I1 = I[1]                        #A\n",
    "#Current density\n",
    "J = I1/A                         #A/cm^2\n",
    "print \"Current density = \",round(J,2),\"A/cm^2\"\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.56 , PAGE NO :- 1986"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Most economical cross-section is =  0.446 cm^2.\n"
     ]
    }
   ],
   "source": [
    "'''A 500-V, 2-core feeder cable 4 km long supplies a maximum current of 200 A and the demand is such that the copper\n",
    "loss per annum is such as would be produced by the full-load current flowiing for six months. The resistance of the\n",
    "conductor 1 km long and 1 sq cm. cross-sectional area is 0.17 ohm. The cost of cable including installation is\n",
    "Rs. (120 A + 24) per metre where A is the area of cross-section in sq. cm and interest and depreciation charges are\n",
    "10%. The cost of energy is 4 paise per kWh. Find the most economical cross-section.'''\n",
    "\n",
    "from sympy import Symbol,solve,Eq\n",
    "\n",
    "#Let us consider 1 km length of feeder cable\n",
    "#Also, let A be the area of cross-section\n",
    "A = Symbol('A')\n",
    "\n",
    "#Cable cost/metre\n",
    "cab_cost = 120.0*A + 24                          #Rs\n",
    "#Cost of 1km long cable\n",
    "cost1 = 120.0*A*(1000)                           #Rs\n",
    "#Interest and depreciation per annum\n",
    "charge1 = (10.0/100)*cost1                       #Rs\n",
    "\n",
    "#Resistance of 1km long cable is\n",
    "res = 0.17/A                                     #ohm\n",
    "#Cu loss in cable = 2*I^2*R\n",
    "I = 200.0                                        #A\n",
    "loss = 2*(I*I)*res/1000                          #kW\n",
    "#Energy loss over 6 months\n",
    "units = loss*(8760.0/2)                          #kWh\n",
    "#Cost of this energy loss is\n",
    "charge2 = 0.04*units                             #Rs\n",
    "#For most economical cross-section charge1= charge2\n",
    "eq = Eq(charge1,charge2)\n",
    "A = solve(eq)\n",
    "A1 = A[1]                                        #cm^2\n",
    "print \"Most economical cross-section is = \",round(A1,3),\"cm^2.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.57 , PAGE NO :- 1987"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The most economical cross-sectional area is =  0.23 cm^2.\n",
      "The most economical diameter is =  0.54 cm.\n"
     ]
    }
   ],
   "source": [
    "'''A 2-core, 11-kV cable is to supply 1 MW at 0.8 p.f. lag for 3000 hours in a year. Capital cost of the cable is\n",
    "Rs. (20 + 400a) per metre where a is the cross-sectional area of core in cm^2. Interest and depreciation total 10% and cost\n",
    "per unit of energy is 15 paise. If the length of the cable is 1 km, calculate the most economical cross-section of the\n",
    "conductor. The specific resistance of copper is 1.75 * 10^–6 ohm-cm.'''\n",
    "\n",
    "from sympy import Symbol,solve,Eq\n",
    "import math as m\n",
    "\n",
    "#Let A be the cross-sectional area of core\n",
    "A = Symbol('A')          \n",
    "#Cost of 1 km length of cable\n",
    "cost1 = (400.0*A)*1000                #Rs\n",
    "#Resistance of 1km cable length is  R = rho*l/A\n",
    "res = 1.75e-6*(1000*100)/A                   #ohm\n",
    "\n",
    "#Now,\n",
    "V = 11.0e+3           #V    (applied voltage)\n",
    "P = 1.0e+6             #W    (power consumed)\n",
    "pf = 0.8               #     (power factor) \n",
    "\n",
    "#P = V*I*pf.Therefore, full-load current is\n",
    "I = P/(V*pf)           #A\n",
    "\n",
    "#Power loss in cable\n",
    "loss = 2*(I*I)*res     #W\n",
    "\n",
    "#Annual cost of energy loss\n",
    "charge1 = loss*(3000)*(15.0/100)*(1/1000.0)       #Rs\n",
    "#Interest and depreciation per annum\n",
    "charge2 = (10.0/100)*cost1                        #Rs\n",
    "\n",
    "#The most economical cross-section will be when charge1 = charge2\n",
    "eq = Eq(charge1,charge2)\n",
    "A = solve(eq)\n",
    "A1 = A[1]                     #cm^2\n",
    "d = m.sqrt(4*A1/3.14)          #cm            (diameter)  \n",
    "print \"The most economical cross-sectional area is = \",round(A1,2),\"cm^2.\"\n",
    "print \"The most economical diameter is = \",round(d,2),\"cm.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.58 , PAGE NO :- 1988"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Most economical cross-section is =  0.55 cm^2.\n"
     ]
    }
   ],
   "source": [
    "'''The cost of a two-core feeder cable including insulation is Rs. (130 A + 24) per metre and the interest and depreciation\n",
    "charges 10% per annum. The cable is two km in length and the cost of energy is 4 paisa per unit. The maximum current in the\n",
    "feeder is 250 amperes and the demand is such that the copper loss is equal to that which would be produced by the full current\n",
    "flowing for six months. If the resistance of a conductor of 1 sq. cm cross-sectional area and one km in length be 0.18 ohm,\n",
    "find the most economical section of the same.'''\n",
    "\n",
    "from sympy import Symbol,solve,Eq\n",
    "\n",
    "#Let us consider 1 km length of feeder cable\n",
    "#Also, let A be the area of cross-section\n",
    "A = Symbol('A')\n",
    "\n",
    "#Cable cost/metre\n",
    "cab_cost = 130.0*A + 24                          #Rs\n",
    "#Cost of 1km long cable\n",
    "cost1 = 130.0*A*(1000)                           #Rs\n",
    "#Interest and depreciation per annum\n",
    "charge1 = (10.0/100)*cost1                       #Rs\n",
    "\n",
    "#Resistance of 1km long cable is\n",
    "res = 0.18/A                                     #ohm\n",
    "#Cu loss in cable = 2*I^2*R\n",
    "I = 250.0                                        #A\n",
    "loss = 2*(I*I)*res/1000                          #kW\n",
    "#Energy loss over 6 months\n",
    "units = loss*(8760.0/2)                          #kWh\n",
    "#Cost of this energy loss is\n",
    "charge2 = 0.04*units                             #Rs\n",
    "#For most economical cross-section charge1= charge2\n",
    "eq = Eq(charge1,charge2)\n",
    "A = solve(eq)\n",
    "A1 = A[1]                                        #cm^2\n",
    "print \"Most economical cross-section is = \",round(A1,2),\"cm^2.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.59 , PAGE NO :- 1988"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Most economical cross-sectional area is =  0.1 cm^2.\n",
      "Most economical current density is =  230.94 A/cm^2.\n",
      "Most economical diameter is =  0.36 cm.\n"
     ]
    }
   ],
   "source": [
    "'''An 11-kV, 3-core cable is to supply a works with 500-kW at 0.9 p.f. lagging for 2,000 hours p.a. Capital cost of the cable per\n",
    "core when laid is Rs. (10,000 + 32,00 A) per km where A is the cross-sectional area of the core in sq. cm. The resistance per km\n",
    "of conductor of 1 cm^2 crosssection is 0.16 ohm.If the energy losses cost 5 paise per unit and the interest and sinking fund is\n",
    "recovered by a charge of 8% p.a., calculate the most economical current density and state the conductor diameter.'''\n",
    "\n",
    "from sympy import Symbol,solve,Eq\n",
    "import math as m\n",
    "\n",
    "#Let A be the cross-sectional area of conductor\n",
    "A = Symbol('A')\n",
    "#The annual charge on cost of conductor per km is\n",
    "charge1 = 0.08*32000.0*A                          #Rs\n",
    "#Current per conductor is I = P/V*pf\n",
    "I = (500000/1.73)/(11000.0)*(0.9)\n",
    "#Resistance of conductor is\n",
    "R = 0.16/A                #ohm\n",
    "\n",
    "#Losses in 3-core cable\n",
    "loss = 3*(I*I)*R/1000.0             #kW\n",
    "\n",
    "#Annual cost of this loss\n",
    "charge2 = loss*(5.0/100)*2000       #Rs\n",
    "\n",
    "#For the most economical cross-section  (charge1 = charge2)\n",
    "eq = Eq(charge1,charge2)\n",
    "A = solve(eq) \n",
    "A1 = A[1]                            #cm^2\n",
    "#Current density is\n",
    "J = I/A1                             #A/cm^2\n",
    "#Conductor diameter is   Using pi*d^2/4 = A\n",
    "d = m.sqrt(A1*4/3.14)                #cm\n",
    "print \"Most economical cross-sectional area is = \",round(A1,2),\"cm^2.\"\n",
    "print \"Most economical current density is = \",round(J,2),\"A/cm^2.\"\n",
    "print \"Most economical diameter is = \",round(d,2),\"cm.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.60 , PAGE NO :- 1989"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Most economical cross-sectional area is =  0.63 cm^2.\n"
     ]
    }
   ],
   "source": [
    "'''Discuss limitations of the application of Kelvin’s law.An industrial load is supplied by a 3-phase cable from a sub-station\n",
    "at a distance of 6 km. The voltage at the load is 11 kV. The daily load cycle for six days in a week for the entire year\n",
    "is as given below :\n",
    "(i) 700 kW at 0.8 p.f. for 7 hours                                                   (ii) 400 kW at 0.9 p.f. for 3 hours,\n",
    "(iii) 88 kW at unity p.f. for 14 hours.\n",
    "Compute the most economical cross-section of conductors for a cable whose cost is Rs. (5000 A +1500) per km (including the\n",
    "cost of laying etc.). The tariff for the energy consumed at the load is Rs. 150 per annum per kVA of M.D. plus 5 paise per unit.\n",
    "Assume the rate of interest and depreciation as 15%. The resistance per km of the conductor is (0.173/A) ohm.'''\n",
    "\n",
    "from sympy import Symbol,solve,Eq\n",
    "\n",
    "#Let us assume cross-section of conductor to be 'A'\n",
    "A = Symbol('A')\n",
    "#Capital cost of the cable is\n",
    "cost1 = 6*5000.0*A                         #Rs\n",
    "#Annual cost of interest and depreciation\n",
    "charge1 = (15.0/100)*cost1                 #Rs\n",
    "\n",
    "#Resistance of conductor is\n",
    "R = 6*(0.173/A)                            #ohm\n",
    "\n",
    "#Line currents due to different loads      Using I = P/V*pf\n",
    "\n",
    "I1 = (700000.0/1.73)/(11.0e+3*0.8)        #A   \n",
    "I2 = (400000.0/1.73)/(11.0e+3*0.9)       #A\n",
    "I3 = (88000.0/1.73)/(11.0e+3*1)           #A\n",
    "\n",
    "#Corresponding energy loss per week        Using loss = 3*I*I*R\n",
    "loss1 = 3*(I1*I1)*R*(6*7)/1000                  #kWh\n",
    "loss2 = 3*(I2*I2)*R*(6*3)/1000                  #kWh\n",
    "loss3 = 3*(I3*I3)*R*(6*14)/1000                 #kWh\n",
    "\n",
    "#Total weekly loss is\n",
    "tot_loss = loss1 + loss2 + loss3               #kW\n",
    "#Annual cost from loss              \n",
    "cost2 = tot_loss*(52)*(5.0/100)                #Rs        (Assumed 52 weeks per year)\n",
    "\n",
    "#Max. Voltage drop in each conductor       Using V = I*R\n",
    "V = I1*R                    #V        (As I1 is Max.)\n",
    "#Max kVA demand charge\n",
    "cost3 = 3*V*I1*(150.0)/1000                    #Rs\n",
    "\n",
    "#Total annual charge due to cable loss is\n",
    "charge2 = cost2 + cost3                         #Rs\n",
    "\n",
    "#For most economical size of cable charge1 = charge2\n",
    "eq = Eq(charge1,charge2)\n",
    "A = solve(eq)\n",
    "A1 = A[1]\n",
    "print \"Most economical cross-sectional area is = \",round(A1,2),\"cm^2.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.61 , PAGE NO :- 1994"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Capacitance of each capacitor is = 157.03 uF.\n"
     ]
    }
   ],
   "source": [
    "'''A 3-phase, 50-Hz, 3,000-V motor develops 600 h.p. (447.6 kW), the power factor being 0.75 lagging and the efficiency\n",
    "0.93. A bank of capacitors is connected in delta across the supply terminals and power factor raised to 0.95 lagging.\n",
    "Each of the capacitance units is built of five similar 600-V capacitors. Determine capacitance of each capacitor.'''\n",
    "\n",
    "from sympy import Symbol,solve,Eq\n",
    "import math as m\n",
    "#Given\n",
    "V = 3000.0         #V      (supplied voltage)\n",
    "pout = 447600.0    #W      (output power)\n",
    "eff = 0.93         #       (efficiency)\n",
    "\n",
    "pin = pout/eff     #W      (input power)\n",
    "\n",
    "#As cosQ = power factor Q = cos-1(pf)\n",
    "phi1 = m.acos(0.75)           #      (angle 1)\n",
    "phi2 = m.acos(0.95)           #      (angle 2)\n",
    "\n",
    "#Now, taking tanQ of angles\n",
    "tan1 = m.tan(phi1)\n",
    "tan2 = m.tan(phi2)\n",
    "\n",
    "#Leading VAR supplied by capacitor bank is\n",
    "pvar = pin*(tan1 - tan2)      # VAR      \n",
    "#Leading VAR supplied by each capacitor bank is\n",
    "pvar = pvar/3                 # VAR        ----------------------(i)\n",
    "\n",
    "#Phase current of capacitor is I = V/Xc   where Xc = 1/w*C    C-> Capacitance\n",
    "C = Symbol('C')\n",
    "w = 2*3.14*50.0               #Hz\n",
    "Icp = V*w*C                   #A\n",
    "#Reactive power is V*Icp\n",
    "pvar2 = V*Icp                 #VAR         -----------------------(ii)\n",
    "#Equating (i) & (ii)\n",
    "eq = Eq(pvar,pvar2)\n",
    "C = solve(eq)\n",
    "C1 = C[0]*1000000.0           #uF      (capacitance)\n",
    "\n",
    "#As it is made of 5 capacitance in series\n",
    "cap_each = 5*C1                 #uF\n",
    "print \"Capacitance of each capacitor is =\",round(cap_each,2),\"uF.\" "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.62 , PAGE NO :- 1994"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Power factor =  0.87\n"
     ]
    }
   ],
   "source": [
    "'''A synchronous motor having a power consumption of 50 kW is connected in parallel with a load of 200 kW having a\n",
    "lagging power factor of 0.8. If the combined load has a p.f. of 0.9, what is the value of leading reactive kVA\n",
    "supplied by the motor and at what p.f. is it working?'''\n",
    "\n",
    "import math as m\n",
    "\n",
    "#Given\n",
    "phi2 = m.acos(0.8)            #(power factor angle of load)\n",
    "phit = m.acos(0.9)            #(combined power factor angle)\n",
    "\n",
    "#Now, taking tanQ of angles\n",
    "tan2 = m.tan(phi2)\n",
    "tant = m.tan(phit)\n",
    "\n",
    "#Combined power\n",
    "power = 200.0 + 50.0             #kW\n",
    "#Total kVAR is\n",
    "kvar = power*tant                #kVAR\n",
    "#Load kVAR is\n",
    "load_kvar = 200.0*tan2           #kVAR\n",
    "\n",
    "#KVAR supplied by motor is\n",
    "mot_kvar = kvar - load_kvar      #kVAR\n",
    "\n",
    "#Now, 50*tan(phi1) = mot_kvar\n",
    "tan1 = mot_kvar/50.0\n",
    "phi1 = m.atan(tan1)\n",
    "\n",
    "#Power factor = cos(phi)\n",
    "pf = m.cos(phi1)                 #leading\n",
    "print \"Power factor = \",round(pf,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.63 , PAGE NO :- 1994"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Power factor is = 0.21\n"
     ]
    }
   ],
   "source": [
    "'''A generating station supplies power to the following, lighting load 100-kW ;an induction motor 400 h.p. (298.4 kW),\n",
    "power factor 0.8, efficiency, 0.92 ; a rotary converter giving 100 A at 500 V at an efficiency of 0.94.\n",
    "What must be the power factor of the rotary converter in order that the power factor of the supply station may be unity.'''\n",
    "\n",
    "import math as m\n",
    "\n",
    "#Motor Power input = Motor output/Efficiency\n",
    "pin = 298.4/0.92               #kW\n",
    "phi1 = m.acos(0.8)             #(motor power factor angle)\n",
    "tan1 = m.tan(phi1)\n",
    "\n",
    "#Lagging motor kVAR is\n",
    "mot_kvar = pin*tan1            #kVAR\n",
    "#Leading kVAR to be supplied by rotary converter is same that of motor.\n",
    "rot_kvar = mot_kvar\n",
    "#Input power of rotary converter is\n",
    "pin_rot = (500.0*100.0)/(0.94*1000)      #kW\n",
    "\n",
    "#For rotary converter,      tanQ = kVAR/kW\n",
    "tan2 = rot_kvar/pin_rot\n",
    "phi2 = m.atan(tan2)\n",
    "\n",
    "#Power factor = cosQ\n",
    "pf = m.cos(phi2)                 #leading\n",
    "\n",
    "print \"Power factor is =\",round(pf,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.64 , PAGE NO :- 1995"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Power factor at maximum savings =  0.8\n",
      "Annual savings = Rs. 833.33\n"
     ]
    }
   ],
   "source": [
    "'''A factory has an average annual demand of 50 kW and an annual load factor of 0.5. The power factor is 0.75 lagging.\n",
    "The tariff is Rs. 100 per kVA maximum demand per annum plus five paise per kWh. If loss-free capacitors costing Rs. 600\n",
    "per kVAR are to be utilized, find the value of the power factor at which maximum saving will result. The interest and\n",
    "depreciation together amount to ten per cent. Also, determine the saving affected by improving the power factor to this value.'''\n",
    "\n",
    "import math as m\n",
    "#Given\n",
    "A = 100.0            #Rs           (charge of maximum demand per kVA)\n",
    "C = (10.0/100)*600   #Rs           (interest and depreciation charge)\n",
    "#The most economical power factor angle is given by sinQ = C/A\n",
    "phi = m.asin(C/A)         #angle\n",
    "#Power factor = cosQ\n",
    "pf = m.cos(phi)\n",
    "\n",
    "#Max demand = Avg demand/load factor\n",
    "maxp = 50.0/0.5          #kW           (Maximum demand)\n",
    "\n",
    "\n",
    "#(i)At initial pf = 0.75 the Max load in kVA is\n",
    "max_kva1 = maxp/0.75        #kVA\n",
    "#Max. demand charge is\n",
    "charge1 = max_kva1*A        #Rs\n",
    "#(ii)At economical 'pf' the Max load in kVA is\n",
    "max_kva2 = maxp/pf          #kVA\n",
    "#Max. demand charge is\n",
    "charge2 = max_kva2*A        #Rs\n",
    "\n",
    "#Annual Savings\n",
    "savings = charge1 - charge2   #Rs\n",
    "print \"Power factor at maximum savings = \",round(pf,2)\n",
    "print \"Annual savings = Rs.\",round(savings,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## EXAMPLE 50.65 , PAGE NO :- 1995"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Therefore, Maximum cost per kVA of pf corrections is = Rs. 314.76\n"
     ]
    }
   ],
   "source": [
    "'''For increasing the kW capacity of a plant working at 0.7 lag p.f. the necessary increase of power can be obtained by raising\n",
    "the p.f. to 0.85 or by installing additional plant. What is the maximum cost per kVA of p.f. correction apparatus to make its use\n",
    "more economical than additional plant at Rs. 500 kVA ?'''\n",
    "\n",
    "from sympy import Symbol\n",
    "import math as m\n",
    "\n",
    "#Let kVA1 be the initial capacity of plant and kVA2 be its increased capacity\n",
    "kVA1 = Symbol('kVA1')\n",
    "#kVA1 * cosQ1 = kVA2 * cosQ2\n",
    "kVA2 = kVA1*(0.85/0.7)\n",
    "#KVA of the additional plant\n",
    "kva_add = kVA2 - kVA1\n",
    "#Capital cost of additional plant is\n",
    "cost_add = 500.0*kva_add          #Rs\n",
    "\n",
    "#Now, cosQ1 and cosQ2 are known and we have to find sinQ1 and sinQ2\n",
    "phi1 = m.acos(0.7)\n",
    "phi2 = m.acos(0.85)\n",
    "\n",
    "sin1 = m.sin(phi1)\n",
    "sin2 = m.sin(phi2)\n",
    "\n",
    "#kVAR supplied by pf corrections\n",
    "kvar_supp  = kVA2*sin1 - kVA1*sin2      #kVAR\n",
    "#Let Cost of pf corrections be x\n",
    "#Now ,cost_add = cost of pf corrections . Therefore\n",
    "x = cost_add/kvar_supp            #Rs\n",
    "\n",
    "print \"Therefore, Maximum cost per kVA of pf corrections is = Rs.\",round(x,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.66 , PAGE NO :- 1996"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Annual savings = Rs. 3054.0\n"
     ]
    }
   ],
   "source": [
    "'''A consumer taking a steady load of 160 kW at a p.f. of 0.8 lag is charged at Rs. 80 per annum per kVA of\n",
    "maximum demand plus 5 paise per kWh consumed. Calculate the value to which he should improve the p.f. in order to\n",
    "affect the maximum saving if the leading kVA cost Rs.100 per kVA and interest and depreciation be at 12% per annum.\n",
    "Calculate also the saving.'''\n",
    "\n",
    "import math as m\n",
    "\n",
    "#Let the cost per kVAR is Rs. B and rate of interest and depreciation is P,then\n",
    "#C = BP/100\n",
    "A = 80.0           #Rs            (cost per kVA of max. demand)\n",
    "C = 100*12/100     #Rs\n",
    "#sinQ = C/A\n",
    "phi = m.asin(C/A)    #        angle\n",
    "pf = m.cos(phi)      #        power factor\n",
    "\n",
    "maxp = 160.0         #kW          (max. demand)\n",
    "#Max. demand in kVA for pf = 0.8\n",
    "max_kva1 = maxp/0.8   #kVA\n",
    "#Max.demand charge is\n",
    "charge1 = max_kva1*80.0                   #Rs\n",
    "\n",
    "#----------------------------------------------------------------------------------#\n",
    "#Max. demand in kVA for most economical pf \n",
    "max_kva2 = maxp/pf    #kVA\n",
    "#Max.demand charge is\n",
    "charge2 = max_kva2*80.0                   #Rs\n",
    "#Annual savings is\n",
    "savings = charge1 - charge2               #Rs\n",
    "print \"Annual savings = Rs.\",round(savings)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.67 , PAGE NO :- 1996"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "power factor =  0.987\n",
      "kVA supplied by plant is =  1245.0 kVA\n"
     ]
    }
   ],
   "source": [
    "'''A consumer takes a steady load of 1500 kW at a p.f. of 0.71 lagging and pays Rs. 50 per annum per kVA of maximum\n",
    "demand. Phase advancing plant costs Rs. 80 per kVA. Determine the capacity of the phase advancing plant required for\n",
    "minimum overall annual expenditure.Interest and depreciation total 10%. What will be the value of the new power factor\n",
    "of the supply?'''\n",
    "\n",
    "import math as m\n",
    "\n",
    "#Let the cost per kVAR is Rs. B and rate of interest and depreciation is P,then\n",
    "#C = BP/100\n",
    "A = 50.0           #Rs            (cost per kVA of max. demand)\n",
    "C = 80*10/100     #Rs\n",
    "#sinQ = C/A\n",
    "phi = m.asin(C/A)    #        angle\n",
    "pf = m.cos(phi)      #        power factor\n",
    "\n",
    "#As power factor = cosQ\n",
    "phi1 = m.acos(0.71)          #angle\n",
    "tan1 = m.tan(phi1)           #tanQ\n",
    "phi2 = m.acos(pf)            #angle\n",
    "tan2 = m.tan(phi2)           #tanQ\n",
    "\n",
    "#kVA supplied by plant is\n",
    "kva_supp = 1500.0*(tan1 - tan2)\n",
    "print \"power factor = \",round(pf,3)\n",
    "print \"kVA supplied by plant is = \",round(kva_supp),\"kVA\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## EXAMPLE 50.68 , PAGE NO :- 1996"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Total annual savings = Rs. 488.29\n"
     ]
    }
   ],
   "source": [
    "'''A factory takes a load of 200 kW at 0.85 p.f. (lagging) for 2,500 hours per annum and buys energy on tariff of Rs. 150\n",
    "per kVA plus 6 paise per kWh consumed. If the power factor is improved to 0.9 lagging by means of capacitors costing\n",
    "Rs. 525 per kVA and having a power loss of 100 W per kVA, calculate the annual saving affected by their use.\n",
    "Allow 8% per annum for interest and depreciation on the capacitors.'''\n",
    "\n",
    "from sympy import Symbol,solve,Eq\n",
    "import math as m\n",
    "\n",
    "#Given\n",
    "maxp = 200.0          #kW           (factory load)\n",
    "pf = 0.85             #             (power factor = cosQ)\n",
    "phi = m.acos(pf)      #angle\n",
    "tan1 = m.tan(phi)     #             (tanQ)\n",
    "#Lagging kVAR of factory load\n",
    "max_kvar = maxp*tan1  #kVAR\n",
    "\n",
    "#Let x be capacitor's kVAR. Therefore, total kVAR is\n",
    "x = Symbol('x')\n",
    "tot_kvar = max_kvar - x\n",
    "#Because loss per kVA is 100W i.e 1/10kW per kVA\n",
    "cap_loss = x/10.0     #kW\n",
    "\n",
    "#Total  kW is\n",
    "tot_kw = maxp + cap_loss   #kW\n",
    "#Overall pf is cosQ = 0.9\n",
    "phi2 = m.acos(0.9)\n",
    "tan2 = m.tan(phi2)\n",
    "eq = Eq(tan2,tot_kvar/tot_kw)\n",
    "x = solve(eq)\n",
    "x1 = x[0]             #kVAR\n",
    "\n",
    "#(i)cost per annum before improvement\n",
    "#Max demand in kVA\n",
    "max_kva = maxp/pf            #kVA  \n",
    "#Units consumed per annum\n",
    "units = maxp*2500.0          #kWh\n",
    "\n",
    "#Total annual cost\n",
    "cost1 = max_kva*150.0 + units*(6.0/100)     #Rs\n",
    "\n",
    "\n",
    "#(ii)cost per annum after improvement\n",
    "max_kva = maxp/0.9      #kVA\n",
    "#Units consumed per annum\n",
    "units = maxp*2500.0          #kWh\n",
    "\n",
    "#Charges due to losses in capacitor\n",
    "charge1 = x1*100*2500*6/(1000*100)         #Rs\n",
    "\n",
    "#Annual interest and depreciation cost\n",
    "charge2 = x1*525*(8.0/100)                 #Rs  \n",
    "\n",
    "#Total annual cost\n",
    "cost2 = max_kva*150.0 + units*(6.0/100) + charge1 + charge2   #Rs\n",
    "\n",
    "#Total annual savings are\n",
    "savings = cost1 - cost2                    #Rs\n",
    "\n",
    "print \"Total annual savings = Rs.\",round(savings,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.69 , PAGE NO :- 1997"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "B is cheaper than A by = Rs.  52.04\n"
     ]
    }
   ],
   "source": [
    "'''A 30 h.p. (22.38 kW) induction motor is supplied with energy on a two-part tariff of Rs. 60 per kVA of maximum demand\n",
    "per annum plus 5 paise per unit. Motor (A) has an efficiency of 89% and a power factor of 0.83.\n",
    "Motor (B) with an efficiency of 90% and a p.f. of 0.91 costs Rs. 160 more. With motor (A) the p.f. would be raised to\n",
    "0.91 (lagging) by installing capacitors at a cost Rs. 50 per kVA.If the service required from the motor is equivalent\n",
    "to 2,280 hr. per annum at full load, compare the annual charges in the two cases. Assume interest and depreciation charges\n",
    "to be 12.5% per annum for the motor and 8% per annum for the capacitors.'''\n",
    "\n",
    "import math as m\n",
    "\n",
    "#(i)For Motor A\n",
    "pin = 22.38/0.89               #kW        (Motor Input in kW)\n",
    "pin_kva = pin/0.83                #kVA       (Motor Input in kVA)\n",
    "#If power factor is changed to 0.91 then\n",
    "pin_kva2 = pin/0.91               #kVA       (Motor Input in kVA)\n",
    "#Annual cost of energy supplied to motor is\n",
    "charge1  = pin_kva2*60.0 + pin*2280.0*(5.0/100)    #Rs\n",
    "\n",
    "#Now, as we know pf = cosQ\n",
    "phi1 = m.acos(0.83)                #angle\n",
    "phi2 = m.acos(0.91)                #angle\n",
    "tan1 = m.tan(phi1)                 #tanQ\n",
    "tan2 = m.tan(phi2)                 #tanQ\n",
    "\n",
    "#kVAR necessary for this improvement is\n",
    "tot_kvar = pin*(tan1 - tan2)       #kVAR\n",
    "#Annual charges on capacitors\n",
    "charge2 = 50.0*tot_kvar*(8.0/100)  #Rs\n",
    "\n",
    "#Total charges per annum is\n",
    "tot_chargeA = charge1 + charge2     #Rs\n",
    "\n",
    "\n",
    "#-----------------------------------------------------------------------------#\n",
    "#(ii)For Motor B\n",
    "pin = 22.38/0.9               #kW        (Motor Input in kW)\n",
    "#If power factor is changed to 0.91 then\n",
    "pin_kva2 = pin/0.91               #kVA       (Motor Input in kVA)\n",
    "#Annual cost of energy supplied to motor is\n",
    "charge1  = pin_kva2*60.0 + pin*2280.0*(5.0/100)    #Rs\n",
    "\n",
    "#Annual charges on capacitors\n",
    "charge2 = (12.5/100)*160           #Rs\n",
    "\n",
    "#Total charges per annum is\n",
    "tot_chargeB = charge1 + charge2     #Rs\n",
    "\n",
    "#Hence B is cheaper than A by\n",
    "cheap = tot_chargeA - tot_chargeB    #Rs\n",
    "\n",
    "\n",
    "print \"B is cheaper than A by = Rs. \",round(cheap,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.70 , PAGE NO :- 1997"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Total annual cost for Motor A is = Rs. 15059.48\n",
      "Total annual cost for Motor B is = Rs. 15430.78\n",
      "Motor A would be recommended.\n"
     ]
    }
   ],
   "source": [
    "'''The motor of a 22.5 kW condensate pump has been burnt beyond economical repairs. Two alternatives have been\n",
    "proposed to replace it by\n",
    "Motor A. Cost = Rs. 6000 ; η at full-load=90% ; at half-load = 86%.\n",
    "Motor B. Cost = Rs. 4000 ; η at full-load=85% ; at half-load= 82%.\n",
    "The life of each motor is 20 years and its salvage value is 10% of the initial cost. The rate of\n",
    "interest is 5% annually. The motor operates at full-load for 25% of the time and at half-load for the\n",
    "remaining period. The annual maintenance cost of motor A is Rs. 420 and that of motor B is Rs. 240.\n",
    "The energy rate is 10 paise per kWh.Which motor will you recommend ?'''\n",
    "\n",
    "pout = 22.5                  #kW     (output power)\n",
    "#(i)For Motor A\n",
    "eff_fl = 0.9                 # (efficiency at full-load)\n",
    "eff_hl = 0.86                 # (efficiency at half-load)\n",
    "#Annual interest on capital cost\n",
    "charge1 = 6000.0*(5.0/100)                         #Rs\n",
    "#Annual depreciation charges = (original cost - salvage value)/20 years\n",
    "charge2 = (6000.0 - 6000.0*(10.0/100))/20          #Rs\n",
    "#Annual maintenance cost\n",
    "charge3 = 420.0                                    #Rs\n",
    "#Energy input per annum\n",
    "units = pout*0.25*8760/eff_fl + (pout/2)*0.75*8760/eff_hl   #kWh\n",
    "#Annual energy cost is\n",
    "charge4 = units*(10.0/100)                         #Rs\n",
    "#Total annual cost is\n",
    "tot_costA = charge1 + charge2 + charge3 + charge4   #Rs\n",
    "\n",
    "#---------------------------------------------------------------------------------------#\n",
    "\n",
    "#(ii)For Motor B\n",
    "eff_fl = 0.85                  # (efficiency at full-load)\n",
    "eff_hl = 0.82                 # (efficiency at half-load)\n",
    "#Annual interest on capital cost\n",
    "charge1 = 4000.0*(5.0/100)                         #Rs\n",
    "#Annual depreciation charges = (original cost - salvage value)/20 years\n",
    "charge2 = (4000.0 - 4000.0*(10.0/100))/20          #Rs\n",
    "#Annual maintenance cost\n",
    "charge3 = 240.0                                    #Rs\n",
    "#Energy input per annum\n",
    "units = pout*0.25*8760/eff_fl + (pout/2)*0.75*8760/eff_hl   #kWh\n",
    "#Annual energy cost is\n",
    "charge4 = units*(10.0/100)                         #Rs\n",
    "#Total annual cost is\n",
    "tot_costB = charge1 + charge2 + charge3 + charge4   #Rs\n",
    "\n",
    "print \"Total annual cost for Motor A is = Rs.\",round(tot_costA,2)\n",
    "print \"Total annual cost for Motor B is = Rs.\",round(tot_costB,2)\n",
    "\n",
    "if(tot_costA>tot_costB):\n",
    "    print \"Motor B would be recommended.\"\n",
    "else:\n",
    "     print \"Motor A would be recommended.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.71 , PAGE NO :- 1998"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Annual Savings = Rs.  7396.89\n"
     ]
    }
   ],
   "source": [
    "'''An industrial load takes 106 kWh a year, the power factor being 0.707 lagging.The maximum demand is 500 kVA.\n",
    "The tariff is Rs. 75 per annum per kVA maximum demand plus 3 paise per unit. Calculate the yearly cost of supply\n",
    "and find the annual saving in cost by installing phase advancing plant costing Rs. 45 per kVA which raises the plant\n",
    "power factor from 0.707 to 0.9 lagging. Allow 10% per annum on the cost of the phase advancing plant to cover all\n",
    "additional costs.'''\n",
    "\n",
    "import math as m\n",
    "\n",
    "#Given\n",
    "units = 1.0e+6          #kWh        (No. of units consumed in a year)\n",
    "max_dem = 500.0         #kVA        (Max. demand charge per annum)\n",
    "#Max. demand charge per annum\n",
    "charge1 = max_dem*75    #Rs\n",
    "#Annual energy charges\n",
    "charge2 = units*(3.0/100) #Rs\n",
    "#Total cost of supply\n",
    "tot_charge1 = charge1 + charge2       #Rs\n",
    "\n",
    "#Now when pf is changed from 0.707 to 0.9 then Max. kVA demand is\n",
    "max_dem =  max_dem*(0.707/0.9)       #kVA\n",
    "\n",
    "#Max. demand charge per annum\n",
    "charge1 = max_dem*75    #Rs\n",
    "#Annual energy charges\n",
    "charge2 = units*(3.0/100) #Rs\n",
    "#Total cost of supply\n",
    "tot_charge2 = charge1 + charge2       #Rs\n",
    "\n",
    "#Now, as we know pf = cosQ\n",
    "phi1 = m.acos(0.707)\n",
    "phi2 = m.acos(0.9)\n",
    "tan1 = m.tan(phi1)\n",
    "tan2 = m.tan(phi2)\n",
    "\n",
    "#kVAR to be supplied is  (kW demand)*(tan1 - tan2)\n",
    "tot_kvar = max_dem*0.707*(tan1 - tan2)              #kVAR\n",
    "\n",
    "#Annual cost of interest and depreciation\n",
    "charge3 =tot_kvar*45*(10.0/100)            #Rs\n",
    "tot_charge2 = tot_charge2 + charge3    #Rs\n",
    "\n",
    "#Annual Savings\n",
    "savings = tot_charge1 - tot_charge2   #Rs\n",
    "\n",
    "print \"Annual Savings = Rs. \",round(savings,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.72 , PAGE NO :- 1999"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Annual charge of Transformer 1 is = Rs. 7884.0\n",
      "Annual charge of Transformer 2 is = Rs. 8409.6\n",
      "Transformer 1 is chosen.\n",
      "To reverse the situation , Capital cost of transformer is > Rs.  5256.0\n"
     ]
    }
   ],
   "source": [
    "'''It is necessary to choose a transformer to supply a load which varies over 24\n",
    "hour period in the manner given below :\n",
    "500 kVA for 4 hours, 1000 kVA for 6 hours, 1500 kVA for 12 hours and 2000 kVA for the rest of the period.\n",
    "Two transformers each rated at 1500 kVA have been quoted. Transformer I has iron loss of\n",
    "2.7 kW and full-load copper loss of 8.1 kW while transformer II has an iron loss and full-load copper\n",
    "loss of 5.4 kW each.\n",
    "(i) Calculate the annual cost of supplying losses for each transformer if electrical energy costs\n",
    "10 paise per kWh.\n",
    "(ii) Determine which transformer should be chosen if the capital cost of the transformer I is\n",
    "Rs. 1000 more than that of the transformer II and annual charges of interest and depreciation\n",
    "are 10%.\n",
    "(iii) What difference in capital cost will reverse the decision made in (ii) above ? '''\n",
    "\n",
    "#(i.a)Transformer No. 1\n",
    "\n",
    "iron_loss = 2.7*24         #kWh             (Iron loss/day)\n",
    "\n",
    "cu_loss = 8.1*(((500.0/1500)**2.0)*4 + ((1000.0/1500)**2.0)*6 + ((1500.0/1500)**2.0)*12 + ((2000.0/1500)**2.0)*2) \n",
    "#kWh(Copper loss/day)\n",
    "\n",
    "#Annual energy loss\n",
    "annual_loss = 365.0*(iron_loss + cu_loss)        #kWh       \n",
    "               \n",
    "#Annual cost of both cases \n",
    "charge1 = annual_loss*(10.0/100)                 #Rs\n",
    "#-----------------------------------------------------------------------#\n",
    "#(i.b)Transformer No. 2\n",
    "\n",
    "iron_loss = 5.4*24         #kWh             (Iron loss/day)\n",
    "cu_loss = 5.4*(((500.0/1500)**2.0)*4 + ((1000.0/1500)**2.0)*6 + ((1500.0/1500)**2.0)*12 + ((2000.0/1500)**2.0)*2)\n",
    "#kWh(Copper loss/day)\n",
    "\n",
    "#Annual energy loss\n",
    "annual_loss = 365.0*(iron_loss + cu_loss)        #kWh       \n",
    "               \n",
    "#Annual cost of both cases \n",
    "charge2 = annual_loss*(10.0/100)                 #Rs\n",
    "\n",
    "print \"Annual charge of Transformer 1 is = Rs.\",round(charge1,2)\n",
    "print \"Annual charge of Transformer 2 is = Rs.\",round(charge2,2)\n",
    "\n",
    "#------------------------------------------------------------------------------------------------------------------------------#\n",
    "#(ii)Sice cost of transformer1 is Rs. 1000 more with 10% interest\n",
    "#Total annual cost for Transformer 1 is\n",
    "charge1a = charge1 + (10.0/100)*1000               #Rs\n",
    "\n",
    "if(charge1a>charge2):\n",
    "    print \"Transformer 2 is chosen.\"\n",
    "else:\n",
    "    print \"Transformer 1 is chosen.\"\n",
    "#------------------------------------------------------------------------------------------------------------------------------#\n",
    "#(iii)Total savings in Transformer 1 is\n",
    "savings = charge2 - charge1                       #Rs\n",
    "#Let x be the capital cost of transformer 1 . Then x*0.1 > savings\n",
    "x = savings/0.1                                   #Rs\n",
    "print \"To reverse the situation , Capital cost of transformer is > Rs. \",round(x,2)    \n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.73 , PAGE NO :- 1999"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Net savings per annum = Rs.  8590.0\n"
     ]
    }
   ],
   "source": [
    "'''Three-phase 50-Hz power is supplied to a mill, the voltage being stepped down to 460-V before use.The monthly power rate\n",
    "is 7.50 per kVA. It is found that the average power factor is 0.745 while the monthly demand is 611 kVA.To improve power\n",
    "factor, 210 kVA capacitors are installed in which there is negligible power loss. The installed cost of the equipment is\n",
    "Rs. 11,600 and fixed charges are estimated at 15% per year. What is the yearly saving introduced by the capacitors.'''\n",
    "\n",
    "import math as m\n",
    "\n",
    "#Monthly demand\n",
    "max_kva = 611.0             #kVA           (maximum demand)\n",
    "pf = 0.745                  #              (power factor)\n",
    "#Now, as we know\n",
    "phi = m.acos(pf)            #angle\n",
    "sin1 = m.sin(phi)\n",
    "\n",
    "#Max demand in kW\n",
    "max_kw = max_kva*pf         #kW\n",
    "#Max demand in kVAR\n",
    "max_kvar = max_kva*sin1        #kVAR  (lagging)\n",
    "#Leading kVAR\n",
    "kvar2 = 210.0                  #kVAR\n",
    "\n",
    "#kVAR after pf improvement\n",
    "tot_kvar = max_kvar - kvar2        #kVAR\n",
    "\n",
    "#kVA after power factor improvement is\n",
    "new_kva = m.sqrt( max_kw**2 + tot_kvar**2 )        #kVA\n",
    "\n",
    "#Reduction in kVA\n",
    "red_kva = max_kva - new_kva                #kVA\n",
    "#Monthly Savings in kVA charge\n",
    "saving = red_kva*7.5                       #Rs\n",
    "#Yearly Savings in kVA charge\n",
    "saving = 12*saving                         #Rs\n",
    "\n",
    "#Fixed charge per annum due to Capital cost on capacitors\n",
    "fxd_charge = 0.15*11600                      #Rs\n",
    "\n",
    "#Net savings\n",
    "net_saving = saving - fxd_charge             #Rs\n",
    "\n",
    "print \"Net savings per annum = Rs. \",round(net_saving)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## EXAMPLE 50.74 , PAGE NO :- 2000"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Minimum number of power units consumed per month =  880.0 units.\n"
     ]
    }
   ],
   "source": [
    "'''A supply undertaking is offering the following two tariffs to prospective customers :\n",
    "Tariff A : Lighting : 20 paise per unit; domestic power: 5 paise per unit, meter rent: 30 paise per meter per month.\n",
    "Tariff B : 12 per cent on the rateable value of the customer's premises plus 3 paise per unit for all purposes.\n",
    "If the annual rateable value of the customer's premises is Rs. 2,500 and his normal consumption for lighting per month\n",
    "is 40 units, determine what amount of domestic power consumption will make both the tariffs equally advantageous.'''\n",
    "\n",
    "from sympy import Symbol,solve,Eq\n",
    "\n",
    "#Let x = minimum  number of power units consumed per month\n",
    "x = Symbol('x')\n",
    "#(i) Tariff A\n",
    "#Total cost per month = meter rent + lighting charges + power charges\n",
    "charge1 = 2*30.0 + 40.0*20.0 + 5*x            #Paise\n",
    "#(ii) Tariff B\n",
    "#Total cost per month = 12% of 2500 + energy charges for al purposes\n",
    "charge2 = 0.12*2500.0*(100.0/12) + 3*(40.0 + x)          #Paise\n",
    "\n",
    "#Equating tariff A and B\n",
    "eq = Eq(charge1,charge2)\n",
    "x  = solve(eq)\n",
    "x1 = x[0]\n",
    "print \"Minimum number of power units consumed per month = \",round(x1,2),\"units.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.75 , PAGE NO :- 2000"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The price of h.t motors per output kW = Rs. 36.2\n"
     ]
    }
   ],
   "source": [
    "'''Transformers and low-tension motors of a certain size can be purchased at Rs. 12 per kVA of full output and Rs. 24 per kW \n",
    "output respectively.If their respective efficiencies are 98% and 90%, what price per kW output could be paid for high-tension\n",
    "motors of the same size but of average efficiency only 89%? Assume an annual load factor of 30%, the cost of energy per unit as\n",
    "7 paise and interest and depreciation at the rate of 8% for low-tension motors.'''\n",
    "\n",
    "from sympy import Symbol,solve,Eq\n",
    "\n",
    "#Let S => The price of h.t motors per output kW in rupees\n",
    "S = Symbol('S')\n",
    "\n",
    "#-------Low-tension Motors with Transformers-----#\n",
    "#Interest and depreciation charges of motors\n",
    "charge1 = 24.0*0.08/0.9                        #Rs\n",
    "#Interest and depreciation charges of transformers\n",
    "charge2 = 12.0*0.9/0.99*0.08                   #Rs\n",
    "#Running charges\n",
    "charge3 = (8760*0.3)*7/(0.98*0.9*100)          #Rs\n",
    "\n",
    "#Total cost of low tension motors with transformers\n",
    "tot_chargeA = charge1 + charge2 + charge3       #Rs -----------(i)\n",
    "\n",
    "#------High-tension Motors with Transformers----#\n",
    "\n",
    "#Standing Charges/output kW\n",
    "charge1 =  S*(0.12)/0.89                        #Rs\n",
    "#Running charges\n",
    "charge2 = (8760*0.3)*7/(0.89*100)               #Rs\n",
    "\n",
    "#Total cost of high tension motors with transformers\n",
    "tot_chargeB = charge1 + charge2                  #Rs -----------(ii)\n",
    "\n",
    "#Equating (i) and (ii)\n",
    "eq = Eq(tot_chargeA,tot_chargeB)\n",
    "S = solve(eq)\n",
    "S1 = S[0]\n",
    "print \"The price of h.t motors per output kW = Rs.\",round(S1,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.76 , PAGE NO :- 2001"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "number of hours per week above which the H.V. supply is cheaper =  36.0\n"
     ]
    }
   ],
   "source": [
    "'''An industrial load can be supplied on the following alternative tariffs (a) highvoltage supply at Rs. 45 per kVA per annum \n",
    "plus 1.5 paise per kWh or (b) low-voltage supply at Rs. 50 per annum plus 1.8 paise per kWh. Transformers and switchgear etc.\n",
    "for the H.V. supply cost Rs. 35 per kVA, the full-load transformer losses being 2%. The fixed charges on the capital cost of\n",
    "the high-voltage plant are 25% and the installation works at full-load. If there are 50 working weeks in a year, find the number\n",
    "of working hours per week above which the H.V. supply is cheaper.'''\n",
    "\n",
    "from sympy import Symbol,solve,Eq\n",
    "\n",
    "#Let x be the number or working hours per week above which H.V. supply is cheaper than the L.V. supply.\n",
    "x  =  Symbol('x')\n",
    "\n",
    "load = 100.0             #kW      (load)\n",
    "rload = load/(98.0/100)  #kW      (rated load with 2% losses)\n",
    "\n",
    "#Cost of switchgear & trasformer\n",
    "cost = rload*35.0       #Rs \n",
    "#annual fixed charge\n",
    "charge1 = cost*0.25     #Rs\n",
    "\n",
    "#Annual energy consumption\n",
    "units = 100.0*x*50.0    #kWh\n",
    "\n",
    "#(a) H.V. Supply\n",
    "#Total annual cost = 45 * kVA + energy charges + charge on H.V. plant\n",
    "charge_hv = 45*(rload) + units/0.98*(1.5/100) + charge1                 #Rs\n",
    "\n",
    "#(b) L.V. Supply\n",
    "#Total annual cost = Rs. 50 × kVA + energy charges\n",
    "charge_lv = 50*load + units*(1.8/100)                                   #Rs\n",
    "\n",
    "#If two annual costs are equal then\n",
    "eq = Eq(charge_hv,charge_lv)\n",
    "x = solve(eq)\n",
    "x1 = x[0]         \n",
    "print \"number of hours per week above which the H.V. supply is cheaper = \",round(x1)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.77 , PAGE NO :- 2002"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Motor X is cheaper by = Rs. 34.8\n"
     ]
    }
   ],
   "source": [
    "'''For a particular drive in a factory requiring 10 h.p. (7.46 kW) motors, following tenders have been received. Which one\n",
    "will you select ?\n",
    "                                     cost                                    efficiency\n",
    "Motor X                            Rs. 1,150                                     86%\n",
    "Motor Y                            Rs. 1,000                                     85%\n",
    "Electrical tariff is Rs. 50 per kW + 5 paise per kWh. Assume interest and depreciation as 10% .'''\n",
    "\n",
    "#(i) Motor X\n",
    "pin = 7.46/0.86                 #kW        (Full load power input)\n",
    "units = pin*8760.0              #kWh       (Units consumed/year)\n",
    "#kW charges\n",
    "charge1 = 50.0*pin              #Rs\n",
    "#kWh charges\n",
    "charge2 = (5.0/100)*units        #Rs\n",
    "#Fixed charges\n",
    "charge3 = (10.0/100)*1150.0     #Rs\n",
    "\n",
    "#Total annual charges\n",
    "tot_chargeX = charge1 + charge2 + charge3     #Rs\n",
    "\n",
    "#-------------------------------------------------------------------------------#\n",
    "#(ii) Motor Y\n",
    "pin = 7.46/0.85                 #kW        (Full load power input)\n",
    "units = pin*8760.0              #kWh       (Units consumed/year)\n",
    "#kW charges\n",
    "charge1 = 50.0*pin              #Rs\n",
    "#kWh charges\n",
    "charge2 = (5.0/100)*units         #Rs\n",
    "#Fixed charges\n",
    "charge3 = (10.0/100)*1000.0     #Rs\n",
    "\n",
    "#Total annual charges\n",
    "tot_chargeY = charge1 + charge2 + charge3     #Rs\n",
    "\n",
    "#-------------------------------------------------------------------------------#\n",
    "if (tot_chargeX > tot_chargeY):\n",
    "    savings = tot_chargeX - tot_chargeY       #Rs\n",
    "    print \"Motor Y is cheaper by = Rs.\",round(savings,2)\n",
    "else:\n",
    "    savings = tot_chargeY - tot_chargeX      #Rs\n",
    "    print \"Motor X is cheaper by = Rs.\",round(savings,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.78 , PAGE NO :- 2002"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Cost of Motor B is = Rs. 10250.0\n"
     ]
    }
   ],
   "source": [
    "'''A 200-h p. (149.2 kW) motor is required to operate at full-load for 1500 hr, at half-load for 3000 hr per year and to\n",
    "be shut down for the remainder of the time. Two motors are available.\n",
    "\n",
    "Motor A : efficiency at full load = 90% ;          at half-load = 88%\n",
    "Motor B : efficiency at full load = 90% ;          at half-load = 89%\n",
    "The unit of energy is 5 paise/kWh and interest and depreciation may be taken as 12 per cent per year. If motor A cost\n",
    "Rs. 9,000 ; what is the maximum price which could economically be paid for motor B ?'''\n",
    "\n",
    "from sympy import Symbol,solve,Eq\n",
    "#(i)Motor A\n",
    "pin_fl = 149.2/0.9          #kW  (full-load power input)\n",
    "pin_hl = (149.2/2)/0.88     #kW  (half-load power input)\n",
    "pin_hl = round(pin_hl,1)\n",
    "pin_fl = round(pin_fl,1)\n",
    "#Total energy consumed in a year\n",
    "units = 1500.0*pin_fl + 3000.0*pin_hl    #kWh\n",
    "#Cost of energy is\n",
    "charge1 = (5.0/100)*units   #Rs\n",
    "#Interest and depreciation on motors\n",
    "charge2 = 0.12*9000         #Rs\n",
    "tot_chargeA = charge1 + charge2    #Rs ----------(i)\n",
    "#------------------------------------------------------------------#\n",
    "\n",
    "#(ii)Motor B\n",
    "pin_fl = 149.2/0.9          #kW  (full-load power input)\n",
    "pin_hl = (149.2/2)/0.89     #kW  (half-load power input)\n",
    "pin_hl = round(pin_hl,1)\n",
    "pin_fl = round(pin_fl,1)\n",
    "#Total energy consumed in a year\n",
    "units = 1500.0*pin_fl + 3000.0*pin_hl    #kWh\n",
    "#Cost of energy is\n",
    "charge1 = (5.0/100)*units   #Rs\n",
    "#Let the cost of motor be x\n",
    "x = Symbol('x')\n",
    "#Interest and depreciation on motors\n",
    "charge2 = 0.12*x         #Rs\n",
    "tot_chargeB = charge1 + charge2    #Rs-------------(ii)\n",
    "\n",
    "#Equating (i)&(ii)\n",
    "eq = Eq(tot_chargeA,tot_chargeB)\n",
    "x = solve(eq)\n",
    "x1 = x[0]\n",
    "print \"Cost of Motor B is = Rs.\",round(x1,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.79 , PAGE NO :- 2003"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Total cost of Tender A is = Rs. 938.83\n",
      "Total cost of Tender B is = Rs. 916.26\n",
      "Tender B is cheaper by = Rs. 22.57\n"
     ]
    }
   ],
   "source": [
    "'''Two tenders A and B for a 1000-kVA, 0.8 power factor transformer are : A,full-load efficiency = 98.5% and iron\n",
    "loss = 6 kW at rated voltage ; B, 98.8% and iron loss 4 kW but costs Rs. 1,500 more than A. The load cycle is 2000\n",
    "hours per annum at full-load, 600 hours at halfload and 400 hours at 25 kVA. Annual charges for interest and\n",
    "depreciation are 12.5% of capital cost and energy costs 3 paise per kWh. Which tender is better and what would be\n",
    "the annual saving.'''\n",
    "\n",
    "#Tender A\n",
    "#Transformer full-load output\n",
    "fl_out = 1000 * 0.8                          #kW\n",
    "eff = (98.5/100)                             # (efficiency)\n",
    "pin = fl_out/eff                            # (input power)\n",
    "#Total losses\n",
    "tot_loss = pin - fl_out                      #kW\n",
    "#F.L. Cu losses\n",
    "fl_culoss = tot_loss - 6.0                  #kW\n",
    "#Total losses per year for a running period of 3000 hr. are—\n",
    "#Iron loss\n",
    "ir_loss = 3000 * 6.0                           #kWh\n",
    "#F.L. Cu losses for 2000 hours\n",
    "fl_units = 2000 * fl_culoss                  #kWh\n",
    "#Cu loss at half-load for 600 hours\n",
    "hl_units = 600*(fl_culoss/4)                #kWh \n",
    "\n",
    "#Cu loss at 25 kVA load for 400 hours\n",
    "units_kva = ((25.0/1000)**2)*fl_culoss*400.0   #kWh\n",
    "\n",
    "#Total energy loss per year\n",
    "enrgy_loss = ir_loss + fl_units + hl_units + units_kva #kWh\n",
    "#Total Cost\n",
    "costA = enrgy_loss*(3.0/100)                  #Rs.\n",
    "\n",
    "#---------------------------------------------------------------------------#\n",
    "\n",
    "#Tender  B\n",
    "#Transformer full-load output\n",
    "fl_out = 1000 * 0.8                          #kW\n",
    "eff = (98.8/100)                             # (efficiency)\n",
    "pin = fl_out/eff                             # (input power)\n",
    "#Total losses\n",
    "tot_loss = pin - fl_out                      #kW\n",
    "#F.L. Cu losses\n",
    "fl_culoss = tot_loss - 4.0                   #kW\n",
    "#Total losses per year for a running period of 3000 hr. are—\n",
    "#Iron loss\n",
    "ir_loss = 3000 * 4                           #kWh\n",
    "#F.L. Cu losses for 2000 hours\n",
    "fl_units = 2000 * fl_culoss                  #kWh\n",
    "#Cu loss at half-load for 600 hours\n",
    "hl_units = 600*(fl_culoss/4)                #kWh \n",
    "\n",
    "#Cu loss at 25 kVA load for 400 hours\n",
    "units_kva = ((25.0/1000)**2)*fl_culoss*400.0   #kWh\n",
    "\n",
    "#Total energy loss per year\n",
    "enrgy_loss = ir_loss + fl_units + hl_units + units_kva #kWh\n",
    "#Total Cost\n",
    "costB = enrgy_loss*(3.0/100) + 1500.0*(12.5/100)       #Rs.\n",
    "\n",
    "print \"Total cost of Tender A is = Rs.\",round(costA,2) \n",
    "print \"Total cost of Tender B is = Rs.\",round(costB,2)\n",
    "\n",
    "if (costA > costB):\n",
    "    diff = costA - costB\n",
    "    print \"Tender B is cheaper by = Rs.\",round(diff,2)\n",
    "else:\n",
    "    diff = costB - costA\n",
    "    print \"Tender A is cheaper by = Rs.\",round(diff,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.80 , PAGE NO :- 2003"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Transformer B should cost Rs. 2920.0 less than A.\n"
     ]
    }
   ],
   "source": [
    "'''Transformer A has iron loss of 150 kWh and load loss of 140 kWh daily while the corresponding losses of transformer B are 75 kWh\n",
    "and 235 kWh. If annual charges are 12.5% of the capital costs and energy costs 5 paise per kWh, what should be the difference in the\n",
    "cost of the two transformers so as to make them equally economical ?'''\n",
    "\n",
    "#Transformer A\n",
    "#Annual loss\n",
    "annual_lossA = 365.0*(150 + 140)          #kWh       (Yearly loss)\n",
    "#Transformer B\n",
    "annual_lossB = 365.0*(75 + 235)           #kWh       (Yearly loss)\n",
    "\n",
    "#Difference in yearly loss\n",
    "tot_loss = annual_lossB - annual_lossA     #kWh\n",
    "\n",
    "#Value of this loss\n",
    "value = tot_loss*(5.0/100)                 #Rs\n",
    "\n",
    "\n",
    "#As transformer B is costlier .\n",
    "#Let the difference in capital cost of transformers be x\n",
    "x = value/0.125                         #Rs\n",
    "\n",
    "print \"Transformer B should cost Rs.\",round(x,2),\"less than A.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 50.81 , PAGE NO :- 2004"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Total annual charges for Transformer A is = Rs.  24804.0\n",
      "Total annual charges for Transformer B is = Rs.  23046.0\n",
      "Total annual charges for Transformer C is = Rs.  28601.0\n",
      "Transformer B is cheaper.\n"
     ]
    }
   ],
   "source": [
    "'''Quotations received from three sources for transformers are :\n",
    "                    Price                 No-load loss                  Full-load loss\n",
    "A                 Rs. 41,000                16 kW                            50 kW\n",
    "B                 Rs. 45,000                14 kW                            45 kW\n",
    "C                 Rs. 38,000                19 kW                            60 kW\n",
    "If the transformers are kept energized for the whole of day (24 hours), but will be on load for 12 hours per day, the remaining\n",
    "period on no-load, the electricity cost being 5 paise per kWh and fixed charges Rs. 125 per kW of loss per annum and if\n",
    "depreciation is 10% of the initial cost, which of the transformers would be most economical to purchase ?'''\n",
    "\n",
    "#Transformer A\n",
    "fl_loss = 50.0        #kW         (Full load losses) \n",
    "nl_loss = 16.0        #kW         (No load losses)\n",
    "\n",
    "fl_culoss = fl_loss - nl_loss    #kW   (Full load copper loss)\n",
    "\n",
    "#Cu loss for 12 hours .Therefore units consumed\n",
    "cu_units = fl_culoss*12          #kWh\n",
    "#Iron loss for 24 hours.Therefore units consumed\n",
    "ir_units = nl_loss*24            #kWh\n",
    "#Total loss per day\n",
    "day_loss = cu_units + ir_units   #kWh\n",
    "#Annual loss is\n",
    "anl_loss = day_loss*365.0        #kWh\n",
    "#Cost of this loss is\n",
    "loss_charge = anl_loss*(5.0/100)        #Rs\n",
    "#Annual fixed charges\n",
    "fxd_charge = 125.0*fl_loss       #Rs\n",
    "#Annual depreciation\n",
    "dep_charge = 0.1*41000.0         #Rs\n",
    "\n",
    "#Total annual charges\n",
    "tot_chargeA = loss_charge + fxd_charge + dep_charge        #Rs\n",
    "print \"Total annual charges for Transformer A is = Rs. \",round(tot_chargeA,2)\n",
    "#--------------------------------------------------------------------------------------------#\n",
    "\n",
    "#Transformer B\n",
    "fl_loss = 45.0        #kW         (Full load losses) \n",
    "nl_loss = 14.0        #kW         (No load losses)\n",
    "\n",
    "fl_culoss = fl_loss - nl_loss    #kW   (Full load copper loss)\n",
    "\n",
    "#Cu loss for 12 hours .Therefore units consumed\n",
    "cu_units = fl_culoss*12          #kWh\n",
    "#Iron loss for 24 hours.Therefore units consumed\n",
    "ir_units = nl_loss*24            #kWh\n",
    "#Total loss per day\n",
    "day_loss = cu_units + ir_units   #kWh\n",
    "#Annual loss is\n",
    "anl_loss = day_loss*365.0        #kWh\n",
    "#Cost of this loss is\n",
    "loss_charge = anl_loss*(5.0/100)        #Rs\n",
    "#Annual fixed charges\n",
    "fxd_charge = 125.0*fl_loss       #Rs\n",
    "#Annual depreciation\n",
    "dep_charge = 0.1*45000.0         #Rs\n",
    "\n",
    "#Total annual charges\n",
    "tot_chargeB = loss_charge + fxd_charge + dep_charge        #Rs\n",
    "print \"Total annual charges for Transformer B is = Rs. \",round(tot_chargeB,2)\n",
    "#--------------------------------------------------------------------------------------------#\n",
    "\n",
    "#Transformer C\n",
    "fl_loss = 60.0        #kW         (Full load losses) \n",
    "nl_loss = 19.0        #kW         (No load losses)\n",
    "\n",
    "fl_culoss = fl_loss - nl_loss    #kW   (Full load copper loss)\n",
    "\n",
    "#Cu loss for 12 hours .Therefore units consumed\n",
    "cu_units = fl_culoss*12          #kWh\n",
    "#Iron loss for 24 hours.Therefore units consumed\n",
    "ir_units = nl_loss*24            #kWh\n",
    "#Total loss per day\n",
    "day_loss = cu_units + ir_units   #kWh\n",
    "#Annual loss is\n",
    "anl_loss = day_loss*365.0        #kWh\n",
    "#Cost of this loss is\n",
    "loss_charge = anl_loss*(5.0/100)        #Rs\n",
    "#Annual fixed charges\n",
    "fxd_charge = 125.0*fl_loss       #Rs\n",
    "#Annual depreciation\n",
    "dep_charge = 0.1*38000.0         #Rs\n",
    "\n",
    "#Total annual charges\n",
    "tot_chargeC = loss_charge + fxd_charge + dep_charge        #Rs\n",
    "print \"Total annual charges for Transformer C is = Rs. \",round(tot_chargeC,2)\n",
    "#--------------------------------------------------------------------------------------------#\n",
    "if(tot_chargeA < tot_chargeB):\n",
    "    if(tot_chargeA < tot_chargeC):\n",
    "        print \"Transformer A is cheaper.\"\n",
    "    else:\n",
    "        print \"Transformer C is cheaper.\"\n",
    "else:\n",
    "    if(tot_chargeB < tot_chargeC):\n",
    "        print \"Transformer B is cheaper.\"\n",
    "    else:\n",
    "        print \"Transformer C is cheaper.\"       \n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## EXAMPLE 50.82 , PAGE NO :- 2005"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Line power factor at full-load =  0.99\n",
      "Line power factor at no-load =  0.27\n"
     ]
    }
   ],
   "source": [
    "'''A 37.3 kW induction motor has power factor 0.9 and efficiency 0.9 at fullload,power factor 0.6 and efficiency 0.7 at half-load.\n",
    "At no-load, the current is 25% of the full-load current and power factor 0.1. Capacitors are supplied to make the line power factor\n",
    "0.8 at half-load.With these capacitors in circuit, find the line power factor at (i) full-load and (ii) no-load.'''\n",
    "\n",
    "import math as m\n",
    "from sympy import Symbol\n",
    "\n",
    "#Full-load motor input P1\n",
    "p1 = 37.3/0.9           #kW\n",
    "#Lagging kVAR drawn by the motor at full-load,\n",
    "kvar1 = p1*(m.tan(m.acos(0.9)))      #kVAR\n",
    "\n",
    "#Half-load motor input P2\n",
    "p2 = (37.3/2)/0.7       #kW\n",
    "#Lagging kVAR drawn by motor at half-load,\n",
    "kvar2 = p2*(m.tan(m.acos(0.6)))      #kVAR\n",
    "\n",
    "#Let the line voltage be Vl\n",
    "Vl = Symbol('Vl')\n",
    "#Full load current\n",
    "I1 = 37.3e+3/(1.73*0.9*0.9*Vl)       #A\n",
    "\n",
    "#Current at no-load\n",
    "I0 = 0.25*I1\n",
    "\n",
    "#Motor Input at no-load P0 = 1.73*Vl*I0*cosQ\n",
    "P0 = 1.73*Vl*I0*0.1/1000                  #W\n",
    "\n",
    "#Lagging kVAR drawn by motor at no-load\n",
    "kvar0 = P0*m.tan(m.acos(0.1))            #kW\n",
    "\n",
    "#Lagging kVAR drawn from mains at half-load\n",
    "kvar1 = p2*m.tan(m.acos(0.8))        #kW\n",
    "\n",
    "#kVAR supplied by capacitors, kVARC = kVAR2 − kVAR2C\n",
    "cap_kvar = kvar2 - kvar1 \n",
    "#kVAR drawn from the main at full-load with capacitors\n",
    "fl_kvar = kvar1 - cap_kvar                     #kVAR\n",
    "\n",
    "#(i) Line power factor at full-load is\n",
    "pf_fl =   m.cos(m.atan(fl_kvar/p1))\n",
    "                \n",
    "print\"Line power factor at full-load = \",round(pf_fl,2)              \n",
    "#----------------------------------------------------------------------------#\n",
    "                \n",
    "#(ii) kVAR drawn from mains at no-load with capacitors\n",
    "nl_kvar = kvar0 - cap_kvar                     #kVAR \n",
    "#Line power factor at no-load\n",
    "pf_nl =   m.cos (m.atan(nl_kvar/P0))\n",
    "print \"Line power factor at no-load = \",round(pf_nl,2)"
   ]
  }
 ],
 "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.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}