diff --git a/config/config.default.yaml b/config/config.default.yaml index d438c51f..42132f22 100644 --- a/config/config.default.yaml +++ b/config/config.default.yaml @@ -360,8 +360,8 @@ solar_thermal: # docs in https://pypsa-eur.readthedocs.io/en/latest/configuration.html#existing-capacities existing_capacities: - grouping_years_power: [1960, 1965, 1970, 1975, 1980, 1985, 1990, 1995, 2000, 2005, 2010, 2015, 2020, 2025, 2030] - grouping_years_heat: [1980, 1985, 1990, 1995, 2000, 2005, 2010, 2015, 2019] # these should not extend 2020 + grouping_years_power: [1895, 1920, 1950, 1955, 1960, 1965, 1970, 1975, 1980, 1985, 1990, 1995, 2000, 2005, 2010, 2015, 2020, 2025, 2030] + grouping_years_heat: [1980, 1985, 1990, 1995, 2000, 2005, 2010, 2015, 2020] # heat grouping years >= baseyear will be ignored threshold_capacity: 10 default_heating_lifetime: 20 conventional_carriers: diff --git a/doc/release_notes.rst b/doc/release_notes.rst index d42b149f..079648d5 100644 --- a/doc/release_notes.rst +++ b/doc/release_notes.rst @@ -9,6 +9,9 @@ Release Notes Upcoming Release ================ +* Group existing capacities to the earlier grouping_year for consistency with optimized capacities. + +* bugfix: installed heating capacities were 5% lower than existing heating capacities * Include gas and oil fields and saline aquifers in estimation of CO2 sequestration potential. diff --git a/scripts/add_brownfield.py b/scripts/add_brownfield.py index 7e49031b..16b4e087 100644 --- a/scripts/add_brownfield.py +++ b/scripts/add_brownfield.py @@ -40,8 +40,8 @@ def add_brownfield(n, n_p, year): # CO2 or global EU values since these are already in n n_p.mremove(c.name, c.df.index[c.df.lifetime == np.inf]) - # remove assets whose build_year + lifetime < year - n_p.mremove(c.name, c.df.index[c.df.build_year + c.df.lifetime < year]) + # remove assets whose build_year + lifetime <= year + n_p.mremove(c.name, c.df.index[c.df.build_year + c.df.lifetime <= year]) # remove assets if their optimized nominal capacity is lower than a threshold # since CHP heat Link is proportional to CHP electric Link, make sure threshold is compatible diff --git a/scripts/add_existing_baseyear.py b/scripts/add_existing_baseyear.py index f1028099..e75fe5a2 100644 --- a/scripts/add_existing_baseyear.py +++ b/scripts/add_existing_baseyear.py @@ -189,8 +189,19 @@ def add_power_capacities_installed_before_baseyear(n, grouping_years, costs, bas phased_out = df_agg[df_agg["DateOut"] < baseyear].index df_agg.drop(phased_out, inplace=True) + older_assets = (df_agg.DateIn < min(grouping_years)).sum() + if older_assets: + logger.warning( + f"There are {older_assets} assets with build year " + f"before first power grouping year {min(grouping_years)}. " + "These assets are dropped and not considered." + "Consider to redefine the grouping years to keep them." + ) + to_drop = df_agg[df_agg.DateIn < min(grouping_years)].index + df_agg.drop(to_drop, inplace=True) + df_agg["grouping_year"] = np.take( - grouping_years, np.digitize(df_agg.DateIn, grouping_years, right=True) + grouping_years[::-1], np.digitize(df_agg.DateIn, grouping_years[::-1]) ) # calculate (adjusted) remaining lifetime before phase-out (+1 because assuming @@ -451,12 +462,25 @@ def add_heating_capacities_installed_before_baseyear( else: efficiency = costs.at[costs_name, "efficiency"] - for i, grouping_year in enumerate(grouping_years): - if int(grouping_year) + default_lifetime <= int(baseyear): - continue + valid_grouping_years = pd.Series( + [ + int(grouping_year) + for grouping_year in grouping_years + if int(grouping_year) + default_lifetime > int(baseyear) + and int(grouping_year) < int(baseyear) + ] + ) - # installation is assumed to be linear for the past default_lifetime years - ratio = (int(grouping_year) - int(grouping_years[i - 1])) / default_lifetime + # get number of years of each interval + _years = ( + valid_grouping_years.diff() + .shift(-1) + .fillna(baseyear - valid_grouping_years.iloc[-1]) + ) + # Installation is assumed to be linear for the past + ratios = _years / _years.sum() + + for ratio, grouping_year in zip(ratios, valid_grouping_years): n.madd( "Link",