diff --git a/config.default.yaml b/config.default.yaml index fb1e9603..0c2c8218 100755 --- a/config.default.yaml +++ b/config.default.yaml @@ -261,6 +261,7 @@ clustering: cluster_network: algorithm: kmeans feature: solar+onwind-time + exclude_carriers: [] # list of carriers which will not be aggregated. If empty, all carriers will be aggregated. aggregation_strategies: generators: p_nom_max: sum # use "min" for more conservative assumptions diff --git a/config.tutorial.yaml b/config.tutorial.yaml index fb5fe807..0cfdc5ab 100755 --- a/config.tutorial.yaml +++ b/config.tutorial.yaml @@ -191,6 +191,7 @@ clustering: cluster_network: algorithm: kmeans feature: solar+onwind-time + exclude_carriers: [] # list of carriers which will not be aggregated. If empty, all carriers will be aggregated. aggregation_strategies: generators: p_nom_max: sum # use "min" for more conservative assumptions diff --git a/scripts/cluster_network.py b/scripts/cluster_network.py index 11defccb..a392d024 100644 --- a/scripts/cluster_network.py +++ b/scripts/cluster_network.py @@ -393,15 +393,14 @@ if __name__ == "__main__": for tech in n.generators.carrier.unique() if tech in snakemake.config['renewable']]) + aggregate_carriers=set(n.carriers.index)-set(snakemake.config["clustering"]["exclude_carriers"]) if snakemake.wildcards.clusters.endswith('m'): n_clusters = int(snakemake.wildcards.clusters[:-1]) aggregate_carriers = snakemake.config["electricity"].get("conventional_carriers") elif snakemake.wildcards.clusters == 'all': n_clusters = len(n.buses) - aggregate_carriers = None # All else: n_clusters = int(snakemake.wildcards.clusters) - aggregate_carriers = None # All if n_clusters == len(n.buses): # Fast-path if no clustering is necessary diff --git a/scripts/simplify_network.py b/scripts/simplify_network.py index 56889fbf..16726156 100644 --- a/scripts/simplify_network.py +++ b/scripts/simplify_network.py @@ -197,7 +197,7 @@ def _adjust_capital_costs_using_connection_costs(n, connection_costs_to_bus, out def _aggregate_and_move_components(n, busmap, connection_costs_to_bus, output, aggregate_one_ports={"Load", "StorageUnit"}, - aggregation_strategies=dict()): + aggregation_strategies=dict(), exclude_carriers=None): def replace_components(n, c, df, pnl): n.mremove(c, n.df(c).index) @@ -210,9 +210,10 @@ def _aggregate_and_move_components(n, busmap, connection_costs_to_bus, output, _adjust_capital_costs_using_connection_costs(n, connection_costs_to_bus, output) _, generator_strategies = get_aggregation_strategies(aggregation_strategies) - + + carriers=set(n.carriers.index)-set(exclude_carriers) generators, generators_pnl = aggregategenerators( - n, busmap, custom_strategies=generator_strategies + n, busmap, carriers=carriers, custom_strategies=generator_strategies ) replace_components(n, "Generator", generators, generators_pnl) @@ -320,8 +321,9 @@ def simplify_links(n, costs, config, output, aggregation_strategies=dict()): logger.debug("Collecting all components using the busmap") + exclude_carriers=config["clustering"]["exclude_carriers"] _aggregate_and_move_components(n, busmap, connection_costs_to_bus, output, - aggregation_strategies=aggregation_strategies) + aggregation_strategies=aggregation_strategies, exclude_carriers=exclude_carriers) return n, busmap def remove_stubs(n, costs, config, output, aggregation_strategies=dict()): @@ -331,8 +333,9 @@ def remove_stubs(n, costs, config, output, aggregation_strategies=dict()): connection_costs_to_bus = _compute_connection_costs_to_bus(n, busmap, costs, config) + exclude_carriers=config["clustering"]["exclude_carriers"] _aggregate_and_move_components(n, busmap, connection_costs_to_bus, output, - aggregation_strategies=aggregation_strategies) + aggregation_strategies=aggregation_strategies, exclude_carriers=exclude_carriers) return n, busmap diff --git a/test/config.test1.yaml b/test/config.test1.yaml index a9df427b..9cc4015b 100755 --- a/test/config.test1.yaml +++ b/test/config.test1.yaml @@ -189,6 +189,7 @@ clustering: cluster_network: algorithm: kmeans feature: solar+onwind-time + exclude_carriers: ["OCGT", "offwind-ac", "coal"] aggregation_strategies: generators: p_nom_max: sum # use "min" for more conservative assumptions