summaryrefslogtreecommitdiff
path: root/DC_Machines_and_Synchronous_Machines/ch6.ipynb
blob: b222858598b0f1ed8d7e7b7ab91985ba5464ee9a (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
{
 "metadata": {
  "name": "",
  "signature": "sha256:9f548e729a327e12aefb50cf84c5cae777df427713c1104c34d610a547e935f3"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 6 : Synchronization and Parallel Operation of Alternators"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      " \n",
      "Example 6.2  Page no : 31"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "X_d = 0.7 \n",
      "X_q = 0.4  \t\t\t#direct and quadrature axis synchronous reactance p.u.\n",
      "R_a = 0\n",
      "phi = math.acos(0.8)  \t\t\t#Lag\n",
      "\n",
      "V_t = 1. \t\t\t#assumed rated terminal Voltage \n",
      "I_a = 1. \t\t\t#Full-load armature current\n",
      "\n",
      "# Calculations\n",
      "psi = math.atan(  (V_t*math.sin(phi)+I_a*X_q)/(V_t*math.cos(phi)+I_a*R_a)            )\n",
      "delta = psi-phi\n",
      "I_d = I_a*math.sin(psi)\n",
      "I_q = I_a*math.cos(psi)\n",
      "E_f = V_t*math.cos(delta)+I_d*X_d+I_q*R_a\n",
      "\n",
      "# Results\n",
      "print 'Total e.m.f induced on open circuit is %.4f p.u.'%(E_f)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Total e.m.f induced on open circuit is 1.5149 p.u.\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.3 Page no :  35"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "import cmath\n",
      "\n",
      "#note that a new function p2z has been defined below for direct representation of complex numbers in polar form\n",
      "def  p2z(RRRR,Theeeta):\n",
      "        return  RRRR*cmath.exp((math.pi*Theeeta/180.)*1j);\n",
      "\n",
      "# Variables\n",
      "Z1 = complex(0,3) \t\t\t#impedance of alternator 1\n",
      "Z2 = complex(0,4) \t\t\t#impedance of alternator 2\n",
      "Z = 6.       #load\n",
      "\n",
      "E1 = p2z(220,0) \t\t\t#induced emf vector on no load\n",
      "E2 = p2z(220,10)\t\t\t#induced emf vector on no load\n",
      "\n",
      "# Calculations and Results\n",
      "I1 = ((E1-E2)*Z+E1*Z2)/(Z*(Z1+Z2)+Z1*Z2)\n",
      "I2 = ((E2-E1)*Z+E2*Z1)/(Z*(Z1+Z2)+Z1*Z2)\n",
      "\n",
      "phi1 = math.degrees(math.atan(I1.imag/I1.real))  \t\t\t#Phasemag returns the angle of complex number in degrees\n",
      "phi2 = math.degrees(math.atan(I2.imag/I2.real))  \t\t\t#Phasemag returns the angle of complex number in degrees\n",
      "\n",
      "I = I1+I2\n",
      "V = I*Z \t\t\t#Terminal voltage\n",
      "print 'i) Terminal voltage is %.1f volts at %.2f degrees'%(abs(V),math.degrees(math.atan(V.imag/V.real)))\n",
      "print 'ii) Currents are %.2f A at %.2f degrees and %.2f A at %.2f degrees      \\\n",
      "\\nTotal current is %.2f A at %.2f degrees  '%(abs(I1),math.degrees(math.atan(I1.imag/I1.real)),\\\n",
      "                                              abs(I2),math.degrees(math.atan(I2.imag/I2.real)),\\\n",
      "                                              abs(I),math.degrees(math.atan(I.imag/I.real)))\n",
      "\n",
      "P1 = abs(V)*abs(I1)*math.cos(math.radians(phi1))\n",
      "P2 = abs(V)*abs(I2)*math.cos(math.radians(phi2))\n",
      "print 'iii)Power delivered is %.2f watts and %.2f watts'%(P1,P2)\n",
      "\n",
      "# note : rounding off error."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "i) Terminal voltage is 210.7 volts at -11.66 degrees\n",
        "ii) Currents are 14.91 A at -17.71 degrees and 20.36 A at -7.24 degrees      \n",
        "Total current is 35.12 A at -11.66 degrees  \n",
        "iii)Power delivered is 2992.46 watts and 4257.11 watts\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.4  Page no :  54"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "V_l = 10000.\n",
      "V_ph = V_l/math.sqrt(3)\n",
      "VA = 10.*10**6\n",
      "I_FL = VA/(V_l*math.sqrt(3)) \t\t\t#Current at full laod\n",
      "IX_s = (20./100)*V_ph \t\t\t#product of I and X_s\n",
      "\n",
      "# Calculations\n",
      "X_s = IX_s/I_FL\n",
      "N_s = 1500.\n",
      "f = 50.\n",
      "P = 120*f/N_s \t\t\t#poles\n",
      "\n",
      "delta_dash_mech = math.pi/180 \t\t\t#phase print lacement in degree mechanical\n",
      "delta_dash_elec = delta_dash_mech*(P/2)  \t\t\t#P/2 is pole pairs(and not poles)\n",
      "E = V_ph \t\t\t#math.since alternator is on no-load\n",
      "P_SY = delta_dash_elec*E**2/X_s  \t\t\t#Synchronous Power\n",
      "P_SY_3ph = P_SY*3 \t\t\t#For 3 phases\n",
      "\n",
      "# Results\n",
      "print 'Synchronising Power of armature is %.3f kW.\\\n",
      "\\nSynchronising Power for 3 phase is %.3f kW'%(P_SY*10**-3,P_SY_3ph*10**-3)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Synchronising Power of armature is 581.776 kW.\n",
        "Synchronising Power for 3 phase is 1745.329 kW\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.5 Page no :  55"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "import cmath\n",
      "\n",
      "#note that a new function p2z has been defined below for direct representation of complex numbers in polar form\n",
      "\n",
      "def  p2z(RRRR,Theeeta):\n",
      "    return  RRRR*cmath.exp(1j*math.pi*Theeeta/180.);\n",
      "\n",
      "# Variables\n",
      "V_L = 6.6*10**3\n",
      "V_ph = V_L/math.sqrt(3)\n",
      "VA = 3.*10**6\n",
      "I_FL = VA/(V_L*math.sqrt(3)) \t\t\t#full load current \n",
      "P = 8.\n",
      "f = 50. \t\t\t#poles and frequency\n",
      "\n",
      "X_s = complex(0,2.9)\t\t\t#X_s = 2.9\n",
      "delta_dash_mech = math.pi/180\n",
      "delta_dash_elec = delta_dash_mech*(P/2)  \t\t\t#P/2 is pole pairs(and not poles)\n",
      "\n",
      "# Calculations and Results\n",
      "#part(i)\n",
      "E = V_ph\n",
      "P_SY = delta_dash_elec*E**2/abs(X_s)  \t\t\t#Synchronous Power per phase\n",
      "P_SY_3ph = P_SY*3 \t\t\t#For 3 phases\n",
      "print 'i)   Synchronising power at no load is %.3f kW'%(P_SY*10**-3)\n",
      "print '   Total Synchronising power at no load is %.2f kW'%(P_SY_3ph*10**-3)\n",
      "\n",
      "N_s = 120*f/P \t\t\t#in rpm\n",
      "n_s = (N_s)/60 \t\t\t#in rps\n",
      "T_SY = P_SY_3ph/(2*math.pi*n_s)\n",
      "print 'Synchronous torque per mechanical degree of phase print lacement is %.2f * 10**3 N-m'%(T_SY*10**-3)\n",
      "\n",
      "#part(ii)\n",
      "phi = math.acos(math.radians(0.85))\n",
      "I = p2z(I_FL,0)\n",
      "V = p2z(V_ph,phi)\n",
      "\n",
      "E = V+I*X_s\n",
      "#E leads I by phasemag(E). V leads I by phasemag(V)\n",
      "\n",
      "delta = (math.pi/180)* (math.atan(E.imag/E.real)-math.atan(V.imag/V.real) ) \t\t\t#power angle in radians\n",
      "P_SY2 = abs(E)*abs(V)*math.cos(delta)*math.sin(delta_dash_elec)/abs(X_s)\n",
      "\n",
      "P_SY_total_2 = 3*P_SY2\n",
      "#n_s = T_SY/(P_SY/(2*math.pi) )       \t\t\t#because T_SY = P_SY/(2*math.pi*n_s)\n",
      "print 'ii)Total Synchronising power is %.0f kW'%(P_SY_total_2*10**-3)\n",
      "\n",
      "T_SY2 = P_SY_total_2/(2*math.pi*n_s)\n",
      "print 'Synchronising torque is %.2f * 10**3 N-m'%(T_SY2/1000)\n",
      "\n",
      "# note : book answer is wrong.\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "i)   Synchronising power at no load is 349.547 kW\n",
        "   Total Synchronising power at no load is 1048.64 kW\n",
        "Synchronous torque per mechanical degree of phase print lacement is 13.35 * 10**3 N-m\n",
        "ii)Total Synchronising power is 1074 kW\n",
        "Synchronising torque is 13.68 * 10**3 N-m\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.6  Page no :  57"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "import cmath\n",
      "\n",
      "#note that a new function p2z has been defined below for direct representation of complex numbers in polar form\n",
      "def  p2z(RRRR,Theeeta):\n",
      "    return  RRRR*cmath.exp(1j*math.pi*Theeeta/180.)\n",
      "\n",
      "# Variables\n",
      "V_l = 10.*10**3\n",
      "V_ph = V_l/math.sqrt(3)\n",
      "R_a = 0.4\n",
      "Z = complex(R_a,6)\n",
      "I_a = p2z(300,-math.acos(math.radians(0.8)))\n",
      "E = V_ph+I_a*Z\n",
      "\n",
      "# Calculations\n",
      "phi = math.acos(0.8)\n",
      "alternator_op_ph = V_ph*abs(I_a)*math.cos(phi) \t\t\t#Power delivered to infinite bus per phase\n",
      "\n",
      "#Power deliered to the altrernator  =  Power delivewred to bus bar +  I**2*R losses in armature\n",
      "alternator_power =  alternator_op_ph+ abs(I_a)**2*R_a\n",
      "\n",
      "#this power developed remains constant.change pf to 1 and calculate corresponding armature current\n",
      "#alternator_power = V_ph*I_a1*math.cos(phi1)+I_a1**2*0.4\n",
      "#solve the quadratic equation  0.4 I_a1**2+5773.50 I_a1- 1421640  = 0\n",
      "I_a1 = (-1*V_ph+math.sqrt(V_ph**2-4*R_a*-1*alternator_power))/(2*R_a)\n",
      "\n",
      "#also as follows \n",
      "E1 = V_ph+I_a1*Z\n",
      "decrease = 100*(abs(E)-abs(E1))/abs(E)\n",
      "\n",
      "# Results\n",
      "print 'Percentage decrease in induced e.m.f is %.1f percent'%(decrease)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Percentage decrease in induced e.m.f is 2.6 percent\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.7 Page no :  58"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "#Line PQ for Altermnator 1 and PR for alternaator 2.AB is at frequency x from P where total load is 3000 kW\n",
      "\n",
      "# Variables\n",
      "QC = 2000.\n",
      "PS = 2.5\n",
      "#PC = x\n",
      "TR = 2000.\n",
      "PT = 2.\n",
      "\n",
      "# Calculations and Results\n",
      "#using similarity of triangles PAC and PQS\n",
      "AC_by_PC = (QC/PS)\t\t\t# because (AC/QC) = (PC/PS)\n",
      "#using similarity of triangles PCB and PTR\n",
      "CB_by_PC = (TR/PT) \t\t\t# because (CB/TR) = (PC/PT)\n",
      "\n",
      "AC_by_x = AC_by_PC   \t\t\t#which implies AC = 12.5*x\n",
      "CB_by_x = CB_by_PC  \t\t\t#which implies CB = 16.67*x\n",
      "\n",
      "AC_plus_CB = 3000.  \t\t\t#total load at the frequency at P is 30 kW\n",
      "x =  AC_plus_CB/(AC_by_x + CB_by_x)\n",
      "AC = AC_by_x * x\n",
      "CB = CB_by_x * x  \n",
      "frequency = 50-x\n",
      "print 'Loads shared by alternator 1 and 2 are %.2f kW and %.2f kW respectively'%(AC,CB)\n",
      "\n",
      "#construction for max load: RT is extended to cut PQ at X.\n",
      "QS = 2000.\n",
      "RT = 2000. \t\t\t#see figure\n",
      "XT = QS*(PT/PS)\n",
      "RX = RT+XT  \t\t\t#maximum load\n",
      "\n",
      "print 'Maximum load is %.0f kW'%(RX)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Loads shared by alternator 1 and 2 are 1333.33 kW and 1666.67 kW respectively\n",
        "Maximum load is 3600 kW\n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.8 Page no :  60"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "P_out = 1500.*10**3\n",
      "V_L = 11000.\n",
      "phi = math.acos(0.8)\n",
      "I_L = P_out/(math.sqrt(3)*V_L*math.cos(phi))\n",
      "\n",
      "I_L_actv = I_L*math.cos(phi)   \t\t\t#wattful or active component of current\n",
      "I_L_reactive = I_L*math.sin(phi) \t\t\t#wattless or reactive component of current\n",
      "\n",
      "# Calculations and Results\n",
      "I_each = I_L/2  \t\t\t#in identical conditions\n",
      "I_arm1 = 45. \t\t\t#given\n",
      "I_1_reactive = math.sqrt(I_arm1**2-39.364**2 )  \t\t\t#from the power triangle \n",
      "I_2_reactive = 59.046-21.80\n",
      "I_a_2 = math.sqrt( 39.364**2 + I_2_reactive**2 )  \t\t\t#required armature current of 2nd alternator\n",
      "print 'Required armature current of second alternator is %.4f A'%(I_a_2)\n",
      "#power factors of 2 machines\n",
      "cos_phi1 = 39.364/45 \n",
      "cos_phi2 = 39.364/54.1921\n",
      "\n",
      "print 'Power factors are %.4f lagging and %.4f lagging'%(cos_phi1,cos_phi2)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Required armature current of second alternator is 54.1921 A\n",
        "Power factors are 0.8748 lagging and 0.7264 lagging\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.9 Page no : 61"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "#Line AB for Altermnator 1 and AC for alternator 2.AF is at frequency x measured from A where total load is 3000 kW\n",
      "# Variables\n",
      "BO = 2000.\n",
      "AO = 5.\t\t\t#AF = x\n",
      "DC = 2000.\n",
      "AD = 3.\n",
      "#AF = x\n",
      "\n",
      "# Calculations\n",
      "#using similarity of triangles AEF and ABO\n",
      "EF_by_AF = (BO/AO)\t\t\t# because (EF/BO) = (AF/AO)\n",
      "#using similarity of triangles AFG and ADC\n",
      "FG_by_AF = (DC/AD) \t\t\t#because (FG/DC) = (AF/AD)\n",
      "\n",
      "EF_by_x = EF_by_AF   \t\t\t#which implies EF = 400*x\n",
      "FG_by_x = FG_by_AF   \t\t\t#which implies FG = 666.67*x\n",
      "\n",
      "EF_plus_FG = 3000  \t\t\t#total load at the frequency at P is 3000 kW\n",
      "x =  EF_plus_FG/(EF_by_x + FG_by_x)\n",
      "EF = (BO/AO)*x\n",
      "FG = (DC/AD)*x  \n",
      "\n",
      "# Results\n",
      "print 'Loads shared by machine 1 and 2 are %.0f kW and %.0f kW respectively'%(EF,FG)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Loads shared by machine 1 and 2 are 1125 kW and 1875 kW respectively\n"
       ]
      }
     ],
     "prompt_number": 19
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.10 Page no :  63"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "import cmath\n",
      "\n",
      "#note that a new function p2z has been defined below for direct representation of complex numbers in polar form\n",
      "\n",
      "def  p2z(RRRR,Theeeta):\n",
      "    return  RRRR*cmath.exp(1j*math.pi*Theeeta/180.);\n",
      "\n",
      "# Variables\n",
      "V_l = 6000.\n",
      "V_ph = V_l/math.sqrt(3)\n",
      "VA = 2000.*10**3\n",
      "I_FL = VA/(V_l*math.sqrt(3))\n",
      "X_s = complex(0,6) \t\t\t#synchronous reactance\n",
      "P = 8.\n",
      "f = 50.\n",
      "\n",
      "delta_mech = math.pi/180 \t\t\t#phase print lacemant in degree mechanical \n",
      "#phase print lacemant in degree electrical\n",
      "delta_elec = delta_mech*(P/2)  \t\t\t#P/2 is pole pairs(and not poles)\n",
      "\n",
      "phi = math.acos(math.radians(0.8))\n",
      "V = p2z(V_ph,phi)\n",
      "E = V+I_FL*X_s\n",
      "#E leads I by phasemag(E). V leads I by phasemag(V)\n",
      "\n",
      "# Calculations and Results\n",
      "delta = (math.pi/180)* (math.atan(E.imag/E.real)-(math.atan(V.imag/V.real ) ) ) \t\t\t#power angle in radians\n",
      "P_SY = abs(E)*abs(V)*math.cos(delta)*math.sin(delta_elec)/abs(X_s) \t\t\t#Synchronising power\n",
      "P_SY_total = 3*P_SY \t\t\t#totla Synchronising power \n",
      "print 'Total Synchronising power is %.3f kW'%(10**-3*P_SY_total)\n",
      "\n",
      "N_s = 120*f/P \t\t\t#in rpm\n",
      "n_s = (N_s)/60 \t\t\t#in rps\n",
      "T_SY = P_SY_total/(2*math.pi*n_s)\n",
      "print 'Synchronising torque is %.0f N-m'%(T_SY)\n",
      "\n",
      "# note : book answer it seems wrong."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Total Synchronising power is 444.753 kW\n",
        "Synchronising torque is 5663 N-m\n"
       ]
      }
     ],
     "prompt_number": 21
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.11  Page no : 64"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "import cmath\n",
      "\n",
      "#note that a new function p2z has been defined below for direct representation of complex numbers in polar form\n",
      "def  p2z(RRRR,Theeeta):\n",
      "    return  RRRR*cmath.exp(1j*math.pi*Theeeta/180.);\n",
      "\n",
      "# Variables\n",
      "V_l = 3300.\n",
      "V_ph = V_l/math.sqrt(3)\n",
      "VA = 3*10.**6\n",
      "I_FL = VA/(V_l*math.sqrt(3))\n",
      "IX_s = (25./100)*V_ph \t\t\t#product of I and X_s\n",
      "X_s = complex(0,IX_s/I_FL) \t\t\t#synchronous reactance\n",
      "N_s = 1000. \t\t\t#in rpm\n",
      "P = 6.\n",
      "f = 50.\n",
      "\n",
      "# Calculations and Results\n",
      "delta_dash_mech = math.pi/180\n",
      "delta_dash_elec = delta_dash_mech*(P/2)  \t\t\t#P/2 is pole pairs(and not poles)\n",
      "\n",
      "I = I_FL\n",
      "phi = math.acos(math.radians(0.8))\n",
      "V = p2z(V_ph,phi)\n",
      "E = V+I*X_s\n",
      "#E leads I by phasemag(E). V leads I by phasemag(V)\n",
      "\n",
      "delta = (math.pi/180)* (math.atan(E.imag/E.real)-math.atan(V.imag/V.real) ) \t\t\t#power angle in radians\n",
      "P_SY = abs(E)*abs(V)*math.cos(delta)*math.sin(delta_dash_elec)/abs(X_s) \t\t\t#Synchronising power per phase\n",
      "print 'Synchronising power is %.3f kW'%(10**-3*P_SY)\n",
      "P_SY_total = 3*P_SY \t\t\t#Total Synchronising power\n",
      "\n",
      "N_s = 120*f/P \t\t\t#in rpm\n",
      "n_s = (N_s)/60 \t\t\t#in rps\n",
      "T_SY = P_SY_total/(2*math.pi*n_s)\n",
      "print 'Synchronising torque is %.0f N-m'%(T_SY)\n",
      "\n",
      "print 'Answer mismatches due to approximation'\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Synchronising power is 217.160 kW\n",
        "Synchronising torque is 6221 N-m\n",
        "Answer mismatches due to approximation\n"
       ]
      }
     ],
     "prompt_number": 22
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.12 Page no : 65"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "V_l = 3300.\n",
      "V_ph = V_l/math.sqrt(3)\n",
      "VA = 3*10.**6\n",
      "I_FL = VA/(V_l*math.sqrt(3))\n",
      "IX_s = (20./100)*V_ph \t\t\t#product of I and X_s\n",
      "X_s = complex(0,IX_s/I_FL) \t\t\t#synchronous reactance\n",
      "N_s = 1000.\n",
      "P = 6.\n",
      "f = 50.\n",
      "\n",
      "delta_dash_mech = math.pi/180 \t\t\t#phase print lacement in degree mechanical\n",
      "#phase print lacement in degree electrical\n",
      "delta_dash_elec = delta_dash_mech*(P/2)  \t\t\t#P/2 is pole pairs(and not poles)\n",
      "\n",
      "# Calculations and Results\n",
      "E = V_ph\n",
      "Z_s = X_s \t\t\t#math.since R = 0\n",
      "P_SY = abs(E)*abs(V_ph)*delta_dash_elec/abs(Z_s) \t\t\t#Synchronising power per phase\n",
      "print 'Synchronising power is %.3f kW'%(10**-3*P_SY)\n",
      "P_SY_total = 3*P_SY \t\t\t#Total Synchronising power\n",
      "print '3 phase Synchronising power is %.3f kW'%(10**-3*P_SY_total)\n",
      "\n",
      "N_s = 120*f/P \t\t\t#in rpm\n",
      "n_s = (N_s)/60 \t\t\t#in rps\n",
      "T_SY = P_SY_total/(2*math.pi*n_s)\n",
      "print 'Synchronising torque is %.0f N-m'%(T_SY)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Synchronising power is 261.799 kW\n",
        "3 phase Synchronising power is 785.398 kW\n",
        "Synchronising torque is 7500 N-m\n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.13 Page no :  66"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "V_L = 11.*10**3\n",
      "V_ph = V_L/math.sqrt(3)\n",
      "VA = 700.*10**3\n",
      "I_FL = VA/(math.sqrt(3)*V_L) \t\t\t#full load current\n",
      "IR_a = (1.5/100)*V_ph \t\t\t#product of I and R_a\n",
      "R_a = IR_a/I_FL\n",
      "IX_s = (14./100)*V_ph \t\t\t# product of I and X_s\n",
      "X_s = IX_s/I_FL \t\t\t#synchronous reactance\n",
      "\n",
      "# Calculations\n",
      "#at full load and 0.8 pf\n",
      "I = I_FL\n",
      "phi = math.acos(0.8)\n",
      "V_ph = complex(V_ph*math.cos(phi),V_ph*math.sin(phi))  \t\t\t#just introduced the angle\n",
      "E_ph = math.sqrt(    (abs(V_ph)*math.cos(phi)+ IR_a)**2+   (abs(V_ph)*math.sin(phi)+ IX_s)**2     )\n",
      "\n",
      "Poles = 4.\n",
      "f = 50. \t\t\t#poles and frequency\n",
      "delta = math.asin( (abs(V_ph)*math.sin(phi)+IX_s)/E_ph)  -phi\n",
      "delta_dash_mech = (math.pi/180) \t\t\t#print lacement in degree mechanical\n",
      "\t\t\t#print lacement in degree electrical\n",
      "delta_dash_elec = delta_dash_mech*(Poles/2)\n",
      "P_SY = abs(E_ph)*abs(V_ph)*math.cos(delta)*math.sin(delta_dash_elec)/X_s   \t\t\t#Synchronising power per phase \n",
      "P_SY_total = 3*P_SY  \t\t\t#total Synchronising power\n",
      "\n",
      "ns = 120*f/(60*Poles)  \t\t\t#in r.p.s\n",
      "T_SY = P_SY_total/(2*math.pi*ns)   \t\t\t#Synchronising torque \n",
      "\n",
      "# Results\n",
      "print 'Synchronising power is %.2fkW'%(P_SY_total/1000)\n",
      "print 'Synchronising torque is %.2f N-m'%(T_SY)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Synchronising power is 191.25kW\n",
        "Synchronising torque is 1217.53 N-m\n"
       ]
      }
     ],
     "prompt_number": 24
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.14 Page no :  68"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "V_l = 9.*10**3\n",
      "V_ph = V_l/math.sqrt(3)\n",
      "VA = 5.5*10**6\n",
      "I_FL = VA/(V_l*math.sqrt(3))\n",
      "IX_s = (25./100)*V_ph \t\t\t#product of I and X_s\n",
      "X_s = complex(0,IX_s/I_FL) \t\t\t#synchronous reactance\n",
      "N_s = 1500. \t\t\t#in rpm\n",
      "n_s = N_s/60 \t\t\t#in rps\n",
      "f = 50.\n",
      "P = 120.*f/N_s \t\t\t#frequency and pole\n",
      "\n",
      "# Calculations\n",
      "delta_dash_mech = math.pi/180 \t\t\t#print lacemnt in degree mechanical \n",
      "#print lacemnt in degree electrical\n",
      "delta_dash_elec = delta_dash_mech*(P/2)  \t\t\t#P/2 is pole pairs(and not poles)\n",
      "\n",
      "E = V_ph\n",
      "P_SY = abs(E)*abs(V_ph)*delta_dash_elec/abs(X_s) \t\t\t#Synchronising power per phase\n",
      "P_SY_total = 3*P_SY \t\t\t#Total Synchronising power\n",
      "\n",
      "T_SY = P_SY_total/(2*math.pi*n_s)\n",
      "\n",
      "# Results\n",
      "print 'Synchronising torque is %.2f N-m'%(T_SY)\n",
      "print 'Answer mismatches due to approximation'\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Synchronising torque is 4888.89 N-m\n",
        "Answer mismatches due to approximation\n"
       ]
      }
     ],
     "prompt_number": 25
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.15  Page no :  69"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "V_L = 6.*10**3\n",
      "V_ph = V_L/math.sqrt(3)\n",
      "VA = 2000.*10**3\n",
      "I_FL = VA/(math.sqrt(3)*V_L)  \n",
      "I = I_FL\n",
      "\n",
      "# Calculations\n",
      "X_s = 1.2\n",
      "R_a = 0.01 \t\t\t#both per unit\n",
      "IR_a = (1/100)*V_ph \t\t\t#product of I and R_a\n",
      "R_a = IR_a/I_FL\n",
      "IX_s = (120/100)*V_ph \t\t\t#product of I and X_s\n",
      "#IX_s = (12/100)*V_ph   \t\t\t# this is the mistake made in the textbook\n",
      "X_s = IX_s/I_FL\n",
      "\n",
      "#at full load and 0.8 pf\n",
      "phi = math.acos(0.8)\n",
      "#V_ph = complex(V_ph*math.cos(phi)V_ph*math.sin(phi))  \t\t\t#just introduced the angle\n",
      "E_ph = math.sqrt(    (abs(V_ph)*math.cos(phi)+ IR_a)**2+   (abs(V_ph)*math.sin(phi)+ IX_s)**2     )\n",
      "Poles = 8\n",
      "f = 50\n",
      "\n",
      "delta = math.asin( (abs(V_ph)*math.sin(phi)+IX_s)/E_ph)  -phi\n",
      "delta_dash_mech = (math.pi/180) \t\t\t#print lacemnt in degree mechanical \n",
      "#print lacemnt in degree electrical\n",
      "delta_dash_elec = delta_dash_mech*(Poles/2)\n",
      "P_SY = abs(E_ph)*abs(V_ph)*math.cos(delta)*math.sin(delta_dash_elec)/X_s   \t\t\t#Synchronising power per phase\n",
      "P_SY_total = 3*P_SY  \t\t\t#total Synchronising power\n",
      "\n",
      "ns = 120*f/(60*Poles)  \t\t\t#in r.p.s\n",
      "T_SY = P_SY_total/(2*math.pi*ns)   \t\t\t#Synchronising torque \n",
      "\n",
      "# Results\n",
      "print 'Synchronising power is %.2f kW'%(P_SY_total/1000)\n",
      "print 'Synchronising torque is %.2f N-m'%(T_SY)\n",
      "\n",
      "print 'Note that answer obtained doesnt match with textbook due to the following reasons: \\\n",
      "\\niIX_s is considered wrong in textbook.It should have been 4156.92instead of 415.692  To verify this use commented statement of IX_s line 13and notice that it matches with textbook ans then' \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Synchronising power is 223.22 kW\n",
        "Synchronising torque is 2960.56 N-m\n",
        "Note that answer obtained doesnt match with textbook due to the following reasons: \n",
        "iIX_s is considered wrong in textbook.It should have been 4156.92instead of 415.692  To verify this use commented statement of IX_s line 13and notice that it matches with textbook ans then\n"
       ]
      }
     ],
     "prompt_number": 27
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.16  Page no :  71"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "E = 11.*10**3/math.sqrt(3)\n",
      "I_sc = 1000.\n",
      "Pole = 2.\n",
      "f = 50.\n",
      "delta_dash_mech = 1*math.pi/180 \t\t\t#print lacemnt in degree mechanical \n",
      "\n",
      "# Calculations\n",
      "#print lacemnt in degree electrical \n",
      "delta_dash_elec = delta_dash_mech*(Pole/2)\n",
      "P_SY = E*I_sc*delta_dash_mech \t\t\t#Synchronising power per phase\n",
      "P_SY_total = P_SY*3 \t\t\t#total Synchronising power\n",
      "\n",
      "ns = 120*f/(60*Pole)  \t\t\t#in r.p.s\n",
      "T_SY = P_SY_total/(2*math.pi*ns)   \t\t\t#Synchronising torque \n",
      "\n",
      "# Results\n",
      "print 'Synchronising power is %.2f kW'%(P_SY_total/1000)\n",
      "print 'Synchronising torque is %.2f N-m'%(T_SY)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Synchronising power is 332.53 kW\n",
        "Synchronising torque is 1058.48 N-m\n"
       ]
      }
     ],
     "prompt_number": 28
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.17 Page no :  72"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "#Line PQ for Altermnator 1 and PR for alternaator 2.AB is at frequency x from P where total load is 30 MW\n",
      "# Variables\n",
      "QT = 25.\n",
      "PT = 2.\n",
      "#PC = x\n",
      "SR = 25.\n",
      "PS = 1.5\n",
      "\n",
      "# Calculations\n",
      "#using similarity of triangles PAC and PQT\n",
      "AC_by_PC = (QT/PT)\t\t\t# because (AC/QT) = (PC/PT)\n",
      "#using similarity of triangles PCB and PSR\n",
      "CB_by_PC = (SR/PS)\n",
      "\n",
      "AC_by_x = AC_by_PC   \t\t\t#which implies AC = 12.5*x\n",
      "CB_by_x = CB_by_PC  \t\t\t#which implies CB = 16.67*x\n",
      "\n",
      "AC_plus_CB = 30  \t\t\t#total load at the frequency at P is 30 MW\n",
      "x =  AC_plus_CB/(AC_by_x + CB_by_x)\n",
      "AC = 12.5*x\n",
      "CB = 16.67*x  \n",
      "frequency = 50-x\n",
      "\n",
      "# Results\n",
      "print 'Loads shared by alternator 1 and 2 are %.2f MW and %.2f MW respectively'%(AC,CB)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Loads shared by alternator 1 and 2 are 12.86 MW and 17.15 MW respectively\n"
       ]
      }
     ],
     "prompt_number": 29
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.18  Page no :  73"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "import cmath\n",
      "\n",
      "#note that a new function p2z has been defined below for direct representation of complex numbers in polar form\n",
      "def  p2z(RRRR,Theeeta):\n",
      "    return  RRRR*cmath.exp(1j*math.pi*Theeeta/180.);\n",
      "\n",
      "# Variables\n",
      "load_total = 1600.*10**3\n",
      "pf = 1/math.sqrt(2)  \t\t\t#lag\n",
      "V_L = 6600.\n",
      "\n",
      "# Calculations\n",
      "I_L = p2z(load_total/(math.sqrt(3)*V_L*pf),-1*math.acos(math.radians(pf)) )\n",
      "I_1 = p2z(90,-1*math.acos(math.radians(0.8)))\n",
      "I_2 = I_L-I_1\n",
      "phi = abs(math.atan(I_2.imag/I_2.real))\n",
      "I_a = abs(I_2)\n",
      "R_a = 1.05\n",
      "X_s = 5 \t\t\t#resistance and synchronous reactance per phase\n",
      "V_ph = V_L/math.sqrt(3)\n",
      "E_ph = math.sqrt(  (V_ph*math.cos(phi)+I_a*R_a )**2 + ( V_ph*math.sin(phi)+I_a*X_s )**2        )\n",
      "E_line = math.sqrt(3)*E_ph\n",
      "\n",
      "# Results\n",
      "print 'Excitation of second alternator is %.2f V '%(E_line)\n",
      "print ' The corresponding field current from the graph is about 310 A'\n",
      "print 'Note: The answer obtained will differ from textbook answer because of higher degree of accuracy while storing I_2 and the improper rounding off of I_2 in the textbook'\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Excitation of second alternator is 6884.65 V \n",
        " The corresponding field current from the graph is about 310 A\n",
        "Note: The answer obtained will differ from textbook answer because of higher degree of accuracy while storing I_2 and the improper rounding off of I_2 in the textbook\n"
       ]
      }
     ],
     "prompt_number": 30
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.19 Page no : 75"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "V_L = 10.*10**3\n",
      "V_ph = V_L/math.sqrt(3)\n",
      "VA = 5.*10**6\n",
      "I_FL = VA/(math.sqrt(3)*V_L) \t\t\t#full-load current\n",
      "IX_s = (20./100)*V_ph \t\t\t#product of I and X_s\n",
      "X_s = IX_s/I_FL \t\t\t#synchronous reactance\n",
      "P = 4.\n",
      "\n",
      "# Calculations\n",
      "delta_dash_mech = 1*(math.pi/180) \t\t\t#print lacement in degree mechanical \n",
      "#print lacement in degree electrical\n",
      "delta_dash_elec = delta_dash_mech*(P/2)\n",
      "E = V_ph  \t\t\t#at no load\n",
      "P_SY =  delta_dash_elec*E**2/X_s  \t\t\t#Synchronising power per phase\n",
      "P_SY_total = P_SY*3  \t\t\t#Total Synchronising power\n",
      "\n",
      "# Results\n",
      "print 'Synchronising power per phase is %.2fkW \\\n",
      "\\nTotal Synchronising power is %.2fkW '%(P_SY/1000,P_SY_total/1000)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Synchronising power per phase is 290.89kW \n",
        "Total Synchronising power is 872.66kW \n"
       ]
      }
     ],
     "prompt_number": 33
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.20 Page no : 76"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "Power_total = 1.414 \t\t\t#per unit\n",
      "V_L = 1. \t\t\t#per unit\n",
      "phi_t = math.acos(0.707)\n",
      "I_L_T = Power_total/(math.sqrt(3)*V_L*math.cos(phi_t))  \t\t\t#Total current\n",
      "\n",
      "# Calculations\n",
      "#Current supplied by each alternator\n",
      "I_1 = I_L_T/2\n",
      "I_2 = I_1\n",
      "V_ph = V_L/math.sqrt(3)\n",
      "\n",
      "phi = math.acos(0.707)\n",
      "R_a = 0\n",
      "X_s = 0.6 \t\t\t#resistacne and synchronous reactance\n",
      "E_ph = math.sqrt(  (V_ph*math.cos(phi)+ I_1*R_a)**2 + (V_ph*math.sin(phi)+I_1*X_s)**2          )\n",
      "delta =  math.atan((I_1*X_s+V_ph*math.sin(phi)) / (V_ph*math.cos(phi))) - phi    \t\t\t#power angle\n",
      "\n",
      "# Results\n",
      "print 'EMF is %.4f p.u. and power angle is %.2f degrees '%(E_ph,delta*180/math.pi)\n",
      "print 'Following assumptions were made :'\n",
      "print '1.Terminal or bus bar voltage at ppoint of connection is constant'\n",
      "print '2.The alternators are identical and are initially equally excited'\n",
      "print '3.The power supplied by prime movers is adjusted so that each machine carries half the load represented by external impedance Z = R+ j 2pifL %( where R and L are constant'\n",
      "print '4.The stator resistance is negligible'\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "EMF is 0.8580 p.u. and power angle is 16.58 degrees \n",
        "Following assumptions were made :\n",
        "1.Terminal or bus bar voltage at ppoint of connection is constant\n",
        "2.The alternators are identical and are initially equally excited\n",
        "3.The power supplied by prime movers is adjusted so that each machine carries half the load represented by external impedance Z = R+ j 2pifL %( where R and L are constant\n",
        "4.The stator resistance is negligible\n"
       ]
      }
     ],
     "prompt_number": 34
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.21 Page no : 77"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "V_l = 480.\n",
      "X_d = 0.1\n",
      "X_q = 0.075\n",
      "R_a = 0. \t\t\t#armature resistance and synchronous reactance of direct quadrature axis\n",
      "I_l = 1200.\n",
      "I_ph = I_l/math.sqrt(3)\n",
      "V_ph = V_l\n",
      "V_t = V_l\n",
      "I_a = I_ph\n",
      "\n",
      "# Calculations\n",
      "phi = math.acos(0.8)\n",
      "psi = math.atan(  (V_t*math.sin(phi)+I_a*X_q)/(V_t*math.cos(phi)+I_a*R_a)            )\n",
      "delta = psi-phi \n",
      "\n",
      "I_d = I_a*math.sin(psi)\n",
      "I_q = I_a*math.cos(psi)\n",
      "E_f = V_t*math.cos(delta)+I_d*X_d+I_q*R_a\n",
      "\n",
      "# Results\n",
      "print 'Excitation e.m.f is %.f V '%(E_f)\n",
      "\n",
      "# note : rounding off error."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Excitation e.m.f is 524 V \n"
       ]
      }
     ],
     "prompt_number": 37
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.22  Page no :  78"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "VA = 3.5*10**6\n",
      "P = 32.        \t\t\t#Poles\n",
      "Power = 2.5*10**6 \t\t\t#In watts\n",
      "V_l = 6.6*10**3\n",
      "phi = math.acos(0.8)\n",
      "I_l = Power/(V_l*math.cos(phi)*math.sqrt(3))\n",
      "X_d = 9.6\n",
      "X_q = 6.\n",
      "R_a = 0. \t\t\t#armature resistance and synchronous reactance of direct quadrature axis\n",
      "\n",
      "# Calculations\n",
      "V_t = V_l/math.sqrt(3)\n",
      "psi = math.atan(  (V_t*math.sin(phi)+I_l*X_q)/(V_t*math.cos(phi)+I_l*R_a)            )\n",
      "delta = psi-phi\n",
      "I_s = I_l\n",
      "I_d = I_s*math.sin(psi)\n",
      "I_q = I_s*math.cos(psi)\n",
      "E_f = V_t*math.cos(delta)+I_d*X_d+I_q*R_a\n",
      "regulation = 100*(E_f-V_t)/V_t\n",
      "\n",
      "# Results\n",
      "print 'percentage regulation is %.2f percent'%(regulation)\n",
      "print 'Excitation emf =  %.0f V'%(E_f)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "percentage regulation is 50.85 percent\n",
        "Excitation emf =  5748 V\n"
       ]
      }
     ],
     "prompt_number": 38
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.23 Page no :  79"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "X_d = 7.6\n",
      "X_q = 4.5\n",
      "R_a = 0.15 \t\t\t#armature resistance and synchronous reactance of directquadrature \n",
      "axisV_l = 13.8*10**3\n",
      "V_l = 13.8*10**3\n",
      "V_t = V_l/math.sqrt(3)\n",
      "phi = math.acos(0.8)\n",
      "VA = 25*10**6\n",
      "I_a = VA/(math.sqrt(3)*V_l)\n",
      "psi = math.atan(  (V_t*math.cos(phi)+I_a*X_q)/(V_t*math.sin(phi)+I_a*R_a)            )\n",
      "\n",
      "# Calculations\n",
      "delta = psi-phi\n",
      "I_s = I_a\n",
      "I_d = I_s*math.sin(psi)\n",
      "I_q = I_s*math.cos(psi)\n",
      "\n",
      "E_f = V_t*math.cos(delta)+I_d*X_d+I_q*R_a\n",
      "regulation = 100*(E_f-V_t)/V_t\n",
      "\n",
      "# Results\n",
      "print 'percentage regulation is %.2f percent'%(regulation)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "percentage regulation is 79.30 percent\n"
       ]
      }
     ],
     "prompt_number": 39
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.24 Page no :  80"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "X_d = 1.\n",
      "X_q = 0.6\n",
      "R_a = 0. \t\t\t#armature resistance and synchronous reactance of direct quadrature axis\n",
      "phi = math.acos(0.8) \t\t\t#lag\n",
      "V_t = 1.\n",
      "I_a = 1. \t\t\t#full load\n",
      "psi = math.atan(  (V_t*math.sin(phi)+I_a*X_q)/(V_t*math.cos(phi)+I_a*R_a)            )\n",
      "\n",
      "# Calculations\n",
      "delta = psi-phi\n",
      "I_s = I_a\n",
      "I_d = I_a*math.sin(psi)\n",
      "I_q = I_a*math.cos(psi)\n",
      "\n",
      "E_f = V_t*math.cos(delta)+I_d*X_d+I_q*R_a\n",
      "regulation = 100*(E_f-V_t)/V_t\n",
      "\n",
      "# Results\n",
      "print 'percentage regulation is %.2f percent'%(regulation)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "percentage regulation is 77.50 percent\n"
       ]
      }
     ],
     "prompt_number": 40
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.25 Page no :  81"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "I_a = 10.\n",
      "phi = 20. \t\t\t#lag and degrees\n",
      "V_t = 400.\n",
      "X_d = 10.\n",
      "X_q = 6.5\n",
      "R_a = 0. \t\t\t#armature resistance and synchronous reactance of direct quadrature axis\n",
      "\n",
      "# Calculations\n",
      "psi = math.atan((V_t*math.sin(math.radians(phi))+I_a*X_q)/(V_t*math.cos(math.radians(phi))+I_a*R_a))\n",
      "delta = math.degrees(psi)-phi\n",
      "I_d = math.degrees(I_a*math.sin(math.radians(psi)))\n",
      "I_q = (I_a*math.cos(psi))\n",
      "\n",
      "# Results\n",
      "print 'Load angle is %.2f degrees '%(delta)\n",
      "print 'I_d and I_q are %.4f A and %.4f A respectively '%(I_d,I_q  )\n",
      "\n",
      "# note : rounding off error."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Load angle is 8.23 degrees \n",
        "I_d and I_q are 4.9272 A and 8.8105 A respectively \n"
       ]
      }
     ],
     "prompt_number": 53
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.26 Page no : 81"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "X_d = 0.8\n",
      "X_q = 0.5\n",
      "R_a = 0.02 \t\t\t#armature resistance and synchronous reactance of direct quadrature axis\n",
      "\n",
      "\t\t\t#case(i)  lag\n",
      "phi = math.acos(0.8)\n",
      "V_t = 1\n",
      "I_a = 1\t\t\t#full-load\n",
      "psi = math.atan(  (V_t*math.sin(phi)+I_a*X_q)/(V_t*math.cos(phi)+I_a*R_a)            )\n",
      "delta = psi-phi\n",
      "\n",
      "I_d = I_a*math.sin(psi)\n",
      "I_q = I_a*math.cos(psi)\n",
      "\n",
      "E_f = V_t*math.cos(delta)+I_d*X_d+I_q*R_a\n",
      "regulation = 100*(E_f-V_t)/V_t\n",
      "print 'percentage regulation at 0.8 pf lag is %.2f percent'%(regulation)\n",
      "\n",
      "\t\t\t#case(ii)  lead\n",
      "phi2 = -1*math.acos(0.8) \t\t\t#minus sign because of leading pf\n",
      "psi2 = math.atan(  (V_t*math.sin(phi2)+I_a*X_q)/(V_t*math.cos(phi2)+I_a*R_a)            )\n",
      "delta2 = psi2-phi2\n",
      "\n",
      "I_d2 = I_a*math.sin(psi2)\n",
      "I_q2 = I_a*math.cos(psi2)\n",
      "\n",
      "E_f2 = V_t*math.cos(delta2)+I_d2*X_d+I_q2*R_a\n",
      "regulation2 = 100*(E_f2-V_t)/V_t\n",
      "print 'percentage regulation at 0.8 pf lead is %.f percent'%(regulation2)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "percentage regulation at 0.8 pf lag is 61.25 percent\n",
        "percentage regulation at 0.8 pf lead is -21 percent\n"
       ]
      }
     ],
     "prompt_number": 55
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.27 Page no : 83"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "from numpy import *\n",
      "\n",
      "# Variables\n",
      "kW = array([800,500,1000,600])\n",
      "cosphi = array([1,0.9,0.8,0.9])\n",
      "tanphi = tan(arccos(cosphi))\n",
      "kVAR = kW*tanphi\n",
      "\n",
      "# Calculations\n",
      "kW_total = kW[0]+kW[1]+kW[2]+kW[3]\n",
      "kVAR_total = kVAR[0]+kVAR[1]+kVAR[2]+-1*kVAR[3] \t\t\t#4th case is leading \n",
      "\n",
      "phi_c = math.atan(kVAR_total/kW_total)  \t\t\t#total power factor angle\n",
      "phi_1 = math.acos(0.95)\t\t\t#pf of machine 1\n",
      "kW_1 = 1000 \t\t\t#active component of machine 1\n",
      "kVAR_1 = kW_1*math.tan(phi_1) \t\t\t#reactive component of machine 1\n",
      "kW_2 = kW_total - kW_1 \t\t\t#active component of machine 1\n",
      "kVAR_2 = kVAR_total-kVAR_1 \t\t\t#reactive component of machine 2\n",
      "\n",
      "phi_2 = math.atan(kVAR_2/kW_2) \n",
      "pf_2 = math.cos(phi_2) \t\t\t#power factor of machine 2\n",
      "\n",
      "# Results\n",
      "print 'Output of second alternator =  %.0f kW'%(kW_2)\n",
      "print 'power factor of machine 2  =  %.2f and lagging'%(pf_2)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Output of second alternator =  1900 kW\n",
        "power factor of machine 2  =  0.98 and lagging\n"
       ]
      }
     ],
     "prompt_number": 56
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.28 Page no : 84"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "from numpy import *\n",
      "\n",
      "# Variables\n",
      "kW = array([250,300,150])\n",
      "cosphi = array([0.9,0.75,0.8]) \t\t\t#all lagging\n",
      "tanphi = tan(arccos(cosphi))\n",
      "kVAR = kW*tanphi\n",
      "\n",
      "# Calculations\n",
      "kW_total = kW[0]+kW[1]+kW[2]\n",
      "kVAR_total = kVAR[0]+kVAR[1]+kVAR[2] \n",
      "\n",
      "phi_1 = math.acos(0.8)\t\t\t#pf of machine 1\n",
      "kW_1 = 100 \t\t\t#active component of machine 1\n",
      "kVAR_1 = kW_1*math.tan(phi_1) \t\t\t#reactive component of machine 1\n",
      "kW_2 = kW_total - kW_1 \t\t\t#active component of machine 1\n",
      "kVAR_2 = kVAR_total-kVAR_1 \t\t\t#reactive component of machine 2\n",
      "phi_2 = math.atan(kVAR_2/kW_2) \n",
      "pf_2 = math.cos(phi_2) \t\t\t#power factor of machine 2\n",
      "\n",
      "# Results\n",
      "print 'Output of second alternator =  %.0f kW'%(kW_2)\n",
      "print 'power factor of machine 2  =  %.4f and lagging'%(pf_2)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Output of second alternator =  600 kW\n",
        "power factor of machine 2  =  0.8172 and lagging\n"
       ]
      }
     ],
     "prompt_number": 57
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.29 Page no :  85"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "V_L = 6.6*10**3\n",
      "V_ph = V_L/math.sqrt(3)\n",
      "V_t = V_ph\n",
      "X_d = 9.6\n",
      "X_q = 6.\n",
      "R_a = 0. \t\t\t#armature resistance and synchronous reactance of direct quadrature axis\n",
      "VA = 3.5*10**6\n",
      "I_L = VA/(math.sqrt(3)*V_L)\n",
      "\n",
      "# Calculations\n",
      "P = 2.5*10**6\n",
      "phi = math.acos(0.8)\n",
      "I_a = P/(math.sqrt(3)*V_L*math.cos(phi))\n",
      "psi = math.atan(  (V_t*math.sin(phi)+ I_a*X_q)/(V_t*math.cos(phi)+ I_a*R_a)     )\n",
      "\n",
      "delta = psi-phi\n",
      "I_d = I_a*math.sin(psi)\n",
      "I_q = I_a*math.cos(phi)\n",
      "\n",
      "E_f = V_t*math.cos(delta)+I_d*X_d+I_q*R_a\n",
      "regulation = 100*(E_f-V_t)/V_t\n",
      "P_max = (V_ph**2/2)*((X_d-X_q)/(X_d*X_q))*(math.sin(2*delta))\n",
      "\n",
      "# Results\n",
      "print 'percentage voltage regulation is %.2f percent'%(regulation)\n",
      "print 'Power under open circuit is %.1f kW per phase'%(P_max/1000)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "percentage voltage regulation is 50.85 percent\n",
        "Power under open circuit is 231.1 kW per phase\n"
       ]
      }
     ],
     "prompt_number": 58
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.30  Page no :  86"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "V_L = 3.3*10**3\n",
      "V_ph = V_L/math.sqrt(3)\n",
      "VA = 3.*10**6\n",
      "I_FL = VA/(math.sqrt(3)*V_L)\n",
      "IX_s = (25./100)*V_ph \t\t\t#product of I and X_s\n",
      "X_s = complex(0,IX_s/I_FL)\n",
      "N_s = 1000 \t\t\t#in r.p.m\n",
      "\n",
      "\n",
      "# Calculations\n",
      "Poles = 6.\n",
      "f = 50.\n",
      "delta_dash_mech = (math.pi/180) \t\t\t#print lacement in degree mechanical\n",
      "#print lacement in degree electrical\n",
      "delta_dash_elec = delta_dash_mech*(Poles/2)\n",
      "\n",
      "I = I_FL\n",
      "phi = math.acos(0.8)\n",
      "V = complex(V_ph*math.cos(phi),V_ph*math.sin(phi))\n",
      "E =  V+ I*X_s\n",
      "\n",
      "delta = (math.pi/180)*math.atan(E.imag/E.real)-phi   \t\t\t#E leads I by (math.pi/180)*phasemag(E) and V leads I by phi radians \n",
      "P_SY = abs(E)*abs(V_ph)*math.cos(delta)*math.sin(delta_dash_elec)/abs(X_s)   \t\t\t#Synchronising power per phase \n",
      "P_SY_total = 3*P_SY  \t\t\t#total Synchronising power\n",
      "\n",
      "ns = 120*f/(60*Poles)  \t\t\t#in r.p.m\n",
      "T_SY = P_SY_total/(2*math.pi*ns)   \t\t\t#Synchronising torque \n",
      "\n",
      "# Results\n",
      "print 'Synchronising power per phase is %.3f kW'%(P_SY/1000)\n",
      "print 'Synchronising torque is %.0f N-m'%(T_SY)\n",
      "print 'Answer mismatches due to improper approximation'\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Synchronising power per phase is 197.555 kW\n",
        "Synchronising torque is 5660 N-m\n",
        "Answer mismatches due to improper approximation\n"
       ]
      }
     ],
     "prompt_number": 60
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.31  Page no :  87"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "V_L = 3.3*10**3\n",
      "V_ph = V_L/math.sqrt(3)\n",
      "VA = 3.*10**6\n",
      "I_FL = VA/(math.sqrt(3)*V_L)\n",
      "IX_s = (20./100)*V_ph \t\t\t#product of I and X_s\n",
      "X_s = complex(0,IX_s/I_FL)\n",
      "N_s = 1000. \t\t\t#in r.p.m\n",
      "Poles = 6.\n",
      "f = 50.\n",
      "\n",
      "# Calculations\n",
      "delta_dash_mech = (math.pi/180) \t\t\t#print lacement in degree mechanical\n",
      "#print lacement in degree electrical \n",
      "delta_dash_elec = delta_dash_mech*(Poles/2)\n",
      "\n",
      "#E = V as the alternator is on no-load and X_s = Z_s\n",
      "P_SY = abs(V_ph)**2*(delta_dash_elec)/abs(X_s)   \t\t\t#Synchronising power per phase\n",
      "P_SY_total = 3*P_SY  \t\t\t#total Synchronising power\n",
      "\n",
      "ns = 120*f/(60*Poles)  \t\t\t#in r.p.s\n",
      "T_SY = P_SY_total/(2*math.pi*ns)   \t\t\t#Synchronising torque \n",
      "\n",
      "# Results\n",
      "print 'Synchronising power per phase is %.3f kW'%(P_SY/1000)\n",
      "print 'Total Synchronising power is %.3f kW'%(P_SY_total/1000)\n",
      "print 'Synchronising torque is %.0f N-m'%(T_SY)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Synchronising power per phase is 261.799 kW\n",
        "Total Synchronising power is 785.398 kW\n",
        "Synchronising torque is 7500 N-m\n"
       ]
      }
     ],
     "prompt_number": 61
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.32 Page no :  88"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "V_L = 11.*10**3\n",
      "V_ph = V_L/math.sqrt(3)\n",
      "VA = 700.*10**3\n",
      "I_FL = VA/(math.sqrt(3)*V_L)\n",
      "IX_s = (14./100)*V_ph \t\t\t#product of I and X_s\n",
      "X_s = IX_s/I_FL\n",
      "#X_s = complex(0,IX_s/I_FL)\n",
      "IR_a = (1.5/100)*V_ph \t\t\t#product of I and R_a\n",
      "R_a = IR_a/I_FL\n",
      "\n",
      "\n",
      "# Calculations\n",
      "I = I_FL\n",
      "phi = math.acos(0.8)\n",
      "V = complex(V_ph*math.cos(phi),V_ph*math.sin(phi))\n",
      "E_ph = math.sqrt(  (V_ph*math.cos(phi)+IR_a)**2 +(V_ph*math.sin(phi)+IX_s)**2    )\n",
      "delta = math.asin((V_ph*math.sin(phi)+IX_s)/E_ph)   -phi\n",
      "\n",
      "Poles = 4.\n",
      "f = 50.\n",
      "delta_dash_mech = (math.pi/180) \t\t\t#phase print lacemnt in degree mechanical\n",
      "delta_dash_elec = delta_dash_mech*(Poles/2)\t\t\t#phase print lacemnt in degree electrical\n",
      "\n",
      "P_SY = abs(V_ph)*abs(E_ph)*math.cos(delta)*math.sin(delta_dash_elec)/abs(X_s)   \t\t\t#Synchronising power per phase\n",
      "P_SY_total = 3*P_SY  \t\t\t#total Synchronising power\n",
      "\n",
      "ns = 120*f/(60*Poles)  \t\t\t#in r.p.s\n",
      "T_SY = P_SY_total/(2*math.pi*ns)   \t\t\t#Synchronising torque \n",
      "\n",
      "# Results\n",
      "print 'Synchronising power per phase is %.3f kW'%(P_SY/1000)\n",
      "print 'Synchronising power is %.3f kW ; '%(P_SY/1000)\n",
      "print 'Total Synchronising power is %.3f kW'%(P_SY_total/1000)\n",
      "print 'Synchronising torque is %.2f N-m'%(T_SY)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Synchronising power per phase is 63.750 kW\n",
        "Synchronising power is 63.750 kW ; \n",
        "Total Synchronising power is 191.249 kW\n",
        "Synchronising torque is 1217.53 N-m\n"
       ]
      }
     ],
     "prompt_number": 62
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.33 Page no : 91"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "import cmath\n",
      "\n",
      "#note that a new function p2z has been defined below for direct representation of complex numbers in polar form\n",
      "def  p2z(RRRR,Theeeta):\n",
      "    return  RRRR*cmath.exp(1j*math.pi*Theeeta/180.);\n",
      "\n",
      "# Variables\n",
      "Z1 = complex(0,2)\n",
      "Z2 = complex(0,3)\n",
      "Z = 6.\n",
      "E1 = p2z(230,0)\n",
      "E2 = p2z(230,10)\n",
      "\n",
      "# Calculations\n",
      "I1 = ((E1-E2)*Z+E1*Z2)/(Z*(Z1+Z2)+Z1*Z2)\n",
      "I2 = ((E2-E1)*Z+E2*Z1)/(Z*(Z1+Z2)+Z1*Z2)\n",
      "\n",
      "phi1 = math.atan(I1.imag/I1.real)  \t\t\t#Phasemag returns the angle of complex number in degrees\n",
      "phi2 = math.atan(I2.imag/I2.real)  \t\t\t#Phasemag returns the angle of complex number in degrees\n",
      "\n",
      "I = I1+I2\n",
      "V = I*Z \t\t\t#Terminal voltage\n",
      "\n",
      "# Results\n",
      "print 'i) Terminal voltage is %.2f volts at %.1f degrees'%(abs(V),math.degrees(math.atan(V.imag/V.real)))\n",
      "print 'ii) Currents are %.2f A at %.0f degrees and %.2f A at %.2f degrees     \\\n",
      "\\nTotal current is %.2f A at %.1f degrees  '%(abs(I1),math.degrees(math.atan(I1.imag/I1.real)),abs(I2),\\\n",
      "                                              math.degrees(math.atan(I2.imag/I2.real)),abs(I) \\\n",
      "                                              ,math.degrees(math.atan(I.imag/I.real)))\n",
      "\n",
      "P1 = abs(V)*abs(I1)*math.cos(math.radians(phi1))\n",
      "P2 = abs(V)*abs(I2)*math.cos(math.radians(phi2))\n",
      "print 'iii)Power delivered %.2f watts and  %.2f watts'%(P1,P2)\n",
      "\n",
      "# note : rounding off error. kindly check the calculations\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "i) Terminal voltage is 224.71 volts at -7.3 degrees\n",
        "ii) Currents are 14.74 A at -14 degrees and 22.88 A at -3.03 degrees     \n",
        "Total current is 37.45 A at -7.3 degrees  \n",
        "iii)Power delivered 3311.43 watts and  5141.03 watts\n"
       ]
      }
     ],
     "prompt_number": 65
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.34  Page no : 91"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "X_d = 0.8\n",
      "X_q = 0.5  \t\t\t#both per unit\n",
      "R_a = 0. \t\t\t#assumed\n",
      "phi = math.acos(0.8)\n",
      "V_t = 1.\t\t\t#pu\n",
      "I_a = 1. \t\t\t#full-load\n",
      "\n",
      "# Calculations\n",
      "psi = math.atan(  (V_t*math.sin(phi)+I_a*X_q)/(V_t*math.cos(phi)+I_a*R_a)            )\n",
      "delta = psi-phi\n",
      "I_d = I_a*math.sin(psi)\n",
      "I_q = I_a*math.cos(psi)\n",
      "E_f = V_t*math.cos(delta)+I_d*X_d+I_q*R_a\n",
      "\n",
      "# Results\n",
      "print 'Open circuit voltage is %.3f p.u.'%(E_f)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Open circuit voltage is 1.603 p.u.\n"
       ]
      }
     ],
     "prompt_number": 66
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.35 Page no : 92"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "from numpy import *\n",
      "\n",
      "# Variables\n",
      "V_L = 6600.\n",
      "I_L = 110.\n",
      "phi_1 = math.acos(0.9) \t\t\t#lagging\n",
      "kW = array([400,1000,400,300])*10**3\n",
      "cosphi = array([1,0.71,0.8,0.9])\n",
      "tanphi = tan(arccos(cosphi))\n",
      "kVAR = kW*tanphi\n",
      "\n",
      "# Calculations\n",
      "kW_total = kW[0]+kW[1]+kW[2]+kW[3]\n",
      "kVAR_total = kVAR[0]+kVAR[1]+kVAR[2]+kVAR[3]\n",
      "\n",
      "phi_c = math.atan(kVAR_total/kW_total)  \t\t\t#total power factor angle\n",
      "load_1 = math.sqrt(3)*V_L*I_L*math.cos(phi_1)\n",
      "\n",
      "kW_1 = load_1 \t\t\t#active component of machine 1\n",
      "kVAR_1 = kW_1*math.tan(phi_1) \t\t\t#reactive component of machine 1\n",
      "kW_2 = kW_total - kW_1 \t\t\t#active component of machine 1\n",
      "kVAR_2 = kVAR_total-kVAR_1 \t\t\t#reactive component of machine 2\n",
      "\n",
      "phi_2 = math.atan(kVAR_2/kW_2) \n",
      "pf_2 = math.cos(phi_2) \t\t\t#power factor of machine 2\n",
      "\n",
      "# Results\n",
      "print 'Output of second alternator =  %.2f kW'%(kW_2/1000)\n",
      "print 'Power factor of machine 2  =  %.4f and lagging'%(pf_2)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Output of second alternator =  968.28 kW\n",
        "Power factor of machine 2  =  0.7366 and lagging\n"
       ]
      }
     ],
     "prompt_number": 67
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.36  Page no :  93"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "V_L = 11000.\n",
      "V_ph = V_L/math.sqrt(3)\n",
      "VA = 2.*10**6\n",
      "phi = math.acos(0.8)\n",
      "I_FL = VA/(math.sqrt(3)*V_L)\n",
      "phi_1 = math.acos(0.8)\n",
      "IX_s = (20./100)*V_ph \t\t\t#product of I and X_s\n",
      "\n",
      "# Calculations\n",
      "X_s = IX_s/I_FL\n",
      "I_1 = I_FL\n",
      "BC = I_1*math.cos(phi_1)*X_s\n",
      "AB = I_1*math.sin(phi_1)*X_s    \n",
      "OA = V_ph\n",
      "OC = math.sqrt( (OA+AB)**2+(BC)**2 ) \n",
      "E_1 = OC\n",
      "E_2 = 1.25*E_1\n",
      "OE = E_2\n",
      "DE = BC\n",
      "AD = math.sqrt(OE**2-DE**2) -OA           \t\t\t#because OE = math.sqrt( (OA+AD)**2 + (DE)**2  )\n",
      "\n",
      "I_2sinphi2 = AD/X_s\n",
      "I_2cosphi2 = I_1*math.cos(phi)\n",
      "I_2 = math.sqrt( (I_2cosphi2)**2 + (I_2sinphi2)**2  )\n",
      "phi2 = math.atan( I_2sinphi2/ I_2cosphi2 )\n",
      "new_pf = math.cos(phi2)\n",
      "\n",
      "# Results\n",
      "print 'Machine current is %.2f A '%(I_2)\n",
      "print 'Power factor is  %.4f lagging'%(new_pf)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Machine current is 228.62 A \n",
        "Power factor is  0.3673 lagging\n"
       ]
      }
     ],
     "prompt_number": 68
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.37  Page no :  95"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "#note that a new function p2z has been defined below for direct representation of complex numbers in polar form\n",
      "def  p2z(RRRR,Theeeta):\n",
      "    return  RRRR*exp(1j*math.pi*Theeeta/180.);\n",
      "\n",
      "\n",
      "# Variables\n",
      "P_out = 3000.*10**3\n",
      "V_L = 6.6*10**3\n",
      "V_ph = V_L/math.sqrt(3)\n",
      "phi = math.acos(0.8)\n",
      "I_L = p2z(P_out/(math.sqrt(3)*V_L*math.cos(phi)),-1*(180/math.pi)*phi)\n",
      "\n",
      "# Calculations\n",
      "P_out1 = P_out/2\n",
      "I_L1 = 150  \t\t\t#given\n",
      "phi_L1 = math.acos(    P_out1/(math.sqrt(3)*V_L*I_L1)  )\n",
      "I_L1 = p2z(I_L1,-1*(180/math.pi)*phi_L1)\n",
      "\n",
      "I_L2 = I_L-I_L1\n",
      "pf_2 = math.cos(math.atan(I_L2.imag/I_L2.real))\n",
      "Z_1 = complex(0.5,10)\n",
      "I_1 = I_L1\n",
      "E_1 = V_ph + I_1*Z_1\n",
      "delta_1 =  math.atan(E_1.imag/E_1.real)   \t\t\t#load angle of alternator 1\n",
      "E_1L = math.sqrt(3)*E_1\n",
      "\n",
      "Z_2 = complex(0.4,12)\n",
      "I_2 = I_L2\n",
      "E_2 = V_ph + I_2*Z_2\n",
      "delta_2 = (math.pi/180)*math.atan(E_2.imag/E_2.real)    \t\t\t#load angle of alternator 2\n",
      "\n",
      "# Results\n",
      "print 'Part i) Currents are %.0f A at %.1f degrees and %.1f A at %.1f degrees\\nTotal current is %.0f at %.2f' %(abs(I_L1),\\\n",
      "                            math.degrees(math.atan(I_L1.imag/I_L1.real)),abs(I_L2),\\\n",
      "                            math.degrees(math.atan(I_L2.imag/I_L2.real)),abs(I_L),math.degrees(math.atan(I_L.imag/I_L.real)))\n",
      "print 'Part ii)Power factor is %.4f and lagging'%(math.cos(phi_L1))\n",
      "print 'Part iii)emf are %.2f V at %.2f degrees and %.4f V at %.0f degrees'%(abs(E_1),\\\n",
      "                            math.degrees(math.atan(E_1.imag/E_1.real)),abs(E_2),math.degrees(math.atan(E_2.imag/E_2.real)))\n",
      "print 'Part iv)Power angles are %.2f degrees and %.0f degrees '%(180/math.pi*delta_1,(180/math.pi)*delta_2)\n",
      "\n",
      "# note : rounding off error. kindly check the calculations\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Part i) Currents are 150 A at -29.0 degrees and 180.6 A at -43.4 degrees\n",
        "Total current is 328 at -36.87\n",
        "Part ii)Power factor is 0.8748 and lagging\n",
        "Part iii)emf are 4776.46 V at 15.49 degrees and 5565.7081 V at 16 degrees\n",
        "Part iv)Power angles are 15.49 degrees and 0 degrees \n"
       ]
      }
     ],
     "prompt_number": 73
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.38  Page no :  97"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "Z1 = complex(0.2,2)\n",
      "Z2 = Z1\n",
      "ZL = complex(3,4)\n",
      "Z = ZL\n",
      "E1 = complex(2000,0)\n",
      "E2 = complex(2200,100)\n",
      "\n",
      "# Calculations\n",
      "I1 = ((E1-E2)*Z+E1*Z2)/(Z*(Z1+Z2)+Z1*Z2)\n",
      "I2 = ((E2-E1)*Z+E2*Z1)/(Z*(Z1+Z2)+Z1*Z2)\n",
      "\n",
      "IL = I1+I2\n",
      "V = IL*Z \t\t\t#Terminal voltage\n",
      "\n",
      "phi1 = math.atan(V.imag/V.real)-math.atan(I1.imag/I1.real)  \t\t\t#Phasemag returns the angle of complex number in degrees\n",
      "phi2 = math.atan(V.imag/V.real)-math.atan(I2.imag/I2.real)  \t\t\t#Phasemag returns the angle of complex number in degrees\n",
      "\n",
      "Pout1 = math.sqrt(3)*math.sqrt(3)*abs(V)*abs(I1)*math.cos(math.radians(phi1))\n",
      "Pout2 = math.sqrt(3)*math.sqrt(3)*abs(V)*abs(I2)*math.cos(math.radians(phi2))\n",
      "\n",
      "# Results\n",
      "print 'Power delivered is %.2f kW and %.2f kW at power-factors %.4f lag and %.4f lag respectively'%(Pout1/1000,Pout2/1000,math.cos(math.radians(phi1)),math.cos(math.radians(phi2)))\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Power delivered is 658.24 kW and 1253.92 kW at power-factors 0.9999 lag and 0.9999 lag respectively\n"
       ]
      }
     ],
     "prompt_number": 74
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.39  Page no :  99"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "f = 50.\n",
      "P = 12.\n",
      "V_L = 6600.\n",
      "V_ph = V_L/math.sqrt(3)\n",
      "VA = 2000.*10**3\n",
      "I_FL = VA/(math.sqrt(3)*V_L)\n",
      "\n",
      "# Calculations\n",
      "IX_s = (25./100)*V_ph \t\t\t#product of I and X_s\n",
      "X_s = complex(0,IX_s/I_FL)\n",
      "N_s = 12*f/P \t\t\t#in rpm\n",
      "delta_dash_mech = (math.pi/180) \t\t\t#phase print lacemnt in degree mechanical\n",
      "delta_dash_elec = delta_dash_mech*(P/2) \t\t\t#phase print lacemnt in degree electrical\n",
      "\n",
      "phi = math.acos(0.8) \t\t\t#lag\n",
      "I = complex(I_FL*math.cos(-1*phi),I_FL*math.sin(-1*phi))\n",
      "V = V_ph\n",
      "E = V + I*X_s\n",
      "delta = math.atan(E.imag/E.real)*(math.pi/180)\n",
      "P_SY = abs(E)*abs(V)*math.cos(delta)*math.sin(delta_dash_elec)/abs(X_s)\n",
      "P_SY_total = 3*P_SY\n",
      "\n",
      "# Results\n",
      "print 'Synchronising power is %.2f kW'%(P_SY/1000)\n",
      "print 'Total Synchronising power is %.2f kW'%(P_SY_total/1000)\n",
      "\n",
      "# note : rounding off error. kindly check."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Synchronising power is 325.36 kW\n",
        "Total Synchronising power is 976.09 kW\n"
       ]
      }
     ],
     "prompt_number": 76
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.40  Page no :  101"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "V_L = 22000.\n",
      "V_ph = V_L/math.sqrt(3)\n",
      "power = 230.*10**6\n",
      "phi = math.acos(1.)\n",
      "I_FL = power/(math.sqrt(3)*V_L*math.cos(phi))\n",
      "I_1 = I_FL\n",
      "X_s = 1.2\n",
      "\n",
      "# Calculations\n",
      "E_1 = math.sqrt( V_ph**2 + (I_1*X_s)**2 )\n",
      "E_2 = 1.3*E_1\n",
      "AC =   math.sqrt( E_2**2-(I_1*X_s)**2  )   -V_ph     \t\t\t# because E**2 = (V_ph+AC)**2+(I_1*X_s)**2\n",
      "I2X_S = AC\n",
      "\n",
      "I_2cosphi2 = I_1  \t\t\t#because phi_2 = math.acos(I_1/I_2) \t\t\t#from ACD\n",
      "I_2sinphi2 = AC/X_s\n",
      "I_2 = math.sqrt( (I_2cosphi2)**2 + (I_2sinphi2)**2  )\n",
      "phi2 = math.atan( I_2sinphi2/ I_2cosphi2 )\n",
      "new_pf = math.cos(phi2)\n",
      "\n",
      "# Results\n",
      "print 'Machine current is %.2f A '%(I_2)\n",
      "print 'Power factor is  %.4f and lagging'%(new_pf)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Machine current is 7274.58 A \n",
        "Power factor is  0.8297 and lagging\n"
       ]
      }
     ],
     "prompt_number": 77
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.41  Page no :  102"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "import cmath\n",
      "\n",
      "#note that a new function p2z has been defined below for direct representation of complex numbers in polar form\n",
      "def  p2z(RRRR,Theeeta):\n",
      "\treturn RRRR*cmath.exp(1j*math.pi*Theeeta/180.);\n",
      "\n",
      "# Variables\n",
      "P_out = 1500.*10**3\n",
      "V_L = 3.3*10**3\n",
      "phi = math.acos(0.8)\n",
      "I_L = p2z(P_out/(math.sqrt(3)*V_L*math.cos(phi)),-1*math.acos(math.radians(0.8)))\n",
      "\n",
      "I_L1_magnitude = 150.  \t\t\t#given\n",
      "P_out1 = (3.*10**6)/2 \t\t\t#because load is EQUALLY shared between 2 alternators\n",
      "pf_L1 = P_out1/(math.sqrt(3)*2*V_L*I_L1_magnitude)  \t\t\t#operating pf of alternator 1\n",
      "phi1 = math.acos(math.radians(pf_L1))\n",
      "I_L1 = p2z(I_L1_magnitude,-1*phi1)\n",
      "I_L2 = I_L-I_L1   \t\t\t#because I_L = I_L1 + I_L2\n",
      "pf_L2 = math.cos(math.atan(I_L2.imag/I_L2.real))\n",
      "\n",
      "# Calculations\n",
      "V_ph = 6.6*10**3/math.sqrt(3)\n",
      "Z_1 = complex(0.5,10)\n",
      "I_1 = I_L1\n",
      "E_1 =  V_ph + I_1*Z_1\n",
      "delta_1 = math.atan(E_1.imag/E_1.real)  \t\t\t#load angle of alternator 1\n",
      "I_2 = I_L2\n",
      "\n",
      "Z_2 = complex(0.4,12)\n",
      "E_2 =  V_ph + I_2*Z_2\n",
      "delta_2 = math.atan(E_2.imag/E_2.real) \t\t\t#load angle of alternator 1\n",
      "\n",
      "# Results\n",
      "print 'for machine 1current is %.0f A at %.2f degrees \\nPower factor of %.4f laginduced emf \\\n",
      "        of %.2f V \\nload angle of %.2f degrees'%(abs(I_L1),math.degrees(math.atan(I_L1.imag/I_L1.real)),pf_L1,abs(E_1),delta_1)\n",
      "print 'for machine 2current is %.1f A at %.1f degrees\\nPower factor of %.4f laginduced emf \\\n",
      "        of %.2f V\\nload angle of %.0f degrees'%(abs(I_L2),math.degrees(math.atan(I_L2.imag/I_L2.real)),pf_L2,abs(E_2),math.degrees(delta_2))\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "for machine 1current is 150 A at -1.56 degrees \n",
        "Power factor of 0.8748 laginduced emf         of 4202.06 V \n",
        "load angle of 0.36 degrees\n",
        "for machine 2current is 178.0 A at -1.6 degrees\n",
        "Power factor of 0.9996 laginduced emf         of 4480.49 V\n",
        "load angle of 28 degrees\n"
       ]
      }
     ],
     "prompt_number": 81
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.42  Page no :  104"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "V_l = 230\n",
      "VA = 5*10**3\n",
      "X_d = 12\n",
      "X_q = 7\n",
      "R_a = 0 \t\t\t#armature resistance and synchronous reactance of direct quadrature axis\n",
      "phi = math.acos(1)\n",
      "\n",
      "# Calculations\n",
      "I_l = VA/(V_l*math.sqrt(3))\n",
      "V_ph = V_l/math.sqrt(3)\n",
      "V_t = V_ph\n",
      "I_a = I_l\n",
      "\n",
      "psi = math.atan(  (V_t*math.sin(phi)+I_a*X_q)/(V_t*math.cos(phi)+I_a*R_a)            )\n",
      "delta = psi-phi\n",
      "I_d = I_a*math.sin(psi)\n",
      "I_q = I_a*math.cos(psi)\n",
      "E_f = V_t*math.cos(delta)+I_d*X_d+I_q*R_a\n",
      "\n",
      "# Results\n",
      "print 'Excitation voltage is %.3f V '%(E_f)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Excitation voltage is 193.852 V \n"
       ]
      }
     ],
     "prompt_number": 82
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.43  Page no :  104"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "V_l = 6.6*10**3\n",
      "V_t = V_l/math.sqrt(3)\n",
      "X_d = 23.2\n",
      "X_q = 14.5\n",
      "R_a = 0. \t\t\t#armature resistance and synchronous reactance of direct quadrature axis\n",
      "VA = 1800.*10**3\n",
      "phi = math.acos(0.8) \t\t\t#lag\n",
      "\n",
      "# Calculations and Results\n",
      "I_a = VA/(V_l*math.sqrt(3))\n",
      "\n",
      "psi = math.atan(  (V_t*math.sin(phi)-I_a*X_q)/(V_t*math.cos(phi)-I_a*R_a)  ) \t\t\t#minus sign in numerator and denomenator for motors\n",
      "delta = psi+phi\n",
      "I_d = I_a*math.sin(psi)\n",
      "I_q = I_a*math.cos(psi)\n",
      "E_f = V_t*math.cos(delta)-I_d*X_d-I_q*R_a\n",
      "print 'Excitation emf  =  %.4f V'%(E_f)\n",
      "#P_m =  ( V_t*E_f*math.sin(delta)/X_d  ) + ((1/X_q)-(1/X_d))*0.5*math.sin(2*delta)*V_t**2\n",
      "#P_m = 0.4996*math.cos(delta)+0.1877*math.sin(2*delta)\n",
      "#for maximum power output differenciate and equate to zero\n",
      "\n",
      "delta_max = 63.4 \t\t\t#degree\n",
      "\n",
      "P_m_max = ((1/X_q)-(1/X_d))*0.5*math.sin(math.radians(2*delta_max))*V_t**2   \t\t\t#Maximuum load supplied with E_f = 0\n",
      "print 'Maximum load the motor can supply is %.4f MW per phase '%(P_m_max*10**-6      )\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Excitation emf  =  3042.2721 V\n",
        "Maximum load the motor can supply is 0.1503 MW per phase \n"
       ]
      }
     ],
     "prompt_number": 83
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}