完成基本多场景功能。
This commit is contained in:
81
tests/test_single_renewable_curtail.py
Normal file
81
tests/test_single_renewable_curtail.py
Normal file
@@ -0,0 +1,81 @@
|
||||
"""
|
||||
测试单一可再生能源时弃风量不受限制的功能
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'src'))
|
||||
|
||||
import numpy as np
|
||||
from storage_optimization import optimize_storage_capacity, SystemParameters
|
||||
|
||||
def test_single_renewable_scenario():
|
||||
"""测试单一可再生能源场景"""
|
||||
|
||||
print("=== 测试单一可再生能源弃风量限制功能 ===\n")
|
||||
|
||||
# 场景1: 只有风电
|
||||
print("场景1: 只有风电系统")
|
||||
wind_only = [50.0] * 24 # 24小时风电出力,每小时50MW
|
||||
solar_none = [0.0] * 24
|
||||
thermal_none = [0.0] * 24
|
||||
load = [30.0] * 24 # 负荷30MW,风电出力大于负荷
|
||||
|
||||
params = SystemParameters(
|
||||
max_curtailment_wind=0.1, # 设置10%弃风限制
|
||||
max_curtailment_solar=0.1,
|
||||
max_grid_ratio=0.2,
|
||||
storage_efficiency=0.9,
|
||||
discharge_rate=1.0,
|
||||
charge_rate=1.0,
|
||||
max_storage_capacity=None
|
||||
)
|
||||
|
||||
result = optimize_storage_capacity(wind_only, solar_none, thermal_none, load, params)
|
||||
|
||||
print(f"风电总出力: {np.sum(wind_only):.1f} MWh")
|
||||
print(f"弃风量: {np.sum(result['curtailed_wind']):.1f} MWh")
|
||||
print(f"弃风比例: {result['total_curtailment_wind_ratio']:.3f}")
|
||||
print(f"储能容量: {result['required_storage_capacity']:.1f} MWh")
|
||||
print(f"预期: 弃风量应该为0(因为只有风电,不受10%限制)")
|
||||
print()
|
||||
|
||||
# 场景2: 只有光伏
|
||||
print("场景2: 只有光伏系统")
|
||||
wind_none = [0.0] * 24
|
||||
solar_only = [40.0] * 24 # 24小时光伏出力,每小时40MW
|
||||
thermal_none = [0.0] * 24
|
||||
load = [20.0] * 24 # 负荷20MW,光伏出力大于负荷
|
||||
|
||||
result = optimize_storage_capacity(wind_none, solar_only, thermal_none, load, params)
|
||||
|
||||
print(f"光伏总出力: {np.sum(solar_only):.1f} MWh")
|
||||
print(f"弃光量: {np.sum(result['curtailed_solar']):.1f} MWh")
|
||||
print(f"弃光比例: {result['total_curtailment_solar_ratio']:.3f}")
|
||||
print(f"储能容量: {result['required_storage_capacity']:.1f} MWh")
|
||||
print(f"预期: 弃光量应该为0(因为只有光伏,不受10%限制)")
|
||||
print()
|
||||
|
||||
# 场景3: 风电+光伏(混合系统)
|
||||
print("场景3: 风电+光伏混合系统")
|
||||
wind_mixed = [30.0] * 24
|
||||
solar_mixed = [20.0] * 24
|
||||
thermal_none = [0.0] * 24
|
||||
load = [25.0] * 24 # 负荷25MW,总发电50MW > 负荷
|
||||
|
||||
result = optimize_storage_capacity(wind_mixed, solar_mixed, thermal_none, load, params)
|
||||
|
||||
print(f"风电总出力: {np.sum(wind_mixed):.1f} MWh")
|
||||
print(f"光伏总出力: {np.sum(solar_mixed):.1f} MWh")
|
||||
print(f"弃风量: {np.sum(result['curtailed_wind']):.1f} MWh")
|
||||
print(f"弃光量: {np.sum(result['curtailed_solar']):.1f} MWh")
|
||||
print(f"弃风比例: {result['total_curtailment_wind_ratio']:.3f}")
|
||||
print(f"弃光比例: {result['total_curtailment_solar_ratio']:.3f}")
|
||||
print(f"储能容量: {result['required_storage_capacity']:.1f} MWh")
|
||||
print(f"预期: 弃风弃光量应受10%限制,总弃风弃光量约为{(720+480)*0.1:.0f} MWh")
|
||||
print()
|
||||
|
||||
print("=== 测试完成 ===")
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_single_renewable_scenario()
|
||||
Reference in New Issue
Block a user