#program to compare the Q of an air filled and teflon filled coaxial line resonator .
from math import pi,sqrt,log
sigma=5.813*10**7;muo=4*pi*10**-7;f=5*10**9;eta=377;a =1*10**-3;b=4*10**-3;
omega=2*pi*f;ko=104.7;B=104.7;alpha=0.022;
Rs=sqrt((omega*muo)/(2*sigma));
alphaca=(Rs/(2*eta*log(b/a)))*((1/a)+(1/b)); # attenuation due to conductor loss for air filled line .
eipsilar=2.08;tandelta=0.0004; # for teflon filled line .
alphact=((Rs*sqrt(2.08)*0.01)/(2*eta*log(b/a)))*((1/ a)+(1/b)); # attenuation due to conductor loss for teflon filled line .
alphada=0; # for air filled line .
alphadt=ko*(sqrt(eipsilar)/2)*tandelta;
Qair=B/(2*alpha);
B=B*sqrt(eipsilar);
alpha =0.062;
Qteflon=B/(2*alpha);
print "Qair = %.1f"%Qair
print "Qteflon = %.1f"%Qteflon
print "conclusion: Qair is almost twice that of Qteflon"
# program to compute the length of the line for resonance at 5 GHZ and the Q of the resonator .
from math import sqrt,pi
W=0.0049;c=3*10**8;f=5*10**9;Zo=50;eipsilar=2.2;ko =104.7;tandelta =0.001;
Rs=0.0184; # taken from example 7.1.
eipsilae=1.87; # effective permittivity .
l=c/(2*f*sqrt(eipsilae)); # resonator length .
B=(2*pi*f*sqrt(eipsilae))/c;
alphac=Rs/(Zo*W);
alphad=(ko*eipsilar*(eipsilae -1)*tandelta)/(2*sqrt(eipsilae)*(eipsilar -1));
alpha=alphac+alphad;
Q=B/(2*alpha);
print "length of the line in meter = %.4f"%l
print "Q of the resonator = %.1f"%Q
# program to find required length ,d and Q for l=1 and l=2 resonator mode.
from math import sqrt,pi
a=0.04755;b=0.02215;eipsilar=2.25;tandelta=0.0004;f =5*10**9;c=3*10**8;
k=(2*pi*f*sqrt(eipsilar))/c # wave number .
for l in range(1,2):
d=(l*pi)/sqrt((k**2)-((pi/b)**2)); # m=1 & n=0 mode .
print "d in meter = %.4f"%d
eta=377/sqrt(eipsilar);
Qc1=3380.;# l=1.
Qc2=3864.;# l=2.
Qd=2500.; # Q due to dielectric loss only .
Q1=((1./Qc1)+(1./Qd))**-1; # for l =1.
Q2=((1./Qc2)+(1./Qd))**-1; # for l =2.
print "Q1 = %.0f"%Q1
print "Q2 = %.0f"%Q2
# program to find dimension and Q;
from math import pi,sqrt
f=5.*10**9;c=3.*10**8;p01=3.832;sigma=5.813*10**7;muo=4.*pi*10** -7;
eipsilar =2.25;
# mode TE011 . and d=2a .
omega=2*pi*f;
eta =377.;
lamda=c/f;
k=(2.*pi)/lamda;
# f=(c/(2⇤pi))⇤sqrt((p01/a)ˆ2+(%pi/(2⇤a))ˆ2); as d=2a given
a=sqrt((p01)**2+(pi/2)**2)/k;
Rs=sqrt((omega*muo)/(2.*sigma))
Qc=(k*a*eta)/(2.*Rs); # for m=l =1,n=0 and d=2a .
print "a in meter = %.4f"%a
print "Qc = %.3f"%Qc
# program to find the resonant frequency and Q for TE01delta mode .
from math import sqrt,pi,tan
delta=0.001;eipsilar=95.;a=0.413;L=0.008255;c=3.*10**8;
#tan((B⇤L)/2)=alpha/beta.
ko=2.405
alpha=(sqrt((2.405/a)**2-(ko)**2));
B=sqrt((eipsilar*(ko)**2) -(2.405/a)**2); # beta
f1=((c*2.405)/(2*pi*sqrt(eipsilar)*a))*10**-7;
f2=((c*2.405)/(2*pi*a))*10**-7;
print "f1 in GHZ= %.3f"%f1
print "f2 in GHZ= %.3f"%f2
Q=1/tan(delta);
print "approx. value of Q due to dielectric loss = %.0f"%Q
# program to find the value of the coupling capacitor required for critical coupling .
from math import pi,sqrt,atan
l=0.02175;Zo=50;eipsilae=1.9;c=3*10^8;
fo=c/(2*l*sqrt(eipsilae)); # first resonant frequency will occur when the resonator ia about l=lamdag/2 in length .
lamdag=c/fo;
alpha=1/8.7; # in Np/m.
Q=pi/(2*l*alpha);
bc=sqrt(pi/(2*Q));
C=bc/(2*pi*fo*Zo)*10**12;
print "coupling capacitor in pF = ",C
C=bc/(2*pi*fo*Zo);
w1=atan(2*pi*fo*C*Zo)*c/(l*sqrt(eipsilae)); # from equation tan (B⇤l) =bc ;
w1=w1*10**-8;
print "frequency in GHZ= ",w1
# program to derive an expression for the change in resonant frequency .
from sympy import symbols,sin,cos,integrate,limit
from math import pi
Ey,Hx,Hz,A,Zte,n,a,p,i,x,z,d,j,k,t,y,er,eo,c,wo,w,b=symbols('Ey,Hx,Hz,A,Zte,n,a,p,i,x,z,d,j,k,t,y,er,eo,c,wo,w,b')
Ey=A*sin((pi*x)/a)*sin((pi*z)/d);
Hx=((-j*A)/Zte)*sin((pi*x)/a)*cos((pi*z)/d);
Hz=((j*pi*A)/(k*n*a))*cos((pi*x)/a)*sin((pi*z)/d);
Ey=Ey**2; #c=(er1)⇤eo;
w=c*integrate(integrate(integrate(Ey,(z,0,d)),(y,0,t)),(x,0,a));
# as sin (2⇤ pi )=0; then last term of above result will be:
w=(c*A**2*a*t*d)/4;
print "on taking sin (2⇤pi )=0 ,w becomes= ",w
wo=((a*b*d*eo)/2)*A**2;
deltaw=(w-wo)/wo;
print "fractional change in resonant frequency= ",deltaw