from __future__ import division
from math import sqrt, atan, pi
N=5 #no. of turns
f=400 #MHz(Frequency)
c=3*10**8 #m/s(Speed of light)
lamda=c/(f*10**6) #m(Wavelength)
print "Part (i):"
S=lamda/50 #m(Spacing between turns)
S_BY_lamda=1/50 #(Spacing/wavelength)
C_BY_lamda=sqrt(2*S_BY_lamda) #(Circumference/wavelength)
print "\tCircumference is",C_BY_lamda,"*lamda"
C=sqrt(2*lamda*S) #m(Circumference)
print "\tCircumference = %0.2f meter "%C
print "Part (ii):"
Lo_BY_lamda=sqrt(S_BY_lamda**2+C_BY_lamda**2) #(Length/wavelength)
print "\tLength of single turn is",round(Lo_BY_lamda,6),"*lamda"
Lo=sqrt(S**2+C**2) #m(Length of single turn)
print "\tLength of single turn = %0.5f meter "%Lo
print "Part (iii):"
Ln_BY_lamda=N*Lo_BY_lamda #(Overall length/wavelength)
print "\tOverall Length is",round(Ln_BY_lamda,7),"*lamda"
Ln=N*Lo #m(Overall length)
print "\tOverall Length = %0.5f meter "%Ln
print "Part (iv):"
alfa=atan(S/C)*180/pi #degree(Pitch angle)
print "\tPitch angle, α = %0.2f degree"%alfa
from math import tan, pi, sqrt, log10
from __future__ import division
N=5 #no. of turns
f=300 #MHz(Frequency)
c=3*10**8 #m/s(speed of light)
print "Part (i):"
lamda=c/(f*10**6) #m(Wavelength)
C_BY_lamda=1 #(Circumference/wavelength)
print "\tNear optimum circumference is",C_BY_lamda,"*lamda"
C=lamda #m(Circumference)
print "\tNear optimum circumference = %0.f meter" %C
print "Part (ii):"
alfa=14 #degree#(Pitch angle)#for near optimum
S_BY_lamda=C_BY_lamda*tan(alfa*pi/180)
print "\tSpacing is",round(S_BY_lamda,4),"*lamda"
S=C*tan(alfa*pi/180) #m(Spacing)
print "\tSpacing = %0.4f meter "%S
print "Part (iii):"
Rin=140*C/lamda #Ω(Input impedence)
print "\tInput impedence = %0.2f Ω "%Rin
print "Part (iv):"
HPBW=52/(C/lamda*sqrt(N*S/lamda)) #degree(HPBW)
print "\tHPBW = %0.2f degree "%HPBW
print "Part (v):"
FNBW=115/(C/lamda*sqrt(N*S/lamda)) #degree(FNBW)
print "\tFNBW = %0.2f degree " %FNBW
print "Part (vi):"
Do=15*(C/lamda)**2*N*(S/lamda) #unitless##Directivity
print "\tDirectivity(unitless) : %0.4f"%Do
Do_dB=10*log10(Do) #dB(Directivity)
print "\tDirectivity = %0.3f dB "%Do_dB
print "Part (vii):"
AR=(2*N+1)/2/N #axial ratio
print "\tAxial ratio : ",AR
print "Part (viii):"
Rin=140*(C/lamda) #Ω(Input impedence)
#50 Ω line
Zo=50 #Ω(Output impedence)
Tau=(Rin-Zo)/(Rin+Zo) #Scaling factor
VSWR=(1+Tau)/(1-Tau) #(VSWR)
print "\tVSWR for 50Ω line : ",VSWR
#75 Ω line
Zo=75 #Ω(Output impedence)
Tau=(Rin-Zo)/(Rin+Zo) #Scaling factor
VSWR=(1+Tau)/(1-Tau) #(VSWR)
print "\tVSWR for 75Ω line : %0.3f"%VSWR
from math import tan, pi, sqrt, log10
HPBW=39 #degree(HPBW)
alfa=12.5 #degree(Pitch angle)
f=475 #MHz(Frequency)
c=3*10**8 #m/s(Speed of light)
lamda=c/(f*10**6) #m(Wavelength)
C=lamda #m(Circumference)
print "Part (i):"
#it is in axial mode as 3/4*lamda<C<4/3*lamda
S=C*tan(alfa*pi/180) #meter(Spacing)
N=52**2/HPBW**2/(S/lamda)/(C/lamda)**2 #turns
print "\tNumber of turns : ",round(N)
print "Part (ii):"
N=round(N) #turns
Do=15*(C/lamda)**2*N*(S/lamda) #unitless(Directivity)
Do_dB=10*log10(Do) #dB(Directivity)
print "\tDirectivity = %0.2f decibels"%Do_dB
print "Part (iii):"
AR=(2*N+1)/2/N #axial ratio
print "\tAxial ratio : ",AR
print "Part (iv):"
#3/4*lamda<C<4/3*lamda
lamda1=C/(3/4) #meter(Wavelength)
lamda2=C/(4/3) #meter(Wavelength)
f1=c/lamda1 #Hz(Frequency)
f2=c/lamda2 #Hz(Frequency)
print "\tFrequency range is",(f1/10**6),"MHz to",round(f2/10**6,2),"MHz."
print "Part (v):"
#At design frequency
Rin=140*C/lamda #Ω(Input impedence)
print "\tAt design frequency, Input impedence = %0.2f Ω "%Rin
#3/4*lamda<C<4/3*lamda
#At high frequency end
Rin=140*C/lamda2 #Ω(Input impedence)
print "\tAt high frequency end, Input impedence = %0.2f Ω "%Rin
#At low frequency end
Rin=140*C/lamda1 #Ω(Input impedence)
print "\tAt low frequency end, Input impedence = %0.2f Ω "%Rin
from math import tan, pi, sqrt, log10
Do_dB=14 #dB(Directivity
f=2.4 #GHz(Frequency)
c=3*10**8 #m/s(Speed of light)
lamda=c/(f*10**6) #m(Wavelength)
Do=10**(Do_dB/10) #unitless(Directivity)
C=lamda #m##for optimum result(Circumference)
alfa=14 #degree ##for optimum result(Pitch angle)
S=C*tan(alfa*pi/180) #m(Spacing)
N=Do/15/(C/lamda)**2/(S/lamda) #turns
N=round(N) #turns
Rin=140*C/lamda #Ω(Input impedence)
print "Input impedence = %0.2f Ω "%Rin
HPBW=52/(C/lamda*sqrt(N*S/lamda)) #degree
print "HPBW = %0.2f degree "%HPBW
FNBW=115/(C/lamda*sqrt(N*S/lamda)) #degree
print "FNBW = %0.f degree "%FNBW
AR=(2*N+1)/2/N #(Axial ratio)
print "Axial ratio : " ,round(AR,1)
from math import tan, pi, sqrt, log10, exp
f=10 #MHz(Frequency)
c=3*10**8 #m/s(Speed of light)
lamda=c/(f*10**6) #m(Wavelength)
d0=10**-3*lamda #m(spacing)
Lo=1*lamda #m(Length)
fi=pi; fi0=0 #radian
r0=d0/2 #m
print "Part (i):"
#R=r0*exp(a*fi-a*fi0) #m
#a=sqrt(1/Lo**2/(R-r0)**2-1) #per adian
a=1.166 #rad**-1(by above equation)
print "\tRate of spiral = %0.3f rad^-1 "%a
R_BY_lamda=r0/lamda*exp(a*2*pi) #m(Radius/wavelength)
print "\tRadius of terminal point is",round(R_BY_lamda,5),"*lamda"
print "Part (ii):"
R=r0*exp(a*2*pi) #m(Radius)
print "\tRadius at terminal point = %0.2f meter " %R
from fractions import Fraction
from math import tan, pi, sqrt, log, atan
fU=900 #MHz(Upper frequency)
fL=450 #MHz(Lower frequency)
c=3*10**8 #m/s(Speed of light)
lamdaU=c/(fU*10**6) #m(Upper wavelength)
lamdaL=c/(fL*10**6) #m(Lower wavelength)
Exp_ratio=4 #expansion ratio
a=log(Exp_ratio)/(2*pi) #rad**-1##rate of spiral
Beta=atan(1/a*pi/180) #degree
r0=lamdaU/4 #meter##minimum radius
print "Minimum radius = %0.1f cm"%(r0*100)
R=lamdaL/4 #meter##minimum radius
print "Maximum radius = %0.1f cm "%(R*100)
fi_m=log(R/r0)/a #radian
fi_m=fi_m*180/pi #degree
print "Φm = %0.2f degree "%(fi_m)
N=1/2 #for Φm=180 #degree
print "Number of turns, N is",Fraction(N)
from math import tan, pi, sqrt, log, atan
Gain=8.5 #dB(Gain)
tau=0.822;sigma=0.149 #for given gain
alfa=2*atan((1-tau*180/pi)/4/sigma) #degree
fL=54 #MHz(Lower frequency)
fU=216 #MHz(Upper frequency)
c=3*10**8 #m/s(Speed of light)
lamdaU=c/(fU*10**6) #m(Upper wavelength)
lamdaL=c/(fL*10**6) #m(Lower wavelength)
l1=lamdaU/2 #m(Length of element1)
lN=lamdaL/2 #m(Length of longest element)
l2=l1/tau; l3=l2/tau; l4=l3/tau; l5=l4/tau; l6=l5/tau; l7=l6/tau; l8=l7/tau; l9=l8/tau #m(Length of elements)
#Spacing between elements in meter
d1=2*sigma*l1
d2=2*sigma*l2
d3=2*sigma*l3
d4=2*sigma*l4
d5=2*sigma*l5
d6=2*sigma*l6
d7=2*sigma*l7
d8=2*sigma*l8
d9=2*sigma*l9
d=d1+d2+d3+d4+d5+d6+d7+d8+d9 #meter(total spacing)
print "Length of longest element = %0.2f m"%lN
print "Length of element1 = %0.3f m"%l1
print "Length of element1 = %0.3f m"%l2
print "Length of element1 = %0.3f m"%l3
print "Length of element1 = %0.3f m"%l4
print "Length of element1 = %0.3f m"%l5
print "Length of element1 = %0.3f m"%l6
print "Length of element1 = %0.3f m"%l7
print "Length of element1 = %0.3f m"%l8
print "Length of element1 = %0.3f m\n"%l9
print "Spacing of element1 = %0.3f m" %d1
print "Spacing of element1 = %0.3f m" %d2
print "Spacing of element1 = %0.3f m" %d3
print "Spacing of element1 = %0.3f m" %d4
print "Spacing of element1 = %0.3f m" %d5
print "Spacing of element1 = %0.3f m" %d6
print "Spacing of element1 = %0.3f m" %d7
print "Spacing of element1 = %0.3f m" %d8
print "Spacing of element1 = %0.3f m" %d9
print "Total Spacing length = %0.3f m "%d
#Answer is not accurate in the book.
from math import tan, pi
from numpy import array
tau=0.895 #scale factor
sigma=0.166 #(spacing factor)
fU=30 #MHz(Upper frequency)
fL=10 #MHz(Lower frequency)
c=3*10**8 #m/s(Speed of light)
lamdaU=c/(fU*10**6) #m(Upper wavelength)
lamdaL=c/(fL*10**6) #m(Lower wavelength)
l1=lamdaU/2 #m(Length of shortest element)
print "Length of shortest element, l1 = %0.2f meter "%l1
#Length of element in meter
l2=l1/tau; l3=l2/tau; l4=l3/tau; l4=l3/tau; l5=l4/tau; l6=l5/tau; l7=l6/tau; l8=l7/tau; l9=l8/tau;
l10=l9/tau; l11=l10/tau #
print """Other elements length l2, l3, l4, l5, l6, l7, l8, l9, l10, l11 are :
%0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f meter respectively."""%(l2,l3,l4,l5,l6,l7,l8,l9,l10,l11)
alfa=17.97 #degree(angle)
R1=(l1/2)/tan(alfa/2*pi/180) #m(Spacing between elements)
R2=R1/tau; R3=R2/tau; R4=R3/tau; R4=R3/tau; R5=R4/tau; R6=R5/tau; R7=R6/tau; R8=R7/tau; R9=R8/tau; R10=R9/tau; R11=R10/tau #m
print "Spacing between elements R1, R2, R3, R4, R5, R6, R7, R8,R9, R10, R11 are : "
print "%0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f meter respectively."%(R1,R2,R3,R4,R5,R6,R7,R8,R9,R10,R11)
#Answer is not accurate in the book.