from math import sqrt,pi,sin,log10
#Variable declaration
C_lambda = 0.1*pi #Circumference (lambda)
R_m = 1.6 #Mutual resistance of two loops (ohm)
theta1 = 90*pi/180 #Angle of radiation (radians)
theta2 = 2*pi/10 #Angle of radiation (radians)
#Calculation
Rr = 197*(C_lambda)**4 #Self resistance of loop (ohm)
D1 = (1.5)*(sin(theta1))**2 #Direcivity of loop alone (unitless)
D1_db = 10*log10(D1) #Directivity of loop alone (dBi)
D2 = 1.5*(2*sqrt(Rr/(Rr-R_m))*sin(theta2))**2
#Directivity of loop with ground plane (unitless)
D2_db = 10*log10(D2) #Direcitivy of loop with ground plane (dBi)
#Result
print "The directivity of loop alone is %.2f or %.2f dBi" % (D1,D1_db)
print """The direcitivy of loop with ground plane is %.2f or %.0f dBi
""" %(D2,D2_db)
from math import sqrt, sin, pi, log10
#Variable declaration
Rr = 197.0 #self resistance of loop (ohm)
Rm = 157.0 #mutual resistance of two loops (ohm)
theta = 2*pi/10 #Angle of radiation (radians)
#Calculation
D = 1.5*(2*sqrt(Rr/(Rr-Rm))*sin(theta))**2 #Directivity (unitless)
D_db = 10*log10(D) #Directivity (dBi)
#Result
print "The direcitivy is %.1f or %.1f dBi" % (D,D_db)
from math import pi, log10
#Variable declaration
c = pi #Circumference (m)
f1 = 1 #Frequency (MHz)
f2 = 10 #Frequency (MHz)
d = 10e-3 #Diameter of copper wire (m)
#Calcalation
RL_Rr1 = 3430/((c**3)*(f1**3.5)*d)
RL_Rr2 = 3430/((c**3)*(f2**3.5)*d)
#Ratio of Loss resistance and radiation resistance (unitless
k1 = 1/(1+RL_Rr1) #Radiation efficiency (unitless)
k_db1 = 10*log10(k1) #Radiation efficiency (in dB)
k2 = 1/(1+RL_Rr2) #Radiation efficiency (unitless)
k_db2 = 10*log10(k2) #Radiation efficiency (in dB)
#Result
print "The radiation effiency for 1 MHz is %.1ef or %.1f dB" % (k1, k_db1)
print "The radiation effiency for 10 MHz is %.2f or %.1f dB" % (k2, k_db2)
from math import pi,sqrt
#Variable declaration
n = 10 #Number of turns (unitless)
dia = 1e-3 #Diameter of copper wire (m)
dia_rod = 1e-2 #Diameter of ferrite rod (m)
len_rod = 10e-2 #Length of ferrite rod (m)
mu_r = 250 - 2.5j #Relative permeability (unitless)
mu_er = 50 #Efeective relative permeability (unitless)
f = 1e6 #Frequency (Hz)
c = 3e8 #Speed of light (m/s)
mu_0 = pi*4e-7 #Absolute permeability (H/m)
#Calculations
wave_lt = c/f #Wavelength (m)
radius = dia_rod/2
C_l = (2*pi*radius)/(wave_lt) #Circumference of loop (m)
Rr = 197*(mu_er**2)*(n**2)*(C_l**4) #Radiation resistance (ohm)
Rf = 2*pi*f*mu_er*(mu_r.imag/mu_r.real)*mu_0*(n**2)*(pi*radius**2)/len_rod #Loss resistance(ohm)
cond = 1/((7e-5**2)*f*pi*mu_er) #Conductivity (S/m)
delta = 1/(sqrt(f*pi*mu_er*cond)) #Depth of penetration(m)
RL = n*(C_l/dia)*sqrt((f*mu_0)/(pi*cond)) #Ohmic resistance (ohm)
k = Rr/(RL+abs(Rf)) #Radiation efficiency (unitless)
L = mu_er*(n**2)*(radius**2)*mu_0/len_rod #Inductance (H)
Q = 2*pi*f*L/(abs(Rf) + Rr + RL) #Ratio of energy stored to energy lost per cycle (unitless)
fHP = f/Q #Bandwidth at half power (Hz)
#Results
print "The radiation efficiency is ", round(k,11)
print "The value of Q is ", round(Q,3)
print "The half-power bandwidth is", round(fHP), "Hz"
import numpy as np
#Variable declaration
Z0 = 376.7 #Intrinsic impdence of free space (ohm)
Zd = 73 + 42.5j #Impedence of infinitesimally thin lambda/2 antenna (ohm)
#Calculation
Z1 = (Z0**2)/(4*Zd) #Terminal impedence of the lambda/2 slot antenna (ohm)
#Result
print "The terminal impedence of the thin lambda/2 slot antenna is", np.around(Z1), "ohm"
#Variable declaration
Zd = 67 #Terminal impedence of cylindrical antenna (ohm)
Z0 = 376.7 #Intrinsic impedence of free space (ohm)
L = 0.475 #Length of complementary slot (lambda)
#Calculation
Z1 = Z0**2/(4*Zd) #Terminal resistance of complementary slot (ohm)
w = 2*L/100 #Width of complementary slot (lambda)
#Result
print "The terminal resistance of the complementary slot is", round(Z1), "ohm"
print "The width of the complementary slot is", w, "lambda"
#Variable declaration
Zd = 710 #Terminal impdence of cylindrical dipole
Z0 = 376.7 #Intrinsic impedence of free space (ohm)
#Calculation
Z1 = Z0**2/(4*Zd) #Terminal resistance of complementary slot (ohm)
#Result
print "The terminal resistance of the complementary slot is", round(Z1),"ohm"
import math
#Variable declaration
delta_e = 0.2 #path length difference in E-plane (lambda)
delta_h = 0.375 #path length difference in H-plane (lambda)
a_e = 10 #E-plane aperture (lambda)
#Calculation
L = a_e**2/(8*delta_e) #Horn length(lambda)
theta_e = 2*math.atan2(a_e,2*L)*180/math.pi #Flare angle in E-plane (degrees)
theta_h = 2*math.acos(L/(L+delta_h))*180/math.pi
#Flare angle in the H-plane (degrees)
a_h = 2*L*math.tan(theta_h/2*math.pi/180) #H-plane aperture (lambda)
hpbw_e = 56/a_e #Half power beamwidth in E-plane (degrees)
hpbw_h = 67/a_h #Half power beamwidth in H-plane (degrees)
D = 10*math.log10(7.5*a_e*a_h) #Directivity (dB)
#Result
print "The length of the pyramidal horn is", L,"lambda"
print "The flare angles in E-plane and H-plane are", round(theta_e,1),"and", round(theta_h,2), "degrees"
print "The H-plane aperture is", round(a_h,1), "lambda"
print "The Half power beamwidths in E-plane and H-plane are", hpbw_e,"&",round(hpbw_h,1),\
"degrees"
print "The direcivity is", round(D,1),"dBi"