{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "CHAPTER 8: AC DYNAMO TORQUE RELATIONS-SYNCHRONOUS MOTORS"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.1, Page number 225"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import cmath\n",
      "\n",
      "#Variable declaration\n",
      "P = 20.0         #Number of poles\n",
      "hp = 40.0        #Power rating of the synchronous motor(hp)\n",
      "V_L = 660.0      #Line voltage(V)\n",
      "beta = 0.5       #At no-load, the rotor is retarded 0.5 mechanical degree from its synchronous position\n",
      "X_s = 10.0       #Synchronous reactance(ohm)\n",
      "R_a = 1.0        #Effective armature resistance(ohm)\n",
      "\n",
      "#Calculation\n",
      "#Case(a)\n",
      "alpha = P*(beta/2)   #Rotor shift from the synchronous position in electrical degrees\n",
      "#Case(b)\n",
      "V_p = V_L/3**0.5     #Phase voltage(V)\n",
      "E_gp = V_p           #Generated voltage/phase at no-load(V)\n",
      "E_r = complex((V_p-E_gp*math.cos(alpha*math.pi/180)),(E_gp*math.sin(alpha*math.pi/180))) #Resultant emf across the armature per phase(V/phase)\n",
      "#Case(c)\n",
      "Z_s = complex(R_a,X_s)    #Synchronous impedance(ohm/phase)\n",
      "I_a  = E_r/Z_s            #Armature current/phase(A/phase)\n",
      "#Case(d)\n",
      "Ia = abs(I_a)                              #Magnitude of armature current/phase(A/phase)\n",
      "theta = cmath.phase(I_a)*180/math.pi       #Phase angle of armature current(degree)\n",
      "P_p = V_p*Ia*math.cos(theta*math.pi/180)   #Power per phase drawn by the motor from the bus(W/phase)\n",
      "P_t = 3*P_p                                #Total power drawn by the motor from the bus(W)\n",
      "#Case(e)\n",
      "P_a = 3*Ia**2*R_a                          #Armature power loss at no-load(W)\n",
      "P_d = (P_t-P_a)/746.0                      #Internal developed horsepower at no-load\n",
      "\n",
      "#Result\n",
      "print('Case(a): Rotor shift from the synchronous position in electrical degrees , \u03b1 = %.f\u00b0 ' %alpha)\n",
      "print('Case(b): Resultant EMF across the armature per phase , E_r = %.1f\u2220%.1f\u00b0 V/phase' %(abs(E_r),cmath.phase(E_r)*180/math.pi))\n",
      "print('Case(c): Armature current per phase , I_a = %.2f\u2220%.1f\u00b0 A/phase' %(Ia,theta))\n",
      "print('Case(d): Power per phase drawn by the motor from the bus , P_p = %.f W/phase' %P_p)\n",
      "print('         Total power drawn by the motor from the bus , P_t = %.f W' %P_t)\n",
      "print('Case(e): Armature power loss = %.f W' %P_a)\n",
      "print('         Internal developed horsepower at no-load , P_d = %.f hp' %P_d)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case(a): Rotor shift from the synchronous position in electrical degrees , \u03b1 = 5\u00b0 \n",
        "Case(b): Resultant EMF across the armature per phase , E_r = 33.2\u222087.5\u00b0 V/phase\n",
        "Case(c): Armature current per phase , I_a = 3.31\u22203.2\u00b0 A/phase\n",
        "Case(d): Power per phase drawn by the motor from the bus , P_p = 1258 W/phase\n",
        "         Total power drawn by the motor from the bus , P_t = 3775 W\n",
        "Case(e): Armature power loss = 33 W\n",
        "         Internal developed horsepower at no-load , P_d = 5 hp\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.2, Page number 226"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import cmath\n",
      "\n",
      "#Variable declaration\n",
      "P = 20.0         #Number of poles\n",
      "hp = 40.0        #Power rating of the synchronous motor(hp)\n",
      "V_L = 660.0      #Line voltage(V)\n",
      "beta = 5.0       #At no-load, the rotor is retarded 0.5 mechanical degree from its synchronous position\n",
      "X_s = 10.0       #Synchronous reactance(ohm)\n",
      "R_a = 1.0        #Effective armature resistance(ohm)\n",
      "\n",
      "#Calculation\n",
      "#Case(a)\n",
      "alpha = P*(beta/2)   #Rotor shift from the synchronous position in electrical degrees\n",
      "#Case(b)\n",
      "V_p = V_L/3**0.5     #Phase voltage(V)\n",
      "E_gp = V_p           #Generated voltage/phase at no-load(V)\n",
      "E_r = complex((V_p-E_gp*math.cos(alpha*math.pi/180)),(E_gp*math.sin(alpha*math.pi/180))) #Resultant emf across the armature per phase(V/phase)\n",
      "#Case(c)\n",
      "Z_s = complex(R_a,X_s)    #Synchronous impedance(ohm/phase)\n",
      "I_a  = E_r/Z_s            #Armature current/phase(A/phase)\n",
      "#Case(d)\n",
      "Ia = abs(I_a)                              #Magnitude of armature current/phase(A/phase)\n",
      "theta = cmath.phase(I_a)*180/math.pi       #Phase angle of armature current(degree)\n",
      "P_p = V_p*Ia*math.cos(theta*math.pi/180)   #Power per phase drawn by the motor from the bus(W/phase)\n",
      "P_t = 3*P_p                                #Total power drawn by the motor from the bus(W)\n",
      "#Case(e)\n",
      "P_a = 3*Ia**2*R_a                          #Armature power loss at no-load(W)\n",
      "P_d = (P_t-P_a)/746.0                      #Internal developed horsepower at no-load\n",
      "\n",
      "#Result\n",
      "print('Case(a): Rotor shift from the synchronous position in electrical degrees , \u03b1 = %.f\u00b0 ' %alpha)\n",
      "print('Case(b): Resultant EMF across the armature per phase , E_r = %.f\u2220%.f\u00b0 V/phase' %(abs(E_r),cmath.phase(E_r)*180/math.pi))\n",
      "print('Case(c): Armature current per phase , I_a = %.1f\u2220%.1f\u00b0 A/phase' %(Ia,theta))\n",
      "print('Case(d): Power per phase drawn by the motor from the bus , P_p = %.f W/phase' %P_p)\n",
      "print('         Total power drawn by the motor from the bus , P_t = %.f W' %P_t)\n",
      "print('Case(e): Armature power loss = %.f W' %P_a)\n",
      "print('         Internal developed horsepower at no-load , P_d = %.1f hp' %P_d)\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): Rotor shift from the synchronous position in electrical degrees , \u03b1 = 50\u00b0 \n",
        "Case(b): Resultant EMF across the armature per phase , E_r = 322\u222065\u00b0 V/phase\n",
        "Case(c): Armature current per phase , I_a = 32.0\u2220-19.3\u00b0 A/phase\n",
        "Case(d): Power per phase drawn by the motor from the bus , P_p = 11526 W/phase\n",
        "         Total power drawn by the motor from the bus , P_t = 34579 W\n",
        "Case(e): Armature power loss = 3081 W\n",
        "         Internal developed horsepower at no-load , P_d = 42.2 hp\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 8.3, Page number 237"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import cmath\n",
      "\n",
      "#Variable declaration\n",
      "P = 6.0          #Number of poles\n",
      "hp = 50.0        #Power rating of the synchronous motor(hp)\n",
      "V_L = 440.0      #Line voltage(V)\n",
      "alpha = 20.0     #At no-load, the rotor is retarded 0.5 mechanical degree from its synchronous position\n",
      "X_s = 2.4        #Synchronous reactance(ohm)\n",
      "R_a = 0.1        #Effective armature resistance(ohm)\n",
      "E_gp_a = 240.0   #Generated phase voltage(V)\n",
      "E_gp_b = 265.0   #Generated phase voltage(V)\n",
      "E_gp_c = 290.0   #Generated phase voltage(V)\n",
      "\n",
      "#Calculation\n",
      "#Case(a)\n",
      "V_p = V_L /3**0.5                          #Phase voltage(V)\n",
      "E_ra = complex((V_p-E_gp_a*math.cos(alpha*math.pi/180)),(E_gp_a*math.sin(alpha*math.pi/180)))  #Resultant emf\n",
      "Z_s = complex(R_a,X_s)                     #Synchronous impedance(ohm)\n",
      "I_ap1  = E_ra/Z_s                          #Armature current(A)\n",
      "theta_1 = cmath.phase(I_ap1)*180/math.pi   #Angle(degree)\n",
      "pf_1 = math.cos(theta_1*math.pi/180)       #Power factor\n",
      "I_a1 = abs(I_ap1)                          #Magnitude of armature current(A)\n",
      "P_d1 = 3*E_gp_a*I_a1*math.cos((160-theta_1)*math.pi/180)  #Power drawn from the bus(W)\n",
      "Horse_power1 = abs(P_d1)/746.0                            #Horsepower developed by the armature(hp) \n",
      "#Case(b)\n",
      "E_rb = complex((V_p-E_gp_b*math.cos(alpha*math.pi/180)),(E_gp_b*math.sin(alpha*math.pi/180)))  #Resultant emf\n",
      "Z_s = complex(R_a,X_s)                     #Synchronous impedance(ohm)\n",
      "I_ap2  = E_rb/Z_s                          #Armature current(A)\n",
      "theta_2 = cmath.phase(I_ap2)*180/math.pi   #Angle(degree)\n",
      "pf_2 = math.cos(theta_2*math.pi/180)       #Power factor\n",
      "I_a2 = abs(I_ap2)                          #Magnitude of armature current(A)\n",
      "P_d2 = 3*E_gp_b*I_a2*math.cos((160-theta_2)*math.pi/180)  #Power drawn from the bus(W)\n",
      "Horse_power2 = abs(P_d2)/746.0                            #Horsepower developed by the armature(hp) \n",
      "#Case(c)\n",
      "E_rc = complex((V_p-E_gp_c*math.cos(alpha*math.pi/180)),(E_gp_c*math.sin(alpha*math.pi/180)))  #Resultant emf\n",
      "Z_s = complex(R_a,X_s)                     #Synchronous impedance(ohm)\n",
      "I_ap3  = E_rc/Z_s                          #Armature current(A)\n",
      "theta_3 = cmath.phase(I_ap3)*180/math.pi   #Angle(degree)\n",
      "pf_3 = math.cos(theta_3*math.pi/180)       #Power factor\n",
      "I_a3 = abs(I_ap3)                          #Magnitude of armature current(A)\n",
      "P_d3 = 3*E_gp_c*I_a3*math.cos((160-theta_3)*math.pi/180)  #Power drawn from the bus(W)\n",
      "Horse_power3 = abs(P_d3)/746.0                            #Horsepower developed by the armature(hp)\n",
      "\n",
      "#Result\n",
      "print('Case(a): Armature current , I_ap = %.2f\u2220%.2f\u00b0 A' %(I_a1,theta_1))\n",
      "print('         Power factor = %.4f lagging' %pf_1)\n",
      "print('         Horsepower developed by the armature , Horsepower = %.1f hp' %Horse_power1)\n",
      "print('Case(b): Armature current , I_ap = %.2f\u2220%.2f\u00b0 A' %(I_a2,theta_2))\n",
      "print('         Power factor = %.f (Unity PF)' %pf_2)\n",
      "print('         Horsepower developed by the armature , Horsepower = %.1f hp' %Horse_power2)\n",
      "print('Case(c): Armature current , I_ap = %.f\u2220%.2f\u00b0 A' %(I_a3,theta_3))\n",
      "print('         Power factor = %.4f leading' %pf_3)\n",
      "print('         Horsepower developed by the armature , Horsepower = %.1f hp' %Horse_power3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case(a): Armature current , I_ap = 36.17\u2220-16.77\u00b0 A\n",
        "         Power factor = 0.9575 lagging\n",
        "         Horsepower developed by the armature , Horsepower = 34.9 hp\n",
        "Case(b): Armature current , I_ap = 37.79\u2220-0.78\u00b0 A\n",
        "         Power factor = 1 (Unity PF)\n",
        "         Horsepower developed by the armature , Horsepower = 38.0 hp\n",
        "Case(c): Armature current , I_ap = 42\u222012.94\u00b0 A\n",
        "         Power factor = 0.9746 leading\n",
        "         Horsepower developed by the armature , Horsepower = 41.1 hp\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.4, Page number 240"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import cmath\n",
      "\n",
      "#Variable declaration\n",
      "P = 2.0              #Number of poles\n",
      "hp = 1000.0          #Power rating of the synchronous motor(hp)\n",
      "V_L = 6000.0         #Line voltage(V)\n",
      "f = 60.0             #Frequency(Hz)\n",
      "R_a = 0.52           #Effective armature resistance(ohm)\n",
      "X_s = 4.2            #Synchronous reactance(ohm)\n",
      "P_t = 811.0          #Input power(kW)\n",
      "PF = 0.8             #Power factor leading\n",
      "\n",
      "#Calculation\n",
      "V_p = V_L/3**0.5                 #Phase voltage(V)\n",
      "I_L = P_t*1000/(3**0.5*V_L*PF)   #Line current(A)\n",
      "I_ap = I_L                       #Phase armature current(A)\n",
      "Z_p = complex(R_a,X_s)           #Impedance per phase(ohm)\n",
      "Zp = abs(Z_p)                    #Magnitude of impedance per phase(ohm)\n",
      "beta = cmath.phase(Z_p)*180/math.pi  #Phase angle of impedance per phase(degree)\n",
      "E_r = I_ap*Zp                    #EMF(V)\n",
      "theta = math.acos(PF)*180/math.pi#Power factor angle(degree)\n",
      "delta = beta+theta               #Difference angle(degree)\n",
      "E_gp_f = (E_r**2+V_p**2-2*E_r*V_p*math.cos(delta*math.pi/180))**0.5  #Generated phase voltage(V)\n",
      "E_gp_g = complex((V_p+E_r*math.cos((180-delta)*math.pi/180)),(E_r*math.sin((180-delta)*math.pi/180))) #Generated phase voltage(V)\n",
      "E_gp_h = complex((V_p*PF-I_ap*R_a),(V_p*math.sin(theta*math.pi/180)+I_ap*X_s)) #Generated phase voltage(V)\n",
      "\n",
      "#Result\n",
      "print('Case(a): Line current , I_L = %.2f A' %I_L)\n",
      "print('         Phase armature current , I_ap = %.2f A' %I_ap)\n",
      "print('Case(b): Impedance per phase , Z_p\u2220\u03b2 = %.3f\u2220%.2f\u00b0 \u03a9' %(Zp,beta))\n",
      "print('Case(c): Magnitude I_aZ_p = E_r = %.1f V' %E_r)\n",
      "print('Case(d): Power factor angle , \u03b8 = %.2f\u00b0 leading' %theta)\n",
      "print('Case(e): Difference angle at 0.8 PF , \u03b4 = %.2f\u00b0 ' %delta)\n",
      "print('Case(f): Generated phase voltage , E_gp = %.f V' %E_gp_f)\n",
      "print('Case(g): Generated phase voltage , E_gp = %.f\u2220%.2f\u00b0 V' %(abs(E_gp_g),cmath.phase(E_gp_g)*180/math.pi))\n",
      "print('Case(h): Generated phase voltage , E_gp = %.f\u2220%.2f\u00b0 V' %(abs(E_gp_h),cmath.phase(E_gp_h)*180/math.pi))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case(a): Line current , I_L = 97.55 A\n",
        "         Phase armature current , I_ap = 97.55 A\n",
        "Case(b): Impedance per phase , Z_p\u2220\u03b2 = 4.232\u222082.94\u00b0 \u03a9\n",
        "Case(c): Magnitude I_aZ_p = E_r = 412.8 V\n",
        "Case(d): Power factor angle , \u03b8 = 36.87\u00b0 leading\n",
        "Case(e): Difference angle at 0.8 PF , \u03b4 = 119.81\u00b0 \n",
        "Case(f): Generated phase voltage , E_gp = 3687 V\n",
        "Case(g): Generated phase voltage , E_gp = 3687\u22205.58\u00b0 V\n",
        "Case(h): Generated phase voltage , E_gp = 3687\u222042.45\u00b0 V\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.5, Page number 242"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "E_gp = 3687.0    #Generated phase voltage(V)\n",
      "V_L = 6000.0     #Line voltage(V)\n",
      "E_r = 412.8      #EMF(V)\n",
      "V_p = V_L/3**0.5 #Phase voltage(V)\n",
      "delta = 119.82   #Difference angle(degree)\n",
      "theta = 36.87    #Power factor angle(degree)\n",
      "R_a = 0.52       #Effective armature resistance(ohm)\n",
      "X_s = 4.2        #Synchronous reactance(ohm)\n",
      "I_a = 97.55      #Armature current(A)\n",
      "\n",
      "#Calculation\n",
      "alpha_1 = math.acos((E_gp**2+V_p**2-E_r**2)/(2*E_gp*V_p))*180/math.pi   #Torque angle(degree)\n",
      "alpha_2 = math.asin(E_r*math.sin(delta*math.pi/180)/E_gp)*180/math.pi   #Torque angle(degree)\n",
      "alpha_3 = theta-math.atan((V_p*math.sin(theta*math.pi/180)+I_a*X_s)/(V_p*math.cos(theta*math.pi/180)-I_a*R_a))*180/math.pi #Torque angle(degree)\n",
      "\n",
      "#Result\n",
      "print('Case(a): Torque angle , \u03b1 = %.2f\u00b0 '%alpha_1)\n",
      "print('Case(b): Torque angle , \u03b1 = %.2f\u00b0 '%alpha_2)\n",
      "print('Case(c): Torque angle , \u03b1 = %.2f\u00b0 '%alpha_3)\n",
      "print('\\nNOTE: ERROR : Negative sign is not mentioned in angle \u03b1 part(c) in textbook answer')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case(a): Torque angle , \u03b1 = 5.57\u00b0 \n",
        "Case(b): Torque angle , \u03b1 = 5.57\u00b0 \n",
        "Case(c): Torque angle , \u03b1 = -5.58\u00b0 \n",
        "\n",
        "NOTE: ERROR : Negative sign is not mentioned in angle \u03b1 part(c) in textbook answer\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.6, Page number 242"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "P = 2.0              #Number of poles\n",
      "hp = 1000.0          #Power rating of the synchronous motor(hp)\n",
      "V_L = 6000.0         #Line voltage(V)\n",
      "f = 60.0             #Frequency(Hz)\n",
      "P_t = 811.0          #Input power(kW)\n",
      "PF = 0.8             #Power factor leading\n",
      "E_gp = 3687.0        #Generated phase voltage(V)\n",
      "I_a = 97.55          #Armature current(A)\n",
      "E_gpI_a = 42.45      #Angle between Generated phase voltage and armature current(degree)\n",
      "\n",
      "#Calculation\n",
      "P_p = E_gp*I_a*math.cos(E_gpI_a*math.pi/180)/1000   #Mechanical power developed per phase(kW)\n",
      "P_t_a = 3*P_p                                       #Total mechanical power developed(kW)\n",
      "P_t_b = P_t_a/0.746                                 #Internal power developed at rated load(hp)\n",
      "S = 120*f/P                                         #Speed of the motor(rpm)\n",
      "T_int = P_t_b*5252/S                                #Internal torque developed(lb-ft)\n",
      "T_ext = hp*5252/3600                                #External torque developed(lb-ft)\n",
      "n = T_ext/T_int*100                                 #Motor efficiency(%)\n",
      "\n",
      "#Result\n",
      "print('Case(a): Mechanical power developed in the armature per phase , P_p = %.3f kW' %P_p)\n",
      "print('         Total Mechanical power developed in the armature , P_t = %.1f kW' %P_t_a)\n",
      "print('Case(b): Internal power developed at rated load , P_t = %.1f hp' %P_t_b)\n",
      "print('Case(c): Internal torque developed , T_int = %.f lb-ft' %T_int)\n",
      "print('Case(d): Motor efficiency , \u03b7 = %.1f percent' %n)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case(a): Mechanical power developed in the armature per phase , P_p = 265.386 kW\n",
        "         Total Mechanical power developed in the armature , P_t = 796.2 kW\n",
        "Case(b): Internal power developed at rated load , P_t = 1067.2 hp\n",
        "Case(c): Internal torque developed , T_int = 1557 lb-ft\n",
        "Case(d): Motor efficiency , \u03b7 = 93.7 percent\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.7, Page number 244"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import cmath\n",
      "\n",
      "#Variable declaration\n",
      "P_o = 2000.0    #Total power consumed by a factory from the transformer(kW)\n",
      "pf_tr = 0.6     #Lagging power factor at which power is consumed from the transformer\n",
      "V_L = 6000.0    #Primary line voltage of a transformer(V)\n",
      "P = 750.0       #Power expected to be delivered by the dc motor-generator(kW)\n",
      "hp = 1000.0     #Rating of the motor(hp)\n",
      "V_L_m = 6000.0  #Line voltage of a synchronous motor(V)\n",
      "pf_sm = 0.8     #Leading power factor of the synchronous motor\n",
      "pf_im = 0.8     #Lagging power factor of the induction motor\n",
      "n = 0.92        #Efficiency of each motor\n",
      "\n",
      "#Calculation\n",
      "#Case(a)\n",
      "P_m_a = hp*746/n                              #Induction/synchronous motor load(kW)\n",
      "I_1_a = P_m_a/(3**0.5*V_L*pf_im)*cmath.exp(1j*-math.acos(pf_im))          #Lagging current drawn by induction motor(A)\n",
      "I_1_prime = P_o*1000/(3**0.5*V_L*pf_tr)*cmath.exp(1j*-math.acos(pf_tr))   #Original lagging factory load current(A)\n",
      "I_TM = I_1_a+I_1_prime                        #Total load current(A)\n",
      "angle_I_TM = cmath.phase(I_TM)*180/math.pi    #Angle of total load current(degree)\n",
      "PF_1 = math.cos(angle_I_TM*math.pi/180)       #Overall sysytem PF\n",
      "#Case(b)\n",
      "I_s1 = P_m_a/(3**0.5*V_L*pf_sm)*cmath.exp(1j*math.acos(pf_sm)) #Leading current drawn by synchronous motor(A)\n",
      "I_TSM = I_s1+I_1_prime                        #Total load current(A)\n",
      "angle_I_TSM = cmath.phase(I_TSM)*180/math.pi   #Angle of total load current(degree)\n",
      "PF_2 = math.cos(angle_I_TSM*math.pi/180)      #Overall sysytem PF\n",
      "#Case(c)\n",
      "percent_I_L =  (abs(I_TM)-abs(I_TSM))/abs(I_TM)*100     #Percent reduction in total load current(%)\n",
      "\n",
      "#Result\n",
      "print('Case(a): Total load current of the induction motor , I_TM =  %.1f\u2220%.1f\u00b0 A' %(abs(I_TM),angle_I_TM))\n",
      "print('         Power factor of the induction motor , Overall system PF = %.4f lagging' %PF_1)\n",
      "print('Case(b): Total load current of the synchronous motor , I_TSM =  %.1f\u2220%.1f\u00b0 A' %(abs(I_TSM),angle_I_TSM))\n",
      "print('         Power factor of the synchronous motor , Overall system PF = %.1f lagging' %PF_2)\n",
      "print('Case(c): Percent reduction in total load current = %.1f percent' %percent_I_L)\n",
      "print('Case(d): PF improvement: Using the synchronous motor raises the total system PF from %.4f lagging to %.1f lagging' %(PF_1,PF_2))\n",
      "print('\\nNOTE: Changes in obtained answer is due to precision and error in some data in the textbook solution')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case(a): Total load current of the induction motor , I_TM =  415.3\u2220-49.4\u00b0 A\n",
        "         Power factor of the induction motor , Overall system PF = 0.6513 lagging\n",
        "Case(b): Total load current of the synchronous motor , I_TSM =  335.3\u2220-36.2\u00b0 A\n",
        "         Power factor of the synchronous motor , Overall system PF = 0.8 lagging\n",
        "Case(c): Percent reduction in total load current = 19.3 percent\n",
        "Case(d): PF improvement: Using the synchronous motor raises the total system PF from 0.6513 lagging to 0.8 lagging\n",
        "\n",
        "NOTE: Changes in obtained answer is due to precision and error in some data in the textbook solution\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.8, Page number 245"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "P = 6.0          #Number of poles\n",
      "f = 60.0         #Frequency(Hz)\n",
      "V_L = 440.0      #Line voltage(V)\n",
      "alpha = 20.0     #At no-load, the rotor is retarded 0.5 mechanical degree from its synchronous position\n",
      "X_s = 2.4        #Synchronous reactance(ohm)\n",
      "R_a = 0.1        #Effective armature resistance(ohm)\n",
      "E_gp = 240.0     #Generated phase voltage(V)\n",
      "V_p = V_L/3**0.5 #Phase voltage(V)\n",
      "\n",
      "#Calculation\n",
      "S = 120*f/P                                               #Speed(rpm)\n",
      "T_p = 7.04*E_gp*V_p*math.sin(alpha*math.pi/180)/(S*X_s)   #Torque developed per phase(lb-ft)\n",
      "Horsepower = 3*T_p*S/5252                                 #Total horsepower developed(hp)\n",
      "\n",
      "#Result\n",
      "print('Case(a): Torque developed per phase , T_p = %.2f lb-ft' %T_p)\n",
      "print('Case(b): Total horsepower developed , Horsepower = %.1f hp' %Horsepower)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case(a): Torque developed per phase , T_p = 50.97 lb-ft\n",
        "Case(b): Total horsepower developed , Horsepower = 34.9 hp\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.9, Page number 251"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import cmath\n",
      "\n",
      "#Variable declaration\n",
      "P_o = 2000.0          #Total power consumed by a factory(kW) \n",
      "pf = 0.6              #Lagging power factor\n",
      "V = 6000.0            #Line voltage(V)\n",
      "loss = 275.0          #Synchronous capacitor losses(kW)\n",
      "\n",
      "#Calculation\n",
      "#Case(a)\n",
      "S_o_conjugate = P_o/pf          #Apparent complex power(kW)\n",
      "sin_theta = (1-pf**2)**0.5      #Sin\u03b8\n",
      "jQ_o = S_o_conjugate*sin_theta  #Original kilovars of lagging load(kvar)\n",
      "#Case(b)\n",
      "jQ_c = -jQ_o                    #Kilovars of correction needed to bring the PF to unity(kvar)\n",
      "#Case(c)\n",
      "R = loss                        #Synchronous capacitor losses(kW)\n",
      "S_c_conjugate = complex(R,jQ_c) #kVA rating of the synchronous capacitor(kVA)\n",
      "angle_S_c_conjugate = cmath.phase(S_c_conjugate)*180/math.pi #Angle of #kVA rating of the synchronous capacitor(degree)\n",
      "PF = math.cos(angle_S_c_conjugate*math.pi/180)               #Power factor of the synchronous capacitor\n",
      "#Case(d)\n",
      "I_o = S_o_conjugate*1000/V                                   #Original current drawn from the mains(A)\n",
      "#Case(e)\n",
      "P_f = P_o+loss                  #Total power(kW)\n",
      "S_f = P_f                       #Total apparent power(kW)\n",
      "I_f = S_f*1000/V                #Final current drawn from the mains after correction(A)\n",
      "\n",
      "#Result\n",
      "print('Case(a): Original kilovars of lagging load , jQ_o = j%.1f kvar' %jQ_o)\n",
      "print('Case(b): Kilovars of correction needed to bring the PF to unity , -jQ_c = %.1fj kvar' %jQ_c)\n",
      "print('Case(c): kVA rating of the synchronous capacitor , S_*c = %.f\u2220%.1f\u00b0 kVA' %(abs(S_c_conjugate),angle_S_c_conjugate))\n",
      "print('         Power factor of the synchronous capacitor = %.3f leading' %PF)\n",
      "print('Case(d): Original current drawn from the mains , I_o = %.1f A' %I_o)\n",
      "print('Case(e): Final current drawn from the mains after correction , I_f = %.1f A' %I_f)\n",
      "print('Case(f): See fig.8-25 in textbook page no.251')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case(a): Original kilovars of lagging load , jQ_o = j2666.7 kvar\n",
        "Case(b): Kilovars of correction needed to bring the PF to unity , -jQ_c = -2666.7j kvar\n",
        "Case(c): kVA rating of the synchronous capacitor , S_*c = 2681\u2220-84.1\u00b0 kVA\n",
        "         Power factor of the synchronous capacitor = 0.103 leading\n",
        "Case(d): Original current drawn from the mains , I_o = 555.6 A\n",
        "Case(e): Final current drawn from the mains after correction , I_f = 379.2 A\n",
        "Case(f): See fig.8-25 in textbook page no.251\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.10, Page number 254"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "kVA = 10000.0     #Rating of a system(kVA)\n",
      "PF = 0.65         #Power factor of the system\n",
      "PF_2 = 0.85       #Raised lagging PF\n",
      "cost = 60.0       #Cost of the synchronous capacitor to improve the PF($/kVA)\n",
      "\n",
      "#Calculation\n",
      "#Case(a)\n",
      "kW_a = kVA*PF                   #Power(kW)\n",
      "sin_theta = (1-PF**2)**0.5      #Sin\u03b8\n",
      "kvar = kVA*sin_theta            #Reactive power(kvar)\n",
      "kVA_a = kvar\n",
      "cost_cap_a = kVA_a*cost         #Cost of raising the PF to unity PF($)\n",
      "#Case(b)\n",
      "kVA_b = kW_a/PF_2               #kVA of final system(kVA)\n",
      "sin_theta_b = (1-PF_2**2)**0.5  #Sin\u03b8\n",
      "kvar_b = kVA_b*sin_theta_b      #kvar of final system(kvar)\n",
      "kvar_add = kvar-kvar_b          #kvar of correction added(kvar)\n",
      "kVA_b = kvar_add\n",
      "cost_cap_b = kVA_b*cost      #Cost of raising the PF to 0.85 PF($)\n",
      "\n",
      "#Result\n",
      "print('Case(a): Cost of raising the PF to Unity PF = $%.f ' %cost_cap_a)\n",
      "print('Case(b): Cost of raising the PF to 0.85 PF lagging = $%.f ' %cost_cap_b)\n",
      "print('\\nNOTE: Slight variations in the obtained answer is due to non-approximation of the values while calculating in python')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case(a): Cost of raising the PF to Unity PF = $455961 \n",
        "Case(b): Cost of raising the PF to 0.85 PF lagging = $214260 \n",
        "\n",
        "NOTE: Slight variations in the obtained answer is due to non-approximation of the values while calculating in python\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.11, Page number 255"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "S_conjugate = 1000.0   #Apparent complex power(kVA)\n",
      "PF = 0.6               #Lagging PF\n",
      "\n",
      "#Calculation\n",
      "P_o = S_conjugate*PF           #Active power dissipated by the load(kW)\n",
      "sin_theta = (1-PF**2)**0.5     #Sin\u03b8\n",
      "jQ_o = S_conjugate*sin_theta   #Inductive reactive quadrature power drawn from and returned to the supply(kvar)\n",
      "\n",
      "#Result\n",
      "print('Case(a): Active(true) power originally dissipated by load , P_o = %.f kW' %P_o)\n",
      "print('Case(b): Inductive reactive quadrature power drawn from and returned to supply , +jQ_o =  j%.f kvar' %jQ_o)\n",
      "print('Case(c): The original power triangle is shown in Fig.8-26a in textbook page no.255')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case(a): Active(true) power originally dissipated by load , P_o = 600 kW\n",
        "Case(b): Inductive reactive quadrature power drawn from and returned to supply , +jQ_o =  j800 kvar\n",
        "Case(c): The original power triangle is shown in Fig.8-26a in textbook page no.255\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.12, Page number 255"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "S_conjugate = 1000.0   #Apparent complex power(kVA)\n",
      "PF = 0.8               #Lagging PF\n",
      "jQ_o = 800.0           #Inductive reactive quadrature power drawn from and returned to the supply(kvar)\n",
      "P_o = 600.0            #Active power dissipated by the load(kW)\n",
      "PF1 = 0.6              #Lagging PF from ex 8.11\n",
      "\n",
      "#Calculation\n",
      "P_f = S_conjugate*PF           #Final active power supplied by the alternator(kW)\n",
      "sin_theta = (1-PF**2)**0.5     #Sin\u03b8\n",
      "jQ_f = S_conjugate*sin_theta   #Reactive power stored and returned to the supply(kvar)\n",
      "P_a = P_f-P_o                  #Additional active power that may be supplied to new consumer(kW)\n",
      "jQ_a = jQ_f-jQ_o               #Correction kilovars required to raise PF from 0.6 to 0.8 lagging(kvar)\n",
      "S_c = 0-jQ_a                   #Rating of correction capacitors needed(kVA)\n",
      "\n",
      "#Result\n",
      "print('Case(a): Final active power supplied by the alternator , P_f = %.f kW' %P_f)\n",
      "print('Case(b): Reactive power stored and returned to the supply , +jQ_f =  j%.f kvar' %jQ_f)\n",
      "print('Case(c): Additional active power that may be supplied to new consumer , P_a = %.f kW' %P_a)\n",
      "print('Case(d): Correction kilovars required to raise PF from 0.6 to 0.8 lagging , -jQ_a = %.fj kvar' %jQ_a)\n",
      "print('Case(e): Rating of correction capacitors needed to accomplish above correction , S_*c = %.f kVA' %S_c)\n",
      "print('Case(f): The power tabulation grid is shown below:')\n",
      "print('_____________________________________________________________________')\n",
      "print('\\t   P(kW) \\t \u00b1jQ(kvar) \\t S*(kVA) \\t Lagging cos\u03b8')\n",
      "print('_____________________________________________________________________')\n",
      "print('Original  %.f \\t\\t  j%.f \\t\\t  %.f \\t\\t  %.1f ' %(P_o,jQ_o,S_conjugate,PF1))\n",
      "print('Added     %.f \\t\\t  %.fj \\t   - \\t\\t   - ' %(P_a,jQ_a))\n",
      "print('Final     %.f \\t\\t  j%.f \\t\\t  %.f \\t\\t  %.1f ' %(P_f,jQ_f,S_conjugate,PF))\n",
      "print('_____________________________________________________________________')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case(a): Final active power supplied by the alternator , P_f = 800 kW\n",
        "Case(b): Reactive power stored and returned to the supply , +jQ_f =  j600 kvar\n",
        "Case(c): Additional active power that may be supplied to new consumer , P_a = 200 kW\n",
        "Case(d): Correction kilovars required to raise PF from 0.6 to 0.8 lagging , -jQ_a = -200j kvar\n",
        "Case(e): Rating of correction capacitors needed to accomplish above correction , S_*c = 200 kVA\n",
        "Case(f): The power tabulation grid is shown below:\n",
        "_____________________________________________________________________\n",
        "\t   P(kW) \t \u00b1jQ(kvar) \t S*(kVA) \t Lagging cos\u03b8\n",
        "_____________________________________________________________________\n",
        "Original  600 \t\t  j800 \t\t  1000 \t\t  0.6 \n",
        "Added     200 \t\t  -200j \t   - \t\t   - \n",
        "Final     800 \t\t  j600 \t\t  1000 \t\t  0.8 \n",
        "_____________________________________________________________________\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.13, Page number 256"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "S_conjugate = 1000.0   #Apparent complex power(kVA)\n",
      "PF = 1.0               #Unity PF\n",
      "jQ_o = 800.0           #Inductive reactive quadrature power drawn from and returned to the supply(kvar)\n",
      "P_o = 600.0            #Active power dissipated by the load(kW)\n",
      "PF1 = 0.6              #Lagging PF from ex 8.11\n",
      "\n",
      "#Calculation\n",
      "P_f = S_conjugate*PF           #Final active power supplied by the alternator(kW)\n",
      "sin_theta = (1-PF**2)**0.5     #Sin\u03b8\n",
      "jQ_f = S_conjugate*sin_theta   #Reactive power stored and returned to the supply(kvar)\n",
      "P_a = P_f-P_o                  #Additional active power that may be supplied to new consumer(kW)\n",
      "jQ_a = jQ_f-jQ_o               #Correction kilovars required to raise PF from 0.6 to 0.8 lagging(kvar)\n",
      "S_c = 0-jQ_a                   #Rating of correction capacitors needed(kVA)\n",
      "\n",
      "#Result\n",
      "print('Case(a): Final active power supplied by the alternator , P_f = %.f kW' %P_f)\n",
      "print('Case(b): Reactive power stored and returned to the supply , +jQ_f =  j%.f kvar' %jQ_f)\n",
      "print('Case(c): Additional active power that may be supplied to new consumer , P_a = %.f kW' %P_a)\n",
      "print('Case(d): Correction kilovars required to raise PF from 0.6 to 0.8 lagging , -jQ_a = %.fj kvar' %jQ_a)\n",
      "print('Case(e): Rating of correction capacitors needed to accomplish above correction , S_*c = %.f kVA' %S_c)\n",
      "print('Case(f): The power tabulation grid is shown below:')\n",
      "print('_____________________________________________________________________')\n",
      "print('\\t   P(kW) \\t \u00b1jQ(kvar) \\t S*(kVA) \\t cos\u03b8')\n",
      "print('_____________________________________________________________________')\n",
      "print('Original  %.f \\t\\t  j%.f \\t\\t  %.f \\t\\t  %.1f ' %(P_o,jQ_o,S_conjugate,PF1))\n",
      "print('Added     %.f \\t\\t  %.fj \\t   - \\t\\t   - ' %(P_a,jQ_a))\n",
      "print('Final     %.f \\t\\t  %.f \\t\\t  %.f \\t\\t  %.1f ' %(P_f,jQ_f,S_conjugate,PF))\n",
      "print('_____________________________________________________________________')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case(a): Final active power supplied by the alternator , P_f = 1000 kW\n",
        "Case(b): Reactive power stored and returned to the supply , +jQ_f =  j0 kvar\n",
        "Case(c): Additional active power that may be supplied to new consumer , P_a = 400 kW\n",
        "Case(d): Correction kilovars required to raise PF from 0.6 to 0.8 lagging , -jQ_a = -800j kvar\n",
        "Case(e): Rating of correction capacitors needed to accomplish above correction , S_*c = 800 kVA\n",
        "Case(f): The power tabulation grid is shown below:\n",
        "_____________________________________________________________________\n",
        "\t   P(kW) \t \u00b1jQ(kvar) \t S*(kVA) \t cos\u03b8\n",
        "_____________________________________________________________________\n",
        "Original  600 \t\t  j800 \t\t  1000 \t\t  0.6 \n",
        "Added     400 \t\t  -800j \t   - \t\t   - \n",
        "Final     1000 \t\t  0 \t\t  1000 \t\t  1.0 \n",
        "_____________________________________________________________________\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.14, Page number 256"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import cmath\n",
      "\n",
      "#Variable declaration\n",
      "P_o = 2000.0    #Load drawn by a factory(kW)\n",
      "pf_o = 0.6      #Lagging PF\n",
      "pf_f = 0.85     #lagging PF required\n",
      "P_a = 275.0     #Losses in the synchronous capacitor(kW)\n",
      "\n",
      "#Calculation\n",
      "S_o_conjugate = P_o/pf_o                        #Original kVA load drawn from the utility(kVA) \n",
      "sin_theta_o = (1-pf_o**2)**0.5                  #Sin\u03b8\n",
      "jQ_o = S_o_conjugate*sin_theta_o                #Original lagging kilovars(kvar)\n",
      "P_f = P_o+P_a                                   #Final system active power consumed from the utility(kW)\n",
      "S_f_conjugate = (P_f/pf_f)*cmath.exp(1j*-math.acos(pf_f))  #Final kVA load drawn from the utility(kVA)\n",
      "sin_theta_f = (1-pf_f**2)**0.5                  #Sin\u03b8\n",
      "jQ_f = abs(S_f_conjugate)*sin_theta_f           #Final lagging kvar\n",
      "jQ_a = jQ_f-jQ_o                                #Correction kvar produced by the synchronous capacitor(kvar)\n",
      "S_a_conjugate = complex(P_a,jQ_a)               #kVA rating of the synchronous capacitor(kVA)\n",
      "angle_S_a_conjugate = cmath.phase(S_a_conjugate)*180/math.pi #Angle(degree)\n",
      "pf_S_a_conjugate = math.cos(angle_S_a_conjugate*math.pi/180) #Leading PF\n",
      "\n",
      "#Result\n",
      "print('Case(a): Original kVA load drawn from the utility , S_*o = %.1f kVA' %S_o_conjugate)\n",
      "print('Case(b): Original lagging kilovars , jQ_o = j%.f kvar' %jQ_o)\n",
      "print('Case(c): Final system active power consumed from the utility , P_f = %.f kW' %P_f)\n",
      "print('Case(d): Final kVA load drawn from the utility , S_*f = %.1f\u2220%.1f\u00b0 kVA' %(abs(S_f_conjugate),cmath.phase(S_f_conjugate)*180/math.pi))\n",
      "print('Case(e): Correction kilovars produced by the synchronous capacitor , -jQ_a = %.fj kvar' %jQ_a)\n",
      "print('Case(f): kVA rating of the synchronous capacitor , S_*a = %.f\u2220%.2f\u00b0 kVA' %(abs(S_a_conjugate),cmath.phase(S_a_conjugate)*180/math.pi))\n",
      "print('Case(g): Power tabulation grid: ')\n",
      "print('_____________________________________________________________________')\n",
      "print('\\t   P(kW) \\t \u00b1jQ(kvar) \\t S*(kVA) \\t cos\u03b8')\n",
      "print('_____________________________________________________________________')\n",
      "print('Original  %.f \\t\\t  j%.f \\t %.1f \\t\\t  %.1f lag' %(P_o,jQ_o,S_o_conjugate,pf_o))\n",
      "print('Added     %.f \\t\\t  %.fj \\t %.f \\t\\t  %.3f lead' %(P_a,jQ_a,abs(S_a_conjugate),pf_S_a_conjugate))\n",
      "print('Final     %.f \\t\\t  j%.f \\t %.1f \\t\\t  %.2f lag' %(P_f,jQ_f,abs(S_f_conjugate),pf_f))\n",
      "print('_____________________________________________________________________')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case(a): Original kVA load drawn from the utility , S_*o = 3333.3 kVA\n",
        "Case(b): Original lagging kilovars , jQ_o = j2667 kvar\n",
        "Case(c): Final system active power consumed from the utility , P_f = 2275 kW\n",
        "Case(d): Final kVA load drawn from the utility , S_*f = 2676.5\u2220-31.8\u00b0 kVA\n",
        "Case(e): Correction kilovars produced by the synchronous capacitor , -jQ_a = -1257j kvar\n",
        "Case(f): kVA rating of the synchronous capacitor , S_*a = 1286\u2220-77.66\u00b0 kVA\n",
        "Case(g): Power tabulation grid: \n",
        "_____________________________________________________________________\n",
        "\t   P(kW) \t \u00b1jQ(kvar) \t S*(kVA) \t cos\u03b8\n",
        "_____________________________________________________________________\n",
        "Original  2000 \t\t  j2667 \t 3333.3 \t\t  0.6 lag\n",
        "Added     275 \t\t  -1257j \t 1286 \t\t  0.214 lead\n",
        "Final     2275 \t\t  j1410 \t 2676.5 \t\t  0.85 lag\n",
        "_____________________________________________________________________\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.15, Page number 257"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import cmath\n",
      "\n",
      "#Variable declaration\n",
      "S_f_conjugate = 3333.3               #Rating of alternator(kVA)\n",
      "S_o_conjugate = complex(2275,1410)   #Load(kVA)\n",
      "PF = 0.8                             #Lagging power factor\n",
      "\n",
      "#Calculation\n",
      "#Case(a)\n",
      "a = 1.0                              #Co-efficient of x^2\n",
      "b = 5332.0                           #Co-efficient of x\n",
      "c = -3947163.0                       #Constant\n",
      "sol_1 = (-b+(b**2-4*a*c)**0.5)/(2*a) #Solution 1\n",
      "sol_2 = (-b-(b**2-4*a*c)**0.5)/(2*a) #Solution 1\n",
      "x = sol_1\n",
      "#Case(b)\n",
      "P_a = PF*x                           #Added active power of the additional load(kW)\n",
      "sin_theta = (1-PF**2)**0.5           #Sin\u03b8\n",
      "Q_a = sin_theta*x                    #Added reactive power of the additional load(kvar)\n",
      "#Case(c)\n",
      "P_o = S_o_conjugate.real             #Real power(kW)\n",
      "Q_o = S_o_conjugate.imag             #Reactive power(kvar)\n",
      "P_f = P_o+P_a                        #Final active power supplied by alternator(kW)\n",
      "Q_f = Q_o+Q_a                        #Final reactive power supplied by alternator(kvar)\n",
      "#Case(d)\n",
      "PF_final = P_f/S_f_conjugate         #Final PF of the alternator\n",
      "\n",
      "#Result\n",
      "print('Case(a): Additional kVA load that may be added without overloading the alternator , x = S_*a = %.2f kVA' %x)\n",
      "print('Case(b): Added active power of the additional load , P_a = %.1f kW' %P_a)\n",
      "print('         Added reactive power of the additional load , Q_a = j%.2f kvar' %Q_a)\n",
      "print('Case(c): Final active power supplied by alternator , P_f = %.1f kW' %P_f)\n",
      "print('         Final reactive power supplied by alternator , Q_f = j%.1f kvar' %Q_f)\n",
      "print('Case(d): Final PF of the alternator , PF = %.3f lagging' %PF_final)\n",
      "print('Power tabulation grid: ')\n",
      "print('_____________________________________________________________________')\n",
      "print('\\t   P(kW) \\t \u00b1jQ(kvar) \\t S*(kVA) \\t cos\u03b8')\n",
      "print('_____________________________________________________________________')\n",
      "print('Original  %.f \\t\\t  j%.f \\t %.1f \\t\\t  %.2f lag' %(P_o,Q_o,abs(S_o_conjugate),math.cos(cmath.phase(S_o_conjugate))))\n",
      "print('Added     %.1fx \\t\\t  j%.1fx \\t %.fx \\t\\t  %.1f lag' %(PF,sin_theta,(PF**2+sin_theta**2),PF))\n",
      "print('Final    (%.f+%.1fx) \\t (%.f+%.1fx) \\t %.1f \\t\\t  %.3f lag' %(P_o,PF,Q_o,sin_theta,S_f_conjugate,PF_final))\n",
      "print('_____________________________________________________________________')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case(a): Additional kVA load that may be added without overloading the alternator , x = S_*a = 658.86 kVA\n",
        "Case(b): Added active power of the additional load , P_a = 527.1 kW\n",
        "         Added reactive power of the additional load , Q_a = j395.32 kvar\n",
        "Case(c): Final active power supplied by alternator , P_f = 2802.1 kW\n",
        "         Final reactive power supplied by alternator , Q_f = j1805.3 kvar\n",
        "Case(d): Final PF of the alternator , PF = 0.841 lagging\n",
        "Power tabulation grid: \n",
        "_____________________________________________________________________\n",
        "\t   P(kW) \t \u00b1jQ(kvar) \t S*(kVA) \t cos\u03b8\n",
        "_____________________________________________________________________\n",
        "Original  2275 \t\t  j1410 \t 2676.5 \t\t  0.85 lag\n",
        "Added     0.8x \t\t  j0.6x \t 1x \t\t  0.8 lag\n",
        "Final    (2275+0.8x) \t (1410+0.6x) \t 3333.3 \t\t  0.841 lag\n",
        "_____________________________________________________________________\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.16, Page number 258"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import cmath\n",
      "\n",
      "#Variable declaration\n",
      "S_o_conjugate = complex(2275,1410)                                  #Load(kVA)\n",
      "theta_S_o_conjugate = cmath.phase(S_o_conjugate)*180/math.pi        #Angle of load(degree)\n",
      "S_a_conjugate = complex(527.1,395.32)                               #Additional load(kVA)\n",
      "theta_S_a_conjugate = cmath.phase(S_a_conjugate)*180/math.pi        #Angle of additional load(degree)\n",
      "S_f_conjugate = complex(2802.1,1805.32)                              #Final load(kVA)\n",
      "theta_S_f_conjugate = cmath.phase(S_f_conjugate)*180/math.pi        #Angle of final load(degree)\n",
      "\n",
      "#Calculation\n",
      "x = S_o_conjugate+S_a_conjugate+(-S_f_conjugate)                    #Tellegens theorem\n",
      "\n",
      "#Result\n",
      "if(x==0):\n",
      "    print('Validity is checked Tellegens theorem , S_*o + S_*a + (_S_*f) = %.f' %abs(x))\n",
      "else:\n",
      "    print('Validity is not checked')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Validity is checked Tellegens theorem , S_*o + S_*a + (_S_*f) = 0\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.17, Page number 258"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import cmath\n",
      "\n",
      "#Variable declaration\n",
      "kW = 40000.0   #Load on a factory(kW)\n",
      "PF = 0.8       #Lagging PF\n",
      "hp = 7500.0    #Power rating of the induction motor(hp)\n",
      "PF_IM = 0.75   #Lagging PF of the induction motor\n",
      "n = 0.91       #Efficiency of induction motor\n",
      "PF_SM = 1.0    #Power factor  of the synchronous motor\n",
      "\n",
      "#Calculation\n",
      "kVA_original = kW/PF                   #Original kVA\n",
      "sin_theta = (1-PF**2)**0.5             #Sin\u03b8\n",
      "kvar_original = kVA_original*sin_theta #Original kvar\n",
      "kW_IM = hp*746/(1000*n)                #Induction motor(kW)\n",
      "kVA_IM = kW_IM/PF_IM                   #Induction motor(kVA)\n",
      "sin_theta_IM = (1-PF_IM**2)**0.5       #Sin\u03b8\n",
      "kvar_IM = kVA_IM*sin_theta_IM          #Induction motor(kvar)\n",
      "kvar_final = kvar_original-kvar_IM     #Final kvar\n",
      "kVA_final = complex(kW,kvar_final)     #Final kVA\n",
      "angle_kVA_final = cmath.phase(kVA_final)*180/math.pi #Angle of Final kVA(degree)\n",
      "PF_final = math.cos(angle_kVA_final*math.pi/180)     #Final power factor\n",
      "\n",
      "#Result\n",
      "print('Overall system PF using a unity PF synchronous motor , Final PF = %.3f lagging' %PF_final)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Overall system PF using a unity PF synchronous motor , Final PF = 0.852 lagging\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.18, Page number 259"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import cmath\n",
      "\n",
      "#Variable declaration\n",
      "kW = 40000.0   #Load on a factory(kW)\n",
      "PF = 0.8       #Lagging PF\n",
      "hp = 7500.0    #Power rating of the synchronous motor(hp)\n",
      "PF_SM = 0.8    #Lagging PF of the synchronous motor\n",
      "n = 0.91       #Efficiency of synchronous motor\n",
      "hp_IM = 7500.0 #Power rating of the induction motor(hp)\n",
      "PF_IM = 0.75   #Lagging PF of the induction motor\n",
      "\n",
      "\n",
      "#Calculation\n",
      "kVA_original = kW/PF                   #Original kVA\n",
      "sin_theta = (1-PF**2)**0.5             #Sin\u03b8\n",
      "kvar_original = kVA_original*sin_theta #Original kvar\n",
      "kW_IM = hp_IM*746/(1000*n)             #Induction motor(kW)\n",
      "kVA_IM = kW_IM/PF_IM                   #Induction motor(kVA)\n",
      "sin_theta_IM = (1-PF_IM**2)**0.5       #Sin\u03b8\n",
      "kvar_IM = kVA_IM*sin_theta_IM          #Induction motor(kvar)\n",
      "kvar_final_IM = kvar_original-kvar_IM  #Final kvar\n",
      "kW_SM = hp*746/(1000*n)                #synchronous motor(kW)\n",
      "kVA_SM = kW_SM/PF_SM                   #synchronous motor(kVA)\n",
      "sin_theta_SM = (1-PF_SM**2)**0.5       #Sin\u03b8\n",
      "kvar_SM = kVA_SM*sin_theta_SM          #synchronous(kvar)\n",
      "kvar_final = kvar_original-kvar_SM-kvar_IM #Final kvar\n",
      "kVA_final = complex(kW,kvar_final)     #Final kVA\n",
      "angle_kVA_final = cmath.phase(kVA_final)*180/math.pi #Angle of Final kVA(degree)\n",
      "PF_final = math.cos(angle_kVA_final*math.pi/180)     #Final power factor\n",
      "\n",
      "#Result\n",
      "print('Case(a): Overall system PF using a unity PF synchronous motor , Final PF = %.3f lagging' %PF_final)\n",
      "print('Case(b): In Ex.8-17, a 6148 kVA, unity PF, 7500 hp synchronous motor is needed. In Ex.8-18, a 7685 kVA, 0.8 PF leading, 7500 hp synchronous motor is needed')\n",
      "print('         Ex.8-18b shows that a 0.8 PF leading, 7500 hp synchronous motor must be physically larger than a unity PF, 7500 hp synchronous motor because of its higher kVA rating')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case(a): Overall system PF using a unity PF synchronous motor , Final PF = 0.895 lagging\n",
        "Case(b): In Ex.8-17, a 6148 kVA, unity PF, 7500 hp synchronous motor is needed. In Ex.8-18, a 7685 kVA, 0.8 PF leading, 7500 hp synchronous motor is needed\n",
        "         Ex.8-18b shows that a 0.8 PF leading, 7500 hp synchronous motor must be physically larger than a unity PF, 7500 hp synchronous motor because of its higher kVA rating\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.19, Page number 259"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import cmath\n",
      "\n",
      "#Variable declaration\n",
      "kVA_load = 500.0   #Load(kVA)\n",
      "PF_load = 0.65     #Lagging PF of load\n",
      "hp = 200.0         #Power rating of the system(hp)\n",
      "n = 0.88           #Efficiency of the system after adding the load\n",
      "PF_final = 0.85    #Final lagging PF after adding the load\n",
      "\n",
      "#Calculation\n",
      "kW_original = kVA_load*PF_load              #Original kW\n",
      "sin_theta_load = (1-PF_load**2)**0.5        #Sin\u03b8\n",
      "kvar_original = kVA_load*sin_theta_load     #Original kvar\n",
      "kW_SM = hp*746/(1000*n)                     #Synchronous motor kW\n",
      "#Case(a)\n",
      "kW_final = kW_original+kW_SM                #Final kW of the system with the motor added\n",
      "kVA_final = kW_final/PF_final               #Final kVA of the system with the motor added\n",
      "PF_system = kW_final/kVA_final              #Final PF of the system with the motor added\n",
      "sin_theta_system = (1-PF_final**2)**0.5     #Sin\u03b8\n",
      "kvar_final = kVA_final*sin_theta_system     #Final kvar of the system with the motor added\n",
      "#Case(b)\n",
      "kvar_SM = kvar_final-kvar_original          #kvar rating of the synchronous motor\n",
      "kVA_SM = complex(kW_SM,kvar_SM)             #kVA rating of the synchronous motor\n",
      "kVA_SM_a = cmath.phase(kVA_SM)*180/math.pi  #Angle of kVA rating of the synchronous motor(degree)\n",
      "PF_SM = math.cos(kVA_SM_a*math.pi/180)      #PF of the sychronous motor\n",
      "\n",
      "#Result\n",
      "print('Case(a): kVA of the system with the motor added , Final kVA = %.f kVA' %kVA_final)\n",
      "print('         PF of the system with the motor added , System PF = %.2f lagging' %PF_system)\n",
      "print('Case(b): kVA of the synchronous motor , Synchronous motor kVa = %.f\u2220%.1f\u00b0 kVA' %(abs(kVA_SM),kVA_SM_a))\n",
      "print('         PF of the synchronous motor at which it operates , Synchronous motor PF = %.3f leading' %PF_SM)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case(a): kVA of the system with the motor added , Final kVA = 582 kVA\n",
        "         PF of the system with the motor added , System PF = 0.85 lagging\n",
        "Case(b): kVA of the synchronous motor , Synchronous motor kVa = 185\u2220-23.4\u00b0 kVA\n",
        "         PF of the synchronous motor at which it operates , Synchronous motor PF = 0.918 leading\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.20, Page number 261"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "f_m = 60.0     #Frequency of motor(Hz)\n",
      "f_a = 4000.0   #Frequency of alternator(Hz)\n",
      "\n",
      "#Calculation\n",
      "Pole_ratio = f_a/f_m    #Ratio of number of poles in alternator to that of motor\n",
      "P_a = 20.0\n",
      "P_m = 3.0\n",
      "P_a1 = 2*P_a            #First combination must have 40 poles on the alternator\n",
      "P_m1 = 2*P_m            #First combination must have 6 poles on the synchronous motor\n",
      "S_1 = 120*f_m/P_m1      #Speed of motor and alternator(rpm)\n",
      "P_a2 = 4*P_a            #Second combination must have 40 poles on the alternator\n",
      "P_m2 = 4*P_m            #Second combination must have 6 poles on the synchronous motor\n",
      "S_2 = 120*f_m/P_m2      #Speed of motor and alternator(rpm)\n",
      "P_a3 = 6*P_a            #Third combination must have 40 poles on the alternator\n",
      "P_m3 = 6*P_m            #Third combination must have 6 poles on the synchronous motor\n",
      "S_3 = 120*f_m/P_m3      #Speed of motor and alternator(rpm)\n",
      "\n",
      "#Result\n",
      "print('First combination have %.f poles on the alternator and %.f poles on the synchronous motor at a speed %.f rpm' %(P_a1,P_m1,S_1))\n",
      "print('Second combination have %.f poles on the alternator and %.f poles on the synchronous motor at a speed %.f rpm' %(P_a2,P_m2,S_2))\n",
      "print('Third combination have %.f poles on the alternator and %.f poles on the synchronous motor at a speed %.f rpm' %(P_a3,P_m3,S_3))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "First combination have 40 poles on the alternator and 6 poles on the synchronous motor at a speed 1200 rpm\n",
        "Second combination have 80 poles on the alternator and 12 poles on the synchronous motor at a speed 600 rpm\n",
        "Third combination have 120 poles on the alternator and 18 poles on the synchronous motor at a speed 400 rpm\n"
       ]
      }
     ],
     "prompt_number": 1
    }
   ],
   "metadata": {}
  }
 ]
}