Custom RF Scripts

Comments

Scripts Based on Pozar's Microwave Engineering

See Resources for a link to Pozar's book.


Series Stub Impedance Matching

This (crude) script can be used to calculate single, series stubs (both open and short) as described in Chapter 5. It may be refined in time, but it works for now.

import math

print("") # Blank line

ZL = 100 - 100j
YL = 1.0/ZL

RL = ZL.real
XL = ZL.imag

GL = YL.real
BL = YL.imag

Z0 = 50.0
Y0 = 1.0/Z0

# Calculating t
root = math.sqrt((GL*(((Y0-GL)**2.0)+(BL**2.0)))/Y0)
den = GL - Y0

t1 = (BL + root)/den
t2 = (BL - root)/den

print("t1 is " + str(t1))
print("t2 is " + str(t2))

# Calculate d

if t1<0:
    d1 = (1.0/(2.0*math.pi)) * (math.pi+math.atan(t1))
else:
    d1 = (1.0/(2.0*math.pi)) * (math.atan(t1))

print("d1 is: "+ str(d1) + " *lambda")

if d1 < 0:
    print("Since d1<0, d1 actually is: " + str(d1+.5) + " *lambda")

if t2<0:
    d2 = (1.0/(2.0*math.pi)) * (math.pi+math.atan(t2))
else:
    d2 = (1.0/(2.0*math.pi)) * (math.atan(t2))

print("d2 is: "+ str(d2) + " *lambda")

if d2 < 0:
    print("Since d1<0, d1 actually is: " + str(d1+.5) + " *lambda")

# Calc X

x1 = (((GL**2.0)*t1)-((Y0-(t1*BL))*(BL+(t1*Y0))))/(Y0*((GL**2.0)+((BL+(Y0*t1))**2.0)))
x2 = (((GL**2.0)*t2)-((Y0-(t2*BL))*(BL+(t2*Y0))))/(Y0*((GL**2.0)+((BL+(Y0*t2))**2.0)))

print("x1 is: "+str(x1))
print("x2 is: "+str(x2))

# Calc l
lo1 = (1.0/(2.0*math.pi))*math.atan(Z0/x1)
lo2 = (1.0/(2.0*math.pi))*math.atan(Z0/x2)

print("lo1 is: "+str(lo1))
print("lo2 is: "+str(lo2+.5))

# Calc l
ls1 = (-1.0/(2.0*math.pi))*math.atan(x1/Z0)
ls2 = (-1.0/(2.0*math.pi))*math.atan(x2/Z0)
print("ls1 is: "+str(ls1+.5))
print("ls2 is: "+str(ls2))






Backlinks:
High Speed Design Wiki:Software Tools


Contact Stephen with any questions: Stephen@ShieldDigitalDesign.com

© Shield Digital Design