Files
windfarm/project_context.md
dmy 4db9d138b8 feat: 优化风电场集电系统设计,支持电缆规格配置
主要更改:
• 新增电缆规格配置支持
  - Excel文件新增Cables工作表,支持自定义电缆参数(截面、载流量、电阻、成本)
  - 实现容量约束扫描算法(Capacitated Sweep),替代原有K-means方法
  - 动态计算所需回路数量,确保每条回路的电缆载流量符合约束

• 代码增强
  - main.py: 集成电缆规格参数,新增命令行参数支持(--clusters手动指定簇数)
  - generate_template.py: 模板文件新增Cables工作表,提供9种标准电缆规格(35mm²-400mm²)

• 文档更新
  - 新增project_context.md: 详细记录项目背景、算法逻辑、电气建模和当前状态
  - 新增GEMINI.md: 开发者偏好配置

优化后的设计更符合实际工程需求,支持电缆容量约束,输出更准确的成本和损耗评估。
2026-01-01 11:39:14 +08:00

3.2 KiB

Project Context: Wind Farm Layout Optimization

Last Updated: 2025-12-30 Project Path: D:\code\windfarm Current Goal: Optimize offshore wind farm cable layout using MST and K-means algorithms, with realistic constraints and CAD export.

1. System Overview

The system simulates and designs the collection system (inter-array cables) for an offshore wind farm. It compares two main algorithms:

  1. MST (Minimum Spanning Tree): Global optimization of cable length. (Note: Often creates overloaded branches in large farms).
  2. Sector Clustering (K-means): Angular clustering to divide turbines into radial "strings" or "loops" feeding the substation. This is the preferred method for large offshore farms to ensure cable capacity constraints are met.

2. Key Implementations

A. Data Handling

  • Generation: Can generate random or grid layouts.
  • Import: Supports reading coordinates from coordinates.xlsx (Columns: Type, ID, X, Y, Power).
  • Units:
    • Power in MW (input).
    • Coordinates in meters.
    • Voltage: 66 kV (Code constant VOLTAGE_LEVEL).

B. Algorithms

  • Angular K-means:
    • Uses (cosθ, sinθ) of the angle relative to substation for clustering.
    • Eliminates cable crossings between sectors.
  • Dynamic Cluster Sizing:
    • Automatically calculates the required number of clusters (feeders) based on: Total_Power / Max_Cable_Capacity.
    • Ensures no string exceeds the thermal limit of the largest available cable.

C. Electrical Modeling

  • Cable Sizing: Selects from standard cross-sections (35mm² to 400mm²).
  • Constraint: Max cable capacity (400mm²) is approx. 50.4 MW at 66kV/0.95PF.
  • Loss Calc: I^2 R losses.

D. Visualization & Export

  • Matplotlib: Shows layout with color-coded cables (Green=Thin -> Red=Thick).
  • DXF Export: Uses ezdxf to generate .dxf files compatible with CAD.
    • Layers: Substation, Turbines, Cable_XXmm.
    • entities: Circles (Turbines), Polylines (Substation), Lines (Cables).

3. Critical Logic & Constants

  • Voltage: 66,000 V
  • Power Factor: 0.95
  • Max Current (400mm²): 580 A * 0.8 (derating) = 464 A.
  • Unit Conversion: Critical fix applied to convert MW to Watts for current calculation (power * 1e6).

4. Current State & file Structure

  • main.py: Core logic.
  • coordinates.xlsx: Input data (if present).
  • wind_farm_design_imported.png: Latest visualization.
  • wind_farm_design.dxf: Latest CAD export.

5. Known Behaviors

  • MST Method: Will report extremely high costs/losses for large farms because it creates a single tree structure that massively overloads the root cables. This is expected behavior (physically invalid but mathematically correct for unconstrained MST).
  • K-means Method: Produces realistic, valid designs with appropriate cable tapering (e.g., 400mm² at root, 35mm² at leaves).

6. Future Improvements (Optional)

  • Obstacle Avoidance: Currently assumes open ocean.
  • Loop Topology: Current design is radial strings. Reliability could be improved with loop/ring structures.
  • Substation Placement Optimization: Currently fixed or calculated as centroid.