PyPSA / pypsa-eur

PyPSA-Eur: A Sector-Coupled Open Optimisation Model of the European Energy System
https://pypsa-eur.readthedocs.io/
342 stars 242 forks source link

s_max_pu = 1 for some lines despite default config of 0.7 #1276

Closed grecht closed 1 month ago

grecht commented 2 months ago

Hi everyone! I noticed that some lines have s_max_pu values of 1 instead of 0.7. These are mostly TYNDP2020 lines and some lines whose names start with "P", see the output below. If this is intentional, what is the reasoning behind this? I could not find anything in the documentation, and the default config file which I used specifies s_max_pu: 0.7 which should hold for all lines, as I understand it.

What I did

nw_path = "resources/networks/elec_s.nc" nw = pypsa.Network(nw_path) print(nw.lines.loc[nw.lines["s_max_pu"] == 1].index)

The output:

WARNING:pypsa.io:Importing network from PyPSA version v0.30.1 while current version is v0.30.2. Read the release notes at https://pypsa.readthedocs.io/en/latest/release_notes.html to prepare your network for import. INFO:pypsa.io:Imported network elec_s.nc has buses, carriers, generators, lines, links, loads, shapes, storage_units Index(['TYNDP2020_0', 'TYNDP2020_1', 'TYNDP2020_2', 'TYNDP2020_3', 'TYNDP2020_4', 'TYNDP2020_6', 'TYNDP2020_8', 'TYNDP2020_9', 'TYNDP2020_11', 'TYNDP2020_13', 'TYNDP2020_14', 'TYNDP2020_15',
'TYNDP2020_16', 'TYNDP2020_17', 'TYNDP2020_24', 'TYNDP2020_25',
'TYNDP2020_26', 'TYNDP2020_27', 'TYNDP2020_28', 'TYNDP2020_29',
'TYNDP2020_30', 'TYNDP2020_31', 'TYNDP2020_32', 'TYNDP2020_33',
'TYNDP2020_34', 'TYNDP2020_35', 'TYNDP2020_36', 'TYNDP2020_37',
'TYNDP2020_47', 'TYNDP2020_48', 'TYNDP2020_49', 'TYNDP2020_50',
'TYNDP2020_51', 'TYNDP2020_53', 'TYNDP2020_54', 'TYNDP2020_56',
'TYNDP2020_57', 'TYNDP2020_59', 'TYNDP2020_60', 'TYNDP2020_74',
'TYNDP2020_77', 'TYNDP2020_82', 'TYNDP2020_88', 'TYNDP2020_89',
'TYNDP2020_90', 'TYNDP2020_92', 'TYNDP2020_94', 'TYNDP2020_97',
'TYNDP2020_98', 'TYNDP2020_99', 'TYNDP2020_100', 'TYNDP2020_101',
'TYNDP2020_113', 'TYNDP2020_120', 'TYNDP2020_121', 'TYNDP2020_122',
'TYNDP2020_123', 'TYNDP2020_124', 'TYNDP2020_125', 'TYNDP2020_132',
'TYNDP2020_133', 'TYNDP2020_134', 'TYNDP2020_135', 'P43', 'P71', 'P84', 'P227', 'P402', 'P470', 'P476', 'P478', 'P485', 'P490', 'P540', 'P625', 'P627', 'P635', 'P636'], dtype='object', name='Line')

fneum commented 2 months ago

No, it's not intended and should indeed be 0.7 also for TYNDP links.

grecht commented 2 months ago

A quick fix would be adding the following line to the main body of build_transmission_projects.py, which worked for me (see https://github.com/PyPSA/pypsa-eur/commit/4ee48844f1fd7b3ffb9942a0124225bb4f212020)

new_lines_df["s_max_pu"] = snakemake.config["lines"]["s_max_pu"]

But it really makes no sense to put this there instead of a single place where s_max_pu is set for all lines. I think this should probably happen here: https://github.com/PyPSA/pypsa-eur/blob/e35f65151805c786593c41c2cd8f1142c1f6f449/scripts/prepare_network.py#L346 But apparently, this is not applied to the transmission projects, not sure why. Maybe it is due to the order of execution.

p-glaum commented 1 month ago

Hi @grecht , you are right! I thought the line factor would be applied later for all lines but it already happens in base_network. I added your suggestion in PR #1323

Thanks for reporting the bug!

grecht commented 1 month ago

Sure, thanks for fixing it!