主要更改: • 新增电缆规格配置支持 - Excel文件新增Cables工作表,支持自定义电缆参数(截面、载流量、电阻、成本) - 实现容量约束扫描算法(Capacitated Sweep),替代原有K-means方法 - 动态计算所需回路数量,确保每条回路的电缆载流量符合约束 • 代码增强 - main.py: 集成电缆规格参数,新增命令行参数支持(--clusters手动指定簇数) - generate_template.py: 模板文件新增Cables工作表,提供9种标准电缆规格(35mm²-400mm²) • 文档更新 - 新增project_context.md: 详细记录项目背景、算法逻辑、电气建模和当前状态 - 新增GEMINI.md: 开发者偏好配置 优化后的设计更符合实际工程需求,支持电缆容量约束,输出更准确的成本和损耗评估。
59 lines
1.9 KiB
Python
59 lines
1.9 KiB
Python
import pandas as pd
|
|
import numpy as np
|
|
|
|
def create_template():
|
|
# Create sample data similar to the internal generator
|
|
data = []
|
|
|
|
# Add Substation
|
|
data.append({
|
|
'Type': 'Substation',
|
|
'ID': 'Sub1',
|
|
'X': 4000,
|
|
'Y': -800,
|
|
'Power': 0
|
|
})
|
|
|
|
# Add Turbines (Grid layout)
|
|
n_turbines = 30
|
|
spacing = 800
|
|
n_cols = 6
|
|
|
|
for i in range(n_turbines):
|
|
row = i // n_cols
|
|
col = i % n_cols
|
|
x = col * spacing
|
|
y = row * spacing
|
|
data.append({
|
|
'Type': 'Turbine',
|
|
'ID': i,
|
|
'X': x,
|
|
'Y': y,
|
|
'Power': np.random.uniform(6.0, 10.0)
|
|
})
|
|
|
|
df = pd.DataFrame(data)
|
|
|
|
# Create Cable data
|
|
cable_data = [
|
|
{'CrossSection': 35, 'Capacity': 150, 'Resistance': 0.524, 'Cost': 80},
|
|
{'CrossSection': 70, 'Capacity': 215, 'Resistance': 0.268, 'Cost': 120},
|
|
{'CrossSection': 95, 'Capacity': 260, 'Resistance': 0.193, 'Cost': 150},
|
|
{'CrossSection': 120, 'Capacity': 295, 'Resistance': 0.153, 'Cost': 180},
|
|
{'CrossSection': 150, 'Capacity': 330, 'Resistance': 0.124, 'Cost': 220},
|
|
{'CrossSection': 185, 'Capacity': 370, 'Resistance': 0.0991, 'Cost': 270},
|
|
{'CrossSection': 240, 'Capacity': 425, 'Resistance': 0.0754, 'Cost': 350},
|
|
{'CrossSection': 300, 'Capacity': 500, 'Resistance': 0.0601, 'Cost': 450},
|
|
{'CrossSection': 400, 'Capacity': 580, 'Resistance': 0.0470, 'Cost': 600}
|
|
]
|
|
df_cables = pd.DataFrame(cable_data)
|
|
|
|
# Save to Excel
|
|
output_file = 'coordinates.xlsx'
|
|
with pd.ExcelWriter(output_file) as writer:
|
|
df.to_excel(writer, sheet_name='Coordinates', index=False)
|
|
df_cables.to_excel(writer, sheet_name='Cables', index=False)
|
|
print(f"Created sample file: {output_file} with sheets 'Coordinates' and 'Cables'")
|
|
|
|
if __name__ == "__main__":
|
|
create_template() |