{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 08 : Synchronous Machines"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.2, Page No 148"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "#to determine voltage regulation by mmf method\n",
      "\n",
      "  \n",
      "pf=0.85 \n",
      "P=150*10**6 \n",
      "V=13*1000.0\n",
      "\n",
      "#Calculations\n",
      "Iarated=P/(math.sqrt(3)*pf*V) \n",
      "If=750 \n",
      "Ifocc=810 \n",
      "B=math.degrees(math.acos(pf))\n",
      "Ff=math.sqrt((Ifocc+If*math.sin(math.radians(B)))**2+(If*math.cos(math.radians(B)))**2) \n",
      "Ef=16.3*1000 \n",
      "vr=Ef/V-1\n",
      "\n",
      "#Results\n",
      "print(vr*100,'voltage regulation(%)') "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(25.384615384615383, 'voltage regulation(%)')\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.6, Page No 149"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "#to calculate the excitation emf\n",
      "\n",
      "  \n",
      "Vt=3300.0 \n",
      "Xs=18/3.0 \n",
      "pf=.707 \n",
      "P=800*1000 \n",
      "\n",
      "#Calculations\n",
      "Ia=P/(math.sqrt(3)*Vt*pf) \n",
      "a=Ia*Xs/math.sqrt(2) \n",
      "b=Vt/math.sqrt(3.0) \n",
      "Ef=math.sqrt((a+b)**2+a**2)*math.sqrt(3.0)\n",
      "\n",
      "#Results\n",
      "print(Ef,'excitation emf(V)(line)') "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(4972.3367904266, 'excitation emf(V)(line)')\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.7, Page No 149"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "\n",
      "#to compute the max power and torque,terminal voltage\n",
      "\n",
      "  \n",
      "V=3300.0 \n",
      "Vt=V/math.sqrt(3) \n",
      "P=1000*10**3 \n",
      "pf=1 \n",
      "Ia=P/(V*math.sqrt(3)*pf) \n",
      "Xsm=3.24 \n",
      "j=math.sqrt(1.0) \n",
      "Efm=Vt-j*Ia*Xsm \n",
      "Efg=abs(Efm) \n",
      "P_emax=3*Vt*Efg/Xsm \n",
      "print(P_emax,'max power(W)') \n",
      "p=24 \n",
      "f=50 \n",
      "\n",
      "#Calculations\n",
      "w_sm=(120*f*2*math.pi)/(p*60) \n",
      "Tmax=P_emax/w_sm \n",
      "print(Tmax,'torque(Nm)') \n",
      "\n",
      "Xsg=4.55 \n",
      "Efm=Vt-j*Ia*Xsg \n",
      "Efmm=abs(Efm) \n",
      "X=Xsm+Xsg \n",
      "P_emax=3*Efg*Efmm/X \n",
      "print(P_emax,'max power(W)') \n",
      "Tmax=P_emax/w_sm \n",
      "print(Tmax,'torque(Nm)') \n",
      "\n",
      "d=90 \n",
      "Efm=Efg*complex(math.cos(math.radians(0)),math.sin(math.radians(0))) \n",
      "Efg=Efmm*complex(math.cos(math.radians(0)),math.sin(math.radians(0)))\n",
      "Ia=(Efg-Efm)/(j*X) \n",
      "v=j*Ia*Xsm \n",
      "Vt=Efm+j*Ia*Xsm \n",
      "\n",
      "#Results\n",
      "print(abs(Vt)*math.sqrt(3),'line voltage(V)') \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(2361111.1111111115, 'max power(W)')\n",
        "(90187.80108540738, 'torque(Nm)')\n",
        "(571722.5941289428, 'max power(W)')\n",
        "(21838.194463906242, 'torque(Nm)')\n",
        "(2153.0750379274127, 'line voltage(V)')\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.8 Page No 150"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "#max power supplied, power angle d, corresponding field current\n",
      "\n",
      "  \n",
      "j=math.sqrt(1) \n",
      "r=100*10**6.0     #va\n",
      "V=11000.0 \n",
      "P=100*10**6 \n",
      "Ef=1     #pu\n",
      "Vth=1     #pu\n",
      "Xs=1.3     #pu\n",
      "Xth=.24     #pu\n",
      "\n",
      "#Calculations\n",
      "P_emax=Ef*Vth/(Xs+Xth) \n",
      "print(P_emax,'max power delivered(pu)') \n",
      "\n",
      "Pe=1 \n",
      "Vt=1 \n",
      "d=math.degrees(math.asin(Pe*Xth/(Vt*Vth)))\n",
      "print(d,'power angle') \n",
      "Vt=math.exp(j*d) \n",
      "Ia=(Vt-Vth)/(j*Xth) \n",
      "Ef=Vth+j*(Xs+Xth)*Ia \n",
      "Voc=11000 \n",
      "If=256 \n",
      "Ff=19150 \n",
      "Iff=If*Ff/Voc\n",
      "\n",
      "#Results\n",
      "print(Iff,'If(A)') \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(0.6493506493506493, 'max power delivered(pu)')\n",
        "(13.88654036262899, 'power angle')\n",
        "(445, 'If(A)')\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.9, Page No 152"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "#to calculate the generator current and its pf\n",
      "\n",
      "  \n",
      "j=math.sqrt(1) \n",
      "X=.24 \n",
      "r=400.0     #rating in MVA\n",
      "rr=600.0     #rating in MVA\n",
      "Pe=r/rr \n",
      "Vt=1 \n",
      "Vth=1 \n",
      "dl=math.degrees(math.asin(Pe*X/(Vt*Vth)))\n",
      "Ia=2*math.sin(math.radians(dl/2))/X \n",
      "V=24000 \n",
      "\n",
      "#Calculations\n",
      "IaB=(rr/3.0)*10**6/(V/math.sqrt(3.0)) \n",
      "Iaa=Ia*IaB \n",
      "print(Iaa,'generating current(A)') \n",
      "phi=dl/2.0 \n",
      "pf= math.cos(math.radians(phi))\n",
      "print(pf,'power factor') \n",
      "\n",
      "Pe=1 \n",
      "dl1=math.degrees(math.asin(Pe*X/(Vt*Vth)))\n",
      "Ia=2*math.sin(math.radians(dl1/2.0))/X \n",
      "Iaa=Ia*IaB \n",
      "print(Iaa,'generating current(A)') \n",
      "phi=dl1/2.0 \n",
      "pf= math.cos(math.radians(phi))\n",
      "print(pf,'power factor') \n",
      "Ef=Vt+j*Ia*(complex(math.cos(math.radians(-phi)),math.sin(math.radians(-phi))))*X \n",
      "Eff=abs(Ef)*V \n",
      "dl2=math.degrees(math.atan(Ef.imag/Ef.real))\n",
      "\n",
      "Xth=.24 \n",
      "Pe=abs(Ef)*Vth*math.sin(math.radians(dl1+dl2))/(X+Xth) \n",
      "\n",
      "#Results\n",
      "print(Pe,'Pe(pu)') "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(9653.646665937797, 'generating current(A)')\n",
        "(0.9967740502090344, 'power factor')\n",
        "(14540.391150848647, 'generating current(A)')\n",
        "(0.9926663306370695, 'power factor')\n",
        "(0.560889816748067, 'Pe(pu)')\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.10 Page No 163"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "#to calculate armature resistance, sync reactance, full load stray load loss, Rac/Rdc,various categories of losses at full load,full load eff\n",
      "\n",
      "  \n",
      "r=60*10**3.0 \n",
      "Psc=3950.0 \n",
      "Isc=108.0 \n",
      "\n",
      "#Calculations\n",
      "Raeff=Psc/(3*Isc**2) \n",
      "print(Raeff,'effective armature resistance(ohm)') \n",
      "V=400.0 \n",
      "Ifoc=2.85 \n",
      "Ifsc=1.21 \n",
      "I_SC=Isc*Ifoc/Ifsc \n",
      "Zs=(V/math.sqrt(3))/I_SC \n",
      "Xs=math.sqrt(Zs**2-Raeff**2) \n",
      "print(Xs,'sync reactance(ohm)') \n",
      "\n",
      "t1=25 \n",
      "t2=75 \n",
      "Rdc=0.075 \n",
      "Radc=Rdc*((273+t2)/(273+t1)) \n",
      "Iarated=r/(math.sqrt(3.0)*V) \n",
      "Pscc=Psc*(Iarated/Isc)**2 \n",
      "P=3*Iarated**2*Radc \n",
      "print(P,'armature loss(W)') \n",
      "loss=Pscc-P \n",
      "print(loss,'loss(W)') \n",
      "\n",
      "a=Raeff/Radc \n",
      "print(a,'Rac/Rdc') \n",
      "\n",
      "Pwf=900.0 \n",
      "print(Pwf,'windage and friction loss(W)') \n",
      "tloss=2440 \n",
      "closs=tloss-Pwf \n",
      "print(closs,'core loss(W)') \n",
      "If=3.1 \n",
      "Rf=110 \n",
      "Pcu=If**2*Rf \n",
      "print(Pcu,'field cu loss(W)') \n",
      "print(loss,'stray load loss(W)') \n",
      "b=loss+Pcu+closs+Pwf+P \n",
      "print(b,'total loss(W)') \n",
      "\n",
      "pf=0.8 \n",
      "op=r*pf \n",
      "ip=op+b \n",
      "eff=op/ip \n",
      "\n",
      "#Results\n",
      "print(eff,'efficiency') "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(0.11288294467306813, 'effective armature resistance(ohm)')\n",
        "(0.9008089329407498, 'sync reactance(ohm)')\n",
        "(1687.5, 'armature loss(W)')\n",
        "(852.3662551440325, 'loss(W)')\n",
        "(1.5051059289742417, 'Rac/Rdc')\n",
        "(900.0, 'windage and friction loss(W)')\n",
        "(1540.0, 'core loss(W)')\n",
        "(1057.1000000000001, 'field cu loss(W)')\n",
        "(852.3662551440325, 'stray load loss(W)')\n",
        "(6036.966255144032, 'total loss(W)')\n",
        "(0.8882808071304457, 'efficiency')\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.11, Page No 164"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "#to calculate net power op,eff,line current and pf\n",
      "\n",
      "  \n",
      "j=math.sqrt(1) \n",
      "Zs=(1.0/3)*(.3+j*6) \n",
      "phi=math.degrees(math.atan(Zs.imag/Zs.real))\n",
      "Vt=400.0/math.sqrt(3.0) \n",
      "Ef=600.0/math.sqrt(3.0) \n",
      "a=math.sqrt(Vt**2+Ef**2-2*Vt*Ef*math.cos(math.radians(phi))) \n",
      "Ia=a/abs(Zs) \n",
      "\n",
      "#Calculations\n",
      "print(Ia,'line current(A)') \n",
      "B=math.degrees(math.acos((Vt**2+a**2-Ef**2)/(2*Vt*a)))\n",
      "phi=90-(90-math.degrees(math.atan(Zs.imag/Zs.real)))-B \n",
      "print(math.cos(math.radians(phi)),'pf') \n",
      "Pein=Vt*Ia*math.cos(math.radians(phi)) \n",
      "Ra=.1 \n",
      "b=Ia**2*Ra \n",
      "loss=2400 \n",
      "Pmout=Pein-loss/3.0-b \n",
      "\n",
      "#Results\n",
      "print(Pmout,'net power op(W)') \n",
      "eff=Pmout/Pein \n",
      "print(eff*100,'efficiency(%)') "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(54.98573992282153, 'line current(A)')\n",
        "(-0.9999999999999998, 'pf')\n",
        "(-13800.755857898721, 'net power op(W)')\n",
        "(108.68095238095239, 'efficiency(%)')\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.12 Page No 165"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "#to find pf\n",
      "\n",
      "  \n",
      "j=math.sqrt(1) \n",
      "Zs=.8+j*5 \n",
      "Vt=3300.0/math.sqrt(3) \n",
      "Pein=800*10**3.0/3     #per ph\n",
      "pf=.8 \n",
      "Qe=-Pein*math.tan(math.radians(math.degrees(math.acos(pf))))\n",
      "#a=Ef*math.cos(math.radians(dl-a))\n",
      "#b=Ef=math.cos(math.radians(dl-a))\n",
      "\n",
      "#Calculations\n",
      "a=((abs(Zs)/Vt)*(Pein-Zs.real*(Vt/abs(Zs))**2)) \n",
      "b=((abs(Zs)/Vt)*(-Qe+(Zs.imag)*(Vt/abs(Zs))**2)) \n",
      "\n",
      "Ef=math.sqrt(a**2+b**2) \n",
      "\n",
      "Pein=(1200.0/3)*1000 \n",
      "a=math.degrees(math.asin((abs(Zs)/(Vt*Ef))*(Pein-pf*(Vt/abs(Zs))**2)))\n",
      "Qe=(Zs.imag)*(Vt/abs(Zs))**2-Ef*Vt*math.cos(math.radians(a))/abs(Zs) \n",
      "pf=math.cos(math.radians(math.degrees(math.atan(Qe/Pein))))\n",
      "\n",
      "#Results\n",
      "print(pf,'pf') d"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(0.8329179992811746, 'pf')\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.13 Page No 165"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#to determine excitation emf, torque angle,stator current, pf, max power, kVAR delivered\n",
      "\n",
      "  \n",
      "j=math.sqrt(1) \n",
      "P=10000.0 \n",
      "V=400.0 \n",
      "Ia=P/(math.sqrt(3)*V) \n",
      "pf=.8 \n",
      "phi=math.degrees(math.acos(pf))\n",
      "Iaa=Ia*complex(math.cos(math.radians(-phi)),math.sin(math.radians(-phi))) \n",
      "Vt=V/math.sqrt(3.0) \n",
      "X=16 \n",
      "Ef=Vt+j*X*Iaa \n",
      "print(abs(Ef),'excitation emf(V)') \n",
      "dl=math.degrees(math.atan(Ef.imag/Ef.real))\n",
      "print(dl,'torque angle') \n",
      "\n",
      "#Calculations\n",
      "Pe=P*pf \n",
      "Eff=abs(Ef)*1.2 \n",
      "dl=(Pe/3)*X/(Eff*Vt) \n",
      "ta=math.degrees(math.asin(dl))\n",
      "print(ta,'torque angle') \n",
      "Ia=(Eff*complex(math.cos(math.radians(ta)),math.sin(math.radians(ta)))-Vt)/(j*X) \n",
      "print(abs(Ia),'stator current(A)') \n",
      "print(math.cos(math.radians(-math.degrees(math.atan(Ia.imag/Ia.real)))),'pf') \n",
      "\n",
      "Ef=413 \n",
      "Pemax=Ef*Vt/X \n",
      "Ia=(Ef*complex(math.cos(math.radians(90)),math.sin(math.radians(90)))-Vt)/(j*X) \n",
      "print(abs(Ia),'stator current(A)') \n",
      "print(math.cos(math.radians(-math.degrees(math.atan(Ia.imag/Ia.real)))),'pf') \n",
      "\n",
      "Qe=((Ia.imag)/(Ia.real))*Pe \n",
      "\n",
      "#Results\n",
      "print(Qe,'kVar delivered') "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(438.17804600413285, 'excitation emf(V)')\n",
        "(-18.434948822922003, 'torque angle')\n",
        "(20.570777448577868, 'torque angle')\n",
        "(20.003478706674613, 'stator current(A)')\n",
        "(0.8165675681224028, 'pf')\n",
        "(29.57394950937959, 'stator current(A)')\n",
        "(0.48805644728523245, 'pf')\n",
        "(-14306.739670518926, 'kVar delivered')\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.14 Page No 172"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "#to calculate armature current, pf ,power angle, power , shaft torques,kVar\n",
      "\n",
      "j=math.sqrt(1) \n",
      "P=8000.0 \n",
      "Prot=500.0 \n",
      "Pmg=P+Prot \n",
      "Pein=Pmg \n",
      "Ef=750.0/math.sqrt(3) \n",
      "Vt=231 \n",
      "Xs=16.0 \n",
      "dl=math.degrees(math.asin(Xs*(Pein/3)/(Ef*Vt)))\n",
      "Eff=Ef*complex(math.cos(math.radians(-dl)),math.sin(math.radians(-dl))) \n",
      "Ia=(Vt-Eff)/(j*Xs) \n",
      "\n",
      "#Calculations\n",
      "print(abs(Ia),'armature current(A)') \n",
      "print(math.cos(math.radians(-math.degrees(math.atan(Ia.imag/Ia.real)))),'pf') \n",
      "f=50 \n",
      "p=4 \n",
      "n_s=120*f/p \n",
      "w_s=2*math.pi*n_s/60 \n",
      "T=Pein/w_s \n",
      "print(T,'torque developed(Nm)') \n",
      "T_s=P/w_s \n",
      "print(T_s,'shaft torques(Nm)') \n",
      "\n",
      "Ef=600/math.sqrt(3) \n",
      "Ia=(Vt-Ef)/(j*Xs) \n",
      "rr=3*Vt*Ia/1000 \n",
      "print(rr,'kVar rating') \n",
      "c=(abs(Ia)/Vt)/(2*math.pi*f) \n",
      "print(-c,'capicator rating(F)') \n",
      "\n",
      "Ef=300/math.sqrt(3) \n",
      "Ia=(Vt-Ef)/(j*Xs) \n",
      "rr=3*Vt*Ia/1000 \n",
      "print(-rr,'kVar rating') \n",
      "L=(Vt/abs(rr))/(2*math.pi*f) \n",
      "print(L,'inductor rating(H)') \n",
      "\n",
      "Ia=j*2000/Vt \n",
      "Ef=Vt-j*Ia*Xs \n",
      "\n",
      "#Results\n",
      "print(abs(Ef)*math.sqrt(3),'excitation(V)') "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(15.629324184839682, 'armature current(A)')\n",
        "(0.6197800073964136, 'pf')\n",
        "(54.11268065124441, 'torque developed(Nm)')\n",
        "(50.929581789406505, 'shaft torques(Nm)')\n",
        "(-4.998702620565402, 'kVar rating')\n",
        "(-9.939446800839497e-05, 'capicator rating(F)')\n",
        "(-2.503242439717299, 'kVar rating')\n",
        "(0.2937373645549075, 'inductor rating(H)')\n",
        "(160.16596233973502, 'excitation(V)')\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.15, Page No 176"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "#find the excitation emf,mech power developed,pf\n",
      "\n",
      "j=math.sqrt(1) \n",
      "V=6600.0 \n",
      "Vt=V/math.sqrt(3) \n",
      "r=4*10.0**6 \n",
      "Ia=r/(math.sqrt(3)*V) \n",
      "Xs=4.8 \n",
      "#Vt**2+Ef**2-2*Vt*Efcosd(dl)=(Ia*Xs)**2\n",
      "#after solving\n",
      "#Ef**2-7.16*Ef+11.69=0 \n",
      "def quad(a,b,c):\n",
      "    d=math.sqrt(b**2-4*a*c) \n",
      "    x1=(-b+d)/(2*a) \n",
      "    x2=(-b-d)/(2*a) \n",
      "    return x1,x2\n",
      "\n",
      "Ef=[0,0]\n",
      "\n",
      "#Calculations\n",
      "Ef=quad(1,-7.16,11.69) \n",
      "dl=20.0\n",
      "print(Ef[0],'excitation(kV)') \n",
      "Pm=3*3.81*Ef[0]*math.sin(math.radians(dl))/Xs \n",
      "print(Pm,'power developed(MW)') \n",
      "pf1=Pm*10**6/(math.sqrt(3)*V*Ia) \n",
      "print(pf1,'pf1') \n",
      "\n",
      "print(Ef[1],'excitation(kV)') \n",
      "Pm=3*3.81*Ef[1]*math.sin(math.radians(dl))/Xs \n",
      "print(Pm,'power developed(MW)') \n",
      "pf2=Pm*10**6/(math.sqrt(3)*V*Ia) \n",
      "\n",
      "#Results\n",
      "print(pf2,'pf2') \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(4.641319932913728, 'excitation(kV)')\n",
        "(3.780055563783382, 'power developed(MW)')\n",
        "(0.9450138909458456, 'pf1')\n",
        "(2.518680067086272, 'excitation(kV)')\n",
        "(2.0513023748834374, 'power developed(MW)')\n",
        "(0.5128255937208593, 'pf2')\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.16, Page No 186"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "#to find power angle,field current\n",
      "j=math.sqrt(1.0) \n",
      "V=400 \n",
      "Vt=V/math.sqrt(3.0) \n",
      "pf=1.0 \n",
      "Ia=50.0 \n",
      "Xs=1.3 \n",
      "\n",
      "#Calculations\n",
      "Ef=Vt-j*Ia*Xs \n",
      "print(-math.degrees(math.atan(Ef.imag/Ef.real)),'power angle') \n",
      "\n",
      "Pm=Vt*Ia*pf \n",
      "pff=.8 \n",
      "Ia=Pm/(Vt*pff) \n",
      "ang=math.degrees(math.acos(pff))\n",
      "Eff=math.sqrt((Vt*math.cos(math.radians(ang)))**2+(Vt*math.cos(math.radians(ang))+Ia*Xs)**2) \n",
      "If=.9 \n",
      "Iff=If*Eff/abs(Ef)\n",
      "\n",
      "#Results\n",
      "print(Iff,'field current(A)') "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(-0.0, 'power angle')\n",
        "(1.7565442792743275, 'field current(A)')\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.17, Page No 187"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "#to calculate motor eff,excitation emf and power angle, max power op,corresponding net op\n",
      "\n",
      "  \n",
      "j=math.sqrt(1.0) \n",
      "Sop=40*1000.0 \n",
      "Vt=600.0 \n",
      "Ra=0.8 \n",
      "Xs=8 \n",
      "\n",
      "Pst=2000.0 \n",
      "Pmnet=30*1000.0 \n",
      "Pm_dev=Pst+Pmnet \n",
      "Ia=Sop/(math.sqrt(3)*Vt) \n",
      "Poh=3*Ia**2*Ra \n",
      "Pin=Pm_dev+Poh \n",
      "eff=(1-(Poh+Pst)/Pin)*100 \n",
      "print(eff,'motor eff(%)') \n",
      "\n",
      "#Calculations\n",
      "cos_phi=Pin/(math.sqrt(3.0)*Vt*Ia) \n",
      "phi=math.degrees(math.acos(cos_phi))\n",
      "Ia=Ia*(math.cos(math.radians(phi))+j*math.sin(math.radians(phi))) \n",
      "Vt=Vt/math.sqrt(3.0) \n",
      "Za=Ra+Xs*j \n",
      "Ef=Vt-Ia*Za \n",
      "Ef_line=Ef*math.sqrt(3.0) \n",
      "print(Ef_line,'excitation emf(V)') \n",
      "delta=math.degrees(math.atan((Ef.imag)/(Ef.real)))\n",
      "print(delta,'power angle(deg)') \n",
      "IaRa=abs(Ia)*Ra \n",
      "IaXs=abs(Ia)*Xs \n",
      "AD=Vt*math.cos(math.radians(phi))-IaRa\n",
      "CD=Vt*math.cos(math.radians(phi))+abs(Ia)*Xs \n",
      "Ef_mag=math.sqrt((abs(AD))**2+(abs(CD))**2) \n",
      "\n",
      "Pm_out_gross=-((abs(Ef_mag))**2*Ra/(abs(Za))**2)+(Vt*abs(Ef_mag)/abs(Za))\n",
      "\n",
      "#Results\n",
      "print(Pm_out_gross,'max power op(W)') \n",
      "power_angle=math.degrees(math.atan((Za.imag)/(Za.real))) \n",
      "print(power_angle,'power angle(deg)') "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(84.375, 'motor eff(%)')\n",
        "(-190.24688522544741, 'excitation emf(V)')"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "(-0.0, 'power angle(deg)')\n",
        "(24191.612053989564, 'max power op(W)')\n",
        "(0.0, 'power angle(deg)')\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.18, Page No 197"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "#find the change in the poweer angle \n",
      "\n",
      "Pe=4000.0 \n",
      "V=400 \n",
      "pf=.8 \n",
      "\n",
      "#Calculations\n",
      "dl=math.degrees(math.acos(pf))\n",
      "Ia=Pe/(math.sqrt(3.0)*V*pf) \n",
      "Vt=V/math.sqrt(3.0) \n",
      "Xs=25 \n",
      "Ef=Vt+j*Ia*complex(math.cos(math.radians(-dl)),math.sin(math.radians(-dl)))*Xs \n",
      "a=math.degrees(math.atan((Ef.imag)/(Ef.real)))\n",
      "\n",
      "dl=math.degrees(math.asin((Pe/3)*Xs/(Vt*abs(Ef)))) \n",
      "ang=dl+a \n",
      "\n",
      "#Results\n",
      "print(ang,'change in power angle(deg)') "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(5.596898962201344, 'change in power angle(deg)')\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.19, Page No 198"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "#to find no of poles,MVA rating, prime mover rating and op torque\n",
      " \n",
      "f=50.0 \n",
      "n_s=100.0 \n",
      "P=120*f/n_s \n",
      "print(P,'no of poles') \n",
      "r=110     #MVA rating\n",
      "pf=.8 \n",
      "\n",
      "#Calculations\n",
      "rr=r/pf \n",
      "print(rr,'MVA rating') \n",
      "eff=.971 \n",
      "rt=r/eff \n",
      "print(rt,'prime mover rating(MW)') \n",
      "T_PM=rt*1000*60/(2*math.pi*n_s) \n",
      "\n",
      "#Results\n",
      "print(T_PM,'op torque(Nm)') "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(60.0, 'no of poles')\n",
        "(137.5, 'MVA rating')\n",
        "(113.28527291452112, 'prime mover rating(MW)')\n",
        "(10817.946698316264, 'op torque(Nm)')\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.20, Page No 198"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "# To calculate sec. line voltage, line current and output va\n",
      "\n",
      "print('(a)Y/D conn') \n",
      "V_LY=6600 \n",
      "V_PY=V_LY/math.sqrt(3) \n",
      "a=12 \n",
      "V_PD=V_PY/a \n",
      "V_LD=V_PD     \n",
      "print(V_LD,'sec line voltage(V)') \n",
      "\n",
      "#Calculations\n",
      "I_PY=10 \n",
      "I_PD=I_PY*a \n",
      "I_LD=I_PD*math.sqrt(3)     \n",
      "print(I_LD,'sec. line current(A)') \n",
      "r=math.sqrt(3)*V_LD*I_LD     \n",
      "print(r,'output rating(va)') \n",
      "\n",
      "print('(b)D/Y conn') \n",
      "I_LD=10 \n",
      "I_PD=I_LD/math.sqrt(3) \n",
      "I_LY=I_PD*a         \n",
      "print(I_LY,'sec. line current(A)') \n",
      "V_PD=6600 \n",
      "V_PY=V_PD/a \n",
      "V_LY=V_PY*math.sqrt(3)     \n",
      "print(V_LY,'sec line voltage(V)') \n",
      "r=math.sqrt(3)*V_LY*I_LY    \n",
      "\n",
      "#Results\n",
      "print(r,'output rating(va)') "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a)Y/D conn\n",
        "(317.5426480542942, 'sec line voltage(V)')\n",
        "(207.84609690826525, 'sec. line current(A)')\n",
        "(114315.3532995459, 'output rating(va)')\n",
        "(b)D/Y conn\n",
        "(69.2820323027551, 'sec. line current(A)')\n",
        "(952.6279441628825, 'sec line voltage(V)')\n",
        "(114315.3532995459, 'output rating(va)')\n"
       ]
      }
     ],
     "prompt_number": 19
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.21, Page No 223"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "#to determine armature current,pf,power angle,mech power developed and eff\n",
      "\n",
      "  \n",
      "j=math.sqrt(1.0) \n",
      "Vt=3300/math.sqrt(3.0) \n",
      "Ef=4270/math.sqrt(3.0) \n",
      "Pein=750000.0/3 \n",
      "Zs=.8+j*5.5 \n",
      "a=90-math.degrees(math.atan((Zs.imag)/(Zs.real)))\n",
      "dl=math.degrees(math.asin(Pein-(Zs.real)*(Vt/abs(Zs))**2)/((Vt*Ef/abs(Zs))))\n",
      "print(dl,'power angle(deg)') \n",
      "b=Vt-Ef*complex(math.cos(math.radians(-dl)),math.sin(math.radians(-dl))) \n",
      "Ia=b/Zs \n",
      "print(abs(Ia),'armature current(A)') \n",
      "phi=math.degrees(math.atan((Ia.imag)/(Ia.real)))\n",
      "print(math.cos(math.radians(phi)),'pf') \n",
      "Ef=math.sqrt(3)*Ef*complex(math.cos(math.radians(-dl)),math.sin(math.radians(-dl))) \n",
      "Pm=math.sqrt(3)*abs(Ef)*abs(Ia)*math.cos(math.radians(dl+phi))\n",
      "print(Pm,'mech power developed(W)') \n",
      "Pst=30000 \n",
      "Pmnet=Pm-Pst \n",
      "eff=Pmnet/(Pein*3)\n",
      "\n",
      "#Results\n",
      "print(eff*100,'efficiency(%)') "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "ename": "ValueError",
       "evalue": "math domain error",
       "output_type": "pyerr",
       "traceback": [
        "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mValueError\u001b[0m                                Traceback (most recent call last)",
        "\u001b[1;32m<ipython-input-6-af32ec64a4fb>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m     10\u001b[0m \u001b[0mZs\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m.8\u001b[0m\u001b[1;33m+\u001b[0m\u001b[0mj\u001b[0m\u001b[1;33m*\u001b[0m\u001b[1;36m5.5\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     11\u001b[0m \u001b[0ma\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m90\u001b[0m\u001b[1;33m-\u001b[0m\u001b[0mmath\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdegrees\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmath\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0matan\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mZs\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mimag\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m/\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mZs\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mreal\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 12\u001b[1;33m \u001b[0mdl\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mmath\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdegrees\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmath\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0masin\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mPein\u001b[0m\u001b[1;33m-\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mZs\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mreal\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m*\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mVt\u001b[0m\u001b[1;33m/\u001b[0m\u001b[0mabs\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mZs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m**\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m/\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mVt\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0mEf\u001b[0m\u001b[1;33m/\u001b[0m\u001b[0mabs\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mZs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m     13\u001b[0m \u001b[1;32mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdl\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;34m'power angle(deg)'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     14\u001b[0m \u001b[0mb\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mVt\u001b[0m\u001b[1;33m-\u001b[0m\u001b[0mEf\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0mcomplex\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmath\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcos\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmath\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mradians\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m-\u001b[0m\u001b[0mdl\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mmath\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msin\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmath\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mradians\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m-\u001b[0m\u001b[0mdl\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
        "\u001b[1;31mValueError\u001b[0m: math domain error"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.22, Page No 223"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "#to find armature current,power factor and power ip\n",
      "\n",
      "  \n",
      "j=math.sqrt(1.0) \n",
      "Vt=3300/math.sqrt(3.0) \n",
      "Ef=4270/math.sqrt(3.0) \n",
      "Pein=600000/3 \n",
      "Zs=.8+j*5.5 \n",
      "\n",
      "#Calculations\n",
      "a=90-math.degrees(math.atan((Zs.imag)/(Zs.real)))\n",
      "dl=math.degrees(math.asin((Pein+(Zs.real)*(Ef/abs(Zs))**2)/((Vt*Ef/abs(Zs))))-a )\n",
      "print(dl,'power angle') \n",
      "b=Vt-Ef*complex(math.cos(math.radians(-dl)),math.sin(math.radians(-dl)))\n",
      "Ia=b/Zs \n",
      "print(abs(Ia),'armature current(A)') \n",
      "phi=math.degrees(math.atan((Ia.imag)/(Ia.real)))\n",
      "print(math.cos(math.radians(phi)),'pf') \n",
      "\n",
      "Peinn=math.sqrt(3.0)*3300*abs(Ia)*math.cos(math.radians(phi))\n",
      "print(Peinn,'power ip(W)') \n",
      "loss=Peinn-Pein*3 \n",
      "\n",
      "#Results\n",
      "print(loss,'ohmic loss(W)') \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "ename": "ValueError",
       "evalue": "math domain error",
       "output_type": "pyerr",
       "traceback": [
        "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mValueError\u001b[0m                                Traceback (most recent call last)",
        "\u001b[1;32m<ipython-input-7-f2810ca219fa>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m     10\u001b[0m \u001b[0mZs\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m.8\u001b[0m\u001b[1;33m+\u001b[0m\u001b[0mj\u001b[0m\u001b[1;33m*\u001b[0m\u001b[1;36m5.5\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     11\u001b[0m \u001b[0ma\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m90\u001b[0m\u001b[1;33m-\u001b[0m\u001b[0mmath\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdegrees\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmath\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0matan\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mZs\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mimag\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m/\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mZs\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mreal\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 12\u001b[1;33m \u001b[0mdl\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mmath\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdegrees\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmath\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0masin\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mPein\u001b[0m\u001b[1;33m+\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mZs\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mreal\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m*\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mEf\u001b[0m\u001b[1;33m/\u001b[0m\u001b[0mabs\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mZs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m**\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m/\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mVt\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0mEf\u001b[0m\u001b[1;33m/\u001b[0m\u001b[0mabs\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mZs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m-\u001b[0m\u001b[0ma\u001b[0m \u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m     13\u001b[0m \u001b[1;32mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdl\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;34m'power angle'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     14\u001b[0m \u001b[0mb\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mVt\u001b[0m\u001b[1;33m-\u001b[0m\u001b[0mEf\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0mcomplex\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmath\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcos\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmath\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mradians\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m-\u001b[0m\u001b[0mdl\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mmath\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msin\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmath\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mradians\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m-\u001b[0m\u001b[0mdl\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
        "\u001b[1;31mValueError\u001b[0m: math domain error"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.23, Page No 231"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "#to calculate pu adjusted sync reactance, feild reactance, reactive power op, rotor power angle\n",
      "\n",
      "  \n",
      "j=math.sqrt(1.0) \n",
      "r=10*10**6 \n",
      "V_SC=13.8*10**3 \n",
      "Ia=r/(math.sqrt(3.0)*V_SC) \n",
      "If=226.0 \n",
      "\n",
      "\n",
      "#Calculations\n",
      "Iff=842.0 \n",
      "I_SC=Ia*Iff/If \n",
      "Xsadj=(V_SC/math.sqrt(3))/I_SC \n",
      "\n",
      "va_b=10*10**6 \n",
      "v_b=13800 \n",
      "Xspu=Xsadj*va_b/v_b**2 \n",
      "print(Xspu,'Xs(pu)') \n",
      "Ra=.75 \n",
      "Zs=Ra+j*Xsadj \n",
      "a=90-math.degrees(math.atan((Zs.imag)/(Zs.real))) \n",
      "\n",
      "pf=.9 \n",
      "phi=math.degrees(math.acos(pf)) \n",
      "Pe=8.75*10**6 \n",
      "Qe=Pe*math.tan(math.radians(phi)) \n",
      "Vt=V_SC/math.sqrt(3) \n",
      "Ia=(Pe/3.0)/(Vt*pf) \n",
      "Ef=Vt+abs(Ia)*abs(Zs)*complex(math.cos(math.radians(90-a-phi)),math.sin(math.radians(90-a-phi))) \n",
      "Ef=abs(Ef)*math.sqrt(3) \n",
      "If=Iff*Ef/V_SC \n",
      "print(If,'field current(A)') \n",
      "loss=3*abs(Ia)**2*Ra \n",
      "Pmin=Pe+loss \n",
      "print(Pmin,'reactive power op(W)') \n",
      "\n",
      "If=842 \n",
      "Voc=7968 \n",
      "Pmin=Pmin/3 \n",
      "dl=math.degrees(math.asin((Pmin-(Zs.real)*(Voc/abs(Zs))**2)/((Voc**2/abs(Zs)))))+a \n",
      "\n",
      "#Results\n",
      "print(dl,'power angle') \n",
      "Q=-(Voc/abs(Zs))**2*(Zs.imag)+Voc**2*math.cos(math.radians(dl+a))/abs(Zs) \n",
      "print(Q,'reactive power op(VAR)') "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(0.2684085510688836, 'Xs(pu)')\n",
        "(1074.3932057155528, 'field current(A)')\n",
        "(9122249.546858348, 'reactive power op(W)')\n",
        "(44.00614893481687, 'power angle')\n",
        "(-7524957.4047774, 'reactive power op(VAR)')\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.25, Page No 231"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "#to calculate the excitation emf,power angle\n",
      "\n",
      "  \n",
      "Vt=1.0\n",
      "Ia=1.0 \n",
      "pf=.8 \n",
      "phi=math.degrees(math.acos(pf)) \n",
      "Iaa=Ia*complex(math.cos(math.radians(-phi)),math.sin(math.radians(-phi))) \n",
      "Xq=.5 \n",
      "\n",
      "#Calculations\n",
      "j=math.sqrt(1) \n",
      "Ef=Vt+j*Iaa*Xq \n",
      "\n",
      "dl=17.1 \n",
      "w=phi+dl \n",
      "Id=Ia*math.sin(math.radians(w))\n",
      "Xd=.8 \n",
      "CD=Id*(Xd-Xq) \n",
      "Eff=abs(Ef)+CD \n",
      "Ef=Vt+j*Iaa*Xd \n",
      "\n",
      "#Results\n",
      "print(abs(Ef),'excitation emf(V)') \n",
      "print(math.degrees(math.atan((Ef.imag)/(Ef.real))),'power angle') "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(1.7088007490635064, 'excitation emf(V)')\n",
        "(-16.313852426260553, 'power angle')\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.26, Page No 231"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "#calculate excitation emf\n",
      "\n",
      "  \n",
      "V=3300.0 \n",
      "Vt=V/math.sqrt(3.0) \n",
      "pf=1 \n",
      "phi=math.degrees(math.acos(pf)) \n",
      "P=1500.0*1000 \n",
      "\n",
      "#Calculations\n",
      "Ia=P/(math.sqrt(3.0)*V*pf) \n",
      "Xq=2.88 \n",
      "Xd=4.01 \n",
      "w=math.degrees(math.atan((Vt*0-Ia*Xq)/Vt))\n",
      "dl=phi-w \n",
      "Id=Ia*math.sin(math.radians(w))\n",
      "Iq=Ia*math.cos(math.radians(w)) \n",
      "Ef=Vt*math.cos(math.radians(dl))-Id*Xd \n",
      "\n",
      "#Results\n",
      "print(Ef*math.sqrt(3.0),'excitation emf(line)(V)') "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(3739.5700468573696, 'excitation emf(line)(V)')\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.27, Page No 231"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "#to calculate generator terminal voltage,excitation emf,power angle\n",
      " \n",
      "Xd=1.48 \n",
      "Xq=1.24 \n",
      "Xe=.1 \n",
      "Xdt=Xd+Xe \n",
      "Xqt=Xq+Xe \n",
      "\n",
      "MVA=1 \n",
      "Vb=1 \n",
      "pf=.9 \n",
      "\n",
      "#Calculations\n",
      "phi=math.degrees(math.acos(pf))\n",
      "#(Vt*math.cos(math.radians(phi)))**2+(Vt*math.sin(math.radians(phi))+Ia*Xe)**2=Vb**2 \n",
      "#after solving\n",
      "#Vt**2-.0870*Vt-.99=0 \n",
      "def\tquad(a,b,c):\n",
      "    d=math.sqrt(b**2-4*a*c) \n",
      "    x1=(-b+d)/(2*a) \n",
      "    x2=(-b-d)/(2*a) \n",
      "    if x1 < Vb :\n",
      "        x=x2\n",
      "    else :\n",
      "        x=x1 \n",
      "\treturn x\n",
      "Vt=quad(1,-.0870,-.99) \n",
      "print(Vt,'terminal voltage(V)') \n",
      "#after solving\n",
      "phi=20 \n",
      "\n",
      "j=math.sqrt(1) \n",
      "Ia=1 \n",
      "Iaa=Ia*complex(math.cos(math.radians(-phi)),math.sin(math.radians(-phi))) \n",
      "Ef=Vb+j*Iaa*Xqt \n",
      "Eff=abs(Ef) \n",
      "dl=math.degrees(math.atan((Ef.imag)/(Ef.real)))\n",
      "print(dl,'power angle') \n",
      "w=dl+phi \n",
      "Id=Ia*math.sin(math.radians(w)) \n",
      "Ef=Ef+Id*(Xdt-Xqt) \n",
      "\n",
      "#Results\n",
      "print(abs(Ef),'excitation emf(V)') "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(1.0394378745684894, 'terminal voltage(V)')\n",
        "(-11.46760596259884, 'power angle')\n",
        "(2.34011465088481, 'excitation emf(V)')\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.28, Page No 231"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "#to find max pu power, pu armature current, pu reactive power\n",
      "\n",
      "  \n",
      "Vt=1 \n",
      "Xd=1.02 \n",
      "Xq=.68 \n",
      "Pmmax=Vt**2*(Xd-Xq)/(2*Xd*Xq) \n",
      "print(Pmmax,'max pu power') \n",
      "dl=.5*math.degrees(math.asin(Pmmax/(Vt**2*(Xd-Xq)/(2*Xd*Xq)))) \n",
      "\n",
      "#Calculations\n",
      "Id=Vt*math.cos(math.radians(dl))/Xd \n",
      "Iq=Vt*math.cos(math.radians(dl))/Xq \n",
      "Ia=math.sqrt(Id**2+Iq**2) \n",
      "print(Ia,'armature current(pu)') \n",
      "\n",
      "Qe=Id*Vt*math.cos(math.radians(dl))+Iq*Vt*math.sin(math.radians(dl)) \n",
      "print(Qe,'reactive power(pu)') \n",
      "\n",
      "pf=math.cos(math.radians(math.degrees(math.atan(Qe/Pmmax))))\n",
      "\n",
      "#Results\n",
      "print(pf,'pf') "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(0.2450980392156862, 'max pu power')\n",
        "(1.249759684704114, 'armature current(pu)')\n",
        "(1.2254901960784315, 'reactive power(pu)')\n",
        "(0.196116135138184, 'pf')\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.29, Page No 231"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "#to calculate power angle,excitation emf,field current\n",
      "j=math.sqrt(1.0) \n",
      "MVA_b=300.0 \n",
      "kV_b=22.0 \n",
      "\n",
      "Pe=250.0/MVA_b \n",
      "pf=.85 \n",
      "Vt=1 \n",
      "\n",
      "#Calculations\n",
      "Ia=Pe/(pf*Vt) \n",
      "phi=math.degrees(math.acos(pf))\n",
      "Iaa=Ia*complex(math.cos(math.radians(-phi)),math.sin(math.radians(-phi))) \n",
      "Xq=1.16 \n",
      "Xd=1.93 \n",
      "Ef=Vt+j*Iaa*Xq \n",
      "dl=math.degrees(math.atan((Ef.imag)/(Ef.real)))\n",
      "print(dl,'power angle') \n",
      "w=phi+dl \n",
      "Id=abs(Iaa)*math.sin(math.radians(w)) \n",
      "Ef=abs(Ef)+Id*(Xd-Xq) \n",
      "print(Ef*kV_b,'excitation emf(V)') \n",
      "\n",
      "If=338.0 \n",
      "If=If*Ef/1 \n",
      "\n",
      "#Results\n",
      "print(If,'field current(A)') "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(-16.941789546757967, 'power angle')\n",
        "(49.48501576455793, 'excitation emf(V)')\n",
        "(760.2697876554809, 'field current(A)')\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.30, Page No 231"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "#to find max andmin pu field excitation\n",
      "\n",
      "  \n",
      "Xd=.71 \n",
      "Xq=.58 \n",
      "Xe=.08 \n",
      "Xdt=Xd+Xe \n",
      "Xqt=Xq+Xe \n",
      "\n",
      "#Calculations\n",
      "Pe=0 \n",
      "Vt=1 \n",
      "dl=0 \n",
      "phi=90 \n",
      "Ia=1 \n",
      "Iq=0 \n",
      "Id=Ia \n",
      "\n",
      "Ef=Vt+Id*Xdt \n",
      "Ifmax=Ef \n",
      "print(Ifmax,'max field excitation(A)') \n",
      "\n",
      "\n",
      "Ef=Vt-Id*Xdt \n",
      "Ifmin=Ef \n",
      "\n",
      "#Results\n",
      "print(Ifmin,'min field excitation(A)') "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(1.79, 'max field excitation(A)')\n",
        "(0.21000000000000008, 'min field excitation(A)')\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.31, Page No 231"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "#to calculate synchronising power and torque coeff/deg mech shift\n",
      "\n",
      "  \n",
      "V=11000.0\n",
      "Vt=V/math.sqrt(3) \n",
      "P=6*10**6.0 \n",
      "\n",
      "#Calculations\n",
      "Ia=P/(math.sqrt(3)*V) \n",
      "ohm_b=Vt/Ia \n",
      "Xs=.5 \n",
      "Xss=Xs*ohm_b \n",
      "\n",
      "f=50.0 \n",
      "P=8.0 \n",
      "n_s=(120*f/P)*(2*math.pi/60) \n",
      "\n",
      "Ef=Vt \n",
      "dl=0 \n",
      "Psyn=(math.pi/15)*(Ef*Vt/Xss)*math.cos(math.radians(dl))\n",
      "print(Psyn,'synchronising power(W)') \n",
      "Tsyn=Psyn/n_s \n",
      "print(Tsyn,'torque coeff(Nm)') \n",
      "\n",
      "pf=.8 \n",
      "phi=math.degrees(math.acos(pf)) \n",
      "Ef=Vt+j*Ia*Xss*complex(math.cos(math.radians(-phi)),math.sin(math.radians(-phi))) \n",
      "dl=math.degrees(math.atan((Ef.imag)/(Ef.real)))\n",
      "Psyn=(math.pi/15)*(abs(Ef)*Vt/Xss)*math.cos(math.radians(dl)) \n",
      "\n",
      "#Results\n",
      "print(Psyn,'synchronising power(W)') \n",
      "Tsyn=Psyn/n_s \n",
      "print(Tsyn,'torque coeff(Nm)') "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(837758.0409572781, 'synchronising power(W)')\n",
        "(10666.666666666666, 'torque coeff(Nm)')\n",
        "(1172861.257340189, 'synchronising power(W)')\n",
        "(14933.333333333328, 'torque coeff(Nm)')\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.32, Page No 231"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#to calculate syncronising power/elec deg,pu sync torque/mech deg\n",
      " \n",
      "j=math.sqrt(1.0) \n",
      "Xd=.8 \n",
      "Xq=.5 \n",
      "Vt=1 \n",
      "pf=.8 \n",
      "phi=math.degrees(math.acos(pf))\n",
      "Ia=1*complex(math.cos(math.radians(phi)),math.sin(math.radians(phi))) \n",
      "\n",
      "Ef=Vt-j*Ia*Xq \n",
      "Eff=abs(Ef) \n",
      "\n",
      "#Calculations\n",
      "dl=math.degrees(math.atan((Ef.imag)/(Ef.real))) \n",
      "w=-dl+phi \n",
      "Id=abs(Ia)*math.sin(math.radians(w))\n",
      "Ef=Eff+Id*(Xd-Xq) \n",
      "\n",
      "Psyn=abs(Ef)*Vt*math.cos(math.radians(dl))/Xd+Vt**2*((Xd-Xq)/(Xd*Xq))*math.cos(math.radians(2*dl))\n",
      "print(Psyn*(math.pi/180),'syncronising power(pu)/elec deg') \n",
      "f=50 \n",
      "P=12 \n",
      "n_s=(120*f/P)*(2*math.pi/60) \n",
      "Tsyn=Psyn/n_s \n",
      "\n",
      "#Results\n",
      "print(Tsyn,'pu sync torque/mech deg') \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(0.02617993877991495, 'syncronising power(pu)/elec deg')\n",
        "(0.028647889756541166, 'pu sync torque/mech deg')\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.33, Page No 231"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#to calculate sync current, power and torque\n",
      "\n",
      "  \n",
      "j=math.sqrt(1.0) \n",
      "P=12000.0 \n",
      "V=400.0 \n",
      "pf=.8 \n",
      "Ia=P/(math.sqrt(3)*V*pf) \n",
      "phi=math.degrees(math.acos(pf))\n",
      "Vt=V/math.sqrt(3) \n",
      "Xs=2.5 \n",
      "\n",
      "#Calculations\n",
      "Ef=Vt-j*Ia*complex(math.cos(math.radians(phi)),math.sin(math.radians(phi)))*Xs \n",
      "tandl=4 \n",
      "Es=2*abs(Ef)*math.cos(math.radians(tandl/2)) \n",
      "Is=Es/Xs \n",
      "print(Is,'sync current(A)') \n",
      "dl=math.degrees(math.atan((Ef.imag)/(Ef.real)))\n",
      "Ps=3*Vt*Is*math.cos(dl+tandl/2)\n",
      "print(Ps,'power(W)') \n",
      "n_s=25*math.pi \n",
      "T_s=Ps/n_s \n",
      "\n",
      "#Results\n",
      "print(T_s,'torque(Nm)') "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(152.2500120412367, 'sync current(A)')\n",
        "(3657.484067729796, 'power(W)')\n",
        "(46.568533492723965, 'torque(Nm)')\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.34, Page No 231"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "#to calculate value of syncpower\n",
      "\n",
      "  \n",
      "V=6600.0\n",
      "E=V/math.sqrt(3.0) \n",
      "\n",
      "P=12.0 \n",
      "dl=1.0*P/2 \n",
      "\n",
      "#Calculations\n",
      "r=20000.0*10**3 \n",
      "I=r/(math.sqrt(3.0)*V) \n",
      "Xs=1.65 \n",
      "\n",
      "Psy=dl*(math.pi/180.0)*E**2/Xs \n",
      "\n",
      "#Results\n",
      "print(Psy,'sync power(W)') \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(921533.8450530063, 'sync power(W)')\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.35, Page No 231"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "#to determine op current and pf\n",
      "\n",
      "  \n",
      "P1=400.0*10**3 \n",
      "P2=400.0*10**3 \n",
      "P3=300.0*10**3 \n",
      "P4=800.0*10**3 \n",
      "pf1=1 \n",
      "pf2=.85 \n",
      "pf3=.8 \n",
      "pf4=.7 \n",
      "\n",
      "#Calculations\n",
      "phi1=math.degrees(math.acos(pf1))\n",
      "phi2=math.degrees(math.acos(pf2)) \n",
      "phi3=math.degrees(math.acos(pf3)) \n",
      "phi4=math.degrees(math.acos(pf4))\n",
      "P=P1+P2+P3+P4 \n",
      "Q1=P1*math.tan(math.radians(phi1))\n",
      "Q2=P2*math.tan(math.radians(phi2)) \n",
      "Q3=P3*math.tan(math.radians(phi3))\n",
      "Q4=P4*math.tan(math.radians(phi4)) \n",
      "Q=Q1+Q2+Q3+Q4 \n",
      "\n",
      "I=100 \n",
      "pf=.9 \n",
      "V=6600.0 \n",
      "P_A=math.sqrt(3)*V*I*pf \n",
      "P_B=P-P_A \n",
      "Q_A=P_A*math.tan(math.radians(math.degrees(math.acos(pf))) )\n",
      "Q_B=Q-Q_A \n",
      "phi=math.degrees(math.acos(Q_B/P_B))\n",
      "pf=math.cos(math.radians(phi))\n",
      "print(pf,'pf') \n",
      "I_B=P_B/(math.sqrt(3.0)*pf*V) \n",
      "\n",
      "#Results\n",
      "print(I_B,'op current(A)') "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(0.9077210377902825, 'pf')\n",
        "(83.9540921749662, 'op current(A)')\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.36, Page No 231"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "#to find the pf and current supplied by the m/c\n",
      "\n",
      "P=50000.0\n",
      "pf=.8 \n",
      "phi=math.degrees(math.acos(pf))\n",
      "Q=P*math.cos(math.radians(phi)) \n",
      "P1=P/2 \n",
      "pf1=.9 \n",
      "\n",
      "#Calculations\n",
      "phi1=math.degrees(math.acos(pf1))\n",
      "Q1=P1*math.cos(math.radians(phi1)) \n",
      "P2=P/2 \n",
      "Q2=Q-Q1 \n",
      "phi2=math.degrees(math.atan(Q2/P2))\n",
      "pf=math.cos(math.radians(phi2)) \n",
      "print(pf,'pf') \n",
      "V_L=400.0\n",
      "I2=P2/(math.sqrt(3)*V_L*pf) \n",
      "\n",
      "#Results\n",
      "print(I2,'current supplied by m/c(A)') \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(0.8192319205190405, 'pf')\n",
        "(44.04661356638744, 'current supplied by m/c(A)')\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.37, Page No 231"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#to find initial current,current at the end of 2 cycles and at the end of 10s\n",
      "\n",
      "  \n",
      "Ef=1.0 \n",
      "Xd2=.2 \n",
      "I2=Ef/Xd2 \n",
      "r=100*10**6 \n",
      "V=22000.0 \n",
      "\n",
      "#Calculations\n",
      "I_b=r/(math.sqrt(3)*V) \n",
      "I2=I2*I_b \n",
      "print(I2,'initial current(A)') \n",
      "\n",
      "Xd1=.3 \n",
      "I1=Ef/Xd1 \n",
      "Xd=1 \n",
      "I=Ef/Xd \n",
      "\n",
      "tau_dw=0.03 \n",
      "tau_f=1 \n",
      "\n",
      "def I_sc(t):\n",
      "    a=(I2-I1)*math.exp(-t/tau_dw)+(I1-I)*math.exp(-t/tau_f)+1 \n",
      "    return a\n",
      "#2 cycles=0.04s\n",
      "\n",
      "#Results\n",
      "print(I_sc(.2867)*I_b,'current at the end of 2 cycles(A)') \n",
      "print(I_sc(10)*I_b,'current at the end of 10s(A)') \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(13121.597027036949, 'initial current(A)')\n",
        "(9656.315026038814, 'current at the end of 2 cycles(A)')\n",
        "(2624.5974078796426, 'current at the end of 10s(A)')\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.39, Page No 231"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "#to calculate sync reactance,voltage regulation,torque angle, ele power developed, voltage and kva rating\n",
      "\n",
      "  \n",
      "r=1000.0*10**3 \n",
      "V=6600.0 \n",
      "Ia=r/(math.sqrt(3.0)*V) \n",
      "pf=.75 \n",
      "\n",
      "#Calculations\n",
      "phi=-math.degrees(math.acos(pf))\n",
      "Vt=V/math.sqrt(3.0) \n",
      "Ef=11400.0/math.sqrt(3) \n",
      "#Ef*complex(cosd(dl),sind(dl))=Vt+j*Xs*Ia*complex(cosd(phi),sind(phi))\n",
      "#after solving\n",
      "#6.58*cosd(dl)=3.81+.058*Xs \n",
      "#6.58*sind(dl)=.0656*Xs \n",
      "#so after solving \n",
      "#cosd(dl-phi)=.434 \n",
      "dl=math.degrees(math.acos(0.434))+phi \n",
      "\n",
      "Xs=Ef*math.sin(math.radians(dl))/65.6 \n",
      "\n",
      "#Results\n",
      "print(Xs,'sync reactance(ohm)') \n",
      "vr=Ef*math.sqrt(3.0)/V-1 \n",
      "print(vr,'voltage regulation(%)') \n",
      "print(dl,'torque angle(deg)') \n",
      "P=3*Ef*Ia*math.cos(math.radians(dl-phi)) \n",
      "print(P,'ele power developed(W)') \n",
      "\n",
      "volr=V/math.sqrt(3) \n",
      "print(volr,'voltage rating(V)') \n",
      "ir=Ia*math.sqrt(3) \n",
      "print(ir,'current rating(A)') \n",
      "r=math.sqrt(3)*volr*ir \n",
      "print(r,'VA rating') \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(38.99116776362744, 'sync reactance(ohm)')\n",
        "(0.7272727272727273, 'voltage regulation(%)')\n",
        "(22.86869850821798, 'torque angle(deg)')\n",
        "(749636.3636363635, 'ele power developed(W)')\n",
        "(3810.5117766515305, 'voltage rating(V)')\n",
        "(151.5151515151515, 'current rating(A)')\n",
        "(999999.9999999999, 'VA rating')\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.40, Page No 231"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "#to determine m/c and pf\n",
      "\n",
      "  \n",
      "j=math.sqrt(1.0) \n",
      "P=230.0*10**6 \n",
      "V=22000.0 \n",
      "pf=1.0 \n",
      "\n",
      "#Calculations\n",
      "Ia=P/(math.sqrt(3)*V*pf) \n",
      "Vt=V/math.sqrt(3) \n",
      "Xs=1.2 \n",
      "Ef=Vt+j*Xs*Ia \n",
      "#if Ef is inc by 30%\n",
      "Ef=1.3*abs(Ef) \n",
      "\n",
      "dl=math.degrees(math.asin((P/3.0)*Xs/(Ef*Vt)))\n",
      "Ia=((Ef*complex(math.cos(math.radians(dl)),math.sin(math.radians(dl))))-Vt)/(j*Xs) \n",
      "print(abs(Ia),'m/c current(A)') \n",
      "print(math.cos(math.radians(math.degrees(math.atan((Ia.imag)/(Ia.real))))),'pf') \n",
      "P=275*10**6 \n",
      "dl=math.degrees(math.asin((P/3.0)*Xs/(Ef*Vt)))\n",
      "Ia=((Ef*complex(math.cos(math.radians(dl)),math.sin(math.radians(dl))))-Vt)/(j*Xs) \n",
      "\n",
      "#Results\n",
      "print(abs(Ia),'m/c current(A)') \n",
      "print(math.cos(math.radians(math.degrees(math.atan((Ia.imag)/(Ia.real))))),'pf') \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(11819.373430797657, 'm/c current(A)')\n",
        "(0.8597700086643913, 'pf')\n",
        "(12155.509739365927, 'm/c current(A)')\n",
        "(0.8046772266804496, 'pf')\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.41, Page No 231"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#to calculate excitation emf,torque angle, eff, shaft op\n",
      "import math\n",
      "#initialisation of variables\n",
      "  \n",
      "j=math.sqrt(1.0) \n",
      "Va=.8 \n",
      "Xa=5.5 \n",
      "Xs=Va+j*Xa \n",
      "V=3300.0 \n",
      "Ia=160.0 \n",
      "pf=.8 \n",
      "loss=30000.0\n",
      "\n",
      "#Calculations\n",
      "phi=math.degrees(math.acos(pf))\n",
      "Ef=V/math.sqrt(3.0)-Xs*Ia*complex(math.cos(math.radians(-phi)),math.sin(math.radians(-phi)))\n",
      "print(abs(Ef),'excitation emf(V)') \n",
      "dl=math.degrees(math.atan((Ef.imag)/(Ef.real)))\n",
      "print(dl,'torque angle(deg)') \n",
      "P_mech=3*abs(Ef)*Ia*math.cos(math.radians(-phi-dl)) \n",
      "op_sft=P_mech-loss \n",
      "print(op_sft,'shaft op(W)') \n",
      "Pip=math.sqrt(3.0)*V*Ia*pf \n",
      "eff=op_sft/Pip\n",
      "\n",
      "#Results\n",
      "print(eff*100,'efficiency(%)') \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(1254.2995269504831, 'excitation emf(V)')\n",
        "(28.82797497778111, 'torque angle(deg)')\n",
        "(217778.26111709396, 'shaft op(W)')\n",
        "(29.76665191278476, 'efficiency(%)')\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.42, Page No 231"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#to caculate generator current,pf, real power,ecitation emf\n",
      "import math\n",
      "#initialisation of variables\n",
      "\n",
      "  \n",
      "r=500.0*10**6 \n",
      "V=22000 \n",
      "Ia=r/(math.sqrt(3.0)*V) \n",
      "print(Ia,'generator current(A)') \n",
      "Vt=V/math.sqrt(3.0) \n",
      "Zb=Vt/Ia \n",
      "MVA_b=500.0\n",
      "MW_b=500.0 \n",
      "Xsg=1.57 \n",
      "Xb=.4 \n",
      "Xb=Xb/Zb \n",
      "rr=250.0 \n",
      "rr=rr/MVA_b \n",
      "Vb=1 \n",
      "Vt=1 \n",
      "Ia=.5 \n",
      "\n",
      "#Calculations\n",
      "phi=math.degrees(math.asin(Xb*Ia/2))\n",
      "pf=math.cos(math.radians(phi))\n",
      "print(pf,'pf') \n",
      "Pe=rr*pf \n",
      "print(Pe,'real power(pu)') \n",
      "Eg=complex(Vt,Xsg*rr**complex(math.cos(math.radians(-phi)),math.sin(math.radians(-phi))))\n",
      "Egg=abs(Eg)*V \n",
      "print(Egg,'excitation emf(V)') \n",
      "\n",
      "\n",
      "rr=500.0 \n",
      "rr=rr/MVA_b \n",
      "Vb=1 \n",
      "Vt=1 \n",
      "Ia=1 \n",
      "phi=math.degrees(math.asin(Xb*Ia/2))\n",
      "pf=math.cos(math.radians(phi))\n",
      "print(pf,'pf') \n",
      "Pe=rr*pf \n",
      "print(Pe,'real power(pu)') \n",
      "Eg=complex(Vt,Xsg*rr**complex(math.cos(math.radians(-phi)),math.sin(math.radians(-phi))))\n",
      "Egg=abs(Eg)*V \n",
      "\n",
      "\n",
      "#Results\n",
      "print(Egg,'excitation emf(V)') "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(13121.597027036949, 'generator current(A)')\n",
        "(0.9946496442265089, 'pf')\n",
        "(0.49732482211325446, 'real power(pu)')\n",
        "(27016.768055398476, 'excitation emf(V)')\n",
        "(0.9784230470709913, 'pf')\n",
        "(0.9784230470709913, 'real power(pu)')\n",
        "(40951.33209066587, 'excitation emf(V)')\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.43, Page No 231"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#to  ulate pf angle, torque angle,equivalent capicitor and inductor value\n",
      "import math\n",
      "#initialisation of variables\n",
      "\n",
      "of1=250.0 \n",
      "scr=0.52     #short ckt ratio\n",
      "of2=of1/scr \n",
      "r=25.0*10**6 \n",
      "V=13000.0 \n",
      "\n",
      "#Calculations\n",
      "Ia=r/(math.sqrt(3.0)*V) \n",
      "Isc=Ia*of1/of2 \n",
      "Xs=V/(math.sqrt(3.0)*Isc) \n",
      "Xb=V/(math.sqrt(3.0)*Ia) \n",
      "Xsadj=Xs/Xb \n",
      "\n",
      "f=50.0 \n",
      "If=200.0 \n",
      "Ef=V*If/of1 \n",
      "Vt=V/math.sqrt(3.0) \n",
      "Ia=(Vt-Ef/math.sqrt(3.0))/Xs \n",
      "dl=0 \n",
      "print(dl,'torque angle(deg)') \n",
      "pf=90.0 \n",
      "print(pf,'pf angle(deg)') \n",
      "L=(V/(math.sqrt(3.0)*Ia))/(2*math.pi*f) \n",
      "print(L,'inductor value(H)') \n",
      "\n",
      "If=300.0 \n",
      "Eff=V*If/of1 \n",
      "Vt=Ef/math.sqrt(3.0) \n",
      "Ia=(Eff/math.sqrt(3)-Vt)/Xs \n",
      "dl=0 \n",
      "print(dl,'torque angle(deg)') \n",
      "pf=90.0 \n",
      "print(pf,'pf angle(deg)') \n",
      "c=1.0/((V/(Ia))*(2.0*math.pi*f)) \n",
      "\n",
      "#Results\n",
      "print(c,'capacitor value(F)') \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(0, 'torque angle(deg)')\n",
        "(90.0, 'pf angle(deg)')\n",
        "(0.2069014260194639, 'inductor value(H)')\n",
        "(0, 'torque angle(deg)')\n",
        "(90.0, 'pf angle(deg)')\n",
        "(5.654655337659404e-05, 'capacitor value(F)')\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.44, Page No 231"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#to determine Xs(saturated),scr,Xs(unsat)and If,generator current\n",
      "import math\n",
      "#initialisation of variables\n",
      "\n",
      "  \n",
      "MVA_b=400.0 \n",
      "kV_b=22.0 \n",
      "\n",
      "#Calculations\n",
      "Ib=MVA_b/(math.sqrt(3.0)*kV_b) \n",
      "ohm_b=kV_b/(math.sqrt(3.0)*Ib) \n",
      "\n",
      "If=1120.0 \n",
      "Voc=kV_b/math.sqrt(3) \n",
      "Isc=13.2 \n",
      "Xssat=Voc/Isc \n",
      "print(Xssat,'Xs(saturated)(ohm)') \n",
      "Xss=Xssat/ohm_b \n",
      "print(Xss,'Xs(saturated)(pu)') \n",
      "scr=1/Xss \n",
      "print(scr,'SCR') \n",
      "Isc=Ib \n",
      "Voc=24.4/math.sqrt(3) \n",
      "Xsunsat=Voc/Isc \n",
      "\n",
      "#Results\n",
      "print(Xsunsat,'Xs(unsaturated)(ohm)') \n",
      "Xsuns=Xsunsat/ohm_b \n",
      "print(Xsuns,'Xs(unsaturated)(pu)') \n",
      "Iff=If*scr \n",
      "print(Iff,'generator current(A)') \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(0.9622504486493764, 'Xs(saturated)(ohm)')\n",
        "(0.795248304668906, 'Xs(saturated)(pu)')\n",
        "(1.257468886295005, 'SCR')\n",
        "(1.342, 'Xs(unsaturated)(ohm)')\n",
        "(1.109090909090909, 'Xs(unsaturated)(pu)')\n",
        "(1408.3651526504057, 'generator current(A)')\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.45, Page No 231"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "#find motor pf\n",
      "\n",
      "  \n",
      "j=math.sqrt(1.0) \n",
      "V=6600.0 \n",
      "Vt=V/math.sqrt(3) \n",
      "pf=.8 \n",
      "\n",
      "#Calculations\n",
      "phi=math.degrees(math.acos(pf)) \n",
      "P=800000.0 \n",
      "Ia=P/(math.sqrt(3)*V*pf) \n",
      "Zs=2+20*j \n",
      "Ef=Vt-Zs*Ia*complex(math.cos(math.radians(phi))+math.sin(math.radians(phi))) \n",
      "Pip=1200*10**3.0 \n",
      "theta=math.degrees(math.atan((Zs.imag)/(Zs.real)))\n",
      "dl=math.degrees(math.acos(((Ef.real)**2*math.degrees(math.acos(theta))/abs(Zs)-P/3.0)/((Ef.real)*abs(Ef)/abs(Zs))))-theta \n",
      "\n",
      "Ia=((Ef.real)-abs(Ef)*complex(math.cos(math.radians(-dl)),math.sin(math.radians(-dl))))/Zs \n",
      "phi=math.degrees(math.atan((Ia.imag)/(Ia.real)))\n",
      "\n",
      "#Results\n",
      "print(math.cos(math.radians(phi)),'pf') "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "ename": "ValueError",
       "evalue": "math domain error",
       "output_type": "pyerr",
       "traceback": [
        "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mValueError\u001b[0m                                Traceback (most recent call last)",
        "\u001b[1;32m<ipython-input-10-84d5f78c41ee>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m     15\u001b[0m \u001b[0mPip\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m1200\u001b[0m\u001b[1;33m*\u001b[0m\u001b[1;36m10\u001b[0m\u001b[1;33m**\u001b[0m\u001b[1;36m3.0\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     16\u001b[0m \u001b[0mtheta\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mmath\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdegrees\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmath\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0matan\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mZs\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mimag\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m/\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mZs\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mreal\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 17\u001b[1;33m \u001b[0mdl\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mmath\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdegrees\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmath\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0macos\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mEf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mreal\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m**\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0mmath\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdegrees\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmath\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0macos\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtheta\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m/\u001b[0m\u001b[0mabs\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mZs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m-\u001b[0m\u001b[0mP\u001b[0m\u001b[1;33m/\u001b[0m\u001b[1;36m3.0\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m/\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mEf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mreal\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0mabs\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mEf\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m/\u001b[0m\u001b[0mabs\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mZs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m-\u001b[0m\u001b[0mtheta\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m     18\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     19\u001b[0m \u001b[0mIa\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mEf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mreal\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m-\u001b[0m\u001b[0mabs\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mEf\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0mcomplex\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmath\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcos\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmath\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mradians\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m-\u001b[0m\u001b[0mdl\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mmath\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msin\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmath\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mradians\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m-\u001b[0m\u001b[0mdl\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m/\u001b[0m\u001b[0mZs\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
        "\u001b[1;31mValueError\u001b[0m: math domain error"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.46, Page No 231"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "#to find exciting emf neglecting saliency and accounting saliency\n",
      "\n",
      "  \n",
      "j=math.sqrt(1.0) \n",
      "Xd=.12/3 \n",
      "Xq=.075/3.0 \n",
      "\n",
      "print('neglecting saliency') \n",
      "Xs=Xd \n",
      "V=440.0 \n",
      "pf=.8 \n",
      "\n",
      "#Calculations\n",
      "phi=math.degrees(math.acos(pf))\n",
      "Vt=V/math.sqrt(3.0) \n",
      "Ia=1000.0 \n",
      "Ef=Vt+j*Xs*Ia*complex(math.cos(math.radians(-phi)),math.sin(math.radians(-phi))) \n",
      "print(abs(Ef)*math.sqrt(3),'excitation emf(line)(V)') \n",
      "print('accounting saliency') \n",
      "w=math.degrees(math.atan((Vt*math.sin(math.radians(phi))+Ia*Xq)/(Vt*math.cos(math.radians(phi)))))\n",
      "dl=w-phi \n",
      "Ef=Vt*math.cos(math.radians(dl))+Ia*math.sin(math.radians(dl))*Xd\n",
      "\n",
      "#Results\n",
      "print(abs(Ef)*math.sqrt(3),'excitation emf(line)(V)') \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "neglecting saliency\n",
        "(497.16652214438125, 'excitation emf(line)(V)')\n",
        "accounting saliency\n",
        "(443.9254541572264, 'excitation emf(line)(V)')\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.47, Page No 231"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "#calculate excitation emf,max load motor supplies, torque angle\n",
      "\n",
      "Xd=23.2 \n",
      "Xq=14.5 \n",
      "V=6600.0 \n",
      "pf=.8 \n",
      "phi=math.degrees(math.acos(pf))\n",
      "Vt=V/math.sqrt(3.0) \n",
      "r=1500*1000.0\n",
      "\n",
      "#Calculations\n",
      "Ia=r/(math.sqrt(3.0)*V)\n",
      "w=math.degrees(math.atan((Vt*math.sin(math.radians(-phi))+Ia*Xq)/(Vt*math.cos(math.radians(phi)))))\n",
      "dl=-phi-w \n",
      "print(dl,'torque angle') \n",
      "Ef=Vt*math.cos(math.radians(dl))-Ia*math.sin(math.radians(w))*Xd \n",
      "print(Ef,'excitation emf(V)') \n",
      "\n",
      "Pe=V**2*((Xd-Xq)/(2*Xd*Xq)) \n",
      "\n",
      "#Results\n",
      "print(Pe,'load supplied(W)') \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(-29.696320419057813, 'torque angle')\n",
        "(3690.199749168095, 'excitation emf(V)')\n",
        "(563275.8620689656, 'load supplied(W)')\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.49, Page No 231"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "#find no load freq setting,sys freq,at no load freq of swing generator, system trip freq\n",
      "\n",
      "  \n",
      "loadtot=260.0\n",
      "r=125.0 \n",
      "pf=.84 \n",
      "\n",
      "#Calculations\n",
      "genfl=r*pf \n",
      "sld=75     #supply load\n",
      "n=3     #no of generators\n",
      "ls=loadtot-n*sld \n",
      "m=-5/genfl \n",
      "f=50 \n",
      "ff=f-m*sld \n",
      "print(ff,'set freq(Hz)') \n",
      "c=f-m*ls \n",
      "print(c,'set freq(Hz) supplied from swing generator') \n",
      "nld=sld+50/4 \n",
      "c=ff+m*nld \n",
      "print(c,'new system freq(Hz)') \n",
      "rld=310-n*sld \n",
      "c=f-m*rld \n",
      "print(c,'set freq(Hz) of swing generator') \n",
      "nld=310.0/n \n",
      "c=ff+m*nld \n",
      "\n",
      "#Results\n",
      "print(c,'system trip freq(Hz)') \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(53.57142857142857, 'set freq(Hz)')\n",
        "(51.666666666666664, 'set freq(Hz) supplied from swing generator')\n",
        "(49.42857142857143, 'new system freq(Hz)')\n",
        "(54.04761904761905, 'set freq(Hz) of swing generator')\n",
        "(48.65079365079365, 'system trip freq(Hz)')\n"
       ]
      }
     ],
     "prompt_number": 1
    }
   ],
   "metadata": {}
  }
 ]
}