{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Ch-4 : Semiconductor Diodes"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Page No.  78 Example 4.1."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(i) The intrinsic conductivity for germanium,\n",
      "sigmai(S/cm) = q*ni*(un+up) = 0.02\n",
      "(ii) The intrinsic conductivity for silicon,\n",
      "sigmai(S/cm)= q*ni*(un+np) =4.32e-06\n"
     ]
    }
   ],
   "source": [
    "un1=3800 #mobility of free electrons in pure germanium\n",
    "up1=1800 #mobility of free holes in pure germanium\n",
    "un2=1300 #mobility of free electrons in pure silicon\n",
    "up2=500 #mobility of free holes in pure silicon\n",
    "q=1.6*10**-19\n",
    "nig=2.5*10**13\n",
    "nis=1.5*10**10\n",
    "sigma1=q*nig*(un1+up1)\n",
    "print \"(i) The intrinsic conductivity for germanium,\"\n",
    "print \"sigmai(S/cm) = q*ni*(un+up) = %0.2f\"%sigma1\n",
    "sigma2=q*nis*(un2+up2)\n",
    "print \"(ii) The intrinsic conductivity for silicon,\"\n",
    "print \"sigmai(S/cm)= q*ni*(un+np) =%0.2e\"%sigma2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Page No. 79 Example 4.6."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a) In intrensic condition, n=p=ni\n",
      "Hence, sigma_i = q*ni*(un+up)\n",
      "sigma_i = 4.32e-06 S/cm\n",
      "(b) Number of silicon atoms/cm**3 = 5*10**22\n",
      "Hence, ND = 5.00e+14 cm**-3\n",
      "Further, n = ND\n",
      "Therefore,    p = ni**2/n = ni**2/ND\n",
      "p = 4.50e+05 cm**-3\n",
      "Thus p << n. Hence p may be neglected while calculating the conductivity.\n",
      "Hence,      sigma = n*q*un = ND*q*un\n",
      "sigma = 0.10 S/cm\n",
      "(c) NA = 1.00e+15 cm**-3\n",
      "Further, p = NA\n",
      "Hence,     n = ni**2/p = ni**2/NA\n",
      "n = 2.25e+05 cm**-3\n",
      "Thus p >> n. Hence n may be neglected while calculating the conductivity.\n",
      "Hence,     sigma = p*q*up = NA*q*up\n",
      "sigma = 0.08 S/cm\n",
      "(d) With both types of impurities present simultaneously, the net acceptor impurity density is,\n",
      "Na = 5.00e+14 cm**-3\n",
      "Hence,     sigma = Na*q*up\n",
      "sigma = 0.04 S/cm\n"
     ]
    }
   ],
   "source": [
    "\n",
    "ni=1.5*10**10\n",
    "un=1300\n",
    "up=500\n",
    "q=1.6*10**-19\n",
    "nos=5*10**22\n",
    "print \"(a) In intrensic condition, n=p=ni\"\n",
    "print \"Hence, sigma_i = q*ni*(un+up)\"\n",
    "sigma_i = q*ni*(un+up)\n",
    "print \"sigma_i = %0.2e S/cm\"%sigma_i\n",
    "print \"(b) Number of silicon atoms/cm**3 = 5*10**22\"\n",
    "ND=5*10**22/10**8\n",
    "print \"Hence, ND = %0.2e cm**-3\"%ND\n",
    "print \"Further, n = ND\"\n",
    "print \"Therefore,    p = ni**2/n = ni**2/ND\"\n",
    "p=ni**2/ND\n",
    "print \"p = %0.2e cm**-3\"%p  # wrong answer in textbook\n",
    "print \"Thus p << n. Hence p may be neglected while calculating the conductivity.\"\n",
    "print \"Hence,      sigma = n*q*un = ND*q*un\"\n",
    "sigma=ND*q*un\n",
    "print \"sigma = %0.2f S/cm\"%sigma\n",
    "NA=(5*10**22)/(5*10**7)\n",
    "print \"(c) NA = %0.2e cm**-3\"%NA\n",
    "print \"Further, p = NA\"\n",
    "print \"Hence,     n = ni**2/p = ni**2/NA\"\n",
    "n=ni**2/NA\n",
    "print \"n = %0.2e cm**-3\"%n\n",
    "print \"Thus p >> n. Hence n may be neglected while calculating the conductivity.\"\n",
    "print \"Hence,     sigma = p*q*up = NA*q*up\"\n",
    "sigma1=NA*q*up\n",
    "print \"sigma = %0.2f S/cm\"%sigma1\n",
    "print \"(d) With both types of impurities present simultaneously, the net acceptor impurity density is,\"\n",
    "Na=NA-ND\n",
    "print \"Na = %0.2e cm**-3\"%Na\n",
    "print \"Hence,     sigma = Na*q*up\"\n",
    "sigma2=Na*q*up\n",
    "print \"sigma = %0.2f S/cm\"%sigma2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Page No. 83 Example 4.7."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a) n = p = ni = 2.5*10**13 cm**-3\n",
      "Therefore,  conductivity,  sigma = q*ni*(un+np) =0.02 S/cm\n",
      "Hence,  resistivity   rho = 1 / sigma =44.64 (ohm-cm)\n",
      "\n",
      "(b) ND = 4.40e+15 cm**-3\n",
      "Also, n = ND\n",
      "Therefore,  p = ni**2 / n = ni**2 / ND =142045454545.45 (holes/cm**3)\n",
      "Here, as n >> p, p can be neglected.\n",
      "Therefore,  conductivity,    sigma = n*q*un = ND*q*un =2.68 (S/cm)\n",
      "Hence,  resistivity,    rho = 1 / sigma =0.37 (ohm-cm)\n",
      "\n",
      "(c) NA = 4.40e+14 (cm**-3)\n",
      "Also, p = NA\n",
      "Therefore,  n = ni**2 / p = ni**2 / NA =1420454545454.55 (electrons/cm**3)\n",
      "Here, as p >> n, n may be neglected. Then,\n",
      "Conductivity,    sigma = p*q*up = NA*q*up =0.13 (S/cm)\n",
      "Hence,  resistivity,    rho = 1 / sigma = 7.89 (ohm-cm)\n",
      "\n",
      "(d) with both p and n type impurities present,\n",
      "      ND = 4.4*10**15 cm**-3 and NA = 4.4*10**14 cm**-3\n",
      "Therefore, the net donor density ND'' is\n",
      "ND'' = (ND - NA) =3960000000000000.00 (cm**-3)\n",
      "Therefore, effective n = ND'' = 3.96*10**15 cm**-3\n",
      "p = ni**2 / N''D =157828282828.28 (cm**-3)\n",
      "Here again p(= ni**2 / N''D) is very small compared with N''D and may be neglected in calculating the effective conductivity.\n",
      "Therefore,  conductivity,    sigma = ND''*q*un =2.41 (S/cm)\n",
      "Hence,  resistivity,    rho = 1 / sigma =0.42 (ohm-cm)\n"
     ]
    }
   ],
   "source": [
    "ni=2.5*10**13\n",
    "un=3800\n",
    "up=1800\n",
    "nog=4.4*10**22\n",
    "q=1.6*10**-19\n",
    "sigma=q*ni*(un+up)\n",
    "print \"(a) n = p = ni = 2.5*10**13 cm**-3\"\n",
    "print \"Therefore,  conductivity,  sigma = q*ni*(un+np) =%0.2f S/cm\"%sigma\n",
    "rho=1/sigma\n",
    "print \"Hence,  resistivity   rho = 1 / sigma =%0.2f (ohm-cm)\"%rho\n",
    "ND=(4.4*10**22)/10**7\n",
    "print \"\\n(b) ND = %0.2e cm**-3\"%ND\n",
    "p=ni**2/ND\n",
    "print \"Also, n = ND\"\n",
    "print \"Therefore,  p = ni**2 / n = ni**2 / ND =%0.2f (holes/cm**3)\"%p\n",
    "print \"Here, as n >> p, p can be neglected.\"\n",
    "sigma1=ND*q*un\n",
    "print \"Therefore,  conductivity,    sigma = n*q*un = ND*q*un =%0.2f (S/cm)\"%sigma1\n",
    "rho1=1/sigma1\n",
    "print \"Hence,  resistivity,    rho = 1 / sigma =%0.2f (ohm-cm)\"%rho1\n",
    "\n",
    "NA=(4.4*10**22)/10**8\n",
    "print \"\\n(c) NA = %0.2e (cm**-3)\"%NA\n",
    "print \"Also, p = NA\"\n",
    "n=ni**2/NA\n",
    "print \"Therefore,  n = ni**2 / p = ni**2 / NA =%0.2f (electrons/cm**3)\"%n\n",
    "sigma2=NA*q*up\n",
    "print \"Here, as p >> n, n may be neglected. Then,\"\n",
    "print \"Conductivity,    sigma = p*q*up = NA*q*up =%0.2f (S/cm)\"%sigma2\n",
    "rho2=1/sigma2\n",
    "print \"Hence,  resistivity,    rho = 1 / sigma = %0.2f (ohm-cm)\"%rho2\n",
    "\n",
    "print \"\\n(d) with both p and n type impurities present,\"\n",
    "print \"      ND = 4.4*10**15 cm**-3 and NA = 4.4*10**14 cm**-3\"\n",
    "print \"Therefore, the net donor density ND'' is\"\n",
    "Nd=ND-NA\n",
    "print \"ND'' = (ND - NA) =%0.2f (cm**-3)\"%Nd\n",
    "print \"Therefore, effective n = ND'' = 3.96*10**15 cm**-3\"\n",
    "p1=ni**2/Nd\n",
    "print \"p = ni**2 / N''D =%0.2f (cm**-3)\"%p1\n",
    "print \"Here again p(= ni**2 / N''D) is very small compared with N''D and may be neglected in calculating the effective conductivity.\"\n",
    "sigma3=Nd*q*un\n",
    "print \"Therefore,  conductivity,    sigma = ND''*q*un =%0.2f (S/cm)\"%sigma3\n",
    "rho3=1/sigma3\n",
    "print \"Hence,  resistivity,    rho = 1 / sigma =%0.2f (ohm-cm)\"%rho3"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Page No. 87 Example 4.8"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "sigma_i = qni(un+up) = 1 / 25*10**4\n",
      "\n",
      "Therefore,  ni = sigma_i / q(un+up) =14492753623.19\n",
      "\n",
      "Net donor density,   ND(= n) = 3.00e+10 (cm**-3)\n",
      "Hence,  p = ni**2 / ND =7001330252.75 (cm**-3)\n",
      "Hence,  sigma = q*(n*un + p*up) =0.00\n",
      "Therefore, total conduction current density, J = sigma*E =0.00 A/cm**2\n"
     ]
    }
   ],
   "source": [
    "un=1250\n",
    "up=475\n",
    "q=1.6*10**-19\n",
    "sigma_i=1/(25*10**4)\n",
    "format(9)\n",
    "ni=1/((25*10**4)*(1.6*10**-19)*(1250+475))\n",
    "print \"sigma_i = qni(un+up) = 1 / 25*10**4\"\n",
    "print \"\\nTherefore,  ni = sigma_i / q(un+up) =%0.2f\"%ni\n",
    "\n",
    "ND=(4*10**10)-10**10\n",
    "print \"\\nNet donor density,   ND(= n) = %0.2e (cm**-3)\"%ND\n",
    "p=ni**2/ND\n",
    "print \"Hence,  p = ni**2 / ND =%0.2f (cm**-3)\"%p\n",
    "sigma=(1.6*10**-19)*((1250*3*10**10)+(475*0.7*10**10))\n",
    "print \"Hence,  sigma = q*(n*un + p*up) =%0.2f\"%sigma\n",
    "\n",
    "J=6.532*4*10**-6\n",
    "print \"Therefore, total conduction current density, J = sigma*E =%0.2f A/cm**2\"%J"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Page No. 92 Example 4.9."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a) Concentration in N-type silicon\n",
      "The conductivity of an N-type Silicon is sigma = q*n*un\n",
      "Concentratoin of electrons, n = sigma / q*un =1.44e+18 (cm**-3)\n",
      "Hence,  concentration of holes, p = ni**2 / n =1.56e+02 (cm**-3)\n",
      "(b) Concentration in P-type silicon\n",
      "The conductivity of a P-type Silicon is sigma = q*p*up\n",
      "Hence,  concentratoin of holes, p  = sigma / q*up =3.75e+18 (cm**-3)\n",
      "and concentration of electrons, n = ni**2 / p = 60.00 (cm**-3)\n"
     ]
    }
   ],
   "source": [
    "ni=1.5*10**10\n",
    "un=1300\n",
    "up=500\n",
    "q=1.6*10**-19\n",
    "sigma=300\n",
    "print \"(a) Concentration in N-type silicon\"\n",
    "format(10)\n",
    "n=sigma/(q*un)\n",
    "print \"The conductivity of an N-type Silicon is sigma = q*n*un\"\n",
    "print \"Concentratoin of electrons, n = sigma / q*un =%0.2e (cm**-3)\"%n\n",
    "p=ni**2/n\n",
    "print \"Hence,  concentration of holes, p = ni**2 / n =%0.2e (cm**-3)\"%p\n",
    "print \"(b) Concentration in P-type silicon\"\n",
    "p=sigma/(q*up)\n",
    "print \"The conductivity of a P-type Silicon is sigma = q*p*up\"\n",
    "print \"Hence,  concentratoin of holes, p  = sigma / q*up =%0.2e (cm**-3)\"%p\n",
    "n=ni**2/p\n",
    "print \"and concentration of electrons, n = ni**2 / p = %0.2f (cm**-3)\"%n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Page No. 93 Example 4.10."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Density of added impurity atoms is, ND = 4.20e+22 (atoms/m**3)\n",
      "Also, n = ND\n",
      "Therefore,  p = ni**2 / n = ni**2 / ND =1.49e+16 (m**-3)\n",
      "Here, as p << n, p may be neglected.\n",
      "Therefore,  sigma = q*ND*un =2553.60 (S/m)\n",
      "Therefore,  resistivity, rho = 1 / sigma =0.00 ohm-m\n",
      "Resistance,  R = rho*L / A =78.32 kohm\n",
      "Voltage drop,  V = RI =78.32 mV\n"
     ]
    }
   ],
   "source": [
    "ND=(4.2*10**28)/10**6\n",
    "print \"Density of added impurity atoms is, ND = %0.2e (atoms/m**3)\"%ND\n",
    "ni=2.5*10**19\n",
    "p=ni**2/ND\n",
    "print \"Also, n = ND\"\n",
    "print \"Therefore,  p = ni**2 / n = ni**2 / ND =%0.2e (m**-3)\"%p\n",
    "print \"Here, as p << n, p may be neglected.\"\n",
    "q=1.6*10**-19\n",
    "un=0.38\n",
    "sigma=q*ND*un\n",
    "print \"Therefore,  sigma = q*ND*un =%0.2f (S/m)\"%sigma\n",
    "\n",
    "rho=1/sigma\n",
    "print \"Therefore,  resistivity, rho = 1 / sigma =%0.2f ohm-m\"%rho\n",
    "\n",
    "L=5*10**-3\n",
    "A=5*10**-6\n",
    "R=(rho*L)/A**2\n",
    "R1=R*10**-3\n",
    "print \"Resistance,  R = rho*L / A =%0.2f kohm\"%R1\n",
    "I=10**-6\n",
    "V=R*I\n",
    "V1=V*10**3\n",
    "print \"Voltage drop,  V = RI =%0.2f mV\"%V1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Page No. 94 Example 4.11."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a) Resistivity,  rho = 1 / sigma = 1 / NA*q*up = 6 ohm-cm\n",
      "Therefore,  NA = 1 / 6*q*up =5.79e+14 (1/cm**3)\n",
      "Similarly,  ND(1/cm**3) = 1 / 4*q*un =4.11e+14 (1/cm**3)\n",
      "Therefore, Va = VT*ln(ND*NA / ni**2) = 0.15 V\n",
      "Hence,  Eo = 0.15 eV\n",
      "\n",
      "(b) Vo = 0.026*ln(2*ND*2*NA / ni**2) =0.19 V\n",
      "Therefore,  Eo(eV) = 0.19 eV\n"
     ]
    }
   ],
   "source": [
    "from math import log\n",
    "q=1.6*10**-19\n",
    "ni=2.5*10**13\n",
    "up=1800\n",
    "un=3800\n",
    "VT=0.026\n",
    "rho=6\n",
    "format(9)\n",
    "NA=1/(6*q*up)\n",
    "print \"(a) Resistivity,  rho = 1 / sigma = 1 / NA*q*up = 6 ohm-cm\"\n",
    "print \"Therefore,  NA = 1 / 6*q*up =%0.2e (1/cm**3)\"%NA\n",
    "ND=1/(4*q*un)\n",
    "print \"Similarly,  ND(1/cm**3) = 1 / 4*q*un =%0.2e (1/cm**3)\"%ND\n",
    "Va=VT*log((ND*NA)/ni**2)\n",
    "print \"Therefore, Va = VT*ln(ND*NA / ni**2) = %0.2f V\"%Va\n",
    "print \"Hence,  Eo = %0.2f eV\"%Va\n",
    "Va1=0.026*log((2*ND*2*NA)/ni**2)\n",
    "print \"\\n(b) Vo = 0.026*ln(2*ND*2*NA / ni**2) =%0.2f V\"%Va1\n",
    "print \"Therefore,  Eo(eV) = %0.2f eV\"%Va1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Page No. 97 Example 4.12."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The current flowing through the PN diode under forward bias is,\n",
      "I = Io*(e**40*VF - 1) =120.73 uA\n"
     ]
    }
   ],
   "source": [
    "from math import exp\n",
    "Ia=0.3*10**-6\n",
    "VF=0.15\n",
    "I=Ia*((exp(40*VF))-1)\n",
    "I1=I*10**6\n",
    "print \"The current flowing through the PN diode under forward bias is,\"\n",
    "print \"I = Io*(e**40*VF - 1) =%0.2f uA\"%I1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Page No. 97 Example 4.13."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The volt-equivalent of the temperature(T) is,\n",
      "VT(V) = T / 11600 = 0.03\n",
      "Therefore, the diode current, I = Io*e**((VF/eta*VT)-1) =1.18 A\n"
     ]
    }
   ],
   "source": [
    "from math import exp\n",
    "VF=0.6\n",
    "T=298\n",
    "Io=10**-5\n",
    "eta=2\n",
    "VT=T/11600.0\n",
    "print \"The volt-equivalent of the temperature(T) is,\"\n",
    "print \"VT(V) = T / 11600 = %0.2f\"%VT\n",
    "I=Io*((exp((VF/(eta*VT))))-1)\n",
    "print \"Therefore, the diode current, I = Io*e**((VF/eta*VT)-1) =%0.2f A\"%I"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Page No. 98 Example 4.16."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Forward resistance of a PN junction diode, rf = (eta*VT)/I  where VT = T/11600 and eta = 2 for silicon\n",
      "Therefore,  rf = 2*(T/11600) / 5*10**-3\n",
      "rf = 10.34 ohm\n"
     ]
    }
   ],
   "source": [
    "I=5*10**-3\n",
    "T=300\n",
    "print \"Forward resistance of a PN junction diode, rf = (eta*VT)/I  where VT = T/11600 and eta = 2 for silicon\"\n",
    "print \"Therefore,  rf = 2*(T/11600) / 5*10**-3\"\n",
    "eta=2 #for silicon\n",
    "rf=600/(11600*5*10**-3)\n",
    "print \"rf = %0.2f ohm\"%rf"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Page No. 100 Example 4.17."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The saturation current at 400 K is,\n",
      "Io2 = Io1 * 2**((T2-T1)/10)\n",
      "    = 7.5*10**-6 * 2**(127-27/10)\n",
      "Io2 = 7.68 mA\n"
     ]
    }
   ],
   "source": [
    "Io1=7.5*10**-6\n",
    "T1=27\n",
    "T2=127\n",
    "print \"The saturation current at 400 K is,\"\n",
    "print \"Io2 = Io1 * 2**((T2-T1)/10)\"\n",
    "print \"    = 7.5*10**-6 * 2**(127-27/10)\"\n",
    "Io2=Io1*(2**((T2-T1)/10))\n",
    "I=Io2*10**3\n",
    "print \"Io2 = %0.2f mA\"%I"
   ]
  }
 ],
 "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.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
