Skip to content

Instantly share code, notes, and snippets.

@bitglue
Last active December 25, 2020 06:08
Show Gist options
  • Save bitglue/62526fb031dd0f75e423dacc344de5c9 to your computer and use it in GitHub Desktop.
Save bitglue/62526fb031dd0f75e423dacc344de5c9 to your computer and use it in GitHub Desktop.
from __future__ import division
from math import pi, sqrt
r = 7.37
cs = 18.8e-15
cp = 4.15e-12
l = 6.5722e-3
l = 6.572233217077748e-3
fs = 14.318078e6
fp = 1/(2*pi*sqrt(l*(cs*cp)/(cs+cp)))
ws = fs*2*pi
wp = fp*2*pi
C = cs
L = l
R = r
D = cp
def par(z, w):
return 1/(1/z + 1/w)
def Zm(f):
w = 2*pi*f
i = complex(0, 1)
return r + i*w*l + 1/(i*w*cs)
def Z(f):
w = 2*pi*f
i = complex(0, 1)
zm = Zm(f)
return par(zm, 1/(i*w*cp))
def print_z(f):
print("Z at %r: %s" % (f, Z(f)))
print("Y at %r: %s" % (f, 1/Z(f)))
print("")
def method1(w):
return (w*c*(R-w*L)+1) / (w*(w*C*D*(R-w*L)+C+D))
def L(Cs, ws):
# equation 2
return 1 / (Cs * ws**2)
def Cs3(L, ws):
# equation 3
return 1 / (L * ws**2)
def Cs7(Cp, ws, wp):
# equation 7
return Cp * (wp**2 - ws**2) / ws**2
def Cp6(Cs, ws, wp):
# equation 6
return Cs*ws**2/(wp**2 - ws**2)
def Cs9(wp, ws, wt, z):
num = 1j * (wp**2 - ws**2) * (ws**2 - wt**2)
denom = ws**2 * wt * z * (wt**2 - wp**2)
return num/denom
def Cp10(L, ws, wp):
return 1/(L*(wp**2 - ws**2))
def L11(cp, ws, wp):
return 1/(cp*(wp**2 - ws**2))
def L12(wp, ws, wt, zt):
num = 1j * wt * zt * (wp**2 - wt**2)
denom = (wp**2 - ws**2) * (ws**2 - wt**2)
return num/denom
def Cp13(wp, ws, wt, zt):
num = 1j * (ws**2 - wt**2)
denom = wt * zt * (wt**2 - wp**2)
return num/denom
#print_z(fs)
#print_z(fs+.245)
#print_z(fs + 1e3)
#print_z(fs + 1e3)
#print_z(14350472.6627)
#print_z(14350472.6627-.246)
#print( sqrt(cs + cp) / sqrt(l*cs*cp) ) / 2 / pi
#print( 1 / sqrt(l*cp) ) / 2 / pi
print("calculating Cs:")
print(Cs7(cp, ws, wp))
print(Cs3(l, ws))
ft = (fs + fp) / 2
wt = ft*2*pi
print(Cs9(wp, ws, wt, Z(ft)))
print(cs)
print("\ncalculating Cp:")
print(cp)
print(Cp10(l, ws, wp))
print(Cp6(cs, ws, wp))
print(Cp13(wp, ws, wt, Z(ft)))
print("\ncalculating L:")
print(L(cs, ws))
print(L11(cp, ws, wp))
print(L12(wp, ws, wt, Z(ft)))
print(l)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment