qingfeng 2 vuotta sitten
vanhempi
commit
6eab039e21

+ 45 - 44
LIB/MIDDLE/CellStateEstimation/BatSafetyWarning/V1_0_1/CBMSBatInterShort.py

@@ -128,6 +128,7 @@ class BatInterShort():
         celldeltsoc=[]
         for j in range(self.param.CellVoltNums):   #获取每个电芯电压对应的SOC值
             cellvolt=cellvolt_list[j]
+            ocv_soc=np.interp(cellvolt,self.param.LookTab_OCV,self.param.LookTab_SOC)
             if j+1 in dict_baltime.keys():
                 ocv_soc=ocv_soc+dict_baltime[j+1]*self.param.BalCurrent/(capacity*3600)   #补偿均衡电流
             else:
@@ -213,9 +214,9 @@ class BatInterShort():
     #充电delt_volt获取.................................................................................
     def _deltvolt(self,chrg_start,chrg_end,voltmax_index):
         if self.celltype<50:
-            volt_list=[4.16, 4.18, 4.2]
+            volt_list=[4.10, 4.12, 4.14]
         else:
-            volt_list=[3.47, 3.49, 3.51]
+            volt_list=[3.50, 3.52, 3.54]
         deltvolt_list=[]
         packcrnt_mean_list=[]
         temp_mean_list=[]
@@ -601,58 +602,58 @@ class BatInterShort():
                     cellvolt_now=self._cellvolt_get(i)
                     if min(celltemp_now)>0 and max(cellvolt_now)<4:
                         charging=2
-                    if charging==2 and min(cellvolt_now)>3 and 4.1<max(cellvolt_now)<4.14:
+                    if charging==2 and min(cellvolt_now)>3 and 4.06<max(cellvolt_now)<4.12:
                         charging=1
                         chrg_start=i
                     else:
                         pass
 
             else: #充电中
-                cellvolt_now=self._cellvolt_get(i)
+                cellvolt_now=self._cellvolt_get(i-1)
                 #计算漏电流......................................................................
-                if max(cellvolt_now)>4.2 and self.packcrnt[i]>-0.1 and self.packcrnt[i+1]>-0.1:   #电压>93%对应的电压
-                    if i-chrg_start>10:
-                        chrg_end=i
-                        charging=0
+                if max(cellvolt_now)>4.1 and self.packcrnt[i]>-0.1 and self.packcrnt[i+1]>-0.1:   #电压>93%对应的电压
+                    # if (self.bmstime[i] - self.bmstime[chrg_start]).total_seconds()>300:
+                    chrg_end=i
+                    charging=0
 
-                        #计算漏电流值...................................................................
-                        if firsttime2==1:
-                            firsttime2=0
-                            voltmax_index=list(cellvolt_now).index(max(cellvolt_now))+1
-                            # cellvolt_max=(self.df_bms['单体电压'+str(voltmax_index)][chrg_start:chrg_end])/1000
-                            
-                            deltvolt_last2,packcrnt_mean_last,temp_mean_last=self._deltvolt(chrg_start,chrg_end,voltmax_index)  #获取deltAs
-                            
-                            time_last2=self.bmstime[chrg_end]
-                            df_ram_chrgvolt.loc[0]=[self.sn,time_last2,list(map(list,deltvolt_last2)),packcrnt_mean_last,temp_mean_last]    #更新RAM信息
-                        else:
-                            dict_baltime2={}
-                            time_now2=self.bmstime[chrg_end]
-                            voltmax_index=list(cellvolt_now).index(max(cellvolt_now))+1
-                            # cellvolt_max=(self.df_bms['单体电压'+str(voltmax_index)][chrg_start:chrg_end])/1000
-                            
-                            deltvolt_now2,packcrnt_mean_now,temp_mean_now=self._deltvolt(chrg_start,chrg_end,voltmax_index)
-                            leak_current2=[]
-                            for j in range(min(len(deltvolt_now2),len(deltvolt_last2))):
-                                if abs(packcrnt_mean_now[j]-packcrnt_mean_last[j])<10 and (abs(temp_mean_now[j]-temp_mean_last[j])<10 or (temp_mean_now[j]>20 and temp_mean_last[j]>20)) and (time_now2-time_last2).total_seconds()<14*24*3600:
-                                    list_sub2=(deltvolt_now2[j]-deltvolt_last2[j])*1000
-                                    list_sub2=np.round(list_sub2,1)
-                                    leak_current2.append(list(list_sub2))
-                                else:
-                                    break
-                            if len(leak_current2)>0:
-                                df_res.loc[len(df_res)]=[time_last2,time_now2,self.sn,4,str(leak_current2),str(dict_baltime2)]  #计算结果存入Dataframe
-                            time_last2=time_now2
-                            deltvolt_last2=deltvolt_now2
-                            packcrnt_mean_last=packcrnt_mean_now
-                            temp_mean_last=temp_mean_now
-                            dict_bal2={}
-                            df_ram_chrgvolt.loc[0]=[self.sn,time_last2,list(map(list,deltvolt_last2)),packcrnt_mean_last,temp_mean_last]    #更新RAM信息
-                    
+                    #计算漏电流值...................................................................
+                    if firsttime2==1:
+                        firsttime2=0
+                        voltmax_index=list(cellvolt_now).index(max(cellvolt_now))+1
+                        # cellvolt_max=(self.df_bms['单体电压'+str(voltmax_index)][chrg_start:chrg_end])/1000
+                        
+                        deltvolt_last2,packcrnt_mean_last,temp_mean_last=self._deltvolt(chrg_start,chrg_end,voltmax_index)  #获取deltAs
+                        
+                        time_last2=self.bmstime[chrg_end]
+                        df_ram_chrgvolt.loc[0]=[self.sn,time_last2,list(map(list,deltvolt_last2)),packcrnt_mean_last,temp_mean_last]    #更新RAM信息
                     else:
