diff --git a/etrago/appl.py b/etrago/appl.py index 02deccd7..714b5e8e 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() @@ -739,19 +696,16 @@ 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, data=1.0, ) - # 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 + # start linear optimal powerflow calculations etrago.optimize() # conduct lopf with full complex timeseries for dispatch disaggregation diff --git a/etrago/cluster/gas.py b/etrago/cluster/gas.py index e5e2796b..b31f4e1e 100644 --- a/etrago/cluster/gas.py +++ b/etrago/cluster/gas.py @@ -226,7 +226,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..9f782c1d 100755 --- a/etrago/cluster/spatial.py +++ b/etrago/cluster/spatial.py @@ -775,13 +775,23 @@ 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