summaryrefslogtreecommitdiff
path: root/Electrical_Circuit_Theory_And_Technology/chapter_25.ipynb
blob: 592a4669bfedcfff8354a1cb44db6366c94dbfef (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
{
 "metadata": {
  "name": "",
  "signature": "sha256:9b0edaefe058f9c7f8efe48336cbbb08a13cafea026561f6301c02956a595ae7"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h1>Chapter 25: Application of complex numbers to parallel a.c. circuits</h1>"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 1, page no. 446</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "Z1  =  0  -  5j;#  in  ohms\n",
      "Z2  =  25  + 40j;#  in  ohms\n",
      "Z3  =  3  -  2j;#  in  ohms\n",
      "r4  =  50;#  in  ohms\n",
      "theta4  =  40;#  in  degrees\n",
      "\n",
      "#calculation:\n",
      " #admittance  Y\n",
      "Y1  =  1/Z1\n",
      " #conductance,  G\n",
      "G1  =  Y1.real\n",
      " #Suspectance,  Bc\n",
      "Bc1  =  abs(Y1.imag)\n",
      " #admittance  Y\n",
      "Y2  =  1/Z2\n",
      " #conductance,  G\n",
      "G2  =  Y2.real\n",
      " #Suspectance,  Bc\n",
      "Bc2  =  abs(Y2.imag)\n",
      " #admittance  Y\n",
      "Y3  =  1/Z3\n",
      " #conductance,  G\n",
      "G3  =  Y3.real\n",
      " #Suspectance,  Bc\n",
      "Bc3  =  abs(Y3.imag)\n",
      "Z4  =  r4*math.cos(theta4*math.pi/180)  +  1j*r4*math.sin(theta4*math.pi/180)\n",
      " #admittance  Y\n",
      "Y4  =  1/Z4\n",
      " #conductance,  G\n",
      "G4  =  Y4.real\n",
      " #Suspectance,  Bc\n",
      "Bc4  =  abs(Y4.imag)\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n  (a)admittance  Y  is  (\",round(Y1.real,2),\"  +  (\",round(Y1.imag,2),\")i)  S, \"\n",
      "print   \" conductance,  G  is  \",round(G1,2),\"  S,  susceptance,Bc  is  \",round(Bc1,2),\"  S\\n\"\n",
      "print  \"\\n  (b)admittance  Y  is  (\",round(Y2.real,2),\"  +  (\",round(Y2.imag,2),\")i)  S, \"\n",
      "print   \" conductance,  G  is  \",round(G2,2),\"  S,  susceptance,Bc  is  \",round(Bc2,2),\"  S\\n\"\n",
      "print  \"\\n  (c)admittance  Y  is  (\",round(Y3.real,2),\"  +  (\",round(Y3.imag,2),\")i)  S, \"\n",
      "print   \" conductance,  G  is  \",round(G3,2),\"  S,  susceptance,Bc  is  \",round(Bc3,2),\"  S\\n\"\n",
      "print  \"\\n  (d)admittance  Y  is  (\",round(Y4.real,2),\"  +  (\",round(Y4.imag,2),\")i)  S, \"\n",
      "print   \" conductance,  G  is  \",round(G4,2),\"  S,  susceptance,Bc  is  \",round(Bc4,2),\"  S\\n\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "  (a)admittance  Y  is  ( -0.0   +  ( 0.2 )i)  S, \n",
        " conductance,  G  is   -0.0   S,  susceptance,Bc  is   0.2   S\n",
        "\n",
        "\n",
        "  (b)admittance  Y  is  ( 0.01   +  ( -0.02 )i)  S, \n",
        " conductance,  G  is   0.01   S,  susceptance,Bc  is   0.02   S\n",
        "\n",
        "\n",
        "  (c)admittance  Y  is  ( 0.23   +  ( 0.15 )i)  S, \n",
        " conductance,  G  is   0.23   S,  susceptance,Bc  is   0.15   S\n",
        "\n",
        "\n",
        "  (d)admittance  Y  is  ( 0.02   +  ( -0.01 )i)  S, \n",
        " conductance,  G  is   0.02   S,  susceptance,Bc  is   0.01   S\n",
        "\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 2, page no. 447</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "Y2  =  0.001  -  0.002j;#  in  S\n",
      "Y3  =  0.05  +  0.08j;#  in  S\n",
      "r1  =  0.004;#  in  S\n",
      "theta1  =  30;#  in  degrees\n",
      "\n",
      " #calculation:\n",
      " #impedance,  Z\n",
      "Z2  =  1/Y2\n",
      "Z3  =  1/Y3\n",
      "Y1  =  r1*math.cos(theta1*math.pi/180)  +  1j*r1*math.sin(theta1*math.pi/180)\n",
      "Z1  =  1/Y1\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n  (a)Impedance,Z  is  (\",round(Z1.real,2),\"  +  (\",round(  Z1.imag,2),\")i)  ohm\\n\"\n",
      "print  \"\\n  (b)Impedance,Z  is  (\",round(Z2.real,2),\"  +  (\",round(  Z2.imag,2),\")i)  ohm\\n\"\n",
      "print  \"\\n  (c)Impedance,Z  is  (\",round(Z3.real,2),\"  +  (\",round(  Z3.imag,2),\")i)  ohm\\n\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "  (a)Impedance,Z  is  ( 216.51   +  ( -125.0 )i)  ohm\n",
        "\n",
        "\n",
        "  (b)Impedance,Z  is  ( 200.0   +  ( 400.0 )i)  ohm\n",
        "\n",
        "\n",
        "  (c)Impedance,Z  is  ( 5.62   +  ( -8.99 )i)  ohm"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 3, page no. 448</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "Y  =  0.040  -  1j*0.025;#  in  S\n",
      "\n",
      "#calculation:\n",
      " #impedance,  Z\n",
      "Z  =  1/Y\n",
      " #conductance,  G\n",
      "G  =  Y.real\n",
      " #Suspectance,  Bc\n",
      "Bc  =  abs(Y.imag)\n",
      " #parallrl  \n",
      " #resistance,  R\n",
      "Rp  =  1/G\n",
      " #capacitive  reactance\n",
      "Xcp  =  1/Bc\n",
      " #series\n",
      " #resistance,  R\n",
      "Rs  =  Z.real\n",
      " #capacitive  reactance\n",
      "Xcs  =  abs(Z.imag)\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n  (a)for  parallel,  resistance,R  is  \",round(Rp,2),\"  ohm  and  capacitive  reactance,  Xc  is  \",round(Xcp,2),\"  ohm\\n\"\n",
      "print  \"\\n  (b)forseries,  resistance,R  is  \",round(Rs,2),\"  ohm  and  capacitive  reactance,  Xc  is  \",round(Xcs,2),\"  ohm\\n\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "  (a)for  parallel,  resistance,R  is   25.0   ohm  and  capacitive  reactance,  Xc  is   40.0   ohm\n",
        "\n",
        "\n",
        "  (b)forseries,  resistance,R  is   17.98   ohm  and  capacitive  reactance,  Xc  is   11.24   ohm"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 4, page no. 449</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "R1  =  8;#  in  ohm\n",
      "R  =  5;#  in  ohm\n",
      "R2  =  6;#  ohm\n",
      "rv  =  50;#  in  volts\n",
      "thetav  =  0;#  in  degrees\n",
      "\n",
      "#calculation:\n",
      " #voltage,V\n",
      "V  =  rv*math.cos(thetav*math.pi/180)  +  1j*rv*math.sin(thetav*math.pi/180)\n",
      " #circuit  impedance,  ZT\n",
      "ZT  =  R  +  (R1*1j*R2/(R1  +  1j*R2))\n",
      " #Current  I\n",
      "I  =  V/ZT\n",
      " #current,I1\n",
      "I1  =  I*(1j*R2/(R1  +  1j*R2))\n",
      " #current,  I2\n",
      "I2  =  I*(R1/(R1  +  1j*R2))\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n  current,  I  = \",round(abs(I),2),\"/_\",round(cmath.phase(complex(I.real, I.imag))*180/math.pi,2),\"deg  A,\"\n",
      "print   \"current,I1  = \",round(abs(I1),2),\"/_\",round(cmath.phase(complex(I1.real, I1.imag))*180/math.pi,2),\"deg  A,  \"\n",
      "print   \"current,  I2  = \",round(abs(I2),2),\"/_\",round(cmath.phase(complex(I2.real, I2.imag))*180/math.pi,2),\"deg  A\\n\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "  current,  I  =  5.7 /_ -25.98 deg  A,\n",
        "current,I1  =  3.42 /_ 27.15 deg  A,  \n",
        "current,  I2  =  4.56 /_ -62.85 deg  A\n",
        "\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 5, page no. 450</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "R1  =  5;#  in  ohm\n",
      "R2  =  3;#  in  ohm  \n",
      "R3  =  8;#  ohm\n",
      "Xc  =  4;#  in  ohms\n",
      "XL  =  12;#  in  Ohms\n",
      "V  =  40;#  in  volts\n",
      "f  =  50;#  in  Hz\n",
      "\n",
      "#calculation:\n",
      "Z1  =  R1  +  1j*XL\n",
      "Z2  =  R2  -  1j*Xc\n",
      "Z3  =  R3\n",
      " #circuit  admittance,  YT  =  1/ZT\n",
      "YT  =  (1/Z1)  +  (1/Z2)  +  (1/Z3)\n",
      " #Current  I\n",
      "I  =  V*YT\n",
      "I1  =  V/Z1\n",
      "I2  =  V/Z2\n",
      "I3  =  V/Z2\n",
      "thetav  =  0\n",
      "thetai  =  cmath.phase(complex(I.real, I.imag))*180/math.pi\n",
      "phi  =  thetav  -  thetai  \n",
      "if  (phi>0):\n",
      "         a  =  \"lagging\"\n",
      "else:\n",
      "         a  =  \"leading\"\n",
      "\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n  current,  I  is  (\",round(I.real,2),\"  +  (\",round(I.imag,2),\")i)  A,\"\n",
      "print   \"and  its  phase  relative  to  the  40  V  supply  is  \",a,\"s  by  \",round(abs(phi),2),\"deg\\n\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "  current,  I  is  ( 10.98   +  ( 3.56 )i)  A,\n",
        "and  its  phase  relative  to  the  40  V  supply  is   leading s  by   17.96 deg\n",
        "\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 6, page no. 451</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "L  =  0.07958;#  in  Henry\n",
      "R  =  18;#  in  ohm\n",
      "C  =  64.96E-6;#  in  Farad\n",
      "rv  =  250;#  in  volts\n",
      "thetav  =  0;#  in  degrees\n",
      "f  =  50;#  in  Hz\n",
      "\n",
      "#calculation:\n",
      " #Inductive  reactance\n",
      "XL  =  2*math.pi*f*L\n",
      " #capacitive  reactance\n",
      "Xc  =  1/(2*math.pi*f*C)\n",
      " #impedance  of  the  coil,\n",
      "Zcoil  =  R  +  1j*XL\n",
      " #impedance  presented  by  the  capacitor,\n",
      "Zc  =  -1j*Xc\n",
      " #Total  equivalent  circuit  impedance,\n",
      "ZT  =  Zcoil*Zc/(Zcoil  +  Zc)\n",
      " #voltage\n",
      "V  =  rv*math.cos(thetav*math.pi/180)  +  1j*rv*math.sin(thetav*math.pi/180)\n",
      " #current,  I\n",
      "I  =  V/ZT\n",
      "thetai  =  cmath.phase(complex(I.real,I.imag))*180/math.pi\n",
      "phi  =  thetav  -  thetai\n",
      "if  (phi>0):\n",
      "         a  =  \"lagging\"\n",
      "else:\n",
      "         a  =  \"leading\"\n",
      "\n",
      " #Current  in  the  coil,  ICOIL\n",
      "Icoil  =  V/Zcoil\n",
      " #Current  in  the  capacitor,  IC\n",
      "Ic  =  V/Zc\n",
      "\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n  (a)the  circuit  impedance  is  \",round(ZT.real,2),\"  +  (\",round(  ZT.imag,2),\")i  ohm\\n\"\n",
      "print  \"\\n  (b)supply  current,  I  = \",round(abs(I),2),\"/_\",round(cmath.phase(complex(I.real, I.imag))*180/math.pi,2),\"deg  A\\n\"\n",
      "print  \"\\n  (c)circuit  phase  relative  is  \",a,\"s  by  \",round(abs(phi),2),\"deg\\n\"\n",
      "print  \"\\n  (d)current  in  coil,  Icoil  = \",round(abs(Icoil),2),\"/_\",round(cmath.phase(complex(Icoil.real, Icoil.imag))*180/math.pi,2),\"deg  A\\n\"\n",
      "print  \"\\n  (e)current  in  capacitor,  Ic  = \",round(abs(Ic),2),\"/_\",round(cmath.phase(complex(Ic.real, Ic.imag))*180/math.pi,2),\"deg A\\n\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "  (a)the  circuit  impedance  is   48.02   +  ( 15.03 )i  ohm\n",
        "\n",
        "\n",
        "  (b)supply  current,  I  =  4.97 /_ -17.38 deg  A\n",
        "\n",
        "\n",
        "  (c)circuit  phase  relative  is   lagging s  by   17.38 deg\n",
        "\n",
        "\n",
        "  (d)current  in  coil,  Icoil  =  8.12 /_ -54.25 deg  A\n",
        "\n",
        "\n",
        "  (e)current  in  capacitor,  Ic  =  5.1 /_ 90.0 deg A"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 7, page no. 452</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "RL  =  6j;#  in  ohm\n",
      "R2  =  8;#  in  ohm\n",
      "Z3  =  10;#  in  ohm\n",
      "rv  =  50;#  in  volts\n",
      "thetav  =  30;#  in  degrees\n",
      "ri  =  31.4;#  in  amperes\n",
      "thetai  =  52.48;#  in  degrees\n",
      "f  =  5000;#  in  Hz\n",
      "\n",
      "#calculation:\n",
      " #impedance,  Z2\n",
      "Z2  =  R2  +  RL\n",
      " #voltage\n",
      "V  =  rv*math.cos(thetav*math.pi/180)  +  1j*rv*math.sin(thetav*math.pi/180)\n",
      " #current,  I\n",
      "I  =  ri*math.cos(thetai*math.pi/180)  +  1j*ri*math.sin(thetai*math.pi/180)\n",
      " #Total  circuit  admittance,\n",
      "YT  =  I/V\n",
      " #admittance,  Y3\n",
      "Y3  =  1/Z3\n",
      " #admittance,  Y2\n",
      "Y2  =  1/Z2\n",
      " #admittance,  Y1\n",
      "Y1  =  YT  -  Y2  -  Y3\n",
      " #impedance,  Z1\n",
      "Z1  =  1/Y1\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n  (a)the  impedance  Z1  is  \",round(Z1.real,2),\"  +  (\",round(  Z1.imag,2),\")i  ohm\\n\"\n",
      "\n",
      " #resistance,  R1\n",
      "R1  =  Z1.real\n",
      "X1  =  Z1.imag  \n",
      "if  ((R1>0)&(X1<0)):\n",
      "    C1  =  -1/(2*math.pi*f*X1)\n",
      "    print  \"\\n  (b)The  series  circuit  thus  consists  of  a  resistor  of  resistance  \",round(R1,2),\"  ohm\"\n",
      "    print   \"  and  a  capacitor  of  capacitance  \",round(C1*1E6,2),\"uFarad\\n\"\n",
      "elif  ((R1>0)&(X1>0)):\n",
      "    L1  =  2*math.pi*f*X1\n",
      "    print  \"\\n  (b)The  series  circuit  thus  consists  of  a  resistor  of  resistance  \",round(R1,2),\"  ohm \"\n",
      "    print   \" and  a  inductor  of  insuctance  \",round(L1*1000,2),\"mHenry\\n\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "  (a)the  impedance  Z1  is   1.6   +  ( -1.2 )i  ohm\n",
        "\n",
        "\n",
        "  (b)The  series  circuit  thus  consists  of  a  resistor  of  resistance   1.6   ohm\n",
        "  and  a  capacitor  of  capacitance   26.55 uFarad\n",
        "\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 8, page no. 453</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "RL1  =  1.02j;#  in  ohm\n",
      "R1  =  1.65;#  in  ohm\n",
      "RLa  =  7j;#  in  ohm\n",
      "Ra  =  5;#  in  ohm\n",
      "Rcb  =  -1j*15;#  in  ohm\n",
      "Rb  =  4;#  in  ohm\n",
      "rv  =  91;#  in  volts\n",
      "thetav  =  0;#  in  degree\n",
      "\n",
      "#calculation:\n",
      " #voltage\n",
      "V  =  rv*math.cos(thetav*math.pi/180)  +  1j*rv*math.sin(thetav*math.pi/180)\n",
      " #impedance,  Z1\n",
      "Z1  =  R1  +  RL1\n",
      " #impedance,  Za\n",
      "Za  =  Ra  +  RLa\n",
      " #impedance,  Zb\n",
      "Zb  =  Rb  +  Rcb\n",
      " #impedance,  Z,  of  the  two  branches  connected  in  parallel\n",
      "Z  =  Za*Zb/(Za  +  Zb)\n",
      " #Total  circuit  impedance\n",
      "ZT  =  Z1  +  Z\n",
      " #Supply  current,  I\n",
      "I  =  V/ZT\n",
      "thetai  =  cmath.phase(complex(I.real, I.imag))*180/math.pi\n",
      "phi  =  thetav  -  thetai  \n",
      "if  (phi>0):\n",
      "         a  =  \"lagging\"\n",
      "else:\n",
      "         a  =  \"leading\"\n",
      "\n",
      " #Voltage  V1\n",
      "V1  =  I*Z1\n",
      " #Voltage  V2\n",
      "V2  =  I*Z\n",
      " #current  Ia\n",
      "Ia  =  V2/Za\n",
      " #Current  Ib\n",
      "Ib  =  V2/Zb\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n  (a)equivalent  series  circuit  impedance  is  \",round(ZT.real,2),\"  +  (\",round(  ZT.imag,2),\")i  ohm\\n\"\n",
      "print  \"\\n  (b)supply  current,  I  is  \",round(I.real,2),\"  +  (\",round(  I.imag,2),\")i  A\\n\"\n",
      "print  \"\\n  (c)circuit  phase  relative  is  \",a,\"  by  \",round(abs(phi),2),\"deg\\n\"\n",
      "print  \"\\n  (d)voltage,  V1  is  (\",round(V1.real,2),\"  +  (\",round(V1.imag,2),\")i)  V  and  V2  is(\",round(V2.real,2),\"  +  (\",round(  V2.imag,2),\")i)  V\\n\"\n",
      "print  \"\\n  (e)current,  Ia  is  (\",round(Ia.real,2),\"  +  (\",round( Ia.imag,2),\")i)  A  and  Ib  is(\",round(Ib.real,2),\"  +  (\",round(  Ib.imag,2),\")i)  A\\n\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "  (a)equivalent  series  circuit  impedance  is   12.0   +  ( 5.0 )i  ohm\n",
        "\n",
        "\n",
        "  (b)supply  current,  I  is   6.46   +  ( -2.69 )i  A\n",
        "\n",
        "\n",
        "  (c)circuit  phase  relative  is   lagging   by   22.61 deg\n",
        "\n",
        "\n",
        "  (d)voltage,  V1  is  ( 13.41   +  ( 2.15 )i)  V  and  V2  is( 77.59   +  ( -2.15 )i)  V\n",
        "\n",
        "\n",
        "  (e)current,  Ia  is  ( 5.04   +  ( -7.49 )i)  A  and  Ib  is( 1.42   +  ( 4.79 )i)  A"
       ]
      }
     ],
     "prompt_number": 8
    }
   ],
   "metadata": {}
  }
 ]
}