From ba41f4d66b112e487c3ce963a57cfb35ab35103f Mon Sep 17 00:00:00 2001 From: cpschau Date: Tue, 24 Sep 2024 14:25:20 +0200 Subject: [PATCH 1/4] remove sector_opts; drop german chp plants from ppm --- scripts/add_existing_baseyear.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/scripts/add_existing_baseyear.py b/scripts/add_existing_baseyear.py index c8ff5f680..d99c7b355 100644 --- a/scripts/add_existing_baseyear.py +++ b/scripts/add_existing_baseyear.py @@ -161,12 +161,9 @@ def add_power_capacities_installed_before_baseyear(n, grouping_years, costs, bas # If heat is considered, add CHPs in the add_heating_capacities function. # Assume that all oil power plants are not CHPs. - if "H" in snakemake.wildcards.sector_opts.split("-"): + if snakemake.params.sector["heating"]: df_agg = df_agg.query("Set != 'CHP'") - elif ( - "I" not in snakemake.wildcards.sector_opts.split("-") - and "Industry" in df_agg.columns - ): + elif not snakemake.params.sector["industry"] and "Industry" in df_agg.columns: df_agg["Industry"].fillna(False, inplace=True) df_agg.query("not Industry", inplace=True) @@ -492,6 +489,7 @@ def add_chp_plants(n, grouping_years, costs, baseyear, clustermaps): ppl = pd.read_csv(snakemake.input.powerplants, index_col=0) if snakemake.input.get("custom_powerplants"): + ppl = ppl.query("~(Set == 'CHP' and Country == 'DE')") ppl = add_custom_powerplants(ppl, snakemake.input.custom_powerplants, True) # drop assets which are already phased out / decommissioned @@ -517,7 +515,7 @@ def add_chp_plants(n, grouping_years, costs, baseyear, clustermaps): # check if the CHPs were read in from MaStR for Germany if "Capacity_thermal" in chp.columns: - if "I" not in snakemake.wildcards.sector_opts.split("-"): + if not snakemake.params.sector["industry"]: chp.query("Industry == False", inplace=True) thermal_capacity_b = ~chp.Capacity_thermal.isna() @@ -1054,13 +1052,14 @@ def set_defaults(n): snakemake = mock_snakemake( "add_existing_baseyear", - configfiles="config/test/config.myopic.yaml", + # configfiles="config/test/config.myopic.yaml", simpl="", - clusters="5", - ll="v1.5", + clusters=27, opts="", - sector_opts="", - planning_horizons=2030, + ll="vopt", + sector_opts="none", + planning_horizons="2020", + run="KN2045_Bal_v4", ) configure_logging(snakemake) From ea604a3e11443f88fda42b8813f000de89fc62bb Mon Sep 17 00:00:00 2001 From: cpschau Date: Tue, 24 Sep 2024 14:36:24 +0200 Subject: [PATCH 2/4] use options variable --- scripts/add_existing_baseyear.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/add_existing_baseyear.py b/scripts/add_existing_baseyear.py index d99c7b355..62a198631 100644 --- a/scripts/add_existing_baseyear.py +++ b/scripts/add_existing_baseyear.py @@ -161,9 +161,9 @@ def add_power_capacities_installed_before_baseyear(n, grouping_years, costs, bas # If heat is considered, add CHPs in the add_heating_capacities function. # Assume that all oil power plants are not CHPs. - if snakemake.params.sector["heating"]: + if options["heating"]: df_agg = df_agg.query("Set != 'CHP'") - elif not snakemake.params.sector["industry"] and "Industry" in df_agg.columns: + elif not options["industry"] and "Industry" in df_agg.columns: df_agg["Industry"].fillna(False, inplace=True) df_agg.query("not Industry", inplace=True) @@ -515,7 +515,7 @@ def add_chp_plants(n, grouping_years, costs, baseyear, clustermaps): # check if the CHPs were read in from MaStR for Germany if "Capacity_thermal" in chp.columns: - if not snakemake.params.sector["industry"]: + if not options["industry"]: chp.query("Industry == False", inplace=True) thermal_capacity_b = ~chp.Capacity_thermal.isna() @@ -1052,7 +1052,6 @@ def set_defaults(n): snakemake = mock_snakemake( "add_existing_baseyear", - # configfiles="config/test/config.myopic.yaml", simpl="", clusters=27, opts="", From 30702125ef3aa486d8eabd6ccfd40cee4809340d Mon Sep 17 00:00:00 2001 From: Michael Lindner Date: Thu, 26 Sep 2024 13:50:46 +0200 Subject: [PATCH 3/4] apply filter only when german_chp.csv is present --- scripts/add_existing_baseyear.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/add_existing_baseyear.py b/scripts/add_existing_baseyear.py index 62a198631..fa61ebf57 100644 --- a/scripts/add_existing_baseyear.py +++ b/scripts/add_existing_baseyear.py @@ -489,7 +489,9 @@ def add_chp_plants(n, grouping_years, costs, baseyear, clustermaps): ppl = pd.read_csv(snakemake.input.powerplants, index_col=0) if snakemake.input.get("custom_powerplants"): - ppl = ppl.query("~(Set == 'CHP' and Country == 'DE')") + if snakemake.input.custom_powerplants.endswith("german_chp.csv"): + logger.info("Supersedeing default German CHPs with custom_powerplants.") + ppl = ppl.query("~(Set == 'CHP' and Country == 'DE')") ppl = add_custom_powerplants(ppl, snakemake.input.custom_powerplants, True) # drop assets which are already phased out / decommissioned From 5b8b8d9f6a492f22a857d3fd84fc0f16cfbe3003 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 26 Sep 2024 13:22:20 +0000 Subject: [PATCH 4/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- scripts/prepare_sector_network.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index f083547fb..745a2317c 100755 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -866,7 +866,8 @@ def add_allam_gas(n, costs): carrier="allam gas", p_nom_extendable=True, capital_cost=costs.at["allam", "fixed"] * costs.at["allam", "efficiency"], - overnight_cost=costs.at["allam", "investment"] * costs.at["allam", "efficiency"], + overnight_cost=costs.at["allam", "investment"] + * costs.at["allam", "efficiency"], marginal_cost=costs.at["allam", "VOM"] * costs.at["allam", "efficiency"], efficiency=costs.at["allam", "efficiency"], efficiency2=0.98 * costs.at["gas", "CO2 intensity"], @@ -952,7 +953,8 @@ def add_methanol_to_power(n, costs, types=None): carrier="allam methanol", p_nom_extendable=True, capital_cost=costs.at["allam", "fixed"] * costs.at["allam", "efficiency"], - overnight_cost=costs.at["allam", "investment"] * costs.at["allam", "efficiency"], + overnight_cost=costs.at["allam", "investment"] + * costs.at["allam", "efficiency"], marginal_cost=costs.at["allam", "VOM"] * costs.at["allam", "efficiency"], efficiency=costs.at["allam", "efficiency"], efficiency2=0.98 * costs.at["methanolisation", "carbondioxide-input"], @@ -976,7 +978,8 @@ def add_methanol_to_power(n, costs, types=None): carrier="CCGT methanol", p_nom_extendable=True, capital_cost=capital_cost, - overnight_cost=costs.at["CCGT", "investment"], * costs.at["CCGT", "efficiency"], + overnight_cost=costs.at["CCGT", "investment"], + *costs.at["CCGT", "efficiency"], marginal_cost=costs.at["CCGT", "VOM"], efficiency=costs.at["CCGT", "efficiency"], efficiency2=costs.at["methanolisation", "carbondioxide-input"], @@ -1005,7 +1008,6 @@ def add_methanol_to_power(n, costs, types=None): * costs.at["methanolisation", "carbondioxide-input"] ) - n.madd( "Link", nodes, @@ -1040,7 +1042,8 @@ def add_methanol_to_power(n, costs, types=None): carrier="OCGT methanol", p_nom_extendable=True, capital_cost=costs.at["OCGT", "fixed"] * costs.at["OCGT", "efficiency"], - overnight_cost=costs.at["OCGT", "investment"] * costs.at["OCGT", "efficiency"], + overnight_cost=costs.at["OCGT", "investment"] + * costs.at["OCGT", "efficiency"], marginal_cost=costs.at["OCGT", "VOM"] * costs.at["OCGT", "efficiency"], efficiency=costs.at["OCGT", "efficiency"], efficiency2=costs.at["methanolisation", "carbondioxide-input"], @@ -3584,7 +3587,7 @@ def add_biomass(n, costs): + costs.at["biomass CHP capture", "investment"] * costs.at["solid biomass", "CO2 intensity"], marginal_cost=0.0, - lifetime=25, # TODO: add value to technology-data + lifetime=25, # TODO: add value to technology-data )