{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 4 : Performance of Lines"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.1, Page No 65"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "R=0.496\t\t# resistance\n",
      "X=1.536\n",
      "Vr=2000.0\n",
      "\n",
      "#Calculations\n",
      "Z=(10*2*2/(11*11)) + complex(30)*2*2/(11*11)\n",
      "Zt=(.04+(1.3*2*2/(11*11))) + complex(0.125,(4.5*2*2/(11*11)))#Transformer impedence\n",
      "Il=250*1000.0/2000\t# line current(amps.)\n",
      "Pl=Il*Il*R\t\t\t#line loss(kW)\n",
      "Po=250*0.8\t\t\t# output(kW)\n",
      "cosr=0.8\t\t\t# power factor\n",
      "sinr=0.6\n",
      "n=200*100.0/(200+7.7)\n",
      "Vs=(Vr*cosr+Il*R)+complex(Vr*sinr+Il*X)\n",
      "V=math.sqrt((1662**2)+ (1392**2))\n",
      "\n",
      "#Results\n",
      "print(\"efficiency= %.1f percent \" %n)\n",
      "print(\"Sending end voltage,|Vs|=%.0f volts\" %V)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "efficiency= 96.3 percent \n",
        "Sending end voltage,|Vs|=2168 volts\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.2, Page No 66"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "print(\"when load is star connected\")\n",
      "Vln=400/math.sqrt(3.0)\t\t# Line to neutral voltage(V)\n",
      "Z=complex(7,11)\t\t\t\t\t#Impedence per phase\n",
      "Il=231/Z\t\t\t\t\t\t# line current(amp.)\n",
      "I=abs(231/Z)\n",
      "Pi=3*I*I*7\n",
      "Po=3*I*I*6\n",
      "\n",
      "#Calculations\n",
      "print(\"power input =%.0f watts\\n\" %Pi)\t\t#Answers don't match due to difference in rounding off of digits\n",
      "print(\"power output=%.0f watts\\n\" %Po)\t#Answers don't match due to difference in rounding off of digits\n",
      "print(\"when load is delta connected\\n\")\n",
      "Ze=complex(2,3)\t\t# equivalent impedence(ohm)\n",
      "Zp=complex(3,5)\t\t# impedence per phase\n",
      "il=231/Zp\t\t\t#Line current(amps.)\n",
      "IL=abs(il)\n",
      "pi=3*IL*IL*3\n",
      "po=3*IL*IL*2\n",
      "\n",
      "#Results\n",
      "print(\"power input=%.1f watts\" %pi)\t\t\t#Answers don't match due to difference in rounding off of digits\n",
      "print(\"power output = %.0f watts \" %po)\t\t#Answers don't match due to difference in rounding off of digits"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "when load is star connected\n",
        "power input =6592 watts\n",
        "\n",
        "power output=5650 watts\n",
        "\n",
        "when load is delta connected\n",
        "\n",
        "power input=14125.0 watts\n",
        "power output = 9417 watts \n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.3, Page No 66"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "a=100/.5\n",
      "Xl=2*(10**-7)*math.log(100/.5)\t\t#inductance(H/meter)\n",
      "XL=20*(1000)*Xl\t\t\t\t\t\t# inductance of 20 km length \n",
      "R=6.65\t\t\t\t\t\t\t\t# resistance(ohm)\n",
      "Rc=20*1000/(58.0*90)\t\t\t\t# resistance of copper(ohm)\n",
      "I=10*1000/(33*.8*math.sqrt(3))\t\t# the current(amps.)\n",
      "\n",
      "#Calculations\n",
      "Pl=3*I*I*Rc/(10**6)\t\t\t\t\t#loss (MW)\n",
      "n=10.0/(10+Pl)\n",
      "print(\"Efficiency=%.4f percent \" %n)\n",
      "Vr=19052\n",
      "cosr=.8\t\t\t\t#power factor\n",
      "sinr=.6\n",
      "Vs=abs(((Vr*cosr+I*Rc) +complex(Vr*sinr+ I*R)))\n",
      "\n",
      "#Results\n",
      "print(\"Vs =%.0f volts\\n\" %Vs)\t#Answer don't match due to difference in rounding off of digits\n",
      "Reg=(Vs-Vr)*100/Vr\n",
      "print(\"Regulation =%.2f percent\" %Reg)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Efficiency=0.9479 percent \n",
        "Vs =28965 volts\n",
        "\n",
        "Regulation =52.03 percent\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.4 Page No 67"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "IR=(400)/((math.sqrt(3)*complex(6.3,9)))\n",
      "\n",
      "#Calculations\n",
      "IY=231*complex(math.cos(math.radians(-120)),math.sin(math.radians(-120)))/8.3\n",
      "IB=231*complex(math.cos(math.radians(120)),math.sin(math.radians(120)))/complex(6.3,-8)\n",
      "In=abs((IR +IY +IB))\t\t#Neutral current\n",
      "print(\"Neutral current =%.2f amps\\n\" %In)\n",
      "VR=abs(IR*complex(6,9))\n",
      "VY=abs(IY*(8))\n",
      "VB=abs(IB*complex(6,-8))\n",
      "\n",
      "#Results\n",
      "print(\"Voltage across Phase R =%.1f volts \\n\" %VR)\n",
      "print(\"Voltage across Phase Y =%.2f volts \\n\" %VY)\n",
      "print(\"Voltage across Phase B =%.0f volts \\n\" %VB)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Neutral current =45.18 amps\n",
        "\n",
        "Voltage across Phase R =227.4 volts \n",
        "\n",
        "Voltage across Phase Y =222.65 volts \n",
        "\n",
        "Voltage across Phase B =227 volts \n",
        "\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.5, Page No 73"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "R=100*.1\t\t#Resistance of line (ohm)\n",
      "Xl=2*(10**-7)*100*1000*math.log(200/.75)\t#inductance of line\n",
      "X2=Xl*314\t\t\t\t\t\t\t\t\t#inductive reactance\n",
      "C=2*(math.pi*100)*8.854*(10**-12)*100*1000*(10**6)/(math.log(200/.75))\t# capacitance per phase (micro farad)\n",
      "\n",
      "#Calculations\n",
      "print(\"Using Nominal-T method\\n\")\n",
      "Ir=20*1000.0/(math.sqrt(3)*66*.8)\n",
      "Vr=66*1000/math.sqrt(3)\n",
      "Vc=complex((38104*.8+ Ir*5),(38104*.6+ Ir*17.55))\t# voltage across condenser\n",
      "Ic=complex(314*(Vc)*.9954*(10**-6))\n",
      "ise=Ir+Ic\n",
      "Is=abs(Ir+Ic)\n",
      "Vs=abs(Vc + (ise*complex(5,17.53)))\n",
      "VR=abs(Vs*complex(-3199)/complex(5,-3181))# no load recieving end voltage\n",
      "Reg=(VR-Vr)*100.0/Vr\n",
      "Pl=3*(Ir*Ir*5 + Is*Is*5)/1000000\n",
      "n=20*100/(20+Pl)\n",
      "print(\"percent regulation=%.1f \" %Reg)\n",
      "print(\"percent efficiency=%.1f \\n\" %n)\n",
      "print(\"Using Nominal-pi method\\n\")\n",
      "Ir1=218.68*complex(.8,-.6)\n",
      "Ic1=complex(314*.4977*(10**-6)*Vr)\n",
      "Il=Ir1+Ic1\n",
      "vs1=Vr+Il*complex(10,35.1)\n",
      "Vs1=abs(vs1)\n",
      "Vr1=Vs1*complex(-6398)/complex(10,-6363)\n",
      "VR1=abs(Vr1)\t\t\t# no load recieving end voltage\n",
      "Reg2=(VR1-Vr)*100/Vr\n",
      "IL=abs(Ir1+Ic1)\n",
      "Loss=3*IL*IL*10\n",
      "n=20*100/21.388\n",
      "\n",
      "#Results\n",
      "print(\"percent regulation=%.2f \" %Reg2)\n",
      "print(\"percent efficiency=%.1f \" %n)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Using Nominal-T method\n",
        "\n",
        "percent regulation=18.2 \n",
        "percent efficiency=93.0 \n",
        "\n",
        "Using Nominal-pi method\n",
        "\n",
        "percent regulation=18.23 \n",
        "percent efficiency=93.5 \n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.6, Page No 78"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import cmath\n",
      "#initialisation of variables\n",
      "R=0.2\n",
      "L=1.3\n",
      "C=0.01*(10**-6)\n",
      "\n",
      "#Calculations\n",
      "z=complex(R,(L*314.0*(10**-3)))\t\t# serie impedence\n",
      "y=complex(314.0*C)\t\t# shunt admittance\n",
      "Zc=cmath.sqrt(z/y)\t\t# characterstic impedence\n",
      "Y=cmath.sqrt(y*z)\n",
      "Vr=132*1000/math.sqrt(3.0)\n",
      "Ir=0\n",
      "Vin=(Vr + Ir*Zc)/2\t\t\t# incident voltage to neutral at the recieving end\n",
      "\n",
      "#Results\n",
      "print(\"Vr =%.3f volts \\n\" %Vr)\t\t#Answer don't match due to difference in rounding off of digits\n",
      "print(\"(i)The incident voltage to neutral at the recieving end {0:.5f}+{1:.5f}i\".format(Vin.real, Vin.imag))\t#Answer don't match due to difference in rounding off of digits\n",
      "Vin2=(Vr - Ir*Zc)/2\t\t\t\t\t\t# The reflected voltage to neutral at the recieving end\n",
      "print(\"(ii)The reflected voltage to neutral at the recieving end{0:.5f}+{1:.5f}i\".format(Vin2.real, Vin2.imag))\t\t#Answer don't match due to difference inrounding off of digits\n",
      "Vrp=Vr*cmath.exp(.2714*120*(10**-3))*cmath.exp(complex(1.169*120*(10**-3))/1000.0)#Taking Vrp=Vr+\n",
      "Vrm=Vr*cmath.exp(-0.0325)*cmath.exp(complex(-.140))/1000\t\t\t#Taking Vrm=Vr-\n",
      "v1=Vrm/2\t\t\t\t               # reflected voltage to neutral at 120 km from the recieving end\n",
      "phase_v1=math.degrees(math.atan(v1.imag/v1.real))\n",
      "v2=Vrp/2\t\t\t                   #incident voltage to neutral at 120 km from the recieving end\n",
      "phase_v2=math.degrees(math.atan(v2.imag/v2.real))#Phase angle of v2\n",
      "print(\"(iii) reflected voltage to neutral at 120 km from the recieving end =%.2f at angle of %.2f\" %(abs(v1),phase_v1))\n",
      "print(\"incident voltage to neutral at 120 km from the recieving end = %.2f at angle of %.2f\" %(abs(v2),phase_v2))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Vr =76210.236 volts \n",
        "\n",
        "(i)The incident voltage to neutral at the recieving end 38105.11777+0.00000i\n",
        "(ii)The reflected voltage to neutral at the recieving end38105.11777+0.00000i\n",
        "(iii) reflected voltage to neutral at 120 km from the recieving end =32.07 at angle of 0.00\n",
        "incident voltage to neutral at 120 km from the recieving end = 39372.08 at angle of 0.00\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.7 Page No 79"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "Ir=40.0*1000/(math.sqrt(3)*132*.8)\n",
      "Vr=132.0*1000/math.sqrt(3)\n",
      "\n",
      "#Calculations\n",
      "Zc=380*complex(math.cos(math.radians(-13.06)),math.sin(math.radians(-13.06)))\n",
      "IR=Ir*complex(math.cos(math.radians(-38.8)),math.sin(math.radians(-38.8)))\n",
      "Vsp=(Vr+IR*Zc)*(1.033*complex(math.cos(math.radians(8.02)),math.sin(math.radians(8.02))))/2\n",
      "Vsm=(Vr-IR*Zc)*(0.968*complex(math.cos(math.radians(8.02)),math.sin(math.radians(8.02))))/2\n",
      "vs=Vsp+ Vsm\n",
      "Vs=abs(vs)\n",
      "ise=(Vsp-Vsm)/Zc\n",
      "Is=abs(ise)\n",
      "P=3*Vs*Is*math.cos(math.radians(33.72))/10**6\n",
      "n=40*100/P\n",
      "\n",
      "#Results\n",
      "print(\"efficiency=%.1f\" %n)\t\t#Answer don't match due to difference in rounding off of digits"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "efficiency=92.3\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.8, Page No 80"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import cmath\n",
      "#initialisation of variables\n",
      "yl=complex(0.2714,1.169)*120*(10**-3)\n",
      "Ir=40*1000/(math.sqrt(3)*132*.8)\n",
      "A=cmath.cosh(yl)\n",
      "\n",
      "#Calculations\n",
      "phase_A=math.degrees(math.atan(A.imag/A.real)) #Phase angle of A\n",
      "IR=Ir*complex(math.cos(math.radians(-38.8)),math.sin(math.radians(-38.8)))\n",
      "Vr=132*1000/math.sqrt(3)\n",
      "Zc=380*complex(math.cos(math.radians(-13.06)),math.sin(math.radians(-13.06)))\n",
      "B=Zc*cmath.sinh(yl)\n",
      "phase_B=math.degrees(math.atan(B.imag/B.real))  #Phase angle of B\n",
      "Vs=(A*Vr+B*IR)\n",
      "f=abs(B)\n",
      "d=abs(Vs)\n",
      "C=cmath.sinh(yl)/Zc\n",
      "phase_C=math.degrees(math.atan(C.imag/C.real)) #Phase angle of C\n",
      "D=cmath.cosh(yl)\n",
      "phase_D=math.degrees(math.atan(D.imag/D.real))\t\t#Phase angle of D\n",
      "\n",
      "#Results\n",
      "print(\"A=%.2f at an angle of %.2f \" %(abs(A),phase_A))\n",
      "print(\"B=%.1f at an angle of %.0f \" %(abs(B),phase_B))\n",
      "print(\"C=%.2f at an angle of %.2f \" %(abs(C),phase_C))\n",
      "print(\"D=%.2f at an angle of %.2f \" %(abs(D),phase_D))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "A=0.99 at an angle of 0.26 \n",
        "B=54.6 at an angle of 64 \n",
        "C=0.00 at an angle of -89.92 \n",
        "D=0.99 at an angle of 0.26 \n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.9 Page No 81"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "Ir=218.7*complex(0.8,-0.6)\n",
      "Ic1=complex(314)*0.6*(10**-6)*76200\n",
      "Il=Ic1+Ir\n",
      "Vs=76200 + Il*complex(24,48.38)\n",
      "\n",
      "#Calculations\n",
      "phase_Vs=math.degrees(math.atan(Vs.imag/Vs.real))\n",
      "Pl=3*24*abs(Il)*abs(Il)/1000000.0   #The Loss(MW)\n",
      "n=40*100/(40+Pl)\n",
      "print(\"Using Nominal- pi method\")\n",
      "print(\"Vs=%.0f volts at an angle of %.2f \\n\" %(abs(Vs),phase_Vs))\n",
      "print(\"efficiency=%.2f percent\" %n)\n",
      "print(\"\\nUsing Nominal-T method\")\n",
      "Vc=76200*complex(0.8,0.6)+218.7*complex(12,24.49)\n",
      "Ic=complex(314)*1.2*(10**-6)*complex(63584,51076.0)\n",
      "Is=complex(199.46,23.95)\n",
      "Vs=(Vc + Is*complex(12,24.49))/1000.0\n",
      "phase_Vs=math.degrees(math.atan(Vs.imag/Vs.real))\t#Phase angle of Vs\n",
      "Pl1=3*12*((200.89**2)+ 218.7**2)/1000000   #The loss(MW)\n",
      "n1=40*100/(40+Pl1)\n",
      "\n",
      "#Results\n",
      "print(\"Vs=%.2f  at an angle of %.2f \" %(abs(Vs),phase_Vs))\n",
      "print(\"efficiency=%.2f percent\\n\" %n1)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Using Nominal- pi method\n",
        "Vs=87299 volts at an angle of 3.95 \n",
        "\n",
        "efficiency=91.28 percent\n",
        "\n",
        "Using Nominal-T method\n",
        "Vs=86.25  at an angle of 40.70 \n",
        "efficiency=92.65 percent\n",
        "\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.10 Page No 92"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import cmath\n",
      "#initialisation of variables\n",
      "R=0.1557*160\n",
      "GMD=(3.7*6.475*7.4)**(1.0/3)\n",
      "Z1=2*(10**-7)*math.log(560/0.978)*160*1000\n",
      "XL=63.8\n",
      "\n",
      "#Calculations\n",
      "C=(10**-9)*2*(10**6)*math.pi*160*1000.0/(36*math.pi*math.log(560/.978))\n",
      "Z=math.sqrt((0.1557**2)+.39875**2)*complex(math.cos(math.radians(68.67)),math.sin(math.radians(68.67)))\n",
      "jwC=complex(314)*1.399*(10**-6)/160.0\n",
      "Zc=cmath.sqrt(Z/jwC)\n",
      "y=cmath.sqrt(Z*jwC)\n",
      "yl=y*160\n",
      "A=cmath.cosh(yl)\n",
      "B=Zc*cmath.sinh(yl)\n",
      "C=cmath.sinh(yl)/Zc\n",
      "Ir=50000/(math.sqrt(3)*132)\n",
      "Vs=(A*76.208) +(B*(10**-3)*Ir*complex(math.cos(math.radians(-36.87)),math.sin(math.radians(-36.87))))\n",
      "VS=152.34\n",
      "Is=C*76.208*(10**3) +(A*Ir*complex(math.cos(math.radians(-36.87)),math.sin(math.radians(-36.87))))\n",
      "Ps=3*abs(Vs)*abs(Is)*math.cos(math.radians(33.96))\n",
      "pf=math.cos(math.radians(33.96))\n",
      "Vnl=abs(Vs)/abs(A)\n",
      "reg=(Vnl-76.208)*100/76.208\n",
      "n=50000*.8*100/abs(Ps)\n",
      "\n",
      "#Results\n",
      "print(\"Vs line to line =%.2f kV\\n\" %VS)\n",
      "print(\"sending end current Is(A){0:.5f}+{1:.5f}i\".format(Is.real, Is.imag)) #Answer don't match due to difference in rounding off of digits\n",
      "print(\"sending end power=%.0f kW\" %Ps)\n",
      "print(\"sending end p.f =%.3f\" %pf)\n",
      "print(\"percent regulation=%.1f \" %reg)\n",
      "print(\"percent efficency=%.1f \" %n)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Vs line to line =152.34 kV\n",
        "\n",
        "sending end current Is(A)211.28696+-129.31797i\n",
        "sending end power=55350 kW\n",
        "sending end p.f =0.829\n",
        "percent regulation=17.2 \n",
        "percent efficency=72.3 \n"
       ]
      }
     ],
     "prompt_number": 10
    }
   ],
   "metadata": {}
  }
 ]
}