Jelajahi Sumber

平峰更新SOC,参数表更新

Eric412V 2 tahun lalu
induk
melakukan
e9a23b2bd4

+ 36 - 44
LIB/MIDDLE/PingFeng/SOC/V1_0_0/soc.py

@@ -4,17 +4,21 @@ from scipy import interpolate
 import logging
 import pandas as pd
 
+# 充满静置3.398,3.366
+# 放完静置3.18, 3.137
+
 # 电压范围3.0 - 3.5
 
 SocCurve = [0.00, 0.05, 0.10, 0.15, 0.20, 0.25, 0.30, 0.35, 0.40, 0.45, 0.50, 0.55, 0.60, 0.65, 0.70, 0.75, 0.80, 0.85,
             0.90, 0.95, 1.00]
-DisOcvCurve = [2.8977, 3.1587, 3.2040, 3.2269, 3.2521, 3.2691, 3.2846, 3.2865, 3.2871, 3.2880, 3.2886, 3.2971, 3.3190,
+DisOcvCurve = [3.1370, 3.1887, 3.2040, 3.2269, 3.2521, 3.2691, 3.2846, 3.2865, 3.2871, 3.2880, 3.2886, 3.2971, 3.3190,
                3.3277, 3.3277, 3.3280, 3.3286, 3.3289, 3.3296, 3.3311, 3.3795]  # 磷酸铁锂
 
 SocLook = interpolate.interp1d(DisOcvCurve, SocCurve, kind='slinear')
-ChgNearFullVol = 3.5  # v
+ChgNearFullVol = 3.43  # v
 DisNearFullVol = 3.0  # v
 
+
 logger = logging.getLogger(__file__)
 
 
@@ -40,10 +44,14 @@ def ChgStatus(cur, chg_time, dis_time, shelve_time):
     flag = False
     if cur > 1:
         chg_time += 1
+        dis_time = 0
+        shelve_time = 0
     if cur < -1:
         dis_time += 1
+        chg_time = 0
+        shelve_time = 0
         flag = True
-    if cur == 0:
+    if abs(cur) < 0.25:
         shelve_time += 1
         chg_time = 0
         dis_time = 0
@@ -51,15 +59,15 @@ def ChgStatus(cur, chg_time, dis_time, shelve_time):
 
 
 # 电芯容量校正
-def CapacityCalculate(soc, soc_zero, cumulative_capacity, t_capacity):
-    s = soc - soc_zero
-    c = cumulative_capacity - t_capacity
-    try:
-        capacity = c / s
-    except Exception as exc:
-        logger.warning(exc)
-        capacity = 120
-    return capacity
+# def CapacityCalculate(soc, soc_zero, cumulative_capacity, t_capacity):
+#     s = soc - soc_zero
+#     c = cumulative_capacity - t_capacity
+#     try:
+#         capacity = c / s
+#     except Exception as exc:
+#         logger.warning(exc)
+#         capacity = 120
+#     return capacity
 
 
 # 累积容量计算
@@ -69,15 +77,15 @@ def CumulativeCapacity(capacity, cur, deltaTime):
 
 
 # 电池包容量计算
-def PackCapacityCalculate(soc_arr, capacity):
-    pack_capacity = np.min(soc_arr * capacity) + np.min(capacity - soc_arr * capacity)
-    return pack_capacity
+# def PackCapacityCalculate(soc_arr, capacity):
+#     pack_capacity = np.min(soc_arr * capacity) + np.min(capacity - soc_arr * capacity)
+#     return pack_capacity
 
 
-# 满校正
+# 满校正
 def ChgFullFunc(soc, vol):
     for index in range(120):
-        if vol[index] > ChgNearFullVol:
+        if vol[index] >= ChgNearFullVol:
             soc[index] = 1
     return soc
 
@@ -85,28 +93,14 @@ def ChgFullFunc(soc, vol):
 # 满放校正
 def DisFullFunc(soc, vol):
     for index in range(120):
-        if vol[index] < DisNearFullVol:
+        if vol[index] <= DisNearFullVol:
             soc[index] = 0
     return soc
 
 
-# 电池包soc计算
-def PackSocCalculate(soc_arr, pack_capacity, capacity):
-    try:
-        pack_soc = np.min(soc_arr * capacity) / pack_capacity
-        if pack_soc > 1:
-            pack_soc = 1
-        if pack_soc < 0:
-            pack_soc = 0
-        return pack_soc
-    except Exception as exc:
-        logger.warning(exc)
-
-
 SOC_DATA = []
 
 
-# 执行函数,最后返回的是dataframe形式,有对应的上传时间和soc,应该要关联设备id,这块没有加
 def soc_test(sn, data):
     try:
         global SOC_DATA
@@ -125,7 +119,6 @@ def soc_test(sn, data):
                     shelve_time = ram['shelve_time']
                     c_capacity = ram['c_capacity']
                     soc_zero = ram['soc_zero']
-
         vol_array = data[
             ['单体电压1', '单体电压2', '单体电压3', '单体电压4', '单体电压5', '单体电压6', '单体电压7', '单体电压8', '单体电压9', '单体电压10', '单体电压11', '单体电压12',
              '单体电压13', '单体电压14', '单体电压15', '单体电压16', '单体电压17', '单体电压18', '单体电压19', '单体电压20', '单体电压21', '单体电压22', '单体电压23',
@@ -140,15 +133,16 @@ def soc_test(sn, data):
              '单体电压111', '单体电压112', '单体电压113', '单体电压114', '单体电压115', '单体电压116', '单体电压117', '单体电压118', '单体电压119',
              '单体电压120']].values
         vol_array = vol_array.astype(float)
+        vol_array = vol_array / 1000
         cur_array = data['总电流[A]'].values
         upload_time = data['时间戳'].values
         pack_soc_arr = np.zeros(len(cur_array))
-        vol_array_zero = vol_array[0] / 1000
-        vol_array_zero[vol_array_zero > 3.3795] = 3.37
+        vol_array_zero = vol_array[0]
         if ~len(soc_zero):
+            vol_array_zero[vol_array_zero > 3.3795] = 3.37
             soc_zero = SocLook(vol_array_zero)
-        pack_capacity = PackCapacityCalculate(soc_zero, capacity)
-        pack_soc_arr[0] = PackSocCalculate(soc_zero, pack_capacity, capacity)
+
+        pack_soc_arr[0] = np.min(soc_zero)
 
         for index in range(len(data) - 1):
             if abs(cur_array[index]) >= 100:
@@ -165,7 +159,7 @@ def soc_test(sn, data):
             # deltaTime = str_to_date(upload_time[index + 1]) - str_to_date(upload_time[index])
             deltaTime = float(deltaTime.seconds)
 
-            soc = AhCalculate(soc_zero, cur_array[index], deltaTime, pack_capacity)
+            soc = AhCalculate(soc_zero, cur_array[index], deltaTime, capacity)
 
             chg_time, dis_time, shelve_time, flag = ChgStatus(cur_array[index], chg_time, dis_time, shelve_time)
 
@@ -176,18 +170,18 @@ def soc_test(sn, data):
                 soc = DisFullFunc(soc, vol_array[index])
 
             if shelve_time > 1800:
-                if vol_array[index][0] > 3.328 or vol_array[index][0] < 3.285:
+                if np.max(vol_array[index]) > 3.328 or np.min(vol_array[index]) < 3.285:
+                    vol_array[index][vol_array[index] < 3.1370] = 3.1370
                     soc_zero = SocLook(vol_array[index])
 
             if flag:
-                if np.min(vol_array[index]) >= 3.0:
+                if np.min(vol_array[index]) >= 3.0 and np.max(vol_array[index]) <= 3.5:
                     c_capacity = CumulativeCapacity(c_capacity, cur_array[index], deltaTime)
 
             if not flag and c_capacity != 0:
                 capacity = c_capacity
 
-            pack_soc = PackSocCalculate(soc, pack_capacity, capacity)
-            pack_soc_arr[index + 1] = pack_soc
+            pack_soc_arr[index + 1] = np.min(soc)
         ram_result = {'sn': sn, 'capacity': capacity, 'chg_time': chg_time, 'dis_time': dis_time, 'shelve_time': shelve_time,
                   'soc_zero': soc_zero, 'c_capacity': c_capacity}
         sn_list = []
@@ -208,8 +202,6 @@ def soc_test(sn, data):
         pack_soc_arr = pack_soc_arr * 100
         result = {'SN': sn, 'SOC': pack_soc_arr[-1], 'UploadTime': upload_time[-1]}
         result = pd.DataFrame(result, index=[0])
-        # pack_soc_frame = pd.DataFrame(pack_soc_arr, columns=['SOC'])
-        # result = pack_soc_frame.assign(UploadTime=upload_time)
         return result
     except Exception as exc:
         logger.warning(exc)

+ 5 - 1
LIB/MIDDLE/SaftyCenter/Common/QX_BatteryParam.py

@@ -162,7 +162,11 @@ class BatteryInfo():
             self.BalCurrent=0.015
             self.LookTab_SOC = [0.0, 2.5, 5.0, 7.5, 10.0, 12.5, 15.0, 17.5, 20.0, 22.5, 25.0, 27.5, 30.0, 32.5, 35.0, 37.5, 40.0, 42.5, 45.0, 47.5, 50.0, 52.5, 55.0, 57.5, 60.0, 62.5, 65.0, 67.5, 70.0, 72.5, 75.0, 77.5, 80.0, 82.5, 85.0, 87.5, 90.0, 92.5, 95.0, 97.5, 100.0]
             self.LookTab_OCV = [2.5220, 2.8283, 3.0608, 3.1690, 3.1981, 3.2012, 3.2071, 3.2229, 3.2341, 3.2452, 3.2533, 3.2607, 3.2691, 3.2775, 3.2849, 3.2859, 3.2859, 3.2862, 3.2865, 3.2871, 3.2874, 3.2886, 3.2896, 3.2908, 3.2933, 3.2998, 3.3181, 3.3249, 3.3258, 3.3262, 3.3268, 3.3268, 3.3274, 3.3277, 3.3280, 3.3286, 3.3289, 3.3299, 3.3305, 3.3333, 3.4406]  
-
+            self.DifVolGap = 3
+            self.CellOVlmt=4
+            self.CellUVlmt=2
+            self.CantChrgVol=2.6
+            self.AvgOtherTempGap=40
         else:
             print('未找到对应电池编号!!!')
             # sys.exit()