From 2251966b7e9e4d504cf178b29a373f642d95cf80 Mon Sep 17 00:00:00 2001 From: facat Date: Sun, 26 Sep 2021 21:25:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=87=86=E5=A4=87=E8=BF=9B=E8=A1=8Cjit?= =?UTF-8?q?=E6=94=B9=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core.py | 2 +- main.py | 59 ++++++++++++++++++++++-------------------- plot_data.py | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 104 insertions(+), 29 deletions(-) create mode 100644 plot_data.py diff --git a/core.py b/core.py index db93b48..55402b7 100644 --- a/core.py +++ b/core.py @@ -58,7 +58,7 @@ class Draw: doc = self._doc doc.saveas("egm.dxf") - def saveas(self, file_name): + def save_as(self, file_name): doc = self._doc doc.saveas(file_name) diff --git a/main.py b/main.py index fd4e261..65c1c17 100644 --- a/main.py +++ b/main.py @@ -1,5 +1,6 @@ -import numpy as np +import sys +from loguru import logger from core import * import timeit @@ -7,13 +8,13 @@ import timeit def egm(): h_g_avr_sag = 11.67 * 2 / 3 h_c_avr_sag = 14.43 * 2 / 3 - h_whole = 40 # 杆塔全高 + h_whole = 130 # 杆塔全高 voltage_n = 3 # 工作电压分成多少份来计算 td = 20 # 雷暴日 - insulator_c_len = 6.8 # 串子绝缘长度 + insulator_c_len = 6.6 # 串子绝缘长度 string_c_len = 9.2 string_g_len = 0.5 - gc_x = [17.9, 17, 15, 17] + gc_x = [17.9, 17, 15, 17.0] # 以后考虑地形角度,地面线 def ground_surface(x): @@ -21,9 +22,9 @@ def egm(): gc_y = [ h_whole - string_g_len - h_g_avr_sag, # 地线对地平均高 - h_whole - string_c_len - h_c_avr_sag - 2.7, # 导线对地平均高 + # h_whole - string_c_len - h_c_avr_sag - 2.7, # 导线对地平均高 h_whole - string_c_len - h_c_avr_sag - 20, # 导线对地平均高 - h_whole - string_c_len - h_c_avr_sag - 35.7, # 导线对地平均高 + # h_whole - string_c_len - h_c_avr_sag - 35.7, # 导线对地平均高 ] if len(gc_y) > 2: # 双回路 phase_n = 3 # 边相导线数量 @@ -40,7 +41,7 @@ def egm(): ng = func_ng(td) n_sf_phases = np.zeros((phase_n, voltage_n)) # 计算每一相的跳闸率 if np.any(np.array(gc_y) < 0): - print("导线可能掉地面了,程序退出。") + logger.info("导线可能掉地面了,程序退出。") return 0 for phase_conductor_foo in range(phase_n): exposed_curve_shielded = False @@ -61,13 +62,13 @@ def egm(): shield_angle = ( math.atan((rc_x - rs_x) / ((rs_y - rc_y) + string_c_len)) * 180 / math.pi ) # 保护角 - print(f"保护角{shield_angle:.3f}°") - print(f"最低相防护标识{rg_type}") + logger.info(f"保护角{shield_angle:.3f}°") + logger.debug(f"最低相防护标识{rg_type}") for u_bar in range(voltage_n): u_ph = ( - math.sqrt(2) * 750 * math.cos(2 * math.pi / voltage_n * u_bar) / 1.732 + -math.sqrt(2) * 750 * math.cos(2 * math.pi / voltage_n * u_bar) / 1.732 ) # 运行相电压 - print(f"计算第{phase_conductor_foo + 1}相,电压为{u_ph:.2f}kV") + logger.info(f"计算第{phase_conductor_foo + 1}相,电压为{u_ph:.2f}kV") # 迭代法计算最大电流 i_max = 0 i_min = min_i(insulator_c_len, u_ph / 1.732) @@ -77,7 +78,7 @@ def egm(): for i_bar in np.linspace( _min_i, _max_i, int((_max_i - _min_i) / 0.1) ): # 雷电流 - # print(f"尝试计算电流为{i_bar:.2f}") + # logger.info(f"尝试计算电流为{i_bar:.2f}") rs = rs_fun(i_bar) rc = rc_fun(i_bar, u_ph) rg = rg_fun(i_bar, rc_y, u_ph, typ=rg_type) @@ -97,7 +98,7 @@ def egm(): ) i_max = i_bar if not rg_rc_circle_intersection: # if circle_intersection is [] - print("保护弧和暴露弧无交点,检查设置参数。") + logger.debug("保护弧和暴露弧无交点,检查设置参数。") continue circle_rc_line_or_rg_intersection = None if rg_type == "g": @@ -113,12 +114,12 @@ def egm(): if rg_type == "g": if rg > rc_y: i_min = i_bar - print(f"捕捉弧在暴露弧之上,设置最小电流为{i_min:.2f}") + logger.info(f"捕捉弧在暴露弧之上,设置最小电流为{i_min:.2f}") else: - print("暴露弧和捕捉弧无交点,检查设置参数。") + logger.info("暴露弧和捕捉弧无交点,检查设置参数。") continue else: - print("暴露弧和捕捉弧无交点,检查设置参数。") + logger.info("暴露弧和捕捉弧无交点,检查设置参数。") continue min_distance_intersection = ( np.sum( @@ -155,25 +156,25 @@ def egm(): ** 0.5 ) if distance > rc: - print("暴露弧已经完全被屏蔽") + logger.info("暴露弧已经完全被屏蔽") exposed_curve_shielded = True break # if phase_conductor_foo == 2: cad.draw(i_min, u_ph, rs_x, rs_y, rc_x, rc_y, rg_x, rg_y, rg_type, 2) cad.draw(i_max, u_ph, rs_x, rs_y, rc_x, rc_y, rg_x, rg_y, rg_type, 6) - cad.saveas(f"egm{phase_conductor_foo+1}.dxf") + cad.save_as(f"egm{phase_conductor_foo + 1}.dxf") # 判断是否导线已经被完全保护 if abs(i_max - _max_i) < 1e-5: - print("无法找到最大电流,可能是杆塔较高。") - print(f"最大电流设置为自然界最大电流{i_max}kA") - print(f"最大电流为{i_max:.2f}") - print(f"最小电流为{i_min:.2f}") + logger.info("无法找到最大电流,可能是杆塔较高。") + logger.info(f"最大电流设置为自然界最大电流{i_max}kA") + logger.info(f"最大电流为{i_max:.2f}") + logger.info(f"最小电流为{i_min:.2f}") if exposed_curve_shielded: - print("暴露弧已经完全被屏蔽,不会跳闸。") + logger.info("暴露弧已经完全被屏蔽,不会跳闸。") continue curt_fineness = 0.1 # 电流积分细度 if i_min > i_max or abs(i_min - i_max) < curt_fineness: - print("最大电流小于最小电流,没有暴露弧。") + logger.info("最大电流小于最小电流,没有暴露弧。") continue # 开始积分 curt_segment_n = int((i_max - i_min) / curt_fineness) # 分成多少份 @@ -213,12 +214,12 @@ def egm(): # if abs(calculus-0.05812740052770032)<1e-5: # abc=123 # pass - n_sf = (2 * ng / 10 * calculus) * arc_possibility(750, insulator_c_len) + n_sf = 2 * ng / 10 * calculus * arc_possibility(750, insulator_c_len) avr_n_sf += n_sf / voltage_n n_sf_phases[phase_conductor_foo][u_bar] = n_sf - print(f"工作电压为{u_ph:.2f}kV时,跳闸率是{n_sf:.6}") - print(f"跳闸率是{avr_n_sf:.6f}") - print(f"不同相跳闸率是{np.mean(n_sf_phases,axis=1)}") + logger.info(f"工作电压为{u_ph:.2f}kV时,跳闸率是{n_sf:.6}") + logger.info(f"跳闸率是{avr_n_sf:.6f}") + logger.info(f"不同相跳闸率是{np.array2string(np.mean(n_sf_phases,axis=1),precision=6)}") def speed(): @@ -228,6 +229,8 @@ def speed(): if __name__ == "__main__": + logger.remove() + logger.add(sys.stderr, level="DEBUG") run_time = timeit.timeit("egm()", globals=globals(), number=1) print(f"运行时间:{run_time:.2f}s") print("Finished.") diff --git a/plot_data.py b/plot_data.py new file mode 100644 index 0000000..6a63be6 --- /dev/null +++ b/plot_data.py @@ -0,0 +1,72 @@ +import numpy as np + +category_names_7欧电阻_随塔高变化 = ["100", "110", "120", "130", "140", "150"] +# 第1列反击 ,第2列绕击 +data_7欧电阻_随塔高变化 = np.array( + [ + [0.000002, 0.019094], + [0.000003, 0.043287], + [0.000006, 0.073033], + [0.000010, 0.103132], + [0.000019, 0.130923], + [0.000032, 0.155414], + ] +) + +category_names_15欧电阻_随塔高变化 = ["100", "110", "120", "130", "140", "150"] + +data_15欧电阻_随塔高变化 = np.array( + [ + [0.000039, 0.019094], + [0.000064, 0.043287], + [0.000098, 0.073033], + [0.000170, 0.103132], + [0.000287, 0.130923], + [0.000440, 0.155414], + ] +) + + +category_names_130m塔高_不同接地电阻 = ["7", "10", "15", "20", "25", "30"] + +data_130m塔高_不同接地电阻 = np.array( + [ + [0.000010, 0.103132], + [0.000101, 0.103132], + [0.000171, 0.103132], + [0.000333, 0.103132], + [0.000563, 0.103132], + [0.000950, 0.103132], + ] +) + +category_names_130m塔高_不同地线保护角 = ["-1", "-3", "-6"] + +data_130m塔高_不同地线保护角 = np.array( + [ + [0.000170, 0.103132], + [0.000168, 0.079659], + [0.000167, 0.055598], + ] +) + + +category_names_66m串长_不同塔高 = ['100', '120', '140'] + +data_66m串长_不同塔高 = np.array( + [ + [0.000053 , 0.023285], + [0.000139 , 0.083229], + [0.000470 , 0.145586], + ] +) + +category_names_68m串长_不同塔高 = [100, 120, 140] + +data_68m串长_不同塔高 = np.array( + [ + [0.000039 , 0.019094], + [0.000098 , 0.073033], + [0.000287 , 0.130923], + ] +)