{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 3: Fibre Optics"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.3.1, Page number 3-6"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "n1 = 1.54   #refractive index of core\n",
      "NA = 0.5    #numerical aperture\n",
      "\n",
      "#Calculation\n",
      "n2 = math.sqrt(n1**2-NA**2)\n",
      "\n",
      "#Result\n",
      "print \"Refractive index of cladding is\",round(n2,2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Refractive index of cladding is 1.46\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.3.2, Page number 3-6"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "n2 = 1.59   #refractive index of cladding\n",
      "NA = 0.2    #numerical aperture\n",
      "n0 = 1.33\n",
      "\n",
      "#Calculation\n",
      "n1 = (math.sqrt(n2**2-NA**2))\n",
      "theta_o = (math.asin((math.sqrt(n2**2-n1**2)/n0)))*180/math.pi\n",
      "\n",
      "#Result\n",
      "print \"Refractive index of core is\",n2\n",
      "print \"Acceptance angle =\",round(theta_o,2),\"degrees\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Refractive index of core is 1.59\n",
        "Acceptance angle = 8.65 degrees\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.3.3, Page number 3-6\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "n1 = 1.49   #refractive index of core\n",
      "n2 = 1.44   #refractive index of cladding\n",
      "\n",
      "#Calculation\n",
      "NA = math.sqrt(n1**2-n2**2)\n",
      "\n",
      "theta_o = math.degrees(math.asin(NA))\n",
      "\n",
      "#Result\n",
      "print \"Numerical Aperture =\",round(NA,5)\n",
      "print \"Acceptance angle =\",round(theta_o,2),\"degrees\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Numerical Aperture = 0.38275\n",
        "Acceptance angle = 22.5 degrees\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.3.4, Page number 3-7"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "n1 = 1.6   #refractive index of core\n",
      "n2 = 1.3   #refractive index of cladding\n",
      "\n",
      "#Calculation\n",
      "theta_c = math.degrees(math.asin(n2/n1))\n",
      "\n",
      "theta_o = math.degrees(math.asin(math.sqrt(n1**2-n2**2)))\n",
      "AC = 2*theta_o\n",
      "\n",
      "#Result\n",
      "print \"Critical angle =\",round(theta_c,2),\"degrees\"\n",
      "print \"Value of angle of acceptance cone =\",round(AC,3),\"degrees\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Critical angle = 54.34 degrees\n",
        "Value of angle of acceptance cone = 137.731 degrees\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.3.5, Page number 3-7"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "n1 = 1.4         #refractive index of core\n",
      "theta_o = 30     #acceptance angle(degrees)\n",
      "\n",
      "#Calculation\n",
      "n2 = math.sqrt(n1**2-math.sin(math.radians(theta_o))**2)\n",
      "\n",
      "#Result\n",
      "print \"Refractive index of cladding is\",round(n2,4)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Refractive index of cladding is 1.3077\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.3.6, Page number 3-8"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#Variable declaration\n",
      "n1 = 1.563   #refractive index of core\n",
      "n2 = 1.498   #refractive index of cladding\n",
      "\n",
      "#Calculation\n",
      "delta = (n1-n2)/n1\n",
      "\n",
      "#Result\n",
      "print \"Fractional index change =\",round(delta,4)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Fractional index change = 0.0416\n"
       ]
      }
     ],
     "prompt_number": 26
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.3.7, Page number 3-8"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#Variable declaration\n",
      "n1 = 1.50       #refractive index of cladding\n",
      "theta_c = 90-5  #critical angle(degrees)\n",
      "\n",
      "#Calculation\n",
      "n2 = math.sin(theta_c*math.pi/180)*n1\n",
      "\n",
      "#Result\n",
      "print \"The maximum index of refraction allowed for cladding is\",round(n2,4)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The maximum index of refraction allowed for cladding is 1.4943\n"
       ]
      }
     ],
     "prompt_number": 28
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.3.8, Page number 3-8"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#Variable declaration\n",
      "n1 = 1.33       #refractive index \n",
      "theta_o = 30    #acceptance angle in air\n",
      "\n",
      "#Calculations\n",
      "theta_0 = math.degrees(math.asin(math.sin(theta_o*math.pi/180)/n1))\n",
      "\n",
      "#Result\n",
      "print \"Acceptance angle =\",round(theta_0,2),\"degrees\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Acceptance angle = 22.08 degrees\n"
       ]
      }
     ],
     "prompt_number": 36
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.4.1, Page number 3-10"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "n1 = 1.52           #refractive index of core\n",
      "n2 = 1.5189         #refractive index of cladding\n",
      "d = 29*10**-6       #core diameter(m)\n",
      "lamda = 1.3*10**-6  #wavelength(m)\n",
      "\n",
      "#Calculation\n",
      "V = (math.pi*d*math.sqrt(n1**2-n2**2))/lamda\n",
      "\n",
      "N = V**2/2\n",
      "\n",
      "#Results\n",
      "print \"Normalized frequency =\",round(V,3)\n",
      "print \"Number of modes =\",round(N)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Normalized frequency = 4.052\n",
        "Number of modes = 8.0\n"
       ]
      }
     ],
     "prompt_number": 40
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.4.2, Page number 3-10"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "n1 = 1.47           #refractive index of core\n",
      "n2 = 1.46           #refractive index of cladding\n",
      "lamda = 1300*10**-9 #wavelength(nm)\n",
      "V = 2.405           #for single mode fibre\n",
      "\n",
      "#Calculation\n",
      "d = (V*lamda)/(math.pi*math.sqrt(n1**2-n2**2))\n",
      "r = d/2\n",
      "\n",
      "#Result\n",
      "print \"Radius =\",round(r/1e-6,3),\"um\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Radius = 2.907 um\n"
       ]
      }
     ],
     "prompt_number": 48
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.4.3, Page number 3-11"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "n1 = 1.48           #refractive index of core\n",
      "delta = 0.055       #relative RI\n",
      "lamda = 1           #wavelength(um)\n",
      "r = 50              #core radius(um)\n",
      "\n",
      "#Calculations\n",
      "n2 = -((delta*n1)-n1)\n",
      "\n",
      "NA = math.sqrt(n1**2-n2**2)\n",
      "\n",
      "theta_o = math.degrees(math.asin(NA))\n",
      "\n",
      "V = (math.pi*2*r*NA)/lamda\n",
      "\n",
      "N = V**2/2\n",
      "\n",
      "#Results\n",
      "print \"Refractive index of cladding =\",n2\n",
      "print \"NA =\",round(NA,3)\n",
      "print \"Acceptance angle =\",round(theta_o,2),\"degrees\"\n",
      "print \"Normalized frequency =\",round(V,3)\n",
      "print \"Number of modes =\",round(N)  #Answer differs due to rounding off in 'V'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Refractive index of cladding = 1.3986\n",
        "NA = 0.484\n",
        "Acceptance angle = 28.95 degrees\n",
        "Normalized frequency = 152.073\n",
        "Number of modes = 11563.0\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.4.4, Page number 3-12"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "n1 = 1.45           #refractive index of core\n",
      "n2 = 1.448          #refractive index of cladding\n",
      "lamda = 1*10**-6    #wavelength(m)\n",
      "d = 6*10**-6        #core diameter(m)\n",
      "\n",
      "#Calculations\n",
      "#Case i\n",
      "theta_c = math.degrees(math.asin(n2/n1))\n",
      "\n",
      "#Case ii\n",
      "theta_o = math.degrees(math.asin(math.sqrt(n1**2-n2**2)))\n",
      "\n",
      "#Case iii\n",
      "NA = math.sqrt(n1**2-n2**2)\n",
      "N = (math.pi**2*d**2*NA**2)/(2*lamda**2)\n",
      "\n",
      "#Results\n",
      "print \"Critical angle =\",round(theta_c),\"degrees\"\n",
      "print \"Acceptance angle =\",round(theta_o,3),\"degrees\"\n",
      "print \"Number of modes =\",round(N)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Critical angle = 87.0 degrees\n",
        "Acceptance angle = 4.366 degrees\n",
        "Number of modes = 1.0\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.4.5, Page number 3-12"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "n1 = 1.50           #refractive index of core\n",
      "n2 = 1.48           #refractive index of cladding\n",
      "lamda = 1*10**-6    #wavelength(m)\n",
      "d = 2*50*10**-6     #core diameter(m)\n",
      "\n",
      "#Calculations\n",
      "NA = math.sqrt(n1**2-n2**2)\n",
      "N = (math.pi**2*d**2*NA**2)/(2*lamda**2)\n",
      "\n",
      "#Result\n",
      "print \"Number of modes =\",round(N)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Number of modes = 2941.0\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.4.6, Page number 3-13"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "n1 = 1.55           #refractive index of core\n",
      "n2 = 1.50           #refractive index of cladding\n",
      "lamda = 1400*10**-9 #wavelength(m)\n",
      "d = 40*10**-6       #core diameter(m)\n",
      "\n",
      "#Calculations\n",
      "NA = math.sqrt(n1**2-n2**2)\n",
      "\n",
      "delta = (n1-n2)/n1\n",
      "\n",
      "V = (math.pi*d*NA)/lamda\n",
      "\n",
      "#Results\n",
      "print \"NA =\",round(NA,4)\n",
      "print \"Fractional index change =\",round(delta,5)\n",
      "print \"V-number =\",round(V,2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "NA = 0.3905\n",
        "Fractional index change = 0.03226\n",
        "V-number = 35.05\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.6.1, Page number 3-17"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "Pout = 0.3   #output power(mW)\n",
      "Pin = 1      #input power(mW)\n",
      "L = 0.1      #fibre length(km)\n",
      "\n",
      "#Calculation\n",
      "a = (-10/L)*math.log10(Pout/Pin)\n",
      "\n",
      "#Result\n",
      "print \"Attenuation =\",round(a,2),\"dB/km\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Attenuation = 52.29 dB/km\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.6.2, Page number 3-18"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "Pin = 9      #input power(mW)\n",
      "L = 3        #fibre length(km)\n",
      "a = 1.5      #loss(dB/km)\n",
      "\n",
      "#Calculation\n",
      "Pl = a*L\n",
      "Pout = Pin*10**(-Pl/10)\n",
      "\n",
      "#Result\n",
      "print \"Output power =\",round(Pout,3),\"uW\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Output power = 3.193 uW\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.6.3, Page number 3-18"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#Variable declaration\n",
      "a = 2.2    #attenuation(dB/km)\n",
      "l1 = 2     #km\n",
      "l2 = 6     #km\n",
      "from sympy import * \n",
      "Pin = symbols('Pin')\n",
      "\n",
      "#Calculations\n",
      "#For 2km,\n",
      "Pl1 = a*l1\n",
      "Po1 = Pin*round(10**(-Pl1/10),3)\n",
      "\n",
      "#For 6km,\n",
      "Pl2 = a*l2\n",
      "Po2 = Pin*round(10**(-Pl2/10),3)\n",
      "\n",
      "#Results\n",
      "print \"After 2 km, Pout =\",Po1\n",
      "print \"After 6 km, Pout =\",Po2"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "After 2 km, Pout = 0.363*Pin\n",
        "After 6 km, Pout = 0.048*Pin\n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.6.4, Page number 3-19"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#Variable declaration\n",
      "Pout = 7.5   #output power(mW)\n",
      "Pin = 8.6    #input power(mW)\n",
      "L = 0.5      #fibre length(km)\n",
      "\n",
      "#Calculation\n",
      "Pl = -10*math.log10(Pout/Pin)\n",
      "a = Pl/L\n",
      "\n",
      "#Result\n",
      "print \"Loss specification =\",round(a,4),\"dB/km\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Loss specification = 1.1887 dB/km\n"
       ]
      }
     ],
     "prompt_number": 19
    }
   ],
   "metadata": {}
  }
 ]
}