Esempio n. 1
0
        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()

d0=gnucap.install_command("myac", myac)
d1=gnucap.install_command("ac", 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
Esempio n. 2
0
class MyAC2(gnucap.SIM):
    def do_it(self, cmd, scope):
        print("HELLOWORLD2")

    def setup(self, cmd):
        pass

    def sweep(self):
        pass


ac = MyAC()
ac2 = MyAC2()
print("install1")
d1 = gnucap.install_command("myac1", ac)
print("install2")
d2 = gnucap.install_command("myac", ac2)
d3 = gnucap.install_command("myac", ac)
d4 = gnucap.install_command("ac", ac)

gnucap.command("set trace")
gnucap.command("ac 1 2 * 2")
gnucap.command("myac1 1 2 * 2")
gnucap.command("myac:0 1 2 * 2")
gnucap.command("myac 1 2 * 2")

print("side effects?")
del (d2)
try:
    gnucap.command("myac:0 1 2 * 2")  # bad command? yes. this was d2
Esempio n. 3
0
                    i[idx] = ir[1] - 1
                    raw[idx] *= -1
                elif ir[0] == -1 and ir[1] == i[idx]:
                    raw[idx] = 0.
                    i[idx] = 0
                elif ir[0] == -1 and i[idx] >= ir[1]:
                    i[idx] -= 1
                elif ir[0] != -1 and i[idx] > ir[0]:
                    i[idx] -= 1
                assert (i[idx] >= 0)

        set_io(j, ir, raw)
        set_io(i, jr, raw)

        f = coo_matrix((raw, (i, j)))
        M = f.todense()
        R = np.real(M)
        I = np.imag(M)
        self._out << "zeroes\n"

        E = eig(R, I, homogeneous_eigvals=True)
        E0 = E[0]

        self.sort_and_output(E0)

        sys.stdout.flush()


sim = spice_pz()
d1 = install_command("pz", sim)
Esempio n. 4
0
class mysim(SIM):
    def do_it(self, cmd, scope):
        #		print("running mysim...")
        out("running mysim...\n")

    def setup(self, cmd):
        pass
        #out = IO.mstdout;
        #out.reset(); # BUG// don't know why this is needed
    def sweep(self):
        pass


sim = mysim()

d1 = install_command("test", sim)
#del(d1) #what does it do?
d1 = install_command("test", sim)

out("installing again\n")
d2 = install_command("test", sim)
out("installing again\n")
d3 = install_command("mysim", sim)

#BUG: that does not work as expected.
# it just breaks "mysim". why?
#d3 = install_command("mysim", sim)

sys.stdout.flush()
Esempio n. 5
0
	c = COMPONENT()
	print("ERROR, component must be pure")
	assert(False)
except AttributeError:
	print("ignoring AttributeError")
	pass
except RuntimeError:
	pass

class MyAC(gnucap.SIM):
	def do_it(self, cmd, scope):
		print("HELLOWORLD")
		stdout.flush()

ac = MyAC()
c1 = gnucap.install_command("myac", ac)
stdout.flush()

# test: "already installed"
c2 = gnucap.install_command("myac", ac)
stdout.flush()

print("running ac")
stdout.flush()
gnucap.command("ac 1 2 * 2")
stdout.flush()

print("running myac")
stdout.flush()
gnucap.command("myac 1 2 * 2")
Esempio n. 6
0
        ac = s._ac
        for i in range(n + 1):
            ac[i] = 0

        s.count_iterations(iTOTAL)

        cl = CARD_LIST().card_list_()
        cl.do_ac()
        cl.ac_load()

        if (0):
            print("M",
                  self.sim_()._acx[0][0],
                  self.sim_()._acx[0][1],
                  self.sim_()._acx[0][2])
            print("M",
                  self.sim_()._acx[1][0],
                  self.sim_()._acx[1][1],
                  self.sim_()._acx[1][2])
            print("M",
                  self.sim_()._acx[2][0],
                  self.sim_()._acx[2][1],
                  self.sim_()._acx[2][2])

        acx.lu_decomp()
        acx.fbsub_(self.sim_()._ac)


sim = mysim()
d1 = install_command("mysim", sim)