summaryrefslogtreecommitdiff
path: root/Fundamentals_of_Electrical_Machines/CH_1.ipynb
blob: 801b1ed11d54dfc4b753b9da4697db18a39a0936 (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
{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "CHAPTER 1: REVIEW OF ELECTRIC CIRCUITS"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.1, Page number 2-3"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Q = 4.0      #Charge(C) \n",
      "t = 0.54     #Time(sec) \n",
      "\n",
      "#Calculation\n",
      "I = Q/t      #Current(A) \n",
      "\n",
      "#Result\n",
      "print('Value of Current is , I = %.2f A' %I) "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Value of Current is , I = 7.41 A\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.2, Page number 4-5"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "V = -24.0     #Voltage(V)\n",
      "I = 3.0       #Current(A)\n",
      "\n",
      "#Calculation \n",
      "P = V*I       #Power supplied by the element A(W) \n",
      "\n",
      "#Result\n",
      "print('Power supplied by the element A is , P = %.1f W' %P)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Power supplied by the element A is , P = -72.0 W\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.3, Page number 7-9"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "R1 = 5.0   #Resistance(ohm)\n",
      "R2 = 4.0   #Resistance(ohm)\n",
      "R3 = 9.0   #Resistance(ohm)\n",
      "R4 = 6.0   #Resistance(ohm)\n",
      "V1 = 10.0  #Resistance(ohm)\n",
      "V2 = 6.0   #Resistance(ohm)\n",
      "\n",
      "\n",
      "#Calculation\n",
      "R_th = (R1*R4/(R1+R4))+R2    #Thevenin resistance(ohm) by removing R3 & short-circuiting voltage sources\n",
      "I = (V1-V2)/(R1+R4)          #Current(A) by applying KVL\n",
      "V_th = 6*I+V2                #Thevenin voltage(V) by applying KVL\n",
      "I_9ohm = V_th/(R_th+R3)      #Current through 9 ohm resistor(A)\n",
      "\n",
      "#Result\n",
      "print('Current through 9 ohm resistor , I_9\u03a9 = %.2f A' %I_9ohm) "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Current through 9 ohm resistor , I_9\u03a9 = 0.52 A\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.4, Page number 10-11"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from scipy.integrate import quad\n",
      "\n",
      "#Variable declaration\n",
      "V_t1 = 30.0            #Magnitudes of voltages(V)  0 < t1 < 2\n",
      "V_t2 = -10.0           #Magnitudes of voltages(V)  2 < t2 < 4\n",
      "T = 4.0                #Time period(sec) from figure\n",
      "\n",
      "#Calculation\n",
      "def integrand(V):\n",
      "    return V**0\n",
      "\n",
      "a, err = quad(integrand, 0, 2)\n",
      "\n",
      "def integrand(V):\n",
      "    return V**0\n",
      "\n",
      "b, err = quad(integrand, 2, 4)\n",
      "\n",
      "V_rms = ((a*V_t1**2+b*V_t2**2)/4)**0.5   #RMS value of voltage waveform(V)\n",
      "\n",
      "#Result\n",
      "print('RMS value , V_rms = %.2f V' %V_rms)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "RMS value , V_rms = 22.36 V\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.5, Page number 15-16"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import cmath\n",
      "\n",
      "#Variable declaration\n",
      "V_P = 200.0                                 #Magnitude of each phase(V) \n",
      "\n",
      "#Calculation\n",
      "V_an = V_P*cmath.exp(1j*0*math.pi/180)      #Magnitude of 3-phase voltage(V)\n",
      "V_bn = V_P*cmath.exp(1j*-120*math.pi/180)   #Magnitude of 3-phase voltage(V)\n",
      "V_cn = V_P*cmath.exp(1j*120*math.pi/180)    #Magnitude of 3-phase voltage(V)\n",
      "V_L = 3**0.5*V_P                            #Magnitude of line voltage(V)\n",
      "\n",
      "#Result\n",
      "print('Expression of phase voltages are,')\n",
      "print('\\t\\t\\t  V_an = %.f\u2220%.f\u00b0 V' %(abs(V_an),cmath.phase(V_an)))\n",
      "print('\\t\\t\\t  V_bn = %.f\u2220%.f\u00b0 V' %(abs(V_bn),cmath.phase(V_bn)*180/math.pi))\n",
      "print('\\t\\t\\t  V_cn = %.f\u2220%.f\u00b0 V' %(abs(V_cn),cmath.phase(V_cn)*180/math.pi))\n",
      "print('Magnitude of the line voltage , V_L = %.1f V' %V_L) "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Expression of phase voltages are,\n",
        "\t\t\t  V_an = 200\u22200\u00b0 V\n",
        "\t\t\t  V_bn = 200\u2220-120\u00b0 V\n",
        "\t\t\t  V_cn = 200\u2220120\u00b0 V\n",
        "Magnitude of the line voltage , V_L = 346.4 V\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.6, Page number 16-17"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import cmath\n",
      "\n",
      "#Variable declaration\n",
      "R = 10.0        #Resistance of each coil(ohm)\n",
      "X = 15.0        #Inductive reactance of each coil(ohm)\n",
      "V_L = 420.0     #Line voltage(V)\n",
      "f = 50.0        #Frequency of supply(Hz)\n",
      "\n",
      "#Calculation\n",
      "V_an = (V_L/3**0.5)*cmath.exp(1j*(0-30)*math.pi/180)       #Phase voltage(V)\n",
      "V_bn = (V_L/3**0.5)*cmath.exp(1j*(-120-30)*math.pi/180)    #Phase voltage(V)\n",
      "V_cn = (V_L/3**0.5)*cmath.exp(1j*(120-30)*math.pi/180)     #Phase voltage(V)\n",
      "Z_P = complex(R,X)                                         #Phase impedance(ohm)\n",
      "#For case(i)\n",
      "I_L1 = V_an/Z_P         #Line current(A)\n",
      "I_L2 = V_bn/Z_P         #Line current(A)\n",
      "I_L3 = V_cn/Z_P         #Line current(A)\n",
      "#For case(ii)\n",
      "pf = R/abs(Z_P)         #Power factor\n",
      "\n",
      "#Result\n",
      "print('(i) Values of line currents are,')\n",
      "print('\\t I_L1 = I_an = %.2f\u2220%.2f\u00b0 A' %(abs(I_L1),cmath.phase(I_L1)*180/math.pi))\n",
      "print('\\t I_L2 = I_bn = %.2f\u2220%.2f\u00b0 A' %(abs(I_L2),cmath.phase(I_L2)*180/math.pi))\n",
      "print('\\t I_L3 = I_cn = %.2f\u2220%.2f\u00b0 A' %(abs(I_L3),cmath.phase(I_L3)*180/math.pi))\n",
      "print('(ii) Power factor is , pf = %.1f lag' %pf)\n",
      "print('\\nNOTE : I_L2 has an angle -206.31\u00b0 in textbook which is same as 153.69\u00b0 i.e (360-206.31)\u00b0 obtained here')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i) Values of line currents are,\n",
        "\t I_L1 = I_an = 13.45\u2220-86.31\u00b0 A\n",
        "\t I_L2 = I_bn = 13.45\u2220153.69\u00b0 A\n",
        "\t I_L3 = I_cn = 13.45\u222033.69\u00b0 A\n",
        "(ii) Power factor is , pf = 0.6 lag\n",
        "\n",
        "NOTE : I_L2 has an angle -206.31\u00b0 in textbook which is same as 153.69\u00b0 i.e (360-206.31)\u00b0 obtained here\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.7, Page number 19-20"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import cmath\n",
      "\n",
      "#Variable declaration\n",
      "Z_P = complex(10,15)     #Per phase impedance(ohm)\n",
      "V_L = 420.0              #Voltage(V)\n",
      "\n",
      "#Calculation\n",
      "#For case(i)\n",
      "V_ab = V_L*cmath.exp(1j*0*math.pi/180)        #Phase voltage(V)\n",
      "V_bc = V_L*cmath.exp(1j*-120*math.pi/180)     #Phase voltage(V)\n",
      "V_ca = V_L*cmath.exp(1j*120*math.pi/180)      #Phase voltage(V)\n",
      "I_ab = V_ab/Z_P                               #Phase current(A)\n",
      "I_bc = V_bc/Z_P                               #Phase current(A)\n",
      "I_ca = V_ca/Z_P                               #Phase current(A)\n",
      "#For case(ii)\n",
      "I_P = abs(I_ab)                               #Phase current magnitude(A)\n",
      "I_L = 3**0.5*I_P                              #Line current magnitude(A)\n",
      "\n",
      "#Result\n",
      "print('(i) Phase currents are,')\n",
      "print('\\t\\t I_ab = %.2f\u2220%.2f\u00b0 A' %(abs(I_ab),cmath.phase(I_ab)*180/math.pi))\n",
      "print('\\t\\t I_bc = %.2f\u2220%.2f\u00b0 A' %(abs(I_bc),cmath.phase(I_bc)*180/math.pi))\n",
      "print('\\t\\t I_ca = %.2f\u2220%.2f\u00b0 A' %(abs(I_ca),cmath.phase(I_ca)*180/math.pi))\n",
      "print('(ii) Magnitude of line current , I_L = %.2f A' %I_L)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i) Phase currents are,\n",
        "\t\t I_ab = 23.30\u2220-56.31\u00b0 A\n",
        "\t\t I_bc = 23.30\u2220-176.31\u00b0 A\n",
        "\t\t I_ca = 23.30\u222063.69\u00b0 A\n",
        "(ii) Magnitude of line current , I_L = 40.35 A\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.8, Page number 22-23"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import cmath\n",
      "\n",
      "#Variable declaration\n",
      "V_P = 280.0          #Generator Phase voltage(V)\n",
      "Z_P = complex(2,3)   #Line impedance per phase(ohm)\n",
      "Z_L = complex(4,5)   #Load impedance per phase(ohm)\n",
      "\n",
      "#Calculation\n",
      "V_An = V_P*cmath.exp(1j*0*math.pi/180)        #Phase voltage(V)\n",
      "V_Bn = V_P*cmath.exp(1j*-120*math.pi/180)     #Phase voltage(V)\n",
      "V_Cn = V_P*cmath.exp(1j*120*math.pi/180)      #Phase voltage(V)\n",
      "Z_t = Z_P+Z_L                                 #Total impedance(ohm)\n",
      "I_Aa = V_An/Z_t                               #Magnitude of line current for phase A(A)\n",
      "I_Bb = V_Bn/Z_t                               #Magnitude of line current for phase B(A)\n",
      "I_Cc = V_Cn/Z_t                               #Magnitude of line current for phase C(A)\n",
      "V_an = I_Aa*Z_L                               #Phase voltage of load(V)\n",
      "V_bn = I_Bb*Z_L                               #Phase voltage of load(V)\n",
      "V_cn = I_Cc*Z_L                               #Phase voltage of load(V)\n",
      "\n",
      "#Result\n",
      "print('Line currents are,')\n",
      "print('\\t\\t I_Aa = %.f\u2220%.f\u00b0 A' %(abs(I_Aa),cmath.phase(I_Aa)*180/math.pi))\n",
      "print('\\t\\t I_Bb = %.f\u2220%.f\u00b0 A' %(abs(I_Bb),cmath.phase(I_Bb)*180/math.pi))\n",
      "print('\\t\\t I_Cc = %.f\u2220%.f\u00b0 A' %(abs(I_Cc),cmath.phase(I_Cc)*180/math.pi))\n",
      "print('\\nLoad phase voltages are,')\n",
      "print('\\t\\t V_an = %.1f\u2220%.1f\u00b0 V' %(abs(V_an),cmath.phase(V_an)*180/math.pi))\n",
      "print('\\t\\t V_bn = %.1f\u2220%.1f\u00b0 V' %(abs(V_bn),cmath.phase(V_bn)*180/math.pi))\n",
      "print('\\t\\t V_cn = %.1f\u2220%.1f\u00b0 V' %(abs(V_cn),cmath.phase(V_cn)*180/math.pi))\n",
      "print('\\nNOTE : ERROR : Z_L = 6.4\u222038.6\u00b0\u03a9 is taken in textbook solution instead of 6.4\u222051.34\u00b0\u03a9 = (4+j5)\u03a9')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Line currents are,\n",
        "\t\t I_Aa = 28\u2220-53\u00b0 A\n",
        "\t\t I_Bb = 28\u2220-173\u00b0 A\n",
        "\t\t I_Cc = 28\u222067\u00b0 A\n",
        "\n",
        "Load phase voltages are,\n",
        "\t\t V_an = 179.3\u2220-1.8\u00b0 V\n",
        "\t\t V_bn = 179.3\u2220-121.8\u00b0 V\n",
        "\t\t V_cn = 179.3\u2220118.2\u00b0 V\n",
        "\n",
        "NOTE : ERROR : Z_L = 6.4\u222038.6\u00b0\u03a9 is taken in textbook solution instead of 6.4\u222051.34\u00b0\u03a9 = (4+j5)\u03a9\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.9, Page number 23-24"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import cmath\n",
      "\n",
      "#Variable declaration\n",
      "Z = complex(6,8)                            #Per phase impedance of load(ohm)\n",
      "V_AN = 340.0*cmath.exp(1j*0*math.pi/180)    #Phase voltage(V)\n",
      "\n",
      "#Calculation\n",
      "V_P = abs(V_AN)                             #Voltage(V)\n",
      "V_BN = V_P*cmath.exp(1j*-120*math.pi/180)   #Phase voltage(V)\n",
      "V_CN = V_P*cmath.exp(1j*120*math.pi/180)    #Phase voltage(V)\n",
      "I_an = V_AN/Z                               #Load current(A)\n",
      "I_bn = V_BN/Z                               #Load current(A)\n",
      "I_cn = V_CN/Z                               #Load current(A)\n",
      "I_n = I_an+I_bn+I_cn                        #Neutral current(A)\n",
      "\n",
      "#Result\n",
      "print('Phase current in each load = Line current in each load are,')\n",
      "print('\\t\\t\\t\\t I_an = I_Aa = %.f\u2220%.f\u00b0 A' %(abs(I_an),cmath.phase(I_an)*180/math.pi))\n",
      "print('\\t\\t\\t\\t I_bn = I_Bb = %.f\u2220%.f\u00b0 A' %(abs(I_bn),cmath.phase(I_bn)*180/math.pi))\n",
      "print('\\t\\t\\t\\t I_cn = I_Cc = %.f\u2220%.f\u00b0 A' %(abs(I_cn),cmath.phase(I_cn)*180/math.pi))\n",
      "print('Neutral current is , I_n = %.f A' %abs(I_n))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Phase current in each load = Line current in each load are,\n",
        "\t\t\t\t I_an = I_Aa = 34\u2220-53\u00b0 A\n",
        "\t\t\t\t I_bn = I_Bb = 34\u2220-173\u00b0 A\n",
        "\t\t\t\t I_cn = I_Cc = 34\u222067\u00b0 A\n",
        "Neutral current is , I_n = 0 A\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.10, Page number 25-26"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import cmath\n",
      "\n",
      "#Variable declaration\n",
      "Z = complex(3,4)                                 #Per phase impedance of load(ohm)\n",
      "V_AN = 200.0*cmath.exp(1j*0*math.pi/180)         #Phase voltage(V)\n",
      "\n",
      "#Calculation\n",
      "V_P = abs(V_AN)                                   #Voltage(V)\n",
      "V_AB = 3**0.5*V_P*cmath.exp(1j*30*math.pi/180)    #Line voltage(V)\n",
      "V_BC = 3**0.5*V_P*cmath.exp(1j*-90*math.pi/180)   #Line voltage(V)\n",
      "V_CA = 3**0.5*V_P*cmath.exp(1j*150*math.pi/180)   #Line voltage(V)\n",
      "#For case(i)\n",
      "I_ab = V_AB/Z                               #Load current(A)\n",
      "I_bc = V_BC/Z                               #Load current(A)\n",
      "I_ca = V_CA/Z                               #Load current(A)\n",
      "#For case(ii)\n",
      "I_Aa = I_ab-I_ca                            #Line current(A)\n",
      "I_Bb = I_bc-I_ab                            #Line current(A)\n",
      "I_Cc = I_ca-I_bc                            #Line current(A)\n",
      "\n",
      "#Result\n",
      "print('(i) Magnitude of load currents are,')\n",
      "print('\\t\\t I_ab = %.1f\u2220%.2f\u00b0 A' %(abs(I_ab),cmath.phase(I_ab)*180/math.pi))\n",
      "print('\\t\\t I_bc = %.1f\u2220%.2f\u00b0 A' %(abs(I_bc),cmath.phase(I_bc)*180/math.pi))\n",
      "print('\\t\\t I_ca = %.1f\u2220%.2f\u00b0 A' %(abs(I_ca),cmath.phase(I_ca)*180/math.pi))\n",
      "print('\\n(ii) Magnitude of line currents are,')\n",
      "print('\\t\\t I_Aa = %.2f\u2220%.2f\u00b0 A' %(abs(I_Aa),cmath.phase(I_Aa)*180/math.pi))\n",
      "print('\\t\\t I_Bb = %.2f\u2220%.2f\u00b0 A' %(abs(I_Bb),cmath.phase(I_Bb)*180/math.pi))\n",
      "print('\\t\\t I_Cc = %.2f\u2220%.2f\u00b0 A' %(abs(I_Cc),cmath.phase(I_Cc)*180/math.pi))\n",
      "print('\\nNOTE : ERROR : Calculation mistakes in textbook')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i) Magnitude of load currents are,\n",
        "\t\t I_ab = 69.3\u2220-23.13\u00b0 A\n",
        "\t\t I_bc = 69.3\u2220-143.13\u00b0 A\n",
        "\t\t I_ca = 69.3\u222096.87\u00b0 A\n",
        "\n",
        "(ii) Magnitude of line currents are,\n",
        "\t\t I_Aa = 120.00\u2220-53.13\u00b0 A\n",
        "\t\t I_Bb = 120.00\u2220-173.13\u00b0 A\n",
        "\t\t I_Cc = 120.00\u222066.87\u00b0 A\n",
        "\n",
        "NOTE : ERROR : Calculation mistakes in textbook\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.11, Page number 28-29"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import cmath\n",
      "\n",
      "#Variable declaration\n",
      "Z = complex(3,4)                                 #Per phase impedance of load(ohm)\n",
      "V_AN = 150.0*cmath.exp(1j*0*math.pi/180)         #Phase voltage(V)\n",
      "\n",
      "#Calculation\n",
      "V_P = abs(V_AN)                                   #Voltage(V)\n",
      "V_BN = V_P*cmath.exp(1j*-120*math.pi/180)         #Phase voltage(V)\n",
      "V_CN = V_P*cmath.exp(1j*120*math.pi/180)          #Phase voltage(V)\n",
      "I_Aa = V_AN/Z                                     #Line current(A)\n",
      "I_Bb = V_BN/Z                                     #Line current(A)\n",
      "I_Cc = V_CN/Z                                     #Line current(A)\n",
      "pf = Z.real/abs(Z)                                #Power factor\n",
      "I = abs(I_Aa)                                     #Magnitude of line current(A)\n",
      "P = V_P*I*pf*10**-3                               #Power supplied to each phase(kW)\n",
      "P_t = 3*P                                         #Total power supplied(kW)\n",
      "\n",
      "#Result\n",
      "print('Line currents are,')\n",
      "print('  I_Aa = %.f\u2220%.2f\u00b0 A' %(abs(I_Aa),cmath.phase(I_Aa)*180/math.pi))\n",
      "print('  I_Bb = %.f\u2220%.2f\u00b0 A' %(abs(I_Bb),cmath.phase(I_Bb)*180/math.pi))\n",
      "print('  I_Cc = %.f\u2220%.2f\u00b0 A' %(abs(I_Cc),cmath.phase(I_Cc)*180/math.pi))\n",
      "print('Power factor , pf = %.1f ' %pf)\n",
      "print('Power supplied to each phase , P = %.1f kW' %P)\n",
      "print('Total Power supplied to the load , P_t = %.1f kW' %P_t)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Line currents are,\n",
        "  I_Aa = 30\u2220-53.13\u00b0 A\n",
        "  I_Bb = 30\u2220-173.13\u00b0 A\n",
        "  I_Cc = 30\u222066.87\u00b0 A\n",
        "Power factor , pf = 0.6 \n",
        "Power supplied to each phase , P = 2.7 kW\n",
        "Total Power supplied to the load , P_t = 8.1 kW\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.12, Page number 32"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "P = 120.0         #Total power(kW)\n",
      "pf = 0.6          #Power factor \n",
      "\n",
      "#Calculation\n",
      "teta = math.acos(pf)                       #Power factor angle(radians)\n",
      "teta_deg = teta*180/math.pi                #Power factor angle(degree)\n",
      "P_2 = 1.0/2*((math.tan(teta)*P/3**0.5)+P)  #Second wattmeter reading(kW)\n",
      "\n",
      "#Result\n",
      "print('Second wattmeter reading , P_2 = %.1f kW' %P_2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Second wattmeter reading , P_2 = 106.2 kW\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.13, Page number 35"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "P = 5000.0         #Power(W)\n",
      "pf_1 = 0.8         #Initial Power factor\n",
      "V = 110.0          #rms Voltage(V)\n",
      "f = 50.0           #Frequency(Hz)\n",
      "pf_2 = 0.9         #Final Power factor\n",
      "\n",
      "#Calculation\n",
      "phi_1 = math.acos(pf_1)               #Initial Power factor angle(radians)\n",
      "phi_1_deg = phi_1*180/math.pi         #Initial Power factor angle(degree)\n",
      "phi_2 = math.acos(pf_2)               #Final Power factor angle(radians)\n",
      "phi_2_deg = phi_2*180/math.pi         #Final Power factor angle(degree)\n",
      "C = P*(math.tan(phi_1)-math.tan(phi_2))/(2*math.pi*f*V**2)*10**6   #Parallel capacitance(\u00b5F)\n",
      "\n",
      "#Result\n",
      "print('Capacitance , C = %.1f \u00b5F' %C)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Capacitance , C = 349.5 \u00b5F\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.14, Page number 35-36"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "pf_1 = 0.85        #Initial Power factor\n",
      "kVA = 20.0         #Load(kVA)\n",
      "f = 50.0           #Frequency(Hz)\n",
      "pf_2 = 0.95        #Final Power factor\n",
      "V = 200.0          #Voltage(V)\n",
      "R = 0.05           #Resistance(ohm)\n",
      "X = 0.2            #Inductive reactance(ohm)\n",
      "\n",
      "#Calculation\n",
      "phi_1 = math.acos(pf_1)               #Initial Power factor angle(radians)\n",
      "phi_1_deg = phi_1*180/math.pi         #Initial Power factor angle(degree)\n",
      "phi_2 = math.acos(pf_2)               #Final Power factor angle(radians)\n",
      "phi_2_deg = phi_2*180/math.pi         #Final Power factor angle(degree)\n",
      "P = kVA*pf_1                          #Load power(kW)\n",
      "C = P*1000*(math.tan(phi_1)-math.tan(phi_2))/(2*math.pi*f*V**2)*10**6   #Parallel capacitance(\u00b5F)\n",
      "#Before adding capacitor\n",
      "I_1 = P*1000/(pf_1*V)                 #Line current(A)\n",
      "P_1 = I_1**2*R                        #Power loss in line(W)\n",
      "#After adding capacitor\\n\",\n",
      "S = P*1000/pf_2                       #Apparent power(VA)\n",
      "I_2 = S/V                             #Line current(A)\n",
      "P_2 = I_2**2*R                        #Power loss in line(W)\n",
      "\n",
      "#Result\n",
      "print('Capacitance , C = %.1f \u00b5F' %C)\n",
      "print('Power loss in the line before adding capacitor , P_1 = %.1f W' %P_1)\n",
      "print('Power loss in the line after adding capacitor , P_2 = %.1f W' %P_2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Capacitance , C = 393.8 \u00b5F\n",
        "Power loss in the line before adding capacitor , P_1 = 500.0 W\n",
        "Power loss in the line after adding capacitor , P_2 = 400.3 W\n"
       ]
      }
     ],
     "prompt_number": 1
    }
   ],
   "metadata": {}
  }
 ]
}