n=2 #(No. of point source)
#E=E0*{exp(%i*pi/2)-exp(-%i*si/2)} where exp(-%i*si)=-1
#si=Beta*d*cosd(fi)=2*pi*cosd(fi)
#E=2*%i*E0*sind(pi*cosd(fi)) But 2*%i*E0=1
from numpy import arange, sin, pi, cos, nditer
fi=arange(0,331,30) #degree(angle)
En=sin(pi*cos(fi*pi/180)) #Normalized field
print " fi :\t",
for x in fi:
print x,"\t",
print ""
print "|En| :\t",
for x in abs(En):
print "%0.2f"%x,"\t",
n=2 #(No. of point source)
#E=E0*{exp(%i*(pi/4+si/2))-exp(-%i*(pi/4+si/2))} as exp(%i*theta)+exp(-%i*theta)=2*cos(theta)
#E=2*E0*cos(pi/4+si/2)
#si=Beta*d*cosd(fi)=2*pi*cosd(fi)
#En=cos(pi/4+Beta*d*cosd(pi/4)) But 2*E0=1
from numpy import arange, sin, pi, cos, nditer
fi=arange(0,331,30) #degree(angle)
En=cos(pi/4+pi/4*cos(fi*pi/180)) #Normalized field
print " fi :\t",
for x in fi:
print x,"\t",
print ""
print "|En| :\t",
for x in abs(En):
print "%0.3f"%x,"\t",
#E=cos(fi)+sin(fi)<si
#En=cos(pi/4+pi*cosd(fi)) as 2*E0=1
from numpy import arange, sin, pi, cos, nditer
fi=arange(0,331,30) #degree(angle)
si=pi/2*(cos(fi*pi/180)+1) #(Phase)
En=cos(pi/4+pi*cos(fi*pi/180)) #Normalized field
print " fi :\t",
for x in fi:
print x,"\t",
print ""
print "|En| :\t",
for x in abs(En):
print "%0.3f"%x,"\t",
#Answer in the book is wrong.
from math import degrees, acos
n=80.0 #(no. of elements)
N=1.0 #for first null
#d=lamda/2 (spacing)
dBYlamda=1.0/2 #(spacing/wavelength)
fi01=degrees(acos(N/n/dBYlamda)) #degree(Angle)
Null_1st=(pi/2*180/pi)-fi01 #degree(First Null)
print "Location of 1st null from maxima = %0.2f degree "%Null_1st
from math import degrees, acos
import numpy as np
n=4.0 #(No. of elements)
#d=lamda/2 (Spacing)
dBYlamda=1.0/2 #(Spacing/wavelength)
alfa=0 #degree(angle)
N=1.0 #(For first null)
print "Part (i) :"
theta01=np.array([degrees(acos(+N/2)),degrees(acos(-N/2))]) #degree(Angle)
N=2 #(For second null)
theta02=np.array([degrees(acos(+N/2)), degrees(acos(-N/2))]) #degree(angle)
#N=3 #not possible as N/2 is greater than 1
print "\tNull directions for N=1 : theta01 =" ,theta01 ,"degree"
print "\tNull directions for N=2 : theta02 =" ,theta02 ,"degree"
print "Part (ii):"
m=0 #for maxima
theta_m=degrees(acos(m/dBYlamda)) #degree(angle)
print "\tDirection of maxima : theta_m = %0.2f degree " %theta_m
print "Part (iii):"
S=1 #for side lobe maxima
#S=2 & onwards not possible
theta_S=np.array([degrees(acos((2*S+1)/2/n/dBYlamda)), degrees(acos(-(2*S+1)/2/n/dBYlamda))]) #degree(angle for side lobe)
print "\tSide lobe maxima : theta_S =",theta_S ,"degree "
print "Part (iv):"
HPBW=2*(90-degrees(acos(1.391/np.pi/n/dBYlamda))) #degree(HPBW)
print "\tHPBW = %0.2f degree " %HPBW
print "Part (v):"
FNBW=2*(90-degrees(acos(1/n/dBYlamda))) #degree(FNBW)
print "\tFNBW = %0.2f degree "%FNBW
print "Part (vi):"
SLL=-13.46 #dB##for isotropic sources array(Side lobe level)
print "\tSide lobe level = %0.2f dB "%SLL
# Answer wrong in the textbook.
import numpy as np
from __future__ import division
n=4 #(No. of elements)
#d=lamda/2 (spacing)
dBYlamda=1/2 #(spacing/wavelength)
theta=0 #degree(angle)
#Beta=2*pi/lamda
print "Part (i):"
Beta_into_lamda=2*np.pi #(Coefficient)
#alfa=-Beta*d
alfa=-Beta_into_lamda*dBYlamda #radian(Progressive phase shift)
alfa=alfa*180/np.pi #degree(Progressive phase shift)
print "\tProgressive phase shift = %0.2f degree "%alfa
print "Part (ii):"
N=range(1,4) #as N=4 is not allowed
theta01=degrees(acos(1-N[0]/n/dBYlamda)) #degree(angle)
theta02=degrees(acos(1-N[1]/n/dBYlamda)) #degree(angle)
theta03=degrees(acos(1-N[2]/n/dBYlamda)) #degree(angle)
print "\tNull directions, theta01, theta02 & theta03 are %0.2f, %0.2f & %0.2f degree "%(theta01,theta02,theta03)
print "Part (iii):"
m=range(0,2) #as m=2 & onwards is not allowed
theta0=degrees(acos(1-m[0]/dBYlamda)) #degree(angle)
theta1=degrees(acos(1-m[1]/dBYlamda)) #degree(angle)
print "\tMaxima directions, theta0, theta1 are %0.2f & %0.2f degree "%(theta0,theta1)
print "Part (iv):"
FNBW=2*degrees(acos(1-1/n/dBYlamda)) #degree(FNBW)
print "\tFNBW = %0.2f degree "%(FNBW)
print "Part (v):"
HPBW=2*degrees(acos(1-1.391/n/np.pi/dBYlamda)) #degree(HPBW)
print "\tHPBW = %0.2f degree : "%HPBW
n=16 #no. of point source
#d=lamda/4 (spacing)
dBYlamda=1/4 #(Spacing/wavelength)
HPBW=2*degrees(acos(1-1.391/n/np.pi/dBYlamda)) #degree(HPBW)
print "HPBW = %0.2f degree" %HPBW
n=10 #no. of elements
#d=lamda/4 (spacing)
dBYlamda=1/4 #/(Spacing/wavelength)
#Broadside array
D=2*n*dBYlamda #unitless(Directivity)
D=10*np.log10(D) #dB(Directivity)
print "Directivity for broadside array = %0.2f dB " %D
#Endfire array
D=4*n*dBYlamda #unitless(Directivity)
D=10*np.log10(D) #dB(Directivity)
print "Directivity for Ordinary endfire array = %0.2f dB "%D
D=20 #dB(Directivity)
#d=lamda/4 (spacing)
dBYlamda=1/4 #(spacing/wavelength)
D=10**(D/10) #unitless(Directivity)
n=D/4/dBYlamda #no. of elements
print "(i) No. of elements : ",n
LBYlamda=(n-1)*dBYlamda #(length/wavelength)
print "(ii) Length of the array is ",(LBYlamda),"*lamda"
HPBW=2*degrees(acos(1-1.391/np.pi/n/dBYlamda)) #degree(HPBW)
print "(iii) HPBW = %0.2f degree " %HPBW
SLL=-13.46 #dB(Side lobe level)
print "(iv) SLL = %0.2f dB " %SLL
Beta_into_lamda=2*np.pi #(temorary calculatuion)
#alfa=-Beta*d #for theta=0
#alfa=Beta*d #for theta=180
alfa1=-Beta_into_lamda*dBYlamda #radian##for theta=0
alfa1=alfa1*180/np.pi #degree(angle)
alfa2=Beta_into_lamda*dBYlamda #radian##for theta=180
alfa2=alfa2*180/np.pi #degree(angle)
print "(v) Progressive phase shift, α for theta equals to 0° & 180° are : ",(alfa1,alfa2)
from sympy import symbols, solve
SLL=19.1 #dB(Side Lobe Level)
#d=lamda/2 (spacing)
dBYlamda=1/2 #(Spacing/wavelength)
n=4 #(no. of elements)
r=round(10**(SLL/20)) #(ratio of main lobe to side lobe)
m=n-1 #(degree )
x0 = symbols('x0')
#T3(x0)=r=4*x0**3-3*x0
T3=4*x0**3-3*x0 -9
#x0=roots([4 0 -3 -r]) #(Coefficient)
x0=solve(T3)
x0=x0[0] #taking real value(Coefficient)
#E4(z)=T3(x)=4*x**3-3*x=4*a1*z**3-3*a1*z+a0*z
#4*a1*z**3=4*x**3 where z**3=(x/x0)**3
a1=4*x0**3/4 #(Coefficient)
#a0*z-3*z*a1=-3*x
a0=(3/x0*a1-3)*x0 #(Coefficient)
print "Coefficients of array polynomial a1 & a0 are : ",float(a0),"&", float(a1)
print "Relative current amplitudes are :",round(float(a0/a1),2),"&",float(a1/a1)