In [3]:

```
from __future__ import division
# To find far field distance for antenna with maximum dimensions and operating frequency
# Given data
D=1# # Maximum dimension in m
f=900*10**6# # Operating frequency in Hz
C=3*10**8# # Speed of light in m/sec
lamda=C/f# # Carrier wavelength in m
# To find far field distance
df=(2*D**2)/lamda# #Far field distance
#Displaying the result in command window
print '\n Far field distance = %0.0f meter'%(df)#
```

In [3]:

```
from __future__ import division
from math import log10,pi
# To find a)transmitter power in dBm b)Transmitter power in dBW and the received power of antenna in dBm at free space distance of 100m from antenna and 10km
# Given data
Pt=50# # Transmitter power in W
fc=900*10**6# # Carrier frequency in Hz
C=3*10**8# # Speed of light in m/s
#a)Transmitter power in dBm
PtdBm=round(10*log10(Pt/(1*10**(-3))))# #Transmitter power in dBm
# Displaying the result in command window
print '\n Transmitter power = %0.1f dBm'%(PtdBm)#
#b)Transmitter power in dBW
PtdBW=round(10*log10(Pt/1))# #Transmitter power in dBW
# Displaying the result in command window
print '\n Transmitter power = %0.1f dBW'%(PtdBW)#
# To find receiver power at 100m
Gt=1# #Transmitter gain
Gr=1# #Receiver gain
d=100# #Free space distance from antenna in m
L=1# #System loss factor since no loss in system
lamda=C/fc# #Carrier wavelength in m
Pr=(Pt*Gt*Gr*lamda**2)/((4*pi)**2*d**2*L)# #Receiver power in W
PrdBm=10*log10(Pr/10**(-3))# #Receiver power in dBm
#Displaying the result in command window
print '\n Receiver power = %0.1f dBm'%(PrdBm)#
#For Pr(10km)
d0=100# #Reference distance
d=10000# #Free space distance from antenna
Pr10km=PrdBm+20*log10(d0/d)# #Received power at 10km from antenna in dBm
#Displaying the result in command window
print '\n Receiver power at 10km from antenna = %0.1f dBm'%(Pr10km)#
```

In [2]:

```
from __future__ import division
from math import sqrt,pi,log10
# To find a)power at receiver b)magnitude of E-field at receiver c)rms voltage applied to receiver input
# Given data
Pt=50# # Transmitter power in Watt
fc=900*10**6# # Carrier frequency in Hz
Gt=1# # Transmitter antenna gain
Gr=2# # Receiver antenna gain
Rant=50# # Receiver antenna resistance in ohm
# a)Power at receiver
d=10*10**3# # Distance from antenna in meter
lamda=(3*10**8)/fc# # Carrier wavelength in meter
Prd1=10*log10((Pt*Gt*Gr*lamda**2)/((4*pi)**2*d**2))# # Power at transmitter in dBW
Prd=10*log10(((Pt*Gt*Gr*lamda**2)/((4*pi)**2*d**2))/(10**-3))# # Power at transmitter in dBm
# Displaying the result in command window
print '\n Power at receiver = %0.1f dBW'%(Prd1)#
print '\n Power at receiver = %0.1f dBm'%(Prd)#
# b)Magnitude of E-field at receiver
Ae=(Gr*lamda**2)/(4*pi)# # Aperture gain
Pr=10**(Prd1/10)# # Receiver power in W
E=sqrt((Pr*120*pi)/Ae)# # Magnitude of E-field at receiver
# Displaying the result in command window
print '\n \n Magnitude of E-field at receiver = %0.4f V/m'%(E)#
# c)rms voltage applied to receiver input
Vant=sqrt(Pr*4*Rant)*10**3# # rms voltage applied to receiver input
#Answer is varrying due to round-off error
#Displaying the result in command window
print '\n \n RMS voltage applied to receiver input = %0.3f mV'%(Vant)#
```

In [2]:

```
from __future__ import division
from math import sqrt,asin,degrees
# To calculate the Brewster angle
# Given data
Er=4# # Permittivity
x=sqrt((Er-1)/(Er**2-1)) # Sine of brewster angle
theta=degrees(asin(x)) # Brewster angle
#Answer is varrying due to round off error
# Displaying the result in command window
print '\n Brewster angle = %0.2f degree'%(theta)#
```

