import math
#Variable declaration
R1=10000 #ohms
R2=1 #ohms
C=.002*10**-6 #F
L=10**-6 #H
#Calculations&Results
#B=complex(0,W*L)/complex(R1-W**2*R2*C*L,W*(L+R1*R2*C))
W=math.sqrt(R1/(R2*L*C))
print "W=%.2e rad/s"%W
f=W/(2*math.pi)
print "f=%.3eHz"%f
A=1+R1*R2*C/L
print "A=%.f"%A
import math
#Variable declaration
#unit in SI
L1=10**-9 #H
L2=10**-9 #H
Go=4.5*10**-3
RL=50 #ohms
W=2*math.pi*150*10**6
#Calculations&Results
n=math.sqrt(1/(Go*RL))
print "n=%.4f"%n
L3=L2/n**2
print "considering L1=L2=1nH"
print "nL3=%.4e H"%L3
C=1/((L1+L2)*W**2)
print "C=%.3e F"%C
import math
#Variable declaration
Cvar=3.5*10**-12
C1=150*10**-12
C2=72*10**-12
L=32*10**-9
#Calculations&Results
C=Cvar+C1*C2/(C1+C2)
f=1/(2*math.pi*math.sqrt(L*C))
print "C=%.3e F\nf=%.3e Hz\n"%(C,f)
Cvar=32*10**-12
C=Cvar+C1*C2/(C1+C2)
f=1/(2*math.pi*math.sqrt(L*C))
print "C=%.3e F\nf=%.3e Hz\n"%(C,f)
Cvar=3.5*10**-12
C=Cvar+C1*C2/(C1+C2)
f=1/(2*math.pi*math.sqrt(L*C))
print "C=%.3e F\nf=%.3e Hz"%(C,f)
import math
#Variable declaration
Ve=2
Be=math.pi/2
#Calculations&Results
Kd=Ve/math.sin(Be)
print "Kd=%.0f"%Kd
#Ko=dW/Vd
Ko=2*math.pi*100*1000
dWH=Kd*Ko
print "dWH=%.4e rad/s"%dWH
dfH=dWH/(2*math.pi)
print "dfH=%.e Hz"%dfH
import math
#Variable declaration
Ve=2
Bemax=math.pi/2
#Calculations&Results
Kd=Ve/Bemax
print"Kd=%.4f"%Kd
Ko=2*math.pi*10**5
dWH=Kd*Ko*Bemax
print "dWH=%.4e rad/s"%dWH
print "dfH=%.e Hz"%(dWH/(2*math.pi))
import math
#Variable declaration
Vin=2. #Volt
Vosc=2. #Volt
VPD=2. #volt
Ein=0.75
Eosc=0.75
Vd=1
#Calculations&Results
dW=2*math.pi*10**7
Km=VPD/(Vin*Vosc)
print "Km=%.1f V**-1"%Km
Kd=0.5*Km*Ein*Eosc
Ko=dW/Vd
#(a)
qd=2*math.pi*(11-10)*10**6/(Ko*Kd)
print "(a)qd=%.4f rad = %.2f degree\n"%(qd,qd*180/math.pi)
#(b)
qd=2*math.pi*(9-10)*10**6/(Ko*Kd)
print "(b)qd=%.4f rad = %.2f degree"%(qd,qd*180/math.pi)
import math
#Variable declaration
Wo=2*math.pi*2*10**6
Wf=2*math.pi*2.5*10**6
Ko=10**7
Ka=10
Kd=0.5
N=20
E=0.8
Wn=10**4
C2=0.5*10**-6 #F
#Calculations
Vd=(Wo-Wf)/Ko
Ve=Vd/Ka
Qe=Ve/Kd
K=Kd*Ka*Ko/N
dW=math.sqrt(2*(2*E*Wn*K-Wn**2))
df=dW/(2*math.pi)
T1=K/Wn**2
T2=2*E/Wn-1/K
R2=T2/C2
R1=T1/C2-R2
#Result
print "Vd=%.4f V\nVe=%.4f V\nQe=%.4f rad\nK=%.2e\ndW=%.4e rad/s\ndf=%.4e Hz\nT1=%.4f s\nT2=%.4e s\nR2=%.2f ohm\nR1=%.1f ohm"%(Vd,Ve,Qe,K,dW,df,T1,T2,R2,R1)
import math
import cmath
#Variable declaration
FG=1.25*cmath.exp(complex(0,40*math.pi/180))
#Calculations
Z_G=(1+FG)/(1-FG)
#Result
print "Z_G = ",Z_G
import cmath
import math
#Variable declaration
Z=50 #ohms
S11=2.18*cmath.exp(complex(0,math.pi/180*(-35)))
S21=2.75*cmath.exp(complex(0,math.pi/180*(96)))
S12=1.26*cmath.exp(complex(0,math.pi/180*(18)))
S22=0.52*cmath.exp(complex(0,math.pi/180*(155)))
FL=0.59*cmath.exp(complex(0,math.pi/180*(-104)))
#Calculations&Results
def mod(n):
r=n.real
i=n.imag
x=math.sqrt(r**2+i**2)
return x
deln=S11*S22-S12*S21
k=(1-mod(S11)**2-mod(S22)**2+mod(deln)**2)/(2*mod(S12*S21))
print "del=",deln
print "k=%.2f"%k
Cs=(S11-deln*S22.conjugate())/(mod(S11)**2-mod(deln)**2)
print "Cs=",Cs.conjugate()
rs=mod((S12*S21)/(mod(S11)**2-mod(deln)**2))
print "rs=%.3f"%rs
CL=(S22-deln*S11.conjugate())/(mod(S22)**2-mod(deln)**2)
print "CL=",CL.conjugate()
rL=mod(S12*S21/(mod(S22)**2-mod(deln)**2))
print "rL=%.2f"%rL
Fin=S11+(S12*S21*FL)/(1-S22*FL)
print "Fin=",Fin
Zin=50*(1+Fin)/(1-Fin)
print "Zin=",Zin
ZG=complex(27.9,1.91)
print "ZG=",ZG
FG=(ZG-50)/(ZG+1)
print "FG=",FG #calculation mistake in calculating FG in book
VSWR=(1.0+mod(FG))/(1.0-mod(FG))
print "VSWR=%.3f"%VSWR #calculation mistake in book
import math
import cmath
#Variable declaration
S11=0.9*cmath.exp(complex(0,math.pi/180*150))
S21=1.7*cmath.exp(complex(0,-math.pi/180*80))
S12=0.07*cmath.exp(complex(0,math.pi/180*120))
S22=1.08*cmath.exp(complex(0,-math.pi/180*56))
#Calculations&Results
def mod(n):
r=n.real
i=n.imag
x=math.sqrt(r**2+i**2)
return x
del1=(1-S11)*(1-S22)-S12*S21
print "del1=",del1
Z_11=((1+S11)*(1-S22)+S21*S12)/del1
print "Z_11=",Z_11
Z_12=2*S12/del1
print "Z_12=",Z_12
Z_21=2*S21/del1
print "Z_21=",Z_21
Z_22=((1-S11)*(1+S22)+S21*S12)/del1
print "Z_22=",Z_22
Zinductor=complex(0,(2*math.pi*2.75*10**9*1.45*10**-9))
Z_inductor=Zinductor/50
print "\nZ_inductor=",Z_inductor
A=[[Z_11,Z_12],[Z_21,Z_22]]+[Z_inductor]
print "[Z_s11,Z_s12;Z_s21,Z_s22]=",A #calculation mistake in the book here. Hence all subsequent answers differ from textbook
deln=(Z_11+1)*(Z_22+1)-A[0][1]*A[1][0]
print "\ndel=",deln
Ss12=2*A[0][1]/deln
print "Ss12=",Ss12
Ss21=2*A[1][0]/deln
print "Ss21=",Ss21
Ss11=((A[0][0]-1)*(A[1][1]+1)-(A[0][1]*A[1][0]))/deln
print "Ss11=",Ss11
Ss22=((A[0][0]+1)*(A[1][1]-1)-A[0][1]*A[1][0])/deln
print "Ss22=",Ss22
delm=S11*S22-S21*S12
print "\ndel=",mod(delm)
k=(1-mod(S11)**2-mod(S22)**2+mod(delm)**2)/(2*mod(S12*S21))
print "k=%.4f"%k
Cs=S11-delm*S22.conjugate()/(mod(S11)**2-mod(delm)**2)
print "Cs=",Cs
rs=mod((S12*S21)/(mod(S11)**2-mod(delm)**2))
print "rs=",rs
CL=(S22-delm*S11.conjugate())/(mod(S22)**2-mod(delm)**2)
print "CL=",CL
rL=mod(S12*S21/(mod(S22)**2-mod(delm)**2))
print "rL=",rL
FL=0.5689*cmath.exp(complex(0,math.pi/180*167.8))
print "FL=",FL
Fin=S11+S12*S21*FL/(1-S22*FL)
print "\nFin=",Fin
Zin=50*(1+Fin)/(1-Fin)
print "Zin=",Zin
ZG=-Zin.real/3-complex(0,Zin.imag)
print "ZG=",ZG