{
 "metadata": {
  "name": "",
  "signature": "sha256:ef0f04156af110c85f44cbf4f7c9b4a7f78444e3b8eab6fe43fee89327c37d26"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h1>Chapter 26: Power in a.c. circuits</h1>"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 1, page no. 466</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "RL  =  12j;#  in  ohm\n",
      "R  =  5;#  in  ohm\n",
      "rv  =  52;#  in  volts\n",
      "thetav  =  30;#  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,  Z\n",
      "Z  =  R  +  RL\n",
      " #current\n",
      "I  =  V/Z\n",
      " #Active  power,  P\n",
      "Pa  =  V.real*I.real  +  V.imag*I.imag\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\nthe  active  power  in  the  circuit  \",Pa,\"  W\\n\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "the  active  power  in  the  circuit   80.0   W"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 2, page no. 467</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "V  =  120  +  200j;#  in  volts\n",
      "I  =  15  +  8j;#  in  amperes\n",
      "\n",
      "#calculation:\n",
      " #Active  power,  P\n",
      "Pa  =  V.real*I.real  +  V.imag*I.imag\n",
      " #Reactive  power,  Q\n",
      "Q  =  V.imag*I.real  -  V.real*I.imag\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n  (a)  the  active  power  in  the  circuit  \",Pa,\"  W\\n\"\n",
      "print  \"\\n  (b)  the  reactive  power  in  the  circuit  \",Q,\"  var\\n\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "  (a)  the  active  power  in  the  circuit   3400.0   W\n",
        "\n",
        "\n",
        "  (b)  the  reactive  power  in  the  circuit   2040.0   var"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 3, page no. 468</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "Vm  =  141.4;#  in  volts\n",
      "w  =  10000;#  in  rad/sec\n",
      "phiv  =  math.pi/9;#  in  radian\n",
      "Pd  =  1732;#  in  Watts\n",
      "pf  =  0.866;#  power  fctr\n",
      "\n",
      "#calculation:\n",
      " #the  rms  voltage,\n",
      "Vrms  =  0.707*Vm\n",
      " #Power  P  =  V*I*cos(phi)\n",
      " #current  magnitude,  Irms\n",
      "Irms  =  Pd/(Vrms*pf)\n",
      "phid  =  math.acos(pf)\n",
      " #current  phase  angle\n",
      "phii  =  phiv  +  phid\n",
      "phiid  =  phii*180/math.pi#  in  degrees\n",
      " #Voltage,  V\n",
      "V  =  Vrms*math.cos(phiv)  +  1j*Vrms*math.sin(phiv)\n",
      " #current,  I\n",
      "I  =  Irms*math.cos(phii)  +  1j*Irms*math.sin(phii)\n",
      " #Impedance,  Z\n",
      "Z  =  V/I\n",
      " #resistance,  R\n",
      "R  =  Z.real\n",
      " #capacitive  reactance,  Xc\n",
      "Xc  =  abs(Z.imag)\n",
      " #capacitance,  C\n",
      "C  =  1/  (w*Xc)\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n  (a)the  current  flowing  and  Circuit  phase  angle  is  \",round(Irms,2),\"/_\",round(phiid,2),\"deg  A\\n\"\n",
      "print  \"\\n  (b)  the  resistance  is  \",round(R,2),\"  ohm\\n\"\n",
      "print  \"\\n  (c)  the  capacitance  is  \",round(C*1E6,2),\"uF\\n\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "  (a)the  current  flowing  and  Circuit  phase  angle  is   20.01 /_ 50.0 deg  A\n",
        "\n",
        "\n",
        "  (b)  the  resistance  is   4.33   ohm\n",
        "\n",
        "\n",
        "  (c)  the  capacitance  is   40.02 uF"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 4, page no. 468</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "#initializing  the  variables:\n",
      "rv  =  100;#  in  volts\n",
      "thetav  =  0;#  in  degrees\n",
      "R  =  5;#  in  ohm\n",
      "R1  =  3;#  in  ohms\n",
      "RL  =  4j;#  in  ohm\n",
      "Rc  =  -10j;#  in  ohms\n",
      "\n",
      "#calculation:\n",
      " #impedance,  Z1\n",
      "Z1  =  R1  +  RL\n",
      " #impedance,  Zc\n",
      "Zc  =  Rc\n",
      " #Circuit  impedance,  Z\n",
      "Z  =  R  +  (Z1*Zc/(Z1  +  Zc))\n",
      " #voltage\n",
      "V  =  rv*math.cos(thetav*math.pi/180)  + 1j*rv*math.sin(thetav*math.pi/180)\n",
      "I  =  V/Z\n",
      "Imag  =  ((I.real)**2  +  (I.imag)**2)**0.5\n",
      " #Active  power  developed  between  points  A  and  B\n",
      "Pab  =  (Imag**2)*R\n",
      " #Active  power  developed  between  points  C  and  D\n",
      "Pcd  =  (Imag**2)*Zc.real\n",
      " #Current,  I1\n",
      "I1  =  I*Zc/(Zc  +  Z1)\n",
      "I1mag  =  ((I1.real)**2  +  (I1.imag)**2)**0.5\n",
      " #active  power  developed  between  points  E  and  F\n",
      "Pef  =  (I1mag**2)*Z1.real\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n  (a)Active  power  developed  between  points  A  and  B  is  \",round(Pab,2),\"  W\\n\"\n",
      "print  \"\\n  (b)Active  power  developed  between  points  C  and  D  is  \",round(Pcd,2),\"  W\\n\"\n",
      "print  \"\\n  (c)Active  power  developed  between  points  E  and  F  is  \",round(Pef,2),\"  W\\n\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "  (a)Active  power  developed  between  points  A  and  B  is   339.62   W\n",
        "\n",
        "\n",
        "  (b)Active  power  developed  between  points  C  and  D  is   0.0   W\n",
        "\n",
        "\n",
        "  (c)Active  power  developed  between  points  E  and  F  is   452.83   W"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 5, page no. 469</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "Pa  =  400;#  in  Watts\n",
      "rv  =  100;#  in  volts\n",
      "thetav  =  30;#  in  degrees\n",
      "R  =  4;#  in  ohm\n",
      "pf  =  0.766;#  power  factor\n",
      "\n",
      " #calculation:\n",
      "V  =  rv*math.cos(thetav*math.pi/180)  +  1j*rv*math.sin(thetav*math.pi/180)\n",
      " #magnitude  of  apparent  power,S  =  V*I\n",
      "S  =  Pa/pf\n",
      "phi  =  math.acos(pf)\n",
      "theta  =  phi*180/math.pi#  in  degrees\n",
      " #Reactive  power  Q\n",
      "Q  =  S*math.sin(phi)\n",
      " #magnitude  of  current\n",
      "Imag  =  S/rv\n",
      "thetai  =  thetav  -  theta\n",
      "I  =  Imag*math.cos(thetai*math.pi/180)  +  1j*Imag*math.sin(thetai*math.pi/180)\n",
      " #Total  circuit  impedance  ZT\n",
      "ZT  =  V/I\n",
      " #impedance  Z\n",
      "Z  =  ZT  -  R\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n  (a)apparent  power  is  \",round(S,2),\"  VA\\n\"\n",
      "print  \"\\n  (b)reactive  power  is  \",round(Q,1),\"  var lagging\\n\"\n",
      "print  \"\\n  (c)the  current  flowing  and  Circuit  phase  angle  is  \",round(Imag,2),\"/_\",round(thetai,2),\"deg  A\\n\"\n",
      "print  \"\\n  (d)impedance,  Z  is  \",round(Z.real,2),\"  +  (\",round(  Z.imag,2),\")i  ohm\\n\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "  (a)apparent  power  is   522.19   VA\n",
        "\n",
        "\n",
        "  (b)reactive  power  is   335.7   var lagging\n",
        "\n",
        "\n",
        "  (c)the  current  flowing  and  Circuit  phase  angle  is   5.22 /_ -10.0 deg  A\n",
        "\n",
        "\n",
        "  (d)impedance,  Z  is   10.67   +  ( 12.31 )i  ohm\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 6, page no. 471</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "S  =  300000;#  in  VA\n",
      "pf1  =  0.70;#  in  power  factor\n",
      "pf2  =  0.90;#  in  power  factor\n",
      "\n",
      "#calculation:\n",
      " #active  power,  P\n",
      "Pa  =  S*pf1\n",
      "phi1  =  math.acos(pf1)\n",
      "phi1d  =  phi1*180/math.pi\n",
      " #Reactive  power,  Q\n",
      "Q  =  S*math.sin(phi1)\n",
      "phi2  =  math.acos(pf2)\n",
      "phi2d  =  phi2*180/math.pi\n",
      " #The  capacitor  rating  needed  to  improve  the  power  factor  to  0.90\n",
      " #the  capacitor  rating,\n",
      "Pr  =  Q  -  (Pa*math.tan(phi2))\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n  the  rating  (in  kilovars)  of  the  capacitors  is  \",round((Pr/1E3),2),\"  kvar leading\\n\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "  the  rating  (in  kilovars)  of  the  capacitors  is   112.54   kvar leading"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 7, page no. 471</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "Z  =  3  +  4j;#  in  ohms\n",
      "rv  =  50;#  in  volts\n",
      "thetav  =  30;#  in  Degrees\n",
      "f  =  1500;#  in  Hz\n",
      "pf1  =  0.966;#  in  power  factor\n",
      "\n",
      "#calculation:\n",
      "V  =  rv*math.cos(thetav*math.pi/180)  + 1j*rv*math.sin(thetav*math.pi/180)\n",
      " #Supply  current,  I\n",
      "I  =  V/Z\n",
      "Istr  =  I.real  -  1j*I.imag\n",
      " #Apparent  power,  S\n",
      "S  =  V*Istr\n",
      " #active  power,  Pa\n",
      "Pa  =  S.real\n",
      "#reactive  power,  Q\n",
      "Q  =  abs(S.imag)\n",
      " #apparent  power,  S\n",
      "S  =  (S.real**2  +  S.imag**2)**0.5\n",
      "phi1  =  math.acos(pf1)\n",
      "phi1d  =  phi1*180/math.pi\n",
      " #rating  of  the  capacitor  \n",
      "Pr  =  Q  -  Pa*math.tan(phi1)\n",
      " #Current  in  capacitor,  Ic\n",
      "Ic  =  Pr/rv\n",
      " #Capacitive  reactance,  Xc\n",
      "Xc  =  rv/Ic\n",
      "C  =  1/(2*math.pi*f*Xc)\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n  (a)supply  current,  I  is  \",round(I.real,2),\"  +  (\",round(  I.imag,2),\")i  A\\n\"\n",
      "print  \"\\n  (b)active  power  is  \",round(Pa,2),\"  W,  apparent  power  is  \",round(  S,2),\"  W  \"\n",
      "print   \"and  reactive  power  is  \",round(  Q,2),\"  W lagging\\n\"\n",
      "print  \"\\n  (c)the  rating  of  the  capacitors  is  \",round(Pr,2),\"  var leading\\n\"\n",
      "print  \"\\n  (d)value  of  capacitance  needed  to  improve  the  power  factor  to  0.966  lagging  is  \",round(  C*1E6,2),\"uF\\n\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "  (a)supply  current,  I  is   9.2   +  ( -3.93 )i  A\n",
        "\n",
        "\n",
        "  (b)active  power  is   300.0   W,  apparent  power  is   500.0   W  and  reactive  power  is   400.0   W lagging\n",
        "\n",
        "\n",
        "  (c)the  rating  of  the  capacitors  is   319.71   var leading\n",
        "\n",
        "\n",
        "  (d)value  of  capacitance  needed  to  improve  the  power  factor  to  0.966  lagging  is   13.57 uF"
       ]
      }
     ],
     "prompt_number": 3
    }
   ],
   "metadata": {}
  }
 ]
}