{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#Chapter 5:Fiber Optics"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example 5.1, Page number 5.28"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 125,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The Critical angle = 78.5 degrees\n",
      "The numerical aperture = 0.3\n",
      "The acceptance angle = 17.4 degrees\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#variable declaration\n",
    "n1=1.50          #Core refractive index\n",
    "n2=1.47          #Cladding refractive index\n",
    "\n",
    "#Calculations\n",
    "C_a=math.asin(n2/n1)        #Critical angle       \n",
    "N_a=(n1**2-n2**2)**(1/2)\n",
    "A_a=math.asin(N_a)\n",
    "\n",
    "#Results\n",
    "print \"The Critical angle =\",round(C_a*180/math.pi,1),\"degrees\"\n",
    "print \"The numerical aperture =\",round(N_a,2)\n",
    "print \"The acceptance angle =\",round(A_a*180/math.pi,1),\"degrees\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example 5.2, Page number 5.28"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 126,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "N = 490.0\n",
      "Fiber can support 490.0 guided modes\n",
      "In graded index fiber, No.of modes propogated inside the fiber = 245.0 only\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#variable declaration\n",
    "d=50                #diameter\n",
    "N_a=0.2             #Numerical aperture\n",
    "lamda=1             #wavelength\n",
    "\n",
    "#Calculations\n",
    "N=4.9*(((d*10**-6*N_a)/(lamda*10**-6))**2)\n",
    "\n",
    "#Result\n",
    "print \"N =\",N\n",
    "print \"Fiber can support\",N,\"guided modes\"\n",
    "print \"In graded index fiber, No.of modes propogated inside the fiber =\",N/2,\"only\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example 5.3, Page number 5.29"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Numerical aperture = 0.008691\n",
      "No. of modes that can be propogated = 1.0\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#variable declaration\n",
    "d=50                #diameter\n",
    "n1=1.450\n",
    "n2=1.447\n",
    "lamda=1             #wavelength\n",
    "\n",
    "#Calculations\n",
    "N_a=(n1**2-n2**2)   #Numerical aperture\n",
    "N=4.9*(((d*10**-6*N_a)/(lamda*10**-6))**2)\n",
    "\n",
    "#Results\n",
    "print \"Numerical aperture =\",N_a\n",
    "print \"No. of modes that can be propogated =\",round(N)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example 5.4, Page number 5.29"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Numerical aperture = 0.46\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#variable declaration\n",
    "delta=0.05          \n",
    "n1=1.46\n",
    "\n",
    "#Calculation\n",
    "N_a=n1*(2*delta)**(1/2)     #Numerical aperture\n",
    "\n",
    "#Result\n",
    "print \"Numerical aperture =\",round(N_a,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example 5.5, Page number 5.29"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "V number = 94.72\n",
      "maximum no.of modes propogating through fiber = 4486.0\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#variable declaration\n",
    "a=50\n",
    "n1=1.53\n",
    "n2=1.50\n",
    "lamda=1             #wavelength\n",
    "\n",
    "#Calculations\n",
    "N_a=(n1**2-n2**2)   #Numerical aperture\n",
    "V=((2*math.pi*a)/lamda)*N_a**(1/2)\n",
    "\n",
    "#Result\n",
    "print \"V number =\",round(V,2)\n",
    "print \"maximum no.of modes propogating through fiber =\",round(N)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example 5.6, Page number 5.29"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Number of modes = 24589.0 modes\n",
      "No.of modes is doubled to account for the two possible polarisations\n",
      "Total No.of modes = 49178.0\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#variable declaration\n",
    "a=100\n",
    "N_a=0.3               #Numerical aperture\n",
    "lamda=850             #wavelength\n",
    "\n",
    "#Calculations\n",
    "V_n=(2*(math.pi)**2*a**2*10**-12*N_a**2)/lamda**2*10**-18\n",
    "#Result\n",
    "print \"Number of modes =\",round(V_n/10**-36),\"modes\"\n",
    "print \"No.of modes is doubled to account for the two possible polarisations\"\n",
    "print \"Total No.of modes =\",round(V_n/10**-36)*2\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example 5.7, Page number 5.29"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Cutoff Wavellength = 1.315 micro m.\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "a=5;\n",
    "n1=1.48;\n",
    "delta=0.01;\n",
    "V=25;\n",
    "\n",
    "#Calculation\n",
    "lamda=(math.pi*(a*10**-6)*n1*math.sqrt(2*delta))/V   # Cutoff Wavelength\n",
    "\n",
    "#Result\n",
    "print \"Cutoff Wavellength =\",round(lamda*10**7,3),\"micro m.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example 5.8, Page number 5.30"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Maximum core radius= 9.95 micro m\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "V=2.405\n",
    "lamda=1.3\n",
    "N_a=0.05\n",
    "\n",
    "#Calculations\n",
    "a_max=(V*lamda)/(2*math.pi*N_a)\n",
    "\n",
    "#Result\n",
    "print \"Maximum core radius=\",round(a_max,2),\"micro m\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example 5.9, Page number 5.30"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Acceptance angle, theta_a = 17.46 degrees\n",
      "For skew rays,theta_as  34.83 degrees\n",
      "#Answer given in the textbook is wrong\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#variable declaration\n",
    "N_a=0.3\n",
    "gamma=45\n",
    "\n",
    "#Calculations\n",
    "theta_a=math.asin(N_a)\n",
    "theta_as=math.asin((N_a)/math.cos(gamma))\n",
    "\n",
    "#Results\n",
    "print \"Acceptance angle, theta_a =\",round(theta_a*180/math.pi,2),\"degrees\"\n",
    "print \"For skew rays,theta_as \",round(theta_as*180/math.pi,2),\"degrees\"\n",
    "print\"#Answer given in the textbook is wrong\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example 5.10, Page number 5.30"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 115,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Numerical aperture = 0.303\n",
      "Acceptance angle = 17.63 degrees\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#variable declaration\n",
    "n1=1.53\n",
    "delta=0.0196\n",
    "\n",
    "#Calculations\n",
    "N_a=n1*(2*delta)**(1/2)\n",
    "A_a=math.asin(N_a)\n",
    "#Result\n",
    "print \"Numerical aperture =\",round(N_a,3)\n",
    "print \"Acceptance angle =\",round(A_a*180/math.pi,2),\"degrees\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example 5.11, Page number 5.30"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "delta = 0.01\n",
      "Core radius,a = 1.55 micro m\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#variable declaration\n",
    "n1=1.480\n",
    "n2=1.465\n",
    "V=2.405\n",
    "lamda=850*10**-9\n",
    "\n",
    "#Calculations\n",
    "delta=(n1**2-n2**2)/(2*n1**2)\n",
    "a=(V*lamda*10**-9)/(2*math.pi*n1*math.sqrt(2*delta))\n",
    "\n",
    "#Results\n",
    "print \"delta =\",round(delta,2)\n",
    "print \"Core radius,a =\",round(a*10**15,2),\"micro m\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example 5.12, Page number 5.31"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 147,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Critical angle= 83.38 degrees\n",
      "Fiber length covered in one reflection= 430.84 micro m\n",
      "Total no.of reflections per metre= 2321.0\n",
      "Since L=1m, Total dist. travelled by light over one metre of fiber = 1.0067 m\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#variable declaration\n",
    "n1=1.5\n",
    "n2=1.49\n",
    "a=25\n",
    "\n",
    "#Calculations\n",
    "C_a=math.asin(n2/n1)           #Critical angle\n",
    "L=2*a*math.tan(C_a)             \n",
    "N_r=10**6/L                    \n",
    "\n",
    "#Result\n",
    "print \"Critical angle=\",round(C_a*180/math.pi,2),\"degrees\"\n",
    "print \"Fiber length covered in one reflection=\",round(L,2),\"micro m\"\n",
    "print \"Total no.of reflections per metre=\",round(N_r)\n",
    "print \"Since L=1m, Total dist. travelled by light over one metre of fiber =\",round(1/math.sin(C_a),4),\"m\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example 5.13, Page number 5.31"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 155,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "No.of modes = 154.69 =155(approx)\n",
      "Taking the two possible polarizations, Total No.of nodes = 309.0\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#variable declaration\n",
    "alpha=1.85\n",
    "lamda=1.3*10**-6\n",
    "a=25*10**-6\n",
    "N_a=0.21\n",
    "\n",
    "#Calculations\n",
    "V_n=((2*math.pi**2)*a**2*N_a**2)/lamda**2\n",
    "N_m=(alpha/(alpha+2))*V_n\n",
    "\n",
    "print \"No.of modes =\",round(N_m,2),\"=155(approx)\"\n",
    "print \"Taking the two possible polarizations, Total No.of nodes =\",round(N_m*2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example 5.14, Page number 5.32"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a)Signal attention per unit length = 3.9 dB km**-1\n",
      "b)Overall signal attenuation = 39.0 dB\n",
      "#Answer given in the textbook is wrong\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#variable declaration\n",
    "P_i=100\n",
    "P_o=2\n",
    "L=10\n",
    "\n",
    "#Calculations\n",
    "S=(10/L)*math.log(P_i/P_o)\n",
    "O=S*L\n",
    "\n",
    "#Result\n",
    "print \"a)Signal attention per unit length =\",round(S,1),\"dB km**-1\"\n",
    "print \"b)Overall signal attenuation =\",round(O),\"dB\"\n",
    "print \"#Answer given in the textbook is wrong\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example 5.15, Page number 5.32"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Total dispersion = 1343.3 ns\n",
      "Bandwidth length product = 37.22 Hz-km\n",
      "#Answer given in the text book is wrong\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#variable declaration\n",
    "L=10\n",
    "n1=1.55\n",
    "delta=0.026\n",
    "C=3*10**5\n",
    "\n",
    "#Calculations\n",
    "delta_T=(L*n1*delta)/C\n",
    "B_W=10/(2*delta_T)\n",
    "\n",
    "#Result\n",
    "print \"Total dispersion =\",round(delta_T/10**-9,1),\"ns\"\n",
    "print \"Bandwidth length product =\",round(B_W/10**5,2),\"Hz-km\"\n",
    "print \"#Answer given in the text book is wrong\""
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}