{
 "metadata": {
  "name": "",
  "signature": "sha256:f3e57a0086738fdcfc0c2ba196533f123679df702a6579b464c4a555347a158e"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 6 - REPRESENTATION AND PERFORMANCE OF LONG TRANSMISSION LINES "
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E1 - Pg 168"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate A,B,C,D\n",
      "import math \n",
      "import cmath\n",
      "import numpy\n",
      "#Given data :\n",
      "r=0.22##ohm\n",
      "x=0.45##ohm\n",
      "g=4.*10.**-9##S\n",
      "b=2.53*10.**-6##S\n",
      "f=50.##Hz\n",
      "l=1000.##Km\n",
      "#Using Convergent series of complex angles\n",
      "z=r+1j*x##ohm\n",
      "y=g+1j*b##ohm\n",
      "Z=z*l##ohm\n",
      "Y=y*l##ohm\n",
      "YZ=Y*Z##ohm\n",
      "Y2Z2=YZ**2.##ohm\n",
      "Y3Z3=YZ**3.##ohm\n",
      "A=1.+YZ/2.+Y2Z2/24.+Y3Z3/720.##ohm\n",
      "D=A##oh,m\n",
      "B=Z*(1.+YZ/6.+Y2Z2/120.+Y3Z3/5040.)##ohm\n",
      "C=Y*(1.+YZ/6.+Y2Z2/120.+Y3Z3/5040.)##ohm\n",
      "print '%s' %(\"Auxiliary Constants by using Convergent series of complex angles : \")#\n",
      "print \"A = \",A#\n",
      "print \"B = \",B#\n",
      "print \"C = \",C#\n",
      "#Using Convergent series of real angles\n",
      "A=cmath.cosh(cmath.sqrt(YZ))##ohm\n",
      "D=A##ohm\n",
      "B=cmath.sqrt(Z/Y)*cmath.sinh(cmath.sqrt(YZ))##ohm\n",
      "C=cmath.sqrt(Y/Z)*cmath.sinh(cmath.sqrt(YZ))##ohm\n",
      "A=cmath.cosh(cmath.sqrt(YZ))##ohm\n",
      "print '%s' %(\"Auxiliary Constants by using Convergent series of real angles : \")#\n",
      "print '%s %.2f %s %.2f' %(\"A, magnitude is \",abs(A),\" and angle in degree is \",cmath.phase(A)*180/math.pi)#\n",
      "print '%s %.2f %s %.2f' %(\"B, magnitude is \",abs(B),\" and angle in degree is \",cmath.phase(B)*180/math.pi)#\n",
      "print '%s %.4f %s %.2f' %(\"C, magnitude is \",abs(C),\" and angle in degree is \",cmath.phase(C)*180/math.pi)#\n",
      "print '%s' %(\"We obtain same result by both of the methods.\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Auxiliary Constants by using Convergent series of complex angles : \n",
        "A =  (0.471555198201+0.229032046676j)\n",
        "B =  (142.776787567+386.558406193j)\n",
        "C =  (-0.000206399312625+0.00207114180387j)\n",
        "Auxiliary Constants by using Convergent series of real angles : \n",
        "A, magnitude is  0.52  and angle in degree is  25.90\n",
        "B, magnitude is  412.08  and angle in degree is  69.73\n",
        "C, magnitude is  0.0021  and angle in degree is  95.69\n",
        "We obtain same result by both of the methods.\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E2 - Pg 169"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate Sending end line voltage in kV,Sending end current in A, magnitude is\n",
      "import math\n",
      "import cmath\n",
      "\n",
      "#Given data :\n",
      "Z=200.*(math.cos(80.*math.pi/180.) + 1j*math.sin(80.*math.pi/180.))##ohm\n",
      "Y=0.0013*(math.cos(90.*math.pi/180.) + 1j*math.sin(90.*math.pi/180.))#S/phase\n",
      "P=80.*10.**6##W\n",
      "pf=0.8##power factor\n",
      "VRL=220.*1000.##V\n",
      "VR=VRL/math.sqrt(3.)##V\n",
      "IR=P/math.sqrt(3.)/VRL/pf##A\n",
      "fi=math.acos(pf)*180/math.pi##degree\n",
      "IR=IR*(math.cos(-fi*math.pi/180.) + 1j*math.sin(-fi*math.pi/180.))##A\n",
      "YZ=Y*Z##ohm\n",
      "Y2Z2=YZ**2##ohm\n",
      "Y3Z3=YZ**3##ohm\n",
      "A=1.+YZ/2.+Y2Z2/24+Y3Z3/720##ohm\n",
      "D=A##oh,m\n",
      "B=Z*(1.+YZ/6.+Y2Z2/120.+Y3Z3/5040.)##ohm\n",
      "C=Y*(1.+YZ/6.+Y2Z2/120.+Y3Z3/5040.)##mho\n",
      "VS=A*VR+B*IR##V\n",
      "VSL=math.sqrt(3.)*abs(VS)##V\n",
      "print '%s %.2f' %(\"Sending end line voltage in kV : \",VSL/1000.)#\n",
      "IS=C*VR+D*IR##\n",
      "print '%s %.2f %s %.2f' %(\"Sending end current in A, magnitude is \",abs(IS),\" and angle in degree is \",cmath.phase(IS)*180/math.pi)#\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Sending end line voltage in kV :  263.59\n",
        "Sending end current in A, magnitude is  187.48  and angle in degree is  7.66\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E3 - Pg 176"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate Constant A0,Constant B0,Constant C0,Constant D0\n",
      "import math\n",
      "import cmath\n",
      "#Given data :\n",
      "VRL=220.##kV\n",
      "VR=VRL/math.sqrt(3.)##V\n",
      "P=10.*10**6##VA\n",
      "Z=1.+1j*8.##ohm(in %)\n",
      "Zse=Z/100.*VRL**2./100.##ohm/phase\n",
      "A=0.9*(math.cos(0.6*math.pi/180.) + 1j*math.sin(0.6*math.pi/180.))##Auxiliary constant\n",
      "D=A ##Auxiliary constant\n",
      "\n",
      "B=153.2*(math.cos(84.6*math.pi/180.) + 1j*math.sin(84.6*math.pi/180.))##Auxiliary constant\n",
      "C=0.0012*(math.cos(90*math.pi/180.) + 1j*math.sin(90*math.pi/180.))##Auxiliary constant\n",
      "A0=A+C*Zse##constant\n",
      "B0=B+D*Zse##ohm#constant\n",
      "C0=C##mho or S#constant\n",
      "D0=A##constant\n",
      "print '%s %.4f %s %.2f' %(\"Constant A0, magnitude is \",abs(A0),\" and angle in degree is \",cmath.phase(A0)*180/math.pi)#\n",
      "print '%s %.f %s %.2f' %(\"Constant B0(ohm), magnitude is \",abs(B0),\" and angle in degree is \",cmath.phase(B0)*180/math.pi)#\n",
      "print '%s %.4f %s %.2f' %(\"Constant C0(S), magnitude is \",abs(C0),\" and angle in degree is \",cmath.phase(C0)*180/math.pi)#\n",
      "print '%s %.1f %s %.2f' %(\"Constant D0, magnitude is \",abs(D0),\" and angle in degree is \",cmath.phase(D0)*180/math.pi)#\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Constant A0, magnitude is  0.8536  and angle in degree is  1.02\n",
        "Constant B0(ohm), magnitude is  188  and angle in degree is  84.39\n",
        "Constant C0(S), magnitude is  0.0012  and angle in degree is  90.00\n",
        "Constant D0, magnitude is  0.9  and angle in degree is  0.60\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E4 - Pg 177"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate Constant A0,Constant B0,Constant C0,Constant D0\n",
      "import math\n",
      "import cmath\n",
      "#Given data :\n",
      "A=0.98*(math.cos(2.*math.pi/180.) + 1j*math.sin(2.*math.pi/180.))##Auxiliary constant\n",
      "D=A##Auxiliary constant\n",
      "B=28.*(math.cos(69.*math.pi/180.) + 1j*math.sin(69.*math.pi/180.))##Auxiliary constant\n",
      "Zse=12.*(math.cos(80.*math.pi/180.) + 1j*math.sin(80.*math.pi/180.))##ohm\n",
      "C=(A*D-1)/B##Auxiliary constant\n",
      "A0=A+C*Zse##constant\n",
      "B0=B+2.*A*Zse+C*Zse**2.##ohm#constant\n",
      "C0=C##mho or S#constant\n",
      "D0=A0##constant\n",
      "print '%s %.2f %s %.2f' %(\"Constant A0, magnitude is \",abs(A0),\" and angle in degree is \",cmath.phase(A0)*180/math.pi)#\n",
      "print '%s %.2f %s %.2f' %(\"Constant B0(ohm), magnitude is \",abs(B0),\" and angle in degree is \",cmath.phase(B0)*180/math.pi)#\n",
      "print '%s %.2f %s %.f' %(\"Constant C0(S), magnitude is \",abs(C0),\" and angle in degree is \",cmath.phase(C0)*180/math.pi)#\n",
      "print '%s %.3f %s %.2f' %(\"Constant D0, magnitude is \",abs(D0),\" and angle in degree is \",cmath.phase(D0)*180/math.pi)#\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Constant A0, magnitude is  0.96  and angle in degree is  3.53\n",
        "Constant B0(ohm), magnitude is  50.89  and angle in degree is  75.24\n",
        "Constant C0(S), magnitude is  0.00  and angle in degree is  53\n",
        "Constant D0, magnitude is  0.958  and angle in degree is  3.53\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E5 - Pg 177"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate \n",
      "import math \n",
      "import cmath\n",
      "#Given data :\n",
      "A=0.92*(math.cos(5.3*math.pi/180.) + 1j*math.sin(5.3*math.pi/180.))#Auxiliary constant\n",
      "D=A##Auxiliary constant\n",
      "B=65.3*(math.cos(81*math.pi/180.) + 1j*math.sin(81*math.pi/180.))##Auxiliary constant\n",
      "ZT=100*(math.cos(70*math.pi/180.) + 1j*math.sin(70*math.pi/180.))##ohm\n",
      "YT=0.0002*(math.cos(-75.*math.pi/180.) + 1j*math.sin(-75.*math.pi/180.))##S\n",
      "C=(A*D-1)/B##Auxiliary constant\n",
      "A0=A*(1+2*YT*ZT)+B*(YT)+C*ZT*(1+YT*ZT)##constant\n",
      "B0=2.*A*ZT+B+C*ZT**2##ohm#constant\n",
      "C0=2.*A*YT*(1.+YT*ZT)+B*YT**2.+C*(1.+YT*ZT)**2.##mho or S#constant\n",
      "D0=A0##constant\n",
      "print '%s %.5f %s %.2f' %(\"Constant A0, magnitude is \",abs(A0),\" and angle in degree is \",cmath.phase(A0)*180/math.pi)#\n",
      "print '%s %.2f %s %.2f' %(\"Constant B0(ohm), magnitude is \",abs(B0),\" and angle in degree is \",cmath.phase(B0)*180/math.pi)#\n",
      "print '%s %.6f %s %.1f' %(\"Constant C0(S), magnitude is \",abs(C0),\" and angle in degree is \",cmath.phase(C0)*180/math.pi)#\n",
      "print '%s %.2f %s %.2f' %(\"Constant D0, magnitude is \",abs(D0),\" and angle in degree is \",cmath.phase(D0)*180/math.pi)#\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Constant A0, magnitude is  0.84340  and angle in degree is  26.45\n",
        "Constant B0(ohm), magnitude is  233.85  and angle in degree is  84.30\n",
        "Constant C0(S), magnitude is  0.003442  and angle in degree is  50.9\n",
        "Constant D0, magnitude is  0.84  and angle in degree is  26.45\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E6 - Pg 178"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate \n",
      "import math \n",
      "import cmath\n",
      "#Given data :\n",
      "A=0.945*math.cos(1.02*math.pi/180.) + 1j*math.sin(1.02*math.pi/180.)##Auxiliary constant\n",
      "D=A##Auxiliary constant\n",
      "B=82.3*math.cos(73.03*math.pi/180.) + 1j*math.sin(73.03*math.pi/180.)##ohm#Auxiliary constant\n",
      "C=0.001376*math.cos(90.4*math.pi/180.) + 1j*math.sin(90.4*math.pi/180.)##S#Auxiliary constant\n",
      "#part (i)\n",
      "Y=C##S\n",
      "Z=2.*(A-1)/C##ohm\n",
      "print '%s' %(\"For equivalent T-network : \")#\n",
      "print '%s %.6f %s %.1f' %(\"Shunt admittance in S, magnitude is \",abs(Y),\" and angle in degree is \",cmath.phase(Y)*180/math.pi)#\n",
      "print '%s %.2f %s %.1f' %(\"Impedance in ohm, magnitude is \",abs(Z),\" and angle in degree is \",cmath.phase(Z)*180/math.pi)#\n",
      "print '%s' %(\"For equivalent pi-network : \")#\n",
      "Z=B##ohm\n",
      "print '%s %.2f %s %.2f' %(\"Series Impedance in ohm, magnitude is \",abs(Z),\" and angle in degree is \",cmath.phase(Z)*180/math.pi)#\n",
      "Y=2.*(A-1)/B##S\n",
      "print '%s %.6f %s %.2f' %(\"Shunt admittance in S, magnitude is \",abs(Y),\" and angle in degree is \",cmath.phase(Y)*180/math.pi)#\n",
      "#For T-Network Value of Z is wrog in the book.\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "For equivalent T-network : \n",
        "Shunt admittance in S, magnitude is  0.999976  and angle in degree is  90.0\n",
        "Impedance in ohm, magnitude is  0.12  and angle in degree is  72.1\n",
        "For equivalent pi-network : \n",
        "Series Impedance in ohm, magnitude is  24.04  and angle in degree is  2.28\n",
        "Shunt admittance in S, magnitude is  0.004821  and angle in degree is  159.83\n"
       ]
      }
     ],
     "prompt_number": 15
    }
   ],
   "metadata": {}
  }
 ]
}