{
 "metadata": {
  "name": "",
  "signature": "sha256:afd6588cf456d4d425f74443bb32014c9097e23d883f51c38473cadd2c6f5ba9"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 2: Optical Fibers"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.1, Page number 49"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Determine maximum thickness of film'''\n",
      "\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "n1 = 3.5         #core refractive index\n",
      "n2 = 3.0         #cladding refractive index\n",
      "v = 6            #no. of modes\n",
      "lamda = 1.5      #propagating wavelength(um)\n",
      "\n",
      "#Calculations\n",
      "theta_c = math.degrees(math.asin(n2/n1))\n",
      "h = (2*math.pi*v*lamda)/(2*math.pi*n1*math.cos(math.radians(theta_c)))\n",
      "\n",
      "#Result\n",
      "print \"The thickness of the film should be less than\",round(h),\"um\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The thickness of the film should be less than 5.0 um\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.2, Page number 50"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''find the angle of acceptance and crtitical angle'''\n",
      "\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "n1 = 1.53         #core refractive index\n",
      "n2 = 1.48         #cladding refractive index\n",
      "n0 = 1            #refractive index for air\n",
      "\n",
      "#calculations\n",
      "theta_a = math.degrees(math.asin(((n1**2-n2**2)**0.5)/n0))   \n",
      "\n",
      "theta_c = math.degrees(math.asin(n2/n1))\n",
      "\n",
      "#Result\n",
      "print \"Angle of acceptance =\",round(theta_a,2),\"degrees\"\n",
      "print \"Critical angle =\",round(theta_c,2),\"degrees\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Angle of acceptance = 22.83 degrees\n",
        "Critical angle = 75.31 degrees\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.3, Page number 50"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Determine the numerical aperture'''\n",
      "\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "v = 26.6         #frequency(Hz)\n",
      "lamda = 1.3      #propagating wavelength(um)\n",
      "a = 25           #core radius(um)\n",
      "\n",
      "#Calculation\n",
      "NA = (v*lamda)/(2*math.pi*a)\n",
      "\n",
      "#Result\n",
      "print \"Numerical aperture =\",round(NA,2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Numerical aperture = 0.22\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.4, Page number 51"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Determine the numerical aperture'''\n",
      "\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "n1 = 1.4675         #core refractive index\n",
      "n2 = 1.4622         #cladding refractive index\n",
      "\n",
      "#Calculation\n",
      "NA = math.sqrt(n1**2-n2**2)\n",
      "\n",
      "#Result\n",
      "print \"Numerical aperture =\",round(NA,3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Numerical aperture = 0.125\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.5, Page number 51"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Determine cut-off wavelength for step index fiber'''\n",
      "\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "n1 = 1.5         #core refractive index\n",
      "n2 = 1.47        #cladding refractive index\n",
      "a = 4            #core radius(um)\n",
      "\n",
      "#Calculation\n",
      "lamda_c = (2*math.pi*a*((n1**2-n2**2)**0.5))/2.405\n",
      "\n",
      "#Result\n",
      "print \"The cut-off wavelength is\",round(lamda_c,2),\"um\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The cut-off wavelength is 3.12 um\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.6, Page number 51"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Determine maximum diameter of the core for single mode fiber'''\n",
      "\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "n1 = 1.55         #core refractive index\n",
      "n2 = 1.48         #cladding refractive index\n",
      "lamda = 1.55      #wavelength(um)\n",
      "\n",
      "#Calculations\n",
      "a = (2.405*lamda)/(2*math.pi*(n1**2-n2**2)**0.5)\n",
      "d = 2*a #diameter\n",
      "\n",
      "#Result\n",
      "print \"Maximum diameter of the core is\",round(d,2),\"um\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Maximum diameter of the core is 2.58 um\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.7, Page number 52"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Determine the number of modes propagating'''\n",
      "\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "n1 = 1.48         #core refractive index\n",
      "n2 = 0.01         #cladding refractive index\n",
      "a = 25            #core radius(um)\n",
      "lamda = 0.84      #Wavelength(um)\n",
      "\n",
      "#Calculation\n",
      "m = 2*(2*math.pi/lamda)**2*(a**2/2)*(n1**2-n2**2)\n",
      "v = math.sqrt(2*m)\n",
      "\n",
      "#Result\n",
      "print \"Number of modes =\",v, \"(Calculation mistake in textbook while calculating 'm'. Hence, the answer differs)\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Number of modes = 391.074660134 (Calculation mistake in textbook while calculating 'm'. Hence, the answer differs)\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.8, Page number 52"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Determine the number of modes for multimode fiber and calculate the same when lamda is changed to 1.3um'''\n",
      "\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "n1 = 1.475       #core refractive index\n",
      "n2 = 1.472       #cladding refractive index\n",
      "a = 20           #core radius(um)\n",
      "lamda = 0.85      #Wavelength(um)\n",
      "\n",
      "#Calculation\n",
      "v = (2*math.pi*a*math.sqrt((n1**2-n2**2)))/lamda\n",
      "M1 = v**2/2\n",
      "\n",
      "lamda2 = 1.3    #um\n",
      "v2 = (2*math.pi*a*math.sqrt((n1**2-n2**2)))/lamda2\n",
      "M2 = v2**2/2\n",
      "\n",
      "#Results\n",
      "print \"Number of modes when lamda is changed =\",round(M1) #v is calculated wrongly in the book and answer for case a M not given\n",
      "print \"Number of modes when lamda is changed =\",round(M2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Number of modes when lamda is changed = 97.0\n",
        "Number of modes when lamda is changed = 41.0\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.9, Page number 53"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Determine the numerical aperture'''\n",
      "\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "n1 = 1.5          #core refractive index\n",
      "n2 = 1.48         #cladding refractive index\n",
      "\n",
      "#Calculation\n",
      "NA = math.sqrt(n1**2-n2**2)\n",
      "\n",
      "#Result\n",
      "print \"Numerical aperture =\",round(NA,5)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Numerical aperture = 0.24413\n"
       ]
      }
     ],
     "prompt_number": 21
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.10, Page number 53"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Determine core radius, NA and maximum acceptance angle'''\n",
      "\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "n1 = 1.450       #core refractive index\n",
      "n2 = 1.447       #cladding refractive index\n",
      "lamda = 1.3      #Wavelength(um)\n",
      "\n",
      "#Calculation\n",
      "v = 2.405\n",
      "a = (v*lamda)/(2*math.pi*math.sqrt((n1**2-n2**2)))\n",
      "\n",
      "NA = math.sqrt(n1**2-n2**2)\n",
      "\n",
      "theta_max = math.degrees(math.asin(NA))\n",
      "\n",
      "#Results\n",
      "print \"Core radius =\",round(a,3),\"um\"\n",
      "print \"Numerical aperture =\",round(NA,4)\n",
      "print \"Maximum acceptance angle =\",round(theta_max,3),\"degrees\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Core radius = 5.338 um\n",
        "Numerical aperture = 0.0932\n",
        "Maximum acceptance angle = 5.349 degrees\n"
       ]
      }
     ],
     "prompt_number": 37
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.11, Page number 53"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Determine critical angle at core cladding interface, NA and acceptance angle'''\n",
      "\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "n1 = 1.50       #core refractive index\n",
      "n2 = 1.47       #cladding refractive index\n",
      "\n",
      "#calculations\n",
      "theta_c = math.degrees(math.asin(n2/n1))\n",
      "\n",
      "NA = math.sqrt(n1**2-n2**2)\n",
      "\n",
      "theta_a = math.degrees(math.asin(NA))\n",
      "\n",
      "#Result\n",
      "print \"Critical angle at core cladding interface =\",round(theta_c,1),\"degrees\"\n",
      "print \"Numerical aperture =\",round(NA,2)\n",
      "print \"Maximum acceptance angle =\",round(theta_a,1),\"degrees\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Critical angle at core cladding interface = 78.5 degrees\n",
        "Numerical aperture = 0.3\n",
        "Maximum acceptance angle = 17.4 degrees\n"
       ]
      }
     ],
     "prompt_number": 38
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.12, Page number 55"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Determine the acceptance angle for skew rays'''\n",
      "\n",
      "#Variable declaration\n",
      "NA = 0.4    #numerical aperture\n",
      "#Since skew rays change direction by 100 degrees at each reflection,\n",
      "r = 50      #degrees\n",
      "\n",
      "#Calculations\n",
      "theta_as = math.degrees(math.asin(NA/math.cos(math.radians(r))))\n",
      "\n",
      "#print\n",
      "print \"Acceptance angle =\",round(theta_as,1),\"degrees\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Acceptance angle = 38.5 degrees\n"
       ]
      }
     ],
     "prompt_number": 39
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.13, Page number 55"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Determine normalized frequency and number of guided modes'''\n",
      "\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "n1 = 1.48       #core refractive index\n",
      "lamda = 0.85    #wavelength(um)\n",
      "a = 80/2        #core radius(um)\n",
      "delta = 1.5/100 #relative index difference\n",
      "\n",
      "#Calculations\n",
      "v = (2*math.pi*a*n1*(2*delta)**0.5)/lamda\n",
      "\n",
      "M = v**2/2\n",
      "\n",
      "#Results\n",
      "print \"Normalized frequency =\",round(v,1),\"Hz\"\n",
      "print \"Number of guided modes =\",round(M)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Normalized frequency = 75.8 Hz\n",
        "Number of guided modes = 2872.0\n"
       ]
      }
     ],
     "prompt_number": 40
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.14, Page number 56"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Determine cut off value for normalized frequency and maximum core radius'''\n",
      "\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "n1 = 1.5          #core refractive index\n",
      "lamda = 1.3       #wavelength(um)\n",
      "delta = 1./100.   #relative index difference\n",
      "alpha = 2\n",
      "\n",
      "#Calculations\n",
      "v = 2.4*(1+2/alpha)**0.5\n",
      "\n",
      "a = (v*lamda)/(2*math.pi*n1*(2*delta)**0.5)\n",
      "\n",
      "#Results\n",
      "print \"Cut off value for normalized frequency =\",round(v,2)\n",
      "print \"Maximum core radius =\",round(a,2),\"um\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Cut off value for normalized frequency = 3.39\n",
        "Maximum core radius = 3.31 um\n"
       ]
      }
     ],
     "prompt_number": 42
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.15, Page number 56"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Determine cut-off wavelength for step index fiber'''\n",
      "\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "n1 = 1.46         #core refractive index\n",
      "a = 4.5           #core radius(um)\n",
      "delta = 0.25/100\n",
      "\n",
      "#Calculation\n",
      "lamda_c = (2*math.pi*a*n1*(2*delta)**0.5)/2.405\n",
      "\n",
      "#Result\n",
      "print \"The cut-off wavelength is\",round(lamda_c,3),\"um\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The cut-off wavelength is 1.214 um\n"
       ]
      }
     ],
     "prompt_number": 43
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.16, Page number 57"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Determine the numerical aperture and acceptance angle'''\n",
      "\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "n1 = 1.45         #core refractive index\n",
      "n2 = 1.4          #cladding refractive index\n",
      "\n",
      "#Calculation\n",
      "NA = math.sqrt(n1**2-n2**2)\n",
      "\n",
      "theta_m = math.degrees(math.asin(NA))\n",
      "\n",
      "#Result\n",
      "print \"Numerical aperture =\",round(NA,4)\n",
      "print \"Acceptance angle =\",round(theta_m,2),\"degrees\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Numerical aperture = 0.3775\n",
        "Acceptance angle = 22.18 degrees\n"
       ]
      }
     ],
     "prompt_number": 44
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.17, Page number 57"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Calculate cladding index, crtical internal reflection angle, external critical acceptance angle and numerical aperture'''\n",
      "\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "n1 = 1.5       #core refractive index\n",
      "delta = 0.0005\n",
      "\n",
      "#Calculations\n",
      "n2 = n1*(1-delta)\n",
      "\n",
      "theta_c = math.degrees(math.asin(n2/n1))\n",
      "\n",
      "n0 = 1   #refractive index for air\n",
      "theta_m = math.degrees(math.asin(((n1**2-n2**2)**0.5)/n0))\n",
      "\n",
      "NA = n1*math.sqrt(2*delta)\n",
      "\n",
      "#Results\n",
      "print \"Cladding index =\",round(n2,5)\n",
      "print \"Crtical internal reflection angle =\",round(theta_c,1),\"degrees\"\n",
      "print \"External critical acceptance angle =\",round(theta_m,2),\"Degrees\"\n",
      "print \"Numerical aperture =\",round(NA,4)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Cladding index = 1.49925\n",
        "Crtical internal reflection angle = 88.2 degrees\n",
        "External critical acceptance angle = 2.72 Degrees\n",
        "Numerical aperture = 0.0474\n"
       ]
      }
     ],
     "prompt_number": 46
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.18, Page number 58"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Determine acceptance angle for fiber in water'''\n",
      "\n",
      "#Variable declaration\n",
      "NA = 0.20    #numerical aperture\n",
      "n2 = 1.59    #cladding refractive index\n",
      "n0 = 1.33    #refractive index for water \n",
      "\n",
      "#Calculations\n",
      "n1 = math.sqrt(NA**2+n2**2)\n",
      "NA = math.sqrt(n1**2-n2**2)/n0\n",
      "theta_m = math.degrees(math.asin(NA))\n",
      "\n",
      "#Result\n",
      "print \"Acceptance angle for fiber in water =\",round(theta_m,1),\"degrees\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Acceptance angle for fiber in water = 8.6 degrees\n"
       ]
      }
     ],
     "prompt_number": 47
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.19, Page number 58"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Determine the numerical aperture and acceptance angle'''\n",
      "\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "n1 = 1.55         #core refractive index\n",
      "n2 = 1.51         #cladding refractive index\n",
      "\n",
      "#Calculation\n",
      "delta = (n1-n2)/n1\n",
      "NA = 2*math.sqrt(delta)\n",
      "\n",
      "theta_m = math.degrees(math.asin(NA))\n",
      "\n",
      "#Result\n",
      "print \"Numerical aperture =\",round(NA,4)\n",
      "print \"Acceptance angle =\",round(theta_m,2),\"degrees\"\n",
      "print \"\\nCalculation mistakes in textbook. Hence, the answers differ.\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Numerical aperture = 0.3213\n",
        "Acceptance angle = 18.74 degrees\n",
        "\n",
        "Calculation mistakes in textbook. Hence, the answers differ.\n"
       ]
      }
     ],
     "prompt_number": 49
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.20, Page number 59"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Determine normalized frequency'''\n",
      "\n",
      "#Variable declaration\n",
      "n = 1.45        #core refractive index\n",
      "lamda = 0.1     #wavelength(um)\n",
      "a = 60/2        #core radius(um)\n",
      "NA = 0.16       #numerical aperture\n",
      "\n",
      "#Calculations\n",
      "v = (2*math.pi*a*NA)/lamda\n",
      "\n",
      "#Results\n",
      "print \"Normalized frequency =\",round(v,1),\"(Calculation mistake in textbook)\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Normalized frequency = 301.6 (Calculation mistake in textbook)\n"
       ]
      }
     ],
     "prompt_number": 50
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.21, Page number 59"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Calculate NA and multi path dospersion per unit length'''\n",
      "\n",
      "#Variable declaration\n",
      "c = 3.*10**8    #speed of light in vacuum(m/s)\n",
      "v = 2.*10**8    #speed of light in core(m/s)\n",
      "theta_c = 75    #cricial angle(degrees)\n",
      "\n",
      "#Calculations\n",
      "n1 = c/v\n",
      "n2 = n1*math.sin(math.radians(theta_c))\n",
      "NA = math.sqrt(n1**2-n2**2)\n",
      "\n",
      "delta_n = n1-n2\n",
      "md = (n1/n2)*(delta_n/c)  #multipath dispersion\n",
      "\n",
      "#Results\n",
      "print \"Numerical aperture =\",round(NA,2)\n",
      "print \"Multi path dospersion per unit length =\",round((md/1E-9),3),\"*10^-9 s/m\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Numerical aperture = 0.39\n",
        "Multi path dospersion per unit length = 0.176 *10^-9 s/m\n"
       ]
      }
     ],
     "prompt_number": 51
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.22, Page number 60"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Determine maximum thickness of guide slab'''\n",
      "\n",
      "#Variable declaration\n",
      "n1 = 3.6          #core refractive index\n",
      "n2 = 3.56         #cladding refractive index\n",
      "lamda = 0.85      #wavelength(um)\n",
      "#For TE10 mode,\n",
      "m = 1\n",
      "n = 0\n",
      "vc = 2.405        #for planar guide\n",
      "\n",
      "#Calculation\n",
      "a = (vc*lamda)/(2*math.pi*math.sqrt(n1**2-n2**2))\n",
      "\n",
      "#Result\n",
      "print \"Maximum thickness of guide slab =\",round(a,3),\"um\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Maximum thickness of guide slab = 0.608 um\n"
       ]
      }
     ],
     "prompt_number": 52
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.23, Page number 61"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Calculate diameter of core'''\n",
      "\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "n1 = 1.5          #core refractive index\n",
      "lamda = 1.3*10**-6       #wavelength(um)\n",
      "delta = 1./100.   #relative index difference\n",
      "M = 1100\n",
      "\n",
      "#Calculations\n",
      "V = math.sqrt(2*M)\n",
      "\n",
      "a = (V*lamda)/(2*math.pi*n1*(2*delta)**0.5)\n",
      "\n",
      "d = 2*a\n",
      "\n",
      "#Result\n",
      "print \"Diameter =\",round(d/1E-5,2),\"um(Calculation mistake in textbook)\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Diameter = 9.15 um(Calculation mistake in textbook)\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.24, Page number 62"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Determine critical angle and numerical aperture'''\n",
      "\n",
      "\n",
      "#Variable declaration\n",
      "n1 = 1.50         #core refractive index\n",
      "n2 = 1.46         #cladding refractive index\n",
      "\n",
      "#Calculation\n",
      "theta_c = math.degrees(math.asin(n2/n1))\n",
      "\n",
      "NA = math.sqrt(n1**2-n2**2)\n",
      "\n",
      "#Result\n",
      "print \"Critical angle =\",round(theta_c,2),\"degrees\"\n",
      "print \"Numerical aperture =\",round(NA,2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Critical angle = 76.74 degrees\n",
        "Numerical aperture = 0.34\n"
       ]
      }
     ],
     "prompt_number": 59
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.25, Page number 62"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Determine the acceptance angle for skew rays'''\n",
      "\n",
      "#Variable declaration\n",
      "NA = 0.344    #numerical aperture\n",
      "#Since skew rays change direction by 100 degrees at each reflection,\n",
      "gamma = 100/2      #degrees\n",
      "\n",
      "#Calculations\n",
      "#For meridional rays\n",
      "theta_a = math.degrees(math.asin(NA))\n",
      "#For speed rays\n",
      "theta_as = math.degrees(math.asin(NA/math.cos(math.radians(gamma))))\n",
      "\n",
      "#print\n",
      "print \"Acceptance angle for meridional rays =\",round(theta_a,2),\"degrees\"\n",
      "print \"Acceptance angle for speed rays =\",round(theta_as,2),\"degrees\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Acceptance angle for meridional rays = 20.12 degrees\n",
        "Acceptance angle for speed rays = 32.36 degrees\n"
       ]
      }
     ],
     "prompt_number": 84
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.26, Page number 62"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "'''Calculate the no. of guided modes and cut-off value of normalized frequency'''\n",
      "\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "n1 = 1.5           #core refractive index\n",
      "lamda = 1.55       #wavelength(um)\n",
      "delta = 1.3/100.   #relative index difference\n",
      "alpha = 1.90       #index profile\n",
      "a = 40/2           #core radius(um)\n",
      "\n",
      "#Calculations\n",
      "Mg = (alpha/(alpha+2))*((n1*2*math.pi*a)/lamda)**2*delta\n",
      "\n",
      "Vc = 2.405*math.sqrt(1+2/alpha)\n",
      "\n",
      "#Results\n",
      "print \"Number of guided modes =\",round(Mg)\n",
      "print \"Cut-off value of normalized frequency =\",round(Vc,2)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Number of guided modes = 94.0\n",
        "Cut-off value of normalized frequency = 3.45\n"
       ]
      }
     ],
     "prompt_number": 61
    }
   ],
   "metadata": {}
  }
 ]
}