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

Fixes/#735 gas clustering not working with status2019 #736

Merged
merged 6 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 1 addition & 49 deletions etrago/appl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -739,19 +696,14 @@ 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

etrago.optimize()

# conduct lopf with full complex timeseries for dispatch disaggregation
Expand Down
2 changes: 1 addition & 1 deletion etrago/cluster/gas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
24 changes: 17 additions & 7 deletions etrago/cluster/spatial.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down