{
 "metadata": {
  "name": "",
  "signature": "sha256:fe5e092c877ff6677e6a5e3ccdd3dedece58eaf02a85044a49674acc32664be2"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h1>Chapter 36: Complex Waveforms</h1>"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 1, page no. 643</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "V = 240; # in Volts\n",
      "f = 50; # in Hz\n",
      "x = 0.2;\n",
      "phi3 = 3*math.pi/4; # in Rad\n",
      "\n",
      " #calculation:\n",
      "Vamp = V*2**0.5\n",
      "w = 2*math.pi*f\n",
      "T = 1/f\n",
      "V3 = Vamp*x\n",
      "f3 = 3*f\n",
      "w3 = 3*w\n",
      "\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n  voltage, V =\",round(Vamp,1),\"sin(\",round(w,1),\"t) + \",round(V3,1),\"sin(\", round(w3,1),\"t - \", round(phi3,1),\") volts\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "  voltage, V = 339.4 sin( 314.2 t) +  67.9 sin( 942.5 t -  2.4 ) volts"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 3, page no. 648</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "A1  =  0.100;#  in  amperes\n",
      "A3  =  0.020;#  in  amperes\n",
      "A5  =  0.010;#  in  amperes\n",
      "\n",
      " #calculation:\n",
      " #the  rms  value  of  current  is  given  by\n",
      "Irms  =  ((A1**2  +  A3**2  +  A5**2)/2)**0.5\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n  the  rms  value  of  current  is  \",round(Irms*1000,2),\" mA\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "  the  rms  value  of  current  is   72.46  mA"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 4, page no. 649</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "A1  =  10;#  in  volts\n",
      "A3  =  3;#  in  volts\n",
      "A5  =  2;#  in  volts\n",
      "\n",
      "#calculation:\n",
      " #the  rms  value  of  voltage  is  given  by\n",
      "Vrms  =  ((A1**2  +  A3**2  +  A5**2)/2)**0.5\n",
      " #the  mean  value  of  voltage  is  given  by\n",
      " #x  =  wt\n",
      "Vav  =  (1/math.pi)*((10 + 1 + 2/5)-(-10 - 1 - 2/5))\n",
      " #form  factor  is  given  by\n",
      "ff  =  Vrms/Vav\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n  (a)the  rms  value  of  voltage  is  \",round(Vrms,2),\"  V\"\n",
      "print  \"\\n  (b)the  mean  value  of  voltage  is  \",round(Vav,2),\"  V\"\n",
      "print  \"\\n  (c)form  factor  is  \",round(ff,3),\"  \""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "  (a)the  rms  value  of  voltage  is   7.52   V\n",
        "\n",
        "  (b)the  mean  value  of  voltage  is   7.26   V\n",
        "\n",
        "  (c)form  factor  is   1.036   "
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 5, page no. 649</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "V  =  240;#  in  volts\n",
      "x  =  0.3;#  for  third  harmonic\n",
      "y  =  0.1;#  for  fifth  harmonic\n",
      "f  =  31.83;#  in  Hz\n",
      "\n",
      " #calculation:\n",
      " #V3  =  x*V1\n",
      " #V5  =  y*V1\n",
      " #the  rms  value  of  the  fundamental,\n",
      "V1  =  ((V**2)/(1  +  x**2  +  y**2))**0.5\n",
      " #Rms  value  of  the  third  harmonic\n",
      "V3  =  x*V1\n",
      " #the  rms  value  of  the  fifth  harmonic,\n",
      "V5  =  y*V1\n",
      " #Maximum  value  of  the  fundamental,\n",
      "V1m  =  V1*2**0.5\n",
      " #Maximum  value  of  the  third  harmonic,\n",
      "V3m  =  V3*2**0.5\n",
      " #Maximum  value  of  the  fifth  harmonic,\n",
      "V5m  =  V5*2**0.5\n",
      "w  =  2*math.pi*f\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"v  =  \",round(V1m,2),\"sin\",round(w,2),\"t  +  \",round(V3m,2),\"sin\",round((3*w),2),\"t  +  \",round(V5m,2),\"sin\",round((5*w),2),\"t  Volts\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "v  =   323.62 sin 199.99 t  +   97.08 sin 599.98 t  +   32.36 sin 999.97 t  Volts\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 6, page no. 652</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "A1  =  12;#  in  amperes\n",
      "A3  =  5;#  in  amperes\n",
      "A5  =  2;#  in  amperes\n",
      "R  =  20;#  in  ohms\n",
      "\n",
      "#calculation:\n",
      " #rms  current\n",
      "Irms  =  ((A1**2  +  A3**2  +  A5**2)/2)**0.5\n",
      " #average  power\n",
      "P  =  R*Irms**2\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n  average  power  \",P,\"  W\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "  average  power   1730.0   W"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 7, page no. 652</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "Ia1  =  2;#  in  amperes\n",
      "Ia3  =  0.3;#  in  amperes\n",
      "Ia5  =  0.1;#  in  amperes\n",
      "Va1  =  60;#  in  volts\n",
      "Va3  =  15;#  in  volts\n",
      "Va5  =  10;#  in  volts\n",
      "Phii1  =  -1*math.pi/6;#  in  radians\n",
      "Phii3  =  -1*math.pi/12;#  in  radians\n",
      "Phii5  =  -8*math.pi/9;#  in  radians\n",
      "Phiv1  =  0;#  in  radians\n",
      "Phiv3  =  math.pi/4;#  in  radians\n",
      "Phiv5  =  -1*math.pi/2;#  in  radians\n",
      "\n",
      "\n",
      " #calculation:\n",
      " #rms  values;\n",
      "I1  =  Ia1/(2**0.5);#  in  amperes\n",
      "I3  =  Ia3/(2**0.5);#  in  amperes\n",
      "I5  =  Ia5/(2**0.5);#  in  amperes\n",
      "V1  =  Va1/(2**0.5);#  in  volts\n",
      "V3  =  Va3/(2**0.5);#  in  volts\n",
      "V5  =  Va5/(2**0.5);#  in  volts\n",
      " #total  power  supplied,\n",
      "P  =  V1*I1*math.cos(Phiv1  -  Phii1)  +  V3*I3*math.cos(Phiv3  -  Phii3)  +  V5*I5*math.cos(Phiv5  -  Phii5)\n",
      " #rms  current\n",
      "Irms  =  ((I1**2  +  I3**2  +  I5**2))**0.5\n",
      " #rms  voltage\n",
      "Vrms  =  ((V1**2  +  V3**2  +  V5**2))**0.5\n",
      " #overall  power  factor\n",
      "pf  =  P/(Vrms*Irms)\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n(a)the  total  active  power  supplied  to  the  circuit  \",round(P,2),\"  W\"\n",
      "print  \"\\n(b)overall  power  factor  \",round(pf,2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "(a)the  total  active  power  supplied  to  the  circuit   53.26   W\n",
        "\n",
        "(b)overall  power  factor   0.84"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 8, page no. 655</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "R1  =  40;#  in  ohm\n",
      "L  =  7.96E-3;#  in  Henry\n",
      "C = 25E-6; # in Farad\n",
      "f = 1000; # in Hx\n",
      "\n",
      "#calculation:\n",
      "wL = 2*math.pi*1000*L\n",
      "wC = 2*math.pi*1000*C\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"(a)i  =  \",round(100/R1,2),\"sin(wt)  +\",round(30/R1,2),\"sin(3wt - pi/3)  +\",round(10/R1,2),\"sin(5wt - pi/6) A\"\n",
      "print  \"(b)i  =  \",round(100/wL,2),\"sin(wt - pi/2)  +\",round(30/(3*wL),2),\"sin(3wt - pi/6)  +\",round(10/(5*wL),2),\"sin(5wt - 2pi/3) A\"\n",
      "print  \"(c)i  =  \",round(100*wC,2),\"sin(wt + pi/2)  +\",round(30*3*wC,2),\"sin(3wt + 5pi/6)  +\",round(10*5*wC,2),\"sin(5wt + pi/3) A\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "(a)i  =   2.5 sin(wt)  + 0.75 sin(3wt - pi/3)  + 0.25 sin(5wt - pi/6) A\n",
        "(b)i  =   2.0 sin(wt - pi/2)  + 0.2 sin(3wt - pi/6)  + 0.04 sin(5wt - 2pi/3) A\n",
        "(c)i  =   15.71 sin(wt + pi/2)  + 14.14 sin(3wt + 5pi/6)  + 7.85 sin(5wt + pi/3) A\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 9, page no. 656</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "V1m  =  240;#  in  volts\n",
      "V3m  =  40;#  in  volts\n",
      "V5m  =  30;#  in  volts\n",
      "w1  =  314;#  fundamental\n",
      "R  =  12;#  in  ohm\n",
      "L  =  0.00955;#  in  Henry\n",
      "\n",
      " #calculation:\n",
      " #fundamental  or  first  harmonic\n",
      " #inductive  reactance,\n",
      "XL1  =  w1*L\n",
      " #impedance  at  the  fundamental  frequency,\n",
      "Z1  =  R  +  1j*XL1\n",
      " #Maximum  current  at  fundamental  frequency\n",
      "I1m  =  V1m/Z1\n",
      "I1mag  =  abs(I1m)\n",
      "phii1  =  cmath.phase(complex(I1m.real,I1m.imag))\n",
      " #Third  harmonic\n",
      "XL3  =  3*XL1\n",
      " #impedance  at  the  third  harmonic  frequency,\n",
      "Z3  =  R  +  1j*XL3\n",
      " #Maximum  current  at  third  harmonic  frequency\n",
      "I3m  =  V3m/Z3\n",
      "I3mag  =  abs(I3m)\n",
      "phii3  =  cmath.phase(complex(I3m.real,I3m.imag))\n",
      " #fifth  harmonic\n",
      "XL5  =  5*XL1\n",
      " #impedance  at  the  third  harmonic  frequency,\n",
      "Z5  =  R  +  1j*XL5\n",
      " #Maximum  current  at  third  harmonic  frequency\n",
      "I5m  =  V5m/Z5\n",
      "I5mag  =  abs(I5m)\n",
      "phii5  =  cmath.phase(complex(I5m.real,I5m.imag))\n",
      " #rms  voltage\n",
      "Vrms  =  ((V1m**2  +  V3m**2  +  V5m**2)/2)**0.5\n",
      " #rms  current\n",
      "Irms  =  ((I1mag**2  +  I3mag**2  +  I5mag**2)/2)**0.5\n",
      " #power  dissipated\n",
      "P  =  R*Irms**2\n",
      " #overall  power  factor\n",
      "pf  =  P/(Vrms*Irms)\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n(a)i  =  \",round(I1mag,2),\"sin(\",round(w1,2),\"t  +  (\",round(phii1,2),\"))  +  \",round(I3mag,2),\"sin(\",round((w1*3),2),\"t  +  (\",round(phii3,2),\"))  +  \",round(I5mag,2),\"sin(\",round((w1*5),2),\"t  +  (\",round(phii5,2),\"))  A\"\n",
      "print  \"\\n(b)the  rms  value  of  current  is  \",round(Irms,2),\"  A\"\n",
      "print  \"\\n(c)the  rms  value  of  voltage  is  \",round(Vrms,2),\"  V\"\n",
      "print  \"\\n(d)the  total  power  dissipated  \",round(P,2),\"  W\"\n",
      "print  \"\\n(e)overall  power  factor  \",round(pf,2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "(a)i  =   19.4 sin( 314.0 t  +  ( -0.24 ))  +   2.67 sin( 942.0 t  +  ( -0.64 ))  +   1.56 sin( 1570.0 t  +  ( -0.9 ))  A\n",
        "\n",
        "(b)the  rms  value  of  current  is   13.89   A\n",
        "\n",
        "(c)the  rms  value  of  voltage  is   173.35   V\n",
        "\n",
        "(d)the  total  power  dissipated   2316.26   W\n",
        "\n",
        "(e)overall  power  factor   0.96"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 10, page no. 658</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "Vom  =  50;#  in  volts\n",
      "V1m  =  200;#  in  volts\n",
      "V2m  =  40;#  in  volts\n",
      "V4m  =  5;#  in  volts\n",
      "f  =  50;#  in  Hz\n",
      "R  =  50;#  in  ohm\n",
      "C  =  100E-6;#  in  farad\n",
      "phiv1  =  0;#  in  rad\n",
      "phiv2  =  -1*math.pi/2;#  in  rad\n",
      "phiv4  =  math.pi/4;#  in  rad\n",
      "\n",
      " #calculation:\n",
      " #voltage\n",
      "V1  =  V1m*math.cos(phiv1)  +  1j*V1m*math.sin(phiv1)\n",
      "V2  =  V2m*math.cos(phiv2)  +  1j*V2m*math.sin(phiv2)\n",
      "V4  =  V4m*math.cos(phiv4)  +  1j*V4m*math.sin(phiv4)\n",
      " #Inductance  has  no  effect  on  a  steady  current.  Hence  the  d.c.  component  of  the  current,  i0,  is  given  by\n",
      "Iom  =  0\n",
      " #fundamental  or  first  harmonic\n",
      "w1  =  2*math.pi*f\n",
      " #inductive  reactance,\n",
      "Xc1  =  1/(w1*C)\n",
      " #impedance  at  the  fundamental  frequency,\n",
      "Z1  =  R  +  1j*Xc1\n",
      " #Maximum  current  at  fundamental  frequency\n",
      "I1m  =  V1/Z1\n",
      "I1mag  =  abs(I1m)\n",
      "phii1  =  cmath.phase(complex(I1m.real,I1m.imag))\n",
      " #second  harmonic\n",
      "Xc2  =  Xc1/2\n",
      " #impedance  at  the  third  harmonic  frequency,\n",
      "Z2  =  R  +  1j*Xc2\n",
      " #Maximum  current  at  third  harmonic  frequency\n",
      "I2m  =  V2/Z2\n",
      "I2mag  =  abs(I2m)\n",
      "phii2  =  cmath.phase(complex(I2m.real,I2m.imag))\n",
      " #fourth  harmonic\n",
      "Xc4  =  Xc1/4\n",
      " #impedance  at  the  third  harmonic  frequency,\n",
      "Z4  =  R  +  1j*Xc4\n",
      " #Maximum  current  at  third  harmonic  frequency\n",
      "I4m  =  V4/Z4\n",
      "I4mag  =  abs(I4m)\n",
      "phii4  =  cmath.phase(complex(I4m.real,I4m.imag))\n",
      " #rms  current\n",
      "Irms  =  (Iom**2  +  (I1mag**2  +  I2mag**2  +  I4mag**2)/2)**0.5\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"(a)i = \",round(Iom,2),\" + \",round(I1mag,2),\"sin(\",round(w1,2),\"t  +  (\",round(phii1,2),\"))  +  \",round(I2mag,2),\"sin(\",round((w1*2),2),\"t  +  (\",round(phii2,2),\"))  +  \",round(I4mag,2),\"sin(\",round((w1*4),2),\"t  +  (\",round(phii4,2),\"))  A\"\n",
      "print  \"(b)the  rms  value  of  current  is  \",round(Irms,2),\"  A\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "(a)i =  0.0  +  3.37 sin( 314.16 t  +  ( -0.57 ))  +   0.76 sin( 628.32 t  +  ( -1.88 ))  +   0.1 sin( 1256.64 t  +  ( 0.63 ))  A\n",
        "(b)the  rms  value  of  current  is   2.45   A\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 11, page no. 659</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "Vom  =  25;#  in  volts\n",
      "V1m  =  100;#  in  volts\n",
      "V3m  =  40;#  in  volts\n",
      "V5m  =  20;#  in  volts\n",
      "w1  =  10000;#  fundamental\n",
      "R  =  5;#  in  ohm\n",
      "L  =  500E-6;#  in  Henry\n",
      "phiv1  =  0;#  in  rad\n",
      "phiv3  =  math.pi/6;#  in  rad\n",
      "phiv5  =  math.pi/12;#  in  rad\n",
      "\n",
      " #calculation:\n",
      " #voltage\n",
      "V1  =  V1m*math.cos(phiv1)  +  1j*V1m*math.sin(phiv1)\n",
      "V3  =  V3m*math.cos(phiv3)  +  1j*V3m*math.sin(phiv3)\n",
      "V5  =  V5m*math.cos(phiv5)  +  1j*V5m*math.sin(phiv5)\n",
      " #Inductance  has  no  effect  on  a  steady  current.  Hence  the  d.c.  component  of  the  current,  i0,  is  given  by\n",
      "Iom  =  Vom/R\n",
      " #fundamental  or  first  harmonic\n",
      " #inductive  reactance,\n",
      "XL1  =  w1*L\n",
      " #impedance  at  the  fundamental  frequency,\n",
      "Z1  =  R  +  1j*XL1\n",
      " #Maximum  current  at  fundamental  frequency\n",
      "I1m  =  V1/Z1\n",
      "I1mag  =  abs(I1m)\n",
      "phii1  =  cmath.phase(complex(I1m.real,I1m.imag))\n",
      "#Third  harmonic\n",
      "XL3  =  3*XL1\n",
      " #impedance  at  the  third  harmonic  frequency,\n",
      "Z3  =  R  +  1j*XL3\n",
      " #Maximum  current  at  third  harmonic  frequency\n",
      "I3m  =  V3/Z3\n",
      "I3mag  =  abs(I3m)\n",
      "phii3  =  cmath.phase(complex(I3m.real,I3m.imag))\n",
      " #fifth  harmonic\n",
      "XL5  =  5*XL1\n",
      " #impedance  at  the  third  harmonic  frequency,\n",
      "Z5  =  R  +  1j*XL5\n",
      " #Maximum  current  at  third  harmonic  frequency\n",
      "I5m  =  V5/Z5\n",
      "I5mag  =  abs(I5m)\n",
      "phii5  =  cmath.phase(complex(I5m.real,I5m.imag))\n",
      " #rms  current\n",
      "Irms  =  (Iom**2  +  (I1mag**2  +  I3mag**2  +  I5mag**2)/2)**0.5\n",
      " #power  dissipated\n",
      "P  =  R*Irms**2\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n(a)i  =  \",round(Iom,2),\"  +  \",round(I1mag,2),\"sin(\",round(w1,2),\"t  +  (\",round(phii1,2),\"))  +  \",round(I3mag,2),\"sin(\",round((w1*3),2),\"t  +  (\",round(phii3,2),\"))  +  \",round(I5mag,2),\"sin(\",round((w1*5),2),\"t  +  (\",round(phii5,2),\"))  A\"\n",
      "print  \"\\n(b)the  rms  value  of  current  is  \",round(Irms,2),\"  A\"\n",
      "print  \"\\n(c)the  total  power  dissipated  \",round(P,3),\"  W\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "(a)i  =   5.0   +   14.14 sin( 10000.0 t  +  ( -0.79 ))  +   2.53 sin( 30000.0 t  +  ( -0.73 ))  +   0.78 sin( 50000.0 t  +  ( -1.11 ))  A\n",
        "\n",
        "(b)the  rms  value  of  current  is   11.34   A\n",
        "\n",
        "(c)the  total  power  dissipated   642.538   W\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 12, page no. 661</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "Vom  =  30;#  in  volts\n",
      "V1m  =  40;#  in  volts\n",
      "V2m  =  25;#  in  volts\n",
      "V4m  =  15;#  in  volts\n",
      "Iom  =  0;#  in  amperes\n",
      "I1m  =  0.743;#  in  Amperes\n",
      "I2m  =  0.781;#  in  Amperes\n",
      "I4m  =  0.636;#  in  Amperes\n",
      "phii1  =  1.190;#  in  rad\n",
      "phii2  =  0.896;#  in  rad\n",
      "phii4  =  0.559;#  in  rad\n",
      "w  =  1000;#  in  rad\n",
      "\n",
      " #calculation:\n",
      " #the  average  power  P  is  given  by\n",
      "P  =  Vom*Iom+(0.707*V1m)*(0.707*I1m)*math.cos(phii1)+(0.707*V2m)*(0.707*I2m)*math.cos(phii2) + (0.707*V4m)*(0.707*I4m)*math.cos(phii4)\n",
      " #rms  current\n",
      "Irms  =  (Iom**2  +  (I1m**2  +  I2m**2  +  I4m**2)/2)**0.5\n",
      " #resistance  R\n",
      "R  =  P/(Irms**2)\n",
      " #impedance\n",
      "Z1  =  V1m/I1m\n",
      " #Xc1\n",
      "Xc1  =  (Z1**2  -  R**2)**0.5\n",
      " #capacitance\n",
      "C  =  1/(w*Xc1)\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n(a)the  average  power  P  is  \",round(P,2),\"  W\"\n",
      "print  \"\\n(c)the  resistance  R  \",round(R,2),\"  ohm  and  capacitance  \",round(C*1E6,2),\"uF\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "(a)the  average  power  P  is   15.66   W\n",
        "\n",
        "(c)the  resistance  R   19.99   ohm  and  capacitance   20.01 uF\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 13, page no. 662</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "V1m  =  300;#  in  volts\n",
      "V3m  =  120;#  in  volts\n",
      "phiv1  =  0;#  in  rad\n",
      "phiv2  =  0.698;#  in  rad\n",
      "w1  =  314;#  in  rad\n",
      "C  =  2.123E-6;#  in  farads\n",
      "R1  =  560;#  in  ohms\n",
      "R2  =  2000;#  in  Ohm\n",
      "\n",
      "#calculation:\n",
      " #voltage\n",
      "V1  =  V1m*math.cos(phiv1)  +  1j*V1m*math.sin(phiv1)\n",
      "V3  =  V3m*math.cos(phiv2)  +  1j*V3m*math.sin(phiv2)\n",
      " #capacitive  reactance,\n",
      "Xc1  =  1/(w1*C)\n",
      " #impedance  at  the  fundamental  frequency,\n",
      "Z1  =  R1  -  1j*Xc1*R2/(R2  -  1j*Xc1)\n",
      " #Maximum  current  at  fundamental  frequency\n",
      "I1m  =  V1/Z1\n",
      "I1mag  =  abs(I1m)\n",
      "phii1  =  cmath.phase(complex(I1m.real,I1m.imag))\n",
      " #Third  harmonic\n",
      "Xc3  =  Xc1/3\n",
      " #impedance  at  the  third  harmonic  frequency,\n",
      "Z3  =  R1  -  1j*Xc3*R2/(R2  -  1j*Xc3)\n",
      "I1m = V1m/Z1\n",
      "I1mag  =  abs(I1m)\n",
      "phii1  =  cmath.phase(complex(I1m.real,I1m.imag))\n",
      " #Maximum  current  at  third  harmonic  frequency\n",
      "I3m  =  V3/Z3\n",
      "I3mag  =  abs(I3m)\n",
      "phii3  =  cmath.phase(complex(I3m.real,I3m.imag))\n",
      " #Percentage  harmonic  content  of  the  supply  current  is  given  by\n",
      "percent  =  I3mag*100/I1mag\n",
      " #total  active  power\n",
      "P  =  (0.707*V1m)*(0.707*I1mag)*math.cos(phiv1  -  phii1)  +  (0.707*V3m)*(0.707*I3m)*math.cos(phiv2  -  phii3)\n",
      "\n",
      "I1 = I1m*R2/(R2 - 1j*Xc1)\n",
      "I3 = I3m*R2/(R2 - 1j*Xc3)\n",
      "\n",
      "I1nmag  =  abs(I1)\n",
      "phini1  =  cmath.phase(complex(I1.real,I1.imag))\n",
      "I3nmag  =  abs(I3)\n",
      "phini3  =  cmath.phase(complex(I3.real,I3.imag))\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n(a)supply current, i=\", round(I1mag,3),\"sin(\", w1,\"t +\",round(phii1,3),\") + \",round(I3mag,3),\"sin(\", 3*w1,\"t +\",round(phii3,3),\") A\"\n",
      "print  \"\\n(b)Percentage  harmonic  content  of  the  supply  current  is  \",round(percent,2),\"  percent\"\n",
      "print  \"\\n(c)total  active  power  is  \",round(abs(P),2),\"  W\"\n",
      "print  \"\\n(d)Voltage, v1 =\", round(I1mag*R1,3),\"sin(\", w1,\"t +\",round(phii1,3),\") + \",round(I3mag*R1,3),\"sin(\", 3*w1,\"t +\",round(phii3,3),\") A\"\n",
      "print  \"\\n(e)current, ic =\", round(I1nmag,3),\"sin(\", w1,\"t +\",round(phini1,3),\") + \",round(I3nmag,3),\"sin(\", 3*w1,\"t +\",round(phini3,3),\") A\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "(a)supply current, i= 0.187 sin( 314 t + 0.643 ) +  0.145 sin( 942 t + 1.305 ) A\n",
        "\n",
        "(b)Percentage  harmonic  content  of  the  supply  current  is   77.57   percent\n",
        "\n",
        "(c)total  active  power  is   25.34   W\n",
        "\n",
        "(d)Voltage, v1 = 104.996 sin( 314 t + 0.643 ) +  81.45 sin( 942 t + 1.305 ) A\n",
        "\n",
        "(e)current, ic = 0.15 sin( 314 t + 1.287 ) +  0.141 sin( 942 t + 1.55 ) A"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 14, page no. 664</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "V1m  =  400;#  in  volts\n",
      "V3m  =  10;#  in  volts\n",
      "C  =  0.2E-6;#  in  farads\n",
      "R  =  2;#  in  ohms\n",
      "L  =  0.5;#  in  Henry\n",
      "\n",
      " #calculation:\n",
      " #Resonance  with  the  third  harmonic  means  that\n",
      "w  =  (1/(9*L*C))**0.5\n",
      " #fundamental  frequency,  f\n",
      "f  =  w/(2*math.pi)\n",
      " #At  the  fundamental  frequency,\n",
      " #impedance  Z1\n",
      "Z1  =  R  +  1j*(w*L  -  1/(w*C))\n",
      "Z1mag  =  abs(Z1)\n",
      "phiZ1  =  cmath.phase(complex(Z1.real,Z1.imag))\n",
      " #Maximum  value  of  current  at  the  fundamental  frequency,\n",
      "I1m  =  V1m/Z1mag\n",
      " #At  the  third  harmonic  frequency,\n",
      "Z3  =  R  +  1j*(3*w*L  -  1/(3*w*C))\n",
      "Z3mag  =  abs(Z3)\n",
      "phiZ3  =  cmath.phase(complex(Z3.real,Z3.imag))\n",
      " #Maximum  value  of  current  at  the  third  harmonic  frequency,\n",
      "I3m  =  V3m/Z3\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"(a)fundamental  frequency  for  resonance  with  the  third  harmonic  is  \",round(f,2),\"  Hz\"\n",
      "print  \"(b)Maximum value of current at fundamental freq. is\",round(abs(I1m),3),\"A \"\n",
      "print   \"and  at  the  third  harmonic  frequency  \",  abs(I3m),\"  A\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "(a)fundamental  frequency  for  resonance  with  the  third  harmonic  is   167.76   Hz\n",
        "(b)Maximum value of current at fundamental freq. is 0.095 A \n",
        "and  at  the  third  harmonic  frequency   5.0   A\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 15, page no. 665</h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from __future__ import division\n",
      "import math\n",
      "import cmath\n",
      "#initializing  the  variables:\n",
      "V1m  =  800;#  in  volts\n",
      "f  =  50;#  in  Hz\n",
      "x  =  0.015;\n",
      "C  =  0.122E-6;#  in  farads\n",
      "R  =  5;#  in  ohms\n",
      "L  =  0.369;#  in  Henry\n",
      "\n",
      " #calculation:\n",
      " #voltage  at  nth  harmonic\n",
      "Vnm  =  x*V1m\n",
      "w  =  2*math.pi*f\n",
      " #For  resonance  at  the  nth  harmonic  nwL  =  1/nwC\n",
      "n  =  1/(w*(L*C)**0.5)\n",
      " #At  resonance,  impedance\n",
      "Zn  =  R\n",
      " #the  maximum  value  of  current  at  the  nth  harmonic\n",
      "Inm  =  Vnm/Zn\n",
      " #capacitive  reactance,  at  nth  harmonic\n",
      "Xcn  =  1/(n*w*C)\n",
      " #the  p.d.  across  the  capacitor  at  the  nth  harmonic\n",
      "Vcn  =  Inm*Xcn\n",
      " #At  the  fundamental  frequency,  inductive  reactance,\n",
      "XL1  =  w*L\n",
      " #capacitive  reactance\n",
      "Xc1  =  1/(w*C)\n",
      " #Impedance  at  the  fundamental  frequency,\n",
      "Z1  =  R  +  1j*(XL1  -  Xc1)\n",
      "Z1mag  =  abs(Z1)\n",
      "phiZ1  =  cmath.phase(complex(Z1.real,Z1.imag))\n",
      " #Maximum  value  of  current  at  the  fundamental  frequency,\n",
      "I1m  =  V1m/Z1mag\n",
      "\n",
      "\n",
      "#Results\n",
      "print  \"\\n\\n  Result  \\n\\n\"\n",
      "print  \"\\n(a)n  =  \",round(n,2),\"\"\n",
      "print  \"\\n(b)the  maximum  value  of  current  at  the  nth  harmonic  \",round(Inm,2),\"  A\"\n",
      "print  \"\\n(c)the  p.d.  across  the  capacitor  at  the  nth  harmonic  is  \",round(Vcn,2),\"\"\n",
      "print  \"\\n(d)the  maximum  value  of  the  fundamental  current.  \",round(I1m,2),\"  A\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "\n",
        "  Result  \n",
        "\n",
        "\n",
        "\n",
        "(a)n  =   15.0 \n",
        "\n",
        "(b)the  maximum  value  of  current  at  the  nth  harmonic   2.4   A\n",
        "\n",
        "(c)the  p.d.  across  the  capacitor  at  the  nth  harmonic  is   4173.92 \n",
        "\n",
        "(d)the  maximum  value  of  the  fundamental  current.   0.03   A"
       ]
      }
     ],
     "prompt_number": 14
    }
   ],
   "metadata": {}
  }
 ]
}