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

Chapter 31: Mesh-current and nodal analysis

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

Example 1, page no. 546

" ] }, { "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", "V1 = 4;# in volts\n", "V2 = 5;# in volts\n", "R1 = 3;# in ohm\n", "R2 = 5;# in ohm\n", "R3 = 4;# in ohm\n", "R4 = 1;# in ohm\n", "R5 = 6;# in ohm\n", "R6 = 8;# in ohm\n", "\n", "#calculation:\n", " #The mesh currents I1, I2 and I3 are shown in Figure 31.2. Using Kirchhoff\u2019s voltage law in 3 loops\n", " #three eqns obtained\n", " #(R1 + R2)*I1 - R2*I2 = V1\n", " #-1*R2*I1 + (R2 + R3 + R4 + R5)*I2 - R4*I3 = 0\n", " # -1*R4*I2 + (R4 + R6)*I3 = -1*V2\n", " #using determinants\n", "d1 = [[V1, -1*R2, 0],[0, (R2 + R3 + R4 + R5), -1*R4],[-1*V2, -1*R4, (R4 + R6)]]\n", "D1 = numpy.linalg.det(d1)\n", "d2 = [[(R1 + R2), V1, 0],[-1*R2, 0, -1*R4],[0, -1*V2, (R4 + R6)]]\n", "D2 = numpy.linalg.det(d2)\n", "d3 = [[(R1 + R2), -1*R2, V1],[-1*R2, (R2 + R3 + R4 + R5), 0],[0, -1*R4, -1*V2]]\n", "D3 = numpy.linalg.det(d3)\n", "d = [[(R1 + R2), -1*R2, 0],[-1*R2, (R2 + R3 + R4 + R5), -1*R4],[0, -1*R4, (R4 + R6)]]\n", "D = numpy.linalg.det(d)\n", "I1 = D1/D\n", "I2 = D2/D\n", "I3 = D3/D \n", "IR2 = I1 - I2\n", "IR4 = I2 - I3\n", "\n", "\n", "#Results\n", "print \"\\n\\n Result \\n\\n\"\n", "print \"\\n (a)current in the 5 ohm resistance is \",round(IR2,2),\" A\"\n", "print \"\\n (b)current in the 1 ohm resistance is \",round(IR4,2),\" A\"" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "\n", "\n", " Result \n", "\n", "\n", "\n", " (a)current in the 5 ohm resistance is 0.44 A\n", "\n", " (b)current in the 1 ohm resistance is 0.69 A" ] } ], "prompt_number": 1 }, { "cell_type": "markdown", "metadata": {}, "source": [ "

Example 2, page no. 547

" ] }, { "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", "rv = 100;# in volts\n", "thetav = 0;# in degrees\n", "R1 = 5;# in ohm\n", "R2 = -1j*4;# in ohm\n", "R3 = 4;# in ohm\n", "R4 = 3j;# in ohm\n", "\n", " #calculation:\n", " #voltages\n", "V = rv*math.cos(thetav*math.pi/180) + 1j*rv*math.sin(thetav*math.pi/180)\n", " #Currents I1, I2 with their directions are shown in Figure 31.03.\n", " #Two loops are chosen. The choice of loop directions is arbitrary.\n", " #using kirchoff rule in 2 loops\n", " #two eqns obtained\n", " #(R1 + R2)*I1 - R2*I2 = V\n", " #-1*R2*I1 + (R3 + R2 + R4)*I2 = 0\n", " #using determinants\n", "d1 = [[V, -1*R2],[0, (R3 + R2 + R4)]]\n", "D1 = numpy.linalg.det(d1)\n", "d2 = [[(R1 + R2), V],[-1*R2, 0]]\n", "D2 = numpy.linalg.det(d2)\n", "d = [[(R1 + R2), -1*R2],[-1*R2, (R3 + R2 + R4)]]\n", "D = numpy.linalg.det(d)\n", "I1 = D1/D\n", "I2 = D2/D\n", "I1mag = abs(I1)\n", " #Current flowing in capacitor\n", "Ic = I1 - I2\n", " #Source power P\n", "phi = cmath.phase(complex(I1.real,I1.imag))\n", "P = V*I1mag*math.cos(phi)\n", "Icmag = abs(Ic)\n", "\n", "\n", "#Results\n", "print \"\\n\\n Result \\n\\n\"\n", "print \"(a)current,I1 is \",round(I1.real,2),\" + (\",round( I1.imag,2),\")i A, current, I2 is\",round(I2.real,2),\" + (\",round(I2.imag,2),\")i A\"\n", "print \"(b)current in the capacitor is \",round(Icmag,2),\" A\"\n", "print \"(c)Source power P is \",round(abs(P),2),\" W\"" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "\n", "\n", " Result \n", "\n", "\n", "(a)current,I1 is 10.17 + ( 3.55 )i A, current, I2 is 5.73 + ( -8.74 )i A\n", "(b)current in the capacitor is 13.06 A\n", "(c)Source power P is 1017.06 W\n" ] } ], "prompt_number": 1 }, { "cell_type": "markdown", "metadata": {}, "source": [ "

