{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "CHAPTER 3: TRANSFORMER AND PER UNIT SYSTEM"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.1, Page number 90-91"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "V_1 = 2200.0     #Primary voltage of transformer(V)\n",
      "V_2 = 220.0      #Secondary voltage of transformer(V)\n",
      "N_2 = 56.0       #Number of turns in the secondary coil of transformer\n",
      "kVA = 25.0       #Rating of transformer(kVA)\n",
      "\n",
      "#Calculation\n",
      "a = V_1/V_2           #Turns ratio\n",
      "#For case(i)\n",
      "N_1 = a*N_2           #Number of primary turns\n",
      "#For case(ii)\n",
      "I_1 = kVA*10**3/V_1   #Primary full load current(A)\n",
      "#For case(iii)\n",
      "I_2 = kVA*10**3/V_2   #Secondary full load current(A)\n",
      "\n",
      "#Result\n",
      "print('(i)   Number of primary turns , N_1 = %.f ' %N_1)\n",
      "print('(ii)  Primary full load current , I_2 = %.2f A' %I_1)\n",
      "print('(iii) Secondary full load current , I_2 = %.1f A' %I_2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i)   Number of primary turns , N_1 = 560 \n",
        "(ii)  Primary full load current , I_2 = 11.36 A\n",
        "(iii) Secondary full load current , I_2 = 113.6 A\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.2, Page number 91"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "V_1 = 220.0     #Voltage(V)\n",
      "N_1 = 150.0     #Number of turns in primary side\n",
      "N_2 = 300.0     #Number of turns in secondary side\n",
      "f = 50.0        #Frequency(Hz)\n",
      "\n",
      "#Calculation\n",
      "#For case(i)\n",
      "a = N_1/N_2                       #Turns ratio\n",
      "#For case(ii)\n",
      "phi_m = V_1/(4.44*f*N_1)*10**3    #Mutual flux(mWb)\n",
      "\n",
      "#Result\n",
      "print('(i)  Turns ratio , a = %.1f ' %a)\n",
      "print('(ii) Mutual flux in the core , \u03a6_m = %.2f mWb' %phi_m)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i)  Turns ratio , a = 0.5 \n",
        "(ii) Mutual flux in the core , \u03a6_m = 6.61 mWb\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.3, Page number 92"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "V_1 = 2200.0    #Primary voltage(V)\n",
      "V_2 = 220.0     #Secondary voltage(V)\n",
      "I_0 = 0.5       #No-load current(A)\n",
      "P_0 = 350.0     #Power absorbed(W)\n",
      "\n",
      "#Calculation\n",
      "cos_phi_0 = P_0/(V_1*I_0)        #No-load power factor\n",
      "I_w = I_0*cos_phi_0              #Iron loss component of current(A)\n",
      "phi_0 = math.acos(cos_phi_0)     #Power factor angle\n",
      "I_m = I_0*math.sin(phi_0)        #Magnetizing component of current(A)\n",
      "\n",
      "#Result\n",
      "print('Iron loss component of current , I_w = %.2f A' %I_w)\n",
      "print('Magnetizing component of current , I_m = %.2f A' %I_m)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Iron loss component of current , I_w = 0.16 A\n",
        "Magnetizing component of current , I_m = 0.47 A\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.4, Page number 94"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "N_1 = 450.0     #Number of turns in the primary side\n",
      "N_2 = 45.0      #Number of turns in the secondary side\n",
      "Z_L = 3.0       #Load impedance(ohm)\n",
      "V_1 = 15.0      #Primary coil voltage of transformer(V)\n",
      "\n",
      "#Calculation\n",
      "#For case(i)\n",
      "a = N_1/N_2       #Turns ratio\n",
      "#For case(ii)\n",
      "Z_1 = a**2*Z_L    #Load impedance referred to primary(ohm)\n",
      "#For case(iii)\n",
      "I_1 = V_1/Z_1     #Primary current(A)\n",
      "\n",
      "#Result\n",
      "print('(i)   Turns ratio , a = %.f ' %a)\n",
      "print('(ii)  Load impedance referred to primary , Z_1 = %.f ohm' %Z_1)\n",
      "print('(iii) Primary current , I_1 = %.2f A' %I_1)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i)   Turns ratio , a = 10 \n",
        "(ii)  Load impedance referred to primary , Z_1 = 300 ohm\n",
        "(iii) Primary current , I_1 = 0.05 A\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.5, Page number 96-97"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "V_1 = 400.0        #Primary voltage of transformer(V)\n",
      "V_2 = 100.0        #Secondary voltage of transformer(V)\n",
      "I_0 = 0.4          #No-load current(A)\n",
      "I_2 = 100.0        #Current drawn by load(A)\n",
      "cos_phi_0 = 0.3    #Power factor lagging from the supply\n",
      "cos_phi_2 = 0.6    #Power factor lagging from the secondary\n",
      "\n",
      "#Calculation\n",
      "phi_0 = math.acos(cos_phi_0)    #Power factor angle(radians)\n",
      "phi_0_deg = phi_0*180/math.pi   #Power factor angle(degree)\n",
      "phi_2 = math.acos(cos_phi_2)    #Power factor angle(radians)\n",
      "phi_2_deg = phi_2*180/math.pi   #Power factor angle(degree)\n",
      "phi_1 = phi_0-phi_2             #Angle(radians)\n",
      "phi_1_deg = phi_1*180/math.pi   #Angle(degree)\n",
      "a = V_1/V_2                     #Turns ratio\n",
      "I_2_ = I_2/a                    #Secondary current equivalent to the primary(A) \n",
      "I_1 = ((I_2_**2)+(I_0**2)+(2*I_2_*I_0*math.cos(phi_1)))**0.5   #Primary current(A)\n",
      "\n",
      "#Result\n",
      "print('Primary current , I_1 = %.1f A' %I_1)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Primary current , I_1 = 25.4 A\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.6, Page number 101"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "V_1 = 2000.0    #Primary voltage of transformer(V)\n",
      "V_2 = 400.0     #Secondary voltage of transformer(V)\n",
      "kVA = 200.0     #Rating of transformer(kVA)\n",
      "R_1 = 3.0       #Primary resistance(ohm)\n",
      "X_1 = 12.0      #Primary reactance(ohm)\n",
      "R_2 = 0.3       #Secondary resistance(ohm)\n",
      "X_2 = 0.1       #Secondary reactance(ohm)\n",
      "\n",
      "#Calculation\n",
      "a = V_1/V_2                         #Turns ratio\n",
      "R_01 = R_1+(a**2*R_2)               #Total resistance referred to primary(ohm)\n",
      "X_01 = X_1+(a**2*X_2)               #Total reactance referred to primary(ohm)\n",
      "Z_01 = ((R_01**2)+(X_01**2))**0.5   #Equivalent impedance referred to primary(ohm)\n",
      "R_02 = R_2+(R_1/a**2)               #Total resistance referred to secondary side(ohm)\n",
      "X_02 = X_2+(X_1/a**2)               #Total reactance referred to secondary side(ohm)\n",
      "Z_02 = ((R_02**2)+(X_02**2))**0.5   #Equivalent impedance referred to secondary side(ohm)\n",
      "\n",
      "#Result\n",
      "print('Equivalent impedance referred to primary , Z_01 = %.1f ohm' %Z_01)\n",
      "print('Equivalent impedance referred to secondary , Z_02 = %.2f ohm' %Z_02)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Equivalent impedance referred to primary , Z_01 = 17.9 ohm\n",
        "Equivalent impedance referred to secondary , Z_02 = 0.72 ohm\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.7, Page number 103-104"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "V_1 = 200.0           #Primary voltage(V)\n",
      "V_2 = 400.0           #Secondary voltage(V)\n",
      "R_1 = 0.3             #Primary resistance(ohm)\n",
      "X_1 = 0.6             #Primary reactance(ohm)\n",
      "R_2 = 0.8             #Secondary resistance(ohm)\n",
      "X_2 = 1.6             #Secondary reactance(ohm)\n",
      "I_2 = 10.0            #Secondary supply current(A)\n",
      "cos_phi_2 = 0.8       #Power factor lagging\n",
      "\n",
      "#Calculation\n",
      "a = V_1/V_2               #Turns ratio\n",
      "R_02 = R_2+(R_1/a**2)     #Total resistance referred to secondary(ohm)\n",
      "X_02 = X_2+(X_1/a**2)     #Total reactance referred to primary(ohm)\n",
      "sin_phi_2 = math.sin(math.acos(cos_phi_2))\n",
      "E_2 = complex((V_2*cos_phi_2+I_2*R_02),(V_2*sin_phi_2+I_2*X_02))  #No-load voltage(V)\n",
      "V_reg = (abs(E_2)-V_2)/V_2*100                                    #Voltage regulation(percent)\n",
      "\n",
      "#Result\n",
      "print('Voltage regulation = %.f percent' %V_reg)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Voltage regulation = 10 percent\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.8, Page number 105-106"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "P_i = 1.0     #Iron loss of transformer(kW)\n",
      "P_cu = 2.0    #Full load copper loss of transformer(kW)\n",
      "kVA = 200.0   #Rating of transformer(kVA)\n",
      "pf_1 = 1.0    #Power factor\n",
      "pf_2 = 0.95   #Power factor\n",
      "\n",
      "#Calculation\n",
      "P_cu1 = (3.0/4)**2*P_cu    #Copper loss at 3/4 full load(kW)\n",
      "P_cu2 = (1.0/2)**2*P_cu    #Copper loss at 1/2 full load(kW)\n",
      "P_01 = (3.0/4)*kVA*pf_1    #Output power at 3/4 full load and unity pf(kW)\n",
      "P_in1 = P_01+P_i+P_cu1     #Input power at 3/4 full load and unity pf(kW)\n",
      "n_1 = (P_01/P_in1)*100     #Efficiency at 3/4 full load and unity pf(percent)\n",
      "P_02 = (1.0/2)*kVA*pf_2    #Output power at 1/2 full load and 0.95 pf(kW)\n",
      "P_in2 = P_02+P_i+P_cu2     #Input power at 1/2 full load and 0.95 pf(kW)\n",
      "n_2 = (P_02/P_in2)*100     #Efficiency at 1/2 full load and 0.95 pf(percent)\n",
      "\n",
      "#Result\n",
      "print('Efficiency at 3/4 full load and unity power factor , \u03b7_1 = %.2f percent' %n_1)\n",
      "print('Efficiency at 1/2 full load and 0.95 power factor , \u03b7_2 = %.2f percent' %n_2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Efficiency at 3/4 full load and unity power factor , \u03b7_1 = 98.60 percent\n",
        "Efficiency at 1/2 full load and 0.95 power factor , \u03b7_2 = 98.45 percent\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.9, Page number 108"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "P_i = 350.0      #Iron loss of transformer(W)\n",
      "P_cu = 650.0     #Full load copper loss of transformer(W)\n",
      "kVA = 30.0       #Rating of transformer(kVA)\n",
      "pf = 0.6         #Power factor\n",
      "\n",
      "#Calculation\n",
      "#For case(i)\n",
      "P_tloss = (P_i+P_cu)*10**-3      #Total full load loss(kW)\n",
      "P_out = kVA*pf                   #Output power at full load(kW)\n",
      "P_in = P_out+P_tloss             #Input power at full load(kW)\n",
      "n_1 = (P_out/P_in)*100           #Efficiency at full load(percent)\n",
      "#For case(ii)\n",
      "kVA_out = kVA*(P_i/P_cu)**0.5    #Output kVA corresponding to maximum efficiency(kVA) \n",
      "P_01 = kVA_out*pf                #Output power(kW)\n",
      "#For case(iii)\n",
      "P_tloss1 = 2*P_i*10**-3          #Total loss(kW)\n",
      "P_in1 = P_01+P_tloss1            #Input power(kW)\n",
      "n_2 = (P_01/P_in1)*100           #Efficiency(percent)\n",
      "\n",
      "#Result\n",
      "print('(i)   Full load efficiency , \u03b7 = %.2f percent' %n_1)\n",
      "print('(ii)  Output kVA corresponding to maximum efficiency = %.1f kVA' %kVA_out)\n",
      "print('(iii) Maximum efficiency , \u03b7 = %.2f percent' %n_2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i)   Full load efficiency , \u03b7 = 94.74 percent\n",
        "(ii)  Output kVA corresponding to maximum efficiency = 22.0 kVA\n",
        "(iii) Maximum efficiency , \u03b7 = 94.97 percent\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.10, Page number 109-110"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "kVA = 12.0        #Rating of transformer(kVA)\n",
      "n = 0.97          #Maximum efficiency at unity pf\n",
      "pf = 1.0          #Power factor\n",
      "t_1 = 8.0         #Time(hours)\n",
      "P_1 = 10.0        #Load(kW)\n",
      "pf_1 = 0.8        #Lagging power factor\n",
      "t_2 = 10.0        #Time(hours)\n",
      "P_2 = 15.0        #Load(kW)\n",
      "pf_2 = 0.90       #Leading power factor\n",
      "t_3 = 6.0         #Time at no-load(hours)\n",
      "P_3 = 0           #Load(kW)\n",
      "\n",
      "#Calculation\n",
      "P_01 = kVA*pf                         #Output power at full load and unity pf(kW)\n",
      "P_in1 = P_01/n                        #Input power at full load(kW)\n",
      "P_tloss = P_in1-P_01                  #Total loss(kW)\n",
      "P_cu = P_tloss/2                      #Copper loss at 12 kVA(kW)\n",
      "P_024 = P_1*t_1+P_2*t_2+P_3*t_3       #All-day output power(kWh)\n",
      "P_i24 = 24*P_cu                       #Iron loss for 24 hours(kWh)\n",
      "P_cu24 = P_cu*t_1*((P_1/pf_1)/kVA)**2+P_cu*t_2*((P_2/pf_2)/kVA)**2   #Copper loss for 24 hours(kW)\n",
      "P_in24 = P_024+P_i24+P_cu24           #All day input power(kWh)\n",
      "n_allday = (P_024/P_in24)*100         #All day efficiency(percent)\n",
      "\n",
      "#Result\n",
      "print('All-day efficiency , \u03b7_allday = %.1f percent' %n_allday)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "All-day efficiency , \u03b7_allday = 96.0 percent\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.11, Page number 111"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "V_1 = 200.0       #Voltage(V)\n",
      "f = 50.0          #Frequency(Hz)\n",
      "I_0 = 0.6         #Current(A)\n",
      "P_0 = 80.0        #Power(W)\n",
      "\n",
      "#Calculation\n",
      "cos_phi_0 = P_0/(V_1*I_0)                    #Power factor\n",
      "sin_phi_0 = math.sin(math.acos(cos_phi_0))\n",
      "I_w = I_0*cos_phi_0                          #Working component of no-load current(A)\n",
      "I_m = I_0*sin_phi_0                          #Magnetizing component of no-load current(A)\n",
      "R_0 = V_1/I_w                                #No-load circuit resistance(ohm)\n",
      "X_0 = V_1/I_m                                #No-load circuit reactance(ohm)\n",
      "\n",
      "#Result\n",
      "print('No-load circuit resistance , R_0 = %.1f ohm' %R_0)\n",
      "print('No-load circuit reactance , X_0 = %.1f ohm' %X_0)\n",
      "print('\\nNOTE : Changes in obtained answer from that of textbook is due to more precision')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "No-load circuit resistance , R_0 = 500.0 ohm\n",
        "No-load circuit reactance , X_0 = 447.2 ohm\n",
        "\n",
        "NOTE : Changes in obtained answer from that of textbook is due to more precision\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.12, Page number 112-113"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "kVA = 25.0        #Rating of transformer(kVA)\n",
      "V1 = 2200.0       #Voltage at low-voltage primary side(V)\n",
      "V2 = 220.0        #Voltage at low-voltage secondary side(V)\n",
      "V_1 = 40.0        #Voltage at h.v side(V)\n",
      "I_1 = 5.0         #Current at high voltage side(A)\n",
      "P = 150.0         #Power at high voltage side(W)\n",
      "\n",
      "#Calculation\n",
      "#For case(i)\n",
      "Z_01 = V_1/I_1                #Equivalent impedance referred to primary(ohm)\n",
      "R_01 = P/I_1**2               #Equivalent resistance referred to primary(ohm)\n",
      "phi = math.acos(R_01/Z_01)    #Power factor angle(radians)\n",
      "phi_deg = phi*180/math.pi     #Power factor angle(degree)\n",
      "X_01 = Z_01*math.sin(phi)     #Equivalent reactance referred to primary(ohm)\n",
      "#For case(ii)\n",
      "a = V1/V2                     #Turns ratio\n",
      "Z_02 = Z_01/a**2              #Equivalent impedance referred to secondary(ohm)\n",
      "R_02 = R_01/a**2              #Equivalent resistance referred to secondary(ohm)\n",
      "X_02 = X_01/a**2              #Equivalent reactance referred to secondary(ohm)\n",
      "#For case(iii)\n",
      "I_2 = kVA*10**3/V2            #Secondary side current(A)\n",
      "E_2 = V2+I_2*Z_02             #Secondary induced voltage(V)\n",
      "VR = (E_2-V2)/V2*100          #Voltage regulation(percent)\n",
      "\n",
      "#Result\n",
      "print('Case(i)')\n",
      "print(' Equivalent resistance referred to primary , R_01 = %.1f ohm' %R_01)\n",
      "print(' Equivalent reactance referred to primary , X_01 = %.1f ohm' %X_01)\n",
      "print(' Equivalent impedance referred to primary , Z_01 = %.1f ohm' %Z_01)\n",
      "print('\\nCase(ii)')\n",
      "print(' Equivalent resistance referred to secondary , R_02 = %.2f ohm' %R_02)\n",
      "print(' Equivalent reactance referred to secondary , X_02 = %.3f ohm' %X_02)\n",
      "print(' Equivalent impedance referred to secondary , Z_02 = %.2f ohm' %Z_02)\n",
      "print('\\nCase(iii)')\n",
      "print(' Voltage regulation , VR = %.1f percent' %VR)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Case(i)\n",
        " Equivalent resistance referred to primary , R_01 = 6.0 ohm\n",
        " Equivalent reactance referred to primary , X_01 = 5.3 ohm\n",
        " Equivalent impedance referred to primary , Z_01 = 8.0 ohm\n",
        "\n",
        "Case(ii)\n",
        " Equivalent resistance referred to secondary , R_02 = 0.06 ohm\n",
        " Equivalent reactance referred to secondary , X_02 = 0.053 ohm\n",
        " Equivalent impedance referred to secondary , Z_02 = 0.08 ohm\n",
        "\n",
        "Case(iii)\n",
        " Voltage regulation , VR = 4.1 percent\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.13, Page number 114-115"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "kVA = 120.0              #Rating of autotransformer(kVA)\n",
      "V1 = 220.0               #Volteage at upper part of coil(V)\n",
      "V2 = 2200.0              #Volteage at lower part of coil(V)\n",
      "\n",
      "#Calculation\n",
      "I_pq = kVA*10**3/V1      #Current of upper winding(A)\n",
      "I_qr = kVA*10**3/V2      #Current of lower winding(A)\n",
      "I_1 = I_pq+I_qr          #Current in primary side(A)\n",
      "V_2 = V1+V2              #Voltage across the secondary side(V)\n",
      "kVA_1 = I_1*V2/1000      #Rating of autotransformer(kVA)\n",
      "kVA_2 = I_pq*V_2/1000    #Rating of autotransformer(kVA)\n",
      " \n",
      "\n",
      "#Result\n",
      "print('kVA ratings of the autotransformer')\n",
      "print('\\t kVA_1 = %.f kVA' %kVA_1)\n",
      "print('\\t kVA_2 = %.f kVA' %kVA_2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "kVA ratings of the autotransformer\n",
        "\t kVA_1 = 1320 kVA\n",
        "\t kVA_2 = 1320 kVA\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.14, Page number 119"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import cmath\n",
      "\n",
      "#Variable declaration\n",
      "kVA_1 = 100.0      #Rating of transformer(kVA)\n",
      "kVA_2 = 200.0      #Rating of transformer(kVA)\n",
      "E_1 = 500.0        #Secondary induced voltage in 100 kVA transformer(V)\n",
      "E_2 = 450.0        #Secondary induced voltage in 200 kVA transformer(V)\n",
      "Z_1 = 0.05         #Impedance of 100 kVA transformer\n",
      "Z_2 = 0.08         #Impedance of 200 kVA transformer\n",
      "\n",
      "#Calculation\n",
      "Z1 = Z_1*E_1/(kVA_1*10**3/E_1)   #Actual impedance of first transformer(ohm)\n",
      "Z2 = Z_2*E_2/(kVA_1*10**3/E_2)   #Actual impedance of second transformer(ohm)\n",
      "I_c = (E_1-E_2)/complex(0,Z1+Z2) #Circulating current(A)\n",
      "\n",
      "#Result\n",
      "print('Circulating current , I_c = %.2f\u2220%.f\u00b0 A' %(abs(I_c),cmath.phase(I_c)*180/math.pi))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Circulating current , I_c = 174.22\u2220-90\u00b0 A\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.15, Page number 125"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "V_L1 = 11.0     #Supply voltage(kV)\n",
      "I_P1 = 6.0      #Current drawn by transformer(A)\n",
      "a = 11.0        #Turns ratio\n",
      "\n",
      "#Calculation\n",
      "#For delta-wye connections\n",
      "V_dP1 = V_L1                  #Phase voltage at primary side(kV)\n",
      "V_dP2 = V_dP1*10**3/a         #Phase voltage at secondary side(V)\n",
      "V_dL2 = 3**0.5*V_dP2          #Line voltage at secondary side(V)\n",
      "I_dP1 = a/3**0.5              #Phase current in the primary(A)\n",
      "I_dL2 = a*I_dP1               #Line current in secondary(A)\n",
      "#For Wye-delta connection \n",
      "V_wP1 = V_L1*10**3/3**0.5     #Phase voltage at primary side(V)\n",
      "V_wP2 = V_wP1/a               #Phase voltage at secondary(V)\n",
      "V_wL2 = V_wP2                 #Line voltage at secondary(V)\n",
      "I_wP2 = a*I_P1                #Phase current in secondary(A)\n",
      "I_wL2 = 3**0.5*I_wP2          #Line current in secondary(A)\n",
      "\n",
      "#Result\n",
      "print('For delta-wye connection')\n",
      "print(' (i)  Line voltage at secondary side , V_L2 = %.f V' %V_dL2)\n",
      "print(' (ii) Line current in the secondary , I_L2 = %.2f A' %I_dL2)\n",
      "print('\\nFor wye-delta connection')\n",
      "print(' (i)  Line voltage at secondary side , V_L2 = %.2f V' %V_wL2)\n",
      "print(' (ii) Line current in the secondary , I_L2 = %.2f A' %I_wL2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "For delta-wye connection\n",
        " (i)  Line voltage at secondary side , V_L2 = 1732 V\n",
        " (ii) Line current in the secondary , I_L2 = 69.86 A\n",
        "\n",
        "For wye-delta connection\n",
        " (i)  Line voltage at secondary side , V_L2 = 577.35 V\n",
        " (ii) Line current in the secondary , I_L2 = 114.32 A\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.16, Page number 132"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import cmath\n",
      "\n",
      "#Variable declaration\n",
      "V_b = 220.0           #Voltage(V)\n",
      "f = 50.0              #Frequency(Hz)\n",
      "S_b = 600.0           #Base value of rating(VA)\n",
      "R = 3.0               #Resistance(ohm)\n",
      "X_L = 5.0             #Inductance(ohm)\n",
      "Z = complex(R,X_L)    #Impedance(ohm)\n",
      "\n",
      "#Calculation\n",
      "I_b = S_b/V_b                #Base value of current(A)\n",
      "Z_b = V_b**2/S_b             #Base impedance(ohm)\n",
      "R_pu = R/Z_b                 #Per unit value of resistance\n",
      "X_Lpu = X_L/Z_b              #Per unit value of inductance\n",
      "Z_pu = complex(R_pu,X_Lpu)   #Per unit of value of impedance\n",
      "Z_pu_alt = abs(Z)/Z_b        #Per unit of value of impedance-alternative method\n",
      "\n",
      "#Result\n",
      "print('Per unit value of resistance , R_pu = %.3f ' %R_pu)\n",
      "print('Per unit value of inductance , X_Lpu = %.3f ' %X_Lpu)\n",
      "print('Per unit of value of impedance , Z_pu = %.3f\u2220%.2f\u00b0 ' %(abs(Z_pu),cmath.phase(Z_pu)*180/math.pi))\n",
      "print('Per unit of value of impedance by alternative method , Z_pu = %.3f ' %Z_pu_alt)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Per unit value of resistance , R_pu = 0.037 \n",
        "Per unit value of inductance , X_Lpu = 0.062 \n",
        "Per unit of value of impedance , Z_pu = 0.072\u222059.04\u00b0 \n",
        "Per unit of value of impedance by alternative method , Z_pu = 0.072 \n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.17, Page number 132-134"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import cmath\n",
      "\n",
      "#Variable declaration\n",
      "MVA_T1 = 100.0       #Rating of transformer T1(MVA)\n",
      "V_T1_hv = 220.0      #Voltage of h.v side of T1(kV)\n",
      "V_T1_lv = 132.0      #Voltage of l.v side of T1(kV)\n",
      "X_T1 = 0.2           #Impedance of T1(pu)\n",
      "MVA_T2 = 50.0        #Rating of transformer T2(MVA)\n",
      "V_T2_hv = 132.0      #Voltage of h.v side of T2(kV)\n",
      "V_T2_lv = 66.0       #Voltage of l.v side of T2(kV)\n",
      "X_T2 = 0.05          #Impedance of T2(pu)\n",
      "X_L = 4.0            #Line impedance(ohm)\n",
      "P = 50.0             #Power absorbed(MW)\n",
      "pf = 0.6             #Lagging power factor\n",
      "\n",
      "#Calculation\n",
      "S_b = MVA_T1                                  #Base apparent power(MW)\n",
      "V_b = V_T1_hv                                 #Base voltage(kV)\n",
      "a = V_T1_hv/V_T1_lv                           #Turns ratio for first transformer\n",
      "V_bline = V_T1_hv/a                           #Base voltage of line(kV)\n",
      "Z_bline = V_bline**2/S_b                      #Base impedance of line(ohm)\n",
      "X_puline = X_L/Z_bline                        #Per unit reactance of line\n",
      "X_pu_T1 = X_T1*(V_T1_hv/V_b)**2*(S_b/MVA_T1)  #Per unit reactance of first transformer\n",
      "V_bload = V_T2_hv/(V_T2_hv/V_T2_lv)           #Load side base voltage(kV)\n",
      "X_pu_load = X_T2*(V_T2_lv/V_bload)**2*(S_b/MVA_T2) #Per unit reactance of second transformer\n",
      "I_b = S_b*1000/(3**0.5*V_bload)               #Base current at the load(A)\n",
      "I_L = MVA_T2*1000/(3**0.5*V_T2_lv*pf)         #Actual current in load(A)\n",
      "I_Lpu = I_L/I_b                               #Per unit value of load current(pu)\n",
      "V_L = V_T2_lv/V_bload                         #Per unit value of voltage at the load terminal(pu)\n",
      "V_gb =  I_Lpu*cmath.exp(1j*math.acos(pf))*complex(0,X_T1+X_puline+X_pu_load)+V_L #Per unit value of grid to bus voltage(pu)\n",
      "V_gba = V_gb*V_T1_hv                          #Actual value of grid to bus voltage(kV)\n",
      "\n",
      "#Result\n",
      "print('Grid to bus voltage , V_gb = %.f\u2220%.2f\u00b0 kV' %(abs(V_gba),cmath.phase(V_gba)*180/math.pi))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Grid to bus voltage , V_gb = 176\u222011.63\u00b0 kV\n"
       ]
      }
     ],
     "prompt_number": 1
    }
   ],
   "metadata": {}
  }
 ]
}