{ "metadata": { "name": "", "signature": "sha256:cc9bf89f9ef283e2e254a84fd5c837c0ed5af6c8784b676db04bdba61dcf814e" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "

# Chapter 30: Introduction to network analysis

" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

### Example 1, page no. 536

" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "from __future__ import division\n", "import math\n", "import cmath\n", "#initializing the variables:\n", "rv1 = 100;# in volts\n", "rv2 = 50;# in volts\n", "thetav1 = 0;# in degrees\n", "thetav2 = 90;# in degrees\n", "R1 = 25;# in ohm\n", "R2 = 20;# in ohm\n", "R3 = 10;# in ohm\n", "\n", "#calculation:\n", " #voltage\n", "V1 = rv1*math.cos(thetav1*math.pi/180) + 1j*rv1*math.sin(thetav1*math.pi/180)\n", "V2 = rv2*math.cos(thetav2*math.pi/180) + 1j*rv2*math.sin(thetav2*math.pi/180)\n", " #The branch currents and their directions are labelled as shown in Figure 30.4\n", " #Two loops are chosen. loop ABEF, and loop BCDE\n", " #using kirchoff rule in 3 loops\n", " #two eqns obtained\n", " #(R1 + R2)*I1 + R2*I2 = V1\n", " #R2*I1 + (R2 + R3)*I2 = V2\n", "I1 = (3*V1 - 2*V2)/(3*(R1 + R2) - 2*(R2))\n", "I2 = (V2 - R2*I1)/(R2 + R3)\n", "I = I1 + I2\n", "\n", "\n", "#Results\n", "print \"\\n\\n Result \\n\\n\"\n", "print \"\\n current, I1 is \",round(I1.real,2),\" + (\",round( I1.imag,2),\")i A, \\n current, I2 is \",round(I2.real,2),\" + (\",round( I2.imag,2),\")i A and \"\n", "print \" total current, I is \",round(I.real,2),\" + (\",round( I.imag,2),\")i A\"" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "\n", "\n", " Result \n", "\n", "\n", "\n", " current, I1 is 3.16 + ( -1.05 )i A, \n", " current, I2 is -2.11 + ( 2.37 )i A and \n", " total current, I is 1.05 + ( 1.32 )i A\n" ] } ], "prompt_number": 4 }, { "cell_type": "markdown", "metadata": {}, "source": [ "

### Example 2, page no. 537

" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "from __future__ import division\n", "import math\n", "import numpy\n", "#initializing the variables:\n", "V = 8;# in volts\n", "R1 = 1;# in ohm\n", "R2 = 2;# in ohm\n", "R3 = 3;# in ohm\n", "R4 = 4;# in ohm\n", "R5 = 5;# in ohm\n", "R6 = 6;# in ohm\n", "\n", "#calculation:\n", " #Currents and their directions are assigned as shown in Figure 30.6.\n", " #Three loops are chosen since three unknown currents are required. The choice of loop directions is arbitrary.\n", " #loop ABCDE, and loop EDGF and loop DCHG\n", " #using kirchoff rule in 3 loops\n", " #three eqns obtained\n", " #R5*I1 + (R6 + R4)*I2 - R4*I3 = V\n", " #-1*R1*I1 + (R6 + R1)*I2 + R2*I3 = 0\n", " # R3*I1 - (R3 + R4)*I2 + (R2 + R3 + R4)*I3 = 0\n", "#using determinants\n", "d1 = [[V, (R6 + R4), -1*R4],[0, (R6 + R1), R2], [0, (-1*(R3 + R4)), (R2 + R3 + R4)]]\n", "D1 = numpy.linalg.det(d1)\n", "d2 = [[R5, V, -1*R4],[-1*R1, 0, R2],[ R3, 0, (R2 + R3 + R4)]]\n", "D2 = numpy.linalg.det(d2)\n", "d3 = [[R5, (R6 + R4), V],[-1*R1, (R6 + R1), 0],[ R3, (-1*(R3 + R4)), 0]]\n", "D3 = numpy.linalg.det(d3)\n", "d = [[R5, (R6 + R4), -1*R4],[-1*R1, (R6 + R1), R2],[ R3, (-1*(R3 + R4)), (R2 + R3 + R4)]]\n", "D = numpy.linalg.det(d)\n", "I1 = D1/D\n", "I2 = D2/D\n", "I3 = D3/D \n", "#Current in the 2 ohm resistance\n", "I = I1 - I2 + I3\n", "#power dissipated in the 3 ohm resistance\n", "P3 = R3*I**2\n", "\n", "\n", "#Results\n", "print \"\\n\\n Result \\n\\n\"\n", "print \"\\n (a)current through 2 ohm resistor is \",round(I2,3),\" A\"\n", "print \"\\n (b)power dissipated in the 3 ohm resistor is \",round(P3,3),\"W\"" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "\n", "\n", " Result \n", "\n", "\n", "\n", " (a)current through 2 ohm resistor is 0.203 A\n", "\n", " (b)power dissipated in the 3 ohm resistor is 1.267 W" ] } ], "prompt_number": 4 }, { "cell_type": "markdown", "metadata": {}, "source": [ "

### Example 3, page no. 539

" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "from __future__ import division\n", "import math\n", "import cmath\n", "#initializing the variables:\n", "E1 = 5 + 0j;# in volts\n", "E2 = 2 + 4j;# in volts\n", "Z1 = 3 + 4j;# in ohm\n", "Z2 = 2 - 5j;# in ohm\n", "Z3 = 6 + 8j;# in ohm\n", "\n", "#calculation:\n", " #Currents I1 and I2 with their directions are shown in Figure 30.8.\n", " #Two loops are chosen with their directions both clockwise.loop ABEF and loop BCDE,\n", " #using kirchoff rule in 3 loops\n", " #two eqns obtained\n", " #(Z1 + Z3)*I1 - Z3*I2 = E1\n", " #-1*Z3*I1 + (Z2 + Z3)*I2 = E2\n", "I1 = ((Z2 + Z3)*E1 + Z3*E2)/((Z2 + Z3)*(Z1 + Z3) - Z3*Z3)\n", "I2 = -1*(E1 - (Z1 + Z3)*I1)/Z3\n", "I3 = I1 - I2\n", "\n", "\n", "#Results\n", "print \"\\n\\n Result \\n\\n\"\n", "print \"current, I1 is \",round(I1.real,2),\" + (\",round( I1.imag,2),\")i A,\\n current, I2 is \",round(I2.real,2),\" + (\",round( I2.imag,2),\")i A and \"\n", "print \" current, I3 is \",round(I3.real,2),\" + (\",round( I3.imag,2),\")i A\"" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "\n", "\n", " Result \n", "\n", "\n", "current, I1 is 0.57 + ( 0.62 )i A,\n", " current, I2 is 0.56 + ( 1.33 )i A and \n", " current, I3 is 0.01 + ( -0.71 )i A\n" ] } ], "prompt_number": 3 }, { "cell_type": "markdown", "metadata": {}, "source": [ "

### Example 4, page no. 541

" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "from __future__ import division\n", "import math\n", "import numpy\n", "import cmath\n", "#initializing the variables:\n", "rv1 = 10;# in volts\n", "rv2 = 12;# in volts\n", "rv3 = 15;# in volts\n", "thetav1 = 0;# in degrees\n", "thetav2 = 0;# in degrees\n", "thetav3 = 0;# in degrees\n", "R1 = 4;# in ohm\n", "R2 = -5j;# in ohm\n", "R3 = 8;# in ohm\n", "R4 = 4;# in ohm\n", "R5 = 3j;# in ohm\n", "\n", "#calculation:\n", " #voltages\n", "V1 = rv1*math.cos(thetav1*math.pi/180) + 1j*rv1*math.sin(thetav1*math.pi/180)\n", "V2 = rv2*math.cos(thetav2*math.pi/180) + 1j*rv2*math.sin(thetav2*math.pi/180)\n", "V3 = rv3*math.cos(thetav3*math.pi/180) + 1j*rv3*math.sin(thetav3*math.pi/180)\n", " #Currents I1, I2 and I3 with their directions are shown in Figure 30.10.\n", " #Three loops are chosen. The choice of loop directions is arbitrary. loop ABGH, and loopBCFG and loop CDEF\n", "Z4 = R4 + R5\n", " #using kirchoff rule in 3 loops\n", " #three eqns obtained\n", " #R1*I1 + R2*I2 = V1 + V2\n", " #-1*R3*I1 + (R3 + R2)*I2 + R3*I3 = V2 + V3\n", " # -1*R3*I1 + R3*I2 + (R3 + Z4)*I3 = V3\n", " #using determinants\n", "d1 = [[(V1 + V2), R2, 0],[(V2 + V3), (R3 + R2), R3],[V3, R3, (R3 + Z4)]]\n", "D1 = numpy.linalg.det(d1)\n", "d2 = [[R1, (V1 + V2), 0],[-1*R3, (V2 + V3), R3],[-1*R3, V3, (R3 + Z4)]]\n", "D2 = numpy.linalg.det(d2)\n", "d3 = [[R1, R2, (V1 + V2)],[-1*R3, (R3 + R2), (V2 + V3)],[-1*R3, R3, V3]]\n", "D3 = numpy.linalg.det(d3)\n", "d = [[R1, R2, 0],[-1*R3, (R3 + R2), R3],[-1*R3, R3, (R3 + Z4)]]\n", "D = numpy.linalg.det(d)\n", "I1 = D1/D\n", "I2 = D2/D\n", "I3 = D3/D \n", "I3mag = abs(I3)\n", "\n", "\n", "#Results\n", "print \"\\n\\n Result \\n\\n\"\n", "print \"\\n magnitude of the current through (4 + i3)ohm impedance is \",round(I3mag,2),\" A\"" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "\n", "\n", " Result \n", "\n", "\n", "\n", " magnitude of the current through (4 + i3)ohm impedance is 1.84 A" ] } ], "prompt_number": 8 } ], "metadata": {} } ] }