From 94b76bdc3cea5c67ed4141904160453ab2b8f17b Mon Sep 17 00:00:00 2001 From: CarlosEpia Date: Tue, 26 Mar 2024 10:31:04 +0100 Subject: [PATCH 1/6] adapt gas clustering for compatibility with status2019 --- etrago/cluster/gas.py | 3 +-- etrago/cluster/spatial.py | 23 ++++++++++++++++------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/etrago/cluster/gas.py b/etrago/cluster/gas.py index e5e2796b..274ea571 100644 --- a/etrago/cluster/gas.py +++ b/etrago/cluster/gas.py @@ -207,7 +207,6 @@ def weighting_for_scenario(ch4_buses, save=None): if save: weightings.to_csv(save) return weightings - # State whether to create a bus weighting and save it, create or not save # it, or use a bus weighting from a csv file if settings["gas_weight_tocsv"] is not None: @@ -226,7 +225,7 @@ def weighting_for_scenario(ch4_buses, save=None): weight_ch4.loc[loaded_weights.index] = loaded_weights else: weight_ch4 = weighting_for_scenario(network_ch4.buses, save=False) - return network_ch4, weight_ch4.squeeze(), n_clusters + return network_ch4, weight_ch4.squeeze(axis=1), n_clusters def kmean_clustering_gas(etrago, network_ch4, weight, n_clusters): diff --git a/etrago/cluster/spatial.py b/etrago/cluster/spatial.py index 872f33ad..810eb612 100755 --- a/etrago/cluster/spatial.py +++ b/etrago/cluster/spatial.py @@ -775,13 +775,22 @@ def kmedoids_dijkstra_clustering( medoid_idx = distances.idxmin() - # dijkstra's algorithm - busmap = dijkstras_algorithm( - buses, - connections, - medoid_idx, - etrago.args["network_clustering"]["CPU_cores"], - ) + if len(busmap) > n_clusters: + # dijkstra's algorithm + busmap = dijkstras_algorithm( + buses, + connections, + medoid_idx, + etrago.args["network_clustering"]["CPU_cores"], + ) + elif len(busmap) < n_clusters: + logger.warning(f""" + The number supplied to the parameter n_clusters for + {buses.carrier[0]} buses is larger than the actual number of buses + in the network. + """ + ) + busmap.index.name = "bus_id" return busmap, medoid_idx From 9a53e9f5983f4ea5ea3223b987548ed0dec6221a Mon Sep 17 00:00:00 2001 From: CarlosEpia Date: Tue, 26 Mar 2024 10:35:03 +0100 Subject: [PATCH 2/6] hot fix skip DRL --- etrago/appl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etrago/appl.py b/etrago/appl.py index 02deccd7..f2e2b055 100644 --- a/etrago/appl.py +++ b/etrago/appl.py @@ -739,7 +739,7 @@ def run_etrago(args, json_path): etrago.skip_snapshots() # Temporary drop DLR as it is currently not working with sclopf - if etrago.args["method"] != "lopf": + if etrago.args["method"]["type"] != "lopf": etrago.network.lines_t.s_max_pu = pd.DataFrame( index=etrago.network.snapshots, columns=etrago.network.lines.index, From a0533367c4f7fb32d699c1feaf5246552287f9b2 Mon Sep 17 00:00:00 2001 From: CarlosEpia Date: Tue, 26 Mar 2024 10:39:31 +0100 Subject: [PATCH 3/6] delete provisional fixes for status2019 --- etrago/appl.py | 43 ------------------------------------------- 1 file changed, 43 deletions(-) diff --git a/etrago/appl.py b/etrago/appl.py index f2e2b055..bbdfdea1 100644 --- a/etrago/appl.py +++ b/etrago/appl.py @@ -681,49 +681,6 @@ def run_etrago(args, json_path): # adjust network regarding eTraGo setting etrago.adjust_network() - if etrago.args["scn_name"] == "status2019": - etrago.network.mremove( - "Link", - etrago.network.links[ - ~etrago.network.links.bus0.isin(etrago.network.buses.index) - ].index, - ) - etrago.network.mremove( - "Link", - etrago.network.links[ - ~etrago.network.links.bus1.isin(etrago.network.buses.index) - ].index, - ) - etrago.network.lines.loc[etrago.network.lines.r == 0.0, "r"] = 10 - - # delete following unconnected CH4 buses. why are they there? - etrago.network.buses.drop( - etrago.network.buses[ - etrago.network.buses.index.isin(["37865", "37870"]) - ].index, - inplace=True, - ) - - etrago.network.links.loc[ - etrago.network.links.carrier.isin( - ["central_gas_chp", "industrial_gas_CHP"] - ), - "p_nom", - ] *= 1e-3 - etrago.network.generators.loc[ - etrago.network.generators.carrier.isin( - [ - "central_lignite_CHP", - "industrial_lignite_CHP", - "central_oil_CHP", - "industrial_coal_CHP", - "central_coal_CHP", - "industrial_oil_CHP" "central_others_CHP", - ] - ), - "p_nom", - ] *= 1e-3 - # ehv network clustering etrago.ehv_clustering() From 90a8cdf1236e0d9dfa24590d11d4170e4443c2d4 Mon Sep 17 00:00:00 2001 From: CarlosEpia Date: Tue, 26 Mar 2024 10:41:22 +0100 Subject: [PATCH 4/6] delete provisional fixes for status2019 - part2 --- etrago/appl.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/etrago/appl.py b/etrago/appl.py index bbdfdea1..36dfd588 100644 --- a/etrago/appl.py +++ b/etrago/appl.py @@ -704,11 +704,6 @@ def run_etrago(args, json_path): ) # start linear optimal powerflow calculations - - etrago.network.storage_units.cyclic_state_of_charge = True - - etrago.network.lines.loc[etrago.network.lines.r == 0.0, "r"] = 10 - etrago.optimize() # conduct lopf with full complex timeseries for dispatch disaggregation From 24aa51f2c74d5f31acc3cdc554159f6e73b1a7b0 Mon Sep 17 00:00:00 2001 From: CarlosEpia Date: Tue, 26 Mar 2024 10:47:08 +0100 Subject: [PATCH 5/6] using Black --- etrago/cluster/gas.py | 1 + etrago/cluster/spatial.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/etrago/cluster/gas.py b/etrago/cluster/gas.py index 274ea571..b31f4e1e 100644 --- a/etrago/cluster/gas.py +++ b/etrago/cluster/gas.py @@ -207,6 +207,7 @@ def weighting_for_scenario(ch4_buses, save=None): if save: weightings.to_csv(save) return weightings + # State whether to create a bus weighting and save it, create or not save # it, or use a bus weighting from a csv file if settings["gas_weight_tocsv"] is not None: diff --git a/etrago/cluster/spatial.py b/etrago/cluster/spatial.py index 810eb612..9f782c1d 100755 --- a/etrago/cluster/spatial.py +++ b/etrago/cluster/spatial.py @@ -784,7 +784,8 @@ def kmedoids_dijkstra_clustering( etrago.args["network_clustering"]["CPU_cores"], ) elif len(busmap) < n_clusters: - logger.warning(f""" + logger.warning( + f""" The number supplied to the parameter n_clusters for {buses.carrier[0]} buses is larger than the actual number of buses in the network. From b7b4960a0c1ddafce1d0cb8580622fa9137c8fff Mon Sep 17 00:00:00 2001 From: Carlos Epia <62600091+CarlosEpia@users.noreply.github.com> Date: Thu, 18 Apr 2024 14:17:48 +0200 Subject: [PATCH 6/6] include again zero resistance check --- etrago/appl.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/etrago/appl.py b/etrago/appl.py index 36dfd588..714b5e8e 100644 --- a/etrago/appl.py +++ b/etrago/appl.py @@ -703,6 +703,8 @@ def run_etrago(args, json_path): data=1.0, ) + etrago.network.lines.loc[etrago.network.lines.r == 0.0, "r"] = 10 + # start linear optimal powerflow calculations etrago.optimize()