Example #1
0
def test_bugs():
	"""Test bugfixes."""
	
	cct = eispice.Circuit('Break-Point Stall Bug')
	cct.Vx = eispice.V('vs',0, 0, 
			eispice.Pulse(0, 1, '0n','1n','1n','4n','8n'))
	cct.Rt = eispice.R('vs', 'vi', 50)
	cct.Tg = eispice.T('vi', 0, 'vo', 0, 50, '2n')
	cct.Cx = eispice.C('vo',0,'5p')
	cct.tran('0.01n', '18n')
	eispice.plot(cct)
	
	cct = eispice.Circuit("LC Tline Bug")
	cct.Vs = eispice.V('vs', 0, 0, 
			eispice.Pulse(0, 1, '15n', '1n', '1n', '5n', '50n'))
	cct.Rs = eispice.R('vs', 1, 50)
	for i in range(1,100):
		setattr(cct,"L%i"%i,eispice.L(i,i+1,"2n"))
		setattr(cct,"C%i"%i,eispice.C(i+1,0,"1p"))
	cct.Rl = eispice.R(i+1, 0, 50)
	cct.tran('0.1n', '200n')
	eispice.plot_voltage(cct, 1 ,'%i' % (i+1))

	cct = eispice.Circuit("SuperLU Hangup Bug")
	cct.Vx = eispice.V('1', '0', 4, 
			eispice.Pulse(4, 8, '10n', '2n', '3n', '5n', '20n'))
	cct.Vy = eispice.V('1', '0', 4, 
			eispice.Pulse(8, 4, '10n', '2n', '3n', '5n', '20n'))
	cct.tran('0.5n', '100n')
	eispice.plot(cct)
Example #2
0
 def __init__(self, pNode, nNode, batteryDescriptor):
     '''
     Arguments:
     pNode -- positive node name
     nNode -- negative node name
     parameterDict -- dictionary to describe the battery
     The following keys should be included:
     batteryDescriptor.Name = 'cell'
     batteryDescriptor.OCVParameter = OCV_SOC_Parameters
     batteryDescriptor.InnerR =  0.021
     batteryDescriptor.R1 = 0.045
     batteryDescriptor.C1 = 300
     batteryDescriptor.R2 = None
     batteryDescriptor.C2 = None
     batteryDescriptor.InitialSOC = 0.99
     batteryDescriptor.Capacity = 5300
     batteryDescriptor.OCVCallback = some call back function
     batteryDescriptor.BalanceResCallBack = None #if it's not None, then a balance resistance will be added.
         
     OCVParameter -- K0~K4 parameter of OCV-SOC relation
     InnerR -- Inner resistance of the battery
     R1,C1 -- R and C value of first order dynamic model
     '''
     name = batteryDescriptor.Name
     if batteryDescriptor.R2 is not None and batteryDescriptor.C2 is not None:
         self.C2 = [('C2_' + name,
                     eispice.C('@nc2_' + name, pNode,
                               batteryDescriptor.C2))]
         self.R2 = [('R2_' + name,
                     eispice.R(pNode, '@nc2_' + name,
                               batteryDescriptor.R2))]
         self.C1 = [('C1_' + name,
                     eispice.C('@nc1_' + name, '@nc2_' + name,
                               batteryDescriptor.C1))]
         self.R1 = [('R1_' + name,
                     eispice.R('@nc2_' + name, '@nc1_' + name,
                               batteryDescriptor.R1))]
     else:
         self.C1 = [('C1_' + name,
                     eispice.C('@nc1_' + name, pNode,
                               batteryDescriptor.C1))]
         self.R1 = [('R1_' + name,
                     eispice.R(pNode, '@nc1_' + name,
                               batteryDescriptor.R1))]
     self.iR = [('iR_' + name,
                 eispice.R('@nc0_' + name, '@nc1_' + name,
                           batteryDescriptor.InnerR))]
     self.ocv = [('OCV_' + name,
                  OCV('@nc0_' + name, nNode, batteryDescriptor.OCVParameter,
                      batteryDescriptor.InitialSOC,
                      batteryDescriptor.Capacity, 'OCV_' + name,
                      batteryDescriptor.OCVCallback))]
     if batteryDescriptor.BalanceResCallBack is not None:
         self.balanceR = customizedCurrentSource(
             pNode, nNode, batteryDescriptor.BalanceResCallBack)
Example #3
0
def circuit():
    cir = eispice.Circuit("Mixed Mode Test")
    #cir.Vx = eispice.V(1,0,4)
    cir.L = eispice.L(1, 0, 27e-9)
    cir.R = eispice.R(1, 0, 820)
    cir.C = eispice.C(1, 0, 47e-12)
    cir.Rout = eispice.R(2, 0, 100)
    cir.TriggerOut = EispicePort(1, 0, triggerout, eispice.Current)
    cir.DetectorOut = EispicePort(2, 0, detectorout, eispice.Voltage)
    return cir
Example #4
0
    def run(self):
        global eispice_finished
        cir = eispice.Circuit("Mixed Mode Test")
        ### here we do the analog circuit description ###
        cir.L = eispice.L(1, 0, 27e-9)
        cir.R = eispice.R(1, 0, 820)
        cir.C = eispice.C(1, 0, 47e-12)
        cir.Rout = eispice.R(2, 0, 100)

        ### now we define our two MyHDL ports ###
        cir.TriggerOut = EispicePort(1, 0, triggerout, eispice.Current)
        cir.DetectorOut = EispicePort(2, 0, detectorout, eispice.Voltage)

        ### starting the simulation ###
        cir.tran(myhdl_timestep, simulationlen)

        ### plotting the results ###
        eispice.plot(cir)
        print "Eispice Simulation finished"
        catchup.set()
        eispice_finished = 1