{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 09 : AC Voltage Controllers"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.1, Page No 560"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "V_s=230.0\n",
      "V_m=math.sqrt(2)*V_s\n",
      "a=45.0\n",
      "\n",
      "#Calculations\n",
      "V_or=(V_m/2)*math.sqrt(1/math.pi*((2*math.pi-a*math.pi/180)+math.sin(math.radians(2*a))/2))    \n",
      "R=20\n",
      "I_or=V_or/R\n",
      "P_o=I_or**2*R    \n",
      "I_s=I_or\n",
      "VA=V_s*I_s\n",
      "pf=P_o/VA    \n",
      "V_o=math.sqrt(2)*V_s/(2*math.pi)*(math.cos(math.radians(a))-1)\n",
      "I_ON=V_o/R  \n",
      "\n",
      "#Results\n",
      "print(\"rms value of o/p voltage=%.3f V\" %V_or)\n",
      "print(\"load power=%.1f W\" %P_o)\n",
      "print(\"i/p pf=%.4f\" %pf)\n",
      "print(\"avg i/p current=%.4f A\" %I_ON)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "rms value of o/p voltage=224.716 V\n",
        "load power=2524.9 W\n",
        "i/p pf=0.9770\n",
        "avg i/p current=-0.7581 A\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.2, Page No 560"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "V_s=230.0\n",
      "V_m=math.sqrt(2)*V_s\n",
      "a=45.0\n",
      "\n",
      "#Calculations\n",
      "V_or=(V_s)*math.sqrt(1/math.pi*((math.pi-a*math.pi/180)+math.sin(math.radians(2*a))/2))    \n",
      "R=20\n",
      "I_or=V_or/R\n",
      "P_o=I_or**2*R    \n",
      "I_s=I_or\n",
      "VA=V_s*I_s\n",
      "pf=P_o/VA    \n",
      "I_TA=math.sqrt(2)*V_s/(2*math.pi*R)*(math.cos(math.radians(a))+1)   \n",
      "I_Tr=math.sqrt(2)*V_s/(2*R)*math.sqrt(1/math.pi*((math.pi-a*math.pi/180)+math.sin(math.radians(2*a))/2)) \n",
      "\n",
      "#Results\n",
      "print(\"rms value of o/p voltage=%.3f V\" %V_or)\n",
      "print(\"load power=%.2f W\" %P_o)\n",
      "print(\"i/p pf=%.2f\" %pf)\n",
      "print(\"avg thyristor current=%.2f A\" %I_TA)   \n",
      "print(\"rms value of thyristor current=%.2f A\" %I_Tr)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "rms value of o/p voltage=219.304 V\n",
        "load power=2404.71 W\n",
        "i/p pf=0.95\n",
        "avg thyristor current=4.42 A\n",
        "rms value of thyristor current=7.75 A\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.3 Page No 564"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "V_s=230.0\n",
      "n=6.0 #on cycles\n",
      "m=4.0 #off cycles\n",
      "\n",
      "#Calculations\n",
      "k=n/(n+m)\n",
      "V_or=V_s*math.sqrt(k)    \n",
      "pf=math.sqrt(k)    \n",
      "R=15\n",
      "I_m=V_s*math.sqrt(2)/R\n",
      "I_TA=k*I_m/math.pi\n",
      "I_TR=I_m*math.sqrt(k)/2  \n",
      "   \n",
      "#Results\n",
      "print(\"rms value of o/ voltage=%.2f V\" %V_or)\n",
      "print(\"i/p pf=%.2f\" %pf)\n",
      "print(\"avg thyristor current=%.2f A\" %I_TA)  \n",
      "print(\"rms value of thyristor current=%.2f A\" %I_TR)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "rms value of o/ voltage=178.16 V\n",
        "i/p pf=0.77\n",
        "avg thyristor current=4.14 A\n",
        "rms value of thyristor current=8.40 A\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.4, Page No 569"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "V_s=230.0\n",
      "V_m=math.sqrt(2)*V_s\n",
      "R=3.0\n",
      "\n",
      "#Calculations\n",
      "I_TAM1=2*V_m/(2*math.pi*R)  \n",
      "I_TRM2=V_m/(2*R)    \n",
      "f=50\n",
      "w=2*math.pi*f\n",
      "t_c=math.pi/w    \n",
      " \n",
      "#Results\n",
      "print(\"max value of avg thyristor current=%.3f A\" %I_TAM1)\n",
      "print(\"max value of avg thyristor current=%.3f A\" %I_TRM2)\n",
      "print(\"ckt turn off time=%.0f ms\" %(t_c*1000))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "max value of avg thyristor current=34.512 A\n",
        "max value of avg thyristor current=54.212 A\n",
        "ckt turn off time=10 ms\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.5 Page No 575"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "R=3.0\n",
      "X_L=4.0\n",
      "\n",
      "#Calculations\n",
      "phi=math.degrees(math.atan(X_L/R))    \n",
      "V_s=230\n",
      "Z=math.sqrt(R**2+X_L**2)\n",
      "I_or=V_s/Z    \n",
      "P=I_or**2*R    \n",
      "I_s=I_or\n",
      "pf=P/(V_s*I_s)    \n",
      "I_TAM=math.sqrt(2)*V_s/(math.pi*Z)    \n",
      "I_Tm=math.sqrt(2)*V_s/(2*Z)    \n",
      "f=50\n",
      "w=2*math.pi*f\n",
      "di=math.sqrt(2)*V_s*w/Z    \n",
      "\n",
      "#Results\n",
      "print(\"min firing angle=%.2f deg\" %phi)\n",
      "print(\"\\nmax firing angle=%.0f deg\" %180)\n",
      "print(\"i/p pf=%.1f\" %pf)\n",
      "print(\"max value of rms load current=%.0f A\" %I_or)\n",
      "print(\"max power=%.0f W\" %P)\n",
      "print(\"max value of avg thyristor current=%.3f A\" %I_TAM)\n",
      "print(\"max value of rms thyristor current=%.3f A\" %I_Tm)\n",
      "print(\"di/dt=%.0f A/s\" %di)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "min firing angle=53.13 deg\n",
        "\n",
        "max firing angle=180 deg\n",
        "i/p pf=0.6\n",
        "max value of rms load current=46 A\n",
        "max power=6348 W\n",
        "max value of avg thyristor current=20.707 A\n",
        "max value of rms thyristor current=32.527 A\n",
        "di/dt=20437 A/s\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.6 Page No 576"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "V=230.0\n",
      "R=3.0 #ohm\n",
      "X_L=5.0 #ohm\n",
      "a=120.0 #firing angle delay\n",
      "\n",
      "#Calculations\n",
      "phi=math.degrees(math.atan(X_L/R))\n",
      "b=0\n",
      "i=1\n",
      "while (i>0) :\n",
      "    LHS=math.sin(math.radians(b-a))\n",
      "    RHS=math.sin(math.radians(a-phi))*math.exp(-(R/X_L)*(b-a)*math.pi/180)\n",
      "    if math.fabs(LHS-RHS)<= 0.01 :\n",
      "        B=b\n",
      "        i=2\n",
      "        break\n",
      "   \n",
      "    b=b+.1   \n",
      "V_or=math.sqrt(2)*V*math.sqrt((1/(2*math.pi))*((B-a)*math.pi/180+(math.sin(math.radians(2*a))-math.sin(math.radians(2*B)))/2))\n",
      "\n",
      "\n",
      "#Results\n",
      "print(\"Extinction angle=%.1f deg\" %B) #answer in the book is wrong as formulae for RHS is wrongly employed\n",
      "print(\"rms value of output voltage=%.2f V\" %V_or) #answer do not match due to wrong B in book\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Extinction angle=156.1 deg\n",
        "rms value of output voltage=97.75 V\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9.8, Page No 581"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "V_s=230.0\n",
      "V_m=math.sqrt(2)*V_s\n",
      "a=60.0\n",
      "R=20.0\n",
      "\n",
      "#Calculations\n",
      "V_or=math.sqrt((V_m**2/(2*math.pi))*(a*math.pi/180-math.sin(math.radians(2*a))/2)+(2*V_m**2/(math.pi))*(math.pi-a*math.pi/180+math.sin(math.radians(2*a))/2))    \n",
      "I_T1r=(V_m/R)*math.sqrt(1/math.pi*((math.pi-a*math.pi/180)+math.sin(math.radians(2*a))/2))    \n",
      "I_T3r=(V_m/(2*R))*math.sqrt(1/math.pi*((a*math.pi/180)-math.sin(math.radians(2*a))/2))    \n",
      "I1=math.sqrt(2)*I_T1r\n",
      "I3=math.sqrt((math.sqrt(2)*I_T1r)**2+(math.sqrt(2)*I_T3r)**2)\n",
      "r=V_s*(I1+I3)    \n",
      "P_o=V_or**2/R\n",
      "pf=P_o/r    \n",
      "\n",
      "#Results\n",
      "print(\"rms value of o/p voltage=%.2f V\" %V_or)\n",
      "print(\"rms value of current for upper thyristors=%.2f A\" %I_T1r)\n",
      "print(\"rms value of current for lower thyristors=%.2f A\" %I_T3r)\n",
      "print(\"t/f VA rating=%.2f VA\" %r)\n",
      "print(\"i/p pf=%.2f\" %pf)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "rms value of o/p voltage=424.94 V\n",
        "rms value of current for upper thyristors=14.59 A\n",
        "rms value of current for lower thyristors=3.60 A\n",
        "t/f VA rating=9631.61 VA\n",
        "i/p pf=0.94\n"
       ]
      }
     ],
     "prompt_number": 7
    }
   ],
   "metadata": {}
  }
 ]
}