Example 3, page no. 548

" ] }, { "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 = 415;# in volts\n", "rv2 = 415;# in volts\n", "thetav1 = 120;# in degrees\n", "thetav2 = 0;# in degrees\n", "R = 3 + 4j;# 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", " #Two mesh currents I1 and I2 are chosen as shown in Figure 31.4.\n", " #Two loops are chosen. The choice of loop directions is arbitrary.\n", " #using kirchoff rule in 2 loops\n", " #two eqns obtained\n", " #2*R*I1 - R*I2 = V1\n", " #-1*R*I1 + 2*R*I2 = V2\n", " #using determinants\n", "d1 = [[V1, -1*R],[V2, 2*R]]\n", "D1 = numpy.linalg.det(d1)\n", "d2 = [[2*R, V1],[-1*R, V2]]\n", "D2 = numpy.linalg.det(d2)\n", "d = [[2*R, -1*R],[-1*R, 2*R]]\n", "D = numpy.linalg.det(d)\n", "I1 = D1/D\n", "I2 = D2/D\n", "I1mag = abs(I1)\n", " #line current IR\n", "IR = I1\n", " #line current IB\n", "IB = -1*I2\n", " #line current IY\n", "IY = I2 - I1\n", "\n", "\n", "#Results\n", "print \"\\n\\n Result \\n\\n\"\n", "print \"current, IR is\",round(IR.real,2),\" + (\",round( IR.imag,2),\")i A, current, IB is\",round(IB.real,2),\" + (\",round( IB.imag,2),\")i A and current, IY is \",round(IY.real,2),\" + (\",round(IY.imag,2),\")i A\"" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "\n", "\n", " Result \n", "\n", "\n", "current, IR is 38.34 + ( 28.75 )i A, current, IB is -44.07 + ( 18.82 )i A and current, IY is 5.73 + ( -47.58 )i A\n" ] } ], "prompt_number": 2 }, { "cell_type": "markdown", "metadata": {}, "source": [ "

Example 4, page no. 551

" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "from __future__ import division\n", "import math\n", "import cmath\n", "#initializing the variables:\n", "ri = 20;# in amperes\n", "thetai = 0;# in degrees\n", "R1 = 10;# in ohm\n", "R2 = 3j;# in ohm\n", "R3 = 4;# in ohm\n", "R4 = 16;# in ohm\n", "\n", "#calculation:\n", " #current\n", "I = ri*math.cos(thetai*math.pi/180) + 1j*ri*math.sin(thetai*math.pi/180)\n", " #Figure 31.8 contains two principal nodes (at 1 and B) and thus only one nodal equation is required. \n", " #B is taken as the reference node and the equation for node 1 is obtained as follows. \n", " #Applying Kirchhoff\u2019s current law to node 1 gives:\n", " #IX + IY = I\n", "V1 = I/((1/R4) +(1/(R2 +R3)))\n", "IY = V1/(R2 + R3)\n", "VAB = IY*R3\n", "\n", "\n", "#Results\n", "print \"\\n\\n Result \\n\\n\"\n", "print \"\\n voltage VAB is \",round(VAB.real,2),\" + (\",round( VAB.imag,2),\")i V\"" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "\n", "\n", " Result \n", "\n", "\n", "\n", " voltage VAB is 62.59 + ( -9.39 )i V" ] } ], "prompt_number": 4 }, { "cell_type": "markdown", "metadata": {}, "source": [ "

Example 5, page no. 552

" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "from __future__ import division\n", "import math\n", "import cmath\n", "#initializing the variables:\n", "rv1 = 8;# in volts\n", "rv2 = 8;# in volts\n", "thetav1 = 0;# in degrees\n", "thetav2 = 90;# in degrees\n", "R1 = 5;# in ohm\n", "R2 = 6j;# in ohm\n", "R3 = 4;# in ohm\n", "R4 = 3;# 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", " #The circuit contains no principal nodes. \n", " #However, if point Y is chosen as the reference node then an equation \n", " #may be written for node X assuming that current leaves point X by both branches\n", "VX = ((V1/(R1 + R3) + V2/(R2 + R4))/(1/(R1 + R3) + 1/(R2 + R4)))\n", "VXY = VX\n", "\n", "\n", "\n", "#Results\n", "print \"\\n\\n Result \\n\\n\"\n", "print \"\\n voltage VXY = \",round(abs(VXY),2),\"/_\",round(cmath.phase(complex(VXY.real, VXY.imag))*180/math.pi,2),\"deg V\"" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "\n", "\n", " Result \n", "\n", "\n", "\n", " voltage VXY = 9.12 /_ 52.13 deg V" ] } ], "prompt_number": 1 }, { "cell_type": "markdown", "metadata": {}, "source": [ "

