{
 "metadata": {
  "name": "",
  "signature": "sha256:a6186b38a4c98127df63df89c795e706ba7e6e448199a1ba5338811786db72cb"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 3 - Semiconductor Diodes"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E1 - Pg 127"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex3_1 Pg-127\n",
      "#calculate current\n",
      "print '%s' %(\"Refer to the diagram 3.11(b)\")\n",
      "print '%s' %(\"Using ohm''s law\")\n",
      "print '%s' %(\"Vt = Vd1 + Vr1\")\n",
      "Vd1=0.7 #voltage drop in V\n",
      "Vt=12. #supply voltage in V\n",
      "R1=1.2*10.**3. #resistor R1 in ohm\n",
      "Vr1=Vt-Vd1 #voltage across R1 in V\n",
      "It=Vr1/R1 #current in A\n",
      "print '%s' %(\"Ohm''s law\")\n",
      "print '%s %.2f' %(\"\\n Current I_t = mA\",It*10**3)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Refer to the diagram 3.11(b)\n",
        "Using ohm''s law\n",
        "Vt = Vd1 + Vr1\n",
        "Ohm''s law\n",
        "\n",
        " Current I_t = mA 9.42\n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E2 - Pg 182"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex3_2 Pg-182\n",
      "#calculate the voltage applied across the junction\n",
      "import math\n",
      "J=10.**5. #forward current density\n",
      "Js=250.*10.**(-3.) #saturation current density\n",
      "e=1.6*10.**(-19.) #electron charge\n",
      "T=300. #temperature\n",
      "k=1.38*10.**(-23.) #Boltzmann constant\n",
      "V=(math.log(J/Js)*k*T)/e #voltage applied across junction\n",
      "print '%s %.2f' %(\"The voltage applied across the junction =V\",V)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The voltage applied across the junction =V 0.33\n"
       ]
      }
     ],
     "prompt_number": 24
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E3 - Pg 182"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex3_3 Pg-182\n",
      "import math\n",
      "I=2.*10.**6. #forward current density\n",
      "Is=30. #saturation current density\n",
      "ekt=40.\n",
      "V=(1./40.)*math.log(I/Is) #Applied forward voltage\n",
      "print '%s %.3f' %(\"Applied forward voltage =V\",V)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Applied forward voltage =V 0.278\n"
       ]
      }
     ],
     "prompt_number": 25
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E4 - Pg 182"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex3_4 Pg-182\n",
      "import math\n",
      "print '%s' %(\"I = Is*exp(eV/kT) = Is*exp(40V)\")\n",
      "print '%s' %(\"Re = del_V/del_I = 1/40I\")\n",
      "print '%s' %(\"Dividing throughtout by volume, one obtains the equation in the form of current density as\")\n",
      "print '%s' %(\"J = Js*(exp(eV/kT)-1)\")\n",
      "J=10.**5. #forward current density\n",
      "Js=250.*10.**(-3.) #saturation current density\n",
      "e=1.6*10.**(-19.) #electron charge\n",
      "T=300. #temperature\n",
      "k=1.38*10.**(-23.) #Boltzmann constant\n",
      "V=(math.log(J/Js)*k*T)/e #voltage applied across junction\n",
      "print '%s %.2f' %(\"\\n The voltage applied across the junction =V\",V)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "I = Is*exp(eV/kT) = Is*exp(40V)\n",
        "Re = del_V/del_I = 1/40I\n",
        "Dividing throughtout by volume, one obtains the equation in the form of current density as\n",
        "J = Js*(exp(eV/kT)-1)\n",
        "\n",
        " The voltage applied across the junction =V 0.33\n"
       ]
      }
     ],
     "prompt_number": 26
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E5 - Pg 183"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex3_5 Pg-183\n",
      "print '%s' %(\"(a) Forward-bias\")\n",
      "Av=50. #applied voltage\n",
      "Jr=5000. #junction resistance\n",
      "Er=50. #external resistance\n",
      "cur=Av/(Er+Jr) #current\n",
      "print '%s %.1f %s' %(\"Current =mA \\n\",cur*10.**3.,\"\\n\")\n",
      "\n",
      "print '%s' %(\"(b) Reverse-bias\")\n",
      "cur_rev=Av/(Jr+10.**6.) #book expression is wrong\n",
      "print '%s %.3f' %(\"Current =1e-2 mA \\n\",cur_rev*10**5)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a) Forward-bias\n",
        "Current =mA \n",
        " 9.9 \n",
        "\n",
        "(b) Reverse-bias\n",
        "Current =1e-2 mA \n",
        " 4.975\n"
       ]
      }
     ],
     "prompt_number": 27
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E6 - Pg 183"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex3_6 Pg-183\n",
      "import math\n",
      "print '%s' %(\"We know that\")\n",
      "print '%s' %(\"  r_ac = dV/dI - 1/(dI/dV) = 1/((I0/KT)exp(V/KT))\")\n",
      "k=8.62*10.**(-5.)\n",
      "T=300. #temperaturein K\n",
      "kT=k*T\n",
      "I0=10.**(-6.) #saturation current\n",
      "V=150.*10.**(-3.) #voltage forward biased\n",
      "r_ac = 1./((I0/kT)*math.exp(V/kT)) #value of exp(0.15/0.02586)=330.45 and not the textbook value of 332.66\n",
      "print '%s %.2f' %(\"\\n The AC resistance =ohm\",r_ac) #text book value wrong\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "We know that\n",
        "  r_ac = dV/dI - 1/(dI/dV) = 1/((I0/KT)exp(V/KT))\n",
        "\n",
        " The AC resistance =ohm 78.26\n"
       ]
      }
     ],
     "prompt_number": 28
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E7 - Pg 184"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex3_7 Pg-184\n",
      "import math\n",
      "print '%s' %(\"We know that (I0)*T2 = (I0)*T1*(2)**((T2-T1/10))\")\n",
      "\n",
      "print '%s' %(\"Substituting the given values,we have \")\n",
      "\n",
      "print '%s' %(\"(40*10**(-6)) = (25*10**(-6)*(2)**x) where x=(T2-T1)/10\")\n",
      "\n",
      "print '%s' %(\"(2)**x = 1.6\")\n",
      "\n",
      "print '%s' %(\"Taking log on both sides,one obtains\")\n",
      "\n",
      "print '%s' %(\"x*log(2) = log(1.6)\")\n",
      "\n",
      "print '%s' %(\"or x = log(1.6)/log(2)\")\n",
      "\n",
      "x=math.log(1.6)/math.log(2.)\n",
      "\n",
      "print '%s' %(\" Now x = (T2-T1)/10 or 0.678 = (T2-25)/10\")\n",
      "T1=25. #temperature T1\n",
      "T2=x*10.+T1 #temperature T2\n",
      "diff_temp=T2-T1 #change in temperature\n",
      "print '%s %.2f' %(\"\\n So the change in temperature =degree celsius\",diff_temp)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "We know that (I0)*T2 = (I0)*T1*(2)**((T2-T1/10))\n",
        "Substituting the given values,we have \n",
        "(40*10**(-6)) = (25*10**(-6)*(2)**x) where x=(T2-T1)/10\n",
        "(2)**x = 1.6\n",
        "Taking log on both sides,one obtains\n",
        "x*log(2) = log(1.6)\n",
        "or x = log(1.6)/log(2)\n",
        " Now x = (T2-T1)/10 or 0.678 = (T2-25)/10\n",
        "\n",
        " So the change in temperature =degree celsius 6.78\n"
       ]
      }
     ],
     "prompt_number": 29
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E8 - Pg 185"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex3_8 Pg-185\n",
      "import math\n",
      "print '%s' %(\"Forward current I is given by \")\n",
      "print '%s' %(\"I=I0*exp(V/(n*Vt))-1\")\n",
      "V=0.3 #voltage\n",
      "n=1. #constant\n",
      "T1=22.+273. #temperature T1 in Kelvin\n",
      "Vt1=T1/11600.\n",
      "I=(math.exp(V/0.025)-1)\n",
      "print '%s' %(\"When temperature rises to 72 degree celcius, then\")\n",
      "\n",
      "T2=72.+273. #temperature T2 in Kelvin\n",
      "Vt2=T2/11600.\n",
      "TR=T2-T1 #temperature rise\n",
      "I_72=(2.)**(TR/10.)\n",
      "\n",
      "I_hash=I_72*(math.exp(V/(Vt2))-1)\n",
      "for_cur_rises=I_hash/I\n",
      "print '%s' %(\"Thus, at 72 degree celcius Forward current rises by \")\n",
      "print '%s' %(for_cur_rises)\n",
      "cur_I=768849.72\n",
      "cur_I_hash=162753.79\n",
      "FCR=cur_I/cur_I_hash\n",
      "print '%s %.2f' %(\"\\n=\",FCR)\n",
      " #answer in the book  is wrong\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Forward current I is given by \n",
        "I=I0*exp(V/(n*Vt))-1\n",
        "When temperature rises to 72 degree celcius, then\n",
        "Thus, at 72 degree celcius Forward current rises by \n",
        "4.72400496343\n",
        "\n",
        "= 4.72\n"
       ]
      }
     ],
     "prompt_number": 30
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E9 - Pg 185"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex3_9 Pg-185\n",
      "import math\n",
      "n=1. #constant\n",
      "T=27.+273. #temperature in K\n",
      "Vt=T/11600.\n",
      "V=0.2 #voltage\n",
      "I0=10.**(-6.) #saturation current\n",
      "I=I0*(math.exp(V/Vt)-1)\n",
      "stat_res=V/I #static resistance\n",
      "print '%s %.2f' %(\"Static resistance =ohm\",stat_res)\n",
      "\n",
      "dyn_res=Vt/(I+I0) #dynamic resistance\n",
      "print '%s %.2f' %(\"Dynamic resistance =ohm\",dyn_res)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Static resistance =ohm 87.63\n",
        "Dynamic resistance =ohm 11.33\n"
       ]
      }
     ],
     "prompt_number": 31
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E10 - Pg 186"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex3_10 Pg-186\n",
      "import math\n",
      "print '%s' %(\"We know that I = I0*(math.exp(V/n*Vt)-1)\")\n",
      "print '%s' %(\"Dividing on both sides by area A, one obtains\")\n",
      "print '%s' %(\"I/A = I0/A*(mah.exp(V/n*Vt)-1)\")\n",
      "print '%s' %(\"or J = J0*(math.exp(V/n*Vt)-1)\")\n",
      "n=1. #constant\n",
      "T=300. #temperature in K\n",
      "Vt=T/11600.\n",
      "J=10.**5. #forward current density\n",
      "J0=250.*10.**(-3.) #saturation current density \n",
      "V=Vt*math.log(J/J0)\n",
      "print '%s %.4f' %(\"\\n The voltage applied across the junction =V\",V)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "We know that I = I0*(math.exp(V/n*Vt)-1)\n",
        "Dividing on both sides by area A, one obtains\n",
        "I/A = I0/A*(mah.exp(V/n*Vt)-1)\n",
        "or J = J0*(math.exp(V/n*Vt)-1)\n",
        "\n",
        " The voltage applied across the junction =V 0.3336\n"
       ]
      }
     ],
     "prompt_number": 32
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E11 - Pg 186"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex3_11 Pg-186\n",
      "Vmin=0.7 #minimum voltage across diode in V\n",
      "V=5. #supply voltage in V\n",
      "V_R1=V-Vmin #voltage across resistor R in V\n",
      "Imin=10.**(-3.) #minimum current\n",
      "R1=V_R1/Imin \n",
      "print '%s %.1f' %(\"Maximum value of R =kohm \\n \",R1*1e-3)\n",
      "I=5.*10.**(-3.) #current through resistance in A\n",
      "V_R2=V-Vmin #voltage across resistor R in V\n",
      "R2=V_R2/I\n",
      "print '%s %.0f' %(\"\\n\\n Minimum value of R =ohm \",R2)\n",
      "Vb=6. #supply voltage\n",
      "Vb_res=Vb-Vmin #voltage across resistor\n",
      "P=I*Vb_res #power dissipated across resistor\n",
      "print '%s %.1f' %(\"\\n\\n Power dissipated across R =W\",P*10**3)\n",
      "P_diode=I*Vmin #power dissipated across diode\n",
      "print '%s %.1f' %(\"\\n power dissipated across diode =mW\",P_diode*1e3)\n",
      "R=10.**3. #resistor in ohm\n",
      "V_R=R*Imin #voltage drop across resistor R in V\n",
      "Vb=V_R+Vmin \n",
      "print '%s %.1f' %(\"\\n\\n The minimum voltage across diode =V\",Vb)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Maximum value of R =kohm \n",
        "  4.3\n",
        "\n",
        "\n",
        " Minimum value of R =ohm  860\n",
        "\n",
        "\n",
        " Power dissipated across R =W 26.5\n",
        "\n",
        " power dissipated across diode =mW 3.5\n",
        "\n",
        "\n",
        " The minimum voltage across diode =V 1.7\n"
       ]
      }
     ],
     "prompt_number": 33
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E12 - Pg 188"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex3_12 Pg-188\n",
      "print '%s' %(\"Refer to the figure 3.51\")\n",
      "Id1=2.*10.**(-3.) #diode current in I\n",
      "Vd1=0.5 #diode voltage in V\n",
      "Rf1=Vd1/Id1 #Dc resistance\n",
      "print '%s' %(\"At Id=2mA and Vd=0.5V\")\n",
      "print '%s %.0f' %(\"\\n Rf =ohm\",Rf1)\n",
      "\n",
      "Id2=20.*10.**(-3.) #diode current in I\n",
      "Vd2=0.75 #diode voltage in V\n",
      "Rf2=Vd2/Id2 #Dc resistance\n",
      "print '%s' %(\"At Id=20mA and Vd=0.75V\")\n",
      "print '%s %.1f' %(\"\\n Rf =ohm \",Rf2)\n",
      "\n",
      "Id3=2.*10.**(-6.) #diode current in I\n",
      "Vd3=10. #diode voltage in V\n",
      "Rf3=Vd3/Id3 #Dc resistance\n",
      "print '%s' %(\"At Id=2*10**(-6)A and Vd=10V\")\n",
      "print '%s %.0f' %(\"\\n Rf =Mohm\",Rf3*10**-6)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Refer to the figure 3.51\n",
        "At Id=2mA and Vd=0.5V\n",
        "\n",
        " Rf =ohm 250\n",
        "At Id=20mA and Vd=0.75V\n",
        "\n",
        " Rf =ohm  37.5\n",
        "At Id=2*10**(-6)A and Vd=10V\n",
        "\n",
        " Rf =Mohm 5\n"
       ]
      }
     ],
     "prompt_number": 34
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E13 - Pg 188"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex3_13 Pg-188\n",
      "print '%s' %(\"Refer to the figure 3.52\")\n",
      "print '%s' %(\"(a) Assuming the diode D to be ideal \")\n",
      "print '%s' %(\"    Ignoring diode D,voltage across R2 is given as (By applying potential divider concept)\")\n",
      "R1=45. #resistor R1\n",
      "R2=5. #resistor R2\n",
      "Vaa=10. #supply voltage\n",
      "Vab=Vaa*(R2/(R1+R2))\n",
      "print '%s %.0f' %(\"\\n Vab=V\",Vab)\n",
      "\n",
      "print '%s' %(\" Thus,diode D is forward biased.It conducts,offering zero resistance  Hence no current would flow through the parallel bransh R2.The circuit equivalent to that shown in figure 3.53(a)\")\n",
      "ID=Vaa/R1 #diode current\n",
      "print '%s %.0f' %(\"\\n Current through diode =mA \",ID*10**3)\n",
      "\n",
      "print '%s' %(\"(b)Assuming the diode to be real\")\n",
      "print '%s' %(\"     Voltage Vab is much larger than Vt hencethe diode conducts.It is replaced by its equivalent as shown in figure 3.53(b).To determine current Id through the diode we first find the Thevenin''s equivalent of the circuit on the left of AB.Vth=open circuit voltage across AB\")\n",
      "Vth=Vaa*(R2/(R1+R2))\n",
      "print '%s %.0f' %(\"\\n Vth=V\",Vth)\n",
      "Rth=R1*R2/(R1+R2)\n",
      "print '%s %.0f' %(\"\\n Rth=ohm \",Rth) #textbook value is wrong\n",
      "print '%s' %(\"Thus,the equivalent circuit becomes as shown in figure 3.53(c)\")\n",
      "Vt=0.3 #load voltage\n",
      "tf=25. #load resistance\n",
      "Id=(Vth-Vt)/(Rth+tf)\n",
      "print '%s %.1f' %(\"\\n Current through diode = mA\",Id*10**3)\n",
      " "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Refer to the figure 3.52\n",
        "(a) Assuming the diode D to be ideal \n",
        "    Ignoring diode D,voltage across R2 is given as (By applying potential divider concept)\n",
        "\n",
        " Vab=V 1\n",
        " Thus,diode D is forward biased.It conducts,offering zero resistance  Hence no current would flow through the parallel bransh R2.The circuit equivalent to that shown in figure 3.53(a)\n",
        "\n",
        " Current through diode =mA  222\n",
        "(b)Assuming the diode to be real\n",
        "     Voltage Vab is much larger than Vt hencethe diode conducts.It is replaced by its equivalent as shown in figure 3.53(b).To determine current Id through the diode we first find the Thevenin''s equivalent of the circuit on the left of AB.Vth=open circuit voltage across AB\n",
        "\n",
        " Vth=V 1\n",
        "\n",
        " Rth=ohm  4\n",
        "Thus,the equivalent circuit becomes as shown in figure 3.53(c)\n",
        "\n",
        " Current through diode = mA 23.7\n"
       ]
      }
     ],
     "prompt_number": 35
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E14 - Pg 190"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex3_14 Pg-190\n",
      "print '%s' %(\"Diodes D2 and D3 are reverse-biased.\\nTherefore,these are like open-switches.\\nDiodes D1 and D2 are forward biased.\\nThese are replaced by their equivalent circuits,as shown in figure 3.54.\\nSince the diodes are silicon V=0.7V. \")\n",
      "Vt=0.7 #voltage drop\n",
      "Vaa=20. #supply voltage in V\n",
      "net_emf=Vaa-Vt-Vt #net emf\n",
      "R1=5.  \n",
      "R2=90.\n",
      "R3=5. #R1,R2,R3 are resistances\n",
      "tot_res=R1+R2+R3 #total resistance\n",
      "print'%s' %(\"Therefore, current through 90 ohm resistor is\")\n",
      "I=net_emf/tot_res\n",
      "print'%s %.0f' %(\"\\nCurrent I =mA\",I*10**3)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Diodes D2 and D3 are reverse-biased.\n",
        "Therefore,these are like open-switches.\n",
        "Diodes D1 and D2 are forward biased.\n",
        "These are replaced by their equivalent circuits,as shown in figure 3.54.\n",
        "Since the diodes are silicon V=0.7V. \n",
        "Therefore, current through 90 ohm resistor is\n",
        "\n",
        "Current I =mA 186\n"
       ]
      }
     ],
     "prompt_number": 36
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E15 - Pg 190"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex3_15 Pg-190\n",
      "print '%s' %(\"(a) When the diode is forward biased figure 3.55(b),it offers zero resistance.\\nIt is like shorted switch.This shorted switch across AB also short-circuits the resistance R2.Obviously,a parallel combination of the diode and R2 is equivalent to a resistance of zero ohms.\")\n",
      "R1=100. #reisitor R1 in ohm \n",
      "R=R1\n",
      "Vaa=10. #supply voltage in V\n",
      "I=Vaa/R\n",
      "print '%s %.1f' %(\"\\n Current drawn from battery =A\",I)\n",
      "print '%s' %(\"(a) When the diode is reverse biased figure 3.55(b).\\nIt is like open switch.Obviously,it then does not make any difference whether the diode is connected or not.\")\n",
      "R2=100 #resistor R2 in ohm\n",
      "tot_R=R1+R2\n",
      "I1=Vaa/tot_R\n",
      "print '%s %.2f' %(\"\\n Current drawn from battery =A\",I1)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a) When the diode is forward biased figure 3.55(b),it offers zero resistance.\n",
        "It is like shorted switch.This shorted switch across AB also short-circuits the resistance R2.Obviously,a parallel combination of the diode and R2 is equivalent to a resistance of zero ohms.\n",
        "\n",
        " Current drawn from battery =A 0.1\n",
        "(a) When the diode is reverse biased figure 3.55(b).\n",
        "It is like open switch.Obviously,it then does not make any difference whether the diode is connected or not.\n",
        "\n",
        " Current drawn from battery =A 0.05\n"
       ]
      }
     ],
     "prompt_number": 37
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E16 - Pg 191"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex3_16 Pg-191\n",
      "Vz=9. #breakdown voltage in V\n",
      "per=0.1 #10% tolerance \n",
      "Tol=Vz*per\n",
      "print '%s %.1f'%(\"Tolerance =V\",Tol)\n",
      "tol_high=Vz+Tol\n",
      "tol_low=Vz-Tol #ranges in tolerance\n",
      "print'%s %.1f %.1f'%(\"\\n Range of breakdown voltage=to V\",tol_low,tol_high)\n",
      "# in the textbook the value 8.2 is wrong the correct value is 8.1\n",
      "T1=25. #temperature T1 in degree celcius\n",
      "T2=75. #temperature T2 in degree celcius\n",
      "diff_temp=T2-T1 #chnage in temperature\n",
      "Vzener=2.*10.**(-3.) #zener voltage\n",
      "fall_break_vol=Vzener*diff_temp #fall in breakdown voltage\n",
      "new_break_vol=Vz-fall_break_vol #new break don voltage\n",
      "print '%s %.1f' %(\"\\n New break don voltage =V\",new_break_vol)\n",
      "range_high=tol_low-fall_break_vol\n",
      "range_low=tol_high-fall_break_vol\n",
      "print '%s %.1f %.1f' %(\"\\n Range of breakdown voltage=to V\",range_high,range_low)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Tolerance =V 0.9\n",
        "\n",
        " Range of breakdown voltage=to V 8.1 9.9\n",
        "\n",
        " New break don voltage =V 8.9\n",
        "\n",
        " Range of breakdown voltage=to V 8.0 9.8\n"
       ]
      }
     ],
     "prompt_number": 38
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E17 - Pg 192"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex3_17 Pg-192\n",
      "import math\n",
      "C=20. #capacitance in pF\n",
      "V=5. #supply voltage in V\n",
      "K=C*math.sqrt(V)\n",
      "C_V1=K/math.sqrt(V+1)\n",
      "print '%s %.1f' %(\"Capacitance for 1V increase =pF\",C_V1)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Capacitance for 1V increase =pF 18.3\n"
       ]
      }
     ],
     "prompt_number": 39
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E18 - Pg 192"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex3_18 Pg-192\n",
      "import math\n",
      "print '%s' %(\"(a) The two diodes are connected in series and hence the current I flows in D1 and D2.\\nObviously,it is in forward direction through D2 and in reverse direction through D1.\\nSince D2 diode is forward biased,V2 will be very small and hence V1=(5-V2) will be very much larger than Vt=0.026V.\\nThis means the current will be equal to reverse saturation current I0.\\nNow,we consider diode D2.\\nWe have \\n\\n\")\n",
      "print '%s' %(\"I = I0*(exp(V/Vt)-1)\")\n",
      "print '%s' %(\"Putting I=I0 and V=V2, we have\")\n",
      "print '%s' %(\"I0 = I0*(exp(V2/Vt)-1)\")\n",
      "print '%s' %(\"exp(V2/Vt)-1 = 1\")\n",
      "Vt=0.026 #threshold voltage\n",
      "V2=Vt*math.log(2.)\n",
      "V=5. #supply voltage in V\n",
      "V1=V-V2 #value in textbook incorrect\n",
      "print '%s %.3f' %(\"\\n V2 =V\",V2)\n",
      "print '%s %.3f' %(\"\\n V2 =V\\n \",V1)\n",
      "print '%s' %(\"Effect of temperature : V2=Vt*ln(2) = kT*ln(2)\")\n",
      "print '%s' %(\"So V2 will increase with temperature\\n\")\n",
      "print '%s' %(\"(b) If Vz is 4.9V then D1 will breakdown. This means V1=4.9V\")\n",
      "Vz=4.9 #breakdown voltage\n",
      "V2=V-Vz\n",
      "print '%s' %(\"Now using I0=5*10**(-6)A and V2=0.1V,one obtains\")\n",
      "I0=5*10**(-6) #current in ampere\n",
      "I=I0*(math.exp(V2/Vt)-1)\n",
      "print '%s %.0f' %(\"\\n Current I=microA\",I*10**6)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a) The two diodes are connected in series and hence the current I flows in D1 and D2.\n",
        "Obviously,it is in forward direction through D2 and in reverse direction through D1.\n",
        "Since D2 diode is forward biased,V2 will be very small and hence V1=(5-V2) will be very much larger than Vt=0.026V.\n",
        "This means the current will be equal to reverse saturation current I0.\n",
        "Now,we consider diode D2.\n",
        "We have \n",
        "\n",
        "\n",
        "I = I0*(exp(V/Vt)-1)\n",
        "Putting I=I0 and V=V2, we have\n",
        "I0 = I0*(exp(V2/Vt)-1)\n",
        "exp(V2/Vt)-1 = 1\n",
        "\n",
        " V2 =V 0.018\n",
        "\n",
        " V2 =V\n",
        "  4.982\n",
        "Effect of temperature : V2=Vt*ln(2) = kT*ln(2)\n",
        "So V2 will increase with temperature\n",
        "\n",
        "(b) If Vz is 4.9V then D1 will breakdown. This means V1=4.9V\n",
        "Now using I0=5*10**(-6)A and V2=0.1V,one obtains\n",
        "\n",
        " Current I=microA 229\n"
       ]
      }
     ],
     "prompt_number": 40
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E19 - Pg 193"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex3_19 Pg-193\n",
      "print '%s' %(\"We have Iv=40*iD\")\n",
      "Iv=1. #luminous intensity\n",
      "iD=Iv/(40.*10.**(-3.)) #LED current\n",
      "print '%s %.0f' %(\"LED current =mA\",iD)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "We have Iv=40*iD\n",
        "LED current =mA 25\n"
       ]
      }
     ],
     "prompt_number": 41
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E20 - Pg 193"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex3_20 Pg-193\n",
      "print '%s %s' %(\"(a) At Id=10mA,\",\"\\n\")\n",
      "V=25. #voltage in mV\n",
      "Id=10. #current in mA\n",
      "Rac=V/Id \n",
      "#AC resistance (value in textbook is wrong)\n",
      "print '%s %.1f %s' %(\"AC resistance Rac=ohm\",Rac,\"\\n\")\n",
      "Id=20. #current in mA\n",
      "Rac=V/Id \n",
      "#AC resistance (value in textbook is wrong)\n",
      "print '%s %.2f %s' %(\"AC resistance Rac=ohm\",Rac,\"\\n\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a) At Id=10mA, \n",
        "\n",
        "AC resistance Rac=ohm 2.5 \n",
        "\n",
        "AC resistance Rac=ohm 1.25 \n",
        "\n"
       ]
      }
     ],
     "prompt_number": 42
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E21 - Pg 194"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex3_21 Pg-194\n",
      "import math\n",
      "print '%s' %(\"We know that\")\n",
      "print '%s' %(\"  r_ac = dV/dI - 1/(dI/dV) = 1/((I0/KT)exp(V/KT))\")\n",
      "k=8.62*10.**(-5.)\n",
      "T=300. #temperaturein K\n",
      "kT=k*T\n",
      "I0=10.**(-6.) #saturation current\n",
      "V=150.*10.**(-3.) #voltage forward biased\n",
      "r_ac = 1./((I0/kT)*math.exp(V/kT))\n",
      "#value of exp(0.15/0.02586)=330.45 and not the textbook value of 332.66\n",
      "print '%s %.2f' %(\"\\n The AC resistance =ohm\",r_ac) #text book value wrong\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "We know that\n",
        "  r_ac = dV/dI - 1/(dI/dV) = 1/((I0/KT)exp(V/KT))\n",
        "\n",
        " The AC resistance =ohm 78.26\n"
       ]
      }
     ],
     "prompt_number": 43
    }
   ],
   "metadata": {}
  }
 ]
}