Пример #1
0
 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)
Пример #2
0
 def _ensure_sim_py(self):
     if self.sim_py is None:
         self._ensure_eq()
         try:
             self.sim_py = dk_simulator.SimulatePy(self.eq, self.solver, self.dc_method)
             if self.sys_reduce_tol >= 0:
                 self.sim_py.balance_realization(self.sys_reduce_tol)
             if (isinstance(self.eq.nonlin, dk_simulator.PartitionedNonlinEquations)
                 and self.transform_opts.decompose):
                 self.eq.F, self.eq.C = self.eq.nonlin.decompose_blocks(self.eq.F, self.eq.C)
         except dk_simulator.ConvergenceError as e:
             raise CircuitException(e)
Пример #3
0
 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"