cluster_network: adjust generator strategy for new columns

This commit is contained in:
Fabian 2022-06-10 00:54:54 +02:00
parent f5a9a27a5d
commit 13992125bd
3 changed files with 18 additions and 5 deletions

View File

@ -309,7 +309,7 @@ def attach_conventional_generators(n, costs, ppl, conventional_carriers, extenda
ppl = (ppl.query('carrier in @carriers').join(costs, on='carrier', rsuffix='_r')
.rename(index=lambda s: 'C' + str(s)))
ppl.efficiency.update(ppl.efficiency_r.dropna())
ppl["efficiency"] = ppl.efficiency.fillna(ppl.efficiency_r)
logger.info('Adding {} generators with capacities [GW] \n{}'
.format(len(ppl), ppl.groupby('carrier').p_nom.sum().div(1e3).round(2)))

View File

@ -281,7 +281,9 @@ def clustering_for_n_clusters(n, n_clusters, custom_busmap=False, aggregate_carr
aggregate_generators_carriers=aggregate_carriers,
aggregate_one_ports=["Load", "StorageUnit"],
line_length_factor=line_length_factor,
generator_strategies={'p_nom_max': p_nom_max_strategy, 'p_nom_min': pd.Series.sum},
generator_strategies={'p_nom_max': p_nom_max_strategy, 'p_nom_min': pd.Series.sum,
'build_year': lambda x: 0, 'lifetime': lambda x: np.inf,
'efficiency': np.mean},
scale_link_capital_costs=False)
if not n.links.empty:
@ -342,7 +344,7 @@ if __name__ == "__main__":
if snakemake.wildcards.clusters.endswith('m'):
n_clusters = int(snakemake.wildcards.clusters[:-1])
aggregate_carriers = pd.Index(n.generators.carrier.unique()).difference(renewable_carriers)
aggregate_carriers = None
elif snakemake.wildcards.clusters == 'all':
n_clusters = len(n.buses)
aggregate_carriers = None # All

View File

@ -200,7 +200,14 @@ def _aggregate_and_move_components(n, busmap, connection_costs_to_bus, output, a
_adjust_capital_costs_using_connection_costs(n, connection_costs_to_bus, output)
generators, generators_pnl = aggregategenerators(n, busmap, custom_strategies={'p_nom_min': np.sum})
strategies = {
'p_nom_min': np.sum,
'p_nom_max': 'sum',
'build_year': lambda x: 0,
'lifetime': lambda x: np.inf,
'efficiency': np.mean
}
generators, generators_pnl = aggregategenerators(n, busmap, custom_strategies=strategies)
replace_components(n, "Generator", generators, generators_pnl)
for one_port in aggregate_one_ports:
@ -351,7 +358,11 @@ def aggregate_to_substations(n, buses_i=None):
aggregate_generators_carriers=None,
aggregate_one_ports=["Load", "StorageUnit"],
line_length_factor=1.0,
generator_strategies={'p_nom_max': 'sum'},
generator_strategies={'p_nom_max': 'sum',
'build_year': lambda x: 0,
'lifetime': lambda x: np.inf,
'efficiency': np.mean
},
scale_link_capital_costs=False)
return clustering.network, busmap