Пример #1
0
 def chargeNdischarge(self, time, saveStatus=True):
     cct = eispice.Circuit("battery stimulator charge")
     cct.batteries = self.bg.generateSpiceModel()
     cct.source = eispice.I(self.bg.pNode, self.bg.nNode,
                            self.source)  # constant current charge source
     cct.load = eispice.R(self.bg.pNode, self.bg.nNode,
                          self.load)  # put the load on
     cct.tran('0.01n', '0.02n')  #doing transient analysis
     for i in range(self.NumberOfCells * self.NumberOfStacks):
         self.bg[i].current = cct.i['V' + str(i)]('0.01n') * 1000
         self.bg[i].quantity += self.bg[i].current * time / 3600
         print('current:{0},  quantity Gain:{1}'.format(
             self.bg[i].current, self.bg[i].qGain))
     if saveStatus:
         self.backup()  # save current status
     self.updateInfo()
Пример #2
0
 def charge(self, time, saveStatus=True):
     cct = eispice.Circuit("battery stimulator charge")
     cct.batteries = self.bg.generateSpiceModel()
     cct.source = eispice.I(self.bg.pNode, self.bg.nNode,
                            self.source)  # constant current charge source
     cct.tran('0.01n', '0.02n')  #doing transient analysis
     for i in range(self.NumberOfCells * self.NumberOfStacks):
         self.bg[i].current = abs(cct.i['V' + str(i)]('0.01n')) * 1000
         self.bg[i].quantity += self.bg[i].current * time / 3600
         self.bg[i].soc = self.bg[i].quantity / self.BATTERYCAPACITY * 100
         print('current:{0},  quantity is:{1}'.format(
             self.bg[i].current, self.bg[i].quantity))
     self.clock += time
     if saveStatus:
         self.backup()  # save current status
     self.updateInfo()
Пример #3
0
    def NdischargeNCharge(self, time, saveStatus=True):
        #calculate the current
        cct = eispice.Circuit("battery stimulator not discharge not charge")
        cct.batteries = self.bg.generateSpiceModel()
        #it will return a list contains connected batteries
        cct.load = eispice.R(self.bg.pNode, self.bg.nNode, 10000000)
        cct.tran('0.01n', '0.02n')  #doing transient analysis
        for i in range(self.NumberOfCells * self.NumberOfStacks):
            print cct.i['V' + str(i)]('0.01n')
            self.bg.current = self.bg.current + abs(
                cct.i['V' + str(i)]('0.01n'))
        print self.bg.current

        qLoss = self.bg.current * time
        for b in self.bg:
            b.quantity = b.quantity - qLoss
        print('current:{0},  quantity loss:{1}'.format(self.bg.current, qLoss))
Пример #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
Пример #5
0
 def discharge(self,time,saveStatus = True):
     totalQuantity=0
     totalSOC=0
     f=open('dischargeData.txt','a')
     cct = eispice.Circuit("battery stimulator discharge")
     cct.batteries = self.bg.generateSpiceModel();#it will return a list contains connected batteries
     cct.load = eispice.R(self.bg.pNode,self.bg.nNode,self.load)# put the load on
     cct.tran('0.01n','0.02n')#doing transient analysis 
     for i in range(self.NumberOfCells*self.NumberOfStacks):
         self.bg[i].current=abs(cct.i['V'+str(i)]('0.01n')) * 1000      
         self.bg[i].quantity -= self.bg[i].current * time/3600
         self.bg[i].soc= self.bg[i].quantity/self.BATTERYCAPACITY
         totalQuantity += self.bg[i].quantity
     #print 'the total quantity is:',totalQuantity 
     totalSOC=totalQuantity/(self.BATTERYCAPACITY*self.NumberOfCells*self.NumberOfStacks)
     self.clock += time
     f.write(str(self.clock)+'\t')
     f.write(str(totalSOC)+'\t')
     f.write('\n')
     f.close()
     if saveStatus:
          self.backup() # save current status
     self.updateInfo()