Example 6, page no. 553

" ] }, { "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", " #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", " #There are only two principal nodes in Figure 31.10 so only one nodal equation is required. \n", " #Node 2 is taken as the reference node.\n", " #The equation at node 1 is I1 + I2 + I3 = 0\n", "Vn1 = ((V1/R1 + V2/R3)/(1/R1 + 1/R2 + 1/R3))\n", "I1 = (Vn1 - V1)/R1\n", "I2 = Vn1/R2\n", "I3 = (Vn1 - V2)/R3\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 \\n and 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", "\n", " current, I1 is -3.16 + ( 1.05 )i A, \n", " current, I2 is 1.05 + ( 1.32 )i A \n", " and current, I3 is 2.11 + ( -2.37 )i A" ] } ], "prompt_number": 6 }, { "cell_type": "markdown", "metadata": {}, "source": [ "

Example 7, page no. 554

" ] }, { "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 = 25;# in volts\n", "rv2 = 25;# in volts\n", "thetav1 = 0;# in degrees\n", "thetav2 = 90;# in degrees\n", "R1 = 2;# in ohm\n", "R2 = -1j*4;# in ohm\n", "R3 = 5;# in ohm\n", "R4 = 4j;# in ohm\n", "R5 = 2.5;# 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", " #The equation at node 1\n", " #Vn1*(1/R1 + 1/R2 + 1/R3) - Vn2/R3 = V1/R1\n", " #The equation at node 2\n", " #Vn1*(-1/R3) + Vn2*(1/R4 + 1/R5 + 1/R3) = V2/R5\n", " #using determinants\n", "d1 = [[V1/R1, -1/R3],[V2/R5, (1/R4 + 1/R5 + 1/R3)]]\n", "D1 = numpy.linalg.det(d1)\n", "d2 = [[(1/R1 + 1/R2 + 1/R3), V1/R1],[-1/R3, V2/R5]]\n", "D2 = numpy.linalg.det(d2)\n", "d = [[(1/R1 + 1/R2 + 1/R3), -1/R3],[-1/R3, (1/R4 + 1/R5 + 1/R3)]]\n", "D = numpy.linalg.det(d)\n", "Vn1 = D1/D\n", "Vn2 = D2/D\n", " #current in the j4 ohm inductance is given by:\n", "I4 = Vn2/R4\n", " #current in the 5 ohm resistance is given by:\n", "I3 = (Vn1 - Vn2)/R3\n", " #active power dissipated in the 2.5 ohm resistor is given by\n", "P5 = R5*((Vn2 - V2)/R5)**2\n", " #magnitude of the active power dissipated\n", "P5mag = abs(P5)\n", "\n", "#Results\n", "print \"\\n\\n Result \\n\\n\"\n", "print \"\\n (a) the voltage at nodes 1 and 2 are \",round(abs(Vn1),1),\"/_\",round(cmath.phase(complex(Vn1.real, Vn1.imag))*180/math.pi,2),\"deg V and \",round(abs(Vn2),1),\"/_\",round(cmath.phase(complex(Vn2.real, Vn2.imag))*180/math.pi,1),\"deg V\"\n", "print \"\\n (b)the current in the j4 ohm inductance = \",round(abs(I4),2),\"/_\",round(cmath.phase(complex(I4.real, I4.imag))*180/math.pi,2),\"deg A\"\n", "print \"\\n (c)the current in the 5 ohm resistance = \",round(abs(I3),2),\"/_\",round(cmath.phase(complex(I3.real, I3.imag))*180/math.pi,2),\"deg A\"\n", "print \"\\n (d) magnitude of the active power dissipated in the 2.5 ohm resistance is \",round(P5mag,2),\" W\"" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "\n", "\n", " Result \n", "\n", "\n", "\n", " (a) the voltage at nodes 1 and 2 are 17.1 /_ -5.3 deg V and 15.8 /_ 93.2 deg V\n", "\n", " (b)the current in the j4 ohm inductance = 3.95 /_ 3.23 deg A\n", "\n", " (c)the current in the 5 ohm resistance = 4.99 /_ -44.06 deg A\n", "\n", " (d) magnitude of the active power dissipated in the 2.5 ohm resistance is 34.4 W" ] } ], "prompt_number": 3 }, { "cell_type": "markdown", "metadata": {}, "source": [ "

