{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "CHAPTER 12: POWER, ENERGY, AND EFFICIENCY RELATIONS OF DC AND AC DYNAMOS"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.1, Page number 412"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "P = 10000.0      #Power rating of the shunt generator(W)\n",
      "V = 230.0        #Voltage rating of the shunt generator(V)\n",
      "S = 1750.0       #Speed of the shunt generator(rpm)\n",
      "V_a = 245.0      #Voltage across armature(V)\n",
      "I_a = 2.0        #Armature current(A)\n",
      "R_f = 230.0      #Field resistance(ohm)\n",
      "R_a = 0.2        #Armature resistance(ohm)\n",
      "\n",
      "#Calculation\n",
      "#Case(a)\n",
      "Rotational_loss = V_a*I_a-(I_a**2*R_a)    #Rotational losses at full load(W) \n",
      "#Case(b)\n",
      "V_t = V\n",
      "I_L = P/V_t                               #Line current(A)\n",
      "I_f = V/R_f                               #Field current(A)\n",
      "Ia = I_f+I_L                              #Armature current(A)\n",
      "armature_loss = Ia**2*R_a                 #Full-load armature loss(W)\n",
      "V_f = V\n",
      "field_loss = V_f*I_f                      #Full-load field loss(W)\n",
      "#Case(c)\n",
      "n = P/(P+Rotational_loss+(armature_loss+field_loss))*100 #Efficiency of the generator at rated load(%) \n",
      "\n",
      "#Result\n",
      "print('Case(a): Rotational losses at full load , Rotational losses = %.1f W' %Rotational_loss)\n",
      "print('Case(b): Full-load armature circuit loss , I_a^2*R_a = %.f W' %armature_loss)\n",
      "print('         Field loss , V_f*I_f = %.f W' %field_loss)\n",
      "print('Case(c): Efficiency of the generator at rated load , \u03b7 = %.1f percent' %n)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case(a): Rotational losses at full load , Rotational losses = 489.2 W\n",
        "Case(b): Full-load armature circuit loss , I_a^2*R_a = 396 W\n",
        "         Field loss , V_f*I_f = 230 W\n",
        "Case(c): Efficiency of the generator at rated load , \u03b7 = 90.0 percent\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.2, Page number 412"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "P = 10000.0               #Power rating of the shunt generator(W)\n",
      "Rotational_loss = 489.2   #Rotational loss at full load(W)\n",
      "armature_loss = 396.0     #Full-load armature loss(W)\n",
      "field_loss = 230.0        #Full-load field loss(W)\n",
      "x1 = 1.0/4                #Fraction of full-load\n",
      "x2 = 1.0/2                #Fraction of full-load\n",
      "x3 = 3.0/4                #Fraction of full-load\n",
      "x4 = 5.0/4                #Fraction of full-load\n",
      "\n",
      "#Calculation\n",
      "n_a = (P*x1)/((P*x1)+Rotational_loss+(armature_loss*(x1**2)+field_loss))*100   #Efficiency of generator(%)\n",
      "n_b = (P*x2)/((P*x2)+Rotational_loss+(armature_loss*(x2**2)+field_loss))*100   #Efficiency of generator(%)\n",
      "n_c = (P*x3)/((P*x3)+Rotational_loss+(armature_loss*(x3**2)+field_loss))*100   #Efficiency of generator(%)\n",
      "n_d = (P*x4)/((P*x4)+Rotational_loss+(armature_loss*(x4**2)+field_loss))*100   #Efficiency of generator(%)\n",
      "\n",
      "#Result\n",
      "print('Case(a): Efficiency of the generator at 1/4 load , \u03b7 = %.1f percent' %n_a)\n",
      "print('Case(b): Efficiency of the generator at 1/2 load , \u03b7 = %.1f percent' %n_b)\n",
      "print('Case(c): Efficiency of the generator at 3/4 load , \u03b7 = %.1f percent' %n_c)\n",
      "print('Case(d): Efficiency of the generator at 5/4 load , \u03b7 = %.1f percent' %n_d)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case(a): Efficiency of the generator at 1/4 load , \u03b7 = 77.1 percent\n",
        "Case(b): Efficiency of the generator at 1/2 load , \u03b7 = 85.9 percent\n",
        "Case(c): Efficiency of the generator at 3/4 load , \u03b7 = 88.8 percent\n",
        "Case(d): Efficiency of the generator at 5/4 load , \u03b7 = 90.3 percent\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.3, Page number 413"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "V = 240.0     #Voltage rating of the dc shunt motor(V)\n",
      "hp = 25.0     #Power rating of the dc shunt motor(hp)\n",
      "S = 1800.0    #Speed of the shunt generator(rpm)\n",
      "I_L = 89.0    #Full-load line current(A)\n",
      "R_a = 0.05    #Armature resistance(ohm)\n",
      "R_f = 120.0   #Field circuit resistance(ohm)\n",
      "\n",
      "#Calculation\n",
      "#Case(a)\n",
      "V_f = V            #Field voltage(V)\n",
      "I_f = V_f/R_f      #Field current(A)\n",
      "I_a = I_L-I_f      #Armature current(A)\n",
      "V_a = V\n",
      "E_c = V_a-I_a*R_a  #Armature voltage to be applied to the motor(V)\n",
      "#Case(b)\n",
      "Ia = 4.2           #Armature current produced by E_c(A)\n",
      "Va = E_c           #Armature voltage(V)\n",
      "P_r = Va*Ia        #Stray power(W)\n",
      "\n",
      "#Result\n",
      "print('Case(a): Armature voltage to be applied to the motor when motor is run light at 1800 rpm during stray power test , E_c = %.2f V' %E_c)\n",
      "print('Case(b): Stray power when voltage in part(a) produces an armature current of 4.2 A at 1800 rpm , P_r = %.1f W' %P_r)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case(a): Armature voltage to be applied to the motor when motor is run light at 1800 rpm during stray power test , E_c = 235.65 V\n",
        "Case(b): Stray power when voltage in part(a) produces an armature current of 4.2 A at 1800 rpm , P_r = 989.7 W\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.4, Page number 415"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "V = 600.0    #Voltage rating of the compound motor(V)\n",
      "hp = 150.0   #Power rating of the compound motor(hp)\n",
      "I_L = 205.0  #Full-load rated line current(A)\n",
      "S = 1500.0   #Full-load speed of the compound generator(rpm)\n",
      "R_sh = 300.0 #Shunt field resistance(ohm)\n",
      "R_a = 0.05   #Armature resistance(ohm)\n",
      "R_s = 0.1    #Series field resistance(ohm)\n",
      "V_a  = 570.0 #Applied voltage(V)\n",
      "I_a = 6.0    #Armature current(A)\n",
      "S_o = 1800.0 #No-load speed of the compound generator(rpm)\n",
      "x1 = 1.0/4                #Fraction of full-load\n",
      "x2 = 1.0/2                #Fraction of full-load\n",
      "x3 = 3.0/4                #Fraction of full-load\n",
      "x4 = 5.0/4                #Fraction of full-load\n",
      "\n",
      "#Calculation\n",
      "#Case(a)\n",
      "Rot_losses = V_a*I_a                        #Rotational loss(W)\n",
      "S_1 = S_o-300*x1                            #Speed at 1/4 load(rpm)\n",
      "Rot_losses_S_1 = (S_1/S)*Rot_losses         #Rotational loss at speed S_1(W)\n",
      "S_2 = S_o-300*x2                            #Speed at 1/2 load(rpm)\n",
      "Rot_losses_S_2 = (S_2/S)*Rot_losses         #Rotational loss at speed S_2(W)\n",
      "S_3 = S_o-300*x3                            #Speed at 3/4 load(rpm)\n",
      "Rot_losses_S_3 = (S_3/S)*Rot_losses         #Rotational loss at speed S_3(W)\n",
      "S_4 = S_o-300*x4                            #Speed at 5/4 load(rpm)\n",
      "Rot_losses_S_4 = (S_4/S)*Rot_losses         #Rotational loss at speed S_4(W)\n",
      "#Case(b)\n",
      "I_sh = V/R_sh                               #Full-load shunt field current(A)\n",
      "Ia = I_L-I_sh                               #Full-load armature current(A)\n",
      "FL_variable_loss = Ia**2*(R_a+R_s)          #Full-load variable electric loss(W)\n",
      "x1_variable_loss = FL_variable_loss*x1**2   #Variable losses at 1/4 load(W)\n",
      "x2_variable_loss = FL_variable_loss*x2**2   #Variable losses at 1/2 load(W)\n",
      "x3_variable_loss = FL_variable_loss*x3**2   #Variable losses at 3/4 load(W)\n",
      "x4_variable_loss = FL_variable_loss*x4**2   #Variable losses at 5/4 load(W)\n",
      "#Case(c)\n",
      "Input_FL = V*I_L                            #Input at full load(W)\n",
      "Input_x1 = V*I_L*x1                         #Input at 1/4 load(W)\n",
      "Input_x2 = V*I_L*x2                         #Input at 1/2 load(W)\n",
      "Input_x3 = V*I_L*x3                         #Input at 3/4 load(W)\n",
      "Input_x4 = V*I_L*x4                         #Input at 5/4 load(W)\n",
      "Field_loss = V*I_sh                         #Field loss for each of the conditions of load(W)\n",
      "Losses_FL = Field_loss+Rot_losses+FL_variable_loss     #Total losses for full load(W)\n",
      "Losses_1 = Field_loss+Rot_losses_S_1+x1_variable_loss  #Total losses for 1/4 load(W)\n",
      "Losses_2 = Field_loss+Rot_losses_S_2+x2_variable_loss  #Total losses for 1/2 load(W)\n",
      "Losses_3 = Field_loss+Rot_losses_S_3+x3_variable_loss  #Total losses for 3/4 load(W)\n",
      "Losses_4 = Field_loss+Rot_losses_S_4+x4_variable_loss  #Total losses for 5/4 load(W)\n",
      "n_FL = (Input_FL-Losses_FL)/Input_FL*100               #Efficiency for full load(%)\n",
      "n_1 = (Input_x1-Losses_1)/Input_x1*100                 #Efficiency for 1/4 load(%)\n",
      "n_2 = (Input_x2-Losses_2)/Input_x2*100                 #Efficiency for 1/2 load(%)\n",
      "n_3 = (Input_x3-Losses_3)/Input_x3*100                 #Efficiency for 3/4 load(%)\n",
      "n_4 = (Input_x4-Losses_4)/Input_x4*100                 #Efficiency for 5/4 load(%) \n",
      "\n",
      "#Result\n",
      "print('Case(a): Rotational loss at full load = %.f W' %Rot_losses)\n",
      "print('         Rotational loss at 1/4 times rated load = %.f W' %Rot_losses_S_1)\n",
      "print('         Rotational loss at 1/2 times rated load = %.f W' %Rot_losses_S_2)\n",
      "print('         Rotational loss at 3/4 times rated load = %.f W' %Rot_losses_S_3)\n",
      "print('         Rotational loss at 5/4 times rated load = %.f W' %Rot_losses_S_4)\n",
      "print('Case(b): Full-load variable electric losses = %.f W' %FL_variable_loss)\n",
      "print('         Variable electric losses at 1/4 load = %.f W' %x1_variable_loss)\n",
      "print('         Variable electric losses at 1/2 load = %.f W' %x2_variable_loss)\n",
      "print('         Variable electric losses at 3/4 load = %.f W' %x3_variable_loss)\n",
      "print('         Variable electric losses at 5/4 load = %.f W' %x4_variable_loss)\n",
      "print('Case(c): Efficiency of motor at full load = %.1f percent' %n_FL)\n",
      "print('         Efficiency of motor at 1/4 load = %.1f percent' %n_1)\n",
      "print('         Efficiency of motor at 1/2 load = %.1f percent' %n_2)\n",
      "print('         Efficiency of motor at 3/4 load = %.1f percent' %n_3)\n",
      "print('         Efficiency of motor at 5/4 load = %.1f percent' %n_4)\n",
      "print('Case(d): Table 12-2 Losses and Efficiencies for Ex. 12-4')\n",
      "print('______________________________________________________________________________________________________________')\n",
      "print('\\t Item \\t\\t\\t At 1/4 load \\t At 1/2 load \\t At 3/4 load \\t At Full load \\t At 5/4 load')\n",
      "print('______________________________________________________________________________________________________________')\n",
      "print('Input(watts)\\t\\t\\t %d \\t\\t %d \\t\\t %d \\t\\t %d \\t\\t %d' %(Input_x1,Input_x2,Input_x3,Input_FL,Input_x4))\n",
      "print('Field loss(watts)\\t\\t %d \\t\\t %d \\t\\t %d \\t\\t %d \\t\\t %d' %(Field_loss,Field_loss,Field_loss,Field_loss,Field_loss))\n",
      "print('Rotational losses,')\n",
      "print(' From part(a) (watts)\\t\\t %d \\t\\t %d \\t\\t %d \\t\\t %d \\t\\t %d' %(Rot_losses_S_1,Rot_losses_S_2,Rot_losses_S_3,Rot_losses,Rot_losses_S_4))\n",
      "print('Variable electric losses,')\n",
      "print(' From part(b) (watts)\\t\\t %d \\t\\t %d \\t\\t %d \\t\\t %d \\t\\t %d' %(x1_variable_loss,x2_variable_loss,x3_variable_loss,FL_variable_loss,x4_variable_loss))\n",
      "print('Total of all losses(watts)\\t %d \\t\\t %d \\t\\t %d \\t\\t %d \\t\\t %d' %(Losses_1,Losses_2,Losses_3,Losses_FL,Losses_4))\n",
      "print('______________________________________________________________________________________________________________')\n",
      "print('Efficiency \u03b7(percent)\\t\\t %.1f \\t\\t %.1f \\t\\t %.1f \\t\\t %.1f \\t\\t %.1f' %(n_1,n_2,n_3,n_FL,n_4))\n",
      "print('______________________________________________________________________________________________________________')\n",
      "print('\\nNOTE: Changes in obtained answer from that of textbook is due to more precision')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case(a): Rotational loss at full load = 3420 W\n",
        "         Rotational loss at 1/4 times rated load = 3933 W\n",
        "         Rotational loss at 1/2 times rated load = 3762 W\n",
        "         Rotational loss at 3/4 times rated load = 3591 W\n",
        "         Rotational loss at 5/4 times rated load = 3249 W\n",
        "Case(b): Full-load variable electric losses = 6181 W\n",
        "         Variable electric losses at 1/4 load = 386 W\n",
        "         Variable electric losses at 1/2 load = 1545 W\n",
        "         Variable electric losses at 3/4 load = 3477 W\n",
        "         Variable electric losses at 5/4 load = 9658 W\n",
        "Case(c): Efficiency of motor at full load = 91.2 percent\n",
        "         Efficiency of motor at 1/4 load = 82.1 percent\n",
        "         Efficiency of motor at 1/2 load = 89.4 percent\n",
        "         Efficiency of motor at 3/4 load = 91.0 percent\n",
        "         Efficiency of motor at 5/4 load = 90.8 percent\n",
        "Case(d): Table 12-2 Losses and Efficiencies for Ex. 12-4\n",
        "______________________________________________________________________________________________________________\n",
        "\t Item \t\t\t At 1/4 load \t At 1/2 load \t At 3/4 load \t At Full load \t At 5/4 load\n",
        "______________________________________________________________________________________________________________\n",
        "Input(watts)\t\t\t 30750 \t\t 61500 \t\t 92250 \t\t 123000 \t\t 153750\n",
        "Field loss(watts)\t\t 1200 \t\t 1200 \t\t 1200 \t\t 1200 \t\t 1200\n",
        "Rotational losses,\n",
        " From part(a) (watts)\t\t 3932 \t\t 3762 \t\t 3591 \t\t 3420 \t\t 3249\n",
        "Variable electric losses,\n",
        " From part(b) (watts)\t\t 386 \t\t 1545 \t\t 3477 \t\t 6181 \t\t 9658\n",
        "Total of all losses(watts)\t 5519 \t\t 6507 \t\t 8268 \t\t 10801 \t\t 14107\n",
        "______________________________________________________________________________________________________________\n",
        "Efficiency \u03b7(percent)\t\t 82.1 \t\t 89.4 \t\t 91.0 \t\t 91.2 \t\t 90.8\n",
        "______________________________________________________________________________________________________________\n",
        "\n",
        "NOTE: Changes in obtained answer from that of textbook is due to more precision\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.5, Page number 415"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "P = 10000.0      #Power rating of the shunt generator(W)\n",
      "V = 230.0        #Voltage rating of the shunt generator(V)\n",
      "S = 1750.0       #Speed of the shunt generator(rpm)\n",
      "V_a = 245.0      #Voltage across armature(V)\n",
      "I_a = 2.0        #Armature current(A)\n",
      "R_a = 0.2        #Armature resistance(ohm)\n",
      "P_r = 489.2      #Shunt generator rotational losses(W)\n",
      "Vf_If = 230.0    #Shunt field circuit loss(W)\n",
      "I_a_rated = 44.5 #Rated armature current(A)\n",
      "\n",
      "#Calculation\n",
      "I_a = ((Vf_If+P_r)/R_a)**0.5             #Armature current at which max efficiency occurs(A)\n",
      "LF = I_a/I_a_rated                       #Load fraction\n",
      "LF_percent = LF*100                      #Load fraction(%)\n",
      "P_k = Vf_If+P_r\n",
      "n_max = P*LF/(P*LF+(Vf_If+P_r)+P_k)*100  #Maximum efficiency(%)\n",
      "LF_d = (P_k/(I_a_rated**2*R_a))**0.5     #Load fraction from fixed losses and rated variable losses\n",
      "\n",
      "#Result\n",
      "print('Case(a): Armature current at which maximum efficiency occurs , I_a = %.f A' %I_a)\n",
      "print('Case(b): Load fraction , L.F = %.1f percent = %.3f*rated' %(LF_percent,LF))\n",
      "print('Case(c): Maximum efiiciency , \u03b7_max = %.2f percent' %n_max)\n",
      "print('Case(d): Load fraction from fixed losses and rated variable losses , L.F = %.3f*rated' %LF_d)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case(a): Armature current at which maximum efficiency occurs , I_a = 60 A\n",
        "Case(b): Load fraction , L.F = 134.8 percent = 1.348*rated\n",
        "Case(c): Maximum efiiciency , \u03b7_max = 90.36 percent\n",
        "Case(d): Load fraction from fixed losses and rated variable losses , L.F = 1.348*rated\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.6, Page number 418"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "V = 240.0      #Voltage rating of dc shunt motor(V)\n",
      "hp = 25.0      #Power rating of dc shunt motor(hp)\n",
      "S = 1100.0     #Speed of the dc shunt motor(rpm)\n",
      "R_a = 0.15     #Armture resistance(ohm)\n",
      "R_f = 80.0     #Field resistance(ohm)\n",
      "I_L = 89.0     #Rated line current(A)\n",
      "\n",
      "#Calculation\n",
      "V_f = V               #Voltage across field winding(V)\n",
      "I_f = V_f/R_f         #Field current(A)\n",
      "I_a = I_L-I_f         #Armature current(A)\n",
      "P_o = hp*746          #Power rating of dc shunt motor(W)\n",
      "V_a = V               #Voltage across armature(V)\n",
      "E_c_fl = V_a-I_a*R_a  #Back EMF(V)\n",
      "E_c = E_c_fl\n",
      "P_d = E_c*I_a         #Power developed by the armature(W)\n",
      "P_r = P_d-P_o         #Full-load rotational losses(W)\n",
      "P_in = V*I_L          #Input power(W)\n",
      "n = P_o/P_in*100      #Full-load efficiency(%)  \n",
      "P_k = V_f*I_f+P_r     #Total constant losses(W)\n",
      "Ia = (P_k/R_a)**0.5   #Armature current for maximum efficiency(A)\n",
      "I_a_rated = I_a\n",
      "LF = Ia/I_a_rated     #Load fraction at which max efficiency is produced\n",
      "rated_input = V*I_L \n",
      "n_max = ((LF*rated_input)-2*P_k)/(LF*rated_input)*100  #Maximum efficiency(%)\n",
      "\n",
      "#Result\n",
      "print('Case(a): Power developed by the armature , P_d = %.1f W' %P_d)\n",
      "print('Case(b): Full-load rotational losses , P_r = %.1f W' %P_r)\n",
      "print('Case(c): Full-laod efficiency , \u03b7 = %.1f percent' %n)\n",
      "print('Case(d): Total constant losses , P_k = %.1f W' %P_k)\n",
      "print('Case(e): Armature current from maximum efficiency , I_a = %.1f A' %Ia)\n",
      "print('Case(f): Load fraction at which maximum efficiency is produced , L.F = %.1f ' %LF)\n",
      "print('Case(g): Maximum efficiency , \u03b7_max = %.1f percent' %n_max)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case(a): Power developed by the armature , P_d = 19530.6 W\n",
        "Case(b): Full-load rotational losses , P_r = 880.6 W\n",
        "Case(c): Full-laod efficiency , \u03b7 = 87.3 percent\n",
        "Case(d): Total constant losses , P_k = 1600.6 W\n",
        "Case(e): Armature current from maximum efficiency , I_a = 103.3 A\n",
        "Case(f): Load fraction at which maximum efficiency is produced , L.F = 1.2 \n",
        "Case(g): Maximum efficiency , \u03b7_max = 87.5 percent\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.7, Page number 420"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "V = 240.0      #Voltage rating of dc shunt motor(V)\n",
      "hp = 25.0      #Power rating of dc shunt motor(hp)\n",
      "S = 1100.0     #Speed of the dc shunt motor(rpm)\n",
      "R_a = 0.15     #Armture resistance(ohm)\n",
      "R_f = 80.0     #Field resistance(ohm)\n",
      "I_L = 89.0     #Rated line current(A)\n",
      "\n",
      "#Calculation\n",
      "V_f = V               #Voltage across field winding(V)\n",
      "I_f = V_f/R_f         #Field current(A)\n",
      "I_a = I_L-I_f         #Armature current(A)\n",
      "P_o = hp*746          #Power rating of dc shunt motor(W)\n",
      "V_a = V               #Voltage across armature(V)\n",
      "E_c_fl = V_a-I_a*R_a  #Back EMF(V)\n",
      "E_c = E_c_fl\n",
      "P_d = E_c*I_a         #Power developed by the armature(W)\n",
      "P_r = P_d-P_o         #Full-load rotational losses(W)\n",
      "P_in = V*I_L          #Input power(W)\n",
      "n = P_o/P_in*100      #Full-load efficiency(%)  \n",
      "P_k = V_f*I_f+P_r     #Total constant losses(W)\n",
      "Ia = (P_k/R_a)**0.5   #Armature current for maximum efficiency(A)\n",
      "I_a_rated = I_a\n",
      "LF = Ia/I_a_rated     #Load fraction at which max efficiency is produced\n",
      "rated_input = V*I_L \n",
      "n_max = ((LF*rated_input)-2*P_k)/(LF*rated_input)*100  #Maximum efficiency(%)\n",
      "\n",
      "#Result\n",
      "print('Case(a): Power developed by the armature , P_d = %.1f W' %P_d)\n",
      "print('Case(b): Full-load rotational losses , P_r = %.1f W' %P_r)\n",
      "print('Case(c): Full-laod efficiency , \u03b7 = %.1f percent' %n)\n",
      "print('Case(d): Total constant losses , P_k = %.1f W' %P_k)\n",
      "print('Case(e): Armature current from maximum efficiency , I_a = %.1f A' %Ia)\n",
      "print('Case(f): Load fraction at which maximum efficiency is produced , L.F = %.1f ' %LF)\n",
      "print('Case(g): Maximum efficiency , \u03b7_max = %.1f percent' %n_max)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case(a): Power developed by the armature , P_d = 19530.6 W\n",
        "Case(b): Full-load rotational losses , P_r = 880.6 W\n",
        "Case(c): Full-laod efficiency , \u03b7 = 87.3 percent\n",
        "Case(d): Total constant losses , P_k = 1600.6 W\n",
        "Case(e): Armature current from maximum efficiency , I_a = 103.3 A\n",
        "Case(f): Load fraction at which maximum efficiency is produced , L.F = 1.2 \n",
        "Case(g): Maximum efficiency , \u03b7_max = 87.5 percent\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.8, Page number 420"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "V = 240.0      #Voltage rating of dc shunt motor(V)\n",
      "hp = 5.0       #Power rating of dc shunt motor(hp)\n",
      "S_fl = 1100.0  #Speed of the dc shunt motor(rpm)\n",
      "R_a = 0.4      #Armture resistance(ohm)\n",
      "R_f = 240.0    #Field resistance(ohm)\n",
      "n = 0.75       #Full-load efficiency\n",
      "\n",
      "#Calculation\n",
      "#Case(a)\n",
      "V_L = V                    #Load voltage(V)\n",
      "P_o = hp*746               #Power rating of dc shunt motor(W)\n",
      "I_L = P_o/(n*V_L)          #Rated input line current(A)\n",
      "V_f = V                    #Voltage across field winding(V)\n",
      "I_f = V_f/R_f              #Field current(A)\n",
      "I_a = I_L-I_f              #Armature current(A)\n",
      "#Case(b)\n",
      "V_a = V                    #Voltage across armature(V)\n",
      "E_c_fl = V_a-I_a*R_a       #Back EMF(V)\n",
      "E_c = E_c_fl\n",
      "P_d = E_c*I_a              #Power developed in the armature at rated load(W)\n",
      "#Case(c)\n",
      "P_r = P_d-P_o              #Rotational losses at rated load(W)\n",
      "#Case(d)\n",
      "P_o_nl = 0                 #At no-load\n",
      "P_r_nl = P_r               #Rotational losses at no load(W)\n",
      "P_d_nl = P_r_nl\n",
      "#Case(e)\n",
      "I_a_nl = P_d_nl/V_a        #No-load armature current(A)\n",
      "#Case(f)\n",
      "E_c_nl = V                 #No-load voltage(V)\n",
      "E_c_fl = E_c               #Full-load voltage(V)\n",
      "S_nl = E_c_nl/E_c_fl*S_fl  #No-load speed(rpm)\n",
      "#Case(g)\n",
      "SR = (S_nl-S_fl)/S_fl*100  #Speed regulation(%)\n",
      "\n",
      "#Result\n",
      "print('Case(a): Rated input line current , I_L = %.2f A' %I_L)\n",
      "print('         Rated armature current , I_a = %.2f A' %I_a)\n",
      "print('Case(b): Power developed in the armature at rated load , P_d = %d W' %P_d)\n",
      "print('Case(c): Rotational losses at rated load , P_r = %d W' %P_r)\n",
      "print('Case(d): Rotational losses at no load , P_r = %d W' %P_r_nl)\n",
      "print('Case(e): No-load armature current , I_a(nl) = %.2f A' %I_a_nl)\n",
      "print('Case(f): No-load speed , S_nl = %.f rpm' %S_nl)\n",
      "print('Case(g): Speed regulation of the motor , SR = %.1f percent' %SR)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case(a): Rated input line current , I_L = 20.72 A\n",
        "         Rated armature current , I_a = 19.72 A\n",
        "Case(b): Power developed in the armature at rated load , P_d = 4577 W\n",
        "Case(c): Rotational losses at rated load , P_r = 847 W\n",
        "Case(d): Rotational losses at no load , P_r = 847 W\n",
        "Case(e): No-load armature current , I_a(nl) = 3.53 A\n",
        "Case(f): No-load speed , S_nl = 1137 rpm\n",
        "Case(g): Speed regulation of the motor , SR = 3.4 percent\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.9, Page number 421"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "V = 240.0      #Voltage rating of dc shunt motor(V)\n",
      "I_L = 55.0     #Rated line current(A) \n",
      "S = 1200.0     #Speed of the dc shunt motor(rpm)\n",
      "P_r = 406.4    #Rotational losses at rated load(W)\n",
      "R_f = 120.0    #Field resistance(ohm)\n",
      "R_a = 0.4      #Armture resistance(ohm)\n",
      "\n",
      "#Calculation\n",
      "#Case(a)\n",
      "V_f = V                    #Voltage across field winding(V)\n",
      "I_f = V_f/R_f              #Field current(A)\n",
      "I_a = I_L-I_f              #Armature current(A)\n",
      "V_a = V                    #Voltage across armature(V)\n",
      "E_c = V_a-I_a*R_a          #Back EMF(V)\n",
      "P_d = E_c*I_a              #Power developed by the armature at rated load(W)\n",
      "#Case(b)\n",
      "P_o = P_d-P_r              #Rated output power(W)\n",
      "P_o_hp = P_o/746           #Rated output power(hp)\n",
      "#Case(c)\n",
      "T_o = P_o_hp*5252/S        #Rated output torque(lb-ft)\n",
      "T_o_Nm = T_o*1.356         #Rated output torque(N-m)\n",
      "#Case(d)\n",
      "P_in = V*I_L               #Input power(W)\n",
      "n = (P_o/P_in)*100         #Efficiency at rated load(%)\n",
      "#Case(e)\n",
      "P_o_nl = 0                 #At no-load\n",
      "P_r_nl = P_r               #Rotational losses at no load(W)\n",
      "P_d_nl = P_r_nl\n",
      "I_a_nl = P_r_nl/V_a        #No-load armature current(A)\n",
      "E_c_nl = V                 #No-load voltage(V)\n",
      "E_c_fl = E_c               #Full-load voltage(V)\n",
      "S_fl = S                   #Full-load speed(rpm)\n",
      "S_nl = E_c_nl/E_c_fl*S_fl  #No-load speed(rpm)\n",
      "#Case(f)\n",
      "SR = (S_nl-S_fl)/S_fl*100  #Speed regulation(%)\n",
      "\n",
      "#Result\n",
      "print('Case(a): Counter EMF , E_c = %.1f V' %E_c)\n",
      "print('         Power developed at rated load , P_d = %.1f W' %P_d)\n",
      "print('Case(b): Rated output power , P_o = %d W' %P_o)\n",
      "print('         Rated output power , P_o = %d hp' %P_o_hp)\n",
      "print('Case(c): Rated output torque , T_o = %.2f lb-ft' %T_o)\n",
      "print('         Rated output torque , T_o = %d N-m' %T_o_Nm)\n",
      "print('Case(d): Efficiency at rated load , \u03b7 = %.1f percent' %n)\n",
      "print('Case(e): No-load armature current , I_a(nl)  = %.3f A' %I_a_nl)\n",
      "print('         No-load speed , S_nl = %.f rpm' %S_nl)\n",
      "print('Case(e): Speed regulation , SR = %.1f percent' %SR)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case(a): Counter EMF , E_c = 218.8 V\n",
        "         Power developed at rated load , P_d = 11596.4 W\n",
        "Case(b): Rated output power , P_o = 11190 W\n",
        "         Rated output power , P_o = 15 hp\n",
        "Case(c): Rated output torque , T_o = 65.65 lb-ft\n",
        "         Rated output torque , T_o = 89 N-m\n",
        "Case(d): Efficiency at rated load , \u03b7 = 84.8 percent\n",
        "Case(e): No-load armature current , I_a(nl)  = 1.693 A\n",
        "         No-load speed , S_nl = 1316 rpm\n",
        "Case(e): Speed regulation , SR = 9.7 percent\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.10, Page number 422"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "V = 125.0        #Voltage rating of generator(V)\n",
      "P_o = 12500.0    #Power rating of generator(W)\n",
      "P_hp = 20.0      #Power rating of motor(hp)\n",
      "R_a = 0.1        #Armature resistance(ohm)\n",
      "R_f = 62.5       #Field resistance(ohm)\n",
      "P_var = 1040.0   #Rated variable electric loss(W)\n",
      "\n",
      "#Calculation\n",
      "#Case(a)\n",
      "P_in = P_hp*746         #Power input to generator(W)\n",
      "n = P_o/P_in*100        #Efficiency(%)\n",
      "#Case(b)\n",
      "V_f = V                 #Voltage across shunt field winding(V)\n",
      "P_sh_loss = V_f**2/R_f  #Shunt field loss(W)\n",
      "#Case(c)\n",
      "V_L = V\n",
      "I_L = P_o/V_L           #Line current(A)\n",
      "I_f = V_f/R_f           #Field current(A)\n",
      "I_a = I_L+I_f           #Armature current(A)\n",
      "E_g = V_L+I_a*R_a       #Generated EMF(V)\n",
      "P_d1 = E_g*I_a          #Generated electric power(W)\n",
      "P_f = V_f*I_f\n",
      "P_d2 = P_o+P_var+P_f    #Generated electric power(W)\n",
      "#Case(d)\n",
      "P_d = P_d1\n",
      "P_r = P_in-P_d          #Rotational power loss(W)\n",
      "#Case(e)\n",
      "P_k = P_r+V_f*I_f       #Constant losses(W)\n",
      "Ia = (P_k/R_a)**0.5     #Armature current for max efficiency(A)\n",
      "#Case(f)\n",
      "I_a_rated = I_a         #Rated armature current(A)\n",
      "LF = Ia/I_a_rated       #Load fraction\n",
      "#Case(g)\n",
      "rated_output = 12500    #Rated output(W)\n",
      "n_max = (LF*rated_output)/((LF*rated_output)+(2*P_k))*100 #Maximum efficiency\n",
      "\n",
      "#Result\n",
      "print('Case(a): Efficiency , \u03b7 = %.f percent' %n)\n",
      "print('Case(b): Shunt field loss  = %d W' %P_sh_loss)\n",
      "print('Case(c): Generated electric power , P_d = %d W (Method 1)' %P_d1)\n",
      "print('         Generated electric power , P_d = %d W (Method 2)' %P_d2)\n",
      "print('Case(d): Rotational power loss , P_r = %.f W' %P_r)\n",
      "print('Case(e): Armature current for maximum efficiency , I_a = %.1f A' %Ia)\n",
      "print('Case(f): Load fraction for maximum efficiency , L.F = %.2f ' %LF)\n",
      "print('Case(g): Maximum efficiency , \u03b7 = %.2f percent' %n_max)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case(a): Efficiency , \u03b7 = 84 percent\n",
        "Case(b): Shunt field loss  = 250 W\n",
        "Case(c): Generated electric power , P_d = 13790 W (Method 1)\n",
        "         Generated electric power , P_d = 13790 W (Method 2)\n",
        "Case(d): Rotational power loss , P_r = 1130 W\n",
        "Case(e): Armature current for maximum efficiency , I_a = 117.5 A\n",
        "Case(f): Load fraction for maximum efficiency , L.F = 1.15 \n",
        "Case(g): Maximum efficiency , \u03b7 = 83.91 percent\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.11, Page number 422"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "V = 125.0        #Voltage rating of generator(V)\n",
      "P_o = 12500.0    #Power rating of generator(W)\n",
      "P_hp = 20.0      #Power rating of motor(hp)\n",
      "R_a = 0.1        #Armature resistance(ohm)\n",
      "R_f = 62.5       #Field resistance(ohm)\n",
      "P_var = 1040.0   #Rated variable electric loss(W)\n",
      "P_k = 1380.0     #Constant losses(W)\n",
      "LF_a = 25.0/100  #At rated output\n",
      "LF_b = 50.0/100  #At rated output\n",
      "LF_c = 75.0/100  #At rated output\n",
      "LF_d = 125.0/100 #At rated output\n",
      "\n",
      "#Calculation\n",
      "output = P_o\n",
      "P_a_rated = P_var\n",
      "n_a = output*LF_a/(output*LF_a+P_k+(LF_a**2)*P_a_rated)*100   #Efficiency of dc shunt generator(%)\n",
      "n_b = output*LF_b/(output*LF_b+P_k+(LF_b**2)*P_a_rated)*100   #Efficiency of dc shunt generator(%)\n",
      "n_c = output*LF_c/(output*LF_c+P_k+(LF_c**2)*P_a_rated)*100   #Efficiency of dc shunt generator(%)\n",
      "n_d = output*LF_d/(output*LF_d+P_k+(LF_d**2)*P_a_rated)*100   #Efficiency of dc shunt generator(%)\n",
      "\n",
      "#Result\n",
      "print('Case(a): Efficiency of dc generator at 25 percent rated output , \u03b7 = %.1f percent' %n_a)\n",
      "print('Case(b): Efficiency of dc generator at 50 percent rated output , \u03b7 = %.1f percent' %n_b)\n",
      "print('Case(c): Efficiency of dc generator at 75 percent rated output , \u03b7 = %.1f percent' %n_c)\n",
      "print('Case(d): Efficiency of dc generator at 125 percent rated output , \u03b7 = %.2f percent' %n_d)\n",
      "print('\\nNOTE: Calculation error in textbook for case(b)')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case(a): Efficiency of dc generator at 25 percent rated output , \u03b7 = 68.4 percent\n",
        "Case(b): Efficiency of dc generator at 50 percent rated output , \u03b7 = 79.2 percent\n",
        "Case(c): Efficiency of dc generator at 75 percent rated output , \u03b7 = 82.7 percent\n",
        "Case(d): Efficiency of dc generator at 125 percent rated output , \u03b7 = 83.87 percent\n",
        "\n",
        "NOTE: Calculation error in textbook for case(b)\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.12, Page number 426"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "kVA = 100.0           #Rating of the alternator(kVA)\n",
      "V  = 1100.0           #Rated voltage of the alternator(V)\n",
      "I_a_nl = 8.0          #No-load armature current(A)\n",
      "P_in_nl = 6000.0      #No-load Power input to the armature(W)\n",
      "V_oc = 1350.0         #Open-circuit line voltage(V)\n",
      "I_f = 18.0            #Field current(A)\n",
      "V_f = 125.0           #Voltage across field winding(V)\n",
      "R_a = 0.45            #Armature resistance(ohm/phase)\n",
      "I_a_rated = 52.5      #Rated armature current(A)\n",
      "\n",
      "#Calculation\n",
      "#Case(a)\n",
      "P_r = P_in_nl-3*(I_a_nl)**2*R_a   #Rotational loss of synchronous dynamo(W)\n",
      "#Case(b)\n",
      "P_f = V_f*I_f                     #Field copper loss(W)\n",
      "#Case(c)\n",
      "P_k = P_r+P_f                     #Fixed losses at rated synchronous speed(W)\n",
      "#Case(d)\n",
      "P_cu = 3*(I_a_rated)**2*R_a       #Electric armature copper loss at rated load(W)\n",
      "LF1 = 1.0/4                       #Load fraction\n",
      "LF2 = 1.0/2                       #Load fraction\n",
      "LF3 = 3.0/4                       #Load fraction\n",
      "P_cu_LF1 = P_cu*(LF1)**2          #Electric armature copper loss at 1/4 load(W)\n",
      "P_cu_LF2 = P_cu*(LF2)**2          #Electric armature copper loss at 1/2 load(W)\n",
      "P_cu_LF3 = P_cu*(LF3)**2          #Electric armature copper loss at 3/4 load(W)\n",
      "#Case(e)\n",
      "PF = 0.9                          #Power factor lagging\n",
      "n_1 = (LF1*kVA*1000*PF)/((LF1*kVA*1000*PF)+P_k+P_cu_LF1)*100   #Efficiency at 1/4 load\n",
      "n_2 = (LF2*kVA*1000*PF)/((LF2*kVA*1000*PF)+P_k+P_cu_LF2)*100   #Efficiency at 1/2 load\n",
      "n_3 = (LF3*kVA*1000*PF)/((LF3*kVA*1000*PF)+P_k+P_cu_LF3)*100   #Efficiency at 3/4 load\n",
      "n_fl = (kVA*1000*PF)/((kVA*1000*PF)+P_k+P_cu)*100              #Efficiency at rated load\n",
      "#Case(f)\n",
      "I_a_max = (P_k/(3*R_a))**0.5       #Armature current for max efficiency at 0.9 PF lagging(A)\n",
      "LF = I_a_max/I_a_rated             #Load fraction for max efficiency\n",
      "n_max = (LF*kVA*1000*PF)/((LF*kVA*1000*PF)+2*P_k)*100          #Max Efficiency 0.9 PF lagging(%) \n",
      "#Case(g)\n",
      "P_o = kVA*PF                       #Output power at 0.9 PF lagging(kW)\n",
      "I_a = I_a_rated\n",
      "P_d = P_o+(3*(I_a)**2*R_a/1000)+(V_f*I_f/1000)  #Armature power developed at 0.9 PF lagging at full-load(kW)\n",
      "\n",
      "#Result\n",
      "print('Case(a): Rotational loss of the synchronous dynamo , P_r = %.f W' %P_r)\n",
      "print('Case(b): Field copper loss , P_f = %.f W' %P_f)\n",
      "print('Case(c): Fixed losses at rated synchronous speed , P_k = %.f W' %P_k)\n",
      "print('Case(d): Electric armature copper loss at 1/4 rated load , P_cu = %.1f W' %P_cu_LF1)\n",
      "print('         Electric armature copper loss at 1/2 rated load , P_cu = %.1f W' %P_cu_LF2)\n",
      "print('         Electric armature copper loss at 3/4 rated load , P_cu = %.f W' %P_cu_LF3)\n",
      "print('         Electric armature copper loss at rated load , P_cu = %.f W' %P_cu)\n",
      "print('Case(e): Efficiency at 1/4 rated load , \u03b7 = %.1f percent' %n_1)\n",
      "print('         Efficiency at 1/2 rated load , \u03b7 = %.1f percent' %n_2)\n",
      "print('         Efficiency at 3/4 rated load , \u03b7 = %.1f percent' %n_3)\n",
      "print('         Efficiency at rated load , \u03b7 = %.1f percent' %n_fl)\n",
      "print('Case(f): Maximum efficiency at 0.9 PF lagging , \u03b7_max = %.1f percent' %n_max)\n",
      "print('Case(g): Armature power developed at 0.9 PF lagging at full load , P_d = %.2f kW' %P_d)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case(a): Rotational loss of the synchronous dynamo , P_r = 5914 W\n",
        "Case(b): Field copper loss , P_f = 2250 W\n",
        "Case(c): Fixed losses at rated synchronous speed , P_k = 8164 W\n",
        "Case(d): Electric armature copper loss at 1/4 rated load , P_cu = 232.6 W\n",
        "         Electric armature copper loss at 1/2 rated load , P_cu = 930.2 W\n",
        "         Electric armature copper loss at 3/4 rated load , P_cu = 2093 W\n",
        "         Electric armature copper loss at rated load , P_cu = 3721 W\n",
        "Case(e): Efficiency at 1/4 rated load , \u03b7 = 72.8 percent\n",
        "         Efficiency at 1/2 rated load , \u03b7 = 83.2 percent\n",
        "         Efficiency at 3/4 rated load , \u03b7 = 86.8 percent\n",
        "         Efficiency at rated load , \u03b7 = 88.3 percent\n",
        "Case(f): Maximum efficiency at 0.9 PF lagging , \u03b7_max = 89.1 percent\n",
        "Case(g): Armature power developed at 0.9 PF lagging at full load , P_d = 95.97 kW\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.13, Page number 430"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "kVA = 1000.0       #Rating of the alternator(kVA)\n",
      "V  = 2300.0        #Rated voltage of the alternator(V)\n",
      "hp = 100.0         #Power rating of the dc motor(hp)\n",
      "V_motor  = 240.0   #Rated voltage of the motor(V)\n",
      "P_1 = 7.5          #Motor output(kW). TEST 1\n",
      "P_2 = 16.0         #Motor output(kW). TEST 2\n",
      "VfIf = 14.0        #Field losses(kW)\n",
      "P_f = VfIf         #Field losses(kW)\n",
      "P_3 = 64.2         #Motor output(kW). TEST 3\n",
      "I_sc = 251.0       #Short circuit current(A)\n",
      "V_L = 1443.0       #Line voltage(V). TEST 4\n",
      "R_a = 0.3          #Armature resistance(ohm)\n",
      "\n",
      "#Calculation\n",
      "#Case(a)\n",
      "P_r = P_2                      #Rotational losses(kW). From TEST 2\n",
      "#Case(b)\n",
      "P_cu = P_3-P_1                 #Full-load armature copper loss(kW)\n",
      "#Case(c)\n",
      "E_gL = V_L                     #Generated line voltage(V)\n",
      "Z_s = (E_gL/3**0.5)/I_sc       #Synchronous impedance of the armature(ohm)\n",
      "#Case(d)\n",
      "X_s = (Z_s**2-R_a**2)**0.5     #Synchronous reactance of the armature(ohm)\n",
      "#Case(e)\n",
      "PF = 0.8                       #Lagging power factor\n",
      "sin_theta = (1-PF**2)**0.5     #Sin\u03b8\n",
      "V_p = V/3**0.5                 #Phase voltage(V)\n",
      "I_a = I_sc                     #Armature current(A)\n",
      "E_gp = complex((V_p*PF+I_a*R_a),(V_p*sin_theta+I_a*X_s)) #Generated phase voltage(V)\n",
      "V_nl = abs(E_gp)                #No-load voltage(V)\n",
      "V_fl = V_p                      #Full-load voltage(V)\n",
      "VR = (V_nl-V_fl)/V_fl*100       #Alternator voltage regulation(%)\n",
      "#Case(f)\n",
      "LF = 1.0                        #Load fraction\n",
      "n_rated = (LF*kVA*PF)/((LF*kVA*PF)+(P_f+P_r)+P_cu)*100   #Efficiency at 0.8 lagging PF(%)\n",
      "#Case(g)\n",
      "P_k = (P_f+P_r)                 #Constant losses(kW)\n",
      "L_F = (P_k/P_cu)**0.5           #Load fraction for max efficiency\n",
      "n_max = (L_F*kVA*PF)/((L_F*kVA*PF)+2*P_k)*100            #Max Efficiency at 0.8 lagging PF(%)\n",
      "#Case(h)\n",
      "PF_h = 1.0                      #Unity PF\n",
      "P_o = kVA*PF_h                  #Output power(kW)\n",
      "P_d = P_o+(3*(I_a)**2*R_a/1000)+(VfIf)                   #Armature power developed at rated-load unity PF(kW) \n",
      "\n",
      "#Result\n",
      "print('Case(a): Rotational losses , P_r = %.1f kW' %P_r)\n",
      "print('Case(b): Full-load armature copper loss , P_cu = %.1f kW' %P_cu)\n",
      "print('Case(c): Synchronous impedance of the armature , Z_s = %.2f \u03a9' %Z_s)\n",
      "print('Case(d): Synchronous reactance of the armature , jX_s = %.2f \u03a9' %X_s)\n",
      "print('Case(e): Alternator voltage regulation at 0.8 PF lagging , VR = %.2f percent' %VR)\n",
      "print('Case(f): Alternator efficiency at 0.8 PF lagging at rated load , \u03b7_rated = %.1f percent' %n_rated)\n",
      "print('Case(g): Maximum efficiency at 0.8 PF lagging , \u03b7_max = %.2f percent' %n_max)\n",
      "print('Case(h): Power developed by the alternator armature at rated load, unity PF , P_d = %.f kW' %P_d)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case(a): Rotational losses , P_r = 16.0 kW\n",
        "Case(b): Full-load armature copper loss , P_cu = 56.7 kW\n",
        "Case(c): Synchronous impedance of the armature , Z_s = 3.32 \u03a9\n",
        "Case(d): Synchronous reactance of the armature , jX_s = 3.31 \u03a9\n",
        "Case(e): Alternator voltage regulation at 0.8 PF lagging , VR = 49.47 percent\n",
        "Case(f): Alternator efficiency at 0.8 PF lagging at rated load , \u03b7_rated = 90.2 percent\n",
        "Case(g): Maximum efficiency at 0.8 PF lagging , \u03b7_max = 90.65 percent\n",
        "Case(h): Power developed by the alternator armature at rated load, unity PF , P_d = 1071 kW\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.14, Page number 434"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "P = 4.0       #Number of poles in Induction motor\n",
      "f = 60.0      #Frequency(Hz)\n",
      "V = 220.0     #Rated voltage of IM(V)\n",
      "hp_IM = 5.0   #Power rating of IM(hp)\n",
      "PF = 0.9      #Power factor\n",
      "I_L = 16.0    #Line current(A)\n",
      "S = 1750.0    #Speed of IM(rpm)\n",
      "I_nl = 6.5    #No-load line current(A)\n",
      "V_nl = 220.0  #No-load line voltage(V)\n",
      "P_nl = 300.0  #No-load power reading(W)\n",
      "I_br = 16.0   #Blocked rotor line current(A)\n",
      "V_br = 50.0   #Blocked rotor voltage(V)\n",
      "P_br = 800.0  #Blocked rotor power reading(W)\n",
      "\n",
      "#Calculation\n",
      "#Case(a)\n",
      "P_cu = P_br                   #Full-load equivalent copper loss(W)\n",
      "I_1 = I_br                    #Primary current(A)\n",
      "R_e1 = P_cu/(3.0/2*I_1**2)    #Equivalent total resistance of IM(ohm) \n",
      "#Case(b)\n",
      "P_in = P_nl                   #Input power to IM(W)\n",
      "I1 = I_nl                     #Input current(A)\n",
      "P_r = P_in-(3.0/2*I1**2*R_e1) #Rotational losses(W)\n",
      "#Case(c)\n",
      "LF1 = 1.0/4                   #Load fraction\n",
      "LF2 = 1.0/2                   #Load fraction\n",
      "LF3 = 3.0/4                   #Load fraction\n",
      "LF4 = 5.0/4                   #Load fraction\n",
      "P_cu_LF1 = LF1**2*P_cu        #Equivalent copper loss at 1/4 rated-load(W)\n",
      "P_cu_LF2 = LF2**2*P_cu        #Equivalent copper loss at 1/2 rated-load(W)\n",
      "P_cu_LF3 = LF3**2*P_cu        #Equivalent copper loss at 3/4 rated-load(W)\n",
      "P_cu_LF4 = LF4**2*P_cu        #Equivalent copper loss at 5/4 rated-load(W)\n",
      "#Case(d)\n",
      "Full_load_input = 3**0.5*V*I_L*PF #Full-load input(W)\n",
      "n_rated = (Full_load_input-(P_r+P_cu))/(Full_load_input)*100              #Efficiency at rated load(%)\n",
      "n_LF1 = (Full_load_input*LF1-(P_r+P_cu_LF1))/(Full_load_input*LF1)*100    #Efficiency at 1/4 rated load(%)\n",
      "n_LF2 = (Full_load_input*LF2-(P_r+P_cu_LF2))/(Full_load_input*LF2)*100    #Efficiency at 1/2 rated load(%)\n",
      "n_LF3 = (Full_load_input*LF3-(P_r+P_cu_LF3))/(Full_load_input*LF3)*100    #Efficiency at 3/4 rated load(%)\n",
      "n_LF4 = (Full_load_input*LF4-(P_r+P_cu_LF4))/(Full_load_input*LF4)*100    #Efficiency at 5/4 rated load(%)\n",
      "#Case(e)\n",
      "P_o = (Full_load_input*n_rated/100)/746          #Output hp at 1/4 rated load\n",
      "P_o_LF1 = (Full_load_input*LF1*n_LF1/100)/746    #Output hp at 1/4 rated load\n",
      "P_o_LF2 = (Full_load_input*LF2*n_LF2/100)/746    #Output hp at 1/2 rated load\n",
      "P_o_LF3 = (Full_load_input*LF3*n_LF3/100)/746    #Output hp at 3/4 rated load\n",
      "P_o_LF4 = (Full_load_input*LF4*n_LF4/100)/746    #Output hp at 5/4 rated load\n",
      "#Case(f)\n",
      "hp = P_o                                         #Rated output(hp)\n",
      "T_o = P_o*5252/S                                 #Output torque at full-load(lb-ft)\n",
      "T_o_Nm = T_o*1.356                               #Output torque at full-load(N-m)\n",
      "\n",
      "#Result\n",
      "print('Case(a): Equivalent total resistance of IM between lines , R_e1 = %.3f \u03a9' %R_e1)\n",
      "print('Case(b): Rotational losses , P_r = %.f W' %P_r)\n",
      "print('Case(c): Equivalent copper loss at full-load , P_cu = %d W' %P_cu)\n",
      "print('         Equivalent copper loss at 1/4 rated load , P_cu = %d W' %P_cu_LF1)\n",
      "print('         Equivalent copper loss at 1/2 rated load , P_cu = %d W' %P_cu_LF2)\n",
      "print('         Equivalent copper loss at 3/4 rated load , P_cu = %d W' %P_cu_LF3)\n",
      "print('         Equivalent copper loss at 5/4 rated load , P_cu = %d W' %P_cu_LF4)\n",
      "print('Case(d): Efficiency at rated load , \u03b7 = %.1f percent' %n_rated)\n",
      "print('         Efficiency at 1/4 rated load , \u03b7 = %.1f percent' %n_LF1)\n",
      "print('         Efficiency at 1/2 rated load , \u03b7 = %.1f percent' %n_LF2)\n",
      "print('         Efficiency at 3/4 rated load , \u03b7 = %.1f percent' %n_LF3)\n",
      "print('         Efficiency at 5/4 rated load , \u03b7 = %.1f percent' %n_LF4)\n",
      "print('Case(e): Output horsepower at rated load , P_o = %.2f hp' %P_o)\n",
      "print('         Output horsepower at 1/4 rated load , P_o = %.3f hp' %P_o_LF1)\n",
      "print('         Output horsepower at 1/2 rated load , P_o = %.3f hp' %P_o_LF2)\n",
      "print('         Output horsepower at 3/4 rated load , P_o = %.2f hp' %P_o_LF3)\n",
      "print('         Output horsepower at 5/4 rated load , P_o = %.2f hp' %P_o_LF4)\n",
      "print('Case(f): Output torque at full-load , T_o = %.1f lb-ft' %T_o)\n",
      "print('         Output torque at full-load , T_o = %.2f N-m' %T_o_Nm)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case(a): Equivalent total resistance of IM between lines , R_e1 = 2.083 \u03a9\n",
        "Case(b): Rotational losses , P_r = 168 W\n",
        "Case(c): Equivalent copper loss at full-load , P_cu = 800 W\n",
        "         Equivalent copper loss at 1/4 rated load , P_cu = 50 W\n",
        "         Equivalent copper loss at 1/2 rated load , P_cu = 200 W\n",
        "         Equivalent copper loss at 3/4 rated load , P_cu = 450 W\n",
        "         Equivalent copper loss at 5/4 rated load , P_cu = 1250 W\n",
        "Case(d): Efficiency at rated load , \u03b7 = 82.4 percent\n",
        "         Efficiency at 1/4 rated load , \u03b7 = 84.1 percent\n",
        "         Efficiency at 1/2 rated load , \u03b7 = 86.6 percent\n",
        "         Efficiency at 3/4 rated load , \u03b7 = 85.0 percent\n",
        "         Efficiency at 5/4 rated load , \u03b7 = 79.3 percent\n",
        "Case(e): Output horsepower at rated load , P_o = 6.06 hp\n",
        "         Output horsepower at 1/4 rated load , P_o = 1.547 hp\n",
        "         Output horsepower at 1/2 rated load , P_o = 3.184 hp\n",
        "         Output horsepower at 3/4 rated load , P_o = 4.69 hp\n",
        "         Output horsepower at 5/4 rated load , P_o = 7.29 hp\n",
        "Case(f): Output torque at full-load , T_o = 18.2 lb-ft\n",
        "         Output torque at full-load , T_o = 24.65 N-m\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.15, Page number 438"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "pole = 4.0    #Number of poles in Induction motor\n",
      "f = 60.0      #Frequency(Hz)\n",
      "V = 220.0     #Rated voltage of IM(V)\n",
      "hp_IM = 5.0   #Power rating of IM(hp)\n",
      "PF = 0.9      #Power factor\n",
      "I_L = 16.0    #Line current(A)\n",
      "S_r = 1750.0  #Speed of IM(rpm)\n",
      "I_nl = 6.5    #No-load line current(A)\n",
      "V_nl = 220.0  #No-load line voltage(V)\n",
      "P_nl = 300.0  #No-load power reading(W)\n",
      "I_br = 16.0   #Blocked rotor line current(A)\n",
      "V_br = 50.0   #Blocked rotor voltage(V)\n",
      "P_br = 800.0  #Blocked rotor power reading(W)\n",
      "R_dc = 1.0    #DC resistance between lines(ohm)\n",
      "V = 220.0     #Voltage rating(V)\n",
      "P_input = 5500.0 #Power drawn(W)\n",
      "\n",
      "#Calculation\n",
      "R_e1 = 1.25*R_dc                    #Equivalent total resistance of IM(ohm)\n",
      "P_in = P_nl                         #Input power to IM(W)\n",
      "I1 = I_nl                           #Input current(A)\n",
      "P_r = P_in-(3.0/2*(I1)**2*R_e1)     #Rotational losses(W)\n",
      "I_1 = I_L\n",
      "SCL_fl = 3.0/2*(I_1)**2*R_e1        #Stator copper loss at full-load(W)\n",
      "SPI = P_input                       #Stator power input(W)\n",
      "RPI = SPI-SCL_fl                    #Rotor power input(W)\n",
      "S = (120*f/pole)                    #Speed of synchronous magnetic field(rpm)\n",
      "s = (S-S_r)/S                       #Slip\n",
      "RPD_fl = RPI*(1-s)                  #Rotor power developed(W)\n",
      "RPO_fl = RPD_fl-P_r                 #Rotor power output(W)\n",
      "#Case(a)\n",
      "P_o = RPO_fl\n",
      "n_fl = (P_o/P_input)*100            #Full-load efficiency(%)\n",
      "#Case(b)\n",
      "hp = P_o/746                        #Output horsepower at full load\n",
      "T_o = hp*5252/S_r                   #Output torque(lb-ft)\n",
      "T_o_Nm = T_o*1.356                  #Output torque(N-m)\n",
      "\n",
      "#Result\n",
      "print('Case(a): Full-load efficiency , \u03b7_fl = %.1f percent' %n_fl)\n",
      "print('Case(b): Output horsepower , hp = %.2f hp at full load' %hp)\n",
      "print('         Output torque , T_o = %.1f lb-ft = %.1f N-m' %(T_o,T_o_Nm))\n",
      "print('Case(c): Comparison of results')\n",
      "print('\\t\\t\\t\\t Ex. 12-14 \\t\\t Ex. 12-15')\n",
      "print('________________________________________________________________________')\n",
      "print('\u03b7_fl(percent)\\t\\t\\t 82.4 \\t\\t\\t %.1f' %n_fl)\n",
      "print('Rated output(hp)\\t\\t 6.06 \\t\\t\\t %.2f' %hp)\n",
      "print('Rated output torque(lb-ft)\\t 18.2 \\t\\t\\t %.1f' %T_o)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case(a): Full-load efficiency , \u03b7_fl = 84.7 percent\n",
        "Case(b): Output horsepower , hp = 6.25 hp at full load\n",
        "         Output torque , T_o = 18.7 lb-ft = 25.4 N-m\n",
        "Case(c): Comparison of results\n",
        "\t\t\t\t Ex. 12-14 \t\t Ex. 12-15\n",
        "________________________________________________________________________\n",
        "\u03b7_fl(percent)\t\t\t 82.4 \t\t\t 84.7\n",
        "Rated output(hp)\t\t 6.06 \t\t\t 6.25\n",
        "Rated output torque(lb-ft)\t 18.2 \t\t\t 18.7\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.16, Page number 440"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import cmath\n",
      "import numpy\n",
      "\n",
      "#Variable declaration\n",
      "P = 6.0            #Number of poles in SCIM \n",
      "S_r = 1176.0       #Rated rotor speed(rpm)\n",
      "V = 220.0          #Voltage rating of SCIM(V)\n",
      "f = 60.0           #Frequency(Hz)\n",
      "P_hp = 7.5         #Power rating of SCIM(hp)\n",
      "R_ap = 0.3         #Armature resistance(ohm)\n",
      "R_r = 0.144        #Rotor resistance(ohm)\n",
      "jXm = 13.5         #Reactance(ohm)\n",
      "jXs = 0.5          #Synchronous reactance(ohm)\n",
      "jXlr = 0.2         #Locked rotor reactance(ohm)\n",
      "P_r = 300.0        #Total rotational losses(W)\n",
      "\n",
      "#Calculation\n",
      "#Case(a)\n",
      "S = 120*f/P        #Speed of the rotating magnetic field(rpm)\n",
      "s = (S-S_r)/S      #Slip\n",
      "R_r_s = R_r/s\n",
      "V_p = V/3**0.5     #Voltage per phase(V)\n",
      "I1_1 = complex(R_ap,jXm+jXs)\n",
      "I1_2 = complex(0,-jXm)\n",
      "I2_1 = complex(0,-jXm)\n",
      "I2_2 = complex(R_r/s,jXm+jXlr)\n",
      "V_1 = V_p\n",
      "V_2 = 0\n",
      "A = [[I1_1,I2_1],[I1_2,I2_2]]        #Matrix containing above mesh eqns array\n",
      "delta = numpy.linalg.det(A)          #Determinant of A\n",
      "#Case(b)\n",
      "I_p = numpy.linalg.det([[V_1,I2_1],[V_2,I2_2]])/delta #Stator armature current(A)\n",
      "I_1 = I_p\n",
      "#Case(c)\n",
      "I_r = numpy.linalg.det([[I1_1,V_1],[I1_2,V_2]])/delta #Rotor armature current(A)\n",
      "I_2 = I_r\n",
      "#Case(d)\n",
      "theta_1 = cmath.phase(I_p)*180/math.pi           #Motor PF angle(degrees)\n",
      "cos_theta1 = math.cos(theta_1*math.pi/180)       #Motor PF\n",
      "#Case(e)\n",
      "SPI = V_p*abs(I_p)*cos_theta1                    #Stator power input(W)\n",
      "#Case(f)\n",
      "SCL = abs(I_p)**2*R_ap                           #Stator Copper Loss(W)\n",
      "#Case(g)\n",
      "RPI = SPI-SCL                                    #Rotor power input(W) Method 1\n",
      "RPI_2 = abs(I_r)**2*(R_r/s)                      #Rotor power input(W) Method 2\n",
      "#Case(h)\n",
      "RCL = s*RPI                                      #Rotor copper losses(W)\n",
      "#Case(i)\n",
      "RPD_1 = RPI-RCL                                  #Rotor power developed(W) Method 1\n",
      "RPD_2 = RPI*(1-s)                                #Rotor power developed(W) Method 2\n",
      "#Case(j)\n",
      "RPO = 3*RPD_1-P_r                                #Total three-phase rotor power output(W)\n",
      "#Case(k)\n",
      "P_to = RPO                                       #Total rotor power at the motor pulley(W)\n",
      "T_o = 7.04*(P_to/S_r)                            #Total 3-phase torque(lb-ft)\n",
      "#Case(l)\n",
      "hp = P_to/746.0                                  #Output horsepower(hp)\n",
      "#Case(m)\n",
      "P_in = 3*SPI                                     #Input power to stator(W)\n",
      "n = P_to/P_in*100                                #Motor efficiency at rated load(%)\n",
      "\n",
      "#Result\n",
      "print('Case(a): Slip , s = %.2f' %s)\n",
      "print('         R_r/s = %.1f \u03a9' %R_r_s)\n",
      "print('Case(b): Stator armature current per phase , I_p = %.2f\u2220%.2f\u00b0 A' %(abs(I_p),cmath.phase(I_p)*180/math.pi))\n",
      "print('Case(c): Rotor current per phase , I_r = %.1f\u2220%.2f\u00b0 A' %(abs(I_r),cmath.phase(I_r)*180/math.pi))\n",
      "print('Case(d): Motor power factor , cos\u04e8 = %.3f' %cos_theta1)\n",
      "print('Case(e): Stator power input per phase , SPI = %d W' %SPI)\n",
      "print('Case(f): Stator copper loss per phase , SCL = %.1f W' %SCL)\n",
      "print('Case(g): Rotor power input per phase , RPI = %.2f W (Method 1)' %RPI)\n",
      "print('         Rotor power input per phase , RPI = %.2f W (Method 2)' %RPI_2)\n",
      "print('Case(h): Rotor copper loss per phase , RCL = %.1f W' %RCL)\n",
      "print('Case(i): Rotor power developed per phase , RPD = %.1f W (Method 1)' %RPD_1)\n",
      "print('         Rotor power developed per phase , RPD = %.1f W (Method 2)' %RPD_2)\n",
      "print('Case(j): Total three-phase rotor power output at shaft , RPO = %.1f W' %RPO)\n",
      "print('Case(k): Total torque developed at output , T_o = %.2f lb-ft' %T_o)\n",
      "print('Case(l): Horsepower output , hp = %.2f hp' %hp)\n",
      "print('Case(m): Efficiency at rated load , \u03b7 = %.2f percent' %n)\n",
      "print('Case(n): Power flow diagram is shown in textbook Fig. 12-12 page no 441')\n",
      "print('\\nNOTE: Changes in obtained answer from that of textbook is due to more precision i.e more number of decimal places')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case(a): Slip , s = 0.02\n",
        "         R_r/s = 7.2 \u03a9\n",
        "Case(b): Stator armature current per phase , I_p = 18.69\u2220-31.75\u00b0 A\n",
        "Case(c): Rotor current per phase , I_r = 16.3\u2220-4.03\u00b0 A\n",
        "Case(d): Motor power factor , cos\u04e8 = 0.850\n",
        "Case(e): Stator power input per phase , SPI = 2018 W\n",
        "Case(f): Stator copper loss per phase , SCL = 104.8 W\n",
        "Case(g): Rotor power input per phase , RPI = 1913.99 W (Method 1)\n",
        "         Rotor power input per phase , RPI = 1913.99 W (Method 2)\n",
        "Case(h): Rotor copper loss per phase , RCL = 38.3 W\n",
        "Case(i): Rotor power developed per phase , RPD = 1875.7 W (Method 1)\n",
        "         Rotor power developed per phase , RPD = 1875.7 W (Method 2)\n",
        "Case(j): Total three-phase rotor power output at shaft , RPO = 5327.1 W\n",
        "Case(k): Total torque developed at output , T_o = 31.89 lb-ft\n",
        "Case(l): Horsepower output , hp = 7.14 hp\n",
        "Case(m): Efficiency at rated load , \u03b7 = 87.96 percent\n",
        "Case(n): Power flow diagram is shown in textbook Fig. 12-12 page no 441\n",
        "\n",
        "NOTE: Changes in obtained answer from that of textbook is due to more precision i.e more number of decimal places\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.17, Page number 442"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "V = 220.0             #Voltage rating of SCIM(V)\n",
      "P_hp = 7.5            #Power rating of SCIM(hp)\n",
      "kVA_up_limit = 7.99   #Upper limit of starting kVA/hp\n",
      "kVA_low_limit = 7.1   #Lower limit of starting kVA/hp\n",
      "\n",
      "#Calculation\n",
      "I_s_u = kVA_up_limit*P_hp*1000/(3**0.5*V)  #Upper limit of starting current(A)\n",
      "I_s_l = kVA_low_limit*P_hp*1000/(3**0.5*V) #Lower limit of starting current(A)\n",
      "\n",
      "#Result\n",
      "print('Case(a): Upper limit of the starting current , I_s = %.1f A' %I_s_u)\n",
      "print('Case(b): Lower limit of the starting current , I_s = %.1f A' %I_s_l)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case(a): Upper limit of the starting current , I_s = 157.3 A\n",
        "Case(b): Lower limit of the starting current , I_s = 139.7 A\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.18, Page number 442"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import cmath\n",
      "import numpy\n",
      "\n",
      "#Variable declaration\n",
      "P = 6.0            #Number of poles in SCIM \n",
      "S_r = 1176.0       #Rated rotor speed(rpm)\n",
      "V = 220.0          #Voltage rating of SCIM(V)\n",
      "f = 60.0           #Frequency(Hz)\n",
      "P_hp = 7.5         #Power rating of SCIM(hp)\n",
      "R_ap = 0.3         #Armature resistance(ohm)\n",
      "R_r = 0.144        #Rotor resistance(ohm)\n",
      "jXm = 13.5         #Reactance(ohm)\n",
      "jXs = 0.5          #Synchronous reactance(ohm)\n",
      "jXlr = 0.2         #Locked rotor reactance(ohm)\n",
      "P_r = 300.0        #Total rotational losses(W)\n",
      "s = 1.0            #Unity slip\n",
      "\n",
      "#Calculation\n",
      "R_r_s = R_r/s\n",
      "V_p = V/3**0.5     #Voltage per phase(V)\n",
      "I1_1 = complex(R_ap,jXm+jXs)\n",
      "I1_2 = complex(0,-jXm)\n",
      "I2_1 = complex(0,-jXm)\n",
      "I2_2 = complex(R_r/s,jXm+jXlr)\n",
      "V_1 = V_p\n",
      "V_2 = 0\n",
      "A = [[I1_1,I2_1],[I1_2,I2_2]]        #Matrix containing above mesh eqns array\n",
      "delta = numpy.linalg.det(A)          #Determinant of A\n",
      "#Case(a)\n",
      "I_s = numpy.linalg.det([[V_1,I2_1],[V_2,I2_2]])/delta #Stator armature current(A)\n",
      "I_1 = I_s\n",
      "#Case(b)\n",
      "theta = cmath.phase(I_s)*180/math.pi     #Phase angle of Stator armature current(degree)\n",
      "cos_theta = math.cos(theta*math.pi/180)  #PF of the motor at starting\n",
      "\n",
      "#Result\n",
      "print('Case(a): Starting stator current of the SCIM , I_s = I_1 = %.1f\u2220%.1f\u00b0 A' %(abs(I_s),theta))\n",
      "print('Case(b): Power factor of the motor at starting , cos\u03b8 = %.3f ' %cos_theta)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case(a): Starting stator current of the SCIM , I_s = I_1 = 153.9\u2220-57.8\u00b0 A\n",
        "Case(b): Power factor of the motor at starting , cos\u03b8 = 0.533 \n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.19, Page number 445"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "V = 220.0         #Rated voltage of SCIM(V)\n",
      "f = 60.0          #Frequency(Hz)\n",
      "P = 4.0           #Number of poles\n",
      "PF = 0.85         #Power factor of capacitor-start IM\n",
      "hp_IM = 5.0       #Power rating of IM(hp)\n",
      "I_L = 28.0        #Rated line current(A)\n",
      "S_r = 1620.0      #Rotor speed of IM(rpm)\n",
      "I_nl = 6.4        #No-load line current(A)\n",
      "V_nl = 220.0      #No-load line voltage(V)\n",
      "P_nl = 239.0      #No-load power reading(W)\n",
      "s_nl = 0.01       #No-load slip\n",
      "I_br = 62.0       #Blocked rotor line current(A)\n",
      "V_br = 64.0       #Blocked rotor voltage(V)\n",
      "P_br = 1922.0     #Blocked rotor power reading(W)\n",
      "s_br = 1.0        #Blocked rotor slip\n",
      "\n",
      "#Calculation\n",
      "#Case(a)\n",
      "R_els = P_br/I_br**2           #Equivalent total resistance of IM(ohm)\n",
      "#Case(b)\n",
      "P_in = P_nl                    #Input power to IM(W)\n",
      "I_ls = I_nl                    #Input current(A)\n",
      "P_ro = P_in-(I_ls**2*R_els)    #Rotational losses(W)\n",
      "#Case(c)\n",
      "S = (120*f/P)                  #Speed of synchronous magnetic field(rpm)\n",
      "S_fl = S_r                     #Full-load rotor speed of IM(rpm) \n",
      "s_fl = (S-S_fl)/S              #Full-load Slip \n",
      "LF1 = 1.0/4                    #Load fraction\n",
      "LF2 = 1.0/2                    #Load fraction\n",
      "LF3 = 3.0/4                    #Load fraction\n",
      "LF4 = 5.0/4                    #Load fraction\n",
      "s_LF1 = s_fl*LF1               #slip at 1/4 rated load\n",
      "s_LF2 = s_fl*LF2               #slip at 1/2 rated load\n",
      "s_LF3 = s_fl*LF3               #slip at 3/4 rated load\n",
      "s_LF4 = s_fl*LF4               #slip at 5/4 rated load\n",
      "#Case(d)\n",
      "s_o = s_nl                          #No-load slip\n",
      "P_rs_fl = P_ro*(1-s_fl)/(1-s_o)     #Rotational losses rated load(W)\n",
      "P_rs_LF1 = P_ro*(1-s_LF1)/(1-s_o)   #Rotational losses at 1/4 rated load(W)\n",
      "P_rs_LF2 = P_ro*(1-s_LF2)/(1-s_o)   #Rotational losses at 1/2 rated load(W)\n",
      "P_rs_LF3 = P_ro*(1-s_LF3)/(1-s_o)   #Rotational losses at 3/4 rated load(W)\n",
      "P_rs_LF4 = P_ro*(1-s_LF4)/(1-s_o)   #Rotational losses at 5/4 rated load(W)\n",
      "#Case(e)\n",
      "Ils = I_L                           #Line current(A)\n",
      "P_cu_fl = Ils**2*R_els              #Equivalent copper loss at full-load slip(W)\n",
      "P_cu_LF1 = LF1**2*P_cu_fl           #Equivalent copper loss at 1/4 rated load(W)\n",
      "P_cu_LF2 = LF2**2*P_cu_fl           #Equivalent copper loss at 1/2 rated load(W)\n",
      "P_cu_LF3 = LF3**2*P_cu_fl           #Equivalent copper loss at 3/4 rated load(W)\n",
      "P_cu_LF4 = LF4**2*P_cu_fl           #Equivalent copper loss at 5/4 rated load(W)\n",
      "#Case(f)\n",
      "Input = V*I_L*PF                    #Input to single phase capacitor start IM(W)\n",
      "n_LF1 = (Input*LF1-(P_rs_LF1+P_cu_LF1))/(Input*LF1)*100   #Efficiency at 1/4 rated load(%)\n",
      "n_LF2 = (Input*LF2-(P_rs_LF2+P_cu_LF2))/(Input*LF2)*100   #Efficiency at 1/2 rated load(%)\n",
      "n_LF3 = (Input*LF3-(P_rs_LF3+P_cu_LF3))/(Input*LF3)*100   #Efficiency at 3/4 rated load(%)\n",
      "n_LF4 = (Input*LF4-(P_rs_LF4+P_cu_LF4))/(Input*LF4)*100   #Efficiency at 5/4 rated load(%)\n",
      "n_fl = (Input-(P_rs_fl+P_cu_fl))/(Input)*100              #Efficiency at full load(%)\n",
      "#Case(g)\n",
      "P_o_LF1 = (Input*LF1*n_LF1/100)/746                       #Output hp at 1/4 rated load\n",
      "P_o_LF2 = (Input*LF2*n_LF2/100)/746                       #Output hp at 1/2 rated load\n",
      "P_o_LF3 = (Input*LF3*n_LF3/100)/746                       #Output hp at 3/4 rated load\n",
      "P_o_LF4 = (Input*LF4*n_LF4/100)/746                       #Output hp at 5/4 rated load\n",
      "P_o = (Input*n_fl/100)/746                                #Output hp at rated load\n",
      "#Case(h)\n",
      "hp = P_o                                                  #Rated output horsepower\n",
      "S_fl = S_r                                                #Full-load rotor speed(rpm)\n",
      "T_o = P_o*5252/S_fl                                       #Output torque at full-load(lb-ft)\n",
      "T_o_ST = T_o*1.356                                        #Output torque at full-load(N-m)\n",
      "\n",
      "#Result\n",
      "print('Case(a): Equivalent total resistance of motor between lines , R_els = %.1f \u03a9' %R_els)\n",
      "print('Case(b): Rotational losses at no load , P_ro = %.1f W' %P_ro)\n",
      "print('Case(c): Slip at rated load , s_fl = %.1f ' %s_fl)\n",
      "print('         Slip at 1/4 rated load , s = %.3f ' %s_LF1)\n",
      "print('         Slip at 1/2 rated load , s = %.2f ' %s_LF2)\n",
      "print('         Slip at 3/4 rated load , s = %.3f ' %s_LF3)\n",
      "print('         Slip at 5/4 rated load , s = %.3f ' %s_LF4)\n",
      "print('Case(d): Rotational loss at rated load , P_r = %.1f W' %P_rs_fl)\n",
      "print('         Rotational loss at 1/4 load , P_r = %.1f W' %P_rs_LF1)\n",
      "print('         Rotational loss at 1/2 load , P_r = %.2f W' %P_rs_LF2)\n",
      "print('         Rotational loss at 3/4 load , P_r = %.1f W' %P_rs_LF3)\n",
      "print('         Rotational loss at 5/4 load , P_r = %.1f W' %P_rs_LF4)\n",
      "print('Case(e): Equivalent copper loss at rated load , P_cu = %.f W' %P_cu_fl)\n",
      "print('         Equivalent copper loss at 1/4 load , P_cu = %.1f W' %P_cu_LF1)\n",
      "print('         Equivalent copper loss at 1/2 load , P_cu = %.f W' %P_cu_LF2)\n",
      "print('         Equivalent copper loss at 3/4 load , P_cu = %.1f W' %P_cu_LF3)\n",
      "print('         Equivalent copper loss at 5/4 load , P_cu = %.1f W' %P_cu_LF4)\n",
      "print('Case(f): Efficiency at rated load , \u03b7 = %.1f W' %n_fl)\n",
      "print('         Efficiency at 1/4 rated load , \u03b7 = %.1f W' %n_LF1)\n",
      "print('         Efficiency at 1/2 rated load , \u03b7 = %.1f W' %n_LF2)\n",
      "print('         Efficiency at 3/4 rated load , \u03b7 = %.1f W' %n_LF3)\n",
      "print('         Efficiency at 5/4 rated load , \u03b7 = %.1f W' %n_LF4)\n",
      "print('Case(g): Output horsepower at rated load , P_o = %.2f hp' %P_o)\n",
      "print('         Output horsepower at 1/4 rated load , P_o = %.2f hp' %P_o_LF1)\n",
      "print('         Output horsepower at 1/2 rated load , P_o = %.2f hp' %P_o_LF2)\n",
      "print('         Output horsepower at 3/4 rated load , P_o = %.2f hp' %P_o_LF3)\n",
      "print('         Output horsepower at 5/4 rated load , P_o = %.2f hp' %P_o_LF4)\n",
      "print('Case(h): Output torque at full load , T_o = %.1f lb-ft' %T_o)\n",
      "print('         Output torque at full load , T_oST = %.1f N-m' %T_o_ST)\n",
      "print('\\nNOTE: ERROR: Calculation error for efficiency at 3/4 load in textbook')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case(a): Equivalent total resistance of motor between lines , R_els = 0.5 \u03a9\n",
        "Case(b): Rotational losses at no load , P_ro = 218.5 W\n",
        "Case(c): Slip at rated load , s_fl = 0.1 \n",
        "         Slip at 1/4 rated load , s = 0.025 \n",
        "         Slip at 1/2 rated load , s = 0.05 \n",
        "         Slip at 3/4 rated load , s = 0.075 \n",
        "         Slip at 5/4 rated load , s = 0.125 \n",
        "Case(d): Rotational loss at rated load , P_r = 198.7 W\n",
        "         Rotational loss at 1/4 load , P_r = 215.2 W\n",
        "         Rotational loss at 1/2 load , P_r = 209.69 W\n",
        "         Rotational loss at 3/4 load , P_r = 204.2 W\n",
        "         Rotational loss at 5/4 load , P_r = 193.1 W\n",
        "Case(e): Equivalent copper loss at rated load , P_cu = 392 W\n",
        "         Equivalent copper loss at 1/4 load , P_cu = 24.5 W\n",
        "         Equivalent copper loss at 1/2 load , P_cu = 98 W\n",
        "         Equivalent copper loss at 3/4 load , P_cu = 220.5 W\n",
        "         Equivalent copper loss at 5/4 load , P_cu = 612.5 W\n",
        "Case(f): Efficiency at rated load , \u03b7 = 88.7 W\n",
        "         Efficiency at 1/4 rated load , \u03b7 = 81.7 W\n",
        "         Efficiency at 1/2 rated load , \u03b7 = 88.2 W\n",
        "         Efficiency at 3/4 rated load , \u03b7 = 89.2 W\n",
        "         Efficiency at 5/4 rated load , \u03b7 = 87.7 W\n",
        "Case(g): Output horsepower at rated load , P_o = 6.23 hp\n",
        "         Output horsepower at 1/4 rated load , P_o = 1.43 hp\n",
        "         Output horsepower at 1/2 rated load , P_o = 3.10 hp\n",
        "         Output horsepower at 3/4 rated load , P_o = 4.69 hp\n",
        "         Output horsepower at 5/4 rated load , P_o = 7.69 hp\n",
        "Case(h): Output torque at full load , T_o = 20.2 lb-ft\n",
        "         Output torque at full load , T_oST = 27.4 N-m\n",
        "\n",
        "NOTE: ERROR: Calculation error for efficiency at 3/4 load in textbook\n"
       ]
      }
     ],
     "prompt_number": 1
    }
   ],
   "metadata": {}
  }
 ]
}