{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 1: Semiconductor Diodes"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 1.1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Thermal Voltage= 25.875 mV\n"
     ]
    }
   ],
   "source": [
    "k=1.38*(10**(-23))      #boltzmann's constant\n",
    "t=273+27                #converting given temperature to Kelvin\n",
    "q=1.6*(10**(-19))       #charge on an electron\n",
    "\n",
    "# V=(k*t)/q\n",
    "\n",
    "V=(k*t)/q\n",
    "V=V*1000                #converting result in millivolts\n",
    "print \"Thermal Voltage=\",V,\"mV\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 1.2 (a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Voltage across Germanium diode= 0.2 V\n",
      "Voltage across Silicon diode  = 0.6 V\n",
      "Voltage across GaAs diode     = 1.1 V\n"
     ]
    }
   ],
   "source": [
    "Id= 1              #in mA, current across diodes\n",
    "#from the standard graph for Ge,Si, and GaAs diodes\n",
    "Vge=0.2\n",
    "Vsi=0.6\n",
    "Vgaas=1.1\n",
    "print \"Voltage across Germanium diode=\",Vge,\"V\"\n",
    "print \"Voltage across Silicon diode  =\",Vsi,\"V\"\n",
    "print \"Voltage across GaAs diode     =\",Vgaas,\"V\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 1.2 (b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Voltage across Germanium diode= 0.3 V\n",
      "Voltage across Silicon diode  = 0.7 V\n",
      "Voltage across GaAs diode     = 1.2 V\n"
     ]
    }
   ],
   "source": [
    "Id= 4               #in mA, current across diodes\n",
    "#from the standard graph for Ge,Si, and GaAs diodes\n",
    "Vge=0.3\n",
    "Vsi=0.7\n",
    "Vgaas=1.2\n",
    "print \"Voltage across Germanium diode=\",Vge,\"V\"\n",
    "print \"Voltage across Silicon diode  =\",Vsi,\"V\"\n",
    "print \"Voltage across GaAs diode     =\",Vgaas,\"V\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 1.2 (c)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Voltage across Germanium diode= 0.42 V\n",
      "Voltage across Silicon diode  = 0.82 V\n",
      "Voltage across GaAs diode     = 1.33 V\n"
     ]
    }
   ],
   "source": [
    "Id=30               #in mA, current across diodes\n",
    "#from the standard graph for Ge,Si, and GaAs diodes\n",
    "Vge=0.42\n",
    "Vsi=0.82\n",
    "Vgaas=1.33\n",
    "print \"Voltage across Germanium diode=\",Vge,\"V\"\n",
    "print \"Voltage across Silicon diode  =\",Vsi,\"V\"\n",
    "print \"Voltage across GaAs diode     =\",Vgaas,\"V\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 1.2 (d)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Average Volatge value for Germanium Diode= 0.307 V\n",
      "Average Volatge value for Silicon Diode= 0.707 V\n",
      "Average Volatge value for GaAs Diode= 1.21 V\n"
     ]
    }
   ],
   "source": [
    "#Average value for Germanium\n",
    "Vg=(0.2+0.3+0.42)/3\n",
    "#Average value for Silicon\n",
    "Vs=(0.6+0.7+0.82)/3\n",
    "#Average value for GaAs\n",
    "Vgs=(1.1+1.2+1.33)/3\n",
    "print \"Average Volatge value for Germanium Diode=\",round(Vg,3),\"V\"\n",
    "print \"Average Volatge value for Silicon Diode=\",round(Vs,3),\"V\"\n",
    "print \"Average Volatge value for GaAs Diode=\",round(Vgs,3),\"V\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 1.2 (e)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Very close correspondence between knee voltage and average voltage\n",
      "Germanium 0.3 V vs 0.307 V\n",
      "Silicon 0.7 V vs 0.707 V\n",
      "GaAs 1.2 V vs 1.21 V\n"
     ]
    }
   ],
   "source": [
    "#comparing average values in d with the standard knee voltages\n",
    "#Average value for Germanium\n",
    "Vg=(0.2+0.3+0.42)/3\n",
    "#Average value for Silicon\n",
    "Vs=(0.6+0.7+0.82)/3\n",
    "#Average value for GaAs\n",
    "Vgs=(1.1+1.2+1.33)/3\n",
    "kge=0.3\n",
    "ksi=0.7\n",
    "kgaas=1.2\n",
    "print \"Very close correspondence between knee voltage and average voltage\"\n",
    "print \"Germanium\",kge,\"V vs\",round(Vg,3),\"V\"\n",
    "print \"Silicon\",ksi,\"V vs\",round(Vs,3),\"V\"\n",
    "print \"GaAs\",kgaas,\"V vs\",round(Vgs,3),\"V\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## There is a Repeatation of Example 1.2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 1.2(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "dc resistance= 250.0 ohms\n"
     ]
    }
   ],
   "source": [
    "Id=2*(10**(-3))        #in ampere\n",
    "Vd=0.5                 #in volts\n",
    "rd=Vd/Id\n",
    "print \"dc resistance=\",rd,\"ohms\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 1.2(b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "dc resistance 40.0 ohms\n"
     ]
    }
   ],
   "source": [
    "Id=20*(10**(-3))          #in ampere\n",
    "Vd=0.8                    #in volts\n",
    "rd=Vd/Id\n",
    "print \"dc resistance=\",rd,\"ohms\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 1.2(c)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "dc resistance= 10.0 Mohms\n"
     ]
    }
   ],
   "source": [
    "#Id=-Is\n",
    "Id=1*(10**(-6))          #in ampere\n",
    "Vd=-10                    #in volts\n",
    "rd=abs(Vd)/Id\n",
    "rd=rd/(10**(6))\n",
    "print \"dc resistance=\",rd,\"Mohms\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 1.3(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ac resistance= 27.5 ohms\n"
     ]
    }
   ],
   "source": [
    "# drawing tangent at Id=2mA and choosing any random points n the tangent to gwt two set of values of Id and Vd\n",
    "Id1=4*(10**(-3))        #IN ampere\n",
    "Id2=0                   #IN ampere\n",
    "Vd1=0.76                #IN VOLTS\n",
    "Vd2=0.65                #IN VOLTS \n",
    "X=Id1-Id2\n",
    "Y=Vd1-Vd2\n",
    "rd=Y/X\n",
    "print \"ac resistance=\",rd,\"ohms\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 1.3(b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ac resistance= 2.0 ohms\n"
     ]
    }
   ],
   "source": [
    "# drawing tangent at Id=2mA and choosing any random points n the tangent to gwt two set of values of Id and Vd\n",
    "Id1=30*(10**(-3))        #IN ampere\n",
    "Id2=20*(10**(-3))       #IN ampere\n",
    "Vd1=0.80                #IN VOLTS\n",
    "Vd2=0.78               #IN VOLTS \n",
    "X=Id1-Id2\n",
    "Y=Vd1-Vd2\n",
    "rd=Y/X\n",
    "print \"ac resistance=\",rd,\"ohms\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 1.3(c)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Dc resistance= 350.0 ohms exceeds ac resistance= 27.5 ohms\n",
      "Dc resistance= 31.6 ohms exceeds ac resistance= 2 ohms\n"
     ]
    }
   ],
   "source": [
    "#calculating Dc resistance\n",
    "#Case-1\n",
    "Id1=2*(10**(-3))      #in ampere\n",
    "Vd1=0.7               #in volts\n",
    "Rd=Vd1/Id1\n",
    "rd=27.5               #ac resistance in ohms\n",
    "if Rd>rd:\n",
    " print \"Dc resistance=\",Rd,\"ohms exceeds ac resistance=\",rd,\"ohms\"\n",
    "else:\n",
    " print \"Dc resistance=\",Rd,\"ohms didnot exceeds ac resistance=\",rd,\"ohms\"\n",
    "\n",
    "#Case-2\n",
    "Id1=25*(10**(-3))      #in ampere\n",
    "Vd1=0.79               #in volts\n",
    "Rd=Vd1/Id1\n",
    "rd=2                   #ac resistance in ohms\n",
    "if Rd>rd:\n",
    " print \"Dc resistance=\",Rd,\"ohms exceeds ac resistance=\",rd,\"ohms\"\n",
    "else:\n",
    " print \"Dc resistance=\",Rd,\"ohms didnot exceeds ac resistance=\",rd,\"ohms\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 1.4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "New potential across zener diode= 10.54 V\n"
     ]
    }
   ],
   "source": [
    "#Equation- change in Cvz=(Tc*Vz*(t1-t0))/100%\n",
    "Tc=0.072            #unit %/celsius\n",
    "t1=100              #in celsius\n",
    "t0=25               #in celsius\n",
    "Vz=10               #in volts\n",
    "Cvz=(Tc*Vz*(t1-t0))/100\n",
    "nVz=Vz+Cvz          #new Vz\n",
    "print \"New potential across zener diode=\",nVz,\"V\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 1.5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The range of Wavelength for the frequency of Visible lightis 750 nm to 400 nm\n"
     ]
    }
   ],
   "source": [
    "#Equation wavelength(x)=c/f,where c=speed of light and f=frequency of the light\n",
    "c=3*(10**(8))*(10**(9))                #in nm/s\n",
    "x1=(c/(400*(10**12)))                   #in nm\n",
    "x2=c/(750*(10**12))                   #in nm\n",
    "print \"The range of Wavelength for the frequency of Visible lightis\",x1,\"nm to\",x2,\"nm\""
   ]
  }
 ],
 "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"
  },
  "widgets": {
   "state": {},
   "version": "1.1.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}