{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter2 - Ray propagation in optical fiber"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 2.1 : Page 21"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "part (a)\n",
      "numerical aperture is 0.244\n",
      "part (b)\n",
      "angle αm = 14.13 degree\n",
      "angle Om = 9.37 degree\n",
      "angle Φc = 80.63 degree\n",
      "part (c)\n",
      "pulse broadning per unit length = 6.76e-11 sm**-1\n"
     ]
    }
   ],
   "source": [
    "from math import degrees, asin, sqrt\n",
    "#NA ,angles and pulse broadning\n",
    "print \"part (a)\"\n",
    "n1=1.5##core refrative index\n",
    "n2=1.48##claddin refractive index\n",
    "a=100/2##radius in micro meter\n",
    "na=1##air refrative index\n",
    "NA=sqrt(n1**2-n2**2)##numerical aperture\n",
    "print \"numerical aperture is %0.3f\"%NA\n",
    "print \"part (b)\"\n",
    "am=(asin(NA))##\n",
    "tm=asin(NA/n1)##\n",
    "tc=asin(n2/n1)##\n",
    "print \"angle αm = %0.2f degree\"%degrees(am)\n",
    "print \"angle Om = %0.2f degree\"%degrees(tm)\n",
    "print \"angle Φc = %0.2f degree\"%degrees(tc)\n",
    "print \"part (c)\"\n",
    "c=3*10**8##speed of light in m/s\n",
    "dtl=((n1/n2)*(n1-n2)/c)##pulse broadning per unit length\n",
    "print \"pulse broadning per unit length = %0.2e sm**-1\"%dtl"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 2.2 : Page 22"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "all other rays will suffer reflections between these two extremes of : 0  and  1650.0  m**-1\n"
     ]
    }
   ],
   "source": [
    "from math import tan\n",
    "#minimum and maximum number of reflections\n",
    "n1=1.5##core refrative index\n",
    "n2=1.48##claddin refractive index\n",
    "a=100/2##radius in micro meter\n",
    "na=1##air refrative index\n",
    "NA=sqrt(n1**2-n2**2)##numerical aperture\n",
    "am=(asin(NA))##\n",
    "tm=asin(NA/n1)##\n",
    "tc=asin(n2/n1)##\n",
    "L=((a*10**-6)/(tan(tm)))##length in meter\n",
    "x=(1/(2*L))##maximum number of reflections per meter\n",
    "print \"all other rays will suffer reflections between these two extremes of :\",(0),\" and \",round(x),\" m**-1\"\n",
    "#answer is wrong in the textbook"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 2.3 : Page 27"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "pulse broadning = 2.45 ns km**-1\n"
     ]
    }
   ],
   "source": [
    "#pulse broadning\n",
    "h=0.85##WAVELENGTH IN MICRO METER\n",
    "y=0.035##spectral width\n",
    "c=0.021##constant\n",
    "cl=3##speed of light in m/s\n",
    "dtl=(y/cl)*c##\n",
    "print \"pulse broadning = %0.2f ns km**-1\"%(dtl*10**4)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 2.4 : Page 27"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "part (a)\n",
      "material dispersion = 253.20 ns when h=850nm\n",
      "part (b)\n",
      "material dispersion = 6.72 ns when h=1300nm\n"
     ]
    }
   ],
   "source": [
    "#pulse broadning\n",
    "print \"part (a)\"\n",
    "h=850##WAVELENGTH IN NANO METER\n",
    "l=80##fiber length in Km\n",
    "dh=30##in Nano Meter\n",
    "m1=105.5##material dispersion for h=850nm in ps/nm-Km\n",
    "m2=2.8##material dispersion for h=1300nm in ps/nm-Km\n",
    "t=m1*l*dh*10**-3##material dispersion in ns when h=850nm\n",
    "print \"material dispersion = %0.2f ns when h=850nm\"%t\n",
    "print \"part (b)\"\n",
    "h=1300##WAVELENGTH IN NANO METER\n",
    "l=80##fiber length in Km\n",
    "dh=30##in Nano Meter\n",
    "m1=105.5##material dispersion for h=850nm in ps/nm-Km\n",
    "m2=2.8##material dispersion for h=1300nm in ps/nm-Km\n",
    "t=m2*l*dh*10**-3##material dispersion in ns when h=850nm\n",
    "print \"material dispersion = %0.2f ns when h=1300nm\"%t"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 2.5 : Page 28"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "part (a)\n",
      "material dispersion = 16.88 ns when h=850nm\n",
      "part (b)\n",
      "material dispersion = 0.448 ns when h=1300nm\n"
     ]
    }
   ],
   "source": [
    "# pulse broadning\n",
    "print \"part (a)\"\n",
    "h=850##WAVELENGTH IN NANO METER\n",
    "l=80##fiber length in Km\n",
    "dh=2##in Nano Meter\n",
    "m1=105.5##material dispersion for h=850nm in ps/nm-Km\n",
    "m2=2.8##material dispersion for h=1300nm in ps/nm-Km\n",
    "t=m1*l*dh*10**-3##material dispersion in ns when h=850nm\n",
    "print \"material dispersion = %0.2f ns when h=850nm\"%t\n",
    "print \"part (b)\"\n",
    "h=1300##WAVELENGTH IN NANO METER\n",
    "l=80##fiber length in Km\n",
    "dh=2##in Nano Meter\n",
    "m1=105.5##material dispersion for h=850nm in ps/nm-Km\n",
    "m2=2.8##material dispersion for h=1300nm in ps/nm-Km\n",
    "t=m2*l*dh*10**-3##material dispersion in ns when h=850nm\n",
    "print \"material dispersion = %0.3f ns when h=1300nm\"%t"
   ]
  }
 ],
 "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
}