From b29e1c196eb71896559f7235bdaa6864ff616cb7 Mon Sep 17 00:00:00 2001 From: millingermarkus Date: Thu, 30 May 2024 14:28:34 +0200 Subject: [PATCH 01/79] Added msw incineration --- scripts/prepare_sector_network.py | 97 +++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index 9f53e317..a0b36286 100755 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -61,13 +61,18 @@ def define_spatial(nodes, options): spatial.biomass.locations = nodes spatial.biomass.industry = nodes + " solid biomass for industry" spatial.biomass.industry_cc = nodes + " solid biomass for industry CC" + spatial.msw.nodes = nodes + " municipal solid waste" + spatial.msw.locations = nodes else: spatial.biomass.nodes = ["EU solid biomass"] spatial.biomass.locations = ["EU"] spatial.biomass.industry = ["solid biomass for industry"] spatial.biomass.industry_cc = ["solid biomass for industry CC"] + spatial.msw.nodes = ["EU municipal solid waste"] + spatial.msw.locations = ["EU"] spatial.biomass.df = pd.DataFrame(vars(spatial.biomass), index=nodes) + spatial.msw.df = pd.DataFrame(vars(spatial.msw), index=nodes) # co2 @@ -2161,11 +2166,16 @@ def add_biomass(n, costs): solid_biomass_potentials_spatial = biomass_potentials["solid biomass"].rename( index=lambda x: x + " solid biomass" ) + msw_biomass_potentials_spatial = biomass_potentials["municipal solid waste"].rename( + index=lambda x: x + " municipal solid waste" + ) else: solid_biomass_potentials_spatial = biomass_potentials["solid biomass"].sum() + msw_biomass_potentials_spatial = biomass_potentials["municipal solid waste"].sum() n.add("Carrier", "biogas") n.add("Carrier", "solid biomass") + n.add("Carrier", "municipal solid waste") n.madd( "Bus", @@ -2183,6 +2193,11 @@ def add_biomass(n, costs): unit="MWh_LHV", ) + n.madd("Bus", + spatial.msw.nodes, + location=spatial.msw.locations, + carrier="municipal solid waste") + n.madd( "Store", spatial.gas.biogas, @@ -2203,6 +2218,15 @@ def add_biomass(n, costs): e_initial=solid_biomass_potentials_spatial, ) + n.madd("Store", + spatial.msw.nodes, + bus=spatial.msw.nodes, + carrier="municipal solid waste", + e_nom=msw_biomass_potentials_spatial, + marginal_cost=0,#costs.at["municipal solid waste", "fuel"], + e_initial=msw_biomass_potentials_spatial, + ) + n.madd( "Link", spatial.gas.biogas_to_gas, @@ -2274,6 +2298,18 @@ def add_biomass(n, costs): carrier="solid biomass transport", ) + n.madd( + "Link", + biomass_transport.index, + bus0=biomass_transport.bus0 + " municipal solid waste", + bus1=biomass_transport.bus1 + " municipal solid waste", + p_nom_extendable=False, + p_nom=5e4, + length=biomass_transport.length.values, + marginal_cost=biomass_transport.costs * biomass_transport.length.values, + carrier="municipal solid waste transport", + ) + elif options["biomass_spatial"]: # add artificial biomass generators at nodes which include transport costs transport_costs = pd.read_csv( @@ -2303,6 +2339,25 @@ def add_biomass(n, costs): type="operational_limit", ) + #Add municipal solid waste + n.madd( + "Generator", + spatial.msw.nodes, + bus=spatial.msw.nodes, + carrier="municipal solid waste", + p_nom=10000, + marginal_cost=0#costs.at["municipal solid waste", "fuel"] + + bus_transport_costs * average_distance, + ) + n.add( + "GlobalConstraint", + "msw limit", + carrier_attribute="municipal solid waste", + sense="<=", + constant=biomass_potentials["municipal solid waste"].sum(), + type="operational_limit", + ) + # AC buses with district heating urban_central = n.buses.index[n.buses.carrier == "urban central heat"] if not urban_central.empty and options["chp"]: @@ -2359,6 +2414,48 @@ def add_biomass(n, costs): lifetime=costs.at[key, "lifetime"], ) + if options['waste_chp']: + print('Adding waste CHPs') + n.madd("Link", + urban_central + " waste CHP", + bus0=urban_central + " municipal solid waste", + bus1=urban_central, + bus4=urban_central + " urban central heat", + bus3="co2 atmosphere", + carrier="urban central waste incineration", + p_nom_extendable=True, + # p_nom=biomass_potential['municipal solid waste'] / 8760, + capital_cost=costs.at['waste CHP', 'fixed'] * costs.at['waste CHP', 'efficiency'], + marginal_cost=costs.at['waste CHP', 'VOM'], + efficiency=costs.at['waste CHP', 'efficiency'], + efficiency4=costs.at['waste CHP', 'efficiency-heat'], + efficiency3=costs.at['solid biomass', 'CO2 intensity']-costs.at['solid biomass', 'CO2 intensity'], + lifetime=costs.at['waste CHP', 'lifetime']) + + if beccs: + n.madd("Link", + urban_central + " waste CHP CC", + bus0=urban_central + " municipal solid waste", + bus1=urban_central, + bus4=urban_central + " urban central heat", + bus3="co2 atmosphere", + bus2="co2 stored", + carrier="urban central waste incineration CC", + p_nom_extendable=True, + # p_nom=costs.at['waste CHP CC', 'efficiency'] * biomass_potential['municipal solid waste'] / 8760, + capital_cost=costs.at['waste CHP CC', 'fixed'] * costs.at['waste CHP CC', 'efficiency'] + + costs.at['biomass CHP capture', 'fixed'] * costs.at['solid biomass', 'CO2 intensity'], + marginal_cost=costs.at['waste CHP CC', 'VOM'], + efficiency=costs.at['waste CHP CC', 'efficiency'], + efficiency4=costs.at['waste CHP CC', 'efficiency-heat'], + #Assuming same CO2 intensity as solid biomass + efficiency3=costs.at['solid biomass', 'CO2 intensity'] * (1 - options["cc_fraction"])-costs.at['solid biomass', 'CO2 intensity'], + efficiency2=costs.at['solid biomass', 'CO2 intensity'] * options["cc_fraction"], + c_b=costs.at['waste CHP CC', 'c_b'], + c_v=costs.at['waste CHP CC', 'c_v'], + lifetime=costs.at['waste CHP CC', 'lifetime']) + + if options["biomass_boiler"]: # TODO: Add surcharge for pellets nodes = pop_layout.index From c7ce47dffdfb0a31625d602e7ab1c2517e4cd6d3 Mon Sep 17 00:00:00 2001 From: millingermarkus Date: Wed, 3 Jul 2024 09:22:09 +0200 Subject: [PATCH 02/79] Energy penalty for solid biomass CHP --- scripts/prepare_sector_network.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index dfa06cac..6735fd7e 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -2417,28 +2417,22 @@ def add_biomass(n, costs): bus4=spatial.co2.df.loc[urban_central, "nodes"].values, carrier="urban central solid biomass CHP CC", p_nom_extendable=True, - capital_cost=costs.at[key, "fixed"] * costs.at[key, "efficiency"] + capital_cost=costs.at[key + " CC", "fixed"] * costs.at[key + " CC", "efficiency"] + costs.at["biomass CHP capture", "fixed"] * costs.at["solid biomass", "CO2 intensity"], - marginal_cost=costs.at[key, "VOM"], - efficiency=costs.at[key, "efficiency"] + marginal_cost=costs.at[key + " CC", "VOM"], + efficiency=costs.at[key + " CC", "efficiency"] - costs.at["solid biomass", "CO2 intensity"] * ( costs.at["biomass CHP capture", "electricity-input"] + costs.at["biomass CHP capture", "compression-electricity-input"] ), - efficiency2=costs.at[key, "efficiency-heat"] - + costs.at["solid biomass", "CO2 intensity"] - * ( - costs.at["biomass CHP capture", "heat-output"] - + costs.at["biomass CHP capture", "compression-heat-output"] - - costs.at["biomass CHP capture", "heat-input"] - ), + efficiency2=costs.at[key + " CC", "efficiency-heat"], efficiency3=-costs.at["solid biomass", "CO2 intensity"] * costs.at["biomass CHP capture", "capture_rate"], efficiency4=costs.at["solid biomass", "CO2 intensity"] * costs.at["biomass CHP capture", "capture_rate"], - lifetime=costs.at[key, "lifetime"], + lifetime=costs.at[key + " CC", "lifetime"], ) if options["biomass_boiler"]: From b5ff1e8f9c935d89cebd87da9f2692f6bb3d3e2b Mon Sep 17 00:00:00 2001 From: millingermarkus Date: Wed, 3 Jul 2024 09:38:08 +0200 Subject: [PATCH 03/79] Added note on carbon capture for BioSNG and BtL --- scripts/prepare_sector_network.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index 6735fd7e..18ed90c4 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -2478,7 +2478,8 @@ def add_biomass(n, costs): marginal_cost=costs.at["BtL", "efficiency"] * costs.at["BtL", "VOM"], ) - # TODO: Update with energy penalty + #Assuming that acid gas removal (incl. CO2) from syngas i performed with Rectisol + #process (Methanol) and that electricity demand for this is included in the base process n.madd( "Link", spatial.biomass.nodes, @@ -2518,7 +2519,8 @@ def add_biomass(n, costs): marginal_cost=costs.at["BioSNG", "efficiency"] * costs.at["BioSNG", "VOM"], ) - # TODO: Update with energy penalty for CC + # Assuming that acid gas removal (incl. CO2) from syngas i performed with Rectisol + # process (Methanol) and that electricity demand for this is included in the base process n.madd( "Link", spatial.biomass.nodes, From 76e15d6862636d7c134f28e7ca28d0dab4e9c678 Mon Sep 17 00:00:00 2001 From: millingermarkus Date: Wed, 3 Jul 2024 09:42:15 +0200 Subject: [PATCH 04/79] Carbon capture capital cost for waste CHP --- scripts/prepare_sector_network.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index 18ed90c4..461a6db6 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -3100,7 +3100,9 @@ def add_industry(n, costs): carrier="waste CHP CC", p_nom_extendable=True, capital_cost=costs.at["waste CHP CC", "fixed"] - * costs.at["waste CHP CC", "efficiency"], + * costs.at["waste CHP CC", "efficiency"] + + costs.at['biomass CHP capture', 'fixed'] + * costs.at['oil', 'CO2 intensity'], marginal_cost=costs.at["waste CHP CC", "VOM"], efficiency=costs.at["waste CHP CC", "efficiency"], efficiency2=costs.at["waste CHP CC", "efficiency-heat"], From 53328e89f2a6df6d2ba269141645488fe069aaad Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 3 Jul 2024 08:07:29 +0000 Subject: [PATCH 05/79] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- scripts/prepare_sector_network.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index 461a6db6..18d0d1a3 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -2417,7 +2417,8 @@ def add_biomass(n, costs): bus4=spatial.co2.df.loc[urban_central, "nodes"].values, carrier="urban central solid biomass CHP CC", p_nom_extendable=True, - capital_cost=costs.at[key + " CC", "fixed"] * costs.at[key + " CC", "efficiency"] + capital_cost=costs.at[key + " CC", "fixed"] + * costs.at[key + " CC", "efficiency"] + costs.at["biomass CHP capture", "fixed"] * costs.at["solid biomass", "CO2 intensity"], marginal_cost=costs.at[key + " CC", "VOM"], @@ -2478,8 +2479,8 @@ def add_biomass(n, costs): marginal_cost=costs.at["BtL", "efficiency"] * costs.at["BtL", "VOM"], ) - #Assuming that acid gas removal (incl. CO2) from syngas i performed with Rectisol - #process (Methanol) and that electricity demand for this is included in the base process + # Assuming that acid gas removal (incl. CO2) from syngas i performed with Rectisol + # process (Methanol) and that electricity demand for this is included in the base process n.madd( "Link", spatial.biomass.nodes, @@ -3101,8 +3102,8 @@ def add_industry(n, costs): p_nom_extendable=True, capital_cost=costs.at["waste CHP CC", "fixed"] * costs.at["waste CHP CC", "efficiency"] - + costs.at['biomass CHP capture', 'fixed'] - * costs.at['oil', 'CO2 intensity'], + + costs.at["biomass CHP capture", "fixed"] + * costs.at["oil", "CO2 intensity"], marginal_cost=costs.at["waste CHP CC", "VOM"], efficiency=costs.at["waste CHP CC", "efficiency"], efficiency2=costs.at["waste CHP CC", "efficiency-heat"], From 84ddfea91ee97064df58eaa51b56bf95337e8b80 Mon Sep 17 00:00:00 2001 From: millingermarkus Date: Wed, 3 Jul 2024 12:38:16 +0200 Subject: [PATCH 06/79] Added electrobiofuels --- config/config.default.yaml | 2 ++ scripts/prepare_sector_network.py | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/config/config.default.yaml b/config/config.default.yaml index ee61d366..60eff164 100644 --- a/config/config.default.yaml +++ b/config/config.default.yaml @@ -606,6 +606,7 @@ sector: conventional_generation: OCGT: gas biomass_to_liquid: false + electrobiofuels: false biosng: false limit_max_growth: enable: false @@ -1030,6 +1031,7 @@ plotting: services rural biomass boiler: '#c6cf98' services urban decentral biomass boiler: '#dde5b5' biomass to liquid: '#32CD32' + electrobiofuels: 'red' BioSNG: '#123456' # power transmission lines: '#6c9459' diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index dfa06cac..1a1f97c0 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -2505,6 +2505,36 @@ def add_biomass(n, costs): marginal_cost=costs.at["BtL", "efficiency"] * costs.at["BtL", "VOM"], ) + #Electrobiofuels (BtL with hydrogen addition to make more use of biogenic carbon). + #Combination of efuels and biomass to liquid, both based on Fischer-Tropsch. + #Experimental version - use with caution + if options['electrobiofuels'] and options.get("biomass_spatial", options["biomass_transport"]): + efuel_scale_factor = costs.at['BtL', 'C stored'] + n.madd( + "Link", + spatial.biomass.nodes, + suffix=" electrobiofuels", + bus0=spatial.biomass.nodes, + bus1=spatial.oil.nodes, + bus2=spatial.h2.nodes, + bus3="co2 atmosphere", + carrier="electrobiofuels", + lifetime=costs.at['electrobiofuels', 'lifetime'], + efficiency=costs.at['electrobiofuels', 'efficiency-biomass'], + efficiency2=-costs.at['electrobiofuels', 'efficiency-hydrogen'], + efficiency3=-costs.at['solid biomass', 'CO2 intensity'] + costs.at['BtL', 'CO2 stored'] + * (1 - costs.at['Fischer-Tropsch', 'capture rate']), + p_nom_extendable=True, + capital_cost=costs.at['BtL', 'fixed'] + * costs.at['BtL', 'efficiency'] / costs.at['electrobiofuels', 'efficiency-biomass'] + + efuel_scale_factor * costs.at['Fischer-Tropsch', 'fixed'] + * costs.at['Fischer-Tropsch', 'efficiency'] / costs.at['electrobiofuels', 'efficiency-hydrogen'], + marginal_cost=costs.at['BtL', 'VOM'] + * costs.at['BtL', 'efficiency'] / costs.at['electrobiofuels', 'efficiency-biomass'] + + efuel_scale_factor * costs.at['Fischer-Tropsch', 'VOM'] + * costs.at['Fischer-Tropsch', 'efficiency'] / costs.at['electrobiofuels', 'efficiency-hydrogen'] + ) + # BioSNG from solid biomass if options["biosng"]: n.madd( From b934653b65581b17ae462487f5cdcbed08c97b1d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 3 Jul 2024 10:42:04 +0000 Subject: [PATCH 07/79] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- scripts/prepare_sector_network.py | 45 ++++++++++++++++++------------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index 1a1f97c0..50d8e134 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -2505,11 +2505,13 @@ def add_biomass(n, costs): marginal_cost=costs.at["BtL", "efficiency"] * costs.at["BtL", "VOM"], ) - #Electrobiofuels (BtL with hydrogen addition to make more use of biogenic carbon). - #Combination of efuels and biomass to liquid, both based on Fischer-Tropsch. - #Experimental version - use with caution - if options['electrobiofuels'] and options.get("biomass_spatial", options["biomass_transport"]): - efuel_scale_factor = costs.at['BtL', 'C stored'] + # Electrobiofuels (BtL with hydrogen addition to make more use of biogenic carbon). + # Combination of efuels and biomass to liquid, both based on Fischer-Tropsch. + # Experimental version - use with caution + if options["electrobiofuels"] and options.get( + "biomass_spatial", options["biomass_transport"] + ): + efuel_scale_factor = costs.at["BtL", "C stored"] n.madd( "Link", spatial.biomass.nodes, @@ -2519,20 +2521,27 @@ def add_biomass(n, costs): bus2=spatial.h2.nodes, bus3="co2 atmosphere", carrier="electrobiofuels", - lifetime=costs.at['electrobiofuels', 'lifetime'], - efficiency=costs.at['electrobiofuels', 'efficiency-biomass'], - efficiency2=-costs.at['electrobiofuels', 'efficiency-hydrogen'], - efficiency3=-costs.at['solid biomass', 'CO2 intensity'] + costs.at['BtL', 'CO2 stored'] - * (1 - costs.at['Fischer-Tropsch', 'capture rate']), + lifetime=costs.at["electrobiofuels", "lifetime"], + efficiency=costs.at["electrobiofuels", "efficiency-biomass"], + efficiency2=-costs.at["electrobiofuels", "efficiency-hydrogen"], + efficiency3=-costs.at["solid biomass", "CO2 intensity"] + + costs.at["BtL", "CO2 stored"] + * (1 - costs.at["Fischer-Tropsch", "capture rate"]), p_nom_extendable=True, - capital_cost=costs.at['BtL', 'fixed'] - * costs.at['BtL', 'efficiency'] / costs.at['electrobiofuels', 'efficiency-biomass'] - + efuel_scale_factor * costs.at['Fischer-Tropsch', 'fixed'] - * costs.at['Fischer-Tropsch', 'efficiency'] / costs.at['electrobiofuels', 'efficiency-hydrogen'], - marginal_cost=costs.at['BtL', 'VOM'] - * costs.at['BtL', 'efficiency'] / costs.at['electrobiofuels', 'efficiency-biomass'] - + efuel_scale_factor * costs.at['Fischer-Tropsch', 'VOM'] - * costs.at['Fischer-Tropsch', 'efficiency'] / costs.at['electrobiofuels', 'efficiency-hydrogen'] + capital_cost=costs.at["BtL", "fixed"] + * costs.at["BtL", "efficiency"] + / costs.at["electrobiofuels", "efficiency-biomass"] + + efuel_scale_factor + * costs.at["Fischer-Tropsch", "fixed"] + * costs.at["Fischer-Tropsch", "efficiency"] + / costs.at["electrobiofuels", "efficiency-hydrogen"], + marginal_cost=costs.at["BtL", "VOM"] + * costs.at["BtL", "efficiency"] + / costs.at["electrobiofuels", "efficiency-biomass"] + + efuel_scale_factor + * costs.at["Fischer-Tropsch", "VOM"] + * costs.at["Fischer-Tropsch", "efficiency"] + / costs.at["electrobiofuels", "efficiency-hydrogen"], ) # BioSNG from solid biomass From 270ce82b9f22dce831dfd87c03e5068eb07e0e07 Mon Sep 17 00:00:00 2001 From: Markus Millinger <50738187+millingermarkus@users.noreply.github.com> Date: Thu, 4 Jul 2024 09:30:22 +0200 Subject: [PATCH 08/79] Cost correction --- scripts/prepare_sector_network.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index 50d8e134..b0155a99 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -2530,18 +2530,14 @@ def add_biomass(n, costs): p_nom_extendable=True, capital_cost=costs.at["BtL", "fixed"] * costs.at["BtL", "efficiency"] - / costs.at["electrobiofuels", "efficiency-biomass"] + efuel_scale_factor * costs.at["Fischer-Tropsch", "fixed"] - * costs.at["Fischer-Tropsch", "efficiency"] - / costs.at["electrobiofuels", "efficiency-hydrogen"], + * costs.at["Fischer-Tropsch", "efficiency"], marginal_cost=costs.at["BtL", "VOM"] * costs.at["BtL", "efficiency"] - / costs.at["electrobiofuels", "efficiency-biomass"] + efuel_scale_factor * costs.at["Fischer-Tropsch", "VOM"] - * costs.at["Fischer-Tropsch", "efficiency"] - / costs.at["electrobiofuels", "efficiency-hydrogen"], + * costs.at["Fischer-Tropsch", "efficiency"], ) # BioSNG from solid biomass From 192a8eb14bb2fb03d81d04e4a10e7695fac03615 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 4 Jul 2024 07:30:50 +0000 Subject: [PATCH 09/79] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- scripts/prepare_sector_network.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index b0155a99..8132f343 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -2528,13 +2528,11 @@ def add_biomass(n, costs): + costs.at["BtL", "CO2 stored"] * (1 - costs.at["Fischer-Tropsch", "capture rate"]), p_nom_extendable=True, - capital_cost=costs.at["BtL", "fixed"] - * costs.at["BtL", "efficiency"] + capital_cost=costs.at["BtL", "fixed"] * costs.at["BtL", "efficiency"] + efuel_scale_factor * costs.at["Fischer-Tropsch", "fixed"] * costs.at["Fischer-Tropsch", "efficiency"], - marginal_cost=costs.at["BtL", "VOM"] - * costs.at["BtL", "efficiency"] + marginal_cost=costs.at["BtL", "VOM"] * costs.at["BtL", "efficiency"] + efuel_scale_factor * costs.at["Fischer-Tropsch", "VOM"] * costs.at["Fischer-Tropsch", "efficiency"], From 821eb07e986696c4b9b4bd1071e3804fa948c143 Mon Sep 17 00:00:00 2001 From: Markus Millinger <50738187+millingermarkus@users.noreply.github.com> Date: Thu, 4 Jul 2024 09:59:45 +0200 Subject: [PATCH 10/79] Correct costs of BtL and BioSNG --- scripts/prepare_sector_network.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index 18d0d1a3..6862df97 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -2475,8 +2475,8 @@ def add_biomass(n, costs): efficiency2=-costs.at["solid biomass", "CO2 intensity"] + costs.at["BtL", "CO2 stored"], p_nom_extendable=True, - capital_cost=costs.at["BtL", "fixed"], - marginal_cost=costs.at["BtL", "efficiency"] * costs.at["BtL", "VOM"], + capital_cost=costs.at["BtL", "fixed"] * costs.at["BtL", "efficiency"], + marginal_cost=costs.at["BtL", "VOM"] * costs.at["BtL", "efficiency"], ) # Assuming that acid gas removal (incl. CO2) from syngas i performed with Rectisol @@ -2496,9 +2496,9 @@ def add_biomass(n, costs): + costs.at["BtL", "CO2 stored"] * (1 - costs.at["BtL", "capture rate"]), efficiency3=costs.at["BtL", "CO2 stored"] * costs.at["BtL", "capture rate"], p_nom_extendable=True, - capital_cost=costs.at["BtL", "fixed"] + capital_cost=costs.at["BtL", "fixed"] * costs.at["BtL", "efficiency"] + costs.at["biomass CHP capture", "fixed"] * costs.at["BtL", "CO2 stored"], - marginal_cost=costs.at["BtL", "efficiency"] * costs.at["BtL", "VOM"], + marginal_cost=costs.at["BtL", "VOM"] * costs.at["BtL", "efficiency"], ) # BioSNG from solid biomass @@ -2516,8 +2516,8 @@ def add_biomass(n, costs): efficiency3=-costs.at["solid biomass", "CO2 intensity"] + costs.at["BioSNG", "CO2 stored"], p_nom_extendable=True, - capital_cost=costs.at["BioSNG", "fixed"], - marginal_cost=costs.at["BioSNG", "efficiency"] * costs.at["BioSNG", "VOM"], + capital_cost=costs.at["BioSNG", "fixed"] * costs.at["BioSNG", "efficiency"], + marginal_cost=costs.at["BioSNG", "VOM"] * costs.at["BioSNG", "efficiency"], ) # Assuming that acid gas removal (incl. CO2) from syngas i performed with Rectisol @@ -2539,10 +2539,10 @@ def add_biomass(n, costs): + costs.at["BioSNG", "CO2 stored"] * (1 - costs.at["BioSNG", "capture rate"]), p_nom_extendable=True, - capital_cost=costs.at["BioSNG", "fixed"] + capital_cost=costs.at["BioSNG", "fixed"] * costs.at["BioSNG", "efficiency"] + costs.at["biomass CHP capture", "fixed"] * costs.at["BioSNG", "CO2 stored"], - marginal_cost=costs.at["BioSNG", "efficiency"] * costs.at["BioSNG", "VOM"], + marginal_cost=costs.at["BioSNG", "VOM"] * costs.at["BioSNG", "efficiency"], ) From c71fa78bfa4fe7471817416387837cf66623209c Mon Sep 17 00:00:00 2001 From: millingermarkus Date: Thu, 4 Jul 2024 10:18:19 +0200 Subject: [PATCH 11/79] Added biomass imports to prepare sector network --- config/config.default.yaml | 6 ++++ scripts/prepare_sector_network.py | 46 +++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/config/config.default.yaml b/config/config.default.yaml index ee61d366..a618ed95 100644 --- a/config/config.default.yaml +++ b/config/config.default.yaml @@ -628,6 +628,11 @@ sector: max_boost: 0.25 var_cf: true sustainability_factor: 0.0025 + solid_biomass_import: + enable: false + price: 54 #EUR/MWh + max_amount: 5 #EJ + upstream_emissions_factor: .1 #share of solid biomass CO2 emissions at full combustion # docs in https://pypsa-eur.readthedocs.io/en/latest/configuration.html#industry industry: @@ -1017,6 +1022,7 @@ plotting: biogas: '#e3d37d' biomass: '#baa741' solid biomass: '#baa741' + solid biomass import: '#d5ca8d' solid biomass transport: '#baa741' solid biomass for industry: '#7a6d26' solid biomass for industry CC: '#47411c' diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index dfa06cac..8332858a 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -2285,6 +2285,52 @@ def add_biomass(n, costs): e_initial=solid_biomass_potentials_spatial, ) + if options["solid_biomass_import"].get("enable", False): + biomass_import_price = options["solid_biomass_import"]["price"] + biomass_import_max_amount = round(options["solid_biomass_import"]["max_amount"] + * 1e9 / 3.6,0) #EJ --> MWh + biomass_import_upstream_emissions = round(options["solid_biomass_import"]["upstream_emissions_factor"] + * costs.at['solid biomass', 'CO2 intensity'],4) + + print("Adding biomass import with cost", biomass_import_price, + "EUR/MWh, a limit of", options["solid_biomass_import"]["max_amount"], + "EJ, and embedded emissions of", + options["solid_biomass_import"]["upstream_emissions_factor"] * 100, '%') + + n.add("Carrier", "solid biomass import") + + n.madd( + "Bus", + ["EU solid biomass import"], + location="EU", + carrier="solid biomass import" + ) + + n.madd( + "Store", + ["solid biomass import"], + bus=["EU solid biomass import"], + carrier="solid biomass import", + e_nom=biomass_import_max_amount, + marginal_cost=biomass_import_price, + e_initial=biomass_import_max_amount + ) + + n.madd( + "Link", + spatial.biomass.nodes, + suffix=" solid biomass import", + bus0=["EU solid biomass import"], + bus1=spatial.biomass.nodes, + bus2="co2 atmosphere", + carrier="solid biomass import", + efficiency=1., + efficiency2=biomass_import_upstream_emissions, + p_nom_extendable=True + ) + + + n.madd( "Link", spatial.gas.biogas_to_gas, From ee6d8b1e42788ad9bad8ef8f89c1303e9ceaf851 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 4 Jul 2024 08:22:21 +0000 Subject: [PATCH 12/79] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- scripts/prepare_sector_network.py | 35 ++++++++++++++++++------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index 8332858a..d7ca791c 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -2287,15 +2287,24 @@ def add_biomass(n, costs): if options["solid_biomass_import"].get("enable", False): biomass_import_price = options["solid_biomass_import"]["price"] - biomass_import_max_amount = round(options["solid_biomass_import"]["max_amount"] - * 1e9 / 3.6,0) #EJ --> MWh - biomass_import_upstream_emissions = round(options["solid_biomass_import"]["upstream_emissions_factor"] - * costs.at['solid biomass', 'CO2 intensity'],4) + biomass_import_max_amount = round( + options["solid_biomass_import"]["max_amount"] * 1e9 / 3.6, 0 + ) # EJ --> MWh + biomass_import_upstream_emissions = round( + options["solid_biomass_import"]["upstream_emissions_factor"] + * costs.at["solid biomass", "CO2 intensity"], + 4, + ) - print("Adding biomass import with cost", biomass_import_price, - "EUR/MWh, a limit of", options["solid_biomass_import"]["max_amount"], - "EJ, and embedded emissions of", - options["solid_biomass_import"]["upstream_emissions_factor"] * 100, '%') + print( + "Adding biomass import with cost", + biomass_import_price, + "EUR/MWh, a limit of", + options["solid_biomass_import"]["max_amount"], + "EJ, and embedded emissions of", + options["solid_biomass_import"]["upstream_emissions_factor"] * 100, + "%", + ) n.add("Carrier", "solid biomass import") @@ -2303,7 +2312,7 @@ def add_biomass(n, costs): "Bus", ["EU solid biomass import"], location="EU", - carrier="solid biomass import" + carrier="solid biomass import", ) n.madd( @@ -2313,7 +2322,7 @@ def add_biomass(n, costs): carrier="solid biomass import", e_nom=biomass_import_max_amount, marginal_cost=biomass_import_price, - e_initial=biomass_import_max_amount + e_initial=biomass_import_max_amount, ) n.madd( @@ -2324,13 +2333,11 @@ def add_biomass(n, costs): bus1=spatial.biomass.nodes, bus2="co2 atmosphere", carrier="solid biomass import", - efficiency=1., + efficiency=1.0, efficiency2=biomass_import_upstream_emissions, - p_nom_extendable=True + p_nom_extendable=True, ) - - n.madd( "Link", spatial.gas.biogas_to_gas, From 5c7bb2bf51304855d932da91b00c0a3ef7dbbfcf Mon Sep 17 00:00:00 2001 From: millingermarkus Date: Thu, 4 Jul 2024 11:16:00 +0200 Subject: [PATCH 13/79] Add option to exclude fossil fuels --- config/config.default.yaml | 1 + scripts/prepare_sector_network.py | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/config/config.default.yaml b/config/config.default.yaml index ee61d366..fb89878f 100644 --- a/config/config.default.yaml +++ b/config/config.default.yaml @@ -407,6 +407,7 @@ sector: biomass: true industry: true agriculture: true + fossil_fuels: true district_heating: potential: 0.6 progress: diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index dfa06cac..afef5c8f 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -542,11 +542,19 @@ def add_carrier_buses(n, carrier, nodes=None): capital_cost=capital_cost, ) + fossils = ['coal', 'gas', 'oil', 'lignite'] + if not options.get('fossil_fuels',True) and carrier in fossils: + print('Not adding fossil ', carrier) + extendable = False + else: + print('Adding fossil ', carrier) + extendable = True + n.madd( "Generator", nodes, bus=nodes, - p_nom_extendable=True, + p_nom_extendable=extendable, carrier=carrier, marginal_cost=costs.at[carrier, "fuel"], ) @@ -2894,12 +2902,17 @@ def add_industry(n, costs): carrier="oil", ) + if not options.get('fossil_fuels', True): + extendable = False + else: + extendable = True + if "oil" not in n.generators.carrier.unique(): n.madd( "Generator", spatial.oil.nodes, bus=spatial.oil.nodes, - p_nom_extendable=True, + p_nom_extendable=extendable, carrier="oil", marginal_cost=costs.at["oil", "fuel"], ) From 5ca27837f37654e04c519081f40658215bec2c84 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 4 Jul 2024 09:20:58 +0000 Subject: [PATCH 14/79] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- scripts/prepare_sector_network.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index afef5c8f..e4fc3299 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -542,12 +542,12 @@ def add_carrier_buses(n, carrier, nodes=None): capital_cost=capital_cost, ) - fossils = ['coal', 'gas', 'oil', 'lignite'] - if not options.get('fossil_fuels',True) and carrier in fossils: - print('Not adding fossil ', carrier) + fossils = ["coal", "gas", "oil", "lignite"] + if not options.get("fossil_fuels", True) and carrier in fossils: + print("Not adding fossil ", carrier) extendable = False else: - print('Adding fossil ', carrier) + print("Adding fossil ", carrier) extendable = True n.madd( @@ -2902,7 +2902,7 @@ def add_industry(n, costs): carrier="oil", ) - if not options.get('fossil_fuels', True): + if not options.get("fossil_fuels", True): extendable = False else: extendable = True From c81d208da21fb15f1ba3da80b30dc0ee2cc9628d Mon Sep 17 00:00:00 2001 From: millingermarkus Date: Thu, 4 Jul 2024 11:59:32 +0200 Subject: [PATCH 15/79] Remove redundant Waste CHP addition --- scripts/prepare_sector_network.py | 42 ------------------------------- 1 file changed, 42 deletions(-) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index adeb8319..57d58fbb 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -2496,48 +2496,6 @@ def add_biomass(n, costs): lifetime=costs.at[key, "lifetime"], ) - if options['waste_chp']: - print('Adding waste CHPs') - n.madd("Link", - urban_central + " waste CHP", - bus0=urban_central + " municipal solid waste", - bus1=urban_central, - bus4=urban_central + " urban central heat", - bus3="co2 atmosphere", - carrier="urban central waste incineration", - p_nom_extendable=True, - # p_nom=biomass_potential['municipal solid waste'] / 8760, - capital_cost=costs.at['waste CHP', 'fixed'] * costs.at['waste CHP', 'efficiency'], - marginal_cost=costs.at['waste CHP', 'VOM'], - efficiency=costs.at['waste CHP', 'efficiency'], - efficiency4=costs.at['waste CHP', 'efficiency-heat'], - efficiency3=costs.at['solid biomass', 'CO2 intensity']-costs.at['solid biomass', 'CO2 intensity'], - lifetime=costs.at['waste CHP', 'lifetime']) - - if beccs: - n.madd("Link", - urban_central + " waste CHP CC", - bus0=urban_central + " municipal solid waste", - bus1=urban_central, - bus4=urban_central + " urban central heat", - bus3="co2 atmosphere", - bus2="co2 stored", - carrier="urban central waste incineration CC", - p_nom_extendable=True, - # p_nom=costs.at['waste CHP CC', 'efficiency'] * biomass_potential['municipal solid waste'] / 8760, - capital_cost=costs.at['waste CHP CC', 'fixed'] * costs.at['waste CHP CC', 'efficiency'] - + costs.at['biomass CHP capture', 'fixed'] * costs.at['solid biomass', 'CO2 intensity'], - marginal_cost=costs.at['waste CHP CC', 'VOM'], - efficiency=costs.at['waste CHP CC', 'efficiency'], - efficiency4=costs.at['waste CHP CC', 'efficiency-heat'], - #Assuming same CO2 intensity as solid biomass - efficiency3=costs.at['solid biomass', 'CO2 intensity'] * (1 - options["cc_fraction"])-costs.at['solid biomass', 'CO2 intensity'], - efficiency2=costs.at['solid biomass', 'CO2 intensity'] * options["cc_fraction"], - c_b=costs.at['waste CHP CC', 'c_b'], - c_v=costs.at['waste CHP CC', 'c_v'], - lifetime=costs.at['waste CHP CC', 'lifetime']) - - if options["biomass_boiler"]: # TODO: Add surcharge for pellets nodes = pop_layout.index From fbacb76e9c37f5191c49dd12de690483021f1e05 Mon Sep 17 00:00:00 2001 From: millingermarkus Date: Thu, 4 Jul 2024 13:34:05 +0200 Subject: [PATCH 16/79] Minor edits to MSW --- config/config.default.yaml | 4 +++- scripts/prepare_sector_network.py | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/config/config.default.yaml b/config/config.default.yaml index ee61d366..af38830f 100644 --- a/config/config.default.yaml +++ b/config/config.default.yaml @@ -365,7 +365,6 @@ biomass: - Secondary Forestry residues - woodchips - Sawdust - Residues from landscape care - - Municipal waste not included: - Sugar from sugar beet - Rape seed @@ -379,6 +378,8 @@ biomass: biogas: - Manure solid, liquid - Sludge + municipal solid waste: + - Municipal waste # docs in https://pypsa-eur.readthedocs.io/en/latest/configuration.html#solar-thermal solar_thermal: @@ -1017,6 +1018,7 @@ plotting: biogas: '#e3d37d' biomass: '#baa741' solid biomass: '#baa741' + municipal solid waste: '#91ba41' solid biomass transport: '#baa741' solid biomass for industry: '#7a6d26' solid biomass for industry CC: '#47411c' diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index 57d58fbb..297574a2 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -56,6 +56,7 @@ def define_spatial(nodes, options): # biomass spatial.biomass = SimpleNamespace() + spatial.msw = SimpleNamespace() if options.get("biomass_spatial", options["biomass_transport"]): spatial.biomass.nodes = nodes + " solid biomass" @@ -3110,6 +3111,17 @@ def add_industry(n, costs): efficiency3=process_co2_per_naphtha, ) + if options.get("biomass",True): + n.madd( + "Link", + spatial.msw.locations, + bus0=spatial.msw.nodes, + bus1=non_sequestered_hvc_locations, + carrier="municipal solid waste", + p_nom_extendable=True, + efficiency=1., + ) + n.madd( "Link", spatial.oil.demand_locations, From e42b36e83db6fe7c9b6d38ece0c5554c6e09510d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 4 Jul 2024 11:40:19 +0000 Subject: [PATCH 17/79] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- scripts/prepare_sector_network.py | 33 ++++++++++++++++++------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index 297574a2..66bb346e 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -2249,12 +2249,14 @@ def add_biomass(n, costs): solid_biomass_potentials_spatial = biomass_potentials["solid biomass"].rename( index=lambda x: x + " solid biomass" ) - msw_biomass_potentials_spatial = biomass_potentials["municipal solid waste"].rename( - index=lambda x: x + " municipal solid waste" - ) + msw_biomass_potentials_spatial = biomass_potentials[ + "municipal solid waste" + ].rename(index=lambda x: x + " municipal solid waste") else: solid_biomass_potentials_spatial = biomass_potentials["solid biomass"].sum() - msw_biomass_potentials_spatial = biomass_potentials["municipal solid waste"].sum() + msw_biomass_potentials_spatial = biomass_potentials[ + "municipal solid waste" + ].sum() n.add("Carrier", "biogas") n.add("Carrier", "solid biomass") @@ -2276,10 +2278,12 @@ def add_biomass(n, costs): unit="MWh_LHV", ) - n.madd("Bus", - spatial.msw.nodes, - location=spatial.msw.locations, - carrier="municipal solid waste") + n.madd( + "Bus", + spatial.msw.nodes, + location=spatial.msw.locations, + carrier="municipal solid waste", + ) n.madd( "Store", @@ -2301,12 +2305,13 @@ def add_biomass(n, costs): e_initial=solid_biomass_potentials_spatial, ) - n.madd("Store", + n.madd( + "Store", spatial.msw.nodes, bus=spatial.msw.nodes, carrier="municipal solid waste", e_nom=msw_biomass_potentials_spatial, - marginal_cost=0,#costs.at["municipal solid waste", "fuel"], + marginal_cost=0, # costs.at["municipal solid waste", "fuel"], e_initial=msw_biomass_potentials_spatial, ) @@ -2422,14 +2427,14 @@ def add_biomass(n, costs): type="operational_limit", ) - #Add municipal solid waste + # Add municipal solid waste n.madd( "Generator", spatial.msw.nodes, bus=spatial.msw.nodes, carrier="municipal solid waste", p_nom=10000, - marginal_cost=0#costs.at["municipal solid waste", "fuel"] + marginal_cost=0 # costs.at["municipal solid waste", "fuel"] + bus_transport_costs * average_distance, ) n.add( @@ -3111,7 +3116,7 @@ def add_industry(n, costs): efficiency3=process_co2_per_naphtha, ) - if options.get("biomass",True): + if options.get("biomass", True): n.madd( "Link", spatial.msw.locations, @@ -3119,7 +3124,7 @@ def add_industry(n, costs): bus1=non_sequestered_hvc_locations, carrier="municipal solid waste", p_nom_extendable=True, - efficiency=1., + efficiency=1.0, ) n.madd( From 23ea16dc1401f8ac006bf658e6c5ddaec14cea9c Mon Sep 17 00:00:00 2001 From: Toni Seibold <153275395+toniseibold@users.noreply.github.com> Date: Mon, 29 Jul 2024 09:47:08 +0200 Subject: [PATCH 18/79] Lifetime of Gas Pipelines (#1162) * inf lifetime of gas pipelines avoids adding new links each planning horizon * p_nom_extendable for existing gas pipelines is set false if retrofitting to H2 is not allowed * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- scripts/add_brownfield.py | 8 -------- scripts/prepare_sector_network.py | 6 ++++-- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/scripts/add_brownfield.py b/scripts/add_brownfield.py index 672f9e62..72dd1c88 100644 --- a/scripts/add_brownfield.py +++ b/scripts/add_brownfield.py @@ -89,10 +89,6 @@ def add_brownfield(n, n_p, year): # deal with gas network pipe_carrier = ["gas pipeline"] if snakemake.params.H2_retrofit: - # drop capacities of previous year to avoid duplicating - to_drop = n.links.carrier.isin(pipe_carrier) & (n.links.build_year != year) - n.mremove("Link", n.links.loc[to_drop].index) - # subtract the already retrofitted from today's gas grid capacity h2_retrofitted_fixed_i = n.links[ (n.links.carrier == "H2 pipeline retrofitted") @@ -115,10 +111,6 @@ def add_brownfield(n, n_p, year): index=pipe_capacity.index ).fillna(0) n.links.loc[gas_pipes_i, "p_nom"] = remaining_capacity - else: - new_pipes = n.links.carrier.isin(pipe_carrier) & (n.links.build_year == year) - n.links.loc[new_pipes, "p_nom"] = 0.0 - n.links.loc[new_pipes, "p_nom_min"] = 0.0 def disable_grid_expansion_if_limit_hit(n): diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index b86f9557..970a1a0a 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -1238,12 +1238,14 @@ def add_storage_and_grids(n, costs): gas_pipes["p_nom_min"] = 0.0 # 0.1 EUR/MWkm/a to prefer decommissioning to address degeneracy gas_pipes["capital_cost"] = 0.1 * gas_pipes.length + gas_pipes["p_nom_extendable"] = True else: gas_pipes["p_nom_max"] = np.inf gas_pipes["p_nom_min"] = gas_pipes.p_nom gas_pipes["capital_cost"] = ( gas_pipes.length * costs.at["CH4 (g) pipeline", "fixed"] ) + gas_pipes["p_nom_extendable"] = False n.madd( "Link", @@ -1252,14 +1254,14 @@ def add_storage_and_grids(n, costs): bus1=gas_pipes.bus1 + " gas", p_min_pu=gas_pipes.p_min_pu, p_nom=gas_pipes.p_nom, - p_nom_extendable=True, + p_nom_extendable=gas_pipes.p_nom_extendable, p_nom_max=gas_pipes.p_nom_max, p_nom_min=gas_pipes.p_nom_min, length=gas_pipes.length, capital_cost=gas_pipes.capital_cost, tags=gas_pipes.name, carrier="gas pipeline", - lifetime=costs.at["CH4 (g) pipeline", "lifetime"], + lifetime=np.inf, ) # remove fossil generators where there is neither From f5fe0d062c136c86c92717f9fc311c76786972de Mon Sep 17 00:00:00 2001 From: Micha Date: Mon, 29 Jul 2024 09:50:02 +0200 Subject: [PATCH 19/79] Rename ev battery master (#1116) * rename EV battery * add release note * adjust tech colors * fix for battery renaming in plot_summary --------- Co-authored-by: Fabian Neumann --- config/config.default.yaml | 2 +- doc/release_notes.rst | 2 ++ scripts/prepare_perfect_foresight.py | 2 +- scripts/prepare_sector_network.py | 8 ++++---- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/config/config.default.yaml b/config/config.default.yaml index 4641837e..f1ab5f31 100644 --- a/config/config.default.yaml +++ b/config/config.default.yaml @@ -1054,7 +1054,7 @@ plotting: V2G: '#e5ffa8' land transport EV: '#baf238' land transport demand: '#38baf2' - Li ion: '#baf238' + EV battery: '#baf238' # hot water storage water tanks: '#e69487' residential rural water tanks: '#f7b7a3' diff --git a/doc/release_notes.rst b/doc/release_notes.rst index fa0473fc..383287a6 100644 --- a/doc/release_notes.rst +++ b/doc/release_notes.rst @@ -10,6 +10,8 @@ Release Notes Upcoming Release ================ +* Renamed the carrier of batteries in BEVs from `battery storage` to `EV battery` and the corresponding bus carrier from `Li ion` to `EV battery`. This is to avoid confusion with stationary battery storage. + * Changed default assumptions about waste heat usage from PtX and fuel cells in district heating. The default value for the link efficiency scaling factor was changed from 100% to 25%. It can be set to other values in the configuration ``sector: use_TECHNOLOGY_waste_heat``. diff --git a/scripts/prepare_perfect_foresight.py b/scripts/prepare_perfect_foresight.py index c5e4caf9..efc95700 100644 --- a/scripts/prepare_perfect_foresight.py +++ b/scripts/prepare_perfect_foresight.py @@ -250,7 +250,7 @@ def adjust_stores(n): n.stores.loc[cyclic_i, "e_cyclic_per_period"] = True n.stores.loc[cyclic_i, "e_cyclic"] = False # non cyclic store assumptions - non_cyclic_store = ["co2", "co2 stored", "solid biomass", "biogas", "Li ion"] + non_cyclic_store = ["co2", "co2 stored", "solid biomass", "biogas", "EV battery"] co2_i = n.stores[n.stores.carrier.isin(non_cyclic_store)].index n.stores.loc[co2_i, "e_cyclic_per_period"] = False n.stores.loc[co2_i, "e_cyclic"] = False diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index 970a1a0a..eaaf207d 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -1543,14 +1543,14 @@ def add_EVs( temperature, ): - n.add("Carrier", "Li ion") + n.add("Carrier", "EV battery") n.madd( "Bus", spatial.nodes, suffix=" EV battery", location=spatial.nodes, - carrier="Li ion", + carrier="EV battery", unit="MWh_el", ) @@ -1623,9 +1623,9 @@ def add_EVs( n.madd( "Store", spatial.nodes, - suffix=" battery storage", + suffix=" EV battery", bus=spatial.nodes + " EV battery", - carrier="battery storage", + carrier="EV battery", e_cyclic=True, e_nom=e_nom, e_max_pu=1, From 6c14d2072636302a33e7afcc71e20909ca304573 Mon Sep 17 00:00:00 2001 From: AmosSchledorn Date: Mon, 29 Jul 2024 10:26:47 +0200 Subject: [PATCH 20/79] checkout sector configtable from master --- doc/configtables/sector.csv | 70 ++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 39 deletions(-) diff --git a/doc/configtables/sector.csv b/doc/configtables/sector.csv index de2873ed..5045cecd 100644 --- a/doc/configtables/sector.csv +++ b/doc/configtables/sector.csv @@ -5,17 +5,9 @@ biomass,--,"{true, false}",Flag to include biomass sector. industry,--,"{true, false}",Flag to include industry sector. agriculture,--,"{true, false}",Flag to include agriculture sector. district_heating,--,,`prepare_sector_network.py `_ -#NAME?,--,float,maximum fraction of urban demand which can be supplied by district heating. Ignored where below current fraction. -#NAME?,--,Dictionary with planning horizons as keys., Increase of today's district heating demand to potential maximum district heating share. Progress = 0 means today's district heating share. Progress = 1 means maximum fraction of urban demand is supplied by district heating -#NAME?,--,float,Share increase in district heat demand in urban central due to heat losses -#NAME?,°C,float,Forward temperature in district heating -#NAME?,°C,float,Return temperature in district heating. Must be lower than forward temperature -#NAME?,K,float,Cooling of heat source for heat pumps -#NAME?,,, -#NAME?,--,"{ammonia, isobutane}",Heat pump refrigerant assumed for COP approximation -#NAME?,K,float,Heat pump pinch point temperature difference in heat exchangers assumed for approximation. -#NAME?,--,float,Isentropic efficiency of heat pump compressor assumed for approximation. Must be between 0 and 1. -#NAME?,--,float,Heat pump heat loss assumed for approximation. Must be between 0 and 1. +-- potential,--,float,maximum fraction of urban demand which can be supplied by district heating. Ignored where below current fraction. +-- progress,--,Dictionary with planning horizons as keys., Increase of today's district heating demand to potential maximum district heating share. Progress = 0 means today's district heating share. Progress = 1 means maximum fraction of urban demand is supplied by district heating +-- district_heating_loss,--,float,Share increase in district heat demand in urban central due to heat losses cluster_heat_buses,--,"{true, false}",Cluster residential and service heat buses in `prepare_sector_network.py `_ to one to save memory. ,,, bev_dsm_restriction _value,--,float,Adds a lower state of charge (SOC) limit for battery electric vehicles (BEV) to manage its own energy demand (DSM). Located in `build_transport_demand.py `_. Set to 0 for no restriction on BEV DSM @@ -65,21 +57,21 @@ heat_pump_sink_T,°C,float,The temperature heat sink used in heat pumps based on reduce_space_heat _exogenously,--,"{true, false}",Influence on space heating demand by a certain factor (applied before losses in district heating). reduce_space_heat _exogenously_factor,--,Dictionary with planning horizons as keys.,"A positive factor can mean renovation or demolition of a building. If the factor is negative, it can mean an increase in floor area, increased thermal comfort, population growth. The default factors are determined by the `Eurocalc Homes and buildings decarbonization scenario `_" retrofitting,,, -#NAME?,--,"{true, false}",Add retrofitting as an endogenous system which co-optimise space heat savings. -#NAME?,--,float,Weight costs for building renovation -#NAME?,--,float,The interest rate for investment in building components -#NAME?,--,"{true, false}",Annualise the investment costs of retrofitting -#NAME?,--,"{true, false}",Weight the costs of retrofitting depending on taxes in countries -#NAME?,--,"{true, false}",Weight the costs of retrofitting depending on labour/material costs per country +-- retro_endogen,--,"{true, false}",Add retrofitting as an endogenous system which co-optimise space heat savings. +-- cost_factor,--,float,Weight costs for building renovation +-- interest_rate,--,float,The interest rate for investment in building components +-- annualise_cost,--,"{true, false}",Annualise the investment costs of retrofitting +-- tax_weighting,--,"{true, false}",Weight the costs of retrofitting depending on taxes in countries +-- construction_index,--,"{true, false}",Weight the costs of retrofitting depending on labour/material costs per country tes,--,"{true, false}",Add option for storing thermal energy in large water pits associated with district heating systems and individual thermal energy storage (TES) tes_tau,,,The time constant used to calculate the decay of thermal energy in thermal energy storage (TES): 1- :math:`e^{-1/24τ}`. -#NAME?,days,float,The time constant in decentralized thermal energy storage (TES) -#NAME?,days,float,The time constant in centralized thermal energy storage (TES) +-- decentral,days,float,The time constant in decentralized thermal energy storage (TES) +-- central,days,float,The time constant in centralized thermal energy storage (TES) boilers,--,"{true, false}",Add option for transforming gas into heat using gas boilers resistive_heaters,--,"{true, false}",Add option for transforming electricity into heat using resistive heaters (independently from gas boilers) oil_boilers,--,"{true, false}",Add option for transforming oil into heat using boilers biomass_boiler,--,"{true, false}",Add option for transforming biomass into heat using boilers -overdimension_individual_heating,--,float,Add option for overdimensioning individual heating systems by a certain factor. This allows them to cover heat demand peaks e.g. 10% higher than those in the data with a setting of 1.1. +overdimension_individual_heating,--,"float",Add option for overdimensioning individual heating systems by a certain factor. This allows them to cover heat demand peaks e.g. 10% higher than those in the data with a setting of 1.1. chp,--,"{true, false}",Add option for using Combined Heat and Power (CHP) micro_chp,--,"{true, false}",Add option for using Combined Heat and Power (CHP) for decentral areas. solar_thermal,--,"{true, false}",Add option for using solar thermal to generate heat. @@ -97,12 +89,12 @@ SMR CC,--,"{true, false}",Add option for transforming natural gas into hydrogen regional_methanol_demand,--,"{true, false}",Spatially resolve methanol demand. Set to true if regional CO2 constraints needed. regional_oil_demand,--,"{true, false}",Spatially resolve oil demand. Set to true if regional CO2 constraints needed. regional_co2 _sequestration_potential,,, -#NAME?,--,"{true, false}",Add option for regionally-resolved geological carbon dioxide sequestration potentials based on `CO2StoP `_. -#NAME?,--,string or list,Name (or list of names) of the attribute(s) for the sequestration potential -#NAME?,--,"{true, false}",Add options for including onshore sequestration potentials -#NAME?,Gt ,float,Any sites with lower potential than this value will be excluded -#NAME?,Gt ,float,The maximum sequestration potential for any one site. -#NAME?,years,float,The years until potential exhausted at optimised annual rate +-- enable,--,"{true, false}",Add option for regionally-resolved geological carbon dioxide sequestration potentials based on `CO2StoP `_. +-- attribute,--,string or list,Name (or list of names) of the attribute(s) for the sequestration potential +-- include_onshore,--,"{true, false}",Add options for including onshore sequestration potentials +-- min_size,Gt ,float,Any sites with lower potential than this value will be excluded +-- max_size,Gt ,float,The maximum sequestration potential for any one site. +-- years_of_storage,years,float,The years until potential exhausted at optimised annual rate co2_sequestration_potential,MtCO2/a,float,The potential of sequestering CO2 in Europe per year co2_sequestration_cost,currency/tCO2,float,The cost of sequestering a ton of CO2 co2_sequestration_lifetime,years,int,The lifetime of a CO2 sequestration site @@ -129,9 +121,9 @@ electricity_distribution _grid_cost_factor,,,Multiplies the investment cost of t electricity_grid _connection,--,"{true, false}",Add the cost of electricity grid connection for onshore wind and solar transmission_efficiency,,,Section to specify transmission losses or compression energy demands of bidirectional links. Splits them into two capacity-linked unidirectional links. -- {carrier},--,str,The carrier of the link. -#NAME?,p.u.,float,Length-independent transmission efficiency. -#NAME?,p.u. per 1000 km,float,Length-dependent transmission efficiency ($\eta^{\text{length}}$) -#NAME?,p.u. per 1000 km,float,Length-dependent electricity demand for compression ($\eta \cdot \text{length}$) implemented as multi-link to local electricity bus. +-- -- efficiency_static,p.u.,float,Length-independent transmission efficiency. +-- -- efficiency_per_1000km,p.u. per 1000 km,float,Length-dependent transmission efficiency ($\eta^{\text{length}}$) +-- -- compression_per_1000km,p.u. per 1000 km,float,Length-dependent electricity demand for compression ($\eta \cdot \text{length}$) implemented as multi-link to local electricity bus. H2_network,--,"{true, false}",Add option for new hydrogen pipelines gas_network,--,"{true, false}","Add existing natural gas infrastructure, incl. LNG terminals, production and entry-points. The existing gas network is added with a lossless transport model. A length-weighted `k-edge augmentation algorithm `_ can be run to add new candidate gas pipelines such that all regions of the model can be connected to the gas network. When activated, all the gas demands are regionally disaggregated as well." H2_retrofit,--,"{true, false}",Add option for retrofiting existing pipelines to transport hydrogen. @@ -147,17 +139,17 @@ conventional_generation,,,Add a more detailed description of conventional carrie biomass_to_liquid,--,"{true, false}",Add option for transforming solid biomass into liquid fuel with the same properties as oil biosng,--,"{true, false}",Add option for transforming solid biomass into synthesis gas with the same properties as natural gas limit_max_growth,,, -#NAME?,--,"{true, false}",Add option to limit the maximum growth of a carrier -#NAME?,p.u.,float,The maximum growth factor of a carrier (e.g. 1.3 allows 30% larger than max historic growth) -#NAME?,,, +-- enable,--,"{true, false}",Add option to limit the maximum growth of a carrier +-- factor,p.u.,float,The maximum growth factor of a carrier (e.g. 1.3 allows 30% larger than max historic growth) +-- max_growth,,, -- -- {carrier},GW,float,The historic maximum growth of a carrier -#NAME?,,, +-- max_relative_growth,,, -- -- {carrier},p.u.,float,The historic maximum relative growth of a carrier ,,, enhanced_geothermal,,, -#NAME?,--,"{true, false}",Add option to include Enhanced Geothermal Systems -#NAME?,--,"{true, false}",Add option for flexible operation (see Ricks et al. 2024) -#NAME?,--,int,The maximum hours the reservoir can be charged under flexible operation -#NAME?,--,float,The maximum boost in power output under flexible operation -#NAME?,--,"{true, false}",Add option for variable capacity factor (see Ricks et al. 2024) -#NAME?,--,float,Share of sourced heat that is replenished by the earth's core (see details in `build_egs_potentials.py `_) +-- enable,--,"{true, false}",Add option to include Enhanced Geothermal Systems +-- flexible,--,"{true, false}",Add option for flexible operation (see Ricks et al. 2024) +-- max_hours,--,int,The maximum hours the reservoir can be charged under flexible operation +-- max_boost,--,float,The maximum boost in power output under flexible operation +-- var_cf,--,"{true, false}",Add option for variable capacity factor (see Ricks et al. 2024) +-- sustainability_factor,--,float,Share of sourced heat that is replenished by the earth's core (see details in `build_egs_potentials.py `_) From 9183846c6eee1b1df85459eb1189655e4d485faf Mon Sep 17 00:00:00 2001 From: AmosSchledorn Date: Mon, 29 Jul 2024 10:30:23 +0200 Subject: [PATCH 21/79] update sector configtable --- doc/configtables/sector.csv | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/doc/configtables/sector.csv b/doc/configtables/sector.csv index 5045cecd..17dae5e0 100644 --- a/doc/configtables/sector.csv +++ b/doc/configtables/sector.csv @@ -6,6 +6,14 @@ industry,--,"{true, false}",Flag to include industry sector. agriculture,--,"{true, false}",Flag to include agriculture sector. district_heating,--,,`prepare_sector_network.py `_ -- potential,--,float,maximum fraction of urban demand which can be supplied by district heating. Ignored where below current fraction. +-- forward_temperature,°C,float,Forward temperature in district heating +-- return_temperature,°C,float,Return temperature in district heating. Must be lower than forward temperature +-- heat_source_cooling,K,float,Cooling of heat source for heat pumps +-- heat_pump_cop_approximation,,, +-- refrigerant,--,"{ammonia, isobutane}",Heat pump refrigerant assumed for COP approximation +-- heat_exchanger_pinch_point_temperature_difference,K,float,Heat pump pinch point temperature difference in heat exchangers assumed for approximation. +-- isentropic_compressor_efficiency,--,float,Isentropic efficiency of heat pump compressor assumed for approximation. Must be between 0 and 1. +-- heat_loss,--,float,Heat pump heat loss assumed for approximation. Must be between 0 and 1. -- progress,--,Dictionary with planning horizons as keys., Increase of today's district heating demand to potential maximum district heating share. Progress = 0 means today's district heating share. Progress = 1 means maximum fraction of urban demand is supplied by district heating -- district_heating_loss,--,float,Share increase in district heat demand in urban central due to heat losses cluster_heat_buses,--,"{true, false}",Cluster residential and service heat buses in `prepare_sector_network.py `_ to one to save memory. From 160cb011ccd4a63762d4798585803fd1d440ea5f Mon Sep 17 00:00:00 2001 From: Amos Schledorn <60692940+amosschle@users.noreply.github.com> Date: Mon, 29 Jul 2024 11:30:44 +0200 Subject: [PATCH 22/79] Update doc/configtables/sector.csv Co-authored-by: Fabian Neumann --- doc/configtables/sector.csv | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/configtables/sector.csv b/doc/configtables/sector.csv index 17dae5e0..e14da557 100644 --- a/doc/configtables/sector.csv +++ b/doc/configtables/sector.csv @@ -10,10 +10,10 @@ district_heating,--,,`prepare_sector_network.py `_ to one to save memory. From 69b01e670fce9b43e2b2b7dd99a3b0bd2d965d2e Mon Sep 17 00:00:00 2001 From: Amos Schledorn <60692940+amosschle@users.noreply.github.com> Date: Mon, 29 Jul 2024 11:33:28 +0200 Subject: [PATCH 23/79] Update config/config.default.yaml Co-authored-by: Fabian Neumann --- config/config.default.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/config/config.default.yaml b/config/config.default.yaml index fbaa965b..5827bffb 100644 --- a/config/config.default.yaml +++ b/config/config.default.yaml @@ -408,7 +408,6 @@ sector: 2045: 0.8 2050: 1.0 district_heating_loss: 0.15 - # check these numbers! forward_temperature: 90 #C return_temperature: 50 #C heat_source_cooling: 6 #K From 1d3e39979a79a27ed738d718373074b3506d2ac9 Mon Sep 17 00:00:00 2001 From: AmosSchledorn Date: Mon, 29 Jul 2024 11:36:46 +0200 Subject: [PATCH 24/79] remove duplicate staticmethods --- .../build_cop_profiles/BaseCopApproximator.py | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/scripts/build_cop_profiles/BaseCopApproximator.py b/scripts/build_cop_profiles/BaseCopApproximator.py index ad537a74..89118284 100644 --- a/scripts/build_cop_profiles/BaseCopApproximator.py +++ b/scripts/build_cop_profiles/BaseCopApproximator.py @@ -45,23 +45,6 @@ class BaseCopApproximator(ABC): """ pass - def celsius_to_kelvin( - t_celsius: Union[float, xr.DataArray, np.array] - ) -> Union[float, xr.DataArray, np.array]: - if (np.asarray(t_celsius) > 200).any(): - raise ValueError( - "t_celsius > 200. Are you sure you are using the right units?" - ) - return t_celsius + 273.15 - - def logarithmic_mean( - t_hot: Union[float, xr.DataArray, np.ndarray], - t_cold: Union[float, xr.DataArray, np.ndarray], - ) -> Union[float, xr.DataArray, np.ndarray]: - if (np.asarray(t_hot <= t_cold)).any(): - raise ValueError("t_hot must be greater than t_cold") - return (t_hot - t_cold) / np.log(t_hot / t_cold) - @staticmethod def celsius_to_kelvin( t_celsius: Union[float, xr.DataArray, np.array] From 9073e49085d08af194aa75a273f77c9ef018425f Mon Sep 17 00:00:00 2001 From: AmosSchledorn Date: Mon, 29 Jul 2024 11:43:53 +0200 Subject: [PATCH 25/79] add link to paper in release notes --- doc/release_notes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/release_notes.rst b/doc/release_notes.rst index ad204b53..32eb7334 100644 --- a/doc/release_notes.rst +++ b/doc/release_notes.rst @@ -10,7 +10,7 @@ Release Notes Upcoming Release ================ -* Changed heat pump COP approximation for central heating to be based on Jensen et al. 2018 and a default forward temperature of 90C. This is more realistic for district heating than the previously used approximation method. +* Changed heat pump COP approximation for central heating to be based on `Jensen et al. (2018) `__ and a default forward temperature of 90C. This is more realistic for district heating than the previously used approximation method. * Renamed the carrier of batteries in BEVs from `battery storage` to `EV battery` and the corresponding bus carrier from `Li ion` to `EV battery`. This is to avoid confusion with stationary battery storage. From 936b4903039873ceb2e7caeb1b61873096738427 Mon Sep 17 00:00:00 2001 From: Fabian Neumann Date: Mon, 29 Jul 2024 11:51:20 +0200 Subject: [PATCH 26/79] address groupby(axis=...) deprecation (#1182) --- scripts/build_retro_cost.py | 2 +- scripts/plot_validation_electricity_production.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/build_retro_cost.py b/scripts/build_retro_cost.py index 52f545e9..44f4a738 100755 --- a/scripts/build_retro_cost.py +++ b/scripts/build_retro_cost.py @@ -890,7 +890,7 @@ def calculate_gain_utilisation_factor(heat_transfer_perm2, Q_ht, Q_gain): Calculates gain utilisation factor nu. """ # time constant of the building tau [h] = c_m [Wh/(m^2K)] * 1 /(H_tr_e+H_tb*H_ve) [m^2 K /W] - tau = c_m / heat_transfer_perm2.T.groupby(axis=1).sum().T + tau = c_m / heat_transfer_perm2.groupby().sum() alpha = alpha_H_0 + (tau / tau_H_0) # heat balance ratio gamma = (1 / Q_ht).mul(Q_gain.sum(axis=1), axis=0) diff --git a/scripts/plot_validation_electricity_production.py b/scripts/plot_validation_electricity_production.py index 5a68cfa5..f842bea3 100644 --- a/scripts/plot_validation_electricity_production.py +++ b/scripts/plot_validation_electricity_production.py @@ -70,7 +70,7 @@ if __name__ == "__main__": optimized = optimized[["Generator", "StorageUnit"]].droplevel(0, axis=1) optimized = optimized.rename(columns=n.buses.country, level=0) optimized = optimized.rename(columns=carrier_groups, level=1) - optimized = optimized.groupby(axis=1, level=[0, 1]).sum() + optimized = optimized.T.groupby(level=[0, 1]).sum().T data = pd.concat([historic, optimized], keys=["Historic", "Optimized"], axis=1) data.columns.names = ["Kind", "Country", "Carrier"] From e9e0a0da2064a242b0d731dc2218de0e6cbca190 Mon Sep 17 00:00:00 2001 From: Fabian Neumann Date: Mon, 29 Jul 2024 11:56:14 +0200 Subject: [PATCH 27/79] address fillna(method='{b|f}fill') deprecation (#1181) * address fillne(method='{b|f}fill') deprecation * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- scripts/add_electricity.py | 2 +- scripts/make_summary_perfect.py | 2 +- scripts/prepare_network.py | 4 +--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/scripts/add_electricity.py b/scripts/add_electricity.py index 17e030b4..49510953 100755 --- a/scripts/add_electricity.py +++ b/scripts/add_electricity.py @@ -852,7 +852,7 @@ if __name__ == "__main__": fuel_price = pd.read_csv( snakemake.input.fuel_price, index_col=0, header=0, parse_dates=True ) - fuel_price = fuel_price.reindex(n.snapshots).fillna(method="ffill") + fuel_price = fuel_price.reindex(n.snapshots).ffill() else: fuel_price = None diff --git a/scripts/make_summary_perfect.py b/scripts/make_summary_perfect.py index 76bd4ad0..8e56e5d4 100644 --- a/scripts/make_summary_perfect.py +++ b/scripts/make_summary_perfect.py @@ -631,7 +631,7 @@ def calculate_co2_emissions(n, label, df): weightings = n.snapshot_weightings.generators.mul( n.investment_period_weightings["years"] .reindex(n.snapshots) - .fillna(method="bfill") + .bfill() .fillna(1.0), axis=0, ) diff --git a/scripts/prepare_network.py b/scripts/prepare_network.py index 00cb00bf..382e633d 100755 --- a/scripts/prepare_network.py +++ b/scripts/prepare_network.py @@ -137,9 +137,7 @@ def add_emission_prices(n, emission_prices={"co2": 0.0}, exclude_co2=False): def add_dynamic_emission_prices(n): co2_price = pd.read_csv(snakemake.input.co2_price, index_col=0, parse_dates=True) co2_price = co2_price[~co2_price.index.duplicated()] - co2_price = ( - co2_price.reindex(n.snapshots).fillna(method="ffill").fillna(method="bfill") - ) + co2_price = co2_price.reindex(n.snapshots).ffill().bfill() emissions = ( n.generators.carrier.map(n.carriers.co2_emissions) / n.generators.efficiency From 0edf566e3fd0bc9f1dbb0cc6db29a94362efa3e3 Mon Sep 17 00:00:00 2001 From: AmosSchledorn Date: Mon, 29 Jul 2024 14:36:30 +0200 Subject: [PATCH 28/79] attempt to handle heat_pump_sources dynamically --- config/config.default.yaml | 6 ++++++ rules/build_sector.smk | 28 ++++++++++++++++------------ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/config/config.default.yaml b/config/config.default.yaml index 5827bffb..f68ff960 100644 --- a/config/config.default.yaml +++ b/config/config.default.yaml @@ -416,6 +416,12 @@ sector: heat_exchanger_pinch_point_temperature_difference: 5 #K isentropic_compressor_efficiency: 0.8 heat_loss: 0.0 + heat_pump_sources: + central_heating: + - air + decentral_heating: + - air + - ground cluster_heat_buses: true heat_demand_cutout: default bev_dsm_restriction_value: 0.75 diff --git a/rules/build_sector.smk b/rules/build_sector.smk index 5f8d5817..d6f959f3 100644 --- a/rules/build_sector.smk +++ b/rules/build_sector.smk @@ -232,22 +232,26 @@ rule build_cop_profiles: heat_pump_cop_approximation_central_heating=config_provider( "sector", "district_heating", "heat_pump_cop_approximation" ), + heat_pump_sources=config_provider("sector", "heat_pump_sources"), input: temp_soil_total=resources("temp_soil_total_elec_s{simpl}_{clusters}.nc"), temp_air_total=resources("temp_air_total_elec_s{simpl}_{clusters}.nc"), output: - cop_air_decentral_heating=resources( - "cop_air_decentral_heating_elec_s{simpl}_{clusters}.nc" - ), - cop_soil_decentral_heating=resources( - "cop_soil_decentral_heating_elec_s{simpl}_{clusters}.nc" - ), - cop_air_central_heating=resources( - "cop_air_central_heating_elec_s{simpl}_{clusters}.nc" - ), - cop_soil_central_heating=resources( - "cop_soil_central_heating_elec_s{simpl}_{clusters}.nc" - ), + **{f"cop_{source}_{sink}": resources( + "cop_" + source + "_" + {sink} + "_" + "elec_s{simpl}_{clusters}.nc" + ) for sink, source in config_provider("sector", "heat_pump_sources").items()}, + # cop_air_decentral_heating=resources( + # "cop_air_decentral_heating_elec_s{simpl}_{clusters}.nc" + # ), + # cop_soil_decentral_heating=resources( + # "cop_soil_decentral_heating_elec_s{simpl}_{clusters}.nc" + # ), + # cop_air_central_heating=resources( + # "cop_air_central_heating_elec_s{simpl}_{clusters}.nc" + # ), + # cop_soil_central_heating=resources( + # "cop_soil_central_heating_elec_s{simpl}_{clusters}.nc" + # ), resources: mem_mb=20000, log: From 51f42b4a36c046534fc50363b77e9d0546d3bbd8 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 29 Jul 2024 12:36:58 +0000 Subject: [PATCH 29/79] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- config/config.default.yaml | 6 +++--- rules/build_sector.smk | 9 ++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/config/config.default.yaml b/config/config.default.yaml index f68ff960..5e204a95 100644 --- a/config/config.default.yaml +++ b/config/config.default.yaml @@ -418,10 +418,10 @@ sector: heat_loss: 0.0 heat_pump_sources: central_heating: - - air + - air decentral_heating: - - air - - ground + - air + - ground cluster_heat_buses: true heat_demand_cutout: default bev_dsm_restriction_value: 0.75 diff --git a/rules/build_sector.smk b/rules/build_sector.smk index d6f959f3..dbba8805 100644 --- a/rules/build_sector.smk +++ b/rules/build_sector.smk @@ -237,9 +237,12 @@ rule build_cop_profiles: temp_soil_total=resources("temp_soil_total_elec_s{simpl}_{clusters}.nc"), temp_air_total=resources("temp_air_total_elec_s{simpl}_{clusters}.nc"), output: - **{f"cop_{source}_{sink}": resources( - "cop_" + source + "_" + {sink} + "_" + "elec_s{simpl}_{clusters}.nc" - ) for sink, source in config_provider("sector", "heat_pump_sources").items()}, + **{ + f"cop_{source}_{sink}": resources( + "cop_" + source + "_" + {sink} + "_" + "elec_s{simpl}_{clusters}.nc" + ) + for sink, source in config_provider("sector", "heat_pump_sources").items() + }, # cop_air_decentral_heating=resources( # "cop_air_decentral_heating_elec_s{simpl}_{clusters}.nc" # ), From 29479c50d0150bf768d02cca7a242b867b5b564d Mon Sep 17 00:00:00 2001 From: AmosSchledorn Date: Mon, 29 Jul 2024 18:29:27 +0200 Subject: [PATCH 30/79] pass heat source/system type to prepare_sector_network and add_existing_baseyear --- config/config.default.yaml | 4 +- rules/build_sector.smk | 37 ++-- rules/solve_myopic.smk | 14 +- scripts/add_existing_baseyear.py | 72 ++++---- .../DecentralHeatingCopApproximator.py | 8 +- scripts/build_cop_profiles/run.py | 74 +++++--- scripts/prepare_sector_network.py | 163 ++++++++---------- 7 files changed, 176 insertions(+), 196 deletions(-) diff --git a/config/config.default.yaml b/config/config.default.yaml index f68ff960..9f595401 100644 --- a/config/config.default.yaml +++ b/config/config.default.yaml @@ -417,9 +417,9 @@ sector: isentropic_compressor_efficiency: 0.8 heat_loss: 0.0 heat_pump_sources: - central_heating: + central: - air - decentral_heating: + decentral: - air - ground cluster_heat_buses: true diff --git a/rules/build_sector.smk b/rules/build_sector.smk index d6f959f3..9b2bfde6 100644 --- a/rules/build_sector.smk +++ b/rules/build_sector.smk @@ -214,6 +214,13 @@ rule build_temperature_profiles: script: "../scripts/build_temperature_profiles.py" +# def output_cop(wildcards): +# return { +# f"cop_{source}_{sink}": resources( +# "cop_" + source + "_" + sink + "_" + "elec_s{simpl}_{clusters}.nc" +# ) +# for sink, source in config["sector"]["heat_pump_sources"].items() +# } rule build_cop_profiles: params: @@ -237,21 +244,7 @@ rule build_cop_profiles: temp_soil_total=resources("temp_soil_total_elec_s{simpl}_{clusters}.nc"), temp_air_total=resources("temp_air_total_elec_s{simpl}_{clusters}.nc"), output: - **{f"cop_{source}_{sink}": resources( - "cop_" + source + "_" + {sink} + "_" + "elec_s{simpl}_{clusters}.nc" - ) for sink, source in config_provider("sector", "heat_pump_sources").items()}, - # cop_air_decentral_heating=resources( - # "cop_air_decentral_heating_elec_s{simpl}_{clusters}.nc" - # ), - # cop_soil_decentral_heating=resources( - # "cop_soil_decentral_heating_elec_s{simpl}_{clusters}.nc" - # ), - # cop_air_central_heating=resources( - # "cop_air_central_heating_elec_s{simpl}_{clusters}.nc" - # ), - # cop_soil_central_heating=resources( - # "cop_soil_central_heating_elec_s{simpl}_{clusters}.nc" - # ), + cop_profiles=resources("cop_profiles_elec_s{simpl}_{clusters}.nc"), resources: mem_mb=20000, log: @@ -969,6 +962,7 @@ rule prepare_sector_network: adjustments=config_provider("adjustments", "sector"), emissions_scope=config_provider("energy", "emissions"), RDIR=RDIR, + heat_pump_sources=config_provider("sector", "heat_pump_sources"), input: unpack(input_profile_offwind), **rules.cluster_gas_network.output, @@ -1045,18 +1039,7 @@ rule prepare_sector_network: ), temp_soil_total=resources("temp_soil_total_elec_s{simpl}_{clusters}.nc"), temp_air_total=resources("temp_air_total_elec_s{simpl}_{clusters}.nc"), - cop_soil_decentral_heating=resources( - "cop_soil_decentral_heating_elec_s{simpl}_{clusters}.nc" - ), - cop_air_decentral_heating=resources( - "cop_air_decentral_heating_elec_s{simpl}_{clusters}.nc" - ), - cop_air_central_heating=resources( - "cop_air_central_heating_elec_s{simpl}_{clusters}.nc" - ), - cop_soil_central_heating=resources( - "cop_soil_central_heating_elec_s{simpl}_{clusters}.nc" - ), + cop_profiles=resources("cop_profiles_elec_s{simpl}_{clusters}.nc"), solar_thermal_total=lambda w: ( resources("solar_thermal_total_elec_s{simpl}_{clusters}.nc") if config_provider("sector", "solar_thermal")(w) diff --git a/rules/solve_myopic.smk b/rules/solve_myopic.smk index bf952d4d..09f25b24 100644 --- a/rules/solve_myopic.smk +++ b/rules/solve_myopic.smk @@ -9,6 +9,7 @@ rule add_existing_baseyear: sector=config_provider("sector"), existing_capacities=config_provider("existing_capacities"), costs=config_provider("costs"), + heat_pump_sources=config_provider("sector", "heat_pump_sources"), input: network=RESULTS + "prenetworks/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.nc", @@ -21,18 +22,7 @@ rule add_existing_baseyear: config_provider("scenario", "planning_horizons", 0)(w) ) ), - cop_soil_decentral_heating=resources( - "cop_soil_decentral_heating_elec_s{simpl}_{clusters}.nc" - ), - cop_air_decentral_heating=resources( - "cop_air_decentral_heating_elec_s{simpl}_{clusters}.nc" - ), - cop_air_central_heating=resources( - "cop_air_central_heating_elec_s{simpl}_{clusters}.nc" - ), - cop_soil_central_heating=resources( - "cop_soil_central_heating_elec_s{simpl}_{clusters}.nc" - ), + cop_profiles=resources("cop_profiles_elec_s{simpl}_{clusters}.nc"), existing_heating_distribution=resources( "existing_heating_distribution_elec_s{simpl}_{clusters}_{planning_horizons}.csv" ), diff --git a/scripts/add_existing_baseyear.py b/scripts/add_existing_baseyear.py index 9770e6ce..00b5eeb7 100644 --- a/scripts/add_existing_baseyear.py +++ b/scripts/add_existing_baseyear.py @@ -442,27 +442,27 @@ def add_heating_capacities_installed_before_baseyear( """ logger.debug(f"Adding heating capacities installed before {baseyear}") - for name in existing_heating.columns.get_level_values(0).unique(): - name_type = "central" if name == "urban central" else "decentral" + for heat_system in existing_heating.columns.get_level_values(0).unique(): + system_type = "central" if heat_system == "urban central" else "decentral" - nodes = pd.Index(n.buses.location[n.buses.index.str.contains(f"{name} heat")]) + nodes = pd.Index(n.buses.location[n.buses.index.str.contains(f"{heat_system} heat")]) - if (name_type != "central") and options["electricity_distribution_grid"]: + if (system_type != "central") and options["electricity_distribution_grid"]: nodes_elec = nodes + " low voltage" else: nodes_elec = nodes - heat_pump_type = "air" if "urban" in name else "ground" - # Add heat pumps - costs_name = f"decentral {heat_pump_type}-sourced heat pump" + heat_source = snakemake.params.heat_pump_sources[system_type] + costs_name = f"{system_type} {heat_source}-sourced heat pump" efficiency = ( - cop[f"{heat_pump_type} {name_type}"][nodes] - if time_dep_hp_cop + cop.sel(heat_system=system_type, heat_source=heat_source, name=nodes).to_pandas().reindex(index=n.snapshots) + if options["time_dep_hp_cop"] else costs.at[costs_name, "efficiency"] ) + too_large_grouping_years = [gy for gy in grouping_years if gy >= int(baseyear)] if too_large_grouping_years: logger.warning( @@ -491,14 +491,14 @@ def add_heating_capacities_installed_before_baseyear( n.madd( "Link", nodes, - suffix=f" {name} {heat_pump_type} heat pump-{grouping_year}", + suffix=f" {heat_system} {heat_source} heat pump-{grouping_year}", bus0=nodes_elec, - bus1=nodes + " " + name + " heat", - carrier=f"{name} {heat_pump_type} heat pump", + bus1=nodes + " " + heat_system + " heat", + carrier=f"{heat_system} {heat_source} heat pump", efficiency=efficiency, capital_cost=costs.at[costs_name, "efficiency"] * costs.at[costs_name, "fixed"], - p_nom=existing_heating.loc[nodes, (name, f"{heat_pump_type} heat pump")] + p_nom=existing_heating.loc[nodes, (heat_system, f"{heat_source} heat pump")] * ratio / costs.at[costs_name, "efficiency"], build_year=int(grouping_year), @@ -509,66 +509,66 @@ def add_heating_capacities_installed_before_baseyear( n.madd( "Link", nodes, - suffix=f" {name} resistive heater-{grouping_year}", + suffix=f" {heat_system} resistive heater-{grouping_year}", bus0=nodes_elec, - bus1=nodes + " " + name + " heat", - carrier=name + " resistive heater", - efficiency=costs.at[f"{name_type} resistive heater", "efficiency"], + bus1=nodes + " " + heat_system + " heat", + carrier=heat_system + " resistive heater", + efficiency=costs.at[f"{system_type} resistive heater", "efficiency"], capital_cost=( - costs.at[f"{name_type} resistive heater", "efficiency"] - * costs.at[f"{name_type} resistive heater", "fixed"] + costs.at[f"{system_type} resistive heater", "efficiency"] + * costs.at[f"{system_type} resistive heater", "fixed"] ), p_nom=( - existing_heating.loc[nodes, (name, "resistive heater")] + existing_heating.loc[nodes, (heat_system, "resistive heater")] * ratio - / costs.at[f"{name_type} resistive heater", "efficiency"] + / costs.at[f"{system_type} resistive heater", "efficiency"] ), build_year=int(grouping_year), - lifetime=costs.at[f"{name_type} resistive heater", "lifetime"], + lifetime=costs.at[f"{system_type} resistive heater", "lifetime"], ) n.madd( "Link", nodes, - suffix=f" {name} gas boiler-{grouping_year}", + suffix=f" {heat_system} gas boiler-{grouping_year}", bus0="EU gas" if "EU gas" in spatial.gas.nodes else nodes + " gas", - bus1=nodes + " " + name + " heat", + bus1=nodes + " " + heat_system + " heat", bus2="co2 atmosphere", - carrier=name + " gas boiler", - efficiency=costs.at[f"{name_type} gas boiler", "efficiency"], + carrier=heat_system + " gas boiler", + efficiency=costs.at[f"{system_type} gas boiler", "efficiency"], efficiency2=costs.at["gas", "CO2 intensity"], capital_cost=( - costs.at[f"{name_type} gas boiler", "efficiency"] - * costs.at[f"{name_type} gas boiler", "fixed"] + costs.at[f"{system_type} gas boiler", "efficiency"] + * costs.at[f"{system_type} gas boiler", "fixed"] ), p_nom=( - existing_heating.loc[nodes, (name, "gas boiler")] + existing_heating.loc[nodes, (heat_system, "gas boiler")] * ratio - / costs.at[f"{name_type} gas boiler", "efficiency"] + / costs.at[f"{system_type} gas boiler", "efficiency"] ), build_year=int(grouping_year), - lifetime=costs.at[f"{name_type} gas boiler", "lifetime"], + lifetime=costs.at[f"{system_type} gas boiler", "lifetime"], ) n.madd( "Link", nodes, - suffix=f" {name} oil boiler-{grouping_year}", + suffix=f" {heat_system} oil boiler-{grouping_year}", bus0=spatial.oil.nodes, - bus1=nodes + " " + name + " heat", + bus1=nodes + " " + heat_system + " heat", bus2="co2 atmosphere", - carrier=name + " oil boiler", + carrier=heat_system + " oil boiler", efficiency=costs.at["decentral oil boiler", "efficiency"], efficiency2=costs.at["oil", "CO2 intensity"], capital_cost=costs.at["decentral oil boiler", "efficiency"] * costs.at["decentral oil boiler", "fixed"], p_nom=( - existing_heating.loc[nodes, (name, "oil boiler")] + existing_heating.loc[nodes, (heat_system, "oil boiler")] * ratio / costs.at["decentral oil boiler", "efficiency"] ), build_year=int(grouping_year), - lifetime=costs.at[f"{name_type} gas boiler", "lifetime"], + lifetime=costs.at[f"{system_type} gas boiler", "lifetime"], ) # delete links with p_nom=nan corresponding to extra nodes in country diff --git a/scripts/build_cop_profiles/DecentralHeatingCopApproximator.py b/scripts/build_cop_profiles/DecentralHeatingCopApproximator.py index d8526c39..11be7407 100644 --- a/scripts/build_cop_profiles/DecentralHeatingCopApproximator.py +++ b/scripts/build_cop_profiles/DecentralHeatingCopApproximator.py @@ -39,12 +39,12 @@ class DecentralHeatingCopApproximator(BaseCopApproximator): return_temperature_celsius : Union[xr.DataArray, np.array] The return temperature in Celsius. source: str - The source of the heat pump. Must be either 'air' or 'soil' + The source of the heat pump. Must be either 'air' or 'ground' """ self.delta_t = forward_temperature_celsius - source_inlet_temperature_celsius - if source_type not in ["air", "soil"]: - raise ValueError("'source' must be one of ['air', 'soil']") + if source_type not in ["air", "ground"]: + raise ValueError("'source' must be one of ['air', 'ground']") else: self.source_type = source_type @@ -57,7 +57,7 @@ class DecentralHeatingCopApproximator(BaseCopApproximator): """ if self.source_type == "air": return self._approximate_cop_air_source() - elif self.source_type == "soil": + elif self.source_type == "ground": return self._approximate_cop_ground_source() def _approximate_cop_air_source(self) -> Union[xr.DataArray, np.array]: diff --git a/scripts/build_cop_profiles/run.py b/scripts/build_cop_profiles/run.py index 12d012bb..5178483a 100644 --- a/scripts/build_cop_profiles/run.py +++ b/scripts/build_cop_profiles/run.py @@ -4,11 +4,39 @@ # SPDX-License-Identifier: MIT import numpy as np +import pandas as pd import xarray as xr from _helpers import set_scenario_config from CentralHeatingCopApproximator import CentralHeatingCopApproximator from DecentralHeatingCopApproximator import DecentralHeatingCopApproximator + +def get_cop( + heat_system_type: str, + heat_source: str, + source_inlet_temperature_celsius: xr.DataArray, +) -> xr.DataArray: + if heat_system_type == "decentral": + return DecentralHeatingCopApproximator( + forward_temperature_celsius=snakemake.params.heat_pump_sink_T_decentral_heating, + source_inlet_temperature_celsius=source_inlet_temperature_celsius, + source_type=heat_source, + ).approximate_cop() + + elif heat_system_type == "central": + return CentralHeatingCopApproximator( + forward_temperature_celsius=snakemake.params.forward_temperature_central_heating, + return_temperature_celsius=snakemake.params.return_temperature_central_heating, + source_inlet_temperature_celsius=source_inlet_temperature_celsius, + source_outlet_temperature_celsius=source_inlet_temperature_celsius + - snakemake.params.heat_source_cooling_central_heating, + ).approximate_cop() + else: + raise ValueError( + f"Invalid heat system type '{heat_system_type}'. Must be one of ['decentral', 'central']" + ) + + if __name__ == "__main__": if "snakemake" not in globals(): from _helpers import mock_snakemake @@ -21,30 +49,28 @@ if __name__ == "__main__": set_scenario_config(snakemake) - for source_type in ["air", "soil"]: - # source inlet temperature (air/soil) is based on weather data - source_inlet_temperature_celsius = xr.open_dataarray( - snakemake.input[f"temp_{source_type}_total"] + cop_all_system_types = [] + for heat_system_type, heat_sources in snakemake.params.heat_pump_sources.items(): + cop_this_system_type = [] + for heat_source in heat_sources: + source_inlet_temperature_celsius = xr.open_dataarray( + snakemake.input[f"temp_{heat_source.replace('ground', 'soil')}_total"] + ) + cop_da = get_cop( + heat_system_type=heat_system_type, + heat_source=heat_source, + source_inlet_temperature_celsius=source_inlet_temperature_celsius, + ) + cop_this_system_type.append(cop_da) + cop_all_system_types.append( + xr.concat( + cop_this_system_type, dim=pd.Index(heat_sources, name="heat_source") + ) ) - # Approximate COP for decentral (individual) heating - cop_individual_heating = DecentralHeatingCopApproximator( - forward_temperature_celsius=snakemake.params.heat_pump_sink_T_decentral_heating, - source_inlet_temperature_celsius=source_inlet_temperature_celsius, - source_type=source_type, - ).approximate_cop() - cop_individual_heating.to_netcdf( - snakemake.output[f"cop_{source_type}_decentral_heating"] - ) + cop_dataarray = xr.concat( + cop_all_system_types, + dim=pd.Index(snakemake.params.heat_pump_sources.keys(), name="heat_system"), + ) - # Approximate COP for central (district) heating - cop_central_heating = CentralHeatingCopApproximator( - forward_temperature_celsius=snakemake.params.forward_temperature_central_heating, - return_temperature_celsius=snakemake.params.return_temperature_central_heating, - source_inlet_temperature_celsius=source_inlet_temperature_celsius, - source_outlet_temperature_celsius=source_inlet_temperature_celsius - - snakemake.params.heat_source_cooling_central_heating, - ).approximate_cop() - cop_central_heating.to_netcdf( - snakemake.output[f"cop_{source_type}_central_heating"] - ) + cop_dataarray.to_netcdf(snakemake.output.cop_profiles) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index d5b892ad..e59984d3 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -1825,23 +1825,6 @@ def add_heat(n, costs): "urban central", ] - cop = { - "air decentral": xr.open_dataarray(snakemake.input.cop_air_decentral_heating) - .to_pandas() - .reindex(index=n.snapshots), - "ground decentral": xr.open_dataarray( - snakemake.input.cop_soil_decentral_heating - ) - .to_pandas() - .reindex(index=n.snapshots), - "air central": xr.open_dataarray(snakemake.input.cop_air_central_heating) - .to_pandas() - .reindex(index=n.snapshots), - "ground central": xr.open_dataarray(snakemake.input.cop_soil_central_heating) - .to_pandas() - .reindex(index=n.snapshots), - } - if options["solar_thermal"]: solar_thermal = ( xr.open_dataarray(snakemake.input.solar_thermal_total) @@ -1851,31 +1834,32 @@ def add_heat(n, costs): # 1e3 converts from W/m^2 to MW/(1000m^2) = kW/m^2 solar_thermal = options["solar_cf_correction"] * solar_thermal / 1e3 - for name in heat_systems: - name_type = "central" if name == "urban central" else "decentral" + cop = xr.open_dataarray(snakemake.input.cop_profiles) + for heat_system in heat_systems: + system_type = "central" if heat_system == "urban central" else "decentral" - if name == "urban central": + if heat_system == "urban central": nodes = dist_fraction.index[dist_fraction > 0] else: nodes = pop_layout.index - n.add("Carrier", name + " heat") + n.add("Carrier", heat_system + " heat") n.madd( "Bus", - nodes + f" {name} heat", + nodes + f" {heat_system} heat", location=nodes, - carrier=name + " heat", + carrier=heat_system + " heat", unit="MWh_th", ) - if name == "urban central" and options.get("central_heat_vent"): + if heat_system == "urban central" and options.get("central_heat_vent"): n.madd( "Generator", - nodes + f" {name} heat vent", - bus=nodes + f" {name} heat", + nodes + f" {heat_system} heat vent", + bus=nodes + f" {heat_system} heat", location=nodes, - carrier=name + " heat vent", + carrier=heat_system + " heat vent", p_nom_extendable=True, p_max_pu=0, p_min_pu=-1, @@ -1886,18 +1870,18 @@ def add_heat(n, costs): for sector in sectors: # heat demand weighting - if "rural" in name: + if "rural" in heat_system: factor = 1 - urban_fraction[nodes] - elif "urban central" in name: + elif "urban central" in heat_system: factor = dist_fraction[nodes] - elif "urban decentral" in name: + elif "urban decentral" in heat_system: factor = urban_fraction[nodes] - dist_fraction[nodes] else: raise NotImplementedError( - f" {name} not in " f"heat systems: {heat_systems}" + f" {heat_system} not in " f"heat systems: {heat_systems}" ) - if sector in name: + if sector in heat_system: heat_load = ( heat_demand[[sector + " water", sector + " space"]] .T.groupby(level=1) @@ -1906,7 +1890,7 @@ def add_heat(n, costs): .multiply(factor) ) - if name == "urban central": + if heat_system == "urban central": heat_load = ( heat_demand.T.groupby(level=1) .sum() @@ -1919,20 +1903,17 @@ def add_heat(n, costs): n.madd( "Load", nodes, - suffix=f" {name} heat", - bus=nodes + f" {name} heat", - carrier=name + " heat", + suffix=f" {heat_system} heat", + bus=nodes + f" {heat_system} heat", + carrier=heat_system + " heat", p_set=heat_load, ) ## Add heat pumps - - heat_pump_types = ["air"] if "urban" in name else ["ground", "air"] - - for heat_pump_type in heat_pump_types: - costs_name = f"{name_type} {heat_pump_type}-sourced heat pump" + for heat_source in snakemake.params.heat_pump_sources[system_type]: + costs_name = f"{system_type} {heat_source}-sourced heat pump" efficiency = ( - cop[f"{heat_pump_type} {name_type}"][nodes] + cop.sel(heat_system=system_type, heat_source=heat_source, name=nodes).to_pandas().reindex(index=n.snapshots) if options["time_dep_hp_cop"] else costs.at[costs_name, "efficiency"] ) @@ -1940,10 +1921,10 @@ def add_heat(n, costs): n.madd( "Link", nodes, - suffix=f" {name} {heat_pump_type} heat pump", + suffix=f" {heat_system} {heat_source} heat pump", bus0=nodes, - bus1=nodes + f" {name} heat", - carrier=f"{name} {heat_pump_type} heat pump", + bus1=nodes + f" {heat_system} heat", + carrier=f"{heat_system} {heat_source} heat pump", efficiency=efficiency, capital_cost=costs.at[costs_name, "efficiency"] * costs.at[costs_name, "fixed"] @@ -1953,59 +1934,59 @@ def add_heat(n, costs): ) if options["tes"]: - n.add("Carrier", name + " water tanks") + n.add("Carrier", heat_system + " water tanks") n.madd( "Bus", - nodes + f" {name} water tanks", + nodes + f" {heat_system} water tanks", location=nodes, - carrier=name + " water tanks", + carrier=heat_system + " water tanks", unit="MWh_th", ) n.madd( "Link", - nodes + f" {name} water tanks charger", - bus0=nodes + f" {name} heat", - bus1=nodes + f" {name} water tanks", + nodes + f" {heat_system} water tanks charger", + bus0=nodes + f" {heat_system} heat", + bus1=nodes + f" {heat_system} water tanks", efficiency=costs.at["water tank charger", "efficiency"], - carrier=name + " water tanks charger", + carrier=heat_system + " water tanks charger", p_nom_extendable=True, ) n.madd( "Link", - nodes + f" {name} water tanks discharger", - bus0=nodes + f" {name} water tanks", - bus1=nodes + f" {name} heat", - carrier=name + " water tanks discharger", + nodes + f" {heat_system} water tanks discharger", + bus0=nodes + f" {heat_system} water tanks", + bus1=nodes + f" {heat_system} heat", + carrier=heat_system + " water tanks discharger", efficiency=costs.at["water tank discharger", "efficiency"], p_nom_extendable=True, ) - tes_time_constant_days = options["tes_tau"][name_type] + tes_time_constant_days = options["tes_tau"][system_type] n.madd( "Store", - nodes + f" {name} water tanks", - bus=nodes + f" {name} water tanks", + nodes + f" {heat_system} water tanks", + bus=nodes + f" {heat_system} water tanks", e_cyclic=True, e_nom_extendable=True, - carrier=name + " water tanks", + carrier=heat_system + " water tanks", standing_loss=1 - np.exp(-1 / 24 / tes_time_constant_days), - capital_cost=costs.at[name_type + " water tank storage", "fixed"], - lifetime=costs.at[name_type + " water tank storage", "lifetime"], + capital_cost=costs.at[system_type + " water tank storage", "fixed"], + lifetime=costs.at[system_type + " water tank storage", "lifetime"], ) if options["resistive_heaters"]: - key = f"{name_type} resistive heater" + key = f"{system_type} resistive heater" n.madd( "Link", - nodes + f" {name} resistive heater", + nodes + f" {heat_system} resistive heater", bus0=nodes, - bus1=nodes + f" {name} heat", - carrier=name + " resistive heater", + bus1=nodes + f" {heat_system} heat", + carrier=heat_system + " resistive heater", efficiency=costs.at[key, "efficiency"], capital_cost=costs.at[key, "efficiency"] * costs.at[key, "fixed"] @@ -2015,16 +1996,16 @@ def add_heat(n, costs): ) if options["boilers"]: - key = f"{name_type} gas boiler" + key = f"{system_type} gas boiler" n.madd( "Link", - nodes + f" {name} gas boiler", + nodes + f" {heat_system} gas boiler", p_nom_extendable=True, bus0=spatial.gas.df.loc[nodes, "nodes"].values, - bus1=nodes + f" {name} heat", + bus1=nodes + f" {heat_system} heat", bus2="co2 atmosphere", - carrier=name + " gas boiler", + carrier=heat_system + " gas boiler", efficiency=costs.at[key, "efficiency"], efficiency2=costs.at["gas", "CO2 intensity"], capital_cost=costs.at[key, "efficiency"] @@ -2034,22 +2015,22 @@ def add_heat(n, costs): ) if options["solar_thermal"]: - n.add("Carrier", name + " solar thermal") + n.add("Carrier", heat_system + " solar thermal") n.madd( "Generator", nodes, - suffix=f" {name} solar thermal collector", - bus=nodes + f" {name} heat", - carrier=name + " solar thermal", + suffix=f" {heat_system} solar thermal collector", + bus=nodes + f" {heat_system} heat", + carrier=heat_system + " solar thermal", p_nom_extendable=True, - capital_cost=costs.at[name_type + " solar thermal", "fixed"] + capital_cost=costs.at[system_type + " solar thermal", "fixed"] * overdim_factor, p_max_pu=solar_thermal[nodes], - lifetime=costs.at[name_type + " solar thermal", "lifetime"], + lifetime=costs.at[system_type + " solar thermal", "lifetime"], ) - if options["chp"] and name == "urban central": + if options["chp"] and heat_system == "urban central": # add gas CHP; biomass CHP is added in biomass section n.madd( "Link", @@ -2106,16 +2087,16 @@ def add_heat(n, costs): lifetime=costs.at["central gas CHP", "lifetime"], ) - if options["chp"] and options["micro_chp"] and name != "urban central": + if options["chp"] and options["micro_chp"] and heat_system != "urban central": n.madd( "Link", - nodes + f" {name} micro gas CHP", + nodes + f" {heat_system} micro gas CHP", p_nom_extendable=True, bus0=spatial.gas.df.loc[nodes, "nodes"].values, bus1=nodes, - bus2=nodes + f" {name} heat", + bus2=nodes + f" {heat_system} heat", bus3="co2 atmosphere", - carrier=name + " micro gas CHP", + carrier=heat_system + " micro gas CHP", efficiency=costs.at["micro CHP", "efficiency"], efficiency2=costs.at["micro CHP", "efficiency-heat"], efficiency3=costs.at["gas", "CO2 intensity"], @@ -2150,27 +2131,27 @@ def add_heat(n, costs): heat_demand["services space"] + heat_demand["residential space"] ) / heat_demand.T.groupby(level=[1]).sum().T - for name in n.loads[ + for heat_system in n.loads[ n.loads.carrier.isin([x + " heat" for x in heat_systems]) ].index: - node = n.buses.loc[name, "location"] + node = n.buses.loc[heat_system, "location"] ct = pop_layout.loc[node, "ct"] # weighting 'f' depending on the size of the population at the node - if "urban central" in name: + if "urban central" in heat_system: f = dist_fraction[node] - elif "urban decentral" in name: + elif "urban decentral" in heat_system: f = urban_fraction[node] - dist_fraction[node] else: f = 1 - urban_fraction[node] if f == 0: continue # get sector name ("residential"/"services"/or both "tot" for urban central) - if "urban central" in name: + if "urban central" in heat_system: sec = "tot" - if "residential" in name: + if "residential" in heat_system: sec = "residential" - if "services" in name: + if "services" in heat_system: sec = "services" # get floor aread at node and region (urban/rural) in m^2 @@ -2178,7 +2159,7 @@ def add_heat(n, costs): pop_layout.loc[node].fraction * floor_area.loc[ct, "value"] * 10**6 ).loc[sec] * f # total heat demand at node [MWh] - demand = n.loads_t.p_set[name] + demand = n.loads_t.p_set[heat_system] # space heat demand at node [MWh] space_heat_demand = demand * w_space[sec][node] @@ -2219,12 +2200,12 @@ def add_heat(n, costs): # add for each retrofitting strength a generator with heat generation profile following the profile of the heat demand for strength in strengths: - node_name = " ".join(name.split(" ")[2::]) + node_name = " ".join(heat_system.split(" ")[2::]) n.madd( "Generator", [node], suffix=" retrofitting " + strength + " " + node_name, - bus=name, + bus=heat_system, carrier="retrofitting", p_nom_extendable=True, p_nom_max=dE_diff[strength] From 1fe54513cd8f33961263d21a693dd4f8cf0c595f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 29 Jul 2024 16:33:49 +0000 Subject: [PATCH 31/79] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- config/config.default.yaml | 6 +++--- rules/build_sector.smk | 2 ++ scripts/add_existing_baseyear.py | 13 +++++++++---- scripts/prepare_sector_network.py | 4 +++- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/config/config.default.yaml b/config/config.default.yaml index 9f595401..794b2bae 100644 --- a/config/config.default.yaml +++ b/config/config.default.yaml @@ -418,10 +418,10 @@ sector: heat_loss: 0.0 heat_pump_sources: central: - - air + - air decentral: - - air - - ground + - air + - ground cluster_heat_buses: true heat_demand_cutout: default bev_dsm_restriction_value: 0.75 diff --git a/rules/build_sector.smk b/rules/build_sector.smk index 9b2bfde6..b7d916ea 100644 --- a/rules/build_sector.smk +++ b/rules/build_sector.smk @@ -214,6 +214,7 @@ rule build_temperature_profiles: script: "../scripts/build_temperature_profiles.py" + # def output_cop(wildcards): # return { # f"cop_{source}_{sink}": resources( @@ -222,6 +223,7 @@ rule build_temperature_profiles: # for sink, source in config["sector"]["heat_pump_sources"].items() # } + rule build_cop_profiles: params: heat_pump_sink_T_decentral_heating=config_provider( diff --git a/scripts/add_existing_baseyear.py b/scripts/add_existing_baseyear.py index 00b5eeb7..610523e9 100644 --- a/scripts/add_existing_baseyear.py +++ b/scripts/add_existing_baseyear.py @@ -445,7 +445,9 @@ def add_heating_capacities_installed_before_baseyear( for heat_system in existing_heating.columns.get_level_values(0).unique(): system_type = "central" if heat_system == "urban central" else "decentral" - nodes = pd.Index(n.buses.location[n.buses.index.str.contains(f"{heat_system} heat")]) + nodes = pd.Index( + n.buses.location[n.buses.index.str.contains(f"{heat_system} heat")] + ) if (system_type != "central") and options["electricity_distribution_grid"]: nodes_elec = nodes + " low voltage" @@ -457,12 +459,13 @@ def add_heating_capacities_installed_before_baseyear( costs_name = f"{system_type} {heat_source}-sourced heat pump" efficiency = ( - cop.sel(heat_system=system_type, heat_source=heat_source, name=nodes).to_pandas().reindex(index=n.snapshots) + cop.sel(heat_system=system_type, heat_source=heat_source, name=nodes) + .to_pandas() + .reindex(index=n.snapshots) if options["time_dep_hp_cop"] else costs.at[costs_name, "efficiency"] ) - too_large_grouping_years = [gy for gy in grouping_years if gy >= int(baseyear)] if too_large_grouping_years: logger.warning( @@ -498,7 +501,9 @@ def add_heating_capacities_installed_before_baseyear( efficiency=efficiency, capital_cost=costs.at[costs_name, "efficiency"] * costs.at[costs_name, "fixed"], - p_nom=existing_heating.loc[nodes, (heat_system, f"{heat_source} heat pump")] + p_nom=existing_heating.loc[ + nodes, (heat_system, f"{heat_source} heat pump") + ] * ratio / costs.at[costs_name, "efficiency"], build_year=int(grouping_year), diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index e59984d3..f71dd5f5 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -1913,7 +1913,9 @@ def add_heat(n, costs): for heat_source in snakemake.params.heat_pump_sources[system_type]: costs_name = f"{system_type} {heat_source}-sourced heat pump" efficiency = ( - cop.sel(heat_system=system_type, heat_source=heat_source, name=nodes).to_pandas().reindex(index=n.snapshots) + cop.sel(heat_system=system_type, heat_source=heat_source, name=nodes) + .to_pandas() + .reindex(index=n.snapshots) if options["time_dep_hp_cop"] else costs.at[costs_name, "efficiency"] ) From 5e73dae3a7b5a5d39c36d47f6f7220b417f2ca46 Mon Sep 17 00:00:00 2001 From: AmosSchledorn Date: Tue, 30 Jul 2024 18:21:10 +0200 Subject: [PATCH 32/79] add heat_pump_sources to config and docs --- config/config.default.yaml | 6 +++--- doc/configtables/sector.csv | 10 +++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/config/config.default.yaml b/config/config.default.yaml index 794b2bae..9f595401 100644 --- a/config/config.default.yaml +++ b/config/config.default.yaml @@ -418,10 +418,10 @@ sector: heat_loss: 0.0 heat_pump_sources: central: - - air + - air decentral: - - air - - ground + - air + - ground cluster_heat_buses: true heat_demand_cutout: default bev_dsm_restriction_value: 0.75 diff --git a/doc/configtables/sector.csv b/doc/configtables/sector.csv index e14da557..17435a28 100644 --- a/doc/configtables/sector.csv +++ b/doc/configtables/sector.csv @@ -6,6 +6,9 @@ industry,--,"{true, false}",Flag to include industry sector. agriculture,--,"{true, false}",Flag to include agriculture sector. district_heating,--,,`prepare_sector_network.py `_ -- potential,--,float,maximum fraction of urban demand which can be supplied by district heating. Ignored where below current fraction. +-- progress,--,Dictionary with planning horizons as keys., Increase of today's district heating demand to potential maximum district heating share. Progress = 0 means today's district heating share. Progress = 1 means maximum fraction of urban demand is supplied by district heating +-- district_heating_loss,--,float,Share increase in district heat demand in urban central due to heat losses +cluster_heat_buses,--,"{true, false}",Cluster residential and service heat buses in `prepare_sector_network.py `_ to one to save memory. -- forward_temperature,°C,float,Forward temperature in district heating -- return_temperature,°C,float,Return temperature in district heating. Must be lower than forward temperature -- heat_source_cooling,K,float,Cooling of heat source for heat pumps @@ -14,9 +17,10 @@ district_heating,--,,`prepare_sector_network.py `_ to one to save memory. +-- heat_pump_sources,,, +-- -- central,--,"Any subset of {ground, air}", Heat pump sources for central heating heat pumps +-- -- decentral,--,"Any subset of {ground, air}", Heat pump sources for decentral heating heat pumps + ,,, bev_dsm_restriction _value,--,float,Adds a lower state of charge (SOC) limit for battery electric vehicles (BEV) to manage its own energy demand (DSM). Located in `build_transport_demand.py `_. Set to 0 for no restriction on BEV DSM bev_dsm_restriction _time,--,float,Time at which SOC of BEV has to be dsm_restriction_value From a2c0311ae7c6ece7003a4cdeeeb3566fbfa856dc Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 30 Jul 2024 16:23:58 +0000 Subject: [PATCH 33/79] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- config/config.default.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/config.default.yaml b/config/config.default.yaml index 9f595401..794b2bae 100644 --- a/config/config.default.yaml +++ b/config/config.default.yaml @@ -418,10 +418,10 @@ sector: heat_loss: 0.0 heat_pump_sources: central: - - air + - air decentral: - - air - - ground + - air + - ground cluster_heat_buses: true heat_demand_cutout: default bev_dsm_restriction_value: 0.75 From 4c1ec3559dc91ecb1dea4d32d2e593c530a549d2 Mon Sep 17 00:00:00 2001 From: Fabian Neumann Date: Wed, 31 Jul 2024 11:53:20 +0200 Subject: [PATCH 34/79] some small adjustments to run as single node model (#1183) * some small adjustments to run as single node model * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- scripts/cluster_gas_network.py | 3 +++ scripts/prepare_sector_network.py | 12 ++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/scripts/cluster_gas_network.py b/scripts/cluster_gas_network.py index 6d4e6c48..b95c4580 100755 --- a/scripts/cluster_gas_network.py +++ b/scripts/cluster_gas_network.py @@ -58,6 +58,9 @@ def build_clustered_gas_network(df, bus_regions, length_factor=1.25): # drop pipes within the same region df = df.loc[df.bus1 != df.bus0] + if df.empty: + return df + # recalculate lengths as center to center * length factor df["length"] = df.apply( lambda p: length_factor diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index eaaf207d..5b28c1b4 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -2775,10 +2775,11 @@ def add_industry(n, costs): ) domestic_navigation = pop_weighted_energy_totals.loc[ - nodes, "total domestic navigation" + nodes, ["total domestic navigation"] ].squeeze() international_navigation = ( - pd.read_csv(snakemake.input.shipping_demand, index_col=0).squeeze() * nyears + pd.read_csv(snakemake.input.shipping_demand, index_col=0).squeeze(axis=1) + * nyears ) all_navigation = domestic_navigation + international_navigation p_set = all_navigation * 1e6 / nhours @@ -3946,12 +3947,11 @@ if __name__ == "__main__": snakemake = mock_snakemake( "prepare_sector_network", - # configfiles="test/config.overnight.yaml", simpl="", opts="", - clusters="37", - ll="v1.0", - sector_opts="730H-T-H-B-I-A-dist1", + clusters="1", + ll="vopt", + sector_opts="", planning_horizons="2050", ) From 4362300dced326c92523aeb5581d798c720aeb76 Mon Sep 17 00:00:00 2001 From: AmosSchledorn Date: Wed, 31 Jul 2024 16:54:46 +0200 Subject: [PATCH 35/79] update configtables and docs --- config/config.default.yaml | 6 +++--- doc/configtables/sector.csv | 10 +++------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/config/config.default.yaml b/config/config.default.yaml index 794b2bae..9f595401 100644 --- a/config/config.default.yaml +++ b/config/config.default.yaml @@ -418,10 +418,10 @@ sector: heat_loss: 0.0 heat_pump_sources: central: - - air + - air decentral: - - air - - ground + - air + - ground cluster_heat_buses: true heat_demand_cutout: default bev_dsm_restriction_value: 0.75 diff --git a/doc/configtables/sector.csv b/doc/configtables/sector.csv index 17435a28..e14da557 100644 --- a/doc/configtables/sector.csv +++ b/doc/configtables/sector.csv @@ -6,9 +6,6 @@ industry,--,"{true, false}",Flag to include industry sector. agriculture,--,"{true, false}",Flag to include agriculture sector. district_heating,--,,`prepare_sector_network.py `_ -- potential,--,float,maximum fraction of urban demand which can be supplied by district heating. Ignored where below current fraction. --- progress,--,Dictionary with planning horizons as keys., Increase of today's district heating demand to potential maximum district heating share. Progress = 0 means today's district heating share. Progress = 1 means maximum fraction of urban demand is supplied by district heating --- district_heating_loss,--,float,Share increase in district heat demand in urban central due to heat losses -cluster_heat_buses,--,"{true, false}",Cluster residential and service heat buses in `prepare_sector_network.py `_ to one to save memory. -- forward_temperature,°C,float,Forward temperature in district heating -- return_temperature,°C,float,Return temperature in district heating. Must be lower than forward temperature -- heat_source_cooling,K,float,Cooling of heat source for heat pumps @@ -17,10 +14,9 @@ cluster_heat_buses,--,"{true, false}",Cluster residential and service heat buses -- -- heat_exchanger_pinch_point_temperature_difference,K,float,Heat pump pinch point temperature difference in heat exchangers assumed for approximation. -- -- isentropic_compressor_efficiency,--,float,Isentropic efficiency of heat pump compressor assumed for approximation. Must be between 0 and 1. -- -- heat_loss,--,float,Heat pump heat loss assumed for approximation. Must be between 0 and 1. --- heat_pump_sources,,, --- -- central,--,"Any subset of {ground, air}", Heat pump sources for central heating heat pumps --- -- decentral,--,"Any subset of {ground, air}", Heat pump sources for decentral heating heat pumps - +-- progress,--,Dictionary with planning horizons as keys., Increase of today's district heating demand to potential maximum district heating share. Progress = 0 means today's district heating share. Progress = 1 means maximum fraction of urban demand is supplied by district heating +-- district_heating_loss,--,float,Share increase in district heat demand in urban central due to heat losses +cluster_heat_buses,--,"{true, false}",Cluster residential and service heat buses in `prepare_sector_network.py `_ to one to save memory. ,,, bev_dsm_restriction _value,--,float,Adds a lower state of charge (SOC) limit for battery electric vehicles (BEV) to manage its own energy demand (DSM). Located in `build_transport_demand.py `_. Set to 0 for no restriction on BEV DSM bev_dsm_restriction _time,--,float,Time at which SOC of BEV has to be dsm_restriction_value From 4cfca27e4f623b4c8bf69793c9ecb4c0a81a02ec Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 31 Jul 2024 14:55:09 +0000 Subject: [PATCH 36/79] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- config/config.default.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/config.default.yaml b/config/config.default.yaml index 9f595401..794b2bae 100644 --- a/config/config.default.yaml +++ b/config/config.default.yaml @@ -418,10 +418,10 @@ sector: heat_loss: 0.0 heat_pump_sources: central: - - air + - air decentral: - - air - - ground + - air + - ground cluster_heat_buses: true heat_demand_cutout: default bev_dsm_restriction_value: 0.75 From caa260fddb51ef6619c990e379d0ea3de2bd9406 Mon Sep 17 00:00:00 2001 From: AmosSchledorn Date: Wed, 31 Jul 2024 17:01:27 +0200 Subject: [PATCH 37/79] update class docs --- .../build_cop_profiles/BaseCopApproximator.py | 50 ++++++++++++- .../CentralHeatingCopApproximator.py | 73 ++++++++++++++++++- .../DecentralHeatingCopApproximator.py | 44 ++++++++--- 3 files changed, 153 insertions(+), 14 deletions(-) diff --git a/scripts/build_cop_profiles/BaseCopApproximator.py b/scripts/build_cop_profiles/BaseCopApproximator.py index 89118284..10019b3d 100644 --- a/scripts/build_cop_profiles/BaseCopApproximator.py +++ b/scripts/build_cop_profiles/BaseCopApproximator.py @@ -14,6 +14,24 @@ class BaseCopApproximator(ABC): """ Abstract class for approximating the coefficient of performance (COP) of a heat pump. + + Attributes: + ---------- + forward_temperature_celsius : Union[xr.DataArray, np.array] + The forward temperature in Celsius. + source_inlet_temperature_celsius : Union[xr.DataArray, np.array] + The source inlet temperature in Celsius. + + Methods: + ------- + __init__(self, forward_temperature_celsius, source_inlet_temperature_celsius) + Initialize CopApproximator. + approximate_cop(self) + Approximate heat pump coefficient of performance (COP). + celsius_to_kelvin(t_celsius) + Convert temperature from Celsius to Kelvin. + logarithmic_mean(t_hot, t_cold) + Calculate the logarithmic mean temperature difference. """ def __init__( @@ -28,8 +46,8 @@ class BaseCopApproximator(ABC): ---------- forward_temperature_celsius : Union[xr.DataArray, np.array] The forward temperature in Celsius. - return_temperature_celsius : Union[xr.DataArray, np.array] - The return temperature in Celsius. + source_inlet_temperature_celsius : Union[xr.DataArray, np.array] + The source inlet temperature in Celsius. """ pass @@ -49,6 +67,19 @@ class BaseCopApproximator(ABC): def celsius_to_kelvin( t_celsius: Union[float, xr.DataArray, np.array] ) -> Union[float, xr.DataArray, np.array]: + """ + Convert temperature from Celsius to Kelvin. + + Parameters: + ---------- + t_celsius : Union[float, xr.DataArray, np.array] + Temperature in Celsius. + + Returns: + ------- + Union[float, xr.DataArray, np.array] + Temperature in Kelvin. + """ if (np.asarray(t_celsius) > 200).any(): raise ValueError( "t_celsius > 200. Are you sure you are using the right units?" @@ -60,6 +91,21 @@ class BaseCopApproximator(ABC): t_hot: Union[float, xr.DataArray, np.ndarray], t_cold: Union[float, xr.DataArray, np.ndarray], ) -> Union[float, xr.DataArray, np.ndarray]: + """ + Calculate the logarithmic mean temperature difference. + + Parameters: + ---------- + t_hot : Union[float, xr.DataArray, np.ndarray] + Hot temperature. + t_cold : Union[float, xr.DataArray, np.ndarray] + Cold temperature. + + Returns: + ------- + Union[float, xr.DataArray, np.ndarray] + Logarithmic mean temperature difference. + """ if (np.asarray(t_hot <= t_cold)).any(): raise ValueError("t_hot must be greater than t_cold") return (t_hot - t_cold) / np.log(t_hot / t_cold) diff --git a/scripts/build_cop_profiles/CentralHeatingCopApproximator.py b/scripts/build_cop_profiles/CentralHeatingCopApproximator.py index a29dab59..7bf15b30 100644 --- a/scripts/build_cop_profiles/CentralHeatingCopApproximator.py +++ b/scripts/build_cop_profiles/CentralHeatingCopApproximator.py @@ -20,8 +20,77 @@ class CentralHeatingCopApproximator(BaseCopApproximator): default parameters from Pieper et al. (2020). The method is based on a thermodynamic heat pump model with some hard-to-know parameters being approximated. - """ + Attributes: + ---------- + forward_temperature_celsius : Union[xr.DataArray, np.array] + The forward temperature in Celsius. + return_temperature_celsius : Union[xr.DataArray, np.array] + The return temperature in Celsius. + source_inlet_temperature_celsius : Union[xr.DataArray, np.array] + The source inlet temperature in Celsius. + source_outlet_temperature_celsius : Union[xr.DataArray, np.array] + The source outlet temperature in Celsius. + delta_t_pinch_point : float, optional + The pinch point temperature difference, by default 5. + isentropic_compressor_efficiency : float, optional + The isentropic compressor efficiency, by default 0.8. + heat_loss : float, optional + The heat loss, by default 0.0. + + Methods: + ------- + __init__( + forward_temperature_celsius: Union[xr.DataArray, np.array], + source_inlet_temperature_celsius: Union[xr.DataArray, np.array], + return_temperature_celsius: Union[xr.DataArray, np.array], + source_outlet_temperature_celsius: Union[xr.DataArray, np.array], + delta_t_pinch_point: float = 5, + isentropic_compressor_efficiency: float = 0.8, + heat_loss: float = 0.0, + ) -> None: + Initializes the CentralHeatingCopApproximator object. + + approximate_cop(self) -> Union[xr.DataArray, np.array]: + Calculate the coefficient of performance (COP) for the system. + + _approximate_delta_t_refrigerant_source( + self, delta_t_source: Union[xr.DataArray, np.array] + ) -> Union[xr.DataArray, np.array]: + Approximates the temperature difference between the refrigerant and the source. + + _approximate_delta_t_refrigerant_sink( + self, + refrigerant: str = "ammonia", + a: float = {"ammonia": 0.2, "isobutane": -0.0011}, + b: float = {"ammonia": 0.2, "isobutane": 0.3}, + c: float = {"ammonia": 0.016, "isobutane": 2.4}, + ) -> Union[xr.DataArray, np.array]: + Approximates the temperature difference between the refrigerant and heat sink. + + _ratio_evaporation_compression_work_approximation( + self, + refrigerant: str = "ammonia", + a: float = {"ammonia": 0.0014, "isobutane": 0.0035}, + ) -> Union[xr.DataArray, np.array]: + Calculate the ratio of evaporation to compression work based on approximation. + + _approximate_delta_t_refrigerant_sink( + self, + refrigerant: str = "ammonia", + a: float = {"ammonia": 0.2, "isobutane": -0.0011}, + b: float = {"ammonia": 0.2, "isobutane": 0.3}, + c: float = {"ammonia": 0.016, "isobutane": 2.4}, + ) -> Union[xr.DataArray, np.array]: + Approximates the temperature difference between the refrigerant and heat sink. + + _ratio_evaporation_compression_work_approximation( + self, + refrigerant: str = "ammonia", + a: float = {"ammonia": 0.0014, "isobutane": 0.0035}, + ) -> Union[xr.DataArray, np.array]: + Calculate the ratio of evaporation to compression work based on approximation. + """ def __init__( self, forward_temperature_celsius: Union[xr.DataArray, np.array], @@ -33,6 +102,7 @@ class CentralHeatingCopApproximator(BaseCopApproximator): heat_loss: float = 0.0, ) -> None: """ + Initializes the CentralHeatingCopApproximator object. Parameters: ---------- @@ -74,6 +144,7 @@ class CentralHeatingCopApproximator(BaseCopApproximator): Calculate the coefficient of performance (COP) for the system. Returns: + -------- Union[xr.DataArray, np.array]: The calculated COP values. """ return ( diff --git a/scripts/build_cop_profiles/DecentralHeatingCopApproximator.py b/scripts/build_cop_profiles/DecentralHeatingCopApproximator.py index 11be7407..d84b6795 100644 --- a/scripts/build_cop_profiles/DecentralHeatingCopApproximator.py +++ b/scripts/build_cop_profiles/DecentralHeatingCopApproximator.py @@ -16,7 +16,27 @@ class DecentralHeatingCopApproximator(BaseCopApproximator): Approximate the coefficient of performance (COP) for a heat pump in a decentral heating system (individual/household heating). - Uses a quadratic regression on the temperature difference between the source and sink based on empirical data proposed by Staffell et al. 2012 . + Uses a quadratic regression on the temperature difference between the source and sink based on empirical data proposed by Staffell et al. 2012. + + Attributes + ---------- + forward_temperature_celsius : Union[xr.DataArray, np.array] + The forward temperature in Celsius. + source_inlet_temperature_celsius : Union[xr.DataArray, np.array] + The source inlet temperature in Celsius. + source_type : str + The source of the heat pump. Must be either 'air' or 'ground'. + + Methods + ------- + __init__(forward_temperature_celsius, source_inlet_temperature_celsius, source_type) + Initialize the DecentralHeatingCopApproximator object. + approximate_cop() + Compute the COP values using quadratic regression for air-/ground-source heat pumps. + _approximate_cop_air_source() + Evaluate quadratic regression for an air-sourced heat pump. + _approximate_cop_ground_source() + Evaluate quadratic regression for a ground-sourced heat pump. References ---------- @@ -30,30 +50,32 @@ class DecentralHeatingCopApproximator(BaseCopApproximator): source_type: str, ): """ - Initialize the COPProfileBuilder object. + Initialize the DecentralHeatingCopApproximator object. - Parameters: + Parameters ---------- forward_temperature_celsius : Union[xr.DataArray, np.array] The forward temperature in Celsius. - return_temperature_celsius : Union[xr.DataArray, np.array] - The return temperature in Celsius. - source: str - The source of the heat pump. Must be either 'air' or 'ground' + source_inlet_temperature_celsius : Union[xr.DataArray, np.array] + The source inlet temperature in Celsius. + source_type : str + The source of the heat pump. Must be either 'air' or 'ground'. """ self.delta_t = forward_temperature_celsius - source_inlet_temperature_celsius if source_type not in ["air", "ground"]: - raise ValueError("'source' must be one of ['air', 'ground']") + raise ValueError("'source_type' must be one of ['air', 'ground']") else: self.source_type = source_type def approximate_cop(self) -> Union[xr.DataArray, np.array]: """ - Compute output of quadratic regression for air-/ground-source heat - pumps. + Compute the COP values using quadratic regression for air-/ground-source heat pumps. - Calls the appropriate method depending on `source`. + Returns + ------- + Union[xr.DataArray, np.array] + The calculated COP values. """ if self.source_type == "air": return self._approximate_cop_air_source() From d273de86001d29bd8996d218eb5cc01f569f1a26 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 31 Jul 2024 15:01:48 +0000 Subject: [PATCH 38/79] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- scripts/build_cop_profiles/CentralHeatingCopApproximator.py | 1 + scripts/build_cop_profiles/DecentralHeatingCopApproximator.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/build_cop_profiles/CentralHeatingCopApproximator.py b/scripts/build_cop_profiles/CentralHeatingCopApproximator.py index 7bf15b30..08dd6a1a 100644 --- a/scripts/build_cop_profiles/CentralHeatingCopApproximator.py +++ b/scripts/build_cop_profiles/CentralHeatingCopApproximator.py @@ -91,6 +91,7 @@ class CentralHeatingCopApproximator(BaseCopApproximator): ) -> Union[xr.DataArray, np.array]: Calculate the ratio of evaporation to compression work based on approximation. """ + def __init__( self, forward_temperature_celsius: Union[xr.DataArray, np.array], diff --git a/scripts/build_cop_profiles/DecentralHeatingCopApproximator.py b/scripts/build_cop_profiles/DecentralHeatingCopApproximator.py index d84b6795..e5f58af4 100644 --- a/scripts/build_cop_profiles/DecentralHeatingCopApproximator.py +++ b/scripts/build_cop_profiles/DecentralHeatingCopApproximator.py @@ -70,7 +70,8 @@ class DecentralHeatingCopApproximator(BaseCopApproximator): def approximate_cop(self) -> Union[xr.DataArray, np.array]: """ - Compute the COP values using quadratic regression for air-/ground-source heat pumps. + Compute the COP values using quadratic regression for air-/ground- + source heat pumps. Returns ------- From 214efeb0569a9a8c72bff32d8226a79891f1f466 Mon Sep 17 00:00:00 2001 From: AmosSchledorn Date: Wed, 31 Jul 2024 17:30:24 +0200 Subject: [PATCH 39/79] make test.sh executable --- test.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 test.sh diff --git a/test.sh b/test.sh old mode 100644 new mode 100755 From b0150bd65d4fb7afd107a1edd9bebf5757f0feba Mon Sep 17 00:00:00 2001 From: AmosSchledorn Date: Thu, 1 Aug 2024 11:59:26 +0200 Subject: [PATCH 40/79] refactor prepare_sector_network.add_heat using Enums --- config/config.default.yaml | 9 +++ rules/build_sector.smk | 1 + scripts/prepare_sector_network.py | 104 ++++++++++++------------------ 3 files changed, 53 insertions(+), 61 deletions(-) diff --git a/config/config.default.yaml b/config/config.default.yaml index 794b2bae..bfa99d90 100644 --- a/config/config.default.yaml +++ b/config/config.default.yaml @@ -422,6 +422,15 @@ sector: decentral: - air - ground + heat_systems: + rural: + - residential rural + - services rural + urban decentral: + - residential urban decentral + - services urban decentral + urban central: + - urban central cluster_heat_buses: true heat_demand_cutout: default bev_dsm_restriction_value: 0.75 diff --git a/rules/build_sector.smk b/rules/build_sector.smk index b7d916ea..34477f5b 100644 --- a/rules/build_sector.smk +++ b/rules/build_sector.smk @@ -965,6 +965,7 @@ rule prepare_sector_network: emissions_scope=config_provider("energy", "emissions"), RDIR=RDIR, heat_pump_sources=config_provider("sector", "heat_pump_sources"), + heat_systems=config_provider("sector", "heat_systems") input: unpack(input_profile_offwind), **rules.cluster_gas_network.output, diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index f71dd5f5..52989c2d 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -22,6 +22,7 @@ from _helpers import ( set_scenario_config, update_config_from_wildcards, ) +from _entities import HeatSystem, HeatSector from add_electricity import calculate_annuity, sanitize_carriers, sanitize_locations from build_energy_totals import ( build_co2_totals, @@ -1817,14 +1818,6 @@ def add_heat(n, costs): for sector in sectors: heat_demand[sector + " space"] = (1 - dE) * heat_demand[sector + " space"] - heat_systems = [ - "residential rural", - "services rural", - "residential urban decentral", - "services urban decentral", - "urban central", - ] - if options["solar_thermal"]: solar_thermal = ( xr.open_dataarray(snakemake.input.solar_thermal_total) @@ -1835,31 +1828,31 @@ def add_heat(n, costs): solar_thermal = options["solar_cf_correction"] * solar_thermal / 1e3 cop = xr.open_dataarray(snakemake.input.cop_profiles) - for heat_system in heat_systems: - system_type = "central" if heat_system == "urban central" else "decentral" + for heat_system in HeatSystem: #this loops through all heat systems defined in _entities.HeatSystem + # system_type = "central" if heat_system == "urban central" else "decentral" - if heat_system == "urban central": + if heat_system == HeatSystem.URBAN_CENTRAL: nodes = dist_fraction.index[dist_fraction > 0] else: nodes = pop_layout.index - n.add("Carrier", heat_system + " heat") + n.add("Carrier", f"{heat_system} heat") n.madd( "Bus", nodes + f" {heat_system} heat", location=nodes, - carrier=heat_system + " heat", + carrier=f"{heat_system} heat", unit="MWh_th", ) - if heat_system == "urban central" and options.get("central_heat_vent"): + if heat_system == HeatSystem.URBAN_CENTRAL and options.get("central_heat_vent"): n.madd( "Generator", nodes + f" {heat_system} heat vent", bus=nodes + f" {heat_system} heat", location=nodes, - carrier=heat_system + " heat vent", + carrier=f"{heat_system} heat vent", p_nom_extendable=True, p_max_pu=0, p_min_pu=-1, @@ -1867,30 +1860,18 @@ def add_heat(n, costs): ) ## Add heat load + factor = heat_system.heat_demand_weighting(urban_fraction=urban_fraction[nodes], dist_fraction=dist_fraction[nodes]) + if not heat_system == HeatSystem.URBAN_CENTRAL: + heat_load = ( + heat_demand[[heat_system.sector.value + " water", heat_system.sector.value + " space"]] + .T.groupby(level=1) + .sum() + .T[nodes] + .multiply(factor) + ) - for sector in sectors: - # heat demand weighting - if "rural" in heat_system: - factor = 1 - urban_fraction[nodes] - elif "urban central" in heat_system: - factor = dist_fraction[nodes] - elif "urban decentral" in heat_system: - factor = urban_fraction[nodes] - dist_fraction[nodes] - else: - raise NotImplementedError( - f" {heat_system} not in " f"heat systems: {heat_systems}" - ) - if sector in heat_system: - heat_load = ( - heat_demand[[sector + " water", sector + " space"]] - .T.groupby(level=1) - .sum() - .T[nodes] - .multiply(factor) - ) - - if heat_system == "urban central": + if heat_system == HeatSystem.URBAN_CENTRAL: heat_load = ( heat_demand.T.groupby(level=1) .sum() @@ -1905,15 +1886,15 @@ def add_heat(n, costs): nodes, suffix=f" {heat_system} heat", bus=nodes + f" {heat_system} heat", - carrier=heat_system + " heat", + carrier=heat_system.value + " heat", p_set=heat_load, ) ## Add heat pumps - for heat_source in snakemake.params.heat_pump_sources[system_type]: - costs_name = f"{system_type} {heat_source}-sourced heat pump" + for heat_source in snakemake.params.heat_pump_sources[heat_system.system_type]: + costs_name = heat_system.heat_pump_costs_name(heat_source) efficiency = ( - cop.sel(heat_system=system_type, heat_source=heat_source, name=nodes) + cop.sel(heat_system=heat_system.system_type, heat_source=heat_source, name=nodes) .to_pandas() .reindex(index=n.snapshots) if options["time_dep_hp_cop"] @@ -1936,13 +1917,13 @@ def add_heat(n, costs): ) if options["tes"]: - n.add("Carrier", heat_system + " water tanks") + n.add("Carrier", heat_system.value + " water tanks") n.madd( "Bus", nodes + f" {heat_system} water tanks", location=nodes, - carrier=heat_system + " water tanks", + carrier=heat_system.value + " water tanks", unit="MWh_th", ) @@ -1952,7 +1933,7 @@ def add_heat(n, costs): bus0=nodes + f" {heat_system} heat", bus1=nodes + f" {heat_system} water tanks", efficiency=costs.at["water tank charger", "efficiency"], - carrier=heat_system + " water tanks charger", + carrier=heat_system.value + " water tanks charger", p_nom_extendable=True, ) @@ -1961,12 +1942,12 @@ def add_heat(n, costs): nodes + f" {heat_system} water tanks discharger", bus0=nodes + f" {heat_system} water tanks", bus1=nodes + f" {heat_system} heat", - carrier=heat_system + " water tanks discharger", + carrier=heat_system.value + " water tanks discharger", efficiency=costs.at["water tank discharger", "efficiency"], p_nom_extendable=True, ) - tes_time_constant_days = options["tes_tau"][system_type] + tes_time_constant_days = options["tes_tau"][heat_system.system_type] n.madd( "Store", @@ -1974,21 +1955,21 @@ def add_heat(n, costs): bus=nodes + f" {heat_system} water tanks", e_cyclic=True, e_nom_extendable=True, - carrier=heat_system + " water tanks", + carrier=heat_system.value + " water tanks", standing_loss=1 - np.exp(-1 / 24 / tes_time_constant_days), - capital_cost=costs.at[system_type + " water tank storage", "fixed"], - lifetime=costs.at[system_type + " water tank storage", "lifetime"], + capital_cost=costs.at[heat_system.system_type + " water tank storage", "fixed"], + lifetime=costs.at[heat_system.system_type + " water tank storage", "lifetime"], ) if options["resistive_heaters"]: - key = f"{system_type} resistive heater" + key = f"{heat_system.system_type} resistive heater" n.madd( "Link", nodes + f" {heat_system} resistive heater", bus0=nodes, bus1=nodes + f" {heat_system} heat", - carrier=heat_system + " resistive heater", + carrier=heat_system.value + " resistive heater", efficiency=costs.at[key, "efficiency"], capital_cost=costs.at[key, "efficiency"] * costs.at[key, "fixed"] @@ -1998,7 +1979,7 @@ def add_heat(n, costs): ) if options["boilers"]: - key = f"{system_type} gas boiler" + key = f"{heat_system.system_type} gas boiler" n.madd( "Link", @@ -2007,7 +1988,7 @@ def add_heat(n, costs): bus0=spatial.gas.df.loc[nodes, "nodes"].values, bus1=nodes + f" {heat_system} heat", bus2="co2 atmosphere", - carrier=heat_system + " gas boiler", + carrier=heat_system.value + " gas boiler", efficiency=costs.at[key, "efficiency"], efficiency2=costs.at["gas", "CO2 intensity"], capital_cost=costs.at[key, "efficiency"] @@ -2017,19 +1998,19 @@ def add_heat(n, costs): ) if options["solar_thermal"]: - n.add("Carrier", heat_system + " solar thermal") + n.add("Carrier", heat_system.value + " solar thermal") n.madd( "Generator", nodes, suffix=f" {heat_system} solar thermal collector", bus=nodes + f" {heat_system} heat", - carrier=heat_system + " solar thermal", + carrier=heat_system.value + " solar thermal", p_nom_extendable=True, - capital_cost=costs.at[system_type + " solar thermal", "fixed"] + capital_cost=costs.at[heat_system.system_type + " solar thermal", "fixed"] * overdim_factor, p_max_pu=solar_thermal[nodes], - lifetime=costs.at[system_type + " solar thermal", "lifetime"], + lifetime=costs.at[heat_system.system_type + " solar thermal", "lifetime"], ) if options["chp"] and heat_system == "urban central": @@ -2125,16 +2106,16 @@ def add_heat(n, costs): # share of space heat demand 'w_space' of total heat demand w_space = {} - for sector in sectors: - w_space[sector] = heat_demand[sector + " space"] / ( - heat_demand[sector + " space"] + heat_demand[sector + " water"] + for sector in HeatSector: + w_space[sector.value] = heat_demand[sector.value + " space"] / ( + heat_demand[sector.value + " space"] + heat_demand[sector.value + " water"] ) w_space["tot"] = ( heat_demand["services space"] + heat_demand["residential space"] ) / heat_demand.T.groupby(level=[1]).sum().T for heat_system in n.loads[ - n.loads.carrier.isin([x + " heat" for x in heat_systems]) + n.loads.carrier.isin([x.value + " heat" for x in HeatSystem]) ].index: node = n.buses.loc[heat_system, "location"] ct = pop_layout.loc[node, "ct"] @@ -2148,6 +2129,7 @@ def add_heat(n, costs): f = 1 - urban_fraction[node] if f == 0: continue + # get sector name ("residential"/"services"/or both "tot" for urban central) if "urban central" in heat_system: sec = "tot" From b2d346f02cdeb3f16f15c258a98cf864c33f7a2a Mon Sep 17 00:00:00 2001 From: lisazeyen Date: Thu, 1 Aug 2024 17:47:21 +0200 Subject: [PATCH 41/79] some simplifications --- scripts/prepare_sector_network.py | 34 +++++++++++-------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index 35de1fe7..cdd12866 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -543,21 +543,16 @@ def add_carrier_buses(n, carrier, nodes=None): ) fossils = ["coal", "gas", "oil", "lignite"] - if not options.get("fossil_fuels", True) and carrier in fossils: - print("Not adding fossil ", carrier) - extendable = False - else: - print("Adding fossil ", carrier) - extendable = True - - n.madd( - "Generator", - nodes, - bus=nodes, - p_nom_extendable=extendable, - carrier=carrier, - marginal_cost=costs.at[carrier, "fuel"], - ) + if options.get("fossil_fuels", True) and carrier in fossils: + + n.madd( + "Generator", + nodes, + bus=nodes, + p_nom_extendable=True, + carrier=carrier, + marginal_cost=costs.at[carrier, "fuel"], + ) # TODO: PyPSA-Eur merge issue @@ -2906,17 +2901,12 @@ def add_industry(n, costs): carrier="oil", ) - if not options.get("fossil_fuels", True): - extendable = False - else: - extendable = True - - if "oil" not in n.generators.carrier.unique(): + if options.get("fossil_fuels", True) and "oil" not in n.generators.carrier.unique(): n.madd( "Generator", spatial.oil.nodes, bus=spatial.oil.nodes, - p_nom_extendable=extendable, + p_nom_extendable=True, carrier="oil", marginal_cost=costs.at["oil", "fuel"], ) From 3eb8b163049b595a91ef5e5036f7f239e68c8145 Mon Sep 17 00:00:00 2001 From: lisazeyen Date: Thu, 1 Aug 2024 17:47:41 +0200 Subject: [PATCH 42/79] add description for new config setting --- doc/configtables/sector.csv | 311 ++++++++++++++++++------------------ 1 file changed, 156 insertions(+), 155 deletions(-) diff --git a/doc/configtables/sector.csv b/doc/configtables/sector.csv index 5045cecd..89c0e55c 100644 --- a/doc/configtables/sector.csv +++ b/doc/configtables/sector.csv @@ -1,155 +1,156 @@ -,Unit,Values,Description -transport,--,"{true, false}",Flag to include transport sector. -heating,--,"{true, false}",Flag to include heating sector. -biomass,--,"{true, false}",Flag to include biomass sector. -industry,--,"{true, false}",Flag to include industry sector. -agriculture,--,"{true, false}",Flag to include agriculture sector. -district_heating,--,,`prepare_sector_network.py `_ --- potential,--,float,maximum fraction of urban demand which can be supplied by district heating. Ignored where below current fraction. --- progress,--,Dictionary with planning horizons as keys., Increase of today's district heating demand to potential maximum district heating share. Progress = 0 means today's district heating share. Progress = 1 means maximum fraction of urban demand is supplied by district heating --- district_heating_loss,--,float,Share increase in district heat demand in urban central due to heat losses -cluster_heat_buses,--,"{true, false}",Cluster residential and service heat buses in `prepare_sector_network.py `_ to one to save memory. -,,, -bev_dsm_restriction _value,--,float,Adds a lower state of charge (SOC) limit for battery electric vehicles (BEV) to manage its own energy demand (DSM). Located in `build_transport_demand.py `_. Set to 0 for no restriction on BEV DSM -bev_dsm_restriction _time,--,float,Time at which SOC of BEV has to be dsm_restriction_value -transport_heating _deadband_upper,°C,float,"The maximum temperature in the vehicle. At higher temperatures, the energy required for cooling in the vehicle increases." -transport_heating _deadband_lower,°C,float,"The minimum temperature in the vehicle. At lower temperatures, the energy required for heating in the vehicle increases." -,,, -ICE_lower_degree_factor,--,float,Share increase in energy demand in internal combustion engine (ICE) for each degree difference between the cold environment and the minimum temperature. -ICE_upper_degree_factor,--,float,Share increase in energy demand in internal combustion engine (ICE) for each degree difference between the hot environment and the maximum temperature. -EV_lower_degree_factor,--,float,Share increase in energy demand in electric vehicles (EV) for each degree difference between the cold environment and the minimum temperature. -EV_upper_degree_factor,--,float,Share increase in energy demand in electric vehicles (EV) for each degree difference between the hot environment and the maximum temperature. -bev_dsm,--,"{true, false}",Add the option for battery electric vehicles (BEV) to participate in demand-side management (DSM) -,,, -bev_availability,--,float,The share for battery electric vehicles (BEV) that are able to do demand side management (DSM) -bev_energy,--,float,The average size of battery electric vehicles (BEV) in MWh -bev_charge_efficiency,--,float,Battery electric vehicles (BEV) charge and discharge efficiency -bev_charge_rate,MWh,float,The power consumption for one electric vehicle (EV) in MWh. Value derived from 3-phase charger with 11 kW. -bev_avail_max,--,float,The maximum share plugged-in availability for passenger electric vehicles. -bev_avail_mean,--,float,The average share plugged-in availability for passenger electric vehicles. -v2g,--,"{true, false}",Allows feed-in to grid from EV battery -land_transport_fuel_cell _share,--,Dictionary with planning horizons as keys.,The share of vehicles that uses fuel cells in a given year -land_transport_electric _share,--,Dictionary with planning horizons as keys.,The share of vehicles that uses electric vehicles (EV) in a given year -land_transport_ice _share,--,Dictionary with planning horizons as keys.,The share of vehicles that uses internal combustion engines (ICE) in a given year. What is not EV or FCEV is oil-fuelled ICE. -transport_electric_efficiency,MWh/100km,float,The conversion efficiencies of electric vehicles in transport -transport_fuel_cell_efficiency,MWh/100km,float,The H2 conversion efficiencies of fuel cells in transport -transport_ice_efficiency,MWh/100km,float,The oil conversion efficiencies of internal combustion engine (ICE) in transport -agriculture_machinery _electric_share,--,float,The share for agricultural machinery that uses electricity -agriculture_machinery _oil_share,--,float,The share for agricultural machinery that uses oil -agriculture_machinery _fuel_efficiency,--,float,The efficiency of electric-powered machinery in the conversion of electricity to meet agricultural needs. -agriculture_machinery _electric_efficiency,--,float,The efficiency of oil-powered machinery in the conversion of oil to meet agricultural needs. -Mwh_MeOH_per_MWh_H2,LHV,float,"The energy amount of the produced methanol per energy amount of hydrogen. From `DECHEMA (2017) `_, page 64." -MWh_MeOH_per_tCO2,LHV,float,"The energy amount of the produced methanol per ton of CO2. From `DECHEMA (2017) `_, page 66." -MWh_MeOH_per_MWh_e,LHV,float,"The energy amount of the produced methanol per energy amount of electricity. From `DECHEMA (2017) `_, page 64." -shipping_hydrogen _liquefaction,--,"{true, false}",Whether to include liquefaction costs for hydrogen demand in shipping. -,,, -shipping_hydrogen_share,--,Dictionary with planning horizons as keys.,The share of ships powered by hydrogen in a given year -shipping_methanol_share,--,Dictionary with planning horizons as keys.,The share of ships powered by methanol in a given year -shipping_oil_share,--,Dictionary with planning horizons as keys.,The share of ships powered by oil in a given year -shipping_methanol _efficiency,--,float,The efficiency of methanol-powered ships in the conversion of methanol to meet shipping needs (propulsion). The efficiency increase from oil can be 10-15% higher according to the `IEA `_ -,,, -shipping_oil_efficiency,--,float,The efficiency of oil-powered ships in the conversion of oil to meet shipping needs (propulsion). Base value derived from 2011 -aviation_demand_factor,--,float,The proportion of demand for aviation compared to today's consumption -HVC_demand_factor,--,float,The proportion of demand for high-value chemicals compared to today's consumption -,,, -time_dep_hp_cop,--,"{true, false}",Consider the time dependent coefficient of performance (COP) of the heat pump -heat_pump_sink_T,°C,float,The temperature heat sink used in heat pumps based on DTU / large area radiators. The value is conservatively high to cover hot water and space heating in poorly-insulated buildings -reduce_space_heat _exogenously,--,"{true, false}",Influence on space heating demand by a certain factor (applied before losses in district heating). -reduce_space_heat _exogenously_factor,--,Dictionary with planning horizons as keys.,"A positive factor can mean renovation or demolition of a building. If the factor is negative, it can mean an increase in floor area, increased thermal comfort, population growth. The default factors are determined by the `Eurocalc Homes and buildings decarbonization scenario `_" -retrofitting,,, --- retro_endogen,--,"{true, false}",Add retrofitting as an endogenous system which co-optimise space heat savings. --- cost_factor,--,float,Weight costs for building renovation --- interest_rate,--,float,The interest rate for investment in building components --- annualise_cost,--,"{true, false}",Annualise the investment costs of retrofitting --- tax_weighting,--,"{true, false}",Weight the costs of retrofitting depending on taxes in countries --- construction_index,--,"{true, false}",Weight the costs of retrofitting depending on labour/material costs per country -tes,--,"{true, false}",Add option for storing thermal energy in large water pits associated with district heating systems and individual thermal energy storage (TES) -tes_tau,,,The time constant used to calculate the decay of thermal energy in thermal energy storage (TES): 1- :math:`e^{-1/24τ}`. --- decentral,days,float,The time constant in decentralized thermal energy storage (TES) --- central,days,float,The time constant in centralized thermal energy storage (TES) -boilers,--,"{true, false}",Add option for transforming gas into heat using gas boilers -resistive_heaters,--,"{true, false}",Add option for transforming electricity into heat using resistive heaters (independently from gas boilers) -oil_boilers,--,"{true, false}",Add option for transforming oil into heat using boilers -biomass_boiler,--,"{true, false}",Add option for transforming biomass into heat using boilers -overdimension_individual_heating,--,"float",Add option for overdimensioning individual heating systems by a certain factor. This allows them to cover heat demand peaks e.g. 10% higher than those in the data with a setting of 1.1. -chp,--,"{true, false}",Add option for using Combined Heat and Power (CHP) -micro_chp,--,"{true, false}",Add option for using Combined Heat and Power (CHP) for decentral areas. -solar_thermal,--,"{true, false}",Add option for using solar thermal to generate heat. -solar_cf_correction,--,float,The correction factor for the value provided by the solar thermal profile calculations -marginal_cost_storage,currency/MWh ,float,The marginal cost of discharging batteries in distributed grids -methanation,--,"{true, false}",Add option for transforming hydrogen and CO2 into methane using methanation. -coal_cc,--,"{true, false}",Add option for coal CHPs with carbon capture -dac,--,"{true, false}",Add option for Direct Air Capture (DAC) -co2_vent,--,"{true, false}",Add option for vent out CO2 from storages to the atmosphere. -allam_cycle,--,"{true, false}",Add option to include `Allam cycle gas power plants `_ -hydrogen_fuel_cell,--,"{true, false}",Add option to include hydrogen fuel cell for re-electrification. Assuming OCGT technology costs -hydrogen_turbine,--,"{true, false}",Add option to include hydrogen turbine for re-electrification. Assuming OCGT technology costs -SMR,--,"{true, false}",Add option for transforming natural gas into hydrogen and CO2 using Steam Methane Reforming (SMR) -SMR CC,--,"{true, false}",Add option for transforming natural gas into hydrogen and CO2 using Steam Methane Reforming (SMR) and Carbon Capture (CC) -regional_methanol_demand,--,"{true, false}",Spatially resolve methanol demand. Set to true if regional CO2 constraints needed. -regional_oil_demand,--,"{true, false}",Spatially resolve oil demand. Set to true if regional CO2 constraints needed. -regional_co2 _sequestration_potential,,, --- enable,--,"{true, false}",Add option for regionally-resolved geological carbon dioxide sequestration potentials based on `CO2StoP `_. --- attribute,--,string or list,Name (or list of names) of the attribute(s) for the sequestration potential --- include_onshore,--,"{true, false}",Add options for including onshore sequestration potentials --- min_size,Gt ,float,Any sites with lower potential than this value will be excluded --- max_size,Gt ,float,The maximum sequestration potential for any one site. --- years_of_storage,years,float,The years until potential exhausted at optimised annual rate -co2_sequestration_potential,MtCO2/a,float,The potential of sequestering CO2 in Europe per year -co2_sequestration_cost,currency/tCO2,float,The cost of sequestering a ton of CO2 -co2_sequestration_lifetime,years,int,The lifetime of a CO2 sequestration site -co2_spatial,--,"{true, false}","Add option to spatially resolve carrier representing stored carbon dioxide. This allows for more detailed modelling of CCUTS, e.g. regarding the capturing of industrial process emissions, usage as feedstock for electrofuels, transport of carbon dioxide, and geological sequestration sites." -,,, -co2network,--,"{true, false}",Add option for planning a new carbon dioxide transmission network -co2_network_cost_factor,p.u.,float,The cost factor for the capital cost of the carbon dioxide transmission network -,,, -cc_fraction,--,float,The default fraction of CO2 captured with post-combustion capture -hydrogen_underground _storage,--,"{true, false}",Add options for storing hydrogen underground. Storage potential depends regionally. -hydrogen_underground _storage_locations,,"{onshore, nearshore, offshore}","The location where hydrogen underground storage can be located. Onshore, nearshore, offshore means it must be located more than 50 km away from the sea, within 50 km of the sea, or within the sea itself respectively." -,,, -ammonia,--,"{true, false, regional}","Add ammonia as a carrrier. It can be either true (copperplated NH3), false (no NH3 carrier) or ""regional"" (regionalised NH3 without network)" -min_part_load_fischer _tropsch,per unit of p_nom ,float,The minimum unit dispatch (``p_min_pu``) for the Fischer-Tropsch process -min_part_load _methanolisation,per unit of p_nom ,float,The minimum unit dispatch (``p_min_pu``) for the methanolisation process -,,, -use_fischer_tropsch _waste_heat,--,"{true, false}",Add option for using waste heat of Fischer Tropsch in district heating networks -use_fuel_cell_waste_heat,--,"{true, false}",Add option for using waste heat of fuel cells in district heating networks -use_electrolysis_waste _heat,--,"{true, false}",Add option for using waste heat of electrolysis in district heating networks -electricity_transmission _grid,--,"{true, false}",Switch for enabling/disabling the electricity transmission grid. -electricity_distribution _grid,--,"{true, false}",Add a simplified representation of the exchange capacity between transmission and distribution grid level through a link. -electricity_distribution _grid_cost_factor,,,Multiplies the investment cost of the electricity distribution grid -,,, -electricity_grid _connection,--,"{true, false}",Add the cost of electricity grid connection for onshore wind and solar -transmission_efficiency,,,Section to specify transmission losses or compression energy demands of bidirectional links. Splits them into two capacity-linked unidirectional links. --- {carrier},--,str,The carrier of the link. --- -- efficiency_static,p.u.,float,Length-independent transmission efficiency. --- -- efficiency_per_1000km,p.u. per 1000 km,float,Length-dependent transmission efficiency ($\eta^{\text{length}}$) --- -- compression_per_1000km,p.u. per 1000 km,float,Length-dependent electricity demand for compression ($\eta \cdot \text{length}$) implemented as multi-link to local electricity bus. -H2_network,--,"{true, false}",Add option for new hydrogen pipelines -gas_network,--,"{true, false}","Add existing natural gas infrastructure, incl. LNG terminals, production and entry-points. The existing gas network is added with a lossless transport model. A length-weighted `k-edge augmentation algorithm `_ can be run to add new candidate gas pipelines such that all regions of the model can be connected to the gas network. When activated, all the gas demands are regionally disaggregated as well." -H2_retrofit,--,"{true, false}",Add option for retrofiting existing pipelines to transport hydrogen. -H2_retrofit_capacity _per_CH4,--,float,"The ratio for H2 capacity per original CH4 capacity of retrofitted pipelines. The `European Hydrogen Backbone (April, 2020) p.15 `_ 60% of original natural gas capacity could be used in cost-optimal case as H2 capacity." -gas_network_connectivity _upgrade ,--,float,The number of desired edge connectivity (k) in the length-weighted `k-edge augmentation algorithm `_ used for the gas network -gas_distribution_grid,--,"{true, false}",Add a gas distribution grid -gas_distribution_grid _cost_factor,,,Multiplier for the investment cost of the gas distribution grid -,,, -biomass_spatial,--,"{true, false}",Add option for resolving biomass demand regionally -biomass_transport,--,"{true, false}",Add option for transporting solid biomass between nodes -biogas_upgrading_cc,--,"{true, false}",Add option to capture CO2 from biomass upgrading -conventional_generation,,,Add a more detailed description of conventional carriers. Any power generation requires the consumption of fuel from nodes representing that fuel. -biomass_to_liquid,--,"{true, false}",Add option for transforming solid biomass into liquid fuel with the same properties as oil -biosng,--,"{true, false}",Add option for transforming solid biomass into synthesis gas with the same properties as natural gas -limit_max_growth,,, --- enable,--,"{true, false}",Add option to limit the maximum growth of a carrier --- factor,p.u.,float,The maximum growth factor of a carrier (e.g. 1.3 allows 30% larger than max historic growth) --- max_growth,,, --- -- {carrier},GW,float,The historic maximum growth of a carrier --- max_relative_growth,,, --- -- {carrier},p.u.,float,The historic maximum relative growth of a carrier -,,, -enhanced_geothermal,,, --- enable,--,"{true, false}",Add option to include Enhanced Geothermal Systems --- flexible,--,"{true, false}",Add option for flexible operation (see Ricks et al. 2024) --- max_hours,--,int,The maximum hours the reservoir can be charged under flexible operation --- max_boost,--,float,The maximum boost in power output under flexible operation --- var_cf,--,"{true, false}",Add option for variable capacity factor (see Ricks et al. 2024) --- sustainability_factor,--,float,Share of sourced heat that is replenished by the earth's core (see details in `build_egs_potentials.py `_) +,Unit,Values,Description +transport,--,"{true, false}",Flag to include transport sector. +heating,--,"{true, false}",Flag to include heating sector. +biomass,--,"{true, false}",Flag to include biomass sector. +industry,--,"{true, false}",Flag to include industry sector. +agriculture,--,"{true, false}",Flag to include agriculture sector. +fossil_fuels,--,"{true, false}","Flag to include imports of fossil fuels ( [""coal"", ""gas"", ""oil"", ""lignite""])" +district_heating,--,,`prepare_sector_network.py `_ +-- potential,--,float,maximum fraction of urban demand which can be supplied by district heating. Ignored where below current fraction. +-- progress,--,Dictionary with planning horizons as keys., Increase of today's district heating demand to potential maximum district heating share. Progress = 0 means today's district heating share. Progress = 1 means maximum fraction of urban demand is supplied by district heating +-- district_heating_loss,--,float,Share increase in district heat demand in urban central due to heat losses +cluster_heat_buses,--,"{true, false}",Cluster residential and service heat buses in `prepare_sector_network.py `_ to one to save memory. +,,, +bev_dsm_restriction _value,--,float,Adds a lower state of charge (SOC) limit for battery electric vehicles (BEV) to manage its own energy demand (DSM). Located in `build_transport_demand.py `_. Set to 0 for no restriction on BEV DSM +bev_dsm_restriction _time,--,float,Time at which SOC of BEV has to be dsm_restriction_value +transport_heating _deadband_upper,°C,float,"The maximum temperature in the vehicle. At higher temperatures, the energy required for cooling in the vehicle increases." +transport_heating _deadband_lower,°C,float,"The minimum temperature in the vehicle. At lower temperatures, the energy required for heating in the vehicle increases." +,,, +ICE_lower_degree_factor,--,float,Share increase in energy demand in internal combustion engine (ICE) for each degree difference between the cold environment and the minimum temperature. +ICE_upper_degree_factor,--,float,Share increase in energy demand in internal combustion engine (ICE) for each degree difference between the hot environment and the maximum temperature. +EV_lower_degree_factor,--,float,Share increase in energy demand in electric vehicles (EV) for each degree difference between the cold environment and the minimum temperature. +EV_upper_degree_factor,--,float,Share increase in energy demand in electric vehicles (EV) for each degree difference between the hot environment and the maximum temperature. +bev_dsm,--,"{true, false}",Add the option for battery electric vehicles (BEV) to participate in demand-side management (DSM) +,,, +bev_availability,--,float,The share for battery electric vehicles (BEV) that are able to do demand side management (DSM) +bev_energy,--,float,The average size of battery electric vehicles (BEV) in MWh +bev_charge_efficiency,--,float,Battery electric vehicles (BEV) charge and discharge efficiency +bev_charge_rate,MWh,float,The power consumption for one electric vehicle (EV) in MWh. Value derived from 3-phase charger with 11 kW. +bev_avail_max,--,float,The maximum share plugged-in availability for passenger electric vehicles. +bev_avail_mean,--,float,The average share plugged-in availability for passenger electric vehicles. +v2g,--,"{true, false}",Allows feed-in to grid from EV battery +land_transport_fuel_cell _share,--,Dictionary with planning horizons as keys.,The share of vehicles that uses fuel cells in a given year +land_transport_electric _share,--,Dictionary with planning horizons as keys.,The share of vehicles that uses electric vehicles (EV) in a given year +land_transport_ice _share,--,Dictionary with planning horizons as keys.,The share of vehicles that uses internal combustion engines (ICE) in a given year. What is not EV or FCEV is oil-fuelled ICE. +transport_electric_efficiency,MWh/100km,float,The conversion efficiencies of electric vehicles in transport +transport_fuel_cell_efficiency,MWh/100km,float,The H2 conversion efficiencies of fuel cells in transport +transport_ice_efficiency,MWh/100km,float,The oil conversion efficiencies of internal combustion engine (ICE) in transport +agriculture_machinery _electric_share,--,float,The share for agricultural machinery that uses electricity +agriculture_machinery _oil_share,--,float,The share for agricultural machinery that uses oil +agriculture_machinery _fuel_efficiency,--,float,The efficiency of electric-powered machinery in the conversion of electricity to meet agricultural needs. +agriculture_machinery _electric_efficiency,--,float,The efficiency of oil-powered machinery in the conversion of oil to meet agricultural needs. +Mwh_MeOH_per_MWh_H2,LHV,float,"The energy amount of the produced methanol per energy amount of hydrogen. From `DECHEMA (2017) `_, page 64." +MWh_MeOH_per_tCO2,LHV,float,"The energy amount of the produced methanol per ton of CO2. From `DECHEMA (2017) `_, page 66." +MWh_MeOH_per_MWh_e,LHV,float,"The energy amount of the produced methanol per energy amount of electricity. From `DECHEMA (2017) `_, page 64." +shipping_hydrogen _liquefaction,--,"{true, false}",Whether to include liquefaction costs for hydrogen demand in shipping. +,,, +shipping_hydrogen_share,--,Dictionary with planning horizons as keys.,The share of ships powered by hydrogen in a given year +shipping_methanol_share,--,Dictionary with planning horizons as keys.,The share of ships powered by methanol in a given year +shipping_oil_share,--,Dictionary with planning horizons as keys.,The share of ships powered by oil in a given year +shipping_methanol _efficiency,--,float,The efficiency of methanol-powered ships in the conversion of methanol to meet shipping needs (propulsion). The efficiency increase from oil can be 10-15% higher according to the `IEA `_ +,,, +shipping_oil_efficiency,--,float,The efficiency of oil-powered ships in the conversion of oil to meet shipping needs (propulsion). Base value derived from 2011 +aviation_demand_factor,--,float,The proportion of demand for aviation compared to today's consumption +HVC_demand_factor,--,float,The proportion of demand for high-value chemicals compared to today's consumption +,,, +time_dep_hp_cop,--,"{true, false}",Consider the time dependent coefficient of performance (COP) of the heat pump +heat_pump_sink_T,°C,float,The temperature heat sink used in heat pumps based on DTU / large area radiators. The value is conservatively high to cover hot water and space heating in poorly-insulated buildings +reduce_space_heat _exogenously,--,"{true, false}",Influence on space heating demand by a certain factor (applied before losses in district heating). +reduce_space_heat _exogenously_factor,--,Dictionary with planning horizons as keys.,"A positive factor can mean renovation or demolition of a building. If the factor is negative, it can mean an increase in floor area, increased thermal comfort, population growth. The default factors are determined by the `Eurocalc Homes and buildings decarbonization scenario `_" +retrofitting,,, +-- retro_endogen,--,"{true, false}",Add retrofitting as an endogenous system which co-optimise space heat savings. +-- cost_factor,--,float,Weight costs for building renovation +-- interest_rate,--,float,The interest rate for investment in building components +-- annualise_cost,--,"{true, false}",Annualise the investment costs of retrofitting +-- tax_weighting,--,"{true, false}",Weight the costs of retrofitting depending on taxes in countries +-- construction_index,--,"{true, false}",Weight the costs of retrofitting depending on labour/material costs per country +tes,--,"{true, false}",Add option for storing thermal energy in large water pits associated with district heating systems and individual thermal energy storage (TES) +tes_tau,,,The time constant used to calculate the decay of thermal energy in thermal energy storage (TES): 1- :math:`e^{-1/24τ}`. +-- decentral,days,float,The time constant in decentralized thermal energy storage (TES) +-- central,days,float,The time constant in centralized thermal energy storage (TES) +boilers,--,"{true, false}",Add option for transforming gas into heat using gas boilers +resistive_heaters,--,"{true, false}",Add option for transforming electricity into heat using resistive heaters (independently from gas boilers) +oil_boilers,--,"{true, false}",Add option for transforming oil into heat using boilers +biomass_boiler,--,"{true, false}",Add option for transforming biomass into heat using boilers +overdimension_individual_heating,--,float,Add option for overdimensioning individual heating systems by a certain factor. This allows them to cover heat demand peaks e.g. 10% higher than those in the data with a setting of 1.1. +chp,--,"{true, false}",Add option for using Combined Heat and Power (CHP) +micro_chp,--,"{true, false}",Add option for using Combined Heat and Power (CHP) for decentral areas. +solar_thermal,--,"{true, false}",Add option for using solar thermal to generate heat. +solar_cf_correction,--,float,The correction factor for the value provided by the solar thermal profile calculations +marginal_cost_storage,currency/MWh ,float,The marginal cost of discharging batteries in distributed grids +methanation,--,"{true, false}",Add option for transforming hydrogen and CO2 into methane using methanation. +coal_cc,--,"{true, false}",Add option for coal CHPs with carbon capture +dac,--,"{true, false}",Add option for Direct Air Capture (DAC) +co2_vent,--,"{true, false}",Add option for vent out CO2 from storages to the atmosphere. +allam_cycle,--,"{true, false}",Add option to include `Allam cycle gas power plants `_ +hydrogen_fuel_cell,--,"{true, false}",Add option to include hydrogen fuel cell for re-electrification. Assuming OCGT technology costs +hydrogen_turbine,--,"{true, false}",Add option to include hydrogen turbine for re-electrification. Assuming OCGT technology costs +SMR,--,"{true, false}",Add option for transforming natural gas into hydrogen and CO2 using Steam Methane Reforming (SMR) +SMR CC,--,"{true, false}",Add option for transforming natural gas into hydrogen and CO2 using Steam Methane Reforming (SMR) and Carbon Capture (CC) +regional_methanol_demand,--,"{true, false}",Spatially resolve methanol demand. Set to true if regional CO2 constraints needed. +regional_oil_demand,--,"{true, false}",Spatially resolve oil demand. Set to true if regional CO2 constraints needed. +regional_co2 _sequestration_potential,,, +-- enable,--,"{true, false}",Add option for regionally-resolved geological carbon dioxide sequestration potentials based on `CO2StoP `_. +-- attribute,--,string or list,Name (or list of names) of the attribute(s) for the sequestration potential +-- include_onshore,--,"{true, false}",Add options for including onshore sequestration potentials +-- min_size,Gt ,float,Any sites with lower potential than this value will be excluded +-- max_size,Gt ,float,The maximum sequestration potential for any one site. +-- years_of_storage,years,float,The years until potential exhausted at optimised annual rate +co2_sequestration_potential,MtCO2/a,float,The potential of sequestering CO2 in Europe per year +co2_sequestration_cost,currency/tCO2,float,The cost of sequestering a ton of CO2 +co2_sequestration_lifetime,years,int,The lifetime of a CO2 sequestration site +co2_spatial,--,"{true, false}","Add option to spatially resolve carrier representing stored carbon dioxide. This allows for more detailed modelling of CCUTS, e.g. regarding the capturing of industrial process emissions, usage as feedstock for electrofuels, transport of carbon dioxide, and geological sequestration sites." +,,, +co2network,--,"{true, false}",Add option for planning a new carbon dioxide transmission network +co2_network_cost_factor,p.u.,float,The cost factor for the capital cost of the carbon dioxide transmission network +,,, +cc_fraction,--,float,The default fraction of CO2 captured with post-combustion capture +hydrogen_underground _storage,--,"{true, false}",Add options for storing hydrogen underground. Storage potential depends regionally. +hydrogen_underground _storage_locations,,"{onshore, nearshore, offshore}","The location where hydrogen underground storage can be located. Onshore, nearshore, offshore means it must be located more than 50 km away from the sea, within 50 km of the sea, or within the sea itself respectively." +,,, +ammonia,--,"{true, false, regional}","Add ammonia as a carrrier. It can be either true (copperplated NH3), false (no NH3 carrier) or ""regional"" (regionalised NH3 without network)" +min_part_load_fischer _tropsch,per unit of p_nom ,float,The minimum unit dispatch (``p_min_pu``) for the Fischer-Tropsch process +min_part_load _methanolisation,per unit of p_nom ,float,The minimum unit dispatch (``p_min_pu``) for the methanolisation process +,,, +use_fischer_tropsch _waste_heat,--,"{true, false}",Add option for using waste heat of Fischer Tropsch in district heating networks +use_fuel_cell_waste_heat,--,"{true, false}",Add option for using waste heat of fuel cells in district heating networks +use_electrolysis_waste _heat,--,"{true, false}",Add option for using waste heat of electrolysis in district heating networks +electricity_transmission _grid,--,"{true, false}",Switch for enabling/disabling the electricity transmission grid. +electricity_distribution _grid,--,"{true, false}",Add a simplified representation of the exchange capacity between transmission and distribution grid level through a link. +electricity_distribution _grid_cost_factor,,,Multiplies the investment cost of the electricity distribution grid +,,, +electricity_grid _connection,--,"{true, false}",Add the cost of electricity grid connection for onshore wind and solar +transmission_efficiency,,,Section to specify transmission losses or compression energy demands of bidirectional links. Splits them into two capacity-linked unidirectional links. +-- {carrier},--,str,The carrier of the link. +-- -- efficiency_static,p.u.,float,Length-independent transmission efficiency. +-- -- efficiency_per_1000km,p.u. per 1000 km,float,Length-dependent transmission efficiency ($\eta^{\text{length}}$) +-- -- compression_per_1000km,p.u. per 1000 km,float,Length-dependent electricity demand for compression ($\eta \cdot \text{length}$) implemented as multi-link to local electricity bus. +H2_network,--,"{true, false}",Add option for new hydrogen pipelines +gas_network,--,"{true, false}","Add existing natural gas infrastructure, incl. LNG terminals, production and entry-points. The existing gas network is added with a lossless transport model. A length-weighted `k-edge augmentation algorithm `_ can be run to add new candidate gas pipelines such that all regions of the model can be connected to the gas network. When activated, all the gas demands are regionally disaggregated as well." +H2_retrofit,--,"{true, false}",Add option for retrofiting existing pipelines to transport hydrogen. +H2_retrofit_capacity _per_CH4,--,float,"The ratio for H2 capacity per original CH4 capacity of retrofitted pipelines. The `European Hydrogen Backbone (April, 2020) p.15 `_ 60% of original natural gas capacity could be used in cost-optimal case as H2 capacity." +gas_network_connectivity _upgrade ,--,float,The number of desired edge connectivity (k) in the length-weighted `k-edge augmentation algorithm `_ used for the gas network +gas_distribution_grid,--,"{true, false}",Add a gas distribution grid +gas_distribution_grid _cost_factor,,,Multiplier for the investment cost of the gas distribution grid +,,, +biomass_spatial,--,"{true, false}",Add option for resolving biomass demand regionally +biomass_transport,--,"{true, false}",Add option for transporting solid biomass between nodes +biogas_upgrading_cc,--,"{true, false}",Add option to capture CO2 from biomass upgrading +conventional_generation,,,Add a more detailed description of conventional carriers. Any power generation requires the consumption of fuel from nodes representing that fuel. +biomass_to_liquid,--,"{true, false}",Add option for transforming solid biomass into liquid fuel with the same properties as oil +biosng,--,"{true, false}",Add option for transforming solid biomass into synthesis gas with the same properties as natural gas +limit_max_growth,,, +-- enable,--,"{true, false}",Add option to limit the maximum growth of a carrier +-- factor,p.u.,float,The maximum growth factor of a carrier (e.g. 1.3 allows 30% larger than max historic growth) +-- max_growth,,, +-- -- {carrier},GW,float,The historic maximum growth of a carrier +-- max_relative_growth,,, +-- -- {carrier},p.u.,float,The historic maximum relative growth of a carrier +,,, +enhanced_geothermal,,, +-- enable,--,"{true, false}",Add option to include Enhanced Geothermal Systems +-- flexible,--,"{true, false}",Add option for flexible operation (see Ricks et al. 2024) +-- max_hours,--,int,The maximum hours the reservoir can be charged under flexible operation +-- max_boost,--,float,The maximum boost in power output under flexible operation +-- var_cf,--,"{true, false}",Add option for variable capacity factor (see Ricks et al. 2024) +-- sustainability_factor,--,float,Share of sourced heat that is replenished by the earth's core (see details in `build_egs_potentials.py `_) From 9a6505d889fac25483c70ccad3ec24d4eb66c474 Mon Sep 17 00:00:00 2001 From: lisazeyen Date: Thu, 1 Aug 2024 17:50:22 +0200 Subject: [PATCH 43/79] add release notes --- doc/release_notes.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/release_notes.rst b/doc/release_notes.rst index 383287a6..1908d739 100644 --- a/doc/release_notes.rst +++ b/doc/release_notes.rst @@ -10,6 +10,8 @@ Release Notes Upcoming Release ================ +* Add flag ``sector: fossil_fuels`` in config to remove the option of importing fossil fuels + * Renamed the carrier of batteries in BEVs from `battery storage` to `EV battery` and the corresponding bus carrier from `Li ion` to `EV battery`. This is to avoid confusion with stationary battery storage. * Changed default assumptions about waste heat usage from PtX and fuel cells in district heating. From de3f679f33a3af4e4d03f6dba851d74beb8e2123 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 1 Aug 2024 15:54:22 +0000 Subject: [PATCH 44/79] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- scripts/prepare_sector_network.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index cdd12866..520a2090 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -544,7 +544,7 @@ def add_carrier_buses(n, carrier, nodes=None): fossils = ["coal", "gas", "oil", "lignite"] if options.get("fossil_fuels", True) and carrier in fossils: - + n.madd( "Generator", nodes, From baa8a827f559b392b57adafbad59fe6cd2c7fb31 Mon Sep 17 00:00:00 2001 From: Fabian Neumann Date: Fri, 2 Aug 2024 11:42:30 +0200 Subject: [PATCH 45/79] change FRESNA references to PyPSA --- README.md | 4 ++-- doc/foresight.rst | 2 +- doc/preparation.rst | 2 +- scripts/build_powerplants.py | 8 ++++---- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index d5a72b77..5c918c9a 100644 --- a/README.md +++ b/README.md @@ -65,10 +65,10 @@ The dataset consists of: (alternating current lines at and above 220kV voltage level and all high voltage direct current lines) and 3803 substations. - The open power plant database - [powerplantmatching](https://github.com/FRESNA/powerplantmatching). + [powerplantmatching](https://github.com/PyPSA/powerplantmatching). - Electrical demand time series from the [OPSD project](https://open-power-system-data.org/). -- Renewable time series based on ERA5 and SARAH, assembled using the [atlite tool](https://github.com/FRESNA/atlite). +- Renewable time series based on ERA5 and SARAH, assembled using the [atlite tool](https://github.com/PyPSA/atlite). - Geographical potentials for wind and solar generators based on land use (CORINE) and excluding nature reserves (Natura2000) are computed with the [atlite library](https://github.com/PyPSA/atlite). A sector-coupled extension adds demand diff --git a/doc/foresight.rst b/doc/foresight.rst index 400f67ce..43a93ead 100644 --- a/doc/foresight.rst +++ b/doc/foresight.rst @@ -242,7 +242,7 @@ Rule overview file `__ generated by pypsa-eur which, in turn, is based on the `powerplantmatching - `__ database. + `__ database. Existing wind and solar capacities are retrieved from `IRENA annual statistics `__ and distributed among the diff --git a/doc/preparation.rst b/doc/preparation.rst index 669f3392..4585f4db 100644 --- a/doc/preparation.rst +++ b/doc/preparation.rst @@ -25,7 +25,7 @@ With these and the externally extracted ENTSO-E online map topology Then the process continues by calculating conventional power plant capacities, potentials, and per-unit availability time series for variable renewable energy carriers and hydro power plants with the following rules: -- :mod:`build_powerplants` for today's thermal power plant capacities using `powerplantmatching `__ allocating these to the closest substation for each powerplant, +- :mod:`build_powerplants` for today's thermal power plant capacities using `powerplantmatching `__ allocating these to the closest substation for each powerplant, - :mod:`build_ship_raster` for building shipping traffic density, - :mod:`build_renewable_profiles` for the hourly capacity factors and installation potentials constrained by land-use in each substation's Voronoi cell for PV, onshore and offshore wind, and - :mod:`build_hydro_profile` for the hourly per-unit hydro power availability time series. diff --git a/scripts/build_powerplants.py b/scripts/build_powerplants.py index 4e2bb88f..bde2bd38 100755 --- a/scripts/build_powerplants.py +++ b/scripts/build_powerplants.py @@ -6,7 +6,7 @@ # coding: utf-8 """ Retrieves conventional powerplant capacities and locations from -`powerplantmatching `_, assigns +`powerplantmatching `_, assigns these to buses and creates a ``.csv`` file. It is possible to amend the powerplant database with custom entries provided in ``data/custom_powerplants.csv``. @@ -30,17 +30,17 @@ Inputs ------ - ``networks/base.nc``: confer :ref:`base`. -- ``data/custom_powerplants.csv``: custom powerplants in the same format as `powerplantmatching `_ provides +- ``data/custom_powerplants.csv``: custom powerplants in the same format as `powerplantmatching `_ provides Outputs ------- -- ``resource/powerplants.csv``: A list of conventional power plants (i.e. neither wind nor solar) with fields for name, fuel type, technology, country, capacity in MW, duration, commissioning year, retrofit year, latitude, longitude, and dam information as documented in the `powerplantmatching README `_; additionally it includes information on the closest substation/bus in ``networks/base.nc``. +- ``resource/powerplants.csv``: A list of conventional power plants (i.e. neither wind nor solar) with fields for name, fuel type, technology, country, capacity in MW, duration, commissioning year, retrofit year, latitude, longitude, and dam information as documented in the `powerplantmatching README `_; additionally it includes information on the closest substation/bus in ``networks/base.nc``. .. image:: img/powerplantmatching.png :scale: 30 % - **Source:** `powerplantmatching on GitHub `_ + **Source:** `powerplantmatching on GitHub `_ Description ----------- From 8bfca9ce696d930b823e4df784c665b8cab23aff Mon Sep 17 00:00:00 2001 From: lisazeyen Date: Fri, 2 Aug 2024 14:05:42 +0200 Subject: [PATCH 46/79] enable electrobiofuels also without biomass spatially resolved --- scripts/prepare_sector_network.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index 7ecdb836..81acb418 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -200,7 +200,7 @@ def define_spatial(nodes, options): spatial.geothermal_heat = SimpleNamespace() spatial.geothermal_heat.nodes = ["EU enhanced geothermal systems"] spatial.geothermal_heat.locations = ["EU"] - + return spatial @@ -2514,13 +2514,14 @@ def add_biomass(n, costs): # Electrobiofuels (BtL with hydrogen addition to make more use of biogenic carbon). # Combination of efuels and biomass to liquid, both based on Fischer-Tropsch. # Experimental version - use with caution - if options["electrobiofuels"] and options.get( - "biomass_spatial", options["biomass_transport"] - ): + if options["electrobiofuels"]: + efuel_scale_factor = costs.at["BtL", "C stored"] + name = (pd.Index(spatial.biomass.nodes) + " " + + pd.Index(spatial.h2.nodes.str.replace(" H2", ""))) n.madd( "Link", - spatial.biomass.nodes, + name, suffix=" electrobiofuels", bus0=spatial.biomass.nodes, bus1=spatial.oil.nodes, From c7a186863e6ca2ed336cc0fc19bf194914910a1b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 2 Aug 2024 12:07:16 +0000 Subject: [PATCH 47/79] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- scripts/prepare_sector_network.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index 81acb418..37d1299c 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -200,7 +200,7 @@ def define_spatial(nodes, options): spatial.geothermal_heat = SimpleNamespace() spatial.geothermal_heat.nodes = ["EU enhanced geothermal systems"] spatial.geothermal_heat.locations = ["EU"] - + return spatial @@ -2517,8 +2517,11 @@ def add_biomass(n, costs): if options["electrobiofuels"]: efuel_scale_factor = costs.at["BtL", "C stored"] - name = (pd.Index(spatial.biomass.nodes) + " " - + pd.Index(spatial.h2.nodes.str.replace(" H2", ""))) + name = ( + pd.Index(spatial.biomass.nodes) + + " " + + pd.Index(spatial.h2.nodes.str.replace(" H2", "")) + ) n.madd( "Link", name, From 9c35a6716cf7763ed3a5f387ed414e39d86c5050 Mon Sep 17 00:00:00 2001 From: lisazeyen Date: Fri, 2 Aug 2024 14:11:26 +0200 Subject: [PATCH 48/79] add documentation for new config option --- doc/configtables/sector.csv | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/configtables/sector.csv b/doc/configtables/sector.csv index 89c0e55c..f6e52116 100644 --- a/doc/configtables/sector.csv +++ b/doc/configtables/sector.csv @@ -138,6 +138,7 @@ biomass_transport,--,"{true, false}",Add option for transporting solid biomass b biogas_upgrading_cc,--,"{true, false}",Add option to capture CO2 from biomass upgrading conventional_generation,,,Add a more detailed description of conventional carriers. Any power generation requires the consumption of fuel from nodes representing that fuel. biomass_to_liquid,--,"{true, false}",Add option for transforming solid biomass into liquid fuel with the same properties as oil +electrobiofuels,--,"{true, false}","Add option for transforming solid biomass and hydrogen into liquid fuel to make more use of biogenic carbon, as a combination of BtL and Fischer-Tropsch" biosng,--,"{true, false}",Add option for transforming solid biomass into synthesis gas with the same properties as natural gas limit_max_growth,,, -- enable,--,"{true, false}",Add option to limit the maximum growth of a carrier From 39c502f29a9b82b073c2b9f5d65bd36837c793cc Mon Sep 17 00:00:00 2001 From: lisazeyen Date: Fri, 2 Aug 2024 14:13:21 +0200 Subject: [PATCH 49/79] add release note --- doc/release_notes.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/release_notes.rst b/doc/release_notes.rst index 1908d739..4293541b 100644 --- a/doc/release_notes.rst +++ b/doc/release_notes.rst @@ -10,6 +10,8 @@ Release Notes Upcoming Release ================ +* Add option to produce electrobiofuels from solid biomass and hydrogen, as a combination of BtL and Fischer-Tropsch to make more use of the biogenic carbon + * Add flag ``sector: fossil_fuels`` in config to remove the option of importing fossil fuels * Renamed the carrier of batteries in BEVs from `battery storage` to `EV battery` and the corresponding bus carrier from `Li ion` to `EV battery`. This is to avoid confusion with stationary battery storage. From eb81cfb7148e7603eda54ebd90017687bd4d2fdb Mon Sep 17 00:00:00 2001 From: lisazeyen Date: Fri, 2 Aug 2024 15:13:47 +0200 Subject: [PATCH 50/79] change units from EJ->TWh and clean up --- config/config.default.yaml | 2 +- scripts/prepare_sector_network.py | 29 +++++++++++------------------ 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/config/config.default.yaml b/config/config.default.yaml index a618ed95..f549752f 100644 --- a/config/config.default.yaml +++ b/config/config.default.yaml @@ -631,7 +631,7 @@ sector: solid_biomass_import: enable: false price: 54 #EUR/MWh - max_amount: 5 #EJ + max_amount: 1390 # TWh upstream_emissions_factor: .1 #share of solid biomass CO2 emissions at full combustion # docs in https://pypsa-eur.readthedocs.io/en/latest/configuration.html#industry diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index d7ca791c..53af5858 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -2287,24 +2287,17 @@ def add_biomass(n, costs): if options["solid_biomass_import"].get("enable", False): biomass_import_price = options["solid_biomass_import"]["price"] - biomass_import_max_amount = round( - options["solid_biomass_import"]["max_amount"] * 1e9 / 3.6, 0 - ) # EJ --> MWh - biomass_import_upstream_emissions = round( - options["solid_biomass_import"]["upstream_emissions_factor"] - * costs.at["solid biomass", "CO2 intensity"], - 4, - ) - - print( - "Adding biomass import with cost", - biomass_import_price, - "EUR/MWh, a limit of", - options["solid_biomass_import"]["max_amount"], - "EJ, and embedded emissions of", - options["solid_biomass_import"]["upstream_emissions_factor"] * 100, - "%", + # convert TWh in MWh + biomass_import_max_amount = options["solid_biomass_import"]["max_amount"] * 1e6 + biomass_import_upstream_emissions = options["solid_biomass_import"]["upstream_emissions_factor"] + + logger.info( + "Adding biomass import with cost %.2f EUR/MWh, a limit of %.2f TWh, and embedded emissions of %.2f%%", + biomass_import_price, + options["solid_biomass_import"]["max_amount"], + biomass_import_upstream_emissions * 100 ) + n.add("Carrier", "solid biomass import") @@ -2334,7 +2327,7 @@ def add_biomass(n, costs): bus2="co2 atmosphere", carrier="solid biomass import", efficiency=1.0, - efficiency2=biomass_import_upstream_emissions, + efficiency2=biomass_import_upstream_emissions* costs.at["solid biomass", "CO2 intensity"], p_nom_extendable=True, ) From 4d9ba02e187aeae5d06db742ebbadce3dbe03987 Mon Sep 17 00:00:00 2001 From: lisazeyen Date: Fri, 2 Aug 2024 15:22:39 +0200 Subject: [PATCH 51/79] add doc for new config --- doc/configtables/sector.csv | 315 ++++++++++++++++++------------------ 1 file changed, 160 insertions(+), 155 deletions(-) diff --git a/doc/configtables/sector.csv b/doc/configtables/sector.csv index 059c4233..21d56422 100644 --- a/doc/configtables/sector.csv +++ b/doc/configtables/sector.csv @@ -1,155 +1,160 @@ -,Unit,Values,Description -transport,--,"{true, false}",Flag to include transport sector. -heating,--,"{true, false}",Flag to include heating sector. -biomass,--,"{true, false}",Flag to include biomass sector. -industry,--,"{true, false}",Flag to include industry sector. -agriculture,--,"{true, false}",Flag to include agriculture sector. -district_heating,--,,`prepare_sector_network.py `_ --- potential,--,float,maximum fraction of urban demand which can be supplied by district heating --- progress,--,Dictionary with planning horizons as keys., Increase of today's district heating demand to potential maximum district heating share. Progress = 0 means today's district heating share. Progress = 1 means maximum fraction of urban demand is supplied by district heating --- district_heating_loss,--,float,Share increase in district heat demand in urban central due to heat losses -cluster_heat_buses,--,"{true, false}",Cluster residential and service heat buses in `prepare_sector_network.py `_ to one to save memory. -,,, -bev_dsm_restriction _value,--,float,Adds a lower state of charge (SOC) limit for battery electric vehicles (BEV) to manage its own energy demand (DSM). Located in `build_transport_demand.py `_. Set to 0 for no restriction on BEV DSM -bev_dsm_restriction _time,--,float,Time at which SOC of BEV has to be dsm_restriction_value -transport_heating _deadband_upper,°C,float,"The maximum temperature in the vehicle. At higher temperatures, the energy required for cooling in the vehicle increases." -transport_heating _deadband_lower,°C,float,"The minimum temperature in the vehicle. At lower temperatures, the energy required for heating in the vehicle increases." -,,, -ICE_lower_degree_factor,--,float,Share increase in energy demand in internal combustion engine (ICE) for each degree difference between the cold environment and the minimum temperature. -ICE_upper_degree_factor,--,float,Share increase in energy demand in internal combustion engine (ICE) for each degree difference between the hot environment and the maximum temperature. -EV_lower_degree_factor,--,float,Share increase in energy demand in electric vehicles (EV) for each degree difference between the cold environment and the minimum temperature. -EV_upper_degree_factor,--,float,Share increase in energy demand in electric vehicles (EV) for each degree difference between the hot environment and the maximum temperature. -bev_dsm,--,"{true, false}",Add the option for battery electric vehicles (BEV) to participate in demand-side management (DSM) -,,, -bev_availability,--,float,The share for battery electric vehicles (BEV) that are able to do demand side management (DSM) -bev_energy,--,float,The average size of battery electric vehicles (BEV) in MWh -bev_charge_efficiency,--,float,Battery electric vehicles (BEV) charge and discharge efficiency -bev_charge_rate,MWh,float,The power consumption for one electric vehicle (EV) in MWh. Value derived from 3-phase charger with 11 kW. -bev_avail_max,--,float,The maximum share plugged-in availability for passenger electric vehicles. -bev_avail_mean,--,float,The average share plugged-in availability for passenger electric vehicles. -v2g,--,"{true, false}",Allows feed-in to grid from EV battery -land_transport_fuel_cell _share,--,Dictionary with planning horizons as keys.,The share of vehicles that uses fuel cells in a given year -land_transport_electric _share,--,Dictionary with planning horizons as keys.,The share of vehicles that uses electric vehicles (EV) in a given year -land_transport_ice _share,--,Dictionary with planning horizons as keys.,The share of vehicles that uses internal combustion engines (ICE) in a given year. What is not EV or FCEV is oil-fuelled ICE. -transport_electric_efficiency,MWh/100km,float,The conversion efficiencies of electric vehicles in transport -transport_fuel_cell_efficiency,MWh/100km,float,The H2 conversion efficiencies of fuel cells in transport -transport_ice_efficiency,MWh/100km,float,The oil conversion efficiencies of internal combustion engine (ICE) in transport -agriculture_machinery _electric_share,--,float,The share for agricultural machinery that uses electricity -agriculture_machinery _oil_share,--,float,The share for agricultural machinery that uses oil -agriculture_machinery _fuel_efficiency,--,float,The efficiency of electric-powered machinery in the conversion of electricity to meet agricultural needs. -agriculture_machinery _electric_efficiency,--,float,The efficiency of oil-powered machinery in the conversion of oil to meet agricultural needs. -Mwh_MeOH_per_MWh_H2,LHV,float,"The energy amount of the produced methanol per energy amount of hydrogen. From `DECHEMA (2017) `_, page 64." -MWh_MeOH_per_tCO2,LHV,float,"The energy amount of the produced methanol per ton of CO2. From `DECHEMA (2017) `_, page 66." -MWh_MeOH_per_MWh_e,LHV,float,"The energy amount of the produced methanol per energy amount of electricity. From `DECHEMA (2017) `_, page 64." -shipping_hydrogen _liquefaction,--,"{true, false}",Whether to include liquefaction costs for hydrogen demand in shipping. -,,, -shipping_hydrogen_share,--,Dictionary with planning horizons as keys.,The share of ships powered by hydrogen in a given year -shipping_methanol_share,--,Dictionary with planning horizons as keys.,The share of ships powered by methanol in a given year -shipping_oil_share,--,Dictionary with planning horizons as keys.,The share of ships powered by oil in a given year -shipping_methanol _efficiency,--,float,The efficiency of methanol-powered ships in the conversion of methanol to meet shipping needs (propulsion). The efficiency increase from oil can be 10-15% higher according to the `IEA `_ -,,, -shipping_oil_efficiency,--,float,The efficiency of oil-powered ships in the conversion of oil to meet shipping needs (propulsion). Base value derived from 2011 -aviation_demand_factor,--,float,The proportion of demand for aviation compared to today's consumption -HVC_demand_factor,--,float,The proportion of demand for high-value chemicals compared to today's consumption -,,, -time_dep_hp_cop,--,"{true, false}",Consider the time dependent coefficient of performance (COP) of the heat pump -heat_pump_sink_T,°C,float,The temperature heat sink used in heat pumps based on DTU / large area radiators. The value is conservatively high to cover hot water and space heating in poorly-insulated buildings -reduce_space_heat _exogenously,--,"{true, false}",Influence on space heating demand by a certain factor (applied before losses in district heating). -reduce_space_heat _exogenously_factor,--,Dictionary with planning horizons as keys.,"A positive factor can mean renovation or demolition of a building. If the factor is negative, it can mean an increase in floor area, increased thermal comfort, population growth. The default factors are determined by the `Eurocalc Homes and buildings decarbonization scenario `_" -retrofitting,,, --- retro_endogen,--,"{true, false}",Add retrofitting as an endogenous system which co-optimise space heat savings. --- cost_factor,--,float,Weight costs for building renovation --- interest_rate,--,float,The interest rate for investment in building components --- annualise_cost,--,"{true, false}",Annualise the investment costs of retrofitting --- tax_weighting,--,"{true, false}",Weight the costs of retrofitting depending on taxes in countries --- construction_index,--,"{true, false}",Weight the costs of retrofitting depending on labour/material costs per country -tes,--,"{true, false}",Add option for storing thermal energy in large water pits associated with district heating systems and individual thermal energy storage (TES) -tes_tau,,,The time constant used to calculate the decay of thermal energy in thermal energy storage (TES): 1- :math:`e^{-1/24τ}`. --- decentral,days,float,The time constant in decentralized thermal energy storage (TES) --- central,days,float,The time constant in centralized thermal energy storage (TES) -boilers,--,"{true, false}",Add option for transforming gas into heat using gas boilers -resistive_heaters,--,"{true, false}",Add option for transforming electricity into heat using resistive heaters (independently from gas boilers) -oil_boilers,--,"{true, false}",Add option for transforming oil into heat using boilers -biomass_boiler,--,"{true, false}",Add option for transforming biomass into heat using boilers -overdimension_individual_heating,--,"float",Add option for overdimensioning individual heating systems by a certain factor. This allows them to cover heat demand peaks e.g. 10% higher than those in the data with a setting of 1.1. -chp,--,"{true, false}",Add option for using Combined Heat and Power (CHP) -micro_chp,--,"{true, false}",Add option for using Combined Heat and Power (CHP) for decentral areas. -solar_thermal,--,"{true, false}",Add option for using solar thermal to generate heat. -solar_cf_correction,--,float,The correction factor for the value provided by the solar thermal profile calculations -marginal_cost_storage,currency/MWh ,float,The marginal cost of discharging batteries in distributed grids -methanation,--,"{true, false}",Add option for transforming hydrogen and CO2 into methane using methanation. -coal_cc,--,"{true, false}",Add option for coal CHPs with carbon capture -dac,--,"{true, false}",Add option for Direct Air Capture (DAC) -co2_vent,--,"{true, false}",Add option for vent out CO2 from storages to the atmosphere. -allam_cycle,--,"{true, false}",Add option to include `Allam cycle gas power plants `_ -hydrogen_fuel_cell,--,"{true, false}",Add option to include hydrogen fuel cell for re-electrification. Assuming OCGT technology costs -hydrogen_turbine,--,"{true, false}",Add option to include hydrogen turbine for re-electrification. Assuming OCGT technology costs -SMR,--,"{true, false}",Add option for transforming natural gas into hydrogen and CO2 using Steam Methane Reforming (SMR) -SMR CC,--,"{true, false}",Add option for transforming natural gas into hydrogen and CO2 using Steam Methane Reforming (SMR) and Carbon Capture (CC) -regional_methanol_demand,--,"{true, false}",Spatially resolve methanol demand. Set to true if regional CO2 constraints needed. -regional_oil_demand,--,"{true, false}",Spatially resolve oil demand. Set to true if regional CO2 constraints needed. -regional_co2 _sequestration_potential,,, --- enable,--,"{true, false}",Add option for regionally-resolved geological carbon dioxide sequestration potentials based on `CO2StoP `_. --- attribute,--,string or list,Name (or list of names) of the attribute(s) for the sequestration potential --- include_onshore,--,"{true, false}",Add options for including onshore sequestration potentials --- min_size,Gt ,float,Any sites with lower potential than this value will be excluded --- max_size,Gt ,float,The maximum sequestration potential for any one site. --- years_of_storage,years,float,The years until potential exhausted at optimised annual rate -co2_sequestration_potential,MtCO2/a,float,The potential of sequestering CO2 in Europe per year -co2_sequestration_cost,currency/tCO2,float,The cost of sequestering a ton of CO2 -co2_sequestration_lifetime,years,int,The lifetime of a CO2 sequestration site -co2_spatial,--,"{true, false}","Add option to spatially resolve carrier representing stored carbon dioxide. This allows for more detailed modelling of CCUTS, e.g. regarding the capturing of industrial process emissions, usage as feedstock for electrofuels, transport of carbon dioxide, and geological sequestration sites." -,,, -co2network,--,"{true, false}",Add option for planning a new carbon dioxide transmission network -co2_network_cost_factor,p.u.,float,The cost factor for the capital cost of the carbon dioxide transmission network -,,, -cc_fraction,--,float,The default fraction of CO2 captured with post-combustion capture -hydrogen_underground _storage,--,"{true, false}",Add options for storing hydrogen underground. Storage potential depends regionally. -hydrogen_underground _storage_locations,,"{onshore, nearshore, offshore}","The location where hydrogen underground storage can be located. Onshore, nearshore, offshore means it must be located more than 50 km away from the sea, within 50 km of the sea, or within the sea itself respectively." -,,, -ammonia,--,"{true, false, regional}","Add ammonia as a carrrier. It can be either true (copperplated NH3), false (no NH3 carrier) or ""regional"" (regionalised NH3 without network)" -min_part_load_fischer _tropsch,per unit of p_nom ,float,The minimum unit dispatch (``p_min_pu``) for the Fischer-Tropsch process -min_part_load _methanolisation,per unit of p_nom ,float,The minimum unit dispatch (``p_min_pu``) for the methanolisation process -,,, -use_fischer_tropsch _waste_heat,--,"{true, false}",Add option for using waste heat of Fischer Tropsch in district heating networks -use_fuel_cell_waste_heat,--,"{true, false}",Add option for using waste heat of fuel cells in district heating networks -use_electrolysis_waste _heat,--,"{true, false}",Add option for using waste heat of electrolysis in district heating networks -electricity_transmission _grid,--,"{true, false}",Switch for enabling/disabling the electricity transmission grid. -electricity_distribution _grid,--,"{true, false}",Add a simplified representation of the exchange capacity between transmission and distribution grid level through a link. -electricity_distribution _grid_cost_factor,,,Multiplies the investment cost of the electricity distribution grid -,,, -electricity_grid _connection,--,"{true, false}",Add the cost of electricity grid connection for onshore wind and solar -transmission_efficiency,,,Section to specify transmission losses or compression energy demands of bidirectional links. Splits them into two capacity-linked unidirectional links. --- {carrier},--,str,The carrier of the link. --- -- efficiency_static,p.u.,float,Length-independent transmission efficiency. --- -- efficiency_per_1000km,p.u. per 1000 km,float,Length-dependent transmission efficiency ($\eta^{\text{length}}$) --- -- compression_per_1000km,p.u. per 1000 km,float,Length-dependent electricity demand for compression ($\eta \cdot \text{length}$) implemented as multi-link to local electricity bus. -H2_network,--,"{true, false}",Add option for new hydrogen pipelines -gas_network,--,"{true, false}","Add existing natural gas infrastructure, incl. LNG terminals, production and entry-points. The existing gas network is added with a lossless transport model. A length-weighted `k-edge augmentation algorithm `_ can be run to add new candidate gas pipelines such that all regions of the model can be connected to the gas network. When activated, all the gas demands are regionally disaggregated as well." -H2_retrofit,--,"{true, false}",Add option for retrofiting existing pipelines to transport hydrogen. -H2_retrofit_capacity _per_CH4,--,float,"The ratio for H2 capacity per original CH4 capacity of retrofitted pipelines. The `European Hydrogen Backbone (April, 2020) p.15 `_ 60% of original natural gas capacity could be used in cost-optimal case as H2 capacity." -gas_network_connectivity _upgrade ,--,float,The number of desired edge connectivity (k) in the length-weighted `k-edge augmentation algorithm `_ used for the gas network -gas_distribution_grid,--,"{true, false}",Add a gas distribution grid -gas_distribution_grid _cost_factor,,,Multiplier for the investment cost of the gas distribution grid -,,, -biomass_spatial,--,"{true, false}",Add option for resolving biomass demand regionally -biomass_transport,--,"{true, false}",Add option for transporting solid biomass between nodes -biogas_upgrading_cc,--,"{true, false}",Add option to capture CO2 from biomass upgrading -conventional_generation,,,Add a more detailed description of conventional carriers. Any power generation requires the consumption of fuel from nodes representing that fuel. -biomass_to_liquid,--,"{true, false}",Add option for transforming solid biomass into liquid fuel with the same properties as oil -biosng,--,"{true, false}",Add option for transforming solid biomass into synthesis gas with the same properties as natural gas -limit_max_growth,,, --- enable,--,"{true, false}",Add option to limit the maximum growth of a carrier --- factor,p.u.,float,The maximum growth factor of a carrier (e.g. 1.3 allows 30% larger than max historic growth) --- max_growth,,, --- -- {carrier},GW,float,The historic maximum growth of a carrier --- max_relative_growth,,, --- -- {carrier},p.u.,float,The historic maximum relative growth of a carrier -,,, -enhanced_geothermal,,, --- enable,--,"{true, false}",Add option to include Enhanced Geothermal Systems --- flexible,--,"{true, false}",Add option for flexible operation (see Ricks et al. 2024) --- max_hours,--,int,The maximum hours the reservoir can be charged under flexible operation --- max_boost,--,float,The maximum boost in power output under flexible operation --- var_cf,--,"{true, false}",Add option for variable capacity factor (see Ricks et al. 2024) --- sustainability_factor,--,float,Share of sourced heat that is replenished by the earth's core (see details in `build_egs_potentials.py `_) +,Unit,Values,Description +transport,--,"{true, false}",Flag to include transport sector. +heating,--,"{true, false}",Flag to include heating sector. +biomass,--,"{true, false}",Flag to include biomass sector. +industry,--,"{true, false}",Flag to include industry sector. +agriculture,--,"{true, false}",Flag to include agriculture sector. +district_heating,--,,`prepare_sector_network.py `_ +-- potential,--,float,maximum fraction of urban demand which can be supplied by district heating +-- progress,--,Dictionary with planning horizons as keys., Increase of today's district heating demand to potential maximum district heating share. Progress = 0 means today's district heating share. Progress = 1 means maximum fraction of urban demand is supplied by district heating +-- district_heating_loss,--,float,Share increase in district heat demand in urban central due to heat losses +cluster_heat_buses,--,"{true, false}",Cluster residential and service heat buses in `prepare_sector_network.py `_ to one to save memory. +,,, +bev_dsm_restriction _value,--,float,Adds a lower state of charge (SOC) limit for battery electric vehicles (BEV) to manage its own energy demand (DSM). Located in `build_transport_demand.py `_. Set to 0 for no restriction on BEV DSM +bev_dsm_restriction _time,--,float,Time at which SOC of BEV has to be dsm_restriction_value +transport_heating _deadband_upper,°C,float,"The maximum temperature in the vehicle. At higher temperatures, the energy required for cooling in the vehicle increases." +transport_heating _deadband_lower,°C,float,"The minimum temperature in the vehicle. At lower temperatures, the energy required for heating in the vehicle increases." +,,, +ICE_lower_degree_factor,--,float,Share increase in energy demand in internal combustion engine (ICE) for each degree difference between the cold environment and the minimum temperature. +ICE_upper_degree_factor,--,float,Share increase in energy demand in internal combustion engine (ICE) for each degree difference between the hot environment and the maximum temperature. +EV_lower_degree_factor,--,float,Share increase in energy demand in electric vehicles (EV) for each degree difference between the cold environment and the minimum temperature. +EV_upper_degree_factor,--,float,Share increase in energy demand in electric vehicles (EV) for each degree difference between the hot environment and the maximum temperature. +bev_dsm,--,"{true, false}",Add the option for battery electric vehicles (BEV) to participate in demand-side management (DSM) +,,, +bev_availability,--,float,The share for battery electric vehicles (BEV) that are able to do demand side management (DSM) +bev_energy,--,float,The average size of battery electric vehicles (BEV) in MWh +bev_charge_efficiency,--,float,Battery electric vehicles (BEV) charge and discharge efficiency +bev_charge_rate,MWh,float,The power consumption for one electric vehicle (EV) in MWh. Value derived from 3-phase charger with 11 kW. +bev_avail_max,--,float,The maximum share plugged-in availability for passenger electric vehicles. +bev_avail_mean,--,float,The average share plugged-in availability for passenger electric vehicles. +v2g,--,"{true, false}",Allows feed-in to grid from EV battery +land_transport_fuel_cell _share,--,Dictionary with planning horizons as keys.,The share of vehicles that uses fuel cells in a given year +land_transport_electric _share,--,Dictionary with planning horizons as keys.,The share of vehicles that uses electric vehicles (EV) in a given year +land_transport_ice _share,--,Dictionary with planning horizons as keys.,The share of vehicles that uses internal combustion engines (ICE) in a given year. What is not EV or FCEV is oil-fuelled ICE. +transport_electric_efficiency,MWh/100km,float,The conversion efficiencies of electric vehicles in transport +transport_fuel_cell_efficiency,MWh/100km,float,The H2 conversion efficiencies of fuel cells in transport +transport_ice_efficiency,MWh/100km,float,The oil conversion efficiencies of internal combustion engine (ICE) in transport +agriculture_machinery _electric_share,--,float,The share for agricultural machinery that uses electricity +agriculture_machinery _oil_share,--,float,The share for agricultural machinery that uses oil +agriculture_machinery _fuel_efficiency,--,float,The efficiency of electric-powered machinery in the conversion of electricity to meet agricultural needs. +agriculture_machinery _electric_efficiency,--,float,The efficiency of oil-powered machinery in the conversion of oil to meet agricultural needs. +Mwh_MeOH_per_MWh_H2,LHV,float,"The energy amount of the produced methanol per energy amount of hydrogen. From `DECHEMA (2017) `_, page 64." +MWh_MeOH_per_tCO2,LHV,float,"The energy amount of the produced methanol per ton of CO2. From `DECHEMA (2017) `_, page 66." +MWh_MeOH_per_MWh_e,LHV,float,"The energy amount of the produced methanol per energy amount of electricity. From `DECHEMA (2017) `_, page 64." +shipping_hydrogen _liquefaction,--,"{true, false}",Whether to include liquefaction costs for hydrogen demand in shipping. +,,, +shipping_hydrogen_share,--,Dictionary with planning horizons as keys.,The share of ships powered by hydrogen in a given year +shipping_methanol_share,--,Dictionary with planning horizons as keys.,The share of ships powered by methanol in a given year +shipping_oil_share,--,Dictionary with planning horizons as keys.,The share of ships powered by oil in a given year +shipping_methanol _efficiency,--,float,The efficiency of methanol-powered ships in the conversion of methanol to meet shipping needs (propulsion). The efficiency increase from oil can be 10-15% higher according to the `IEA `_ +,,, +shipping_oil_efficiency,--,float,The efficiency of oil-powered ships in the conversion of oil to meet shipping needs (propulsion). Base value derived from 2011 +aviation_demand_factor,--,float,The proportion of demand for aviation compared to today's consumption +HVC_demand_factor,--,float,The proportion of demand for high-value chemicals compared to today's consumption +,,, +time_dep_hp_cop,--,"{true, false}",Consider the time dependent coefficient of performance (COP) of the heat pump +heat_pump_sink_T,°C,float,The temperature heat sink used in heat pumps based on DTU / large area radiators. The value is conservatively high to cover hot water and space heating in poorly-insulated buildings +reduce_space_heat _exogenously,--,"{true, false}",Influence on space heating demand by a certain factor (applied before losses in district heating). +reduce_space_heat _exogenously_factor,--,Dictionary with planning horizons as keys.,"A positive factor can mean renovation or demolition of a building. If the factor is negative, it can mean an increase in floor area, increased thermal comfort, population growth. The default factors are determined by the `Eurocalc Homes and buildings decarbonization scenario `_" +retrofitting,,, +-- retro_endogen,--,"{true, false}",Add retrofitting as an endogenous system which co-optimise space heat savings. +-- cost_factor,--,float,Weight costs for building renovation +-- interest_rate,--,float,The interest rate for investment in building components +-- annualise_cost,--,"{true, false}",Annualise the investment costs of retrofitting +-- tax_weighting,--,"{true, false}",Weight the costs of retrofitting depending on taxes in countries +-- construction_index,--,"{true, false}",Weight the costs of retrofitting depending on labour/material costs per country +tes,--,"{true, false}",Add option for storing thermal energy in large water pits associated with district heating systems and individual thermal energy storage (TES) +tes_tau,,,The time constant used to calculate the decay of thermal energy in thermal energy storage (TES): 1- :math:`e^{-1/24τ}`. +-- decentral,days,float,The time constant in decentralized thermal energy storage (TES) +-- central,days,float,The time constant in centralized thermal energy storage (TES) +boilers,--,"{true, false}",Add option for transforming gas into heat using gas boilers +resistive_heaters,--,"{true, false}",Add option for transforming electricity into heat using resistive heaters (independently from gas boilers) +oil_boilers,--,"{true, false}",Add option for transforming oil into heat using boilers +biomass_boiler,--,"{true, false}",Add option for transforming biomass into heat using boilers +overdimension_individual_heating,--,float,Add option for overdimensioning individual heating systems by a certain factor. This allows them to cover heat demand peaks e.g. 10% higher than those in the data with a setting of 1.1. +chp,--,"{true, false}",Add option for using Combined Heat and Power (CHP) +micro_chp,--,"{true, false}",Add option for using Combined Heat and Power (CHP) for decentral areas. +solar_thermal,--,"{true, false}",Add option for using solar thermal to generate heat. +solar_cf_correction,--,float,The correction factor for the value provided by the solar thermal profile calculations +marginal_cost_storage,currency/MWh ,float,The marginal cost of discharging batteries in distributed grids +methanation,--,"{true, false}",Add option for transforming hydrogen and CO2 into methane using methanation. +coal_cc,--,"{true, false}",Add option for coal CHPs with carbon capture +dac,--,"{true, false}",Add option for Direct Air Capture (DAC) +co2_vent,--,"{true, false}",Add option for vent out CO2 from storages to the atmosphere. +allam_cycle,--,"{true, false}",Add option to include `Allam cycle gas power plants `_ +hydrogen_fuel_cell,--,"{true, false}",Add option to include hydrogen fuel cell for re-electrification. Assuming OCGT technology costs +hydrogen_turbine,--,"{true, false}",Add option to include hydrogen turbine for re-electrification. Assuming OCGT technology costs +SMR,--,"{true, false}",Add option for transforming natural gas into hydrogen and CO2 using Steam Methane Reforming (SMR) +SMR CC,--,"{true, false}",Add option for transforming natural gas into hydrogen and CO2 using Steam Methane Reforming (SMR) and Carbon Capture (CC) +regional_methanol_demand,--,"{true, false}",Spatially resolve methanol demand. Set to true if regional CO2 constraints needed. +regional_oil_demand,--,"{true, false}",Spatially resolve oil demand. Set to true if regional CO2 constraints needed. +regional_co2 _sequestration_potential,,, +-- enable,--,"{true, false}",Add option for regionally-resolved geological carbon dioxide sequestration potentials based on `CO2StoP `_. +-- attribute,--,string or list,Name (or list of names) of the attribute(s) for the sequestration potential +-- include_onshore,--,"{true, false}",Add options for including onshore sequestration potentials +-- min_size,Gt ,float,Any sites with lower potential than this value will be excluded +-- max_size,Gt ,float,The maximum sequestration potential for any one site. +-- years_of_storage,years,float,The years until potential exhausted at optimised annual rate +co2_sequestration_potential,MtCO2/a,float,The potential of sequestering CO2 in Europe per year +co2_sequestration_cost,currency/tCO2,float,The cost of sequestering a ton of CO2 +co2_sequestration_lifetime,years,int,The lifetime of a CO2 sequestration site +co2_spatial,--,"{true, false}","Add option to spatially resolve carrier representing stored carbon dioxide. This allows for more detailed modelling of CCUTS, e.g. regarding the capturing of industrial process emissions, usage as feedstock for electrofuels, transport of carbon dioxide, and geological sequestration sites." +,,, +co2network,--,"{true, false}",Add option for planning a new carbon dioxide transmission network +co2_network_cost_factor,p.u.,float,The cost factor for the capital cost of the carbon dioxide transmission network +,,, +cc_fraction,--,float,The default fraction of CO2 captured with post-combustion capture +hydrogen_underground _storage,--,"{true, false}",Add options for storing hydrogen underground. Storage potential depends regionally. +hydrogen_underground _storage_locations,,"{onshore, nearshore, offshore}","The location where hydrogen underground storage can be located. Onshore, nearshore, offshore means it must be located more than 50 km away from the sea, within 50 km of the sea, or within the sea itself respectively." +,,, +ammonia,--,"{true, false, regional}","Add ammonia as a carrrier. It can be either true (copperplated NH3), false (no NH3 carrier) or ""regional"" (regionalised NH3 without network)" +min_part_load_fischer _tropsch,per unit of p_nom ,float,The minimum unit dispatch (``p_min_pu``) for the Fischer-Tropsch process +min_part_load _methanolisation,per unit of p_nom ,float,The minimum unit dispatch (``p_min_pu``) for the methanolisation process +,,, +use_fischer_tropsch _waste_heat,--,"{true, false}",Add option for using waste heat of Fischer Tropsch in district heating networks +use_fuel_cell_waste_heat,--,"{true, false}",Add option for using waste heat of fuel cells in district heating networks +use_electrolysis_waste _heat,--,"{true, false}",Add option for using waste heat of electrolysis in district heating networks +electricity_transmission _grid,--,"{true, false}",Switch for enabling/disabling the electricity transmission grid. +electricity_distribution _grid,--,"{true, false}",Add a simplified representation of the exchange capacity between transmission and distribution grid level through a link. +electricity_distribution _grid_cost_factor,,,Multiplies the investment cost of the electricity distribution grid +,,, +electricity_grid _connection,--,"{true, false}",Add the cost of electricity grid connection for onshore wind and solar +transmission_efficiency,,,Section to specify transmission losses or compression energy demands of bidirectional links. Splits them into two capacity-linked unidirectional links. +-- {carrier},--,str,The carrier of the link. +-- -- efficiency_static,p.u.,float,Length-independent transmission efficiency. +-- -- efficiency_per_1000km,p.u. per 1000 km,float,Length-dependent transmission efficiency ($\eta^{\text{length}}$) +-- -- compression_per_1000km,p.u. per 1000 km,float,Length-dependent electricity demand for compression ($\eta \cdot \text{length}$) implemented as multi-link to local electricity bus. +H2_network,--,"{true, false}",Add option for new hydrogen pipelines +gas_network,--,"{true, false}","Add existing natural gas infrastructure, incl. LNG terminals, production and entry-points. The existing gas network is added with a lossless transport model. A length-weighted `k-edge augmentation algorithm `_ can be run to add new candidate gas pipelines such that all regions of the model can be connected to the gas network. When activated, all the gas demands are regionally disaggregated as well." +H2_retrofit,--,"{true, false}",Add option for retrofiting existing pipelines to transport hydrogen. +H2_retrofit_capacity _per_CH4,--,float,"The ratio for H2 capacity per original CH4 capacity of retrofitted pipelines. The `European Hydrogen Backbone (April, 2020) p.15 `_ 60% of original natural gas capacity could be used in cost-optimal case as H2 capacity." +gas_network_connectivity _upgrade ,--,float,The number of desired edge connectivity (k) in the length-weighted `k-edge augmentation algorithm `_ used for the gas network +gas_distribution_grid,--,"{true, false}",Add a gas distribution grid +gas_distribution_grid _cost_factor,,,Multiplier for the investment cost of the gas distribution grid +,,, +biomass_spatial,--,"{true, false}",Add option for resolving biomass demand regionally +biomass_transport,--,"{true, false}",Add option for transporting solid biomass between nodes +biogas_upgrading_cc,--,"{true, false}",Add option to capture CO2 from biomass upgrading +conventional_generation,,,Add a more detailed description of conventional carriers. Any power generation requires the consumption of fuel from nodes representing that fuel. +biomass_to_liquid,--,"{true, false}",Add option for transforming solid biomass into liquid fuel with the same properties as oil +biosng,--,"{true, false}",Add option for transforming solid biomass into synthesis gas with the same properties as natural gas +limit_max_growth,,, +-- enable,--,"{true, false}",Add option to limit the maximum growth of a carrier +-- factor,p.u.,float,The maximum growth factor of a carrier (e.g. 1.3 allows 30% larger than max historic growth) +-- max_growth,,, +-- -- {carrier},GW,float,The historic maximum growth of a carrier +-- max_relative_growth,,, +-- -- {carrier},p.u.,float,The historic maximum relative growth of a carrier +,,, +enhanced_geothermal,,, +-- enable,--,"{true, false}",Add option to include Enhanced Geothermal Systems +-- flexible,--,"{true, false}",Add option for flexible operation (see Ricks et al. 2024) +-- max_hours,--,int,The maximum hours the reservoir can be charged under flexible operation +-- max_boost,--,float,The maximum boost in power output under flexible operation +-- var_cf,--,"{true, false}",Add option for variable capacity factor (see Ricks et al. 2024) +-- sustainability_factor,--,float,Share of sourced heat that is replenished by the earth's core (see details in `build_egs_potentials.py `_) +solid_biomass_import,,, +-- enable,--,"{true, false}",Add option to include solid biomass imports +-- price,currency/MWh,float,Price for importing solid biomass +-- max_amount,Twh,float,Maximum solid biomass import potential +-- upstream_emissions_factor,p.u.,float,Upstream emissions of solid biomass imports From 440f3e4a7f6cea53585d41f129dc4b9d08e68901 Mon Sep 17 00:00:00 2001 From: lisazeyen Date: Fri, 2 Aug 2024 15:26:32 +0200 Subject: [PATCH 52/79] add release notes --- doc/release_notes.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/release_notes.rst b/doc/release_notes.rst index 4293541b..d2453bb1 100644 --- a/doc/release_notes.rst +++ b/doc/release_notes.rst @@ -10,7 +10,9 @@ Release Notes Upcoming Release ================ -* Add option to produce electrobiofuels from solid biomass and hydrogen, as a combination of BtL and Fischer-Tropsch to make more use of the biogenic carbon +* Add option to import solid biomass + +* Add option to produce electrobiofuels (flag ``electrobiofuels`) from solid biomass and hydrogen, as a combination of BtL and Fischer-Tropsch to make more use of the biogenic carbon * Add flag ``sector: fossil_fuels`` in config to remove the option of importing fossil fuels From e28c66e43c03476470e7d425c80536993b632aa0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 2 Aug 2024 13:27:40 +0000 Subject: [PATCH 53/79] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- scripts/prepare_sector_network.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index a3de3f20..09055525 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -2295,15 +2295,16 @@ def add_biomass(n, costs): biomass_import_price = options["solid_biomass_import"]["price"] # convert TWh in MWh biomass_import_max_amount = options["solid_biomass_import"]["max_amount"] * 1e6 - biomass_import_upstream_emissions = options["solid_biomass_import"]["upstream_emissions_factor"] - + biomass_import_upstream_emissions = options["solid_biomass_import"][ + "upstream_emissions_factor" + ] + logger.info( - "Adding biomass import with cost %.2f EUR/MWh, a limit of %.2f TWh, and embedded emissions of %.2f%%", - biomass_import_price, - options["solid_biomass_import"]["max_amount"], - biomass_import_upstream_emissions * 100 + "Adding biomass import with cost %.2f EUR/MWh, a limit of %.2f TWh, and embedded emissions of %.2f%%", + biomass_import_price, + options["solid_biomass_import"]["max_amount"], + biomass_import_upstream_emissions * 100, ) - n.add("Carrier", "solid biomass import") @@ -2333,7 +2334,8 @@ def add_biomass(n, costs): bus2="co2 atmosphere", carrier="solid biomass import", efficiency=1.0, - efficiency2=biomass_import_upstream_emissions* costs.at["solid biomass", "CO2 intensity"], + efficiency2=biomass_import_upstream_emissions + * costs.at["solid biomass", "CO2 intensity"], p_nom_extendable=True, ) From 4a6dd2fe33125086926f6653b55c308b8efb8f0c Mon Sep 17 00:00:00 2001 From: AmosSchledorn Date: Fri, 2 Aug 2024 15:56:37 +0200 Subject: [PATCH 54/79] fix naming bugs --- config/config.default.yaml | 15 +++-------- scripts/build_cop_profiles/run.py | 12 ++++----- scripts/prepare_sector_network.py | 43 +++++++++++++++---------------- 3 files changed, 31 insertions(+), 39 deletions(-) diff --git a/config/config.default.yaml b/config/config.default.yaml index bfa99d90..ebb8eb4f 100644 --- a/config/config.default.yaml +++ b/config/config.default.yaml @@ -417,20 +417,13 @@ sector: isentropic_compressor_efficiency: 0.8 heat_loss: 0.0 heat_pump_sources: - central: + urban central: - air - decentral: + urban decentral: + - air + rural: - air - ground - heat_systems: - rural: - - residential rural - - services rural - urban decentral: - - residential urban decentral - - services urban decentral - urban central: - - urban central cluster_heat_buses: true heat_demand_cutout: default bev_dsm_restriction_value: 0.75 diff --git a/scripts/build_cop_profiles/run.py b/scripts/build_cop_profiles/run.py index 5178483a..583d097a 100644 --- a/scripts/build_cop_profiles/run.py +++ b/scripts/build_cop_profiles/run.py @@ -12,18 +12,18 @@ from DecentralHeatingCopApproximator import DecentralHeatingCopApproximator def get_cop( - heat_system_type: str, + heat_system_category: str, heat_source: str, source_inlet_temperature_celsius: xr.DataArray, ) -> xr.DataArray: - if heat_system_type == "decentral": + if heat_system_category in ["urban decentral", "rural"]: return DecentralHeatingCopApproximator( forward_temperature_celsius=snakemake.params.heat_pump_sink_T_decentral_heating, source_inlet_temperature_celsius=source_inlet_temperature_celsius, source_type=heat_source, ).approximate_cop() - elif heat_system_type == "central": + elif heat_system_category == "urban central": return CentralHeatingCopApproximator( forward_temperature_celsius=snakemake.params.forward_temperature_central_heating, return_temperature_celsius=snakemake.params.return_temperature_central_heating, @@ -33,7 +33,7 @@ def get_cop( ).approximate_cop() else: raise ValueError( - f"Invalid heat system type '{heat_system_type}'. Must be one of ['decentral', 'central']" + f"Invalid heat system type '{heat_system_category}'. Must be one of ['urban decentral', 'urban central', 'rural]" ) @@ -50,14 +50,14 @@ if __name__ == "__main__": set_scenario_config(snakemake) cop_all_system_types = [] - for heat_system_type, heat_sources in snakemake.params.heat_pump_sources.items(): + for heat_system_category, heat_sources in snakemake.params.heat_pump_sources.items(): cop_this_system_type = [] for heat_source in heat_sources: source_inlet_temperature_celsius = xr.open_dataarray( snakemake.input[f"temp_{heat_source.replace('ground', 'soil')}_total"] ) cop_da = get_cop( - heat_system_type=heat_system_type, + heat_system_category=heat_system_category, heat_source=heat_source, source_inlet_temperature_celsius=source_inlet_temperature_celsius, ) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index 52989c2d..989f4dc2 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -1840,9 +1840,9 @@ def add_heat(n, costs): n.madd( "Bus", - nodes + f" {heat_system} heat", + nodes + f" {heat_system.value} heat", location=nodes, - carrier=f"{heat_system} heat", + carrier=f"{heat_system.value} heat", unit="MWh_th", ) @@ -1891,10 +1891,10 @@ def add_heat(n, costs): ) ## Add heat pumps - for heat_source in snakemake.params.heat_pump_sources[heat_system.system_type]: + for heat_source in snakemake.params.heat_pump_sources[heat_system.system_category]: costs_name = heat_system.heat_pump_costs_name(heat_source) efficiency = ( - cop.sel(heat_system=heat_system.system_type, heat_source=heat_source, name=nodes) + cop.sel(heat_system=heat_system.system_category, heat_source=heat_source, name=nodes) .to_pandas() .reindex(index=n.snapshots) if options["time_dep_hp_cop"] @@ -2013,7 +2013,7 @@ def add_heat(n, costs): lifetime=costs.at[heat_system.system_type + " solar thermal", "lifetime"], ) - if options["chp"] and heat_system == "urban central": + if options["chp"] and heat_system == HeatSystem.URBAN_CENTRAL: # add gas CHP; biomass CHP is added in biomass section n.madd( "Link", @@ -2070,7 +2070,7 @@ def add_heat(n, costs): lifetime=costs.at["central gas CHP", "lifetime"], ) - if options["chp"] and options["micro_chp"] and heat_system != "urban central": + if options["chp"] and options["micro_chp"] and heat_system.value != "urban central": n.madd( "Link", nodes + f" {heat_system} micro gas CHP", @@ -2079,7 +2079,7 @@ def add_heat(n, costs): bus1=nodes, bus2=nodes + f" {heat_system} heat", bus3="co2 atmosphere", - carrier=heat_system + " micro gas CHP", + carrier=heat_system.value + " micro gas CHP", efficiency=costs.at["micro CHP", "efficiency"], efficiency2=costs.at["micro CHP", "efficiency-heat"], efficiency3=costs.at["gas", "CO2 intensity"], @@ -2106,36 +2106,35 @@ def add_heat(n, costs): # share of space heat demand 'w_space' of total heat demand w_space = {} - for sector in HeatSector: - w_space[sector.value] = heat_demand[sector.value + " space"] / ( - heat_demand[sector.value + " space"] + heat_demand[sector.value + " water"] + for sector in sectors: + w_space[sector] = heat_demand[sector + " space"] / ( + heat_demand[sector + " space"] + heat_demand[sector + " water"] ) w_space["tot"] = ( heat_demand["services space"] + heat_demand["residential space"] ) / heat_demand.T.groupby(level=[1]).sum().T - for heat_system in n.loads[ - n.loads.carrier.isin([x.value + " heat" for x in HeatSystem]) + for name in n.loads[ + n.loads.carrier.isin([x + " heat" for x in heat_systems]) ].index: - node = n.buses.loc[heat_system, "location"] + node = n.buses.loc[name, "location"] ct = pop_layout.loc[node, "ct"] # weighting 'f' depending on the size of the population at the node - if "urban central" in heat_system: + if "urban central" in name: f = dist_fraction[node] - elif "urban decentral" in heat_system: + elif "urban decentral" in name: f = urban_fraction[node] - dist_fraction[node] else: f = 1 - urban_fraction[node] if f == 0: continue - # get sector name ("residential"/"services"/or both "tot" for urban central) - if "urban central" in heat_system: + if "urban central" in name: sec = "tot" - if "residential" in heat_system: + if "residential" in name: sec = "residential" - if "services" in heat_system: + if "services" in name: sec = "services" # get floor aread at node and region (urban/rural) in m^2 @@ -2143,7 +2142,7 @@ def add_heat(n, costs): pop_layout.loc[node].fraction * floor_area.loc[ct, "value"] * 10**6 ).loc[sec] * f # total heat demand at node [MWh] - demand = n.loads_t.p_set[heat_system] + demand = n.loads_t.p_set[name] # space heat demand at node [MWh] space_heat_demand = demand * w_space[sec][node] @@ -2184,12 +2183,12 @@ def add_heat(n, costs): # add for each retrofitting strength a generator with heat generation profile following the profile of the heat demand for strength in strengths: - node_name = " ".join(heat_system.split(" ")[2::]) + node_name = " ".join(name.split(" ")[2::]) n.madd( "Generator", [node], suffix=" retrofitting " + strength + " " + node_name, - bus=heat_system, + bus=name, carrier="retrofitting", p_nom_extendable=True, p_nom_max=dE_diff[strength] From 318e05c9fb663c467f59f7610679aca0db40cbf6 Mon Sep 17 00:00:00 2001 From: AmosSchledorn Date: Fri, 2 Aug 2024 16:29:54 +0200 Subject: [PATCH 55/79] refactor naming --- scripts/build_cop_profiles/run.py | 42 +++++++++++++++++++++---------- scripts/prepare_sector_network.py | 41 +++++++++++++++--------------- 2 files changed, 49 insertions(+), 34 deletions(-) diff --git a/scripts/build_cop_profiles/run.py b/scripts/build_cop_profiles/run.py index 583d097a..7aa5b1bf 100644 --- a/scripts/build_cop_profiles/run.py +++ b/scripts/build_cop_profiles/run.py @@ -7,23 +7,35 @@ import numpy as np import pandas as pd import xarray as xr from _helpers import set_scenario_config +import sys; sys.path.append("..") +from scripts._entities import HeatSystemType from CentralHeatingCopApproximator import CentralHeatingCopApproximator from DecentralHeatingCopApproximator import DecentralHeatingCopApproximator def get_cop( - heat_system_category: str, + heat_system_type: str, heat_source: str, source_inlet_temperature_celsius: xr.DataArray, ) -> xr.DataArray: - if heat_system_category in ["urban decentral", "rural"]: - return DecentralHeatingCopApproximator( - forward_temperature_celsius=snakemake.params.heat_pump_sink_T_decentral_heating, - source_inlet_temperature_celsius=source_inlet_temperature_celsius, - source_type=heat_source, - ).approximate_cop() + """ + Calculate the coefficient of performance (COP) for a heating system. - elif heat_system_category == "urban central": + Parameters + ---------- + heat_system_type : str + The type of heating system. + heat_source : str + The heat source used in the heating system. + source_inlet_temperature_celsius : xr.DataArray + The inlet temperature of the heat source in Celsius. + + Returns + ------- + xr.DataArray + The calculated coefficient of performance (COP) for the heating system. + """ + if HeatSystemType(heat_system_type).is_central: return CentralHeatingCopApproximator( forward_temperature_celsius=snakemake.params.forward_temperature_central_heating, return_temperature_celsius=snakemake.params.return_temperature_central_heating, @@ -31,10 +43,14 @@ def get_cop( source_outlet_temperature_celsius=source_inlet_temperature_celsius - snakemake.params.heat_source_cooling_central_heating, ).approximate_cop() + else: - raise ValueError( - f"Invalid heat system type '{heat_system_category}'. Must be one of ['urban decentral', 'urban central', 'rural]" - ) + return DecentralHeatingCopApproximator( + forward_temperature_celsius=snakemake.params.heat_pump_sink_T_decentral_heating, + source_inlet_temperature_celsius=source_inlet_temperature_celsius, + source_type=heat_source, + ).approximate_cop() + if __name__ == "__main__": @@ -50,14 +66,14 @@ if __name__ == "__main__": set_scenario_config(snakemake) cop_all_system_types = [] - for heat_system_category, heat_sources in snakemake.params.heat_pump_sources.items(): + for heat_system_type, heat_sources in snakemake.params.heat_pump_sources.items(): cop_this_system_type = [] for heat_source in heat_sources: source_inlet_temperature_celsius = xr.open_dataarray( snakemake.input[f"temp_{heat_source.replace('ground', 'soil')}_total"] ) cop_da = get_cop( - heat_system_category=heat_system_category, + heat_system_type=heat_system_type, heat_source=heat_source, source_inlet_temperature_celsius=source_inlet_temperature_celsius, ) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index 989f4dc2..c15d8167 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -1829,7 +1829,6 @@ def add_heat(n, costs): cop = xr.open_dataarray(snakemake.input.cop_profiles) for heat_system in HeatSystem: #this loops through all heat systems defined in _entities.HeatSystem - # system_type = "central" if heat_system == "urban central" else "decentral" if heat_system == HeatSystem.URBAN_CENTRAL: nodes = dist_fraction.index[dist_fraction > 0] @@ -1886,15 +1885,15 @@ def add_heat(n, costs): nodes, suffix=f" {heat_system} heat", bus=nodes + f" {heat_system} heat", - carrier=heat_system.value + " heat", + carrier=f"{heat_system} heat", p_set=heat_load, ) ## Add heat pumps - for heat_source in snakemake.params.heat_pump_sources[heat_system.system_category]: + for heat_source in snakemake.params.heat_pump_sources[heat_system.system_type.value]: costs_name = heat_system.heat_pump_costs_name(heat_source) efficiency = ( - cop.sel(heat_system=heat_system.system_category, heat_source=heat_source, name=nodes) + cop.sel(heat_system=heat_system.system_type.value, heat_source=heat_source, name=nodes) .to_pandas() .reindex(index=n.snapshots) if options["time_dep_hp_cop"] @@ -1917,13 +1916,13 @@ def add_heat(n, costs): ) if options["tes"]: - n.add("Carrier", heat_system.value + " water tanks") + n.add("Carrier", f"{heat_system} water tanks") n.madd( "Bus", nodes + f" {heat_system} water tanks", location=nodes, - carrier=heat_system.value + " water tanks", + carrier=f"{heat_system} water tanks", unit="MWh_th", ) @@ -1933,7 +1932,7 @@ def add_heat(n, costs): bus0=nodes + f" {heat_system} heat", bus1=nodes + f" {heat_system} water tanks", efficiency=costs.at["water tank charger", "efficiency"], - carrier=heat_system.value + " water tanks charger", + carrier=f"{heat_system} water tanks charger", p_nom_extendable=True, ) @@ -1942,12 +1941,12 @@ def add_heat(n, costs): nodes + f" {heat_system} water tanks discharger", bus0=nodes + f" {heat_system} water tanks", bus1=nodes + f" {heat_system} heat", - carrier=heat_system.value + " water tanks discharger", + carrier=f"{heat_system} water tanks discharger", efficiency=costs.at["water tank discharger", "efficiency"], p_nom_extendable=True, ) - tes_time_constant_days = options["tes_tau"][heat_system.system_type] + tes_time_constant_days = options["tes_tau"][heat_system.central_or_decentral] n.madd( "Store", @@ -1955,21 +1954,21 @@ def add_heat(n, costs): bus=nodes + f" {heat_system} water tanks", e_cyclic=True, e_nom_extendable=True, - carrier=heat_system.value + " water tanks", + carrier=f"{heat_system} water tanks", standing_loss=1 - np.exp(-1 / 24 / tes_time_constant_days), - capital_cost=costs.at[heat_system.system_type + " water tank storage", "fixed"], - lifetime=costs.at[heat_system.system_type + " water tank storage", "lifetime"], + capital_cost=costs.at[heat_system.central_or_decentral + " water tank storage", "fixed"], + lifetime=costs.at[heat_system.central_or_decentral + " water tank storage", "lifetime"], ) if options["resistive_heaters"]: - key = f"{heat_system.system_type} resistive heater" + key = f"{heat_system.central_or_decentral} resistive heater" n.madd( "Link", nodes + f" {heat_system} resistive heater", bus0=nodes, bus1=nodes + f" {heat_system} heat", - carrier=heat_system.value + " resistive heater", + carrier=f"{heat_system} resistive heater", efficiency=costs.at[key, "efficiency"], capital_cost=costs.at[key, "efficiency"] * costs.at[key, "fixed"] @@ -1979,7 +1978,7 @@ def add_heat(n, costs): ) if options["boilers"]: - key = f"{heat_system.system_type} gas boiler" + key = f"{heat_system.central_or_decentral} gas boiler" n.madd( "Link", @@ -1988,7 +1987,7 @@ def add_heat(n, costs): bus0=spatial.gas.df.loc[nodes, "nodes"].values, bus1=nodes + f" {heat_system} heat", bus2="co2 atmosphere", - carrier=heat_system.value + " gas boiler", + carrier=f"{heat_system} gas boiler", efficiency=costs.at[key, "efficiency"], efficiency2=costs.at["gas", "CO2 intensity"], capital_cost=costs.at[key, "efficiency"] @@ -1998,19 +1997,19 @@ def add_heat(n, costs): ) if options["solar_thermal"]: - n.add("Carrier", heat_system.value + " solar thermal") + n.add("Carrier", f"{heat_system} solar thermal") n.madd( "Generator", nodes, suffix=f" {heat_system} solar thermal collector", bus=nodes + f" {heat_system} heat", - carrier=heat_system.value + " solar thermal", + carrier=f"{heat_system} solar thermal", p_nom_extendable=True, - capital_cost=costs.at[heat_system.system_type + " solar thermal", "fixed"] + capital_cost=costs.at[heat_system.central_or_decentral + " solar thermal", "fixed"] * overdim_factor, p_max_pu=solar_thermal[nodes], - lifetime=costs.at[heat_system.system_type + " solar thermal", "lifetime"], + lifetime=costs.at[heat_system.central_or_decentral + " solar thermal", "lifetime"], ) if options["chp"] and heat_system == HeatSystem.URBAN_CENTRAL: @@ -2115,7 +2114,7 @@ def add_heat(n, costs): ) / heat_demand.T.groupby(level=[1]).sum().T for name in n.loads[ - n.loads.carrier.isin([x + " heat" for x in heat_systems]) + n.loads.carrier.isin([x + " heat" for x in HeatSystem]) ].index: node = n.buses.loc[name, "location"] ct = pop_layout.loc[node, "ct"] From 69c6a4dca418d01e6f74c7a95ed64ad2ea3afb38 Mon Sep 17 00:00:00 2001 From: lisazeyen Date: Fri, 2 Aug 2024 16:45:57 +0200 Subject: [PATCH 56/79] set e_max_pu to force municipal waste to be used --- scripts/prepare_sector_network.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index 87170287..142ecca5 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -2358,7 +2358,8 @@ def add_biomass(n, costs): * costs.at["solid biomass", "CO2 intensity"], p_nom_extendable=True, ) - + + e_max_pu = pd.Series([1] * (len(snapshots) - 1) + [0], index=n.snapshots) n.madd( "Store", spatial.msw.nodes, @@ -2366,6 +2367,7 @@ def add_biomass(n, costs): carrier="municipal solid waste", e_nom=msw_biomass_potentials_spatial, marginal_cost=0, # costs.at["municipal solid waste", "fuel"], + e_max_pu=e_max_pu, e_initial=msw_biomass_potentials_spatial, ) From 3149bfd926d2aad2741b3c4cbee629dbcdd4d635 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 2 Aug 2024 14:47:20 +0000 Subject: [PATCH 57/79] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- scripts/prepare_sector_network.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index 142ecca5..4e736176 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -2358,7 +2358,7 @@ def add_biomass(n, costs): * costs.at["solid biomass", "CO2 intensity"], p_nom_extendable=True, ) - + e_max_pu = pd.Series([1] * (len(snapshots) - 1) + [0], index=n.snapshots) n.madd( "Store", From b62db804351166ae548d727af95d8ba621b10b7f Mon Sep 17 00:00:00 2001 From: lisazeyen Date: Fri, 2 Aug 2024 16:59:42 +0200 Subject: [PATCH 58/79] fix bug with e_max_pu --- scripts/prepare_sector_network.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index 4e736176..c7080f63 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -2358,8 +2358,8 @@ def add_biomass(n, costs): * costs.at["solid biomass", "CO2 intensity"], p_nom_extendable=True, ) - - e_max_pu = pd.Series([1] * (len(snapshots) - 1) + [0], index=n.snapshots) + + e_max_pu = pd.Series([1] * (len(n.snapshots) - 1) + [0], index=n.snapshots) n.madd( "Store", spatial.msw.nodes, From f58322c3e52b890858c00c01053afacafe95f870 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 2 Aug 2024 15:02:07 +0000 Subject: [PATCH 59/79] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- scripts/prepare_sector_network.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index c7080f63..8fdbac6e 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -2358,7 +2358,7 @@ def add_biomass(n, costs): * costs.at["solid biomass", "CO2 intensity"], p_nom_extendable=True, ) - + e_max_pu = pd.Series([1] * (len(n.snapshots) - 1) + [0], index=n.snapshots) n.madd( "Store", From 76b377b2d149c6637fa9637ff99335ce89af0ada Mon Sep 17 00:00:00 2001 From: AmosSchledorn Date: Fri, 2 Aug 2024 17:02:16 +0200 Subject: [PATCH 60/79] udpate docs --- doc/configtables/sector.csv | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/doc/configtables/sector.csv b/doc/configtables/sector.csv index e14da557..a075dd3d 100644 --- a/doc/configtables/sector.csv +++ b/doc/configtables/sector.csv @@ -6,6 +6,8 @@ industry,--,"{true, false}",Flag to include industry sector. agriculture,--,"{true, false}",Flag to include agriculture sector. district_heating,--,,`prepare_sector_network.py `_ -- potential,--,float,maximum fraction of urban demand which can be supplied by district heating. Ignored where below current fraction. +-- progress,--,Dictionary with planning horizons as keys., Increase of today's district heating demand to potential maximum district heating share. Progress = 0 means today's district heating share. Progress = 1 means maximum fraction of urban demand is supplied by district heating +-- district_heating_loss,--,float,Share increase in district heat demand in urban central due to heat losses -- forward_temperature,°C,float,Forward temperature in district heating -- return_temperature,°C,float,Return temperature in district heating. Must be lower than forward temperature -- heat_source_cooling,K,float,Cooling of heat source for heat pumps @@ -14,8 +16,10 @@ district_heating,--,,`prepare_sector_network.py `_ to one to save memory. ,,, bev_dsm_restriction _value,--,float,Adds a lower state of charge (SOC) limit for battery electric vehicles (BEV) to manage its own energy demand (DSM). Located in `build_transport_demand.py `_. Set to 0 for no restriction on BEV DSM From bbf64a2fde2825f0a954526b1b99cc53ce1f7b60 Mon Sep 17 00:00:00 2001 From: AmosSchledorn Date: Fri, 2 Aug 2024 17:03:34 +0200 Subject: [PATCH 61/79] Refactor module structure --- scripts/build_cop_profiles/run.py | 2 +- scripts/enums/HeatSector.py | 25 ++++ scripts/enums/HeatSystem.py | 218 ++++++++++++++++++++++++++++++ scripts/enums/HeatSystemType.py | 35 +++++ scripts/prepare_sector_network.py | 4 +- 5 files changed, 282 insertions(+), 2 deletions(-) create mode 100644 scripts/enums/HeatSector.py create mode 100644 scripts/enums/HeatSystem.py create mode 100644 scripts/enums/HeatSystemType.py diff --git a/scripts/build_cop_profiles/run.py b/scripts/build_cop_profiles/run.py index 7aa5b1bf..776ed289 100644 --- a/scripts/build_cop_profiles/run.py +++ b/scripts/build_cop_profiles/run.py @@ -8,7 +8,7 @@ import pandas as pd import xarray as xr from _helpers import set_scenario_config import sys; sys.path.append("..") -from scripts._entities import HeatSystemType +from scripts.enums.HeatSystemType import HeatSystemType from CentralHeatingCopApproximator import CentralHeatingCopApproximator from DecentralHeatingCopApproximator import DecentralHeatingCopApproximator diff --git a/scripts/enums/HeatSector.py b/scripts/enums/HeatSector.py new file mode 100644 index 00000000..008a0693 --- /dev/null +++ b/scripts/enums/HeatSector.py @@ -0,0 +1,25 @@ +# SPDX-License-Identifier: MIT + +from enum import Enum + +class HeatSector(Enum): + """ + Enumeration class representing different heat sectors. + + Attributes: + RESIDENTIAL (str): Represents the residential heat sector. + SERVICES (str): Represents the services heat sector. + """ + + RESIDENTIAL = "residential" + SERVICES = "services" + + def __str__(self) -> str: + """ + Returns the string representation of the heat sector. + + Returns: + str: The string representation of the heat sector. + """ + return self.value + diff --git a/scripts/enums/HeatSystem.py b/scripts/enums/HeatSystem.py new file mode 100644 index 00000000..042793a6 --- /dev/null +++ b/scripts/enums/HeatSystem.py @@ -0,0 +1,218 @@ +# -*- coding: utf-8 -*- +# SPDX-FileCopyrightText: : 2020-2024 The PyPSA-Eur Authors +# +# SPDX-License-Identifier: MIT + +from enum import Enum + +from .HeatSystemType import HeatSystemType +from .HeatSector import HeatSector + +class HeatSystem(Enum): + """ + Enumeration representing different heat systems. + + Attributes + ---------- + RESIDENTIAL_RURAL : str + Heat system for residential areas in rural locations. + SERVICES_RURAL : str + Heat system for service areas in rural locations. + RESIDENTIAL_URBAN_DECENTRAL : str + Heat system for residential areas in urban decentralized locations. + SERVICES_URBAN_DECENTRAL : str + Heat system for service areas in urban decentralized locations. + URBAN_CENTRAL : str + Heat system for urban central areas. + + Methods + ------- + __str__() + Returns the string representation of the heat system. + central_or_decentral() + Returns whether the heat system is central or decentralized. + system_type() + Returns the type of the heat system. + sector() + Returns the sector of the heat system. + rural() + Returns whether the heat system is for rural areas. + urban_decentral() + Returns whether the heat system is for urban decentralized areas. + urban() + Returns whether the heat system is for urban areas. + heat_demand_weighting(urban_fraction=None, dist_fraction=None) + Calculates the heat demand weighting based on urban fraction and distribution fraction. + heat_pump_costs_name(heat_source) + Generates the name for the heat pump costs based on the heat source. + """ + + RESIDENTIAL_RURAL = "residential rural" + SERVICES_RURAL = "services rural" + RESIDENTIAL_URBAN_DECENTRAL = "residential urban decentral" + SERVICES_URBAN_DECENTRAL = "services urban decentral" + URBAN_CENTRAL = "urban central" + + def __init__(self, *args): + super().__init__(*args) + + def __str__(self) -> str: + """ + Returns the string representation of the heat system. + + Returns + ------- + str + The string representation of the heat system. + """ + return self.value + + @property + def central_or_decentral(self) -> str: + """ + Returns whether the heat system is central or decentralized. + + Returns + ------- + str + "central" if the heat system is central, "decentral" otherwise. + """ + if self == HeatSystem.URBAN_CENTRAL: + return "central" + else: + return "decentral" + + @property + def system_type(self) -> HeatSystemType: + """ + Returns the type of the heat system. + + Returns + ------- + str + The type of the heat system. + + Raises + ------ + RuntimeError + If the heat system is invalid. + """ + if self == HeatSystem.URBAN_CENTRAL: + return HeatSystemType.URBAN_CENTRAL + elif self == HeatSystem.RESIDENTIAL_URBAN_DECENTRAL or self == HeatSystem.SERVICES_URBAN_DECENTRAL: + return HeatSystemType.URBAN_DECENTRAL + elif self == HeatSystem.RESIDENTIAL_RURAL or self == HeatSystem.SERVICES_RURAL: + return HeatSystemType.RURAL + else: + raise RuntimeError(f"Invalid heat system: {self}") + + @property + def sector(self) -> HeatSector: + """ + Returns the sector of the heat system. + + Returns + ------- + HeatSector + The sector of the heat system. + """ + if ( + self == HeatSystem.RESIDENTIAL_RURAL + or self == HeatSystem.RESIDENTIAL_URBAN_DECENTRAL + ): + return HeatSector.RESIDENTIAL + elif ( + self == HeatSystem.SERVICES_RURAL + or self == HeatSystem.SERVICES_URBAN_DECENTRAL + ): + return HeatSector.SERVICES + else: + 'tot' + + @property + def is_rural(self) -> bool: + """ + Returns whether the heat system is for rural areas. + + Returns + ------- + bool + True if the heat system is for rural areas, False otherwise. + """ + if self == HeatSystem.RESIDENTIAL_RURAL or self == HeatSystem.SERVICES_RURAL: + return True + else: + return False + + @property + def is_urban_decentral(self) -> bool: + """ + Returns whether the heat system is for urban decentralized areas. + + Returns + ------- + bool + True if the heat system is for urban decentralized areas, False otherwise. + """ + if self == HeatSystem.RESIDENTIAL_URBAN_DECENTRAL or self == HeatSystem.SERVICES_URBAN_DECENTRAL: + return True + else: + return False + + @property + def is_urban(self) -> bool: + """ + Returns whether the heat system is for urban areas. + + Returns + ------- + bool True if the heat system is for urban areas, False otherwise. """ + return not self.is_rural + + def heat_demand_weighting(self, urban_fraction=None, dist_fraction=None) -> float: + """ + Calculates the heat demand weighting based on urban fraction and distribution fraction. + + Parameters + ---------- + urban_fraction : float, optional + The fraction of urban heat demand. + dist_fraction : float, optional + The fraction of distributed heat demand. + + Returns + ------- + float + The heat demand weighting. + + Raises + ------ + RuntimeError + If the heat system is invalid. + """ + if "rural" in self.value: + return 1 - urban_fraction + elif "urban central" in self.value: + return dist_fraction + elif "urban decentral" in self.value: + return urban_fraction - dist_fraction + else: + raise RuntimeError(f"Invalid heat system: {self}") + + def heat_pump_costs_name(self, heat_source: str) -> str: + """ + Generates the name for the heat pump costs based on the heat source. + + Parameters + ---------- + heat_source : str + The heat source. + + Returns + ------- + str + The name for the heat pump costs. + """ + return f"{self.central_or_decentral} {heat_source}-sourced heat pump" + + diff --git a/scripts/enums/HeatSystemType.py b/scripts/enums/HeatSystemType.py new file mode 100644 index 00000000..6847965d --- /dev/null +++ b/scripts/enums/HeatSystemType.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +# SPDX-FileCopyrightText: : 2020-2024 The PyPSA-Eur Authors +# +# SPDX-License-Identifier: MIT + +from enum import Enum + +class HeatSystemType(Enum): + """ + Enumeration representing different types of heat systems. + """ + + URBAN_CENTRAL = "urban central" + URBAN_DECENTRAL = "urban decentral" + RURAL = "rural" + + def __str__(self) -> str: + """ + Returns the string representation of the heat system type. + + Returns: + str: The string representation of the heat system type. + """ + return self.value + + @property + def is_central(self) -> bool: + """ + Returns whether the heat system type is central. + + Returns: + bool: True if the heat system type is central, False otherwise. + """ + return self == HeatSystemType.URBAN_CENTRAL + diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index c15d8167..99598f45 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -22,7 +22,9 @@ from _helpers import ( set_scenario_config, update_config_from_wildcards, ) -from _entities import HeatSystem, HeatSector +from scripts.enums.HeatSystem import HeatSystem +from scripts.enums.HeatSystemType import HeatSystemType +from scripts.enums.HeatSector import HeatSector from add_electricity import calculate_annuity, sanitize_carriers, sanitize_locations from build_energy_totals import ( build_co2_totals, From 6b924ecfb0088e1100df0edadedbebcd98d917a5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 2 Aug 2024 15:15:09 +0000 Subject: [PATCH 62/79] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- rules/build_sector.smk | 2 +- scripts/build_cop_profiles/run.py | 9 +++-- scripts/enums/HeatSector.py | 3 +- scripts/enums/HeatSystem.py | 35 +++++++++++------- scripts/enums/HeatSystemType.py | 4 +- scripts/prepare_sector_network.py | 61 +++++++++++++++++++++++-------- 6 files changed, 78 insertions(+), 36 deletions(-) diff --git a/rules/build_sector.smk b/rules/build_sector.smk index 34477f5b..5916aa02 100644 --- a/rules/build_sector.smk +++ b/rules/build_sector.smk @@ -965,7 +965,7 @@ rule prepare_sector_network: emissions_scope=config_provider("energy", "emissions"), RDIR=RDIR, heat_pump_sources=config_provider("sector", "heat_pump_sources"), - heat_systems=config_provider("sector", "heat_systems") + heat_systems=config_provider("sector", "heat_systems"), input: unpack(input_profile_offwind), **rules.cluster_gas_network.output, diff --git a/scripts/build_cop_profiles/run.py b/scripts/build_cop_profiles/run.py index 776ed289..6a4a0061 100644 --- a/scripts/build_cop_profiles/run.py +++ b/scripts/build_cop_profiles/run.py @@ -7,11 +7,15 @@ import numpy as np import pandas as pd import xarray as xr from _helpers import set_scenario_config -import sys; sys.path.append("..") -from scripts.enums.HeatSystemType import HeatSystemType from CentralHeatingCopApproximator import CentralHeatingCopApproximator from DecentralHeatingCopApproximator import DecentralHeatingCopApproximator +from scripts.enums.HeatSystemType import HeatSystemType + +import sys + +sys.path.append("..") + def get_cop( heat_system_type: str, @@ -52,7 +56,6 @@ def get_cop( ).approximate_cop() - if __name__ == "__main__": if "snakemake" not in globals(): from _helpers import mock_snakemake diff --git a/scripts/enums/HeatSector.py b/scripts/enums/HeatSector.py index 008a0693..4c763fec 100644 --- a/scripts/enums/HeatSector.py +++ b/scripts/enums/HeatSector.py @@ -1,7 +1,9 @@ +# -*- coding: utf-8 -*- # SPDX-License-Identifier: MIT from enum import Enum + class HeatSector(Enum): """ Enumeration class representing different heat sectors. @@ -22,4 +24,3 @@ class HeatSector(Enum): str: The string representation of the heat sector. """ return self.value - diff --git a/scripts/enums/HeatSystem.py b/scripts/enums/HeatSystem.py index 042793a6..608da92f 100644 --- a/scripts/enums/HeatSystem.py +++ b/scripts/enums/HeatSystem.py @@ -5,8 +5,9 @@ from enum import Enum -from .HeatSystemType import HeatSystemType -from .HeatSector import HeatSector +from scripts.enums.HeatSector import HeatSector +from scripts.enums.HeatSystemType import HeatSystemType + class HeatSystem(Enum): """ @@ -55,7 +56,7 @@ class HeatSystem(Enum): def __init__(self, *args): super().__init__(*args) - + def __str__(self) -> str: """ Returns the string representation of the heat system. @@ -81,7 +82,7 @@ class HeatSystem(Enum): return "central" else: return "decentral" - + @property def system_type(self) -> HeatSystemType: """ @@ -99,7 +100,10 @@ class HeatSystem(Enum): """ if self == HeatSystem.URBAN_CENTRAL: return HeatSystemType.URBAN_CENTRAL - elif self == HeatSystem.RESIDENTIAL_URBAN_DECENTRAL or self == HeatSystem.SERVICES_URBAN_DECENTRAL: + elif ( + self == HeatSystem.RESIDENTIAL_URBAN_DECENTRAL + or self == HeatSystem.SERVICES_URBAN_DECENTRAL + ): return HeatSystemType.URBAN_DECENTRAL elif self == HeatSystem.RESIDENTIAL_RURAL or self == HeatSystem.SERVICES_RURAL: return HeatSystemType.RURAL @@ -127,7 +131,7 @@ class HeatSystem(Enum): ): return HeatSector.SERVICES else: - 'tot' + "tot" @property def is_rural(self) -> bool: @@ -143,7 +147,7 @@ class HeatSystem(Enum): return True else: return False - + @property def is_urban_decentral(self) -> bool: """ @@ -154,7 +158,10 @@ class HeatSystem(Enum): bool True if the heat system is for urban decentralized areas, False otherwise. """ - if self == HeatSystem.RESIDENTIAL_URBAN_DECENTRAL or self == HeatSystem.SERVICES_URBAN_DECENTRAL: + if ( + self == HeatSystem.RESIDENTIAL_URBAN_DECENTRAL + or self == HeatSystem.SERVICES_URBAN_DECENTRAL + ): return True else: return False @@ -166,12 +173,14 @@ class HeatSystem(Enum): Returns ------- - bool True if the heat system is for urban areas, False otherwise. """ + bool True if the heat system is for urban areas, False otherwise. + """ return not self.is_rural - + def heat_demand_weighting(self, urban_fraction=None, dist_fraction=None) -> float: """ - Calculates the heat demand weighting based on urban fraction and distribution fraction. + Calculates the heat demand weighting based on urban fraction and + distribution fraction. Parameters ---------- @@ -198,7 +207,7 @@ class HeatSystem(Enum): return urban_fraction - dist_fraction else: raise RuntimeError(f"Invalid heat system: {self}") - + def heat_pump_costs_name(self, heat_source: str) -> str: """ Generates the name for the heat pump costs based on the heat source. @@ -214,5 +223,3 @@ class HeatSystem(Enum): The name for the heat pump costs. """ return f"{self.central_or_decentral} {heat_source}-sourced heat pump" - - diff --git a/scripts/enums/HeatSystemType.py b/scripts/enums/HeatSystemType.py index 6847965d..5bd1bee3 100644 --- a/scripts/enums/HeatSystemType.py +++ b/scripts/enums/HeatSystemType.py @@ -5,6 +5,7 @@ from enum import Enum + class HeatSystemType(Enum): """ Enumeration representing different types of heat systems. @@ -22,7 +23,7 @@ class HeatSystemType(Enum): str: The string representation of the heat system type. """ return self.value - + @property def is_central(self) -> bool: """ @@ -32,4 +33,3 @@ class HeatSystemType(Enum): bool: True if the heat system type is central, False otherwise. """ return self == HeatSystemType.URBAN_CENTRAL - diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index cd3c2beb..88748dcc 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -22,9 +22,6 @@ from _helpers import ( set_scenario_config, update_config_from_wildcards, ) -from scripts.enums.HeatSystem import HeatSystem -from scripts.enums.HeatSystemType import HeatSystemType -from scripts.enums.HeatSector import HeatSector from add_electricity import calculate_annuity, sanitize_carriers, sanitize_locations from build_energy_totals import ( build_co2_totals, @@ -40,6 +37,10 @@ from pypsa.geo import haversine_pts from pypsa.io import import_components_from_dataframe from scipy.stats import beta +from scripts.enums.HeatSector import HeatSector +from scripts.enums.HeatSystem import HeatSystem +from scripts.enums.HeatSystemType import HeatSystemType + spatial = SimpleNamespace() logger = logging.getLogger(__name__) @@ -1833,7 +1834,11 @@ def add_heat(n, costs): solar_thermal = options["solar_cf_correction"] * solar_thermal / 1e3 cop = xr.open_dataarray(snakemake.input.cop_profiles) - for heat_system in HeatSystem: #this loops through all heat systems defined in _entities.HeatSystem + for ( + heat_system + ) in ( + HeatSystem + ): # this loops through all heat systems defined in _entities.HeatSystem if heat_system == HeatSystem.URBAN_CENTRAL: nodes = dist_fraction.index[dist_fraction > 0] @@ -1864,17 +1869,23 @@ def add_heat(n, costs): ) ## Add heat load - factor = heat_system.heat_demand_weighting(urban_fraction=urban_fraction[nodes], dist_fraction=dist_fraction[nodes]) + factor = heat_system.heat_demand_weighting( + urban_fraction=urban_fraction[nodes], dist_fraction=dist_fraction[nodes] + ) if not heat_system == HeatSystem.URBAN_CENTRAL: heat_load = ( - heat_demand[[heat_system.sector.value + " water", heat_system.sector.value + " space"]] + heat_demand[ + [ + heat_system.sector.value + " water", + heat_system.sector.value + " space", + ] + ] .T.groupby(level=1) .sum() .T[nodes] .multiply(factor) ) - if heat_system == HeatSystem.URBAN_CENTRAL: heat_load = ( heat_demand.T.groupby(level=1) @@ -1895,10 +1906,16 @@ def add_heat(n, costs): ) ## Add heat pumps - for heat_source in snakemake.params.heat_pump_sources[heat_system.system_type.value]: + for heat_source in snakemake.params.heat_pump_sources[ + heat_system.system_type.value + ]: costs_name = heat_system.heat_pump_costs_name(heat_source) efficiency = ( - cop.sel(heat_system=heat_system.system_type.value, heat_source=heat_source, name=nodes) + cop.sel( + heat_system=heat_system.system_type.value, + heat_source=heat_source, + name=nodes, + ) .to_pandas() .reindex(index=n.snapshots) if options["time_dep_hp_cop"] @@ -1951,7 +1968,9 @@ def add_heat(n, costs): p_nom_extendable=True, ) - tes_time_constant_days = options["tes_tau"][heat_system.central_or_decentral] + tes_time_constant_days = options["tes_tau"][ + heat_system.central_or_decentral + ] n.madd( "Store", @@ -1961,8 +1980,12 @@ def add_heat(n, costs): e_nom_extendable=True, carrier=f"{heat_system} water tanks", standing_loss=1 - np.exp(-1 / 24 / tes_time_constant_days), - capital_cost=costs.at[heat_system.central_or_decentral + " water tank storage", "fixed"], - lifetime=costs.at[heat_system.central_or_decentral + " water tank storage", "lifetime"], + capital_cost=costs.at[ + heat_system.central_or_decentral + " water tank storage", "fixed" + ], + lifetime=costs.at[ + heat_system.central_or_decentral + " water tank storage", "lifetime" + ], ) if options["resistive_heaters"]: @@ -2011,10 +2034,14 @@ def add_heat(n, costs): bus=nodes + f" {heat_system} heat", carrier=f"{heat_system} solar thermal", p_nom_extendable=True, - capital_cost=costs.at[heat_system.central_or_decentral + " solar thermal", "fixed"] + capital_cost=costs.at[ + heat_system.central_or_decentral + " solar thermal", "fixed" + ] * overdim_factor, p_max_pu=solar_thermal[nodes], - lifetime=costs.at[heat_system.central_or_decentral + " solar thermal", "lifetime"], + lifetime=costs.at[ + heat_system.central_or_decentral + " solar thermal", "lifetime" + ], ) if options["chp"] and heat_system == HeatSystem.URBAN_CENTRAL: @@ -2074,7 +2101,11 @@ def add_heat(n, costs): lifetime=costs.at["central gas CHP", "lifetime"], ) - if options["chp"] and options["micro_chp"] and heat_system.value != "urban central": + if ( + options["chp"] + and options["micro_chp"] + and heat_system.value != "urban central" + ): n.madd( "Link", nodes + f" {heat_system} micro gas CHP", From a990a898ef3535000204fbc1508f88b69b3c2896 Mon Sep 17 00:00:00 2001 From: AmosSchledorn Date: Fri, 2 Aug 2024 17:27:16 +0200 Subject: [PATCH 63/79] update naming in add_existing_baseyear --- scripts/add_existing_baseyear.py | 43 +++++++++++++++++--------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/scripts/add_existing_baseyear.py b/scripts/add_existing_baseyear.py index 610523e9..6edc7b7b 100644 --- a/scripts/add_existing_baseyear.py +++ b/scripts/add_existing_baseyear.py @@ -23,6 +23,9 @@ from _helpers import ( ) from add_electricity import sanitize_carriers from prepare_sector_network import cluster_heat_buses, define_spatial, prepare_costs +from scripts.enums.HeatSystem import HeatSystem +from scripts.enums.HeatSystemType import HeatSystemType +from scripts.enums.HeatSector import HeatSector logger = logging.getLogger(__name__) cc = coco.CountryConverter() @@ -443,23 +446,23 @@ def add_heating_capacities_installed_before_baseyear( logger.debug(f"Adding heating capacities installed before {baseyear}") for heat_system in existing_heating.columns.get_level_values(0).unique(): - system_type = "central" if heat_system == "urban central" else "decentral" + heat_system = HeatSystem(heat_system) nodes = pd.Index( n.buses.location[n.buses.index.str.contains(f"{heat_system} heat")] ) - if (system_type != "central") and options["electricity_distribution_grid"]: + if (not heat_system.is_central) and options["electricity_distribution_grid"]: nodes_elec = nodes + " low voltage" else: nodes_elec = nodes # Add heat pumps - heat_source = snakemake.params.heat_pump_sources[system_type] - costs_name = f"{system_type} {heat_source}-sourced heat pump" + heat_source = snakemake.params.heat_pump_sources[heat_system.system_type.value] + costs_name = f"{heat_system.system_type} {heat_source}-sourced heat pump" efficiency = ( - cop.sel(heat_system=system_type, heat_source=heat_source, name=nodes) + cop.sel(heat_system=heat_system.system_type.value, heat_source=heat_source, name=nodes) .to_pandas() .reindex(index=n.snapshots) if options["time_dep_hp_cop"] @@ -496,13 +499,13 @@ def add_heating_capacities_installed_before_baseyear( nodes, suffix=f" {heat_system} {heat_source} heat pump-{grouping_year}", bus0=nodes_elec, - bus1=nodes + " " + heat_system + " heat", + bus1=nodes + " " + heat_system.value + " heat", carrier=f"{heat_system} {heat_source} heat pump", efficiency=efficiency, capital_cost=costs.at[costs_name, "efficiency"] * costs.at[costs_name, "fixed"], p_nom=existing_heating.loc[ - nodes, (heat_system, f"{heat_source} heat pump") + nodes, (heat_system.value, f"{heat_source} heat pump") ] * ratio / costs.at[costs_name, "efficiency"], @@ -516,20 +519,20 @@ def add_heating_capacities_installed_before_baseyear( nodes, suffix=f" {heat_system} resistive heater-{grouping_year}", bus0=nodes_elec, - bus1=nodes + " " + heat_system + " heat", + bus1=nodes + " " + heat_system.value + " heat", carrier=heat_system + " resistive heater", - efficiency=costs.at[f"{system_type} resistive heater", "efficiency"], + efficiency=costs.at[f"{heat_system.system_type} resistive heater", "efficiency"], capital_cost=( - costs.at[f"{system_type} resistive heater", "efficiency"] - * costs.at[f"{system_type} resistive heater", "fixed"] + costs.at[f"{heat_system.system_type} resistive heater", "efficiency"] + * costs.at[f"{heat_system.system_type} resistive heater", "fixed"] ), p_nom=( - existing_heating.loc[nodes, (heat_system, "resistive heater")] + existing_heating.loc[nodes, (heat_system.value, "resistive heater")] * ratio - / costs.at[f"{system_type} resistive heater", "efficiency"] + / costs.at[f"{heat_system.system_type} resistive heater", "efficiency"] ), build_year=int(grouping_year), - lifetime=costs.at[f"{system_type} resistive heater", "lifetime"], + lifetime=costs.at[f"{heat_system.system_type} resistive heater", "lifetime"], ) n.madd( @@ -540,19 +543,19 @@ def add_heating_capacities_installed_before_baseyear( bus1=nodes + " " + heat_system + " heat", bus2="co2 atmosphere", carrier=heat_system + " gas boiler", - efficiency=costs.at[f"{system_type} gas boiler", "efficiency"], + efficiency=costs.at[f"{heat_system.system_type} gas boiler", "efficiency"], efficiency2=costs.at["gas", "CO2 intensity"], capital_cost=( - costs.at[f"{system_type} gas boiler", "efficiency"] - * costs.at[f"{system_type} gas boiler", "fixed"] + costs.at[f"{heat_system.system_type} gas boiler", "efficiency"] + * costs.at[f"{heat_system.system_type} gas boiler", "fixed"] ), p_nom=( existing_heating.loc[nodes, (heat_system, "gas boiler")] * ratio - / costs.at[f"{system_type} gas boiler", "efficiency"] + / costs.at[f"{heat_system.system_type} gas boiler", "efficiency"] ), build_year=int(grouping_year), - lifetime=costs.at[f"{system_type} gas boiler", "lifetime"], + lifetime=costs.at[f"{heat_system.system_type} gas boiler", "lifetime"], ) n.madd( @@ -573,7 +576,7 @@ def add_heating_capacities_installed_before_baseyear( / costs.at["decentral oil boiler", "efficiency"] ), build_year=int(grouping_year), - lifetime=costs.at[f"{system_type} gas boiler", "lifetime"], + lifetime=costs.at[f"{heat_system.system_type} gas boiler", "lifetime"], ) # delete links with p_nom=nan corresponding to extra nodes in country From 0259e066e4a5688d002e47ec9b34bc9e45ae437d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 2 Aug 2024 15:28:09 +0000 Subject: [PATCH 64/79] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- scripts/add_existing_baseyear.py | 29 ++++++++++++++++++++++------- scripts/build_cop_profiles/run.py | 4 ++-- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/scripts/add_existing_baseyear.py b/scripts/add_existing_baseyear.py index 6edc7b7b..bf5a8dc3 100644 --- a/scripts/add_existing_baseyear.py +++ b/scripts/add_existing_baseyear.py @@ -23,9 +23,10 @@ from _helpers import ( ) from add_electricity import sanitize_carriers from prepare_sector_network import cluster_heat_buses, define_spatial, prepare_costs + +from scripts.enums.HeatSector import HeatSector from scripts.enums.HeatSystem import HeatSystem from scripts.enums.HeatSystemType import HeatSystemType -from scripts.enums.HeatSector import HeatSector logger = logging.getLogger(__name__) cc = coco.CountryConverter() @@ -462,7 +463,11 @@ def add_heating_capacities_installed_before_baseyear( costs_name = f"{heat_system.system_type} {heat_source}-sourced heat pump" efficiency = ( - cop.sel(heat_system=heat_system.system_type.value, heat_source=heat_source, name=nodes) + cop.sel( + heat_system=heat_system.system_type.value, + heat_source=heat_source, + name=nodes, + ) .to_pandas() .reindex(index=n.snapshots) if options["time_dep_hp_cop"] @@ -521,18 +526,26 @@ def add_heating_capacities_installed_before_baseyear( bus0=nodes_elec, bus1=nodes + " " + heat_system.value + " heat", carrier=heat_system + " resistive heater", - efficiency=costs.at[f"{heat_system.system_type} resistive heater", "efficiency"], + efficiency=costs.at[ + f"{heat_system.system_type} resistive heater", "efficiency" + ], capital_cost=( - costs.at[f"{heat_system.system_type} resistive heater", "efficiency"] + costs.at[ + f"{heat_system.system_type} resistive heater", "efficiency" + ] * costs.at[f"{heat_system.system_type} resistive heater", "fixed"] ), p_nom=( existing_heating.loc[nodes, (heat_system.value, "resistive heater")] * ratio - / costs.at[f"{heat_system.system_type} resistive heater", "efficiency"] + / costs.at[ + f"{heat_system.system_type} resistive heater", "efficiency" + ] ), build_year=int(grouping_year), - lifetime=costs.at[f"{heat_system.system_type} resistive heater", "lifetime"], + lifetime=costs.at[ + f"{heat_system.system_type} resistive heater", "lifetime" + ], ) n.madd( @@ -543,7 +556,9 @@ def add_heating_capacities_installed_before_baseyear( bus1=nodes + " " + heat_system + " heat", bus2="co2 atmosphere", carrier=heat_system + " gas boiler", - efficiency=costs.at[f"{heat_system.system_type} gas boiler", "efficiency"], + efficiency=costs.at[ + f"{heat_system.system_type} gas boiler", "efficiency" + ], efficiency2=costs.at["gas", "CO2 intensity"], capital_cost=( costs.at[f"{heat_system.system_type} gas boiler", "efficiency"] diff --git a/scripts/build_cop_profiles/run.py b/scripts/build_cop_profiles/run.py index 6a4a0061..7e405a42 100644 --- a/scripts/build_cop_profiles/run.py +++ b/scripts/build_cop_profiles/run.py @@ -3,6 +3,8 @@ # # SPDX-License-Identifier: MIT +import sys + import numpy as np import pandas as pd import xarray as xr @@ -12,8 +14,6 @@ from DecentralHeatingCopApproximator import DecentralHeatingCopApproximator from scripts.enums.HeatSystemType import HeatSystemType -import sys - sys.path.append("..") From ddf0da2687a541c9147c9293744b706352cc69fd Mon Sep 17 00:00:00 2001 From: Fabian Neumann Date: Sun, 4 Aug 2024 16:01:51 +0200 Subject: [PATCH 65/79] base_network: bugfix - bring voronoi cells in correct order --- scripts/base_network.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/base_network.py b/scripts/base_network.py index 118e7dba..8172b332 100644 --- a/scripts/base_network.py +++ b/scripts/base_network.py @@ -808,7 +808,7 @@ def voronoi(points, outline, crs=4326): voronoi = gpd.GeoDataFrame(geometry=voronoi) joined = gpd.sjoin_nearest(pts, voronoi, how="right") - return joined.dissolve(by="Bus").squeeze() + return joined.dissolve(by="Bus").reindex(points.index).squeeze() def build_bus_shapes(n, country_shapes, offshore_shapes, countries): From a56834e51ebe7bc0ae6805143369396406993b9c Mon Sep 17 00:00:00 2001 From: lisazeyen Date: Mon, 5 Aug 2024 10:32:22 +0200 Subject: [PATCH 66/79] add switch for msw waste --- config/config.default.yaml | 2 + scripts/prepare_sector_network.py | 122 +++++++++++++++++------------- 2 files changed, 71 insertions(+), 53 deletions(-) diff --git a/config/config.default.yaml b/config/config.default.yaml index 6b906ee8..32c073b4 100644 --- a/config/config.default.yaml +++ b/config/config.default.yaml @@ -600,6 +600,7 @@ sector: biomass_to_liquid: false electrobiofuels: false biosng: false + municipal_solid_waste: false limit_max_growth: enable: false # allowing 30% larger than max historic growth @@ -627,6 +628,7 @@ sector: max_amount: 1390 # TWh upstream_emissions_factor: .1 #share of solid biomass CO2 emissions at full combustion + # docs in https://pypsa-eur.readthedocs.io/en/latest/configuration.html#industry industry: St_primary_fraction: diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index 8fdbac6e..fdded30a 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -2266,8 +2266,38 @@ def add_biomass(n, costs): n.add("Carrier", "biogas") n.add("Carrier", "solid biomass") - n.add("Carrier", "municipal solid waste") - + + + if (options["municipal_solid_waste"] and not options["industry"] + and cf_industry["waste_to_energy"] or cf_industry["waste_to_energy_cc"]): + logger.warning("Flag municipal_solid_waste can be only used with industry " + "sector waste to energy." + "Setting municipal_solid_waste=False.") + options["municipal_solid_waste"] = False + + if options["municipal_solid_waste"]: + + n.add("Carrier", "municipal solid waste") + + n.madd( + "Bus", + spatial.msw.nodes, + location=spatial.msw.locations, + carrier="municipal solid waste", + ) + + e_max_pu = pd.Series([1] * (len(n.snapshots) - 1) + [0], index=n.snapshots) + n.madd( + "Store", + spatial.msw.nodes, + bus=spatial.msw.nodes, + carrier="municipal solid waste", + e_nom=msw_biomass_potentials_spatial, + marginal_cost=0, # costs.at["municipal solid waste", "fuel"], + e_max_pu=e_max_pu, + e_initial=msw_biomass_potentials_spatial, + ) + n.madd( "Bus", spatial.gas.biogas, @@ -2284,12 +2314,6 @@ def add_biomass(n, costs): unit="MWh_LHV", ) - n.madd( - "Bus", - spatial.msw.nodes, - location=spatial.msw.locations, - carrier="municipal solid waste", - ) n.madd( "Store", @@ -2358,18 +2382,8 @@ def add_biomass(n, costs): * costs.at["solid biomass", "CO2 intensity"], p_nom_extendable=True, ) - - e_max_pu = pd.Series([1] * (len(n.snapshots) - 1) + [0], index=n.snapshots) - n.madd( - "Store", - spatial.msw.nodes, - bus=spatial.msw.nodes, - carrier="municipal solid waste", - e_nom=msw_biomass_potentials_spatial, - marginal_cost=0, # costs.at["municipal solid waste", "fuel"], - e_max_pu=e_max_pu, - e_initial=msw_biomass_potentials_spatial, - ) + + n.madd( "Link", @@ -2441,18 +2455,19 @@ def add_biomass(n, costs): marginal_cost=biomass_transport.costs * biomass_transport.length.values, carrier="solid biomass transport", ) - - n.madd( - "Link", - biomass_transport.index, - bus0=biomass_transport.bus0 + " municipal solid waste", - bus1=biomass_transport.bus1 + " municipal solid waste", - p_nom_extendable=False, - p_nom=5e4, - length=biomass_transport.length.values, - marginal_cost=biomass_transport.costs * biomass_transport.length.values, - carrier="municipal solid waste transport", - ) + + if options["municipal_solid_waste"]: + n.madd( + "Link", + biomass_transport.index, + bus0=biomass_transport.bus0 + " municipal solid waste", + bus1=biomass_transport.bus1 + " municipal solid waste", + p_nom_extendable=False, + p_nom=5e4, + length=biomass_transport.length.values, + marginal_cost=biomass_transport.costs * biomass_transport.length.values, + carrier="municipal solid waste transport", + ) elif options["biomass_spatial"]: # add artificial biomass generators at nodes which include transport costs @@ -2482,25 +2497,26 @@ def add_biomass(n, costs): constant=biomass_potentials["solid biomass"].sum(), type="operational_limit", ) - - # Add municipal solid waste - n.madd( - "Generator", - spatial.msw.nodes, - bus=spatial.msw.nodes, - carrier="municipal solid waste", - p_nom=10000, - marginal_cost=0 # costs.at["municipal solid waste", "fuel"] - + bus_transport_costs * average_distance, - ) - n.add( - "GlobalConstraint", - "msw limit", - carrier_attribute="municipal solid waste", - sense="<=", - constant=biomass_potentials["municipal solid waste"].sum(), - type="operational_limit", - ) + + if options["municipal_solid_waste"]: + # Add municipal solid waste + n.madd( + "Generator", + spatial.msw.nodes, + bus=spatial.msw.nodes, + carrier="municipal solid waste", + p_nom=10000, + marginal_cost=0 # costs.at["municipal solid waste", "fuel"] + + bus_transport_costs * average_distance, + ) + n.add( + "GlobalConstraint", + "msw limit", + carrier_attribute="municipal solid waste", + sense="<=", + constant=biomass_potentials["municipal solid waste"].sum(), + type="operational_limit", + ) # AC buses with district heating urban_central = n.buses.index[n.buses.carrier == "urban central heat"] @@ -3207,7 +3223,7 @@ def add_industry(n, costs): efficiency3=process_co2_per_naphtha, ) - if options.get("biomass", True): + if options.get("biomass", True) and options["municipal_solid_waste"]: n.madd( "Link", spatial.msw.locations, @@ -4110,7 +4126,7 @@ if __name__ == "__main__": "prepare_sector_network", simpl="", opts="", - clusters="1", + clusters="37", ll="vopt", sector_opts="", planning_horizons="2050", From 69f51ec7d6e30ccc63d900aa61952c355fba1480 Mon Sep 17 00:00:00 2001 From: lisazeyen Date: Mon, 5 Aug 2024 10:45:57 +0200 Subject: [PATCH 67/79] add release notes and doc for new config settings --- doc/configtables/sector.csv | 323 ++++++++++++++++++------------------ doc/release_notes.rst | 4 +- 2 files changed, 165 insertions(+), 162 deletions(-) diff --git a/doc/configtables/sector.csv b/doc/configtables/sector.csv index c96aa629..9cf5a504 100644 --- a/doc/configtables/sector.csv +++ b/doc/configtables/sector.csv @@ -1,161 +1,162 @@ -,Unit,Values,Description -transport,--,"{true, false}",Flag to include transport sector. -heating,--,"{true, false}",Flag to include heating sector. -biomass,--,"{true, false}",Flag to include biomass sector. -industry,--,"{true, false}",Flag to include industry sector. -agriculture,--,"{true, false}",Flag to include agriculture sector. -fossil_fuels,--,"{true, false}","Flag to include imports of fossil fuels ( [""coal"", ""gas"", ""oil"", ""lignite""])" -district_heating,--,,`prepare_sector_network.py `_ --- potential,--,float,maximum fraction of urban demand which can be supplied by district heating --- progress,--,Dictionary with planning horizons as keys., Increase of today's district heating demand to potential maximum district heating share. Progress = 0 means today's district heating share. Progress = 1 means maximum fraction of urban demand is supplied by district heating --- district_heating_loss,--,float,Share increase in district heat demand in urban central due to heat losses -cluster_heat_buses,--,"{true, false}",Cluster residential and service heat buses in `prepare_sector_network.py `_ to one to save memory. -,,, -bev_dsm_restriction _value,--,float,Adds a lower state of charge (SOC) limit for battery electric vehicles (BEV) to manage its own energy demand (DSM). Located in `build_transport_demand.py `_. Set to 0 for no restriction on BEV DSM -bev_dsm_restriction _time,--,float,Time at which SOC of BEV has to be dsm_restriction_value -transport_heating _deadband_upper,°C,float,"The maximum temperature in the vehicle. At higher temperatures, the energy required for cooling in the vehicle increases." -transport_heating _deadband_lower,°C,float,"The minimum temperature in the vehicle. At lower temperatures, the energy required for heating in the vehicle increases." -,,, -ICE_lower_degree_factor,--,float,Share increase in energy demand in internal combustion engine (ICE) for each degree difference between the cold environment and the minimum temperature. -ICE_upper_degree_factor,--,float,Share increase in energy demand in internal combustion engine (ICE) for each degree difference between the hot environment and the maximum temperature. -EV_lower_degree_factor,--,float,Share increase in energy demand in electric vehicles (EV) for each degree difference between the cold environment and the minimum temperature. -EV_upper_degree_factor,--,float,Share increase in energy demand in electric vehicles (EV) for each degree difference between the hot environment and the maximum temperature. -bev_dsm,--,"{true, false}",Add the option for battery electric vehicles (BEV) to participate in demand-side management (DSM) -,,, -bev_availability,--,float,The share for battery electric vehicles (BEV) that are able to do demand side management (DSM) -bev_energy,--,float,The average size of battery electric vehicles (BEV) in MWh -bev_charge_efficiency,--,float,Battery electric vehicles (BEV) charge and discharge efficiency -bev_charge_rate,MWh,float,The power consumption for one electric vehicle (EV) in MWh. Value derived from 3-phase charger with 11 kW. -bev_avail_max,--,float,The maximum share plugged-in availability for passenger electric vehicles. -bev_avail_mean,--,float,The average share plugged-in availability for passenger electric vehicles. -v2g,--,"{true, false}",Allows feed-in to grid from EV battery -land_transport_fuel_cell _share,--,Dictionary with planning horizons as keys.,The share of vehicles that uses fuel cells in a given year -land_transport_electric _share,--,Dictionary with planning horizons as keys.,The share of vehicles that uses electric vehicles (EV) in a given year -land_transport_ice _share,--,Dictionary with planning horizons as keys.,The share of vehicles that uses internal combustion engines (ICE) in a given year. What is not EV or FCEV is oil-fuelled ICE. -transport_electric_efficiency,MWh/100km,float,The conversion efficiencies of electric vehicles in transport -transport_fuel_cell_efficiency,MWh/100km,float,The H2 conversion efficiencies of fuel cells in transport -transport_ice_efficiency,MWh/100km,float,The oil conversion efficiencies of internal combustion engine (ICE) in transport -agriculture_machinery _electric_share,--,float,The share for agricultural machinery that uses electricity -agriculture_machinery _oil_share,--,float,The share for agricultural machinery that uses oil -agriculture_machinery _fuel_efficiency,--,float,The efficiency of electric-powered machinery in the conversion of electricity to meet agricultural needs. -agriculture_machinery _electric_efficiency,--,float,The efficiency of oil-powered machinery in the conversion of oil to meet agricultural needs. -Mwh_MeOH_per_MWh_H2,LHV,float,"The energy amount of the produced methanol per energy amount of hydrogen. From `DECHEMA (2017) `_, page 64." -MWh_MeOH_per_tCO2,LHV,float,"The energy amount of the produced methanol per ton of CO2. From `DECHEMA (2017) `_, page 66." -MWh_MeOH_per_MWh_e,LHV,float,"The energy amount of the produced methanol per energy amount of electricity. From `DECHEMA (2017) `_, page 64." -shipping_hydrogen _liquefaction,--,"{true, false}",Whether to include liquefaction costs for hydrogen demand in shipping. -,,, -shipping_hydrogen_share,--,Dictionary with planning horizons as keys.,The share of ships powered by hydrogen in a given year -shipping_methanol_share,--,Dictionary with planning horizons as keys.,The share of ships powered by methanol in a given year -shipping_oil_share,--,Dictionary with planning horizons as keys.,The share of ships powered by oil in a given year -shipping_methanol _efficiency,--,float,The efficiency of methanol-powered ships in the conversion of methanol to meet shipping needs (propulsion). The efficiency increase from oil can be 10-15% higher according to the `IEA `_ -,,, -shipping_oil_efficiency,--,float,The efficiency of oil-powered ships in the conversion of oil to meet shipping needs (propulsion). Base value derived from 2011 -aviation_demand_factor,--,float,The proportion of demand for aviation compared to today's consumption -HVC_demand_factor,--,float,The proportion of demand for high-value chemicals compared to today's consumption -,,, -time_dep_hp_cop,--,"{true, false}",Consider the time dependent coefficient of performance (COP) of the heat pump -heat_pump_sink_T,°C,float,The temperature heat sink used in heat pumps based on DTU / large area radiators. The value is conservatively high to cover hot water and space heating in poorly-insulated buildings -reduce_space_heat _exogenously,--,"{true, false}",Influence on space heating demand by a certain factor (applied before losses in district heating). -reduce_space_heat _exogenously_factor,--,Dictionary with planning horizons as keys.,"A positive factor can mean renovation or demolition of a building. If the factor is negative, it can mean an increase in floor area, increased thermal comfort, population growth. The default factors are determined by the `Eurocalc Homes and buildings decarbonization scenario `_" -retrofitting,,, --- retro_endogen,--,"{true, false}",Add retrofitting as an endogenous system which co-optimise space heat savings. --- cost_factor,--,float,Weight costs for building renovation --- interest_rate,--,float,The interest rate for investment in building components --- annualise_cost,--,"{true, false}",Annualise the investment costs of retrofitting --- tax_weighting,--,"{true, false}",Weight the costs of retrofitting depending on taxes in countries --- construction_index,--,"{true, false}",Weight the costs of retrofitting depending on labour/material costs per country -tes,--,"{true, false}",Add option for storing thermal energy in large water pits associated with district heating systems and individual thermal energy storage (TES) -tes_tau,,,The time constant used to calculate the decay of thermal energy in thermal energy storage (TES): 1- :math:`e^{-1/24τ}`. --- decentral,days,float,The time constant in decentralized thermal energy storage (TES) --- central,days,float,The time constant in centralized thermal energy storage (TES) -boilers,--,"{true, false}",Add option for transforming gas into heat using gas boilers -resistive_heaters,--,"{true, false}",Add option for transforming electricity into heat using resistive heaters (independently from gas boilers) -oil_boilers,--,"{true, false}",Add option for transforming oil into heat using boilers -biomass_boiler,--,"{true, false}",Add option for transforming biomass into heat using boilers -overdimension_individual_heating,--,"float",Add option for overdimensioning individual heating systems by a certain factor. This allows them to cover heat demand peaks e.g. 10% higher than those in the data with a setting of 1.1. -chp,--,"{true, false}",Add option for using Combined Heat and Power (CHP) -micro_chp,--,"{true, false}",Add option for using Combined Heat and Power (CHP) for decentral areas. -solar_thermal,--,"{true, false}",Add option for using solar thermal to generate heat. -solar_cf_correction,--,float,The correction factor for the value provided by the solar thermal profile calculations -marginal_cost_storage,currency/MWh ,float,The marginal cost of discharging batteries in distributed grids -methanation,--,"{true, false}",Add option for transforming hydrogen and CO2 into methane using methanation. -coal_cc,--,"{true, false}",Add option for coal CHPs with carbon capture -dac,--,"{true, false}",Add option for Direct Air Capture (DAC) -co2_vent,--,"{true, false}",Add option for vent out CO2 from storages to the atmosphere. -allam_cycle,--,"{true, false}",Add option to include `Allam cycle gas power plants `_ -hydrogen_fuel_cell,--,"{true, false}",Add option to include hydrogen fuel cell for re-electrification. Assuming OCGT technology costs -hydrogen_turbine,--,"{true, false}",Add option to include hydrogen turbine for re-electrification. Assuming OCGT technology costs -SMR,--,"{true, false}",Add option for transforming natural gas into hydrogen and CO2 using Steam Methane Reforming (SMR) -SMR CC,--,"{true, false}",Add option for transforming natural gas into hydrogen and CO2 using Steam Methane Reforming (SMR) and Carbon Capture (CC) -regional_methanol_demand,--,"{true, false}",Spatially resolve methanol demand. Set to true if regional CO2 constraints needed. -regional_oil_demand,--,"{true, false}",Spatially resolve oil demand. Set to true if regional CO2 constraints needed. -regional_co2 _sequestration_potential,,, --- enable,--,"{true, false}",Add option for regionally-resolved geological carbon dioxide sequestration potentials based on `CO2StoP `_. --- attribute,--,string or list,Name (or list of names) of the attribute(s) for the sequestration potential --- include_onshore,--,"{true, false}",Add options for including onshore sequestration potentials --- min_size,Gt ,float,Any sites with lower potential than this value will be excluded --- max_size,Gt ,float,The maximum sequestration potential for any one site. --- years_of_storage,years,float,The years until potential exhausted at optimised annual rate -co2_sequestration_potential,MtCO2/a,float,The potential of sequestering CO2 in Europe per year -co2_sequestration_cost,currency/tCO2,float,The cost of sequestering a ton of CO2 -co2_sequestration_lifetime,years,int,The lifetime of a CO2 sequestration site -co2_spatial,--,"{true, false}","Add option to spatially resolve carrier representing stored carbon dioxide. This allows for more detailed modelling of CCUTS, e.g. regarding the capturing of industrial process emissions, usage as feedstock for electrofuels, transport of carbon dioxide, and geological sequestration sites." -,,, -co2network,--,"{true, false}",Add option for planning a new carbon dioxide transmission network -co2_network_cost_factor,p.u.,float,The cost factor for the capital cost of the carbon dioxide transmission network -,,, -cc_fraction,--,float,The default fraction of CO2 captured with post-combustion capture -hydrogen_underground _storage,--,"{true, false}",Add options for storing hydrogen underground. Storage potential depends regionally. -hydrogen_underground _storage_locations,,"{onshore, nearshore, offshore}","The location where hydrogen underground storage can be located. Onshore, nearshore, offshore means it must be located more than 50 km away from the sea, within 50 km of the sea, or within the sea itself respectively." -,,, -ammonia,--,"{true, false, regional}","Add ammonia as a carrrier. It can be either true (copperplated NH3), false (no NH3 carrier) or ""regional"" (regionalised NH3 without network)" -min_part_load_fischer _tropsch,per unit of p_nom ,float,The minimum unit dispatch (``p_min_pu``) for the Fischer-Tropsch process -min_part_load _methanolisation,per unit of p_nom ,float,The minimum unit dispatch (``p_min_pu``) for the methanolisation process -,,, -use_fischer_tropsch _waste_heat,--,"{true, false}",Add option for using waste heat of Fischer Tropsch in district heating networks -use_fuel_cell_waste_heat,--,"{true, false}",Add option for using waste heat of fuel cells in district heating networks -use_electrolysis_waste _heat,--,"{true, false}",Add option for using waste heat of electrolysis in district heating networks -electricity_transmission _grid,--,"{true, false}",Switch for enabling/disabling the electricity transmission grid. -electricity_distribution _grid,--,"{true, false}",Add a simplified representation of the exchange capacity between transmission and distribution grid level through a link. -electricity_distribution _grid_cost_factor,,,Multiplies the investment cost of the electricity distribution grid -,,, -electricity_grid _connection,--,"{true, false}",Add the cost of electricity grid connection for onshore wind and solar -transmission_efficiency,,,Section to specify transmission losses or compression energy demands of bidirectional links. Splits them into two capacity-linked unidirectional links. --- {carrier},--,str,The carrier of the link. --- -- efficiency_static,p.u.,float,Length-independent transmission efficiency. --- -- efficiency_per_1000km,p.u. per 1000 km,float,Length-dependent transmission efficiency ($\eta^{\text{length}}$) --- -- compression_per_1000km,p.u. per 1000 km,float,Length-dependent electricity demand for compression ($\eta \cdot \text{length}$) implemented as multi-link to local electricity bus. -H2_network,--,"{true, false}",Add option for new hydrogen pipelines -gas_network,--,"{true, false}","Add existing natural gas infrastructure, incl. LNG terminals, production and entry-points. The existing gas network is added with a lossless transport model. A length-weighted `k-edge augmentation algorithm `_ can be run to add new candidate gas pipelines such that all regions of the model can be connected to the gas network. When activated, all the gas demands are regionally disaggregated as well." -H2_retrofit,--,"{true, false}",Add option for retrofiting existing pipelines to transport hydrogen. -H2_retrofit_capacity _per_CH4,--,float,"The ratio for H2 capacity per original CH4 capacity of retrofitted pipelines. The `European Hydrogen Backbone (April, 2020) p.15 `_ 60% of original natural gas capacity could be used in cost-optimal case as H2 capacity." -gas_network_connectivity _upgrade ,--,float,The number of desired edge connectivity (k) in the length-weighted `k-edge augmentation algorithm `_ used for the gas network -gas_distribution_grid,--,"{true, false}",Add a gas distribution grid -gas_distribution_grid _cost_factor,,,Multiplier for the investment cost of the gas distribution grid -,,, -biomass_spatial,--,"{true, false}",Add option for resolving biomass demand regionally -biomass_transport,--,"{true, false}",Add option for transporting solid biomass between nodes -biogas_upgrading_cc,--,"{true, false}",Add option to capture CO2 from biomass upgrading -conventional_generation,,,Add a more detailed description of conventional carriers. Any power generation requires the consumption of fuel from nodes representing that fuel. -biomass_to_liquid,--,"{true, false}",Add option for transforming solid biomass into liquid fuel with the same properties as oil -biosng,--,"{true, false}",Add option for transforming solid biomass into synthesis gas with the same properties as natural gas -limit_max_growth,,, --- enable,--,"{true, false}",Add option to limit the maximum growth of a carrier --- factor,p.u.,float,The maximum growth factor of a carrier (e.g. 1.3 allows 30% larger than max historic growth) --- max_growth,,, --- -- {carrier},GW,float,The historic maximum growth of a carrier --- max_relative_growth,,, --- -- {carrier},p.u.,float,The historic maximum relative growth of a carrier -,,, -enhanced_geothermal,,, --- enable,--,"{true, false}",Add option to include Enhanced Geothermal Systems --- flexible,--,"{true, false}",Add option for flexible operation (see Ricks et al. 2024) --- max_hours,--,int,The maximum hours the reservoir can be charged under flexible operation --- max_boost,--,float,The maximum boost in power output under flexible operation --- var_cf,--,"{true, false}",Add option for variable capacity factor (see Ricks et al. 2024) --- sustainability_factor,--,float,Share of sourced heat that is replenished by the earth's core (see details in `build_egs_potentials.py `_) -solid_biomass_import,,, --- enable,--,"{true, false}",Add option to include solid biomass imports --- price,currency/MWh,float,Price for importing solid biomass --- max_amount,Twh,float,Maximum solid biomass import potential --- upstream_emissions_factor,p.u.,float,Upstream emissions of solid biomass imports +,Unit,Values,Description +transport,--,"{true, false}",Flag to include transport sector. +heating,--,"{true, false}",Flag to include heating sector. +biomass,--,"{true, false}",Flag to include biomass sector. +industry,--,"{true, false}",Flag to include industry sector. +agriculture,--,"{true, false}",Flag to include agriculture sector. +fossil_fuels,--,"{true, false}","Flag to include imports of fossil fuels ( [""coal"", ""gas"", ""oil"", ""lignite""])" +district_heating,--,,`prepare_sector_network.py `_ +-- potential,--,float,maximum fraction of urban demand which can be supplied by district heating +-- progress,--,Dictionary with planning horizons as keys., Increase of today's district heating demand to potential maximum district heating share. Progress = 0 means today's district heating share. Progress = 1 means maximum fraction of urban demand is supplied by district heating +-- district_heating_loss,--,float,Share increase in district heat demand in urban central due to heat losses +cluster_heat_buses,--,"{true, false}",Cluster residential and service heat buses in `prepare_sector_network.py `_ to one to save memory. +,,, +bev_dsm_restriction _value,--,float,Adds a lower state of charge (SOC) limit for battery electric vehicles (BEV) to manage its own energy demand (DSM). Located in `build_transport_demand.py `_. Set to 0 for no restriction on BEV DSM +bev_dsm_restriction _time,--,float,Time at which SOC of BEV has to be dsm_restriction_value +transport_heating _deadband_upper,°C,float,"The maximum temperature in the vehicle. At higher temperatures, the energy required for cooling in the vehicle increases." +transport_heating _deadband_lower,°C,float,"The minimum temperature in the vehicle. At lower temperatures, the energy required for heating in the vehicle increases." +,,, +ICE_lower_degree_factor,--,float,Share increase in energy demand in internal combustion engine (ICE) for each degree difference between the cold environment and the minimum temperature. +ICE_upper_degree_factor,--,float,Share increase in energy demand in internal combustion engine (ICE) for each degree difference between the hot environment and the maximum temperature. +EV_lower_degree_factor,--,float,Share increase in energy demand in electric vehicles (EV) for each degree difference between the cold environment and the minimum temperature. +EV_upper_degree_factor,--,float,Share increase in energy demand in electric vehicles (EV) for each degree difference between the hot environment and the maximum temperature. +bev_dsm,--,"{true, false}",Add the option for battery electric vehicles (BEV) to participate in demand-side management (DSM) +,,, +bev_availability,--,float,The share for battery electric vehicles (BEV) that are able to do demand side management (DSM) +bev_energy,--,float,The average size of battery electric vehicles (BEV) in MWh +bev_charge_efficiency,--,float,Battery electric vehicles (BEV) charge and discharge efficiency +bev_charge_rate,MWh,float,The power consumption for one electric vehicle (EV) in MWh. Value derived from 3-phase charger with 11 kW. +bev_avail_max,--,float,The maximum share plugged-in availability for passenger electric vehicles. +bev_avail_mean,--,float,The average share plugged-in availability for passenger electric vehicles. +v2g,--,"{true, false}",Allows feed-in to grid from EV battery +land_transport_fuel_cell _share,--,Dictionary with planning horizons as keys.,The share of vehicles that uses fuel cells in a given year +land_transport_electric _share,--,Dictionary with planning horizons as keys.,The share of vehicles that uses electric vehicles (EV) in a given year +land_transport_ice _share,--,Dictionary with planning horizons as keys.,The share of vehicles that uses internal combustion engines (ICE) in a given year. What is not EV or FCEV is oil-fuelled ICE. +transport_electric_efficiency,MWh/100km,float,The conversion efficiencies of electric vehicles in transport +transport_fuel_cell_efficiency,MWh/100km,float,The H2 conversion efficiencies of fuel cells in transport +transport_ice_efficiency,MWh/100km,float,The oil conversion efficiencies of internal combustion engine (ICE) in transport +agriculture_machinery _electric_share,--,float,The share for agricultural machinery that uses electricity +agriculture_machinery _oil_share,--,float,The share for agricultural machinery that uses oil +agriculture_machinery _fuel_efficiency,--,float,The efficiency of electric-powered machinery in the conversion of electricity to meet agricultural needs. +agriculture_machinery _electric_efficiency,--,float,The efficiency of oil-powered machinery in the conversion of oil to meet agricultural needs. +Mwh_MeOH_per_MWh_H2,LHV,float,"The energy amount of the produced methanol per energy amount of hydrogen. From `DECHEMA (2017) `_, page 64." +MWh_MeOH_per_tCO2,LHV,float,"The energy amount of the produced methanol per ton of CO2. From `DECHEMA (2017) `_, page 66." +MWh_MeOH_per_MWh_e,LHV,float,"The energy amount of the produced methanol per energy amount of electricity. From `DECHEMA (2017) `_, page 64." +shipping_hydrogen _liquefaction,--,"{true, false}",Whether to include liquefaction costs for hydrogen demand in shipping. +,,, +shipping_hydrogen_share,--,Dictionary with planning horizons as keys.,The share of ships powered by hydrogen in a given year +shipping_methanol_share,--,Dictionary with planning horizons as keys.,The share of ships powered by methanol in a given year +shipping_oil_share,--,Dictionary with planning horizons as keys.,The share of ships powered by oil in a given year +shipping_methanol _efficiency,--,float,The efficiency of methanol-powered ships in the conversion of methanol to meet shipping needs (propulsion). The efficiency increase from oil can be 10-15% higher according to the `IEA `_ +,,, +shipping_oil_efficiency,--,float,The efficiency of oil-powered ships in the conversion of oil to meet shipping needs (propulsion). Base value derived from 2011 +aviation_demand_factor,--,float,The proportion of demand for aviation compared to today's consumption +HVC_demand_factor,--,float,The proportion of demand for high-value chemicals compared to today's consumption +,,, +time_dep_hp_cop,--,"{true, false}",Consider the time dependent coefficient of performance (COP) of the heat pump +heat_pump_sink_T,°C,float,The temperature heat sink used in heat pumps based on DTU / large area radiators. The value is conservatively high to cover hot water and space heating in poorly-insulated buildings +reduce_space_heat _exogenously,--,"{true, false}",Influence on space heating demand by a certain factor (applied before losses in district heating). +reduce_space_heat _exogenously_factor,--,Dictionary with planning horizons as keys.,"A positive factor can mean renovation or demolition of a building. If the factor is negative, it can mean an increase in floor area, increased thermal comfort, population growth. The default factors are determined by the `Eurocalc Homes and buildings decarbonization scenario `_" +retrofitting,,, +-- retro_endogen,--,"{true, false}",Add retrofitting as an endogenous system which co-optimise space heat savings. +-- cost_factor,--,float,Weight costs for building renovation +-- interest_rate,--,float,The interest rate for investment in building components +-- annualise_cost,--,"{true, false}",Annualise the investment costs of retrofitting +-- tax_weighting,--,"{true, false}",Weight the costs of retrofitting depending on taxes in countries +-- construction_index,--,"{true, false}",Weight the costs of retrofitting depending on labour/material costs per country +tes,--,"{true, false}",Add option for storing thermal energy in large water pits associated with district heating systems and individual thermal energy storage (TES) +tes_tau,,,The time constant used to calculate the decay of thermal energy in thermal energy storage (TES): 1- :math:`e^{-1/24τ}`. +-- decentral,days,float,The time constant in decentralized thermal energy storage (TES) +-- central,days,float,The time constant in centralized thermal energy storage (TES) +boilers,--,"{true, false}",Add option for transforming gas into heat using gas boilers +resistive_heaters,--,"{true, false}",Add option for transforming electricity into heat using resistive heaters (independently from gas boilers) +oil_boilers,--,"{true, false}",Add option for transforming oil into heat using boilers +biomass_boiler,--,"{true, false}",Add option for transforming biomass into heat using boilers +overdimension_individual_heating,--,float,Add option for overdimensioning individual heating systems by a certain factor. This allows them to cover heat demand peaks e.g. 10% higher than those in the data with a setting of 1.1. +chp,--,"{true, false}",Add option for using Combined Heat and Power (CHP) +micro_chp,--,"{true, false}",Add option for using Combined Heat and Power (CHP) for decentral areas. +solar_thermal,--,"{true, false}",Add option for using solar thermal to generate heat. +solar_cf_correction,--,float,The correction factor for the value provided by the solar thermal profile calculations +marginal_cost_storage,currency/MWh ,float,The marginal cost of discharging batteries in distributed grids +methanation,--,"{true, false}",Add option for transforming hydrogen and CO2 into methane using methanation. +coal_cc,--,"{true, false}",Add option for coal CHPs with carbon capture +dac,--,"{true, false}",Add option for Direct Air Capture (DAC) +co2_vent,--,"{true, false}",Add option for vent out CO2 from storages to the atmosphere. +allam_cycle,--,"{true, false}",Add option to include `Allam cycle gas power plants `_ +hydrogen_fuel_cell,--,"{true, false}",Add option to include hydrogen fuel cell for re-electrification. Assuming OCGT technology costs +hydrogen_turbine,--,"{true, false}",Add option to include hydrogen turbine for re-electrification. Assuming OCGT technology costs +SMR,--,"{true, false}",Add option for transforming natural gas into hydrogen and CO2 using Steam Methane Reforming (SMR) +SMR CC,--,"{true, false}",Add option for transforming natural gas into hydrogen and CO2 using Steam Methane Reforming (SMR) and Carbon Capture (CC) +regional_methanol_demand,--,"{true, false}",Spatially resolve methanol demand. Set to true if regional CO2 constraints needed. +regional_oil_demand,--,"{true, false}",Spatially resolve oil demand. Set to true if regional CO2 constraints needed. +regional_co2 _sequestration_potential,,, +-- enable,--,"{true, false}",Add option for regionally-resolved geological carbon dioxide sequestration potentials based on `CO2StoP `_. +-- attribute,--,string or list,Name (or list of names) of the attribute(s) for the sequestration potential +-- include_onshore,--,"{true, false}",Add options for including onshore sequestration potentials +-- min_size,Gt ,float,Any sites with lower potential than this value will be excluded +-- max_size,Gt ,float,The maximum sequestration potential for any one site. +-- years_of_storage,years,float,The years until potential exhausted at optimised annual rate +co2_sequestration_potential,MtCO2/a,float,The potential of sequestering CO2 in Europe per year +co2_sequestration_cost,currency/tCO2,float,The cost of sequestering a ton of CO2 +co2_sequestration_lifetime,years,int,The lifetime of a CO2 sequestration site +co2_spatial,--,"{true, false}","Add option to spatially resolve carrier representing stored carbon dioxide. This allows for more detailed modelling of CCUTS, e.g. regarding the capturing of industrial process emissions, usage as feedstock for electrofuels, transport of carbon dioxide, and geological sequestration sites." +,,, +co2network,--,"{true, false}",Add option for planning a new carbon dioxide transmission network +co2_network_cost_factor,p.u.,float,The cost factor for the capital cost of the carbon dioxide transmission network +,,, +cc_fraction,--,float,The default fraction of CO2 captured with post-combustion capture +hydrogen_underground _storage,--,"{true, false}",Add options for storing hydrogen underground. Storage potential depends regionally. +hydrogen_underground _storage_locations,,"{onshore, nearshore, offshore}","The location where hydrogen underground storage can be located. Onshore, nearshore, offshore means it must be located more than 50 km away from the sea, within 50 km of the sea, or within the sea itself respectively." +,,, +ammonia,--,"{true, false, regional}","Add ammonia as a carrrier. It can be either true (copperplated NH3), false (no NH3 carrier) or ""regional"" (regionalised NH3 without network)" +min_part_load_fischer _tropsch,per unit of p_nom ,float,The minimum unit dispatch (``p_min_pu``) for the Fischer-Tropsch process +min_part_load _methanolisation,per unit of p_nom ,float,The minimum unit dispatch (``p_min_pu``) for the methanolisation process +,,, +use_fischer_tropsch _waste_heat,--,"{true, false}",Add option for using waste heat of Fischer Tropsch in district heating networks +use_fuel_cell_waste_heat,--,"{true, false}",Add option for using waste heat of fuel cells in district heating networks +use_electrolysis_waste _heat,--,"{true, false}",Add option for using waste heat of electrolysis in district heating networks +electricity_transmission _grid,--,"{true, false}",Switch for enabling/disabling the electricity transmission grid. +electricity_distribution _grid,--,"{true, false}",Add a simplified representation of the exchange capacity between transmission and distribution grid level through a link. +electricity_distribution _grid_cost_factor,,,Multiplies the investment cost of the electricity distribution grid +,,, +electricity_grid _connection,--,"{true, false}",Add the cost of electricity grid connection for onshore wind and solar +transmission_efficiency,,,Section to specify transmission losses or compression energy demands of bidirectional links. Splits them into two capacity-linked unidirectional links. +-- {carrier},--,str,The carrier of the link. +-- -- efficiency_static,p.u.,float,Length-independent transmission efficiency. +-- -- efficiency_per_1000km,p.u. per 1000 km,float,Length-dependent transmission efficiency ($\eta^{\text{length}}$) +-- -- compression_per_1000km,p.u. per 1000 km,float,Length-dependent electricity demand for compression ($\eta \cdot \text{length}$) implemented as multi-link to local electricity bus. +H2_network,--,"{true, false}",Add option for new hydrogen pipelines +gas_network,--,"{true, false}","Add existing natural gas infrastructure, incl. LNG terminals, production and entry-points. The existing gas network is added with a lossless transport model. A length-weighted `k-edge augmentation algorithm `_ can be run to add new candidate gas pipelines such that all regions of the model can be connected to the gas network. When activated, all the gas demands are regionally disaggregated as well." +H2_retrofit,--,"{true, false}",Add option for retrofiting existing pipelines to transport hydrogen. +H2_retrofit_capacity _per_CH4,--,float,"The ratio for H2 capacity per original CH4 capacity of retrofitted pipelines. The `European Hydrogen Backbone (April, 2020) p.15 `_ 60% of original natural gas capacity could be used in cost-optimal case as H2 capacity." +gas_network_connectivity _upgrade ,--,float,The number of desired edge connectivity (k) in the length-weighted `k-edge augmentation algorithm `_ used for the gas network +gas_distribution_grid,--,"{true, false}",Add a gas distribution grid +gas_distribution_grid _cost_factor,,,Multiplier for the investment cost of the gas distribution grid +,,, +biomass_spatial,--,"{true, false}",Add option for resolving biomass demand regionally +biomass_transport,--,"{true, false}",Add option for transporting solid biomass between nodes +biogas_upgrading_cc,--,"{true, false}",Add option to capture CO2 from biomass upgrading +conventional_generation,,,Add a more detailed description of conventional carriers. Any power generation requires the consumption of fuel from nodes representing that fuel. +biomass_to_liquid,--,"{true, false}",Add option for transforming solid biomass into liquid fuel with the same properties as oil +biosng,--,"{true, false}",Add option for transforming solid biomass into synthesis gas with the same properties as natural gas +municipal_solid_waste,--,"{true, false}",Add option for municipal solid waste +limit_max_growth,,, +-- enable,--,"{true, false}",Add option to limit the maximum growth of a carrier +-- factor,p.u.,float,The maximum growth factor of a carrier (e.g. 1.3 allows 30% larger than max historic growth) +-- max_growth,,, +-- -- {carrier},GW,float,The historic maximum growth of a carrier +-- max_relative_growth,,, +-- -- {carrier},p.u.,float,The historic maximum relative growth of a carrier +,,, +enhanced_geothermal,,, +-- enable,--,"{true, false}",Add option to include Enhanced Geothermal Systems +-- flexible,--,"{true, false}",Add option for flexible operation (see Ricks et al. 2024) +-- max_hours,--,int,The maximum hours the reservoir can be charged under flexible operation +-- max_boost,--,float,The maximum boost in power output under flexible operation +-- var_cf,--,"{true, false}",Add option for variable capacity factor (see Ricks et al. 2024) +-- sustainability_factor,--,float,Share of sourced heat that is replenished by the earth's core (see details in `build_egs_potentials.py `_) +solid_biomass_import,,, +-- enable,--,"{true, false}",Add option to include solid biomass imports +-- price,currency/MWh,float,Price for importing solid biomass +-- max_amount,Twh,float,Maximum solid biomass import potential +-- upstream_emissions_factor,p.u.,float,Upstream emissions of solid biomass imports diff --git a/doc/release_notes.rst b/doc/release_notes.rst index d2453bb1..355e516a 100644 --- a/doc/release_notes.rst +++ b/doc/release_notes.rst @@ -10,9 +10,11 @@ Release Notes Upcoming Release ================ +* split solid biomass potentials into solid biomass and municipal solid waste. Add option to use municipal solid waste. This option is only activated in combination with the flag ``waste_to_energy`` + * Add option to import solid biomass -* Add option to produce electrobiofuels (flag ``electrobiofuels`) from solid biomass and hydrogen, as a combination of BtL and Fischer-Tropsch to make more use of the biogenic carbon +* Add option to produce electrobiofuels (flag ``electrobiofuels``) from solid biomass and hydrogen, as a combination of BtL and Fischer-Tropsch to make more use of the biogenic carbon * Add flag ``sector: fossil_fuels`` in config to remove the option of importing fossil fuels From e0b5fe9048f6dd597fdb52b5108405f6509b9dde Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 5 Aug 2024 08:46:28 +0000 Subject: [PATCH 68/79] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- scripts/prepare_sector_network.py | 36 ++++++++++++++++--------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index fdded30a..081ada58 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -2266,26 +2266,31 @@ def add_biomass(n, costs): n.add("Carrier", "biogas") n.add("Carrier", "solid biomass") - - - if (options["municipal_solid_waste"] and not options["industry"] - and cf_industry["waste_to_energy"] or cf_industry["waste_to_energy_cc"]): - logger.warning("Flag municipal_solid_waste can be only used with industry " - "sector waste to energy." - "Setting municipal_solid_waste=False.") + + if ( + options["municipal_solid_waste"] + and not options["industry"] + and cf_industry["waste_to_energy"] + or cf_industry["waste_to_energy_cc"] + ): + logger.warning( + "Flag municipal_solid_waste can be only used with industry " + "sector waste to energy." + "Setting municipal_solid_waste=False." + ) options["municipal_solid_waste"] = False - + if options["municipal_solid_waste"]: - + n.add("Carrier", "municipal solid waste") - + n.madd( "Bus", spatial.msw.nodes, location=spatial.msw.locations, carrier="municipal solid waste", ) - + e_max_pu = pd.Series([1] * (len(n.snapshots) - 1) + [0], index=n.snapshots) n.madd( "Store", @@ -2297,7 +2302,7 @@ def add_biomass(n, costs): e_max_pu=e_max_pu, e_initial=msw_biomass_potentials_spatial, ) - + n.madd( "Bus", spatial.gas.biogas, @@ -2314,7 +2319,6 @@ def add_biomass(n, costs): unit="MWh_LHV", ) - n.madd( "Store", spatial.gas.biogas, @@ -2382,8 +2386,6 @@ def add_biomass(n, costs): * costs.at["solid biomass", "CO2 intensity"], p_nom_extendable=True, ) - - n.madd( "Link", @@ -2455,7 +2457,7 @@ def add_biomass(n, costs): marginal_cost=biomass_transport.costs * biomass_transport.length.values, carrier="solid biomass transport", ) - + if options["municipal_solid_waste"]: n.madd( "Link", @@ -2497,7 +2499,7 @@ def add_biomass(n, costs): constant=biomass_potentials["solid biomass"].sum(), type="operational_limit", ) - + if options["municipal_solid_waste"]: # Add municipal solid waste n.madd( From 813e54555a75191ab546aaefe86747325bd56ac8 Mon Sep 17 00:00:00 2001 From: Bobby Xiong <36541459+bobbyxng@users.noreply.github.com> Date: Mon, 5 Aug 2024 11:18:02 +0200 Subject: [PATCH 69/79] Corrected Moyle Interconnector capacity in links_p_nom.csv to 500 MW (#1199) --- data/links_p_nom.csv | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/links_p_nom.csv b/data/links_p_nom.csv index bd7a4c95..56a99e52 100644 --- a/data/links_p_nom.csv +++ b/data/links_p_nom.csv @@ -5,7 +5,7 @@ Cross-Channel,France - Echingen 50°41′48″N 1°38′21″E / 50.69667 Volgograd-Donbass,Russia - Volzhskaya 48°49′34″N 44°40′20″E / 48.82611°N 44.67222°E,Ukraine - Mikhailovskaya 48°39′13″N 38°33′56″E / 48.65361°N 38.56556°E,475(0/475),400,750.0,1965,Merc/Thyr,Shut down in 2014,[1],44.672222222222224,48.82611111111111,38.565555555555555,48.65361111111111 Konti-Skan 1,Denmark - Vester Hassing 57°3′46″N 10°5′24″E / 57.06278°N 10.09000°E,Sweden - Stenkullen 57°48′15″N 12°19′13″E / 57.80417°N 12.32028°E,176(87/89),250,250.0,1965,Merc,Replaced in August 2006 by modern converters using thyristors,[1],10.09,57.062777777777775,12.320277777777777,57.80416666666667 SACOI 1a,Italy - Suvereto 43°3′10″N 10°41′42″E / 43.05278°N 10.69500°E ( before 1992: Italy - San Dalmazio 43°15′43″N 10°55′05″E / 43.26194°N 10.91806°E),"France- Lucciana 42°31′40″N 9°26′59″E / 42.52778°N 9.44972°E",483(365/118),200,200.0,1965,Merc,"Replaced in 1986 by Thyr- multiterminal scheme",[1],10.695,43.05277777777778,9.449722222222222,42.52777777777778 -SACOI 1b,"France- Lucciana 42°31′40″N 9°26′59″E / 42.52778°N 9.44972°E", "Codrongianos- Italy 40°39′7″N 8°42′48″E / 40.65194°N 8.71333°E",483(365/118),200,200.0,1965,Merc,"Replaced in 1986 by Thyr- multiterminal scheme",[1],9.449722222222222,42.52777777777778,8.679351,40.65765 +SACOI 1b,"France- Lucciana 42°31′40″N 9°26′59″E / 42.52778°N 9.44972°E","Codrongianos- Italy 40°39′7″N 8°42′48″E / 40.65194°N 8.71333°E",483(365/118),200,200.0,1965,Merc,"Replaced in 1986 by Thyr- multiterminal scheme",[1],9.449722222222222,42.52777777777778,8.679351,40.65765 Kingsnorth,UK - Kingsnorth 51°25′11″N 0°35′46″E / 51.41972°N 0.59611°E,UK - London-Beddington 51°22′23″N 0°7′38″W / 51.37306°N 0.12722°W,85(85/0),266,320.0,1975,Merc,Bipolar scheme Supplier: English Electric Shut down in 1987,[33],0.5961111111111111,51.41972222222222,-0.1272222222222222,51.37305555555555 Skagerrak 1 + 2,Denmark - Tjele 56°28′44″N 9°34′1″E / 56.47889°N 9.56694°E,Norway - Kristiansand 58°15′36″N 7°53′55″E / 58.26000°N 7.89861°E,230(130/100),250,500.0,1977,Thyr,Supplier: STK(Nexans) Control system upgrade by ABB in 2007,[34][35][36],9.566944444444445,56.47888888888889,7.898611111111111,58.26 Gotland 2,Sweden - Västervik 57°43′41″N 16°38′51″E / 57.72806°N 16.64750°E,Sweden - Yigne 57°35′13″N 18°11′44″E / 57.58694°N 18.19556°E,99.5(92.9/6.6),150,130.0,1983,Thyr,Supplier: ABB,,16.6475,57.72805555555556,18.195555555555554,57.58694444444444 @@ -23,7 +23,7 @@ Visby-Nas,Sweden - Nas 57°05′58″N 18°14′27″E / 57.09944°N 18.24 SwePol,Poland - Wierzbięcin 54°30′8″N 16°53′28″E / 54.50222°N 16.89111°E,Sweden - Stärnö 56°9′11″N 14°50′29″E / 56.15306°N 14.84139°E,245(245/0),450,600.0,2000,Thyr,Supplier: ABB,[38],16.891111111111112,54.50222222222222,14.841388888888888,56.153055555555554 Tjæreborg,Denmark - Tjæreborg/Enge 55°26′52″N 8°35′34″E / 55.44778°N 8.59278°E,Denmark - Tjæreborg/Substation 55°28′07″N 8°33′36″E / 55.46861°N 8.56000°E,4.3(4.3/0),9,7.0,2000,IGBT,Interconnection to wind power generating stations,,8.592777777777778,55.44777777777778,8.56,55.46861111111111 Italy-Greece,Greece - Arachthos 39°11′00″N 20°57′48″E / 39.18333°N 20.96333°E,Italy - Galatina 40°9′53″N 18°7′49″E / 40.16472°N 18.13028°E,310(200/110),400,500.0,2001,Thyr,,,20.963333333333335,39.18333333333333,18.130277777777778,40.164722222222224 -Moyle,UK - Auchencrosh 55°04′10″N 4°58′50″W / 55.06944°N 4.98056°W,UK - N. Ireland- Ballycronan More 54°50′34″N 5°46′11″W / 54.84278°N 5.76972°W,63.5(63.5/0),250,2501.0,2001,Thyr,"Supplier: Siemens- Nexans",[39],-4.980555555555556,55.06944444444444,-5.769722222222223,54.842777777777776 +Moyle,UK - Auchencrosh 55°04′10″N 4°58′50″W / 55.06944°N 4.98056°W,UK - N. Ireland- Ballycronan More 54°50′34″N 5°46′11″W / 54.84278°N 5.76972°W,63.5(63.5/0),250,500.0,2001,Thyr,"Supplier: Siemens- Nexans",[39],-4.980555555555556,55.06944444444444,-5.769722222222223,54.842777777777776 HVDC Troll,Norway - Kollsnes 60°33′01″N 4°50′26″E / 60.55028°N 4.84056°E,Norway - Offshore platform Troll A 60°40′00″N 3°40′00″E / 60.66667°N 3.66667°E,70(70/0),60,80.0,2004,IGBT,Power supply for offshore gas compressor Supplier: ABB,[40],4.8405555555555555,60.55027777777778,3.6666666666666665,60.666666666666664 Estlink,Finland - Espoo 60°12′14″N 24°33′06″E / 60.20389°N 24.55167°E,Estonia - Harku 59°23′5″N 24°33′37″E / 59.38472°N 24.56028°E,105(105/0),150,350.0,2006,IGBT,Supplier: ABB,[40],24.551666666666666,60.20388888888889,24.560277777777777,59.38472222222222 NorNed,Netherlands - Eemshaven 53°26′4″N 6°51′57″E / 53.43444°N 6.86583°E,Norway - Feda 58°16′58″N 6°51′55″E / 58.28278°N 6.86528°E,580(580/0),450,700.0,2008,Thyr,"Supplier: ABB- Nexans",[40],6.865833333333334,53.434444444444445,6.865277777777778,58.28277777777778 From 5362c376966bdb7b996040ae6850f9154c634e27 Mon Sep 17 00:00:00 2001 From: AmosSchledorn Date: Mon, 5 Aug 2024 11:27:52 +0200 Subject: [PATCH 70/79] update myopic mode to heat system declarations --- rules/solve_myopic.smk | 14 +-- scripts/add_existing_baseyear.py | 172 +++++++++++++----------------- scripts/enums/HeatSystem.py | 40 ++++++- scripts/prepare_sector_network.py | 5 +- 4 files changed, 118 insertions(+), 113 deletions(-) diff --git a/rules/solve_myopic.smk b/rules/solve_myopic.smk index 09f25b24..8d7fa284 100644 --- a/rules/solve_myopic.smk +++ b/rules/solve_myopic.smk @@ -69,6 +69,7 @@ rule add_brownfield: snapshots=config_provider("snapshots"), drop_leap_day=config_provider("enable", "drop_leap_day"), carriers=config_provider("electricity", "renewable_carriers"), + heat_pump_sources=config_provider("sector", "heat_pump_sources"), input: unpack(input_profile_tech_brownfield), simplify_busmap=resources("busmap_elec_s{simpl}.csv"), @@ -77,18 +78,7 @@ rule add_brownfield: + "prenetworks/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.nc", network_p=solved_previous_horizon, #solved network at previous time step costs=resources("costs_{planning_horizons}.csv"), - cop_soil_decentral_heating=resources( - "cop_soil_decentral_heating_elec_s{simpl}_{clusters}.nc" - ), - cop_air_decentral_heating=resources( - "cop_air_decentral_heating_elec_s{simpl}_{clusters}.nc" - ), - cop_air_central_heating=resources( - "cop_air_central_heating_elec_s{simpl}_{clusters}.nc" - ), - cop_soil_central_heating=resources( - "cop_soil_central_heating_elec_s{simpl}_{clusters}.nc" - ), + cop_profiles=resources("cop_profiles_elec_s{simpl}_{clusters}.nc"), output: RESULTS + "prenetworks-brownfield/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.nc", diff --git a/scripts/add_existing_baseyear.py b/scripts/add_existing_baseyear.py index 6edc7b7b..1c620989 100644 --- a/scripts/add_existing_baseyear.py +++ b/scripts/add_existing_baseyear.py @@ -438,8 +438,8 @@ def add_heating_capacities_installed_before_baseyear( currently assumed heating capacities split between residential and services proportional to heating load in both 50% capacities in rural buses 50% in urban buses - cop: dict - Dictionary with time-dependent coefficients of performance (COPs) for air and ground heat pumps as values and keys "air decentral", "ground decentral", "air central", "ground central" + cop: xr.DataArray + DataArray with time-dependent coefficients of performance (COPs) heat pumps. Coordinates are heat sources (see config), heat system types (see :file:`scripts/enums/HeatSystemType.py`), nodes and snapshots. time_dep_hp_cop: bool If True, time-dependent (dynamic) COPs are used for heat pumps """ @@ -452,66 +452,65 @@ def add_heating_capacities_installed_before_baseyear( n.buses.location[n.buses.index.str.contains(f"{heat_system} heat")] ) - if (not heat_system.is_central) and options["electricity_distribution_grid"]: + if (not heat_system == HeatSystem.URBAN_CENTRAL) and options["electricity_distribution_grid"]: nodes_elec = nodes + " low voltage" else: nodes_elec = nodes - # Add heat pumps - heat_source = snakemake.params.heat_pump_sources[heat_system.system_type.value] - costs_name = f"{heat_system.system_type} {heat_source}-sourced heat pump" - - efficiency = ( - cop.sel(heat_system=heat_system.system_type.value, heat_source=heat_source, name=nodes) - .to_pandas() - .reindex(index=n.snapshots) - if options["time_dep_hp_cop"] - else costs.at[costs_name, "efficiency"] - ) - - too_large_grouping_years = [gy for gy in grouping_years if gy >= int(baseyear)] - if too_large_grouping_years: - logger.warning( - f"Grouping years >= baseyear are ignored. Dropping {too_large_grouping_years}." + too_large_grouping_years = [gy for gy in grouping_years if gy >= int(baseyear)] + if too_large_grouping_years: + logger.warning( + f"Grouping years >= baseyear are ignored. Dropping {too_large_grouping_years}." + ) + 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) + ] ) - 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) - ] - ) - assert valid_grouping_years.is_monotonic_increasing + assert valid_grouping_years.is_monotonic_increasing - # get number of years of each interval - _years = valid_grouping_years.diff() - # Fill NA from .diff() with value for the first interval - _years[0] = valid_grouping_years[0] - baseyear + default_lifetime - # Installation is assumed to be linear for the past - ratios = _years / _years.sum() + # get number of years of each interval + _years = valid_grouping_years.diff() + # Fill NA from .diff() with value for the first interval + _years[0] = valid_grouping_years[0] - baseyear + default_lifetime + # Installation is assumed to be linear for the past + ratios = _years / _years.sum() for ratio, grouping_year in zip(ratios, valid_grouping_years): + # Add heat pumps + for heat_source in snakemake.params.heat_pump_sources[heat_system.system_type.value]: + costs_name = heat_system.heat_pump_costs_name(heat_source) - n.madd( - "Link", - nodes, - suffix=f" {heat_system} {heat_source} heat pump-{grouping_year}", - bus0=nodes_elec, - bus1=nodes + " " + heat_system.value + " heat", - carrier=f"{heat_system} {heat_source} heat pump", - efficiency=efficiency, - capital_cost=costs.at[costs_name, "efficiency"] - * costs.at[costs_name, "fixed"], - p_nom=existing_heating.loc[ - nodes, (heat_system.value, f"{heat_source} heat pump") - ] - * ratio - / costs.at[costs_name, "efficiency"], - build_year=int(grouping_year), - lifetime=costs.at[costs_name, "lifetime"], - ) + efficiency = ( + cop.sel(heat_system=heat_system.system_type.value, heat_source=heat_source, name=nodes) + .to_pandas() + .reindex(index=n.snapshots) + if options["time_dep_hp_cop"] + else costs.at[costs_name, "efficiency"] + ) + + n.madd( + "Link", + nodes, + suffix=f" {heat_system} {heat_source} heat pump-{grouping_year}", + bus0=nodes_elec, + bus1=nodes + " " + heat_system.value + " heat", + carrier=f"{heat_system} {heat_source} heat pump", + efficiency=efficiency, + capital_cost=costs.at[costs_name, "efficiency"] + * costs.at[costs_name, "fixed"], + p_nom=existing_heating.loc[ + nodes, (heat_system.value, f"{heat_source} heat pump") + ] + * ratio + / costs.at[costs_name, "efficiency"], + build_year=int(grouping_year), + lifetime=costs.at[costs_name, "lifetime"], + ) # add resistive heater, gas boilers and oil boilers n.madd( @@ -520,42 +519,42 @@ def add_heating_capacities_installed_before_baseyear( suffix=f" {heat_system} resistive heater-{grouping_year}", bus0=nodes_elec, bus1=nodes + " " + heat_system.value + " heat", - carrier=heat_system + " resistive heater", - efficiency=costs.at[f"{heat_system.system_type} resistive heater", "efficiency"], + carrier=heat_system.value + " resistive heater", + efficiency=costs.at[heat_system.resistive_heater_costs_name, "efficiency"], capital_cost=( - costs.at[f"{heat_system.system_type} resistive heater", "efficiency"] - * costs.at[f"{heat_system.system_type} resistive heater", "fixed"] + costs.at[heat_system.resistive_heater_costs_name, "efficiency"] + * costs.at[heat_system.resistive_heater_costs_name, "fixed"] ), p_nom=( existing_heating.loc[nodes, (heat_system.value, "resistive heater")] * ratio - / costs.at[f"{heat_system.system_type} resistive heater", "efficiency"] + / costs.at[heat_system.resistive_heater_costs_name, "efficiency"] ), build_year=int(grouping_year), - lifetime=costs.at[f"{heat_system.system_type} resistive heater", "lifetime"], + lifetime=costs.at[heat_system.resistive_heater_costs_name, "lifetime"], ) n.madd( "Link", nodes, - suffix=f" {heat_system} gas boiler-{grouping_year}", + suffix=f"{heat_system} gas boiler-{grouping_year}", bus0="EU gas" if "EU gas" in spatial.gas.nodes else nodes + " gas", - bus1=nodes + " " + heat_system + " heat", + bus1=f"{nodes} {heat_system} heat", bus2="co2 atmosphere", - carrier=heat_system + " gas boiler", - efficiency=costs.at[f"{heat_system.system_type} gas boiler", "efficiency"], + carrier=heat_system.value + " gas boiler", + efficiency=costs.at[heat_system.gas_boiler_costs_name, "efficiency"], efficiency2=costs.at["gas", "CO2 intensity"], capital_cost=( - costs.at[f"{heat_system.system_type} gas boiler", "efficiency"] - * costs.at[f"{heat_system.system_type} gas boiler", "fixed"] + costs.at[heat_system.gas_boiler_costs_name, "efficiency"] + * costs.at[heat_system.gas_boiler_costs_name, "fixed"] ), p_nom=( - existing_heating.loc[nodes, (heat_system, "gas boiler")] + existing_heating.loc[nodes, (heat_system.value, "gas boiler")] * ratio - / costs.at[f"{heat_system.system_type} gas boiler", "efficiency"] + / costs.at[heat_system.gas_boiler_costs_name, "efficiency"] ), build_year=int(grouping_year), - lifetime=costs.at[f"{heat_system.system_type} gas boiler", "lifetime"], + lifetime=costs.at[heat_system.gas_boiler_costs_name, "lifetime"], ) n.madd( @@ -563,20 +562,20 @@ def add_heating_capacities_installed_before_baseyear( nodes, suffix=f" {heat_system} oil boiler-{grouping_year}", bus0=spatial.oil.nodes, - bus1=nodes + " " + heat_system + " heat", + bus1=f"{nodes} {heat_system} heat", bus2="co2 atmosphere", - carrier=heat_system + " oil boiler", - efficiency=costs.at["decentral oil boiler", "efficiency"], + carrier=heat_system.value + " oil boiler", + efficiency=costs.at[heat_system.oil_boiler_costs_name, "efficiency"], efficiency2=costs.at["oil", "CO2 intensity"], - capital_cost=costs.at["decentral oil boiler", "efficiency"] - * costs.at["decentral oil boiler", "fixed"], + capital_cost=costs.at[heat_system.oil_boiler_costs_name, "efficiency"] + * costs.at[heat_system.oil_boiler_costs_name, "fixed"], p_nom=( - existing_heating.loc[nodes, (heat_system, "oil boiler")] + existing_heating.loc[nodes, (heat_system.value, "oil boiler")] * ratio - / costs.at["decentral oil boiler", "efficiency"] + / costs.at[heat_system.oil_boiler_costs_name, "efficiency"] ), build_year=int(grouping_year), - lifetime=costs.at[f"{heat_system.system_type} gas boiler", "lifetime"], + lifetime=costs.at[f"{heat_system.central_or_decentral} gas boiler", "lifetime"], ) # delete links with p_nom=nan corresponding to extra nodes in country @@ -651,28 +650,7 @@ if __name__ == "__main__": n=n, baseyear=baseyear, grouping_years=grouping_years_heat, - cop={ - "air decentral": xr.open_dataarray( - snakemake.input.cop_air_decentral_heating - ) - .to_pandas() - .reindex(index=n.snapshots), - "ground decentral": xr.open_dataarray( - snakemake.input.cop_soil_decentral_heating - ) - .to_pandas() - .reindex(index=n.snapshots), - "air central": xr.open_dataarray( - snakemake.input.cop_air_central_heating - ) - .to_pandas() - .reindex(index=n.snapshots), - "ground central": xr.open_dataarray( - snakemake.input.cop_soil_central_heating - ) - .to_pandas() - .reindex(index=n.snapshots), - }, + cop=xr.open_dataarray(snakemake.input.cop_profiles), time_dep_hp_cop=options["time_dep_hp_cop"], costs=costs, default_lifetime=snakemake.params.existing_capacities[ diff --git a/scripts/enums/HeatSystem.py b/scripts/enums/HeatSystem.py index 608da92f..4b1c11af 100644 --- a/scripts/enums/HeatSystem.py +++ b/scripts/enums/HeatSystem.py @@ -210,7 +210,7 @@ class HeatSystem(Enum): def heat_pump_costs_name(self, heat_source: str) -> str: """ - Generates the name for the heat pump costs based on the heat source. + Generates the name for the heat pump costs based on the heat source and system. Parameters ---------- @@ -223,3 +223,41 @@ class HeatSystem(Enum): The name for the heat pump costs. """ return f"{self.central_or_decentral} {heat_source}-sourced heat pump" + + @property + def resistive_heater_costs_name(self) -> str: + """ + Generates the name for the resistive heater costs based on the heat system. + + Returns + ------- + str + The name for the heater costs. + """ + return f"{self.central_or_decentral} resistive heater" + + @property + def gas_boiler_costs_name(self) -> str: + """ + Generates the name for the gas boiler costs based on the heat system. + + Returns + ------- + str + The name for the gas boiler costs. + """ + return f"{self.central_or_decentral} gas boiler" + + @property + def oil_boiler_costs_name(self) -> str: + """ + Generates the name for the oil boiler costs based on the heat system. + + Returns + ------- + str + The name for the oil boiler costs. + """ + return "decentral oil boiler" + + diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index 88748dcc..9ea69dfb 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -1802,7 +1802,7 @@ def build_heat_demand(n): return heat_demand -def add_heat(n, costs): +def add_heat(n, costs, cop): logger.info("Add heat sector") sectors = ["residential", "services"] @@ -1833,7 +1833,6 @@ def add_heat(n, costs): # 1e3 converts from W/m^2 to MW/(1000m^2) = kW/m^2 solar_thermal = options["solar_cf_correction"] * solar_thermal / 1e3 - cop = xr.open_dataarray(snakemake.input.cop_profiles) for ( heat_system ) in ( @@ -4098,7 +4097,7 @@ if __name__ == "__main__": add_land_transport(n, costs) if options["heating"]: - add_heat(n, costs) + add_heat(n=n, costs=costs, cop=xr.open_dataarray(snakemake.input.cop_profiles)) if options["biomass"]: add_biomass(n, costs) From 390085aaad9088942701470ef0a0bd3e46f0fdd2 Mon Sep 17 00:00:00 2001 From: AmosSchledorn Date: Mon, 5 Aug 2024 11:35:34 +0200 Subject: [PATCH 71/79] update add_existing_baseyear --- scripts/add_existing_baseyear.py | 53 -------------------------------- 1 file changed, 53 deletions(-) diff --git a/scripts/add_existing_baseyear.py b/scripts/add_existing_baseyear.py index abdd0a8d..593dfa26 100644 --- a/scripts/add_existing_baseyear.py +++ b/scripts/add_existing_baseyear.py @@ -458,7 +458,6 @@ def add_heating_capacities_installed_before_baseyear( else: nodes_elec = nodes -<<<<<<< HEAD too_large_grouping_years = [gy for gy in grouping_years if gy >= int(baseyear)] if too_large_grouping_years: logger.warning( @@ -471,28 +470,6 @@ def add_heating_capacities_installed_before_baseyear( if int(grouping_year) + default_lifetime > int(baseyear) and int(grouping_year) < int(baseyear) ] -======= - # Add heat pumps - heat_source = snakemake.params.heat_pump_sources[heat_system.system_type.value] - costs_name = f"{heat_system.system_type} {heat_source}-sourced heat pump" - - efficiency = ( - cop.sel( - heat_system=heat_system.system_type.value, - heat_source=heat_source, - name=nodes, - ) - .to_pandas() - .reindex(index=n.snapshots) - if options["time_dep_hp_cop"] - else costs.at[costs_name, "efficiency"] - ) - - too_large_grouping_years = [gy for gy in grouping_years if gy >= int(baseyear)] - if too_large_grouping_years: - logger.warning( - f"Grouping years >= baseyear are ignored. Dropping {too_large_grouping_years}." ->>>>>>> 0259e066e4a5688d002e47ec9b34bc9e45ae437d ) assert valid_grouping_years.is_monotonic_increasing @@ -543,42 +520,19 @@ def add_heating_capacities_installed_before_baseyear( suffix=f" {heat_system} resistive heater-{grouping_year}", bus0=nodes_elec, bus1=nodes + " " + heat_system.value + " heat", -<<<<<<< HEAD carrier=heat_system.value + " resistive heater", efficiency=costs.at[heat_system.resistive_heater_costs_name, "efficiency"], capital_cost=( costs.at[heat_system.resistive_heater_costs_name, "efficiency"] * costs.at[heat_system.resistive_heater_costs_name, "fixed"] -======= - carrier=heat_system + " resistive heater", - efficiency=costs.at[ - f"{heat_system.system_type} resistive heater", "efficiency" - ], - capital_cost=( - costs.at[ - f"{heat_system.system_type} resistive heater", "efficiency" - ] - * costs.at[f"{heat_system.system_type} resistive heater", "fixed"] ->>>>>>> 0259e066e4a5688d002e47ec9b34bc9e45ae437d ), p_nom=( existing_heating.loc[nodes, (heat_system.value, "resistive heater")] * ratio -<<<<<<< HEAD / costs.at[heat_system.resistive_heater_costs_name, "efficiency"] ), build_year=int(grouping_year), lifetime=costs.at[heat_system.resistive_heater_costs_name, "lifetime"], -======= - / costs.at[ - f"{heat_system.system_type} resistive heater", "efficiency" - ] - ), - build_year=int(grouping_year), - lifetime=costs.at[ - f"{heat_system.system_type} resistive heater", "lifetime" - ], ->>>>>>> 0259e066e4a5688d002e47ec9b34bc9e45ae437d ) n.madd( @@ -588,15 +542,8 @@ def add_heating_capacities_installed_before_baseyear( bus0="EU gas" if "EU gas" in spatial.gas.nodes else nodes + " gas", bus1=f"{nodes} {heat_system} heat", bus2="co2 atmosphere", -<<<<<<< HEAD carrier=heat_system.value + " gas boiler", efficiency=costs.at[heat_system.gas_boiler_costs_name, "efficiency"], -======= - carrier=heat_system + " gas boiler", - efficiency=costs.at[ - f"{heat_system.system_type} gas boiler", "efficiency" - ], ->>>>>>> 0259e066e4a5688d002e47ec9b34bc9e45ae437d efficiency2=costs.at["gas", "CO2 intensity"], capital_cost=( costs.at[heat_system.gas_boiler_costs_name, "efficiency"] From 61bb225a34fadc2eda0eb35c81b33efd86bda296 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 5 Aug 2024 09:42:42 +0000 Subject: [PATCH 72/79] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- scripts/add_existing_baseyear.py | 26 ++++++++++++++++++++------ scripts/enums/HeatSystem.py | 8 ++++---- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/scripts/add_existing_baseyear.py b/scripts/add_existing_baseyear.py index 593dfa26..15c57f32 100644 --- a/scripts/add_existing_baseyear.py +++ b/scripts/add_existing_baseyear.py @@ -453,12 +453,16 @@ def add_heating_capacities_installed_before_baseyear( n.buses.location[n.buses.index.str.contains(f"{heat_system} heat")] ) - if (not heat_system == HeatSystem.URBAN_CENTRAL) and options["electricity_distribution_grid"]: + if (not heat_system == HeatSystem.URBAN_CENTRAL) and options[ + "electricity_distribution_grid" + ]: nodes_elec = nodes + " low voltage" else: nodes_elec = nodes - too_large_grouping_years = [gy for gy in grouping_years if gy >= int(baseyear)] + too_large_grouping_years = [ + gy for gy in grouping_years if gy >= int(baseyear) + ] if too_large_grouping_years: logger.warning( f"Grouping years >= baseyear are ignored. Dropping {too_large_grouping_years}." @@ -483,11 +487,17 @@ def add_heating_capacities_installed_before_baseyear( for ratio, grouping_year in zip(ratios, valid_grouping_years): # Add heat pumps - for heat_source in snakemake.params.heat_pump_sources[heat_system.system_type.value]: + for heat_source in snakemake.params.heat_pump_sources[ + heat_system.system_type.value + ]: costs_name = heat_system.heat_pump_costs_name(heat_source) efficiency = ( - cop.sel(heat_system=heat_system.system_type.value, heat_source=heat_source, name=nodes) + cop.sel( + heat_system=heat_system.system_type.value, + heat_source=heat_source, + name=nodes, + ) .to_pandas() .reindex(index=n.snapshots) if options["time_dep_hp_cop"] @@ -521,7 +531,9 @@ def add_heating_capacities_installed_before_baseyear( bus0=nodes_elec, bus1=nodes + " " + heat_system.value + " heat", carrier=heat_system.value + " resistive heater", - efficiency=costs.at[heat_system.resistive_heater_costs_name, "efficiency"], + efficiency=costs.at[ + heat_system.resistive_heater_costs_name, "efficiency" + ], capital_cost=( costs.at[heat_system.resistive_heater_costs_name, "efficiency"] * costs.at[heat_system.resistive_heater_costs_name, "fixed"] @@ -576,7 +588,9 @@ def add_heating_capacities_installed_before_baseyear( / costs.at[heat_system.oil_boiler_costs_name, "efficiency"] ), build_year=int(grouping_year), - lifetime=costs.at[f"{heat_system.central_or_decentral} gas boiler", "lifetime"], + lifetime=costs.at[ + f"{heat_system.central_or_decentral} gas boiler", "lifetime" + ], ) # delete links with p_nom=nan corresponding to extra nodes in country diff --git a/scripts/enums/HeatSystem.py b/scripts/enums/HeatSystem.py index 4b1c11af..75cd3344 100644 --- a/scripts/enums/HeatSystem.py +++ b/scripts/enums/HeatSystem.py @@ -210,7 +210,8 @@ class HeatSystem(Enum): def heat_pump_costs_name(self, heat_source: str) -> str: """ - Generates the name for the heat pump costs based on the heat source and system. + Generates the name for the heat pump costs based on the heat source and + system. Parameters ---------- @@ -227,7 +228,8 @@ class HeatSystem(Enum): @property def resistive_heater_costs_name(self) -> str: """ - Generates the name for the resistive heater costs based on the heat system. + Generates the name for the resistive heater costs based on the heat + system. Returns ------- @@ -259,5 +261,3 @@ class HeatSystem(Enum): The name for the oil boiler costs. """ return "decentral oil boiler" - - From f593983ea04bb7e44c6fdb2699c67d8505ca52bf Mon Sep 17 00:00:00 2001 From: AmosSchledorn Date: Mon, 5 Aug 2024 11:45:12 +0200 Subject: [PATCH 73/79] update copyright notic in heatSector --- scripts/enums/HeatSector.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/enums/HeatSector.py b/scripts/enums/HeatSector.py index 4c763fec..03bcaffd 100644 --- a/scripts/enums/HeatSector.py +++ b/scripts/enums/HeatSector.py @@ -1,4 +1,6 @@ # -*- coding: utf-8 -*- +# SPDX-FileCopyrightText: : 2020-2024 The PyPSA-Eur Authors +# # SPDX-License-Identifier: MIT from enum import Enum From 268ff9378375e8618130833274a772e27041e2b4 Mon Sep 17 00:00:00 2001 From: AmosSchledorn Date: Mon, 5 Aug 2024 12:07:24 +0200 Subject: [PATCH 74/79] fix boiler buses for existing heating --- scripts/add_existing_baseyear.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/add_existing_baseyear.py b/scripts/add_existing_baseyear.py index 15c57f32..d0f85a1a 100644 --- a/scripts/add_existing_baseyear.py +++ b/scripts/add_existing_baseyear.py @@ -552,7 +552,7 @@ def add_heating_capacities_installed_before_baseyear( nodes, suffix=f"{heat_system} gas boiler-{grouping_year}", bus0="EU gas" if "EU gas" in spatial.gas.nodes else nodes + " gas", - bus1=f"{nodes} {heat_system} heat", + bus1=nodes + " " + heat_system.value + " heat", bus2="co2 atmosphere", carrier=heat_system.value + " gas boiler", efficiency=costs.at[heat_system.gas_boiler_costs_name, "efficiency"], @@ -575,7 +575,7 @@ def add_heating_capacities_installed_before_baseyear( nodes, suffix=f" {heat_system} oil boiler-{grouping_year}", bus0=spatial.oil.nodes, - bus1=f"{nodes} {heat_system} heat", + bus1=nodes + " " + heat_system.value + " heat", bus2="co2 atmosphere", carrier=heat_system.value + " oil boiler", efficiency=costs.at[heat_system.oil_boiler_costs_name, "efficiency"], From ea7fc92546ce05e9fbc4e36f2562b47e3a107859 Mon Sep 17 00:00:00 2001 From: AmosSchledorn Date: Mon, 5 Aug 2024 12:19:43 +0200 Subject: [PATCH 75/79] update solve_perfect.add_existing_baseyear input/params --- rules/solve_perfect.smk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rules/solve_perfect.smk b/rules/solve_perfect.smk index d2ea1a16..057f7ee2 100644 --- a/rules/solve_perfect.smk +++ b/rules/solve_perfect.smk @@ -7,6 +7,7 @@ rule add_existing_baseyear: sector=config_provider("sector"), existing_capacities=config_provider("existing_capacities"), costs=config_provider("costs"), + heat_pump_sources=config_provider("sector", "heat_pump_sources"), input: network=RESULTS + "prenetworks/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.nc", @@ -19,6 +20,7 @@ rule add_existing_baseyear: config_provider("scenario", "planning_horizons", 0)(w) ) ), + cop_profiles=resources("cop_profiles_elec_s{simpl}_{clusters}.nc"), cop_soil_decentral_heating=resources( "cop_soil_decentral_heating_elec_s{simpl}_{clusters}.nc" ), From 93d60a2927bf7c5cf9872d8fd123319503f8d8c2 Mon Sep 17 00:00:00 2001 From: AmosSchledorn Date: Mon, 5 Aug 2024 12:26:26 +0200 Subject: [PATCH 76/79] remove obsolote cop inputs from solve_perfect.add_existing_baseyear --- rules/solve_perfect.smk | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/rules/solve_perfect.smk b/rules/solve_perfect.smk index 057f7ee2..a06c6dfa 100644 --- a/rules/solve_perfect.smk +++ b/rules/solve_perfect.smk @@ -21,18 +21,6 @@ rule add_existing_baseyear: ) ), cop_profiles=resources("cop_profiles_elec_s{simpl}_{clusters}.nc"), - cop_soil_decentral_heating=resources( - "cop_soil_decentral_heating_elec_s{simpl}_{clusters}.nc" - ), - cop_air_decentral_heating=resources( - "cop_air_decentral_heating_elec_s{simpl}_{clusters}.nc" - ), - cop_air_central_heating=resources( - "cop_air_central_heating_elec_s{simpl}_{clusters}.nc" - ), - cop_soil_central_heating=resources( - "cop_soil_central_heating_elec_s{simpl}_{clusters}.nc" - ), existing_heating_distribution=resources( "existing_heating_distribution_elec_s{simpl}_{clusters}_{planning_horizons}.csv" ), From 4fe8eeeffab8191ff2fb69f9f5a4320c4bd3ab2d Mon Sep 17 00:00:00 2001 From: AmosSchledorn Date: Mon, 5 Aug 2024 15:07:46 +0200 Subject: [PATCH 77/79] rename "enums" to "definitions" and write modules in snake case --- scripts/definitions/heat_sector.py | 28 +++ scripts/definitions/heat_system.py | 263 ++++++++++++++++++++++++ scripts/definitions/heat_system_type.py | 35 ++++ 3 files changed, 326 insertions(+) create mode 100644 scripts/definitions/heat_sector.py create mode 100644 scripts/definitions/heat_system.py create mode 100644 scripts/definitions/heat_system_type.py diff --git a/scripts/definitions/heat_sector.py b/scripts/definitions/heat_sector.py new file mode 100644 index 00000000..03bcaffd --- /dev/null +++ b/scripts/definitions/heat_sector.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# SPDX-FileCopyrightText: : 2020-2024 The PyPSA-Eur Authors +# +# SPDX-License-Identifier: MIT + +from enum import Enum + + +class HeatSector(Enum): + """ + Enumeration class representing different heat sectors. + + Attributes: + RESIDENTIAL (str): Represents the residential heat sector. + SERVICES (str): Represents the services heat sector. + """ + + RESIDENTIAL = "residential" + SERVICES = "services" + + def __str__(self) -> str: + """ + Returns the string representation of the heat sector. + + Returns: + str: The string representation of the heat sector. + """ + return self.value diff --git a/scripts/definitions/heat_system.py b/scripts/definitions/heat_system.py new file mode 100644 index 00000000..2f305644 --- /dev/null +++ b/scripts/definitions/heat_system.py @@ -0,0 +1,263 @@ +# -*- coding: utf-8 -*- +# SPDX-FileCopyrightText: : 2020-2024 The PyPSA-Eur Authors +# +# SPDX-License-Identifier: MIT + +from enum import Enum + +from scripts.definitions.heat_sector import HeatSector +from scripts.definitions.heat_system_type import HeatSystemType + + +class HeatSystem(Enum): + """ + Enumeration representing different heat systems. + + Attributes + ---------- + RESIDENTIAL_RURAL : str + Heat system for residential areas in rural locations. + SERVICES_RURAL : str + Heat system for service areas in rural locations. + RESIDENTIAL_URBAN_DECENTRAL : str + Heat system for residential areas in urban decentralized locations. + SERVICES_URBAN_DECENTRAL : str + Heat system for service areas in urban decentralized locations. + URBAN_CENTRAL : str + Heat system for urban central areas. + + Methods + ------- + __str__() + Returns the string representation of the heat system. + central_or_decentral() + Returns whether the heat system is central or decentralized. + system_type() + Returns the type of the heat system. + sector() + Returns the sector of the heat system. + rural() + Returns whether the heat system is for rural areas. + urban_decentral() + Returns whether the heat system is for urban decentralized areas. + urban() + Returns whether the heat system is for urban areas. + heat_demand_weighting(urban_fraction=None, dist_fraction=None) + Calculates the heat demand weighting based on urban fraction and distribution fraction. + heat_pump_costs_name(heat_source) + Generates the name for the heat pump costs based on the heat source. + """ + + RESIDENTIAL_RURAL = "residential rural" + SERVICES_RURAL = "services rural" + RESIDENTIAL_URBAN_DECENTRAL = "residential urban decentral" + SERVICES_URBAN_DECENTRAL = "services urban decentral" + URBAN_CENTRAL = "urban central" + + def __init__(self, *args): + super().__init__(*args) + + def __str__(self) -> str: + """ + Returns the string representation of the heat system. + + Returns + ------- + str + The string representation of the heat system. + """ + return self.value + + @property + def central_or_decentral(self) -> str: + """ + Returns whether the heat system is central or decentralized. + + Returns + ------- + str + "central" if the heat system is central, "decentral" otherwise. + """ + if self == HeatSystem.URBAN_CENTRAL: + return "central" + else: + return "decentral" + + @property + def system_type(self) -> HeatSystemType: + """ + Returns the type of the heat system. + + Returns + ------- + str + The type of the heat system. + + Raises + ------ + RuntimeError + If the heat system is invalid. + """ + if self == HeatSystem.URBAN_CENTRAL: + return HeatSystemType.URBAN_CENTRAL + elif ( + self == HeatSystem.RESIDENTIAL_URBAN_DECENTRAL + or self == HeatSystem.SERVICES_URBAN_DECENTRAL + ): + return HeatSystemType.URBAN_DECENTRAL + elif self == HeatSystem.RESIDENTIAL_RURAL or self == HeatSystem.SERVICES_RURAL: + return HeatSystemType.RURAL + else: + raise RuntimeError(f"Invalid heat system: {self}") + + @property + def sector(self) -> HeatSector: + """ + Returns the sector of the heat system. + + Returns + ------- + HeatSector + The sector of the heat system. + """ + if ( + self == HeatSystem.RESIDENTIAL_RURAL + or self == HeatSystem.RESIDENTIAL_URBAN_DECENTRAL + ): + return HeatSector.RESIDENTIAL + elif ( + self == HeatSystem.SERVICES_RURAL + or self == HeatSystem.SERVICES_URBAN_DECENTRAL + ): + return HeatSector.SERVICES + else: + "tot" + + @property + def is_rural(self) -> bool: + """ + Returns whether the heat system is for rural areas. + + Returns + ------- + bool + True if the heat system is for rural areas, False otherwise. + """ + if self == HeatSystem.RESIDENTIAL_RURAL or self == HeatSystem.SERVICES_RURAL: + return True + else: + return False + + @property + def is_urban_decentral(self) -> bool: + """ + Returns whether the heat system is for urban decentralized areas. + + Returns + ------- + bool + True if the heat system is for urban decentralized areas, False otherwise. + """ + if ( + self == HeatSystem.RESIDENTIAL_URBAN_DECENTRAL + or self == HeatSystem.SERVICES_URBAN_DECENTRAL + ): + return True + else: + return False + + @property + def is_urban(self) -> bool: + """ + Returns whether the heat system is for urban areas. + + Returns + ------- + bool True if the heat system is for urban areas, False otherwise. + """ + return not self.is_rural + + def heat_demand_weighting(self, urban_fraction=None, dist_fraction=None) -> float: + """ + Calculates the heat demand weighting based on urban fraction and + distribution fraction. + + Parameters + ---------- + urban_fraction : float, optional + The fraction of urban heat demand. + dist_fraction : float, optional + The fraction of distributed heat demand. + + Returns + ------- + float + The heat demand weighting. + + Raises + ------ + RuntimeError + If the heat system is invalid. + """ + if "rural" in self.value: + return 1 - urban_fraction + elif "urban central" in self.value: + return dist_fraction + elif "urban decentral" in self.value: + return urban_fraction - dist_fraction + else: + raise RuntimeError(f"Invalid heat system: {self}") + + def heat_pump_costs_name(self, heat_source: str) -> str: + """ + Generates the name for the heat pump costs based on the heat source and + system. + + Parameters + ---------- + heat_source : str + The heat source. + + Returns + ------- + str + The name for the heat pump costs. + """ + return f"{self.central_or_decentral} {heat_source}-sourced heat pump" + + @property + def resistive_heater_costs_name(self) -> str: + """ + Generates the name for the resistive heater costs based on the heat + system. + + Returns + ------- + str + The name for the heater costs. + """ + return f"{self.central_or_decentral} resistive heater" + + @property + def gas_boiler_costs_name(self) -> str: + """ + Generates the name for the gas boiler costs based on the heat system. + + Returns + ------- + str + The name for the gas boiler costs. + """ + return f"{self.central_or_decentral} gas boiler" + + @property + def oil_boiler_costs_name(self) -> str: + """ + Generates the name for the oil boiler costs based on the heat system. + + Returns + ------- + str + The name for the oil boiler costs. + """ + return "decentral oil boiler" diff --git a/scripts/definitions/heat_system_type.py b/scripts/definitions/heat_system_type.py new file mode 100644 index 00000000..5bd1bee3 --- /dev/null +++ b/scripts/definitions/heat_system_type.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +# SPDX-FileCopyrightText: : 2020-2024 The PyPSA-Eur Authors +# +# SPDX-License-Identifier: MIT + +from enum import Enum + + +class HeatSystemType(Enum): + """ + Enumeration representing different types of heat systems. + """ + + URBAN_CENTRAL = "urban central" + URBAN_DECENTRAL = "urban decentral" + RURAL = "rural" + + def __str__(self) -> str: + """ + Returns the string representation of the heat system type. + + Returns: + str: The string representation of the heat system type. + """ + return self.value + + @property + def is_central(self) -> bool: + """ + Returns whether the heat system type is central. + + Returns: + bool: True if the heat system type is central, False otherwise. + """ + return self == HeatSystemType.URBAN_CENTRAL From 2e35bef480614a09ff25e7154cbb8f1028b6e1c5 Mon Sep 17 00:00:00 2001 From: AmosSchledorn Date: Mon, 5 Aug 2024 15:08:05 +0200 Subject: [PATCH 78/79] rename "enums" to "definitions" and write modules in snake case --- scripts/add_existing_baseyear.py | 6 +- scripts/build_cop_profiles/run.py | 2 +- scripts/enums/HeatSector.py | 28 ---- scripts/enums/HeatSystem.py | 263 ------------------------------ scripts/enums/HeatSystemType.py | 35 ---- scripts/prepare_sector_network.py | 6 +- 6 files changed, 7 insertions(+), 333 deletions(-) delete mode 100644 scripts/enums/HeatSector.py delete mode 100644 scripts/enums/HeatSystem.py delete mode 100644 scripts/enums/HeatSystemType.py diff --git a/scripts/add_existing_baseyear.py b/scripts/add_existing_baseyear.py index d0f85a1a..ff1a3e46 100644 --- a/scripts/add_existing_baseyear.py +++ b/scripts/add_existing_baseyear.py @@ -24,9 +24,9 @@ from _helpers import ( from add_electricity import sanitize_carriers from prepare_sector_network import cluster_heat_buses, define_spatial, prepare_costs -from scripts.enums.HeatSector import HeatSector -from scripts.enums.HeatSystem import HeatSystem -from scripts.enums.HeatSystemType import HeatSystemType +from scripts.definitions.heat_sector import HeatSector +from scripts.definitions.heat_system import HeatSystem +from scripts.definitions.heat_system_type import HeatSystemType logger = logging.getLogger(__name__) cc = coco.CountryConverter() diff --git a/scripts/build_cop_profiles/run.py b/scripts/build_cop_profiles/run.py index 7e405a42..4d57db31 100644 --- a/scripts/build_cop_profiles/run.py +++ b/scripts/build_cop_profiles/run.py @@ -12,7 +12,7 @@ from _helpers import set_scenario_config from CentralHeatingCopApproximator import CentralHeatingCopApproximator from DecentralHeatingCopApproximator import DecentralHeatingCopApproximator -from scripts.enums.HeatSystemType import HeatSystemType +from scripts.definitions.heat_system_type import HeatSystemType sys.path.append("..") diff --git a/scripts/enums/HeatSector.py b/scripts/enums/HeatSector.py deleted file mode 100644 index 03bcaffd..00000000 --- a/scripts/enums/HeatSector.py +++ /dev/null @@ -1,28 +0,0 @@ -# -*- coding: utf-8 -*- -# SPDX-FileCopyrightText: : 2020-2024 The PyPSA-Eur Authors -# -# SPDX-License-Identifier: MIT - -from enum import Enum - - -class HeatSector(Enum): - """ - Enumeration class representing different heat sectors. - - Attributes: - RESIDENTIAL (str): Represents the residential heat sector. - SERVICES (str): Represents the services heat sector. - """ - - RESIDENTIAL = "residential" - SERVICES = "services" - - def __str__(self) -> str: - """ - Returns the string representation of the heat sector. - - Returns: - str: The string representation of the heat sector. - """ - return self.value diff --git a/scripts/enums/HeatSystem.py b/scripts/enums/HeatSystem.py deleted file mode 100644 index 75cd3344..00000000 --- a/scripts/enums/HeatSystem.py +++ /dev/null @@ -1,263 +0,0 @@ -# -*- coding: utf-8 -*- -# SPDX-FileCopyrightText: : 2020-2024 The PyPSA-Eur Authors -# -# SPDX-License-Identifier: MIT - -from enum import Enum - -from scripts.enums.HeatSector import HeatSector -from scripts.enums.HeatSystemType import HeatSystemType - - -class HeatSystem(Enum): - """ - Enumeration representing different heat systems. - - Attributes - ---------- - RESIDENTIAL_RURAL : str - Heat system for residential areas in rural locations. - SERVICES_RURAL : str - Heat system for service areas in rural locations. - RESIDENTIAL_URBAN_DECENTRAL : str - Heat system for residential areas in urban decentralized locations. - SERVICES_URBAN_DECENTRAL : str - Heat system for service areas in urban decentralized locations. - URBAN_CENTRAL : str - Heat system for urban central areas. - - Methods - ------- - __str__() - Returns the string representation of the heat system. - central_or_decentral() - Returns whether the heat system is central or decentralized. - system_type() - Returns the type of the heat system. - sector() - Returns the sector of the heat system. - rural() - Returns whether the heat system is for rural areas. - urban_decentral() - Returns whether the heat system is for urban decentralized areas. - urban() - Returns whether the heat system is for urban areas. - heat_demand_weighting(urban_fraction=None, dist_fraction=None) - Calculates the heat demand weighting based on urban fraction and distribution fraction. - heat_pump_costs_name(heat_source) - Generates the name for the heat pump costs based on the heat source. - """ - - RESIDENTIAL_RURAL = "residential rural" - SERVICES_RURAL = "services rural" - RESIDENTIAL_URBAN_DECENTRAL = "residential urban decentral" - SERVICES_URBAN_DECENTRAL = "services urban decentral" - URBAN_CENTRAL = "urban central" - - def __init__(self, *args): - super().__init__(*args) - - def __str__(self) -> str: - """ - Returns the string representation of the heat system. - - Returns - ------- - str - The string representation of the heat system. - """ - return self.value - - @property - def central_or_decentral(self) -> str: - """ - Returns whether the heat system is central or decentralized. - - Returns - ------- - str - "central" if the heat system is central, "decentral" otherwise. - """ - if self == HeatSystem.URBAN_CENTRAL: - return "central" - else: - return "decentral" - - @property - def system_type(self) -> HeatSystemType: - """ - Returns the type of the heat system. - - Returns - ------- - str - The type of the heat system. - - Raises - ------ - RuntimeError - If the heat system is invalid. - """ - if self == HeatSystem.URBAN_CENTRAL: - return HeatSystemType.URBAN_CENTRAL - elif ( - self == HeatSystem.RESIDENTIAL_URBAN_DECENTRAL - or self == HeatSystem.SERVICES_URBAN_DECENTRAL - ): - return HeatSystemType.URBAN_DECENTRAL - elif self == HeatSystem.RESIDENTIAL_RURAL or self == HeatSystem.SERVICES_RURAL: - return HeatSystemType.RURAL - else: - raise RuntimeError(f"Invalid heat system: {self}") - - @property - def sector(self) -> HeatSector: - """ - Returns the sector of the heat system. - - Returns - ------- - HeatSector - The sector of the heat system. - """ - if ( - self == HeatSystem.RESIDENTIAL_RURAL - or self == HeatSystem.RESIDENTIAL_URBAN_DECENTRAL - ): - return HeatSector.RESIDENTIAL - elif ( - self == HeatSystem.SERVICES_RURAL - or self == HeatSystem.SERVICES_URBAN_DECENTRAL - ): - return HeatSector.SERVICES - else: - "tot" - - @property - def is_rural(self) -> bool: - """ - Returns whether the heat system is for rural areas. - - Returns - ------- - bool - True if the heat system is for rural areas, False otherwise. - """ - if self == HeatSystem.RESIDENTIAL_RURAL or self == HeatSystem.SERVICES_RURAL: - return True - else: - return False - - @property - def is_urban_decentral(self) -> bool: - """ - Returns whether the heat system is for urban decentralized areas. - - Returns - ------- - bool - True if the heat system is for urban decentralized areas, False otherwise. - """ - if ( - self == HeatSystem.RESIDENTIAL_URBAN_DECENTRAL - or self == HeatSystem.SERVICES_URBAN_DECENTRAL - ): - return True - else: - return False - - @property - def is_urban(self) -> bool: - """ - Returns whether the heat system is for urban areas. - - Returns - ------- - bool True if the heat system is for urban areas, False otherwise. - """ - return not self.is_rural - - def heat_demand_weighting(self, urban_fraction=None, dist_fraction=None) -> float: - """ - Calculates the heat demand weighting based on urban fraction and - distribution fraction. - - Parameters - ---------- - urban_fraction : float, optional - The fraction of urban heat demand. - dist_fraction : float, optional - The fraction of distributed heat demand. - - Returns - ------- - float - The heat demand weighting. - - Raises - ------ - RuntimeError - If the heat system is invalid. - """ - if "rural" in self.value: - return 1 - urban_fraction - elif "urban central" in self.value: - return dist_fraction - elif "urban decentral" in self.value: - return urban_fraction - dist_fraction - else: - raise RuntimeError(f"Invalid heat system: {self}") - - def heat_pump_costs_name(self, heat_source: str) -> str: - """ - Generates the name for the heat pump costs based on the heat source and - system. - - Parameters - ---------- - heat_source : str - The heat source. - - Returns - ------- - str - The name for the heat pump costs. - """ - return f"{self.central_or_decentral} {heat_source}-sourced heat pump" - - @property - def resistive_heater_costs_name(self) -> str: - """ - Generates the name for the resistive heater costs based on the heat - system. - - Returns - ------- - str - The name for the heater costs. - """ - return f"{self.central_or_decentral} resistive heater" - - @property - def gas_boiler_costs_name(self) -> str: - """ - Generates the name for the gas boiler costs based on the heat system. - - Returns - ------- - str - The name for the gas boiler costs. - """ - return f"{self.central_or_decentral} gas boiler" - - @property - def oil_boiler_costs_name(self) -> str: - """ - Generates the name for the oil boiler costs based on the heat system. - - Returns - ------- - str - The name for the oil boiler costs. - """ - return "decentral oil boiler" diff --git a/scripts/enums/HeatSystemType.py b/scripts/enums/HeatSystemType.py deleted file mode 100644 index 5bd1bee3..00000000 --- a/scripts/enums/HeatSystemType.py +++ /dev/null @@ -1,35 +0,0 @@ -# -*- coding: utf-8 -*- -# SPDX-FileCopyrightText: : 2020-2024 The PyPSA-Eur Authors -# -# SPDX-License-Identifier: MIT - -from enum import Enum - - -class HeatSystemType(Enum): - """ - Enumeration representing different types of heat systems. - """ - - URBAN_CENTRAL = "urban central" - URBAN_DECENTRAL = "urban decentral" - RURAL = "rural" - - def __str__(self) -> str: - """ - Returns the string representation of the heat system type. - - Returns: - str: The string representation of the heat system type. - """ - return self.value - - @property - def is_central(self) -> bool: - """ - Returns whether the heat system type is central. - - Returns: - bool: True if the heat system type is central, False otherwise. - """ - return self == HeatSystemType.URBAN_CENTRAL diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index 83b76bb9..d9d0f6e3 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -37,9 +37,9 @@ from pypsa.geo import haversine_pts from pypsa.io import import_components_from_dataframe from scipy.stats import beta -from scripts.enums.HeatSector import HeatSector -from scripts.enums.HeatSystem import HeatSystem -from scripts.enums.HeatSystemType import HeatSystemType +from scripts.definitions.heat_sector import HeatSector +from scripts.definitions.heat_system import HeatSystem +from scripts.definitions.heat_system_type import HeatSystemType spatial = SimpleNamespace() logger = logging.getLogger(__name__) From 0e8fb80bc42adb6bb098c08645da3472efb1081f Mon Sep 17 00:00:00 2001 From: AmosSchledorn Date: Mon, 5 Aug 2024 16:11:18 +0200 Subject: [PATCH 79/79] clean up, improve docs --- scripts/add_existing_baseyear.py | 12 +++---- scripts/definitions/heat_system.py | 4 +++ scripts/prepare_sector_network.py | 55 +++++++++++++++++------------- 3 files changed, 41 insertions(+), 30 deletions(-) diff --git a/scripts/add_existing_baseyear.py b/scripts/add_existing_baseyear.py index ff1a3e46..f67c38d9 100644 --- a/scripts/add_existing_baseyear.py +++ b/scripts/add_existing_baseyear.py @@ -420,13 +420,13 @@ def add_power_capacities_installed_before_baseyear(n, grouping_years, costs, bas def add_heating_capacities_installed_before_baseyear( - n, - baseyear, - grouping_years, + n: pypsa.Network, + baseyear: int, + grouping_years: list, cop: dict, time_dep_hp_cop: bool, - costs, - default_lifetime, + costs: pd.DataFrame, + default_lifetime: int, existing_heating: pd.DataFrame, ): """ @@ -500,7 +500,7 @@ def add_heating_capacities_installed_before_baseyear( ) .to_pandas() .reindex(index=n.snapshots) - if options["time_dep_hp_cop"] + if time_dep_hp_cop else costs.at[costs_name, "efficiency"] ) diff --git a/scripts/definitions/heat_system.py b/scripts/definitions/heat_system.py index 2f305644..b907b0fe 100644 --- a/scripts/definitions/heat_system.py +++ b/scripts/definitions/heat_system.py @@ -212,6 +212,7 @@ class HeatSystem(Enum): """ Generates the name for the heat pump costs based on the heat source and system. + Used to retrieve data from `technology-data `. Parameters ---------- @@ -230,6 +231,7 @@ class HeatSystem(Enum): """ Generates the name for the resistive heater costs based on the heat system. + Used to retrieve data from `technology-data `. Returns ------- @@ -242,6 +244,7 @@ class HeatSystem(Enum): def gas_boiler_costs_name(self) -> str: """ Generates the name for the gas boiler costs based on the heat system. + Used to retrieve data from `technology-data `. Returns ------- @@ -254,6 +257,7 @@ class HeatSystem(Enum): def oil_boiler_costs_name(self) -> str: """ Generates the name for the oil boiler costs based on the heat system. + Used to retrieve data from `technology-data `. Returns ------- diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index d9d0f6e3..585b3f25 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -1780,7 +1780,7 @@ def build_heat_demand(n): .unstack(level=1) ) - sectors = ["residential", "services"] + sectors = [sector.value for sector in HeatSector] uses = ["water", "space"] heat_demand = {} @@ -1808,10 +1808,21 @@ def build_heat_demand(n): return heat_demand -def add_heat(n, costs, cop): +def add_heat(n: pypsa.Network, costs: pd.DataFrame, cop: xr.DataArray): + """ + Add heat sector to the network. + + Parameters: + n (pypsa.Network): The PyPSA network object. + costs (pd.DataFrame): DataFrame containing cost information. + cop (xr.DataArray): DataArray containing coefficient of performance (COP) values. + + Returns: + None + """ logger.info("Add heat sector") - sectors = ["residential", "services"] + sectors = [sector.value for sector in HeatSector] heat_demand = build_heat_demand(n) @@ -3113,27 +3124,23 @@ def add_industry(n, costs): if options["oil_boilers"]: nodes = pop_layout.index - for name in [ - "residential rural", - "services rural", - "residential urban decentral", - "services urban decentral", - ]: - n.madd( - "Link", - nodes + f" {name} oil boiler", - p_nom_extendable=True, - bus0=spatial.oil.nodes, - bus1=nodes + f" {name} heat", - bus2="co2 atmosphere", - carrier=f"{name} oil boiler", - efficiency=costs.at["decentral oil boiler", "efficiency"], - efficiency2=costs.at["oil", "CO2 intensity"], - capital_cost=costs.at["decentral oil boiler", "efficiency"] - * costs.at["decentral oil boiler", "fixed"] - * options["overdimension_individual_heating"], - lifetime=costs.at["decentral oil boiler", "lifetime"], - ) + for heat_system in HeatSystem: + if not heat_system == HeatSystem.URBAN_CENTRAL: + n.madd( + "Link", + nodes + f" {heat_system} oil boiler", + p_nom_extendable=True, + bus0=spatial.oil.nodes, + bus1=nodes + f" {heat_system} heat", + bus2="co2 atmosphere", + carrier=f"{heat_system} oil boiler", + efficiency=costs.at["decentral oil boiler", "efficiency"], + efficiency2=costs.at["oil", "CO2 intensity"], + capital_cost=costs.at["decentral oil boiler", "efficiency"] + * costs.at["decentral oil boiler", "fixed"] + * options["overdimension_individual_heating"], + lifetime=costs.at["decentral oil boiler", "lifetime"], + ) n.madd( "Link",