from ahkab import new_ac, run from ahkab.circuit import Circuit from ahkab.plotting import plot_results # calls matplotlib for you import numpy as np import matplotlib.pyplot as plt # Define the circuit cir = Circuit('Butterworth 1kHz band-pass filter') cir.add_vsource('V1', 'n1', cir.gnd, dc_value=0., ac_value=1.) cir.add_resistor('R1', 'n1', 'n2', 50.) cir.add_inductor('L1', 'n2', 'n3', 0.245894) cir.add_capacitor('C1', 'n3', 'n4', 1.03013e-07) cir.add_inductor('L2', 'n4', cir.gnd, 9.83652e-05) cir.add_capacitor('C2', 'n4', cir.gnd, 0.000257513) cir.add_inductor('L3', 'n4', 'n5', 0.795775) cir.add_capacitor('C3', 'n5', 'n6', 3.1831e-08) cir.add_inductor('L4', 'n6', cir.gnd, 9.83652e-05) cir.add_capacitor('C4', 'n6', cir.gnd, 0.000257513) cir.add_capacitor('C5', 'n7', 'n8', 1.03013e-07) cir.add_inductor('L5', 'n6', 'n7', 0.245894) cir.add_resistor('R2', 'n8', cir.gnd, 50.) # Define the analysis ac1 = new_ac(.97e3, 1.03e3, 1e2, x0=None) # run it res = run(cir, ac1) # plot the results plot_results('5th order 1kHz Butterworth filter', [('|Vn8|',"")], res['ac'], outfilename='bpf_transfer_fn.png')
from ahkab.circuit import Circuit from ahkab.symbolic import symbolic_analysis import matplotlib.pyplot as plt R = 1 #0.1e3 L = 1e-2 #0.2e-12 C = 0.5 #0.3e-9 c = Circuit('Sincronização de circuito LC') # resistors must be placed so all tanks are connected through one c.add_resistor('R1', 'n1', 'n2', R) c.add_resistor('R2', 'n2', 'n3', R) c.add_resistor('R3', 'n3', 'n4', R) c.add_resistor('R3', 'n4', 'n2', R) # tank1 c.add_inductor('L1', 'n1', c.gnd, L) c.add_capacitor('C1', 'n1', c.gnd, C) # tank2 c.add_inductor('L2', 'n2', c.gnd, L) c.add_capacitor('C2', 'n2', c.gnd, C) # tank3 c.add_inductor('L3', 'n3', c.gnd, L) c.add_capacitor('C3', 'n3', c.gnd, C) # tank4 c.add_inductor('L4', 'n4', c.gnd, L) c.add_capacitor('C4', 'n4', c.gnd, C) # Interferência destrutiva x0 = ahkab.new_x0(c, { 'V(n1)': -0.2 / C, 'V(n2)': -0.1 / C, 'V(n3)': 0.1 / C,