{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Ch-3 : Modes and Rays"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex:3.1 Pg: 84"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "core radius=37.90 micrometer\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi\n",
    "from __future__ import division\n",
    "n1=1.50## core refractive index\n",
    "n2=1.48## cladding refractive index\n",
    "y=1.3*10**-6#\n",
    "m=1000## the no. of models\n",
    "v=sqrt(2*m)#\n",
    "a=(v*y)/(2*pi*(sqrt(n1**2-n2**2)))*10**6## core radius in micrometer\n",
    "print \"core radius=%0.2f micrometer\"%(a)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex:3.2 Pg: 84"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "numerical aperture=0.09\n",
      "\n",
      " core radius=5.23 micrometer\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi\n",
    "from __future__ import division\n",
    "n1=1.505## core refractive index\n",
    "n2=1.502## cladding refractive index\n",
    "n_m=sqrt(n1**2-n2**2)## numerical aperture\n",
    "y=1.3*10**-6#\n",
    "v=2.4#\n",
    "a=(v*y)/(2*pi*(sqrt(n1**2-n2**2)))*10**6## core radius in micrometer\n",
    "print \"numerical aperture=%0.2f\"%(n_m)#\n",
    "print \"\\n core radius=%0.2f micrometer\"%(a)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex:3.3 Pg: 85"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "propagation constant=7.22 rad/um\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi\n",
    "from __future__ import division\n",
    "n1=1.5## core refractive index\n",
    "dl=0.01##index difference\n",
    "m=0## for the dominant mode\n",
    "v=0## for the dominant mode\n",
    "y=1.3## in micrometer\n",
    "a=5## radius in micrometer\n",
    "k=(2*pi)/y#\n",
    "b=k**2*n1**2-(2*k*n1*sqrt(2*dl))/a#\n",
    "B=sqrt(b)## propagation constant in rad/um\n",
    "print \"propagation constant=%0.2f rad/um\"%(B)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex:3.5 Pg: 85"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "total no. of models allowed=8\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi,ceil\n",
    "from __future__ import division\n",
    "n1=3.6## core refractive index\n",
    "n2=3.3## cladding refractive index\n",
    "d=2.0## thickness in um\n",
    "y=0.8## wavelength in um\n",
    "m=(2*d*sqrt(n1**2-n2**2))/y## total no. of models allowed\n",
    "M=ceil(m)## total no. of models allowed\n",
    "print \"total no. of models allowed=%d\"%(M)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex:3.6 Pg: 86"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "normalised frequency=75.80\n",
      "\n",
      " the total no. of guided  modess =2873\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi,ceil\n",
    "from __future__ import division\n",
    "n1=1.48## core refractive index\n",
    "a=40*(10**-6)## core radius in meter\n",
    "dl=0.015## index difference\n",
    "y=0.85*(10**-6)## wavelength in um\n",
    "v=(2*pi*a*n1*sqrt(2*dl))/y## normalised frequency\n",
    "M=v**2/2#\n",
    "m=ceil(M)## the total no. of guided  modes\n",
    "print \"normalised frequency=%0.2f\"%(v)#\n",
    "print \"\\n the total no. of guided  modess =%d\"%(m)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    " ## Ex:3.7 Pg: 87"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "cladding refractive index=1.44\n",
      "\n",
      " normalised frequency=56.08\n",
      "\n",
      " the total no. of guided  modess =1572\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi\n",
    "from __future__ import division\n",
    "n1=1.46## core refractive index\n",
    "dl=0.015## index difference\n",
    "a=30*(10**-6)## core radius in meter\n",
    "y=0.85*(10**-6)## wavelength in um\n",
    "n2=n1-(n1*dl)## cladding refractive index\n",
    "v=(2*pi*a*n1*sqrt(2*dl))/y## normalised frequency\n",
    "M=v**2/2## the total no. of guided  modes\n",
    "print \"cladding refractive index=%0.2f\"%(n2)#\n",
    "print \"\\n normalised frequency=%0.2f\"%(v)#\n",
    "print \"\\n the total no. of guided  modess =%d\"%(M)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex:3.8 Pg: 87"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "normalised frequency=46.90\n",
      "\n",
      " the diameter of the fiber core =91.50 um\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi\n",
    "from __future__ import division\n",
    "n1=1.5## core refractive index\n",
    "dl=0.01## index difference\n",
    "M=1100## the total no. of guided  modes\n",
    "y=1.3*(10**-6)## wavelength in um\n",
    "v=sqrt(2*M)## normalised frequency\n",
    "a=(v*y)/(2*pi*n1*sqrt(2*dl))*10**6## core radius in meter\n",
    "print \"normalised frequency=%0.2f\"%(v)#\n",
    "print \"\\n the diameter of the fiber core =%0.2f um\"%(2*a)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    " ## Ex:3.9 Pg: 87"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "normalised frequency=60.32\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi\n",
    "from __future__ import division\n",
    "n1=1.45## core refractive index\n",
    "n_m=0.16## numerical aperture\n",
    "a=30*10**-6## core radius in micrometer\n",
    "y=0.5*(10**-6)## wavelength in um\n",
    "v=(2*pi*a*n_m)/y## normalised frequency\n",
    "print \"normalised frequency=%0.2f\"%(v)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex:3.10 Pg: 88"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the max thickness=0.61 um\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi\n",
    "from __future__ import division\n",
    "n1=3.6## core refractive index\n",
    "n2=3.56## cladding refractive index\n",
    "y=0.85*(10**-6)## wavelength in um\n",
    "m=1#\n",
    "n=0#\n",
    "v_c=2.405## for planner guide\n",
    "a=(v_c*y)/(2*pi*sqrt(n1**2-n2**2))## core radius in micrometer\n",
    "print \"the max thickness=%0.2f um\"%(a*10**6)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex:3.11 Pg: 88"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the core diameter=92 um\n"
     ]
    }
   ],
   "source": [
    "from math import pi,sqrt,ceil\n",
    "from __future__ import division\n",
    "n1=1.5 #core refractive index\n",
    "y=1.3*(10**-6) #wavelength in um\n",
    "M=1100 #total no. of models\n",
    "dl=0.01 #index difference\n",
    "v=sqrt(2*M) #\n",
    "V=ceil(v) #\n",
    "a=(V*y)/(2*pi*n1*sqrt(2*dl))*10**6 #core radius in micrometer\n",
    "a1=ceil(a) #core radius in micrometer\n",
    "print \"the core diameter=%d um\"%(2*a1) "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex:3.12 Pg: 89"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The max core diameter in meter=3.66 um\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi\n",
    "from __future__ import division\n",
    "n1=1.45## core refractive index\n",
    "dl=0.015## index difference\n",
    "y=0.85*(10**-6)## wavelength in meter\n",
    "v=2.4*(1+(2/2))**(0.5)## Max normalised frequency\n",
    "a=(v*y)/(2*pi*n1*(2*dl)**(0.5))## Max core radius in m\n",
    "d=2*a## The max core diameter in meter\n",
    "print \"The max core diameter in meter=%0.2f um\"%( d*10**6)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex:3.13 Pg: 89"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The number of modes=10.11\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi\n",
    "from __future__ import division\n",
    "n1=1.48## core refractive index\n",
    "n2=1.46## cladding refractive index\n",
    "a=2.5## radius in um\n",
    "y=0.85## wavelength in um\n",
    "dl=(n1-n2)/n1## index difference\n",
    "v=(2*pi*a*n1*(2*dl)**(0.5))/y## the normaised frequency\n",
    "M=(v*v)/2## number of modes\n",
    "print \"The number of modes=%0.2f\"%( M)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex:3.14 Pg: 90"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The number of modes=0.22\n",
      "\n",
      " The number of modes=0.15\n",
      "\n",
      " answer in textbook is wrong\n",
      "\n",
      " The number of modes=353.78\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi\n",
    "from __future__ import division\n",
    "a=25## radius in um\n",
    "y=1.3## wavelength in um\n",
    "v=26.6## the normaised frequency\n",
    "NA=(v*y)/(2*pi*a)## Numerical aperture\n",
    "a_c=pi*(NA)**2#\n",
    "M=(v*v)/2#\n",
    "print \"The number of modes=%0.2f\"%( NA)#\n",
    "print \"\\n The number of modes=%0.2f\"%( a_c)#\n",
    "print \"\\n answer in textbook is wrong\"#\n",
    "print \"\\n The number of modes=%0.2f\"%( M)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex:3.15 Pg: 90"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The cut off wavelength =1.27 um\n",
      "\n",
      " The min core radius =2.05 um\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "n1=1.49## core refractive index\n",
    "n2=1.47## cladding refractive index\n",
    "a=2## radius in um\n",
    "dl=(n1-n2)/n1## index difference\n",
    "v_c=2.405#\n",
    "y_c=(2*3.14*a*n1*(2*dl)**(0.5))/v_c## cut off wavelength in um\n",
    "Y=1.31## wavelength in um\n",
    "A=(v_c*Y)/(2*3.14*n1*(2*dl)**(0.5))## min core radius in um\n",
    "print \"The cut off wavelength =%0.2f um\"%( y_c)#\n",
    "print \"\\n The min core radius =%0.2f um\"%( A)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex:3.16 Pg: 91"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The normalised frequency =47.12\n",
      "\n",
      " The mode volume =554 guided modes\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi\n",
    "from __future__ import division\n",
    "a=25## radius in um\n",
    "NA=0.3## Numerical aperture\n",
    "y=1## wavelength in um\n",
    "v=(2*pi*a*NA)/y## the normalised frequency\n",
    "V=47.1## the normalised frequency\n",
    "M=(V*V)/4## The mode volume\n",
    "print \"The normalised frequency =%0.2f\"%( v)#\n",
    "print \"\\n The mode volume =%d guided modes\"%( M)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex:3.17 Pg: 91"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The cut off wavelength =1.21 um\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "n1=1.46## core refractive index\n",
    "a=4.5## radius in um\n",
    "dl=0.0025## relative index difference\n",
    "v_c=2.405#\n",
    "y_c=(2*3.14*a*n1*(2*dl)**(0.5))/v_c## cut off wavelength in um\n",
    "print \"The cut off wavelength =%0.2f um\"%( y_c)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex:3.18 Pg: 92"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The cut of numbers =91.83\n",
      "\n",
      " The number of modes =4216.48\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi\n",
    "from __future__ import division\n",
    "n1=1.5## core refractive index\n",
    "n2=1.45## cladding refractive index\n",
    "a=50## radius in um\n",
    "y=1.3## operating wavelength in um\n",
    "NA=sqrt(n1**2-n2**2)## numerical aperture\n",
    "N_A=0.38#\n",
    "v=(2*pi*a*N_A)/y## cut of numbers\n",
    "M=v**2/2## number of modes\n",
    "print \"The cut of numbers =%0.2f\"%( v)#\n",
    "print \"\\n The number of modes =%0.2f\"%( M)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex:3.19 Pg: 92"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The max core radius =1.91 um\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi\n",
    "from __future__ import division\n",
    "n1=1.53## core refractive index\n",
    "n2=1.5## cladding refractive index\n",
    "y=1.5## operating wavelength in um\n",
    "NA=sqrt(n1**2-n2**2)## numerical aperture\n",
    "a=(2.405*y)/(2*3.14*NA)## max radius in um\n",
    "print \"The max core radius =%0.2f um\"%( a)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex:3.20 Pg: 92"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The v-number =67.35\n",
      "\n",
      " The number of modes =2267.87\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi\n",
    "from __future__ import division\n",
    "a=25## max radius in um\n",
    "y=0.8## operating wavelength in um\n",
    "NA=0.343## numerical aperture\n",
    "v=(2*pi*a*NA)/y## v-number\n",
    "M=v**2/2##number of modes\n",
    "print \"The v-number =%0.2f\"%( v)#\n",
    "print \"\\n The number of modes =%0.2f\"%( M)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex:3.21 Pg: 93"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The core radius =40.84 um\n",
      "\n",
      " The cladding refractive index =1.45\n",
      "\n",
      " answer in textbook is wrong\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi\n",
    "from __future__ import division\n",
    "n1=1.5## core refractive index\n",
    "NA=0.38## numerical aperture\n",
    "v=75## v-number\n",
    "y=1.3## operating wavelength in um\n",
    "a=(v*y)/(2*pi*NA)## core radius in um\n",
    "n2=sqrt(n1**2-NA**2)## cladding refractive index\n",
    "print \"The core radius =%0.2f um\"%( a)#\n",
    "print \"\\n The cladding refractive index =%0.2f\"%( n2)#\n",
    "print \"\\n answer in textbook is wrong\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex:3.22 Pg: 94"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The divergence angle =0.15 degree\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi\n",
    "from __future__ import division\n",
    "y=1.2## operating wavelength in um\n",
    "w=5## spot size in um\n",
    "x=(2*y)/(pi*w)## the divergence angle in degree\n",
    "print \"The divergence angle =%0.2f degree\"%( x)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex:3.23 Pg: 94"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The cut off wavelength =1.21 um\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi\n",
    "from __future__ import division\n",
    "n1=1.46## core refractive index\n",
    "a=4.5## core radius in um\n",
    "dl=0.0025## relative index difference\n",
    "NA=n1*(sqrt(2*dl))## numerical aperture\n",
    "v=2.405#\n",
    "y=(2*pi*a*NA)/(v)## cut off wavelength in um\n",
    "print \"The cut off wavelength =%0.2f um\"%( y)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex:3.24 Pg: 94"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The number of modes at 870 nm =726.14 um\n",
      "\n",
      " The number of modes =244.27 um\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi\n",
    "from __future__ import division\n",
    "n1=1.5## core refractive index\n",
    "n2=1.47## cladding refractive index\n",
    "y1=0.87## operating wavelength in um\n",
    "y2=1.5## operating wavelength in um\n",
    "a=25## max radius in um\n",
    "NA=sqrt(n1**2-n2**2)## numerical aperture\n",
    "v1=(2*pi*a*NA)/y1#\n",
    "v2=(2*pi*a*NA)/y2#\n",
    "al=2## parabolic index profile for GRIN\n",
    "M1=(al/(al+2))*(v1**2/2)## number of modes\n",
    "M2=(al/(al+2))*(v2**2/2)## number of modes\n",
    "print \"The number of modes at 870 nm =%0.2f um\"%( M1)#\n",
    "print \"\\n The number of modes =%0.2f um\"%( M2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex:3.25 Pg: 95"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The numerical aperture =0.34 um\n",
      "\n",
      " The max core radius =0.94 um\n",
      "\n",
      " The spot size =2.27 um\n",
      "\n",
      " The divergence angle =0.22 degree\n",
      "\n",
      " The spot size at 50 meter =5.97 m\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi\n",
    "from __future__ import division\n",
    "n1=1.5## core refractive index\n",
    "n2=1.46## cladding refractive index\n",
    "v=2.4## cut off parameter\n",
    "y=0.85## operating wavelength in um\n",
    "NA=sqrt(n1**2-n2**2)## numerical aperture\n",
    "a=(v*y)/(2*3.14*NA)## max radius in um\n",
    "w=v*a## spot size\n",
    "x=(2*y)/(3.4*w)## divergence angle in degree\n",
    "d=50## distance in meter\n",
    "w_s=(y*d)/(pi*w)## spot size at 50 meter\n",
    "print \"The numerical aperture =%0.2f um\"%( NA)#\n",
    "print \"\\n The max core radius =%0.2f um\"%( a)#\n",
    "print \"\\n The spot size =%0.2f um\"%( w)#\n",
    "print \"\\n The divergence angle =%0.2f degree\"%( x)#\n",
    "print \"\\n The spot size at 50 meter =%0.2f m\"%( w_s)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex:3.26 Pg: 95"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The max diameter=3.05 um\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi\n",
    "from __future__ import division\n",
    "n1=1.53## core refractive index\n",
    "n2=1.50## cladding  refractive index\n",
    "y=1.2## wavelength in um\n",
    "v=2.405#\n",
    "a=(v*y)/(2*3.14*(sqrt(n1**2-n2**2)))## core radius in micrometer\n",
    "print \"The max diameter=%0.2f um\"%(2*a)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex:3.27 Pg: 95"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The largest core radius =2.91 um\n",
      "\n",
      " The fractional refractive index=1.46\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi\n",
    "from __future__ import division\n",
    "n1=1.47## core refractive index\n",
    "n2=1.46## cladding  refractive index\n",
    "y=1.3## wavelength in um\n",
    "dl=(n1-n2)/n1## fractional refractive index diff\n",
    "NA=sqrt(n1**2-n2**2)#\n",
    "v=2.405#\n",
    "a=(v*y)/(2*3.14*(sqrt(n1**2-n2**2)))## largest core radius in micrometer\n",
    "n_eff=n1-(NA/(2*3.14*(a/y)))## fractional refractive index\n",
    "print \"The largest core radius =%0.2f um\"%( a)#\n",
    "print \"\\n The fractional refractive index=%0.2f\"%(n_eff)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex:3.28 Pg: 95"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The cut off parameter =45.09\n",
      "\n",
      " The number of modes =1016\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi\n",
    "from __future__ import division\n",
    "n1=1.50## core refractive index\n",
    "n2=1.48## cladding  refractive index\n",
    "NA=sqrt(n1**2-n2**2)## numerical aperture\n",
    "a=25## core radius in um\n",
    "y=0.85## wavelength in um\n",
    "v=(2*3.14*a*NA)/y## cut off parameter\n",
    "M=v**2/2## number of modes\n",
    "print \"The cut off parameter =%0.2f\"%( v)#\n",
    "print \"\\n The number of modes =%d\"%(M)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex:3.29 Pg: 96"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The max value of D =0.00\n",
      "\n",
      " The cladding refractive index =1.50\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "n1=1.50## core refractive index\n",
    "a=25## core radius in um\n",
    "y=1.5## wavelength in um\n",
    "v=2.405#\n",
    "NA=(v*y)/(2*3.14*a)## numerical aperture\n",
    "D=(NA/n1)**2/(2)## max value of D\n",
    "n2=n1-(D*n1)## cladding refractive index\n",
    "print \"The max value of D =%0.2f\"%(D)#\n",
    "print \"\\n The cladding refractive index =%0.2f\"%(n2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex:3.30 Pg: 96"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The max value of D =0.03\n",
      "\n",
      " The critical angle =76.87 degree\n",
      "\n",
      " The acceptance angle =40.56 degree\n",
      "\n",
      " The solid acceptance angle =0.38 degree\n",
      "\n",
      " The numerical aperture =0.35\n",
      "\n",
      " The normalise v-number =113.04\n",
      "\n",
      " The number of guided modes =6389\n",
      "\n",
      " The reduction in modes =6310\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt,pi,asin\n",
    "from __future__ import division\n",
    "n1=1.52## core refractive index\n",
    "n2=1.48## cladding  refractive index\n",
    "a=45## core radius in um\n",
    "y=0.85## wavelength in um\n",
    "dl=(n1-n2)/n1## relative refractive index\n",
    "x=(asin(n2/n1))*(180/3.14)## critical angle in degree\n",
    "NA=sqrt(n1**2-n2**2)## numerical aperture\n",
    "a_c=(asin(NA))*(180/3.14)## acceptance angle in degree\n",
    "a_s=3.14*(n1**2-n2**2)## solid acceptance angle\n",
    "v=(2*3.14*a*0.34)/y## normalise v-number\n",
    "M=v**2/2## number of guided modes\n",
    "a1=5## for single mode step fiber\n",
    "v1=(2*3.14*a1*0.34)/y#\n",
    "M1=v1**2/2#\n",
    "R=M-M1## reduction in modes\n",
    "print \"The max value of D =%0.2f\"%(dl)#\n",
    "print \"\\n The critical angle =%0.2f degree\"%(x)#\n",
    "print \"\\n The acceptance angle =%0.2f degree\"%(2*a_c)#\n",
    "print \"\\n The solid acceptance angle =%0.2f degree\"%(a_s)#\n",
    "print \"\\n The numerical aperture =%0.2f\"%(NA)#\n",
    "print \"\\n The normalise v-number =%0.2f\"%(v)#\n",
    "print \"\\n The number of guided modes =%d\"%(M)#\n",
    "print \"\\n The reduction in modes =%d\"%(R)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex:3.31 Pg: 97"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The normalised frequency =28.26\n",
      "\n",
      " The number of modes =399\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "n1=1.46## core refractive index\n",
    "a=45/2## max radius in um\n",
    "y=0.85## operating wavelength in um\n",
    "NA=0.17## numerical aperture\n",
    "v=(2*3.14*a*NA)/y##normalised frequency\n",
    "M=v**2/2## number of modes\n",
    "print \"The normalised frequency =%0.2f\"%( v)#\n",
    "print \"\\n The number of modes =%d\"%( M)"
   ]
  }
 ],
 "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
}