{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 9: Optical Communication Systems"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example 9.1, Page Number 449"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The Photogenereated Current is 6.30e-06 A\n",
      "The total shot noise Current is 3.18e-08 A\n",
      "The Total Johnson Noise Current is 4.06939798988e-07 A\n",
      "The Required Signal to noise ratio is 238.5\n",
      "The optimum Load Resistance 318.5 ohm\n",
      "The Optimum Johnson Noise Current is 1.61e-07 A\n",
      "The New Signal to noise Ratio is 1471.1\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt\n",
    "\n",
    "#Given P-I-N Diode\n",
    "q=0.6 #Quantam Efficiency\n",
    "l=1.3*(10**-6) #Wavelength in Meters\n",
    "i=3*(10**-9) #Reverse Bias Leakage Current in Ampere\n",
    "r=50 #Resistance in Ohm\n",
    "b=500*(10**6) #Bandwidth in Hertz\n",
    "P=10*(10**-6) #Optical Power in Watt\n",
    "e=1.6*(10**-19) #Charge of a Electron\n",
    "h=6.6*(10**-34) #Plancks Constant\n",
    "c=3*(10**8)  #Speed Of Light\n",
    "k=1.38*(10**-23) #Boltzmann Constant\n",
    "c1=1*(10**-12) #Assumed Capacitance in Farad\n",
    "\n",
    "ip=(q*P*e*l)/(h*c)  #Where i is the Photogenerated current\n",
    "\n",
    "print \"The Photogenereated Current is %.2e A\"%(ip)\n",
    "\n",
    "itotal=sqrt(2*(i+ip)*e*b) #Where itotal is the Total Shot Noise Current using equation 9.11\n",
    "\n",
    "print \"The total shot noise Current is %.2e A\"%(itotal)\n",
    "\n",
    "ij=sqrt(4*k*r*b*300)/r #Where ij is the Total Johnson Noise Current using Equation 9.13\n",
    "\n",
    "print \"The Total Johnson Noise Current is \"+str(ij)+\" A\"\n",
    "\n",
    "sn=(ip**2)/((itotal**2)+(ij**2)) #Where sn is the Signal to Noise Ratio in Decibel\n",
    "sn=round(sn,1)\n",
    "print \"The Required Signal to noise ratio is \"+str(sn)\n",
    "\n",
    "rl=1/(2*3.14*c1*b) #Where rl is the optimum Load Resistance\n",
    "rl=round(rl,1)\n",
    "print \"The optimum Load Resistance \"+str(rl)+\" ohm\"\n",
    "\n",
    "ij2=sqrt(4*k*rl*b*300)/rl\n",
    "\n",
    "print \"The Optimum Johnson Noise Current is %.2e A\"%(ij2)\n",
    "\n",
    "sn1=(ip**2)/((itotal**2)+(ij2**2))\n",
    "sn1=round(sn1,1)\n",
    "print \"The New Signal to noise Ratio is \"+str(sn1)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example 9.2, Page Number 462"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The Transmitter Output is 0 Dbm\n",
      "The Receiver Sensitivity is -50 Dbm\n",
      "The Required Margin is 50 Dbm\n",
      "System Loss-\n",
      "Fiber Loss 2 Db/Km,15 Km                                        30 Db\n",
      "Detector Coupling Loss                                           1 Db\n",
      "Total Splicing Loss (0.5 DB x 10)                                5 Db\n",
      "Headroom for Temperature range,ageing effects & Future Splices   5 Db\n",
      "Total Attenuation                                               41 Db\n",
      "The Excess Power Margin required is 9 Db\n"
     ]
    }
   ],
   "source": [
    "print \"The Transmitter Output is 0 Dbm\"\n",
    "print \"The Receiver Sensitivity is -50 Dbm\"\n",
    "print \"The Required Margin is 50 Dbm\"\n",
    "print \"System Loss-\"\n",
    "print \"Fiber Loss 2 Db/Km,15 Km                                        30 Db\"\n",
    "print \"Detector Coupling Loss                                           1 Db\"\n",
    "print \"Total Splicing Loss (0.5 DB x 10)                                5 Db\"\n",
    "print \"Headroom for Temperature range,ageing effects & Future Splices   5 Db\"\n",
    "print \"Total Attenuation                                               41 Db\"\n",
    "f=30\n",
    "d=1\n",
    "t=5\n",
    "h=5\n",
    "t=f+d+t+h  #The total power attenuation\n",
    "p=50-t\n",
    "\n",
    "print \"The Excess Power Margin required is \"+str(p)+\" Db\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example 9.3, Page Number 474"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The Requirement for Single Mode Behaviour becomes\n",
      "1.51 <= d/lambda <= 4.53\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt\n",
    "n1=2.286 #The Ordinary Refractive Index \n",
    "d=6*(10**-3) #Refractive Index Change\n",
    "n2=n1-d #The Difference of the Two\n",
    "\n",
    "NA=sqrt((n1**2)-(n2**2))\n",
    "\n",
    "first=1/(4*NA)\n",
    "first=round(first,2)\n",
    "\n",
    "second=3/(4*NA)\n",
    "second=round(second,2)\n",
    "\n",
    "print \"The Requirement for Single Mode Behaviour becomes\"\n",
    "print str(first)+\" <= d/lambda <= \"+str(second)  #Where d=5*Lambda for suitable thickness design\n",
    "\n",
    "#The Higher Region is Miscalculated in the Book"
   ]
  }
 ],
 "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
}
