#assume lamda=50
lamda=50.0
#Given
delta_phi_max=56.72
a=0.5*lamda
b=0.25*lamda
b1=2.75*lamda
k=2*pi/lamda
rho_1=(k*b1**2)/(4*2*(delta_phi_max*pi/180))
flare_ang=2*math.degrees(math.atan((b1/2)/rho_1))
print "Total flare angle:",flare_ang,"deg"
#Given
lamda=50.0
a=0.5*lamda
b=0.25*lamda
b1=0.275*lamda
rho_1=6*lamda #From example 13.1
s=b1**2/(8*lamda*rho_1)
#for the above s, theta = 90 and normalized field of -20dB
theta=90
En=-20
E_theta_dB=En+20.0*log10((1+cos(theta*pi/180))/2.0)
E_theta=10**(E_theta_dB/20)
print "Normalized voltage ratio:",E_theta
#Given
lamda=50.0
a=0.5*lamda
b=0.25*lamda
b1=2.75*lamda
rho_1=6*lamda
x=b1/sqrt(2*lamda*rho_1)
C2_x=0.518
S2_x=0.0576
DE=((64*a*rho_1)/(pi*lamda*b1))*(C2_x+S2_x)
print "Directivity:",10*log10(DE),"dB"
rho_e=sqrt(rho_1**2+(b1**2)/2)
B=(b1/lamda)*sqrt(50/(rho_e/lamda))
print "B=",B
#for the above value of B, GE=73.5
GE=73.5
DE1=(a/lamda)*(GE/sqrt(50/(rho_e/lamda)))
print "Directivity:",10*log10(DE1),"dB"
#given
lamda=50.0
a=0.5*lamda
b=0.25*lamda
a1=5.5*lamda
rho_2=6*lamda
u=(1/sqrt(2))*((sqrt(lamda*rho_2)/a1)+(a1/(sqrt(lamda*rho_2))))
v=(1/sqrt(2))*((sqrt(lamda*rho_2)/a1)-(a1/(sqrt(lamda*rho_2))))
C_u=0.394 #Values are from appendix
C_v=-0.659
S_u=0.373
S_v=-0.669
D_h=(4*pi*b*rho_2/(a1*lamda))*((C_u-C_v)**2+(S_u-S_v)**2)
print "Directivity:",10*log10(D_h),"dB"
rho_h=sqrt(rho_2**2+(a1/2)**2)
x=sqrt(50/(rho_h/lamda))
A=(a1/lamda)*x
#for the above value of A G_h=91.8
G_h=91.8
D_h1=(b/lamda)*(G_h/x)
print "Directivity:",10*log10(D_h1),"dB"
#Given
lamda=50.0
rho_1=rho_2=6*lamda
a1=5.5*lamda
b1=2.75*lamda
a=0.5*lamda
b=0.25*lamda
rho_e=6.1555*lamda #From previous
rho_h=6.6*lamda #examples
p_e=(b1-b)*(sqrt((rho_e/b1)**2-(1/4)))
p_h=(a1-a)*(sqrt((rho_h/a1)**2-(1/4)))
print "The values of rho-e and rho-h are not equal."
DE=12.79 #Using previous example values
DH=7.52
Dp=(pi*lamda**2/(32*a*b))*DE*DH
print "Directivity: %f dB" % (10*log10(Dp))
DE1=12.89
DH1=8.338
Dp1=(pi*lamda**2/(32*a*b))*DE1*DH1
print "Directivity: %f dB" % (10*log10(Dp1))
s=b1**2/(8*lamda*rho_1)
t=a1**2/(8*lamda*rho_2)
print "The values of s and t are %f, %f" %(s,t)
LE=0.20
LH=2.75
print "For the given values of s and t, LE=%f dB and LH=%f dB" %(LE,LH)
Dp2=10*(1.008+log10(a1*b1/lamda**2))-(LE+LH)
print "Directivity: %f dB" %Dp2
#Given
G0_db=22.6
G0=10**(G0_db/10)
f=11*10**9
v=30000000000.0
lamda=v/f
a=0.8382*lamda
b=0.3725*lamda
#The Value x1 is calculated on a trial and error basis
x=11.1157
rho_e=x*lamda
rho_h=lamda*(G0**2/(8*pi**3))*(1/x)
print "The values of rho-e and rho-h are %f and %f." %(rho_e,rho_h)
a1=(G0/(2*pi))*sqrt(3/(2*pi*x))*lamda
b1=sqrt(2*x)*lamda
print "Corresponding values of a1 and b1: %f cm, %f cm" %(a1,b1)
p_e=(b1-b)*(sqrt((rho_e/b1)**2-(1/4)))
p_h=(a1-a)*(sqrt((rho_h/a1)**2-(1/4)))
print "Values of pE and pH: %f cm, %f cm" %(p_e,p_h)
G0_1=(2*pi/lamda**2)*sqrt(3*lamda*rho_h)*sqrt(2*lamda*rho_e)
print "Directivity:",10*log10(G0_1)