{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 9: Power Conversation and Motor Drive Operations"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 9.1,Page 457"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "peak voltage is 37.6 V\n",
      "load voltage is 35.7 V\n",
      "ripple voltage is 3.96 V\n",
      "approx. load voltage is 35.62 V\n"
     ]
    }
   ],
   "source": [
    "#finding peak,load,ripple voltages\n",
    "\n",
    "#initialisation of variable\n",
    "from math import pi,tan,sqrt,sin,cos,acos,atan\n",
    "V=28.0;#V\n",
    "C=4700.0;#microF\n",
    "R=16.0;#load\n",
    "f=120.0;#hertz\n",
    "\n",
    "#calculation\n",
    "Vp=V*2**.5-2;\n",
    "Vd=0.95*Vp;\n",
    "Id=Vd/R;\n",
    "v=Id/f/C;\n",
    "#approximation\n",
    "Vd1=Vp-v*1e6/2;\n",
    "\n",
    "#result\n",
    "print \"peak voltage is\",round(Vp,2), \"V\"\n",
    "print \"load voltage is\",round(Vd,1), \"V\"\n",
    "print \"ripple voltage is\",round(v*1e6,2), \"V\"\n",
    "print \"approx. load voltage is\",round(Vd1,2), \"V\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 9.2,Page 459"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Zth is 1.0 + 1.0 in ohm\n",
      "inductor is 2.65 mH\n"
     ]
    }
   ],
   "source": [
    "#finding inductor,Zth\n",
    "\n",
    "#initialisation of variable\n",
    "from math import pi,tan,sqrt,sin,cos,acos,atan\n",
    "V1=120.0;#pri voltage\n",
    "V2=28.0;#sec voltage\n",
    "I=2.0;#pri current\n",
    "f=60.0;#Hz\n",
    "Vth=28.8;#open voltage\n",
    "V3=12.1;#pri-short voltage\n",
    "Is=2.0;#short current at 45 degree\n",
    "\n",
    "#calculation\n",
    "Zi=(V2*V3)/V1/Is*cos(45*pi/180);\n",
    "Zj=(V2*V3)/V1/Is*sin(45*pi/180);\n",
    "L=Zi/(2*pi*f);\n",
    "\n",
    "#result\n",
    "print'Zth is',round(Zi),'+',round(Zj),'in ohm'\n",
    "print \"inductor is\",round(L*1000,2), \"mH\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 9.4,Page 463"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "power factor is 0.32\n"
     ]
    }
   ],
   "source": [
    "#finding power factor\n",
    "\n",
    "#initialisation of variable\n",
    "from math import pi,tan,sqrt,sin,cos,acos,atan\n",
    "I1=1.8;#current\n",
    "R=16.0;#resistance\n",
    "I2=5.7;#A\n",
    "V=28.8;#Voltage\n",
    "\n",
    "#calculation\n",
    "P=I1**2*R;\n",
    "S=I2*V;\n",
    "Pf=P/S;\n",
    "\n",
    "#result\n",
    "print \"power factor is\",round(Pf,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 9.5, Page 468"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "aparrent power is 8.14 kVA\n",
      "dissipated power is 7.84 kW\n",
      "power factor is 0.96\n"
     ]
    }
   ],
   "source": [
    "#finding power factor\n",
    "\n",
    "#initialisation of variable\n",
    "from math import pi,tan,sqrt,sin,cos,acos,atan\n",
    "I=22.6;#current\n",
    "I2=28.00;\n",
    "V=120.0;#Voltage\n",
    "V2=280.0;\n",
    "\n",
    "#calculation\n",
    "Pt=3*I*V;\n",
    "Pl=I2*V2;\n",
    "Pf=Pl/Pt;\n",
    "\n",
    "#result\n",
    "print \"aparrent power is\",round(Pt/1000,2),\"kVA\"\n",
    "print \"dissipated power is\",round(Pl/1000,2),\"kW\"\n",
    "print \"power factor is\",round(Pl/Pt,2)\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 9.6,Page 474"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ratio is 0.72\n",
      "firing angle is 58 degrees\n",
      "dc voltage is 148.85 V\n",
      "time delay is 2.69 ms\n"
     ]
    }
   ],
   "source": [
    "#finding firing angle, time delay,Vd\n",
    "\n",
    "#initialisation of variable\n",
    "from math import pi,tan,sqrt,sin,cos,acos,atan\n",
    "V=208.0;#voltage\n",
    "R=100.0;#load\n",
    "Vd=150.0;#V\n",
    "\n",
    "#calculation\n",
    "r=Vd/V;\n",
    "a=58;#degree\n",
    "Vd=3*2**.5*208*(cos(pi/3+a*pi/180)-cos(2*pi/3+a*pi/180))/pi;\n",
    "t=a*16.7/360;\n",
    "\n",
    "#result\n",
    "print \"ratio is\",round(r,2)\n",
    "print('firing angle is 58 degrees');\n",
    "print \"dc voltage is\",round(Vd,2), \"V\"\n",
    "print \"time delay is\",round(t,2), \"ms\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 9.7,Page 480"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "max. current is 41.67 A\n",
      "dissipated power is 8.68 W\n"
     ]
    }
   ],
   "source": [
    "#finding maximum current and power dissipated\n",
    "\n",
    "#initialisation of variable\n",
    "from math import pi,tan,sqrt,sin,cos,acos,atan\n",
    "P=150.0;#power\n",
    "V=8.0;#voltage\n",
    "R=.01;#resistance\n",
    "D=.5;#duty cycle\n",
    "\n",
    "#calculation\n",
    "I=P/.9/D/V;\n",
    "Ir=I*D**.5;\n",
    "Pq=Ir**2*R;\n",
    "\n",
    "#result\n",
    "print \"max. current is\",round(I,2), \"A\"\n",
    "print \"dissipated power is\",round(Pq,2),\"W\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 9.8,Page 489"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "pwm fundamental frequency is 30.72 kHz\n",
      "output voltage is 9.46 V\n"
     ]
    }
   ],
   "source": [
    "#finding fundamental frequency and output voltage\n",
    "\n",
    "#initialisation of variable\n",
    "from math import pi,tan,sqrt,sin,cos,acos,atan\n",
    "f1=60.0;#frequency\n",
    "V=150.0;#voltage\n",
    "f2=31.0;#kHz\n",
    "\n",
    "#calculation\n",
    "f3=f1*4;\n",
    "Vo=V*10**(-4.2);\n",
    "\n",
    "#result\n",
    "print \"pwm fundamental frequency is\",round(f3*2**7/1000,2), \"kHz\"\n",
    "print \"output voltage is\",round(Vo*1000,2), \"V\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 9.9,Page 491"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "average voltage is 127.32 V\n",
      "\n",
      "Va-d @ 200Vin=4.2V\n",
      "\n",
      "\n",
      "pick R1=47kohm\n",
      "current through dividers is 2.62 mA\n",
      "R2 is 1.6 kohm\n",
      "capacitor is 27.01 microF\n"
     ]
    }
   ],
   "source": [
    "#finding resistances,capacitor,average voltage\n",
    "\n",
    "#initialisation of variable\n",
    "from math import pi,tan,sqrt,sin,cos,acos,atan\n",
    "V=120.0;#load voltage\n",
    "f=60.0;#Hz\n",
    "Vp=200.0;#V\n",
    "Vd=5.0;#V\n",
    "\n",
    "\n",
    "#calculation\n",
    "Vdc=2*Vp/pi;\n",
    "Va=4.2;\n",
    "R1=47.0;\n",
    "I=(Vdc-Va)/R1;\n",
    "R2=Va/I;\n",
    "K=1.0/(1/R1+1/R2)# R1 \\\\ R2\n",
    "C=1.0/2/pi/3.8/K;\n",
    "\n",
    "#result\n",
    "print \"average voltage is\",round(Vdc,2), \"V\"\n",
    "print('\\nVa-d @ 200Vin=4.2V')\n",
    "print('\\n\\npick R1=47kohm')\n",
    "print \"current through dividers is\",round(I,2), \"mA\"\n",
    "print \"R2 is\",round(R2,2), \"kohm\"\n",
    "print \"capacitor is\",round(C*1000,2), \"microF\""
   ]
  }
 ],
 "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.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}