{
 "metadata": {
  "name": "",
  "signature": "sha256:3b131d89e4b494324f859c73c4c8ff2378f807a6d190d044117f9ece13923645"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 14 - Optical Fibers and Communications"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E1 - Pg 695"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex14_1 Pg-695\n",
      "#Cut-off wavelength\n",
      "import math\n",
      "n1=1.545 #core refracrive index\n",
      "n2=1.510 #cladding refractive index\n",
      "d=3.*10.**(-6.) #diamter of optical fiber in m\n",
      "\n",
      "a=d/2. #core radius in m\n",
      "dela=(n1-n2)/n1 #fractional difference of refractive indices\n",
      "lamda_c=(2.*math.pi*a*n1*math.sqrt(2.*dela))/2.405 #cut-off wavelength\n",
      "print '%s %.2f %s' %(\"Cut-off wavelength =\",lamda_c*1e6,\"um\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Cut-off wavelength = 1.29 um\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E1 - Pg 695"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex14_2 Pg-695\n",
      "#Normalized frequency and total number of guided mode\n",
      "import math\n",
      "n1=1.53 #core refracrive index\n",
      "n2=1.5 #cladding refractive index\n",
      "lamda=10.**(-6.) #cut-off wavelength\n",
      "a=50.*10.**(-6.) #core radius in m\n",
      "\n",
      "\n",
      "V=(2.*math.pi*a*math.sqrt(n1**2.-n2**2.))/lamda #normalised frequency\n",
      "print '%s %.2f %s' %(\"Normalised frequency =\",V,\"\\n\")\n",
      "\n",
      "ms=V**2./2. #total number of guided mode\n",
      "print '%s %.2f %s' %(\"Total number of guided mode =\",ms,\"\\n\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Normalised frequency = 94.72 \n",
        "\n",
        "Total number of guided mode = 4485.74 \n",
        "\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E3 - Pg 695"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex14_3 Pg-695\n",
      "#critical angle, acceptance angle, numerical aperture\n",
      "import math\n",
      "n1=1.5#core refracrive index\n",
      "n2=1.46 #cladding refractive index\n",
      "asin=1.\n",
      "tetha_rad=math.asin(n2/n1) #critical angle in radians\n",
      "tetha=tetha_rad*180./math.pi #critical angle in degree \n",
      "print '%s %.2f %s' %(\"Critical angle =\",tetha,\"degree\\n\")\n",
      "tetha_m_rad=math.asin(math.sqrt(n1**2.-n2**2.)) #acceptance angle in radians\n",
      "tetha_m=tetha_m_rad*180./math.pi\n",
      "print '%s %.2f %s' %(\"Acceptance angle =\",tetha_m,\"degree\\n\")\n",
      "NA=math.sin(tetha_m_rad)\n",
      "print '%s %.2f %s' %(\"Numerical Apperture =\",NA,\"\\n\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Critical angle = 76.74 degree\n",
        "\n",
        "Acceptance angle = 20.13 degree\n",
        "\n",
        "Numerical Apperture = 0.34 \n",
        "\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E4 - Pg 696"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex14_4 Pg-696\n",
      "#calculate cladding refractive index and RI of the core\n",
      "import math\n",
      "NA=0.5 #numerical apperture\n",
      "n1=1.54 #core refractive index\n",
      "n2=math.sqrt(n1**2.-NA**2.) #cladding refractive index\n",
      "print '%s %.2f %s' %(\"(1)Cladding refractive index =\",n2,\"\\n\")\n",
      "RI=(n1-n2)/n1 #change in core cladding refractive index\n",
      "print '%s %.2f %s' %(\"(2)RI of the core =\",RI,\"\\n\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(1)Cladding refractive index = 1.46 \n",
        "\n",
        "(2)RI of the core = 0.05 \n",
        "\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E5 - Pg 696"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex14_5 Pg-696\n",
      "#numerical aperture and max entrance angle \n",
      "import math \n",
      "n1=1.5#core refracrive index\n",
      "n2=1.48 #cladding refractive index\n",
      "n=1.\n",
      "asin=1.\n",
      "NA=math.sqrt(n1**2.-n2**2.) #numerical apperture\n",
      "print '%s %.2f %s' %(\"(1)Numerical apperture =\",NA,\"\\n\")\n",
      "AA_rad=math.asin(NA/n) #maximum Acceptance angle in rad\n",
      "AA=AA_rad*180./math.pi #maximum entrance angle in degree\n",
      "print '%s %.2f %s' %(\"(2)The maximum entrance angle i0 =\",AA,\"degree\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(1)Numerical apperture = 0.24 \n",
        "\n",
        "(2)The maximum entrance angle i0 = 14.13 degree\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E6 - Pg 697"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex14_6 Pg-697\n",
      "#core refractive index, numerical aperture,maximum entrance angle\n",
      "import math\n",
      "n2=1.59 #cladding refractive index\n",
      "NA=0.2 #numerical apperture\n",
      "n0=1. #when fiber is in air\n",
      "asin=1.\n",
      "n1=math.sqrt(n2**2.+NA**2.) #core refractive index\n",
      "print '%s %.2f %s' %(\"Core refractive index =\",n1,\"\\n\")\n",
      "n=1.33 #water refractive index\n",
      "NA=math.sqrt(n1**2.-n2**2.)/n0 #numerical apperture\n",
      "print '%s %.2f %s' %(\"Numerical apperture =\",NA,\"\\n\")\n",
      "AA_rad=math.asin(NA/n) #maximum Acceptance angle in rad\n",
      "AA=AA_rad*180./math.pi #maximum entrance angle in degree\n",
      "print '%s %.2f %s' %(\"The maximum entrance angle i0 =\",AA,\"degree\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Core refractive index = 1.60 \n",
        "\n",
        "Numerical apperture = 0.20 \n",
        "\n",
        "The maximum entrance angle i0 = 8.65 degree\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E7 - Pg 697"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex14_7 Pg-697\n",
      "#core refractive index, cladding refractive index\n",
      "import math\n",
      "NA=0.22 #numerical apperture\n",
      "dela=0.012 #fractional difference of refractive indices\n",
      "n1=NA/(math.sqrt(2.*dela)) #core refractive index\n",
      "print '%s %.2f %s' %(\"Core refractive index =\",n1,\"\\n\")\n",
      "n2=n1-dela*n1 #cladding refractive index\n",
      "print '%s %.2f %s' %(\"Cladding refractive index =\",n2,\"\\n\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Core refractive index = 1.42 \n",
        "\n",
        "Cladding refractive index = 1.40 \n",
        "\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E8 - Pg 698"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex14_8 Pg-698\n",
      "#numerical aperture,acceptance angle, critical angle\n",
      "import math\n",
      "n1=1.52 #core refracrive index\n",
      "n2=1.46 #cladding refractive index\n",
      "dela=(n1-n2)/n1 #fractional difference of refractive indices\n",
      "asin=1.\n",
      "NA=n1*math.sqrt(2.*dela) #numerical apperture\n",
      "print '%s %.2f %s' %(\"Numerical apperture =\",NA,\"\\n\")\n",
      "AA_rad=math.asin(NA/n1) #maximum Acceptance angle in rad\n",
      "AA=AA_rad*180./math.pi #maximum entrance angle in degree\n",
      "print '%s %.2f %s' %(\"Acceptance angle i0 =\",AA,\"degree\\n\")\n",
      "tetha_rad=math.asin(n2/n1) #critical angle in radians\n",
      "tetha=tetha_rad*180./math.pi #critical angle in degree \n",
      "print '%s %.2f %s' %(\"Critical angle =\",tetha,\"degree\\n\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Numerical apperture = 0.43 \n",
        "\n",
        "Acceptance angle i0 = 16.32 degree\n",
        "\n",
        "Critical angle = 73.85 degree\n",
        "\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E9 - Pg 698"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex14_9 Pg-698\n",
      "import math\n",
      "n1=1.45 #core refracrive index\n",
      "NA=0.16#cladding refractive index\n",
      "lamda=0.9*10.**(-6.) #cut-off wavelength\n",
      "d=60./100. #core radius in m\n",
      "V=(math.pi*d*NA)/lamda #normalised frequency\n",
      "print '%s %.2f %s' %(\"Normalised frequency =\",V*1e-5,\"*1e5\\n\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Normalised frequency = 3.35 *1e5\n",
        "\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E10 - Pg 698"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex14_10 Pg-698\n",
      "#radis of core, numerical apperture, acceptance angle\n",
      "import math \n",
      "n1=1.48 #core refracrive index\n",
      "n2=1.47 #cladding refractive index\n",
      "lamda=850e-6 #cut-off wavelength\n",
      "V=2.405 #normalised frequency\n",
      "asin=1.\n",
      "n=n1+n2\n",
      "#In the book cut off wavelength in the question is 850 um but in\n",
      "# the calcution part it is taken as 850nm. Here Ive taken 850um \n",
      "d=V*lamda/(math.pi*math.sqrt(n1**2.-n2**2.)) #diamter of core\n",
      "a=d/2. #radius of core\n",
      "print '%s %.2f %s' %(\"Radius of core =\",a*1e3,\"mm\\n\")#answer in the book is wrong\n",
      "NA=math.sqrt(n1**2.-n2**2.) #numerical apperture\n",
      "print '%s %.2f %s' %(\"Numerical apperture =\",NA,\"\\n\")\n",
      "AA_rad=math.asin(NA/n) #maximum Acceptance angle in rad\n",
      "AA=AA_rad*180./math.pi #maximum entrance angle in degree\n",
      "print '%s %.2f %s' %(\"Acceptance angle i0 =\",AA,\"degree\\n\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Radius of core = 1.89 mm\n",
        "\n",
        "Numerical apperture = 0.17 \n",
        "\n",
        "Acceptance angle i0 = 3.34 degree\n",
        "\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E11 - Pg 699"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex14_11 Pg-699\n",
      "#loss in fiber\n",
      "import math\n",
      "L=500./1000. #length of fiber in m\n",
      "Pin=1.*10.**(-3.) #input power in watt\n",
      "Pout=85./100.*10.**(-3.) #output power in watt\n",
      "alpha=(10./L)*math.log10(Pin/Pout) #loss\n",
      "print '%s %.2f %s' %(\"Loss in the fiber =\",alpha,\"dB/Km\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Loss in the fiber = 1.41 dB/Km\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E12 - Pg 699"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex14_12 Pg-699\n",
      "import math\n",
      "L=10. #length of fiber in km\n",
      "alpha=2.5 #loss in the fiber per km\n",
      "Pin=500.*10.**(-6.) #input power in watt\n",
      "tot_alpha=-1.*alpha*L #total loss in the fiber\n",
      "Pout=Pin*10.**(tot_alpha/10.) #output power in watt\n",
      "print '%s %.2f %s' %(\"Output power =\",Pout*1e6,\"uW\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Output power = 1.58 uW\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E13 - Pg 700"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex14_13 Pg-700\n",
      "#Maximum core diameter which permit single mode operation\n",
      "import math \n",
      "dela=1./100. #fractional difference of refractive indices\n",
      "lamda=1.3*10.**(-6.) #cutoff wavelength in m\n",
      "n1=1.5 #refractive index\n",
      "d=6.6*10.**(-6.) #diameter of the core\n",
      "alpha=2. #loss in fiber\n",
      "print'%s' %(\"We have for a GRIN , maximum value of normalized frequency for single mode operation is given by\")\n",
      "print'%s' %(\"V = 2.4*math.sqrt(1+2/alpha)\")\n",
      "V=2.4*math.sqrt(1.+2./alpha) #normalzed frequency\n",
      "print'%s' %(\"For maximum core radiation , we have\")\n",
      "r=V*lamda/(2.*math.pi*n1*math.sqrt(2.*dela)) #radius of the core\n",
      "print'%s %.2f %s' %(\"r =\",r*1e6,\"um\\n\")\n",
      "rr=2.*r #diameter of the core\n",
      "print'%s %.2f %s' %(\"\\nMaximum core diameter which permit single mode operation\\n=2*r =\",rr*1e6,\"um\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "We have for a GRIN , maximum value of normalized frequency for single mode operation is given by\n",
        "V = 2.4*math.sqrt(1+2/alpha)\n",
        "For maximum core radiation , we have\n",
        "r = 3.31 um\n",
        "\n",
        "\n",
        "Maximum core diameter which permit single mode operation\n",
        "=2*r = 6.62 um\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E14 - Pg 700"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex14_14 Pg-700\n",
      "#Maximum core diameter which permit single mode operation\n",
      "import math\n",
      "dela=1.5/100. #fractional difference of refractive indices\n",
      "lamda=0.85*10.**(-6.) #cutoff wavelength in m\n",
      "n1=1.48 #refractive index\n",
      "d=6.6*10.**(-6.) #diameter of the core\n",
      "V=2.4 #normalzed frequency\n",
      "print '%s' %(\"For maximum core radiation,we have\")\n",
      "r=V*lamda/(2.*math.pi*n1*math.sqrt(2.*dela))\n",
      "print '%s %.2f %s' %(\"r=\",r*1e6,\"um\\n\")\n",
      "r=1.3*10.**(-6.) #actual radius=1.266 micrometer and assumed to 1.3 micometer\n",
      "rr=2.*r #diameter of the core\n",
      "print '%s %.2f %s' %(\"\\nMaximum core diameter which permit single mode operation\\n=2*r=\",rr*1e6,\"um\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "For maximum core radiation,we have\n",
        "r= 1.27 um\n",
        "\n",
        "\n",
        "Maximum core diameter which permit single mode operation\n",
        "=2*r= 2.60 um\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E15 - Pg 701"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex14_15 Pg-701\n",
      "#attenuation of an optial fiber, output power\n",
      "import math\n",
      "alpha=3.5 #loss in fiber\n",
      "Pi=0.5#input power in milli watt\n",
      "L=4. #length of fiber in km\n",
      "print '%s' %(\"The attenuation of an optical fiber is given by\")\n",
      "print '%s' %(\"alpha=(10/L)*math.log(Pi/Po)\")\n",
      "Po=Pi/(10.**(alpha*L/10.))\n",
      "print '%s %.2f %s' %(\"\\nOutput power =\",Po*1e3,\"mW\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The attenuation of an optical fiber is given by\n",
        "alpha=(10/L)*math.log(Pi/Po)\n",
        "\n",
        "Output power = 19.91 mW\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E16 - Pg 701"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex14_16 Pg-701\n",
      "#cut-off wavelength expression\n",
      "import math\n",
      "n1=1.46 #core refracrive index\n",
      "r=4.5*10.**(-6.)  #radius of the core\n",
      "dela=0.25/100. #fractional difference of refractive indices\n",
      "Vc=2.405 #normalzed frequency\n",
      "print '%s' %(\"We have, cut-off wavelength expression\")\n",
      "lamda=(2*math.pi*r*n1*math.sqrt(2.*dela))/Vc\n",
      "print '%s %.2f %s' %(\"=\",lamda*1e6,\"um\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "We have, cut-off wavelength expression\n",
        "= 1.21 um\n"
       ]
      }
     ],
     "prompt_number": 16
    }
   ],
   "metadata": {}
  }
 ]
}