新增一个技术

目标。 在已有算例中引入一个新的发电技术 (如 Geothermal)。

一个技术对应 tech_registry.csv 中的一行,加上每个按技术索引的输入文件中的一行。添加新技术主要是机械的 CSV 编辑,无需修改代码。

步骤

1. 选定 slug 并注册技术。 打开 examples/<scenario>/input/tech_registry.csv 并新增一行:

tech,name,carrier,is_storage
Geothermal,Geothermal,geothermal,False

tech 列是其他文件中通用的 slug (不含空格、不含点)。carrier 为自由格式字符串;请选取有意义的取值 (geothermalnuclearhydrogen 等)。

2. 在每个按技术索引的输入文件中新增一行。 模型读取以下按技术索引的文件,每个文件都需为新技术新增一行:

tech_lifetime.csv             tech_fuel_price.csv
tech_emission_factor.csv      tech_investment_cost.csv
tech_fixed_OM_cost.csv        tech_variable_OM_cost.csv
tech_ramp_up.csv              tech_ramp_down.csv
tech_capacity_max.csv         tech_capacity_min.csv

例如在 tech_lifetime.csv 中:

tech,year,unit,value
Geothermal,2020,years,30

如果新技术具有随时间变化的可用度 (如光伏 / 风电),还需将其加入 tech_max_gen_profile.csv

3. 可选:已有装机。 若规划期开始前已有 Geothermal 投运,在 tech_existing.csv 中加入一行:

tech,zone,commission_year,unit,capacity
Geothermal,BA1,2020,MW,150

4. 可选:扩展候选。 若希望优化器可新建 Geothermal,在 tech_candidates.csv 中加入 capacity_max 不为零的行:

zone,tech,year,unit,capacity_min,capacity_max
BA1,Geothermal,2020,MW,0,inf
BA1,Geothermal,2025,MW,0,inf

条目缺失意味着 "此组合不可扩展";``capacity_max=0`` 等同于此。

5. 重新运行。

cd examples/<scenario>
python -m prepshot

验证

打开输出 NetCDF,确认新技术出现:

import xarray as xr
ds = xr.open_dataset("output/year.nc")
print("Geothermal" in ds.tech.values)        # True
print(ds["install"].sel(tech="Geothermal"))  # capacity over time

常见陷阱

  • slug 拼写错误。 slug 必须在所有 CSV 文件和 tech_registry.csv 中保持完全一致。任何按技术索引的文件缺少新 slug,加载器都会在构建过程中抛出 KeyError

  • 忘记填写 ``tech_capacity_max``。 缺少行会触发 KeyError。如不限上限,请使用 inf

  • 储能技术需补充额外文件。 若注册表中 is_storage=True,还需填写 storage_charge_efficiency.csvstorage_discharge_efficiency.csvstorage_energy_to_power_ratio.csvstorage_initial_level.csv

对水电 (carrier='hydro') 而言,请参见 新增梯级水电系统 —— 水库物理过程会为每个技术再增加约 10 个文件。