Example 8, page no. 556

" ] }, { "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", "ri = 25;# in amperes\n", "thetai = 0;# in degrees\n", "R1 = 4;# in ohm\n", "R2 = 3j;# in ohm\n", "R3 = 5;# in ohm\n", "R4 = 10j;# in ohm\n", "R5 = 20j;# in ohm\n", "\n", " #calculation:\n", " #current\n", "I = ri*math.cos(thetai*math.pi/180) + 1j*ri*math.sin(thetai*math.pi/180)\n", " #Node 3 is taken as the reference node.\n", " #At node 1,\n", " #V1*(1/(R1 + R2) + 1/R3) - V2/R3 = I\n", " #The equation at node 2\n", " #V1*(-1/R3) + V2*(1/R4 + 1/R5 + 1/R3) = 0\n", " #using determinants\n", "d1 = [[I, -1/R3],[0 , (1/R4 + 1/R5 + 1/R3)]]\n", "D1 = numpy.linalg.det(d1)\n", "d2 = [[(1/(R1 + R2) + 1/R3), I],[-1/R3, 0]]\n", "D2 = numpy.linalg.det(d2)\n", "d = [[(1/(R1 + R2) + 1/R3), -1/R3],[-1/R3, (1/R4 + 1/R5 + 1/R3)]]\n", "D = numpy.linalg.det(d)\n", "V1 = D1/D\n", "V2 = D2/D\n", " #the voltage between point X and node 3 is\n", "VX = V1*R2/(R1 + R2)\n", " #Thus the voltage\n", "VY = V2\n", "VXY = VX - VY\n", "\n", "\n", "#Results\n", "print \"\\n\\n Result \\n\\n\"\n", "print \"\\n voltage VXY is \",round(VXY.real,2),\" + (\",round( VXY.imag,2),\")i V\"" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "\n", "\n", " Result \n", "\n", "\n", "\n", " voltage VXY is -16.16 + ( -15.05 )i V" ] } ], "prompt_number": 8 }, { "cell_type": "markdown", "metadata": {}, "source": [ "

Example 9, page no. 557

" ] }, { "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", "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", " #In Figure 31.13, the reference node is shown at point A.\n", " #At node 1,\n", " #V1*(1/R1 + 1/R6 + 1/R5) - V2/R1 - V3/R5 = V/R5\n", " #The equation at node 2\n", " #V1*(-1/R1) + V2*(1/R2 + 1/R1 + 1/R3) - V3/R3 = 0\n", " #At node 3\n", " # - V1/R5 - V2/R3 + V3*(1/R4 + 1/R3 + 1/R5) = -1*V/R5\n", "#using determinants\n", "d1 = [[V/R5, -1/R1, -1/R5],[0, (1/R2 + 1/R1 + 1/R3), -1/R3],[-1*V/R5, -1/R3, (1/R4 + 1/R3 + 1/R5)]]\n", "D1 = numpy.linalg.det(d1)\n", "d2 = [[(1/R1 + 1/R6 + 1/R5), V/R5, -1/R5],[-1/R1, 0, -1/R3],[-1/R5, -1*V/R5, (1/R4 + 1/R3 + 1/R5)]]\n", "D2 = numpy.linalg.det(d2)\n", "d3 = [[(1/R1 + 1/R6 + 1/R5), -1/R1, V/R5],[-1/R1, (1/R2 + 1/R1 + 1/R3), 0],[-1/R5, -1/R3, -1*V/R5]]\n", "D3 = numpy.linalg.det(d3)\n", "d =[[(1/R1 + 1/R6 + 1/R5), -1/R1, -1/R5],[-1/R1, (1/R2 + 1/R1 + 1/R3), -1/R3],[-1/R5, -1/R3, (1/R4 + 1/R3 + 1/R5)]]\n", "D = numpy.linalg.det(d)\n", "Vn1 = D1/D\n", "Vn2 = D2/D\n", "Vn3 = D3/D \n", " #the current in the 2 ohm resistor\n", "I2 = Vn2/R2\n", " #power dissipated in the 3 ohm resistance\n", "P3 = R3*((Vn2 - Vn3)/R3)**2\n", "\n", "\n", "#Results\n", "print \"\\n\\n Result \\n\\n\"\n", "print \"\\n (a)current through 2 ohm resistor is \",round(I2,2),\" A\"\n", "print \"\\n (b)power dissipated in the 3 ohm resistor is \",round(P3,2),\" 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.19 A\n", "\n", " (b)power dissipated in the 3 ohm resistor is 1.27 W\n" ] } ], "prompt_number": 3 } ], "metadata": {} } ] }