def main(argv): if len(sys.argv) < 2: arg = "D237A" # default transistor model else: arg = str(sys.argv[1]) argoky = 0 if arg in Diodes.keys(): argoky = 1 if not argoky: print(' please give on of the Diode model name') print(Diodes.keys()) exit() t = "Diode_clipper" v = Diode_clipper(arg) parser = dk_simulator.Parser(v.S, v.V, v.FS) p = dk_simulator.get_executor(t, parser, v.solver, '-p', c_tempdir='/tmp', c_verbose='--c-verbose', c_debug_load='', linearize='', c_real=("double")) v.generate_table(p) v.plot(p)
def main(argv): if len(sys.argv) < 4: print(' to less args given') exit() arg = str(sys.argv[1]) S = str(sys.argv[2]) V = str(sys.argv[3]) if len(sys.argv) > 3: M = sys.argv[4] else: M = None if len(sys.argv) > 4: O = sys.argv[5] else: O = None if len(sys.argv) > 5: D = sys.argv[6] else: D = None t = "Circ_table" v = Circ_table(arg, S, V, M, O, D) parser = dk_simulator.Parser(v.S, v.V, v.FS) p = dk_simulator.get_executor(t, parser, v.solver, '-p', c_tempdir='/tmp', c_verbose='--c-verbose', c_debug_load='', linearize='', c_real=("double")) y = p(v.signal()) v.generate_table(p, y) v.plot(p, y)
def _ensure_parser(self, symbolic=False, for_filter=False): if self.parser is None or not self.parser.matches(symbolic, for_filter): if self.S is None: raise CircuitException("no netlist defined") if self.V is None and not symbolic: raise CircuitException("no netlist values defined") self.parser = dk_simulator.Parser(self.S, self.V, self.FS, not self.backward_euler, for_filter, symbolic)
def check(self, name, args): p = dk_simulator.Parser(self.S, self.V, self.FS, not args.backward_euler, create_filter=True, symbolic=False) p1 = dk_simulator.Parser(self.S, self.V, self.FS, not args.backward_euler) sim = dk_simulator.SimulatePy(dk_simulator.EquationSystem(p1), self.solver) J = sim.jacobi() f = dk_simulator.LinearFilter(p, J) b, a = f.get_z_coeffs(samplerate=48000, subst_var=f.convert_variable_dict({})) res = np.array([[float(v) for v in b], [float(v) for v in a]]) if np.allclose(res, self.result): return "Ok" else: return "Fail"
def _ensure_filter(self, symbolic): self._ensure_parser(symbolic=symbolic, for_filter=True) if len(self.parser.get_nonlin_funcs()) > 0: if symbolic: raise CircuitException("ciruit is nonlinear: symbolic formula generation not supported") p = dk_simulator.Parser(self.S, self.V, self.FS, not self.backward_euler) sim = dk_simulator.SimulatePy(dk_simulator.EquationSystem(p), self.solver, self.dc_method) J = sim.jacobi() else: J = None self.sim_filter = dk_simulator.LinearFilter(self.parser, J)
def check(self, name, args): parser = dk_simulator.Parser(self.S, self.V, self.FS, not args.backward_euler) p = dk_simulator.get_executor(name, parser, self.solver, args.pure_python, c_tempdir=args.c_tempdir, c_verbose=args.c_verbose, c_debug_load=args.c_debug_load, linearize=args.linearize) if args.print_result: self.print_data(p(self.signal()), "\nresult = np.") return "" res = self.check_signal(p) # side-effect: calculate time_per_sample if hasattr(p, "time_per_sample"): s = " [%.2g]" % p.time_per_sample else: s = "" return "%s%s" % (res[1], s)
def main(argv): if len(sys.argv) < 2: arg = "2N5088" # set default transistor model, when none is given else: arg = str(sys.argv[1]) argoky = 0 if arg in Transistors.keys(): argoky = 1 if not argoky: print (' please give on of the Transistor model name') print (Transistors.keys()) exit() t = "Transistor_table" v = Transistor_table(arg) parser = dk_simulator.Parser(v.S, v.V, v.FS) p = dk_simulator.get_executor( t, parser, v.solver, '-p', c_tempdir='/tmp', c_verbose='--c-verbose', c_debug_load='', linearize='', c_real=("double")) v.generate_table(p) v.plot(p)