|
@@ -40,33 +40,34 @@ class BatUniform:
|
|
|
s = str(j)
|
|
|
celltemp.append(self.df_bms.loc[num,'单体温度' + s])
|
|
|
celltemp.remove(min(celltemp))
|
|
|
+ self.celltemp=celltemp
|
|
|
if self.celltype==99:
|
|
|
if min(celltemp)>=20:
|
|
|
self.tempweight=1
|
|
|
- self.StandardStandingTime=600
|
|
|
+ self.StandardStandingTime=1800
|
|
|
elif min(celltemp)>=10:
|
|
|
self.tempweight=0.6
|
|
|
- self.StandardStandingTime=900
|
|
|
+ self.StandardStandingTime=3600
|
|
|
elif min(celltemp)>=5:
|
|
|
self.tempweight=0.
|
|
|
- self.StandardStandingTime=1800
|
|
|
+ self.StandardStandingTime=3600
|
|
|
else:
|
|
|
self.tempweight=0.1
|
|
|
- self.StandardStandingTime=3600
|
|
|
+ self.StandardStandingTime=7200
|
|
|
else:
|
|
|
if min(celltemp)>=20:
|
|
|
self.tempweight=1
|
|
|
- self.StandardStandingTime=300
|
|
|
+ self.StandardStandingTime=1200
|
|
|
elif min(celltemp)>=10:
|
|
|
self.tempweight=0.8
|
|
|
- self.StandardStandingTime=600
|
|
|
+ self.StandardStandingTime=1800
|
|
|
elif min(celltemp)>=5:
|
|
|
self.tempweight=0.6
|
|
|
- self.StandardStandingTime=1800
|
|
|
+ self.StandardStandingTime=3600
|
|
|
else:
|
|
|
self.tempweight=0.2
|
|
|
- self.StandardStandingTime=3600
|
|
|
-
|
|
|
+ self.StandardStandingTime=7200
|
|
|
+
|
|
|
#获取当前行所有电压数据............................................................................................................................
|
|
|
def _cellvolt_get(self,num):
|
|
|
cellvolt=[]
|
|
@@ -76,11 +77,11 @@ class BatUniform:
|
|
|
return(cellvolt)
|
|
|
|
|
|
#寻找DVDQ的峰值点,并返回..........................................................................................................................
|
|
|
- def _dvdq_peak(self, time, soc, cellvolt, packcrnt):
|
|
|
- cellvolt1 = self._np_move_avg(cellvolt, 5, mode="same")
|
|
|
+ def _dvdq_peak(self, time, soc, cellvolt, packcrnt):
|
|
|
+ cellvolt = self._np_move_avg(cellvolt, 3, mode="same")
|
|
|
Soc = 0
|
|
|
Ah = 0
|
|
|
- Volt = cellvolt1[0]
|
|
|
+ Volt = cellvolt[0]
|
|
|
DV_Volt = []
|
|
|
DQ_Ah = []
|
|
|
DVDQ = []
|
|
@@ -93,11 +94,11 @@ class BatUniform:
|
|
|
Step = (time[m] - time[m - 1]).total_seconds()
|
|
|
Soc = Soc - packcrnt[m] * Step * 100 / (3600 * self.param.Capacity)
|
|
|
Ah = Ah - packcrnt[m] * Step / 3600
|
|
|
- if (cellvolt[m]-Volt)>0.99 and Ah>0:
|
|
|
+ if (cellvolt[m]-Volt)>0.0019 and Ah>0:
|
|
|
DQ_Ah.append(Ah)
|
|
|
DV_Volt.append(cellvolt[m]-Volt)
|
|
|
DVDQ.append((DV_Volt[-1])/DQ_Ah[-1])
|
|
|
- xvolt.append(cellvolt[m]/1000)
|
|
|
+ xvolt.append(cellvolt[m])
|
|
|
Volt=cellvolt[m]
|
|
|
Ah = 0
|
|
|
soc1.append(Soc)
|
|
@@ -113,20 +114,18 @@ class BatUniform:
|
|
|
'DV_Volt':DV_Volt,
|
|
|
'XVOLT':xvolt})
|
|
|
start_time=df_Data1.loc[0,'time']
|
|
|
- start_time=start_time+datetime.timedelta(seconds=600)
|
|
|
+ start_time=start_time+datetime.timedelta(seconds=900)
|
|
|
end_time=df_Data1.loc[len(time1)-1,'time']
|
|
|
end_time=end_time-datetime.timedelta(seconds=1200)
|
|
|
- if soc2[0]<40 and soc2[-1]>93:
|
|
|
- df_Data1=df_Data1[(df_Data1['SOC']>44) & (df_Data1['SOC']<90)]
|
|
|
- elif soc2[0]<40 and soc2[-1]<=93:
|
|
|
- df_Data1=df_Data1[(df_Data1['SOC']>44) & (df_Data1['time']<end_time)]
|
|
|
- elif soc2[0]>=40 and soc2[-1]>93:
|
|
|
- df_Data1=df_Data1[(df_Data1['time']>start_time) & (df_Data1['SOC']<90)]
|
|
|
+ if soc2[0]<36:
|
|
|
+ df_Data1=df_Data1[(df_Data1['SOC']>39.5) & (df_Data1['SOC']<80)]
|
|
|
else:
|
|
|
- df_Data1=df_Data1[(df_Data1['time']>start_time) & (df_Data1['time']<end_time)]
|
|
|
+ df_Data1=df_Data1[(df_Data1['time']>start_time) & (df_Data1['SOC']<80)]
|
|
|
+ df_Data1=df_Data1[(df_Data1['XVOLT']>self.param.PeakVoltLowLmt) & (df_Data1['XVOLT']<self.param.PeakVoltUpLmt)]
|
|
|
|
|
|
+ # print(packcrnt[int(len(time)/2)], min(self.celltemp))
|
|
|
# ax1 = plt.subplot(3, 1, 1)
|
|
|
- # plt.plot(df_Data1['XVOLT'],df_Data1['DVDQ'],'r*-')
|
|
|
+ # plt.plot(df_Data1['XVOLT'],df_Data1['DVDQ'],'g*-')
|
|
|
# plt.xlabel('Volt/V')
|
|
|
# plt.ylabel('DV/DQ')
|
|
|
# plt.legend()
|
|
@@ -140,18 +139,18 @@ class BatUniform:
|
|
|
# plt.xlabel('SOC/%')
|
|
|
# plt.ylabel('DV/DQ')
|
|
|
# plt.legend()
|
|
|
- # plt.show()
|
|
|
+ # # plt.show()
|
|
|
|
|
|
if len(df_Data1)>2: #寻找峰值点,且峰值点个数>2
|
|
|
PeakIndex = df_Data1['DVDQ'].idxmax()
|
|
|
df_Data2 = df_Data1[(df_Data1['SOC'] > (df_Data1['SOC'][PeakIndex] - 0.5)) & (df_Data1['SOC'] < (df_Data1['SOC'][PeakIndex] + 0.5))]
|
|
|
- if len(df_Data2) > 2:
|
|
|
+ if len(df_Data2) > 1 and df_Data1.loc[PeakIndex,'XVOLT']<self.param.PeakVoltUpLmt-0.015:
|
|
|
return df_Data1['AhSoc'][PeakIndex]
|
|
|
else:
|
|
|
df_Data1 = df_Data1.drop([PeakIndex])
|
|
|
PeakIndex = df_Data1['DVDQ'].idxmax()
|
|
|
df_Data2 = df_Data1[(df_Data1['SOC'] > (df_Data1['SOC'][PeakIndex] - 0.5)) & (df_Data1['SOC'] < (df_Data1['SOC'][PeakIndex] + 0.5))]
|
|
|
- if len(df_Data2) > 2:
|
|
|
+ if len(df_Data2) > 1 and df_Data1.loc[PeakIndex,'XVOLT']<self.param.PeakVoltUpLmt-0.015:
|
|
|
return df_Data1['AhSoc'][PeakIndex]
|
|
|
else:
|
|
|
return 0
|
|
@@ -177,43 +176,46 @@ class BatUniform:
|
|
|
cellvolt_now=self._cellvolt_get(i) #获取当前行电压数据
|
|
|
cellvolt_min=min(cellvolt_now)
|
|
|
cellvolt_max=max(cellvolt_now)
|
|
|
- cellmin_num=cellvolt_now.index(cellvolt_min)+1
|
|
|
- cellmax_num=cellvolt_now.index(cellvolt_max)+1
|
|
|
- cellsoc_min=np.interp(cellvolt_min,self.param.LookTab_OCV,self.param.LookTab_SOC)
|
|
|
- cellsoc_max=np.interp(cellvolt_max,self.param.LookTab_OCV,self.param.LookTab_SOC)
|
|
|
- cellvolt_diff=(cellvolt_max-cellvolt_min)*1000
|
|
|
- cellsoc_diff=cellsoc_max-cellsoc_min
|
|
|
- cellsoc_diff=eval(format(cellsoc_diff,'.1f'))
|
|
|
- cellvolt_diff=eval(format(cellvolt_diff,'.0f'))
|
|
|
- df_res.loc[len(df_res)]=[self.bmstime[i], self.sn, cellsoc_diff, cellvolt_diff, cellmin_num, cellmax_num]
|
|
|
+ if 3<cellvolt_min<4.5 and 3<cellvolt_max<4.5:
|
|
|
+ cellmin_num=cellvolt_now.index(cellvolt_min)+1
|
|
|
+ cellmax_num=cellvolt_now.index(cellvolt_max)+1
|
|
|
+ cellsoc_min=np.interp(cellvolt_min,self.param.LookTab_OCV,self.param.LookTab_SOC)
|
|
|
+ cellsoc_max=np.interp(cellvolt_max,self.param.LookTab_OCV,self.param.LookTab_SOC)
|
|
|
+ cellvolt_diff=(cellvolt_max-cellvolt_min)*1000
|
|
|
+ cellsoc_diff=cellsoc_max-cellsoc_min
|
|
|
+ cellsoc_diff=eval(format(cellsoc_diff,'.1f'))
|
|
|
+ cellvolt_diff=eval(format(cellvolt_diff,'.0f'))
|
|
|
+ df_res.loc[len(df_res)]=[self.bmstime[i], self.sn, cellsoc_diff, cellvolt_diff, cellmin_num, cellmax_num]
|
|
|
elif standingtime>3600*12:
|
|
|
standingtime=0
|
|
|
cellvolt_now=self._cellvolt_get(i) #获取当前行电压数据
|
|
|
cellvolt_min=min(cellvolt_now)
|
|
|
cellvolt_max=max(cellvolt_now)
|
|
|
- cellmin_num=cellvolt_now.index(cellvolt_min)+1
|
|
|
- cellmax_num=cellvolt_now.index(cellvolt_max)+1
|
|
|
- cellsoc_min=np.interp(cellvolt_min,self.param.LookTab_OCV,self.param.LookTab_SOC)
|
|
|
- cellsoc_max=np.interp(cellvolt_max,self.param.LookTab_OCV,self.param.LookTab_SOC)
|
|
|
- cellvolt_diff=(cellvolt_max-cellvolt_min)*1000
|
|
|
- cellsoc_diff=cellsoc_max-cellsoc_min
|
|
|
- cellsoc_diff=eval(format(cellsoc_diff,'.1f'))
|
|
|
- cellvolt_diff=eval(format(cellvolt_diff,'.0f'))
|
|
|
- df_res.loc[len(df_res)]=[self.bmstime[i], self.sn, cellsoc_diff, cellvolt_diff, cellmin_num, cellmax_num]
|
|
|
+ if 3<cellvolt_min<4.5 and 3<cellvolt_max<4.5:
|
|
|
+ cellmin_num=cellvolt_now.index(cellvolt_min)+1
|
|
|
+ cellmax_num=cellvolt_now.index(cellvolt_max)+1
|
|
|
+ cellsoc_min=np.interp(cellvolt_min,self.param.LookTab_OCV,self.param.LookTab_SOC)
|
|
|
+ cellsoc_max=np.interp(cellvolt_max,self.param.LookTab_OCV,self.param.LookTab_SOC)
|
|
|
+ cellvolt_diff=(cellvolt_max-cellvolt_min)*1000
|
|
|
+ cellsoc_diff=cellsoc_max-cellsoc_min
|
|
|
+ cellsoc_diff=eval(format(cellsoc_diff,'.1f'))
|
|
|
+ cellvolt_diff=eval(format(cellvolt_diff,'.0f'))
|
|
|
+ df_res.loc[len(df_res)]=[self.bmstime[i], self.sn, cellsoc_diff, cellvolt_diff, cellmin_num, cellmax_num]
|
|
|
elif i>=len(self.df_bms)-4:
|
|
|
standingtime=0
|
|
|
cellvolt_now=self._cellvolt_get(i) #获取当前行电压数据
|
|
|
cellvolt_min=min(cellvolt_now)
|
|
|
cellvolt_max=max(cellvolt_now)
|
|
|
- cellmin_num=cellvolt_now.index(cellvolt_min)+1
|
|
|
- cellmax_num=cellvolt_now.index(cellvolt_max)+1
|
|
|
- cellsoc_min=np.interp(cellvolt_min,self.param.LookTab_OCV,self.param.LookTab_SOC)
|
|
|
- cellsoc_max=np.interp(cellvolt_max,self.param.LookTab_OCV,self.param.LookTab_SOC)
|
|
|
- cellvolt_diff=(cellvolt_max-cellvolt_min)*1000
|
|
|
- cellsoc_diff=cellsoc_max-cellsoc_min
|
|
|
- cellsoc_diff=eval(format(cellsoc_diff,'.1f'))
|
|
|
- cellvolt_diff=eval(format(cellvolt_diff,'.0f'))
|
|
|
- df_res.loc[len(df_res)]=[self.bmstime[i], self.sn, cellsoc_diff, cellvolt_diff, cellmin_num, cellmax_num]
|
|
|
+ if 3<cellvolt_min<4.5 and 3<cellvolt_max<4.5:
|
|
|
+ cellmin_num=cellvolt_now.index(cellvolt_min)+1
|
|
|
+ cellmax_num=cellvolt_now.index(cellvolt_max)+1
|
|
|
+ cellsoc_min=np.interp(cellvolt_min,self.param.LookTab_OCV,self.param.LookTab_SOC)
|
|
|
+ cellsoc_max=np.interp(cellvolt_max,self.param.LookTab_OCV,self.param.LookTab_SOC)
|
|
|
+ cellvolt_diff=(cellvolt_max-cellvolt_min)*1000
|
|
|
+ cellsoc_diff=cellsoc_max-cellsoc_min
|
|
|
+ cellsoc_diff=eval(format(cellsoc_diff,'.1f'))
|
|
|
+ cellvolt_diff=eval(format(cellvolt_diff,'.0f'))
|
|
|
+ df_res.loc[len(df_res)]=[self.bmstime[i], self.sn, cellsoc_diff, cellvolt_diff, cellmin_num, cellmax_num]
|
|
|
break
|
|
|
else:
|
|
|
continue
|
|
@@ -249,28 +251,30 @@ class BatUniform:
|
|
|
cellvolt_now=self._cellvolt_get(i) #获取当前行电压数据
|
|
|
cellvolt_min=min(cellvolt_now)
|
|
|
cellvolt_max=max(cellvolt_now)
|
|
|
- if abs(self.packcrnt[i+2]) >= 0.1 and cellvolt_max < self.param.OcvInflexionBelow:
|
|
|
- standingtime=0
|
|
|
- cellmin_num=cellvolt_now.index(cellvolt_min)+1
|
|
|
- cellmax_num=cellvolt_now.index(cellvolt_max)+1
|
|
|
- cellsoc_min=np.interp(cellvolt_min,self.param.LookTab_OCV,self.param.LookTab_SOC)
|
|
|
- cellsoc_max=np.interp(cellvolt_max,self.param.LookTab_OCV,self.param.LookTab_SOC)
|
|
|
- cellvolt_diff=(cellvolt_max-cellvolt_min)*1000
|
|
|
- cellsoc_diff=cellsoc_max-cellsoc_min
|
|
|
- cellsoc_diff=eval(format(cellsoc_diff,'.1f'))
|
|
|
- cellvolt_diff=eval(format(cellvolt_diff,'.0f'))
|
|
|
- df_res.loc[len(df_res)]=[self.bmstime[i], self.sn, cellsoc_diff, cellvolt_diff, cellmin_num, cellmax_num]
|
|
|
- elif i>=len(self.df_bms)-4 and cellvolt_max < self.param.OcvInflexionBelow:
|
|
|
+ if abs(self.packcrnt[i+2]) >= 0.1:
|
|
|
+ standingtime=0
|
|
|
+ if 2 < cellvolt_max < self.param.OcvInflexionBelow:
|
|
|
+ cellmin_num=cellvolt_now.index(cellvolt_min)+1
|
|
|
+ cellmax_num=cellvolt_now.index(cellvolt_max)+1
|
|
|
+ cellsoc_min=np.interp(cellvolt_min,self.param.LookTab_OCV,self.param.LookTab_SOC)
|
|
|
+ cellsoc_max=np.interp(cellvolt_max,self.param.LookTab_OCV,self.param.LookTab_SOC)
|
|
|
+ cellvolt_diff=(cellvolt_max-cellvolt_min)*1000
|
|
|
+ cellsoc_diff=cellsoc_max-cellsoc_min
|
|
|
+ cellsoc_diff=eval(format(cellsoc_diff,'.1f'))
|
|
|
+ cellvolt_diff=eval(format(cellvolt_diff,'.0f'))
|
|
|
+ df_res.loc[len(df_res)]=[self.bmstime[i], self.sn, cellsoc_diff, cellvolt_diff, cellmin_num, cellmax_num]
|
|
|
+ elif i>=len(self.df_bms)-4:
|
|
|
standingtime=0
|
|
|
- cellmin_num=cellvolt_now.index(cellvolt_min)+1
|
|
|
- cellmax_num=cellvolt_now.index(cellvolt_max)+1
|
|
|
- cellsoc_min=np.interp(cellvolt_min,self.param.LookTab_OCV,self.param.LookTab_SOC)
|
|
|
- cellsoc_max=np.interp(cellvolt_max,self.param.LookTab_OCV,self.param.LookTab_SOC)
|
|
|
- cellvolt_diff=(cellvolt_max-cellvolt_min)*1000
|
|
|
- cellsoc_diff=cellsoc_max-cellsoc_min
|
|
|
- cellsoc_diff=eval(format(cellsoc_diff,'.1f'))
|
|
|
- cellvolt_diff=eval(format(cellvolt_diff,'.0f'))
|
|
|
- df_res.loc[len(df_res)]=[self.bmstime[i], self.sn, cellsoc_diff, cellvolt_diff, cellmin_num, cellmax_num]
|
|
|
+ if 2 < cellvolt_max < self.param.OcvInflexionBelow:
|
|
|
+ cellmin_num=cellvolt_now.index(cellvolt_min)+1
|
|
|
+ cellmax_num=cellvolt_now.index(cellvolt_max)+1
|
|
|
+ cellsoc_min=np.interp(cellvolt_min,self.param.LookTab_OCV,self.param.LookTab_SOC)
|
|
|
+ cellsoc_max=np.interp(cellvolt_max,self.param.LookTab_OCV,self.param.LookTab_SOC)
|
|
|
+ cellvolt_diff=(cellvolt_max-cellvolt_min)*1000
|
|
|
+ cellsoc_diff=cellsoc_max-cellsoc_min
|
|
|
+ cellsoc_diff=eval(format(cellsoc_diff,'.1f'))
|
|
|
+ cellvolt_diff=eval(format(cellvolt_diff,'.0f'))
|
|
|
+ df_res.loc[len(df_res)]=[self.bmstime[i], self.sn, cellsoc_diff, cellvolt_diff, cellmin_num, cellmax_num]
|
|
|
else:
|
|
|
pass
|
|
|
else:
|
|
@@ -281,7 +285,7 @@ class BatUniform:
|
|
|
|
|
|
#获取DVDQ算法所需数据——开始............................................................................................................
|
|
|
if charging==0: #判断充电开始
|
|
|
- if self.packcrnt[i]<=-1 and self.packcrnt[i+1]<=-1 and self.packcrnt[i+2]<=-1 and self.bms_soc[i]<45: #充电开始
|
|
|
+ if self.packcrnt[i]<=-1 and self.packcrnt[i+1]<=-1 and self.packcrnt[i+2]<=-1 and self.bms_soc[i]<40: #充电开始
|
|
|
charging=1
|
|
|
if len(chrg_start)>len(chrg_end):
|
|
|
chrg_start[-1]=i
|
|
@@ -331,26 +335,31 @@ class BatUniform:
|
|
|
peaksoc_list=[]
|
|
|
for i in range(len(chrg_end)):
|
|
|
peaksoc_list = []
|
|
|
- for j in range(1, self.param.CellVoltNums + 1):
|
|
|
- s = str(j)
|
|
|
- cellvolt = self.df_bms['单体电压' + s]
|
|
|
- cellvolt = list(cellvolt[chrg_start[i]:chrg_end[i]])
|
|
|
- time = list(self.bmstime[chrg_start[i]:chrg_end[i]])
|
|
|
- packcrnt = list(self.packcrnt[chrg_start[i]:chrg_end[i]])
|
|
|
- soc = list(self.bms_soc[chrg_start[i]:chrg_end[i]])
|
|
|
- peaksoc = self._dvdq_peak(time, soc, cellvolt, packcrnt)
|
|
|
- if peaksoc>1:
|
|
|
- peaksoc_list.append(peaksoc) #计算到达峰值点的累计Soc
|
|
|
+ self._celltemp_weight(chrg_start[i])
|
|
|
+ if min(self.celltemp)>10:
|
|
|
+ for j in range(1, self.param.CellVoltNums + 1):
|
|
|
+ s = str(j)
|
|
|
+ cellvolt = self.df_bms['单体电压' + s]/1000
|
|
|
+ cellvolt = list(cellvolt[chrg_start[i]:chrg_end[i]])
|
|
|
+ time = list(self.bmstime[chrg_start[i]:chrg_end[i]])
|
|
|
+ packcrnt = list(self.packcrnt[chrg_start[i]:chrg_end[i]])
|
|
|
+ soc = list(self.bms_soc[chrg_start[i]:chrg_end[i]])
|
|
|
+ peaksoc = self._dvdq_peak(time, soc, cellvolt, packcrnt)
|
|
|
+ if peaksoc>1:
|
|
|
+ peaksoc_list.append(peaksoc) #计算到达峰值点的累计Soc
|
|
|
+ else:
|
|
|
+ pass
|
|
|
+ if len(peaksoc_list)>self.param.CellVoltNums/2:
|
|
|
+ peaksoc_max=max(peaksoc_list)
|
|
|
+ peaksoc_min=min(peaksoc_list)
|
|
|
+ peaksoc_maxnum=peaksoc_list.index(peaksoc_min)+1
|
|
|
+ peaksoc_minnum=peaksoc_list.index(peaksoc_max)+1
|
|
|
+ cellsoc_diff=peaksoc_max-peaksoc_min
|
|
|
+ cellsoc_diff=eval(format(cellsoc_diff,'.1f'))
|
|
|
+ df_res.loc[len(df_res)]=[self.bmstime[chrg_start[i]], self.sn, cellsoc_diff, 0, peaksoc_minnum, peaksoc_maxnum]
|
|
|
else:
|
|
|
pass
|
|
|
- if len(peaksoc_list)>11:
|
|
|
- peaksoc_max=max(peaksoc_list)
|
|
|
- peaksoc_min=min(peaksoc_list)
|
|
|
- peaksoc_maxnum=peaksoc_list.index(peaksoc_min)+1
|
|
|
- peaksoc_minnum=peaksoc_list.index(peaksoc_max)+1
|
|
|
- cellsoc_diff=peaksoc_max-peaksoc_min
|
|
|
- cellsoc_diff=eval(format(cellsoc_diff,'.1f'))
|
|
|
- df_res.loc[len(df_res)]=[self.bmstime[chrg_start[i]], self.sn, cellsoc_diff, 0, peaksoc_minnum, peaksoc_maxnum]
|
|
|
+ # plt.show()
|
|
|
else:
|
|
|
pass
|
|
|
|