{
 "metadata": {
  "name": "",
  "signature": "sha256:c31c7734af7a6179a63aac4a4be2acaa7976b91a58a8c77446fe6a6c4b3a076e"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 3: Signal degradation in optical fibers"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.1, Page Number: 91"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#variable declaration\n",
      "Z1 = 1.0                               #distance (km)\n",
      "Z2 = 2.0                               #distance (km)\n",
      "alpha_in_dB_per_km = 3.0               #loss(dB/km)\n",
      "\n",
      "#calculation\n",
      "R1 = (alpha_in_dB_per_km *Z1)/10.0     \n",
      "R2 = (alpha_in_dB_per_km *Z2)/10.0\n",
      "P0_Pz1 = (10**R1)                      #power loss at 1 km\n",
      "P0_Pz2 = (10**R2)                      #power loss at 2 km\n",
      "Pz_P01 = 1-(1/P0_Pz1)\n",
      "Pz_P02 = 1-(1/P0_Pz2)\n",
      "\n",
      "#result\n",
      "print \"Optical signal power decresed for 1km = \" , round(Pz_P01*100,0) , \"%\"\n",
      "print \"Optical signal power decresed for 2km = \" , round(Pz_P02*100,0) , \"%\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Optical signal power decresed for 1km =  50.0 %\n",
        "Optical signal power decresed for 2km =  75.0 %\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.2, Page Number: 91"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#variable declaration\n",
      "Pin = 200*10**-6                       #power launched into the fiber(uW)\n",
      "alpha = 0.4                            #attenuation (dB/KM)\n",
      "z = 30                                 #optical fiber length 30 KM\n",
      "\n",
      "#calculation\n",
      "Pin_dBm = 10*(math.log10(Pin/10**-3))                #input power (dBm)\n",
      "Pout_dBm = 10*(math.log10(Pin/10**-3))-alpha*z       #output power(dBm)\n",
      "Pout = 10**(Pout_dBm/10)\n",
      "\n",
      "#result\n",
      "print \"Input power = \" , round(Pin_dBm,1),\"dBm\"\n",
      "print \"Output power = \" , round(Pout_dBm,1),\"dBm\"\n",
      "print \"Output power = \" , round(Pout*10**3,1),\"um\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Input power =  -7.0 dBm\n",
        "Output power =  -19.0 dBm\n",
        "Output power =  12.6 um\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.3, Page Number: 97"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#variable declaration\n",
      "alpha_0 = 1.64                     #attenuation at Lam_bda_0 in dB/KM\n",
      "Lam_bda_0 = 850*10**-9             #wavelength 850 nm\n",
      "Lam_bda1 = 1310*10**-9             #wavelength 1350 nm\n",
      "Lam_bda2 = 1550*10**-9             #waavelength 1550 nm \n",
      "\n",
      "#calculation\n",
      "alpha_Lambda1 = alpha_0*((Lam_bda_0/Lam_bda1)**4)    #rayleigh scattering loss1(dB/Km)\n",
      "alpha_Lambda2 = alpha_0*((Lam_bda_0/Lam_bda2)**4)    #rayleigh scattering loss2(dB/Km)\n",
      "\n",
      "#result\n",
      "print \"Rayleigh scattering loss alpha at 1310 nm = \" , round(alpha_Lambda1,3),\"dB/Km\"\n",
      "print \"Rayleigh scattering loss alpha at 1550 nm = \" , round(alpha_Lambda2,3),\"dB/Km\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Rayleigh scattering loss alpha at 1310 nm =  0.291 dB/Km\n",
        "Rayleigh scattering loss alpha at 1550 nm =  0.148 dB/Km\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.4, Page Number: 99"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#variable declaration\n",
      "alpha = 2                             #graded index profile\n",
      "n2 = 1.5                              #cladding\n",
      "Lam_bda = 1.3*10**-6                  #wavelength\n",
      "R = 0.01                              #bend radius of curvature\n",
      "a = 25*10**-6                         #core radius\n",
      "delta = 0.01                          #core cladding index profile\n",
      "k = 4.83*10**6                        #propagation constant\n",
      "\n",
      "#calculation\n",
      "no_of_modes= -10000.0                                     #number of modes decreased by 50% in greded index fibre\n",
      "part1 = (alpha+2)/(2*alpha*delta)\n",
      "part2 = (1-no_of_modes)/part1                             #Right side of equation\n",
      "part3 = (2*a/R)+math.floor((3/(2*n2*k*R))**(2/3))*100     #left side of equation\n",
      "\n",
      "#result\n",
      "print \"From equation part2 =\",round(part2,1),\"= part3 =\",round(part3,1)\n",
      "print \"Radius of curvature  = \", round(R*100,1),\"cm\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "From equation part2 = 100.0 = part3 = 100.0\n",
        "Radius of curvature  =  1.0 cm\n"
       ]
      }
     ],
     "prompt_number": 27
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.5, Page Number: 103"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#variable declaration\n",
      "C = 3*10**8                             #free space velocity(m/s) \n",
      "n1 = 1.48                               #core refractive index\n",
      "n2 = 1.465                              #cladding refractive index\n",
      "delta = 0.01                            #index difference\n",
      "L = 10**3                               #fiber length (Km)\n",
      "\n",
      "#calculation\n",
      "deltaT = (L*(n1**2)/(C*n2))*delta       #pulse broadening(ns/Km)\n",
      "\n",
      "#result\n",
      "print \"Pulse broadening = \" , round((deltaT/L)*10**12,0),\"ns/Km\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Pulse broadening =  50.0 ns/Km\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.6, Page Number: 104"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#variable declaration\n",
      "n1 = 1.48                                 #core refractive index\n",
      "n2 = 1.465                                #cladding refractive index\n",
      "delta = 0.01                              #index difference\n",
      "C =3*(10**8)                              #free space velcotiy(m/s)\n",
      "\n",
      "#calculation\n",
      "BL = (n2/(n1**2))*(C/delta)               #bit rate distance product(Mb/s-km)\n",
      "\n",
      "#result\n",
      "print \"Bandwidth distance at pulse spreding of 50ns/km = \" , round(BL*10**-9),\"Mb/s-km\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Bandwidth distance at pulse spreding of 50ns/km =  20.0 Mb/s-km\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.7, Page Number: 107"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#variable declaration\n",
      "Lamda = 800*10**-9                         #Wavelength (m)\n",
      "sigma_Lamda_LED = 40*10**-9                #spectral width (m)\n",
      "mat_dispersion = 0.00011                   #material dispersion     \n",
      "\n",
      "#calculation\n",
      "pulse_spread = sigma_Lamda_LED*mat_dispersion  #pulse spread(ns/km)\n",
      "\n",
      "#result\n",
      "print \"Material dispersion =\" ,round(pulse_spread*10**12,1),\"ns/km\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Material dispersion = 4.4 ns/km\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.8, Page Number: 110"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#variable declaration\n",
      "n2 = 1.48                             #index of cladding\n",
      "delta = 0.002                         #index difference\n",
      "Lam_bda = 1320*10**-9                 #Wavelength (nm)\n",
      "V_dVb_dV = 0.26                       #The value in square brackets for v = 2.4\n",
      "C =3*10**8                            #velocity of light in free space\n",
      "\n",
      "#calculation\n",
      "Dwg_Lamda = -(((n2*delta)/C)*(1/Lam_bda))*V_dVb_dV    #waveguide dispersion(ps/nm*km)\n",
      "\n",
      "#result\n",
      "print \"Waveguide dispersion = \" ,round(Dwg_Lamda*10**6,1),\"ps/(nm*km)\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Waveguide dispersion =  -1.9 ps/(nm*km)\n"
       ]
      }
     ],
     "prompt_number": 11
    }
   ],
   "metadata": {}
  }
 ]
}