{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#  Chapter 5 : Fibre Optics"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 1 , Page number 90"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Critical angle= 78.52 degrees\n",
      "numerical aperture= 0.298\n",
      "acceptance angle= 17.367 degrees\n"
     ]
    }
   ],
   "source": [
    "#importing module\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "n1=1.5                  #core refractive index\n",
    "n2=1.47                 #clad refractive index\n",
    "\n",
    "#Calculations\n",
    "thetac=math.asin(n2/n1)\n",
    "NA=(n1**2-n2**2)**0.5\n",
    "im=math.asin(NA)\n",
    "\n",
    "#Result\n",
    "print\"Critical angle= %2.2f\" %math.degrees(thetac),\"degrees\"\n",
    "print\"numerical aperture= %1.3f\" %NA\n",
    "print\"acceptance angle= %2.3f\" %math.degrees(im),\"degrees\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 2 , Page number 91"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "refractive index of cladding= 1.587\n"
     ]
    }
   ],
   "source": [
    "#importing module\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "n1=1.6                #core refractive index\n",
    "NA=0.2                #Numerical aperture\n",
    "\n",
    "#Calculations\n",
    "NA=(n1**2-NA**2)**0.5\n",
    "\n",
    "#Result\n",
    "print\"refractive index of cladding= %1.3f\" %NA"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 3 , Page number 91"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "numerical aperture= 0.252\n",
      "Acceptance angle= 14.61 degrees\n"
     ]
    }
   ],
   "source": [
    "#importing module\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "n1=1.6                 #core refractive index\n",
    "n2=1.58                #clad refractive index\n",
    "\n",
    "#Calculations\n",
    "NA=(n1**2-n2**2)**0.5\n",
    "im=math.asin(NA)\n",
    "\n",
    "#Result\n",
    "print\"numerical aperture= %1.3f\" %NA\n",
    "print\"Acceptance angle= %2.2f\" %math.degrees(im),\"degrees\"  #The answer in the textbook is mathematically incorrect"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 4 , Page number 91"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "refractive index of core material= 1.42\n",
      "refractive index of cladding material= 1.40\n"
     ]
    }
   ],
   "source": [
    "#importing module\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "delr=12*10**-3         #fractional refractive index change\n",
    "NA=0.22                #Numerical aperture\n",
    "\n",
    "#Calculations\n",
    "n1=NA/math.sqrt(2*delr)\n",
    "n2=n1-(n1*delr)\n",
    "\n",
    "#Result\n",
    "print\"refractive index of core material= %1.2f\" %n1\n",
    "print\"refractive index of cladding material= %1.2f\" %n2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 5 , Page number 92"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "acceptance angle= 8.6 degrees\n"
     ]
    }
   ],
   "source": [
    "#importing module\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "NA=0.2                 #Numerical aperture\n",
    "n0=1.33                #refractive index\n",
    "n2=1.59                #clad refractive index\n",
    "\n",
    "#Calculations\n",
    "n1=math.sqrt(NA**2+n2**2)\n",
    "NA1=math.sqrt(n1**2-n2**2)/n0\n",
    "thetac=math.asin(NA1)\n",
    "\n",
    "#Result\n",
    "print\"acceptance angle= %1.1f\" %math.degrees(thetac),\"degrees\""
   ]
  }
 ],
 "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.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
