def DirectCoupled_C_Coupled_ShuntResonators(gi, RS, RL, f0, BW, Lres, fstart, fstop, npoints): Nres = len(gi) - 2 # Number of resonators bw = BW / f0 # Calculation of w1, w2, w - 8.11-1 (15) f1 = f0 - BW / 2 f2 = f0 + BW / 2 w1 = 2 * np.pi * f1 w2 = 2 * np.pi * f2 w0 = np.sqrt(w1 * w2) w = (w2 - w1) / w0 # Calculation of GA and GB GA = 1 / RS GB = 1 / RL # Draw circuit schem.use('svg') d = schem.Drawing(inches_per_unit=0.3) _fontsize = 8 # Network rf.stylely() freq = rf.Frequency(start=fstart, stop=fstop, npoints=npoints, unit='MHz') line = rf.media.DefinedGammaZ0(frequency=freq) # Component counter count_C = 0 count_L = 0 count_gnd = 0 params = {} params['Xres'] = Lres params['gi'] = gi params['N'] = Nres params['ZS'] = RS params['ZL'] = RL params['f1'] = f1 params['f2'] = f2 Cseries, Lres, Cres = synthesize_DC_Filter_C_Coupled_Shunt_Resonators( params) # Source port # Drawing: Source port and the first line d += elm.Line(color='white').length(2).linewidth(0) d += elm.Dot().label('ZS = ' + str(RS) + " \u03A9", fontsize=_fontsize).linewidth(1) d += elm.Line().length(1).linewidth(1) # Network: Port 1 connections = [] # Network connections L = [] C = [] ground = [] Port1 = rf.Circuit.Port(frequency=freq, name='port1', z0=RS) # First coupling capacitor # Drawing d += elm.Capacitor().right().label(getUnitsWithScale( Cseries[0], 'Capacitance'), fontsize=_fontsize).linewidth(1) d += elm.Line().right().length(1).linewidth(1) # Network count_C += 1 C.append(line.capacitor(Cseries[0], name='C' + str(count_C))) connections.append([(Port1, 0), (C[0], 0)]) for i in range(0, Nres): # Resonator # Drawing d.push() d += elm.Line().down().length(1).linewidth(1) d.push() d += elm.Line().left().length(1.5).linewidth(1) d += elm.Capacitor().down().label(getUnitsWithScale( Cres[i], 'Capacitance'), fontsize=_fontsize).linewidth(1) d += elm.Ground().linewidth(1) d.pop() d += elm.Line().right().length(1.5).linewidth(1) d += elm.Inductor2(loops=2).down().label( getUnitsWithScale(Lres[i], 'Inductance'), fontsize=_fontsize).linewidth(1) d += elm.Ground().linewidth(1) # Network count_C += 1 C.append(line.capacitor(Cres[i], name='C' + str(count_C))) count_gnd += 1 ground.append( rf.Circuit.Ground(frequency=freq, name='ground' + str(count_gnd), z0=RS)) count_L += 1 L.append(line.inductor(Lres[i], name='L' + str(count_L))) count_gnd += 1 ground.append( rf.Circuit.Ground(frequency=freq, name='ground' + str(count_gnd), z0=RS)) # Next coupling capacitor # Drawing d.pop() d += elm.Line().right().length(1.5).linewidth(1) d += elm.Capacitor().right().label(getUnitsWithScale( Cseries[i + 1], 'Capacitance'), fontsize=_fontsize).linewidth(1) d += elm.Line().right().length(1.5).linewidth(1) # Network count_C += 1 C.append(line.capacitor(Cseries[i + 1], name='C' + str(count_C))) # Connections connections.append([(C[2 * i], 1), (C[2 * i + 1], 0), (C[2 * i + 2], 0), (L[i], 0)]) connections.append([(C[2 * i + 1], 1), (ground[2 * i], 0)]) connections.append([(L[i], 1), (ground[2 * i + 1], 0)]) # Drawing d += elm.Dot().label('ZL = ' + str(float("{:.2f}".format(RL))) + " \u03A9", fontsize=_fontsize).linewidth(1) d += elm.Line(color='white').length(2).linewidth(0) # Network Port2 = rf.Circuit.Port(frequency=freq, name='port2', z0=RL) # Connections connections.append([(C[-1], 1), (Port2, 0)]) return d, connections
def DirectCoupled_C_Coupled_SeriesResonators(params, port_match): gi = params['gi'] f1 = params['f1'] f2 = params['f2'] fstart = params['f_start'] fstop = params['f_stop'] npoints = params['n_points'] RS = params['ZS'] RL = params['ZL'] Nres = len(gi) - 2 # Number of resonators w1 = 2 * np.pi * f1 w2 = 2 * np.pi * f2 w0 = np.sqrt(w1 * w2) w = (w2 - w1) / w0 # Draw circuit schem.use('svg') d = schem.Drawing(inches_per_unit=0.3) _fontsize = 8 # Network rf.stylely() freq = rf.Frequency(start=fstart, stop=fstop, npoints=npoints, unit='MHz') line = rf.media.DefinedGammaZ0(frequency=freq) # Component counter count_C = 0 count_L = 0 count_gnd = 0 syn_params = {} syn_params['gi'] = params['gi'] syn_params['N'] = params['N'] syn_params['ZS'] = params['ZS'] syn_params['ZL'] = params['ZL'] syn_params['f1'] = float(params['f1']) * 1e6 syn_params['f2'] = float(params['f2']) * 1e6 syn_params['Xres'] = [float(i) * 1e-9 for i in params['Xres']] # Resonator inductance Match_source, Match_load, Cinv, Lres, Cres = synthesize_DC_Filter_C_Coupled_Series_Resonators( syn_params) # Source port # Drawing: Source port and the first line d += elm.Line(color='white').length(2).linewidth(0) d += elm.Dot().label('ZS = ' + str(RS) + " \u03A9", fontsize=_fontsize, loc='bottom').linewidth(1) d += elm.Line().length(1).linewidth(1) # Network: Port 1 connections = [] # Network connections L = [] C = [] ground = [] Port1 = rf.Circuit.Port(frequency=freq, name='port1', z0=RS) # First coupling if (port_match[0] == 'C'): # Drawing d += elm.Capacitor().right().label(getUnitsWithScale( Match_source, 'Capacitance'), fontsize=_fontsize).linewidth(1) d += elm.Line().right().length(1).linewidth(1) # Network C.append(line.capacitor(Match_source, name='C' + str(count_C))) connections.append([(Port1, 0), (C[0], 0)]) else: # Drawing d += elm.Inductor2(loops=2).right().label( getUnitsWithScale(Match_source, 'Inductance'), fontsize=_fontsize).linewidth(1) d += elm.Line().right().length(1).linewidth(1) # Network L.append(line.inductor(Match_source, name='L' + str(count_L))) connections.append([(Port1, 0), (L[0], 0)]) for i in range(0, Nres): # Resonator # Drawing d.push() d += elm.Capacitor().down().label(getUnitsWithScale( Cinv[i], 'Capacitance'), fontsize=_fontsize).linewidth(1) d += elm.Ground().linewidth(1) # Network count_C += 1 C.append(line.capacitor(Cinv[i], name='C' + str(count_C))) count_gnd += 1 ground.append( rf.Circuit.Ground(frequency=freq, name='ground' + str(count_gnd), z0=RS)) d.pop() d += elm.Inductor2(loops=2).right().label( getUnitsWithScale(Lres[i], 'Inductance'), fontsize=_fontsize).linewidth(1) d += elm.Capacitor().right().label(getUnitsWithScale( Cres[i], 'Capacitance'), fontsize=_fontsize).linewidth(1) count_L += 1 L.append(line.inductor(Lres[i], name='L' + str(count_L))) count_C += 1 C.append(line.capacitor(Cres[i], name='C' + str(count_C))) # Connections if (port_match[0] == 'C'): connections.append([(C[2 * i], 1), (C[2 * i + 1], 0), (L[i], 0)]) connections.append([(L[i], 1), (C[2 * i + 2], 0)]) connections.append([(C[2 * i + 1], 1), (ground[i], 0)]) else: # There's one inductance too much and one capacitor too few if (i == 0): # The first element must connect to the inductor connections.append([(L[0], 1), (C[2 * i], 0), (L[i + 1], 0)]) else: connections.append([(C[2 * i - 1], 1), (C[2 * i], 0), (L[i + 1], 0)]) connections.append([(L[i + 1], 1), (C[2 * i + 1], 0)]) connections.append([(C[2 * i], 1), (ground[i], 0)]) # Drawing d.push() d += elm.Capacitor().down().label(getUnitsWithScale( Cinv[-1], 'Capacitance'), fontsize=_fontsize).linewidth(1) d += elm.Ground().linewidth(1) count_C += 1 C.append(line.capacitor(Cinv[-1], name='C' + str(count_C))) count_gnd += 1 ground.append( rf.Circuit.Ground(frequency=freq, name='ground' + str(count_gnd), z0=RS)) d.pop() if (port_match[1] == 'C'): d += elm.Capacitor().right().label(getUnitsWithScale( Match_load, 'Capacitance'), fontsize=_fontsize).linewidth(1) count_C += 1 C.append(line.capacitor(Match_load, name='C' + str(count_C))) else: d += elm.Inductor2(loops=2).right().label( getUnitsWithScale(Match_load, 'Inductance'), fontsize=_fontsize).linewidth(1) count_L += 1 L.append(line.capacitor(Match_load, name='L' + str(count_L))) # Load port # Drawing d += elm.Line().length(1).linewidth(1) d += elm.Dot().label('ZL = ' + str(float("{:.2f}".format(RL))) + " \u03A9", fontsize=_fontsize, loc='bottom').linewidth(1) d += elm.Line(color='white').length(2).linewidth(0) # Network Port2 = rf.Circuit.Port(frequency=freq, name='port2', z0=RL) # Connections if (port_match[1] == 'C'): connections.append([(C[-3], 1), (C[-2], 0), (C[-1], 0)]) connections.append([(C[-2], 1), (ground[-1], 0)]) connections.append([(C[-1], 1), (Port2, 0)]) else: connections.append([(C[-2], 1), (C[-1], 0), (L[-1], 0)]) connections.append([(C[-1], 1), (ground[-1], 0)]) connections.append([(L[-1], 1), (Port2, 0)]) return d, connections
def DirectCoupled_QW_Coupled_ShuntResonators(gi, RS, RL, f0, BW, fstart, fstop, npoints): Nres = len(gi) - 2 # Number of resonators params = {} params['gi'] = gi params['N'] = Nres params['ZS'] = RS params['ZL'] = RL params['f1'] = f0 - BW / 2 params['f2'] = f0 + BW / 2 RS, RL, qw, Lres, Cres = synthesize_DC_Filter_QW_Shunt_Resonators(params) # Draw circuit schem.use('svg') d = schem.Drawing() _fontsize = 12 # Network rf.stylely() freq = rf.Frequency(start=fstart, stop=fstop, npoints=npoints, unit='MHz') line = rf.media.DefinedGammaZ0(frequency=freq) # Component counter count_C = 0 count_L = 0 count_TL = 0 count_gnd = 0 # Source port # Drawing: Source port and the first line d += elm.Dot().label('ZS = ' + str(RS) + " \u03A9", fontsize=_fontsize).linewidth(1) d += elm.Line().length(1).linewidth(1) # Network: Port 1 connections = [] # Network connections L = [] C = [] TL = [] ground = [] Port1 = rf.Circuit.Port(frequency=freq, name='port1', z0=RS) # Quarter wavelength line beta = freq.w / rf.c Z0_line = rf.media.DefinedGammaZ0(frequency=freq, Z0=RS, gamma=0 + beta * 1j) d += elm.Line().right().length(1).linewidth(1) for i in range(0, Nres): # Resonator # Drawing d.push() d += elm.Line().down().length(1).linewidth(1) d.push() d += elm.Line().left().length(1).linewidth(1) d += elm.Capacitor().down().label(getUnitsWithScale( Cres[i], 'Capacitance'), fontsize=_fontsize).linewidth(1) d += elm.Ground().linewidth(1) d.pop() d += elm.Line().right().length(1).linewidth(1) d += elm.Inductor2(loops=2).down().label(getUnitsWithScale( Lres[i], 'Inductance'), fontsize=_fontsize, loc='bottom').linewidth(1) d += elm.Ground().linewidth(1) # Network count_C += 1 C.append(line.capacitor(Cres[i], name='C' + str(count_C))) count_gnd += 1 ground.append( rf.Circuit.Ground(frequency=freq, name='ground' + str(count_gnd), z0=RS)) count_L += 1 L.append(line.inductor(Lres[i], name='L' + str(count_L))) count_gnd += 1 ground.append( rf.Circuit.Ground(frequency=freq, name='ground' + str(count_gnd), z0=RS)) # Coupling line # Drawing d.pop() d += elm.Line().right().length(2).linewidth(1) d += TransmissionLine().right().label( "l = " + getUnitsWithScale(qw, 'Distance'), fontsize=_fontsize, loc='bottom').label("Z\u2080 = " + str(RS) + " \u03A9 ", loc='top').linewidth(1) d += elm.Line().right().length(2).linewidth(1) count_TL += 1 TL.append( Z0_line.line(Z0_line.theta_2_d(90, deg=True), unit='m', name='TL' + str(count_TL))) if (i == 0): # Connect to the source port connections.append([(Port1, 0), (L[0], 0), (C[0], 0), (TL[0], 0)]) else: # Connect to the previous TL connections.append([(TL[i - 1], 1), (L[i], 0), (C[i], 0), (TL[i], 0)]) connections.append([(C[i], 1), (ground[2 * i], 0)]) connections.append([(L[i], 1), (ground[2 * i + 1], 0)]) # Load port # Drawing d += elm.Dot().label('ZL = ' + str(float("{:.2f}".format(RL))) + " \u03A9", fontsize=_fontsize).linewidth(1) # Network Port2 = rf.Circuit.Port(frequency=freq, name='port2', z0=RL) # Connections connections.append([(Port2, 0), (TL[-1], 1)]) return d, connections
def DirectCoupled_L_Coupled_SeriesResonators(params): gi = params['gi'] RS = params['ZS'] RL = params['ZL'] f1 = params['f1'] f2 = params['f2'] f0 = params['fc'] Magnetic_Coupling = params['Magnetic_Coupling'] fstart = params['f_start'] fstop = params['f_stop'] npoints = params['n_points'] w0 = 2 * np.pi * f0 * 1e6 Nres = len(gi) - 2 # Number of resonators # Draw circuit schem.use('svg') d = schem.Drawing(inches_per_unit=0.3) _fontsize = 8 # Network rf.stylely() freq = rf.Frequency(start=fstart, stop=fstop, npoints=npoints, unit='MHz') line = rf.media.DefinedGammaZ0(frequency=freq) # Component counter count_C = 0 count_L = 0 count_gnd = 0 params['f1'] = params['f1'] * 1e6 params['f2'] = params['f2'] * 1e6 M, Lseries, Cres = synthesize_DC_Filter_L_Coupled_Series_Resonators(params) if (Magnetic_Coupling == 0): # Source port # Drawing: Source port and the first line d += elm.Dot().label('ZS = ' + str(RS) + " \u03A9", fontsize=_fontsize).linewidth(1) d += elm.Line().length(1).linewidth(1) # Network: Port 1 connections = [] # Network connections L = [] C = [] ground = [] Port1 = rf.Circuit.Port(frequency=freq, name='port1', z0=RS) # First coupling inductor # Drawing d += elm.Inductor2(loops=2).right().label( getUnitsWithScale(Lseries[0], 'Inductance'), fontsize=_fontsize).linewidth(1) # Network count_L += 1 L.append(line.inductor(Lseries[0], name='L' + str(count_L))) connections.append([(Port1, 0), (L[0], 0)]) for i in range(0, Nres + 1): d.push() # Coupling # Drawing d += elm.Inductor2(loops=2).down().label( getUnitsWithScale(M[i], 'Inductance'), fontsize=_fontsize).linewidth(1) d += elm.Ground().linewidth(1) #Network count_L += 1 L.append(line.inductor(M[i], name='L' + str(count_L))) count_gnd += 1 ground.append( rf.Circuit.Ground(frequency=freq, name='ground' + str(count_gnd), z0=RS)) d.pop() # Series resonator d += elm.Inductor2(loops=2).right().label( getUnitsWithScale(Lseries[i + 1], 'Inductance'), fontsize=_fontsize).linewidth(1) count_L += 1 L.append(line.inductor(Lseries[i + 1], name='L' + str(count_L))) if (i < Nres): d += elm.Capacitor().right().label( getUnitsWithScale(Cres[i], 'Capacitance'), fontsize=_fontsize).linewidth(1) count_C += 1 C.append(line.capacitor(Cres[i], name='C' + str(count_C))) # Connections if (i == 0): # Then, connect to the first inductor connections.append([(L[0], 1), (L[1], 0), (L[2], 0)]) connections.append([(L[1], 1), (ground[i], 0)]) connections.append([(L[2], 1), (C[i], 0)]) else: # Then, connect to the previous capacitor connections.append([(C[i - 1], 1), (L[2 * i + 1], 0), (L[2 * i + 2], 0)]) connections.append([(L[2 * i + 1], 1), (ground[i], 0)]) if (i < Nres): # The last iteration is the coupling for the load port connections.append([(L[2 * i + 2], 1), (C[i], 0)]) # Drawing d += elm.Line().length(1).linewidth(1) d += elm.Dot().label('ZL = ' + str(float("{:.2f}".format(RL))) + " \u03A9", fontsize=_fontsize).linewidth(1) # Network Port2 = rf.Circuit.Port(frequency=freq, name='port2', z0=RL) # Connections connections.append([(L[-1], 1), (Port2, 0)]) else: # Magnetic coupling Lp = Lseries # Source port # Drawing: Source port and the first line d += elm.Line(color='white').length(2).linewidth(0) d += elm.Dot().label('ZS = ' + str(RS) + " \u03A9", fontsize=_fontsize).linewidth(1) d += elm.Line().length(2).linewidth(1) # Network: Port 1 connections = [] # Network connections L = [] C = [] ground = [] count_L = 0 count_C = 0 count_gnd = 0 Port1 = rf.Circuit.Port(frequency=freq, name='port1', z0=RS) for i in range(0, Nres): x = d.add( elm.Transformer( t1=4, t2=4, loop=True, core=True, fontsize=_fontsize).label( getUnitsWithScale(Lp[i], 'Inductance'), loc='left').label( getUnitsWithScale(Lp[i + 1], 'Inductance'), loc='right').label("k = " + str( round(M[i] / np.sqrt(Lp[i] * Lp[i + 1]), 3)), loc='top').flip()) d += elm.Ground().at(x.p1).linewidth(1) d += elm.Ground().at(x.s1).linewidth(1) d += elm.Line().at(x.s2).length(1) d += elm.Capacitor().right().label(getUnitsWithScale( Cres[i], 'Capacitance'), fontsize=_fontsize).linewidth(1) d += elm.Line().length(1) # Network: The transformer is simulated using the uncoupled lumped equivalen (Zverev, Fig. 10.4 (c)) count_L += 1 L.append(line.inductor(Lp[i] - M[i], name='L' + str(count_L))) count_L += 1 L.append(line.inductor(M[i], name='L' + str(count_L))) count_L += 1 L.append(line.inductor(Lp[i + 1] - M[i], name='L' + str(count_L))) count_gnd += 1 ground.append( rf.Circuit.Ground(frequency=freq, name='ground' + str(count_gnd), z0=RS)) count_C += 1 C.append(line.capacitor(Cres[i], name='C' + str(count_C))) print("L[" + str(3 * i) + "] = ", getUnitsWithScale(Lp[i] - M[i], 'Inductance')) print("L[" + str(3 * i + 1) + "] = ", getUnitsWithScale(M[i], 'Inductance')) print("L[" + str(3 * i + 2) + "] = ", getUnitsWithScale(Lp[i + 1] - M[i], 'Inductance')) print("C[" + str(i) + "] = ", getUnitsWithScale(Cres[i], 'Capacitance')) # Connections if (i == 0): # Connect the first inductor to the source port connections.append([(Port1, 0), (L[0], 0)]) else: # Connect the first inductor to the previous capacitor connections.append([(C[i - 1], 1), (L[3 * i], 0)]) connections.append([(L[3 * i], 1), (L[3 * i + 1], 0), (L[3 * i + 2], 0)]) connections.append([(L[3 * i + 1], 1), (ground[i], 0)]) connections.append([(L[3 * i + 2], 1), (C[i], 0)]) x = d.add( elm.Transformer( t1=4, t2=4, loop=True, core=True, fontsize=_fontsize).label( getUnitsWithScale(Lp[-2], 'Inductance'), loc='left').label( getUnitsWithScale(Lp[-1], 'Inductance'), loc='right').label( "k = " + str(round(M[-1] / np.sqrt(Lp[-2] * Lp[-1]), 3)), loc='top').flip()) d += elm.Ground().at(x.p1).linewidth(1) d += elm.Ground().at(x.s1).linewidth(1) # Network: The transformer is simulated using the uncoupled lumped equivalen (Zverev, Fig. 10.4 (c)) count_L += 1 L.append(line.inductor(Lp[-2] - M[-1], name='L' + str(count_L))) count_L += 1 L.append(line.inductor(M[-1], name='L' + str(count_L))) count_L += 1 L.append(line.inductor(Lp[-1] - M[-1], name='L' + str(count_L))) count_gnd += 1 ground.append( rf.Circuit.Ground(frequency=freq, name='ground' + str(count_gnd), z0=RS)) print("L[" + str(3 * Nres) + "] = ", getUnitsWithScale(Lp[-2] - M[-1], 'Inductance')) print("L[" + str(3 * Nres + 1) + "] = ", getUnitsWithScale(M[-1], 'Inductance')) print("L[" + str(3 * Nres + 2) + "] = ", getUnitsWithScale(Lp[-1] - M[-1], 'Inductance')) # Load port d += elm.Line().at(x.s2).length(2).linewidth(1) d += elm.Dot().label('ZL = ' + str(RL) + " \u03A9", fontsize=_fontsize).linewidth(1) d += elm.Line(color='white').length(2).linewidth(0) Port2 = rf.Circuit.Port(frequency=freq, name='port2', z0=RL) # Connections connections.append([(C[-1], 1), (L[-3], 0)]) connections.append([(L[-3], 1), (L[-2], 0), (L[-1], 0)]) connections.append([(L[-2], 1), (ground[-1], 0)]) connections.append([(L[-1], 1), (Port2, 0)]) return d, connections
def getCanonicalFilterSchematic(params): # Unpack the dictionary gi = params['gi'] N = params['N'] ZS = params['ZS'] fc = params['fc'] f1 = params['f1'] f2 = params['f2'] FirstElement = params['FirstElement'] Mask = params['Mask'] if (Mask == 'Bandpass' or Mask == 'Bandstop'): w1 = 2 * np.pi * f1 * 1e6 # rad/s w2 = 2 * np.pi * f2 * 1e6 # rad/s w0 = np.sqrt(w1 * w2) Delta = w2 - w1 else: w0 = 2 * np.pi * fc * 1e6 # rad/s print(gi) ################################################## # Draw circuit schem.use('svg') d = schem.Drawing(inches_per_unit=0.3) _fontsize = 8 # Draw the source port and the first line (if needed) d += elm.Line(color='white').length(2).linewidth(0) d += elm.Dot().label('ZS = ' + str(ZS) + " \u03A9", fontsize=_fontsize).linewidth(1) d += elm.Line().length(2).linewidth(1) # Draw the filter components for i in range(N): if (((i % 2 == 0) and (FirstElement == 1)) or ((i % 2 != 0) and (FirstElement != 1))): d += elm.Dot() d.push() # Save the drawing point for later # Mask-type transformation if (Mask == 'Lowpass'): d += elm.Capacitor().down().label( getUnitsWithScale(gi[i + 1] / (ZS * w0), 'Capacitance'), fontsize=_fontsize).linewidth(1) d += elm.Ground().linewidth(1) elif (Mask == 'Highpass'): d += elm.Inductor2(loops=2).down().label( getUnitsWithScale(ZS / (gi[i + 1] * w0), 'Inductance'), fontsize=_fontsize).linewidth(1) d += elm.Ground().linewidth(1) elif (Mask == 'Bandpass'): d.push() d += elm.Line().down().length(2).linewidth(1) d += elm.Dot() d.push() d += elm.Line().left().length(1).linewidth(1) d += elm.Capacitor().down().label( getUnitsWithScale(gi[i + 1] / (ZS * Delta), 'Capacitance'), fontsize=_fontsize).linewidth(1) d += elm.Ground().linewidth(1) d.pop() d += elm.Line().right().length(1).linewidth(1) d += elm.Inductor2(loops=2).down().label( getUnitsWithScale(ZS * Delta / (gi[i + 1] * w0 * w0), 'Inductance'), fontsize=_fontsize).linewidth(1) d += elm.Ground().linewidth(1) d.pop() elif (Mask == 'Bandstop'): d += elm.Dot() d.push() d += elm.Inductor2(loops=2).down().label( getUnitsWithScale(ZS / (gi[i + 1] * Delta), 'Inductance'), fontsize=_fontsize).linewidth(1) d += elm.Capacitor().down().label( getUnitsWithScale(gi[i + 1] * Delta / (ZS * w0 * w0), 'Capacitance'), fontsize=_fontsize).linewidth(1) d += elm.Ground().linewidth(1) d.pop() d.pop() # Restore the drawing point else: # Mask-type transformation if (Mask == 'Lowpass'): d += elm.Inductor2(loops=2).label( getUnitsWithScale(ZS * gi[i + 1] / w0, 'Inductance'), fontsize=_fontsize).linewidth(1) elif (Mask == 'Highpass'): d += elm.Capacitor().label(getUnitsWithScale( 1 / (gi[i + 1] * w0 * ZS), 'Capacitance'), fontsize=_fontsize).linewidth(1) elif (Mask == 'Bandpass'): d += elm.Inductor2(loops=2).label( getUnitsWithScale(ZS * gi[i + 1] / (Delta), 'Inductance'), fontsize=_fontsize).linewidth(1) d += elm.Capacitor().label(getUnitsWithScale( Delta / (ZS * w0 * w0 * gi[i + 1]), 'Capacitance'), fontsize=_fontsize).linewidth(1) elif (Mask == 'Bandstop'): d.push() d += elm.Inductor2(loops=2).right().label( getUnitsWithScale(gi[i + 1] * ZS * Delta / (w0 * w0), 'Inductance'), fontsize=_fontsize).linewidth(1) d.pop() d += elm.Line().up().length(2).linewidth(1) d += elm.Capacitor().right().label( getUnitsWithScale(1 / (ZS * Delta * gi[i + 1]), 'Capacitance'), fontsize=_fontsize).linewidth(1) d += elm.Line().down().length(2).linewidth(1) # Draw the last line (if needed) and the load port d += elm.Line().right().length(2).linewidth(1) d += elm.Dot().label('ZL = ' + str(float("{:.2f}".format(ZS * gi[-1]))) + " \u03A9", fontsize=_fontsize).linewidth(1) d += elm.Line(color='white').length(2).linewidth(0) return d