pypsa-eur icon indicating copy to clipboard operation
pypsa-eur copied to clipboard

Myopic code adds renewable capacity twice

Open Irieo opened this issue 2 years ago • 0 comments

Checklist

  • [x] I am using the current master branch or the latest release. Please indicate.
  • [x] I am running on an up-to-date pypsa-eur environment. Update via conda 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')] image

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" ??

Irieo avatar Dec 01 '23 16:12 Irieo