import math
#Initialisation
sig=0.005 #sigma
ur=1 #relative permeability
er=12 #relative permittivity
eo=8.85*10**-12 #permittivity of a free space
f1=10*10**3 #frequency of radio wave 1
f2=10*10**9 #frequency of radio wave 2
#Calculation
c1=sig/(2*math.pi*f1*eo*er) #conductivity at f1
c2=sig/(2*math.pi*f2*eo*er) #conductivity at f2
#Result
print'conductivity at f1 = %.1f >> 1'%c1
print'conductivity at f2 = %.1f x10^-4 >> 1'%(c2*10**4)
#Initialisation
c1=3*10**8 #speed of light in m/s
f1=100*10**6 #frequency in hertz
f2=1*10**9 #frequency in hertz
#Calculation
v1=c1/(9) #velocity in m/s
v2=c1 #velocity in m/s
h1=v1*f1**-1 #wavelength at f1, v1
h2=v2*f1**-1 #wavelength at f1, v2
h3=v1*f2**-1 #wavelength at f2, v1
h4=v2*f2**-1 #wavelength at f2, v2
#Result
print'Velocity,'
print'V1 = %.2f x10^7 m/s'%(v1*10**-7)
print'V2 = %.2f x10^8 m/s'%(v2*10**-8)
print'\nfor f1 = 100 MHz'
print'lambda1 = %f m'%h1
print'lambda2 = %d m'%h2
print'\nfor f2 = 1 GHz'
print'lambda1 = %.2f cm'%(h3*10)
print'lambda2 = %d cm'%(h4*10**2)
import math
import cmath
#Initialisation
s=0.08 #medium conductivit
w=10**7 #angular velocity
e=8.85*10**-7 #permitivity if free space
u=14 #medium permeability
uo=4*3.14*10**-7 #permeability of free space
#Calculation
f=w*(2*3.14)**-1 #frequency
a=math.sqrt(f*math.pi*s*uo) #attenuation
b=a #phase
d=complex(a,b)
y=d #propagation constants
z=math.log10(0.5)/(-math.log10(math.exp(1))*2*a) #Depth of the land
#Result
print'(1) Attenuation = %.1f Np/m'%a
print' Phase = %.1f Rad/m'%b
print' Propagation constant = %.1f'%y.real
print' + %.1f j rad/m'%y.imag
print'(2) Depth of land = %.2f m'%z
#Initialisation
W=100*10**-12 #power in watt
no=120*math.pi
#Calculation
Em=math.sqrt(2*no*W) #effective value of E
Ee=Em/math.sqrt(2) #effective value of E
Hm=math.sqrt((2*10**-10)/(no)) #effective value of H
He=Hm/math.sqrt(2) #effective value of H
#Result
print'Em = %.1f uV/m'%(Em*10**6)
print'Ee = %.1f uV/m'%(Ee*10**6)
print'Hm = %.3f uA/m'%(Hm*10**6)
print'He = %.2f uA/m'%(He*10**6)
#Initialisation
f=7.5 #frequency in GHz
d=40 #link distance in Km
Pt=30 #transmitter power in dBm
La=15 #additional loss
Pth=-78 #RX threshold
#Calculation
FSL=92.4+(20*math.log10(f*d)) #FSL
RSL=Pt-(0.4*FSL)-La #RSL
FM=RSL-Pth #fade margin
#Result
print'(1) Received signal level (RSL) = %.1f dBm'%RSL
print'(2) Fade margin = %.1f dB'%FM
#Initialisation
Pt=10 #transmitter power in watt
Gt=5 #antenna power in dBm
Lt=2 #feeder loss in dB
d=8000 #distance in meter
no=120*math.pi
#Calculation
EIRP=Pt+Gt-Lt
x=EIRP*10**-1
EIRP2=10**x #Equivalent isotropic radiated power
Ed=math.sqrt(30*EIRP2)/d #Electric Field Intensity
W=(Ed**2)/(2*no) #power in watt
#Result
print'EIRP = %.1f W'%EIRP2
print'|Ed| = %.2f mV/m'%(Ed*10**3)
print'W = %.1f nW/m^2'%(W*10**9)
#Initialisation
FSL=128 #FSL in dB
Lb=135 #Sum of FSL and medium loss Lm
Lc=5
Gt=30 #transmitter gain in dB
Gr=30 #reciever gain in dB
Pr=-60 #received signal level
#Calculation
Lm=Lb-FSL #medium loss in dB
Lm1=10**(Lm*10**-1) #medium loss
Pt=Lc+Lb-Gt-Gr+Pr #power in dBm
Pt1=10**(Pt*10**-1) #power in watt
#Result
print'Medium Loss = %d'%Lm1
print'Pt = %.1f mW'%(Pt1)
#Initialisation
ri1=1.00025 #refractive index
ri2=1.00023 #refractive index
h1=1 #height in Km
h2=1.5 #height in Km
n=1.00026 #variation
#Calculation
deln=ri1-ri2
delh=h2-h1
d=deln/delh
R=n/d #radius of curvature
#Result
print'Radiowave curvature radius, R = %.d Km'%R
#Initialisation
R=25000 #path curvature radius in Km
Re=6370 #Earth radius in Km
#Calculation
K=R*(R-Re)**-1 #K factor
Re1=K*Re #equivalent radii of the Earth
R1=(1*Re1**-1)-(1*Re**-1)+(1*R**-1)
d=1*R1**-1 #equivalent radii of the path
#Result
print'K = %.3f'%K
print'Re1 = %d'%Re1
print'R1 = %d'%d
print'Therefore, R1 ~ infinity'