{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 1 - Semiconductor Material & Junction Diode"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 1.1 Page No 51"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The electron drift velocity = 40.00 m/s\n",
      "The time required for an electron to move across the thickness = 12.50 micro seconds\n"
     ]
    }
   ],
   "source": [
    "# Given data\n",
    "miu = 0.2# m**2/V-s\n",
    "V = 100# mV\n",
    "V = V * 10**-3# V\n",
    "d = 0.5# mm\n",
    "d = d * 10**-3# m\n",
    "# mobility, miu = Vd/E and\n",
    "E = V/d\n",
    "# Drift velocity,\n",
    "Vd = miu*E# m/s\n",
    "print \"The electron drift velocity = %.2f m/s\"%Vd\n",
    "# Time required,\n",
    "T = d/Vd# sec\n",
    "T=T*10**6# µs\n",
    "print \"The time required for an electron to move across the thickness = %.2f micro seconds\"%T"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 1.2 Page No 52"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The intrinsic conductivity = 2.24 (ohm-m)**-1\n"
     ]
    }
   ],
   "source": [
    "# Given data\n",
    "q = 1.6*10**-19# C\n",
    "n_i = 2.5*10**19# /m**3\n",
    "miu_n = 0.38# m**2/V-s\n",
    "miu_p = 0.18# m**2/V-s\n",
    "# The intrinsic conductivity for germanium,\n",
    "sigma_i = q*n_i*(miu_n+miu_p)# (ohm-m)**-1\n",
    "print \"The intrinsic conductivity = %.2f (ohm-m)**-1\"%sigma_i"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 1.3 Page No 52"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The intrinsic carrier concentration = 2.16e+19 per m**3\n"
     ]
    }
   ],
   "source": [
    "# Given data\n",
    "rho = 0.50# ohm-m\n",
    "q = 1.6*10**-19# C\n",
    "miu_n = 0.39# m**2/V-s\n",
    "miu_p = 0.19# m**2/V-s\n",
    "sigma = 1/rho# (ohm-m)**-1\n",
    "#conductivity of a semiconductor, sigma = q*n_i*(miu_p+miu_n) or\n",
    "n_i = sigma/(q*(miu_n+miu_p))# /m**3\n",
    "print \"The intrinsic carrier concentration = %.2e per m**3\"%n_i"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 1.4 Page No 52"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The conductivity of Si sample = 14.40 (ohm-m)**-1\n"
     ]
    }
   ],
   "source": [
    "# Given data\n",
    "N_D = 10**21# /m**3\n",
    "N_A = 5*10**20# /m**3\n",
    "NdasD = N_D-N_A# /m**3\n",
    "n = NdasD# /m**3\n",
    "miu_n = 0.18# m**2/V-s\n",
    "q = 1.6*10**-19# C\n",
    "# The conductivity of silicon,\n",
    "sigma = q*n*miu_n# (ohm-m)**-1\n",
    "print \"The conductivity of Si sample = %.2f (ohm-m)**-1\"%sigma"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 1.5 Page No 53"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The conductivity of copper = 4.79e+05 mho/cm\n"
     ]
    }
   ],
   "source": [
    "# Given data\n",
    "At = 63.54## atomic weight of copper\n",
    "d = 8.9## density = %.2f gm/cm**3\n",
    "n = 6.023*10**23/At*d# electron/cm**3\n",
    "q = 1.63*10**-19# C\n",
    "miu = 34.8# m**2/V-s\n",
    "# The conductivity of copper,\n",
    "sigma = n*q*miu# mho/cm\n",
    "print \"The conductivity of copper = %.2e mho/cm\"%sigma"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 1.6 Page No 53"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Concentration of holes in a p-type Ge = 3.47e+17 /cm**3\n",
      "The concentration of electrons in a p-type Ge = 1.80e+09 /cm**3\n",
      "The concentration of electrons in n-type Si = 4.81e+14 /cm**3\n",
      "The concentration of holes in n-type Si = 4.68e+05 /cm**3\n"
     ]
    }
   ],
   "source": [
    "# Given data\n",
    "sigma = 100# (ohm-m)**-1\n",
    "n_i = 2.5*10**13# /cm**3\n",
    "miu_n = 3800# cm**2/V-s\n",
    "miu_p = 1800# cm**2/V-s\n",
    "q = 1.6*10**-19# C\n",
    "# Conductivity of a p-type germanium, sigma = q*p*miu_p or\n",
    "p = sigma/(q*miu_p)# /cm**3\n",
    "print \"Concentration of holes in a p-type Ge = %.2e /cm**3\"%p\n",
    "# The concentration of electrons = %.2f a p-type Ge\n",
    "n = (n_i**2)/p# /cm**3\n",
    "print \"The concentration of electrons in a p-type Ge = %.2e /cm**3\"%n\n",
    "#Given for Si\n",
    "sigma= 0.1# (ohm m)**-1\n",
    "miu_n= 1300# cm**2/V-sec\n",
    "n_i= 1.5*10**10# /cm**3\n",
    "#sigma = q*n*miu_n\n",
    "n = sigma/(q*miu_n)# /cm**3\n",
    "print \"The concentration of electrons in n-type Si = %.2e /cm**3\"%n\n",
    "# The concentration of holes = %.2f n-type Si\n",
    "p = (n_i**2)/n# /cm**3\n",
    "print \"The concentration of holes in n-type Si = %.2e /cm**3\"%p"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 1.7 Page No 54"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The resistivity of a dopped Ge = 3.72 ohm-cm\n"
     ]
    }
   ],
   "source": [
    "# Given data\n",
    "miu_n = 3800## cm**2/V-s\n",
    "miu_p = 1800##  cm**2/V-s\n",
    "n_i = 2.5*10**13# /cm**3\n",
    "Nge = 4.41*10**22# /cm**3\n",
    "q = 1.602*10**-19# C\n",
    "impurity = 10**8\n",
    "# The number of donor atoms,\n",
    "N_D = Nge/impurity##in /cm**3\n",
    "# The number of holes\n",
    "p = (n_i**2)/N_D# /cm**3\n",
    "# Conductivity of an N-type Ge,\n",
    "sigma = q*N_D*miu_n# (ohm-cm)**-1\n",
    "# The resistivity of the Ge\n",
    "rho = 1/sigma# ohm-cm\n",
    "print \"The resistivity of a dopped Ge = %.2f ohm-cm\"% rho"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 1.8 Page No 54"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The resistivity of intrinsic silicon = 2.25e+05 ohm-cm\n",
      "The resistivity of doped silicon = 4.67 ohm-cm\n"
     ]
    }
   ],
   "source": [
    "# Given data\n",
    "Nsi = 4.96*10**22# /cm**3\n",
    "n_i = 1.52*10**10# /cm**2\n",
    "q = 1.6*10**-19# C\n",
    "miu_n = 0.135#  m**2/V-s\n",
    "miu_n = miu_n * 10**4#  cm**2/V-s\n",
    "miu_p = 0.048#  m**2/V-s\n",
    "miu_p = miu_p * 10**4#  cm**2/V-s\n",
    "# The conductivity of an intrinsic silicon,\n",
    "sigma = q*n_i*(miu_n+miu_p)# (ohm-cm)**-1\n",
    "# The resistivity of intrinsic silicon \n",
    "rho = 1/sigma# ohm-cm\n",
    "print \"The resistivity of intrinsic silicon = %.2e ohm-cm\"%rho\n",
    "\n",
    "impurity = 50*10**6\n",
    "# The number of donor atoms,\n",
    "N_D = Nsi/impurity# /cm**3\n",
    "# Total free electrons,\n",
    "n = N_D# /cm**3\n",
    "# Total holes = %.2f a doped Si,\n",
    "p = (n_i**2)/n# /cm**3\n",
    "# Conductivity of a doped Si,\n",
    "sigma = q*n*miu_n# (ohm-m)**-1\n",
    "# The resistivity of doped silicon\n",
    "rho = 1/sigma# ohm-cm\n",
    "print \"The resistivity of doped silicon = %.2f ohm-cm\"%rho"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 1.9 Page No 55"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The value of temperature = 0.14 K\n"
     ]
    }
   ],
   "source": [
    "# Given data\n",
    "N_D= 5.0*10**28/(2.0*10**8)\n",
    "# The Fermi level, E_F= E_C if,\n",
    "N_C= N_D\n",
    "# Formula N_C= 4.82*10**21*T**(3/2)\n",
    "T= (N_C/(4.82*10**21.0))**(2.0/3)# K\n",
    "print \"The value of temperature = %.2f K\"%T"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 1.10 Page No 55"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The miniority carrier concentration = 0.10 m**2/V-s\n",
      "The resistivity = 0.60 ohm-m\n",
      "The position of Fermi level = 0.23 eV\n",
      "Minority carrier concentration = 9.00e+12 atoms/cm**3\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "# Given data\n",
    "n_i = 1.5*10**16##m**3\n",
    "impurity = 10**20\n",
    "minority = (n_i**2)/impurity# atoms/m**3\n",
    "q = 1.6*10**-19# C\n",
    "rho = 2*10**3# ohm-m\n",
    "# The miniority carrier concentration \n",
    "miu_n = 1/(q*rho*n_i*2)##in m**2/V-s\n",
    "print \"The miniority carrier concentration = %.2f m**2/V-s\"%miu_n\n",
    "n = impurity\n",
    "# The conductivity,\n",
    "sigma = q*impurity*miu_n# (ohm-m)**-1\n",
    "# The resistivity \n",
    "rho = 1/sigma#  ohm-m\n",
    "print \"The resistivity = %.2f ohm-m\"%rho\n",
    "kT = 0.026# eV\n",
    "n_o = n\n",
    "# The position of Fermi level \n",
    "E_FdividedEi = kT*math.log(n_o/n_i)# eV\n",
    "print \"The position of Fermi level = %.2f eV\"%E_FdividedEi\n",
    "# Minority carrier concentration \n",
    "M = ((n_i*2)**2)/n_o# atoms/cm**3\n",
    "print \"Minority carrier concentration = %.2e atoms/cm**3\"%M"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 1.11 Page No 56"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The resistivity = 9.62 ohm-cm\n"
     ]
    }
   ],
   "source": [
    "# Given data\n",
    "d = 5.0*10**22# atoms/cm**3\n",
    "impurity = 10**8# atoms\n",
    "N_D = d/impurity\n",
    "n_i = 1.45*10**10\n",
    "n = N_D\n",
    "#Low of mass action,  n*p = (n_i**2)\n",
    "p = (n_i**2)/n# /cm**3\n",
    "q = 1.6*10**-19# C\n",
    "miu_n = 1300# cm/V-s\n",
    "n_i = n\n",
    "#The Conductivity\n",
    "sigma = q*miu_n*n_i# (ohm-cm)**-1\n",
    "# The resistivity\n",
    "rho = 1/sigma# ohm-cm\n",
    "print \"The resistivity = %.2f ohm-cm\"%rho"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 1.12 Page No 57"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The resistivity = 9.62 ohm-cm\n"
     ]
    }
   ],
   "source": [
    "# Given data\n",
    "d = 5.0*10**22# atoms/cm**3\n",
    "impurity = 10**8# atoms\n",
    "N_D = d/impurity\n",
    "n_i = 1.45*10**10\n",
    "n = N_D\n",
    "#Low of mass action,  n*p = (n_i**2)\n",
    "p = (n_i**2)/n# /cm**3\n",
    "q = 1.6*10**-19# C\n",
    "miu_n = 1300# cm/V-s\n",
    "n_i = n\n",
    "#The Conductivity\n",
    "sigma = q*miu_n*n_i# (ohm-cm)**-1\n",
    "# The resistivity\n",
    "rho = 1/sigma# ohm-cm\n",
    "print \"The resistivity = %.2f ohm-cm\"%rho"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 1.14 Page No 58"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The minority carrier concentration = 2.25e+03 holes/cm**3\n",
      "The location of Fermi level = 0.409 eV\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "# Given data\n",
    "n_i = 1.5*10**10# electrons/cm**3\n",
    "N_D = 10**17# electrons/cm**3\n",
    "n = N_D# electrons/cm**3\n",
    "# The minority carrier concentration\n",
    "p = (n_i**2)/n# holes/cm**3\n",
    "print \"The minority carrier concentration = %.2e holes/cm**3\"%p\n",
    "kT = 0.026\n",
    "# The location of Fermi level \n",
    "E_FminusEi = kT*math.log(N_D/n_i)# eV\n",
    "print \"The location of Fermi level = %.3f eV\"%E_FminusEi"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 1.15 Page No 59"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The doping level = 1.92e+15 /cm**3\n",
      "The drift velocity = 650.00 cm/sec\n"
     ]
    }
   ],
   "source": [
    "# Given data\n",
    "V = 1# V\n",
    "I = 8# mA\n",
    "I = I * 10**-3# A\n",
    "R = V/I# ohm\n",
    "l = 2# mm\n",
    "l = l * 10**-1# cm\n",
    "b = 2# mm\n",
    "b = b * 10**-1# cm\n",
    "A = l*b# cm**2\n",
    "L = 2# cm\n",
    "# R = (rho*L)/A\n",
    "sigma = L/(R*A)# (ohm-cm)**-1\n",
    "# n = N_D\n",
    "miu_n = 1300# cm**2/V-s\n",
    "q = 1.6 * 10**-19# C\n",
    "# sigma = n*q*miu_n\n",
    "N_D = sigma/( miu_n*q )# /cm**3\n",
    "print \"The doping level = %.2e /cm**3\"%N_D\n",
    "d = 2.0\n",
    "E = V/d\n",
    "# The drift velocity \n",
    "Vd = miu_n * E# cm/s\n",
    "print \"The drift velocity = %.2f cm/sec\"%Vd"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 1.17 Page No 60"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The conductivity = 4.68e+05 mho/m\n",
      "The mobility = 3.48e-05 m**2/V-s\n",
      "The drift velocity = 1.79e-04 m/s\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "# Given data\n",
    "l = 1000# ft\n",
    "l = l * 12*2.54# cm\n",
    "R = 6.51# ohm\n",
    "rho = R/l# ohm/cm\n",
    "# The conductivity \n",
    "sigma = 1/rho# mho/cm\n",
    "sigma = sigma * 10**2# mho/m\n",
    "D= 1.03*10**-3# m\n",
    "A= math.pi*D**2/4# m**2\n",
    "print \"The conductivity = %.2e mho/m\"%sigma\n",
    "q = 1.6*10**-19# C\n",
    "n = 8.4*10**28# electrons/m**3\n",
    "# sigma = n*q*miu\n",
    "miu = sigma/(n*q)# m**2/V-s\n",
    "print \"The mobility = %.2e m**2/V-s\"%miu\n",
    "T = 2\n",
    "# The drift velocity \n",
    "V = T/(n*q*A)# m/s\n",
    "print \"The drift velocity = %.2e m/s\"%V"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 1.18 Page No 61"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The concentration of holes = 1.50e+16 /cm**3\n",
      "The concentartion of electrons = 6.67e+07 /cm**3\n"
     ]
    }
   ],
   "source": [
    "# Given data\n",
    "N_D = 2*10**16# /cm**3\n",
    "N_A = 5*10**15# /cm**3\n",
    "# The concentration of holes \n",
    "Pp = N_D-N_A# /cm**3\n",
    "print \"The concentration of holes = %.2e /cm**3\"%Pp\n",
    "n_i = 10**12\n",
    "# The concentartion of electrons \n",
    "n_p = (n_i**2)/Pp# /cm**3\n",
    "print \"The concentartion of electrons = %.2e /cm**3\"%n_p"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 1.19 Page No 62"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The hall angle = 1.95 degree\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "# Given data\n",
    "rho = 0.005# ohm-m\n",
    "Bz = 0.48# Wb/m**2\n",
    "R_H = 3.55*10**-4# m**3/C\n",
    "ExByJx= rho\n",
    "# R_H = Ey/(Bz*Jx)\n",
    "EyByJx= R_H*Bz\n",
    "# The hall angle \n",
    "theta_H = math.degrees(math.atan(EyByJx/ExByJx))# °\n",
    "print \"The hall angle = %.2f degree\"%theta_H"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 1.20 Page No 63"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The voltage between contacts = 0.0026 V\n"
     ]
    }
   ],
   "source": [
    "# Given data\n",
    "R_H = 3.55 * 10**-4# m**3/C\n",
    "Ix = 15# mA\n",
    "Ix = Ix * 10**-3# A\n",
    "A = 15*1# mm\n",
    "A = A * 10**-6# m**2\n",
    "Bz = 0.48# Wb/m**2\n",
    "Jx = Ix/A# A/m**2\n",
    "# R_H = Ey/(Bz*Jx)\n",
    "Ey = R_H*Bz*Jx# V/m\n",
    "# voltage between contacts \n",
    "Voltage = Ey*Ix# V\n",
    "print \"The voltage between contacts = %.4f V\"%Voltage"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 1.21 Page No 63"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The concentration of donor atoms = 4.630e+13 cm**-3\n"
     ]
    }
   ],
   "source": [
    "# Given data\n",
    "A = 0.001# cm**2\n",
    "l = 20# µm\n",
    "l = l * 10**-4# cm\n",
    "V = 20# V\n",
    "I = 100# mA\n",
    "I = I * 10**-3# A\n",
    "R = V/I# ohm\n",
    "# R = l/(sigma*A)\n",
    "sigma = l/(R*A)# (ohm-cm)**-1\n",
    "miu_n = 1350# cm**2/V-s\n",
    "q = 1.6*10**-19# C\n",
    "# sigma = n*q*miu_n or\n",
    "# The concentration of donor atoms \n",
    "n = sigma/(q*miu_n)# cm**-3\n",
    "print \"The concentration of donor atoms = %.3e cm**-3\"%n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 1.22 Page No 64"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The doping needed = 8.681e+15 cm**-3\n"
     ]
    }
   ],
   "source": [
    "# Given data\n",
    "R = 2# k ohm\n",
    "R = R * 10**3# ohm\n",
    "L = 200# µm\n",
    "L = L * 10**-4# cm\n",
    "A = 10**-6# cm**2\n",
    "miu_n = 8000# cm**2/V-s\n",
    "q = 1.6*10**-19# C\n",
    "n = '0.9*N_D'\n",
    "# R = (rho*l)/A= (1/(n*q*miu_n))*(l/A)\n",
    "# rho = L/(R*q*miu_n*A)\n",
    "n = L/(R*q*miu_n*A)# /cm**-3\n",
    "# The doping needed \n",
    "Nd= n/0.9\n",
    "print \"The doping needed = %.3e cm**-3\"%Nd"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 1.23 Page No 65"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The position of the Fermi level = 0.29 eV\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "# Given data\n",
    "KT = 26*10**-3\n",
    "Nd = 10**15\n",
    "n_i = 1.5*10**10\n",
    "# The position of the Fermi level \n",
    "E_FminusE_Fi = KT*math.log(abs( Nd/n_i ))# eV\n",
    "print \"The position of the Fermi level = %.2f eV\"%E_FminusE_Fi"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 1.24 Page No 65"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The concentration of donors atoms = 1.2176e+16 cm**-3\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "# Given data\n",
    "Na = 5 * 10**15# cm**-3\n",
    "Nc = 2.8 * 10**19# cm**-3\n",
    "E_CminusE_F = 0.215# eV\n",
    "KT = 26* 10**-3# eV\n",
    "# The concentration of donors atoms \n",
    "Nd = Na + Nc * (math.exp( -E_CminusE_F/KT ))# cm**-3\n",
    "print \"The concentration of donors atoms = %.4e cm**-3\"%Nd"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 1.25 Page No 65"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The percentage doping efficiency = 78.12 %\n"
     ]
    }
   ],
   "source": [
    "# Given data\n",
    "Nd = 10**18\n",
    "R = 10# ohm\n",
    "A =10**-6# cm**2\n",
    "L = 10# mm\n",
    "L = L * 10**-4# cm\n",
    "miu_n = 800# cm**2/V-s\n",
    "q = 1.6*10**-19# C\n",
    "#Formula used, n = L/(q*miu_n*A*R)\n",
    "n = L/(q*miu_n*A*R)# cm**-3\n",
    "# The percentage doping efficiency \n",
    "doping = (n/Nd)*100## % doping efficiency in %\n",
    "print \"The percentage doping efficiency = %.2f %%\"%doping"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 1.26 Page No 66"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The current through the diode under forward bias = 10.72 µA\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "# Given data\n",
    "Io = 2*10**-7# A\n",
    "V = 0.1# V\n",
    "# Current through the diode under forward bias,\n",
    "I = Io*( (math.exp(40*V))-1 )# A\n",
    "I = I * 10**6# µA\n",
    "print \"The current through the diode under forward bias = %.2f µA\"%I\n",
    "\n",
    "# Note: Calculated value of I in the book is wrong."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 1.28 Page No 67"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The dynamic resistance in forward direction = 3.36 ohm\n",
      "The dynamic resistance in reverse direction = 0.39 Mohm\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "# Given data\n",
    "T = 125.0# degree C\n",
    "T = T + 273.0# K\n",
    "V_T = T/11600.0\n",
    "Io = 30# µA\n",
    "Io = Io * 10**-6# A\n",
    "V = 0.2# V\n",
    "# The dynamic resistance = %.2f forward direction,\n",
    "r_f = V_T/( Io * (math.exp(V/V_T)) )# ohm\n",
    "print \"The dynamic resistance in forward direction = %.2f ohm\"%r_f\n",
    "r_f = V_T/( Io * (math.exp(-V/V_T)) )# ohm\n",
    "# The dynamic resistance = %.2f reverse direction \n",
    "r_f = r_f * 10**-6# Mohm\n",
    "print \"The dynamic resistance in reverse direction = %.2f Mohm\"%r_f"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 1.29 Page No 68"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The voltage = -59.87 mV\n",
      "The ratio of diode current with a forward bias to current with a reverse bias = -6.842\n",
      "The value of I1 = 458.13 µA\n",
      "The value of I2 = 21.90 mA\n",
      "The value of I3 = 1.03 A\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "# Given data\n",
    "Eta = 1\n",
    "V_T = 0.026\n",
    "# I = Io*( (exp(V/(Eta*V_T))) - 1 ) and  I = -Io\n",
    "# I = -0.9*Io\n",
    "# -0.9*Io = Io*( (exp(V/(Eta*V_T))) - 1 )\n",
    "V = Eta*V_T*math.log(0.1)# V\n",
    "V = V * 10**3# mV\n",
    "print \"The voltage = %.2f mV\"%V\n",
    "V = 0.05# V\n",
    "# The ratio of diode current with a forward bias to current with a reverse bias \n",
    "If_by_Ir= ( (math.exp(V/V_T))-1 )/( (math.exp(-V/V_T))-1 )\n",
    "print \"The ratio of diode current with a forward bias to current with a reverse bias = %.3f\"%If_by_Ir\n",
    "Io = 10# µA\n",
    "V = 0.1# V\n",
    "# The value of I1 \n",
    "I1 = Io*( (math.exp(V/V_T))-1 )# µA\n",
    "print \"The value of I1 = %.2f µA\"%I1\n",
    "V = 0.2# V\n",
    "# The value of I2\n",
    "I2 = Io*( (math.exp(V/V_T))-1 )# µA \n",
    "I2 = I2 * 10**-3# mA\n",
    "print \"The value of I2 = %.2f mA\"%I2\n",
    "V = 0.3# V\n",
    "# The value of I3\n",
    "I3 = Io*( (math.exp(V/V_T))-1 )# µA\n",
    "I3 = I3 * 10**-6# A\n",
    "print \"The value of I3 = %.2f A\"%I3"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 1.30 Page No 69"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The factor  by which current will get multiplied = 638.025\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "# Given data\n",
    "# Io150 = Io25 * 2**((150-25)/10)\n",
    "#Io150 = 5800*Io25\n",
    "T = 150# degree C\n",
    "T = T  + 273# K\n",
    "V_T = 8.62*10**-5 * T# V\n",
    "V = 0.4# V\n",
    "Eta = 2\n",
    "Vt = 0.026# V \n",
    "# The factor  by which current will get multiplied \n",
    "I150byI25= 5800*math.exp(V/(Eta*V_T))/math.exp(V/(Eta*Vt))\n",
    "print \"The factor  by which current will get multiplied = %.3f\"%I150byI25"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 1.31 Page No 69"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The operating point of the diode is : (0.50V,4.50mA)\n"
     ]
    }
   ],
   "source": [
    "# Given data\n",
    "R = 1# ohm\n",
    "V = 5# V\n",
    "V1 = 0.5# V\n",
    "R1 = 1# k ohm\n",
    "R1 = R1 * 10**3# ohm\n",
    "# V-(I_D*R1)-(I_D*R) - V1 = 0\n",
    "I_D = (V-V1)/(R1+R)# A\n",
    "I_D = I_D * 10**3# mA\n",
    "V_D = (I_D*10**-3*R) + V1# V\n",
    "print \"The operating point of the diode is : (%.2fV,%.2fmA)\"%(V_D,I_D)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 1.32 Page No 70"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The voltage drop across the forward biased diode, = 0.0180 V\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "# Given data\n",
    "Eta = 1\n",
    "kT = 26# meV\n",
    "# (%e**((e*V1)/kT)) = 2 or\n",
    "#The voltage drop across the forward biased diode\n",
    "V1 = math.log(2)*kT# mV\n",
    "V1= V1*10**-3# V\n",
    "print \"The voltage drop across the forward biased diode, = %.4f V\"%V1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 1.33 Page No 71"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The space charge capacitance = 70.74 pF\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "# Given data\n",
    "epsilon_Ge = 16/(36*math.pi*10**11)# F/cm\n",
    "d = 2*10**-4# cm\n",
    "A = 1# mm**2\n",
    "A = A * 10**-2# cm**2\n",
    "epsilon_o = epsilon_Ge# F/cm\n",
    "# The space charge capacitance \n",
    "C_T = (epsilon_o*A)/d# F\n",
    "C_T = C_T * 10**12# pF\n",
    "print \"The space charge capacitance = %.2f pF\"%C_T"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 1.34 Page No 71"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The value of C_T = 61.68 pf/cm**2\n"
     ]
    }
   ],
   "source": [
    "import math \n",
    "# Given data\n",
    "D = 0.102# cm \n",
    "A = (math.pi*(D**2))/4# cm**2\n",
    "sigma_p = 0.286# (ohm-cm)**-1\n",
    "q = 1.6*10**-19# C\n",
    "miu_p = 500\n",
    "# Formula used, sigma_p = q*miu_p*N_A\n",
    "N_A = sigma_p/(q*miu_p)# atoms/cm**3\n",
    "V1 = 5# V\n",
    "V2 = 0.35# V\n",
    "Vb = V1+V2# V\n",
    "# The transition capacitance,\n",
    "C_T = 2.92*10**-4*((N_A/Vb)**(1./2))*A# pF/cm**2\n",
    "print \"The value of C_T = %.2f pf/cm**2\"%C_T"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 1.35 Page No 71"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The value of C_T for reverse bias = 15.00 pF\n"
     ]
    }
   ],
   "source": [
    "# Given data\n",
    "C_T1 = 15# pF\n",
    "Vb1 = 8# V\n",
    "Vb2 = 12# V\n",
    "# C_T1/C_T2 = (Vb2/Vb1)**(1/2)\n",
    "C_T2 = C_T1 * ((Vb1/Vb2)**(1/2))# pF\n",
    "print \"The value of C_T for reverse bias = %.2f pF\"%C_T2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 1.36 Page No 72"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The voltage = -59.87 mV\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "# Given data\n",
    "V_T = 0.026# V\n",
    "Eta = 1\n",
    "I = '-0.9*Io'\n",
    "# T = Io*((%e**(V/(Eta*V_T)))-1 )\n",
    "# I = Io*((%e**(V/(Eta*V_T)))-1 )\n",
    "V = math.log(0.1)*V_T# V \n",
    "V = V * 10**3# mV\n",
    "print \"The voltage = %.2f mV\"%V"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 1.37 Page No 72"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Part (a) : The value of I_D for first circuit = 0.97 mA\n",
      "Part (b) : The value of I_D for second circuit = 0.10 mA\n"
     ]
    }
   ],
   "source": [
    "# Given data\n",
    "Vin = 20# V\n",
    "Vgamma = 0.7# V\n",
    "R = 20# k ohm\n",
    "R = R * 10**3# ohm\n",
    "# Vin-(I_D*Vin) - Vgamma = 0 or\n",
    "# The value of I_D,\n",
    "I_D = (Vin-Vgamma)/R# A\n",
    "I_D = I_D * 10**3# mA\n",
    "print \"Part (a) : The value of I_D for first circuit = %.2f mA\"%I_D\n",
    "\n",
    "# Part (b)\n",
    "Vin= 10.# V\n",
    "Vgamma = 0.7# V\n",
    "R = 100# k ohm\n",
    "# Drain current,\n",
    "I_D= Vin/R# mV\n",
    "print \"Part (b) : The value of I_D for second circuit = %.2f mA\"%I_D"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 1.38 Page No 73"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The value of I_D = 3.10 mA\n",
      "The value of Vo = 6.90 V\n"
     ]
    }
   ],
   "source": [
    "# Given data\n",
    "R1 = 1# k ohm\n",
    "R1 = R1 * 10**3# ohm\n",
    "R2 = 2# k ohm\n",
    "R2 = R2 * 10**3# ohm\n",
    "V = 10# V\n",
    "V1 = 0.7# V \n",
    "# V * (I_D*R1) - (R2*I_D) - V1 = 0\n",
    "I_D = (V-V1)/(R1+R2)# A\n",
    "I_D = I_D * 10**3# mA\n",
    "print \"The value of I_D = %.2f mA\"%I_D\n",
    "# The output voltage,\n",
    "Vo = (I_D*10**-3 * R2) +V1# V\n",
    "print \"The value of Vo = %.2f V\"%Vo"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 1.39 Page No 73"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Part (a): The current through resistance = 1.00 A\n",
      "Part (b) : Current through 10 ohm resistance will be Zero\n",
      "Part (c): Current will be zero\n",
      "Part (d): The diode will be ON and current = 1.00 A\n"
     ]
    }
   ],
   "source": [
    "# Given data\n",
    "V = 10.# V\n",
    "R = 10# ohm\n",
    "# Current through resistance,\n",
    "I = V/R# A\n",
    "print \"Part (a): The current through resistance = %.2f A\"%I\n",
    "print \"Part (b) : Current through 10 ohm resistance will be Zero\"\n",
    "print \"Part (c): Current will be zero\"\n",
    "print \"Part (d): The diode will be ON and current = %.2f A\"%I"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 1.40 Page No 74"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The operating point is  : (0.50V,4.50mA)\n"
     ]
    }
   ],
   "source": [
    "# Given data\n",
    "Vth= 0.5# V\n",
    "R_F= 1*10**3# ohm\n",
    "V= 5# V\n",
    "# Applying KVL for loop, V-Vd-R_F*Ii= 0    (i)\n",
    "# When Ii=0\n",
    "Vd= V# V\n",
    "# When Vd= 0\n",
    "Ii= V/R_F# A\n",
    "# From eq(i)\n",
    "Ii= (V-Vth)/R_F# A\n",
    "Vd= V-R_F*Ii# V\n",
    "print \"The operating point is  : (%.2fV,%.2fmA)\"%(Vd,Ii*1000)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 1.43 Page No 76"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The voltage at V1 = 6.00 volts\n",
      "The voltage at V2 = 5.40 volts\n"
     ]
    }
   ],
   "source": [
    "# Given data\n",
    "V_CC = 6# V\n",
    "Vr = 0.6# V\n",
    "V1= V_CC##in V\n",
    "V2 = V1-Vr# V\n",
    "print \"The voltage at V1 = %.2f volts\"%V1\n",
    "print \"The voltage at V2 = %.2f volts\"%V2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 1.44 Page No 76"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The value of I1 = 1.80 mA\n",
      "The value of I2 = 1.80 mA\n"
     ]
    }
   ],
   "source": [
    "# Given data\n",
    "V_T = 0.7# V\n",
    "V = 5# V\n",
    "R = 2# k ohm\n",
    "R = R * 10**3# ohm\n",
    "Vs = 0.7\n",
    "Vx = Vs+V_T# V\n",
    "# The value of I1 \n",
    "I1 = (V-Vx)/R# A\n",
    "I1 = I1 * 10**3# mA\n",
    "print \"The value of I1 = %.2f mA\"%I1\n",
    "# The value of I2 \n",
    "I2 = I1# mA\n",
    "print \"The value of I2 = %.2f mA\"%I2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa 1.45 Page No 77"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The value of Vo = 1.00 V\n"
     ]
    }
   ],
   "source": [
    "# Given data\n",
    "Rf = 300.# ohm\n",
    "V = 0.5# V\n",
    "R = 600.# ohm\n",
    "Vi = 2.# V\n",
    "# The output voltage \n",
    "Vo = (Vi-V)*( R/(R+Rf) )# V\n",
    "print \"The value of Vo = %.2f V\"%Vo"
   ]
  }
 ],
 "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
}