-
Notifications
You must be signed in to change notification settings - Fork 13
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
Fixes/#660 fix ehv clustering #676
Changes from 8 commits
bca53a7
5e566b1
3edaf25
c63a459
4217772
db95efc
3463f1e
0c73a77
27d1714
85216ab
1027eca
a5c36ad
7e0eb63
9529a8d
b76a7bf
92aeaf1
79ecf3e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,6 +99,7 @@ | |
"grid_max_abs_foreign": None, # absolute capacity per voltage level | ||
}, | ||
}, | ||
"delete_dispensable_ac_buses": False, # bool. Find and delete unnecesary buses | ||
"generator_noise": 789456, # apply generator noise, False or seed number | ||
"extra_functionality": {}, # Choose function name or {} | ||
# Spatial Complexity: | ||
|
@@ -383,6 +384,11 @@ def run_etrago(args, json_path): | |
Limit overall energy production country-wise for each generator | ||
by carrier. Set upper/lower limit in p.u. | ||
|
||
delete_dispensable_ac_buses: bool | ||
Choose if unnecessary buses should be identified and deleted from the | ||
grid. This buses have no load or generation attached. Additionally, | ||
they are just connected to two other buses. | ||
Default: False. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would probably not call it "unnecessary buses" that somehow sounds as if it would be a bug. Choose if electrical buses that are only connecting two lines should be removed. These buses have no other components attached to them, the connected lines are merged. This reduces the spatial complexity without losing any accuracy. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed. |
||
network_clustering_ehv : bool | ||
Choose if you want to cluster the full HV/EHV dataset down to only the | ||
EHV buses. In that case, all HV buses are assigned to their closest EHV | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -401,6 +401,12 @@ def busmap_by_shortest_path(etrago, scn_name, fromlvl, tolvl, cpu_cores=4): | |
transformer = connected_transformer(etrago.network, s_buses) | ||
mask = transformer.bus1.isin(buses_of_vlvl(etrago.network, tolvl)) | ||
|
||
dc = etrago.network.links[etrago.network.links.carrier == "DC"] | ||
dc.index = "DC_" + dc.index | ||
lines_plus_dc = pd.concat([lines, dc]) | ||
lines_plus_dc = lines_plus_dc[etrago.network.lines.columns] | ||
lines_plus_dc["carrier"] = "AC" | ||
|
||
# temporary end points, later replaced by bus1 pendant | ||
t_buses = transformer[mask].bus0 | ||
|
||
|
@@ -409,7 +415,8 @@ def busmap_by_shortest_path(etrago, scn_name, fromlvl, tolvl, cpu_cores=4): | |
|
||
# graph creation | ||
edges = [ | ||
(row.bus0, row.bus1, row.length, ix) for ix, row in lines.iterrows() | ||
(row.bus0, row.bus1, row.length, ix) | ||
for ix, row in lines_plus_dc.iterrows() | ||
] | ||
M = graph_from_edges(edges) | ||
|
||
|
@@ -538,24 +545,26 @@ def fetch(): | |
|
||
busmap = fetch() | ||
|
||
# TODO: Or better try/except/finally | ||
if not busmap: | ||
print("Busmap does not exist and will be created.\n") | ||
|
||
cpu_cores = etrago.args["network_clustering"]["CPU_cores"] | ||
if cpu_cores == "max": | ||
cpu_cores = mp.cpu_count() | ||
else: | ||
cpu_cores = int(cpu_cores) | ||
|
||
busmap_by_shortest_path( | ||
etrago, | ||
scn_name, | ||
fromlvl=[110], | ||
tolvl=[220, 380, 400, 450], | ||
cpu_cores=cpu_cores, | ||
if busmap: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess you don't want to include this change There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I included this change intentionally. Using old eHV busmaps leads to errors in the eHV due to the different arguments for the parameter "foreign_lines": {"carrier": "AC",} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, but then I would solve it differently. Right now the busmap is only created if there is data in the table. If there is no data, you do not create the busmap and run into problems. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right now the busmap is always created. If there is one already, a message is shown to inform that it will be replaced. Since sometimes we know that the busmap can be reused, I will include a new argument called "reuse_busmap" in my next commit. It will be included in the "network_clustering_ehv" parameter. |
||
print( | ||
"Existing busmap will be deleted and a new one will be calculated." | ||
) | ||
busmap = fetch() | ||
etrago.engine.execute("""DELETE FROM grid.egon_etrago_hv_busmap""") | ||
|
||
cpu_cores = etrago.args["network_clustering"]["CPU_cores"] | ||
if cpu_cores == "max": | ||
cpu_cores = mp.cpu_count() | ||
else: | ||
cpu_cores = int(cpu_cores) | ||
|
||
busmap_by_shortest_path( | ||
etrago, | ||
scn_name, | ||
fromlvl=[110], | ||
tolvl=[220, 380, 400, 450], | ||
cpu_cores=cpu_cores, | ||
) | ||
busmap = fetch() | ||
|
||
return busmap | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you set the default to false?
It would also make sense to put it to the spatial clustering attributes, wouldn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also you need to add the parameter to the args.json file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think setting this to False can save some time when using small datasets. Also setting it to True would keep the current behaviour of eTraGo. I changed it so to True, but probably both of them make perfect sense.
args.json was also updated.