import ngspyce import numpy as np from matplotlib import pyplot as plt ngspyce.cmd(b'source quad.net') #trrandom(2 2m 0 10m 0) ngspyce.cmd(b'tran 1m 20m') print('\n'.join(ngspyce.vectorNames())) vcos, vsin, time = ngspyce.vectors(['Vcos','Vsin','time']).values() #np.savetxt('vcos.txt', vcos) #np.savetxt('vsin.txt', vsin) #np.savetxt('time.txt', time) #exit() plt.plot(time,vcos, label='Vcos') plt.plot(time,vsin, label='Vsin') plt.legend() plt.show()
def test_vsource(self): ns.circ('va a 0 dc 1') ns.operating_point() self.assertEqual(ns.vectors(), {'a': [1], 'va#branch': [0]})
def test_resistor(self): ns.circ(['va a 0 dc 1', 'r a 0 2']) ns.operating_point() self.assertEqual(ns.vectors(), {'a': [1], 'va#branch': [-0.5]})
def assertVectors(self, vectors): self.assertEqualDictOfArray(ns.vectors(), vectors)