In [2]:

```
from __future__ import division
from math import log10,sqrt,pi
# To find a)the length and effective aperture of receiving antenna b)the received power at mobile
# Given data
d=5*10**3# # distance of mobile from base station in m
E0=1*10**-3# # E-field at 1Km from transmitter in V/m
d0=1*10**3# # Distance from transmitter in m
f=900*10**6# # Carrier frequency used for the system in Hz
c=3*10**8# # Speed of ligth in m/s
gain=2.55# # Gain of receiving antenna in dB
G=10**(gain/10)# # Gain of receiving antenna
# a)To find the length and effective aperture of receiving antenna
lamda=c/f# # Wavelength
L=lamda/4# # Length of antenna
Ae=(G*lamda**2)/(4*pi)# # Effective aperture of receiving antenna
# Displaying the result in command window
print '\n Length of antenna = %0.4f m'%(L)#
print ' = %0.2f cm'%(L*10**2)#
print '\n Effective aperture of receiving antenna = %0.3f m**2'%(Ae)#
# b)To find the received power at mobile
# Given data
ht=50# # Heigth of transmitting antenna
hr=1.5# # Heigth of receiving antenna
ERd=(2*E0*d0*2*pi*ht*hr)/(d**2*lamda)# # Electic field at distance d in V/m
Prd=((ERd**2/377)*Ae)# # The received power at mobile in W
PrddB=10*log10(Prd)# # The received power at mobile in dBW
PrddBm=10*log10(Prd/10**-3)# # The received power at mobile in dBm
Prd=((ERd**2/377)*Ae)*10**13# # The received power at mobile in 10**-13W
# Displaying the result in command window
print '\n \n The received power at mobile = %0.1f X 10**-13 W'%(Prd)#
print ' = %0.2f dBW'%(PrddB)#
print ' = %0.2f dBm'%(PrddBm)#
```

In [8]:

```
from __future__ import division
from math import log10,sqrt,pi
# To compute diffraction loss and identify Fresnel zone within which tip of obstruction lies for a)h=25m b)h=0 c)h=-25m
# Given data
lamda=1/3# # Wavelength in meter
d1=1*10**3# # Distance between transmitter and obstructing screen in m
d2=1*10**3# # Distance between receiver and obstructing screen in m
# a) For h=25m
h=25# # Effective heigth of obstruction screen in m
v=h*sqrt((2*(d1+d2))/(lamda*d1*d2))# # Fresnel diffraction parameter
print '\n a) For h=25m Fresnel diffraction parameter v = %0.2f'%(v)#
print '\n From the plot of Knife-edge diffraction gain as a function of Fresnel diffraction parameter, diffraction loss is 22dB.'
Gd=-20*log10(0.225/v)# # Diffraction loss for v>2.4 in dB
print '\n Using numerical approximation, diffraction loss for v > 2.4 = %0.1f dB'%(Gd)#
delta=(h**2/2)*((d1+d2)/(d1*d2))# # Path length difference between direct and diffracted rays
n=(2*delta)/lamda# # Number of Fresnel zones in which the obstruction lies
print '\n Fresnel zone within which tip of obstruction lies = %0.2f'%(n)#
print '\n Therefore, the tip of obstruction completely blocks the first three Fresnel zones.'
# b) For h=0
h=0# # Effective heigth of obstruction screen in m
v=h*sqrt((2*(d1+d2))/(lamda*d1*d2))# # Fresnel diffraction parameter
print '\n \n b) For h=0 Fresnel diffraction parameter v = %0.0f'%(v)#
print '\n From the plot of Knife-edge diffraction gain as a function of Fresnel diffraction parameter, diffraction loss is 6dB.'
Gd=-20*log10(0.5-0.62*v)# # Diffraction loss for v=0 in dB
print '\n Using numerical approximation, diffraction loss for v=0 = %0.0f dB'%(Gd)#
delta=(h**2/2)*((d1+d2)/(d1*d2))# # Path length difference between direct and diffracted rays
n=(2*delta)/lamda# # Number of Fresnel zones in which the obstruction lies
print '\n Fresnel zone within which tip of obstruction lies = %0.0f'%(n)#
print '\n Therefore, the tip of obstruction lies in middle of first Fresnel zone.'
# c) For h=-25m
h=-25# # Effective heigth of obstruction screen in m
v=h*sqrt((2*(d1+d2))/(lamda*d1*d2))# # Fresnel diffraction parameter
print '\n \n c) For h=-25m Fresnel diffraction parameter v = %0.2f'%(v)#
print '\n From the plot of Knife-edge diffraction gain as a function of Fresnel diffraction parameter, diffraction loss is approximately 1dB.'
Gd=0# # Diffraction loss for v<-1 in dB
print '\n Using numerical approximation, diffraction loss for v < -1 = %0.0f in dB'%(Gd)#
delta=(h**2/2)*((d1+d2)/(d1*d2))# # Path length difference between direct and diffracted rays
n=(2*delta)/lamda# # Number of Fresnel zones in which the obstruction lies
print '\n Fresnel zone within which tip of obstruction lies = %0.2f'%(n)#
print '\n Therefore, the tip of obstruction completely blocks the first three Fresnel zones but diffraction loss is negligible.'
```

