pypsa-eur
pypsa-eur copied to clipboard
Myopic code adds renewable capacity twice
Checklist
- [x] I am using the current
masterbranch or the latest release. Please indicate. - [x] I am running on an up-to-date
pypsa-eurenvironment. Update viaconda env update -f envs/environment.yaml.
Describe the Bug
add_existing_baseyear.py of the myopic code branch adds capacity for ["solar", "onwind", "offwind"] carriers twice.
to reproduce: call add_existing_baseyear rule output file, e.g.:
snakemake -call results/myopic-master/prenetworks-brownfield/elec_s_2_lv1.0__3H-B_2025.nc
and revise dataframe: n.generators[(n.generators.index.str.contains('DE')) & (n.generators.carrier=='solar')]
Possible quick fix:
these lines placed at the end of the script fix the carrier capacities:
for generator in ["solar", "onwind", "offwind"]:
mask = n.generators.index.str.contains(f"{generator}-{baseyear}")
if len(mask) > 0:
n.generators.loc[mask, "p_nom"] = 0.0
n.generators.loc[mask, "p_nom_min"] = 0.0
For a proper fix:
for a proper fix, the script add_existing_baseyear.py should be thoroughly revised. Potential problems:
- in general, the idea that we strip the renewable capacity to add them again (thus replicating the code of the add_electricity.py)
- in general, the idea to have "carrier" and "year" information in generator name (not a standard for pypsa code)
- hard-coded values and assumptions (e.g., "1999" -> why do we remove RES before 1999? why hard-coded?)
- complex nested loops and if-conditions
- "# this is for the year 2020" ??