feat: 优化风电场集电系统设计,支持电缆规格配置
This commit is contained in:
44
main.py
44
main.py
@@ -13,6 +13,10 @@ import argparse
|
||||
plt.rcParams['font.sans-serif'] = ['Microsoft YaHei', 'SimHei', 'Arial']
|
||||
plt.rcParams['axes.unicode_minus'] = False
|
||||
|
||||
# 常量定义
|
||||
VOLTAGE_LEVEL = 66000 # 66kV
|
||||
POWER_FACTOR = 0.95
|
||||
|
||||
# 1. 生成风电场数据(实际应用中替换为真实坐标)
|
||||
def generate_wind_farm_data(n_turbines=30, seed=42, layout='random', spacing=800):
|
||||
"""
|
||||
@@ -381,10 +385,6 @@ def design_with_capacitated_sweep(turbines, substation, cable_specs=None):
|
||||
|
||||
return cluster_connections + substation_connections, turbines
|
||||
|
||||
# 常量定义
|
||||
VOLTAGE_LEVEL = 66000 # 66kV
|
||||
POWER_FACTOR = 0.95
|
||||
|
||||
def get_max_cable_capacity_mw(cable_specs=None):
|
||||
"""
|
||||
计算给定电缆规格中能够承载的最大功率 (单位: MW)。
|
||||
@@ -616,8 +616,8 @@ def export_to_dxf(turbines, substation, connections_details, filename):
|
||||
if layer_name not in doc.layers:
|
||||
doc.layers.add(layer_name)
|
||||
|
||||
# 绘制直线
|
||||
msp.add_line(p1, p2, dxfattribs={'layer': layer_name})
|
||||
# 绘制二维多段线
|
||||
msp.add_lwpolyline([p1, p2], dxfattribs={'layer': layer_name})
|
||||
|
||||
# 添加电缆型号文字(可选,在线的中点)
|
||||
# mid_x = (p1[0] + p2[0]) / 2
|
||||
@@ -824,7 +824,7 @@ def compare_design_methods(excel_path=None, n_clusters_override=None):
|
||||
# 这里我们导出Sector Clustering的结果
|
||||
export_to_dxf(clustered_turbines, substation, kmeans_evaluation['details'], dxf_filename)
|
||||
|
||||
plt.show()
|
||||
# plt.show()
|
||||
|
||||
# 打印详细结果
|
||||
print(f"\n===== 海上风电场设计方案比较 ({'导入数据' if excel_path else '自动生成'}) =====")
|
||||
@@ -834,6 +834,36 @@ def compare_design_methods(excel_path=None, n_clusters_override=None):
|
||||
print(f" 预估总损耗: {eval_data['total_loss']:.2f} kW")
|
||||
print(f" 连接数量: {eval_data['num_connections']}")
|
||||
|
||||
# Calculate additional metrics for K-means (Capacitated Sweep)
|
||||
print("\n===== K-Means (Capacitated Sweep) 详细统计 =====")
|
||||
|
||||
# 1. 总回路数
|
||||
# The 'cluster' column in clustered_turbines holds the circuit ID.
|
||||
num_circuits = clustered_turbines['cluster'].nunique()
|
||||
print(f"总回路数: {num_circuits}")
|
||||
|
||||
# 2. 每种型号电缆长度
|
||||
cable_lengths = defaultdict(float)
|
||||
max_current = 0.0
|
||||
|
||||
for conn in kmeans_evaluation['details']:
|
||||
# Length
|
||||
section = conn['cable']['cross_section']
|
||||
length = conn['length']
|
||||
cable_lengths[section] += length
|
||||
|
||||
# Max Current
|
||||
current = conn['cable']['current']
|
||||
if current > max_current:
|
||||
max_current = current
|
||||
|
||||
print("每种型号电缆的长度:")
|
||||
for section in sorted(cable_lengths.keys()):
|
||||
print(f" {section}mm²: {cable_lengths[section]:.2f} m")
|
||||
|
||||
# 3. 最大支路电流
|
||||
print(f"最大支路电流: {max_current:.2f} A")
|
||||
|
||||
return results
|
||||
|
||||
# 8. 执行比较
|
||||
|
||||
Reference in New Issue
Block a user