From 44ee205820f937923e6aac1b2d85b27d81d7a42b Mon Sep 17 00:00:00 2001 From: Tom Brown Date: Mon, 21 Sep 2020 17:04:45 +0200 Subject: [PATCH] Fix recalculation of offshore connection costs for "m" clusters I.e. when the generators are clustered to the "simplified" network resolution, but the grid is clustered further, e.g. by using the clusters = 37m "m" option. --- scripts/prepare_sector_network.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index eef8206b..f635b78b 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -73,6 +73,7 @@ def update_wind_solar_costs(n,costs): #map simplified network -> clustered network busmap = pd.read_hdf(snakemake.input.clustermaps, key="/busmap") + #map initial network -> clustered network clustermaps = busmap_s.map(busmap) #code adapted from pypsa-eur/scripts/add_electricity.py @@ -90,7 +91,16 @@ def update_wind_solar_costs(n,costs): #convert to aggregated clusters with weighting weight = ds['weight'].to_pandas() - connection_cost = (connection_cost*weight).groupby(clustermaps).sum()/weight.groupby(clustermaps).sum() + + #e.g. clusters == 37m means that VRE generators are left + #at clustering of simplified network, but that they are + #connected to 37-node network + if snakemake.wildcards.clusters[-1:] == "m": + genmap = busmap_s + else: + genmap = clustermaps + + connection_cost = (connection_cost*weight).groupby(genmap).sum()/weight.groupby(genmap).sum() capital_cost = (costs.at['offwind', 'fixed'] + costs.at[tech + '-station', 'fixed'] +