{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter10 - Optical Amplifiers"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 10.1 : Page 254"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "refrative index is : 3.75\n",
      "spectral bandwidth = 2.09 GHz\n"
     ]
    }
   ],
   "source": [
    "from math import pi, asin, sqrt\n",
    "from __future__ import division\n",
    "#refractive index and bandwidth\n",
    "#given data :\n",
    "lamda=1.55*10**-6## in m\n",
    "del_lamda=1*10**-9## in m\n",
    "L=320*10**-6## in m\n",
    "n=(lamda)**2/(2*del_lamda*L)#\n",
    "Gs=10**(5/10)## 5 dB is equivalent to 3.16\n",
    "R1=30/100#\n",
    "R2=R1#\n",
    "c=3*10**8## in m/s\n",
    "del_v=(c/(pi*n*L))*asin((1-(Gs*sqrt(R1*R2)))/(sqrt(4*Gs*sqrt(R1*R2))))#\n",
    "print \"refrative index is : %0.2f\"%n\n",
    "print \"spectral bandwidth = %0.2f GHz\"%(del_v*10**-9)\n",
    "#bandwidth is calculated wrong in the textbook"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 10.2 : Page 260"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "small signal gain of EDFA = 32.91 dB\n",
      "maximum possible achievable gain = 84.71 dB\n"
     ]
    }
   ],
   "source": [
    "from math import log10, exp\n",
    "#small-signal gain of EDFA and maximum pssible achievable gain\n",
    "ts=0.80##\n",
    "sa=4.6444*10**-25##in m**2\n",
    "n12=6*10**24##m**-3\n",
    "se=4.644*10**-25##m**2\n",
    "n21=0.70##\n",
    "l=7##in meter\n",
    "x=((sa*n12*l*(((se/sa)+1)*n21-1)))##\n",
    "G=ts*exp(x)##\n",
    "Gdb=10*log10(G)##\n",
    "Gmax=exp(se*n12*l)##\n",
    "Gmaxdb=10*log10(Gmax)##\n",
    "print \"small signal gain of EDFA = %0.2f dB\"%Gdb\n",
    "print \"maximum possible achievable gain = %0.2f dB\"%Gmaxdb"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 10.3 : Page 264"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "part (a)\n",
      "output signal power for forward pumping = 4.60 micro Watt\n",
      "part (b)\n",
      "overall gain = 6.63 dB\n"
     ]
    }
   ],
   "source": [
    "#output signal power and overall gain\n",
    "print \"part (a)\"\n",
    "psin=1*10**-6##in watts\n",
    "ppin=1##in watts\n",
    "gr=5*10**-14##mW**-1\n",
    "ap1=60*10**-12##m**2\n",
    "l=2000##meter\n",
    "asdb=0.15##dB/km\n",
    "As=3.39*10**-5##m**-1\n",
    "apdb=0.20##db/km\n",
    "ap=4.50*10**-5##m**-1\n",
    "z=(1-exp(-ap*l))/ap##\n",
    "y=(gr/ap1)##\n",
    "y1=z*y##\n",
    "y2=y1-(As*l)##\n",
    "psl=psin*exp(y2)##\n",
    "print \"output signal power for forward pumping = %0.2f micro Watt\"%(psl*10**6)\n",
    "print \"part (b)\"\n",
    "y1=z*y##\n",
    "y2=y1-(As*l)##\n",
    "psl=psin*exp(y2)##\n",
    "gfra=psl/(psin)##\n",
    "Gdb=10*log10(gfra)##\n",
    "print \"overall gain = %0.2f dB\"%Gdb"
   ]
  }
 ],
 "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
}