## Get C matrix from ac-analysis ## FIXME, there must be a better way acx = gnucap.cvar.CKT_BASE_acx ## Static attributes must be accessed through cvar acx.zero() card_list = gnucap.cvar.CARD_LIST_card_list # card_list.do_ac() # card_list.ac_load() C_bs = gnucap.bsmatrix_to_array_c(acx) self.lastC = np.imag(C_bs) self.lastC = np.array([[1e-6, 0], [0, 0]]) mytran = MyTransient() gnucap.attach_command("mytran", mytran) gnucap.command("store tran v(2)") t0 = 0 alpha = 1 gnucap.command("options method euler") gnucap.command("mytran 1e-4 1e-3 0") while True: n = gnucap.cvar.status.total_nodes residual = mytran.v0_n - mytran.v0_0 print "residual: ", np.sqrt(np.dot(residual, residual))
## FIXME, there must be a better way acx = gnucap.cvar.CKT_BASE_acx ## Static attributes must be accessed through cvar acx.zero() card_list = gnucap.cvar.CARD_LIST_card_list # card_list.do_ac() # card_list.ac_load() C_bs = gnucap.bsmatrix_to_array_c(acx) self.lastC = np.imag(C_bs) self.lastC = np.array([[1e-6, 0], [0, 0]]) mytran = MyTransient() gnucap.attach_command("mytran", mytran) gnucap.command("store tran v(2)") t0 = 0 alpha = 1 gnucap.command("options method euler") gnucap.command("mytran 1e-4 1e-3 0") while True: n = gnucap.cvar.status.total_nodes residual = mytran.v0_n - mytran.v0_0 print "residual: ", np.sqrt(np.dot(residual, residual))
card_list.do_ac() card_list.ac_load() print "Loaded AC-matrix", gnucap.get_complex_array(gnucap.cvar.SIM_ac, n) print gnucap.bsmatrix_to_array_c(acx) ## Solve acx.lu_decomp() acx.fbsub(gnucap.cvar.SIM_ac) print "rhs after", gnucap.get_complex_array(gnucap.cvar.SIM_ac, n) def setup(self, cmd): pass def sweep(self): pass myac = MyAC() gnucap.attach_command("myac", myac) gnucap.command("store ac vm(2)") gnucap.command("myac") w= gnucap.SIM.find_wave("vm(2)") x,y = gnucap.wave_to_arrays(w) print x,y