{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 20: Alternating Currents and Electronics"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex20.1:pg-982"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "We have to wait for a time of t= 10.0  sec\n"
     ]
    }
   ],
   "source": [
    "  #Example 20_1\n",
    " \n",
    "  \n",
    "#To findout the time that it has to wait after turning off the set before it is safe to touch capacitor\n",
    "r=10.0**6          #Units in Ohms\n",
    "c=10.0**-5             #Units in F\n",
    "ti=r*c           #Units in Sec\n",
    "print \"We have to wait for a time of t=\",round(ti),\" sec\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex20.2:pg-983"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The RMS current when f=20 Hz is= 0.00402  Ohms\n",
      "The RMS current when f=2*10**6 Hz is= 402.12  Ohms\n"
     ]
    }
   ],
   "source": [
    "  #Example 20_2\n",
    "\n",
    "import math\n",
    "  \n",
    "#To find the rms current in the circuit \n",
    "f=20         #Units in Hz\n",
    "c=4*10.0**-7         #Units in F\n",
    "xc=1/(2.0*math.pi*f*c)           #Units in Ohms/sec\n",
    "f=2*10**6          #Units in Hz\n",
    "xc1=1/(2*math.pi*f*c)           #Units in Ohms/sec\n",
    "v=80.0           #Units in V\n",
    "i=v/xc            #Units in A\n",
    "i1=v/xc1            #Units in A\n",
    "print \"The RMS current when f=20 Hz is=\",round(i,5),\" Ohms\\nThe RMS current when f=2*10**6 Hz is=\",round(i1,2),\" Ohms\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex20.3:pg-984"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The current in the inductor when frequency=60 Hz is I= 7.07  A\n",
      "\n",
      "The current in the inductor when frequency=6*10**2 Hz is I= 0.000707  A\n"
     ]
    }
   ],
   "source": [
    "  #Example 20_3\n",
    " \n",
    "  \n",
    "#To find the current through the inductor\n",
    "f=60             #Units in Hz\n",
    "l=15.0*10**-3           #Units in H\n",
    "xl=2*math.pi*f*l           #Units in Ohms\n",
    "v=40          #Units in V\n",
    "i=v/xl           #Units in A\n",
    "print \"The current in the inductor when frequency=60 Hz is I=\",round(i,2),\" A\"\n",
    "f=6.0*10**5             #Units in Hz\n",
    "l=15.0*10**-3           #Units in H\n",
    "xl=2*math.pi*f*l           #Units in Ohms\n",
    "v=40          #Units in V\n",
    "i=v/xl           #Units in A\n",
    "print \"\\nThe current in the inductor when frequency=6*10**2 Hz is I=\",round(i,6),\" A\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex20.4:pg-984"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (<ipython-input-4-42e5d01775ba>, line 15)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  File \u001b[1;32m\"<ipython-input-4-42e5d01775ba>\"\u001b[1;36m, line \u001b[1;32m15\u001b[0m\n\u001b[1;33m    print \"The current in circuit is I=\",round( ,4),\" A\\nVolt meter readings across resistor Vr=\",round( ,1),\" V\\nReadings across capacitor is Vc=\",round( ,1),\" V\\nPower loss in circuit is=\",round( ,1),\" W\",i,vr,vc,p)\u001b[0m\n\u001b[1;37m                                                ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
     ]
    }
   ],
   "source": [
    "  #Example 20_4\n",
    " \n",
    "  \n",
    "#To find current in circuit, Voltmeter reading, reading across capacitor and power loss\n",
    "f=2000             #Units in Hz\n",
    "c=0.6*10**-6           #Units in F\n",
    "xc=1/(2*math.pi*f*c)           #Units in Ohms\n",
    "r=300          #Units in Ohms\n",
    "z=sqrt(r**2+xc**2)        #Units in Ohms\n",
    "v=80          #Units in V\n",
    "i=v/z            #Units in A\n",
    "vr=i*r      #Units in V\n",
    "vc=i*xc          #Units in V\n",
    "p=i**2*r           #Units in W\n",
    "print \"The current in circuit is I=\",round( ,4),\" A\\nVolt meter readings across resistor Vr=\",round( ,1),\" V\\nReadings across capacitor is Vc=\",round( ,1),\" V\\nPower loss in circuit is=\",round( ,1),\" W\",i,vr,vc,p)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex20.5:pg-984"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The current in circuit is I= 2.17  A\n",
      "Volt meter reading across R Vr= 43.4  V\n",
      "Volt meter reading across L Vl= 32.7  V\n",
      "Volt meter reading across c Vc= 57.6  V\n",
      "\n"
     ]
    }
   ],
   "source": [
    "  #Example 20_5\n",
    "\n",
    "import math  \n",
    "#To find the current in circuit and voltmeters reading across R C and L\n",
    "f=600           #Units in Hz\n",
    "l=4.0*10**-3           #Units in H\n",
    "xl=2*math.pi*f*l          #Units in Ohms\n",
    "c=10.0*10**-6           #Units in F\n",
    "xc=1/(2*math.pi*f*c)         #Units in Ohms\n",
    "r=20.0         #Units in Ohms\n",
    "z=math.sqrt(r**2+(xl-xc)**2)        #Units in Ohms\n",
    "v=50.0           #Units in V\n",
    "i=v/z          #Units in A\n",
    "vr=i*r      #Units in V\n",
    "vl=i*xl        #Units in V\n",
    "vc=i*xc      #Units in V\n",
    "print \"The current in circuit is I=\",round(i,2),\" A\\nVolt meter reading across R Vr=\",round(vr,1),\" V\\nVolt meter reading across L Vl=\",round(vl,1),\" V\\nVolt meter reading across c Vc=\",round(vc,1),\" V\\n\"\n"
   ]
  }
 ],
 "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.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}