Пример #6
0
def test_ibis():
	"""Extended eispice.Ibis Model Testing
	NOTE: Will only work on my development tree, these models are copyrighted
	and can not be distributed with eispice. CE
	"""
	
	# 29le010.ibs
	ibs = eispice.Ibis("../development/29le010.ibs")
	cct = eispice.Circuit('test_29le010')
	cct.Driver = ibs['17']('vs')
	cct.Tg = eispice.T('vs', 0, 'vo', 0, 75, '10n')
	cct.Receiver = ibs['2']('vo')
	cct.tran('0.1n', '5n')
	eispice.plot(cct)

	# 39wf800a.ibs
	ibs = eispice.Ibis("../development/39wf800a.ibs")
	cct = eispice.Circuit('test_39wf800a')
	cct.Driver = ibs['e2']('vs')
	cct.Tg = eispice.T('vs', 0, 'vo', 0, 100, '10n')
	cct.Receiver = ibs['a1']('vo')
	cct.tran('0.1n', '5n')
	eispice.plot(cct)

	# ad9222bcp.ibs
	ibs = eispice.Ibis("../development/ad9222bcp.ibs")
	cct = eispice.Circuit('test_ad9222bcp')
	cct.Driver = ibs['39']('vs')
	cct.Tg = eispice.T('vs', 0, 'vo', 0, 50, '10n')
	cct.Receiver = ibs['38']('vs')
	cct.tran('0.1n', '200n')
	eispice.plot(cct)
	
	# ad9289bbc.ibs
	ibs = eispice.Ibis("../development/ad9289bbc.ibs")
	cct = eispice.Circuit('test_ad9289bbc')
	cct.DriverP = ibs['b1']('vsp')
	cct.DriverN = ibs['b1']('vsn', direction=eispice.Falling)
	cct.Rl = eispice.R('vsp',0,50)
	cct.R2 = eispice.R('vsn',0,50)
	cct.tran('0.1n', '10n')
	eispice.plot(cct)
	
	# ahc1g14.ibs
	ibs = eispice.Ibis("../development/ahc1g14.ibs")
	cct = eispice.Circuit('test_ahc1g14')
	cct.Driver = ibs['4']('vx', modelName='ahc_xgouti_50')
	cct.Rl = eispice.R('vx','vs',33.2)
	cct.Tg = eispice.T('vs', 0, 'vo', 0, 50, '10n')
	cct.Receiver = ibs['2']('vs', modelName='ahc_xg14in_50')
	cct.tran('0.1n', '50n')
	eispice.plot(cct)

	# alvc00m_300.ibs
	ibs = eispice.Ibis("../development/alvc00m_300.ibs")
	cct = eispice.Circuit('test_alvc00m_300')
	cct.Driver = ibs['3']('vx')
	cct.Rl = eispice.R('vx','vs',33.2)
	cct.Tg = eispice.T('vs', 0, 'vo', 0, 50, '10n')
	cct.Receiver = ibs['1']('vs')
	cct.tran('0.1n', '50n')
	eispice.plot(cct)

	# au1000.ibs
	ibs = eispice.Ibis("../development/au1000.ibs")
	cct = eispice.Circuit('test_au1000')
	cct.Driver = ibs['A1']('vx')
	cct.Rl = eispice.R('vx','vs',33.2)
	cct.Tg = eispice.T('vs', 0, 'vo', 0, 50, '10n')
	cct.Receiver = ibs['A10']('vs')
	cct.tran('0.1n', '50n')
	eispice.plot(cct)
Пример #7
0
import eispice
ibs = eispice.Ibis('test')
cct = eispice.Circuit('IBIS Test')
cct.Driver = ibs['2']('vs')
cct.Rt = eispice.R('vs', 'vi', 33.2)
cct.Tg = eispice.T('vi', 0, 'vo', 0, 50, '2n')
cct.Receiver = ibs['1']('vo')
cct.tran('0.01n', '20n')
eispice.plot(cct)
Пример #8
0
import eispice

cct1 = eispice.Circuit("Ted's Circuit 1")
cct1.V18 = eispice.V(eispice.GND, 1, 18)
cct1.V7 = eispice.V(2, eispice.GND, 7)
cct1.I5m = eispice.I(1, 2, 0.005)

cct1.op()

print '-- Circuit 1 --'
print 'V18 Current: %gA' % cct1.i['V18'](0)
print 'V7 Current: %gA' % cct1.i['V7'](0)
print 'I5m Voltage: %gV' % (cct1.v[1](0) - cct1.v[2](0))

cct2 = eispice.Circuit("Ted's Circuit 2")
cct2.In5 = eispice.I(eispice.GND, 1, (20 - 25 - 5))
cct2.V60 = eispice.V(2, 1, 60)
cct2.V100 = eispice.V(2, eispice.GND, 100)

