{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 7: Optical Fibre Communication"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.1, Page 206"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import sqrt\n",
      "\n",
      "#Variable declaration\n",
      "NA = 0.24;#Numerical Aperture\n",
      "delta = 0.014;\n",
      "\n",
      "#Calculations & Results\n",
      "n1 = (NA)/sqrt(2*delta);#Refractive index of first medium \n",
      "print 'Refractive index of first medium is ',round(n1,4)\n",
      "n2 = n1 - (delta*n1);#Refractive index of secong material\n",
      "print 'Refractive index of secong material is ',round(n2,4)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Refractive index of first medium is  1.4343\n",
        "Refractive index of secong material is  1.4142\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.2, Page 207"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import sqrt,asin,degrees\n",
      "\n",
      "#Variable declaration\n",
      "n1 = 1.49; # Refractive index of first medium\n",
      "n2 = 1.44; # Refractive index of second medium\n",
      "\n",
      "#Calculations & Results\n",
      "def deg_to_dms(deg):\n",
      "    d = int(deg)\n",
      "    md = abs(deg - d) * 60\n",
      "    m = int(md)\n",
      "    sd = (md - m) * 60\n",
      "    sd=round(sd,2)\n",
      "    return [d, m, sd]\n",
      "\n",
      "delta = (n1-n2)/n1; # Index difference\n",
      "NA = n1* sqrt(2*delta);\n",
      "print 'Numerical Aperture of fiber is',round(NA,3)\n",
      "theta = degrees(asin(NA));\n",
      "print 'Acceptance angle is ',deg_to_dms(theta),'degrees'\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Numerical Aperture of fiber is 0.386\n",
        "Acceptance angle is  [22, 42, 22.17] degrees\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.3, Page 207"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import sqrt,asin,degrees\n",
      "\n",
      "#Variable declaration\n",
      "NA = 0.15 ; # Numerical Aperture of fiber\n",
      "n2 = 1.55; # Refractive index of cladding\n",
      "n0w = 1.33; # Refractive index of water\n",
      "n0a = 1; # Refractive index of air\n",
      "\n",
      "#Calculations\n",
      "def deg_to_dms(deg):\n",
      "    d = int(deg)\n",
      "    md = abs(deg - d) * 60\n",
      "    m = int(md)\n",
      "    sd = (md - m) * 60\n",
      "    sd=round(sd,2)\n",
      "    return [d, m, sd]\n",
      "\n",
      "n1 = sqrt(NA**2 + n2**2);\n",
      "NAW = (sqrt(n1**2 -n2**2))/n0w;\n",
      "theta = degrees(asin(NAW));#Acceptance angle in water\n",
      "\n",
      "#Result\n",
      "print 'Acceptance angle in water is ',deg_to_dms(theta),'degrees'\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Acceptance angle in water is  [6, 28, 32.55] degrees\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.4, Page 216"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import log10\n",
      "\n",
      "#Variable declaration\n",
      "l = 16; # Length of optical fiber in Km\n",
      "Pi = 240e-6; # Mean optical length launched in optical fiber in Watts\n",
      "Po = 6e-6; # Mean optical power at the output in watts\n",
      "\n",
      "#Calculations&Results\n",
      "alpha = 10*log10(Pi/Po);#Signal attenuation in fiber\n",
      "print 'Signal attenuation in fiber',round(alpha),'dB'\n",
      "alpha1 = alpha/l;#Signal attenuation per km of the fiber\n",
      "print 'Signal attenuation per km of the fiber',round(alpha1),'dB/km'\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Signal attenuation in fiber 16.0 dB\n",
        "Signal attenuation per km of the fiber 1.0 dB/km\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.5, Page 219"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import pi,exp\n",
      "\n",
      "#Variable declaration\n",
      "Tf = 1400; # Fictive temperature of silicon in Kelvin\n",
      "betai = 7e-11; # Isothermal compressibility square meter per newton\n",
      "n = 1.46; # Refractive index of silicon\n",
      "p = 0.286; # Photoelastic constant of silicon\n",
      "lamda = 0.63e-6 # Wavelength in micrometer\n",
      "kb = 1.38e-23 # Boltzmann constant in joule per kelvin\n",
      "L = 1e3;\n",
      "\n",
      "#Calculations\n",
      "alphas = (8 * pi**3 * n**8 * p**2 * kb * Tf * betai)/(3 * lamda**4);#Rayleigh scattering coefficient\n",
      "alphars = exp(-alphas * L);#Loss factor\n",
      "\n",
      "#Results\n",
      "print 'Rayleigh scattering coefficient is ',round(alphas/1e-3,2),'*10^-3 /m'\n",
      "print 'Loss factor is',round(alphars,3)  #Answer varies due to rounding-off values\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Rayleigh scattering coefficient is  1.2 *10^-3 /m\n",
        "Loss factor is 0.302\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.6, Page 222"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "alpha = 0.5; # Attenuation of single mode optical fibre in dB per km\n",
      "lamda = 1.4; # Operating wavelength of optical fiber in micrometer\n",
      "d = 8 # Diameter of fiber in micrometer\n",
      "y = 0.6; # Laser source frequency width\n",
      "\n",
      "#Calculations\n",
      "pb = 4.4e-3 * d**2 * lamda**2 * alpha * y;#Threshold optical power in SBS\n",
      "prs = 5.9e-2 * d**2 * lamda * alpha;#Threshold optical power in SRS\n",
      "\n",
      "#Results\n",
      "print 'Threshold optical power in SBS',pb/1e-3,'mW'\n",
      "print 'Threshold optical power in SRS',prs,'W'\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Threshold optical power in SBS 165.5808 mW\n",
        "Threshold optical power in SRS 2.6432 W\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.7, Page 225"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import sqrt, pi\n",
      "\n",
      "#Variable declaration\n",
      "n1 = 1.50; # Refreactive index of forst medium\n",
      "delta = 0.003; # Index difference\n",
      "lamda = 1.6*1e-6; # Operating wavelength of fober in meter\n",
      "\n",
      "#Calculations&Results\n",
      "n2 = sqrt(n1**2-(2*delta*n1**2));#refractive index of cladding\n",
      "#Substituting n2^2 = n1^2 - 2*delta*n1^2 in euation of Rc,\n",
      "rc = (3*n1**2*lamda)/(4*pi*((2*delta*n1**2)**(3./2)));#The critical radius of curvature for which bending losses occur \n",
      "print 'The critical radius of curvature for which bending losses occur is ',round(rc/1e-6,2),'um'\n",
      "#Incorrect answer in the textbook\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The critical radius of curvature for which bending losses occur is  547.92 um\n"
       ]
      }
     ],
     "prompt_number": 7
    }
   ],
   "metadata": {}
  }
 ]
}