unify vre treatment for hac clustering for simplify_network and cluster_network

This commit is contained in:
martacki 2022-03-22 16:53:05 +01:00
parent 69c0341145
commit 8cb4c17930

View File

@ -351,7 +351,7 @@ def aggregate_to_substations(n, buses_i=None):
aggregate_generators_carriers=None, aggregate_generators_carriers=None,
aggregate_one_ports=["Load", "StorageUnit"], aggregate_one_ports=["Load", "StorageUnit"],
line_length_factor=1.0, line_length_factor=1.0,
generator_strategies={'p_nom_max': 'sum'}, generator_strategies={'p_nom_max': 'sum', 'p_nom_min': 'sum'},
scale_link_capital_costs=False) scale_link_capital_costs=False)
return clustering.network, busmap return clustering.network, busmap
@ -407,21 +407,20 @@ if __name__ == "__main__":
n, substation_map = aggregate_to_substations(n) n, substation_map = aggregate_to_substations(n)
busmaps.append(substation_map) busmaps.append(substation_map)
# treatment of outliers (nodes without a profile for considered carrier) for "cluster_network" # treatment of outliers (nodes without a profile for considered carrier):
if snakemake.config.get("clustering", {}).get("cluster_network", {}).get("algorithm", "hac") == "hac": # all nodes that have no profile of the given carrier are being aggregated to closest neighbor
if (
snakemake.config.get("clustering", {}).get("cluster_network", {}).get("algorithm", "hac") == "hac" or
cluster_config.get("algorithm", "hac") == "hac"
):
carriers = cluster_config.get("feature", "solar+onwind-time").split('-')[0].split('+') carriers = cluster_config.get("feature", "solar+onwind-time").split('-')[0].split('+')
buses_i = list(set(n.buses.index)-set(n.generators.query("carrier in @carriers").bus)) for carrier in carriers:
n, busmap_hac = aggregate_to_substations(n, buses_i) buses_i = list(set(n.buses.index)-set(n.generators.query("carrier == @carrier").bus))
busmaps.append(busmap_hac) logger.info(f'clustering preparaton (hac): aggregating {len(buses_i)} buses of type {carrier}.')
if snakemake.wildcards.simpl:
# treatment of outliers (nodes without a profile for a considered carrier) for "simplify"
if cluster_config.get("algorithm", "hac") == "hac":
carriers = cluster_config.get("feature", "solar+onwind-time").split('-')[0].split('+')
buses_i = list(set(n.buses.index)-set(n.generators.query("carrier in @carriers").bus))
n, busmap_hac = aggregate_to_substations(n, buses_i) n, busmap_hac = aggregate_to_substations(n, buses_i)
busmaps.append(busmap_hac) busmaps.append(busmap_hac)
# conduct clustering
if snakemake.wildcards.simpl:
n, cluster_map = cluster(n, int(snakemake.wildcards.simpl), snakemake.config, n, cluster_map = cluster(n, int(snakemake.wildcards.simpl), snakemake.config,
algorithm=cluster_config.get('algorithm', 'hac'), algorithm=cluster_config.get('algorithm', 'hac'),
feature=cluster_config.get('feature', None)) feature=cluster_config.get('feature', None))