{
 "metadata": {
  "name": "",
  "signature": "sha256:d4d0afedfad591dd3db7bcb4692f0b80c70309a906e9699c9f80be4fd8fe4dbc"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 4: Signal Degradation in Optical Fibers"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.1, Page number 100"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Calculate the loss of fiber'''\n",
      "\n",
      "from sympy import *\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "L = 400./1000.   #distance(km)\n",
      "Pi = Symbol(\"Pi\")\n",
      "Po = 0.25*Pi\n",
      "\n",
      "#Calculations\n",
      "Loss = (10*math.log10(Pi/Po))/L\n",
      "\n",
      "#Result\n",
      "print \"Loss =\",round(Loss),\"dB/km\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Loss = 15.0 dB/km\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.2, Page number 101"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Calculate power level'''\n",
      "\n",
      "#Variable declaration\n",
      "L = 3            #distance(km)\n",
      "a = 0.5          #attenuation loss(dB/km)\n",
      "lamda = 0.82     #wavelength(um)\n",
      "Pi = 1           #input power(mW)\n",
      "\n",
      "#Calculation\n",
      "Po = Pi*10**((-a*L)/10)\n",
      "\n",
      "#Result\n",
      "print \"Power level =\",round(Po,2),\"mW\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Power level = 0.71 mW\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.3, Page number 101"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Determine maximum possible link length'''\n",
      "\n",
      "#Variable declaration\n",
      "a = 0.5                  #attenuation loss(dB/km)\n",
      "Pi = 1.5*10**-3          #input power(uW)\n",
      "Po = 2.*10**-6           #output power(uW)\n",
      "\n",
      "#Calculation\n",
      "L = (10*math.log10(Pi/Po))/a\n",
      "\n",
      "#Result\n",
      "print \"Maximum possible link length =\",round(L,2),\"km\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Maximum possible link length = 57.5 km\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.4, Page number 102"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Determine pulse dispersion per unit length'''\n",
      "\n",
      "#Variable declaration\n",
      "pd = 1.2*10**-3   #pulse broadening(ns)\n",
      "d = 30            #distance\n",
      "\n",
      "#Calculation\n",
      "D = pd/d\n",
      "\n",
      "#Result\n",
      "print \"Pulse dispersion per unit length =\",D,\"ns/m\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Pulse dispersion per unit length = 4e-05 ns/m\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.5, Page number 102"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Determine the optical output power'''\n",
      "\n",
      "#Variable declaration\n",
      "L = 30           #distance(km)\n",
      "a = 0.8          #attenuation loss(dB/km)\n",
      "lamda = 1300     #wavelength(nm)\n",
      "Pi = 200         #input power(uW)\n",
      "\n",
      "#Calculation\n",
      "Po = Pi*10**((-a*L)/10)\n",
      "\n",
      "#Result\n",
      "print \"Optical output power =\",round(Po,3),\"uW\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Optical output power = 0.796 uW\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.6, Page number 103"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Determine\n",
      "a)Overall signal attenuation\n",
      "b)signal attenuation per km\n",
      "c)signal attenuation for the link\n",
      "d)input output power ratio'''\n",
      "\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "L = 8            #distance(km)\n",
      "Pi = 120*10**-6  #input power(W)\n",
      "Po = 3*10**-6    #output power(W)\n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "a = 10*math.log10(Pi/Po)\n",
      "\n",
      "#Part b\n",
      "adb = a/L\n",
      "\n",
      "#Part c\n",
      "l = 10\n",
      "x = adb*l       #loss occured along 10km of fiber\n",
      "y = 9           #loss due to splices(dB)\n",
      "dB = x+y\n",
      "\n",
      "#Part d\n",
      "pi_by_po = 10**(round(dB)/10)\n",
      "\n",
      "#Results\n",
      "print \"a) Overall signal attenuation =\",round(a),\"dB\"\n",
      "print \"b) Signal attenuation per km =\",round(adb),\"dB/km\"\n",
      "print \"c) Signal attenuation for the link =\",round(dB),\"dB\"\n",
      "print \"d) Input output power ratio =\",round(pi_by_po,1)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "a) Overall signal attenuation = 16.0 dB\n",
        "b) Signal attenuation per km = 2.0 dB/km\n",
        "c) Signal attenuation for the link = 29.0 dB\n",
        "d) Input output power ratio = 794.3\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.7, Page number 104"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Determine theoretical attenuation for two given wavelengths'''\n",
      "\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "Tf = 1400           #fictive temperature(K)\n",
      "p = 0.286           #photoelastic coeeficient for silica\n",
      "n = 1.46            #refractive index\n",
      "Bo = 7*10**-11      #isothermal compressibility\n",
      "K = 1.381*10**-23   #Boltzman's constant(J/k)\n",
      "L = 10**3\n",
      "\n",
      "#Calculation\n",
      "#For lamda = 0.63 um\n",
      "lamda1 = 0.63*10**-6 #wavelength(m)\n",
      "Yr1 = (8*math.pi**3*n**8*p**2*Bo*K*Tf)/(3*lamda1**4)\n",
      "E1 = math.exp(-Yr1*L)\n",
      "a1 = 10.*math.log10(1/E1)\n",
      "\n",
      "#For lamda = 1.30 um\n",
      "lamda2 = 1.30*10**-6 #wavelength(m)\n",
      "Yr2 = (8*math.pi**3*n**8*p**2*Bo*K*Tf)/(3*lamda2**4)\n",
      "E2 = math.exp(-Yr2*L)\n",
      "a2 = 10.*math.log10(1/E2)\n",
      "\n",
      "\n",
      "#Result\n",
      "print \"(solutions of example 4.8 and 4.7 are interchanged in the textbook)\"\n",
      "print \"Theoretical attenuation =\",round(a1,3),\"dB/km\"\n",
      "print \"Theoretical attenuation =\",round(a2,3),\"dB/km\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(solutions of example 4.8 and 4.7 are interchanged in the textbook)\n",
        "Theoretical attenuation = 5.21 dB/km\n",
        "Theoretical attenuation = 0.287 dB/km\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.8, Page number 104"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Calculating the refractive index of glass'''\n",
      "\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "lamda = 1*10**-6    #wavelength(m)\n",
      "p = 0.245           #photoelastic coefficient\n",
      "Bc = 8.4*10**-11    #isothermal compressebility(m^2/N)\n",
      "Tf = 758            #fictive temperature(K)\n",
      "K = 1.381*10**-23   #Boltzman's constant(J/k)\n",
      "alpha = 0.46        #attenuation(Db/Km)\n",
      "L = 1.*10**3        #distance(km)\n",
      "\n",
      "#Calculations\n",
      "Yr = (8*math.pi**3*p**2*Bc*K*Tf)/(3*lamda**4)\n",
      "n= (alpha/(4.34*Yr*10**3))**(1./8.)\n",
      "\n",
      "#Result\n",
      "print \"Refractive index =\",round(n,2)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Refractive index = 1.49\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.9, Page nuber 106"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Calculating the operating wavelength of laser and attenuation of fiber'''\n",
      "\n",
      "#Variable declaration\n",
      "Pb = 150.*10**-3     #threshold optical power for brillouin(W)\n",
      "Pr = 1.5             #threshold optical power for raman(W)\n",
      "d = 8.0               #core diameter(um)\n",
      "v = 1                #bandwidth(GHz)\n",
      "\n",
      "#Calculations\n",
      "'''\n",
      "Pb is given by,\n",
      "Pb = 4.4*10**-3*d^2*lamda^2*alpha*v ----(1)\n",
      "\n",
      "Pr is given by,\n",
      "Pr = 5.9*10**-2*d^2*lamda*alpha  ----(2)\n",
      "\n",
      "Dividing (1) by (2), we get,\n",
      "'''\n",
      "\n",
      "lamda = (Pb*5.9*10**-2*d**2)/(Pr*4.4*10**-3*d**2)\n",
      "\n",
      "alpha = Pr/(5.9*10**-2*d**2*lamda)\n",
      "\n",
      "#Results\n",
      "print \"Operating wavelength =\",round(lamda,2),\"um\"\n",
      "print \"Attenuation =\",round(alpha,3),\"dB/km\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Operating wavelength = 1.34 um\n",
        "Attenuation = 0.296 dB/km\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.10, Page number 107"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Estimating the threshold optical powers for Brillowin and raman scattering'''\n",
      "\n",
      "#Variable declaration\n",
      "d = 6          #core diameter(um)\n",
      "v = 0.8        #bandwidth(GHz)     \n",
      "lamda = 1.5    #wavelength(um)\n",
      "alpha = 0.5    #attenuation(dB/Km)\n",
      "\n",
      "#Calculations\n",
      "Pb = 4.4*10**-3*d**2*lamda**2*alpha*v\n",
      "\n",
      "Pr = 5.9*10**-3*d**2*lamda*alpha\n",
      "\n",
      "#Results\n",
      "print \"Threshold optical power for SBS =\",round((Pb/1E-3),2),\"mW\"\n",
      "print \"Threshold optical power for SRS =\",round((Pr/1E-1),2),\"W\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Threshold optical power for SBS = 142.56 mW\n",
        "Threshold optical power for SRS = 1.59 W\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.11, Page number 107"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Determing the critical radius of curvature'''\n",
      "\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "delta = 3./100      #relative refracive index difference\n",
      "n1 = 1.5            #refractive index of core\n",
      "lamda = 0.82*10**-6 #operating wavelength(m)\n",
      "\n",
      "#Calculations\n",
      "n2 = math.sqrt(n1**2-2*delta*n1**2)\n",
      "\n",
      "Rc = (3*n1**2*lamda)/(4*math.pi*(n1**2-n2**2)**0.5)\n",
      "\n",
      "#Results\n",
      "print \"The critical radius of curvature is\",round((Rc/1E-6),3),\"um(Calculation mistake in textbook)\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The critical radius of curvature is 1.199 um(Calculation mistake in textbook)\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.12, Page number 108"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Calculating the crtitical radius of curvature'''\n",
      "\n",
      "#Variable declaration\n",
      "delta = 3./100      #relative refracive index difference\n",
      "n1 = 2.0            #refractive index of core\n",
      "lamda = 1.55*10**-6 #operating wavelength(m)\n",
      "d = 8               #core diameter(um)\n",
      "\n",
      "#Calculations\n",
      "a = d/2\n",
      "n2 = math.sqrt(n1**2-2*delta*n1**2)\n",
      "lamda_c = (2*math.pi*a*10**-6*n1*((2*delta)**0.5))/2.405\n",
      "Rc = (20*lamda*(2.748-0.996*(lamda/lamda_c))**-3)/((n1**2-n2**2)**0.5)\n",
      "\n",
      "#Result\n",
      "print \"The critical radius of curvature is\",round((Rc/1E-6),3),\"um\"\n",
      "\n",
      "#note There is a calculation mistake in calculating 'n' in the textbook. Hence, the difference in results\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The critical radius of curvature is 4.322 um\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.13, Page number 109"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Determine-\n",
      "a)Maximum possible bandwidth\n",
      "b)pulse dispersion per unit length\n",
      "c)bandwidth length product'''\n",
      "\n",
      "#Variable declaration\n",
      "t = 0.1*10**-6    #pulse broadening(sec)\n",
      "L = 10            #distance(km)\n",
      "\n",
      "#Calculatons\n",
      "#Part a\n",
      "Bt = 1/(2*t)\n",
      "\n",
      "#Part b\n",
      "D = t/L\n",
      "\n",
      "#Part c\n",
      "Bl = Bt*L\n",
      "\n",
      "#Results\n",
      "print \"a)Maximum possible bandwidth =\",Bt/1E+6,\"MHz\"\n",
      "print \"b)Pulse dispersion per unit length =\",D/1E-6,\"us/km\"\n",
      "print \"c)Bandwidth length product =\",Bl/1E+6,\"Mhz km\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "a)Maximum possible bandwidth = 5.0 MHz\n",
        "b)Pulse dispersion per unit length = 0.01 us/km\n",
        "c)Bandwidth length product = 50.0 Mhz km\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.14, Page number 109"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Estimating the wavelength of transmitted light'''\n",
      "\n",
      "#Variable declaration\n",
      "Rc = 84*10**-6 #radius of curvature(m)\n",
      "n1 = 1.46     #core refractive index\n",
      "n2 = 1.45     #cladding refractive index\n",
      "\n",
      "#Calculations\n",
      "lamda = (Rc*4*math.pi*(n1**2-n2**2)**0.5)/(3*n1**2)\n",
      "\n",
      "#Result\n",
      "print \"Wavelength =\",round(lamda/1e-6,2),\"um(Calculation mistake in textbook)\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Wavelength = 28.16 um(Calculation mistake in textbook)\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.15, Page number 110"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Calculating the pulse broadening due to dispersion'''\n",
      "\n",
      "#Variable declaration\n",
      "lamda = 1.5       #wavelength(um)\n",
      "M = 20            #dispersion parameter(ps n/m-km)\n",
      "L = 30            #length of fiber(km)\n",
      "s_l = 2           #spectral width(nm)\n",
      "\n",
      "#Calculations\n",
      "s_m = s_l*L*M\n",
      "\n",
      "#Result\n",
      "print \"Pulse broadening =\",s_m,\"ps\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Pulse broadening = 1200 ps\n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.16, Page number 110"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Calculating material dispersion parameter and rms pulse broadening'''\n",
      "\n",
      "#Variable declaration\n",
      "lamda = 850       #wavelength(nm)\n",
      "s_l = 20          #spectral width(nm)\n",
      "Dh = 0.025        #material dispersion\n",
      "c = 2.998*10**5   #speed of light(km/s)\n",
      "L = 1             #length of fiber(km)\n",
      "\n",
      "#Calculations\n",
      "M = Dh/(c*lamda)\n",
      "\n",
      "s_m = s_l*L*M\n",
      "\n",
      "#Results\n",
      "print \"Material dispersion parameter =\",round((M/1E-12),2),\"ps n/m km^-1\"\n",
      "print \"RMS pulse broadening =\",round((s_m/1E-9),2),\"ns/km\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Material dispersion parameter = 98.1 ps n/m km^-1\n",
        "RMS pulse broadening = 1.96 ns/km\n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.17, Pge number 111"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Determing the pulse boradening per km'''\n",
      "\n",
      "#Variable declaration\n",
      "lamda = 0.9       #wavelength(um)\n",
      "s_l = 45          #spectral width(um)\n",
      "Dh = 4*10**-2     #material dispersion\n",
      "c = 3*10**8       #speed of light(m/s)\n",
      "L = 1             #length of fiber(km)\n",
      "\n",
      "#Calculations\n",
      "s_m = (s_l*L*Dh*lamda)/c\n",
      "\n",
      "#Result\n",
      "print \"Pulse boradening =\",s_m/1E-9,\"ns/km\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Pulse boradening = 5.4 ns/km\n"
       ]
      }
     ],
     "prompt_number": 21
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.18, Page number 111"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Determing the pulse boradening per km'''\n",
      "\n",
      "#Variable declaration\n",
      "lamda = 0.85       #wavelength(nm)\n",
      "M = 95             #material dispersion parameter(ps n/m km^-1)\n",
      "\n",
      "#Calculations\n",
      "s_l = 0.0012*lamda\n",
      "s_m = s_l*L*M\n",
      "\n",
      "#Result\n",
      "print \"Pulse boradening =\",s_m,\"ns/km\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Pulse boradening = 0.0969 ns/km\n"
       ]
      }
     ],
     "prompt_number": 22
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.19, Page number 112"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Calculating the pulse broadening'''\n",
      "\n",
      "#Variable declaration\n",
      "NA = 0.275       #numerical aperture\n",
      "n1 = 1.48        #core refractive index\n",
      "L = 5            #length of fiber(km)\n",
      "c = 3.*10**5     #speed of light(km/sec)\n",
      "\n",
      "#Calculations\n",
      "STs = (L*NA**2)/(2*n1*c)\n",
      "\n",
      "#Result\n",
      "print \"Pulse broadening =\",round((STs/1E-9),2),\"ns(Calculation mistake in textbook)\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Pulse broadening = 425.82 ns(Calculation mistake in textbook)\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.20, Page number 112"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Calculate -\n",
      "a)delay difference between modes\n",
      "b)rms pulse broadening\n",
      "c)maximum bit rate\n",
      "d)bandwidth length product'''\n",
      "\n",
      "from math import sqrt\n",
      "\n",
      "#Variable declaration\n",
      "L = 3*10**3   #length of link(m)\n",
      "n1 = 1.5      #refractive index of core\n",
      "D = 2./100     #refractive index difference\n",
      "c = 2.998*10**8 #speed of light(m/s)\n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "Sts = (L*n1*D)/c\n",
      "\n",
      "#Part b\n",
      "s_s = (L*n1*D)/(2*sqrt(3)*c)\n",
      "\n",
      "#Part c\n",
      "Bt = 1/(2*Sts)\n",
      "\n",
      "#Part d\n",
      "Bl = Bt*L\n",
      " \n",
      "#Results\n",
      "print \"Delay difference is\",round(Sts/1E-9),\"ns\"\n",
      "print \"rms pulse broadening due to intermodal dispersion is\",round((s_s/1E-9),1),\"ns\"\n",
      "print \"Maximum bit rate is\",round((Bt/1E+6),1),\"Mbits/sec\"\n",
      "print \"Bandwidth length product is\",round((Bl/1E+9),1),\"MHz km\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Delay difference is 300.0 ns\n",
        "rms pulse broadening due to intermodal dispersion is 86.7 ns\n",
        "Maximum bit rate is 1.7 Mbits/sec\n",
        "Bandwidth length product is 5.0 MHz km\n"
       ]
      }
     ],
     "prompt_number": 24
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.21, Page number 113"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Calculating the rms pulse broadening per km for multimode step index fiber and graded index fiber'''\n",
      "\n",
      "#Variable declaration\n",
      "s_s = 86.7      #pulse broadening(ns)\n",
      "L = 6           #length of link(km)\n",
      "n1 = 1.5        #core refractive index\n",
      "delta = 1./100  #refractive index difference\n",
      "c = 2.998*10**8 #speed of light(m/s)\n",
      "\n",
      "#Calculations\n",
      "s_m = s_s/L\n",
      "\n",
      "L1 = 10**3\n",
      "s_g = (L1*n1*delta**2)/(20*sqrt(3)*c)\n",
      "\n",
      "#Result\n",
      "print \"The rms pulse broadening per km for multimode step index fiber is\",s_m,\"ns/km\"\n",
      "print \"The rms pulse broadening per km for graded index fiber is\",round((s_g/1E-12),2),\"ps/km\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The rms pulse broadening per km for multimode step index fiber is 14.45 ns/km\n",
        "The rms pulse broadening per km for graded index fiber is 14.44 ps/km\n"
       ]
      }
     ],
     "prompt_number": 25
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.22, Page number 114"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Estimating the total pulse broadening per km '''\n",
      "\n",
      "#Variable declaration\n",
      "NA = 0.4         #numerical aperture\n",
      "n1 = 1.48        #core refractive index\n",
      "n2 = 1.47        #cladding refractive index\n",
      "M = 30           #material dispersion parameter(ps n/m /km)\n",
      "s_l = 25         #spectral width(ns)\n",
      "L = 1            #length of fiber(km)\n",
      "delta = 1./100    #refractive index difference\n",
      "\n",
      "#Calculations\n",
      "s_m = M*L*s_l\n",
      "s_s = (L1*n1*delta**2)/(20*sqrt(3)*c)\n",
      "s_t = math.sqrt(s_m**2+s_s**2)\n",
      "\n",
      "#Results\n",
      "print \"Total pulse broadening per km is\",s_t,\"ps\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Total pulse broadening per km is 750.0 ps\n"
       ]
      }
     ],
     "prompt_number": 26
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.23, Page number 115"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Calculate-\n",
      "a)total pulse broadening per km\n",
      "b)bandwidth length product'''\n",
      "\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "NA = 0.3         #numerical aperture\n",
      "n1 = 1.45        #core refractive index\n",
      "M = 250          #material dispersion parameter(ps n/m /km)\n",
      "s_l = 50         #spectral width(ns)\n",
      "L = 1            #length of fiber(km)\n",
      "c = 2.998*10**8  #speed of light(m/s)\n",
      "\n",
      "#Calculations\n",
      "#Part a\n",
      "s_m = (M*L*s_l)*10**-3                           #ns/km\n",
      "s_s = ((L*10**3*NA**2)/(4*math.sqrt(3)*n1*c*10**3))*10**12  #ns/km\n",
      "s_t = math.sqrt(s_m**2+s_s**2)\n",
      "\n",
      "#Part b\n",
      "Bl = 0.2/s_t\n",
      "\n",
      "#Results\n",
      "print \"a)total pulse broadening =\",round(s_t,2),\"ns/km\"            #Answer varies due to rounding-off errors\n",
      "print \"b)bandwidth length product =\",round((Bl/1E-3),1),\"Mhz km\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "a)total pulse broadening = 32.39 ns/km\n",
        "b)bandwidth length product = 6.2 Mhz km\n"
       ]
      }
     ],
     "prompt_number": 39
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.24, Page number 116"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Finding the beat length'''\n",
      "\n",
      "#Variable declaration\n",
      "lamda = 1.32       #wavelength(um)\n",
      "Lbc = 100          #length of fiber(km)\n",
      "Sf = 1.5           #spectral width(nm)\n",
      "\n",
      "#Calculations\n",
      "Bf = lamda**2/(Lbc*Sf)\n",
      "Lb = lamda/Bf\n",
      "\n",
      "#Result\n",
      "print \"Beat length =\",round(Lb,1),\"km\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Beat length = 113.6 km\n"
       ]
      }
     ],
     "prompt_number": 28
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.25, Page number 116"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Calculate modal birefringence'''\n",
      "\n",
      "#Variable declaration\n",
      "lamda = 1.3*10**-6  #wavelength(um)\n",
      "Lb1 = 0.5*10**-3    #length of fiber(mm)\n",
      "Lb2 = 60            #(m)\n",
      "\n",
      "#Calculations\n",
      "#for beat length of 0.5mm,\n",
      "Bf1 = lamda/Lb1\n",
      "\n",
      "#for beat length of 60m,\n",
      "Bf2 = lamda/Lb2\n",
      "\n",
      "#Result\n",
      "print \"The modal birefringences are \",Bf1/1E-3, \"*10^-3 and\",round((Bf2/1E-8),2),\"*10^-4\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The modal birefringences are  2.6 *10^-3 and 2.17 *10^-4\n"
       ]
      }
     ],
     "prompt_number": 29
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.26, Page number 117"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Calculate the modal birefringence, coherence length and difference between propagation constants'''\n",
      "\n",
      "#Variable declaration\n",
      "lamda = 0.5*10**-6  #wavelength(um)\n",
      "Lb = 5*10**-2       #length of fiber(km)\n",
      "S_l = 1*10**-9      #spectral width(nm)\n",
      "\n",
      "#Calculations\n",
      "Bf = lamda/Lb\n",
      "\n",
      "Lbc = lamda**2/(Bf*S_l)\n",
      "\n",
      "B = (2*math.pi)/Lb      #Bx-By\n",
      "\n",
      "#Results\n",
      "print \"Modal birefringence =\",Bf\n",
      "print \"Coherence length =\",Lbc,\"m\"\n",
      "print \"Difference between propagation constants =\",round(B,1)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Modal birefringence = 1e-05\n",
        "Coherence length = 25.0 m\n",
        "Difference between propagation constants = 125.7\n"
       ]
      }
     ],
     "prompt_number": 30
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.27, Page number 117"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Calculating the maximum bit rate'''\n",
      "\n",
      "#Variable declaration\n",
      "L = 10*10**3        #length of fiber(m)\n",
      "St2 = 600*10**-12   #mode dispersion(s/km)\n",
      "\n",
      "#Calculations\n",
      "Bt = 0.9/(0.55*St2*L)\n",
      "\n",
      "#Result\n",
      "print \"Maximum bit rate =\",round(Bt/1E+3),\"Kbps\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Maximum bit rate = 273.0 Kbps\n"
       ]
      }
     ],
     "prompt_number": 31
    }
   ],
   "metadata": {}
  }
 ]
}