{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 4 - AC to AC Converters"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex 4.1 page 158"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " rms load voltage = 101.70 V\n",
      "\n",
      " rms load current = 20.34 A\n",
      "\n",
      " rms thyristor current = 14.38 A\n",
      "\n",
      " input power factor = 0.442 \n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "from math import sqrt,pi,sin\n",
    "R=5    #  ohm\n",
    "Vs=230    #  V\n",
    "f=50    #  Hz\n",
    "alpha = 120    #  degree\n",
    "\n",
    "Vor=Vs*sqrt(1/pi*(pi-alpha*pi/180+sin(2*alpha*pi/180)/2))    #  V\n",
    "print '\\n rms load voltage = %.2f V'%( Vor)\n",
    "Ior=Vor/R    #  A\n",
    "print '\\n rms load current = %.2f A'%( Ior)\n",
    "Irms=Ior/sqrt(2)    # A\n",
    "print '\\n rms thyristor current = %.2f A'%( Irms)\n",
    "pf=sqrt(1/pi*((pi-alpha*pi/180)+sin(2*alpha*pi/180)/2))    #  power factor\n",
    "print '\\n input power factor = %.3f '%(pf)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex 4.2 page 158"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " (a) rms output voltage = 138 V\n",
      "\n",
      " (b) Power output to load = 1904.4 W\n",
      "\n",
      " (c) Power input to regulator = 1904.4 W\n",
      "\n",
      " (d) input power factor = 0.6 \n",
      "\n",
      " (e) average scr current = 3.727 A\n",
      "\n",
      "     rms scr current = 9.758 A\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "from math import sqrt,pi,sin\n",
    "R=10    #  ohm\n",
    "Vs=230    #  V\n",
    "f=50    #  Hz\n",
    "nc=18    #  conducting cycles\n",
    "noff=32    #  off cycles\n",
    "\n",
    "k=nc/(nc+noff)    #  duty ratio\n",
    "Vor=Vs*sqrt(k)    #  V\n",
    "Po=Vor**2/R    #  W\n",
    "Pi=Po    #  W (losses are negligble)\n",
    "Ior=Vor/R    # A\n",
    "pf=Po/Vs/Ior    # W\n",
    "Im=Vs*sqrt(2)/R    # A\n",
    "Irms=Im*sqrt(k)/2    # A\n",
    "Iav=k*Im/pi    # A\n",
    "print '\\n (a) rms output voltage = %.0f V'%( Vor)\n",
    "print '\\n (b) Power output to load = %.1f W'%( Po)\n",
    "print '\\n (c) Power input to regulator = %.1f W'%( Pi)\n",
    "print '\\n (d) input power factor = %.1f '%(pf)\n",
    "print '\\n (e) average scr current = %.3f A'%( Iav)\n",
    "print '\\n     rms scr current = %.3f A'%( Irms)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex 4.3 page 159"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " rms load voltage = 162.63 V\n",
      "\n",
      " rms load current = 16.26 A\n",
      "\n",
      " power input = 2645.00 W\n",
      "\n",
      " load power factor = 0.7 \n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "from math import sqrt,pi,sin\n",
    "R=10    #  ohm\n",
    "Vs=230    #  V\n",
    "f=50    #  Hz\n",
    "alpha = 90    #  degree\n",
    "\n",
    "Vor=Vs*sqrt(1/pi*(pi-alpha*pi/180+sin(2*alpha*pi/180)/2))    #  V\n",
    "Ior=Vor/R    #  A\n",
    "P=Ior**2*R    #  W\n",
    "pf=Vor/Vs    #  power factor\n",
    "print '\\n rms load voltage = %.2f V'%( Vor)\n",
    "print '\\n rms load current = %.2f A'%( Ior)\n",
    "print '\\n power input = %.2f W'%( P)\n",
    "print '\\n load power factor = %.1f '%(pf)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex 4.4 page 160"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " rms load voltage = 219.30 V\n",
      "\n",
      " rms load current = 7.31 A\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "from math import sqrt,pi,sin\n",
    "\n",
    "R=30    #  ohm\n",
    "Vs=230    #  V\n",
    "f=50    #  Hz\n",
    "alpha = 45    #  degree\n",
    "\n",
    "Vor=Vs*sqrt(1/pi*(pi-alpha*pi/180+sin(2*alpha*pi/180)/2))    #  V\n",
    "Ior=Vor/R    #  A\n",
    "print '\\n rms load voltage = %.2f V'%( Vor)\n",
    "print '\\n rms load current = %.2f A'%( Ior)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex 4.5 page 160"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " max load voltage = 230.00 V\n",
      "\n",
      " max load current = 16.263 A\n",
      "\n",
      " range of delay angle = 0 to 45\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "from math import sqrt,pi,sin,tan\n",
    "\n",
    "R=10    #  ohm\n",
    "Vs=230    #  V\n",
    "f=50    #  Hz\n",
    "fi = 45    #  degree\n",
    "\n",
    "Vmax=Vs    #  V(max supply voltage)\n",
    "XL=R*tan(fi*pi/180)    #  ohm\n",
    "Z=XL*sqrt(2)    #  ohm\n",
    "Imax=Vs/Z    # A\n",
    "\n",
    "print '\\n max load voltage = %.2f V'%( Vmax)\n",
    "print '\\n max load current = %.3f A'%( Imax)\n",
    "print '\\n range of delay angle = %d to %d'%(0,fi)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex 4.7 page 161"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " (i) control range of firing angle = 53.13 to pi\n",
      "\n",
      " (ii) max rms load current = 46 A\n",
      "\n",
      " (iii) max power input to load = 6348 W\n",
      "\n",
      " (iv) max power factor = 0.6 \n",
      "\n",
      " (v) max rms thyristor current = 32.527 A\n",
      "\n",
      "     max average thyristor current = 20.718 A\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "from math import sqrt,pi,sin,atan\n",
    "\n",
    "R=3    #  ohm\n",
    "wL=4    # ohm\n",
    "Vs=230    #  V\n",
    "f=50    #  Hz\n",
    "\n",
    "fi=atan(wL/R)*180/pi    # degree\n",
    "print '\\n (i) control range of firing angle = %.2f to pi'%(fi)\n",
    "Imax=Vs/sqrt(R**2+wL**2)    #  A\n",
    "print '\\n (ii) max rms load current = %.f A'%( Imax)\n",
    "Pmax=Imax**2*R    # W\n",
    "print '\\n (iii) max power input to load = %.f W'%( Pmax)\n",
    "pf_max=Pmax/Vs/Imax    #  power factor\n",
    "print '\\n (iv) max power factor = %.1f '%( pf_max)\n",
    "Ithrms=Imax/sqrt(2)    #  A\n",
    "Ithav=Ithrms/1.57    #  A\n",
    "print '\\n (v) max rms thyristor current = %.3f A'%( Ithrms)\n",
    "print '\\n     max average thyristor current = %.3f A'%( Ithav)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}