Example #1
0
    def test_dcop(self):
        cir = gnucap.Circuit(simple_netlist)
        sim = gnucap.Simulation(cir, direct=self.direct)

        res = sim.run_dcop()

        assert_equal(res['v(2)'].value(27), 0.75)
Example #2
0
    def test_netlist(self):
        def check_netlist(sim):
            assert_equal(sim.command('list'), 
               'V1 ( 1 0 )  DC  1.\nR1 ( 1 2 )  1.K\nR2 ( 2 0 )  3.K')
            
        sim = gnucap.Simulation(None, direct=self.direct)
        sim.send_netlist(simple_netlist)
        check_netlist(sim)
	sim=None

        cir = gnucap.Circuit(simple_netlist)
        sim = gnucap.Simulation(cir, direct=self.direct)
        check_netlist(sim)
	sim=None

        sim = gnucap.Simulation(simple_netlist, direct=self.direct)
        check_netlist(sim)
Example #3
0
    def test_raw_dcop(self):
        sim = gnucap.Simulation(None, direct=self.direct)

        sim.send_netlist(simple_netlist)

        sim.command('print op v(nodes)')

        res = sim.command('op 27', parse_result=True)

        assert_equal(res['v(2)'].value(27), 0.75)
Example #4
0
    def test_transient(self):
        cir = gnucap.Circuit(simple_netlist)
        sim = gnucap.Simulation(cir, direct=self.direct)

        res = sim.run_transient(t=LinSweep(0, 1, n=6))

        refv2 = Waveform(np.array([0., 0.2, 0.4, 0.6, 0.8, 1.]),
                         np.array([0.75, 0.75, 0.75, 0.75, 0.75, 0.75]))

        assert_waveform_equal(res.v(2), refv2)

        assert_equal(res.v(2).xlabels, ['Time'])
Example #5
0
    def test_ac(self):
        cir = gnucap.Circuit()
        cir['V1'] = gnucap.VS(1, 0, 1, ac=1)
        cir['R'] = gnucap.R(1,2,10e3)
        cir['C'] = gnucap.C(2,0,1e-9)

        sim = gnucap.Simulation(cir, direct=self.direct)

        for freq in (1e3, [1e3], [1e3, 2e3], LinSweep(1e4, 1e5, 10), LogSweep(1e4, 1e5, decade=10)):
            res = sim.run_ac(freq=freq)

            v2 = res.v(2)

            freq = v2.xval()

            v2ref = 1/(1 + 2j*np.pi * freq * 10e3 * 1e-9)

            assert_waveform_almost_equal(abs(v2), abs(v2ref), 5)
Example #6
0
    def test_start(self):
        sim = gnucap.Simulation(None, direct=self.direct)

        print sim.command('list')