Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Line num_parallel = 0 after simplification and clustering #444

Closed
2 tasks done
euronion opened this issue Nov 25, 2022 · 4 comments
Closed
2 tasks done

Line num_parallel = 0 after simplification and clustering #444

euronion opened this issue Nov 25, 2022 · 4 comments
Milestone

Comments

@euronion
Copy link
Contributor

euronion commented Nov 25, 2022

Checklist

  • I am using the current master branch or the latest release. Please indicate.
  • I am running on an up-to-date pypsa-eur environment. Update via conda env update -f envs/environment.yaml.

Describe the Bug

Line number "3" after clustering (clusters=128) has num_parallel = 0 which does not make any sense.
Where does the line with this unrealistic value come from?

Here's the line in question:

n.lines.query("num_parallel == 0").iloc[0]
Out[6]:
bus0                                      AL1 0
bus1                                      MK1 0
num_parallel                                0.0
length                               175.650433
type                Al/St 240/40 4-bundle 380.0
s_max_pu                                    0.7
s_nom                                       0.0
capital_cost                        9031.968712
x                                           0.0
r                                           0.0
g                                           0.0
b                                           0.0
s_nom_extendable                          False
s_nom_min                                   0.0
s_nom_max                                   inf
build_year                                    0
lifetime                                    inf
carrier
terrain_factor                              1.0
v_ang_min                                  -inf
v_ang_max                                   inf
sub_network
x_pu                                        0.0
r_pu                                        0.0
g_pu                                        0.0
b_pu                                        0.0
x_pu_eff                                    0.0
r_pu_eff                                    0.0
s_nom_opt                                   0.0
Name: 3, dtype: object
@martacki
Copy link
Member

martacki commented Nov 26, 2022

Very interesting. But in fact, this is not a bug, because the un-aggregated lines of elec.nc that build line 3 in elec_s_128.nc already have the attributes num_paralell = 0. This is because they are all under_construction=True.

If you don't believe me, you can check:

linemap = pd.read_csv("resources/linemap_elec_s_128.csv", dtype={"Line": str, "name": str}, index_col=0)
aggregated_lines = linemap.query("name == '3'").index
n_full = pypsa.Network("networks/elec.nc")
n_full.lines.loc[aggregated_lines][["under_construction", "num_parallel"]]

For my test-run, the array aggregated_lines has only one index (14988), and the respective line in elec.nc has the following attributes:

under_construction    True
num_parallel           0.0
Name: 14988, dtype: object

Thus, line 3 also has num_parallel=0.

In fact, my aggregated test-network with 128 nodes had another line in Germany (Line 59) with num_parallel=0. The same statement is true in this case. Here, the array aggregated_lines again consists of a single index (3575), and the respective line 3575 in elec.nc has the attributes

under_construction    True
num_parallel           0.0
Name: 3575, dtype: object

@martacki martacki added discussion and removed bug labels Nov 26, 2022
@martacki
Copy link
Member

We might rather think about the model assumptions if it makes sense to assign some artificial num_parallel value to lines that are under construction, for example based on their intended voltage level.

@euronion
Copy link
Contributor Author

Interesting! This information is not really preserved in the aggregated links, right? So difficult to understand? Can we do something about it?

Looking at it from a different angle:

If I set

config["lines"]["under_construction"] = "remove"

instead of zero the line should be gone, right?

@martacki
Copy link
Member

You are right, the under_construction tag is being removed after simplify_network, see: https://github.com/PyPSA/pypsa-eur/blob/master/scripts/simplify_network.py#L587-L594.

I never tried removing lines using the config, so I don't know. I usually try one of

n.lines = n.lines.query("under_construction == False")
n.lines = n.lines[~n.lines.under_construction]
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants