{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 2 ENERGY BAND THEORY OF SOLIDS"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 2_1 pgno:49"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "no =  15000000000.0 /cmˆ3\n",
      "n =  1000000000000000000 /cmˆ3\n",
      "number of holes ,p=(noˆ2/n))=  225.0  /cmˆ3\n"
     ]
    }
   ],
   "source": [
    "#exa 2.1\n",
    "no=1.5*10**10\n",
    "print \"no = \",no,\"/cmˆ3\" # initializing value of electrons and hole per cmˆ3.\n",
    "n=1*10**18\n",
    "print \"n = \",n,\"/cmˆ3\" # initializing value of number of electrons per cmˆ3.\n",
    "p=(no**2/n)\n",
    "print \"number of holes ,p=(noˆ2/n))= \",p,\" /cmˆ3\" # calculation\n",
    "#this is solved problem 2.1 of chapter 2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 2_2 pgno:49"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "n =  100000  /cmˆ3\n",
      "p =  10000000000000000000  /cmˆ3\n",
      "Value of intrinsic concentration ,no=sqrt(n∗p))=  1e+12  /cmˆ3\n"
     ]
    }
   ],
   "source": [
    "#exa 2.2\n",
    "from math import sqrt\n",
    "n=1*10**5\n",
    "print\"n = \",n,\" /cmˆ3\" # initializing value of electrons and hole per cmˆ3.\n",
    "p=1*10**19\n",
    "print\"p = \",p,\" /cmˆ3\" # initializing value of number of hole per cmˆ3\n",
    "no=sqrt(n*p)\n",
    "print\"Value of intrinsic concentration ,no=sqrt(n∗p))= \",no,\" /cmˆ3\"# calculation\n",
    "#this is solved problem 2.2 of chapter 2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 2_3 pgno:49"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "e =  1.6e-19 columb\n",
      "Ef−Efi =  0.309  eV\n",
      "no =  2.5e+13  /cmˆ3\n",
      "T =  300  K\n",
      "exp =  2.718\n",
      "k = ”,k,” J/K\n",
      "number of electrons per cmˆ3, n=no∗(exˆ((Ef−Efi)/kT)))=  3.83494867662e+18  /cmˆ3\n"
     ]
    }
   ],
   "source": [
    "#exa 2.3\n",
    "e=1.6*10**-19\n",
    "print\"e = \",e,\"columb\" # initializing the value of electronic charge .\n",
    "Ef_Efi =0.309\n",
    "print\"Ef−Efi = \",Ef_Efi,\" eV\" # initializing the value of difference in the energy levels .\n",
    "no=2.5*10**13\n",
    "print\"no = \",no,\" /cmˆ3\" # initializing value of number of electrons per cmˆ3\n",
    "T=300\n",
    "print\"T = \",T,\" K\" # initializing value of temperature .\n",
    "ex=2.718\n",
    "print\"exp = \",ex # initializing the value of exponential .\n",
    "k=1.38*10**-23\n",
    "print\"k = ”,k,” J/K\" # initializing value of boltzmann constant .\n",
    "n=no*(ex**((Ef_Efi*e)/(k*T)))\n",
    "print\"number of electrons per cmˆ3, n=no∗(exˆ((Ef−Efi)/kT)))= \",n,\" /cmˆ3\" #calculation\n",
    "#This is solved problem 2.3 of chapter 2.\n",
    "#The value used for ”Ef−Efi” in the solution is different than provided in the question .\n",
    "#I have used the value provided in the solution ( i .e Ef Efi =0.309)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 2_4 pgno:50"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "e =  1.6e-19  columb\n",
      "Ef =  0.4065  eV\n",
      "n =  100000000000000000  /cmˆ3\n",
      "T =  300  K\n",
      "exp =  2.718\n",
      "k =  1.38e-23  J/K\n",
      "Number of electrons per cmˆ3, no=n/(exˆ((Ef)/kT) ) )=  15061844796.9  electrons /cmˆ3\n"
     ]
    }
   ],
   "source": [
    "#exa 2.4\n",
    "e=1.6*10**-19\n",
    "print\"e = \",e,\" columb\" # initializing the value of electronic charge .\n",
    "Ef =0.4065\n",
    "print \"Ef = \",Ef,\" eV\" # initializing the value of fermi level .\n",
    "n=10**17\n",
    "print\"n = \",n,\" /cmˆ3\" # initializing value of number of electrons per cmˆ3.\n",
    "T=300\n",
    "print\"T = \",T,\" K\" # initializing value of temperature .\n",
    "ex=2.718\n",
    "print\"exp = \",ex # initializing the value of exponential .\n",
    "k=1.38*10**-23\n",
    "print\"k = \",k,\" J/K\" # initializing value of boltzmann constant .\n",
    "no=n/(ex**((Ef*e)/(k*T)))\n",
    "print\"Number of electrons per cmˆ3, no=n/(exˆ((Ef)/kT) ) )= \",no,\" electrons /cmˆ3\" # calculation\n",
    "#this is solved problem 2.4 of chapter 2.\n",
    "#the value used for \"n\" in the solution is different than provided in the question .\n",
    "#I have used the value provided in the solution ( i .e n=10ˆ17)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 2_5 pgno:50"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "e =  1.6e-19 columb\n",
      "n =  10000000000000000000000  /mˆ3\n",
      "u =  0.12  mˆ2/Vs\n",
      "L =  0.001  m\n",
      "A =  1e-10  mˆ2\n",
      " conductivity , sigma=n∗e∗u)=  192.0 siemen/m\n",
      "Resistivity ,p=(1/sigma))=  0.00520833333333  ohm metre\n",
      " resistance ,R=(p∗L/A) )=  52083.3333333  ohm\n"
     ]
    }
   ],
   "source": [
    "#exa 2.5\n",
    "e=1.6*10**-19\n",
    "print\"e = \",e,\"columb\" # initializing the value of electronic charge .\n",
    "n=1*10**22\n",
    "print\"n = \",n,\" /mˆ3\" # initializing value of number of electrons per cmˆ3\n",
    "u=1200*10**-4\n",
    "print\"u = \",u,\" mˆ2/Vs\" # initializing the value of mobility .\n",
    "L=0.1*10**-2\n",
    "print\"L = \",L,\" m\" # initializing the value of length .\n",
    "A=100*10**-12\n",
    "print\"A = \",A,\" mˆ2\" # initializing the value of area of cross section .\n",
    "sigma=n*e*u\n",
    "print\" conductivity , sigma=n∗e∗u)= \",sigma,\"siemen/m\" # calculation .\n",
    "p=(1/sigma)\n",
    "print\"Resistivity ,p=(1/sigma))= \",p,\" ohm metre\"#calculation .\n",
    "R=(p*L/A)\n",
    "print\" resistance ,R=(p∗L/A) )= \",R,\" ohm\" #calculation .\n",
    "#this is solved problem 2.5 of chapter 2.\n",
    "#the value used for \"A\" in the solution is different than provided in the question .\n",
    "#I have used the value provided in the solution ( i .e A=100∗10ˆ−12)\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 2_6 pgno:50"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "R =  52080.0 ohm\n",
      "V =  5 volt\n",
      " Drift current , I=(V/R) )=  9.60061443932e-05  amphere\n"
     ]
    }
   ],
   "source": [
    "#exa 2.6\n",
    "R=52.08*10**3\n",
    "print\"R = \",R,\"ohm\" # initializing value of Resistance .\n",
    "V=5\n",
    "print\"V = \",V,\"volt\" # initializing value of voltage .\n",
    "I=(V/R)\n",
    "print\" Drift current , I=(V/R) )= \",I,\" amphere\" # calculation\n",
    "#this is solved problem 2.6 of chapter 2."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 2_7 pgno:50"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Energy gap of GaAs =  1.43 eV\n",
      " Energy gap of GaP =  2.43 eV\n",
      " Plank constant =  6.624e-34  joule \n",
      " Light speed =  300000000 m/s\n",
      "Difference between the energy gap of GaAs and GaP ,x=(Eg2−Eg1) )=  1.0  eV\n",
      "Excess energy gap added to GaAs to form GaAsP,(0.4∗x))=  0.4  eV \n",
      "Band gap energy GaAsP,Eg=(Eg1+g))=  1.83  eV \n",
      "wavelength of radiation emitted , lamda=(c∗h/Eg))=  6.7868852459e-07  metre \n"
     ]
    }
   ],
   "source": [
    "#exa 2.7\n",
    "Eg1 =1.43\n",
    "print\" Energy gap of GaAs = \",Eg1,\"eV\" # initializing the value of energy gap of GaAs.\n",
    "Eg2 =2.43\n",
    "print\" Energy gap of GaP = \",Eg2,\"eV\"# initializing the value of energy gap of Gap.\n",
    "h=6.624*10**-34\n",
    "print\" Plank constant = \",h,\" joule \"# initializing the value of plank constant .\n",
    "c=3*10**8\n",
    "print\" Light speed = \",c,\"m/s\" # initializing the value of speed of light.\n",
    "x=(Eg2-Eg1)\n",
    "print\"Difference between the energy gap of GaAs and GaP ,x=(Eg2−Eg1) )= \",x,\" eV\"# calculation\n",
    "g=(0.4*x)\n",
    "print\"Excess energy gap added to GaAs to form GaAsP,(0.4∗x))= \",g,\" eV \"#calculation\n",
    "Eg=(Eg1+g)\n",
    "print\"Band gap energy GaAsP,Eg=(Eg1+g))= \",Eg ,\" eV \"#calculation\n",
    "lamda=(c*h/(Eg*1.6*10**-19))\n",
    "print\"wavelength of radiation emitted , lamda=(c∗h/Eg))= \",lamda,\" metre \"\n",
    "# calculation 19 #this is solved problem 2.7 of chapter 2."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 2_8 pgno:51"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Energy gap of GaAs =  1.43  eV\n",
      " Energy gap of GaP =  2.43  eV\n",
      " Plank constant =  6.624e-34  joule\n",
      " Light speed =  300000000  m/s\n",
      " lamda =  540000000  m\n",
      "Difference between the energy gap of GaAs and GaP ,x=(Eg2−Eg1) )=  1.0  eV\n",
      "Band gap energy ,Eg=(c∗h/lamda∗(1.6∗10ˆ−19)))= 2.3e-15  eV\n",
      "X=Eg−(Eg1)=  -1.43\n"
     ]
    }
   ],
   "source": [
    "#exa 2.8\n",
    "Eg1 =1.43\n",
    "print\" Energy gap of GaAs = \",Eg1,\" eV\" # initializing the value of energy gap of GaAs.\n",
    "Eg2 =2.43\n",
    "print\" Energy gap of GaP = \",Eg2,\" eV\"# initializing the value of energy gap of Gap.\n",
    "h=6.624*10**-34\n",
    "print\" Plank constant = \",h,\" joule\"# initializing the value of plank constant .\n",
    "c=3*10**8\n",
    "print\" Light speed = \",c,\" m/s\" # initializing the value of speed of light.\n",
    "lamda =540*10**6\n",
    "print\" lamda = \",lamda,\" m\" # initializing the value of wavelength .\n",
    "x=(Eg2-Eg1)\n",
    "print\"Difference between the energy gap of GaAs and GaP ,x=(Eg2−Eg1) )= \",x,\" eV\"# calculation\n",
    "Eg=((c*h/(lamda*(1.6*10**-19))))\n",
    "print\"Band gap energy ,Eg=(c∗h/lamda∗(1.6∗10ˆ−19)))=\",Eg,\" eV\"# calculation\n",
    "X=Eg-(Eg1)\n",
    "print\"X=Eg−(Eg1)= \",X  # calculation \n",
    "#this is solved problem 2.8 of chapter 2.\n",
    "#the value of Eg(band gap energy )is provided wrong in the book after calculation.Due to this value ofX,alsodiffer."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 2_9 pgno:51"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Temperature 1 =  500 K\n",
      " Nv =  2e+19 cmˆ−3\n",
      " Temperature 2 =  300 K\n",
      "NV at 500K=(Nv((500/300) ˆ(3/2) ) ) )=  2e+19  cmˆ−3 \n"
     ]
    }
   ],
   "source": [
    "#exa 2.9\n",
    "T1 =500\n",
    "print\" Temperature 1 = \",T1,\"K\" # initializing the value of temperature 1.\n",
    "Nv =2*10**19\n",
    "print\" Nv = \",round(Nv,3),\"cmˆ−3\"# initializing the value of effective density of state for valence band .\n",
    "T2 =300\n",
    "print\" Temperature 2 = \",T2,\"K\"# initializing the value of temperature 2.\n",
    "NV=(Nv*((500/300)**(3/2)))\n",
    "print\"NV at 500K=(Nv((500/300) ˆ(3/2) ) ) )= \",round(NV,3),\" cmˆ−3 \"#calculation\n",
    "#this is solved problem 2.9 of chapter 2."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 2_10 pgno:52"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Nd =  100000000000000000 cmˆ−3\n",
      " Ec Ed =  0.045\n",
      "Vt =  0.0259  eV \n",
      " Nc =  2.8e+19 cmˆ−3\n",
      "exp =  2.718\n",
      "Fraction of electron still in the donor state,(nd/(nd+n)=(((Nc/Nd)∗eˆ((−Ec Ed)/Vt),1)ˆ−1)=  0.0198886296934\n"
     ]
    }
   ],
   "source": [
    "#exa 2.10\n",
    "Nd =1*10**17\n",
    "print\"Nd = \",Nd,\"cmˆ−3\" # initializing the value of effective energy density of state.\n",
    "Ec_Ed =0.045\n",
    "print\" Ec Ed = \",Ec_Ed # initializing the value of donor ionisation level .\n",
    "Vt =0.0259\n",
    "print\"Vt = \",Vt,\" eV \"# initializing the value of thermal voltage .\n",
    "Nc=2.8*10**19\n",
    "print\" Nc = \",Nc,\"cmˆ−3\"# initializing the value of effective density of state of conduction band .\n",
    "e=2.718\n",
    "print\"exp = \",e # initializing the value of exponential .\n",
    "N=(((Nc/Nd)*e**((-(Ec_Ed))/Vt))+1)**-1\n",
    "print \"Fraction of electron still in the donor state,(nd/(nd+n)=(((Nc/Nd)∗eˆ((−Ec Ed)/Vt),1)ˆ−1)= \",N  # calculation\n",
    "#this is solved problem 2.10 of chapter 2."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 2_11 pgno:52"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Na =  10000000000000000  cmˆ−3\n",
      "Ea Ev =  0.045\n",
      "Nv =  1.04e+19  cmˆ−3\n",
      "Vt =  0.0259  eV\n",
      "Fraction of holes that are still in the acceptor state ,(pa/(pa+p))=(1+((Nv/4∗Na)∗exp(−(Ea −Ev)/Vt)))ˆ(−1)=  0.0213895767669\n"
     ]
    }
   ],
   "source": [
    "#exa 2.11\n",
    "from math import exp\n",
    "Na =1*10**16\n",
    "print\"Na = \",Na,\" cmˆ−3\"# initializing the value of acceptor concentration \n",
    "Ea_Ev =0.045\n",
    "print\"Ea Ev = \",Ea_Ev # initializing the boron acceptor ionization energy .\n",
    "Nv=(1.04*10**19)\n",
    "print\"Nv = \",Nv,\" cmˆ−3\"# initializing the value of effective density of state for valence band .\n",
    "Vt=(0.0259)\n",
    "print\"Vt = \",Vt,\" eV\"# initializing the value of thermal voltage .\n",
    "p=(1+((Nv/(4*Na))*exp(-(Ea_Ev)/Vt)))**(-1)\n",
    "print\"Fraction of holes that are still in the acceptor state ,(pa/(pa+p))=(1+((Nv/4∗Na)∗exp(−(Ea −Ev)/Vt)))ˆ(−1)= \",p #calculation\n",
    "#this is solved problem 2.11 of chapter 2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 2_12 pgno:52"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Nd =  100000000000000000  cmˆ−3\n",
      "Na =  0  cmˆ−3\n",
      "ni =  15000000000.0  cmˆ−3\n",
      "Electron concentration ,n=(−(Na−Nd)+sqrt ((Na−Nd)ˆ2+4∗no))/2)=  1e+17  cmˆ−3\n",
      "Hole concentration ,p)=  2250.0  cmˆ−3\n"
     ]
    }
   ],
   "source": [
    "#exa 2.12\n",
    "Nd =1*10**17\n",
    "print\"Nd = \",Nd,\" cmˆ−3\" # initializing the value of donor concentration .\n",
    "Na=0\n",
    "print\"Na = \",Na,\" cmˆ−3\"# initializing the value of acceptor concentration .\n",
    "no=1.5*10**10\n",
    "print\"ni = \",no,\" cmˆ−3\"# initializing the value of electron hole per cmˆ3.\n",
    "n=(-(Na-Nd)+sqrt((Na-Nd)**2+4*no))/2\n",
    "print\"Electron concentration ,n=(−(Na−Nd)+sqrt ((Na−Nd)ˆ2+4∗no))/2)= \",n,\" cmˆ−3\"#calculation\n",
    "p=(no**2/n)\n",
    "print\"Hole concentration ,p)= \",p,\" cmˆ−3\" # calculation\n",
    "#this is solved problem 2.13 of chapter 2."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 2_14 pgno:53"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Nd =  60000000000000000  cmˆ−3\n",
      "Na =  100000000000000000  cmˆ−3\n",
      "no =  15000000000.0  cmˆ−3\n",
      "Hole concentration ,n=(−(Na−Nd)+sqrt ((Na−Nd)ˆ2+4∗no))/2)=  4e+16  cmˆ−3\n",
      "Electron concentration ,n=(noˆ2/p))=  5625.0\n"
     ]
    }
   ],
   "source": [
    "#exa 2.14\n",
    "Nd =6*10**16\n",
    "print\"Nd = \",Nd,\" cmˆ−3\" # initializing the value of donor concentration .\n",
    "Na =10**17\n",
    "print\"Na = \",Na,\" cmˆ−3\"# initializing the value of acceptor concentration .\n",
    "no=1.5*10**10\n",
    "print\"no = \",no,\" cmˆ−3\"# initializing the value of electron and hole per cmˆ3.\n",
    "p=((Na-Nd)+sqrt((Na-Nd)**2+4*no))/2\n",
    "print\"Hole concentration ,n=(−(Na−Nd)+sqrt ((Na−Nd)ˆ2+4∗no))/2)= \",p,\" cmˆ−3\"#calculation\n",
    "n=(no**2/p)\n",
    "print \"Electron concentration ,n=(noˆ2/p))= \",n # calculation\n",
    "#this is solved problem 2.14 of chapter 2.\n",
    "#the value of Na,Nd in the solution is different than provided in the question\n",
    "#I have used the value used in the solution(i.e Na=10ˆ17 ,Nd=6∗10ˆ16)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 2_15 pgno:53"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Nd =  60000000000000000  cmˆ−3\n",
      "Na =  100000000000000000  cmˆ−3\n",
      "no =  15000000000.0  cmˆ−3\n",
      "Hole concentration ,n=(−(Na−Nd)+sqrt ((Na−Nd)ˆ2+4∗no))/2)=  4e+16 cmˆ−3\n",
      "Electron concentration ,n=(noˆ2/p))=  5625.0\n"
     ]
    }
   ],
   "source": [
    "#exa 2.15\n",
    "Nd =6*10**16\n",
    "print\"Nd = \",Nd,\" cmˆ−3\" # initializing the value of donor concentration .\n",
    "Na =10**17\n",
    "print\"Na = \",Na,\" cmˆ−3\"# initializing the value of acceptor concentration .\n",
    "no=1.5*10**10\n",
    "print\"no = \",no,\" cmˆ−3\"# initializing the value of electron and hole per cmˆ3.\n",
    "p=((Na-Nd)+sqrt((Na-Nd)**2+4*no))/2\n",
    "print\"Hole concentration ,n=(−(Na−Nd)+sqrt ((Na−Nd)ˆ2+4∗no))/2)= \",p,\"cmˆ−3\"#calculation\n",
    "n=(no**2/p)\n",
    "print\"Electron concentration ,n=(noˆ2/p))= \",n # calculation\n",
    "#this is solved problem 2.15 of chapter 2.\n",
    "#the value of Na,Nd in the solution is different than provided in the question\n",
    "#I have used the value used in the solution(i.e Na=10ˆ17 ,Nd=6∗10ˆ16)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 2_16 pgno:53"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Nv =  1.04e+19  cmˆ−3\n",
      "Ef Ev =  0.3  eV\n",
      "T =  300 K\n",
      "T =  500 K\n",
      "Vt1 =  0.0259 eV\n",
      "k =  1.38e-23 J/K\n",
      "e =  1.6e-19 columb\n",
      "Value of constant ,K1=(Nv/((T) ˆ(3/2) ) )=  3.46666666667e+16  cmˆ−3 K(−2/3)\n",
      "Value of valence band concentration at 500K,Nv =K1∗T(3/2)=  1.73333333333e+19  cmˆ−3\n",
      "Value of parameter VT at 500K,VT=(K∗T/e)=  0.043125  cmˆ−3\n",
      "Hole concentration ,p=(Nv∗(exp(Ef Ev)/(VT)))=  1.65083278171e+16  cmˆ−3\n"
     ]
    }
   ],
   "source": [
    "#exa 2.16\n",
    "from math import exp\n",
    "Nv1 =1.04*10**19\n",
    "print\"Nv = \",Nv1,\" cmˆ−3\"# initializing the value of valence band concentration at 300K.\n",
    "Ef_Ev =0.3\n",
    "print\"Ef Ev = \",Ef_Ev,\" eV\"# initializing the value of boron acceptor ionization energy.\n",
    "T1 =300\n",
    "print\"T = \",T1,\"K\"# initializing the value of temperature 1.\n",
    "T2 =500\n",
    "print\"T = \",T2,\"K\"# initializing the value of temperature 2.\n",
    "Vt1 =0.0259\n",
    "print\"Vt1 = \",Vt1,\"eV\"# initializing the value of thermal voltage at 300K.\n",
    "k=1.38*10**-23\n",
    "print\"k = \",k,\"J/K\" # initializing value of boltzmann constant .\n",
    "e=1.6*10**-19\n",
    "print\"e = \",e,\"columb\" # initializing the value of electronic charge .\n",
    "K1=(Nv1/((T1)**(3/2)))\n",
    "print\"Value of constant ,K1=(Nv/((T) ˆ(3/2) ) )= \",K1,\" cmˆ−3 K(−2/3)\"# calculation\n",
    "Nv2=K1*T2**(3/2)\n",
    "print\"Value of valence band concentration at 500K,Nv =K1∗T(3/2)= \",Nv2,\" cmˆ−3\"# calculation\n",
    "VT=(k*T2/e)\n",
    "print\"Value of parameter VT at 500K,VT=(K∗T/e)= \",VT,\" cmˆ−3\"# calculation\n",
    "p=(Nv2*(exp(-(Ef_Ev)/(VT))))\n",
    "print\"Hole concentration ,p=(Nv∗(exp(Ef Ev)/(VT)))= \",p,\" cmˆ−3\"# calculation\n",
    "#this is solved problem 2.16 of chapter 2.\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 2_17 pgno:54"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Nv =  7000000000000000000 cmˆ−3\n",
      "Nc =  4.7e+17 cmˆ−3\n",
      "T =  300 K\n",
      "T =  450 K\n",
      "Vt1 =  0.0259 eV\n",
      "Vt2 =  0.03881 eV\n",
      "Eg =  1.42 eV\n",
      "intrinsic concentration at 300K,no=(sqrt(Nc∗Nv∗(exp(−Eg/Vt1))))=  2255422.87974\n",
      "Value of constant ,K1=(Nc/((T) ˆ(3/2) ) )=  1.56666666667e+15\n",
      "Value of constant k1 at 450K ,k1=(K1∗T2ˆ(3/2))=  7.05e+17\n",
      "Value of constant ,K2=(Nv/((T1) ˆ(3/2) ) )=  23333333333333333\n",
      "Value of constant k2 at 450K ,k2=(K2∗T2ˆ(3/2))=  10499999999999999850\n",
      "Value of constant K,=  7.4025e+36\n",
      "intrinsic concentration at 450K,no=(sqrt(K∗(exp(−Eg/Vt2) ) ) )=  30874193378.4  cmˆ3\n"
     ]
    }
   ],
   "source": [
    "#exa 2.17\n",
    "from math import sqrt\n",
    "Nv =7*10**18\n",
    "print\"Nv = \",Nv,\"cmˆ−3\"# initializing the value of valence band concentration at 300K.\n",
    "Nc=4.7*10**17\n",
    "print\"Nc = \",Nc,\"cmˆ−3\"# initializing the value of conduction band concentration at 300K.\n",
    "T1 =300\n",
    "print\"T = \",T1,\"K\"# initializing the value of temperature 1.\n",
    "T2 =450\n",
    "print\"T = \",T2,\"K\"# initializing the value of temperature 2.\n",
    "Vt1 =0.0259\n",
    "print\"Vt1 = \",Vt1,\"eV\"# initializing the value of thermal voltage at 300K.\n",
    "Vt2 =0.03881\n",
    "print\"Vt2 = \",Vt2,\"eV\"# initializing the value of thermal voltage at 450K.\n",
    "Eg=1.42\n",
    "print\"Eg = \",Eg,\"eV\"# initializing the value of thermal voltage .\n",
    "no=(sqrt(Nc*Nv*(exp(-Eg/Vt1))))\n",
    "print\"intrinsic concentration at 300K,no=(sqrt(Nc∗Nv∗(exp(−Eg/Vt1))))= \",no #calculation\n",
    "K1=(Nc/((T1)**(3/2)))\n",
    "print\"Value of constant ,K1=(Nc/((T) ˆ(3/2) ) )= \",K1 # calculation\n",
    "k1=(K1*T2**(3/2))\n",
    "print\"Value of constant k1 at 450K ,k1=(K1∗T2ˆ(3/2))= \",k1# calculation\n",
    "K2=(Nv/((T1)**(3/2)))\n",
    "print\"Value of constant ,K2=(Nv/((T1) ˆ(3/2) ) )= \",K2# calculation\n",
    "k2=(K2*T2**(3/2))\n",
    "print\"Value of constant k2 at 450K ,k2=(K2∗T2ˆ(3/2))= \",k2 # calculation\n",
    "K=k1*k2\n",
    "print\"Value of constant K,= \",K # calculation\n",
    "no1=(sqrt(K*(exp(-Eg/Vt2))))\n",
    "print\"intrinsic concentration at 450K,no=(sqrt(K∗(exp(−Eg/Vt2) ) ) )= \",no1,\" cmˆ3\"# calculation\n",
    "#this is solved problem 2.17 of chapter 2."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 2_18 pgno:55"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Nv =  1.04e+19 cmˆ−3\n",
      "Nc =  2.8e+19 cmˆ−3\n",
      "T =  300 K\n",
      "T =  550 K\n",
      "Vt1 =  0.0259 eV\n",
      "Vt2 =  0.0474 eV\n",
      "Eg1 =  1.12 eV\n",
      "intrinsic concentration at 300K,no=(sqrt(Nc∗Nv∗(exp(−Eg1/Vt1))))=  6949358641.26\n",
      "Value of constant ,K1=(Nc/((T) ˆ(3/2) ) )=  9.3023255814e+16\n",
      "Value of constant k1 at 550K ,k1=(K1∗T2ˆ(3/2))=  5.11627906977e+19\n",
      "Value of constant ,K2=(Nv/((T1) ˆ(3/2) ) )=  3.46666666667e+16\n",
      "Value of constant k2 at 550K ,k2=(K2∗T2ˆ(3/2))=  1.90666666667e+19\n",
      "Value of constant K,=  9.75503875969e+38\n",
      "Intrinsic concentration at 550K,no=(sqrt(K∗(exp(−Eg1/Vt2))))=  2.31051731905e+14  cmˆ3\n",
      "Donor concentration at which intrinsic concentration is 10% of the total electron concentration ,Nd=(4∗(no1ˆ2) /(1.2) )=  1.77949676054e+29  cmˆ3\n"
     ]
    }
   ],
   "source": [
    "#exa 2.18\n",
    "from math import sqrt\n",
    "from math import exp\n",
    "Nv=1.04*10**19\n",
    "print\"Nv = \",Nv,\"cmˆ−3\"# initializing the value of valence band concentration at 300K.\n",
    "Nc=2.8*10**19\n",
    "print\"Nc = \",Nc,\"cmˆ−3\"# initializing the value of conduction band concentration at 300K.\n",
    "T1 =300\n",
    "print\"T = \",T1,\"K\"# initializing the value of temperature 1.\n",
    "T2 =550\n",
    "print\"T = \",T2,\"K\"# initializing the value of temperature 2.\n",
    "Vt1 =0.0259\n",
    "print\"Vt1 = \",Vt1,\"eV\"# initializing the value of thermal voltage at 300K.\n",
    "Vt2 =0.0474\n",
    "print\"Vt2 = \",Vt2,\"eV\"# initializing the value of thermal voltage at 550K.\n",
    "Eg1=1.12\n",
    "print\"Eg1 = \",Eg1,\"eV\"# initializing the value of thermal voltage .\n",
    "no=(sqrt(Nc*Nv*(exp(-Eg1/Vt1))))\n",
    "print\"intrinsic concentration at 300K,no=(sqrt(Nc∗Nv∗(exp(−Eg1/Vt1))))= \",no #calculation\n",
    "K1=(Nc/((T1)^(3/2)))\n",
    "print\"Value of constant ,K1=(Nc/((T) ˆ(3/2) ) )= \",K1  # calculation\n",
    "k1=(K1*T2**(3/2))\n",
    "print\"Value of constant k1 at 550K ,k1=(K1∗T2ˆ(3/2))= \",k1 # calculation \n",
    "K2=(Nv/((T1)**(3/2)))\n",
    "print\"Value of constant ,K2=(Nv/((T1) ˆ(3/2) ) )= \",K2 # calculation\n",
    "k2=(K2*T2**(3/2))\n",
    "print\"Value of constant k2 at 550K ,k2=(K2∗T2ˆ(3/2))= \",k2  # calculation\n",
    "K=k1*k2\n",
    "print\"Value of constant K,= \",K # calculation\n",
    "no1=(sqrt(K*(exp(-Eg1/Vt2))))\n",
    "print\"Intrinsic concentration at 550K,no=(sqrt(K∗(exp(−Eg1/Vt2))))= \",no1,\" cmˆ3\"# calculation\n",
    "Nd=(4*(no1**2)/(1.2))\n",
    "print\"Donor concentration at which intrinsic concentration is 10% of the total electron concentration ,Nd=(4∗(no1ˆ2) /(1.2) )= \",Nd,\" cmˆ3\"# calculation\n",
    "#this is solved problem 2.18 of chapter 2.\n",
    "#the value of temperature and % of the intrinsic carrier concentration given in the question is different than used in the solution .\n",
    "#I have used the value provided in the solution (i.e T2=550 and % of the intrinsic carrier concentration =10%)\n",
    "#the value of Donor concentration at which intrinsic concentration is 10% of the total electron concentration (Nd) , is provided wrong in the book after calculation .\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 2_19 pgno:55"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Ec Ef =  0.2  eV\n",
      "Nc = 2.8e+19  cmˆ−3\n",
      "Na = 30000000000000000  cmˆ−3\n",
      "Vt = 0.0259  eV\n",
      "Donor concentration ,Nd=(Nc∗(exp(−(Ec Ef)/(Vt))) )+(Na)=  4.24031697774e+16  cmˆ−3\n"
     ]
    }
   ],
   "source": [
    "#exa 2.19\n",
    "Ec_Ef =0.2\n",
    "print\"Ec Ef = \",Ec_Ef,\" eV\" # initializing the value of difference in the energy levels.\n",
    "Nc=2.8*10**19\n",
    "print\"Nc =\",Nc,\" cmˆ−3\"# initializing the conduction band concentration .\n",
    "Na =3*10**16\n",
    "print\"Na =\",Na,\" cmˆ−3\"# initializing the acceptor concentration .\n",
    "Vt =0.0259\n",
    "print\"Vt =\",Vt,\" eV\"# initializing the thermal voltage at 300K.\n",
    "Nd=(Nc*(exp(-(Ec_Ef)/(Vt))))+(Na)\n",
    "print\"Donor concentration ,Nd=(Nc∗(exp(−(Ec Ef)/(Vt))) )+(Na)= \",Nd,\" cmˆ−3\"# calculation\n",
    "#this is solved problem 2.19 of chapter 2."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 2_20 pgno:56"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Nv =  6000000000000000000 cmˆ−3\n",
      "Nc =  1.04e+19 cmˆ−3\n",
      "T1 =  300 K\n",
      "T2 =  200 K\n",
      "Vt1 =  0.0259 eV\n",
      "Vt2 =  0.0173 eV\n",
      "Eg1 =  0.6 eV\n",
      "intrinsic concentration at 300K,no=(sqrt(Nc∗Nv∗(exp(−Eg1/Vt1))))=  7.36468677124e+13\n",
      "Eg2 =  0.66 eV\n",
      "Value of constant ,K1=(Nc/((T) ˆ(3/2) ) )=  3.46666666667e+16\n",
      "Value of constant k1 at 200K ,k1=(K1∗T2ˆ(3/2))=  6.93333333333e+18\n",
      "Value of constant ,K2=(Nv/((T1) ˆ(3/2) ) )=  20000000000000000\n",
      "Value of constant k2 at 200K ,k2=(K2∗T2ˆ(3/2))=  4000000000000000000\n",
      "Value of constant K,=  2.77333333333e+37\n",
      "intrinsic concentration at 200K,no=(sqrt(K∗(exp(−Eg2/Vt2))))=  27369762834.6  cmˆ3\n"
     ]
    }
   ],
   "source": [
    "#exa 2.20\n",
    "from math import sqrt\n",
    "from math import exp\n",
    "Nv =6*10**18\n",
    "print\"Nv = \",Nv,\"cmˆ−3\"# initializing the value of valence band concentration at 300K.\n",
    "Nc=1.04*10**19\n",
    "print\"Nc = \",Nc,\"cmˆ−3\"# initializing the value of conduction band concentration at 300K.\n",
    "T1 =300\n",
    "print\"T1 = \",T1,\"K\"# initializing the value of temperature 1.\n",
    "T2 =200\n",
    "print\"T2 = \",T2,\"K\"# initializing the value of temperature 2.\n",
    "Vt1 =0.0259\n",
    "print\"Vt1 = \",Vt1,\"eV\"# initializing the value of thermal voltage at 300K.\n",
    "Vt2 =0.0173\n",
    "print\"Vt2 = \",Vt2,\"eV\"# initializing the value of thermal voltage at 200K.\n",
    "Eg1=0.60\n",
    "print\"Eg1 = \",Eg1,\"eV\"# initializing the value of thermal voltage used for 300K .\n",
    "no=(sqrt(Nc*Nv*(exp(-Eg1/Vt1))))\n",
    "print\"intrinsic concentration at 300K,no=(sqrt(Nc∗Nv∗(exp(−Eg1/Vt1))))= \",no  #calculation\n",
    "Eg2=0.66\n",
    "print\"Eg2 = \",Eg2,\"eV\"# initializing the value of thermal voltage used for 200K.\n",
    "K1=(Nc/((T1)**(3/2)))\n",
    "print\"Value of constant ,K1=(Nc/((T) ˆ(3/2) ) )= \",K1  # calculation\n",
    "k1=(K1*T2**(3/2))\n",
    "print\"Value of constant k1 at 200K ,k1=(K1∗T2ˆ(3/2))= \",k1 # calculation\n",
    "K2=(Nv/((T1)**(3/2)))\n",
    "print\"Value of constant ,K2=(Nv/((T1) ˆ(3/2) ) )= \",K2 # calculation\n",
    "k2=(K2*T2**(3/2))\n",
    "print\"Value of constant k2 at 200K ,k2=(K2∗T2ˆ(3/2))= \",k2 # calculation\n",
    "K=k1*k2\n",
    "print\"Value of constant K,= \",K # calculation\n",
    "no1=(sqrt(K*(exp(-Eg2/Vt2))))\n",
    "print\"intrinsic concentration at 200K,no=(sqrt(K∗(exp(−Eg2/Vt2))))= \",round(no1,2),\" cmˆ3\"# calculation\n",
    "#this is solved problem 2.20 of chapter 2.\n",
    "#The answer of intrinsic concentration at 300K,(no) is provided wrong in the book."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 2_21 pgno:56"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Eg1 =  2  eV\n",
      "Eg2 =  2.2  eV\n",
      "Vt =  0.0259  eV\n",
      "Ratio of their intrinsic concentration at 300K,(no1/no2)=sqrt(exp((−Eg1/Vt)−(−Eg2/Vt)))=  47.5130239084\n"
     ]
    }
   ],
   "source": [
    "#exa 2.21\n",
    "Eg1=2\n",
    "print\"Eg1 = \",Eg1,\" eV\" # initializing the value of band energy gap for semiconductor1.\n",
    "Eg2 =2.2\n",
    "print\"Eg2 = \",Eg2,\" eV\"# initializing the value of band energy gap for semiconductor2.\n",
    "Vt =0.0259\n",
    "print\"Vt = \",Vt,\" eV\"# initializing the value of thermal voltage at 300K.\n",
    "No=sqrt(exp((-Eg1/Vt)-(-Eg2/Vt)))\n",
    "print\"Ratio of their intrinsic concentration at 300K,(no1/no2)=sqrt(exp((−Eg1/Vt)−(−Eg2/Vt)))= \",No  # calculation"
   ]
  }
 ],
 "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.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
