{
 "metadata": {
  "name": "",
  "signature": "sha256:e3f5e499dcd1ee49e675b7d331eadcbb56a69331fd31c0617d103de1bd691963"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Ch-13, Major Electrical Equipment in Power Plant"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "example 13.1 Page 277"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "pg=3000  #kva rating of generators single phase\n",
      "xg=0.1  #10%reactanse of generator\n",
      "vg=11   #voltage at the terminals of generator\n",
      "xbf=5    #reactanse of feeder fron bus to fault\n",
      "pb=pg ;vb=vg ;ib=pg/vg  #let power and voltage of as respective base then current base\n",
      "zb=(vb*10**3)/ib   #base impedence\n",
      "xpu=xbf/zb  #per unit reactance of feeder\n",
      "tx=(xg/2)+(xpu) #total reactance \n",
      "sckva=pg/tx  #short circuit kva is ratio ofpower to total reactance\n",
      "sci=sckva/vg   #short circuit current\n",
      "print 'a'\n",
      "print \" p.u.feeder reactor %.3fp.u \\n total reactance is %.3fp.u \\n short circuit kVA %dkVA \\n short circuit current %.1fA\"%(xpu,tx,sckva,sci)\n",
      "gz=zb*xg  #generator impedence\n",
      "tz=(gz/2)+xbf  #total impedence\n",
      "scc=(vg*10**3)/tz  #short circuit current in ampears\n",
      "print 'b' \n",
      "print \" generator impedence %.3fohm \\n total impedence %.3f ohm \\n short circuit current %.1fA\"%(gz,tz,scc)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "a\n",
        " p.u.feeder reactor 0.000p.u \n",
        " total reactance is 0.050p.u \n",
        " short circuit kVA 60000kVA \n",
        " short circuit current 5454.5A\n",
        "b\n",
        " generator impedence 4.000ohm \n",
        " total impedence 7.000 ohm \n",
        " short circuit current 1571.4A\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "example 13.2 page 277"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import sqrt\n",
      "pa1=20000 ; pa2=30000  #kva in in 3 ph power\n",
      "va1=11    ; va2=11  #voltage in kilo volts\n",
      "pt1=20000 ; pt2=30000#kva of 3 ph transformer\n",
      "vpt1=11   ; vpt2=11#voltage of primery of transformer\n",
      "vst1=132  ; vst2=132#voltage of secondary of transformer\n",
      "xg1=0.5  ; xg2=0.65   #reactance of generator\n",
      "xt1=0.05  ;xt2=0.05 #reactance of transformer with their own kva\n",
      "pb=pa2; vbg=va2 ;vbt=vpt2 #assumeing base quantoties\n",
      "xtn1=xt1*pb/pa1  ;xtn2=xt2*pb/pa2 #transformer reactance with new base\n",
      "xgn1=xg1*pb/pa1; xgn2=xg2*pb/pa2\n",
      "xn1=xtn1+xgn1 ;xn2=xtn2+xgn2  #reactancee up to fault from each generator\n",
      "xn=(xn1*xn2)/(xn1+xn2)  #equalent reactance between generator and fault\n",
      "sckva=pb/xn   #short circuit KVA\n",
      "print '(a)'\n",
      "print \" equivalent reactance is %.4f p.u \\n short circuit KVA %dKVA\"%(xn,sckva)\n",
      "print '(b)'\n",
      "sccb=sckva/(vst1*sqrt(3))\n",
      "sccg1=sccb*(xn2/(xn1+xn2))*vst1/vpt1\n",
      "sccg2=sccb*(xn1/(xn1+xn2))*vst2/vpt2\n",
      "print \" short circuit current on bus bar side %.1fA \\n short circuit current of generator 1 is %.1fA \\n short circuit current of generator 2 is %.1fA \\n\"%(sccb,sccg1,sccg2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a)\n",
        " equivalent reactance is 0.3787 p.u \n",
        " short circuit KVA 79220KVA\n",
        "(b)\n",
        " short circuit current on bus bar side 346.5A \n",
        " short circuit current of generator 1 is 1908.6A \n",
        " short circuit current of generator 2 is 2249.4A \n",
        "\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "example 13.3 Page 278"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "pa1=20000 ; pa2=30000  #kva in in 3 ph power\n",
      "va1=11    ; va2=11  #voltage in kilo volts\n",
      "pt1=20000 ; pt2=30000#kva of 3 ph transformer\n",
      "vpt1=11   ; vpt2=11#voltage of primery of transformer\n",
      "vst1=132  ; vst2=132#voltage of secondary of transformer\n",
      "xg1=0.5   ;xg2=0.65   #reactance of generator\n",
      "xt1=0.05  ;xt2=0.05 #reactance of transformer with their own kva\n",
      "pb=pa2 ;vbg=va2 ;vbt=vpt2 #assumeing base quantoties\n",
      "xtn1=xt1*pb/pa1  ;xtn2=xt2*pb/pa2 #transformer reactance with new base\n",
      "xgn1=xg1*pb/pa1 ;xgn2=xg2*pb/pa2\n",
      "xn1=xtn1+xgn1 ;xn2=xtn2+xgn2  #reactancee up to fault from each generator\n",
      "xn=(xn1*xn2)/(xn1+xn2)  #equalent reactance between generator and fault\n",
      "sckva=pb/xn   #short circuit KVA\n",
      "pf=50000  #fault kva rating\n",
      "xf=pb/pf  #reactance from fault\n",
      "xx=xf*xn1/(xn1-xf)\n",
      "x=xx-xn2 #reactance to be added \n",
      "bi=(vst1**2)*1000/(pb)\n",
      "xo=x*bi\n",
      "print \" reactance to be added in circuit of generator 2 have %.1f p.u. \\n reactance in ohms %.1f\"%(x,xo)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " reactance to be added in circuit of generator 2 have -0.7 p.u. \n",
        " reactance in ohms -406.0\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "example 13.4 Page 278"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "pa=50; xgb=0.5; xb=0.1 #given power,reactance of generator\n",
      "x1=xgb+xb \n",
      "x=x1*x1*xgb/(x1*x1+x1*xgb+x1*xgb)\n",
      "f=pa/x\n",
      "print \" total reactance %.4f.p.u \\n fault MVA %.1fMVA\"%(x,f)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " total reactance 0.1875.p.u \n",
        " fault MVA 266.7MVA\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "example13_5 Page 279"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "vb=33\n",
      "pb=20 ;zb=vb**2/pb   #base voltage and base power\n",
      "pa1=10 ;pa2=10; xa1=0.08; xa2=0.08   #given power and reactance for different branches\n",
      "pbb=20 ;xb=0.06 ;pc=15 ;xc=0.12; pd=20; xd=0.08 \n",
      "xab=2.17; xbc=3.26; xcd=1.63; xda=4.35 \n",
      "xap1=xa1*pb/pa1 \n",
      "xap2=xa2*pb/pa2 ;xap=xap1*xap2/(xap1+xap2)\n",
      "xbp=xb*pb/pbb \n",
      "xcp=xc*pb/pc \n",
      "xdp=xd*pb/pd     #generators reactance in per unit\n",
      "xabp=round(xab*100/zb)/100 \n",
      "xbcp=round(xbc*100/zb)/100 \n",
      "xcdp=round(xcd*100/zb)/100 \n",
      "xdap=round(xda*100/zb)/100  #reactance in per unit between bus\n",
      "def del2star(d12,d23,d31):\n",
      "    dsum=d12+d23+d31\n",
      "    s1=d12*d31/(dsum)\n",
      "    s2=d12*d23/(dsum)\n",
      "    s3=d31*d23/dsum\n",
      "    return [s1,s2,s3]\n",
      "def star2del(s1,s2,s3):\n",
      "    d12=s1+s2+(s1*s2)/s3\n",
      "    d23=s2+s3+(s2*s3)/s1\n",
      "    d31=s3+s1+(s3*s1)/s2\n",
      "    return [d12,d31,d23]\n",
      "[xac,xrc,xra]=star2del(xcdp,xdap,xdp)\n",
      "rc=xrc*xcp/(xrc+xcp)\n",
      "ra=xra*xap/(xra+xap)\n",
      "[xpr,xpc,xpa]=del2star(xac,rc,ra)\n",
      "xf1=xbcp+xpc\n",
      "xf2=xpr+xabp\n",
      "xf=xf1*xf2/(xf1+xf2)\n",
      "xfr=xf+xpa\n",
      "xx=xfr*xbp/(xfr+xbp)\n",
      "netr=xx #net reactance\n",
      "fkva=pb*1000/xx\n",
      "print \"the rating of circuit breaker should be %d KVA, or %d MVA\"%(fkva,fkva/1000)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the rating of circuit breaker should be 671200 KVA, or 671 MVA\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "example 13_6 Page 285"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "p=150 #given ,power\n",
      "v=11 #given voltage\n",
      "xg=0.12 #reactance of generator\n",
      "xb=0.08 #reactance of line\n",
      "scca=1/xg\n",
      "ms=scca**2\n",
      "sccb=1/(xg+xb)\n",
      "ms1=sccb**2\n",
      "print 'a'\n",
      "print \"short circuit current is %.3fp.u \\n ratio of mechanical stress on short circuit to aech. stresses on full load %.2f\"%(scca,ms)\n",
      "print 'b'\n",
      "print \"short circuit current is with reactor %.3fp.u \\n ratio of mechanical stress on short circuit to aech. stresses on full load with reactor %.f\"%(sccb,ms1)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "a\n",
        "short circuit current is 8.333p.u \n",
        " ratio of mechanical stress on short circuit to aech. stresses on full load 69.44\n",
        "b\n",
        "short circuit current is with reactor 5.000p.u \n",
        " ratio of mechanical stress on short circuit to aech. stresses on full load with reactor 25\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "example13_7 Page 286"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import acos, pi, sin, cos, atan\n",
      "xf=complex(0,0.04)\n",
      "pf=0.8 ;ph=acos(pf)*180/pi\n",
      "v=1 ;i=1 #let v and i\n",
      "vb=v+i*xf*(complex(cos(ph*pi/180),-sin(ph*pi/180)))\n",
      "iv=vb-abs(v) \n",
      "print \"bus bar voltage %.4f.p.u at angle %.1f\\nincrease in voltage %.4f =%.4f percent\"%(abs(vb),atan(vb.imag/vb.real)*180/pi,abs(iv),abs(iv*100))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "bus bar voltage 1.0245.p.u at angle 1.8\n",
        "increase in voltage 0.0400 =4.0000 percent\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "example 13.8 page 286"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "p1=30 ;x1=0.3 #power and reactance of different sets\n",
      "p2=30 ;x2=0.3\n",
      "p3=20 ;x3=0.3\n",
      "l=10  ;xl=0.04\n",
      "pb=p1 ;xp3=x3*pb/p3\n",
      "tr=(xp3*x1*x2)/(xp3*x1+xp3*x2+x1*x2)\n",
      "sc=pb/tr\n",
      "print 'a'\n",
      "print \"total reactance %.4f p.u \\n short circuit MVA on l.v.bus %.2fMVA\"%(tr,sc)\n",
      "print 'b'\n",
      "xlp=xl*pb/l\n",
      "trr=tr+xlp\n",
      "scc=pb/trr\n",
      "print \"total reactance seen from h.v.side of transformer %.2fp.u \\n short circuit MVA %.2fMVA\"%(trr,scc)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "a\n",
        "total reactance 0.1125 p.u \n",
        " short circuit MVA on l.v.bus 266.67MVA\n",
        "b\n",
        "total reactance seen from h.v.side of transformer 0.23p.u \n",
        " short circuit MVA 129.03MVA\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "example 13.9 Page 287"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "p1=30 ;x1=0.15; p2=10; x2=0.125 \n",
      "pt=10 ;vs=3.3 ;pm=100\n",
      "pb=p1 #let base as power of unit 1\n",
      "x22=x2*pb/p2; x11=x1*pb/p1\n",
      "xx=1/((1/x22)+(1/x11)+(1/x11))\n",
      "xl=(pb/pm)-xx\n",
      "xt2=xl*pt/pb\n",
      "bi=vs**2/pt\n",
      "xtt=xt2*bi\n",
      "print \" reactance of transformer is %.4f.p.u \\n reactance of transformer on %dMVA base is %.5fp.u. \\n reactance of transformer %.4fohm\"%(xl,pt,xl,xtt)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " reactance of transformer is -0.0625.p.u \n",
        " reactance of transformer on 10MVA base is -0.06250p.u. \n",
        " reactance of transformer -0.0227ohm\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "example 13.10 Page 287"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given #p=power/v=voltage/f=frequency/x=reactance/iff=feeder reactance take off\n",
      "pa=20 ;va=11 ;f=50 ;xa=0.2 ;pb=30 ;xb=0.2 ;pf=10 ;xf=0.06; iff=0.5\n",
      "pba=20 ;vba=11\n",
      "xap=xa*pba/pb\n",
      "xfp=xf*pba/pf\n",
      "nx=xfp+(xa/2)*(xa/2+xap)/(xa+xap)\n",
      "fcp=nx**(-1)\n",
      "bc=pba*1000/(va*sqrt(3))\n",
      "fc=fcp*bc\n",
      "print 'a'\n",
      "print \"fault current %.2fohm\"%(fc)\n",
      "ic=iff*fcp\n",
      "xtx=ic**(-1)\n",
      "xn=xtx-nx\n",
      "zb=va**2/pba\n",
      "xnn=xn*zb\n",
      "print 'b'\n",
      "print \"reactance required %.4fohm\"%(xnn)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "a\n",
        "fault current 5524.88ohm\n",
        "b\n",
        "reactance required 1.1400ohm\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "example 13 11 Page 288"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "n1=5 ;x=0.4 ;d=0.1; g=20  #given\n",
      "mva=(g/x)+(g*(n1-1)/(x+n1*d))\n",
      "n2=10  #given\n",
      "mva2=(g/x)+(g*(n2-1)/(x+n2*d))\n",
      "print 'a'\n",
      "print \"fault MVA =(g/x)+(g*(n-1)/(x+nd)) \\n fault level is to equal to fault MVA if n=infinity\"\n",
      "print 'b'\n",
      "print \" MVA=%.2fMVA if n=%d \\n MVA=%.2fMVA if n=%d\"%(mva,n1,mva2,n2)\n",
      "fl=g*((1/x)+(1/d))\n",
      "print 'c'\n",
      "print \"\\nfault level %dMVA\"%(fl)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "a\n",
        "fault MVA =(g/x)+(g*(n-1)/(x+nd)) \n",
        " fault level is to equal to fault MVA if n=infinity\n",
        "b\n",
        " MVA=138.89MVA if n=5 \n",
        " MVA=178.57MVA if n=10\n",
        "c\n",
        "\n",
        "fault level 250MVA\n"
       ]
      }
     ],
     "prompt_number": 11
    }
   ],
   "metadata": {}
  }
 ]
}