cct2.op()

print '-- Circuit 2 --'
print 'V60 Current: %gA' % cct2.i['V60'](0)
print 'V100 Current: %gA' % cct2.i['V100'](0)
Пример #9
0
            return 0.001
    else:
        return 0.001


if __name__ == '__main__':

    #define a descriptor list for the battery group
    descriptorLst = []
    for i in range(1):
        des = BatteryDescriptor()
        des.Name = 'cell' + str(i)  # define a name
        des.OCVCallback = OCVInfoRecorder
        # add more customize parameters here
        #...
        descriptorLst.append(des)
    cct = eispice.Circuit("Battery Group Test")
    #define a battery group with the descriptor list
    cct.bg = RealBatteryGroup(1, eispice.GND,
                              descriptorLst)  #print the runtime message
    #add a constant current load (1.0A)
    cct.load = customizedCurrentSource(1, eispice.GND, constantCurrentLoad)
    print cct.devices()  #print the network of the circuit
    cct.tran('1', '7000')  #timestep=1 last 25000 seconds
    #here do something after simulation, for example save realDataList
    realDataArr = np.array(realDataList)
    np.savetxt('Realdata.txt', realDataArr, delimiter='\t')
    #print measureDataList
    measureDataArr = np.array(measureDataList)
    np.savetxt('MeasuredData.txt', measureDataArr, delimiter='\t')
    eispice.plot(cct)
Пример #10
0
import eispice

cct = eispice.Circuit("battery stimulator not discharge not charge")


def generateSpiceModel():
    spiceModel = []

    Vsp = ('Vsp', eispice.V('V1+', eispice.GND, 3.65))  #eispice source model
    Rsp = ('Rsp', eispice.R('V1+', 'V2-', 0.0155))  #eispice resistance model
    Rb = ('Rb', eispice.R('V2-', eispice.GND, 240))

    Vsp2 = ('Vsp2', eispice.V('V2-', 'V2+', 3.65))
    Rsp2 = ('Rsp2', eispice.R('V2+', eispice.GND, 0.0155))
    Rb2 = ('Rb2', eispice.R('V2-', eispice.GND, 240))

    spiceModel.append(Vsp)
    spiceModel.append(Rsp)  #set a signel battery spice model
    spiceModel.append(Rb)

    spiceModel.append(Vsp2)
    spiceModel.append(Rsp2)
    spiceModel.append(Rb2)

    return spiceModel


cct.batteries = generateSpiceModel()
cct.tran('0.01n', '0.02n')
print 'current of Vsp is:', cct.i['Vsp']('0.01n')  #unit is A
print 'current of Vsp2 is:', cct.i['Vsp2']('0.01n')  #unit is A
Пример #11
0
    '''
    t = device.time
    if int(t) % 40 == 0:  # print every 40 seconds
        debugString = "t:{time},v:{voltage},soc:{soc},i:{current}".format(
            **device.__dict__)
        print debugString


if __name__ == '__main__':
    #define a squre wave constant current load
    def constantCurrentLoad(load):
        if load.vp > load.vn:
            if load.time < 1009:
                return 0.001
            elif load.time < 1742:  #int(load.time)%40 <10:
                return 2.652
            else:
                return 0.001
        else:
            return 0.001

    cct = eispice.Circuit("Real Battery Model Discharge test")
    #define a battery Cell with the pre-defined battery parameter
    cct.rb = RealBattery(1, eispice.GND,
                         defaultDescriptor)  #print the runtime message
    #define a customized load
    cct.load = customizedCurrentSource(1, eispice.GND, constantCurrentLoad)
    #time step 1s, 3000s duration
    cct.tran('1', '3500')  #timestep=1 last 25000 seconds
    eispice.plot(cct)
Пример #12
0
import eispice

cct = eispice.Circuit("Non-Linear Capacitor Test")

wave = eispice.Pulse('1n', '10n', '10n', '5n', '3n', '5n', '25n')
cct.Vc = eispice.V(3, 0, '1n', wave)

cct.Vx = eispice.V(1, 0, 4, eispice.Pulse(4, 8, '10n', '2n', '3n', '5n',
                                          '20n'))
cct.Cx = eispice.BC(1, 0, 'v(3)*10')

cct.tran('0.5n', '100n')

eispice.plot(cct)

print "%s... Pass" % cct.title