CBMSBatInterShort.py 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554
  1. import pandas as pd
  2. import numpy as np
  3. import matplotlib.pyplot as plt
  4. from USER.Common import BatParam
  5. class BatInterShort():
  6. def __init__(self,sn,celltype,df_bms,df_soh): #参数初始化
  7. self.sn=sn
  8. self.celltype=celltype
  9. self.param=BatParam.BatParam(celltype)
  10. self.df_bms=df_bms
  11. self.packcrnt=df_bms['电流']*self.param.PackCrntDec
  12. self.bms_soc=df_bms['SOC']
  13. self.bmstime= pd.to_datetime(df_bms['接收时间'], format='%Y-%m-%d %H:%M:%S')
  14. self.df_soh=df_soh
  15. self.cellvolt_name=['单体电压'+str(x) for x in range(1,self.param.CellVoltNums+1)]
  16. self.celltemp_name=['温度采样'+str(x) for x in range(1,self.param.CellTempNums+1)]
  17. def intershort(self):
  18. if self.celltype<50:
  19. df_res=self._ncm_intershort()
  20. return df_res
  21. elif self.celltype>50:
  22. df_res=self._lfp_intershort()
  23. return df_res
  24. else:
  25. return pd.DataFrame()
  26. #定义滑动滤波函数....................................................................................
  27. def _np_move_avg(self,a, n, mode="same"):
  28. return (np.convolve(a, np.ones((n,)) / n, mode=mode))
  29. #寻找当前行数据的最小温度值.............................................................................
  30. def _celltemp_weight(self,num):
  31. celltemp = list(self.df_bms.loc[num,self.celltemp_name])
  32. celltemp=min(celltemp)
  33. self.celltemp=celltemp
  34. if self.celltype==99:
  35. if celltemp>=20:
  36. self.tempweight=1
  37. self.StandardStandingTime=3600
  38. elif celltemp>=10:
  39. self.tempweight=0.6
  40. self.StandardStandingTime=7200
  41. elif celltemp>=5:
  42. self.tempweight=0.
  43. self.StandardStandingTime=7200
  44. else:
  45. self.tempweight=0.1
  46. self.StandardStandingTime=10800
  47. else:
  48. if celltemp>=20:
  49. self.tempweight=1
  50. self.StandardStandingTime=3600
  51. elif celltemp>=10:
  52. self.tempweight=0.8
  53. self.StandardStandingTime=3600
  54. elif celltemp>=5:
  55. self.tempweight=0.6
  56. self.StandardStandingTime=7200
  57. else:
  58. self.tempweight=0.2
  59. self.StandardStandingTime=10800
  60. #获取当前行所有电压数据........................................................................................
  61. def _cellvolt_get(self,num):
  62. cellvolt = np.array(self.df_bms.loc[num,self.cellvolt_name])
  63. return cellvolt
  64. #获取当前行所有soc差...........................................................................................
  65. def _celldeltsoc_get(self,num,dict_baltime,capacity):
  66. cellsoc=[]
  67. celldeltsoc=[]
  68. for j in range(1, self.param.CellVoltNums+1): #获取每个电芯电压对应的SOC值
  69. cellvolt=self.df_bms.loc[num,'单体电压' + str(j)]
  70. ocv_soc=np.interp(cellvolt,self.param.LookTab_OCV,self.param.LookTab_SOC)
  71. if j in dict_baltime.keys():
  72. ocv_soc=ocv_soc+dict_baltime[j]*self.param.BalCurrent/(capacity*3600) #补偿均衡电流
  73. else:
  74. pass
  75. cellsoc.append(ocv_soc)
  76. cellsocmean=(sum(cellsoc)-max(cellsoc)-min(cellsoc))/(len(cellsoc)-2)
  77. for j in range(len(cellsoc)): #计算每个电芯的soc差
  78. celldeltsoc.append(cellsoc[j]-cellsocmean)
  79. return np.array(celldeltsoc)
  80. #获取所有电芯的As差
  81. def _cellDeltAs_get(self,chrg_st,chrg_end,dict_baltime):
  82. cellAs=[]
  83. celldeltAs=[]
  84. for j in range(1, self.param.CellVoltNums+1): #获取每个电芯电压>峰值电压的充入As数
  85. if j in dict_baltime.keys(): #补偿均衡电流
  86. As=-self.param.BalCurrent*dict_baltime[j]
  87. else:
  88. As=0
  89. As_tatol=0
  90. symbol=0
  91. for m in range(chrg_st+1,chrg_end):
  92. As=As-self.packcrnt[m]*(self.bmstime[m]-self.bmstime[m-1]).total_seconds()
  93. if symbol<5:
  94. if self.df_bms.loc[m,'单体电压'+str(j)]>self.param.PeakCellVolt[symbol]:
  95. As_tatol=As_tatol+As
  96. symbol=symbol+1
  97. else:
  98. continue
  99. else:
  100. cellAs.append(As_tatol/5)
  101. break
  102. cellAsmean=(sum(cellAs)-max(cellAs)-min(cellAs))/(len(cellAs)-2)
  103. for j in range(len(cellAs)): #计算每个电芯的soc差
  104. celldeltAs.append(cellAs[j]-cellAsmean)
  105. return np.array(celldeltAs)
  106. #计算每个电芯的均衡时长..........................................................................................................................
  107. def _bal_time(self,dict_bal):
  108. dict_baltime={}
  109. dict_baltime1={}
  110. for key in dict_bal:
  111. count=1
  112. x=eval(key)
  113. while x>0:
  114. if x & 1==1: #判断最后一位是否为1
  115. if count in dict_baltime.keys():
  116. dict_baltime[count] = dict_baltime[count] + dict_bal[key]
  117. else:
  118. dict_baltime[count] = dict_bal[key]
  119. else:
  120. pass
  121. count += 1
  122. x >>= 1 #右移一位
  123. dict_baltime=dict(sorted(dict_baltime.items(),key=lambda dict_baltime:dict_baltime[0]))
  124. for key in dict_baltime: #解析均衡的电芯编号
  125. if self.celltype==1: #科易6040
  126. if key<14:
  127. dict_baltime1[key]=dict_baltime[key]
  128. elif key<18:
  129. dict_baltime1[key-1]=dict_baltime[key]
  130. else:
  131. dict_baltime1[key-3]=dict_baltime[key]
  132. elif self.celltype==1: #科易4840
  133. if key<4:
  134. dict_baltime1[key-1]=dict_baltime[key]
  135. elif key<8:
  136. dict_baltime1[key-1]=dict_baltime[key]
  137. elif key<14:
  138. dict_baltime1[key-3]=dict_baltime[key]
  139. elif key<18:
  140. dict_baltime1[key-4]=dict_baltime[key]
  141. else:
  142. dict_baltime1[key-6]=dict_baltime[key]
  143. else:
  144. dict_baltime1=dict_baltime
  145. return dict_baltime1
  146. #三元电池的内短路电流计算...........................................................................................................................................................
  147. def _ncm_intershort(self):
  148. column_name=['time_st', 'time_sp', 'sn', 'method','short_current','baltime']
  149. df_res=pd.DataFrame(columns=column_name)
  150. if not self.df_bms.empty:
  151. if self.df_soh.empty:
  152. batsoh=self.df_bms.loc[0,'PackSOH']
  153. capacity=self.param.Capacity*batsoh/100
  154. else:
  155. batsoh=self.df_soh.loc[len(self.df_soh)-1,'soh']
  156. capacity=self.param.Capacity*batsoh/100
  157. standingtime=0
  158. standingtime1=0
  159. firsttime=1
  160. firsttime1=1
  161. dict_bal={}
  162. dict_bal1={}
  163. for i in range(2,len(self.df_bms)-2):
  164. if firsttime1==0: #满电静置算法--计算均衡状态对应的均衡时间
  165. try:
  166. balstat=int(self.df_bms.loc[i,'单体均衡状态'])
  167. if balstat>0.5:
  168. bal_step=(self.bmstime[i+1]-self.bmstime[i]).total_seconds() #均衡步长
  169. bal_step=int(bal_step)
  170. if str(balstat) in dict_bal1.keys():
  171. dict_bal1[str(balstat)]=dict_bal1[str(balstat)]+bal_step
  172. else:
  173. dict_bal1[str(balstat)]=bal_step
  174. else:
  175. pass
  176. except:
  177. dict_bal1={}
  178. else:
  179. pass
  180. if abs(self.packcrnt[i]) < 1 and abs(self.packcrnt[i-1]) < 1 and abs(self.packcrnt[i+1]) < 1:
  181. delttime=(self.bmstime[i]-self.bmstime[i-1]).total_seconds()
  182. standingtime=standingtime+delttime
  183. standingtime1=standingtime1+delttime
  184. self._celltemp_weight(i)
  185. #静置法计算内短路-开始.....................................................................................................................................
  186. if firsttime==1:
  187. if standingtime>self.StandardStandingTime*2: #静置时间满足要求
  188. standingtime=0
  189. cellvolt_now=self._cellvolt_get(i)
  190. cellvolt_min=min(cellvolt_now)
  191. cellvolt_max=max(cellvolt_now)
  192. cellvolt_last=self._cellvolt_get(i-1)
  193. deltvolt=max(abs(cellvolt_now-cellvolt_last))
  194. if 2<cellvolt_min<4.5 and 2<cellvolt_max<4.5 and deltvolt<0.003:
  195. dict_baltime=self._bal_time(dict_bal) #获取每个电芯的均衡时间
  196. deltsoc_last=self._celldeltsoc_get(i,dict_baltime,capacity)
  197. time_last=self.bmstime[i]
  198. firsttime=0
  199. else:
  200. pass
  201. elif standingtime>3600*5:
  202. standingtime=0
  203. cellvolt_now=self._cellvolt_get(i)
  204. cellvolt_min=min(cellvolt_now)
  205. cellvolt_max=max(cellvolt_now)
  206. cellvolt_last=self._cellvolt_get(i-1)
  207. deltvolt=max(abs(cellvolt_now-cellvolt_last))
  208. if 2<cellvolt_min<4.5 and 2<cellvolt_max<4.5 and deltvolt<0.005:
  209. dict_baltime=self._bal_time(dict_bal) #获取每个电芯的均衡时间
  210. deltsoc_now=self._celldeltsoc_get(i,dict_baltime,capacity)
  211. time_now=self.bmstime[i]
  212. list_sub=deltsoc_now-deltsoc_last
  213. list_pud=[0.01*capacity*3600*1000/(time_now-time_last).total_seconds()]*self.param.CellVoltNums
  214. leak_current=list_sub*list_pud
  215. # leak_current=np.array(leak_current)
  216. leak_current=np.round(leak_current,3)
  217. leak_current=list(leak_current)
  218. df_res.loc[len(df_res)]=[time_last,time_now,self.sn,1,str(leak_current),str(dict_baltime)] #计算结果存入Dataframe
  219. time_last=time_now #更新时间
  220. deltsoc_last=deltsoc_now #更新soc差
  221. dict_bal={}
  222. else:
  223. try:
  224. balstat=int(self.df_bms.loc[i,'单体均衡状态'])
  225. if balstat>0.5:
  226. bal_step=(self.bmstime[i+1]-self.bmstime[i]).total_seconds() #均衡步长
  227. bal_step=int(bal_step)
  228. if str(balstat) in dict_bal.keys():
  229. dict_bal[str(balstat)]=dict_bal[str(balstat)]+bal_step
  230. else:
  231. dict_bal[str(balstat)]=bal_step
  232. else:
  233. pass
  234. except:
  235. dict_bal={}
  236. #满电静置法计算内短路-开始.....................................................................................................................................................
  237. if standingtime1>self.StandardStandingTime and abs(self.packcrnt[i+2]) >= 1:
  238. standingtime1=0
  239. cellvolt_now1=self._cellvolt_get(i)
  240. cellvolt_max1=max(cellvolt_now1)
  241. cellvolt_min1=min(cellvolt_now1)
  242. cellvolt_last1=self._cellvolt_get(i-1)
  243. deltvolt1=max(abs(cellvolt_now1-cellvolt_last1))
  244. cellsoc_now1=np.interp(cellvolt_max1,self.param.LookTab_OCV,self.param.LookTab_SOC)
  245. if cellsoc_now1>=self.param.FullChrgSoc-50 and 2<cellvolt_min1<4.5 and 2<cellvolt_max1<4.5 and deltvolt1<0.005:
  246. if firsttime1==1:
  247. dict_baltime1=self._bal_time(dict_bal1) #获取每个电芯的均衡时间
  248. deltsoc_last1=self._celldeltsoc_get(i,dict_baltime1,capacity)
  249. time_last1=self.bmstime[i]
  250. firsttime1=0
  251. else:
  252. dict_baltime1=self._bal_time(dict_bal1) #获取每个电芯的均衡时间
  253. time_now1=self.bmstime[i]
  254. if (time_now1-time_last1).total_seconds()>3600*12:
  255. deltsoc_now1=self._celldeltsoc_get(i,dict_baltime1,capacity)
  256. list_sub1=deltsoc_now1-deltsoc_last1
  257. list_pud1=[0.01*capacity*3600*1000/(time_now1-time_last1).total_seconds()]*self.param.CellVoltNums
  258. leak_current1=list_sub1*list_pud1
  259. # leak_current1=np.array(leak_current1)
  260. leak_current1=np.round(leak_current1,3)
  261. leak_current1=list(leak_current1)
  262. df_res.loc[len(df_res)]=[time_last1,time_now1,self.sn,2,str(leak_current1),str(dict_baltime1)] #计算结果存入Dataframe
  263. time_last1=time_now1 #更新时间
  264. deltsoc_last1=deltsoc_now1 #更新soc差
  265. dict_bal1={}
  266. else:
  267. pass
  268. else:
  269. pass
  270. else:
  271. pass
  272. else:
  273. dict_bal={}
  274. firsttime=1
  275. standingtime=0
  276. standingtime1=0
  277. pass
  278. if df_res.empty: #返回计算结果
  279. return pd.DataFrame()
  280. else:
  281. return df_res
  282. #磷酸铁锂电池内短路计算程序.............................................................................................................................
  283. def _lfp_intershort(self):
  284. column_name=['time_st', 'time_sp', 'sn', 'method','short_current','baltime']
  285. df_res=pd.DataFrame(columns=column_name)
  286. if not self.df_bms.empty:
  287. if self.df_soh.empty:
  288. batsoh=self.df_bms.loc[0,'PackSOH']
  289. capacity=self.param.Capacity*batsoh/100
  290. else:
  291. batsoh=self.df_soh.loc[len(self.df_soh)-1,'soh']
  292. capacity=self.param.Capacity*batsoh/100
  293. standingtime=0
  294. standingtime1=0
  295. firsttime=1
  296. firsttime1=1
  297. dict_bal={}
  298. dict_bal1={}
  299. chrg_start=[]
  300. chrg_end=[]
  301. dict_bal_list=[]
  302. charging=0
  303. dict_bal3={}
  304. for i in range(3,len(self.df_bms)-3):
  305. #静置法计算内短路..........................................................................................................................
  306. if firsttime1==0: #满电静置算法--计算均衡状态对应的均衡时间
  307. try:
  308. balstat=int(self.df_bms.loc[i,'单体均衡状态'])
  309. if balstat>0.5:
  310. bal_step=(self.bmstime[i+1]-self.bmstime[i]).total_seconds() #均衡步长
  311. bal_step=int(bal_step)
  312. if str(balstat) in dict_bal1.keys():
  313. dict_bal1[str(balstat)]=dict_bal1[str(balstat)]+bal_step
  314. else:
  315. dict_bal1[str(balstat)]=bal_step
  316. else:
  317. pass
  318. except:
  319. dict_bal1={}
  320. else:
  321. pass
  322. if abs(self.packcrnt[i]) < 0.1 and abs(self.packcrnt[i-1]) < 0.1 and abs(self.packcrnt[i+1]) < 0.1:
  323. delttime=(self.bmstime[i]-self.bmstime[i-1]).total_seconds()
  324. standingtime=standingtime+delttime
  325. standingtime1=standingtime1+delttime
  326. self._celltemp_weight(i)
  327. #静置法计算内短路-开始.....................................................................................................................................
  328. if firsttime==1:
  329. if standingtime>self.StandardStandingTime: #静置时间满足要求
  330. standingtime=0
  331. cellvolt_now=self._cellvolt_get(i)
  332. cellvolt_min=min(cellvolt_now)
  333. cellvolt_max=max(cellvolt_now)
  334. cellvolt_last=self._cellvolt_get(i-1)
  335. deltvolt=max(abs(cellvolt_now-cellvolt_last))
  336. if 2<cellvolt_max<self.param.OcvInflexionBelow-0.002 and 2<cellvolt_min<4.5 and abs(deltvolt)<0.003:
  337. dict_baltime=self._bal_time(dict_bal) #获取每个电芯的均衡时间
  338. deltsoc_last=self._celldeltsoc_get(i,dict_baltime,capacity)
  339. time_last=self.bmstime[i]
  340. firsttime=0
  341. else:
  342. pass
  343. else:
  344. pass
  345. elif standingtime>3600*12:
  346. standingtime=0
  347. cellvolt_now=np.array(self._cellvolt_get(i))
  348. cellvolt_min=min(cellvolt_now)
  349. cellvolt_max=max(cellvolt_now)
  350. cellvolt_last=np.array(self._cellvolt_get(i-1))
  351. deltvolt=max(abs(cellvolt_now-cellvolt_last))
  352. if 2<cellvolt_max<self.param.OcvInflexionBelow-0.002 and 2<cellvolt_min<4.5 and abs(deltvolt)<0.003:
  353. dict_baltime=self._bal_time(dict_bal) #获取每个电芯的均衡时间
  354. deltsoc_now=self._celldeltsoc_get(i, dict_baltime,capacity) #获取每个电芯的SOC差
  355. time_now=self.bmstime[i]
  356. list_sub=deltsoc_now-deltsoc_last
  357. list_pud=[0.01*capacity*3600*1000/(time_now-time_last).total_seconds()]*self.param.CellVoltNums
  358. leak_current=list_sub*list_pud
  359. # leak_current=np.array(leak_current)
  360. leak_current=np.round(leak_current,3)
  361. leak_current=list(leak_current)
  362. df_res.loc[len(df_res)]=[time_last,time_now,self.sn,1,str(leak_current),str(dict_baltime)] #计算结果存入Dataframe
  363. time_last=time_now #更新时间
  364. deltsoc_last=deltsoc_now #更新soc差
  365. dict_bal={}
  366. else:
  367. pass
  368. else:
  369. try:
  370. balstat=int(self.df_bms.loc[i,'单体均衡状态'])
  371. if balstat>0.5:
  372. bal_step=(self.bmstime[i+1]-self.bmstime[i]).total_seconds() #均衡步长
  373. bal_step=int(bal_step)
  374. if str(balstat) in dict_bal.keys():
  375. dict_bal[str(balstat)]=dict_bal[str(balstat)]+bal_step
  376. else:
  377. dict_bal[str(balstat)]=bal_step
  378. else:
  379. pass
  380. except:
  381. dict_bal={}
  382. #非平台区间静置法计算内短路-开始.....................................................................................................................................................
  383. if standingtime1>self.StandardStandingTime:
  384. standingtime1=0
  385. cellvolt_now1=self._cellvolt_get(i)
  386. cellvolt_max1=max(cellvolt_now1)
  387. cellvolt_min1=min(cellvolt_now1)
  388. cellvolt_last1=self._cellvolt_get(i-1)
  389. deltvolt1=max(abs(cellvolt_now1-cellvolt_last1))
  390. if 2<cellvolt_max1<self.param.OcvInflexionBelow-0.002 and 2<cellvolt_min1<4.5 and deltvolt1<0.003:
  391. if firsttime1==1:
  392. dict_baltime1=self._bal_time(dict_bal1) #获取每个电芯的均衡时间
  393. deltsoc_last1=self._celldeltsoc_get(i,dict_baltime1,capacity)
  394. time_last1=self.bmstime[i]
  395. firsttime1=0
  396. else:
  397. dict_baltime1=self._bal_time(dict_bal1) #获取每个电芯的均衡时间
  398. deltsoc_now1=self._celldeltsoc_get(i,dict_baltime1,capacity)
  399. time_now1=self.bmstime[i]
  400. time_now1=self.bmstime[i]
  401. if abs(max(deltsoc_now1)-max(deltsoc_last1))<10 and (time_now1-time_last1).total_seconds()>3600*24:
  402. list_sub1=deltsoc_now1-deltsoc_last1
  403. list_pud1=[0.01*capacity*3600*1000/(time_now1-time_last1).total_seconds()]*self.param.CellVoltNums
  404. leak_current1=list_sub1*list_pud1
  405. # leak_current1=np.array(leak_current1)
  406. leak_current1=np.round(leak_current1,3)
  407. leak_current1=list(leak_current1)
  408. df_res.loc[len(df_res)]=[time_last1,time_now1,self.sn,2,str(leak_current1),str(dict_baltime1)] #计算结果存入Dataframe
  409. time_last1=time_now1 #更新时间
  410. deltsoc_last1=deltsoc_now1 #更新soc差
  411. dict_bal1={}
  412. else:
  413. pass
  414. else:
  415. pass
  416. else:
  417. pass
  418. else:
  419. dict_bal={}
  420. firsttime=1
  421. standingtime=0
  422. standingtime1=0
  423. pass
  424. #获取充电数据——开始..............................................................................................................
  425. try:
  426. balstat=int(self.df_bms.loc[i,'单体均衡状态']) #统计均衡状态
  427. if balstat>0.5:
  428. bal_step=(self.bmstime[i+1]-self.bmstime[i]).total_seconds() #均衡步长
  429. bal_step=int(bal_step)
  430. if str(balstat) in dict_bal3.keys():
  431. dict_bal3[str(balstat)]=dict_bal3[str(balstat)]+bal_step
  432. else:
  433. dict_bal3[str(balstat)]=bal_step
  434. else:
  435. pass
  436. except:
  437. dict_bal3={}
  438. if charging==0:
  439. if self.packcrnt[i]<=-1 and self.packcrnt[i+1]<=-1 and self.packcrnt[i+2]<=-1 and self.bms_soc[i]<40: #判断充电开始
  440. cellvolt_now=self._cellvolt_get(i)
  441. if min(cellvolt_now)<self.param.CellFullChrgVolt-0.15:
  442. charging=1
  443. if len(chrg_start)>len(chrg_end):
  444. chrg_start[-1]=i
  445. else:
  446. chrg_start.append(i)
  447. else:
  448. pass
  449. else:
  450. pass
  451. else: #充电中
  452. if (self.bmstime[i+1]-self.bmstime[i]).total_seconds()>180 or (self.packcrnt[i]>self.param.Capacity/3 and self.packcrnt[i+1]>self.param.Capacity/3): #如果充电过程中时间间隔>180s,则舍弃该次充电
  453. chrg_start.remove(chrg_start[-1])
  454. charging=0
  455. continue
  456. elif self.packcrnt[i]<=-1 and self.packcrnt[i+1]<=-1 and self.packcrnt[i+2]<-1:
  457. cellvolt_now=self._cellvolt_get(i)
  458. if min(cellvolt_now)>self.param.CellFullChrgVolt-0.11: #电压>满充电压-0.13V,即3.37V
  459. self._celltemp_weight(i)
  460. if i-chrg_start[-1]>10 and self.celltemp>10:
  461. chrg_end.append(i+1)
  462. dict_bal_list.append(dict_bal3)
  463. dict_bal3={}
  464. charging=0
  465. continue
  466. else:
  467. chrg_start.remove(chrg_start[-1])
  468. charging=0
  469. continue
  470. else:
  471. pass
  472. else:
  473. pass
  474. #基于充电数据计算单体电芯的漏电流..........................................................................................................
  475. if len(chrg_end)>1:
  476. for i in range(len(chrg_end)):
  477. if i<1:
  478. dict_baltime={}
  479. deltAs_last=self._cellDeltAs_get(chrg_start[i],chrg_end[i],dict_baltime)
  480. time_last=self.bmstime[chrg_end[i]]
  481. else:
  482. dict_baltime=self._bal_time(dict_bal_list[i]) #获取每个电芯的均衡时间
  483. deltAs_now=self._cellDeltAs_get(chrg_start[i],chrg_end[i],dict_baltime) #获取每个电芯的As差
  484. time_now=self.bmstime[chrg_end[i]]
  485. list_sub=deltAs_now-deltAs_last
  486. list_pud=[-1000/(time_now-time_last).total_seconds()]*self.param.CellVoltNums
  487. leak_current=list_sub*list_pud
  488. # leak_current=np.array(leak_current)
  489. leak_current=np.round(leak_current,3)
  490. leak_current=list(leak_current)
  491. df_res.loc[len(df_res)]=[time_last,time_now,self.sn,3,str(leak_current),str(dict_baltime)] #计算结果存入Dataframe
  492. deltAs_last=deltAs_now
  493. time_last=time_now
  494. else:
  495. pass
  496. if df_res.empty:
  497. return pd.DataFrame()
  498. else:
  499. return df_res