{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter12 - Fiber-optic communiation systems"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 12.1 : Page 299"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "maximum possible link length = 8.00 km\n",
      "total rise time of the system in ns is 30.0\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "from math import sqrt, pi\n",
    "#link length and reise time\n",
    "af=2.5##dB/km\n",
    "ac=0.5##dB/splice\n",
    "nc=1##\n",
    "lc=1##dB\n",
    "ncc=2##\n",
    "plx=-10##dBm\n",
    "prx=-42##dBm\n",
    "Ms=6##dB\n",
    "L=((plx-prx-Ms-(lc*ncc))/(af+ac))##\n",
    "TTX=12##NS\n",
    "TRX=11##NS\n",
    "NS1=3##NS/KM\n",
    "NS2=1##NS/KM\n",
    "tmat=(NS1*L)##ns\n",
    "tint=(NS2*L)##ns\n",
    "tsys=sqrt((TTX**2+tmat**2+tint**2+TRX**2))##ns\n",
    "print\"maximum possible link length = %0.2f km\"% L\n",
    "print \"total rise time of the system in ns is\",round(tsys)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 12.2: Page 305"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "part (a)\n",
      "maximum possible link length = 4.71 km\n",
      "part (b)\n",
      "system bandwidth = 8.00 MHz\n"
     ]
    }
   ],
   "source": [
    "## link length and bandwidth\n",
    "print \"part (a)\"\n",
    "af=3##dB/km\n",
    "ac=0.5##dB/splice\n",
    "nc=1##\n",
    "lc=1##dB\n",
    "ncc=1.5##\n",
    "plx=0##dBm\n",
    "prx=-25##dBm\n",
    "Ms=7##dB\n",
    "L=((plx-prx-Ms-(lc*ncc))/(af+ac))##\n",
    "TTX=12##NS\n",
    "TRX=11##NS\n",
    "NS1=3##NS/KM\n",
    "NS2=1##NS/KM\n",
    "tmat=(NS1*L)##ns\n",
    "tint=(NS2*L)##ns\n",
    "tsys=sqrt((TTX**2+tmat**2+tint**2+TRX**2))##ns\n",
    "print \"maximum possible link length = %0.2f km\"%L\n",
    "print \"part (b)\"\n",
    "af=3##dB/km\n",
    "ac=0.5##dB/splice\n",
    "nc=1##\n",
    "lc=1##dB\n",
    "ncc=1.5##\n",
    "plx=-0##dBm\n",
    "prx=-25##dBm\n",
    "Ms=7##dB\n",
    "L=((plx-prx-Ms-(lc*ncc))/(af+ac))##\n",
    "TTX=1##NS\n",
    "TRX=5##NS\n",
    "NS1=9##NS/KM\n",
    "NS2=2##NS/KM\n",
    "tf=((NS1*L)**2+(NS2*L)**2)##\n",
    "tsys=sqrt((TTX**2+tf+TRX**2))##ns\n",
    "df=0.35/(tsys*10**-3)##\n",
    "print \"system bandwidth = %0.2f MHz\"%round(df)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 12.3 : Page 310"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "no. of subscribers are 38.0\n"
     ]
    }
   ],
   "source": [
    "from math import log10\n",
    "#no. of subscribers\n",
    "pt=1##mW\n",
    "pn=-40##dBm\n",
    "pn1=10**(pn/10)##\n",
    "c=0.05##\n",
    "d=0.11##\n",
    "x=((pn1)/(pt*c))##\n",
    "y=((log10(x))/(log10((1-d)*(1-c))))##\n",
    "n=y+1##\n",
    "print \"no. of subscribers are\",round(n)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 12.4: Page 311"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Total power, P_tot = 92.4 mW\n"
     ]
    }
   ],
   "source": [
    "# Total power\n",
    "#given data :\n",
    "L_eff=20## in km\n",
    "del_lamdaC=125## in nm\n",
    "gR=6*10**-14## m/W\n",
    "A_eff=55*10**-12## in m**2#\n",
    "del_lamdaS=0.8## in nm\n",
    "N=32## number of channels\n",
    "F=0.1##  constant\n",
    "P_tot=(4*F*del_lamdaC*A_eff)/(gR*del_lamdaS*L_eff*(N-1))#\n",
    "print \"Total power, P_tot = %0.1f mW\"%P_tot"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 12.5 : Page 312"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "SBS threshold power for the worst case = 8.66 mW\n",
      "SBS threshold power for the best possible case = 17.33 mW\n"
     ]
    }
   ],
   "source": [
    "#SBS threshold power\n",
    "#given data :\n",
    "gb=4*10**-11## in m/W\n",
    "A_eff=55*10**-12## in m**2\n",
    "L_eff=20## in km\n",
    "lamda_p=1.55## micro-m\n",
    "n=1.46## constant\n",
    "Va=5960## for the silica fiber in m-s**-1\n",
    "Vb=(2*n*Va)/lamda_p#\n",
    "del_v=100*10**6## in Hz\n",
    "del_Vb=20*10**6## in Hz\n",
    "b1=1#\n",
    "b2=2#\n",
    "P_th=((21*b1*A_eff)/(gb*L_eff))*(1+(del_v/del_Vb))\n",
    "P_th1=((21*b2*A_eff)/(gb*L_eff))*(1+(del_v/del_Vb))\n",
    "print \"SBS threshold power for the worst case = %0.2f mW\"%P_th\n",
    "print \"SBS threshold power for the best possible case = %0.2f mW\"%P_th1"
   ]
  }
 ],
 "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
}