{
 "metadata": {
  "name": "",
  "signature": "sha256:d17d5fe4155b7f2d086c5c988af67c717660e52a459d2e6f74c5f9135d5d0a50"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 10: WDM concepts and Components"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10.1, Page Number: 343"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#variable declaration   \n",
      "Lambda2 = 1520.0*10**-9                           #spectral bandwidth(nHz)\n",
      "Lambda1 = 1420.0*10**-9\n",
      "C = 3.0*10**8                                     #free space velocity(m/s)\n",
      "delta_Lambda1=100.0*10**-9                        #spectral band(nm)\n",
      "delta_Lambda2=105.0*10**-9\n",
      "\n",
      "#calculation\n",
      "delta_v1= C*delta_Lambda1 /(Lambda1**2)           #optical bandwidth(Hz) \n",
      "delta_v2= C*delta_Lambda2/(Lambda2**2)\n",
      "\n",
      "#result\n",
      "print \"Usable spectral band for 100 nm = \",round(delta_v1*10**-12,1),\"THz\"\n",
      "print \"Usable spectral band for 100 nm = \",round(delta_v2*10**-12),\"THz\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Usable spectral band for 100 nm =  14.9 THz\n",
        "Usable spectral band for 100 nm =  14.0 THz\n"
       ]
      }
     ],
     "prompt_number": 20
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10.2, Page Number: 343"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#variable declaration\n",
      "c=3.0*pow(10,8)                                    #free space velocity(m/s)\n",
      "delta_lambda=0.8*pow(10,-9)                        #spectral band (meter)\n",
      "lam_bda=1550*pow(10,-9)                            #wavwlenth (meter)\n",
      "\n",
      "#calculation\n",
      "delta_v=(c*delta_lambda)/lam_bda**2                #Mean freqency spacing(GHz)\n",
      "\n",
      "#result\n",
      "print \"Mean freqency spacing = \" , round(delta_v*(pow(10,-9))),\"GHz\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Mean freqency spacing =  100.0 GHz\n"
       ]
      }
     ],
     "prompt_number": 21
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10.3, Page Number: 348"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#variable declaration\n",
      "p0=200.0*pow(10,-6)                              #input optical power level (watts)\n",
      "p1=90.0*pow(10,-6)                               #output power at port-1\n",
      "p2=85.0*pow(10,-6)                               #output power at port-2\n",
      "p3=6.3*pow(10,-9)                                #output power at port-3\n",
      "\n",
      "#calculation\n",
      "coupling_ratio=(p2/(p1+p2))*100                    #Coupling ratio(%)\n",
      "Excess_loss=10*(math.log10(p0/(p1+p2)))            #Excess loss(dB)\n",
      "Insertion_loss_0_1=10*(math.log10(p0/p1))          #Insertion loss(dB)\n",
      "Insertion_loss_0_2=10*(math.log10(p0/p2))\n",
      "Return_loss = 10*(math.log10(p3/p0))               #Return loss(dB)\n",
      "\n",
      "#result\n",
      "print \"Coupling ratio = \" , round(coupling_ratio,1) , \"%\"\n",
      "print \"Excess loss = \" , round(Excess_loss,2) , \"dB\"\n",
      "print \"Insertion loss (port0 to port1 = \" , round(Insertion_loss_0_1,2), \"dB\"\n",
      "print \"Insertion loss (port0 to port2 = \" , round(Insertion_loss_0_2,2), \"dB\"\n",
      "print \"Return loss = \" , round(Return_loss), \"dB\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Coupling ratio =  48.6 %\n",
        "Excess loss =  0.58 dB\n",
        "Insertion loss (port0 to port1 =  3.47 dB\n",
        "Insertion loss (port0 to port2 =  3.72 dB\n",
        "Return loss =  -45.0 dB\n"
       ]
      }
     ],
     "prompt_number": 22
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10.6, Page Number: 353"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#variable declaration\n",
      "k = 0.6/(10**-3)                           #Coupling coefficint (per mm)\n",
      "m = 1                                      #mode=1\n",
      "\n",
      "#calculation\n",
      "L = ((math.pi)*(m+1))/(2*k)                #coupling length(mm)\n",
      "\n",
      "#result\n",
      "print \"Coupling length L = \",round(L*(10**3),2),\"mm\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Coupling length L =  5.24 mm\n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10.7, Page Number: 355"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#variable declaration\n",
      "Power_Lost = 5.0/100.0                      #lost power%\n",
      "FT = 1-Power_Lost                           #power coupled\n",
      "N = 32\n",
      "\n",
      "#calculation\n",
      "Excess_Loss = -10*(math.log10(FT**(math.log10(N)/math.log10(2))))               #Excess Loss(dB)\n",
      "Splitting_Loss = -10*math.log10(N)                                              #Splitting Loss(dB)\n",
      "Total_Loss = (-Excess_Loss) + Splitting_Loss                                  \n",
      "\n",
      "#result\n",
      "print \"Excess Loss = \" , round(Excess_Loss,1) ,\"dB\"\n",
      "print \"Splitting Loss = \" , round(abs(Splitting_Loss)) ,\"dB\"\n",
      "print \"Total Loss experienced in Star Couplers = \" , round(-Total_Loss,1) , \"dB\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Excess Loss =  1.1 dB\n",
        "Splitting Loss =  15.0 dB\n",
        "Total Loss experienced in Star Couplers =  16.2 dB\n"
       ]
      }
     ],
     "prompt_number": 24
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10.8, Page Number: 357"
     ]
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 10.8(a)"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#variable declaration\n",
      "delta_lambda=0.08*pow(10,-9)                         #wavelength spacing (nm)\n",
      "lam_bda=1550*pow(10,-9)                              #wavelength (meters)\n",
      "neff=1.5                                             #effective refractive index in the waveguide\n",
      "c=3*10**8                                            #free space velocity(m/s)\n",
      "\n",
      "#calculation\n",
      "delta_v1=10*10**9                                    #Frequency sepration\n",
      "delta_l1=c/(2*neff*delta_v1)                         #Waveguide length(mm)\n",
      "\n",
      "#result\n",
      "print \"Waveguide length1 diffrence = \" , round(delta_l1*10**3) ,\"mm\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Waveguide length1 diffrence =  10.0 mm\n"
       ]
      }
     ],
     "prompt_number": 28
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 10.8(b)"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#variable declaration\n",
      "delta_lambda=0.08*pow(10,-9)                         #wavelength spacing (nm)\n",
      "lam_bda=1550*pow(10,-9)                              #wavelength (meters)\n",
      "neff=1.5                                             #effective refractive index in the waveguide\n",
      "c=3*10**8                                            #free space velocity(m/s)\n",
      "\n",
      "#calculation\n",
      "delta_v2=130*10**9                                   #Frequency sepration\n",
      "delta_l2=c/(2*neff*delta_v2)                         #Waveguide length(mm)\n",
      "\n",
      "#result\n",
      "print \"Waveguide length2 diffrence = \" , round(delta_l2*10**3,2) ,\"mm\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Waveguide length2 diffrence =  0.77 mm\n"
       ]
      }
     ],
     "prompt_number": 29
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10.9, Page Number: 364"
     ]
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 10.9(a)"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#variable declaration\n",
      "kl=1.0                            #coupling coeffiecint and length                           \n",
      "k2=2.0\n",
      "k3=3.0\n",
      "\n",
      "#calculation\n",
      "rmax1=math.tanh(kl)**2                       #peak reflectivity Rmax\n",
      "rmax2=math.tanh(k2)**2\n",
      "rmax3=math.tanh(k3)**2\n",
      "\n",
      "#result\n",
      "print \"For k1 Rmax = \" , round(rmax1*100) ,\"%\"\n",
      "print \"For k2 Rmax = \" , round(rmax2*100) ,\"%\"\n",
      "print \"For k3 Rmax = \" ,round(rmax3*100) ,\"%\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "For k1 Rmax =  58.0 %\n",
        "For k2 Rmax =  93.0 %\n",
        "For k3 Rmax =  99.0 %\n"
       ]
      }
     ],
     "prompt_number": 30
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 10.9(b)"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#variable declaration\n",
      "L=0.5                                             #length (cm)\n",
      "lam_bda_brg = 1530*10**-9                         #reflaaction wavelength(nm)\n",
      "n_eff = 1.48                                      #mode effective index of core\n",
      "delta_n = 2.5*10**-4\n",
      "etta = 0.82                                       #efficiency(%)\n",
      "\n",
      "#calculation\n",
      "k = (math.pi*delta_n*etta)/(lam_bda_brg)                                                         #coupling coefficint\n",
      "delta_lambda = (lam_bda_brg**2)*(math.sqrt(((k/100*L)**2)+math.pi**2))/(math.pi*n_eff*L)         #bandwidth\n",
      "\n",
      "#result\n",
      "print \"Coupling coefficint = \", round(k/100,1), \"1/cm\"\n",
      "print \"Total bandwidth = \", round(delta_lambda*10**11,2),\"nm\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Coupling coefficint =  4.2 1/cm\n",
        "Total bandwidth =  0.38 nm\n"
       ]
      }
     ],
     "prompt_number": 31
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10.10, Page Number: 372"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#variable declaration\n",
      "lambda_c=1550*pow(10,-9)                         #wavelength(nm)\n",
      "nc=1.45                                          #refrective index of grating array waveguide \n",
      "ns=1.45                                          #refrective index of teh star coupler\n",
      "ng=1.47                                          #group index of grating array waveguide\n",
      "x=5*10**-6                                       #spacing between input waveguide(um)\n",
      "d=5*10**-6                                       #spacing between output waveguide(um)\n",
      "m=1                                              #mode\n",
      "lf=10*10**-3                                     #distance between Tx to Rx\n",
      "\n",
      "#calculation\n",
      "delta_l=m*lambda_c/nc                            #waveguide length diffrence(um)\n",
      "delta_lambda=(x/lf)*(ns*d/m)*(ns/ng)             #channel spacing(nm)\n",
      "\n",
      "#result\n",
      "print \"Waveguide length diffrence = \" , round(delta_l*10**6,3), \"um\"\n",
      "print \"Channel spacing interms of wavelength = \" , round(delta_lambda*10**9,2) ,\"nm\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Waveguide length diffrence =  1.069 um\n",
        "Channel spacing interms of wavelength =  3.58 nm\n"
       ]
      }
     ],
     "prompt_number": 32
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10.11, Page Number: 373"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#variable declaration \n",
      "nc=1.45                                            #refractive index\n",
      "Lambda_C = 1550.5*pow(10,-9)                       #center wavelength(nm)\n",
      "delta_Lambda = 32.2*pow(10,-9)                     #free spectral range(nm)\n",
      "c=3*10**8                                          #free space velocity(m/s)\n",
      "\n",
      "#calculation\n",
      "delta_L = Lambda_C**2/(nc*delta_Lambda)            #length diffrence(um)\n",
      "\n",
      "#result\n",
      "print \"Length diffrence between adjacent array waveguide = \" , round(delta_L*10**6,2) , \"um\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Length diffrence between adjacent array waveguide =  51.49 um\n"
       ]
      }
     ],
     "prompt_number": 33
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10.12, Page Number: 383"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#variable declaration\n",
      "Lam_bda = 1550*pow(10,-9)                                 #DBR laser wavelength(nm)\n",
      "delta_neff = 0.0065                                       #index change\n",
      "\n",
      "#calculation\n",
      "delta_Lambda_tune = Lam_bda*delta_neff                    #tuning range (meter)  \n",
      "delta_Lambda_signal = 0.02*pow(10,-9)                     #spectral width(meter)\n",
      "delta_Lambda_channel = 10*delta_Lambda_signal             #channal width\n",
      "N = delta_Lambda_tune/delta_Lambda_channel                #The number of channels\n",
      "\n",
      "#result\n",
      "print \"Tuning wavelength = \" , round(delta_Lambda_tune*10**9) , \"nm\"\n",
      "print \"The number of channels that can operate in this tuning range is N = \" , round(N)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Tuning wavelength =  10.0 nm\n",
        "The number of channels that can operate in this tuning range is N =  50.0\n"
       ]
      }
     ],
     "prompt_number": 34
    }
   ],
   "metadata": {}
  }
 ]
}