-                        charging=0
+                        dict_baltime2={}
+                        time_now2=self.bmstime[chrg_end]
+                        voltmax_index=list(cellvolt_now).index(max(cellvolt_now))+1
+                        # cellvolt_max=(self.df_bms['单体电压'+str(voltmax_index)][chrg_start:chrg_end])/1000
+                        
+                        deltvolt_now2,packcrnt_mean_now,temp_mean_now=self._deltvolt(chrg_start,chrg_end,voltmax_index)
+                        leak_current2=[]
+                        for j in range(min(len(deltvolt_now2),len(deltvolt_last2))):
+                            if abs(packcrnt_mean_now[j]-packcrnt_mean_last[j])<10 and (abs(temp_mean_now[j]-temp_mean_last[j])<10 or (temp_mean_now[j]>20 and temp_mean_last[j]>20)) and (time_now2-time_last2).total_seconds()<14*24*3600:
+                                list_sub2=(deltvolt_now2[j]-deltvolt_last2[j])*1000
+                                list_sub2=np.round(list_sub2,1)
+                                leak_current2.append(list(list_sub2))
+                            else:
+                                break
+                        if len(leak_current2)>0:
+                            df_res.loc[len(df_res)]=[time_last2,time_now2,self.sn,4,str(leak_current2),str(dict_baltime2)]  #计算结果存入Dataframe
+                        time_last2=time_now2
+                        deltvolt_last2=deltvolt_now2
+                        packcrnt_mean_last=packcrnt_mean_now
+                        temp_mean_last=temp_mean_now
+                        dict_bal2={}
+                        df_ram_chrgvolt.loc[0]=[self.sn,time_last2,list(map(list,deltvolt_last2)),packcrnt_mean_last,temp_mean_last]    #更新RAM信息
+                    
+                    # else:
+                    #     charging=0
                 
-                elif self.packcrnt[i]>-0.1 and self.packcrnt[i-1]>-0.1: #(self.packcrnt[i]<-eval(self.pack_param['capacity'])/2 and self.packcrnt[i-1]<-eval(self.pack_param['capacity'])/2):  #如果充电过程中时间间隔>180s,则舍弃该次充电
+                elif self.packcrnt[i]>-0.1 and self.packcrnt[i+1]>-0.1: #(self.packcrnt[i]<-eval(self.pack_param['capacity'])/2 and self.packcrnt[i-1]<-eval(self.pack_param['capacity'])/2):  #如果充电过程中时间间隔>180s,则舍弃该次充电
                     charging=0
                 elif i==len(self.df_bms)-2:  #数据中断后仍在充电,将前段充电数据写入RAM
                     df_ram_lfp=self.df_bms.iloc[chrg_start:]