from scipy.integrate import quad,dblquad
#formula for beam solid angle theta_a=double_integration of d_omega
theta_a=quad(lambda x:1,0,2*pi)[0]*quad(lambda x:sin(x),0,pi/6)[0]
print 'Exact Beam Solid Angle:',theta_a,'steradians'
#formula for approx angle=delta1*delta2
delta1=pi/3
delta2=pi/3
theta_a1=delta1*delta2
theta_a1=delta1**2
print 'Approximate Beam Solid Angle:',theta_a1,'steradians'
import scipy
#The half power point of the pattern occurs at 60 degrees. Therefore theta_1r=2*pi/3
theta_1r=(2*pi)/3
theta_2r=(2*pi)/3
#Given U=B0*cos(theta)
exact_theta_a=dblquad(lambda x,y:cos(x)*sin(x), 0, (2*pi), lambda x:0, lambda x:(pi/2))
print 'Exact Beam Solid Angle:',exact_theta_a[0],'steradians'
#Formula for approx theta = theta_1r*theta_2r
approx_theta_a=theta_1r*theta_2r
print 'Approximate Beam Solid Angle:',approx_theta_a,'steradians'
#formula for exact directivity=4*pi/exact_beam_angle
exact_direct=((4*pi)/(exact_theta_a[0]))
#formula for approx directivity=4*pi/approx_beam_angle
approx_direct=((4*pi)/(approx_theta_a))
#exact directivity in dB
exact_direct_db=10*log10(exact_direct)
#approx directivity in dB
approx_direct_db=10*log10(approx_direct)
print 'Exact directivity:',exact_direct_db,'dB'
print 'Approx. directivity:',approx_direct_db,'dB'
import scipy
#Maximum intensity
u_max=1
#Calculation of radiated power
p_rad=dblquad(lambda x,y:(sin(x)**2)*sin(x),0,2*pi,lambda x:0,lambda x:pi)
print 'Radiated Power:',p_rad[0],'W'
#Calulation of maximum directivity
D0=(4*pi)/(p_rad[0])
#Directivity in dB
D0_db=10*log10(D0)
print 'Directivity:',D0_db,'dB'
deg=90
#Calculation od directivity
D0_1=101/(deg-0.0027*deg**2)
D0_1_db=10*log10(D0_1)
print 'Directivity:',D0_1_db,'dB'
#Calculation of directivity
D0_2=(-172.4)+(191*sqrt((0.818+(1/deg))))
D0_2_db=10*log10(D0_2)
print 'Directivity:',D0_2,'dB'
import scipy
B0=1
#Maximum intensity
u_max=1
#Array containing angles in radians
a=sin(array([10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180])*pi/180)**2
#Calculation of radiated power
p_rad1=B0*((pi/18)**2)*sum(a)*sum(a)
print 'Power Radiated:',p_rad1,'W'
#Calculation of directivity
D0=(4*pi)/(p_rad1)
print 'Directivity using numerical techniques:',D0
#Calu=culation of radiated power
a=quad(lambda x:sin(x)**2,0,pi)
b=quad(lambda x:sin(x)**2,0,pi)
p_rad2=a[0]*b[0]
#Directivity
D01=(4*pi)/(p_rad2)
print 'Directivity:',D01
import scipy
B0=1
#Maximum intensity
u_max=1
#Arrays containing angles in radians
a=sin(array([5,15,25,35,45,55,65,75,85])*pi/180)**2
b=sin(array([5,15,25,35,45,55,65,75,85])*pi/180)**2
#Calculation of radiated power
p_rad=B0*((pi/18)**2)*(2*sum(a))*(2*sum(b))
#Calculation of directivity
D0=(4*pi*u_max)/(p_rad)
print 'Directivity using 18 divisions:',D0
import scipy
#maximum intensuty
u_max=1
B0=1
#Input impedance in Ohms
inp_imp=73
#Characteristic impedance in Ohms
char_imp=50
#Calculation of radiated power
p_rad=B0*quad(lambda x:1,0,2*pi)[0]*quad(lambda x:sin(x)**4,0,pi)[0]
#Calulation of directivity
D0=(4*pi*u_max)/(p_rad)
#conduction & dielectric efficiency ecd=1 since antenna is loseless
ecd=1
#Maximum Gain
G0=ecd*D0
G0_db=10*log10(G0)
#Reflection Coefficient Tau
tau=float(inp_imp-char_imp)/float(inp_imp+char_imp)
#Reflection efficiency=1-tau**2
er=1-tau**2
er_db=10*log10(er)
#Total efficiency
e0=er*ecd
e0_db=10*log10(e0)
#Absolute Gain
G0_abs=e0*D0
G0abs_db=10*log10(G0_abs)
print 'Maximum Gain:',G0_db
print 'Reflection efficiency:',er_db
print 'Total efficiency:',e0_db
print 'Absolute Gain:',G0abs_db
import scipy
#unit vector of the wave
rho_w=array([1,0])
#unit vector of the electric field
rho_a=array([1/sqrt(2),1/sqrt(2)])
#Polarization factor
PLF=abs(dot(rho_w,rho_a))**2
print 'Polarization Factor:',PLF
import scipy
#unit vector of the wave
rho_w=array([1/sqrt(2),1/sqrt(2)])
#unit vector of the electric field
rho_a=array([1/sqrt(2),-1/sqrt(2)])
#Polarization Factor
PLF=abs(dot(rho_w,rho_a))**2
print 'Polarization Factor:',PLF
import scipy
#Radiation Resistance
rad_res=73
#Frequency of antenna
f=10**8
#Velocity
v=3*10**8
#Wavelength
lamda=v/f
#Length of antenna
l=lamda/2
#Perimeter of the antenna
b=(3*10**-4)*lamda
C=2*pi*b
#value of omega
w=2*pi*f
#Constant
mu0=4*pi*10**-7
#Conductivity
sigma=5.7*10**7
#High frequency resistance
Rhf=(l/C)*(sqrt((w*mu0)/(2*sigma)))
#Load resistance
Rl=Rhf/2
#calculation of conduction & dielectric efficiency
ecd=(rad_res)/(rad_res+Rl)
ecd_db=10*log10(ecd)
print 'Conduction-dielectric efficiency:',ecd_db
import scipy
lamda=1
#Maximum directivity of transmitter
D0_t_db=16
D0_t=10**(float(D0_t_db)/10)
#Maximum directivity of receiver
D0_r_db=20
D0_r=10**(D0_r_db/10)
#Reflection coeficients of transmitter and receiver
tau_r=0.1
tau_t=0.2
#Power at transmitter
P_t=2
#Calculation of Power to the receiver
P_r=(1-tau_r**2)*(1-tau_t**2)*((lamda/(4*pi*100*lamda))**2)*D0_t*D0_r*P_t
print 'Power delivered to the load of receiver:',P_r,'W'
import scipy
#antenna temp at receiver terminals
Ta=150
#physical temp of transmission line
T0=300
#thermal efficiency of the antennna
eA=0.99
#antenna physical temperature
Tp=300
l=1
#antenna temp at antenna terminals due to physical temperature
T_ap=Tp*(1/eA-1)
#Loss of waveguide in dB/m
alpha_db=0.13
#Loss of waveguide in Np/m
alpha_np=alpha_db/0.868
#Calulation of effective temperature
T_A=Ta*exp(-l*alpha_np*2)+T_ap*exp(-l*alpha_np*2)+T0*(1-exp(-l*alpha_np*2))
print 'Effective temperature:',T_A,'K'