import math
#Initialisation
c=3*10**8 #speed of light
f=400*10**6 #frequency in Hz
l1=15*10**3 #distance in m
l2=15*10**3 #distance in m
l=30*10**3 #distance in m
k=1.33 #k factor
d1=15 #distance in Km
d2=15 #distance in Km
re=6370 #distance in Km
#Calculation
h=c*f**-1 #wavelength in m
r1=math.sqrt(l1*l2*h/l) #Fresnel radius
ho=(500*d1*d2)/(k*re) #Earth bulge
#Results
print'(1) Fresnel radius, r1 = %d m'%r1
print'(2) h0 = %.2f m'%ho
import math
#Initialisation
f=400 #frequency in MHz
k=1.33 #k factor
er=3 #dielectric conductivity
sg=10**-4 #Earth effective conductivity
eo=8.85*10**-12 #permittivity of free space
re1=8500 #Effective Earth radius in Km
c=3*10**8 #speed of light
B=1
d=50
#Calculation
kh=1.6*10**-3 #horizontal polarization using Fig. 6.2
kv=5*10**-3 #vertical polarization using Fig. 6.2
X=2.2*B*f**(1*3**-1)*re1**(-2*3**-1)*d #normalized length of the path
FX=11+10*math.log10(X)-17.6*X #distance attenuation value
#Results
print'(1) Kh = %.1f x 10**-3'%(kh*10**3)
print' Kv = %.1f x 10**-3'%(kv*10**3)
print'(2) F(X) = %.2f dB'%FX
import math
#Initialisation
f=300*10**6 #frequency in Hz
l1=4*10**3 #distance in m
l2=6*10**3 #distance in m
h1=20 #height in m
c=3*10**8 #speed of light
d1=4 #distance in km
d2=6 #distance in km
R=10 #radius in km
m=0.13
n=1.99
#Calculation
h=c*f**-1 #wavelength
l=l1+l2
r1=math.sqrt(l1*l2*h/l)
rat=h1/r1 #ratio
a=math.sqrt((2*(d1+d2))/(h*d1*d2))
v=0.0316*h1*a
jv=6.9+20*math.log10(1.585) #knife-edge obstacle loss
k=8.2+12*n
Tmn=k*m
A=jv+Tmn #rounded obstacle loss
#Results
print'(1) Ratio = %f'%rat
print'(2) Loss J(v) = %.1f dB'%jv
print'(3) Loss A = %.2f dB'%A
import math
#Initialisation
f=150*10**6 #frequency in Hz
c1=3*10**8 #speed of light
h11=60 #in metre
d11=2000 #in metre
d1=259.6 #in metre
b=2000 #in metre
a=250 #in metre
h21=80 #in metre
d21=7259 #in metre
c=7250 #in metre
#Calculation
h=c1*f**-1 #wavelength
v1=h11*math.sqrt((2*(h*d1)**-1)+(1*d11**-1))
L1=6.9+20*math.log10(math.sqrt((v1-0.1)**2+1)+v1-0.1) #path diffraction loss
v2=h21*math.sqrt((2*(h*d11)**-1)+(1*d21**-1))
L2=6.9+20*math.log10(math.sqrt((v2-0.1)**2+1)+v2-0.1) #path diffraction loss
#Results
print'Diffraction loss L1 = %.2f dB'%L1
print' L2 = %.2f dB'%L2
import math
#Initialisation
f=450*10**6 #frequency in Hz
q1=1.282 #cumulative distribution value
q2=1.645 #cumulative distribution value
#Calculation
sg=3.8+1.6*math.log10(450) #standard deviation
fm1=q1*sg #fade margin
fm2=q2*sg #fade margin
fm=fm2-fm1 #gain
#Results
print'Antenna gain = %.2f dB'%fm
import math
#Initialisation
q90=1.282 #cumulative distribution value of 90%
sl=8 #standard deviation
q97=1.881 #cumulative distribution value of 97%
pt=5 #transmitter power
#Calculation
fm=q90*sl #fade margin
fm1=q97*sl #fade margin
p=fm1-fm #power in dB
p1=pt*10**(p/10) #power in watt
#Results
print'(1) Fade margin for received signal = %.3f dB'%fm
print'(2) New transmitter power = %d W'%p1
import math
#Initialisation
d= 50*10**3 #distance in m
#Calculation
sl1=5.3 #location standard deviation
st1=3 #time standard deviation
sl2=6.2 #location standard deviation
st2=2 #time standard deviation
sv=math.sqrt(sl1**2+st1**2) #total standard deviation of VHF
su=math.sqrt(sl2**2+st2**2) #total standard deviation of UHF
#Results
print'(1)for VHF, sigmaL = %.1f dB '%sl1
print' sigmaT = %.1f dB '%st1
print' for UHF, sigmaL = %.1f dB '%sl2
print' sigmaT = %.1f dB '%st2
print'(3) Standard deviation values, sigmaVHF = %.1f dB'%sv
print' sigmaUHF = %.1f dB'%su
import math
#Initialisation
d=5 #in dB
h=20 #Transmitter initial height
#Calculation
ht=h*10**(0.25) #Transmitter ultimate antenna height
#Results
print'(1) Antenna Height = %.2f m'%round(ht)
import math
#Initialisation
f=1800*10**6 #frequency in Hz
c=3*10**8 #speed of light
#Calculation
h=c*f**-1 #wavelength
hv=20*h #in metre
dh=10*h #in metre
#Results
print'hv = %.2f m '%hv
print'dh = %.2f m '%dh
import math
#Initialisation
p1=20 #transmitter power
g=6 #gain
h1=20 #height in metre
#Calculation
ct=p1/10 #Power gain
ch=(h1*30**-1)**2 #height gain
cg=g*4**-1 #antenna gain
co=10*math.log10(ct*ch*cg) #Total effects
#Results
print'(1) Power gain, Ct = %.f'%ct
print' Height gain = %.2f'%ch
print' Antenna gain = %.1f'%cg
print'(2) Total effects = %.2f dB'%co
import math
#Initialisation
g1=10 #transmitter gain
ct=15 #power in watt
#Calculation
g2=g1-2.2 #gain in dBd
cg=g2-6 #Antenna gain
ct1=ct*10**-1
ct2=10*math.log10(ct1) #Power gain
ch=(ct*30**-1)**2
ch1=10*math.log10(ch) #Height gain
ct3=ct1*0.5
ct4=10*math.log10(ct3)
co=ct4+cg+ch1 #Total effects
#Results
print'(1) Power gain, Ct = %.2f'%ct2
print' Height gain = %.2f'%ch1
print' Antenna gain = %.1f'%cg
print'(2) Total effects = %.2f dB'%co
import math
#Initialisation
sr=-106 #Receiver sensitivity
f=8 #Fade margin
cl=6 #Coupler loss
dl=1 #Duplexer Loss
bf=6.5 #BTS feeder loss
ba=12 #BTS antenna gain
pl=138 #Path loss
pg=15 #Pathlength in km
ta=2 #Terminal antenna gain
tf=0.5 #Terminal feeder loss
#Calculation
prm=sr+f #minimum received power
ptb=prm+cl+dl+bf-ba+pl-ta+tf #BTS transmitter power in dbBm
pw=10**((ptb-30)/10)
#Results
print'BTS transmitter power = %.2f dBm'%ptb
print' = %d W'%pw
import math
#Initialisation
pm=2 #transmitter power
ld=1 #Duplexer losses
lp=138 #Path loss
lfm=0.5 #terminal feeder losses
lfb=6.5 #transmitter feeder losses
gt=12 #BTS transmitter antenna gain
gr=2 #BTS receiver antenna gain
i=3
bs=-110 #BTS receiver sensitivity
#Calculation
ptm=10*math.log10(pm*10**3)
prb=ptm-ld-lp-lfm-lfb+gt+gr
pr=prb+i #BTS received power
fm=pr-bs #fade margin
#Results
print'BTS received power = %.1f dBm'%pr
print'Fade margin = %.1f dB'%fm
import math
#Initialisation
t1=25 #terminal transmitter power
t2=2 #terminal transmitter power
gd=3 #correction factor of receiver antennas
lc=5 #coupler loss
prm=-105 #receiver sensitivity
prb=-110 #receiver sensitivity
#Calculation
ptb=10*math.log10(t1*10**3)
ptm=10*math.log10(t2*10**3)
p=ptb-ptm #Transmitting gain in downlink
ga=prm-prb #Receiving gain in uplink
tg=gd+ga+lc #total gain on the uplink
#Results
print'Transmitting gain in downlink = %.1f dBm'%p
print'Receiving gain in uplink = %.1f dBm'%ga
print'total gain on the uplink = %.1f dBm'%tg
import math
#Initialisation
f=450 #frequency in MHz
d=25 #distance in m
hb=30
hm=5
#Calculation
fsl=32.4+(20*math.log10(f))+(20*math.log10(d)) #free space loss
lp=120+(40*math.log10(d))-(20*math.log10(hb))-(20*math.log10(hm)) #path loss
lm=76.3-10*math.log10(hm)
l=(40*math.log10(25))+(20*math.log10(f))-(20*math.log10(hb))+lm #path loss based on the clutter factor model
#Results
print'(1) Free space loss = %.1f dB'%fsl
print'(2) Loss = %.1f dB'%lp
print'(3) Loss based on clutter factor = %.1f dB'%l
import math
#Initialisation
pt=30 #transmitter power in watt
d=15 #distance in km
gt=3 #transmitter gain
ht=30 #transmitter height in m
hr=4 #receiver height in m
no=3.77*10**14
#Calculation
gt1=10**(gt*10**-1)
pt1=gt1*pt
e=88*math.sqrt(pt1)*pt*hr/(2*d**2) #Field strength
pr1=(e**2)/(2*no) #Recieved power
#Results
print'Field strength = %f V/m'%e
print'Recieved power = %.2f pW'%(pr1*10**12)
import math
#Initialisation
f=420 #frequency in Hz
h1=40 #height in m
h2=5 #height in m
d=15 #distance in km
#Calculation
A=69.55+26.16*math.log10(f)-13.82*math.log10(h1) #Hata parameters
B=44.9-6.55*math.log10(h1)
C=2*(math.log10(f*28**-1))**2+5.4
D=4.78*(math.log10(420))**2-18.33*math.log10(f)+40.94
E1=3.2*(math.log10(11.75*h2))**2-4.97
E2=(((1.1*math.log10(f))-0.7)*h2)-((1.56*math.log10(f))-0.8)
L3=A+B*math.log10(d)-D #in open area;
L2=A+B*math.log10(d)-C #in suburban area;
L1=A+B*math.log10(d)-E1 #in large cities;
L11=A+B*math.log10(d)-E2 #in small cities;
#Results
print'In large cities L1 = %.2f dB'%L1
print'In small cities L1 = %.2f dB'%L11
print'In suburban area L2 = %.2f dB'%L2
print'In open area L2 = %.2f dB'%L3
import math
#Initialisation
f=1800 #frequency in MHz
d=10 #distance in m
hb=40
hm=3
A=132.57 #Hata model data
B=34.4 #Hata model data
#Calculation
E2=(((1.1*math.log10(f))-0.7)*hm)-((1.56*math.log10(f))-0.8)
lp=46.3+33.9*math.log10(f)-13.82*math.log10(hb)+(44.9-6.55*math.log10(hb)-E2+hm)
L=A+B+-E2
#Results
print'Path loss based on COST–Hata model,'
print' Lp = %.2f dB'%lp
print'Path loss based on Hata model,'
print' Lp = %.2f dB'%L
import math
#Initialisation
pt=20 #transmitter power in watt
Hb=30 #in metre
Hm=3 #in metre
gt=14.2 #trasmitter gain in dB
gr=0.2 #receiver gain in dB
f=450 #frequency in MHz
gm=-2 #in dBd
gr2=-2.2 #in dBi
r1=10
n=20
hb=10
hm=10
#Calculation
gt1=gt+gr2
pr1=-62-38*math.log10(r1)-20*math.log10(f*900**-1)+7 #received signal level in suburban
pr2=-64-43*math.log10(r1)-20*math.log10(f*900**-1)+7 #received signal level in urban
ao=10*math.log10(2)+(gr2-6) #in dB (wrong value calculated in textbook)
pr11=-62-38*math.log10(r1)-20*math.log10(f*900**-1)+ao #received signal level in rural
pr22=-64-43*math.log10(r1)-20*math.log10(f*900**-1)+ao #received signal level in cities
ptd=10*math.log10(pt*10**3) #in dBm
lp1=ptd-pr11 #Path loss in rural area
lp2=ptd-pr22 #Path loss in cities area
#Results
print'(2) In the suburban area, Pr = %.1f dBm'%pr1
print' In the urban area, Pr = %.1f dBm'%pr2
print'(3) Path loss in rural area Lp = %.1f dB'%lp1 #(wrong value calculated in textbook)
print' Path loss in cities area Lp = %.1f dB'%lp2 #(wrong value calculated in textbook)