import math
#Given
h=0.1588
epsilon=2.2
v=3*10**8
f=10*10**9
W=(float(v)/(2*f))*(math.sqrt(2/(epsilon+1)))
W_cm=W*100
print "Width of the patch:",W_cm,"cm"
epsilon_eff=((epsilon+1)/2.0)+((epsilon-1)/2.0)*(1.0+12.0*h/W)**(-0.5)
print "Effective dielectric constant:",epsilon_eff
delta_L=(h*0.412*(epsilon_eff+0.3)*((W/h)+0.264))/((epsilon_eff-0.258)*((W/h)+0.8))
print "Extended incremental length of the patch:",delta_L,"cm"
lamda=v*100/f
L=(lamda/2)-(2*delta_L)
print "Actual length of patch:",L,"cm"
L_e=L+2*delta_L
print "Effective length of the patch:",L_e,"cm"
import scipy.integrate
import math
def S_i(a):
temp=scipy.integrate.quad(lambda x:sin(x)/x,0,a)
return temp[0]
def J0(s):
temp=scipy.integrate.quad(lambda x:cos(s*sin(x)),0,pi)
temp=(1/pi)*temp[0]
return temp
#Given
v=3*10**10
f=10*10**9
L=0.906
W=1.186
h=0.1588
epsilon=2.2
lamda_0=v/f
k0=(2*pi)/lamda_0
X=k0*W
I1=-2+cos(X)+X*S_i(X)+sin(X)/X
G1=I1/(120*pi**2)
temp=scipy.integrate.quad(lambda x:(((sin(k0*W*cos(x)/2)/cos(x))**2)*J0(k0*L*sin(x))*sin(x)**3),0,pi)
G12=(1/(120*pi**2))*temp[0]
Rin=1/(2*(G1+G12))
print "Input Impedance:",Rin,"ohms"
R=50.0
y0=(L/pi)*(math.acos(sqrt(R/Rin)))
print "The position of the inset feed point where input impedance is 50 ohms:",y0,"cm"
#All these values are taken or calculated from the previous examples
lamda=50.0
v=3*10**10
f=10*10**9
L=0.906
W=1.186
h=0.1588
epsilon=2.2
lamda_0=v/f
G1=0.00157
G12=0.00061683
I1=1.863
g_12=G12/G1
D_AF=2/(1+g_12)
D0=((2*pi*W)/lamda_0)**2*(1/I1)
D2=D0*D_AF
print "Directivity:",10*log10(D2),"dB"
I2=3.59801
D_2=((2*pi*W)/lamda_0)**2*(pi/I2)
print "Directivity:",10*log10(D_2),"dB"
#given
epsilon=2.2
h=0.1588
fr=10*10**9
F=(8.791*10**9)/(fr*sqrt(epsilon))
a=F/(1+((2*h)/(pi*epsilon*F))*((log(pi*F/(2*h))+1.7726)))**0.5
print "Actual radius of the microstrip patch antenna: %f cm"% a
#given
fc=10*10**9
h=0.1588
frac_bw=0.05
VSWR=2
Qt=(VSWR-1)/(frac_bw*VSWR**0.5)
print "The total Quality Factor: %f" % Qt
f1=fc/(sqrt(1+(1/Qt)))
f2=fc*(sqrt(1+(1/Qt)))
print "The resonant frequencies are : %f GHz, %f GHz" %(f1/10**9,f2/10**9)
rel_ratio=1+1/Qt
print "The relative ratio is %f. Thus the patch is nearly square," % rel_ratio