{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "CHAPTER 9: SYNCHRONOUS GENERATOR"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.1, Page number 295"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "N = 300.0       #Speed of water turbine(rpm)\n",
      "f = 50.0        #Frequency of induced voltage(Hz)\n",
      "\n",
      "#Calculation\n",
      "P = 120*f/N     #Number of poles\n",
      "\n",
      "#Result\n",
      "print('Number of poles of the generator , P = %.f poles' %P)\n",
      "print('Alternatively , %.f pairs of north(N) and south(S) poles' %(P/2))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Number of poles of the generator , P = 20 poles\n",
        "Alternatively , 10 pairs of north(N) and south(S) poles\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.2, Page number 299-300"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "P = 8.0        #Number of poles\n",
      "m = 3.0        #Number of phase \n",
      "S = 144.0      #Number of slots\n",
      "\n",
      "#Calculation\n",
      "T_p = S/P               #Pole pitch(slots)\n",
      "slots_1 = 180/T_p       #Pole pitch per slot(degree)\n",
      "gamma = 2*slots_1       #Short pitch angle(degree)\n",
      "y = gamma*math.pi/180   #Short pitch angle(radian)\n",
      "k_p = math.cos(y/2)     #Pitch factor\n",
      "\n",
      "#Result\n",
      "print('Pitch factor , k_p = %.2f ' %k_p)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Pitch factor , k_p = 0.98 \n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.3, Page number 300-301"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "P = 4.0     #Number of poles\n",
      "m = 3.0     #Number of phase \n",
      "S = 40.0    #Number of slots\n",
      "s_1 = 1.0   #Coil span\n",
      "s_2 = 9.0   #Coil span\n",
      "\n",
      "#Calculation\n",
      "T_p = S/P               #Pole pitch(slots)\n",
      "T_c = s_2-s_1           #Coil pitch for coil spans 1 to 9(slots)\n",
      "slots = 180/T_p         #Pole pitch per slot(degree)\n",
      "y = T_p-T_c             #Short pitch angle(slots)\n",
      "gamma = y*slots         #Short pitch angle(degree)\n",
      "y = gamma*math.pi/180   #Short pitch angle(radian)\n",
      "k_p = math.cos(y/2)     #Pitch factor\n",
      "\n",
      "#Result\n",
      "print('Pitch factor , k_p = %.2f ' %k_p)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Pitch factor , k_p = 0.95 \n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.4, Page number 302"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "P = 4.0     #Number of poles\n",
      "S = 48.0    #Number of slots\n",
      "m = 3.0     #Number of phase \n",
      "\n",
      "#Calculation\n",
      "T_p = S/P                                        #Pole pitch(slots)\n",
      "slot = 180/T_p                                   #Pole pitch per slot(degree)\n",
      "a = slot*math.pi/180                             #Pole pitch per slot(radian)\n",
      "n = S/(P*m)                                      #Number of slots or coils per pole per phase\n",
      "k_d = math.sin(n*a/2)/(n*math.sin(a/2))          #Distribution factor\n",
      "\n",
      "#Result\n",
      "print('Distribution factor , k_d = %.2f ' %k_d)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Distribution factor , k_d = 0.96 \n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.5, Page number 304-305"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "P = 12.0         #Number of poles\n",
      "S = 180.0        #Number of slots\n",
      "phi_m = 0.05     #Flux per pole(Wb)\n",
      "N = 600.0        #Speed of machine(rpm)\n",
      "m = 3.0          #Number of phase\n",
      "\n",
      "#Calculation\n",
      "T_p = S/P                                   #Pole pitch(slots)\n",
      "slot = 180/T_p                              #Slots per pole(degree)\n",
      "n = S/(P*m)                                 #Number of slots or coils per pole per phase\n",
      "a = slot*math.pi/180                        #Pole pitch per slot(radian)\n",
      "k_d = math.sin(n*a/2)/(n*math.sin(a/2))     #Distribution factor\n",
      "k_p = 1.0                                   #Pitch factor\n",
      "Z = (180/m)*slot                            #Number of conductors per phase\n",
      "T = Z/2                                     #Number of turns per phase\n",
      "f = P*N/120                                 #Frequency(Hz)\n",
      "E = 4.44*k_p*k_d*f*phi_m*T                  #Induced voltage(V)\n",
      "E_L = 3**0.5*E                              #Line voltage(V)\n",
      "\n",
      "#Result\n",
      "print('Line voltage , E_L = %.1f V' %E_L)\n",
      "print('\\nNOTE : Changes in obtained answer from that of textbook answer is due to precision i.e more number of decimal places')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Line voltage , E_L = 7945.7 V\n",
        "\n",
        "NOTE : Changes in obtained answer from that of textbook answer is due to precision i.e more number of decimal places\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.6, Page number 305-307"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "P = 4.0         #Number of poles\n",
      "m = 3.0         #Number of phase \n",
      "f = 50.0        #Frequency(Hz)\n",
      "phi_m = 0.05    #Flux per pole(Wb)\n",
      "n = 6.0         #Number of slots per pole per phase\n",
      "cond = 5.0      #Conductors per layer\n",
      "no_layer = 2.0  #Number of layer winding\n",
      "\n",
      "#Calculation\n",
      "T_p = n*m                                     #Slots per pole\n",
      "slot = 180/T_p                                #Slots per pole(degree)\n",
      "a = slot*math.pi/180                          #Pole pitch per slot(radian)\n",
      "T_c = (5.0/6)*T_p                             #Coil pitch is 5/6 of full pitch\n",
      "gamma = T_p-T_c                               #Short pitch angle(slots)\n",
      "y_angle = gamma*slot                          #Short pitch(angle)\n",
      "y = y_angle*math.pi/180                       #Short pitch(radians)\n",
      "k_p = math.cos(y/2)                           #Pitch factor\n",
      "k_d = math.sin(n*a/2)/(n*math.sin(a/2))       #Distribution factor\n",
      "T = 1.0/2*n*P*cond*no_layer                   #Number of turns in any phase\n",
      "E = 4.44*k_p*k_d*f*phi_m*T                    #Voltage per phase(V)\n",
      "\n",
      "#Result\n",
      "print('Voltage per phase , E = %.2f V' %E)\n",
      "print('\\nNOTE : Changes in obtained answer from that of textbook answer is due to precision i.e more number of decimal places')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Voltage per phase , E = 1230.19 V\n",
        "\n",
        "NOTE : Changes in obtained answer from that of textbook answer is due to precision i.e more number of decimal places\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.7, Page number 307-308"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "P = 10.0           #Number of poles\n",
      "m = 3.0            #Number of phase \n",
      "f = 50.0           #Frequency(Hz)\n",
      "n = 3.0            #Number of slots per pole per phase\n",
      "phi_m1 = 0.05      #Fundamental component of flux(Wb)\n",
      "phi_m3 = 0.006     #Third harmonic component of flux(Wb)\n",
      "T_c = 150.0        #Coil span(degree)\n",
      "cond = 5.0         #Conductors per layer\n",
      "no_layer = 2.0     #Number of layer winding\n",
      "\n",
      "#Calculation\n",
      "T_p = n*m                                     #Slots per pole\n",
      "slot = 180/T_p                                #Slots per pole(degree)\n",
      "a = slot*math.pi/180                          #Pole pitch per slot(radian)\n",
      "gamma = 180-T_c                               #Short pitch angle(degree)\n",
      "y = gamma*math.pi/180                         #Short pitch angle(radian)\n",
      "T = 1.0/2*P*n*cond*no_layer                   #Number of turns\n",
      "k_p1 = math.cos(y/2)                          #Fundamental pitch factor\n",
      "k_d1 = math.sin(n*a/2)/(n*math.sin(a/2))      #Fundamental distribution factor\n",
      "E_1 = 4.44*k_p1*k_d1*f*phi_m1*T               #Fundamental emf per phase(V)\n",
      "k_p3 = math.cos(3*y/2)                        #Third harmonic pitch factor\n",
      "k_d3 = math.sin(3*n*a/2)/(n*math.sin(3*a/2))  #Third harmonic distribution factor\n",
      "E_3 = 4.44*k_p3*k_d3*f*phi_m3*T               #Voltage(V)\n",
      "E = (E_1**2+E_3**2)**0.5                      #Induced voltage per phase(V)\n",
      "\n",
      "#Result\n",
      "print('rms value of induced voltage per phase , E = %.1f V' %E)\n",
      "print('\\nNOTE : Changes in obtained answer from that of textbook answer is due to precision i.e more number of decimal places')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "rms value of induced voltage per phase , E = 1546.5 V\n",
        "\n",
        "NOTE : Changes in obtained answer from that of textbook answer is due to precision i.e more number of decimal places\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.8, Page number 312"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "kVA = 50.0        #Ratings(kVA)\n",
      "V_t = 220.0       #Voltage(V)\n",
      "R_a = 0.011       #Effective resistance(ohm)\n",
      "X_s = 0.09        #Synchronous reactance(ohm)\n",
      "pf = 0.85         #Lagging power factor\n",
      "\n",
      "#Calculation\n",
      "phi = math.acos(pf)                                                #Power factor angle(radians)\n",
      "I_a = kVA*10**3/V_t                                                #Armature current(A)\n",
      "E_f = ((V_t*pf+I_a*R_a)**2+(V_t*math.sin(phi)+I_a*X_s)**2)**0.5    #Induced voltage per phase(V)\n",
      "VR = ((E_f-V_t)/V_t)*100                                           #Voltage regulation(percent)\n",
      "\n",
      "#Result\n",
      "print('No-load induced voltage per phase , E_f = %.1f V' %E_f)\n",
      "print('Voltage regulation , VR = %.1f percent' %VR)\n",
      "print('\\nNOTE : Changes in obtained answer from that of textbook answer is due to precision i.e more number of decimal places')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "No-load induced voltage per phase , E_f = 233.5 V\n",
        "Voltage regulation , VR = 6.1 percent\n",
        "\n",
        "NOTE : Changes in obtained answer from that of textbook answer is due to precision i.e more number of decimal places\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.9, Page number 314"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "kVA = 200.0          #Rating(kVA)\n",
      "V_t = 33.0*10**3     #Voltage(V)\n",
      "R_a = 0.54           #Armature resistance(ohm)\n",
      "V_L = 415.0          #Voltage between lines for SC test(V)\n",
      "I_sh = 25.0          #Short circuit current(A)\n",
      "pf = 0.9             #Lagging power factor\n",
      "\n",
      "#Calculation\n",
      "#For case(i)\n",
      "V_P = V_L/3**0.5                                                   #Phase voltage during short circuit test(V)\n",
      "Z_s = V_P/I_sh                                                     #Synchronous impedance(ohm)\n",
      "#For case(ii)\n",
      "X_s = (Z_s**2-R_a**2)**0.5                                         #Synchronous reactance(ohm)\n",
      "#For case(iii)\n",
      "I_a = kVA*1000/(3**0.5*V_t)                                        #Full load current(A)\n",
      "V_ta = V_t/3**0.5                                                  #Voltage per phase of alternator(V)\n",
      "phi = math.acos(pf)                                                #Power factor angle(radians)\n",
      "E_f = ((V_ta*pf+I_a*R_a)**2+(V_ta*math.sin(phi)+I_a*X_s)**2)**0.5  #No-load voltage per phase(V) \n",
      "VR = ((E_f-V_ta)/V_ta)*100                                         #Voltage regulation\n",
      "\n",
      "#Result\n",
      "print('(i)   Synchronous impedance , Z_s = %.1f ohm' %Z_s)\n",
      "print('(ii)  Synchronous reactance , X_s = %.2f ohm' %X_s)\n",
      "print('(iii) Voltage regulation , VR = %.2f percent' %VR)\n",
      "print('\\nNOTE : ERROR : In textbook calculation , R_a is taken instead of X_s in calculation of E_f')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i)   Synchronous impedance , Z_s = 9.6 ohm\n",
        "(ii)  Synchronous reactance , X_s = 9.57 ohm\n",
        "(iii) Voltage regulation , VR = 0.09 percent\n",
        "\n",
        "NOTE : ERROR : In textbook calculation , R_a is taken instead of X_s in calculation of E_f\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.10, Page number 317"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "MVA = 30.0      #Rating(MVA)\n",
      "V = 20.0        #Supply voltage(kV)\n",
      "N = 1800.0      #Speed(rpm)\n",
      "V_t = 15.0      #Voltage per phase(kV)\n",
      "E_f = 10.0      #Per phase terminal voltage(kV)\n",
      "delta = 40.0    #Power angle(degree)\n",
      "X_s = 6.0       #Per phase synchronous reactance(ohm)\n",
      "\n",
      "#Calculation\n",
      "#For case(i)\n",
      "d = delta*math.pi/180           #Power angle(radians)\n",
      "P = 3*V_t*E_f*math.sin(d)/X_s   #3-phase power delivered to the load(MW)\n",
      "#For case(ii)\n",
      "P_max = 3*V_t*E_f/X_s           #Three phase maximum power(MW)\n",
      "\n",
      "#Result\n",
      "print('(i)  Three-phase real power delivered to the load , P = %.2f MW' %P)\n",
      "print('(ii) Three-phase maximum power , P_max = %.f MW' %P_max)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i)  Three-phase real power delivered to the load , P = 48.21 MW\n",
        "(ii) Three-phase maximum power , P_max = 75 MW\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.11, Page number 321-322"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "kVA = 25.0        #Rating(kVA)\n",
      "V = 440.0         #Suppy voltage(V)\n",
      "f = 50.0          #Supply frequency(Hz)\n",
      "pf = 0.8          #Lagging power factor\n",
      "R_a = 0.3         #Resistance of machine per phase(ohm)\n",
      "X_d = 5.0         #Reactance of machine per phase(ohm)\n",
      "X_q = 3.0         #Reactance of machine per phase(ohm)\n",
      "\n",
      "#Calculation\n",
      "#For case(i)\n",
      "phi = math.acos(pf)                                #Power factor angle(radians)\n",
      "phi_deg = phi*180/math.pi                          #Power factor angle(degree)\n",
      "V_t = V/3**0.5                                     #Terminal voltage per phase(V)\n",
      "I_a = kVA*10**3/(3**0.5*V)                         #Armature current(A)\n",
      "tan_d = (I_a*X_q*pf/(V_t+I_a*X_q*math.sin(phi)))\n",
      "d = math.atan(tan_d)                               #Torque angle(radians)\n",
      "d_angle = d*180/math.pi                            #Torque angle(degree)\n",
      "#For case(ii)\n",
      "I_d = I_a*math.sin(d+phi)                          #Direct axis component of the current(A)\n",
      "E_f = V_t*math.cos(d)+I_d*X_d                      #Induced voltage per phase(V)\n",
      "#For case(iii)\n",
      "VR = ((E_f-V_t)/V_t)*100                           #Voltage regulation(percent)\n",
      "\n",
      "#Result\n",
      "print('(i)   Torque angle , \u03b4 = %.2f\u00b0 ' %d_angle)\n",
      "print('(ii)  Induced voltage per phase , E_f = %.2f V' %E_f)\n",
      "print('(iii) Voltage regulation , VR = %.2f percent' %VR)\n",
      "print('\\nNOTE : Changes in obtained answer from that of textbook answer is due to precision i.e more number of decimal places')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i)   Torque angle , \u03b4 = 14.12\u00b0 \n",
        "(ii)  Induced voltage per phase , E_f = 373.80 V\n",
        "(iii) Voltage regulation , VR = 47.15 percent\n",
        "\n",
        "NOTE : Changes in obtained answer from that of textbook answer is due to precision i.e more number of decimal places\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.12, Page number 324-325"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import cmath\n",
      "\n",
      "#Variable declaration\n",
      "E_1 = 220.0                             #Induced voltage per phase by alternator 1(V)\n",
      "E_2 = 220*cmath.exp(1j*5*math.pi/180)   #Induced voltage per phase by alternator 2(V)\n",
      "Z_1 = complex(0,3)                      #Impedance of alternator 1(ohm)\n",
      "Z_2 = complex(0,4)                      #Impedance of alternator 2(ohm)\n",
      "Z = 5.0                                 #Load(ohm)\n",
      "\n",
      "#Calculation\n",
      "#For case(i)\n",
      "I = (E_1*Z_2+E_2*Z_1)/(Z_1*Z_2+Z*(Z_1+Z_2))          #Load current(A)\n",
      "#For case(ii)\n",
      "V_t = I*Z                                            #Terminal voltage(V)\n",
      "#For case(iii)\n",
      "I_a1 = ((E_1-E_2)*Z+E_1*Z_2)/(Z_1*Z_2+Z*(Z_1+Z_2))   #Armature current(A)\n",
      "P_1 = abs(V_t*I_a1)*math.cos(cmath.phase(V_t)-cmath.phase(I_a1))*10**-3  #Power per phase delivered by the first alternator(W)\n",
      "\n",
      "#Result\n",
      "print('(i)   Load current , I = %.1f\u2220%.f\u00b0 A' %(abs(I),cmath.phase(I)*180/math.pi))\n",
      "print('(ii)  Terminal voltage , V_t = %.f\u2220%.f\u00b0 V' %(abs(V_t),cmath.phase(V_t)*180/math.pi))\n",
      "print('(iii) Power per phase delivered by the first alternator , P_1 = %.1f kW' %P_1)\n",
      "print('\\nNOTE : ERROR : In textbook case(iii) power calculation current I is taken instead of I_a1')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i)   Load current , I = 41.6\u2220-17\u00b0 A\n",
        "(ii)  Terminal voltage , V_t = 208\u2220-17\u00b0 V\n",
        "(iii) Power per phase delivered by the first alternator , P_1 = 4.4 kW\n",
        "\n",
        "NOTE : ERROR : In textbook case(iii) power calculation current I is taken instead of I_a1\n"
       ]
      }
     ],
     "prompt_number": 1
    }
   ],
   "metadata": {}
  }
 ]
}