In [1]:

```
from __future__ import division
from math import log10,sqrt,pi,atan
# To determine a)the loss due to knife-edge diffraction b)the heigth of obstacle required to induce 6dB diffraction loss
# Given data
f=900*10**6# # Operating frequency in Hz
c=3*10**8# # Speed of ligth in m/s
hr=25# # Heigth of receiver in m
ht=50# # Heigth of transmitter in m
h=100# # Heigth of obstruction in m
d1=10*10**3# # Distance between transmitter and obstruction in m
d2=2*10**3# # Distance between receiver and obstruction in m
# a)To determine the loss due to knife-edge diffraction
lamda=c/f# # Operating wavelength in m
ht=ht-hr# # Hegth of transmitter after subtracting smallest heigth (hr)
h=h-hr# # Heigth of obstruction after subtracting smallest heigth (hr)
bet=atan((h-ht)/d1)# # From geometry of environment in rad
gamm=atan(h/d2)# # From geometry of environment in rad
alpha=bet+gamm# # From geometry of environment in rad
v=alpha*sqrt((2*d1*d2)/(lamda*(d1+d2)))# # Fresnel diffraction parameter
# the loss due to knife-edge diffraction
Gd=-20*log10(0.225/v)# # Diffraction loss for v>2.4 in dB
# Displaying the result in command window
print '\n The loss due to knife-edge diffraction = %0.1f dB'%(Gd)#
# b)To determine the heigth of obstacle required to induce 6dB diffraction loss
Gd=6# # Diffraction loss in dB
v=0# # Fresnel diffraction parameter from the plot of Knife-edge diffraction gain as a function of Fresnel diffraction parameter
# v=0 is possible only if alpha=0. Therefore bet=-gamm
# By considering this situation, the geometry of environment provides (h/d2)=(ht/(d1+d2))
h=(ht*d2)/(d1+d2)# # the heigth of obstacle required to induce 6dB diffraction loss
# Displaying the result in command window
print '\n The heigth of obstacle required to induce 6dB diffraction loss = %0.2f m'%(h)#
```

In [2]:

