{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#  Chapter 10 : Opto-electronic Devices"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 10.1 , Page number 385"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Thickness of silicon= 0.016 cm\n"
     ]
    }
   ],
   "source": [
    "#importing module\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "alpha=10**2 #absorption coefficient in cm^-1\n",
    "absorption=0.2 #80% absorption represented in decimal format\n",
    "\n",
    "#Calculations\n",
    "d=(1/alpha)*math.log(1/absorption)\n",
    "\n",
    "#Result\n",
    "print(\"Thickness of silicon= %.3f cm\" %d)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 10.2 , Page number 385"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "open-circuit voltage Voc= 0.541 V\n"
     ]
    }
   ],
   "source": [
    "#importing module\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "Na=3*10**18 #in cm^-3\n",
    "Nd=2*10**16 #in cm^-3\n",
    "Dn=25 #in cm**2/s\n",
    "Dp=10 #in cm**2/s\n",
    "tau_n0=4*10**-7 #in s\n",
    "tau_p0=10**-7 #in s\n",
    "JL=20*10**-3 #photocurrent density in mA/cm**2\n",
    "T=300 #in K\n",
    "ni=1.5*10**10 #in cm^-3\n",
    "e=1.6*10**-19 #in Joules\n",
    "Const=0.026 #constant for KT/e in V\n",
    "\n",
    "#Calculations\n",
    "Ln=math.sqrt(Dn*tau_n0) #in micro-m\n",
    "Lp=math.sqrt(Dp*tau_p0) #in micro-m\n",
    "JS=e*ni**2*((Dn/(Ln*Na))+(Dp/(Lp*Nd))) #reverse saturation current density in A/cm**2\n",
    "Voc=Const*math.log(1+(JL/JS))\n",
    "\n",
    "#Result\n",
    "print(\"open-circuit voltage Voc= %0.3f V\" %Voc)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 10.3 , Page number 399"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Gain of the photoconductor= 686.4\n"
     ]
    }
   ],
   "source": [
    "#importing module\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "L=80*10**-4 #length in m\n",
    "myu_n=1350 #in cm**2/V\n",
    "myu_p=480 #in cm**2/V\n",
    "V=12 #applied voltage in V\n",
    "tau_n=3.95*10**-9 #transit time in sec\n",
    "tau_p=2*10**-6 #carrier lifetime in sec\n",
    "\n",
    "#Calculations\n",
    "tn=L**2/(myu_n*V) #transit time in sec\n",
    "Gph=(tau_p/tau_n)*(1+(myu_p/myu_n))\n",
    "\n",
    "#Result\n",
    "print(\"Gain of the photoconductor= %3.1f\" %Gph)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 10.4 , Page number 400"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "steady-state photocurrent density= 0.43 A/cm**2\n"
     ]
    }
   ],
   "source": [
    "#importing module\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "Na=5*10**16 #in cm**3\n",
    "Nd=5*10**16 #in cm**3\n",
    "Dn=25 #in cm**2/s\n",
    "Dp=10 #in cm**2/s\n",
    "tau_n0=6*10**-7 #in s\n",
    "tau_p0=2*10**-7 #in s\n",
    "VR=6 #in V\n",
    "GL=5*10**20 #in cm^-3/s\n",
    "ni=1.5*10**10 #in cm^-3\n",
    "e=1.6*10**-19 #in Joules\n",
    "epsilon_s=11.7*8.85*10**-14 #in F/cm\n",
    "Const=0.026 #constant for KT/e in V\n",
    "\n",
    "#Calculations\n",
    "Ln=math.sqrt(Dn*tau_n0) #in mico-m\n",
    "Lp=math.sqrt(Dp*tau_p0) #in micro-m\n",
    "Vbi=Const*math.log((Na*Nd)/ni**2) #in V\n",
    "W=(((2*epsilon_s)/e)*((Na+Nd)/(Na*Nd))*(Vbi+VR))**0.5 #in micro-m\n",
    "JL=e*GL*(W+Ln+Lp) #photocurrent density\n",
    "\n",
    "#Result\n",
    "print(\"steady-state photocurrent density= %0.2f A/cm**2\" %JL)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 10.5 , Page number 401"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Critical angle for GaAs-air interface= 15.9 degrees\n"
     ]
    }
   ],
   "source": [
    "#importing module\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "n1=1 \n",
    "n2=3.66\n",
    "\n",
    "#Calculations\n",
    "theta_c=math.asin(n1/n2)\n",
    "\n",
    "#Result\n",
    "print(\"Critical angle for GaAs-air interface= %2.1f degrees\" %math.degrees(theta_c))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 10.6 , Page number 402"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a)\n",
      "electron concentration= 1e+15 cm^-3\n",
      "\n",
      "hole concentration= 2.1e+05 cm^-3\n",
      "\n",
      "Fermi level w.r.t intrinsic fermi level= 0.279 eV\n",
      "\n",
      "b)\n",
      "electron concentration= 1e+15 cm^-3\n",
      "\n",
      "hole concentration= 1e+12 cm^-3\n",
      "\n",
      "Quasi fermi level for n-type carrier= 0.279 eV\n",
      "\n",
      "Quasi fermi level for p-type carrier= 0.11 eV\n",
      "\n",
      "c)\n",
      "electron concentration= 1e+18 cm^-3\n",
      "\n",
      "hole concentration= 1e+18 cm^-3\n",
      "\n",
      "Quasi fermi level for n-type carrier= 0.45 eV\n",
      "\n",
      "Quasi fermi level for p-type carrier= 0.45 eV\n",
      "\n"
     ]
    }
   ],
   "source": [
    "#importing module\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "Nd=10**15 #donor atoms in cm^-3\n",
    "ni=1.45*10**10 #in cm^-3\n",
    "k=8.62*10**-5 #in eV/K\n",
    "T=300 #in K\n",
    "Const=0.025 #coonstant for kT in eV\n",
    "\n",
    "#Calculations\n",
    "#a)\n",
    "n=10**15 #in cm^-3\n",
    "p=ni**2/Nd #in cm^-3\n",
    "delE=Const*math.log(n/ni) #in eV\n",
    "\n",
    "#b)\n",
    "n0=10**15 #in cm^-3\n",
    "p0=10**12 #in cm^-3\n",
    "delE_fni=Const*math.log(n0/ni) #in eV\n",
    "delE_ifp=Const*math.log(p0/ni) #in eV\n",
    "\n",
    "#c)\n",
    "n1=10**18 #in cm^-3\n",
    "p1=10**18 #in cm^-3\n",
    "delE_fni1=Const*math.log(n1/ni) #in eV\n",
    "delE_ifp1=Const*math.log(p1/ni) #in eV\n",
    "\n",
    "#Result\n",
    "print(\"a)\\nelectron concentration= %.1g cm^-3\\n\" %n)\n",
    "print(\"hole concentration= %.2g cm^-3\\n\" %p)\n",
    "print(\"Fermi level w.r.t intrinsic fermi level= %0.3f eV\\n\" %delE)\n",
    "print(\"b)\\nelectron concentration= %.1g cm^-3\\n\" %n0)\n",
    "print(\"hole concentration= %.1g cm^-3\\n\" %p0)\n",
    "print(\"Quasi fermi level for n-type carrier= %0.3f eV\\n\" %delE_fni)\n",
    "print(\"Quasi fermi level for p-type carrier= %0.2f eV\\n\" %delE_ifp)\n",
    "print(\"c)\\nelectron concentration= %.1g cm^-3\\n\" %n1)\n",
    "print(\"hole concentration= %.1g cm^-3\\n\" %p1)\n",
    "print(\"Quasi fermi level for n-type carrier= %0.2f eV\\n\" %delE_fni1)\n",
    "print(\"Quasi fermi level for p-type carrier= %0.2f eV\\n\" %delE_ifp1)\n",
    "#The answers vary due to round off error"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 10.7 , Page number 403"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Wavelength of radiation for germanium= 1.85 micro-m\n",
      "\n",
      "Wavelength of radiation for silicon= 1.10 micro-m\n",
      "\n",
      "Wavelength of radiation for gallium-arsenide= 0.87 micro-m\n",
      "\n",
      "Wavelength of radiation for SiO2= 0.14 micro-m\n",
      "\n"
     ]
    }
   ],
   "source": [
    "#importing module\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "h=4.135*10**-15 #plancks constant in eVs\n",
    "c=3*10**8 #in m/s\n",
    "EgGe=0.67 #in eV\n",
    "EgSi=1.124 #in eV\n",
    "EgGaAs=1.42 #in eV\n",
    "EgSiO2=9 #in eV\n",
    "\n",
    "#Calculations\n",
    "lamda1=(h*c)/EgGe/10**-6 #in micro-m\n",
    "lamda2=(h*c)/EgSi/10**-6 #in micro-m\n",
    "lamda3=(h*c)/EgGaAs/10**-6 #in micro-m\n",
    "lamda4=(h*c)/EgSiO2/10**-6 #in micro-m\n",
    "\n",
    "#Result\n",
    "print(\"Wavelength of radiation for germanium= %1.2f micro-m\\n\" %lamda1)\n",
    "print(\"Wavelength of radiation for silicon= %1.2f micro-m\\n\" %lamda2) #The answers vary due to round off error\n",
    "print(\"Wavelength of radiation for gallium-arsenide= %1.2f micro-m\\n\" %lamda3)\n",
    "print(\"Wavelength of radiation for SiO2= %1.2f micro-m\\n\" %lamda4)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 10.8 , Page number 404"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a)Current= 5.59*10**-15 A\n",
      "\n",
      "b)Total number of solar cells= 25000\n"
     ]
    }
   ],
   "source": [
    "#importing module\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "Na=10**18 #in cm**-3\n",
    "Nd=10**17 #in cm**-3\n",
    "myu_p=471 #in cm**2/Vs\n",
    "myu_n=1417 #in cm**2/Vs\n",
    "tau_p=10**-8 #in s\n",
    "tau_n=10**-6 #in s \n",
    "JL=40 #in mA/cm**2\n",
    "A=10**-5 #in cm**2\n",
    "R1=1000 #in ohm\n",
    "e=1.6*10**-19 #in J\n",
    "ni=1.45*10**10 #in cm**-3\n",
    "Vt=0.02586 #constant for kT/e at 300K in V\n",
    "V=0.1 #in V\n",
    "n=10 #number of solar cells\n",
    "\n",
    "#Calculations\n",
    "#a)\n",
    "Dp=Vt*myu_p #in cm**2/s\n",
    "Dn=Vt*myu_n #in cm**2/s\n",
    "Ln=math.sqrt(Dn*tau_n) #in cm\n",
    "Lp=math.sqrt(Dp*tau_p) #in cm\n",
    "Js=e*ni**2*((Dp/(Nd*Lp))+(Dn/(Na*Ln))) #in A/cm**2\n",
    "Is=Js*10**-5 #in A\n",
    "IF=Is*(math.exp(V/Vt)-1) #in A\n",
    "\n",
    "#b)\n",
    "IL=40*10**-8 #in A\n",
    "I=IL-IF #in \n",
    "X=((10**-3)/(I))*n\n",
    "\n",
    "#Result\n",
    "print(\"a)Current= %.2f*10**-15 A\\n\" %round(IF/10**-15,2)) #The answers vary due to round off error\n",
    "print(\"b)Total number of solar cells= %i\" %X)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 10.9 , Page number 405"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Wavelength= 8.69*10**-7 m\n"
     ]
    }
   ],
   "source": [
    "#importing module\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "Eg=1.43 #Energy band gap in eV\n",
    "h=4.14*10**-15 #planck's constant in eV/s\n",
    "c=3*10**8 #in m/s\n",
    "\n",
    "#Calculations\n",
    "lamda=(h*c)/Eg\n",
    "\n",
    "#Result\n",
    "print(\"Wavelength= %0.2f*10**-7 m\" %round(lamda/10**-7,2)) #The answers vary due to round off error"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 10.10 , Page number 406"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Power conversion efficiency = 0.32 %\n"
     ]
    }
   ],
   "source": [
    "#importing module\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "PC=190 #optical Power generated in mW\n",
    "I=25*10**-3 #in A\n",
    "V=1.5 #in V\n",
    "\n",
    "#Calculations\n",
    "P=V/I #Electrical Power\n",
    "n=PC/P\n",
    "\n",
    "#Result\n",
    "print(\"Power conversion efficiency = %0.2f %%\" %(n/10))\n",
    "#The answer provided in the textbook is wrong"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python [Root]",
   "language": "python",
   "name": "Python [Root]"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
