summaryrefslogtreecommitdiff
path: root/A_TEXTBOOK_OF_ELECTRICAL_TECHNOLOGY_VOL-III_by_B.L.Thareja/chapter41.ipynb
blob: 0a494d2d9f32e9f45b1a8b326486c4906916e994 (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
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# CHAPTER 41 : A.C. Transmission and Distribution"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.1  ,   PAGE NO :- 1613"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Cu for 3-phase system =  0.29  * Cu for dc system.\n"
     ]
    }
   ],
   "source": [
    "'''A 3-phase, 4-wire system is used for lighting. Compare the amount of copper required with that needed for a\n",
    "2-wire D.C. system with same line voltage. Assume the same losses and balanced load. The neutral is one half\n",
    "the cross-section of one of the respective outers.'''\n",
    "\n",
    "from sympy import Symbol\n",
    "\n",
    "#(a) Two-wire DC\n",
    "#We know that,  I = P/V .Therefore\n",
    "I = Symbol('I')\n",
    "#Also let the resistance be R1\n",
    "R1 = Symbol('R1')\n",
    "#power loss is\n",
    "loss1 = 2*(I*I)*R1         \n",
    "\n",
    "#(b) Three-phase,4-wire\n",
    "\n",
    "#We know that,  I2 = P/3*V .Therefore I2 = I/3\n",
    "#Also let the resistance be R2\n",
    "R2 = Symbol('R2')\n",
    "#power loss is\n",
    "loss2 = 3*(I/3*I/3)*R2\n",
    "\n",
    "#loss1/loss2 = 2*I^2*R1/(I^2*R2*1/3) .Let ratio of resistances is R1/R2 = r1_r2\n",
    "#As loss1 = loss2\n",
    "r1_r2 = 1.0/6\n",
    "\n",
    "#Let the ratio of areas of conductors be a1_a2 As R o< 1/A\n",
    "a2_a1 = 1/r1_r2\n",
    "\n",
    "#Cu loss of 3-phase/Cu loss of dc system = 3.5*A2*l/2*A1*l\n",
    "ratio = (3.5/2)/a2_a1\n",
    "\n",
    "print \"Cu for 3-phase system = \",round(ratio,2),\" * Cu for dc system.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.2 , PAGE NO :- 1613"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Wt of copper for 3-conductors =  9349.58 kg.\n"
     ]
    }
   ],
   "source": [
    "'''Estimate the weight of copper required to supply a load of 100 MW at upf by a 3-phase, 380-kV system over a distance\n",
    "of 100 km. The neutral point is earthed. The resistance of the conductor is 0.045 ohm/cm^2/km. The weight of copper\n",
    "is 0.01 kg/cm^3. The efficiency of transmission can be assumed to be 90 percent.'''\n",
    "\n",
    "#Power loss in the line\n",
    "loss1 = (1 - 0.9) * 100.0                #MW\n",
    "#Line current Il = P/vl*cosQ\n",
    "Il = 100 * 1.0e+6/(1.732*380*(1.0e+3)*1)  #A\n",
    "#Since I^2R loss in 3-conductors is loss1, loss per conductor is\n",
    "loss_c = loss1*1.0e+6/3                  #W\n",
    "\n",
    "#Resistance per conductor           Using loss = I^2*R\n",
    "R_c = loss_c/(Il*Il)                   #ohm\n",
    "#Resistance per conductor per km\n",
    "R_km = R_c/100                         #ohm\n",
    "#Conductor cross-section\n",
    "Vol = 0.045/R_km                       #m^3\n",
    "#Volume of copper per meter run\n",
    "Vol = Vol*100                          #cm^3\n",
    "#Weight of copper for 3-conductor for 100 km length\n",
    "wt = 3 * (Vol * 0.01) * 100 * 1000     #kg\n",
    "\n",
    "print \"Wt of copper for 3-conductors = \",round(wt,2),\"kg.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.3 , PAGE NO :- 1614"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Additional power transmitted =  80.5 %.\n"
     ]
    }
   ],
   "source": [
    "'''A d.c. 2-wire distribution system is converted into a.c. 3-phase, 3-wire system by adding a third conductor of\n",
    "the same size as the two existing conductors. If voltage between conductors and percentage power loss remain the same, calculate\n",
    "the percentage additional balanced load which can now be carried by the conductors at 0.95 p.f.'''\n",
    "\n",
    "from sympy import Symbol\n",
    "\n",
    "#(a)DC 2-wire system\n",
    "\n",
    "#Let us assume\n",
    "V = 1.0\n",
    "R = 1.0\n",
    "I1 = Symbol('I1')\n",
    "#Power transmitted\n",
    "P1 = V*I1\n",
    "#Power loss\n",
    "loss1 = 2*(I1**2)*R             \n",
    "#%power loss = power loss/Power transmitted\n",
    "ploss1 = loss1/P1\n",
    "\n",
    "#(b)3-phase, 3-wire system\n",
    "\n",
    "I2 = Symbol('I2')\n",
    "#Power transmitted       P = 1.732*VI*cosQ\n",
    "P2 = 1.732*V*I2*(0.95)\n",
    "#Power loss\n",
    "loss2 = 3*(I2**2)*R\n",
    "#%power loss = power loss/Power transmitted\n",
    "ploss2 = loss2/P2\n",
    "\n",
    "#As ploss1 == ploss2\n",
    "I2 = 2*(0.95)*I1/1.732\n",
    "P2 = 1.732*V*I2*(0.95)\n",
    "#Add. power transmitted\n",
    "ptrans = (P2 - P1)/P1 *100           #%\n",
    "\n",
    "print \"Additional power transmitted = \",round(ptrans,2),\"%.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.4 , PAGE NO :- 1614"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Additional power transmitted =  30.0 MW.\n"
     ]
    }
   ],
   "source": [
    "'''A 2-phase, 3-wire a.c. system has a middle conductor of same cross-sectional area as the outer and supplies a load\n",
    "of 20 MW. The system is converted into 3-phase, 4-wire system by running a neutral wire. Calculate the new power which\n",
    "can be supplied if voltage across consumer terminal and percentage line losses remain the same. Assume balanced load.'''\n",
    "\n",
    "from sympy import Symbol\n",
    "\n",
    "#(a)2-phase 3-wire system\n",
    "\n",
    "#Let us assume\n",
    "V = 1.0\n",
    "R = 1.0\n",
    "cosQ = 1.0\n",
    "I1 = Symbol('I1')\n",
    "#Power transmitted\n",
    "P1 = 2*V*I1*cosQ\n",
    "#Power loss\n",
    "loss1 = 2*(I1**2)*R             \n",
    "#%power loss = power loss/Power transmitted\n",
    "ploss1 = loss1/P1\n",
    "\n",
    "#(b)3-phase, 4-wire system\n",
    "\n",
    "I2 = Symbol('I2')\n",
    "#Power transmitted       P = 1.732*VI*cosQ\n",
    "P2 = 3*V*I2*cosQ\n",
    "#Power loss\n",
    "loss2 = 3*(I2**2)*R\n",
    "#%power loss = power loss/Power transmitted\n",
    "ploss2 = loss2/P2\n",
    "\n",
    "#As ploss1 == ploss2\n",
    "I2 = I1\n",
    "P2 = 3*V*I2*cosQ\n",
    "#New Power that can be supplied  P1/P2 = 20/x\n",
    "pnew = 20*P2/P1           #MW\n",
    "\n",
    "print \"Additional power transmitted = \",round(pnew,2),\"MW.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.5 , PAGE NO :- 1617"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "L =  1.02 uH/m.\n",
      "L =  10.92 uH/m.\n"
     ]
    }
   ],
   "source": [
    "'''What is the inductance per loop metre of two parallel conductors of a single phase system if each has a diameter of 1\n",
    "cm and their axes are 5 cm apart when conductors have a relative permeability of (a) unity and (b) 100. The relative\n",
    "permeability of the surrounding medium is unity in both cases. End effects may be neglected and the current may be assumed\n",
    "uniformly distributed over cross-section of the wires.'''\n",
    "\n",
    "import math as m\n",
    "# (a)\n",
    "# u = u0\n",
    "u0 = 4*3.14*1.0e-7                   #H/m\n",
    "ui = 1.0\n",
    "L = u0/3.14*(m.log(5.0/0.5) + ui/4)*1.0e+6  #uH/m\n",
    "print \"L = \",round(L,2),\"uH/m.\"\n",
    "# (b)\n",
    "# u = u0\n",
    "u0 = 4*3.14*1.0e-7                   #H/m\n",
    "ui = 100.0\n",
    "L = u0/3.14*(m.log(5.0/0.5) + ui/4)*1.0e+6  #uH/m\n",
    "print \"L = \",round(L,2),\"uH/m.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.6 , PAGE NO :- 1617"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "loop impedance is =  19.83 ohm.\n"
     ]
    }
   ],
   "source": [
    "'''A 20-km single-phase transmission line having 0.823 cm diameter has two line conductors separated by 1.5 metre.\n",
    "The conductor has a resistance of 0.311 ohm per kilometre. Find the loop impedance of this line at 50 Hz.'''\n",
    "\n",
    "import math as m\n",
    "\n",
    "#Given\n",
    "length = 20.0*1000            #m\n",
    "u = 4*3.14*1.0e-7                #H\n",
    "ui = 1.0\n",
    "D = 1.5                       #m\n",
    "r = 0.823/2*1.0e-2            #m\n",
    "#inductance is\n",
    "L = length*(u/3.14*(m.log(D/r) + ui/4 ))     #H\n",
    "#reactance is\n",
    "X = 2*3.14*50.0*L             #ohm\n",
    "#loop resistance\n",
    "R = 2*length*0.311/1000       #ohm\n",
    "#impedance is\n",
    "Z = m.sqrt(X*X + R*R)         #ohm\n",
    "\n",
    "print \"loop impedance is = \",round(Z,2),\"ohm.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.7 , PAGE NO :- 1618"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Capacitance (excluding ground effect) =  0.00928 uF/km\n",
      "Capacitance (including ground effect) =  0.00932 uF/km\n"
     ]
    }
   ],
   "source": [
    "'''The conductors in a single-phase transmission line are 6 m above ground. Each conductor has a diameter of 1.5 cm\n",
    "and the two conductors are spaced 3 m apart. Calculate the capacitance per km of the line\n",
    "(i) excluding ground effect           and          (ii) including the ground effect.'''\n",
    "\n",
    "import math as m\n",
    "#Given\n",
    "D = 3.0         #m      (distance between conductors)\n",
    "r = 1.5/2*1e-2  #m      (radius)\n",
    "h = 6.0         #m      (height from ground)\n",
    "eps = 8.85e-12  #epsilon (constant)\n",
    "\n",
    "#(i)Capacitance per km excluding ground effect\n",
    "Cn = 2*3.14*eps/(m.log(D/r))*1.0e+9         #uF/km\n",
    "print \"Capacitance (excluding ground effect) = \",round(Cn,5),\"uF/km\"\n",
    "\n",
    "#(ii)Capacitance including ground effect\n",
    "Cn = 2*3.14*eps/(m.log(D/(r*m.sqrt(1 + D*D/(4*h*h)))))*1.0e+9         #uF/km\n",
    "print \"Capacitance (including ground effect) = \",round(Cn,5),\"uF/km\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.8 , PAGE NO :- 1620"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Sending-end voltage =  3859.08 V.\n"
     ]
    }
   ],
   "source": [
    "'''A single-phase line has an impedance of 5ang(60) and supplies a load of 120 A,3,300 V at 0.8 p.f. lagging.\n",
    "Calculate the sending-end voltage and draw a vector diagram.'''\n",
    "\n",
    "import cmath as cm\n",
    "import math as m\n",
    "#Given\n",
    "Er = cm.rect(3300.0,0)             #V    (Voltage) \n",
    "Z =  cm.rect(5.0,3.14/3)           #ohm  (Impedance)\n",
    "pf = 0.8                           #power factor\n",
    "theta = m.acos(pf)                 #Q    (power factor angle)\n",
    "\n",
    "I = cm.rect(120.0,-theta)           #A    (current)\n",
    "\n",
    "#Voltage drop\n",
    "V = (I)*(Z)                            #V\n",
    "\n",
    "#Sending-end voltage is\n",
    "Es = Er + V                        #V\n",
    "\n",
    "Es = m.sqrt(Es.real**2 + Es.imag**2)#V\n",
    "\n",
    "print \"Sending-end voltage = \",round(Es,2),\"V.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPE 41.9 , PAGE NO :- 1620"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Sending end voltage is =  33.71 V.\n",
      "Power factor =  0.796 lag\n"
     ]
    }
   ],
   "source": [
    "'''An overhead, single-phase transmission line delivers 1100 kW at 33 kV at 0.8 p.f. lagging. The total resistance of the line is\n",
    "10ohm  and total inductive reactance is 15ohm . Determine\n",
    "(i) sending-end voltage          (ii) sending-end p.f.       and          (iii) transmission efficiency.'''\n",
    "\n",
    "import math as m\n",
    "import cmath as cm\n",
    "#Given\n",
    "P = 1100.0                    #kW     (Power delivered)\n",
    "V = 33.0                      #kV     (Voltage)\n",
    "pf = 0.8                      #       (Power factor)\n",
    "R = 10.0                      #ohm    (Resistance)\n",
    "X = 15.0                      #ohm    (Reactance) \n",
    "#Full-load line current is\n",
    "I = P/(V*pf)                  #A\n",
    "theta = m.acos(pf)            #Q    (power factor angle)\n",
    "I = cm.rect(I,-theta)          #ohm      (impedance)\n",
    "#Line-loss\n",
    "loss = I*I*R/1000             #kW\n",
    "\n",
    "\n",
    "#(iii)Transmission efficiency\n",
    "eff = (P/(P+loss))*100        #%\n",
    "#Line voltage drop is   IZ\n",
    "Z = R + 1j * X\n",
    "\n",
    "\n",
    "#Sending end voltage is\n",
    "Es = V + I*Z/1000                    #V\n",
    "Es1 = m.sqrt(Es.real**2 + Es.imag**2) #V\n",
    "print \"Sending end voltage is = \",round(Es1,2),\"V.\"\n",
    "\n",
    "\n",
    "#Sending end pf angle is\n",
    "theta2 = theta + cm.phase(Es)\n",
    "pf2 = m.cos(theta2)           #power factor\n",
    "\n",
    "print \"Power factor = \",round(pf2,3),\"lag\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.10 , PAGE NO :- 1621"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Max. length in km is =  13.59 km.\n"
     ]
    }
   ],
   "source": [
    "'''What is the maximum length in km for a 1-phase transmission line having copper conductors of 0.775 cm^2 cross-section\n",
    "over which 200 kW at unity power factor and at 3300 V can be delivered ? The efficiency of transmission is 90 per cent.\n",
    "Take specific resistance as (1.725 * 10–8) ohm-m.'''\n",
    "\n",
    "#Given\n",
    "A = 0.775e-4        #m^2     (Area of copper conductor)\n",
    "P = 200.0           #kW       (Power)\n",
    "V = 3300.0          #V        (Voltage)\n",
    "pf = 1.0            #         (Power factor)\n",
    "rho = 1.725e-8      #ohm-m    (Specific Resistance)\n",
    "\n",
    "#Sending-end power is\n",
    "Es = P/0.9          #kW\n",
    "#Line losses\n",
    "loss = Es - P       #kW\n",
    "#Line current\n",
    "I = P/(V*pf)*1000        #A\n",
    "\n",
    "\n",
    "#If R is resistance of consuctor then 2*I^2*R = loss\n",
    "R = loss/(2*I*I)*1000   #ohm\n",
    "\n",
    "#Now, using R = rho*l/A . The length is\n",
    "l = R*A/rho        #m   \n",
    "l = l/1000         #km\n",
    "print \"Max. length in km is = \",round(l,2),\"km.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.11 , PAGE NO :- 1621"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "load current =  209.19 A\n",
      "Voltage at sending end is =  2419.76 V.\n",
      "Sending power =  526.03 kW.\n",
      "Sending end reactive power =  701.38 kVAR.\n",
      "Sending end volt ampere kVA =  876.72 kVA.\n"
     ]
    }
   ],
   "source": [
    "'''An industrial load consisting of a group of induction motors which aggregate 500 kW at 0.6 power factor lagging is\n",
    "supplied by a distribution feeder having an equivalent impedance of (0.15 + j0.6) ohm. The voltage at the load end of\n",
    "the feeder is 2300 volts.\n",
    "(a) Determine the load current.\n",
    "(b) Find the power, reactive power and voltampere supplied to the sending end of the feeder.\n",
    "(c) Find the voltage at the sending end of the feeder.'''\n",
    "\n",
    "import math as m\n",
    "import cmath as cm\n",
    "#Given\n",
    "P = 500.0           #kW       (Power)\n",
    "V = 2300.0          #V        (Voltage)\n",
    "pf = 0.6            #         (Power factor)\n",
    "#(a)line current\n",
    "I = P*1000/(V*pf*1.732)     #A        (Current)\n",
    "theta = m.acos(pf)    #         (Power factor angle)       \n",
    "I1 = cm.rect(I,-theta) #A\n",
    "Z = 0.15 + 1j*0.6      #ohm      (Impedance)\n",
    "\n",
    "#Voltage drop is\n",
    "drop = I1*Z            #V\n",
    "#Sending end voltage is\n",
    "Es = V + drop         #V\n",
    "Es = abs(Es)\n",
    "\n",
    "#Sending end pf angle is\n",
    "theta2 = theta + cm.phase(Es)\n",
    "pf2 = m.cos(theta2)           #power factor\n",
    "pf21 = m.sin(theta2)          #sinQ component\n",
    "\n",
    "#Sending power = root(3)*Vl*Il*cosQ\n",
    "Ps =  1.732*Es*I*pf2/1000            #kW\n",
    "\n",
    "#Sending end reactive power  = root(3)*Vl*Il*sinQ\n",
    "Prs = 1.732*Es*I*pf21/1000           #kVAR\n",
    "\n",
    "#Sending end volt ampere kVA = root(3)*Vl*Il\n",
    "Pvs = 1.732*Es*I/1000                #kVA\n",
    "\n",
    "print \"load current = \",round(I,2),\"A\"\n",
    "print \"Voltage at sending end is = \",round(Es,2),\"V.\"\n",
    "print \"Sending power = \",round(Ps,2),\"kW.\"\n",
    "print \"Sending end reactive power = \",round(Prs,2),\"kVAR.\"\n",
    "print \"Sending end volt ampere kVA = \",round(Pvs,2),\"kVA.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.12 , PAGE NO :- 1622"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Resistance R =  3.24 ohm.\n",
      "Reactance X =  6.11 ohm.\n"
     ]
    }
   ],
   "source": [
    "'''A 33-kV, 3-phase generating station is to supply 10 MW load at 31 kV and 0.9 power factor lagging over a 3-phase\n",
    "transmission line 3 km long. For the efficiency of the line to be 96% , what must be the resistance and reactance of the line?'''\n",
    "\n",
    "import math as m\n",
    "#Given\n",
    "#Power Output\n",
    "pout = 10.0         #MW      (Power output)\n",
    "eff = 0.96          #        (Efficiency)\n",
    "pin = pout/eff      #MW      (Power input)\n",
    "\n",
    "#Total loss\n",
    "loss = pin - pout   #MW\n",
    "\n",
    "#Full-load current I = P/V*pf*root(3)\n",
    "I = pout*1e+6/(31.0e+3*0.9*1.732)     #A\n",
    "\n",
    "#If R is resistance per phase,then 3*I*I*R = loss\n",
    "R = loss*1e+6/(3*I*I)                 #ohm\n",
    "\n",
    "#Now, Vs per phase is\n",
    "Vs = 33/1.732                        #kV\n",
    "#Vr per phase is\n",
    "Vr = 31/1.732                        #kV\n",
    "#Using Vs = Vr + I(RcosQ + XsinQ )\n",
    "X = ((Vs - Vr)/I*1000 - R*0.9)/m.sqrt(1 - 0.9*0.9)\n",
    "\n",
    "print \"Resistance R = \",round(R,2),\"ohm.\"\n",
    "print \"Reactance X = \",round(X,2),\"ohm.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## EXAMPLE 41.13 , PAGE NO :- 1622"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Voltage at recieving end =  59.91 V.\n",
      "Angle between voltages =  3.12 degrees.\n",
      "Transmission efficiency is =  92.59 %.\n"
     ]
    }
   ],
   "source": [
    "'''A balanced Y-connected load of (300 + j100) ohm is supplied by a 3-phase line 40 km long with an impedance of\n",
    "(0.6 + j0.7) ohm per km (line-to-neutral). Find the voltage at the receiving end when the voltage at the sending\n",
    "end is 66 kV. What is the phase angle between these voltages? Also, find the transmission efficiency of the line.'''\n",
    "\n",
    "import math as m\n",
    "from sympy import Symbol,solve,Eq\n",
    "#Resistance for 40 km conductor length\n",
    "R = 40 * 0.6                    #ohm\n",
    "#Reactance for 40 km conductor length\n",
    "X = 40 * 0.7                    #ohm \n",
    "#Total resistance/phase\n",
    "R1 = R + 300                    #ohm\n",
    "#Total reactance/phase\n",
    "X1 = X + 100                    #ohm\n",
    "#Total impedance/phase\n",
    "Z = m.sqrt(R1**2 + X1**2)       #ohm\n",
    "#Line current\n",
    "Il = 66000.0/1.732/Z              #A      \n",
    "\n",
    "#Now,\n",
    "theta = m.atan(100.0/300.0)\n",
    "cosQ = m.cos(theta)\n",
    "sinQ = m.sin(theta)\n",
    "#Voltage drop in conductor resistance\n",
    "dropR =  Il*R                     #V\n",
    "#Voltage drop in conductor reactance\n",
    "dropX =  Il*X                     #V\n",
    "\n",
    "#Let us assume recieving end voltage as Vr\n",
    "Vr = Symbol('Vr')\n",
    "#Sending-end voltage is\n",
    "Vs1 = 66000.0/1.732               #V\n",
    "Vs2 = (Vr + dropR*cosQ + dropX*sinQ)**2 + (dropX*cosQ - dropR*sinQ)**2   #V\n",
    "eq = Eq(Vs1*Vs1,Vs2)\n",
    "Vr = solve(eq)\n",
    "Vr1 = Vr[1]                       #V\n",
    "\n",
    "#Line-voltage across load\n",
    "Vrl = Vr1*1.732/1000              #kV\n",
    "print \"Voltage at recieving end = \",round(Vrl,2),\"V.\"\n",
    "\n",
    "#Angle between voltages\n",
    "a_b = (dropX*cosQ - dropR*sinQ)/(Vr1 + dropR*cosQ + dropX*sinQ)\n",
    "theta2 = m.atan(a_b)*180/3.14 #angle\n",
    "print \"Angle between voltages = \",round(theta2,2),\"degrees.\"\n",
    "#Transmission Efficiency\n",
    "eff = (300.0/R1)*100\n",
    "print \"Transmission efficiency is = \",round(eff,2),\"%.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.14 , PAGE NO :- 1623"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Sending end voltage is =  12.12 V.\n",
      "Power factor =  0.76\n",
      "Transmission Efficiency =  93.93 %\n",
      "Voltage Regulation =  10.2 %\n"
     ]
    }
   ],
   "source": [
    "'''Define ‘regulation’ and ‘efficiency’ of a short transmission line.A 3-phase, 50-Hz, transmission line having resistance of \n",
    "5ohm per phase and inductance of 30 mH per phase supplies a load of 1000 kW at 0.8 lagging and 11 kV at the receiving end. Find.\n",
    "(a) sending end voltage and power factor (b) transmission efficiency (c) regulation.'''\n",
    "\n",
    "import math as m\n",
    "import cmath as cm\n",
    "\n",
    "#Recieving-end Voltage\\phase\n",
    "Vr = 11000.0/1.732                  #V\n",
    "#Line current\n",
    "Il = 1000.0e+3/(1.732*11000.0*0.8)  #A\n",
    "#Inductive reactance\n",
    "Xl = 2*3.14*50*30.0e-3              #ohm\n",
    "R = 5.0                             #ohm\n",
    "#Impedance\n",
    "Z = R + 1j*Xl                       #ohm\n",
    "#drop per conductor\n",
    "theta = m.atan(0.8)\n",
    "Il1 = cm.rect(Il,-theta)\n",
    "drop = Il1*(Z)                       #ohm\n",
    "\n",
    "#(a)Sending end voltage\n",
    "Vs = Vr + drop                      #V\n",
    "Vs1 = abs(Vs)*1.732/1000               #kV\n",
    "#For power factor\n",
    "theta2 = theta + cm.phase(Vs)\n",
    "#Power factor\n",
    "pf = m.cos(theta2)\n",
    "\n",
    "#(b)\n",
    "#Power loss\n",
    "loss = 3*Il*Il*R/1000                #kW\n",
    "#Input Power\n",
    "pin = 1000.0 + loss                  #kW\n",
    "#Transmission efficiency\n",
    "eff = 1000.0/pin *100                #%  \n",
    "# (c)% Voltage regulation\n",
    "reg = (Vs1 - 11.0)/11.0*100            #%\n",
    "\n",
    "print \"Sending end voltage is = \",round(Vs1,2),\"V.\"\n",
    "print \"Power factor = \",round(pf,2)\n",
    "print \"Transmission Efficiency = \",round(eff,2),\"%\"\n",
    "print \"Voltage Regulation = \",round(reg,2),\"%\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.15 , PAGE NO :- 1624"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Active power =  111397.0 kW.\n",
      "Reactive power =  53952.0 kVAR.\n"
     ]
    }
   ],
   "source": [
    "'''A short 3-φ line with an impedance of (6 + j8) ohm per line has sending and receiving end line voltages of 120 and\n",
    "110 kV respectively for some receiving-end load at a p.f. of 0.9. Find the active power and the reactive power at the\n",
    "receiving end.'''\n",
    "\n",
    "import math as m\n",
    "\n",
    "#Given\n",
    "R = 6.0              #ohm\n",
    "X = 8.0              #ohm\n",
    "cosQ = 0.9\n",
    "sinQ = m.sqrt(1 - 0.9*0.9)\n",
    "#Sending end-voltage\n",
    "Vs = 120.0/1.732*1000                 #V\n",
    "#Recieving end-voltage\n",
    "Vr = 110.0/1.732*1000                 #V\n",
    "#Now  Vs = Vr + IRcosQ + IXsinQ.Therefore,line current is\n",
    "I = (Vs - Vr)/(R*cosQ + X*sinQ)  #A\n",
    "\n",
    "#Active Power at recieving end\n",
    "act_pwr = 1.732*110.0*I*cosQ       #kW\n",
    "#Reactive Power at recieving end\n",
    "rct_pwr = 1.732*110.0*I*sinQ       #kVAR\n",
    "\n",
    "print \"Active power = \",round(act_pwr),\"kW.\"\n",
    "print \"Reactive power = \",round(rct_pwr),\"kVAR.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.16 , PAGE NO :- 1624"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "-------pf = 0.707------- \n",
      "% regulation =  15.18\n",
      "Efficiency =  93.8\n",
      "-------pf = 0.9--------- \n",
      "% regulation =  9.36\n",
      "Efficiency =  96.08\n"
     ]
    }
   ],
   "source": [
    "'''A 3-phase, 20 km line delivers a load of 10 MW at 11 kV having a lagging p.f. of 0.707 at the receiving end.\n",
    "The line has a resistance of 0.02 ohm/km phase and an inductive reactance of 0.07 ohm/km/phase. Calculate the regulation\n",
    "and efficiency of the line. If, now, the receiving end p.f. is raised to 0.9 by using static capacitors, calculate the\n",
    "new value of regulation and efficiency.'''\n",
    "\n",
    "import cmath as cm\n",
    "import math as m\n",
    "\n",
    "print \"-------pf = 0.707------- \"\n",
    "#(i) When pf = 0.707   (lag)\n",
    "pf = 0.707\n",
    "#line current  \n",
    "Il = 10.0e+6/(1.732*11000*pf)      #A\n",
    "#Vr per phase\n",
    "Vr = 11000.0/1.732                 #V\n",
    "#Total resistance/phase for 20km\n",
    "R = 20*0.02                        #W\n",
    "#Total reactance/phase for 20km\n",
    "X = 20*0.07                        #W\n",
    "\n",
    "#Total impedance/phase\n",
    "Z = R + 1j*X                       #ohm\n",
    "#If Vr is taken as reference vector,then drop per phase is\n",
    "theta = m.acos(pf)\n",
    "Il1 = cm.rect(Il,-theta)           #A\n",
    "#drop/phase\n",
    "drop = Il1*Z                        #V\n",
    "#Sending end voltage\n",
    "Vs = Vr + drop                    #V\n",
    "Vs1 = abs(Vs)                     #V\n",
    "#% regulation\n",
    "reg = (Vs1 - Vr)/Vr*100\n",
    "print \"% regulation = \",round(reg,2)\n",
    "\n",
    "#Total line loss\n",
    "loss = 3*Il*Il*R/1.0e+6          #MW\n",
    "#Total output\n",
    "tot_op = 10.0 + loss           #MW\n",
    "#Efficiency\n",
    "eff = 10.0/tot_op*100\n",
    "print \"Efficiency = \",round(eff,2)\n",
    "#-----------------------------------------------------------------------------------------------------------------------#\n",
    "print \"-------pf = 0.9--------- \"\n",
    "#(ii) When pf = 0.9    (lag)\n",
    "pf = 0.9\n",
    "#line current  \n",
    "Il = 10.0e+6/(1.732*11000*pf)      #A\n",
    "\n",
    "#If Vr is taken as reference vector,then drop per phase is\n",
    "theta = m.acos(pf)\n",
    "Il1 = cm.rect(Il,-theta)           #A\n",
    "#drop/phase\n",
    "drop = Il1*Z                        #V\n",
    "#Sending end voltage\n",
    "Vs = Vr + drop                    #V\n",
    "Vs1 = abs(Vs)                     #V\n",
    "#% regulation\n",
    "reg = (Vs1 - Vr)/Vr*100\n",
    "print \"% regulation = \",round(reg,2)\n",
    "\n",
    "#Total line loss\n",
    "loss = 3*Il*Il*R/1.0e+6          #MW\n",
    "#Total output\n",
    "tot_op = 10.0 + loss           #MW\n",
    "#Efficiency\n",
    "eff = 10.0/tot_op*100\n",
    "print \"Efficiency = \",round(eff,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.17 , PAGE NO :- 1625"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Sending end-voltage is =  11.86 kV.\n",
      "Total loss =  68.57 kW.\n",
      "Reduction in loss =  24.69 kW.\n"
     ]
    }
   ],
   "source": [
    "'''A load of 1,000 kW at 0.8 p.f. lagging is received at the end of a 3-phase line 10 km long. The resistance and inductance\n",
    "of each conductor per km are 0.531 W and 1.76 mH respectively. The voltage at the receiving end is 11 kV at 50 Hz.\n",
    "Find the sending-end voltage and the power loss in the line. What would be the reduction in the line loss if the p.f.\n",
    "of the load were improved to unity?'''\n",
    "\n",
    "import cmath as cm\n",
    "import math as m\n",
    "\n",
    "#Line current\n",
    "Il = 1000.0 * 1000/(1.732 * 11 * 1000 * 0.8)                   #A\n",
    "#Voltage/phase\n",
    "V = 11000/1.732                                                #V\n",
    "X = 2*3.14*50* 1.76e-3 *10                                     #ohm\n",
    "R= 0.531 * 10                                                  #ohm\n",
    "Z = R + 1j*X\n",
    "#Voltage drop/phase\n",
    "theta = m.acos(0.8)\n",
    "Il1 = cm.rect(Il,-theta)\n",
    "drop = Il1*Z                           #V\n",
    "#Sending end voltage is\n",
    "Vs = V + drop                          #V\n",
    "#line-to-line sending-end voltage\n",
    "Vs1= abs(Vs)*1.732/1000                #kV\n",
    "#Total loss \n",
    "loss = 3*Il*Il*R/1000                  #kW\n",
    "\n",
    "#Line current for unity p.f.\n",
    "Il2  = 1000/(11*1.732)                 #A\n",
    "#New losses\n",
    "new_loss = 3*Il2*Il2*R/1000            #kW\n",
    "\n",
    "#Reduction in loss\n",
    "red_loss = loss - new_loss             #kW\n",
    "\n",
    "print \"Sending end-voltage is = \",round(Vs1,2),\"kV.\"\n",
    "print \"Total loss = \",round(loss,2),\"kW.\"\n",
    "print \"Reduction in loss = \",round(red_loss,2),\"kW.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.18 , PAGE NO :- 1625"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Length of line =  69.55 km.\n"
     ]
    }
   ],
   "source": [
    "'''Estimate the distance over which a load of 15,000 kW at 0.85 p.f. can be delivered by a 3-phase transmission line\n",
    "having conductors of steel-cored aluminium each of resistance 0.905 W per kilometre. The voltage at the receiving end\n",
    "is to be 132 kV and the loss in transmission is to be 7.5% of the load.'''\n",
    "\n",
    "#Line current\n",
    "Il = 15000/(132 * 1.732 * 0.85)                    #A\n",
    "#Total loss\n",
    "loss = (7.5/100)*15000                           #kW\n",
    "\n",
    "#If R is the resistance of one conductor, then 3*I^2*R = loss\n",
    "R = loss*1000/(3*Il*Il)                          #ohm  \n",
    "\n",
    "#Length of the line\n",
    "length = R/0.905                                 #km.\n",
    "print \"Length of line = \",round(length,2),\"km.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## EXAMPLE 41.19 , PAGE NO :- 1625"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Power factor =  0.797\n",
      "Efficiency of transmission line is =  97.15\n"
     ]
    }
   ],
   "source": [
    "'''A 3-phase line has a resistance of 5.31 ohm and inductance of 0.0176 H. Power is transmitted at 33 kV, 50-Hz from one end\n",
    "and the load at the receiving end is 3,600 kW at 0.8 p.f. lagging. Find the line current, receiving-end voltage,\n",
    "sending-end p.f. and efficiency of transmisson.'''\n",
    "\n",
    "from sympy import Symbol,solve,Eq\n",
    "import math as m\n",
    "import cmath as cm\n",
    "\n",
    "#Let us assume that Vr is receiving end voltage\n",
    "Vr = Symbol('Vr')\n",
    "#Power delivered/phase = Vr*I*cosQ.Therefore I is\n",
    "I = (3600.0/3)*1000/(0.8*Vr)\n",
    "#Sending end voltage/phase =\n",
    "Vs = 33000.0/1.732                   #V\n",
    "R = 5.31                             #ohm\n",
    "X = 2*3.14*0.0176*50                 #ohm\n",
    "\n",
    "#Now,\n",
    "cosQ = 0.8\n",
    "sinQ = m.sqrt(1 - 0.8*0.8)\n",
    "\n",
    "#As we know, Vs = Vr + IRcosQ + IXsinQ\n",
    "Vs2 = Vr + I*R*cosQ + I*X*sinQ           #V\n",
    "eq = Eq(Vs,Vs2)\n",
    "Vr = solve(eq)\n",
    "Vr1 = Vr[1]                              #V\n",
    "#Line voltage at receiving end\n",
    "Vrl = Vr1*1.732/1000                     #kV\n",
    "I = (3600.0/3)*1000/(0.8*Vr1)            #A\n",
    "\n",
    "Vs = Vr1 + I*(cosQ - 1j*sinQ)*(R + 1j*X) #V\n",
    "#Power factor\n",
    "theta = m.acos(0.8) + cm.phase(Vs)\n",
    "pf2 = m.cos(theta)\n",
    "print \"Power factor = \",round(pf2,3)\n",
    "#Power lost in line is\n",
    "loss = 3*I*I*R/1000                   #kW\n",
    "#Power at sending end is\n",
    "tot_pwr = 3600.0 + loss               #kW\n",
    "#Eficiency of transmission is\n",
    "eff = 3600.0/tot_pwr*100\n",
    "print \"Efficiency of transmission line is = \",round(eff,2) "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.20 , PAGE NO :- 1626"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Total Maximum power =  18.0 MW.\n",
      "Total kVAR supplied =  28801.69 kW.\n"
     ]
    }
   ],
   "source": [
    "'''A 3-phase short transmission line has resistance and reactance per phase of 15 ohm and 20 ohm respectively. If the sending-end\n",
    "voltage is 33 kV and the regulation of the line is not to exceed 10%, find the maximum power in kW which can be transmitted\n",
    "over the line. Find also the kVAR supplied by the line when delivering the maximum power.'''\n",
    "\n",
    "import math as m\n",
    "\n",
    "#Given\n",
    "Vs = 33000.0/1.732                     #V        (Sending end voltage)\n",
    "Vr = Vs/(1 + 10.0/100)                 #V        (Receiving end voltage)\n",
    "Z = m.sqrt(15**2 + 20**2)              #ohm      (impedance)\n",
    "R = 15.0                               #ohm      (resistance)\n",
    "X = 20.0                               #ohm      (reactance) \n",
    "#Maximum Power transmitted is given by\n",
    "Pmax = (Vr/Z)**2*(Z*(Vs/Vr) - R)       #watts/phase\n",
    "\n",
    "#Total max. power\n",
    "ptot = Pmax*3/1e+6                     #MW\n",
    "\n",
    "#kVAR supplied per phase is given by\n",
    "pkvar =  (Vr/Z)**2*X/1e+3               #kW\n",
    "#Total kVAR supplied\n",
    "kvartot = 3*pkvar                       #kW\n",
    "\n",
    "print \"Total Maximum power = \",round(ptot,2),\"MW.\"\n",
    "print \"Total kVAR supplied = \",round(kvartot,2),\"kW.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.21 , PAGE NO :- 1627"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Sending end voltage =  67.69 kV.\n",
      "Efficiency =  98.8 %\n",
      "Max. value of Q for 3-phases are =  346840.0 kVA.\n"
     ]
    }
   ],
   "source": [
    "'''A 3-phase, 50-Hz generating station supplies a load of 9,900 kW at 0.866 p.f. (lag) through a short overhead transmission line.\n",
    "Determine the sending-end voltage if the receiving-end voltage is 66 kV and also the efficiency of transmission.\n",
    "The resistance per km is 4ohm and inductance 40 mH. What is the maximum power in kVA that can be transmitted through\n",
    "the line if both the sending and receiving-end voltages are kept at 66 kV and resistance of the line is negligible.?'''\n",
    "\n",
    "import math as m\n",
    "#Resistance\n",
    "R = 4.0                #ohm\n",
    "#Reactance\n",
    "X = 40.0e-3*(2*3.14*50)#ohm\n",
    "#Impedance\n",
    "Z = m.sqrt(R*R + X*X)  #ohm\n",
    "#Line current\n",
    "I = 9900.0/(1.732*66*0.866)  #A\n",
    "#Receiving end voltage\n",
    "Vr = 66000.0/1.732           #V\n",
    "#Now,\n",
    "cosQ = 0.866\n",
    "sinQ = m.sqrt(1 - 0.866**2)\n",
    "#Sending end voltage is\n",
    "Vs = Vr + I*R*cosQ + I*X*sinQ    #V\n",
    "#Line value of sending end voltage\n",
    "Vs1 = Vs*1.732/1000              #kV\n",
    "print \"Sending end voltage = \",round(Vs1,2),\"kV.\"\n",
    "#Total line loss\n",
    "loss = 3*I*I*R/1000             #kW\n",
    "#Efficiency is\n",
    "eff = 9900.0/(9900.0 + loss)*100#%\n",
    "print \"Efficiency = \",round(eff,2),\"%\"\n",
    "\n",
    "#Max. value of Q for 3-phases are (As Vs = Vr R is negligible)\n",
    "Z = X                           #ohm   \n",
    "max_value = (3*Vr*Vr)/(Z*Z)*X*1e-3    #kVA\n",
    "print \"Max. value of Q for 3-phases are = \",round(max_value,-1),\"kVA.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.22 , PAGE NO :- 1627"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Power factor at sending end =  0.79\n",
      "Transmission efficiency =  94.73 %\n"
     ]
    }
   ],
   "source": [
    "'''3-phase load of 2000 kVA,0.8 p.f. is supplied at 6.6 kV, 50-Hz by means of a 33 kV transmission line 20 km long and a 5 : 1\n",
    "transformer. The resistance per km of each conductor is 0.4 ohm and reactance 0.5 ohm. The resistance and reactance of the\n",
    "transformer primary are 7.5 ohm and 13.2 ohm, whilst the resistance of the secondary is 0.35 ohm and reactance 0.65 ohm.\n",
    "Find the voltage necessary at the sending end of transformission line when 6.6 kV is maintained at the load-end and find\n",
    "the sending-end power factor. Determine also the efficiency of transmission.'''\n",
    "\n",
    "import math as m\n",
    "#Impedance of high voltage line\n",
    "Zh = 8.0 + 1j*10.0                    #ohm\n",
    "#Impedance of transformer(primary side)\n",
    "Zt = 7.5 + 1j*13.2                    #ohm\n",
    "#Total impedance on high tension side\n",
    "Ztot_h = Zh + Zt                      #ohm\n",
    "#Impedance as referred to secondary side\n",
    "Zsec = Ztot_h/(5**2)                    #ohm\n",
    "\n",
    "#Total impedance on high tension side\n",
    "Ztot_l = Zsec + (0.35 + 1j*0.65)      #ohm\n",
    "\n",
    "#Now,kVA load per phase\n",
    "load = 2000.0/3                       #kVA          \n",
    "#Receiving-end voltage per phase\n",
    "Vr = 6.6/1.732                        #kV\n",
    "#current in line is\n",
    "I = load/Vr                           #A\n",
    "#Now,\n",
    "cosQ = 0.8\n",
    "sinQ = m.sqrt(1 - 0.8*0.8)\n",
    "#Drop per conductor\n",
    "drop = I*(Zsec.real*cosQ + Zsec.imag*sinQ) #V\n",
    "#Sending end voltage is\n",
    "Vs = Vr + drop/1000                       #kV\n",
    "#Sending end voltage referred from high voltage side\n",
    "Vs = Vs*5                                 #kV\n",
    "#Line sending end voltage\n",
    "Vsl = Vs*1.732                            #kV\n",
    "\n",
    "#If theta is phase angle at sending end then\n",
    "tantheta = (sinQ + I*Zsec.imag/(Vr*1000))/(cosQ + I*Zsec.real/(Vr*1000))\n",
    "theta = m.atan(tantheta)\n",
    "pf = m.cos(theta)\n",
    "print \"Power factor at sending end = \",round(pf,2)\n",
    "#power loss/phase\n",
    "loss = (I*I)*0.97/1000                    #kW\n",
    "#power at the receiving end/phase\n",
    "power = 2000.0*cosQ/3                     #kW\n",
    "#Transmission efficiency\n",
    "eff = power/(power + loss)*100\n",
    "print \"Transmission efficiency = \",round(eff,2),\"%\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.23 , PAGE NO :- 1629"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Sending end current is 240.3 A.\n",
      "Sending end voltage is 79598.0 V.\n",
      "Voltage regulation =  20.6 %.\n"
     ]
    }
   ],
   "source": [
    "'''A (medium) single-phase transmission line 50 km long has the following constants :\n",
    "\n",
    "resistance/km = 0.5 ohm           ; reactance/km = 1.6 ohm\n",
    "susceptance/km = 28 * 10−6 S      ; receiving-end line voltage = 66,000 V\n",
    "Assuming that total capacitance of the line is located at receiving end alone, determine the\n",
    "sending-end voltage, the sending-end current and regulation. The line is delivering 15,000 kW at\n",
    "0.8 p.f. lagging. Draw a vector diagram to illustrate your answer.'''\n",
    "\n",
    "\n",
    "import math as m\n",
    "import cmath as cm\n",
    "\n",
    "#Load current at receiving end   Using I = P/VcosQ\n",
    "Ir = 15.0e+6/(66e+3*0.8)                      #A\n",
    "\n",
    "#Total resistance is\n",
    "R = 0.5*50.0                                  #ohm\n",
    "#Total reactance is\n",
    "X = 1.6*50.0                                  #ohm\n",
    "#Susceptance\n",
    "B = 28e-6*50.0                                #Siemens\n",
    "#Capacitive admittance\n",
    "Y = B                                         #Siemens\n",
    "#Sending end current Is is vector sum of load current Ir and capacitive current Ic\n",
    "Er = 66000.0\n",
    "Ic = 1j*Er*Y                             #A\n",
    "theta = m.acos(0.8)\n",
    "Irl = cm.rect(Ir,-theta)                 #A\n",
    "\n",
    "#Sending end current is\n",
    "Is = Irl + Ic                           #A\n",
    "Z = R + 1j*X                            #ohm\n",
    "print \"Sending end current is\",round(abs(Is),2),\"A.\"\n",
    "#line drop\n",
    "drop = Is*Z                             #V\n",
    "#Sending end voltage is\n",
    "Es = Er + drop                          #V\n",
    "print \"Sending end voltage is\",round(abs(Es)),\"V.\"\n",
    "#Voltage regulation is\n",
    "reg = (abs(Es)-abs(Er))/abs(Er)*100                    #%\n",
    "print \"Voltage regulation = \",round(reg,2),\"%.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.24 , PAGE NO :- 1631"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Line value of sending end voltage = 155.43 kV.\n",
      "Power factor =  0.774 lagging.\n"
     ]
    }
   ],
   "source": [
    "'''A 3-phase, 50-Hz overhead transmission line 100 km long with 132 kV between lines at the receiving end has the\n",
    "following constants :\n",
    "\n",
    "resistance/km/phase = 0.15 ohm                                             inductance/km/phase = 1.20 mH\n",
    "capacitance/km/phase = 0.01 mF\n",
    "\n",
    "Determine, using an approximate method of allowing for capacitance, the voltage, current and\n",
    "p.f. at the sending end when the load at the receiving end is 72 MW at 0.8 p.f. lagging. Draw vector\n",
    "diagram for the circuit assumed.'''\n",
    "\n",
    "import math as m\n",
    "import cmath as cm\n",
    "#For a 100-km length of line\n",
    "#Resistance of line is\n",
    "R = 0.15*100                         #ohm\n",
    "Xl = (2*3.14*50)*(1.2e-3)*100        #ohm\n",
    "Xc = 1/(2*3.14*50*0.1e-3)*100       #ohm\n",
    "\n",
    "#Using nominal T-method\n",
    "Vr = 132/1.732                       #kV\n",
    "#Load current\n",
    "Ir = (72e+6)/(1.732*132e+3*0.8)      #A\n",
    "#Load current is\n",
    "theta = m.acos(0.8)\n",
    "Irl = cm.rect(Ir,-theta)             #A\n",
    "#Impedance Zbc is\n",
    "Zbc = R/2 + 1j*Xl/2                  #ohm\n",
    "#Drop/phase over BC is\n",
    "drop = Irl*Zbc                       #V\n",
    "#Now, voltage V1 is\n",
    "V1 = Vr*1000 + drop                  #V\n",
    "\n",
    "#From fig. Ic is\n",
    "Ic = V1/(-1j*Xc)                     #A\n",
    "\n",
    "#Sending end current is\n",
    "Is = Ic + Irl                         #A\n",
    "\n",
    "#Impedance Zab is\n",
    "Zab = R/2 + 1j*Xl/2                  #ohm\n",
    "#Drop/phase over AB is\n",
    "drop2 = Is*Zab                       #V\n",
    "#Sending end voltage is\n",
    "Vs = V1 + drop2                      #V\n",
    "#Line value of sending end voltage is\n",
    "Vsl = 1.732*abs(Vs)/1000             #kV\n",
    "print \"Line value of sending end voltage =\",round(Vsl,2),\"kV.\"\n",
    "#Phase angle between Vs and Is is\n",
    "angle = abs(cm.phase(Vs)) + abs(cm.phase(Is))\n",
    "pf = m.cos(angle)                    #(lag)\n",
    "print \"Power factor = \",round(pf,3),\"lagging.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.25 , PAGE NO :- 1632"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Line value of sending end voltage = 117.15 kV.\n",
      " sending end current = 110.11 A.\n",
      "Efficiency =  95.95 %.\n"
     ]
    }
   ],
   "source": [
    "'''A 3-phase, 50-Hz transmission line, 100 km long delivers 20 MW at 0.9 p.f. lagging and at 110 kV. The resistance and\n",
    "reactance of the line per phase per km are 0.2 ohm and 0.4 ohm respectively while the capacitive admittance is 2.5 * 10e−6 S per\n",
    "km. Calculate (a) the voltage and current at the sending end and (b) the efficiency of transmission. Use the nominal T-method.'''\n",
    "\n",
    "import math as m\n",
    "import cmath as cm\n",
    "\n",
    "#Resistance for 100 km is\n",
    "R = 0.2*100                              #ohm\n",
    "#Reactance for 100 km is\n",
    "X = 0.4*100                              #ohm\n",
    "#Capacitive admittance for 100 km is\n",
    "Y = 2.5e-6*100                           #Siemens\n",
    "#Receiving end voltage Er is\n",
    "Er = 110.0/1.732                         #kV\n",
    "Ir = 20.0e+6/(1.732*110e+3*0.9)          #A\n",
    "#Now\n",
    "cosQ = 0.9\n",
    "sinQ = m.sqrt(1 - 0.9*0.9)\n",
    "theta = m.acos(0.9)              \n",
    "Irl = cm.rect(Ir,-theta)                 #A\n",
    "\n",
    "#Impedance is\n",
    "Zbc = R/2 + 1j*X/2                       #ohm\n",
    "#Voltage drop between point B and C is\n",
    "dropbc = Irl*Zbc                             #V\n",
    "V1 = Er*1000 + dropbc                       #V\n",
    "\n",
    "#Current through capacitor              \n",
    "Ic = V1*1j*Y                                   #A\n",
    "\n",
    "#Sending end current is\n",
    "Is = Ic + Irl                               #A\n",
    "Zab = Zbc\n",
    "#Voltage drop between point A and B is\n",
    "dropab = Irl*Zab                             #V\n",
    "Vs = V1  + dropab                            #V\n",
    " \n",
    "#Line value of sending end voltage is\n",
    "Vsl = 1.73*abs(Vs)/1000             #kV\n",
    "print \"Line value of sending end voltage =\",round(Vsl,2),\"kV.\"\n",
    "print \" sending end current =\",round(abs(Is),2),\"A.\"\n",
    "              \n",
    "#Phase angle between Vs and Is is\n",
    "angle = abs(cm.phase(Vs)) + abs(cm.phase(Is))\n",
    "pf = m.cos(angle)                    #(lag)\n",
    "\n",
    "#Input power\n",
    "pin = 1.73*abs(Vsl)*abs(Is)*pf/1e+3         #MW\n",
    "\n",
    "#Efficiency\n",
    "eff = 20.0/pin*100\n",
    "print \"Efficiency = \",round(eff,2),\"%.\"          \n",
    "                            "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.26 , PAGE NO :- 1635"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Line value of sending-end voltage 174.83 kV.\n",
      "power factor =  0.75\n"
     ]
    }
   ],
   "source": [
    "'''A 3-phase transmission line,100 km long has following constants:\n",
    "resistance per km per phase = 0.28 ohm    ;       inductive reactance per km per phase = 0.63 ohm .\n",
    "Capacitive susceptance per km per phase = 4 * 10e-6 siemens.\n",
    "If the load at the receiving end is 75 MVA at 0.8 p.f. lagging with 132 kV between lines calculate sending-end voltage,\n",
    "current and p.f. Use nominal-pi-method.'''\n",
    "\n",
    "import math as m\n",
    "import cmath as cm\n",
    "\n",
    "#For 100 km length line\n",
    "#Resistance/phase\n",
    "R = 0.28*100               #ohm\n",
    "#Inductive Reactance/phase\n",
    "Xl = 0.63*100              #ohm\n",
    "#Capacitive Susceptance/phase\n",
    "Y = 4.0e-6*100             #S\n",
    "#Capacitive Susceptance at each end\n",
    "Y = 1j*Y/2                    #S\n",
    "#Receiving end voltage Vr is\n",
    "Vr = 132e+3/1.732          #V\n",
    "#Receiving end current Ir is\n",
    "Ir = 75.0e+6/(1.732*132e+3*0.8)  #A\n",
    "theta = m.acos(0.8)\n",
    "Irl = cm.rect(Ir,-theta)   #A\n",
    "#Current through capacitance is\n",
    "Ic = Vr*Y                  #A\n",
    "#Now\n",
    "Il = Ic + Irl             #A\n",
    "\n",
    "#Drop per conductor is\n",
    "Zl = R +1j*Xl              #ohm\n",
    "drop = Il*Zl               #V\n",
    "\n",
    "#sending end voltage\n",
    "Vs = Vr + drop\n",
    "#Line value of sending-end voltage\n",
    "Vsl = abs(Vs)*1.732/1000             #kV\n",
    "print \"Line value of sending-end voltage\",round(Vsl,2),\"kV.\"\n",
    "#\n",
    "Ic2 = Vs*Y                 #A\n",
    "Is = Ic2 + Il\n",
    "\n",
    "#Angle between VS and IS\n",
    "angle = abs(cm.phase(Vs)) + abs(cm.phase(Is))     \n",
    "pf = m.cos(angle)\n",
    "#cos41.4 = 0.75 \n",
    "print \"power factor = \",round(pf,2) "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.27 , PAGE NO :- 1637"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Regulation =  15.18 %\n",
      "Transmission efficiency =  95.02 %.\n"
     ]
    }
   ],
   "source": [
    "'''A 100-km long, three-phase, 50-Hz transmission line has resistance/phase/km = 0.1 ohm ; reactance/phase/km = 0.5 ohm ; \n",
    "susceptance/phase/km = 10 * 10−6 siemens.If the line supplies a load of 20 MW at 0.9 p.f. lagging at 66 kV at the receiving end,\n",
    "calculate by nominal ‘p’ method, the regulation and efficiency of the line.Neglect leakage.'''\n",
    "\n",
    "import math as m\n",
    "import cmath as cm\n",
    "#For a 100 km line\n",
    "#resistance/phase\n",
    "R = 0.1 * 100                         #ohm\n",
    "#inductive reactance/phase\n",
    "Xl = 0.5 * 100                        #ohm\n",
    "#Capacitive susceptance/phase\n",
    "Yc = 10.0 * 1.0e-6 * 100               #siemens\n",
    "#Susceptance at each end\n",
    "Yc = 1j*Yc/2                          #siemens\n",
    "#Voltage at receiving end is\n",
    "Vr = 66.0e+3/1.732                    #V\n",
    "Ir = 20.0e+6/(1.732*66e+3*0.9)        #A\n",
    "theta = m.acos(0.9)\n",
    "Irl = cm.rect(Ir,-theta)              #A\n",
    "Ic1  = Vr*Yc                          #A\n",
    "Il = Irl + Ic1                         #A\n",
    "\n",
    "#drop/conductor\n",
    "Zl = R + 1j*Xl                        #ohm\n",
    "drop = Il*Zl                          #V\n",
    "#Sending end voltage is\n",
    "Vs = Vr + drop                        #V\n",
    "#Line value of sending end voltage\n",
    "Vsl = abs(Vs)*1.732/1000                   #kV\n",
    "Ic2 = Vs*Yc                           #A\n",
    "#Sending end current is\n",
    "Is = Ic2 + Il                         #A     \n",
    "\n",
    "#Phase angle between Vs and Is is\n",
    "angle = abs(cm.phase(Vs)) + abs(cm.phase(Is))\n",
    "pf = m.cos(angle)                    #(lag)\n",
    "\n",
    "\n",
    "#(i) Regulation is\n",
    "reg = (abs(Vsl) - 66.0)/66.0 * 100  \n",
    "print \"Regulation = \",round(reg,2),\"%\"\n",
    "#(ii)Efficiency\n",
    "#Input power is\n",
    "pin = 1.732*Vsl*abs(Is)*pf*1000.0/1.0e+6   #MW\n",
    "\n",
    "eff = 20.0/pin*100                   #%\n",
    "\n",
    "print \"Transmission efficiency = \",round(eff,2),\"%.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.28 , PAGE NO :- 1638"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Line value of sending end voltage =  122.24 kV.\n",
      "Sending end current =  195.65 A.\n",
      "Transmission efficiency =  95.36 %.\n",
      "Receiving end voltage =  63148.47 V.\n",
      "Receiving end current =  19.0 A.\n"
     ]
    }
   ],
   "source": [
    "'''(a) A 50-Hz, 3-phase, 100-km long line delivers a load of 40 MVA at 110 kV and 0.7 p.f. lag. The line constants\n",
    "(line to neutral) are :\n",
    "resistance of 11 ohms, inductive reactance of 38 ohms and capacitive susceptance of 3 * 10−4 siemens. Find the sending-end\n",
    "voltage, current,power factor and efficiency of power transmission.\n",
    "(b) draw the vector diagram.\n",
    "(c) If the sending-end voltage is held constant and load is removed, calculate the receiving-end voltage and current.'''\n",
    "\n",
    "\n",
    "import math as m\n",
    "import cmath as cm\n",
    "\n",
    "#resistance/phase\n",
    "R = 11.0                        #ohm\n",
    "#inductive reactance/phase\n",
    "Xl = 38.0                       #ohm\n",
    "#Capacitive susceptance/phase\n",
    "Yc = 3.0e-4                     #siemens\n",
    "#Susceptance at each end\n",
    "Yc = 1j*Yc/2                          #siemens\n",
    "#Voltage at receiving end is\n",
    "Vr = 110.0e+3/1.732                    #V\n",
    "Ir = 40.0e+6/(1.732*110e+3)        #A\n",
    "theta = m.acos(0.7)\n",
    "Irl = cm.rect(Ir,-theta)              #A\n",
    "Ic1  = Vr*Yc                          #A\n",
    "Il = Irl + Ic1                         #A\n",
    "\n",
    "#drop/conductor\n",
    "Zl = R + 1j*Xl                        #ohm\n",
    "drop = Il*Zl                          #V\n",
    "#Sending end voltage is\n",
    "Vs = Vr + drop                        #V\n",
    "#Line value of sending end voltage\n",
    "Vsl = abs(Vs)*1.732/1000                   #kV\n",
    "Ic2 = Vs*Yc                           #A\n",
    "#Sending end current is\n",
    "Is = Ic2 + Il                         #A     \n",
    "print \"Line value of sending end voltage = \",round(Vsl,2),\"kV.\"\n",
    "print \"Sending end current = \",round(abs(Is),2),\"A.\"\n",
    "#Phase angle between Vs and Is is\n",
    "angle = abs(cm.phase(Vs)) + abs(cm.phase(Is))\n",
    "pf = m.cos(angle)                    #(lag)\n",
    "\n",
    "#Efficiency\n",
    "#Input power is\n",
    "pin = 1.732*Vsl*abs(Is)*pf*1000.0/1.0e+6   #MW\n",
    "\n",
    "eff = (40.0*0.7)/pin*100                   #%\n",
    "\n",
    "print \"Transmission efficiency = \",round(eff,2),\"%.\"\n",
    "\n",
    "\n",
    "#(c)Under no-load condition, current in the conductor is  Ic1\n",
    "#Drop/phase =\n",
    "drop = Ic1*Zl                      #V\n",
    "#Sending end voltage is\n",
    "Vs = Vr + drop                     #V\n",
    "Ic2 = Vs*Yc                         #A\n",
    "Is = Ic1 + Ic2                     #A\n",
    "print \"Receiving end voltage = \",round(abs(Vs),2),\"V.\"\n",
    "print \"Receiving end current = \",round(abs(Is),2),\"A.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.29 , PAGE NO :- 1640"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Sending end voltage is =  59558.07 V.\n",
      "Sending end current is =  282.23 A.\n",
      "Sending end power is =  48.99 MW.\n",
      "Transmission efficiency =  81.65 %\n"
     ]
    }
   ],
   "source": [
    "'''Find the following for a single-circuit transmission line delivering a load of 50 MVA at 110 kV and p.f. 0.8 lagging :\n",
    "(i) sending-end voltage,    (ii) sending-end current,    (iii) sending-end power,        (iv) efficiency of\n",
    "transmission. (Given A = D = 0.98 ∠3º , B = 110 ∠75º ohm, C = 0.0005 ∠80º ohm).'''\n",
    "\n",
    "import math as m\n",
    "import cmath as cm\n",
    "\n",
    "#Receiving end voltage Vr is\n",
    "Vr = 110.0/1.732                      #kV\n",
    "Ir = 50.0e+6/(1.732*110e+3)           #A\n",
    "theta = m.acos(0.8)\n",
    "Irl = cm.rect(Ir,theta)              #A\n",
    "\n",
    "#Now,\n",
    "A = D = cm.rect(0.98,3*3.14/180)\n",
    "B = cm.rect(110.0,75*3.14/180)\n",
    "C = cm.rect(0.0005,80*3.14/180)\n",
    "\n",
    "#(i)Sending end voltage is\n",
    "Vs = A*Vr*1000 + B*Irl                       #V\n",
    "print \"Sending end voltage is = \",round(abs(Vs),2),\"V.\"\n",
    "#(ii)Sending end current is\n",
    "Is = C*Vr*1000 + D*Irl                       #A\n",
    "print \"Sending end current is = \",round(abs(Is),2),\"A.\"\n",
    "#Angle between Vs and Is is\n",
    "angle = cm.phase(Is) - cm.phase(Vs)\n",
    "pf = m.cos(angle)\n",
    "\n",
    "#(iii)Sending end power is\n",
    "s_pwr = 3*abs(Vs)*abs(Is)*pf/1.0e+6               #MW\n",
    "print \"Sending end power is = \",round(s_pwr,2),\"MW.\"\n",
    "#Receiving end power is\n",
    "r_pwr = 50.0*0.8                        #MW\n",
    "#(iv)Transmission efficiency\n",
    "eff = r_pwr/s_pwr*100                   #%\n",
    "print \"Transmission efficiency = \",round(eff,2),\"%\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.30 , PAGE NO :- 1640"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "A =  (0.9325+0.016875j)\n",
      "B =  (22.5+90j)\n",
      "C =  (-1.265625e-05+0.001449375j)\n",
      "D =  (0.9325+0.016875j)\n",
      "Voltage regulation  =  34.77 %.\n"
     ]
    }
   ],
   "source": [
    "'''A 150 km, 3-φ, 110-V, 50-Hz transmission line transmits a load of 40,000 kW at 0.8 p.f. lag at receiving end.\n",
    "resistance/km/phase = 0.15 ohm, reactance/km/phase = 0.6 ohm ; susceptance/km/phase = 10e−5 S\n",
    "(a) determine the A, B, C and D constants of the line .                          (b) find regulation of the line.'''\n",
    "\n",
    "import math as m\n",
    "import cmath as cm\n",
    "\n",
    "#For a 150km length line\n",
    "R = 0.15*150.0                    #ohm\n",
    "X = 0.6*150.0                     #ohm\n",
    "Y = 1j*1.0e-5*150.0               #S\n",
    "Z = R + 1j*X                      #ohm\n",
    "\n",
    "#(a)\n",
    "A = D = 1 + Y*Z/2\n",
    "B = Z\n",
    "C = Y*(1 + Y*Z/4)\n",
    "print \"A = \" ,A\n",
    "print \"B = \" ,B\n",
    "print \"C = \" ,C\n",
    "print \"D = \" ,D\n",
    "#(b)\n",
    "Vr = 110/1.732*1000              #V\n",
    "Ir = 40.0e+6/(1.732*110*0.8*1000)#A\n",
    "theta = m.acos(0.8)\n",
    "Irl = cm.rect(Ir,-theta)         #A\n",
    "#Sending end voltage is\n",
    "Vs = A*Vr + B*Irl                 #V\n",
    "\n",
    "#Now,   Vs = A*Vro  =>  Vro = Vs/A\n",
    "Vro = Vs/A                       #V\n",
    "\n",
    "#Voltage regulation\n",
    "reg = (abs(Vro) - abs(Vr))/abs(Vr)*100\n",
    "print \"Voltage regulation  = \",round(reg,2),\"%.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.31 , PAGE NO :- 1641"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Regulation =  29.97 %\n",
      "Charging current Ic =  (-7.1+127.64j) A.\n"
     ]
    }
   ],
   "source": [
    "'''A 132-kV, 50-Hz, 3-phase transmission line delivers a load of 50 MW at 0.8 p.f. lagging at receiving-end.\n",
    "The generalised constants of the transmission line are A = D = 0.95 ∠1.4º ; B = 96 ∠ 7.8º ; C = 0.0015 ∠90º\n",
    "Find the regulation of the line and the charging current. Use nominal T-method.'''\n",
    "\n",
    "import math as m\n",
    "import cmath as cm\n",
    "\n",
    "#Given\n",
    "A = D = cm.rect(0.95,1.4*3.14/180)\n",
    "B = cm.rect(96.0,78*3.14/180)\n",
    "C = cm.rect(0.0015,90*3.14/180)\n",
    "\n",
    "#Receiving end voltage\n",
    "Ir = 50e+6/(1.732*132e+3*0.8)             #A\n",
    "theta = m.acos(0.8)\n",
    "Irl = cm.rect(Ir,-theta)                  #A\n",
    "Vr = 132e+3/1.732                         #V\n",
    "#Sending end voltage\n",
    "Vs = A*Vr + B*Irl                         #V\n",
    "#Sending end current\n",
    "Is = C*Vr + D*Irl                         #A\n",
    "Vro = abs(Vs)/abs(A)\n",
    "\n",
    "#% Regulation\n",
    "reg = (abs(Vro) - abs(Vr))/abs(Vr)*100        #%\n",
    "\n",
    "print \"Regulation = \",round(reg,2),\"%\"\n",
    "#Charging current\n",
    "Ic =  Is - Irl                            #A\n",
    "print \"Charging current Ic = \",complex(round(Ic.real,2),round(Ic.imag,2)),\"A.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## EXAMPLE 41.32 , PAGE NO :- 1641"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "A =  A1*A2 + B1*C2\n",
      "C =  A2*C1 + C2*D1\n",
      "B =  A1*B2 + B1*D2\n",
      "D =  B2*C1 + D1*D2\n"
     ]
    }
   ],
   "source": [
    "'''A 3-phase transmission line consists of two lines 1 and 2 connected in series,line 1 being at the sending end and\n",
    "2 at the receiving end. The respective auxiliary constants of the two lines are :\n",
    "A1, B1, C1, D1 and A2, B2, C2, D2. Find the A, B, C, D constants of the whole line which is equivalent to two\n",
    "series-connected lines.'''\n",
    "\n",
    "from sympy import Symbol\n",
    "A1 = Symbol('A1')\n",
    "B1 = Symbol('B1')\n",
    "C1 = Symbol('C1')\n",
    "D1 = Symbol('D1')\n",
    "\n",
    "A2 = Symbol('A2')\n",
    "B2 = Symbol('B2')\n",
    "C2 = Symbol('C2')\n",
    "D2 = Symbol('D2')\n",
    "\n",
    "Vr = Symbol('Vr')\n",
    "Ir = Symbol('Ir')\n",
    "\n",
    "#--------For A &C---------------#\n",
    "Ir = 0\n",
    "Vr = 1\n",
    "#For line no. 2\n",
    "V = A2*Vr + B2*Ir\n",
    "I = C2*Vr + D2*Ir  \n",
    "\n",
    "#For line no. 1\n",
    "Vs = A1*V + B1*I\n",
    "Is = C1*V + D1*I\n",
    "\n",
    "#For A\n",
    "print \"A = \",Vs\n",
    "print \"C = \",Is\n",
    "\n",
    "#--------For B & D---------------#\n",
    "Ir = 1\n",
    "Vr = 0\n",
    "#For line no. 2\n",
    "V = A2*Vr + B2*Ir\n",
    "I = C2*Vr + D2*Ir  \n",
    "\n",
    "#For line no. 1\n",
    "Vs = A1*V + B1*I\n",
    "Is = C1*V + D1*I\n",
    "\n",
    "#For A\n",
    "print \"B = \",Vs\n",
    "print \"D = \",Is\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.33 , PAGE NO :- 1644"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Critical voltage =  136.01 kV.\n"
     ]
    }
   ],
   "source": [
    "'''Find the disruptive critical voltage for a transmission line having :\n",
    "conductor spacing = 1 m                  ;                            conductor (stranded) radius = 1 cm\n",
    "barometric pressure = 76 cm of Hg        ;                            temperature = 40ºC\n",
    "Air break-down potential gradient (at 76 cm of Hg and at 25ºC) = 21.1 kV (r.m.s.)/cm.'''\n",
    "\n",
    "import math as m\n",
    "\n",
    "#Given\n",
    "g0 = 21.1            #kV/cm (air breakdown potential gradient)\n",
    "m0 = 0.85            #(assumed)\n",
    "d = 3.92*76/(273 + 40)\n",
    "r = 1.0              #cm\n",
    "D = 100.0            #cm\n",
    "\n",
    "#Vc = 2.3*m0*g0*d*r*log(D/r)\n",
    "Vc = 2.3*m0*g0*d*r*m.log10(D/r)    #kV\n",
    "#Line voltage\n",
    "Vc = 1.732*Vc\n",
    "print \"Critical voltage = \",round(Vc,2),\"kV.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.34 , PAGE NO :- 1644"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Critical voltage =  152.4 kV.\n",
      "visual corona voltage =  157.67 kV.\n"
     ]
    }
   ],
   "source": [
    "'''Find the disruptive critical and visual corona voltage of a grid-line operating at 132 kV.\n",
    "conductor dia = 1.9 cm                      ;                   conductor spacing = 3.81 m\n",
    "temperature = 44ºC                          ;                   barometric pressure = 73.7 cm\n",
    "conductor surface factor :   fine weather = 0.8               ; rough weather = 0.66.'''\n",
    "\n",
    "\n",
    "import math as m\n",
    "\n",
    "#Given\n",
    "\n",
    "m0 = 0.8             #\n",
    "d = 3.92*73.7/(273 + 44)\n",
    "r = 1.9              #cm\n",
    "D = 381.0              #cm\n",
    "\n",
    "#Vc = 2.3*m0*g0*d*r*log(D/r)\n",
    "Vc = 48.8*m0*d*r/2*m.log10(2*D/r)    #kV\n",
    "#Line voltage\n",
    "Vc = 1.732*Vc\n",
    "print \"Critical voltage = \",round(Vc,2),\"kV.\"\n",
    "\n",
    "#(b)\n",
    "#Vv = 2.3*g0*mv*d*r*(1 + 0.3/root(d*r))*log10(D/r)\n",
    "mv = 0.66\n",
    "Vv = 48.8*mv*d*r*(1 + 0.3/m.sqrt(d*r))*m.log10(D/r)\n",
    "print \"visual corona voltage = \",round(Vv,2),\"kV.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## EXAMPLE 41.35 , PAGE NO :- 1644"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Critical disruptive voltage =  53.34 kV/km.\n",
      "Corona loss =  121.49 kW.\n"
     ]
    }
   ],
   "source": [
    "'''A certain 3-phase equilateral transmission line has a total corona loss of 53 kW at 106 kV and a loss of 98 kW at 110.9 kV.\n",
    "What is the disruptive critical voltage between lines? What is the corona loss at 113 kV?'''\n",
    "\n",
    "from sympy import Symbol,solve,Eq\n",
    "\n",
    "#total corona loss P o< (V- Vc)^2\n",
    "# P1/P2 = (V1 - Vc)^2/(V2 - Vc)^2\n",
    "\n",
    "V1 = 106/1.732   #kV\n",
    "V2 = 110.9/1.732 #kV\n",
    "#Let Vc be distruptive critical voltage\n",
    "Vc = Symbol('Vc')\n",
    "#ratio P1/P2 =\n",
    "P1_P2a = 53.0/98.0\n",
    "#Ratio (V1 - Vc)^2/(V2 - Vc)^2\n",
    "P1_P2b = (V1 - Vc)**2/(V2 - Vc)**2\n",
    "#Equating the ratios\n",
    "eq = Eq(P1_P2a,P1_P2b)\n",
    "Vc = solve(eq)\n",
    "Vc1 = Vc[0]                #kV/km\n",
    "\n",
    "#Now,  W/98 = (Vb - Vc)^2/(V2 - Vc)^2\n",
    "W = 98*(113/1.732 - Vc1)**2/(V2 - Vc1)**2     #kW\n",
    "print \"Critical disruptive voltage = \",round(Vc1,2),\"kV/km.\"\n",
    "print \"Corona loss = \",round(W,2),\"kW.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.36 , PAGE NO :- 1645"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "corona power loss per km =  1.76 kW/km/phase.\n"
     ]
    }
   ],
   "source": [
    "'''A 3-phase, 50-Hz, 220-kV transmission line consists of conductors of 1.2 cm radius spaced 2 metres at the corners of an\n",
    "equilateral triangle. Calculate the corona power loss per km of the line at a temperature of 20ºC and barometric pressure of \n",
    "72.2 cm.Take the surface factors of the conductor as 0.96.'''\n",
    "\n",
    "import math as m\n",
    "\n",
    "#As we know P = 241*(f+25)/d*root(r/D)*(V-Vc)^2\n",
    "#Here,\n",
    "d = 3.92*(72.2)/(273 + 20)\n",
    "#Given\n",
    "m0 = 0.96            #    (surface factors) \n",
    "D = 200.0            #cm  (distance btwn condr.)\n",
    "r = 1.2              #cm  (radius of condr.)\n",
    "#Critical Voltage\n",
    "Vc = 48.8*m0*d*r*m.log10(D/r)        #kV/phase\n",
    "V = 220.0/1.732                      #kV/phase\n",
    "P = 241*(50+25)/d*m.sqrt(r/D)*(V-Vc)**2*1.0e-5      #kW/km/phase\n",
    "#Total loss for 3-phase\n",
    "loss = 3*P                                        #kW/km/phase\n",
    "print \"corona power loss per km = \",round(loss,2),\"kW/km/phase.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.37 , PAGE NO :- 1648"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Sheath diameter =  8.29 cm.\n"
     ]
    }
   ],
   "source": [
    "'''A single-core lead-covered cable is to be designed for 66-kV to earth. Its conductor radius is 1.0 cm and its three insulating\n",
    "materials A, B, C have permittivities of 5.4 and 3 respectively with corresponding maximum safe working stress of 38 kV per cm\n",
    "(r.m.s. value), 26-kV per cm and 20-kV per cm respectively. Find the minimum diameter of the lead sheath.'''\n",
    "\n",
    "import math as m\n",
    "from sympy import solve,Symbol,Eq\n",
    "\n",
    "#Given\n",
    "gA =  38.0                           #kV/cm        (working stress on A)\n",
    "gB =  26.0                           #kV/cm        (working stress on B)\n",
    "gC =  20.0                           #kV/cm        (working stress on C)\n",
    "ea =  5.0                            #             (rel. permittivity of A)\n",
    "eb =  4.0                            #             (rel. permittivity of B)\n",
    "ec =  3.0                            #             (rel. permittivity of C)\n",
    "ra = 1.0                             #cm           (radius A)\n",
    "#Working stress O< 1/(rel. permittivty)*(condr. radius)\n",
    "#gA/gB =  rb*eb/ra*ea\n",
    "#Radius of B is\n",
    "rb = (gA/gB)*(ra*ea/eb)             #cm \n",
    "#gA/gC =  rc*ec/ra*ea\n",
    "#Radius of C is\n",
    "rc = (gA/gC)*(ra*ea/ec)             #cm\n",
    "\n",
    "#Now , V = g*r*2.3*log10(r1/r)\n",
    "\n",
    "V1 = gA*ra*2.3*m.log10(rb/ra)      #kV\n",
    "V2 = gB*rb*2.3*m.log10(rc/rb)      #kV\n",
    "V = 66.0                           #kV\n",
    "V3  = V - V1 - V2                 #V\n",
    "\n",
    "#Let the radius of sheath be rs\n",
    "#V3 = gC*rc*2.3*m.log10(rs/rc)      #kV . Therefore, rs is\n",
    "\n",
    "rs =  rc * 10**(V3/(gC*rc*2.3))                      #cm\n",
    "print \"Sheath diameter = \",round(2*rs,2),\"cm.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.38 , PAGE NO :- 1649"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Charging current =  4.31 A.\n"
     ]
    }
   ],
   "source": [
    "'''The capacitances per kilometer of a 3-phase cable are 0.63 μF between the three cores bunched and the sheath and 0.37 μF\n",
    "between one core and the other two connected to sheath. Calculate the charging current taken by eight kilometres of this cable\n",
    "when connected to a 3-phase, 50-Hz, 6,600-V supply.'''\n",
    "\n",
    "#According to question  0.63 = 3*Cs\n",
    "Cs = 0.63/3         #uF/km\n",
    "#Also 0.37 = 2*C1 + Cs\n",
    "C1 = (0.37 - Cs)/2  #uF/km\n",
    "#For 8 km\n",
    "Cs = Cs*8          #uF\n",
    "C1 = C1*8          #uF\n",
    "\n",
    "Cn = Cs + 3*C1     #uF\n",
    "Vp = 6600.0/1.732  #V\n",
    "w = 2*3.14*50.0    #rad/s\n",
    "#Charging current is\n",
    "Ic = Vp*(w*Cn*1e-6)     #A\n",
    "print \"Charging current = \",round(Ic,2),\"A.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.39 , PAGE NO :- 1649"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Charging for 15 km =  48.0 A.\n"
     ]
    }
   ],
   "source": [
    "'''A 3-core, 3-phase belted cable tested for capacitance between a pair of cores on single phase with the third core earthed,\n",
    "gave a capacitance of 0.4 mF per km. Calculate the charging current for 1.5 km length of this cable when connected to 22 kV, \n",
    "3-phase,50-Hz supply.'''\n",
    "\n",
    "\n",
    "Cl = 0.4             #uF  (Capacitance)\n",
    "Vl = 22000.0         #V   (line voltage)\n",
    "w = 2*3.14*50        #rad/s\n",
    "#Charging current\n",
    "Ic = (2.0/1.732)*Vl*Cl*w*1.0e-6     #A/km\n",
    "#Charging current for 15 km\n",
    "Ic = 15*Ic                   #A\n",
    "print \"Charging for 15 km = \",round(Ic),\"A.\"\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.40 , PAGE NO :- 1649"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Capacitance (i) =  0.33 uF.\n",
      "Capacitance (ii) =  0.13 uF.\n",
      "capacitance between 2 shorted conductors and the other =  0.49 uF.\n"
     ]
    }
   ],
   "source": [
    "'''A 3-core, 3-phase metal-sheathed cable has (i) capacitance of 1 μF between shorted conductors and sheath and (ii) capacitance\n",
    "between two conductors shorted with the sheath and the third conductor 0.6 μF. Find the capacitance\n",
    "(a) between any two conductors                                  (b) between any two shorted conductors and the third conductor.'''\n",
    "\n",
    "#(a)\n",
    "#(i)As we know 3*Cs = 1.0\n",
    "Cs = 1.0/3                #uF\n",
    "#(ii) 2*C1 + Cs = 0.6         #uF\n",
    "C1 = (0.6 - Cs)/2         #uF\n",
    "print \"Capacitance (i) = \",round(Cs,2),\"uF.\"\n",
    "print \"Capacitance (ii) = \",round(C1,2),\"uF.\"\n",
    "#(b)\n",
    "#capacitance between 2 shorted conductors and the other is given by\n",
    "Cn = 2*C1 + (2.0/3)*Cs    #uF\n",
    "print \"capacitance between 2 shorted conductors and the other = \",round(Cn,2),\"uF.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.41 , PAGE NO :- 1650"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Voltage drop from A to B  =  (7.47+2.78j) V.\n"
     ]
    }
   ],
   "source": [
    "'''A 2-wire a.c. feeder 1 km long supplies a load of 100 A at 0.8 p.f. lag 200 volts\n",
    "at its far end and a load of 60 A at 0.9 p.f. lag at its mid-point. The resistance and reactance per km\n",
    "(lead and return) are 0.06 ohm and 0.08 ohm respectively. Calculate the voltage drop along the\n",
    "distributor from sending end to mid-point and from mid-point to far end.'''\n",
    "\n",
    "import math as m\n",
    "import cmath as cm\n",
    "\n",
    "#Voltage at C\n",
    "Vc = 200.0                #V\n",
    "theta = m.acos(0.8)\n",
    "Ic = 100.0                #A\n",
    "Icl = cm.rect(Ic,-theta)  #A\n",
    "#Loop impedance of feeder BC is\n",
    "Z = (0.06 + 1j*0.08)/2    #ohm\n",
    "#Voltage drop in BC \n",
    "drop = Icl*Z              #V\n",
    "#Voltage at B is\n",
    "Vb = Vc + drop            #V\n",
    "#Current at B is\n",
    "Ib = 60.0                 #A\n",
    "theta = m.acos(0.9)\n",
    "Ibl = cm.rect(Ib,-theta)  #A\n",
    "#Current in feeder AB is\n",
    "Iab = Ibl + Icl             #A\n",
    "#Drop in AB is\n",
    "dropab = Iab*Z            #V\n",
    "print \"Voltage drop from A to B  = \",complex(round(dropab.real,2),round(dropab.imag,2)),\"V.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.42 , PAGE NO :- 1651"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "drop =  5.0 V.\n"
     ]
    }
   ],
   "source": [
    "'''A single-phase a.c. distributor 500 m long has a total impedance of (0.02 + j 0.04) ohm and is fed from one end at\n",
    "250V. It is loaded as under :\n",
    "(i) 50 A at unity power factor 200 m from feeding point.\n",
    "(ii) 100 A at 0.8 p.f. lagging 300 m from feeding point.\n",
    "(iii) 50 A at 0.6 p.f. lagging at the far end.\n",
    "Calculate the total voltage drop and voltage at the far end.'''\n",
    "\n",
    "#Using 3rd method\n",
    "import math as m\n",
    "import cmath as cm\n",
    "\n",
    "#The center of gravity(C.G) of load is at the following distance from feeding end\n",
    "\n",
    "cg = (50.0*200 + 100.0*300 + 50.0*500)/(50 + 100 + 50)     #m\n",
    "\n",
    "#Value of resistance upto CG\n",
    "R = cg*0.02/500                                #ohm\n",
    "#Value of reactance upto CG\n",
    "X = cg*0.04/500                                #ohm\n",
    "#Average pf\n",
    "pf = (50*1 + 100.0*0.8 + 50.0*0.6)/200\n",
    "cosQ = pf\n",
    "sinQ = m.sqrt(1 - pf*pf)\n",
    "#Drop is\n",
    "Itot = 50.0 + 100.0 + 50.0                     #A\n",
    "drop = 200.0*(R*cosQ + X*sinQ)                 #V\n",
    "print \"drop = \",round(drop),\"V.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.43 , PAGE NO :- 1652"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Supply voltage =  345.0 V.\n",
      "Supply Voltage lead B by =   4.59 degrees.\n"
     ]
    }
   ],
   "source": [
    "'''A single-phase distributor, one km long has resistance and reactance per conductor of 0.2 ohm and 0.3 ohm respectively. At the\n",
    "far end, the voltage VB = 240 V and the current is 100 A at a power factor of 0.8 lag. At the mid-point A of the distributor \n",
    "current of 100 A is tapped at a power factor of 0.6 lag with reference to the voltage VA at the mid-point. Calculate the supply\n",
    "voltage VS for the distributor and the phase angle between VS and VB.'''\n",
    "\n",
    "import math as m\n",
    "import cmath as cm\n",
    "\n",
    "#Given\n",
    "Vb = 240.0                  #V   (Voltage at B)\n",
    "Ib = 100.0                  #A   (current)\n",
    "theta = m.acos(0.8)\n",
    "Ibl = cm.rect(Ib,-theta)    #A\n",
    "X = 0.2 + 1j*0.3            #ohm\n",
    "#Drop over AB\n",
    "dropab = Ibl*(X)            #V\n",
    "\n",
    "#Voltage at A\n",
    "Va = Vb + dropab            #V\n",
    "\n",
    "#Phase angle between A and B\n",
    "ang = cm.phase(Va)\n",
    "theta2 = m.acos(0.6)\n",
    "theta2 = theta2 - ang\n",
    "Ia = 100.0                  #A\n",
    "Ial = cm.rect(Ia,-theta2)   #A\n",
    "\n",
    "#Total I\n",
    "I = Ial + Ibl               #A\n",
    "#Drop in section\n",
    "dropsa = I*X                #V\n",
    "\n",
    "#Voltage at S\n",
    "Vs = Va + dropsa            #V\n",
    "print \"Supply voltage = \",round(abs(Vs)),\"V.\"\n",
    "print \"Supply Voltage lead B by =  \",round(cm.phase(Vs)*180/3.14,2),\"degrees.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.44 , PAGE NO :- 1653"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Ia =  (25-24j) A.\n"
     ]
    }
   ],
   "source": [
    "'''A 1-phase ring distributor ABC is fed at A. The loads at B and C are 20 A at 0.8 p.f. lagging and 15 A at 0.6 p.f.\n",
    "lagging respectively, both expressed with reference to voltage at A. The total impedances of the sections AB, BC and\n",
    "CA are (1 + j1), (1 + j2) and (1 + j3) ohm respectively. Find the total current fed at A and the current in each section.'''\n",
    "\n",
    "import math as m\n",
    "import cmath as cm\n",
    "\n",
    "\n",
    "#Current in AB is\n",
    "theta = m.acos(0.8) \n",
    "Iab = cm.rect(20,-theta)\n",
    "\n",
    "#Current in AC is\n",
    "theta = m.acos(0.6) \n",
    "Iac   = cm.rect(15,-theta)\n",
    "\n",
    "#Impedances of dif. section\n",
    "Zab = 1 + 1j                 #ohm\n",
    "Zbc = 1 + 1j*2               #ohm\n",
    "Zca = 1 + 1j*3               #ohm\n",
    "\n",
    "#Drop over AB is\n",
    "dropab = Iab*Zab            #V\n",
    "\n",
    "#Drop over AC is\n",
    "dropac = Iac*Zca            #V\n",
    "\n",
    "#Potential diff. B and C is\n",
    "pd_bc = dropac - dropab     #V\n",
    "\n",
    "#Equivalent Thevenin's thm  impedance across bc\n",
    "Ztot = Zab + Zca + Zbc      #ohm\n",
    "\n",
    "#Current in BC\n",
    "Ibc = pd_bc/Ztot            #A\n",
    "\n",
    "#Total current in AB is\n",
    "Iab2 = Iab + Ibc            #A\n",
    "\n",
    "#Total current in BC is\n",
    "Ibc2 = Iac - Ibc           #A\n",
    "\n",
    "#Total current fed at point A\n",
    "Ia = Iab2 + Ibc2            #A\n",
    "\n",
    "print \"Ia = \",Ia,\"A.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.45 , PAGE NO :- 1654"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "I1 =  (19.5-16.5j) A.\n",
      "I2 =  (14.5-19.5j) A.\n",
      "I3 =  (3.5-4.5j) A.\n",
      "Vb =  (347.5-22.5j) V.\n",
      "Vc =  (327-24j) V.\n"
     ]
    }
   ],
   "source": [
    "'''A 2-wire ring distributor ABC is supplied at A at 400 V. Point loads of 20 A at a p.f. of 0.8 lagging and 30 A at a p.f. 0.6\n",
    "lagging are tapped off at B and C respectively. Both the power factors refer to the voltage at A. The respective go-and-return \n",
    "impedances of sections AB,BC and CA are (1 + j2) ohm, (2 + j3) ohm and (1 + j3) ohm. Calculate the current flowing through each\n",
    "section and the potentials at B and C. Use Superposition theorem.'''\n",
    "\n",
    "import math as m\n",
    "import cmath as cm\n",
    "\n",
    "\n",
    "#Current in AB is\n",
    "theta = m.acos(0.8) \n",
    "Iab = cm.rect(20,-theta)\n",
    "\n",
    "#Current in AC is\n",
    "theta = m.acos(0.6) \n",
    "Iac   = cm.rect(30,-theta)\n",
    "\n",
    "#Impedances of dif. section\n",
    "Zab = 1 + 1j*2                 #ohm\n",
    "Zbc = 2 + 1j*3               #ohm\n",
    "Zca = 1 + 1j*3               #ohm\n",
    "\n",
    "#Let the currents in AB and AC is Ia1 and Ia2\n",
    "Ia1 = Iab*(Zbc + Zca)/(Zbc + Zca + Zab)        #A\n",
    "\n",
    "\n",
    "Ia2 = Iab - Ia1                              #A\n",
    "\n",
    "#Let the currents in AB and AC is Ia11 and Ia22\n",
    "Ia11 = Iac*(Zca)/(Zbc + Zca + Zab)        #A\n",
    "Ia22 = Iac - Ia11                        #A\n",
    "\n",
    "#As per superposition thm,\n",
    "I1 = Ia1 + Ia11                        #A\n",
    "I2 = Ia2 + Ia22                        #A\n",
    "I3 = Ia11 - Ia2                        #A\n",
    "\n",
    "#Potential Of B is\n",
    "Vb = 400.0 - I1*Zab               #V\n",
    "#Potential of C is \n",
    "Vc = 400.0 - I2*Zca               #V\n",
    "\n",
    "print \"I1 = \",I1,\"A.\"\n",
    "print \"I2 = \",I2,\"A.\"\n",
    "print \"I3 = \",I3,\"A.\"\n",
    "print \"Vb = \",Vb,\"V.\"\n",
    "print \"Vc = \",Vc,\"V.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.46 , PAGE NO :- 1655"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Iab =  (139.76-42.81j) A\n",
      "Ibc =  (99.76-12.81j) A\n",
      "Icd =  (-20.24-12.81j) A\n",
      "Ida =  (-80.86+22.2j) A\n"
     ]
    }
   ],
   "source": [
    "'''A 3-phase ring main ABCD, fed from end A, supplies balanced loads of 50 A at 0.8 p.f. lagging at B, 120 A at u.p.f. at C and\n",
    "70 A at 0.866 p.f. lagging at D, the load currents being referred to the voltage at point A.The impedance per phase of the various\n",
    "line sections are :\n",
    "section AB = (1 + j0.6)ohm                         ;           section BC = (1.2 + j0.9) ohm\n",
    "section CD = (0.8 + j0.5)ohm                       ;           section DA = (3 + j2) ohm\n",
    "Determine the currents in the various sections.'''\n",
    "\n",
    "from sympy import Symbol\n",
    "import math as m\n",
    "import cmath as cm\n",
    "import numpy as np\n",
    "\n",
    "#Let the current in section AB = (x + jy)A\n",
    "x = Symbol('x')\n",
    "y = Symbol('y')\n",
    "Iab = x + 1j*y                                 #A\n",
    "#Current in BC\n",
    "theta = m.acos(0.8)\n",
    "Icl = cm.rect(50.0,-theta)                     #A\n",
    "Ibc = Iab - Icl                                #A\n",
    "#Current in CD\n",
    "Icd = Ibc - 120                                #A\n",
    "#Current in DA\n",
    "theta = m.acos(0.866)\n",
    "Idl = cm.rect(70.0,-theta)                     #A\n",
    "Ida = Icd - Idl                                #A\n",
    "#Applying kirchoff's law\n",
    "V = (1 + 1j*0.6)*Iab + (1.2 + 1j*0.9)*Ibc + (0.8 + 1j*0.5)*Icd + (3 + 1j*2)*Ida    #V\n",
    "#Equating V to 0 we get following two equations\n",
    "# 6*x - 4*y + 1009.8 = 0              -   1 \n",
    "# 4*x + 6*y - 302.2 = 0               -   2\n",
    "\n",
    "\n",
    "a = np.array([[6,-4], [4,6]])\n",
    "b = np.array([1009.8,302.2])\n",
    "vec = np.linalg.solve(a, b)\n",
    "x = vec[0]\n",
    "y = vec[1]\n",
    "\n",
    "\n",
    "Iab = x + 1j*y                                 #A\n",
    "#Current in BC\n",
    "Ibc = Iab - Icl                                #A\n",
    "#Current in CD\n",
    "Icd = Ibc - 120                                #A\n",
    "#Current in DA\n",
    "Ida = Icd - Idl                                #A\n",
    "\n",
    "print \"Iab = \",complex(round(Iab.real,2),round(Iab.imag,2)),\"A\"\n",
    "print \"Ibc = \",complex(round(Ibc.real,2),round(Ibc.imag,2)),\"A\"\n",
    "print \"Icd = \",complex(round(Icd.real,2),round(Icd.imag,2)),\"A\"\n",
    "print \"Ida = \",complex(round(Ida.real,2),round(Ida.imag,2)),\"A\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.47 , PAGE NO :- 1656"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Power transmitted by 1st line =  5283.01 kW.\n",
      "Power transmitted by 2nd line =  6716.99 kW.\n",
      "Total power(check) =  12000.0 kW.\n"
     ]
    }
   ],
   "source": [
    "'''A total load of 12,000 kW at a power factor of 0.8 lagging is transmitted to a substation by two overhead\n",
    "three-phase lines connected in parallel. One line has a conductor resistance of 2 ohm per conductor and reactance\n",
    "(line to neutral) of 1.5 ohm, the corresponding values for the other line being 1.5 and 1.2 ohm respectively. Calculate\n",
    "the power transmitted by each overhead line.'''\n",
    "\n",
    "import math as m\n",
    "import cmath as cm\n",
    "\n",
    "#Let us assume a line voltage of 1000 kV for convinience.\n",
    "Z1 = 2 + 1j*1.5                      #ohm        \n",
    "Z2 = 1.5 + 1j*1.2                    #ohm\n",
    "#Total load current\n",
    "Il = 12000/(1.732*1000*0.8)          #A\n",
    "theta = m.acos(0.8)\n",
    "Il1 = cm.rect(Il,-theta)             #A\n",
    "\n",
    "#Now\n",
    "I1 = Il1*Z2/(Z1 + Z2)                  #A\n",
    "\n",
    "#Power transmitted by 1st line\n",
    "P1 = 1.732*I1.real*1000            #kW\n",
    "\n",
    "#Now\n",
    "I2 = Il1*Z1/(Z1 + Z2)                  #A\n",
    "\n",
    "#Power transmitted by 1st line\n",
    "P2 = 1.732*I2.real*1000            #kW\n",
    "\n",
    "#Total power\n",
    "power = P1 + P2                    #kW\n",
    "print \"Power transmitted by 1st line = \",round(P1,2),\"kW.\"\n",
    "print \"Power transmitted by 2nd line = \",round(P2,2),\"kW.\"\n",
    "print \"Total power(check) = \",round(power,2),\"kW.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## EXAMPLE 41.48 , PAGE NO :- 1658"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "V1 =  7.54 kV\n",
      "V2 =  8.29 kV\n",
      "V3 =  9.87 kV\n",
      "V4 =  12.45 kV\n",
      "string efficiency =  76.55 %\n"
     ]
    }
   ],
   "source": [
    "'''For a string insulator with four discs, the capacitance of the disc is ten times the capacitance between the pin and earth.\n",
    "Calculate the voltage across each disc when used on a 66-kV line. Also, calculate the string efficiency.'''\n",
    "\n",
    "import math as m\n",
    "from sympy import Symbol,solve,Eq\n",
    "#Let C be self capacitance and kC be capacitance b/w each link and earth,\n",
    "#Given\n",
    "k = 10.0\n",
    "#Let voltage across 1st disc be\n",
    "V1 = Symbol('V1')\n",
    "V2 = (1+k)/k*V1                  #V\n",
    "V3 = (1 + 3/k + 1/k**2)*V1       #V\n",
    "V4 = (1 + 6/k + 5/k**2 + 1/k**3)*V1       #V\n",
    "#Voltage V is\n",
    "Va = V1 + V2 + V3 + V4            #kV\n",
    "Vb = 66/1.73                     #kV\n",
    "eq = Eq(Va,Vb)\n",
    "V1 = solve(eq)\n",
    "V1l = V1[0]                      #kV\n",
    "V2 = (1+k)/k*V1l                  #V\n",
    "V3 = (1 + 3/k + 1/k**2)*V1l       #V\n",
    "V4 = (1 + 6/k + 5/k**2 + 1/k**3)*V1l       #V\n",
    "print \"V1 = \",round(V1l,2),\"kV\"\n",
    "print \"V2 = \",round(V2,2),\"kV\"\n",
    "print \"V3 = \",round(V3,2),\"kV\"\n",
    "print \"V4 = \",round(V4,2),\"kV\"\n",
    "#string efficiency\n",
    "eff = 66.0/(4*1.732*V4)*100           #%\n",
    "print \"string efficiency = \",round(eff,2),\"%\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.49 , PAGE NO :- 1659"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "V1 =  5.51 kV\n",
      "V2 =  6.12 kV\n",
      "V3 =  7.42 kV\n",
      "string efficiency =  85.63 %\n"
     ]
    }
   ],
   "source": [
    "'''Explain what is meant by string efficiency and how it can be improved. Each line of a 3-phase, 33-kV system is suspended by a\n",
    "string of 3 identical insulator discs. The capacitance of each disc is 9 times the capacitance to ground. Find voltage distribution\n",
    "across each insulator and the string efficiency. Suggest a method for improving the string efficiency.'''\n",
    "\n",
    "import math as m\n",
    "from sympy import Symbol,solve,Eq\n",
    "#Let C be self capacitance and kC be mutual capacitance b/w each\n",
    "#Given\n",
    "k = 9.0\n",
    "#Let voltage across 1st disc be\n",
    "V1 = Symbol('V1')\n",
    "V2 = (1+k)/k*V1                  #V\n",
    "V3 = (1 + 3/k + 1/k**2)*V1       #V\n",
    "\n",
    "#Voltage V is\n",
    "Va = V1 + V2 + V3                 #kV\n",
    "Vb = 33/1.732                     #kV    \n",
    "eq = Eq(Va,Vb)\n",
    "V1 = solve(eq)\n",
    "V1l = V1[0]                      #kV\n",
    "V2 = (1+k)/k*V1l                  #V\n",
    "V3 = (1 + 3/k + 1/k**2)*V1l       #V\n",
    "\n",
    "print \"V1 = \",round(V1l,2),\"kV\"\n",
    "print \"V2 = \",round(V2,2),\"kV\"\n",
    "print \"V3 = \",round(V3,2),\"kV\"\n",
    "\n",
    "#string efficiency\n",
    "eff = 33.0/(3*1.732*V3)*100           #%\n",
    "print \"string efficiency = \",round(eff,2),\"%\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.50 , PAGE NO :- 1660"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Bus-bar voltage of station A =  33.79 kV\n",
      "phase angle  =  1.75 degrees\n"
     ]
    }
   ],
   "source": [
    "'''The bus-bar voltages of two stations A and B are 33 kV and are in phase. If station A sends 8.5 MW power at u.p.f.\n",
    "to station B through an interconnector having an impedance of (3 + j4) ohm , determine the bus-bar voltage of station A\n",
    "and the phase angle shift between the busbar voltages.'''\n",
    "\n",
    "import cmath as cm\n",
    "\n",
    "#Voltage of station B is\n",
    "Vb = 33000.0/1.732         #V/phase\n",
    "\n",
    "#Power transferred\n",
    "pin = 8.5                   #MW\n",
    "\n",
    "#Current in interconnector\n",
    "I = pin*1e+6/(1.732*33000)\n",
    "\n",
    "#Voltage  Va is\n",
    "Va = Vb + I*(3+1j*4)\n",
    "#Bus-bar voltage of station A is\n",
    "Va1 = 1.732*abs(Va)/1000      #kV\n",
    "\n",
    "print \"Bus-bar voltage of station A = \",round(Va1,2),\"kV\"\n",
    "print \"phase angle  = \",round(cm.phase(Va)*180/3.14,2),\"degrees\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.51 , PAGE NO :- 1666"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Clearance between conductor and water at mid-way =  62.0 m.\n"
     ]
    }
   ],
   "source": [
    "'''A transmission line conductor at a river crossing is supported from two towers at heights of 70 m above water level.\n",
    "The horizontal distance between towers is 300 m. If the tension in conductor is 1,500 kg, find the clearance at a point\n",
    "midway between the towers. The size of conductor is 0.9 cm2. Density of conductor material is 8.9 g/cm3 and suspension\n",
    "length of the string is 2 metres.'''\n",
    "\n",
    "#Given\n",
    "l = 300.0/2                    #m               (distance of mid pt from one tower)\n",
    "T = 1500.0                     #kg-wt           (tension)\n",
    "\n",
    "#density = mass/volume. Therefore Weight (W) = rho*l*A\n",
    "W = (0.9e-4)*(8.9e+3)      #kg-wt\n",
    "\n",
    "#Sag in the line\n",
    "sag = (W*l**2)/(2*T)             #m\n",
    "\n",
    "\n",
    "#Clearance between conductor and water at mid-way\n",
    "cler = 70.0 - sag - 2.0        #m\n",
    "print \"Clearance between conductor and water at mid-way = \",round(cler),\"m.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.52 , PAGE NO :- 1666"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Total weight per metre run of line =  2.46 kg-wt/m.\n"
     ]
    }
   ],
   "source": [
    "'''The effective diameter of a line is 1.96 cm and it weighs 90 kg per 100 metre length. What would be the additional loading due\n",
    "to ice of radial thickness 1.25 cm and a horizontal wind pressure of 30 kg/m^2 of projected area? Also, find the total weight \n",
    "per metre run of the line.Density of ice is 920 kg/m^3.'''\n",
    "\n",
    "import math as m\n",
    "\n",
    "#Given\n",
    "W = 90.0/100                #kg/m       (weight of condr)\n",
    "#Weight due to ice is Wi = 3.14*rho*R*(D+R)\n",
    "Wi = 3.14*920.0*0.0125*(0.0196 + 0.0125)         #kg/m    (Weight of ice)\n",
    "#Weight due to wind is Ww = P*(D + 2*R)\n",
    "Ww = 30.0*(0.0196 + 2*0.0125)          #kg/m\n",
    "\n",
    "#Total weight is given by\n",
    "\n",
    "Wt = m.sqrt((W+Wi)**2 + Ww**2)         #kg-wt/m\n",
    "\n",
    "print \"Total weight per metre run of line = \",round(Wt,2),\"kg-wt/m.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.53 , PAGE NO :- 1666"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "sag =  3.27 m.\n"
     ]
    }
   ],
   "source": [
    "'''A transmission line has a span of 150 metres between supports, the supports being at the same level. The conductor has a\n",
    "cross-sectional area of 2 cm^2. The ultimate strength is 5,000 kg/cm^2. The specific gravity of the material is 8.9. If the wind\n",
    "pressure is 1.5 kg/m length of the conductor, calculate the sag at the centre of the conductor if factor of safety is 5.'''\n",
    "\n",
    "\n",
    "import math as m\n",
    "\n",
    "#Safety factor = Ultimate stress/Working stress\n",
    "sf = 5.0                               #Safety factor\n",
    "wstress = 5000.0/sf                    #kg/cm^2\n",
    "#Tension\n",
    "A = 2.0                        #cm^2   (cross-sectional area)\n",
    "T = wstress*A                          #kg-wt\n",
    "#Volume of 1m of conductor\n",
    "V = A*100.0                            #cm^3\n",
    "#Wt of 1m of material                               Using   density = mass/volume\n",
    "W = 8.9*200.0/1000.0                   #kg-wt\n",
    "#W is 1.78 and not 1.98\n",
    "\n",
    "#Total weight per metre\n",
    "Wt = m.sqrt(W**2 + 1.5**2)\n",
    "\n",
    "#Sag = W*l^2/2T\n",
    "l = 150.0/2                            #m  (length from pole to centre)\n",
    "sag = Wt*l**2/(2*T)                    #m\n",
    "\n",
    "\n",
    "print \"sag = \",round(sag,2),\"m.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.54 , PAGE NO :- 1667"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Verticle Sag =  5.38 m.\n"
     ]
    }
   ],
   "source": [
    "'''A transmission line has a span of 200 metres between level supports. The conductor has a cross-sectional area of 1.29 cm^2,\n",
    "weighs 1,170 kg/km and has a breaking stress of 4,218 kg/cm2. Calculate the sag for a factor of safety of 5 allowing a wind pressure\n",
    "of 122 kg per m^2 of projected area. What is the vertical sag?'''\n",
    "\n",
    "import math as m\n",
    "\n",
    "#Safety factor =  ultimate stress/working stress    \n",
    "wstress = 4218.0/5                                     #kg/cm2     (working stress)\n",
    "#Working tension\n",
    "A = 1.29                                               #cm^2       (cross-sectional area) \n",
    "T = wstress*A                                          #kg-wt\n",
    "W = 1170.0/1000                                        #kg-wt/m\n",
    "#Let us now find diameter of the conductor from the equation\n",
    "# A = 3.14 * d^2/4\n",
    "d  = m.sqrt(4*A/3.14)/100                              #m \n",
    "#Projected area of the conductor per metre length\n",
    "proArea = d*1                                          #m^2\n",
    "#Weight of wind exerted\n",
    "Ww = 122*proArea                                       #kg-wt/m\n",
    "\n",
    "#Total weight\n",
    "Wt = m.sqrt(W**2 + Ww**2)                              #kg-wt/m\n",
    "\n",
    "#Slant sag\n",
    "l = 200.0/2                                            #m\n",
    "sag = Wt*l**2/(2*T)                                    #m\n",
    "\n",
    "#Now, tan θ = Ww/W\n",
    "tanQ = Ww/W\n",
    "#vertical sag\n",
    "vsag = sag*m.cos(m.atan(tanQ))                         #m\n",
    "print \"Verticle Sag = \",round(vsag,2),\"m.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.55 , PAGE NO :- 1667"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Max. sag produced =  3.93 m.\n",
      "Verticle sag =  2.36 m.\n"
     ]
    }
   ],
   "source": [
    "'''A transmission line has a span of 214 metres. The line conductor has a cross-section of 3.225 cm^2 and has an ultimate \n",
    "breaking strengh of 2,540 kg/cm^2. Assuming that the line is covered with ice and provides a combined copper and ice load of\n",
    "1.125 kg/m while the wind pressure is 1.5 kg/m run (i) calculate the maximum sag produced. Take a factor of safety of 3\n",
    "(ii) also determine the vertical sag.'''\n",
    "\n",
    "import math as m\n",
    "\n",
    "#(i) Maximum sag\n",
    "#Here,\n",
    "W = 1.125                             #kg-wt/m\n",
    "Ww = 1.5                              #kg-wt/m\n",
    "Wt =  m.sqrt(1.125**2 + 1.5**2)       #kg-wt/m\n",
    "#Safety factor = ultimate stress/working stress\n",
    "wstress = 2540.0/3                    #kg-wt/cm2\n",
    "#Permissible tension\n",
    "A = 3.225                             #cm^2       (cross-sectional area)    \n",
    "T = wstress*(3.225)                   #kg-wt\n",
    "#Sag is\n",
    "l = 214.0/2                           #m \n",
    "sag = Wt*l**2/(2*T)                   #m\n",
    "\n",
    "#(ii)Verticle Sag\n",
    "#Now,\n",
    "tanQ = Ww/W\n",
    "cosQ = m.cos(m.atan(tanQ))\n",
    "#vertical sag\n",
    "vsag = sag*cosQ                       #m\n",
    "print \"Max. sag produced = \",round(sag,2),\"m.\"\n",
    "print \"Verticle sag = \",round(vsag,2),\"m.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.56 , PAGE NO :- 1658"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Minimum clearance =  23.02 m.\n",
      "Hence, clearance point =   30.7 m.\n"
     ]
    }
   ],
   "source": [
    "'''Two towers of height 30 and 90 m respectively support a transmission line conductor at water crossing. The horizontal\n",
    "distance between the towers is 500 m. If the tension in the conductor is 1,600 kg, find the minimum clearance of the\n",
    "conductor and the clearance of the conductor mid-way between the supports. Weight of the conductor is 1.5 kg/m. Bases of\n",
    "the towers can be considered to be at the water level.'''\n",
    "\n",
    "\n",
    "#Given\n",
    "l = 500.0/2             #m         (mid-way of towers)\n",
    "h = 90.0 - 30.0         #m         (height)\n",
    "T = 1600.0              #kg-wt     (tension)\n",
    "W = 1.5                 #kg-wt/m   (weight)\n",
    "\n",
    "#Point of maximum sag is\n",
    "x1 = l - h*T/(2*W*l)\n",
    "\n",
    "#Sag is\n",
    "sag = W*x1**2/(2*T)       #m\n",
    "\n",
    "#Minimum clearance is\n",
    "cler = 30.0 - sag        #m\n",
    "print \"Minimum clearance = \",round(cler,2),\"m.\"\n",
    "#Taking this point as reference , sag of mid-pt is\n",
    "sag2 = W*(l-x1)**2/(2*T) #m\n",
    "\n",
    "#Mid-point Clearance\n",
    "cler2 = cler + sag2\n",
    "print \"Hence, clearance point =  \",round(cler2,2),\"m.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## EXAMPLE 41.57 , PAGE NO :- 1658"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Clearance of conductor from water surface =  63.89 m.\n"
     ]
    }
   ],
   "source": [
    "'''An overhead transmission line at a river crossing is supported from two towers at heights of 50 m and 100 m above the\n",
    "water level, the horizontal distance between the towers being 400 m. If the maximum allowable tension is 1,800 kg and the\n",
    "conductor weighs 1 kg/m, find the clearance between the conductor and water at a point mid-way between the towers.'''\n",
    "\n",
    "#Given\n",
    "h = 100.0 - 50.0             #m        (height)\n",
    "l = 400.0/2                  #m        (mid-way length)\n",
    "T = 1800.0                   #kg-wt    (tension)\n",
    "W = 1.0                      #kg-wt/m  (Weigth)\n",
    "#Point of max sag\n",
    "x1 = l - h*T/(2*W*l)         #m\n",
    "x2 = l + h*T/(2*W*l)         #m\n",
    "\n",
    "#Distance of mid-pt from the above point is\n",
    "d1 = (x2 - x1)/2             #m\n",
    "\n",
    "#Therefore height of P above max sag point is\n",
    "h1 = W*d1**2/(2*T)           #m\n",
    "h2 = W*x2**2/(2*T)           #m\n",
    "\n",
    "#Therefore point P from top is\n",
    "Psag = h2 - h1               #m\n",
    "\n",
    "#Clearance above ground is\n",
    "cler = 100.0 - Psag          #m\n",
    "\n",
    "print \"Clearance of conductor from water surface = \",round(cler,2),\"m.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## EXAMPLE 41.58 , PAGE NO :- 1659"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Horizontal Tension =  2373.42 kg-wt/m.\n"
     ]
    }
   ],
   "source": [
    "'''A conductor is strung across a river, being supported at the two ends at heights of 20 m and 16 m respectively, from the bed\n",
    "of the river. The distance between the supports is 375 m and the weight of the conductor = 1.2 kg/m.If the clearance of the\n",
    "conductor from the river bed be 9 m, find the horizontal tension in the conductor. Assume a parabolic configuration and that\n",
    "there is no wind or ice loading.'''\n",
    "\n",
    "from sympy import Symbol,solve,Eq\n",
    "\n",
    "#Given\n",
    "l = 375.0/2                     #m   (mid-pt of towers)\n",
    "h = 20.0 - 16.0                 #m   (height)\n",
    "W = 1.2                         #kg-wt/m\n",
    "\n",
    "#Let T be the tension in conductor\n",
    "T = Symbol('T')\n",
    "x1 = l - h*T/(2*W*l)            #m\n",
    "\n",
    "#Minimum clearance\n",
    "cler = 9.0                      #m       \n",
    "sag = 16.0 - cler               #m\n",
    "\n",
    "#Now ,sag is also\n",
    "sag2 = (W*x1*x1)/(2*T)            #m\n",
    "\n",
    "#Equating the two equations\n",
    "eq = Eq(sag,sag2)\n",
    "T = solve(eq)\n",
    "T1 = T[0]                       #kg-wt/m\n",
    "print \"Horizontal Tension = \",round(T1,2),\"kg-wt/m.\""
   ]
  }
 ],
 "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
}