{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 15 - Fibre Optics"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 1 - pg 524"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "With cladding , NA  and Acceptance angle = 0.1225 and 7.035 degrees\n",
      "Without cladding , NA =  1.1214\n"
     ]
    }
   ],
   "source": [
    "#pg 524\n",
    "#Calculate the acceptance angle\n",
    "#Given :\n",
    "import math\n",
    "n0 = 1;#refractive index of outer medium\n",
    "n1 = 1.5025; # refractive index of core\n",
    "n2 = 1.4975; # refractive index of cladding\n",
    "#calculations\n",
    "NA = math.sqrt(n1**2 - n2**2); # Numerical aperture with cladding\n",
    "alpha_c = math.asin(NA/n0)*57.3; # acceptance angle in degrees\n",
    "NA1 = math.sqrt(n1**2 - n0**2);# Numerical aperture without cladding\n",
    "#results\n",
    "print \"With cladding , NA  and Acceptance angle =\",round(NA,4),\"and\",round(alpha_c,3),\"degrees\"\n",
    "print \"Without cladding , NA = \",round(NA1,4)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 2 - pg 525"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Ls (mu_m) =  1230.9\n",
      "Reflections per m =  812.0\n"
     ]
    }
   ],
   "source": [
    "#pg 525\n",
    "#calculate the Ls and reflections per m\n",
    "#Given :\n",
    "import math\n",
    "n1 = 1.5025;# refractive index of core\n",
    "delta = 0.0033; # \n",
    "a = 50.; # core radius in mu_m\n",
    "#calculations\n",
    "Ls = a*math.sqrt(2/delta);# skip distance in mu_m\n",
    "# 1 mu_m = 1.0*10**-6 m\n",
    "R = 1/(Ls*10**-6);# reflections per m\n",
    "#results\n",
    "print \"Ls (mu_m) = \",round(Ls,1)\n",
    "print \"Reflections per m = \",round(R,0)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3 - pg 526"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Limiting diameter (mu_m) =  7.92\n"
     ]
    }
   ],
   "source": [
    "#pg 526\n",
    "#calculate the Limiting diameter\n",
    "#Given :\n",
    "import math\n",
    "lambd = 1.25; # wavelength in mu_m\n",
    "n1 = 1.462; # refractive index of core\n",
    "n2 = 1.457; # refractive index of cladding\n",
    "#calculations\n",
    "# Single mode propogation : (2*pi*a*sqrt(n1**2 - n2**2))/lambd < 2.405\n",
    "a  = (2.405*lambd)/(2*math.pi*math.sqrt(n1**2 - n2**2)); # radius in mu_m\n",
    "d = a*2; # diameter in mu_m\n",
    "#results\n",
    "print \"Limiting diameter (mu_m) = \",round(d,2)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4 - pg 527"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Attenuation (dB/km) =  2.6\n"
     ]
    }
   ],
   "source": [
    "#pg 527\n",
    "#calculate the Attenuation\n",
    "#Given :\n",
    "import math\n",
    "n1 = 1.525; # refractive index of core\n",
    "n2 = 1.500; # refractive index of cladding\n",
    "d = 30.; # core diameter in mu_m\n",
    "#calculations\n",
    "ab = 0.00001/100; # percentage absorbed\n",
    "a = d/2.; # core radius in mu_m\n",
    "delta = (n1-n2)/n1;\n",
    "Ls = a*math.sqrt(2/delta);# skip distance in mu_m\n",
    "#1 mu_m = 1.0*10^-6 m\n",
    "R = 1000/(Ls*10**-6); # reflections per km (1000 m)\n",
    "red_p = 1 - ab; # reduced power for each reflection\n",
    "#Power P1km = P0*red_p^(6*10^6)\n",
    "# A = 10*log10[P0/P1km] , P0 in the numerator and denominator will cancel each other\n",
    "A = 10*math.log10(1/(red_p)**(R));\n",
    "#results\n",
    "print \"Attenuation (dB/km) = \",round(A,1)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5 - pg 533"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Maximum delay (ps) =  16.7\n",
      "Bandwidth of 2MHz can propogate a distance of (km) =   15.0\n"
     ]
    }
   ],
   "source": [
    "#pg 533\n",
    "#calculate the maximum delay and bandwidth\n",
    "#Given :\n",
    "n1 = 1.5025; # refractive index of core\n",
    "n2 = 1.4975; # refractive index of cladding\n",
    "L = 1; # length in m\n",
    "F = 2*10**6; # frequency in Hz\n",
    "c = 3*10**8;# light speed in m/s\n",
    "#calculations\n",
    "delta_t = (n1*L/c)*((n1/n2)-1);# maximum delay in s;\n",
    "f = 1/(2*delta_t); # bandwidth for 1 m propogation\n",
    "L1 = 1/(2*F*delta_t); # distance for 2MHz bandwidth\n",
    "#results\n",
    "print \"Maximum delay (ps) = \",round(delta_t*10**12,1)\n",
    "print \"Bandwidth of 2MHz can propogate a distance of (km) =  \",round(L1*10**-3,0);\n"
   ]
  }
 ],
 "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
}
