import math
import numpy as np
def get_output(a1,a2,a3,VR0,R1,R2,R3,R4,RL,C1,C2,C3,C4,f):
S=1j*2*math.pi*f
G1=1/R1
G2=1/R2
G3=1/R3
G4=1/R4
GL=1/RL
VG11=1/(a1*VR0)
VG12=1/((1-a1)*VR0)
VG21=1/(a2*VR0)
VG22=1/((1-a2)*VR0)
VG31=1/(a3*VR0)
VG32=1/((1-a3)*VR0)
YC1=S*C1
YC2=S*C2
YC3=S*C3
YC4=S*C4
G11=G3+VG11+VG21+VG31
G12=0
G13=-VG11
G14=-VG21
G15=-VG31
G16=0
G17=0
G21=G12
G22=G4+VG12+VG22+VG32
G23=-VG21
G24=-VG22
G25=-VG32
G26=0
G27=0
G31=G13
G32=G23
G33=VG11+VG12+G1
G34=0
G35=0
G36=-G1
G37=0
G41=G14
G42=G24
G43=G34
G44=VG21+VG22+YC1
G45=0
G46=-YC1
G47=0
G51=G15
G52=G25
G53=G35
G54=G45
G55=VG31+VG32+YC3
G56=0
G57=-YC3
G61=G16
G62=G26
G63=G36
G64=G46
G65=G56
G66=G1+G2+YC1+YC2
G67=-G2
G71=G17
G72=G27
G73=G37
G74=G47
G75=G57
G76=G67
G77=G2+GL+YC3+YC4
Y=np.matrix([[G11,G12,G13,G14,G15,G16,G17],
[G21,G22,G23,G24,G25,G26,G27],
[G31,G32,G33,G34,G35,G36,G37],
[G41,G42,G43,G44,G45,G46,G47],
[G51,G52,G53,G54,G55,G56,G57],
[G61,G62,G63,G64,G65,G66,G67],
[G71,G72,G73,G74,G75,G76,G77]])
I=np.matrix([[1/R3],
[0],
[0],
[0],
[0],
[0],
[0]])
out=Y.I*I
return out
def get_db(x):
return 20*math.log10(x)
V1=get_output(0.15,0.15,0.15,50e3,39e3,39e3,1.5e3,220,39e3,10e-9,6.8e-9,1e-9,1.5e-9,100)
V2=get_output(0.15,0.15,0.15,50e3,39e3,39e3,1.5e3,220,39e3,10e-9,6.8e-9,1e-9,1.5e-9,100)
print(abs(V1))
print(abs(V2))