{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "CHAPTER 1: REVIEW OF ELECTRIC CIRCUITS"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.1, Page number 2-3"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Q = 4.0      #Charge(C) \n",
      "t = 0.54     #Time(sec) \n",
      "\n",
      "#Calculation\n",
      "I = Q/t      #Current(A) \n",
      "\n",
      "#Result\n",
      "print('Value of Current is , I = %.2f A' %I) "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Value of Current is , I = 7.41 A\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.2, Page number 4-5"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "V = -24.0     #Voltage(V)\n",
      "I = 3.0       #Current(A)\n",
      "\n",
      "#Calculation \n",
      "P = V*I       #Power supplied by the element A(W) \n",
      "\n",
      "#Result\n",
      "print('Power supplied by the element A is , P = %.1f W' %P)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Power supplied by the element A is , P = -72.0 W\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.3, Page number 7-9"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "R1 = 5.0   #Resistance(ohm)\n",
      "R2 = 4.0   #Resistance(ohm)\n",
      "R3 = 9.0   #Resistance(ohm)\n",
      "R4 = 6.0   #Resistance(ohm)\n",
      "V1 = 10.0  #Resistance(ohm)\n",
      "V2 = 6.0   #Resistance(ohm)\n",
      "\n",
      "\n",
      "#Calculation\n",
      "R_th = (R1*R4/(R1+R4))+R2    #Thevenin resistance(ohm) by removing R3 & short-circuiting voltage sources\n",
      "I = (V1-V2)/(R1+R4)          #Current(A) by applying KVL\n",
      "V_th = 6*I+V2                #Thevenin voltage(V) by applying KVL\n",
      "I_9ohm = V_th/(R_th+R3)      #Current through 9 ohm resistor(A)\n",
      "\n",
      "#Result\n",
      "print('Current through 9 ohm resistor , I_9\u03a9 = %.2f A' %I_9ohm) "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Current through 9 ohm resistor , I_9\u03a9 = 0.52 A\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.4, Page number 10-11"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from scipy.integrate import quad\n",
      "\n",
      "#Variable declaration\n",
      "V_t1 = 30.0            #Magnitudes of voltages(V)  0 < t1 < 2\n",
      "V_t2 = -10.0           #Magnitudes of voltages(V)  2 < t2 < 4\n",
      "T = 4.0                #Time period(sec) from figure\n",
      "\n",
      "#Calculation\n",
      "def integrand(V):\n",
      "    return V**0\n",
      "\n",
      "a, err = quad(integrand, 0, 2)\n",
      "\n",
      "def integrand(V):\n",
      "    return V**0\n",
      "\n",
      "b, err = quad(integrand, 2, 4)\n",
      "\n",
      "V_rms = ((a*V_t1**2+b*V_t2**2)/4)**0.5   #RMS value of voltage waveform(V)\n",
      "\n",
      "#Result\n",
      "print('RMS value , V_rms = %.2f V' %V_rms)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "RMS value , V_rms = 22.36 V\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.5, Page number 15-16"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import cmath\n",
      "\n",
      "#Variable declaration\n",
      "V_P = 200.0                                 #Magnitude of each phase(V) \n",
      "\n",
      "#Calculation\n",
      "V_an = V_P*cmath.exp(1j*0*math.pi/180)      #Magnitude of 3-phase voltage(V)\n",
      "V_bn = V_P*cmath.exp(1j*-120*math.pi/180)   #Magnitude of 3-phase voltage(V)\n",
      "V_cn = V_P*cmath.exp(1j*120*math.pi/180)    #Magnitude of 3-phase voltage(V)\n",
      "V_L = 3**0.5*V_P                            #Magnitude of line voltage(V)\n",
      "\n",
      "#Result\n",
      "print('Expression of phase voltages are,')\n",
      "print('\\t\\t\\t  V_an = %.f\u2220%.f\u00b0 V' %(abs(V_an),cmath.phase(V_an)))\n",
      "print('\\t\\t\\t  V_bn = %.f\u2220%.f\u00b0 V' %(abs(V_bn),cmath.phase(V_bn)*180/math.pi))\n",
      "print('\\t\\t\\t  V_cn = %.f\u2220%.f\u00b0 V' %(abs(V_cn),cmath.phase(V_cn)*180/math.pi))\n",
      "print('Magnitude of the line voltage , V_L = %.1f V' %V_L) "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Expression of phase voltages are,\n",
        "\t\t\t  V_an = 200\u22200\u00b0 V\n",
        "\t\t\t  V_bn = 200\u2220-120\u00b0 V\n",
        "\t\t\t  V_cn = 200\u2220120\u00b0 V\n",
        "Magnitude of the line voltage , V_L = 346.4 V\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.6, Page number 16-17"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import cmath\n",
      "\n",
      "#Variable declaration\n",
      "R = 10.0        #Resistance of each coil(ohm)\n",
      "X = 15.0        #Inductive reactance of each coil(ohm)\n",
      "V_L = 420.0     #Line voltage(V)\n",
      "f = 50.0        #Frequency of supply(Hz)\n",
      "\n",
      "#Calculation\n",
      "V_an = (V_L/3**0.5)*cmath.exp(1j*(0-30)*math.pi/180)       #Phase voltage(V)\n",
      "V_bn = (V_L/3**0.5)*cmath.exp(1j*(-120-30)*math.pi/180)    #Phase voltage(V)\n",
      "V_cn = (V_L/3**0.5)*cmath.exp(1j*(120-30)*math.pi/180)     #Phase voltage(V)\n",
      "Z_P = complex(R,X)                                         #Phase impedance(ohm)\n",
      "#For case(i)\n",
      "I_L1 = V_an/Z_P         #Line current(A)\n",
      "I_L2 = V_bn/Z_P         #Line current(A)\n",
      "I_L3 = V_cn/Z_P         #Line current(A)\n",
      "#For case(ii)\n",
      "pf = R/abs(Z_P)         #Power factor\n",
      "\n",
      "#Result\n",
      "print('(i) Values of line currents are,')\n",
      "print('\\t I_L1 = I_an = %.2f\u2220%.2f\u00b0 A' %(abs(I_L1),cmath.phase(I_L1)*180/math.pi))\n",
      "print('\\t I_L2 = I_bn = %.2f\u2220%.2f\u00b0 A' %(abs(I_L2),cmath.phase(I_L2)*180/math.pi))\n",
      "print('\\t I_L3 = I_cn = %.2f\u2220%.2f\u00b0 A' %(abs(I_L3),cmath.phase(I_L3)*180/math.pi))\n",
      "print('(ii) Power factor is , pf = %.1f lag' %pf)\n",
      "print('\\nNOTE : I_L2 has an angle -206.31\u00b0 in textbook which is same as 153.69\u00b0 i.e (360-206.31)\u00b0 obtained here')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i) Values of line currents are,\n",
        "\t I_L1 = I_an = 13.45\u2220-86.31\u00b0 A\n",
        "\t I_L2 = I_bn = 13.45\u2220153.69\u00b0 A\n",
        "\t I_L3 = I_cn = 13.45\u222033.69\u00b0 A\n",
        "(ii) Power factor is , pf = 0.6 lag\n",
        "\n",
        "NOTE : I_L2 has an angle -206.31\u00b0 in textbook which is same as 153.69\u00b0 i.e (360-206.31)\u00b0 obtained here\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.7, Page number 19-20"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import cmath\n",
      "\n",
      "#Variable declaration\n",
      "Z_P = complex(10,15)     #Per phase impedance(ohm)\n",
      "V_L = 420.0              #Voltage(V)\n",
      "\n",
      "#Calculation\n",
      "#For case(i)\n",
      "V_ab = V_L*cmath.exp(1j*0*math.pi/180)        #Phase voltage(V)\n",
      "V_bc = V_L*cmath.exp(1j*-120*math.pi/180)     #Phase voltage(V)\n",
      "V_ca = V_L*cmath.exp(1j*120*math.pi/180)      #Phase voltage(V)\n",
      "I_ab = V_ab/Z_P                               #Phase current(A)\n",
      "I_bc = V_bc/Z_P                               #Phase current(A)\n",
      "I_ca = V_ca/Z_P                               #Phase current(A)\n",
      "#For case(ii)\n",
      "I_P = abs(I_ab)                               #Phase current magnitude(A)\n",
      "I_L = 3**0.5*I_P                              #Line current magnitude(A)\n",
      "\n",
      "#Result\n",
      "print('(i) Phase currents are,')\n",
      "print('\\t\\t I_ab = %.2f\u2220%.2f\u00b0 A' %(abs(I_ab),cmath.phase(I_ab)*180/math.pi))\n",
      "print('\\t\\t I_bc = %.2f\u2220%.2f\u00b0 A' %(abs(I_bc),cmath.phase(I_bc)*180/math.pi))\n",
      "print('\\t\\t I_ca = %.2f\u2220%.2f\u00b0 A' %(abs(I_ca),cmath.phase(I_ca)*180/math.pi))\n",
      "print('(ii) Magnitude of line current , I_L = %.2f A' %I_L)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i) Phase currents are,\n",
        "\t\t I_ab = 23.30\u2220-56.31\u00b0 A\n",
        "\t\t I_bc = 23.30\u2220-176.31\u00b0 A\n",
        "\t\t I_ca = 23.30\u222063.69\u00b0 A\n",
        "(ii) Magnitude of line current , I_L = 40.35 A\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.8, Page number 22-23"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import cmath\n",
      "\n",
      "#Variable declaration\n",
      "V_P = 280.0          #Generator Phase voltage(V)\n",
      "Z_P = complex(2,3)   #Line impedance per phase(ohm)\n",
      "Z_L = complex(4,5)   #Load impedance per phase(ohm)\n",
      "\n",
      "#Calculation\n",
      "V_An = V_P*cmath.exp(1j*0*math.pi/180)        #Phase voltage(V)\n",
      "V_Bn = V_P*cmath.exp(1j*-120*math.pi/180)     #Phase voltage(V)\n",
      "V_Cn = V_P*cmath.exp(1j*120*math.pi/180)      #Phase voltage(V)\n",
      "Z_t = Z_P+Z_L                                 #Total impedance(ohm)\n",
      "I_Aa = V_An/Z_t                               #Magnitude of line current for phase A(A)\n",
      "I_Bb = V_Bn/Z_t                               #Magnitude of line current for phase B(A)\n",
      "I_Cc = V_Cn/Z_t                               #Magnitude of line current for phase C(A)\n",
      "V_an = I_Aa*Z_L                               #Phase voltage of load(V)\n",
      "V_bn = I_Bb*Z_L                               #Phase voltage of load(V)\n",
      "V_cn = I_Cc*Z_L                               #Phase voltage of load(V)\n",
      "\n",
      "#Result\n",
      "print('Line currents are,')\n",
      "print('\\t\\t I_Aa = %.f\u2220%.f\u00b0 A' %(abs(I_Aa),cmath.phase(I_Aa)*180/math.pi))\n",
      "print('\\t\\t I_Bb = %.f\u2220%.f\u00b0 A' %(abs(I_Bb),cmath.phase(I_Bb)*180/math.pi))\n",
      "print('\\t\\t I_Cc = %.f\u2220%.f\u00b0 A' %(abs(I_Cc),cmath.phase(I_Cc)*180/math.pi))\n",
      "print('\\nLoad phase voltages are,')\n",
      "print('\\t\\t V_an = %.1f\u2220%.1f\u00b0 V' %(abs(V_an),cmath.phase(V_an)*180/math.pi))\n",
      "print('\\t\\t V_bn = %.1f\u2220%.1f\u00b0 V' %(abs(V_bn),cmath.phase(V_bn)*180/math.pi))\n",
      "print('\\t\\t V_cn = %.1f\u2220%.1f\u00b0 V' %(abs(V_cn),cmath.phase(V_cn)*180/math.pi))\n",
      "print('\\nNOTE : ERROR : Z_L = 6.4\u222038.6\u00b0\u03a9 is taken in textbook solution instead of 6.4\u222051.34\u00b0\u03a9 = (4+j5)\u03a9')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Line currents are,\n",
        "\t\t I_Aa = 28\u2220-53\u00b0 A\n",
        "\t\t I_Bb = 28\u2220-173\u00b0 A\n",
        "\t\t I_Cc = 28\u222067\u00b0 A\n",
        "\n",
        "Load phase voltages are,\n",
        "\t\t V_an = 179.3\u2220-1.8\u00b0 V\n",
        "\t\t V_bn = 179.3\u2220-121.8\u00b0 V\n",
        "\t\t V_cn = 179.3\u2220118.2\u00b0 V\n",
        "\n",
        "NOTE : ERROR : Z_L = 6.4\u222038.6\u00b0\u03a9 is taken in textbook solution instead of 6.4\u222051.34\u00b0\u03a9 = (4+j5)\u03a9\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.9, Page number 23-24"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import cmath\n",
      "\n",
      "#Variable declaration\n",
      "Z = complex(6,8)                            #Per phase impedance of load(ohm)\n",
      "V_AN = 340.0*cmath.exp(1j*0*math.pi/180)    #Phase voltage(V)\n",
      "\n",
      "#Calculation\n",
      "V_P = abs(V_AN)                             #Voltage(V)\n",
      "V_BN = V_P*cmath.exp(1j*-120*math.pi/180)   #Phase voltage(V)\n",
      "V_CN = V_P*cmath.exp(1j*120*math.pi/180)    #Phase voltage(V)\n",
      "I_an = V_AN/Z                               #Load current(A)\n",
      "I_bn = V_BN/Z                               #Load current(A)\n",
      "I_cn = V_CN/Z                               #Load current(A)\n",
      "I_n = I_an+I_bn+I_cn                        #Neutral current(A)\n",
      "\n",
      "#Result\n",
      "print('Phase current in each load = Line current in each load are,')\n",
      "print('\\t\\t\\t\\t I_an = I_Aa = %.f\u2220%.f\u00b0 A' %(abs(I_an),cmath.phase(I_an)*180/math.pi))\n",
      "print('\\t\\t\\t\\t I_bn = I_Bb = %.f\u2220%.f\u00b0 A' %(abs(I_bn),cmath.phase(I_bn)*180/math.pi))\n",
      "print('\\t\\t\\t\\t I_cn = I_Cc = %.f\u2220%.f\u00b0 A' %(abs(I_cn),cmath.phase(I_cn)*180/math.pi))\n",
      "print('Neutral current is , I_n = %.f A' %abs(I_n))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Phase current in each load = Line current in each load are,\n",
        "\t\t\t\t I_an = I_Aa = 34\u2220-53\u00b0 A\n",
        "\t\t\t\t I_bn = I_Bb = 34\u2220-173\u00b0 A\n",
        "\t\t\t\t I_cn = I_Cc = 34\u222067\u00b0 A\n",
        "Neutral current is , I_n = 0 A\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.10, Page number 25-26"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import cmath\n",
      "\n",
      "#Variable declaration\n",
      "Z = complex(3,4)                                 #Per phase impedance of load(ohm)\n",
      "V_AN = 200.0*cmath.exp(1j*0*math.pi/180)         #Phase voltage(V)\n",
      "\n",
      "#Calculation\n",
      "V_P = abs(V_AN)                                   #Voltage(V)\n",
      "V_AB = 3**0.5*V_P*cmath.exp(1j*30*math.pi/180)    #Line voltage(V)\n",
      "V_BC = 3**0.5*V_P*cmath.exp(1j*-90*math.pi/180)   #Line voltage(V)\n",
      "V_CA = 3**0.5*V_P*cmath.exp(1j*150*math.pi/180)   #Line voltage(V)\n",
      "#For case(i)\n",
      "I_ab = V_AB/Z                               #Load current(A)\n",
      "I_bc = V_BC/Z                               #Load current(A)\n",
      "I_ca = V_CA/Z                               #Load current(A)\n",
      "#For case(ii)\n",
      "I_Aa = I_ab-I_ca                            #Line current(A)\n",
      "I_Bb = I_bc-I_ab                            #Line current(A)\n",
      "I_Cc = I_ca-I_bc                            #Line current(A)\n",
      "\n",
      "#Result\n",
      "print('(i) Magnitude of load currents are,')\n",
      "print('\\t\\t I_ab = %.1f\u2220%.2f\u00b0 A' %(abs(I_ab),cmath.phase(I_ab)*180/math.pi))\n",
      "print('\\t\\t I_bc = %.1f\u2220%.2f\u00b0 A' %(abs(I_bc),cmath.phase(I_bc)*180/math.pi))\n",
      "print('\\t\\t I_ca = %.1f\u2220%.2f\u00b0 A' %(abs(I_ca),cmath.phase(I_ca)*180/math.pi))\n",
      "print('\\n(ii) Magnitude of line currents are,')\n",
      "print('\\t\\t I_Aa = %.2f\u2220%.2f\u00b0 A' %(abs(I_Aa),cmath.phase(I_Aa)*180/math.pi))\n",
      "print('\\t\\t I_Bb = %.2f\u2220%.2f\u00b0 A' %(abs(I_Bb),cmath.phase(I_Bb)*180/math.pi))\n",
      "print('\\t\\t I_Cc = %.2f\u2220%.2f\u00b0 A' %(abs(I_Cc),cmath.phase(I_Cc)*180/math.pi))\n",
      "print('\\nNOTE : ERROR : Calculation mistakes in textbook')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i) Magnitude of load currents are,\n",
        "\t\t I_ab = 69.3\u2220-23.13\u00b0 A\n",
        "\t\t I_bc = 69.3\u2220-143.13\u00b0 A\n",
        "\t\t I_ca = 69.3\u222096.87\u00b0 A\n",
        "\n",
        "(ii) Magnitude of line currents are,\n",
        "\t\t I_Aa = 120.00\u2220-53.13\u00b0 A\n",
        "\t\t I_Bb = 120.00\u2220-173.13\u00b0 A\n",
        "\t\t I_Cc = 120.00\u222066.87\u00b0 A\n",
        "\n",
        "NOTE : ERROR : Calculation mistakes in textbook\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.11, Page number 28-29"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import cmath\n",
      "\n",
      "#Variable declaration\n",
      "Z = complex(3,4)                                 #Per phase impedance of load(ohm)\n",
      "V_AN = 150.0*cmath.exp(1j*0*math.pi/180)         #Phase voltage(V)\n",
      "\n",
      "#Calculation\n",
      "V_P = abs(V_AN)                                   #Voltage(V)\n",
      "V_BN = V_P*cmath.exp(1j*-120*math.pi/180)         #Phase voltage(V)\n",
      "V_CN = V_P*cmath.exp(1j*120*math.pi/180)          #Phase voltage(V)\n",
      "I_Aa = V_AN/Z                                     #Line current(A)\n",
      "I_Bb = V_BN/Z                                     #Line current(A)\n",
      "I_Cc = V_CN/Z                                     #Line current(A)\n",
      "pf = Z.real/abs(Z)                                #Power factor\n",
      "I = abs(I_Aa)                                     #Magnitude of line current(A)\n",
      "P = V_P*I*pf*10**-3                               #Power supplied to each phase(kW)\n",
      "P_t = 3*P                                         #Total power supplied(kW)\n",
      "\n",
      "#Result\n",
      "print('Line currents are,')\n",
      "print('  I_Aa = %.f\u2220%.2f\u00b0 A' %(abs(I_Aa),cmath.phase(I_Aa)*180/math.pi))\n",
      "print('  I_Bb = %.f\u2220%.2f\u00b0 A' %(abs(I_Bb),cmath.phase(I_Bb)*180/math.pi))\n",
      "print('  I_Cc = %.f\u2220%.2f\u00b0 A' %(abs(I_Cc),cmath.phase(I_Cc)*180/math.pi))\n",
      "print('Power factor , pf = %.1f ' %pf)\n",
      "print('Power supplied to each phase , P = %.1f kW' %P)\n",
      "print('Total Power supplied to the load , P_t = %.1f kW' %P_t)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Line currents are,\n",
        "  I_Aa = 30\u2220-53.13\u00b0 A\n",
        "  I_Bb = 30\u2220-173.13\u00b0 A\n",
        "  I_Cc = 30\u222066.87\u00b0 A\n",
        "Power factor , pf = 0.6 \n",
        "Power supplied to each phase , P = 2.7 kW\n",
        "Total Power supplied to the load , P_t = 8.1 kW\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.12, Page number 32"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "P = 120.0         #Total power(kW)\n",
      "pf = 0.6          #Power factor \n",
      "\n",
      "#Calculation\n",
      "teta = math.acos(pf)                       #Power factor angle(radians)\n",
      "teta_deg = teta*180/math.pi                #Power factor angle(degree)\n",
      "P_2 = 1.0/2*((math.tan(teta)*P/3**0.5)+P)  #Second wattmeter reading(kW)\n",
      "\n",
      "#Result\n",
      "print('Second wattmeter reading , P_2 = %.1f kW' %P_2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Second wattmeter reading , P_2 = 106.2 kW\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.13, Page number 35"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "P = 5000.0         #Power(W)\n",
      "pf_1 = 0.8         #Initial Power factor\n",
      "V = 110.0          #rms Voltage(V)\n",
      "f = 50.0           #Frequency(Hz)\n",
      "pf_2 = 0.9         #Final Power factor\n",
      "\n",
      "#Calculation\n",
      "phi_1 = math.acos(pf_1)               #Initial Power factor angle(radians)\n",
      "phi_1_deg = phi_1*180/math.pi         #Initial Power factor angle(degree)\n",
      "phi_2 = math.acos(pf_2)               #Final Power factor angle(radians)\n",
      "phi_2_deg = phi_2*180/math.pi         #Final Power factor angle(degree)\n",
      "C = P*(math.tan(phi_1)-math.tan(phi_2))/(2*math.pi*f*V**2)*10**6   #Parallel capacitance(\u00b5F)\n",
      "\n",
      "#Result\n",
      "print('Capacitance , C = %.1f \u00b5F' %C)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Capacitance , C = 349.5 \u00b5F\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.14, Page number 35-36"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "pf_1 = 0.85        #Initial Power factor\n",
      "kVA = 20.0         #Load(kVA)\n",
      "f = 50.0           #Frequency(Hz)\n",
      "pf_2 = 0.95        #Final Power factor\n",
      "V = 200.0          #Voltage(V)\n",
      "R = 0.05           #Resistance(ohm)\n",
      "X = 0.2            #Inductive reactance(ohm)\n",
      "\n",
      "#Calculation\n",
      "phi_1 = math.acos(pf_1)               #Initial Power factor angle(radians)\n",
      "phi_1_deg = phi_1*180/math.pi         #Initial Power factor angle(degree)\n",
      "phi_2 = math.acos(pf_2)               #Final Power factor angle(radians)\n",
      "phi_2_deg = phi_2*180/math.pi         #Final Power factor angle(degree)\n",
      "P = kVA*pf_1                          #Load power(kW)\n",
      "C = P*1000*(math.tan(phi_1)-math.tan(phi_2))/(2*math.pi*f*V**2)*10**6   #Parallel capacitance(\u00b5F)\n",
      "#Before adding capacitor\n",
      "I_1 = P*1000/(pf_1*V)                 #Line current(A)\n",
      "P_1 = I_1**2*R                        #Power loss in line(W)\n",
      "#After adding capacitor\\n\",\n",
      "S = P*1000/pf_2                       #Apparent power(VA)\n",
      "I_2 = S/V                             #Line current(A)\n",
      "P_2 = I_2**2*R                        #Power loss in line(W)\n",
      "\n",
      "#Result\n",
      "print('Capacitance , C = %.1f \u00b5F' %C)\n",
      "print('Power loss in the line before adding capacitor , P_1 = %.1f W' %P_1)\n",
      "print('Power loss in the line after adding capacitor , P_2 = %.1f W' %P_2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Capacitance , C = 393.8 \u00b5F\n",
        "Power loss in the line before adding capacitor , P_1 = 500.0 W\n",
        "Power loss in the line after adding capacitor , P_2 = 400.3 W\n"
       ]
      }
     ],
     "prompt_number": 1
    }
   ],
   "metadata": {}
  }
 ]
}