{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 5: Fibre Optics"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.1, Page 5.15"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import pi, sqrt, asin\n",
      "\n",
      "# Given \n",
      "mu1 = 1.52 # refractive index for core\n",
      "mu2 = 1.41 # refractive index for cladding\n",
      "\n",
      "#Calculations\n",
      "theta_c = asin(mu2 / mu1) * (180 / pi)\n",
      "NA = sqrt(mu1**2 - mu2**2)\n",
      "theta_0 = asin(NA) * (180 / pi)\n",
      "\n",
      "#Result\n",
      "print \"Critical angle = %.2f degree \\nNumerical aperture = %.3f\\nMaximum incidence angle = %.1f degree\"%(theta_c,NA,theta_0)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Critical angle = 68.07 degree \n",
        "Numerical aperture = 0.568\n",
        "Maximum incidence angle = 34.6 degree\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.2, Page 5.16"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import pi, sqrt, asin\n",
      "\n",
      "# Given \n",
      "mu1 = 1.6 # refractive index for core\n",
      "mu2 = 1.5 # refractive index for cladding\n",
      "\n",
      "#Calculations\n",
      "NA = sqrt(mu1**2 - mu2**2)#calculation for numerical aperture\n",
      "theta_0 = asin(NA) * (180 / pi)#calculation for maximum incidence angle\n",
      "\n",
      "#Result\n",
      "print \"Numerical aperture = %.3f\\nMaximum incidence angle = %.2f degree\"%(NA,theta_0)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Numerical aperture = 0.557\n",
        "Maximum incidence angle = 33.83 degree\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.3, Page 5.16"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import pi, sqrt, asin\n",
      " \n",
      "# Given \n",
      "mu_0 = 1 # refractive index of air\n",
      "mu1 = 1.5 # refractive index for core\n",
      "mu2 = 1.48 # refractive index for cladding\n",
      "\n",
      "#Calculations\n",
      "theta_c = asin(mu2 / mu1) * (180 / pi)\n",
      "delta_mu = (mu1 - mu2) / mu1\n",
      "NA = sqrt(mu1**2 - mu2**2)\n",
      "theta_0 = asin(NA) * (180 / pi)\n",
      "\n",
      "#Result\n",
      "print \"Critical angle = %.2f degrees \\nNumerical aperture = %.3f \\nAcceptance angle = %.2f degrees\\nFractional refractive index = %.2f %%\"%(theta_c,NA,theta_0,delta_mu*100)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Critical angle = 80.63 degrees \n",
        "Numerical aperture = 0.244 \n",
        "Acceptance angle = 14.13 degrees\n",
        "Fractional refractive index = 1.33 %\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.4, Page 5.17"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import * \n",
      "# Given \n",
      "mu1 = 1.62 # refractive index for core\n",
      "mu2 = 1.52 # refractive index for cladding\n",
      "\n",
      "#Calculations\n",
      "NA = sqrt(mu1**2 - mu2**2)\n",
      "theta_0 = asin(NA) * (180 / pi)\n",
      "\n",
      "#Results\n",
      "print \"Numerical aperture = %.2f \\nMaximum incidence angle = %.1f degrees\"%(NA,theta_0)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Numerical aperture = 0.56 \n",
        "Maximum incidence angle = 34.1 degrees\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.5, Page 5.17"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import sqrt\n",
      "\n",
      "# Given \n",
      "NA = 0.22 # numerical aperture\n",
      "delta_mu = 0.012 # fractional refractive index\n",
      "\n",
      "#Calculations\n",
      "mu1 = sqrt(NA**2 / (1 - (1 - delta_mu)**2))\n",
      "mu2 = (1 - delta_mu) * mu1\n",
      "\n",
      "#Result\n",
      "print \"Refractive index for core = %.3f\\nRefractive index for cladding = %.2f\"%(mu1,mu2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Refractive index for core = 1.424\n",
        "Refractive index for cladding = 1.41\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.6, Page 5.17"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import pi, sqrt, asin, sin\n",
      "\n",
      "# Given \n",
      "d = 0.0064 # diameter of fiber in cm\n",
      "mu1 = 1.53 # refractive index for core\n",
      "mu2 = 1.39 # refractive index for clad\n",
      "L = 90 # length of fiber in cm\n",
      "mu_0 = 1 # refractive index of air\n",
      "\n",
      "#calculations\n",
      "NA = sqrt(mu1**2 - mu2**2)\n",
      "theta_0 = asin(NA) * (180 / pi)\n",
      "N1 = L / (d * sqrt((mu1 / (mu_0 * sin(theta_0 * (pi / 180))))**2 - 1))\n",
      "N2 = L / (d * sqrt((mu1 / (mu_0 * sin(theta_0 * (pi / 360))))**2 - 1))\n",
      "\n",
      "#Result\n",
      "print \"Numerical aperture = %.2f\\nAcceptance angle = %.1f degrees \\nNumber of reflections at maximum incidence = %.f \\nNumber of reflections in second case = %.f \"%(NA,theta_0,N1,N2)\n",
      "#Incorrect answer in the textbook"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Numerical aperture = 0.64\n",
        "Acceptance angle = 39.7 degrees \n",
        "Number of reflections at maximum incidence = 6468 \n",
        "Number of reflections in second case = 3204 \n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.7, Page 5.18"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import pi\n",
      "\n",
      "# Given \n",
      "d = 0.05 # diameter of fiber in mm\n",
      "NA = 0.22 # numerical aperture\n",
      "l = 8.5e-4 # wavelength of light in mm\n",
      "\n",
      "#calculations\n",
      "Vn = (pi * d * NA) / l\n",
      "Mm = 0.5 * (Vn)**2\n",
      "\n",
      "#Result\n",
      "print \"The normalized frequency = %.2f\\nNumber of guided in the core = %d\"%(Vn,Mm)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The normalized frequency = 40.66\n",
        "Number of guided in the core = 826\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.8, Page 5.18"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import sqrt, pi\n",
      "\n",
      "# Given \n",
      "l = 1.25e-6 #wavelength of light in meter\n",
      "mu1 = 1.465 # refractive index for core\n",
      "mu2 = 1.460 # refractive index for cladding\n",
      "\n",
      "#Calculations\n",
      "NA = sqrt(mu1**2 - mu2**2)\n",
      "k = (2.4 * l) / ( pi * NA)\n",
      "Mm = 0.5 * ((pi * 50e-6 * NA) / l)**2\n",
      "\n",
      "#Result\n",
      "print \"Diameter of core < %.1e meter,\\n number of modes = %d\"%(k,Mm)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Diameter of core < 7.9e-06 meter,\n",
        " number of modes = 115\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.9, Page 5.19"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import sqrt, pi\n",
      "\n",
      "# Given \n",
      "l = 0.85e-6 #wavelength of light in meter\n",
      "mu1 = 1.461 # refractive index for core\n",
      "mu2 = 1.456 # refractive index for clad\n",
      "d = 4e-5 # diameter of core in meter\n",
      "\n",
      "#Calculations\n",
      "NA = sqrt(mu1**2 - mu2**2)\n",
      "Mm = 0.5 * ((pi * d * NA) / l)**2\n",
      "\n",
      "#Result\n",
      "print \"Numerical aperture = %.3f\\n Number of modes = %d \"%(NA,Mm)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Numerical aperture = 0.121\n",
        " Number of modes = 159 \n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.10, Page 5.19\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import sqrt, pi\n",
      "\n",
      "# Given\n",
      "mu1 = 3.6 # refractive index for core\n",
      "mu2 = 3.55 # refractive index for cladding\n",
      "\n",
      "#Calculations\n",
      "NA = sqrt(mu1**2 - mu2**2)#calculation for numerical aperture\n",
      "Mm1 = 0.5 * (pi * 5 * NA)**2#calculation for no. of modes in first case\n",
      "Mm2 = 0.5 * (pi * 50 * NA)**2#calculation for no. of modes in second case\n",
      "\n",
      "#Result\n",
      "print \"Number of modes in first case = %d \\nNumber of modes in second case = %d\"%(Mm1,Mm2)\n",
      "#Incorrect answer in the textbook"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Number of modes in first case = 44 \n",
        "Number of modes in second case = 4410\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.11, Page 5.20"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import sqrt, pi\n",
      "\n",
      "# Given \n",
      "l = 1.25e-6 #wavelength of light in meter\n",
      "mu1 = 1.46 # refractive index for core\n",
      "mu2 = 1.457 # refractive index for cladding\n",
      "\n",
      "#Calculations\n",
      "NA = sqrt(mu1**2 - mu2**2)#calculation for numerical aperture\n",
      "k = (2.4 * l) / ( pi * NA)\n",
      "\n",
      "#Result\n",
      "print \"Maximum diameter of core = %.2f micro meter\"%(k*1e6)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Maximum diameter of core = 10.21 micro meter\n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.12, Page 5.20"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import log10\n",
      "\n",
      "# Given \n",
      "L = 0.1 # length of fiber in km\n",
      "p = 5e-6 # power of signal in watt\n",
      "p_ = 1e-6 # power of signal inside the fiber in watt\n",
      "\n",
      "#Calculation\n",
      "alpha = (10 * log10(p / p_)) / L#calculation for absorption coefficient\n",
      "\n",
      "#Result\n",
      "print \"Absorption coefficient = %d dB/km \"%alpha"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Absorption coefficient = 69 dB/km \n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.13, Page 5.20"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import exp\n",
      "\n",
      "# Given \n",
      "L = 3 # length of optical fiber in km\n",
      "l = 6 # losses in dB\n",
      "p = 5e-3 # input power in watt \n",
      "\n",
      "#calculations\n",
      "alpha = (l * 3) / L\n",
      "p_ = p / (exp((2.303 * alpha * L) / 10))\n",
      "\n",
      "#Result\n",
      "print \"Output power = %.3f mW \"%(p_*1e3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Output power = 0.079 mW \n"
       ]
      }
     ],
     "prompt_number": 19
    }
   ],
   "metadata": {}
  }
 ]
}