from __future__ import division
#Given
Is=0.1*(10**-6) #A
Pi=0 #dBm
Cs=0.1*(10**-12) #F
Ls=2*(10**-9)
Cj=0.15*(10**-12) #F
Rs=10 #ohm
T=293 #K
nktbye=25*(10**-3) #V
#Rj
Rj=(nktbye/Is)
print 'Rj:' ,Rj/1000,'Kohm'
#Bi
Bi=nktbye/2
Bii=Bi*1000
print 'Bi:' ,Bii,'A/W'
#Bv
Bv=Rj*Bii
print 'Bv:',Bv, 'V/W'
from math import log10
#Given
vswr=4
modT=(vswr-1)/(vswr+1)
Lm=-10*log10(1-(modT*modT)) #dB
print 'Mismatch Loss:' ,Lm,'dB'
#Sensitivity reduces by a factor
Bvd=(1-(modT*modT))
Bvdp=Bvd*100
print 'Voltge sensitivity reduces by:' ,Bvdp,'%'
from math import sqrt , pi
#Given
f=10e9 #Hz
c=3e10 #cm/s
a=4 #cm
s=0.1 #cm
lmb=c/f #cm
lmbg=lmb/(sqrt(1-((lmb/(2*a))**2)))
vswr=lmbg/(pi*s)
print 'VSWR: %0.3f'%vswr
#Answer in book for lmbg is given as 3.49 but it should be 3.23 and hence the answer will be 10.3
#Given
delx=3.5 #cm
s=0.25 #cm
lmbg=2*delx
vswr=lmbg/(pi*s)
print 'VSWR: %0.3f'%vswr
#Given
vswr=2
Pin=4.5e-3 #W
modT=(vswr-1)/(vswr+1)
#Power reflected,
Pr=(modT**2)*Pin
#As coupler samples only 1/1000th power
Prr=Pr*1000
print 'Reflected Power:' ,Prr,'W'
from math import tan
#Given
Z0=50 #ohm
p=2.4
L=0.313
x=2*pi*L
y=tan(x)
Zl=(Z0*(1+(p*p*1J)))/(p+(p*1J))
T=(Zl-Z0)/(Zl+Z0)
p=sqrt(((T.real))**2+((T.imag))**2)
print 'Reflection coefficient: %0.3f'%p
#Given
Zl=25+25*1J #ohm
Z0=50 #ohm
T=(Zl-Z0)/(Zl+Z0)
p=sqrt(((T.real))**2+((T.imag))**2)
print 'Reflection coefficient: %0.3f'%p
vswrr=(1+p)/(1-p)
print 'VSWR: %0.3f'%vswrr
#Fraction of power delivered
Pd=1-(p**2)
Pdp=Pd*100
print 'Fraction of power delivered:',Pdp, '%'
#Given
d=2.4 #cm
lmbc=1.8
c=3*10**10 #cm/s
lmbg=2*d
lmb=(lmbg*lmbc)/(sqrt(lmbg**2+lmbc**2))
#Operating frequency
f=c/lmb
print 'Operating frequency: %0.3f'%(f/10**9),'GHz'
from numpy import mat
#Given
p=1.5
IsL=1 #dB
InL=30 #dB
S21=10**(-IsL/20)
#Assuming tgree ports to be identical
S32=S21
S13=S21
#Isolations are also the same
S31=10**(-InL/20)
S23=S31
S12=S31
#Refelction coefficients are also the same
T=(p-1)/(p+1)
S11=T
S22=T
S33=T
S=mat([[S11, S12, S13], [S21, S22, S23], [S31, S32, S33] ])
print 'Matrix is:\n' ,S
#Given
R1=10.6 #GHz
R2=8.30 #GHz
Q0=8200
Q0d=890
Er=(R1/R2)**2
print 'Dielectric constant %0.3f'%Er
Qd=(Q0-Q0d)/(Q0*Q0d)
print 'Loss tangent of dielectric' ,Qd
#Given
l0=0.15 #cm
lmbg=2*2.24 #cm
le=1.14 #cm
a=2.286 #cm
d=2
B0=(2*pi)/lmbg
x=tan(B0*l0)/(B0*l0)
#Also
x1=(l0*x)/le
#Correct value seems to be
Bele=2.786
e1=((((a/pi)**2)*(Bele/le)**2)+1)
e2=(((2*a)/lmbg)**2)+1
Er=e1/e2
print 'Er: %0.3f'%Er
#Answer in book for Er is given as 2.062 but it should be 2.038