{
 "metadata": {
  "name": "",
  "signature": "sha256:69c313bd7e7f4ca84b1b5e5f091a7854a8c80d86bc1470f5cbc9e6d39211d1ba"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "chapter5 - Optical fiber connection : splicing"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.2.1, page 5-2"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "from numpy import sqrt, pi, log10\n",
      "n1=1.47         #refractive index of fiber\n",
      "n=1         #refractive index of air\n",
      "r=((n1-n)/(n1+n))**2     #computing fraction of light reflected\n",
      "loss=-10*log10(1-r)     #loss\n",
      "total_loss=2*loss \n",
      "print \"r = %.3f, which means %.1f percent of the transimitted light is reflected at one interface\" %(r,r*100) \n",
      "print \"Total loss is %.3f dB\" %(total_loss) \n",
      "#answer in the book for total loss of fiber is wrong."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "r = 0.036, which means 3.6 percent of the transimitted light is reflected at one interface\n",
        "Total loss is 0.320 dB\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.2.2, page 5-4"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from numpy import arccos\n",
      "n1=1.47         #refractive index of fiber\n",
      "n=1         #refractive index of air\n",
      "d=40*10**-6     #core diameter\n",
      "y=4*10**-6      #lateral dispalcement\n",
      "a=d/2       #computing core radius\n",
      "eta_lateral = (16*(n1/n)**2)/(pi*(1+(n1/n))**4)*(2*arccos(y/(2*a))-(y/a)*(1-(y/(2*a))**2)**0.5)      #computing eta_lateral with air gap\n",
      "loss=-10*log10(eta_lateral)         #computing loss when air gap is present\n",
      "eta_lateral1=(2*arccos(y/(2*a))-(y/a)*(1-(y/(2*a))**2)**0.5)/pi        #computing eta_lateral without air gap\n",
      "loss1=-10*log10(eta_lateral1)       #computing loss when air gap is not present\n",
      "print \"loss with air gap is %.2f dB.\\nloss with no air gap is %.2f dB.\" %(loss,loss1) \n",
      "#answer in the book for loss with air gap is wrong"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "loss with air gap is 0.91 dB.\n",
        "loss with no air gap is 0.59 dB.\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.2.3, page 5-5"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "n1=1.48         #refractive index of fiber\n",
      "n=1         #refractive index of air\n",
      "theta=10    #angle in degree\n",
      "NA1=0.3 \n",
      "NA2=0.6\n",
      "eta_angular1= (16*(n1/n)**2)/((1+(n1/n))**4)*(1-((n*theta*pi/180)/(pi*NA1)))    #computing eta angular\n",
      "eta_angular2= (16*(n1/n)**2)/((1+(n1/n))**4)*(1-((n*theta*pi/180)/(pi*NA2)))    #computing eta angular\n",
      "loss1=-10*log10(eta_angular1)       #computing loss\n",
      "loss2=-10*log10(eta_angular2)       #computing loss\n",
      "print \"\\nLoss when NA is %.1f is %.2f dB.\\nLoss when NA is %.1f is %.2f dB.\" %(NA1,loss1,NA2,loss2) "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "Loss when NA is 0.3 is 1.22 dB.\n",
        "Loss when NA is 0.6 is 0.75 dB.\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.4.1, page 5-15"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from numpy import exp\n",
      "d=1*10**-6      #lateral displacement\n",
      "W=4.95*10**-6   #MFD\n",
      "Lsm_lat= -10*log10(exp(-(d/W)**2))       #computing loss\n",
      "print \"Insertion loss is %.2f dB.\" %(Lsm_lat) "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Insertion loss is 0.18 dB.\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.4.2, page 5-15  "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "lamda=1.3*10**-6    #wavelength\n",
      "theta=1         #angle in degree\n",
      "n2=1.465        #cladding refractive index\n",
      "W=4.95*10**-6       #MFD\n",
      "Lsm_ang= -10*log10(exp(-(pi*n2*W*(theta*pi/180)/lamda)**2))       #computing loss\n",
      "print \"Insertion loss is %.2f dB.\" %(Lsm_ang) "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Insertion loss is 0.41 dB.\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.6.1, page 5-28 "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "p1=50*10**-6 \n",
      "p2=0.003*10**-6 \n",
      "p3=25*10**-6 \n",
      "p4=26.5*10**-6\n",
      "EL=10*log10(p1/(p3+p4))         #computing excess loss\n",
      "IL13=10*log10(p1/p3)      #computing insertion loss\n",
      "IL14=10*log10(p1/p4)      #computing insertion loss\n",
      "ct=10*log10(p2/p1)      #computing cross talk\n",
      "sr=(p3/(p3+p4))*100     #computing split ratio\n",
      "print \"\"\"Excess loss is %.2f dB.\n",
      "Insertion loss from port 1 to port 3 is %.2f dB.\n",
      "Insertion loss from port 1 to port 4 is %.2f dB.\n",
      "cross talk is %.2f dB.\\nSplit ratio is %.2f percent\"\"\" %(EL,IL13,IL14,ct,sr  ) \n",
      "#Printing and calculation error in the book.Minus sign is not printed in the answer of excess loss.\n",
      "#P1 is taken 25 instead of 50 while calculating cross talk. "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Excess loss is -0.13 dB.\n",
        "Insertion loss from port 1 to port 3 is 3.01 dB.\n",
        "Insertion loss from port 1 to port 4 is 2.76 dB.\n",
        "cross talk is -42.22 dB.\n",
        "Split ratio is 48.54 percent\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.6.2, page 5-29"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "N=16        #Number of ports\n",
      "Pin=1*10**-3    #input power\n",
      "Pout=12*10**-6  #output power\n",
      "split_loss=10*log10(N)      #computing split loss\n",
      "excess_loss=10*log10(Pin/(Pout*N))      #computing excess loss\n",
      "total_loss=split_loss+excess_loss       #computing total loss\n",
      "insertion_loss= 10*log10(Pin/Pout)      #computing insertion loss\n",
      "print \"Total loss is %.2f dB.\\nInsertion loss is %.2f dB.\" %(total_loss,insertion_loss) \n",
      "#answer in the book for Total loss & insertion loss are wrong."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Total loss is 19.21 dB.\n",
        "Insertion loss is 19.21 dB.\n"
       ]
      }
     ],
     "prompt_number": 15
    }
   ],
   "metadata": {}
  }
 ]
}