{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter No.3 : The cellular concept system design fundamentals"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3.1 Page No.61"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " The number of channels available per cell for 4-cell reuse system = 165 channels\n",
      "\n",
      " One control channel and 160 voice channels would be assigned to each cell.\n",
      "\n",
      " \n",
      " The number of channels available per cell for 7-cell reuse system = 95 channels\n",
      "\n",
      " Each cell would have one control channel, four cells would have 90 voice channels and three cells would have 91 voice channels.\n",
      "\n",
      " \n",
      " The number of channels available per cell for 12-cell reuse system = 55 channels\n",
      "\n",
      " Each cell would have one control channel, eight cells would have 53 voice channels and four cells would have 54 voice channels.\n"
     ]
    }
   ],
   "source": [
    "from math import ceil\n",
    "# To compute the number of channels available per cell for a)four-cell reuse system a)seven-cell reuse system a)12-cell reuse system\n",
    "\n",
    "# Given data\n",
    "B=33*10**6#                                                  # Total bandwidth allocated to particular FDD system in Hz\n",
    "Bc=25*10**3#                                                 # Bandwidth per channel in Hz\n",
    "Nc=2#                                                       # Number of simplex channels\n",
    "Bc=Bc*Nc#                                                   # Channel bandwidth in Hz\n",
    "\n",
    "Ntotal=B/Bc#                                                # Total number of channels\n",
    "\n",
    "#a) To compute the number of channels available per cell for four-cell reuse system\n",
    "N=4#                                                        # frequency reuse factor\n",
    "chpercell=Ntotal/N#                                         # number of channels available per cell for four-cell reuse system\n",
    "\n",
    "# Displaying the result in command window\n",
    "print \"\\n The number of channels available per cell for 4-cell reuse system = %0.0f channels\"%(chpercell)\n",
    "print \"\\n One control channel and 160 voice channels would be assigned to each cell.\"\n",
    "\n",
    "# b) To compute the number of channels available per cell for seven-cell reuse system\n",
    "N=7#                                                        # frequency reuse factor\n",
    "chpercell=ceil(Ntotal/N)#                                         # number of channels available per cell for seven-cell reuse system\n",
    "\n",
    "# Answer is varrying due to round-off error\n",
    "\n",
    "# Displaying the result in command window\n",
    "print \"\\n \\n The number of channels available per cell for 7-cell reuse system = %0.0f channels\"%(chpercell)\n",
    "print \"\\n Each cell would have one control channel, four cells would have 90 voice channels and three cells would have 91 voice channels.\"\n",
    "\n",
    "# c) To compute the number of channels available per cell for 12-cell reuse system\n",
    "N=12#                                                        # frequency reuse factor\n",
    "chpercell=Ntotal/N#                                          # number of channels available per cell for seven-cell reuse system\n",
    "\n",
    "# Displaying the result in command window\n",
    "print \"\\n \\n The number of channels available per cell for 12-cell reuse system = %0.0f channels\"%(chpercell)\n",
    "print \"\\n Each cell would have one control channel, eight cells would have 53 voice channels and four cells would have 54 voice channels.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3.2 Page No.72"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " Signal to noise ratio for n=4 with frequency reuse factor N=7 = 18.66 dB\n",
      "\n",
      " Signal to noise ratio for n=3 with frequency reuse factor N=7 = 12.05 dB\n",
      "\n",
      " Signal to noise ratio for n=3 with frequency reuse factor N=12 = 15.56 dB\n",
      "\n",
      " Since SIR is for n=3 with frequency reuse factor N=7 greater than the minimum required, so N=12 is used.\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt, log10\n",
    "from __future__ import division\n",
    "# To find frequency reuse factor for path loss exponent (n) a)n=4 b)n=3\n",
    "\n",
    "# Given data\n",
    "SIdB=15#                     # Signal to interference(dB)\n",
    "io=6#                        # Number of cochannel cell\n",
    "\n",
    "# For n=4\n",
    "n1=4#                        # Path loss exponent\n",
    "N1=7#                        # First consideration: frequency reuse factor N=7\n",
    "DR1=sqrt(3*N1)#              # Co-channel reuse ratio\n",
    "si1=(1/io)*(DR1)**n1#         # Signal to interference\n",
    "sidB1=10*log10(si1)#         # Signal to interference(dB)\n",
    "\n",
    "# For n=3\n",
    "n2=3#                        # Path loss exmponent\n",
    "si=(1/io)*(DR1)**n2#          # Signal to interference for first consideration: frequency reuse factor N=7\n",
    "sidB=10*log10(si)#           # Signal to interference(dB)\n",
    "\n",
    "N2=12#                       # second consideration : frequency reuse factor N=12 since sidB<SIdB \n",
    "DR2=sqrt(3*N2)#              # Co-channel reuse ratio\n",
    "si2=(1/io)*(DR2)**n2#         # Signal to interference\n",
    "sidB2=10*log10(si2)#         # Signal to interference(dB)\n",
    "\n",
    "# Displaying the result in command window\n",
    "print \"\\n Signal to noise ratio for n=4 with frequency reuse factor N=7 = %0.2f dB\"%(sidB1)\n",
    "print \"\\n Signal to noise ratio for n=3 with frequency reuse factor N=7 = %0.2f dB\"%(sidB)\n",
    "print \"\\n Signal to noise ratio for n=3 with frequency reuse factor N=12 = %0.2f dB\"%(sidB2)\n",
    "print \"\\n Since SIR is for n=3 with frequency reuse factor N=7 greater than the minimum required, so N=12 is used.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3.4 Page No.80"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " Total number of users for 1 channel = 1\n",
      "\n",
      " Total number of users for 5 channel = 11\n",
      "\n",
      " Total number of users for 10 channel = 40\n",
      "\n",
      " Total number of users for 20 channel = 111\n",
      "\n",
      " Total number of users for 100 channel = 809\n"
     ]
    }
   ],
   "source": [
    "# To find number of users for Number of channels (C) a)C=1 b)C=5 c)C=10 d)C=20 e)C=100\n",
    "\n",
    "# Given data\n",
    "GOS=0.005#             #G rade of Service\n",
    "Au=0.1#                # Traffic intensity per user\n",
    "\n",
    "# a)To find number of users for C=1\n",
    "C1=1#                  # Number of channels\n",
    "A1=0.005#              # Total traffic intensity from Erlangs B chart\n",
    "U1=(A1/Au)#            # Number of users\n",
    "U1=1#                  # Since one user could be supported on one channel\n",
    "\n",
    "# b)To find number of users for C=5\n",
    "C2=5#                  # Number of channels\n",
    "A2=1.13#               # Total traffic intensity from Erlangs B chart\n",
    "U2=round(A2/Au)#       # Number of users\n",
    "\n",
    "# c)To find number of users for C=10\n",
    "C3=10#                 # Number of channels\n",
    "A3=3.96#               # Total traffic intensity from Erlangs B chart\n",
    "U3=round(A3/Au)#       # Number of users\n",
    "\n",
    "# Answer is varrying due to round off error\n",
    "\n",
    "# d)To find number of users for C=20\n",
    "C4=20#                 # Number of channels\n",
    "A4=11.10#              # Total traffic intensity from Erlangs B chart\n",
    "U4=round(A4/Au)#       # Number of users\n",
    "\n",
    "# Answer is varrying due to round off error\n",
    "\n",
    "# e)To find number of users for C=100\n",
    "C5=100#                # Number of channels\n",
    "A5=80.9#               # Total traffic intensity from Erlangs B chart\n",
    "U5=round(A5/Au)#       # Number of users\n",
    "\n",
    "# Displaying the result in command window\n",
    "print \"\\n Total number of users for 1 channel = %0.0f\"%(U1)\n",
    "print \"\\n Total number of users for 5 channel = %0.0f\"%(U2)\n",
    "print \"\\n Total number of users for 10 channel = %0.0f\"%(U3)\n",
    "print \"\\n Total number of users for 20 channel = %0.0f\"%(U4)\n",
    "print \"\\n Total number of users for 100 channel = %0.0f\"%(U5)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3.5 Page No.83"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " Total number of users in system A = 47280\n",
      "\n",
      " The percentage market penetration of system A  = 2.36\n",
      "\n",
      " \n",
      " Total number of users in system B = 44100\n",
      "\n",
      " The percentage market penetration of system B  = 2.205\n",
      "\n",
      " \n",
      " Total number of users in system C = 43120\n",
      "\n",
      " The percentage market penetration of system C  = 2.156\n",
      "\n",
      " \n",
      " Total number of users in all 3 systems = 134500\n",
      "\n",
      " The combined Market penetration percentage of all systems = 6.725\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "# To find number of users for a)system A b)system B c)system C\n",
    "\n",
    "# Given data\n",
    "GOS=0.02#                           # Grade of Service (Probability of bloacking)\n",
    "lamda=2#                            # Average calls per hour\n",
    "H=(3/60)#                           # Call duration in seconds\n",
    "\n",
    "Au=lamda*H#                         # Traffic intensity per user\n",
    "\n",
    "# a)To find number of users for System A\n",
    "C1=19#                             # Number of channels used\n",
    "A1=12#                             # Traffic intensity from Erlang B chart\n",
    "U1=round(A1/Au)#                   # Number of users per cell\n",
    "cells1=394\n",
    "TU1=U1*cells1#                     # Total number of users\n",
    "MP1=TU1/(2*10**6)*100#              # Market penetration percentage\n",
    "\n",
    "# b)To find number of users for System B\n",
    "C2=57#                            # No. of channels used\n",
    "A2=45#                            # Traffic intensity from Erlang B chart\n",
    "U2=round(A2/Au)#                  # Number of users per cell\n",
    "cells2=98\n",
    "TU2=U2*cells2#                    # Total no. of users\n",
    "MP2=TU2/(2*10**6)*100#             # Market penetration percentage\n",
    "\n",
    "# c)To find number of users for System C\n",
    "C3=100#                          # Number of channels used\n",
    "A3=88#                           # traffic intensity from Erlang B chart\n",
    "U3=round(A3/Au)#                 # Number of users per cell\n",
    "cells3=49\n",
    "TU3=U3*cells3#                   # Total no. of users\n",
    "MP3=TU3/(2*10**6)*100#            # Market penetration percentage\n",
    "\n",
    "TU=TU1+TU2+TU3#                  # Total number of users in all 3 systems\n",
    "MP=TU/(2*10**6)*100#              # Combined Market penetration percentage\n",
    "\n",
    "# Displaying the result in command window\n",
    "print \"\\n Total number of users in system A = %0.0f\"%(TU1)\n",
    "print \"\\n The percentage market penetration of system A  = %0.2f\"%(MP1)\n",
    "print \"\\n \\n Total number of users in system B = %0.0f\"%(TU2)\n",
    "print \"\\n The percentage market penetration of system B  = %0.3f\"%(MP2)\n",
    "print \"\\n \\n Total number of users in system C = %0.0f\"%(TU3)\n",
    "print \"\\n The percentage market penetration of system C  = %0.3f\"%(MP3)\n",
    "print \"\\n \\n Total number of users in all 3 systems = %0.0f\"%(TU)\n",
    "print \"\\n The combined Market penetration percentage of all systems = %0.3f\"%(MP)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3.6 Page No.84"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " Number of cells in given system = 31 cells\n",
      "\n",
      " \n",
      " Number of channels per cell in given system = 95 channels/cell\n",
      "\n",
      " \n",
      " Traffic intensity in given system = 84 Erlangs/cell\n",
      "\n",
      " \n",
      " Maximum carried traffic in given system = 2604 Erlangs\n",
      "\n",
      " \n",
      " Total number of users = 86800 users\n",
      "\n",
      " \n",
      " Number of mobiles per unique channel = 130 mobiles/channel\n",
      "\n",
      " \n",
      " Theoretically maximum number of served mobiles is the number of available channels in the system.\n",
      "\n",
      " Theoretical Maximum number of users could be served at one time = 2945 users\n",
      "It is 3.4% of customer base.\n"
     ]
    }
   ],
   "source": [
    "# To find a)Number of cells in given area b)Number of channels/cell c)Traffic intensity per cell d)Maximum carried traffic e)Total number of users for 2% GOS f) Number of mobiles per unique channel   g)Maximum number of users could be served at one time\n",
    "\n",
    "# Given data\n",
    "Area=1300#                          # Total coverage area in m**2\n",
    "R=4#                                # Radius of cell in m\n",
    "N=7#                                # Frequecy reuse factor\n",
    "S=40*10**6#                          # Allocated spectrum in Hz\n",
    "Ch=60*10**3#                         # Channel width in Hz\n",
    "\n",
    "# a)Number of cells\n",
    "CA=2.5981*R**2#                      # Area of hexagonal cell in m**2\n",
    "Nc=round(Area/CA)#                  # Number of cells\n",
    "\n",
    "# Displaying the result in command window\n",
    "print \"\\n Number of cells in given system = %0.0f cells\"%(Nc)\n",
    "\n",
    "# b)Number of channels/cell\n",
    "C1=round(S/(Ch*N))#                  # Number of channels\n",
    "\n",
    "# Displaying the result in command window\n",
    "print \"\\n \\n Number of channels per cell in given system = %0.0f channels/cell\"%(C1)\n",
    "\n",
    "# c) Traffic intensity per cell\n",
    "C1=95#                               # Number of channels from b)\n",
    "GOS=0.02#                            # Grade of service\n",
    "A=84#                                # Traffic intensity from Erlang B chart\n",
    "\n",
    "# Displaying the result in command window\n",
    "print \"\\n \\n Traffic intensity in given system = %0.0f Erlangs/cell\"%(A)\n",
    "\n",
    "# d)Maximum carried traffic\n",
    "traffic=Nc*A#                       # Maximum carried traffic\n",
    "\n",
    "# Displaying the result in command window\n",
    "print \"\\n \\n Maximum carried traffic in given system = %0.0f Erlangs\"%(traffic)\n",
    "\n",
    "# e)Total number of users for 2% GOS \n",
    "trafficperuser=0.03#                 # Given traffic per user\n",
    "U=traffic/trafficperuser#            # Total number of users\n",
    "\n",
    "# Displaying the result in command window\n",
    "print \"\\n \\n Total number of users = %0.0f users\"%(U)\n",
    "\n",
    "# f) Number of mobiles per unique channel\n",
    "C=666#                               # Number of channels\n",
    "mobilesperchannel=round(U/C)#        # Number of mobiles per unique channel\n",
    "\n",
    "# Displaying the result in command window\n",
    "print \"\\n \\n Number of mobiles per unique channel = %0.0f mobiles/channel\"%(mobilesperchannel)\n",
    "\n",
    "# g)Maximum number of users could be served at one time\n",
    "print \"\\n \\n Theoretically maximum number of served mobiles is the number of available channels in the system.\"\n",
    "C=C1*Nc#                              # Maximum number of users could be served at one time\n",
    "\n",
    "# Displaying the result in command window\n",
    "print \"\\n Theoretical Maximum number of users could be served at one time = %0.0f users\"%(C)\n",
    "print \"It is 3.4% of customer base.\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3.7 Page 85"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " Number of users per square km in given system = 62 users/sq km\n",
      "\n",
      " \n",
      " Percentage of probability that delayed call have to wait longer than t=10 sec = 56.29 percent\n",
      "\n",
      " \n",
      " Percentage of probability that call is delayed more than 10 sec = 2.81 percent\n"
     ]
    }
   ],
   "source": [
    "from math import exp\n",
    "# To find a)number of users per square km b)probability that delayed call have to wait longer than t=10sec c)probability that call is delayed more than 10 sec\n",
    "\n",
    "# Given data\n",
    "R=1.387#                                  # Radius of cell in m\n",
    "Area=2.598*R**2#                           # Area of hexagonal cell in m**2\n",
    "cellpercluster=4#                         # Number of cells/cluster\n",
    "channels=60#                              # Number of channels\n",
    "\n",
    "channelspercell=channels/cellpercluster#  # Number of channels per cell\n",
    "\n",
    "# a)To find number of users per square km\n",
    "A=0.029#                                  # Traffic intensity per user\n",
    "delayprob=0.05#                           # Grade of service\n",
    "traffic=9#                                # Traffic intensity from Erlang chart C\n",
    "U1=traffic/A#                             # Total number of users in 5sq.km.\n",
    "U=round(U1/Area)#                         # Number of users per square km\n",
    "\n",
    "# Displaying the result in command window\n",
    "print \"\\n Number of users per square km in given system = %0.0f users/sq km\"%(U)\n",
    "\n",
    "# b)To find the probability that delayed call have to wait longer than t=10sec\n",
    "lamda=1#                                 # Holding time\n",
    "H1=A/lamda#                              # Duration of call\n",
    "H=H1*3600#                                # Duration of call in second\n",
    "t=10\n",
    "Pr=exp(-(channelspercell-traffic)*t/H)*100#         # probability that delayed call have to wait longer than t=10sec.\n",
    "\n",
    "# Displaying the result in command window\n",
    "print \"\\n \\n Percentage of probability that delayed call have to wait longer than t=10 sec = %0.2f percent\"%(Pr)\n",
    "\n",
    "# c)To find the probability that call is delayed more than 10 sec\n",
    "Pr10=delayprob*Pr#                        # probability that call is delayed more than 10 sec\n",
    "\n",
    "# Displaying the result in command window\n",
    "print \"\\n \\n Percentage of probability that call is delayed more than 10 sec = %0.2f percent\"%(Pr10)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3.8 Page 89"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " Number of channels without use of microcell = 300 channels\n",
      "\n",
      " \n",
      " Number of channels with the use of lettered microcells = 660 channels\n",
      "\n",
      " \n",
      " Number of channels if all base stations are replaced by microcells = 1020 channels\n"
     ]
    }
   ],
   "source": [
    "# To find number of channels in 3 km by 3 km square centered around A in Figure 3.9 for a)without use of microcell b)with the use of lettered microcells c)all base stations are replaced by microcells\n",
    "\n",
    "# Given data\n",
    "R=1#                                                                      # Cell radius in km\n",
    "r=0.5#                                                                    # Micro-cell radius in km\n",
    "Nc=60#                                                                    # Number of channels in base station\n",
    "\n",
    "# a)To find number of channels without use of microcell\n",
    "Nb1=5#                                                                     # Number of base stations in given area\n",
    "N1=Nb1*Nc#                                                                 # Number of channels without use of microcell\n",
    "\n",
    "# b)To find number of channels with the use of lettered microcells\n",
    "Nb2=6#                                                                     # Number of lettered microcells\n",
    "Nb2=Nb1+Nb2#                                                               # Total number of base stations in given area\n",
    "N2=Nb2*Nc#                                                                 # Number of channels with the use of lettered microcells\n",
    "\n",
    "# c)To find number of channels if all base stations are replaced by microcells\n",
    "Nb3=12#                                                                    # Number of all the microcells\n",
    "Nb3=Nb1+Nb3#                                                               # Total number of base stations in given area\n",
    "N3=Nb3*Nc#                                                                 # Number of channels if all base stations are replaced by microcells\n",
    "\n",
    "# Displaying the result in command window\n",
    "print \"\\n Number of channels without use of microcell = %0.0f channels\"%(N1)\n",
    "print \"\\n \\n Number of channels with the use of lettered microcells = %0.0f channels\"%(N2)\n",
    "print \"\\n \\n Number of channels if all base stations are replaced by microcells = %0.0f channels\"%(N3)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3.9 Page 92"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      " Cell capacity of unsectored system = 1326 calls/hour\n",
      "\n",
      " \n",
      " Cell capacity of 120 degree sectored system = 1008 calls/hour\n",
      "\n",
      " \n",
      " Decrease in cell capacity in 120 degree sectored system = 0 percent\n"
     ]
    }
   ],
   "source": [
    "# To analyze trunking efficiency capacity of sectoring and unsectoring\n",
    "\n",
    "# Given data\n",
    "H=2/60#                                                       # Average call duration in hour\n",
    "GOS=0.01#                                                     # Probability of blocking\n",
    "\n",
    "# Unsectored system\n",
    "C1=57#                                                         # Number of traffic channels per cell in unsectored system\n",
    "A=44.2#                                                        # Carried traffic in unsectored system\n",
    "calls1=1326#                                                   # Number of calls per hour in unsectored system from Erlangs B table\n",
    "\n",
    "# 120 degree sectored system\n",
    "C2=C1/3#                                                      # Number of traffic channels per antenna sector in 120 degree sectored system\n",
    "calls2=336#                                                   # Number of calls per hour in 120 degree sectored system from Erlangs B table\n",
    "Ns1=3#                                                        # Number of sectors\n",
    "capacity=Ns1*calls2#                                          # Cell capacity or number of calls handled by system per hour\n",
    "\n",
    "dif=calls1-capacity#                                          # decrease in cell capacity in 120 degree sectored system\n",
    "percentdif=(dif/calls1)*100#                                  # decrease in cell capacity in 120 degree sectored system in percentage\n",
    "\n",
    "# Displaying the result in command window\n",
    "print \"\\n Cell capacity of unsectored system = %0.0f calls/hour\"%(calls1)\n",
    "print \"\\n \\n Cell capacity of 120 degree sectored system = %0.0f calls/hour\"%(capacity)\n",
    "print \"\\n \\n Decrease in cell capacity in 120 degree sectored system = %0.0f percent\"%(percentdif)"
   ]
  }
 ],
 "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
}