feat: 新增电价参数配置功能
- 在Excel模板中新增电价参数项(默认0.4元/kWh) - GUI界面显示电价参数,支持从Excel读取 - 核心计算逻辑集成电价参数,为后续经济性分析做准备 - 支持自定义电价或使用默认值
This commit is contained in:
11
main.py
11
main.py
@@ -18,6 +18,7 @@ plt.rcParams['axes.unicode_minus'] = False
|
||||
# 常量定义
|
||||
VOLTAGE_LEVEL = 66000 # 66kV
|
||||
POWER_FACTOR = 0.95
|
||||
ELECTRICITY_PRICE = 0.4 # 元/kWh
|
||||
|
||||
# 1. 生成风电场数据(实际应用中替换为真实坐标)
|
||||
def generate_wind_farm_data(n_turbines=30, seed=42, layout='random', spacing=800):
|
||||
@@ -224,8 +225,15 @@ def load_data_from_excel(file_path):
|
||||
system_params['voltage'] = val
|
||||
elif 'factor' in key or '功率因数' in key:
|
||||
system_params['power_factor'] = val
|
||||
elif 'price' in key or '电价' in key:
|
||||
system_params['electricity_price'] = val
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
# 设置默认电价(如果参数表中未提供)
|
||||
if 'electricity_price' not in system_params:
|
||||
system_params['electricity_price'] = ELECTRICITY_PRICE
|
||||
|
||||
if system_params:
|
||||
print(f"成功加载系统参数: {system_params}")
|
||||
except Exception as e:
|
||||
@@ -1107,7 +1115,8 @@ def compare_design_methods(excel_path=None, n_clusters_override=None, interactiv
|
||||
|
||||
voltage = system_params.get('voltage', VOLTAGE_LEVEL)
|
||||
power_factor = system_params.get('power_factor', POWER_FACTOR)
|
||||
print(f"使用的系统参数: 电压={voltage} V, 功率因数={power_factor}")
|
||||
electricity_price = system_params.get('electricity_price', ELECTRICITY_PRICE)
|
||||
print(f"使用的系统参数: 电压={voltage} V, 功率因数={power_factor}, 电价={electricity_price} 元/kWh")
|
||||
|
||||
# 准备三种电缆方案
|
||||
# 原始 specs 是 5 元素元组: (section, capacity, resistance, cost, is_optional)
|
||||
|
||||
Reference in New Issue
Block a user