From d976a8faf7af42e97ac3b35badccbd02fc269cd5 Mon Sep 17 00:00:00 2001 From: Fabian Neumann Date: Wed, 7 Jul 2021 17:58:47 +0200 Subject: [PATCH 01/14] add CO2 network [first draft] --- config.default.yaml | 1 + scripts/prepare_sector_network.py | 58 +++++++++++++++++++++++++------ 2 files changed, 49 insertions(+), 10 deletions(-) diff --git a/config.default.yaml b/config.default.yaml index 5f1fa1b8..ecadc3c0 100644 --- a/config.default.yaml +++ b/config.default.yaml @@ -214,6 +214,7 @@ sector: SMR: true co2_sequestration_potential: 200 #MtCO2/a sequestration potential for Europe co2_sequestration_cost: 20 #EUR/tCO2 for transport and sequestration of CO2 + co2_network: false cc_fraction: 0.9 # default fraction of CO2 captured with post-combustion capture hydrogen_underground_storage: true use_fischer_tropsch_waste_heat: true diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index fa485e6a..aca8d76f 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -277,6 +277,18 @@ def patch_electricity_network(n): def add_co2_tracking(n, options): + if options["co2_network"]: + nodes = pop_layout.index + co2_nodes = nodes + " co2 stored" + co2_locations = nodes + co2_vents = nodes + " co2 vent" + co2_max_sequestration = np.inf + else: + co2_nodes = "co2 stored" + co2_locations = "EU" + co2_vents = "co2 vent" + co2_max_sequestration = np.inf # TODO should be nodal sequestration potentials + # minus sign because opposite to how fossil fuels used: # CH4 burning puts CH4 down, atmosphere up n.add("Carrier", "co2", @@ -299,26 +311,33 @@ def add_co2_tracking(n, options): ) # this tracks CO2 stored, e.g. underground - n.add("Bus", - "co2 stored", - location="EU", + n.madd("Bus", + co2_nodes, + location=co2_locations, carrier="co2 stored" ) - n.add("Store", - "co2 stored", + n.madd("Store", + co2_nodes, e_nom_extendable=True, - e_nom_max=options['co2_sequestration_potential'] * 1e6, + e_nom_max=co2_max_sequestration, capital_cost=options['co2_sequestration_cost'], carrier="co2 stored", - bus="co2 stored" + bus=co2_nodes ) + # TODO if nodally resolved total allowed sequestration needs to + # be an extra_functionality constraint + # (best to implement it this way for either case) + # let e_nom_max represent geological potential + # don't forget to log duals of extra functionality! + # options['co2_sequestration_potential'] * 1e6 + if options['co2_vent']: - n.add("Link", - "co2 vent", - bus0="co2 stored", + n.madd("Link", + co2_vents, + bus0=co2_nodes, bus1="co2 atmosphere", carrier="co2 vent", efficiency=1., @@ -326,6 +345,25 @@ def add_co2_tracking(n, options): ) +def add_co2_network(n, costs): + + # TODO create co2 network topology from electricity + co2_links = pd.DataFrame() + + # assumed to be bidirectional + n.madd("Link", + co2_links.index, + bus0=co2_links.bus0.values + " co2 stored", + bus1=co2_links.bus1.values + " co2 stored", + p_min_pu=-1, + p_nom_extendable=True, + length=co2_links.length.values, + capital_cost=costs.at['CO2 pipeline', 'fixed'] * co2_links.length.values, + carrier="CO2 pipeline", + lifetime=costs.at['CO2 pipeline', 'lifetime'] + ) + + def add_dac(n, costs): heat_carriers = ["urban central heat", "services urban decentral heat"] From a98870e1597cc5cd25daa1d11cae14125960edec Mon Sep 17 00:00:00 2001 From: Fabian Neumann Date: Wed, 7 Jul 2021 18:07:57 +0200 Subject: [PATCH 02/14] correction for .madd() and call co2_network --- scripts/prepare_sector_network.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index aca8d76f..c5a99fcc 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -284,9 +284,9 @@ def add_co2_tracking(n, options): co2_vents = nodes + " co2 vent" co2_max_sequestration = np.inf else: - co2_nodes = "co2 stored" + co2_nodes = ["co2 stored"] co2_locations = "EU" - co2_vents = "co2 vent" + co2_vents = ["co2 vent"] co2_max_sequestration = np.inf # TODO should be nodal sequestration potentials # minus sign because opposite to how fossil fuels used: @@ -2074,6 +2074,9 @@ def limit_individual_line_extension(n, maxext): if "noH2network" in opts: remove_h2_network(n) + if options["co2_network"]: + add_co2_network(n, costs) + for o in opts: m = re.match(r'^\d+h$', o, re.IGNORECASE) if m is not None: From 56bdeafacbff5c731aa4859cec96917f3ed38ed1 Mon Sep 17 00:00:00 2001 From: Fabian Neumann Date: Fri, 9 Jul 2021 10:42:16 +0200 Subject: [PATCH 03/14] add co2 network topology --- scripts/prepare_sector_network.py | 37 ++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index c5a99fcc..bff2d840 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -54,6 +54,39 @@ def get(item, investment_year=None): return item +def create_network_topology(n, prefix, connector=" -> "): + """ + Create a network topology like the power transmission network. + + Parameters + ---------- + n : pypsa.Network + prefix : str + connector : str + + Returns + ------- + pd.DataFrame with columns bus0, bus1 and length + """ + + attrs = ["bus0", "bus1", "length"] + + candidates = pd.concat([ + n.lines[attrs], + n.links.loc[n.links.carrier == "DC", attrs] + ]) + + positive_order = candidates.bus0 < candidates.bus1 + candidates_p = candidates[positive_order] + swap_buses = {"bus0": "bus1", "bus1": "bus0"} + candidates_n = candidates[~positive_order].rename(columns=swap_buses) + candidates = pd.concat([candidates_p, candidates_n]) + + topo = candidates.groupby(["bus0", "bus1"], as_index=False).mean() + topo.index = topo.apply(lambda c: prefix + c.bus0 + connector + c.bus1, axis=1) + return topo + + def co2_emissions_year(countries, opts, year): """ Calculate CO2 emissions in one specific year (e.g. 1990 or 2018). @@ -347,10 +380,8 @@ def add_co2_tracking(n, options): def add_co2_network(n, costs): - # TODO create co2 network topology from electricity - co2_links = pd.DataFrame() + co2_links = create_network_topology(n, "CO2 pipeline ") - # assumed to be bidirectional n.madd("Link", co2_links.index, bus0=co2_links.bus0.values + " co2 stored", From 62bba87cda517f253dce0ab6bb41d76b4831271a Mon Sep 17 00:00:00 2001 From: Fabian Neumann Date: Fri, 9 Jul 2021 10:42:16 +0200 Subject: [PATCH 04/14] add co2 network topology Co-authored-by: lisazeyen --- scripts/prepare_sector_network.py | 37 ++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index c5a99fcc..bff2d840 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -54,6 +54,39 @@ def get(item, investment_year=None): return item +def create_network_topology(n, prefix, connector=" -> "): + """ + Create a network topology like the power transmission network. + + Parameters + ---------- + n : pypsa.Network + prefix : str + connector : str + + Returns + ------- + pd.DataFrame with columns bus0, bus1 and length + """ + + attrs = ["bus0", "bus1", "length"] + + candidates = pd.concat([ + n.lines[attrs], + n.links.loc[n.links.carrier == "DC", attrs] + ]) + + positive_order = candidates.bus0 < candidates.bus1 + candidates_p = candidates[positive_order] + swap_buses = {"bus0": "bus1", "bus1": "bus0"} + candidates_n = candidates[~positive_order].rename(columns=swap_buses) + candidates = pd.concat([candidates_p, candidates_n]) + + topo = candidates.groupby(["bus0", "bus1"], as_index=False).mean() + topo.index = topo.apply(lambda c: prefix + c.bus0 + connector + c.bus1, axis=1) + return topo + + def co2_emissions_year(countries, opts, year): """ Calculate CO2 emissions in one specific year (e.g. 1990 or 2018). @@ -347,10 +380,8 @@ def add_co2_tracking(n, options): def add_co2_network(n, costs): - # TODO create co2 network topology from electricity - co2_links = pd.DataFrame() + co2_links = create_network_topology(n, "CO2 pipeline ") - # assumed to be bidirectional n.madd("Link", co2_links.index, bus0=co2_links.bus0.values + " co2 stored", From 4f9d2f9d5f91286e334168a9ec8638d1d2141cd0 Mon Sep 17 00:00:00 2001 From: Fabian Neumann Date: Fri, 9 Jul 2021 12:50:40 +0200 Subject: [PATCH 05/14] add concept for management of spatial resolutions --- scripts/prepare_sector_network.py | 86 +++++++++++++++++++------------ 1 file changed, 54 insertions(+), 32 deletions(-) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index bff2d840..0ef06a00 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -19,6 +19,37 @@ import logging logger = logging.getLogger(__name__) +from types import SimpleNamespace +spatial = SimpleNamespace() + + +def define_spatial(nodes): + """ + Namespace for spatial + + Parameters + ---------- + nodes : list-like + """ + + global spatial + global options + + spatial.nodes = nodes + + spatial.co2 = SimpleNamespace() + + if options["co2_network"]: + spatial.co2.nodes = nodes + " co2 stored" + spatial.co2.locations = nodes + spatial.co2.vents = nodes + " co2 vent" + else: + spatial.co2.nodes = ["co2 stored"] + spatial.co2.locations = "EU" + spatial.co2.vents = ["co2 vent"] + + spatial.co2.df = pd.DataFrame(vars(spatial.co2), index=nodes) + def emission_sectors_from_opts(opts): @@ -310,18 +341,6 @@ def patch_electricity_network(n): def add_co2_tracking(n, options): - if options["co2_network"]: - nodes = pop_layout.index - co2_nodes = nodes + " co2 stored" - co2_locations = nodes - co2_vents = nodes + " co2 vent" - co2_max_sequestration = np.inf - else: - co2_nodes = ["co2 stored"] - co2_locations = "EU" - co2_vents = ["co2 vent"] - co2_max_sequestration = np.inf # TODO should be nodal sequestration potentials - # minus sign because opposite to how fossil fuels used: # CH4 burning puts CH4 down, atmosphere up n.add("Carrier", "co2", @@ -345,18 +364,18 @@ def add_co2_tracking(n, options): # this tracks CO2 stored, e.g. underground n.madd("Bus", - co2_nodes, - location=co2_locations, + spatial.co2.nodes, + location=spatial.co2.locations, carrier="co2 stored" ) n.madd("Store", - co2_nodes, + spatial.co2.nodes, e_nom_extendable=True, - e_nom_max=co2_max_sequestration, + e_nom_max=np.inf, capital_cost=options['co2_sequestration_cost'], carrier="co2 stored", - bus=co2_nodes + bus=spatial.co2.nodes ) # TODO if nodally resolved total allowed sequestration needs to @@ -369,8 +388,8 @@ def add_co2_tracking(n, options): if options['co2_vent']: n.madd("Link", - co2_vents, - bus0=co2_nodes, + spatial.co2.vents, + bus0=spatial.co2.nodes, bus1="co2 atmosphere", carrier="co2 vent", efficiency=1., @@ -408,7 +427,7 @@ def add_dac(n, costs): locations, suffix=" DAC", bus0="co2 atmosphere", - bus1="co2 stored", + bus1=spatial.co2.df.loc[locations, "nodes"].values, bus2=locations.values, bus3=heat_buses, carrier="DAC", @@ -1058,10 +1077,11 @@ def add_storage(n, costs): if options['methanation']: n.madd("Link", - nodes + " Sabatier", + spatial.nodes, + suffix=" Sabatier", bus0=nodes + " H2", bus1="EU gas", - bus2="co2 stored", + bus2=spatial.co2.nodes, p_nom_extendable=True, carrier="Sabatier", efficiency=costs.at["methanation", "efficiency"], @@ -1073,10 +1093,11 @@ def add_storage(n, costs): if options['helmeth']: n.madd("Link", - nodes + " helmeth", + spatial.nodes, + suffix=" helmeth", bus0=nodes, bus1="EU gas", - bus2="co2 stored", + bus2=spatial.co2.nodes, carrier="helmeth", p_nom_extendable=True, efficiency=costs.at["helmeth", "efficiency"], @@ -1089,11 +1110,12 @@ def add_storage(n, costs): if options['SMR']: n.madd("Link", - nodes + " SMR CC", + spatial.nodes, + suffix=" SMR CC", bus0="EU gas", bus1=nodes + " H2", bus2="co2 atmosphere", - bus3="co2 stored", + bus3=spatial.co2.nodes, p_nom_extendable=True, carrier="SMR CC", efficiency=costs.at["SMR CC", "efficiency"], @@ -1442,7 +1464,7 @@ def add_heat(n, costs): bus1=nodes[name], bus2=nodes[name] + " urban central heat", bus3="co2 atmosphere", - bus4="co2 stored", + bus4=spatial.co2.df.loc[nodes[name], "nodes"].values, carrier="urban central gas CHP CC", p_nom_extendable=True, capital_cost=costs.at['central gas CHP', 'fixed']*costs.at['central gas CHP', 'efficiency'] + costs.at['biomass CHP capture', 'fixed']*costs.at['gas', 'CO2 intensity'], @@ -1675,7 +1697,7 @@ def add_biomass(n, costs): bus1=urban_central, bus2=urban_central + " urban central heat", bus3="co2 atmosphere", - bus4="co2 stored", + 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'] + costs.at['biomass CHP capture', 'fixed'] * costs.at['solid biomass', 'CO2 intensity'], @@ -1726,7 +1748,7 @@ def add_industry(n, costs): bus0="EU solid biomass", bus1="solid biomass for industry", bus2="co2 atmosphere", - bus3="co2 stored", + bus3="co2 stored", # TODO co2: where to allocate if co2 is spatially resolved? carrier="solid biomass for industry CC", p_nom_extendable=True, capital_cost=costs.at["cement capture", "fixed"] * costs.at['solid biomass', 'CO2 intensity'], @@ -1764,7 +1786,7 @@ def add_industry(n, costs): bus0="EU gas", bus1="gas for industry", bus2="co2 atmosphere", - bus3="co2 stored", + bus3="co2 stored", # TODO co2: where to allocate if co2 is spatially resolved? carrier="gas for industry CC", p_nom_extendable=True, capital_cost=costs.at["cement capture", "fixed"] * costs.at['gas', 'CO2 intensity'], @@ -1847,7 +1869,7 @@ def add_industry(n, costs): nodes + " Fischer-Tropsch", bus0=nodes + " H2", bus1="EU oil", - bus2="co2 stored", + bus2=spatial.co2.nodes, carrier="Fischer-Tropsch", efficiency=costs.at["Fischer-Tropsch", 'efficiency'], capital_cost=costs.at["Fischer-Tropsch", 'fixed'], @@ -1940,7 +1962,7 @@ def add_industry(n, costs): "process emissions CC", bus0="process emissions", bus1="co2 atmosphere", - bus2="co2 stored", + bus2="co2 stored", # TODO co2: where to allocate if co2 is spatially resolved? carrier="process emissions CC", p_nom_extendable=True, capital_cost=costs.at["cement capture", "fixed"], From 2b204c45e421b8459371a46f79e0bb4e24c50851 Mon Sep 17 00:00:00 2001 From: Fabian Neumann Date: Fri, 9 Jul 2021 12:51:48 +0200 Subject: [PATCH 06/14] run define_spatial in __main__ --- scripts/prepare_sector_network.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index 0ef06a00..0552790a 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -2075,6 +2075,8 @@ def limit_individual_line_extension(n, maxext): patch_electricity_network(n) + define_spatial(pop_layout.index) + if snakemake.config["foresight"] == 'myopic': add_lifetime_wind_solar(n, costs) From cd99089628ea3c54925ddef7fa190a2d9e3bb729 Mon Sep 17 00:00:00 2001 From: Fabian Neumann Date: Fri, 9 Jul 2021 13:10:43 +0200 Subject: [PATCH 07/14] account for underwater fraction --- scripts/prepare_sector_network.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index 0552790a..aced4719 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -100,12 +100,13 @@ def create_network_topology(n, prefix, connector=" -> "): pd.DataFrame with columns bus0, bus1 and length """ - attrs = ["bus0", "bus1", "length"] + ln_attrs = ["bus0", "bus1", "length"] + lk_attrs = ["bus0", "bus1", "length", "underwater_fraction"] candidates = pd.concat([ - n.lines[attrs], - n.links.loc[n.links.carrier == "DC", attrs] - ]) + n.lines[ln_attrs], + n.links.loc[n.links.carrier == "DC", lk_attrs] + ]).fillna(0) positive_order = candidates.bus0 < candidates.bus1 candidates_p = candidates[positive_order] @@ -400,6 +401,10 @@ def add_co2_tracking(n, options): def add_co2_network(n, costs): co2_links = create_network_topology(n, "CO2 pipeline ") + + cost_onshore = (1 - co2_links.underwater_fraction) * costs.at['CO2 pipeline', 'fixed'] * co2_links.length + cost_submarine = co2_links.underwater_fraction * costs.at['CO2 pipeline submarine', 'fixed'] * co2_links.length + capital_cost = cost_onshore + cost_submarine n.madd("Link", co2_links.index, @@ -408,7 +413,7 @@ def add_co2_network(n, costs): p_min_pu=-1, p_nom_extendable=True, length=co2_links.length.values, - capital_cost=costs.at['CO2 pipeline', 'fixed'] * co2_links.length.values, + capital_cost=capital_cost.values, carrier="CO2 pipeline", lifetime=costs.at['CO2 pipeline', 'lifetime'] ) From d58a7f86a45c4825c843d1a35f64715f7cd7c376 Mon Sep 17 00:00:00 2001 From: Fabian Neumann Date: Fri, 9 Jul 2021 13:22:00 +0200 Subject: [PATCH 08/14] allow copperplated carbon capture to be distributed freely to co2 stores --- scripts/prepare_sector_network.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index aced4719..16eb12f6 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -1748,12 +1748,13 @@ def add_industry(n, costs): efficiency=1. ) - n.add("Link", - "solid biomass for industry CC", + n.madd("Link", + spatial.co2.locations, + suffix=" solid biomass for industry CC", bus0="EU solid biomass", bus1="solid biomass for industry", bus2="co2 atmosphere", - bus3="co2 stored", # TODO co2: where to allocate if co2 is spatially resolved? + bus3=spatial.co2.nodes, carrier="solid biomass for industry CC", p_nom_extendable=True, capital_cost=costs.at["cement capture", "fixed"] * costs.at['solid biomass', 'CO2 intensity'], @@ -1786,12 +1787,13 @@ def add_industry(n, costs): efficiency2=costs.at['gas', 'CO2 intensity'] ) - n.add("Link", - "gas for industry CC", + n.madd("Link", + spatial.co2.locations, + suffix=" gas for industry CC", bus0="EU gas", bus1="gas for industry", bus2="co2 atmosphere", - bus3="co2 stored", # TODO co2: where to allocate if co2 is spatially resolved? + bus3=spatial.co2.nodes, carrier="gas for industry CC", p_nom_extendable=True, capital_cost=costs.at["cement capture", "fixed"] * costs.at['gas', 'CO2 intensity'], @@ -1963,11 +1965,12 @@ def add_industry(n, costs): ) #assume enough local waste heat for CC - n.add("Link", - "process emissions CC", + n.madd("Link", + spatial.co2.locations, + suffix=" process emissions CC", bus0="process emissions", bus1="co2 atmosphere", - bus2="co2 stored", # TODO co2: where to allocate if co2 is spatially resolved? + bus2=spatial.co2.nodes, carrier="process emissions CC", p_nom_extendable=True, capital_cost=costs.at["cement capture", "fixed"], From 36fdde788760e0f7fc943975ff57b64cfb10d83e Mon Sep 17 00:00:00 2001 From: Fabian Neumann Date: Fri, 9 Jul 2021 14:36:13 +0200 Subject: [PATCH 09/14] correctly name co2 submarine pipeline! --- 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 16eb12f6..ca956e44 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -403,7 +403,7 @@ def add_co2_network(n, costs): co2_links = create_network_topology(n, "CO2 pipeline ") cost_onshore = (1 - co2_links.underwater_fraction) * costs.at['CO2 pipeline', 'fixed'] * co2_links.length - cost_submarine = co2_links.underwater_fraction * costs.at['CO2 pipeline submarine', 'fixed'] * co2_links.length + cost_submarine = co2_links.underwater_fraction * costs.at['CO2 submarine pipeline', 'fixed'] * co2_links.length capital_cost = cost_onshore + cost_submarine n.madd("Link", From 3754643e8192c57452c84d7a8a3639abd17a49a3 Mon Sep 17 00:00:00 2001 From: Fabian Neumann Date: Fri, 6 Aug 2021 12:46:03 +0200 Subject: [PATCH 10/14] add co2 sequestration potential global constraint --- scripts/prepare_sector_network.py | 9 +-------- scripts/solve_network.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index ca956e44..659fbf37 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -45,7 +45,7 @@ def define_spatial(nodes): spatial.co2.vents = nodes + " co2 vent" else: spatial.co2.nodes = ["co2 stored"] - spatial.co2.locations = "EU" + spatial.co2.locations = ["EU"] spatial.co2.vents = ["co2 vent"] spatial.co2.df = pd.DataFrame(vars(spatial.co2), index=nodes) @@ -379,13 +379,6 @@ def add_co2_tracking(n, options): bus=spatial.co2.nodes ) - # TODO if nodally resolved total allowed sequestration needs to - # be an extra_functionality constraint - # (best to implement it this way for either case) - # let e_nom_max represent geological potential - # don't forget to log duals of extra functionality! - # options['co2_sequestration_potential'] * 1e6 - if options['co2_vent']: n.madd("Link", diff --git a/scripts/solve_network.py b/scripts/solve_network.py index 8c0313f1..3796bc4d 100644 --- a/scripts/solve_network.py +++ b/scripts/solve_network.py @@ -3,6 +3,7 @@ import pypsa import numpy as np +import pandas as pd from pypsa.linopt import get_var, linexpr, define_constraints @@ -150,9 +151,27 @@ def add_chp_constraints(n): define_constraints(n, lhs, "<=", 0, 'chplink', 'backpressure') +def add_co2_sequestration_limit(n, sns): + + co2_stores = n.stores.loc[n.stores.carrier=='co2 stored'].index + + if co2_stores.empty or ('Store', 'e') not in n.variables.index: + return + + vars_final_co2_stored = get_var(n, 'Store', 'e').loc[sns[-1], co2_stores] + + lhs = linexpr((1, vars_final_co2_stored)).sum() + rhs = n.config["sector"].get("co2_sequestration_potential", 200) * 1e6 + + name = 'co2_sequestration_limit' + define_constraints(n, lhs, "<=", rhs, 'GlobalConstraint', + 'mu', axes=pd.Index([name]), spec=name) + + def extra_functionality(n, snapshots): add_chp_constraints(n) add_battery_constraints(n) + add_co2_sequestration_limit(n, snapshots) def solve_network(n, config, opts='', **kwargs): From d7a290df31737f3127e05868c83ff7cb36ddd7f2 Mon Sep 17 00:00:00 2001 From: Fabian Neumann Date: Fri, 6 Aug 2021 15:51:07 +0200 Subject: [PATCH 11/14] add release note --- doc/release_notes.rst | 8 ++++++++ doc/spatial_resolution.rst | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/doc/release_notes.rst b/doc/release_notes.rst index bd99ce16..a24ccb7c 100644 --- a/doc/release_notes.rst +++ b/doc/release_notes.rst @@ -60,6 +60,14 @@ Future release These are included in the environment specifications of PyPSA-Eur. * Consistent use of ``__main__`` block and further unspecific code cleaning. * Distinguish costs for home battery storage and inverter from utility-scale battery costs. +* Add option to regionally resolve CO2 storage and add CO2 pipeline transport because geological storage potential, + CO2 utilisation sites and CO2 capture sites may be separated. + The CO2 network is built from zero based on the topology of the electricity grid (greenfield). + Pipelines are assumed to be bidirectional and lossless. + Furthermore, neither retrofitting of natural gas pipelines (required pressures are too high, 80-160 bar vs <80 bar) + nor other modes of CO2 transport (by ship, road or rail) are considered. + The regional representation of CO2 is activated with the config setting ``sector: co2_network: true`` but is deactivated by default. + The global limit for CO2 sequestration now applies to the sum of all CO2 stores via an ``extra_functionality`` constraint. diff --git a/doc/spatial_resolution.rst b/doc/spatial_resolution.rst index 1be9f3ad..13e94543 100644 --- a/doc/spatial_resolution.rst +++ b/doc/spatial_resolution.rst @@ -48,7 +48,7 @@ Solid biomass: single node for Europe, until transport costs can be incorporated. CO2: single node for Europe, but a transport and storage cost is added for -sequestered CO2. +sequestered CO2. Optionally: nodal, with CO2 transport via pipelines. Liquid hydrocarbons: single node for Europe, since transport costs for liquids are low. From e1a0a7d5fd45c83a2f4eeee371e47952f1c3972c Mon Sep 17 00:00:00 2001 From: Fabian Neumann Date: Tue, 10 Aug 2021 10:31:06 +0200 Subject: [PATCH 12/14] set co2 sequestration cost to 10 EUR/t excl. transport --- config.default.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.default.yaml b/config.default.yaml index b2de9bf9..66a9f299 100644 --- a/config.default.yaml +++ b/config.default.yaml @@ -223,7 +223,7 @@ sector: co2_vent: true SMR: true co2_sequestration_potential: 200 #MtCO2/a sequestration potential for Europe - co2_sequestration_cost: 20 #EUR/tCO2 for transport and sequestration of CO2 + co2_sequestration_cost: 10 #EUR/tCO2 for sequestration of CO2 co2_network: false cc_fraction: 0.9 # default fraction of CO2 captured with post-combustion capture hydrogen_underground_storage: true From 960d857d0bdf5d290878f7530e60902ed2909ca5 Mon Sep 17 00:00:00 2001 From: lisazeyen <35347358+lisazeyen@users.noreply.github.com> Date: Fri, 24 Sep 2021 15:29:04 +0200 Subject: [PATCH 13/14] Update config.default.yaml add color for CO2 pipelines --- config.default.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/config.default.yaml b/config.default.yaml index 66a9f299..14a6cc0a 100644 --- a/config.default.yaml +++ b/config.default.yaml @@ -467,6 +467,7 @@ plotting: hot water storage: '#BBBBBB' hot water charging: '#BBBBBB' hot water discharging: '#999999' + CO2 pipeline: '#999999' CHP: r CHP heat: r CHP electric: r From 7ed20aba7a06d02f5a3895b24857b6f3841f715d Mon Sep 17 00:00:00 2001 From: lisazeyen <35347358+lisazeyen@users.noreply.github.com> Date: Fri, 24 Sep 2021 15:30:43 +0200 Subject: [PATCH 14/14] Update prepare_sector_network.py add logger info if CO2 network is added --- scripts/prepare_sector_network.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index 33f9c4b6..b3fb0426 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -392,7 +392,8 @@ def add_co2_tracking(n, options): def add_co2_network(n, costs): - + + logger.info("Adding CO2 network.") co2_links = create_network_topology(n, "CO2 pipeline ") cost_onshore = (1 - co2_links.underwater_fraction) * costs.at['CO2 pipeline', 'fixed'] * co2_links.length