{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "CHAPTER 7: PARALLEL OPERATION"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.1, Page number 182"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "R_sh = 120.0   #Shunt field resistance(ohm)\n",
      "R_a = 0.1      #Armature resistance(ohm)\n",
      "V_L = 120.0    #Line voltage(V)\n",
      "E_g1 = 125.0   #Generated voltage by dynamo A(V)\n",
      "E_g2 = 120.0   #Generated voltage by dynamo B(V)\n",
      "E_g3 = 114.0   #Generated voltage by dynamo C(V)\n",
      "\n",
      "#Calculation\n",
      "#Case(a) #1\n",
      "I_gA = (E_g1-V_L)/R_a  #Current in the generating dynamo A(A)\n",
      "I_f = V_L/R_sh         #Shunt field current(A)\n",
      "I_a1 = I_gA+I_f        #Armature current for dynamo A(A)\n",
      "I_L1 = I_gA            #Current delivered by dynamo A to the bus(A)\n",
      "#2\n",
      "I_gB = (E_g2-V_L)/R_a #Current in the generating dynamo B(A)\n",
      "I_a2 = I_gB+I_f       #Armature current for dynamo B(A)\n",
      "I_L2 = I_gB           #Current delivered by dynamo B to the bus(A)\n",
      "#3\n",
      "I_gC = (V_L-E_g3)/R_a #Current in the generating dynamo C(A)\n",
      "I_a3 = I_gC           #Armature current for dynamo C(A)\n",
      "I_L3 = I_gC+I_f       #Current received by dynamo C from the bus(A)\n",
      "#Case(b) #1\n",
      "P_LA = V_L*I_L1       #Power delivered to the bus by dynamo A(W)\n",
      "P_gA = E_g1*I_a1      #Power generated by dynamo A(W)\n",
      "#2\n",
      "P_LB = V_L*I_L2       #Power delivered to the bus by dynamo B(W)\n",
      "P_gB = E_g2*I_a2      #Power generated by dynamo B(W)\n",
      "#3\n",
      "P_LC = V_L*I_L3       #Power delivered by the bus to dynamo C(W)\n",
      "P_gC = E_g3*I_a3      #Power generated by dynamo C(W)\n",
      "\n",
      "#Result\n",
      "print('Case(a) 1: Line current delivered by dynamo A to the bus , I_LA = %.f A' %I_L1)\n",
      "print('           Armature current , I_a = %.f A' %I_a1)\n",
      "print('        2: Line current delivered by dynamo B to the bus , I_LB = %.f A. Thus dynamo B is floating' %I_L2)\n",
      "print('           Armature current , I_a = %.f A' %I_a2)\n",
      "print('        3: Line current received by dynamo C from the bus , I_LC = %.f A' %I_L3)\n",
      "print('           Armature current , I_a = %.f A' %I_a3)\n",
      "print('\\nCase(b) 1: Power delivered to the bus by dynamo A , P_LA = %.f W' %P_LA)\n",
      "print('           Power generated by dynamo A , P_gA = %.f W' %P_gA)\n",
      "print('        2: Dynamo B neither receives or delivers power , P_LB = %.f W' %P_LB)\n",
      "print('           Power generated by dynamo B to excite its field , P_gB = %.f W' %P_gB)\n",
      "print('        3: Power delivered by the bus to dynamo C , P_LC = %.f W' %P_LC)\n",
      "print('           Internal power delivered in the direction of rotation of its prime mover , P_gC = %.f W' %P_gC)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case(a) 1: Line current delivered by dynamo A to the bus , I_LA = 50 A\n",
        "           Armature current , I_a = 51 A\n",
        "        2: Line current delivered by dynamo B to the bus , I_LB = 0 A. Thus dynamo B is floating\n",
        "           Armature current , I_a = 1 A\n",
        "        3: Line current received by dynamo C from the bus , I_LC = 61 A\n",
        "           Armature current , I_a = 60 A\n",
        "\n",
        "Case(b) 1: Power delivered to the bus by dynamo A , P_LA = 6000 W\n",
        "           Power generated by dynamo A , P_gA = 6375 W\n",
        "        2: Dynamo B neither receives or delivers power , P_LB = 0 W\n",
        "           Power generated by dynamo B to excite its field , P_gB = 120 W\n",
        "        3: Power delivered by the bus to dynamo C , P_LC = 7320 W\n",
        "           Internal power delivered in the direction of rotation of its prime mover , P_gC = 6840 W\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.2, Page number 182"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "R_a = 0.1       #Armature resistance(ohm)\n",
      "R_f = 100.0     #Field circuit resistance(ohm)\n",
      "V_L_b = 120.0   #Bus voltage(V)\n",
      "V_L_a = 140.0   #Generated voltage of the generator(V)\n",
      "\n",
      "#Calculation\n",
      "#Case(a)\n",
      "V_f = V_L_a                  #Voltage across the field(V)\n",
      "I_f_a = V_f/R_f              #Field current(A)\n",
      "I_a_a = I_f_a                #Armature current(A)\n",
      "E_g_a = V_L_a+I_a_a*R_a      #Generated EMF(V)\n",
      "P_g_a = E_g_a*I_a_a          #Generated power(W)\n",
      "#Case(b)\n",
      "I_a_b = (E_g_a-V_L_b)/R_a    #Armature current(A)\n",
      "I_f_b = V_L_b/R_f            #Field current(A)\n",
      "I_Lg = I_a_b-I_f_b           #Generated line current(A)\n",
      "P_L = V_L_b*I_Lg             #Power generated across the lines(W)\n",
      "E_g_b = V_L_a\n",
      "P_g_b = E_g_b*I_a_b          #Generated power(W)\n",
      "\n",
      "#Result\n",
      "print('Case(a): Generated current before it is connected to the bus , I_a = %.1f A' %I_a_a)\n",
      "print('         Generated power before it is connected to the bus , P_g = %.1f W' %P_g_a)\n",
      "print('Case(b): Generated armature current after it is connected to the bus , I_a = %.1f A' %I_a_b)\n",
      "print('         Generated line current after it is connected to the bus , I_Lg = %.1f A' %I_Lg)\n",
      "print('         Generated power across the line after it is connected to the bus , P_g = %.f W' %P_L)\n",
      "print('         Generated power after it is connected to the bus , P_g = %.f W' %P_g_b)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case(a): Generated current before it is connected to the bus , I_a = 1.4 A\n",
        "         Generated power before it is connected to the bus , P_g = 196.2 W\n",
        "Case(b): Generated armature current after it is connected to the bus , I_a = 201.4 A\n",
        "         Generated line current after it is connected to the bus , I_Lg = 200.2 A\n",
        "         Generated power across the line after it is connected to the bus , P_g = 24024 W\n",
        "         Generated power after it is connected to the bus , P_g = 28196 W\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.3, Page number 183"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "R_a1 = 0.1      #Armature resistance of shunt generator 1(ohm)\n",
      "R_a2 = 0.1      #Armature resistance of shunt generator 2(ohm)\n",
      "R_a3 = 0.1      #Armature resistance of shunt generator 3(ohm)\n",
      "R_L = 2.0       #Load resistance(ohm)\n",
      "E_g1 = 127.0    #Voltage generated by shunt generator 1(V)\n",
      "E_g2 = 120.0    #Voltage generated by shunt generator 2(V)\n",
      "E_g3 = 119.0    #Voltage generated by shunt generator 3(V)\n",
      "\n",
      "#Calculation\n",
      "#Case(a)\n",
      "V_L = ((E_g1/R_a1)+(E_g2/R_a2)+(E_g3/R_a3))/((1/R_a1)+(1/R_a2)+(1/R_a3)+(1/R_L))\n",
      "#Case(b)\n",
      "I_L1 = (E_g1-V_L)/R_a1   #Current delivered/received by generator 1(A)\n",
      "I_L2 = (E_g2-V_L)/R_a2   #Current delivered/received by generator 2(A)\n",
      "I_L3 = (E_g3-V_L)/R_a3   #Current delivered/received by generator 3(A)\n",
      "I_L = -V_L/R_L           #Current received by 2 ohm load(A)\n",
      "#Case(c)\n",
      "I_a1 = I_L1              #Armature current for generator 1(A)\n",
      "I_a2 = I_L2              #Armature current for generator 2(A)\n",
      "I_a3 = I_L3              #Armature current for generator 3(A)\n",
      "P_g1 = E_g1*I_a1         #Power generated by generator 1(W)\n",
      "P_g2 = E_g2*I_a2         #Power generated by generator 2(W)\n",
      "P_g3 = E_g3*I_a3         #Power generated by generator 3(W)\n",
      "#Case(d)\n",
      "P_L1 = V_L*I_L1          #Power delivered/received from generator 1(W)\n",
      "P_L2 = V_L*I_L2          #Power delivered/received from generator 2(W)\n",
      "P_L3 = V_L*I_L3          #Power delivered/received from generator 3(W)\n",
      "P_L = V_L*I_L            #Power delivered/received from 2 ohm load(W)\n",
      "\n",
      "#Result\n",
      "print('Case(a): Terminal bus voltage , V_L = %.f V' %V_L)\n",
      "print('Case(b): Current delivered to the bus by generator 1 , I_L1 = %.f A (to bus)' %I_L1)\n",
      "print('         Current delivered to the bus by generator 2 , I_L2 = %.f A' %I_L2)\n",
      "print('         Current received by the generator 3 from the bus , I_L3 = %.f A (from bus)' %I_L3)\n",
      "print('         Current received from the bus by load , I_L3 = %.f A (from bus)' %I_L)\n",
      "print('Case(c): Power generated by generator 1 , P_g1 = %.f W' %P_g1)\n",
      "print('         Power generated by generator 2 , P_g2 = %.f W (floating)' %P_g2)\n",
      "print('         Power generated by generator 3 , P_g3 = %.f W' %P_g3)\n",
      "print('Case(d): Power delivered to the bus from generator 1 , P_L1 = %.f W' %P_L1)\n",
      "print('         Power delivered to the bus from generator 2 , P_L2 = %.f W' %P_L2)\n",
      "print('         Power received from the bus by generator 3 , P_L2 = %.f W' %P_L3)\n",
      "print('         Power received from the bus by load , P_L = %.f W' %P_L)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case(a): Terminal bus voltage , V_L = 120 V\n",
        "Case(b): Current delivered to the bus by generator 1 , I_L1 = 70 A (to bus)\n",
        "         Current delivered to the bus by generator 2 , I_L2 = 0 A\n",
        "         Current received by the generator 3 from the bus , I_L3 = -10 A (from bus)\n",
        "         Current received from the bus by load , I_L3 = -60 A (from bus)\n",
        "Case(c): Power generated by generator 1 , P_g1 = 8890 W\n",
        "         Power generated by generator 2 , P_g2 = 0 W (floating)\n",
        "         Power generated by generator 3 , P_g3 = -1190 W\n",
        "Case(d): Power delivered to the bus from generator 1 , P_L1 = 8400 W\n",
        "         Power delivered to the bus from generator 2 , P_L2 = 0 W\n",
        "         Power received from the bus by generator 3 , P_L2 = -1200 W\n",
        "         Power received from the bus by load , P_L = -7200 W\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.4, Page number 184"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "P1 = 300.0          #Power rating of generator 1(kW)\n",
      "P2 = 600.0          #Power rating of generator 2(kW)\n",
      "V = 220.0           #Voltage rating of generator 1 and 2(V)\n",
      "V_o = 250.0         #No-load voltage applied to both the generators(V)\n",
      "V_1 = 230.0         #Terminal voltage(V)\n",
      "V_2 = 240.0         #Terminal voltage(V)\n",
      "\n",
      "#Calculation\n",
      "#Case(a)\n",
      "kW1_a = (V_o-V_1)/(V_o-V)*P1   #Load carried by generator 1(kW)\n",
      "kW2_a = (V_o-V_1)/(V_o-V)*P2   #Load carried by generator 2(kW)\n",
      "#Case(b)\n",
      "kW1_b = (V_o-V_2)/(V_o-V)*P1   #Load carried by generator 1(kW)\n",
      "kW2_b = (V_o-V_2)/(V_o-V)*P2   #Load carried by generator 2(kW)\n",
      "#Case(c)\n",
      "frac_a = (V_o-V_1)/(V_o-V)     #Fraction of rated kW carried by each generator\n",
      "frac_b = (V_o-V_2)/(V_o-V)     #Fraction of rated kW carried by each generator\n",
      "\n",
      "#Result\n",
      "print('Case(a): When the terminal voltage is 230 V Generator 1 carries = %.f kW' %kW1_a)\n",
      "print('         When the terminal voltage is 230 V Generator 2 carries = %.f kW' %kW2_a)\n",
      "print('Case(b): When the terminal voltage is 240 V Generator 1 carries = %.f kW' %kW1_b)\n",
      "print('         When the terminal voltage is 240 V Generator 2 carries = %.f kW' %kW2_b)\n",
      "print('Case(c): Both generators carry no-load at 250 V ; %.3f rated load at %d V ; %.3f rated load at %d V ; and rated load at %d V ;' %(frac_b,V_2,frac_a,V_1,V))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case(a): When the terminal voltage is 230 V Generator 1 carries = 200 kW\n",
        "         When the terminal voltage is 230 V Generator 2 carries = 400 kW\n",
        "Case(b): When the terminal voltage is 240 V Generator 1 carries = 100 kW\n",
        "         When the terminal voltage is 240 V Generator 2 carries = 200 kW\n",
        "Case(c): Both generators carry no-load at 250 V ; 0.333 rated load at 240 V ; 0.667 rated load at 230 V ; and rated load at 220 V ;\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.5, Page number 191"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "E_1 = 220.0    #Terminal voltage of alternator 1(V)\n",
      "E_2 = 222.0    #Terminal voltage of alternator 2(V)\n",
      "f_1 = 60.0     #Frequency of alternator 1(Hz)\n",
      "f_2 = 59.5     #Frequency of alternator 2(Hz)\n",
      "\n",
      "#Calculation\n",
      "E_max = (E_1+E_2)/2    #Maximum effective voltage across each lamp(V) \n",
      "E_min = (E_2-E_1)/2    #Minimum effective voltage across each lamp(V) \n",
      "f = f_1-f_2            #Frequency of the voltage across the lamps(Hz)\n",
      "E_peak = E_max/0.7071  #Peak value of the voltage across each lamp(V)\n",
      "n = (1.0/2)*f_1        #Number of maximum light pulsations per minute\n",
      "\n",
      "#Result\n",
      "print('Case(a): Maximum effective voltage across each lamp , E_max/lamp = %.f V (rms)' %E_max)\n",
      "print('         Minimum effective voltage across each lamp , E_min/lamp = %.f V' %E_min)\n",
      "print('Case(b): Frequency of the voltage across the lamps , f = %.1f Hz' %f)\n",
      "print('Case(c): Peak value of the voltage across each lamp , E_peak = %.f V' %E_peak)\n",
      "print('Case(d): Number of maximum light pulsations per minute , n = %.f pulsations/min' %n)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case(a): Maximum effective voltage across each lamp , E_max/lamp = 221 V (rms)\n",
        "         Minimum effective voltage across each lamp , E_min/lamp = 1 V\n",
        "Case(b): Frequency of the voltage across the lamps , f = 0.5 Hz\n",
        "Case(c): Peak value of the voltage across each lamp , E_peak = 313 V\n",
        "Case(d): Number of maximum light pulsations per minute , n = 30 pulsations/min\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.6, Page number 191"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "E_1 = 220.0   #Voltage generated by alternator 1(V)\n",
      "E_2 = 220.0   #Voltage generated by alternator 2(V)\n",
      "f_1 = 60.0    #Frequency of alternator 1(Hz)\n",
      "f_2 = 58.0    #Frequency of alternator 2(Hz)\n",
      "\n",
      "#Calculation\n",
      "E_max = (E_1+E_2)/2    #Maximum effective voltage across each lamp(V)\n",
      "f = f_1-f_2            #Frequency of the voltage across the lamp(Hz)\n",
      "E_min = (E_2-E_1)/2    #Minimum effective voltage across each lamp(V) \n",
      "\n",
      "#Result\n",
      "print('Case(a): Maximum effective voltage across each lamp , E_max/lamp = %.f V' %E_max)\n",
      "print('         Frequency of the voltage across each lamp , f = %.f Hz' %f)\n",
      "print('Case(b): The voltages are equal and opposite in the local circuit')\n",
      "print('Case(c): Minimum effective voltage across each lamp , E_min/lamp = %.f V' %E_min)\n",
      "print('         Frequency of the voltage across each lamp , f = 0 Hz')\n",
      "print('Case(d): The voltages are in phase in the local circuit')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case(a): Maximum effective voltage across each lamp , E_max/lamp = 220 V\n",
        "         Frequency of the voltage across each lamp , f = 2 Hz\n",
        "Case(b): The voltages are equal and opposite in the local circuit\n",
        "Case(c): Minimum effective voltage across each lamp , E_min/lamp = 0 V\n",
        "         Frequency of the voltage across each lamp , f = 0 Hz\n",
        "Case(d): The voltages are in phase in the local circuit\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.7, Page number 193"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import cmath\n",
      "\n",
      "#Variable declaration\n",
      "E_1 = 220.0    #Terminal voltage of alternator 1(V) From Ex. 7-5\n",
      "E_2 = 222.0    #Terminal voltage of alternator 2(V)\n",
      "f_1 = 60.0     #Frequency of alternator 1(Hz)\n",
      "f_2 = 59.5     #Frequency of alternator 2(Hz)\n",
      "E1 = 220.0     #Voltage generated by alternator 1(V) From Ex. 7-6\n",
      "E2 = 220.0     #Voltage generated by alternator 2(V)\n",
      "f1 = 60.0      #Frequency of alternator 1(Hz)\n",
      "f2 = 58.0      #Frequency of alternator 2(Hz)\n",
      "R_a1 = 0.1     #Armature resistance of alternator 1(ohm)\n",
      "R_a2 = 0.1     #Armature resistance of alternator 2(ohm)\n",
      "X_a1 = 0.9     #Armature reactance of alternator 1(ohm)\n",
      "X_a2 = 0.9     #Armature reactance of alternator 2(ohm)\n",
      "\n",
      "#Calculation\n",
      "Z_1 = complex(R_a1,X_a1)   #Effective impedance of alternator 1(ohm)\n",
      "Z_2 = complex(R_a2,X_a2)   #Effective impedance of alternator 2(ohm)\n",
      "#In Ex.7-5\n",
      "E_r = E_2-E_1              #Effective voltage generated(V) \n",
      "I_s = E_r/(Z_1+Z_2)        #Synchronizing current in the armature(A)\n",
      "#In Ex.7-6\n",
      "Er = E2 -E1                #Effective voltage generated(V)\n",
      "Is = Er/(Z_1+Z_2)          #Synchronizing current in the armature(A)\n",
      "\n",
      "#Result\n",
      "print('In Ex.7-5 the synchronizing current in the armatures of both alternators , I_s = %.3f\u2220%.2f\u00b0 A' %(abs(I_s),cmath.phase(I_s)*180/math.pi))\n",
      "print('In Ex.7-6 the synchronizing current in the armatures of both alternators , I_s = %.f\u2220%.f\u00b0 A' %(abs(Is),cmath.phase(Is)*180/math.pi))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "In Ex.7-5 the synchronizing current in the armatures of both alternators , I_s = 1.104\u2220-83.66\u00b0 A\n",
        "In Ex.7-6 the synchronizing current in the armatures of both alternators , I_s = 0\u22200\u00b0 A\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.8, Page number 195"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import cmath\n",
      "\n",
      "#Variable declaration\n",
      "E_gp1 = 200.0    #Terminal voltage of alternator 1(V)\n",
      "E_gp2 = 220.0    #Terminal voltage of alternator 2(V)\n",
      "R_a1 = 0.2       #Armature resistance of alternator 1(ohm)\n",
      "R_a2 = 0.2       #Armature resistance of alternator 2(ohm)\n",
      "X_a1 = 2.0       #Armature reactance of alternator 1(ohm)\n",
      "X_a2 = 2.0       #Armature reactance of alternator 1(ohm)\n",
      "\n",
      "#Calculation\n",
      "#Case(a)\n",
      "Z_p1 = complex(R_a1,X_a1)   #Effective impedance of alternator 1(ohm)\n",
      "Z_p2 = complex(R_a2,X_a2)   #Effective impedance of alternator 2(ohm)\n",
      "E_r = (E_gp2-E_gp1)         #Effective voltage generated(V)\n",
      "I_s = E_r/(Z_p1+Z_p2)       #Synchronizing current in the armature(A)\n",
      "Is = abs(I_s)               #Magnitude of Synchronizing current(A)\n",
      "theta = cmath.phase(I_s)*180/math.pi         #Angle of Synchronizing current(degree)\n",
      "P_2 = E_gp2*Is*math.cos(theta*math.pi/180)   #Generator action developed by alternator 2(W)\n",
      "#Case(b)\n",
      "P_1 = -E_gp1*Is*math.cos(theta*math.pi/180)  #Synchronizing power received by alternator 1(W) \n",
      "#Case(c)\n",
      "P1 = abs(P_1)                                #Magnitude of P1(W)\n",
      "losses = P_2-P1                              #Power loss in both armatures(W)\n",
      "check = E_r*Is*math.cos(theta*math.pi/180)   #Verifying losses(W) by Eq.7-7\n",
      "double_check = Is**2*(R_a1+R_a2)             #Verifying losses(W) by Eq.7-7\n",
      "#Case(d)\n",
      "V_p2  = E_gp2-Is*abs(Z_p2)                   #Generator action(V)\n",
      "V_p1  = E_gp1+Is*abs(Z_p1)                   #Motor action(V)\n",
      "\n",
      "#Result\n",
      "print('Case(a): Generator action developed by alternator 2 , P_2 = %.1f W' %P_2)\n",
      "print('Case(b): Synchronizing power received by alternator 1 , P_1 = %.1f W' %P_1)\n",
      "print('Case(c): Power loss in both armature , Losses = %.f W' %losses)\n",
      "print('Case(d): Terminal voltage of alternator 2 , V_p2 = %.f V (generator action)' %V_p2)\n",
      "print('         Terminal voltage of alternator 1 , V_p2 = %.f V (motor action)' %V_p1)\n",
      "print('Case(e): Phasor diagram is shown in Fig 7-14 in textbook page no 195')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case(a): Generator action developed by alternator 2 , P_2 = 108.9 W\n",
        "Case(b): Synchronizing power received by alternator 1 , P_1 = -99.0 W\n",
        "Case(c): Power loss in both armature , Losses = 10 W\n",
        "Case(d): Terminal voltage of alternator 2 , V_p2 = 210 V (generator action)\n",
        "         Terminal voltage of alternator 1 , V_p2 = 210 V (motor action)\n",
        "Case(e): Phasor diagram is shown in Fig 7-14 in textbook page no 195\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.9, Page number 199"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import cmath\n",
      "\n",
      "#Variable declaration\n",
      "E_2 = 230.0*cmath.exp(1j*180.0*math.pi/180)    #Voltage generated by alternator 2(V)\n",
      "E_1 = 230.0*cmath.exp(1j*20.0*math.pi/180)     #Voltage generated by alternator 1(V)\n",
      "Z = 2.01*cmath.exp(1j*84.3*math.pi/180)        #Impedance(ohm)\n",
      "\n",
      "#Calculation\n",
      "E_r = E_2+E_1                                  #Total voltage generated by Alternator 1 and 2(V)\n",
      "Z_1 = Z\n",
      "Z_2 = Z\n",
      "#Case(a)\n",
      "I_s = E_r/(Z_1+Z_2)                            #Synchronizing current(A)\n",
      "Is = abs(I_s)                                  #Magnitude of Synchronizing current(A)\n",
      "I_s_a = cmath.phase(I_s)*180/math.pi           #Phase angle of Synchronizing current(degrees)\n",
      "#Case(b)\n",
      "E_gp1 = abs(E_1)\n",
      "E_gp1_Is = (cmath.phase(E_1)*180/math.pi)-I_s_a     #Angle(degree)\n",
      "P_1 = E_gp1*Is*math.cos(E_gp1_Is*math.pi/180)       #Synchronizing power developed by alternator 1(W)\n",
      "#Case(c)\n",
      "E_gp2 = abs(E_2)\n",
      "E_gp2_Is = (cmath.phase(E_2)*180/math.pi)-I_s_a     #Angle(degree)\n",
      "P_2 = E_gp2*Is*math.cos(E_gp2_Is*math.pi/180)       #Synchronizing power developed by alternator 2(W)\n",
      "#Case(d)\n",
      "P2 = abs(P_2);\n",
      "losses = P_1-P2                                     #Losses in the armature(W)\n",
      "theta = cmath.phase(Z)*180/math.pi                  #Angle(degree)\n",
      "check = abs(E_r)*Is*math.cos(theta*math.pi/180)     #Verifying losses(W) by Eq.7-7\n",
      "R_aT = 2*Z.real                                     #Total armature resistance of alternator 1 and 2(ohm)\n",
      "double_check = Is**2*R_aT                           #Verifying losses(W) by Eq.7-7\n",
      "\n",
      "#Result\n",
      "print('Case(a): Synchronizing current , I_s = %.2f\u2220%.1f\u00b0 A' %(Is,I_s_a))\n",
      "print('Case(b): Synchronizing power developed by alternator 1 , P_1 = %.f W (power delivered to bus)' %P_1)\n",
      "print('Case(c): Synchronizing power developed by alternator 2 , P_2 = %.f W (power received from bus)' %P_2)\n",
      "print('Case(d): Losses in the armature , Losses = %.f W' %losses)\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): Synchronizing current , I_s = 19.87\u222015.7\u00b0 A\n",
        "Case(b): Synchronizing power developed by alternator 1 , P_1 = 4557 W (power delivered to bus)\n",
        "Case(c): Synchronizing power developed by alternator 2 , P_2 = -4400 W (power received from bus)\n",
        "Case(d): Losses in the armature , Losses = 158 W\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 7.10, Page number 200"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import cmath\n",
      "\n",
      "#Variable declaration\n",
      "E_2 = 230.0*cmath.exp(1j*180.0*math.pi/180)    #Voltage generated by alternator 2(V)\n",
      "E_1 = 230.0*cmath.exp(1j*20.0*math.pi/180)     #Voltage generated by alternator 1(V)\n",
      "Z = 6.0*cmath.exp(1j*50.0*math.pi/180)         #Impedance(ohm)\n",
      "\n",
      "#Calculation\n",
      "E_r = E_2+E_1                                  #Total voltage generated by Alternator 1 and 2(V)\n",
      "Z_1 = Z\n",
      "Z_2 = Z\n",
      "#Case(a)\n",
      "I_s = E_r/(Z_1+Z_2)                            #Synchronizing current(A)\n",
      "Is = abs(I_s)                                  #Magnitude of Synchronizing current(A)\n",
      "I_s_a = cmath.phase(I_s)*180/math.pi           #Phase angle of Synchronizing current(degrees)\n",
      "#Case(b)\n",
      "E_gp1 = abs(E_1)\n",
      "E_gp1_Is = (cmath.phase(E_1)*180/math.pi)-I_s_a     #Angle(degree)\n",
      "P_1 = E_gp1*Is*math.cos(E_gp1_Is*math.pi/180)       #Synchronizing power developed by alternator 1(W)\n",
      "#Case(c)\n",
      "E_gp2 = abs(E_2)\n",
      "E_gp2_Is = (cmath.phase(E_2)*180/math.pi)-I_s_a     #Angle(degree)\n",
      "P_2 = E_gp2*Is*math.cos(E_gp2_Is*math.pi/180)       #Synchronizing power developed by alternator 2(W)\n",
      "#Case(d)\n",
      "P2 = abs(P_2);\n",
      "losses = P_1-P2                                     #Losses in the armature(W)\n",
      "theta = cmath.phase(Z)*180/math.pi                  #Angle(degree)\n",
      "check = abs(E_r)*Is*math.cos(theta*math.pi/180)     #Verifying losses(W) by Eq.7-7\n",
      "R_aT = 2*Z.real                                     #Total armature resistance of alternator 1 and 2(ohm)\n",
      "double_check = Is**2*R_aT                           #Verifying losses(W) by Eq.7-7\n",
      "\n",
      "#Result\n",
      "print('Case(a): Synchronizing current , I_s = %.2f\u2220%.1f\u00b0 A' %(Is,I_s_a))\n",
      "print('Case(b): Synchronizing power developed by alternator 1 , P_1 = %.f W (power delivered to bus)' %P_1)\n",
      "print('Case(c): Synchronizing power developed by alternator 2 , P_2 = %.f W (power received from bus)' %P_2)\n",
      "print('Case(d): Losses in the armature , Losses = %.f W' %losses)\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): Synchronizing current , I_s = 6.66\u222050.0\u00b0 A\n",
        "Case(b): Synchronizing power developed by alternator 1 , P_1 = 1326 W (power delivered to bus)\n",
        "Case(c): Synchronizing power developed by alternator 2 , P_2 = -984 W (power received from bus)\n",
        "Case(d): Losses in the armature , Losses = 342 W\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 7.11, Page number 207"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import cmath\n",
      "import numpy\n",
      "\n",
      "#Variable declaration\n",
      "V_AB = 100.0*cmath.exp(1j*0.0*math.pi/180)      #Voltage supplied across A & B(V)\n",
      "V_BC = 100.0*cmath.exp(1j*-120.0*math.pi/180)   #Voltage supplied across B & C(V)\n",
      "V_CA = 100.0*cmath.exp(1j*120.0*math.pi/180)    #Voltage supplied across C & A(V)\n",
      "I1_1 = complex(6,0)\n",
      "I1_2 = complex(-3,0)\n",
      "I2_1 = complex(-3,0)\n",
      "I2_2 = complex(3,-4)\n",
      "V_1 = complex(100,0)\n",
      "V_2 = complex(-50,-86.6)\n",
      "\n",
      "#Calculation\n",
      "A = [[I1_1,I2_1],[I1_2,I2_2]]          #Matrix containing mesh equations array\n",
      "delta = numpy.linalg.det(A)            #Determinant of A\n",
      "#Case(a)\n",
      "I_1 = numpy.linalg.det([[V_1,I2_1],[V_2,I2_2]])/delta   #Mesh current I_1(A) \n",
      "I_2 = numpy.linalg.det([[I1_1,V_1],[I1_2,V_2]])/delta    #Mesh current I_2(A) \n",
      "#Case(b)\n",
      "I_A = I_1                      #Line current(A)\n",
      "I_B = I_2-I_1                  #Line current(A)\n",
      "I_C = -I_2                     #Line current(A)\n",
      "#Case(c)\n",
      "Z_A = complex(3,0)             #Impedance(ohm)\n",
      "Z_B = complex(3,0)             #Impedance(ohm)\n",
      "Z_C = complex(0,-4)            #Impedance(ohm)\n",
      "V_AO = I_A*Z_A                 #Phase voltage(V)\n",
      "V_BO = I_B*Z_B                 #Phase voltage(V)\n",
      "V_CO = I_C*Z_C                 #Phase voltage(V)\n",
      "\n",
      "#Result\n",
      "print('Case(a): Mesh current , I_1 = (%.3f%.4fj) A  = %.1f\u2220%.2f\u00b0 A' %(I_1.real,I_1.imag,abs(I_1),cmath.phase(I_1)*180/math.pi))\n",
      "print('         Mesh current , I_2 = (%.2f%.3fj) A  = %.2f\u2220%.2f\u00b0 A' %(I_2.real,I_2.imag,abs(I_2),cmath.phase(I_2)*180/math.pi))\n",
      "print('Case(a): Line current , I_A = (%.2f%.3fj) A  = %.1f\u2220%.2f\u00b0 A' %(I_A.real,I_A.imag,abs(I_A),cmath.phase(I_A)*180/math.pi))\n",
      "print('         Line current , I_B = (%.3f%.3fj) A  = %.3f\u2220%.2f\u00b0 A' %(I_B.real,I_B.imag,abs(I_B),cmath.phase(I_B)*180/math.pi))\n",
      "print('         Line current , I_C = (%.2f+%.3fj) A  = %.2f\u2220%.2f\u00b0 A' %(I_C.real,I_C.imag,abs(I_C),cmath.phase(I_C)*180/math.pi))\n",
      "print('Case(c): Phase voltage , V_AO = %.1f\u2220%.2f\u00b0 V' %(abs(V_AO),cmath.phase(V_AO)*180/math.pi))\n",
      "print('         Phase voltage , V_BO = %.2f\u2220%.1f\u00b0 V' %(abs(V_BO),cmath.phase(V_BO)*180/math.pi))\n",
      "print('         Phase voltage , V_CO = %.2f\u2220%.2f\u00b0 V' %(abs(V_CO),cmath.phase(V_CO)*180/math.pi))\n",
      "print('Case(d): The phasor diagram is shown in fig 7-23b in textbook page no.208')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case(a): Mesh current , I_1 = (26.157-3.5589j) A  = 26.4\u2220-7.75\u00b0 A\n",
        "         Mesh current , I_2 = (18.98-7.118j) A  = 20.27\u2220-20.56\u00b0 A\n",
        "Case(a): Line current , I_A = (26.16-3.559j) A  = 26.4\u2220-7.75\u00b0 A\n",
        "         Line current , I_B = (-7.176-3.559j) A  = 8.010\u2220-153.62\u00b0 A\n",
        "         Line current , I_C = (-18.98+7.118j) A  = 20.27\u2220159.44\u00b0 A\n",
        "Case(c): Phase voltage , V_AO = 79.2\u2220-7.75\u00b0 V\n",
        "         Phase voltage , V_BO = 24.03\u2220-153.6\u00b0 V\n",
        "         Phase voltage , V_CO = 81.09\u222069.44\u00b0 V\n",
        "Case(d): The phasor diagram is shown in fig 7-23b in textbook page no.208\n"
       ]
      }
     ],
     "prompt_number": 1
    }
   ],
   "metadata": {}
  }
 ]
}