excel结果中输出弃电量。

This commit is contained in:
dmy
2025-12-27 17:57:38 +08:00
parent 7ce065f2df
commit 2956bc80fb
4 changed files with 283 additions and 840 deletions

28
main.py
View File

@@ -320,6 +320,15 @@ def export_results_to_excel(solar_output, wind_output, thermal_output, load_dema
grid_feed_out.append(power) # 上网电量
# 创建主要数据DataFrame
# 计算弃电损失量(弃风+弃光)
curtailment_loss = [result['curtailed_wind'][i] + result['curtailed_solar'][i] for i in range(len(result['curtailed_wind']))]
# 计算累计弃电损失量
cumulative_curtailment = []
cumulative = 0
for loss in curtailment_loss:
cumulative += loss
cumulative_curtailment.append(cumulative)
data_df = pd.DataFrame({
'小时': hours,
'光伏出力(MW)': solar_output,
@@ -332,6 +341,8 @@ def export_results_to_excel(solar_output, wind_output, thermal_output, load_dema
'储能状态(MWh)': result['storage_profile'],
'弃风量(MW)': result['curtailed_wind'],
'弃光量(MW)': result['curtailed_solar'],
'弃电损失量(MW)': curtailment_loss,
'累计弃电量(MWh)': cumulative_curtailment,
'购电量(MW)': grid_purchase,
'上网电量(MW)': grid_feed_out
})
@@ -340,6 +351,15 @@ def export_results_to_excel(solar_output, wind_output, thermal_output, load_dema
total_grid_feed_in = sum(result['grid_feed_in'])
total_grid_purchase = sum(-x for x in result['grid_feed_in'] if x < 0) # 购电量
total_grid_feed_out = sum(x for x in result['grid_feed_in'] if x > 0) # 上网电量
# 计算弃电损失量
total_curtail_wind = sum(result['curtailed_wind'])
total_curtail_solar = sum(result['curtailed_solar'])
total_curtail_energy = total_curtail_wind + total_curtail_solar
# 计算总潜在发电量
total_potential_generation = sum(solar_output) + sum(wind_output) + sum(thermal_output)
curtailment_loss_ratio = (total_curtail_energy / total_potential_generation * 100) if total_potential_generation > 0 else 0
stats_df = pd.DataFrame({
'指标': [
@@ -351,6 +371,10 @@ def export_results_to_excel(solar_output, wind_output, thermal_output, load_dema
'弃风率',
'弃光率',
'上网电量比例',
'总弃风电量',
'总弃光电量',
'总弃电量',
'弃电损失比例',
'能量平衡校验',
'净购电量/净上网电量',
'总购电量',
@@ -366,6 +390,10 @@ def export_results_to_excel(solar_output, wind_output, thermal_output, load_dema
f"{result['total_curtailment_wind_ratio']:.3f}",
f"{result['total_curtailment_solar_ratio']:.3f}",
f"{result['total_grid_feed_in_ratio']:.3f}",
f"{total_curtail_wind:.2f} MWh",
f"{total_curtail_solar:.2f} MWh",
f"{total_curtail_energy:.2f} MWh",
f"{curtailment_loss_ratio:.2f}%",
"通过" if result['energy_balance_check'] else "未通过",
f"{-total_grid_feed_in:.2f} MWh" if total_grid_feed_in < 0 else f"{total_grid_feed_in:.2f} MWh",
f"{total_grid_purchase:.2f} MWh",