Skip to content

Commit

Permalink
create hv busmap everytime eHV clus runs
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosEpia committed Oct 5, 2023
1 parent 3edaf25 commit c63a459
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions etrago/cluster/spatial.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,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_plus_dc.iterrows()
(row.bus0, row.bus1, row.length, ix)
for ix, row in lines_plus_dc.iterrows()
]
M = graph_from_edges(edges)

Expand Down Expand Up @@ -538,24 +539,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:
print(
"Existing busmap will be deleted and a new one will be calculated.\n"
)
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

Expand Down

0 comments on commit c63a459

Please sign in to comment.