Files
multi_energy_complementarity/tests/test_single_renewable.py

91 lines
2.8 KiB
Python
Raw Normal View History

2025-12-27 19:15:56 +08:00
import sys
import os
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'src'))
import pandas as pd
import numpy as np
def create_single_wind_excel():
"""创建只有风电的测试Excel文件"""
# 创建24小时数据
hours = list(range(1, 25))
# 风电出力前12小时高后12小时低
wind_output = [80, 75, 70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 8, 6, 5, 4, 3, 2, 1, 0.5, 0.2, 0.1]
# 光伏出力全部为0
solar_output = [0.0] * 24
# 火电出力全部为0
thermal_output = [0.0] * 24
# 负荷需求恒定40MW
load_demand = [40.0] * 24
# 创建DataFrame
data = {
'小时': hours,
'光伏出力(MW)': solar_output,
'风电出力(MW)': wind_output,
'火电出力(MW)': thermal_output,
'负荷需求(MW)': load_demand
}
df = pd.DataFrame(data)
# 保存为Excel文件
excel_file = 'single_wind_test.xlsx'
df.to_excel(excel_file, index=False, sheet_name='data')
print(f"已创建单一风电测试文件: {excel_file}")
print(f"风电总出力: {sum(wind_output):.1f} MWh")
print(f"负荷总需求: {sum(load_demand):.1f} MWh")
return excel_file
def create_single_solar_excel():
"""创建只有光伏的测试Excel文件"""
# 创建24小时数据
hours = list(range(1, 25))
# 风电出力全部为0
wind_output = [0.0] * 24
# 光伏出力:中间时段高
solar_output = [0, 0, 0, 0, 0, 0, 10, 20, 40, 60, 80, 60, 40, 20, 10, 5, 2, 1, 0.5, 0.2, 0.1, 0, 0, 0]
# 火电出力全部为0
thermal_output = [0.0] * 24
# 负荷需求恒定30MW
load_demand = [30.0] * 24
# 创建DataFrame
data = {
'小时': hours,
'光伏出力(MW)': solar_output,
'风电出力(MW)': wind_output,
'火电出力(MW)': thermal_output,
'负荷需求(MW)': load_demand
}
df = pd.DataFrame(data)
# 保存为Excel文件
excel_file = 'single_solar_test.xlsx'
df.to_excel(excel_file, index=False, sheet_name='data')
print(f"已创建单一光伏测试文件: {excel_file}")
print(f"光伏总出力: {sum(solar_output):.1f} MWh")
print(f"负荷总需求: {sum(load_demand):.1f} MWh")
return excel_file
if __name__ == "__main__":
print("创建单一可再生能源测试文件...")
wind_file = create_single_wind_excel()
solar_file = create_single_solar_excel()
print(f"\n测试文件已创建完成:")
print(f"1. {wind_file} - 单一风电场景")
print(f"2. {solar_file} - 单一光伏场景")
print(f"\n可以使用以下命令测试:")
print(f"uv run python main.py --excel {wind_file}")
print(f"uv run python main.py --excel {solar_file}")