```
from __future__ import division
from math import log10,sqrt,erf
# To find a)the minimum mean square error b)the standard deviation about mean value c)received power at d=2 km d)the likelihood that the received signal level at 2 km e) the percentage of area within 2 km
# Given data
d0=100# # First receiver distance in meter
d1=200# # Second receiver distance in meter
d2=1000# # Third receiver distance in meter
d3=3000# # Fourth receiver distance in meter
p0=0# # Receved power of first receiver in dBm
p1=-20# # Receved power of second receiver in dBm
p2=-35# # Receved power of third receiver in dBm
p3=-70# # Receved power of forth receiver in dBm
# a)To find the minimum mean square error
n=2887.8/654.306# # Loss exponent after differentiating and equating the squared error function with zero
# Displaying the result in command window
print '\n Loss exponent = %0.0f'%(n)#
# b)To find the standard deviation about mean value
P0=-10*n*log10(d0/100)# # The estimate of p0 with path loss model
P1=-10*n*log10(d1/100)# # The estimate of p1 with path loss model
P2=-10*n*log10(d2/100)# # The estimate of p2 with path loss model
P3=-10*n*log10(d3/100)# # The estimate of p3 with path loss model
J=(p0-P0)**2+(p1-P1)**2+(p2-P2)**2+(p3-P3)**2# # Sum of squared error
SD=sqrt(J/4)# # The standard deviation about mean value
# Displaying the result in command window
print '\n The standard deviation about mean value = %0.2f dB'%(SD)#
# The decimal point is not given in the answer given in book.
# c)To find received power at d=2 km
d=2000# # The distance of receiver
P=-10*n*log10(d/100)# # The estimate of p2 with path loss model
# Displaying the result in command window
print '\n The received power (at d=2 km) = %0.2f dBm'%(P)#
# Answer is varying due to round off error
# d)To find the likelihood that the received signal level at 2 km
gam=-60# # The received power at 2km will be greater than this power
z=(gam-P)/SD#
Pr=(1/2)*(1-erf(z/sqrt(2)))# # The probability that received signal will be greater than -60dBm
# Displaying the result in command window
print '\n The probability that received signal will be greater than -60dBm = %0.1f percent'%(Pr*100)#
# Answer is varying due to round off error
# e)To find the percentage of area within 2 km
A=92# # From figure 4.18, area receives coverage above -60dBm
# Displaying the result in command window
print '\n The percentage of area within 2 km = %0.0f percent'%(A)#
```

In [3]:

```
from __future__ import division
from math import log10,pi
# To find the power at receiver
# Given data
d=50*10**3# # Distance between transmitter and receiver in m
hte=100# # Effective heigth of transmitter in m
hre=10# # Effective heigth of receiver in m
EIRP=1*10**3# # Radiated power in Watt
f=900*10**6# # Operating frequency in Hz
c=3*10**8# # Speed of ligth in m/s
lamda=c/f# # operating wavelength in m
EIRP=20*log10(EIRP)# # Radiated power in dB
Gr=0# # Receiving gain in dB
Lf=-10*log10(lamda**2/(4*pi*d)**2)# # Free space path loss in dB
Amu=43# # Attenuation relative to free space in dB from Okumuras curve
Garea=9# # Gain due to type of environment in dB from Okumuras curve
Ghte=20*log10(hte/200)# # Base station antenna heigth gain factor for 1000m > hte > 30m
Ghre=20*log10(hre/3)# # Mobile antenna heigth gain factor for 10m > hre > 3m
L50=Lf+Amu-Ghte-Ghre-Garea# # Total mean path loss
# The median reeived power
Pr=EIRP-L50+Gr#
#Displaying the result in command window
print '\n The power at receiver = %0.2f dBm'%(Pr)#
#Answer is varrying due to round-off error
```

In [1]:

```
from math import log10
# To find the mean path loss
# Given data
d0=1# # Reference distance in m
d=30# # Distance from transmitter in m
nSF=3.27# # Exponent value for same floor
nMF=5.22# # Path loss exponent value for multiple floors
FAF=24.4# # Floor attenuation factor for specified floor in dB
n=2# # Number of blocks
PAF=13# # Particular attenuation factor for paricular obstruction in dB
PLSFd0=31.5# # Attenuation at reference distance for same floor in dB
PLMFd0=5.5# # Attenuation at reference distance for multiple floor in dB
#Mean path loss at same floor
PL1=PLSFd0+10*nSF*log10(d/d0)+FAF+n*PAF#
#Mean path loss at multiple floor
PL2=PLMFd0+10*nMF*log10(d/d0)+n*PAF#
#Displaying the result in command window
print '\n The mean path loss at same floor = %0.1f dB'%(PL1)#
print '\n The mean path loss at multiple floor = %0.1f dB'%(PL2)#
```

In [4]:

```
from __future__ import division
# To find far field distance for antenna with maximum dimensions and operating frequency
# Given data
D=1# # Maximum dimension in m
f=600*10**6# # Operating frequency in Hz
C=3*10**8# # Speed of light in m/sec
lamda=C/f# # Carrier wavelength in m
# To find far field distance
df=(2*D**2)/lamda# #Far field distance
#Displaying the result in command window
print '\n Far field distance = %0.0f meter'%(df)#
```