{
 "metadata": {
  "name": "",
  "signature": "sha256:7b09bc4939eefcfd52ab3af51ad805d4dcc13501d36382e73f4451d0d172843b"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter7 - Source to fiber power launching and photodetectors"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.2.1, page 7-11"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "from numpy import pi, sqrt, log10\n",
      "n1=3.4     #refractive index of optical source\n",
      "n=1.46      #refractive index of silica fiber\n",
      "r=((n1-n)/(n1+n))**2     #computing Frensel reflection\n",
      "L=-10*log10(1-r)       #computing loss\n",
      "print \"Frensel reflection is %.3f.\\nPower loss is %.2f dB.\" %(r,L) "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Frensel reflection is 0.159.\n",
        "Power loss is 0.75 dB.\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.2.2, page 7-11"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "r=35*10**-6         #radius\n",
      "R=150       #Lambertian emission pattern\n",
      "NA=0.2      #Numerical aperture\n",
      "Pled = pi**2*r**2*R*NA**2 \n",
      "Pled=Pled*10**7 \n",
      "print \"Optical power for larger core of 35 micrometer is %.3f mW.\" %(Pled) \n",
      "r1=25*10**-6 \n",
      "Pled1=(r1/r)**2*Pled \n",
      "print \"Optical power for smaller core of 25 micrometer is %.2f mW.\" %(Pled1) "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Optical power for larger core of 35 micrometer is 0.725 mW.\n",
        "Optical power for smaller core of 25 micrometer is 0.37 mW.\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.2.3, page 7-12"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "r=25*10**-6         #radius\n",
      "R=39       #Lambertian emission pattern\n",
      "NA=0.25     #numerical aperture\n",
      "a=35*10**-6     #area\n",
      "Pc1= pi**2*a**2*R*NA**2   #computing coupled power when r<a\n",
      "Pc1=Pc1*10**7 \n",
      "Pc= pi**2*r**2*R*NA**2    #computing coupled power when r>a\n",
      "Pc=Pc*10**7 \n",
      "print \"Optical power when r>a is %.2f mW.\\nOptical power when r<a is %.3f mW.\" %(Pc,Pc1) "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Optical power when r>a is 0.15 mW.\n",
        "Optical power when r<a is 0.295 mW.\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.5.1, page 7-23"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "h=6.626*10**-34     #plank's constant\n",
      "c=3*10**8       #speed of light\n",
      "e=1.6*10**-19   #charge of electron\n",
      "q=1.43      #Bandgap energy\n",
      "lamda=h*c/(q*e)*10**9     #computing wavelength\n",
      "print \"Wavelength is %d nm\" %(lamda) "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Wavelength is 868 nm\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.5.2, page 7-23"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "R=0.6       #responsivity\n",
      "Pin=15      #optical power in microwatt\n",
      "Ip=R*Pin        #computing photocurrent\n",
      "print \"Photocurrent generated is %d microAmpere.\" %Ip "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Photocurrent generated is 9 microAmpere.\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.5.3, page 7-23"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "lamda1=1300*10**-9 \n",
      "lamda2=1600*10**-9 \n",
      "h=6.625*10**-34     #plank's constant\n",
      "c=3*10**8       #speed of light\n",
      "q=1.6*10**-19   #charge of electron\n",
      "eta=90/100  #quantum efficiency\n",
      "E=0.73       #energy gap in eV\n",
      "R1=eta*q*lamda1/(h*c) \n",
      "R2=eta*q*lamda2/(h*c) \n",
      "lamdac=1.24/E \n",
      "print \"Responsivity at 1300nm is %.2f A/W.\\nResponsivity at 1600nm is %.2f A/W.\\nCut-off wavelength is %.1f micrometer.\" %(R1,R2,lamdac) \n",
      "#R1 is calculated wrong."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Responsivity at 1300nm is 0.94 A/W.\n",
        "Responsivity at 1600nm is 1.16 A/W.\n",
        "Cut-off wavelength is 1.7 micrometer.\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.5.4, page 7-24"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "lamda=0.8*10**-6 \n",
      "h=6.625*10**-34     #plank's constant\n",
      "c=3*10**8       #speed of light\n",
      "q=1.6*10**-19   #charge of electron\n",
      "ne=1.8*10**11   #electrons collected\n",
      "np=4*10**11     #photons incident\n",
      "eta=ne/np       #computing quantum efficiency\n",
      "R=eta*q*lamda/(h*c)     #computing responsivity\n",
      "print \"Responsivity of photodiode at 0.8 micrometer is %.3f A/W.\" %R \n",
      "#answer in the book is wrong. "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Responsivity of photodiode at 0.8 micrometer is 0.290 A/W.\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.5.5, page 7-24"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "E=1.8*10**-19  # Energy of photon\n",
      "nq=70/100  # Quantum\n",
      "Ip=3  # current in uA\n",
      "h=6.625*10**-34     #plank's constant\n",
      "c=3*10**8       #speed of light\n",
      "lamda=h*c/E*10**6  # wavelength in micro meter\n",
      "print \"Photodiode operates at %0.2f micro meter\" %lamda\n",
      "q=1.6*10**-19   #charge of electron\n",
      "R=nq*q/E     #computing responsivity\n",
      "Popt=Ip/R\n",
      "print \"Incident optical power required =  %.3f uW.\" %Popt "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Photodiode operates at 1.10 micro meter\n",
        "Incident optical power required =  4.821 uW.\n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.5.6, page 7-25"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "h=6.626*10**-34     #plank's constant\n",
      "c=3*10**8       #speed of light\n",
      "q=1.6*10**-19   #charge of electron\n",
      "E=1.35       #energy gap in eV\n",
      "lamda=h*c/(q*E)    #computing wavelength\n",
      "lamda=lamda*10**6 \n",
      "print \"The InP photodetector will stop operation above %.2f micrometer.\" %(lamda) \n",
      "#calculation error in the book."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The InP photodetector will stop operation above 0.92 micrometer.\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.5.7, page 7-26"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "h=6.626*10**-34     #plank's constant\n",
      "c=3*10**8       #speed of light\n",
      "eta=65/100  #quantum efficiency\n",
      "I=2.5*10**-6      #photocurrent \n",
      "E=1.5*10**-19   #energy of photns\n",
      "q=1.6*10**-19   #charge of electron\n",
      "lamda=h*c/E    #computing wavelength\n",
      "R=eta*q*lamda/(h*c)     #computing responsivity\n",
      "Popt=I/R        #computing optical power\n",
      "lamda=lamda*10**6 \n",
      "Popt=Popt*10**6 \n",
      "print \"Wavelength is %.3f micrometer.\\nResponsivity is %.3f A/W.\\nIncident optical power required is %.1f microWatt.\" %(lamda,R,Popt) \n",
      "#answer of R(responsivity) in the book is calculated as 0.694 A/W, deviation of 0.001."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Wavelength is 1.325 micrometer.\n",
        "Responsivity is 0.693 A/W.\n",
        "Incident optical power required is 3.6 microWatt.\n"
       ]
      }
     ],
     "prompt_number": 19
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.5.8, page 7-26"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "ne=3.9*10**6   #electrons collected\n",
      "np=6*10**6     #photons incident\n",
      "eta=100*ne/np   #computing efficiency\n",
      "print \"Quantum efficiency is %d percent.\" %(eta) "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Quantum efficiency is 65 percent.\n"
       ]
      }
     ],
     "prompt_number": 20
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.8.1, page 7-37"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "w=25*10**-6     #width\n",
      "v=1*10**5       #velocity\n",
      "r=40*10**-6     #radius\n",
      "eps=12.5*10**-13 \n",
      "t=w/v       #computing drift time\n",
      "c=eps*3.14*(r)**2/w      #computing junction capacitance\n",
      "c=c*10**16 \n",
      "print \"Drift time %.1e sec.\\nJunction capacitance %.1f pf.\" %(t,c) \n",
      "#calculation error in drift time answer."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Drift time 2.5e-10 sec.\n",
        "Junction capacitance 2.5 pf.\n"
       ]
      }
     ],
     "prompt_number": 21
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.8.2, page 7-38"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "w=20*10**-6     #width\n",
      "v=4*10**4       #velocity\n",
      "t=w/v       #computing drift time\n",
      "BW=(2*pi*t)**-1         #computing bandwidth\n",
      "rt=1/BW     #computing response time\n",
      "rt=rt*10**9 \n",
      "print \"Maximum response time is %.1f ns.\" %(rt)\n",
      "#Calculation error in the book."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Maximum response time is 3.1 ns.\n"
       ]
      }
     ],
     "prompt_number": 22
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.9.1, page 7-43"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "lamda=1.4*10**-6 \n",
      "h=6.626*10**-34     #plank's constant\n",
      "c=3*10**8       #speed of light\n",
      "q=1.6*10**-19   #charge of electron\n",
      "eta=65/100  #quantum efficiency\n",
      "I=10*10**-9     #current\n",
      "NEP= h*c*sqrt(2*q*I)/(eta*q*lamda) \n",
      "D=NEP**-1 \n",
      "print \"Noise equivalent power is %.3e W.\\nSpecific directivity is %.2e.\" %(NEP,D) \n",
      "#answers in the book for NEP & D is wrong."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Noise equivalent power is 7.723e-14 W.\n",
        "Specific directivity is 1.29e+13.\n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.9.2, page 7-44"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "lamda=1300*10**-9 \n",
      "h=6.626*10**-34     #plank's constant\n",
      "c=3*10**8       #speed of light\n",
      "q=1.6*10**-19   #charge of electron\n",
      "eta=90/100  #quantum efficiency\n",
      "P0=300*10**-9   #optical power\n",
      "Id=4     #dark current\n",
      "B=20*10**6      #bandwidth\n",
      "K=1.39*10**-23  #Boltzman constant\n",
      "T=298       #temperature\n",
      "R=1000      #load resister\n",
      "Ip= 10**9*eta*P0*q*lamda/(h*c) \n",
      "Its=10**9*(2*q*B*(Ip+Id)) \n",
      "Its=sqrt(Its) \n",
      "print \"rms shot noise current is %.2f nA.\" %(Its) \n",
      "It= 4*K*T*B/R \n",
      "It=sqrt(It) \n",
      "print \"Thermal noise is %.2e A.\" %(It) \n",
      "#answer given in book for shot noise & Thermal noise are wrong."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "rms shot noise current is 1.35 nA.\n",
        "Thermal noise is 1.82e-08 A.\n"
       ]
      }
     ],
     "prompt_number": 24
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.10.1, page 7-51"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from numpy import floor\n",
      "lamda=0.85*10**-6 \n",
      "h=6.626*10**-34     #plank's constant\n",
      "c=3*10**8       #speed of light\n",
      "q=1.6*10**-19   #charge of electron\n",
      "eta=75/100  #quantum efficiency\n",
      "P0=0.6*10**-6   #incident optical power\n",
      "Im=15*10**2    #avalanche gain\n",
      "R= eta*q*lamda/(h*c)    #computing responsivity\n",
      "Ip=10**8*P0*R        #computing photocurrent\n",
      "Ip=floor(Ip) \n",
      "M=Im/Ip         #computing multiplication factor\n",
      "print \"Multiplication factor is %d.\" %(M) "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Multiplication factor is 50.\n"
       ]
      }
     ],
     "prompt_number": 27
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.10.2, page 7-51"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "lamda=900*10**-9  # Wavelength in m\n",
      "P0=0.5 # Optical power\n",
      "Im=10  # Photocurrent\n",
      "h=6.626*10**-34     #plank's constant\n",
      "c=3*10**8       #speed of light\n",
      "q=1.6*10**-19   #charge of electron\n",
      "eta=65.0/100  #quantum efficiency\n",
      "R= eta*q*lamda/(h*c)    #computing responsivity\n",
      "Ip=P0*R        #computing photocurrent \n",
      "M=Im/Ip         #computing multiplication factor\n",
      "print \"Multiplication factor is %0.2f.\" %(M) \n",
      "# Answer is wrong in the textbook."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Multiplication factor is 42.47.\n"
       ]
      }
     ],
     "prompt_number": 46
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.10.3, page 7-52"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "lamda=900*10**-9 \n",
      "h=6.626*10**-34     #plank's constant\n",
      "c=3*10**8       #speed of light\n",
      "q=1.6*10**-19   #charge of electron\n",
      "eta=65/100  #quantum efficiency\n",
      "P0=0.5*10**-6   #incident optical power\n",
      "Im=10*10**2    #avalanche gain\n",
      "R= eta*q*lamda/(h*c)    #computing responsivity\n",
      "Ip=10**8*P0*R        #computing photocurrent\n",
      "M=Im/Ip         #computing multiplication factor\n",
      "print \"Multiplication factor is %d.\" %(M) \n",
      "#answer in the book is wrong."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Multiplication factor is 42.\n"
       ]
      }
     ],
     "prompt_number": 47
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.10.3, page 7-52"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "lamda=900*10**-9 \n",
      "h=6.626*10**-34     #plank's constant\n",
      "c=3*10**8       #speed of light\n",
      "q=1.6*10**-19   #charge of electron\n",
      "eta=65/100  #quantum efficiency\n",
      "P0=0.5*10**-6   #incident optical power\n",
      "Im=10*10**2    #avalanche gain\n",
      "R= eta*q*lamda/(h*c)    #computong responsivity\n",
      "Ip=10**8*P0*R        #computing photocurrent\n",
      "M=Im/Ip         #computing multiplication factor\n",
      "print \"Multiplication factor is %d.\" %M "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Multiplication factor is 42.\n"
       ]
      }
     ],
     "prompt_number": 48
    }
   ],
   "metadata": {}
  }
 ]
}