2021-09-20 20:51:09 +08:00
|
|
|
|
import math
|
|
|
|
|
|
import ezdxf
|
|
|
|
|
|
import numpy as np
|
|
|
|
|
|
|
|
|
|
|
|
gCAD = None
|
|
|
|
|
|
gMSP = None
|
|
|
|
|
|
gCount = 1
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-12-22 16:11:14 +08:00
|
|
|
|
class Parameter:
|
|
|
|
|
|
h_g_sag: float # 地线弧垂
|
|
|
|
|
|
h_c_sag: float # 导线弧垂
|
|
|
|
|
|
voltage_n: int # 工作电压分成多少份来计算
|
|
|
|
|
|
td: int # 雷暴日
|
|
|
|
|
|
insulator_c_len: float # 串子绝缘长度
|
|
|
|
|
|
string_c_len: float
|
|
|
|
|
|
string_g_len: float
|
|
|
|
|
|
gc_x: [float] # 导、地线水平坐标
|
|
|
|
|
|
ground_angels: [float] # 地面倾角,向下为正
|
|
|
|
|
|
h_arm: float # 导、地线垂直坐标
|
|
|
|
|
|
altitude: int # 海拔,单位米
|
|
|
|
|
|
max_i: float # 最大尝试电流,单位kA
|
2021-12-26 20:28:03 +08:00
|
|
|
|
rated_voltage: float # 额定电压
|
2021-12-22 16:11:14 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
para = Parameter()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def rg_line_function_factory(_rg, ground_angel): # 返回一个地面捕雷线的直线方程
|
|
|
|
|
|
y_d = _rg / math.cos(ground_angel) # y轴上的截距
|
|
|
|
|
|
# 利用公式y-y0=k(x-x0) 得到直线公式
|
|
|
|
|
|
y0 = y_d
|
|
|
|
|
|
x0 = 0
|
|
|
|
|
|
k = math.tan(math.pi - ground_angel)
|
|
|
|
|
|
|
|
|
|
|
|
def f(x):
|
|
|
|
|
|
return y0 + k * (x - x0)
|
|
|
|
|
|
|
|
|
|
|
|
return f
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-09-20 20:51:09 +08:00
|
|
|
|
class Draw:
|
|
|
|
|
|
def __init__(self):
|
|
|
|
|
|
self._doc = ezdxf.new(dxfversion="R2010")
|
|
|
|
|
|
self._doc.layers.add("EGM", color=2)
|
|
|
|
|
|
global gCAD
|
|
|
|
|
|
gCAD = self
|
|
|
|
|
|
|
2021-12-22 16:11:14 +08:00
|
|
|
|
def draw(
|
|
|
|
|
|
self,
|
|
|
|
|
|
i_curt,
|
|
|
|
|
|
u_ph,
|
|
|
|
|
|
rs_x,
|
|
|
|
|
|
rs_y,
|
|
|
|
|
|
rc_x,
|
|
|
|
|
|
rc_y,
|
|
|
|
|
|
rg_x,
|
|
|
|
|
|
rg_y,
|
|
|
|
|
|
rg_type,
|
|
|
|
|
|
ground_angel,
|
|
|
|
|
|
color,
|
|
|
|
|
|
):
|
2021-09-20 20:51:09 +08:00
|
|
|
|
doc = self._doc
|
|
|
|
|
|
msp = doc.modelspace()
|
|
|
|
|
|
global gMSP
|
|
|
|
|
|
gMSP = msp
|
|
|
|
|
|
rs = rs_fun(i_curt)
|
|
|
|
|
|
rc = rc_fun(i_curt, u_ph)
|
2021-09-21 20:00:03 +08:00
|
|
|
|
rg = rg_fun(i_curt, rc_y, u_ph, typ=rg_type)
|
|
|
|
|
|
msp.add_circle((rs_x, rs_y), rs, dxfattribs={"color": color})
|
|
|
|
|
|
msp.add_line((0, 0), (rs_x, rs_y)) # 地线
|
2021-09-22 00:18:06 +08:00
|
|
|
|
msp.add_circle((rc_x, rc_y), rc, dxfattribs={"color": color + 2})
|
2021-09-21 20:00:03 +08:00
|
|
|
|
msp.add_line((rc_x, 0), (rc_x, rc_y)) # 导线
|
|
|
|
|
|
msp.add_line((rs_x, rs_y), (rc_x, rc_y))
|
|
|
|
|
|
# 角度线
|
|
|
|
|
|
circle_intersection = solve_circle_intersection(rs, rc, rs_x, rs_y, rc_x, rc_y)
|
|
|
|
|
|
msp.add_line(
|
|
|
|
|
|
(rc_x, rc_y), circle_intersection, dxfattribs={"color": color}
|
|
|
|
|
|
) # 地线
|
|
|
|
|
|
if rg_type == "g":
|
2021-12-22 16:11:14 +08:00
|
|
|
|
ground_angel_func = rg_line_function_factory(rg, ground_angel)
|
|
|
|
|
|
msp.add_line(
|
|
|
|
|
|
(0, ground_angel_func(0)),
|
|
|
|
|
|
(2000, ground_angel_func(2000)),
|
|
|
|
|
|
dxfattribs={"color": color},
|
|
|
|
|
|
)
|
|
|
|
|
|
circle_line_section = solve_circle_line_intersection(
|
|
|
|
|
|
rc, rc_x, rc_y, ground_angel_func
|
|
|
|
|
|
)
|
2021-09-22 00:18:06 +08:00
|
|
|
|
if not circle_line_section:
|
|
|
|
|
|
pass
|
|
|
|
|
|
else:
|
|
|
|
|
|
msp.add_line(
|
|
|
|
|
|
(rc_x, rc_y), circle_line_section, dxfattribs={"color": color}
|
|
|
|
|
|
) # 导线和圆的交点
|
2021-09-21 20:00:03 +08:00
|
|
|
|
if rg_type == "c":
|
|
|
|
|
|
msp.add_circle((rg_x, rg_y), rg, dxfattribs={"color": color})
|
|
|
|
|
|
rg_rc_intersection = solve_circle_intersection(
|
|
|
|
|
|
rg, rc, rg_x, rg_y, rc_x, rc_y
|
|
|
|
|
|
)
|
2021-09-23 00:15:30 +08:00
|
|
|
|
if rg_rc_intersection:
|
|
|
|
|
|
msp.add_line(
|
|
|
|
|
|
(rc_x, rc_y), rg_rc_intersection, dxfattribs={"color": color}
|
|
|
|
|
|
) # 圆和圆的交点
|
2021-09-20 20:51:09 +08:00
|
|
|
|
# 计算圆交点
|
2021-09-21 20:00:03 +08:00
|
|
|
|
|
2021-09-20 20:51:09 +08:00
|
|
|
|
# msp.add_line((dgc, h_cav), circle_intersection) # 导线
|
|
|
|
|
|
|
|
|
|
|
|
def save(self):
|
|
|
|
|
|
doc = self._doc
|
|
|
|
|
|
doc.saveas("egm.dxf")
|
|
|
|
|
|
|
2021-09-26 21:25:08 +08:00
|
|
|
|
def save_as(self, file_name):
|
2021-09-23 00:15:30 +08:00
|
|
|
|
doc = self._doc
|
|
|
|
|
|
doc.saveas(file_name)
|
|
|
|
|
|
|
2021-09-20 20:51:09 +08:00
|
|
|
|
|
|
|
|
|
|
# 圆交点
|
2021-09-21 20:00:03 +08:00
|
|
|
|
def solve_circle_intersection(
|
|
|
|
|
|
radius1,
|
|
|
|
|
|
radius2,
|
|
|
|
|
|
center_x1,
|
|
|
|
|
|
center_y1,
|
|
|
|
|
|
center_x2,
|
|
|
|
|
|
center_y2,
|
|
|
|
|
|
):
|
2021-09-20 20:51:09 +08:00
|
|
|
|
# 用牛顿法求解
|
2021-09-23 00:15:30 +08:00
|
|
|
|
x = radius2 + center_x2 # 初始值
|
|
|
|
|
|
y = radius2 + center_y2 # 初始值
|
2021-09-21 20:00:03 +08:00
|
|
|
|
# TODO 考虑出现2个解的情况
|
2021-09-20 20:51:09 +08:00
|
|
|
|
for bar in range(0, 10):
|
2021-09-21 20:00:03 +08:00
|
|
|
|
A = [
|
|
|
|
|
|
[-2 * (x - center_x1), -2 * (y - center_y1)],
|
|
|
|
|
|
[-2 * (x - center_x2), -2 * (y - center_y2)],
|
|
|
|
|
|
]
|
2021-09-20 20:51:09 +08:00
|
|
|
|
b = [
|
2021-09-21 20:00:03 +08:00
|
|
|
|
(x - center_x1) ** 2 + (y - center_y1) ** 2 - radius1 ** 2,
|
|
|
|
|
|
(x - center_x2) ** 2 + (y - center_y2) ** 2 - radius2 ** 2,
|
2021-09-20 20:51:09 +08:00
|
|
|
|
]
|
|
|
|
|
|
X_set = np.linalg.solve(A, b)
|
|
|
|
|
|
x += X_set[0]
|
|
|
|
|
|
y += X_set[1]
|
|
|
|
|
|
if np.all(np.abs(X_set) < 1e-5):
|
|
|
|
|
|
return [x, y]
|
|
|
|
|
|
return []
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-09-23 00:15:30 +08:00
|
|
|
|
# 圆与捕雷线交点
|
2021-12-22 16:11:14 +08:00
|
|
|
|
def solve_circle_line_intersection(
|
|
|
|
|
|
radius, center_x, center_y, ground_surface_func
|
|
|
|
|
|
): # 返回交点的x和y坐标
|
|
|
|
|
|
x0 = 0
|
|
|
|
|
|
y0 = ground_surface_func(x0)
|
|
|
|
|
|
x1 = 1
|
|
|
|
|
|
y1 = ground_surface_func(x1)
|
|
|
|
|
|
k = (y1 - y0) / (x1 - x0)
|
|
|
|
|
|
distance = distance_point_line(center_x, center_y, x0, y0, k) # 捕雷线到暴露圆中点的距离
|
2021-09-20 20:51:09 +08:00
|
|
|
|
if distance > radius:
|
|
|
|
|
|
return []
|
|
|
|
|
|
else:
|
2021-12-22 16:11:14 +08:00
|
|
|
|
# r = (radius ** 2 - (rg - center_y) ** 2) ** 0.5 + center_x
|
|
|
|
|
|
a = center_x
|
|
|
|
|
|
b = center_y
|
|
|
|
|
|
c = y0
|
|
|
|
|
|
d = x0
|
|
|
|
|
|
bb = -2 * a + 2 * c * k - 2 * d * (k ** 2) - 2 * b * k
|
|
|
|
|
|
aa = 1 + k ** 2
|
|
|
|
|
|
rr = radius
|
|
|
|
|
|
cc = (
|
|
|
|
|
|
a ** 2
|
|
|
|
|
|
+ c ** 2
|
|
|
|
|
|
- 2 * c * k * d
|
|
|
|
|
|
+ (k ** 2) * (d ** 2)
|
|
|
|
|
|
- 2 * b * (c - k * d)
|
|
|
|
|
|
+ b ** 2
|
|
|
|
|
|
- rr ** 2
|
|
|
|
|
|
)
|
|
|
|
|
|
_x = (-bb + (bb ** 2 - 4 * aa * cc) ** 0.5) / 2 / aa
|
|
|
|
|
|
_y = ground_surface_func(_x)
|
|
|
|
|
|
# 验算结果
|
|
|
|
|
|
equ = (center_x - _x) ** 2 + (center_y - _y) ** 2 - radius ** 2
|
|
|
|
|
|
assert abs(equ) < 1e-5
|
|
|
|
|
|
return [_x, _y]
|
2021-09-20 20:51:09 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def min_i(string_len, u_ph):
|
2021-12-22 16:11:14 +08:00
|
|
|
|
# 海拔修正
|
|
|
|
|
|
altitude = para.altitude
|
2022-01-10 01:16:09 +08:00
|
|
|
|
k_a = math.exp((altitude-1000) / 8150) # 气隙海拔修正
|
2021-12-22 16:11:14 +08:00
|
|
|
|
u_50 = 1 / k_a * (530 * string_len + 35) # 50045 上附录的公式,实际应该用负极性电压的公式
|
2021-09-20 20:51:09 +08:00
|
|
|
|
z_0 = 300 # 雷电波阻抗
|
|
|
|
|
|
z_c = 251 # 导线波阻抗
|
2021-12-22 16:11:14 +08:00
|
|
|
|
# 新版大手册公式 3-277
|
2021-09-20 20:51:09 +08:00
|
|
|
|
r = (u_50 + 2 * z_0 / (2 * z_0 + z_c) * u_ph) * (2 * z_0 + z_c) / (z_0 * z_c)
|
|
|
|
|
|
return r
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def thunder_density(i): # l雷电流幅值密度函数
|
2021-12-22 16:11:14 +08:00
|
|
|
|
td = para.td
|
|
|
|
|
|
r = None
|
|
|
|
|
|
if td == 20:
|
|
|
|
|
|
r = -(10 ** (-i / 44)) * math.log(10) * (-1 / 44) # 雷暴日20d
|
|
|
|
|
|
if td == 40:
|
|
|
|
|
|
r = -(10 ** (-i / 88)) * math.log(10) * (-1 / 88) # 雷暴日40d
|
2021-09-20 20:51:09 +08:00
|
|
|
|
return r
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def angel_density(angle): # 入射角密度函数 angle单位是弧度
|
2021-12-22 16:11:14 +08:00
|
|
|
|
r = 0.75 * abs((np.cos(angle - math.pi / 2) ** 3)) # 新版大手册公式3-275
|
2021-09-20 20:51:09 +08:00
|
|
|
|
return r
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def rs_fun(i):
|
2021-12-22 16:11:14 +08:00
|
|
|
|
r = 10 * (i ** 0.65) # 新版大手册公式3-271
|
2021-09-20 20:51:09 +08:00
|
|
|
|
return r
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def rc_fun(i, u_ph):
|
2021-12-22 16:11:14 +08:00
|
|
|
|
r = 1.63 * ((5.015 * (i ** 0.578) - 0.001 * u_ph) ** 1.125) # 新版大手册公式3-272
|
2021-09-20 20:51:09 +08:00
|
|
|
|
return r
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-09-21 20:00:03 +08:00
|
|
|
|
# typ 如果是g,代表捕雷线公式,c代表暴露弧公式
|
|
|
|
|
|
def rg_fun(i_curt, h_cav, u_ph, typ="g"):
|
|
|
|
|
|
rg = None
|
|
|
|
|
|
if typ == "g":
|
|
|
|
|
|
if h_cav < 40:
|
2021-12-22 16:11:14 +08:00
|
|
|
|
rg = (3.6 + 1.7 ** math.log(43 - h_cav)) * (i_curt ** 0.65) # 新版大手册公式3-273
|
2021-09-21 20:00:03 +08:00
|
|
|
|
else:
|
2021-12-22 16:11:14 +08:00
|
|
|
|
rg = 5.5 * (i_curt ** 0.65) # 新版大手册公式3-273
|
2021-09-21 20:00:03 +08:00
|
|
|
|
elif typ == "c": # 此时返回的是圆半径
|
|
|
|
|
|
rg = rc_fun(i_curt, u_ph)
|
2021-09-20 20:51:09 +08:00
|
|
|
|
return rg
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-09-21 20:00:03 +08:00
|
|
|
|
def intersection_angle(
|
2021-12-22 16:11:14 +08:00
|
|
|
|
rc_x, rc_y, rs_x, rs_y, rg_x, rg_y, i_curt, u_ph, ground_angel, rg_type
|
2021-09-21 20:00:03 +08:00
|
|
|
|
): # 暴露弧的角度
|
2021-09-20 20:51:09 +08:00
|
|
|
|
rs = rs_fun(i_curt)
|
|
|
|
|
|
rc = rc_fun(i_curt, u_ph)
|
2021-09-21 20:00:03 +08:00
|
|
|
|
rg = rg_fun(i_curt, rc_y, u_ph, typ=rg_type)
|
|
|
|
|
|
circle_intersection = solve_circle_intersection(
|
|
|
|
|
|
rs, rc, rs_x, rs_y, rc_x, rc_y
|
|
|
|
|
|
) # 两圆的交点
|
|
|
|
|
|
circle_line_or_rg_intersection = None
|
2021-12-22 16:11:14 +08:00
|
|
|
|
rg_line_func = rg_line_function_factory(rg, ground_angel)
|
2021-09-21 20:00:03 +08:00
|
|
|
|
if rg_type == "g":
|
|
|
|
|
|
circle_line_or_rg_intersection = solve_circle_line_intersection(
|
2021-12-22 16:11:14 +08:00
|
|
|
|
rc, rc_x, rc_y, rg_line_func
|
2021-09-21 20:00:03 +08:00
|
|
|
|
) # 暴露圆和补雷线的交点
|
|
|
|
|
|
if rg_type == "c":
|
|
|
|
|
|
circle_line_or_rg_intersection = solve_circle_intersection(
|
|
|
|
|
|
rg, rc, rg_x, rg_y, rc_x, rc_y
|
|
|
|
|
|
) # 两圆的交点
|
2021-12-22 16:11:14 +08:00
|
|
|
|
# TODO 应该是不存在落到地面线以下的情况,先把以下注释掉
|
|
|
|
|
|
|
|
|
|
|
|
# if circle_line_or_rg_intersection:
|
|
|
|
|
|
# (
|
|
|
|
|
|
# circle_line_or_rg_intersection_x,
|
|
|
|
|
|
# circle_line_or_rg_intersection_y,
|
|
|
|
|
|
# ) = circle_line_or_rg_intersection
|
|
|
|
|
|
# if (
|
|
|
|
|
|
# ground_surface(rg, circle_line_or_rg_intersection_x)
|
|
|
|
|
|
# > circle_line_or_rg_intersection_y
|
|
|
|
|
|
# ): # 交点在地面线以下,就可以不积分
|
|
|
|
|
|
# # 找到暴露弧和地面线的交点
|
|
|
|
|
|
# circle_line_or_rg_intersection = circle_ground_surface_intersection(
|
|
|
|
|
|
# rc, rc_x, rc_y, ground_surface
|
|
|
|
|
|
# )
|
2021-09-22 11:22:13 +08:00
|
|
|
|
theta1 = None
|
2021-09-20 20:51:09 +08:00
|
|
|
|
np_circle_intersection = np.array(circle_intersection)
|
2021-09-21 20:00:03 +08:00
|
|
|
|
theta2_line = np_circle_intersection - np.array([rc_x, rc_y])
|
2021-09-20 20:51:09 +08:00
|
|
|
|
theta2 = math.atan(theta2_line[1] / theta2_line[0])
|
2021-09-21 20:00:03 +08:00
|
|
|
|
np_circle_line_or_rg_intersection = np.array(circle_line_or_rg_intersection)
|
2021-09-22 11:22:13 +08:00
|
|
|
|
if not circle_line_or_rg_intersection:
|
2021-12-22 16:11:14 +08:00
|
|
|
|
if rc_y - rc > rg_line_func(rc_x): # rg在rc下面
|
|
|
|
|
|
# 捕捉线太低了,对高塔无保护,θ_1从-90°开始计算,即从与地面垂直的角度开始就已经暴露了。
|
2021-09-22 11:22:13 +08:00
|
|
|
|
theta1 = -math.pi / 2
|
|
|
|
|
|
else:
|
|
|
|
|
|
theta1_line = np_circle_line_or_rg_intersection - np.array([rc_x, rc_y])
|
|
|
|
|
|
theta1 = math.atan(theta1_line[1] / theta1_line[0])
|
2021-09-20 20:51:09 +08:00
|
|
|
|
return np.array([theta1, theta2])
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-09-21 20:00:03 +08:00
|
|
|
|
# 点到直线的距离
|
2021-09-21 01:35:42 +08:00
|
|
|
|
def distance_point_line(point_x, point_y, line_x, line_y, k) -> float:
|
2021-09-20 20:51:09 +08:00
|
|
|
|
d = abs(k * point_x - point_y - k * line_x + line_y) / ((k ** 2 + 1) ** 0.5)
|
|
|
|
|
|
return d
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-09-21 00:36:09 +08:00
|
|
|
|
def func_calculus_pw(theta, max_w):
|
2021-09-20 20:51:09 +08:00
|
|
|
|
w_fineness = 0.01
|
2021-09-22 11:22:13 +08:00
|
|
|
|
segments = int(max_w / w_fineness)
|
|
|
|
|
|
if segments < 2: # 最大最小太小,没有可以积分的
|
|
|
|
|
|
return 0
|
|
|
|
|
|
w_samples, d_w = np.linspace(0, max_w, segments, retstep=True)
|
2021-12-22 16:11:14 +08:00
|
|
|
|
# 童中宇 750KV信洛Ⅰ线雷电防护性能研究 公式 3-10
|
2021-09-21 01:35:42 +08:00
|
|
|
|
cal_w_np = abs(angel_density(w_samples)) * np.sin(theta - (w_samples - math.pi / 2))
|
|
|
|
|
|
r_pw = np.sum((cal_w_np[:-1] + cal_w_np[1:])) / 2 * d_w
|
2021-09-20 20:51:09 +08:00
|
|
|
|
return r_pw
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-09-21 20:00:03 +08:00
|
|
|
|
def calculus_bd(theta, rc, rs, rg, rc_x, rc_y, rs_x, rs_y): # 对θ进行积分
|
2021-09-20 22:33:11 +08:00
|
|
|
|
max_w = 0
|
2021-09-20 20:51:09 +08:00
|
|
|
|
# 求暴露弧上一点的切线
|
2021-09-21 20:00:03 +08:00
|
|
|
|
line_x = math.cos(theta) * rc + rc_x
|
|
|
|
|
|
line_y = math.sin(theta) * rc + rc_y
|
2021-09-20 20:51:09 +08:00
|
|
|
|
k = math.tan(theta + math.pi / 2) # 入射角
|
|
|
|
|
|
# 求保护弧到直线的距离,判断是否相交
|
2021-09-21 20:00:03 +08:00
|
|
|
|
d_to_rs = distance_point_line(rs_x, rs_y, line_x, line_y, k)
|
2021-09-20 20:51:09 +08:00
|
|
|
|
if d_to_rs < rs: # 相交
|
2021-12-22 16:11:14 +08:00
|
|
|
|
# 要用过这一点到保护弧的切线
|
2021-09-21 20:00:03 +08:00
|
|
|
|
new_k = tangent_line_k(line_x, line_y, rs_x, rs_y, rs, init_k=k)
|
2021-09-20 20:51:09 +08:00
|
|
|
|
if new_k >= 0:
|
|
|
|
|
|
max_w = math.atan(new_k) # 用于保护弧相切的角度
|
|
|
|
|
|
elif new_k < 0:
|
|
|
|
|
|
max_w = math.atan(new_k) + math.pi
|
2021-09-21 00:36:09 +08:00
|
|
|
|
# TODO to be removed
|
2021-09-21 01:35:42 +08:00
|
|
|
|
# global gCount
|
|
|
|
|
|
# gCount = gCount+1
|
|
|
|
|
|
# if gCount % 100 == 0:
|
|
|
|
|
|
# gMSP.add_circle((0, h_gav), rs)
|
|
|
|
|
|
# gMSP.add_circle((dgc, h_cav), rc)
|
|
|
|
|
|
# gMSP.add_line((dgc, h_cav), (line_x, line_y))
|
|
|
|
|
|
# gMSP.add_line(
|
|
|
|
|
|
# (-500, new_k * (-500 - line_x) + line_y),
|
|
|
|
|
|
# (500, new_k * (500 - line_x) + line_y),
|
|
|
|
|
|
# )
|
|
|
|
|
|
# gCAD.save()
|
|
|
|
|
|
# pass
|
2021-09-20 20:51:09 +08:00
|
|
|
|
else:
|
|
|
|
|
|
max_w = theta + math.pi / 2 # 入射角
|
2021-09-21 00:36:09 +08:00
|
|
|
|
# TODO to be removed
|
2021-09-20 20:51:09 +08:00
|
|
|
|
if gCount % 200 == 0:
|
|
|
|
|
|
# # intersection_angle(dgc, h_gav, h_cav, i_curt, u_ph)
|
|
|
|
|
|
# gMSP.add_circle((0, h_gav), rs)
|
|
|
|
|
|
# gMSP.add_circle((dgc, h_cav), rc)
|
|
|
|
|
|
# gMSP.add_line((dgc, h_cav), (line_x, line_y))
|
|
|
|
|
|
# gMSP.add_line(
|
|
|
|
|
|
# (-500, k * (-500 - line_x) + line_y),
|
|
|
|
|
|
# (500, k * (500 - line_x) + line_y),
|
|
|
|
|
|
# )
|
|
|
|
|
|
# gCAD.save()
|
|
|
|
|
|
pass
|
2021-12-22 16:11:14 +08:00
|
|
|
|
# 童中宇 750KV信洛Ⅰ线雷电防护性能研究 公式 3-10
|
2021-09-21 00:36:09 +08:00
|
|
|
|
r = rc / math.cos(theta) * func_calculus_pw(theta, max_w)
|
2021-09-20 20:51:09 +08:00
|
|
|
|
return r
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-09-22 00:18:06 +08:00
|
|
|
|
def bd_area(
|
2021-12-22 16:11:14 +08:00
|
|
|
|
i_curt, u_ph, rc_x, rc_y, rs_x, rs_y, rg_x, rg_y, ground_angel, rg_type
|
2021-09-22 00:18:06 +08:00
|
|
|
|
): # 暴露弧的投影面积
|
2021-09-21 20:00:03 +08:00
|
|
|
|
theta1, theta2 = intersection_angle(
|
2021-12-22 16:11:14 +08:00
|
|
|
|
rc_x, rc_y, rs_x, rs_y, rg_x, rg_y, i_curt, u_ph, ground_angel, rg_type
|
2021-09-21 20:00:03 +08:00
|
|
|
|
) # θ角度
|
2021-09-20 20:51:09 +08:00
|
|
|
|
theta_fineness = 0.01
|
|
|
|
|
|
rc = rc_fun(i_curt, u_ph)
|
|
|
|
|
|
rs = rs_fun(i_curt)
|
2021-09-21 20:00:03 +08:00
|
|
|
|
rg = rg_fun(i_curt, rc_y, u_ph, typ=rg_type)
|
2021-09-23 00:15:30 +08:00
|
|
|
|
theta_segments = int((theta2 - theta1) / theta_fineness)
|
|
|
|
|
|
if theta_segments < 2:
|
|
|
|
|
|
return 0
|
|
|
|
|
|
theta_sample, d_theta = np.linspace(theta1, theta2, theta_segments, retstep=True)
|
2021-09-21 01:35:42 +08:00
|
|
|
|
if len(theta_sample) < 2:
|
|
|
|
|
|
return 0
|
|
|
|
|
|
vec_calculus_bd = np.vectorize(calculus_bd)
|
2021-09-21 20:00:03 +08:00
|
|
|
|
calculus_bd_np = vec_calculus_bd(theta_sample, rc, rs, rg, rc_x, rc_y, rs_x, rs_y)
|
2021-09-21 01:35:42 +08:00
|
|
|
|
r_bd = np.sum(calculus_bd_np[:-1] + calculus_bd_np[1:]) / 2 * d_theta
|
|
|
|
|
|
# for calculus_theta in theta_sample[:-1]:
|
|
|
|
|
|
# r_bd += (
|
|
|
|
|
|
# (
|
|
|
|
|
|
# calculus_bd(calculus_theta, rc, rs, rg, dgc, h_cav, h_gav)
|
|
|
|
|
|
# + calculus_bd(calculus_theta + d_theta, rc, rs, rg, dgc, h_cav, h_gav)
|
|
|
|
|
|
# )
|
|
|
|
|
|
# / 2
|
|
|
|
|
|
# * d_theta
|
|
|
|
|
|
# )
|
2021-09-20 20:51:09 +08:00
|
|
|
|
return r_bd
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def tangent_line_k(line_x, line_y, center_x, center_y, radius, init_k=10.0):
|
|
|
|
|
|
# 直线方程为 y-y0=k(x-x0),x0和y0为经过直线的任意一点
|
|
|
|
|
|
# 牛顿法求解k
|
|
|
|
|
|
# f(k)=(k*x1-y1-k*x0+y0)**2-R**2*(k**2+1) x1,y1是圆心
|
2021-09-21 20:00:03 +08:00
|
|
|
|
# 已考虑两个解的判别
|
2021-09-20 20:51:09 +08:00
|
|
|
|
k_candidate = [-100, 100]
|
|
|
|
|
|
if abs(center_y - line_y) < 1 and abs(line_x - center_x - radius) < 1:
|
|
|
|
|
|
# k不存在
|
|
|
|
|
|
k_candidate = [99999999, 99999999]
|
|
|
|
|
|
else:
|
|
|
|
|
|
for ind, k_cdi in enumerate(list(k_candidate)):
|
|
|
|
|
|
k = k_candidate[ind]
|
|
|
|
|
|
k_candidate[ind] = None
|
2021-09-22 11:22:13 +08:00
|
|
|
|
max_iteration = 30
|
|
|
|
|
|
for bar in range(0, max_iteration):
|
2021-09-20 20:51:09 +08:00
|
|
|
|
fk = (k * center_x - center_y - k * line_x + line_y) ** 2 - (
|
|
|
|
|
|
radius ** 2
|
|
|
|
|
|
) * (k ** 2 + 1)
|
|
|
|
|
|
|
|
|
|
|
|
d_fk = (
|
|
|
|
|
|
2
|
|
|
|
|
|
* (k * center_x - center_y - k * line_x + line_y)
|
|
|
|
|
|
* (center_x - line_x)
|
|
|
|
|
|
- 2 * (radius ** 2) * k
|
|
|
|
|
|
)
|
|
|
|
|
|
if abs(d_fk) < 1e-5 and abs(line_x - center_x - radius) < 1e-5:
|
|
|
|
|
|
# k不存在,角度为90°,k取一个很大的正数
|
|
|
|
|
|
k_candidate[ind] = 99999999999999
|
|
|
|
|
|
break
|
|
|
|
|
|
d_k = -fk / d_fk
|
|
|
|
|
|
k += d_k
|
|
|
|
|
|
if abs(d_k) < 1e-3:
|
|
|
|
|
|
dd = distance_point_line(center_x, center_y, line_x, line_y, k)
|
|
|
|
|
|
if abs(dd - radius) < 1:
|
|
|
|
|
|
k_candidate[ind] = k
|
|
|
|
|
|
break
|
2021-09-22 11:22:13 +08:00
|
|
|
|
# 解决数值稳定性
|
|
|
|
|
|
if bar == max_iteration - 1:
|
|
|
|
|
|
if abs(math.atan(k)) * 180 / math.pi > 89:
|
|
|
|
|
|
k_candidate[ind] = k
|
2021-09-20 20:51:09 +08:00
|
|
|
|
# 把k转化成相应的角度,从x开始,逆时针为正
|
|
|
|
|
|
k_angle = []
|
|
|
|
|
|
for kk in k_candidate:
|
2021-09-23 00:15:30 +08:00
|
|
|
|
# if kk is None:
|
|
|
|
|
|
# abc = 123
|
|
|
|
|
|
# tangent_line_k(line_x, line_y, center_x, center_y, radius)
|
|
|
|
|
|
# pass
|
2021-09-20 20:51:09 +08:00
|
|
|
|
if kk >= 0:
|
|
|
|
|
|
k_angle.append(math.atan(kk))
|
|
|
|
|
|
if kk < 0:
|
|
|
|
|
|
k_angle.append(math.pi + math.atan(kk))
|
|
|
|
|
|
# 返回相对x轴最大的角度k
|
|
|
|
|
|
return np.array(k_candidate)[np.max(k_angle) == k_angle].tolist()[-1]
|
2021-09-20 22:41:40 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def func_ng(td): # 地闪密度
|
|
|
|
|
|
return 0.023 * (td ** 1.3)
|
2021-09-22 00:18:06 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 圆和地面线的交点,只去正x轴上的。
|
|
|
|
|
|
def circle_ground_surface_intersection(radius, center_x, center_y, ground_surface):
|
|
|
|
|
|
# 最笨的办法,一个个去试
|
|
|
|
|
|
x_series = np.linspace(0, radius, int(radius / 0.001)) + center_x
|
2021-09-22 11:22:13 +08:00
|
|
|
|
part_to_be_squared = (
|
|
|
|
|
|
radius ** 2 - (x_series - center_x) ** 2
|
|
|
|
|
|
) # 有可能出现-0.00001的数值,只是一个数值稳定问题。
|
2021-09-22 00:18:06 +08:00
|
|
|
|
part_to_be_squared[
|
|
|
|
|
|
(part_to_be_squared < 0) & (abs(part_to_be_squared) < 1e-3)
|
|
|
|
|
|
] = 0 # 强制为0
|
|
|
|
|
|
y_series = center_y - part_to_be_squared ** 0.5
|
|
|
|
|
|
ground_surface_y = ground_surface(x_series)
|
|
|
|
|
|
equal_location = np.abs(ground_surface_y - y_series) < 0.5
|
|
|
|
|
|
r_x = x_series[equal_location][0]
|
|
|
|
|
|
r_y = ground_surface(r_x)
|
|
|
|
|
|
return r_x, r_y
|
2021-09-23 00:15:30 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# u_ph是相电压
|
|
|
|
|
|
# insulator_c_len绝缘子闪络距离
|
|
|
|
|
|
def arc_possibility(rated_voltage, insulator_c_len): # 建弧率
|
2021-12-22 16:11:14 +08:00
|
|
|
|
# 50064 中附录给的公式
|
2021-09-23 00:15:30 +08:00
|
|
|
|
_e = rated_voltage / (3 ** 0.5) / insulator_c_len
|
|
|
|
|
|
r = (4.5 * (_e ** 0.75) - 14) * 1e-2
|
|
|
|
|
|
return r
|