修复可用电量计算。
This commit is contained in:
@@ -101,16 +101,46 @@ def read_system_parameters(file_path: str) -> SystemParameters:
|
||||
except (ValueError, TypeError):
|
||||
raise ValueError(f"参数 '{param_name}' 的值 '{param_value}' 不是有效的数值")
|
||||
|
||||
# 创建SystemParameters对象
|
||||
return SystemParameters(
|
||||
max_curtailment_wind=params_dict.get('最大弃风率', 0.1),
|
||||
max_curtailment_solar=params_dict.get('最大弃光率', 0.1),
|
||||
max_grid_ratio=params_dict.get('最大上网电量比例', 0.2),
|
||||
storage_efficiency=params_dict.get('储能效率', 0.9),
|
||||
discharge_rate=params_dict.get('放电倍率', 1.0),
|
||||
charge_rate=params_dict.get('充电倍率', 1.0),
|
||||
max_storage_capacity=params_dict.get('最大储能容量', None)
|
||||
)
|
||||
# 读取各参数值,如果找不到则使用默认值
|
||||
get_param_value = lambda param_name: df_params.loc[df_params['参数名称'] == param_name, '参数值'].iloc[0] if param_name in df_params['参数名称'].values else None
|
||||
|
||||
max_storage_capacity = get_param_value('最大储能容量')
|
||||
# 处理空值或字符串"空"
|
||||
if pd.isna(max_storage_capacity) or max_storage_capacity == '空':
|
||||
max_storage_capacity = None
|
||||
|
||||
try:
|
||||
return SystemParameters(
|
||||
max_curtailment_wind=get_param_value('最大弃风率') or 0.1,
|
||||
max_curtailment_solar=get_param_value('最大弃光率') or 0.1,
|
||||
max_grid_ratio=get_param_value('最大上网电量比例') or 0.2,
|
||||
storage_efficiency=get_param_value('储能效率') or 0.9,
|
||||
discharge_rate=get_param_value('放电倍率') or 1.0,
|
||||
charge_rate=get_param_value('充电倍率') or 1.0,
|
||||
max_storage_capacity=max_storage_capacity,
|
||||
rated_thermal_capacity=get_param_value('额定火电装机容量') or 100.0,
|
||||
rated_solar_capacity=get_param_value('额定光伏装机容量') or 100.0,
|
||||
rated_wind_capacity=get_param_value('额定风电装机容量') or 100.0,
|
||||
available_thermal_energy=get_param_value('火电可用发电量') or 2400.0,
|
||||
available_solar_energy=get_param_value('光伏可用发电量') or 600.0,
|
||||
available_wind_energy=get_param_value('风电可用发电量') or 1200.0
|
||||
)
|
||||
except (KeyError, IndexError, Exception) as e:
|
||||
print(f"读取参数失败:{str(e)},使用默认参数")
|
||||
return SystemParameters(
|
||||
max_curtailment_wind=0.1,
|
||||
max_curtailment_solar=0.1,
|
||||
max_grid_ratio=0.2,
|
||||
storage_efficiency=0.9,
|
||||
discharge_rate=1.0,
|
||||
charge_rate=1.0,
|
||||
rated_thermal_capacity=100.0,
|
||||
rated_solar_capacity=100.0,
|
||||
rated_wind_capacity=100.0,
|
||||
available_thermal_energy=2400.0,
|
||||
available_solar_energy=600.0,
|
||||
available_wind_energy=1200.0
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
print(f"读取参数工作表失败,使用默认参数:{str(e)}")
|
||||
@@ -261,7 +291,13 @@ def create_excel_template(file_path: str, data_type: str = "8760"):
|
||||
'储能效率',
|
||||
'放电倍率',
|
||||
'充电倍率',
|
||||
'最大储能容量'
|
||||
'最大储能容量',
|
||||
'额定火电装机容量',
|
||||
'额定光伏装机容量',
|
||||
'额定风电装机容量',
|
||||
'火电可用发电量',
|
||||
'光伏可用发电量',
|
||||
'风电可用发电量'
|
||||
],
|
||||
'参数值': [
|
||||
0.1, # 最大弃风率
|
||||
@@ -270,7 +306,13 @@ def create_excel_template(file_path: str, data_type: str = "8760"):
|
||||
0.9, # 储能效率
|
||||
1.0, # 放电倍率
|
||||
1.0, # 充电倍率
|
||||
'' # 最大储能容量(空表示无限制)
|
||||
'', # 最大储能容量(空表示无限制)
|
||||
100.0, # 额定火电装机容量
|
||||
100.0, # 额定光伏装机容量
|
||||
100.0, # 额定风电装机容量
|
||||
2400.0, # 火电可用发电量
|
||||
600.0, # 光伏可用发电量
|
||||
1200.0 # 风电可用发电量
|
||||
],
|
||||
'参数说明': [
|
||||
'允许的最大弃风率(0.0-1.0)',
|
||||
@@ -279,7 +321,13 @@ def create_excel_template(file_path: str, data_type: str = "8760"):
|
||||
'储能充放电效率(0.0-1.0)',
|
||||
'储能放电倍率(C-rate,>0)',
|
||||
'储能充电倍率(C-rate,>0)',
|
||||
'储能容量上限(MWh,空表示无限制)'
|
||||
'储能容量上限(MWh,空表示无限制)',
|
||||
'额定火电装机容量(MW)',
|
||||
'额定光伏装机容量(MW)',
|
||||
'额定风电装机容量(MW)',
|
||||
'火电可用发电量(MWh)',
|
||||
'光伏可用发电量(MWh)',
|
||||
'风电可用发电量(MWh)'
|
||||
],
|
||||
'取值范围': [
|
||||
'0.0-1.0',
|
||||
@@ -288,7 +336,13 @@ def create_excel_template(file_path: str, data_type: str = "8760"):
|
||||
'0.0-1.0',
|
||||
'>0',
|
||||
'>0',
|
||||
'>0或空'
|
||||
'>0或空',
|
||||
'>0',
|
||||
'>0',
|
||||
'>0',
|
||||
'≥0',
|
||||
'≥0',
|
||||
'≥0'
|
||||
],
|
||||
'默认值': [
|
||||
'0.1',
|
||||
@@ -297,7 +351,13 @@ def create_excel_template(file_path: str, data_type: str = "8760"):
|
||||
'0.9',
|
||||
'1.0',
|
||||
'1.0',
|
||||
'无限制'
|
||||
'无限制',
|
||||
'100.0',
|
||||
'100.0',
|
||||
'100.0',
|
||||
'2400.0',
|
||||
'600.0',
|
||||
'1200.0'
|
||||
]
|
||||
})
|
||||
parameters_df.to_excel(writer, sheet_name='参数', index=False)
|
||||
|
||||
Reference in New Issue
Block a user