循环向量化
This commit is contained in:
36
main.py
36
main.py
@@ -1,3 +1,5 @@
|
||||
import numpy as np
|
||||
|
||||
from core import *
|
||||
import timeit
|
||||
|
||||
@@ -104,19 +106,27 @@ def egm():
|
||||
i_curt_samples, d_curt = np.linspace(
|
||||
i_min, i_max, curt_segment_n + 1, retstep=True
|
||||
)
|
||||
for i_curt in i_curt_samples[:-1]:
|
||||
cal_bd_first = bd_area(i_curt, u_ph, dgc, h_gav, h_cav)
|
||||
cal_bd_second = bd_area(i_curt + d_curt, u_ph, dgc, h_gav, h_cav)
|
||||
cal_thunder_density_first = thunder_density(i_curt)
|
||||
cal_thunder_density_second = thunder_density(i_curt + d_curt)
|
||||
calculus += (
|
||||
(
|
||||
cal_bd_first * cal_thunder_density_first
|
||||
+ cal_bd_second * cal_thunder_density_second
|
||||
)
|
||||
/ 2
|
||||
* d_curt
|
||||
)
|
||||
bd_area_vec = np.vectorize(bd_area)
|
||||
cal_bd_np = bd_area_vec(
|
||||
i_curt_samples, u_ph, dgc, h_gav, h_cav
|
||||
) * thunder_density(i_curt_samples)
|
||||
calculus = np.sum(cal_bd_np[:-1] + cal_bd_np[1:]) / 2 * d_curt
|
||||
# for i_curt in i_curt_samples[:-1]:
|
||||
# cal_bd_first = bd_area(i_curt, u_ph, dgc, h_gav, h_cav)
|
||||
# cal_bd_second = bd_area(i_curt + d_curt, u_ph, dgc, h_gav, h_cav)
|
||||
# cal_thunder_density_first = thunder_density(i_curt)
|
||||
# cal_thunder_density_second = thunder_density(i_curt + d_curt)
|
||||
# calculus += (
|
||||
# (
|
||||
# cal_bd_first * cal_thunder_density_first
|
||||
# + cal_bd_second * cal_thunder_density_second
|
||||
# )
|
||||
# / 2
|
||||
# * d_curt
|
||||
# )
|
||||
# if abs(calculus-0.05812740052770032)<1e-5:
|
||||
# abc=123
|
||||
# pass
|
||||
n_sf = (
|
||||
2 * ng / 10 * calculus
|
||||
) # 跳闸率 利用Q╱GDW 11452-2015 架空输电线路防雷导则的公式 Ng=0.023*Td^(1.3) 20天雷暴日地闪密度为1.13
|
||||
|
||||
Reference in New Issue
Block a user