From 555002a35bc527e9750214ebc3584c489b8f9498 Mon Sep 17 00:00:00 2001 From: Fabian Neumann Date: Wed, 19 May 2021 13:57:44 +0200 Subject: [PATCH 1/9] fixup: remove remaining instances of {network} wildcard from recent PR --- Snakefile | 4 ++-- scripts/build_retro_cost.py | 2 +- scripts/prepare_sector_network.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Snakefile b/Snakefile index c8b1d65e..9ab7d2f1 100644 --- a/Snakefile +++ b/Snakefile @@ -179,7 +179,7 @@ rule build_industrial_production_per_country: input: ammonia_production="resources/ammonia_production.csv" output: - industrial_production_per_country="resources/industrial_production_per_country.csv" + industrial_production_per_country="resources/industrial_production_per_country.csv" threads: 1 resources: mem_mb=1000 script: 'scripts/build_industrial_production_per_country.py' @@ -282,7 +282,7 @@ rule build_retro_cost: input: building_stock="data/retro/data_building_stock.csv", data_tabula="data/retro/tabula-calculator-calcsetbuilding.csv", - air_temperature = "resources/temp_air_total_{network}_s{simpl}_{clusters}.nc", + air_temperature = "resources/temp_air_total_elec_s{simpl}_{clusters}.nc", u_values_PL="data/retro/u_values_poland.csv", tax_w="data/retro/electricity_taxes_eu.csv", construction_index="data/retro/comparative_level_investment.csv", diff --git a/scripts/build_retro_cost.py b/scripts/build_retro_cost.py index cb0acf41..7730e490 100644 --- a/scripts/build_retro_cost.py +++ b/scripts/build_retro_cost.py @@ -841,7 +841,7 @@ if __name__ == "__main__": building_stock="data/retro/data_building_stock.csv", data_tabula="data/retro/tabula-calculator-calcsetbuilding.csv", u_values_PL="data/retro/u_values_poland.csv", - air_temperature = "resources/temp_air_total_{network}_s{simpl}_{clusters}.nc", + air_temperature = "resources/temp_air_total_elec_s{simpl}_{clusters}.nc", tax_w="data/retro/electricity_taxes_eu.csv", construction_index="data/retro/comparative_level_investment.csv", floor_area_missing="data/retro/floor_area_missing.csv", diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index f30fad57..485c70cc 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -1915,7 +1915,7 @@ if __name__ == "__main__": retro_cost_energy = "resources/retro_cost_elec_s{simpl}_{clusters}.csv", floor_area = "resources/floor_area_elec_s{simpl}_{clusters}.csv" ), - output=['results/version-cb48be3/prenetworks/{network}_s{simpl}_{clusters}_lv{lv}__{sector_opts}_{planning_horizons}.nc'] + output=['results/version-cb48be3/prenetworks/elec_s{simpl}_{clusters}_lv{lv}__{sector_opts}_{planning_horizons}.nc'] ) import yaml with open('config.yaml', encoding='utf8') as f: From e4848d603d2d9cdaceef827793d2b36ae51f4060 Mon Sep 17 00:00:00 2001 From: Tom Brown Date: Fri, 21 May 2021 12:37:02 +0200 Subject: [PATCH 2/9] PyPSA-Eur-Sec Version 0.5.0 See the release notes: https://pypsa-eur-sec.readthedocs.io/en/latest/release_notes.html#pypsa-eur-sec-0-5-0-21st-may-2021 --- config.default.yaml | 2 +- doc/conf.py | 4 ++-- doc/release_notes.rst | 19 +++++++++++++++++-- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/config.default.yaml b/config.default.yaml index 74a61b85..617e716a 100644 --- a/config.default.yaml +++ b/config.default.yaml @@ -1,4 +1,4 @@ -version: 0.4.0 +version: 0.5.0 logging_level: INFO diff --git a/doc/conf.py b/doc/conf.py index af5a2aa8..1961a23b 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -70,9 +70,9 @@ author = u'2019-2020 Tom Brown (KIT), Marta Victoria (Aarhus University), Lisa Z # built documents. # # The short X.Y version. -version = u'0.4' +version = u'0.5' # The full version, including alpha/beta/rc tags. -release = u'0.4.0' +release = u'0.5.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/doc/release_notes.rst b/doc/release_notes.rst index a9561857..8d2a44f5 100644 --- a/doc/release_notes.rst +++ b/doc/release_notes.rst @@ -3,16 +3,31 @@ Release Notes ########################################## Future release -=================== +============== + +* Include new features here. + + +PyPSA-Eur-Sec 0.5.0 (21st May 2021) +=================================== + +This release includes improvements to the cost database for building retrofits, carbon budget management and wildcard settings, as well as an import bugfix for the emissions from land transport. + +This release is known to work with `PyPSA-Eur `_ Version 0.3.0 and `Technology Data `_ Version 0.2.0. + +Please note that the data bundle has also been updated. + +New features and bugfixes: -* For the myopic investment option, a carbon budget and a type of decay (exponential or beta) can be selected in the ``config.yaml`` file to distribute the budget across the ``planning_horizons``. For example, ``cb40ex0`` in the ``{sector_opts}`` wildcard will distribute a carbon budget of 40 GtCO2 following an exponential decay with initial growth rate 0. * The cost database for retrofitting of the thermal envelope of buildings has been updated. Now, for calculating the space heat savings of a building, losses by thermal bridges and ventilation are included as well as heat gains (internal and by solar radiation). See the section :ref:`retro` for more details on the retrofitting module. +* For the myopic investment option, a carbon budget and a type of decay (exponential or beta) can be selected in the ``config.yaml`` file to distribute the budget across the ``planning_horizons``. For example, ``cb40ex0`` in the ``{sector_opts}`` wildcard will distribute a carbon budget of 40 GtCO2 following an exponential decay with initial growth rate 0. * Added an option to alter the capital cost or maximum capacity of carriers by a factor via ``carrier+factor`` in the ``{sector_opts}`` wildcard. This can be useful for exploring uncertain cost parameters. Example: ``solar+c0.5`` reduces the ``capital_cost`` of solar to 50\% of original values. Similarly ``solar+p3`` multiplies the ``p_nom_max`` by 3. * Rename the bus for European liquid hydrocarbons from ``Fischer-Tropsch`` to ``EU oil``, since it can be supplied not just with the Fischer-Tropsch process, but also with fossil oil. * Bugfix: The new separation of land transport by carrier in Version 0.4.0 failed to account for the carbon dioxide emissions from internal combustion engines. This is now treated as a negative load on the atmospheric carbon dioxide bus, just like aviation emissions. * Bugfix: Fix reading in of ``pypsa-eur/resources/powerplants.csv`` to PyPSA-Eur Version 0.3.0 (use column attribute name ``DateIn`` instead of old ``YearDecommissioned``). * Bugfix: Make sure that ``Store`` components (battery and H2) are also removed from PyPSA-Eur, so they can be added later by PyPSA-Eur-Sec. +Thanks to Lisa Zeyen (KIT) for the retrofitting improvements and Marta Victoria (Aarhus University) for the carbon budget and wildcard management. PyPSA-Eur-Sec 0.4.0 (11th December 2020) ========================================= From 1ede513990bb22690cacf8e2859c1dd5950a5367 Mon Sep 17 00:00:00 2001 From: Tom Brown Date: Fri, 21 May 2021 13:40:22 +0200 Subject: [PATCH 3/9] doc: Fix badge link for doc and clarifications in release notes --- doc/index.rst | 4 ++-- doc/release_notes.rst | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/index.rst b/doc/index.rst index 39c8ab04..1bf307f5 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -4,8 +4,8 @@ PyPSA-Eur-Sec: A Sector-Coupled Open Optimisation Model of the European Energy S .. image:: https://img.shields.io/github/v/release/pypsa/pypsa-eur-sec?include_prereleases :alt: GitHub release (latest by date including pre-releases) -.. image:: https://readthedocs.org/projects/pypsa-eur/badge/?version=latest - :target: https://pypsa-eur.readthedocs.io/en/latest/?badge=latest +.. image:: https://readthedocs.org/projects/pypsa-eur-sec/badge/?version=latest + :target: https://pypsa-eur-sec.readthedocs.io/en/latest/?badge=latest :alt: Documentation Status .. image:: https://img.shields.io/github/license/pypsa/pypsa-eur-sec diff --git a/doc/release_notes.rst b/doc/release_notes.rst index 8d2a44f5..cca25c7f 100644 --- a/doc/release_notes.rst +++ b/doc/release_notes.rst @@ -11,7 +11,7 @@ Future release PyPSA-Eur-Sec 0.5.0 (21st May 2021) =================================== -This release includes improvements to the cost database for building retrofits, carbon budget management and wildcard settings, as well as an import bugfix for the emissions from land transport. +This release includes improvements to the cost database for building retrofits, carbon budget management and wildcard settings, as well as an important bugfix for the emissions from land transport. This release is known to work with `PyPSA-Eur `_ Version 0.3.0 and `Technology Data `_ Version 0.2.0. @@ -23,7 +23,7 @@ New features and bugfixes: * For the myopic investment option, a carbon budget and a type of decay (exponential or beta) can be selected in the ``config.yaml`` file to distribute the budget across the ``planning_horizons``. For example, ``cb40ex0`` in the ``{sector_opts}`` wildcard will distribute a carbon budget of 40 GtCO2 following an exponential decay with initial growth rate 0. * Added an option to alter the capital cost or maximum capacity of carriers by a factor via ``carrier+factor`` in the ``{sector_opts}`` wildcard. This can be useful for exploring uncertain cost parameters. Example: ``solar+c0.5`` reduces the ``capital_cost`` of solar to 50\% of original values. Similarly ``solar+p3`` multiplies the ``p_nom_max`` by 3. * Rename the bus for European liquid hydrocarbons from ``Fischer-Tropsch`` to ``EU oil``, since it can be supplied not just with the Fischer-Tropsch process, but also with fossil oil. -* Bugfix: The new separation of land transport by carrier in Version 0.4.0 failed to account for the carbon dioxide emissions from internal combustion engines. This is now treated as a negative load on the atmospheric carbon dioxide bus, just like aviation emissions. +* Bugfix: The new separation of land transport by carrier in Version 0.4.0 failed to account for the carbon dioxide emissions from internal combustion engines in land transport. This is now treated as a negative load on the atmospheric carbon dioxide bus, just like aviation emissions. * Bugfix: Fix reading in of ``pypsa-eur/resources/powerplants.csv`` to PyPSA-Eur Version 0.3.0 (use column attribute name ``DateIn`` instead of old ``YearDecommissioned``). * Bugfix: Make sure that ``Store`` components (battery and H2) are also removed from PyPSA-Eur, so they can be added later by PyPSA-Eur-Sec. From e367f8ae11380050f4e0265afa1228c39fc5fe62 Mon Sep 17 00:00:00 2001 From: Leon <5868911+leonsn@users.noreply.github.com> Date: Mon, 24 May 2021 22:11:24 +0200 Subject: [PATCH 4/9] Fix error when running without the industry sector (#96) Fixing that the code stops with an error if running without the industry sector, e.g. only including electricity and heat. When the industry sector is not included, balances_df.index.levels[0] does not include "process emissions". Using the XOR operator "^" does then add it instead of removing it when compared to the co2_carriers list. The XOR operator does only work as intended, i.e. excluding the three emission-related strings, when these strings are already in the original list. The proposed change fixes the issue. --- scripts/plot_summary.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/plot_summary.py b/scripts/plot_summary.py index bc852e70..9b3a81e1 100644 --- a/scripts/plot_summary.py +++ b/scripts/plot_summary.py @@ -177,7 +177,7 @@ def plot_balances(): balances_df = pd.read_csv(snakemake.input.balances,index_col=list(range(3)),header=list(range(n_header))) balances = {i.replace(" ","_") : [i] for i in balances_df.index.levels[0]} - balances["energy"] = balances_df.index.levels[0].symmetric_difference(co2_carriers) + balances["energy"] = [i for i in balances_df.index.levels[0] if i not in co2_carriers] for k,v in balances.items(): @@ -401,4 +401,4 @@ if __name__ == "__main__": opts=sector_opts.split('-') for o in opts: if "cb" in o: - plot_carbon_budget_distribution() \ No newline at end of file + plot_carbon_budget_distribution() From 0e3d21f5a4f8470bfaa8a0d0765acb9544b859d2 Mon Sep 17 00:00:00 2001 From: lisazeyen <35347358+lisazeyen@users.noreply.github.com> Date: Tue, 25 May 2021 09:03:02 +0200 Subject: [PATCH 5/9] add EU oil bus already when adding land transport to be able to run the model without industry and avoid warning of missing bus. Add a check for scaling down total electricity demand to avoid warning of invalid value in double_scalar (#100) --- scripts/prepare_sector_network.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index 485c70cc..93def4c0 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -1154,6 +1154,12 @@ def add_land_transport(network): if ice_share > 0: + if "EU oil" not in network.buses.index: + network.madd("Bus", + ["EU oil"], + location="EU", + carrier="oil") + network.madd("Load", nodes, suffix=" land transport oil", @@ -1769,6 +1775,7 @@ def add_industry(network): #remove today's industrial electricity demand by scaling down total electricity demand for ct in n.buses.country.unique(): loads = n.loads.index[(n.loads.index.str[:2] == ct) & (n.loads.carrier == "electricity")] + if n.loads_t.p_set[loads].empty: continue factor = 1 - industrial_demand.loc[loads,"current electricity"].sum()/n.loads_t.p_set[loads].sum().sum() n.loads_t.p_set[loads] *= factor From bea8194b7b326bee3a438be354f944828c3df72b Mon Sep 17 00:00:00 2001 From: Fabian Neumann Date: Tue, 25 May 2021 09:42:01 +0200 Subject: [PATCH 6/9] prepare: add costs for biogas upgrading (#126) Co-authored-by: lisazeyen Co-authored-by: lisazeyen --- 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 93def4c0..94fb5048 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -1548,6 +1548,8 @@ def add_biomass(network): bus1="EU gas", bus2="co2 atmosphere", carrier="biogas to gas", + capital_cost=costs.loc["biogas upgrading", "fixed"], + marginal_cost=costs.loc["biogas upgrading", "VOM"], efficiency2=-costs.at['gas','CO2 intensity'], p_nom_extendable=True) From 32365312da1f5c5d8ed3c77786b7f92afcc157fd Mon Sep 17 00:00:00 2001 From: Fabian Neumann Date: Tue, 25 May 2021 15:51:38 +0200 Subject: [PATCH 7/9] retro: fix renaming u_values subsectors and btype (#127) by not looping the .replace() across all columns of the dataframe. Circumvents: TypeError: Cannot compare types 'ndarray(dtype=float64)' and 'str' --- scripts/build_retro_cost.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/build_retro_cost.py b/scripts/build_retro_cost.py index 7730e490..985c530f 100644 --- a/scripts/build_retro_cost.py +++ b/scripts/build_retro_cost.py @@ -253,7 +253,8 @@ def prepare_building_stock_data(): axis=1, inplace=True, errors="ignore") - u_values = u_values.apply(lambda x: x.replace(rename_sectors)) + u_values.subsector.replace(rename_sectors, inplace=True) + u_values.btype.replace(rename_sectors, inplace=True) # for missing weighting of surfaces of building types assume MFH u_values["assumed_subsector"] = u_values.subsector From 4bc5d94d42e930bbe64860bffc03d6fa097ac6e8 Mon Sep 17 00:00:00 2001 From: Tom Brown Date: Tue, 1 Jun 2021 17:36:59 +0200 Subject: [PATCH 8/9] README: Add network picture to make scope clear --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 0ec3de71..7995217c 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,14 @@ them: ![sector diagram](graphics/multisector_figure.png) +Each of these sectors is built up on the transmission network nodes +from [PyPSA-Eur](https://github.com/PyPSA/pypsa-eur): + +![network diagram](https://github.com/PyPSA/pypsa-eur/blob/master/doc/img/base.png?raw=true) + +For computational reasons the model is usually clustered down +to 50-200 nodes. + PyPSA-Eur-Sec was initially based on the model PyPSA-Eur-Sec-30 described in the paper [Synergies of sector coupling and transmission From e542efd552bbd404dde2e42fc5998caf303c4408 Mon Sep 17 00:00:00 2001 From: Tom Brown Date: Tue, 1 Jun 2021 17:42:14 +0200 Subject: [PATCH 9/9] README: Fix date of preprint (was too optimistic...) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7995217c..fe81519b 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ problems that distort the results. See the github repository [issues](https://github.com/PyPSA/pypsa-eur-sec/issues) for some of the problems (please feel free to help or make suggestions). There is neither documentation nor a paper yet, but we hope to have a preprint -out by summer 2020. We cannot support this model if you choose to use +out by autumn 2021. We cannot support this model if you choose to use it.