{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter No.1: Special Diodes"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.1, Page No. 9"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Reverse Saturation current of diode\n",
      "import math\n",
      "\n",
      "#variable declaration\n",
      "\n",
      "I=40*10**-3           #forword bias current in A\n",
      "V=0.25                #forword bias voltage in Volt\n",
      "T=20                  #junction temperature in degree C\n",
      "T=T+273               #junction temperature in degree K\n",
      "ETA=1                 #For Ge\n",
      "e=1.6*10**-19         #in Coulamb(electronic charge)\n",
      "k=1.38*10**-23        #in J/K(Boltzman Constant)\n",
      "\n",
      "#Calculation\n",
      "#Formula : I=Io*(exp(e*V/(ETA*k*T))-1)\n",
      "x=math.ceil((e*V/(ETA*k*T)))\n",
      "Io=I/(math.exp(x)-1)\n",
      "Io=math.ceil(Io*10**8)/10**8\n",
      "\n",
      "#Result\n",
      "print(\"Reverse saturation current in micro Ampere : %.2f \"%(Io*10**6))\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Reverse saturation current in micro Ampere : 1.82 \n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "example 1.2, Page No. 9"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Value of forword voltage\n",
      "import math\n",
      "#variable declaration\n",
      "Io=10*10**-6                   # reverse saturation currrent in A\n",
      "I=1                            # forword current in Ampere\n",
      "ETA=2                          # For Si\n",
      "T=27                           # room temperature in degree C\n",
      "T=T+273                        # room temperature in degree K\n",
      "e=1.6*10**-19                  # in Coulamb(electronic charge)\n",
      "k=1.38*10**-23                 # in J/K(Boltzman Constant)\n",
      "\n",
      "#Calculation\n",
      "#Formula : I=Io*(exp(%e*V/(ETA*k*T))-1)\n",
      "V=(ETA*k*T/e)*math.log(I/(Io)+1)\n",
      "V=math.floor(V*100)/100\n",
      "#result\n",
      "print(\"Forward Voltage across the diode in Volt :%.2f\"%V)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Forward Voltage across the diode in Volt :0.59\n"
       ]
      }
     ],
     "prompt_number": 21
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "example 1.3 , Page No. 23"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#DC Current, DC Voltage, Ripple Factor\n",
      "import math\n",
      "#Variable Declaration\n",
      "RL=1                #load resistance in kOhm\n",
      "#rf<<RL\n",
      "Vrms=200            #in Volt\n",
      "\n",
      "#Part (i)\n",
      "Vo=Vrms*math.sqrt(2)        #in volt\n",
      "Idc=Vo/(RL*10**3*math.pi)   #in Ampere\n",
      "print(\"(i)\\nDC current in load in mA :%.0f\"%(math.floor((Idc*10**3))))\n",
      "\n",
      "#Part (ii)\n",
      "Vdc=RL*10**3*Idc            #in Volt\n",
      "print(\"\\n(ii)\\nDC voltage across load in volt :%.0f\"%(math.floor(Vdc)))\n",
      "\n",
      "#Part (iii)\n",
      "#Gamma=sqrt((Irms/Idc)^2-1)=sqrt((Io/2)/(Io/%pi)-1)=sqrt((%pi/2)^2-1)\n",
      "Gamma=math.sqrt((math.pi/2)**2-1)    #unitless\n",
      "print(\"\\n(iii)\\nRipple factor :%.2f \"%(math.floor(Gamma*100)/100))\n",
      "\n",
      "#Part (iv)\n",
      "PIV=Vrms*math.sqrt(2)       #in volt\n",
      "print(\"\\n(iv)\\nPeak Inverse Voltage in volt :%.0f\"%(math.floor(PIV)))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i)\n",
        "DC current in load in mA :90\n",
        "\n",
        "(ii)\n",
        "DC voltage across load in volt :90\n",
        "\n",
        "(iii)\n",
        "Ripple factor :1.21 \n",
        "\n",
        "(iv)\n",
        "Peak Inverse Voltage in volt :282\n"
       ]
      }
     ],
     "prompt_number": 31
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "example 1.4 , Page No. 23"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Average dc current rms current rectifcation efcieny PIV\n",
      "import math\n",
      "#variable declaration\n",
      "rf=20.0                      #in ohm\n",
      "RL=980.0                     #in Ohm\n",
      "Vrms=50.0                    #in Volt\n",
      "Vo=Vrms*math.sqrt(2)         #in Volt\n",
      "Io=Vo/(RL+rf)                #in Ampere\n",
      "\n",
      "#Part (i)\n",
      "Idc=2*Io/math.pi             #in Ampere\n",
      "print(\"(i)\\nAverage DC current in mA :%.0f\"%(math.floor(Idc*10**3)))\n",
      "\n",
      "#Part (ii)\n",
      "Irms=Io/math.sqrt(2)          #in Ampere\n",
      "print(\"\\n(ii)\\nrms value of load current in mA :%.0f\"%(math.ceil(Irms*1000)))\n",
      "\n",
      "#Part (iii)\n",
      "Vdc=RL*Idc                    #in Volt\n",
      "print(\"\\n(iii)\\nDC output voltage in volt :%.1f\"%(math.floor(Vdc*10)/10))\n",
      "\n",
      "#Part (iv)\n",
      "ETA=(Idc**2*RL/(Irms**2*(RL+rf)))*100          #Rectification Efficiency in %\n",
      "print(\"\\n(iv)\\nRectification Efficiency is %.1f%%\"%(math.ceil(ETA*10)/10))\n",
      "\n",
      "#Part (v)\n",
      "PIV=2*Vo                       #in volt\n",
      "print(\"\\n(v)\\nPeak Inverse Voltage in volt :%.1f\"%PIV)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i)\n",
        "Average DC current in mA :45\n",
        "\n",
        "(ii)\n",
        "rms value of load current in mA :50\n",
        "\n",
        "(iii)\n",
        "DC output voltage in volt :44.1\n",
        "\n",
        "(iv)\n",
        "Rectification Efficiency is 79.5%\n",
        "\n",
        "(v)\n",
        "Peak Inverse Voltage in volt :141.4\n"
       ]
      }
     ],
     "prompt_number": 38
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "example 1.5, Page No.26"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Minimum value of resistance\n",
      "import math\n",
      "#Variable declaration\n",
      "\n",
      "Vin=40                       #in volt\n",
      "VZ=10                        #in volt\n",
      "Vo=10                        #in volt\n",
      "IZmax=50                     #in mA\n",
      "IL=0                         #in mA\n",
      "\n",
      "#calculation\n",
      "#Formula : I=IZ+IL=IZmax+0\n",
      "I=IZmax+0                    #in mA\n",
      "#Formula : VZ=Vin-R*I\n",
      "Rmin=(Vin-VZ)/(I*10**-3)     #in Ohm\n",
      "#Result\n",
      "print(\"Minimum value of resistance in Ohm :%.0f \"%Rmin)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Minimum value of resistance in Ohm :600 \n"
       ]
      }
     ],
     "prompt_number": 40
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "example 1.6, Page No.26"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Value of series resistor\n",
      "import math\n",
      "#variable declaration\n",
      "Vmin=15                    #Minimum input voltage in volt\n",
      "VZ=6.8                     #Voltage across zener in volt\n",
      "Vo=VZ                      #output voltage in volt\n",
      "Vsr1=Vmin-Vo               #Voltage aross series resistance in volt\n",
      "print(\"If R is the series resistance, Total current in series resistance in Ampere : I=Vsr/R=8.2/R \")\n",
      "ILmin=5                    #in mA\n",
      "print(\"current in zener diode in Ampere :IZ=I-IL=(8.2/R-IL*10-3).............eqn(1)\\n\");\n",
      "Vmax=20                    #mximum output voltage\n",
      "Vo=VZ                      #output voltage in volt\n",
      "Vsr2=Vmax-Vo               #Voltage aross series resistance in volt\n",
      "print(\"Current in series resistance circuit in Ampere : I=Vsr/R\\n\")\n",
      "ILmax=15                   #in mA\n",
      "print(\"current in zener diode in Ampere :IZ=I-IL=(Rs/R-IL*10-3)..............eqn(2)\\n\")\n",
      "print(\"For Zener diode to work as voltage regulator,(1) and (2) must be same.\");\n",
      "print(\"(8.2/R-IL*10-3)=(13.2/R-IL*10-3)\")\n",
      "R=(Vsr2-Vsr1)/(ILmax*10**-3-ILmin*10**-3)            #in Ohm\n",
      "print(\"\\nRequired value of Series Resistor in ohm : %.0f\"%R)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "If R is the series resistance, Total current in series resistance in Ampere : I=Vsr/R=8.2/R \n",
        "current in zener diode in Ampere :IZ=I-IL=(8.2/R-IL*10-3).............eqn(1)\n",
        "\n",
        "Current in series resistance circuit in Ampere : I=Vsr/R\n",
        "\n",
        "current in zener diode in Ampere :IZ=I-IL=(Rs/R-IL*10-3)..............eqn(2)\n",
        "\n",
        "For Zener diode to work as voltage regulator,(1) and (2) must be same.\n",
        "(8.2/R-IL*10-3)=(13.2/R-IL*10-3)\n",
        "\n",
        "Required value of Series Resistor in ohm : 500\n"
       ]
      }
     ],
     "prompt_number": 51
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "example 1.7 Page No.27"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Current limiting resistance and dissipated power\n",
      "import math\n",
      "#variable declaration\n",
      "\n",
      "Vin=18                     #in volt\n",
      "IZ=20                      #in mA\n",
      "ILav=(5+35)/2              #in mA\n",
      "VZ=12                      #in volt\n",
      "Vo=12                      #in volt\n",
      "\n",
      "#Calculation\n",
      "I=IZ+ILav                  #in mA\n",
      "R=(Vin-Vo)/(I*10**-3)      #in Ohm\n",
      "P=(I*10**-3)**2*R          #in Watts\n",
      "\n",
      "#Result\n",
      "print(\"Current limiting resistance in Ohm : %.0f\"%R);\n",
      "print(\"Power disspation in resistance in Watt :%.2f \"%P);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Current limiting resistance in Ohm : 150\n",
        "Power disspation in resistance in Watt :0.24 \n"
       ]
      }
     ],
     "prompt_number": 45
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "example 1.8, Page No. 28"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Maximum and minimum input supply voltage\n",
      "import math\n",
      "#Variable declaration\n",
      "R=1                            #in kOhm\n",
      "RL=5                           #in kOhm\n",
      "VZ=10                          #in volt\n",
      "Vo=10                          #in volt\n",
      "P=250                          #in mW\n",
      "\n",
      "#Calculation\n",
      "IL=Vo/RL                       #in mA\n",
      "IZmin=0                        #in mA\n",
      "IZmax=P/VZ                     #in mA\n",
      "Imin=IZmin+IL                  #in mA\n",
      "Imax=IZmax+IL                  #in mA\n",
      "Vin_min=VZ+Imin*10**-3*R*10**3   #in volt\n",
      "Vin_max=VZ+Imax*10**-3*R*10**3   #in volt\n",
      "\n",
      "#Result\n",
      "print(\"The input voltage ranges from %.0fV to %.0fV\"%(Vin_min,Vin_max));"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The input voltage ranges from 12V to 37V\n"
       ]
      }
     ],
     "prompt_number": 53
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "example 1.9, Page No.28"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Output voltage voltage drop and current in zener diode\n",
      "import math\n",
      "#Variable Declaration\n",
      "R=5                             #in kOhm\n",
      "R=R*1000                        #in Ohm\n",
      "RL=10.0                         #in kOhm\n",
      "RL=RL*1000                      #in Ohm\n",
      "Vin=120.0                       #in Volt\n",
      "VZ=50.0                         #in Volt\n",
      "\n",
      "#Part (i)\n",
      "\n",
      "#calculation\n",
      "Vo=VZ                           #in Volt\n",
      "#Result\n",
      "print(\"\\n(i)\\nOutput voltage in volt :%.0f\"%Vo)\n",
      "\n",
      "#Part (ii)\n",
      "\n",
      "#calculation\n",
      "VR=Vin-VZ                       #in Volt\n",
      "#Result\n",
      "print(\"\\n(ii)\\nVoltage drop across series resistance in volt :%.0f\"%VR);\n",
      "\n",
      "\n",
      "\n",
      "#Part (iii) \n",
      "\n",
      "#Calculation\n",
      "IL=Vo/RL                        #in Ampere\n",
      "I=VR/R                          #in Ampere\n",
      "IZ=I-IL                         #in Ampere\n",
      "#Result\n",
      "print(\"\\n(iii)\\nLoad Current in mA :%.0f\"%(IL*1000))\n",
      "print(\"Current through resistance R in mA :%.0f\"%(I*1000));\n",
      "print(\"Load Current in mA :%.0f\"%(IZ*1000))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "(i)\n",
        "Output voltage in volt :50\n",
        "\n",
        "(ii)\n",
        "Voltage drop across series resistance in volt :70\n",
        "\n",
        "(iii)\n",
        "Load Current in mA :5\n",
        "Current through resistance R in mA :14\n",
        "Load Current in mA :9\n"
       ]
      }
     ],
     "prompt_number": 61
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "example 1.10, Page No. 30"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Maximum and Minimum LED current\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "VDmin=1.5              #in Volt\n",
      "VDmax=2.3              #in Volt\n",
      "VS=5.0                 #in Volt\n",
      "RS=270.0               #in Ohm\n",
      "\n",
      "#Calculation\n",
      "Imin=(VS-VDmax)/RS     #in Ampere\n",
      "Imax=(VS-VDmin)/RS     #in Ampere\n",
      "\n",
      "#Result\n",
      "print(\"Minimum value of LED current in mA : %.0f\"%(Imin*1000))\n",
      "print(\"Maximum value of LED current in mA : %.0f\"%(math.ceil(Imax*1000)))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Minimum value of LED current in mA : 10\n",
        "Maximum value of LED current in mA : 13\n"
       ]
      }
     ],
     "prompt_number": 65
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "example 1.11, Page No. 33"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Frequency range of tuning circuit\n",
      "import math\n",
      "\n",
      "#VAriable declarion\n",
      "C1min=10                 #in pF\n",
      "C2max=50                 #in pF\n",
      "L=5                      #in mH\n",
      "L=L*10**-3               #in H\n",
      "\n",
      "#Calculation\n",
      "\n",
      "#Formula : CT=C1*C2/(C1+C2)\n",
      "#Minimum\n",
      "C1=10                    #in pF\n",
      "C2=10                    #in pF\n",
      "CTmin=C1*C2/(C1+C2)      #in pF\n",
      "CTmin=CTmin*10**-12      #in F\n",
      "#Maximum\n",
      "C1=50                    #in pF\n",
      "C2=50                    #in pF\n",
      "CTmax=C1*C2/(C1+C2)      #in pF\n",
      "CTmax=CTmax*10**-12      #in F\n",
      "\n",
      "#Formula : f=1/(2*%pi*sqrt(L*C))\n",
      "#maximum :\n",
      "fmax=1/(2*math.pi*math.sqrt(L*CTmin));\n",
      "#minimum :\n",
      "fmin=1/(2*math.pi*math.sqrt(L*CTmax));\n",
      "\n",
      "#Result\n",
      "print(\"The frequency of tuning circuit ranges from %.3fMHz to %.3fMHz.\"%(fmin/10**6,fmax/10**6));\n",
      "#Note : Answer in the book is wrong."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The frequency of tuning circuit ranges from 0.450MHz to 1.007MHz.\n"
       ]
      }
     ],
     "prompt_number": 68
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "example 1.12, page No.33"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Diode Capacitance\n",
      "import math\n",
      "\n",
      "#Variable Declaration\n",
      "C1=21.0                 # in pF\n",
      "V1=4.0                  # in volt\n",
      "V2=9.0                  # in volt\n",
      "\n",
      "#Calculations\n",
      "print(\"C is proportional to 1/sqrt(V)\")\n",
      "print(\"So, C2/C1=sqrt(V1/V2)\")\n",
      "C2=math.sqrt(V1/V2)*C1     #in pF\n",
      "\n",
      "#Result\n",
      "print(\"At reverse bias 9V, Diode capacitance in pF : %.0f\"%math"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "C is proportional to 1/sqrt(V)\n",
        "So, C2/C1=sqrt(V1/V2)\n",
        "At reverse bias 9V, Diode capacitance in pF : 14\n"
       ]
      }
     ],
     "prompt_number": 72
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "example 1.13, Page No.39"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Photocurrent\n",
      "import math\n",
      "#Variable Declaration\n",
      "R=0.90               #in A/W\n",
      "Pop=1.0              #in mW\n",
      "\n",
      "#Part (i)\n",
      "#calculation\n",
      "IP=R*Pop             #in mA\n",
      "#Result\n",
      "print(\"(i)\\nPower of incident light 1mW, Photocurrent in mA is :%.2f\"%IP);\n",
      "\n",
      "#Part (ii)\n",
      "#Result\n",
      "print(\"\\n(ii)\\nHere IP is not proportional to Pop(for Pop>1.5mW)\")\n",
      "print(\"Hence Photourrent can not be calculated.\")"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i)\n",
        "Power of incident light 1mW, Photocurrent in mA is :0.90\n",
        "\n",
        "(ii)\n",
        "Here IP is not proportional to Pop(for Pop>1.5mW)\n",
        "Hence Photourrent can not be calculated.\n"
       ]
      }
     ],
     "prompt_number": 74
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "example 1.14, Page No. 39"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Responsivity of InGaAs photodiode\n",
      "import math\n",
      "#variable declaration\n",
      "ETA=70.0                #in %\n",
      "Eg=0.75                 #in eV\n",
      "Eg=Eg*1.6*10**-19       #in Joule\n",
      "h=6.63*10**-34          #Planks constant in J-s\n",
      "c=3*10**8               #speed of light in m/s\n",
      "e=1.6*10**-19           #in coulamb\n",
      "\n",
      "#Calcualtions\n",
      "lambda1=h*c/Eg           #in meter\n",
      "R=(ETA/100)*e*lambda1/(h*c)     #in A/W\n",
      "\n",
      "#Result\n",
      "print(\"Wavelength in nm :%.1f\"%(lambda1*10**9))\n",
      "print(\"Responsivity of InGaAs photodiode in A/W :%.3f\"%R)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Wavelength in nm :1657.5\n",
        "Responsivity of InGaAs photodiode in A/W :0.933\n"
       ]
      }
     ],
     "prompt_number": 78
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "example 1.15, Page No. 41"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Equilibrium contact potential\n",
      "import math\n",
      "#variable declaration\n",
      "W1=2.5                    #in eV\n",
      "W2=1.9                    #in eV\n",
      "\n",
      "#Calculation\n",
      "ContactPotential=W1-W2    #in Volt\n",
      "\n",
      "#Result\n",
      "print(\"Contact potential in Volts :%.1f \"%ContactPotential)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Contact potential in Volts :0.6 \n"
       ]
      }
     ],
     "prompt_number": 80
    }
   ],
   "metadata": {}
  }
 ]
}