diff --git a/.zenodo.json b/.zenodo.json index 151a3f7b0a..af7b7c0d33 100644 --- a/.zenodo.json +++ b/.zenodo.json @@ -1,6 +1,6 @@ { "title": "MAgPIE - An Open Source land-use modeling framework", - "version": "4.6.11", + "version": "4.7.0", "creators": [ { "name": "Dietrich, Jan Philipp", @@ -90,7 +90,7 @@ "affiliation": "Potsdam Institute for Climate Impact Research" }, { - "name": "Führlich, Pascal", + "name": "Sauer, Pascal", "affiliation": "Potsdam Institute for Climate Impact Research", "orcid": "0000-0002-6856-8239" }, @@ -109,5 +109,5 @@ "license": { "id": "AGPL-3.0-or-later" }, - "publication_date": "2023-09-05" + "publication_date": "2023-12-11" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d66df98b4..775263e8a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,27 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## [4.7.0] - 2023-12-11 + +### changed +- **14_yields_and_config** The new default is to not use yield calibration factors from a calibration run. The switch s14_use_yield_calib can optionally reenable the use of yield calibration factors. +- **36_employment** regression between hourly labor regression and GDP pc changed from linear to log-log +- **inputdata** Now using inputdata rev4.94 which is based on 67420 cells (67k, previously 59k) +- **scripts** For the emulator scripts select a different bioenergy demand variable that excludes bioenergy sources other than second generation bioenergy crops. Set the minimal bioenergy demand to zero. Both avoid artificial clustering of data points and allow for better fits. +- **scripts** LUH2_disaggregation output script was modified. Specifically, flooded area was made compatible with the LUH definition, cropland and grazing land were added to the states.nc file, and specific naming/details (datatype, zname, xname, and yname) were added when creating the .nc files. + +### added +- **14_yields/config** Added option for considering impacts of land degradation on yields. If `s14_degradation` is switched to 1, MAgPIE will include cluster-specific information on the state of nature's contributions to people relevant for yields `./modules/14_yields/input/f14_yld_ncp_report.cs3`. +- **18_residues** Included cluster-level residue realization, for cluster-level production of residues (but balancing of recycling and burning budgets remains at region-level, for computational lightness) +- **32_forestry** new interface `vm_land_forestry` +- **58_peatland** added realization "v2" with updated peatland map and GHG emission factors + +### fixed +- **inputdata** There was a major bug (related to proj/terra) in the rev4.91 inputdata that was fixed with rev4.92 +- **inputdata** There was another bug (terra default na.rm changed) in the inputdata that was fixed with rev4.93 +- **scripts** Fixed a bug in NPI/NDC calculations leading to missing AD policies when run with 67k + + ## [4.6.11] - 2023-09-05 ### changed @@ -760,7 +781,8 @@ This release version is focussed on consistency between the MAgPIE setup and the First open source release of the framework. See [MAgPIE 4.0 paper](https://doi.org/10.5194/gmd-12-1299-2019) for more information. -[Unreleased]: https://github.com/magpiemodel/magpie/compare/v4.6.11...develop +[Unreleased]: https://github.com/magpiemodel/magpie/compare/v4.7.0...develop +[4.7.0]: https://github.com/magpiemodel/magpie/compare/v4.6.11...v4.7.0 [4.6.11]: https://github.com/magpiemodel/magpie/compare/v4.6.10...v4.6.11 [4.6.10]: https://github.com/magpiemodel/magpie/compare/v4.6.9...v4.6.10 [4.6.9]: https://github.com/magpiemodel/magpie/compare/v4.6.8...v4.6.9 diff --git a/CITATION.cff b/CITATION.cff index dc43cf0107..80b1e60eeb 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -106,11 +106,11 @@ authors: given-names: Anne affiliation: "Potsdam Institute for Climate Impact Research" - - family-names: Führlich + - family-names: Sauer given-names: Pascal orcid: https://orcid.org/0000-0002-6856-8239 affiliation: "Potsdam Institute for Climate Impact Research" - email: pascal.fuehrlich@pik-potsdam.de + email: pascal.sauer@pik-potsdam.de - family-names: Lotze-Campen given-names: Hermann @@ -125,8 +125,8 @@ authors: email: popp@pik-potsdam.de title: MAgPIE - An Open Source land-use modeling framework -version: 4.6.11 -date-released: 2023-09-05 +version: 4.7.0 +date-released: 2023-12-11 repository-code: https://github.com/magpiemodel/magpie keywords: - landuse diff --git a/README.md b/README.md index 84a747e145..7ae86d6331 100644 --- a/README.md +++ b/README.md @@ -24,8 +24,8 @@ https://www.pik-potsdam.de/research/projects/activities/land-use-modelling/magpi A framework description paper has been published in Geoscientific Model Development (GMD): https://doi.org/10.5194/gmd-12-1299-2019 -The model documentation for version 4.6.11 can be found at -https://rse.pik-potsdam.de/doc/magpie/4.6.11/ +The model documentation for version 4.7.0 can be found at +https://rse.pik-potsdam.de/doc/magpie/4.7.0/ A most recent version of the documentation can also be extracted from the model source code via the R package goxygen @@ -37,7 +37,7 @@ Please find a set of tutorials here https://magpiemodel.github.io/tutorials/. This guide will give you a brief technical introduction in how to install, run and use the model and how to analyse the model output. -Please pay attentions to the MAgPIE Coding Etiquette when you modify the code. +Please pay attention to the MAgPIE Coding Etiquette when you modify the code. The Coding Etiquette you find at the beginning of the documentation mentioned above. The Coding Etiquette explains also the naming conventions and other structural characteristics. @@ -150,7 +150,7 @@ following requirements: For other dependencies comparable measures should apply. When a dependency is added this dependency should be added to the *HOW TO INSTALL* section in the -README file of the model framework (mentioning the depencendy and explaining +README file of the model framework (mentioning the dependency and explaining how it can be installed). If not all requirements can be fulfilled by the new dependency this case should be discussed with the model maintainer (magpie@pik-potsdam.de) to find a good solution for it. @@ -188,7 +188,7 @@ magpie@pik-potsdam.de Please contact magpie@pik-potsdam.de ## CITATION -See file CITATION.cff or the [How-to-Cite section](https://rse.pik-potsdam.de/doc/magpie/4.6.11/#how-to-cite) in the model documentation for information how to cite the model. +See file CITATION.cff or the [How-to-Cite section](https://rse.pik-potsdam.de/doc/magpie/4.7.0/#how-to-cite) in the model documentation for information how to cite the model. ## AUTHORS See list of authors in CITATION.cff diff --git a/config/default.cfg b/config/default.cfg index 3d0ab80977..4bb8230385 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -22,10 +22,10 @@ cfg$model <- "main.gms" #def = "main.gms" #### input settings #### # which input data sets should be used? -cfg$input <- c(regional = "rev4.88_h12_magpie.tgz", - cellular = "rev4.88_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", - validation = "rev4.88_h12_validation.tgz", - additional = "additional_data_rev4.43.tgz", +cfg$input <- c(regional = "rev4.94_h12_magpie.tgz", + cellular = "rev4.94_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", + validation = "rev4.94_h12_validation.tgz", + additional = "additional_data_rev4.46.tgz", calibration = "calibration_H12_per_ton_fao_may22_glo_08Aug23.tgz") # NOTE: It is recommended to recalibrate the model when changing cellular input data @@ -56,11 +56,18 @@ cfg$force_download <- FALSE cfg$force_replace <- FALSE # Settings for the yield calibration +# For this yield calibration (that uses results from a special MAgPIE calibration run +# triggered by the recalibrate switch) to be activated the switch s14_use_yield_calib needs +# to be turned on. (Default is off) +# This switch should only be activated for penalty_apr22 crop realization. +# For other realizations, it is recommended not to use this yield calibration. +# +# Switch to turn on/off recalibration of yields. # * (TRUE): Yield calibration will be performed # * (ifneeded): Yield calibration will only be executed if input data is # * downloaded from repository # * (FALSE): Yield calibration will not be performed -cfg$recalibrate <- "ifneeded" # def = "ifneeded" +cfg$recalibrate <- FALSE # def = FALSE # Up to which accuracy shall be recalibrated? cfg$calib_accuracy <- 0.05 # def = 0.05 # What is the maximum number of iterations if the precision goal is not reached? @@ -307,6 +314,23 @@ cfg$gms$s14_limit_calib <- 1 # def = 1 # NOTE: It is recommended to recalibrate the model when changing this setting! cfg$gms$s14_calib_ir2rf <- 1 # def = 1 +# * Switch to include yield impacts of land degradation. +# * The state of yield-relevant nature's contributions to people (NCP) +# * is reported through ./modules/14_yields/input/f14_yld_ncp_report.cs3 +# * based on estimated outcomes for soil loss or pollination sufficiency +# * per cluster from an existing model run. +# * options: 1 (yields are reduced based on yield reduction coefficients) +# * 0 (land degradation is switched off) +cfg$gms$s14_degradation <- 0 # def = 0 + +# Switch to toggle the use of yield calibration factors (that resulted from a calibration run). +# If 0, no yield calibration factors are used, meaning all calibration factors are set to 1. +# If 1, yield calibration factors are used. (For this option to function, either an existing calibration file +# must be supplied in the input directory, or yields must be recalibrated during preprocessing.) +# This switch should only be activated for penalty_apr22 crop realization. +# For other realizations, it is recommended not to use this yield calibration. +cfg$gms$s14_use_yield_calib <- 0 # def = 0 + # ***--------------------- 15_food --------------------------------------- # * (anthropometrics_jan18): estimates food using scenario dependent regression # * and demography drivers @@ -703,7 +727,7 @@ cfg$gms$c31_grassl_yld_scenario <- "cc" # def = "cc" # * SSP scenario switch for pasture suitability areas (only take effect for realization grasslands_apr22) # * options: ssp126, ssp245, ssp370, ssp460, ssp585 -# * nocc (fixed to values from 1995), +# * nocc (fixed to values from 1995), # * nocc_hist (ssp245 until year defined in sm_fix_cc, fixed thereafter) cfg$gms$c31_past_suit_scen <- "ssp370" # def = "ssp370" @@ -1281,8 +1305,8 @@ cfg$gms$nitrogen <- "rescaled_jan21" # def = rescaled_jan21 cfg$gms$carbon <- "normal_dec17" # def = normal_dec17 # * RCP scenario of land carbon sink adjustment factor, from Grassi et al 2021 -# * options: RCP19, RCP26, RCP34, RCP45, RCP60, RCPBU, -# * nocc (fixed to values from 1995), +# * options: RCP19, RCP26, RCP34, RCP45, RCP60, RCPBU, +# * nocc (fixed to values from 1995), # * nocc_hist (RCPBU until year defined in sm_fix_cc, fixed thereafter) cfg$gms$c52_land_carbon_sink_rcp <- "RCPBU" @@ -1515,8 +1539,14 @@ cfg$gms$s57_maxmac_ch4_awms <- -1 # def = -1 # ***--------------------- 58_peatland ------------------------------------ # * (off): Peatland area and associated GHG emissions are assumed zero -# * (on): Peatland area is initialized with present-day degraded and intact peatland. -# * GHG emissions are calculated using IPCC Tier 1 emission factors (2013 Wetland supplement). +# * (on): Peatland area is initialized with degraded and intact peatland for the year 2015, +# * and projected into the future based on changes in managed land. +# * GHG emissions are calculated using IPCC Tier 1 emission factors (2013 Wetland supplement). +# * (v2): Peatland area is initialized with degraded and intact peatland area for the year 2020, +# * and projected into the future based on changes in managed land. +# * For boreal and tropical climates, GHG emissions are calculated using emission +# * factors from the IPCC 2013 Wetland supplement. For temperate climates, more recent +# * estimates from Tiemeyer et al 2020 are used. cfg$gms$peatland <- "on" # def = on # * peatland rewetting @@ -1544,9 +1574,9 @@ cfg$gms$s58_cost_degrad_recur <- 0 # def = 0 # * High costs make sure that the balance variables are only used as a last resort. cfg$gms$s58_cost_balance <- 1e+06 # def = 1e+06 -# * Switch for fixing peatland area to 2015 levels from 1995 onwards until the given year -# * Note: The initial peatland area is only available for the year 2015. -# * Fixing the peatland area in previous time steps to 2015 levels provides a better +# * Switch for fixing peatland area between 1995 and the year given by s58_fix_peatland +# * Note: Depending on the realisation, the initial peatland area is only available for the year 2015 (`on`) or 2020 (`v2`). +# * Fixing peatland area in previous time steps provides a better # * proxy for GHG emissions from peatlands than assuming no peatland area. cfg$gms$s58_fix_peatland <- 2015 # def = 2015 diff --git a/config/scenario_config.csv b/config/scenario_config.csv index 8fc52c3c0f..1bc205be25 100644 --- a/config/scenario_config.csv +++ b/config/scenario_config.csv @@ -79,7 +79,7 @@ gms$s73_timber_demand_switch;;;;;;;;;;;;;;;;;;;;;;1;1;1;1;1;;;;;1;1;0;;;;;;;;;;; gms$s35_forest_damage;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4;4;4;4;4;;;;;;; gms$c32_shock_scenario;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;none;002lin2030;004lin2030;008lin2030;016lin2030;;;;;;; gms$c35_shock_scenario;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;none;002lin2030;004lin2030;008lin2030;016lin2030;;;;;;; -input['cellular'];;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;rev4.88_h12_0bd54110_cellularmagpie_c200_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz;rev4.88_h12_6819938d_cellularmagpie_c200_MRI-ESM2-0-ssp126_lpjml-8e6c5eb1.tgz;rev4.88_h12_1b5c3817_cellularmagpie_c200_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz;rev4.88_h12_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;rev4.88_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz;rev4.88_h12_09a63995_cellularmagpie_c200_MRI-ESM2-0-ssp585_lpjml-8e6c5eb1.tgz; +input['cellular'];;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;rev4.94_h12_0bd54110_cellularmagpie_c200_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz;rev4.94_h12_6819938d_cellularmagpie_c200_MRI-ESM2-0-ssp126_lpjml-8e6c5eb1.tgz;rev4.94_h12_1b5c3817_cellularmagpie_c200_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz;rev4.94_h12_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;rev4.94_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz;rev4.94_h12_09a63995_cellularmagpie_c200_MRI-ESM2-0-ssp585_lpjml-8e6c5eb1.tgz; gms$c52_land_carbon_sink_rcp;;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;RCP19;RCP26;RCP45;RCP60;RCPBU;RCPBU; gms$c57_macc_version;;;;;;;;;;;;;;;;;;;;;;;;;;;PBL_2022;PBL_2022;PBL_2022;PBL_2022;;;;;;;;;;;;;;; gms$c57_macc_scenario;;;;;;;;;;;;;;;;;;;;;;;;;;;Default;Optimistic;Default;Optimistic;;;;;;;;;;;;;;; diff --git a/config/scenario_config_emulator.csv b/config/scenario_config_emulator.csv index e415b5b1a8..d071e157ae 100644 --- a/config/scenario_config_emulator.csv +++ b/config/scenario_config_emulator.csv @@ -1,6 +1,16 @@ -title;start;mag_scen;co2tax_name;co2tax_2025 -2;1;SSP2,NPI;Base;C_SSP2-Base-rem-5 -3;0;SSP2,NDC;NDC;C_SSP2-NDC-rem-5 -4;0;SSP2,NDC;PkBudg1300;C_SSP2-PkBudg1300-rem-5 -5;0;SSP2,NDC;PkBudg1100;C_SSP2-PkBudg1100-rem-5 -5;0;SSP2,NDC;PkBudg900;C_SSP2-PkBudg900-rem-5 +start;mag_scen;ghgtax_name;mifname;no_ghgprices_land_until +0;SDP-MC|NPI|nocc_hist;Base; C_SDP_MC-Base;y2150 +0;SDP-MC|NDC|nocc_hist;NDC; C_SDP_MC-NDC;y2150 +0;SDP-MC|NDC|nocc_hist;PkBudg500; C_SDP_MC-PkBudg500;y2030 +0;SSP1|NPI|nocc_hist;Base; C_SSP1-Base;y2150 +0;SSP1|NDC|nocc_hist;NDC; C_SSP1-NDC;y2150 +0;SSP1|NDC|nocc_hist;PkBudg1150; C_SSP1-PkBudg1150;y2030 +0;SSP1|NDC|nocc_hist;PkBudg500; C_SSP1-PkBudg500;y2030 +0;SSP2|NPI|nocc_hist;Base; C_SSP2EU-Base;y2150 +0;SSP2|NDC|nocc_hist;NDC; C_SSP2EU-NDC;y2150 +1;SSP2|NDC|nocc_hist;PkBudg1150; C_SSP2EU-PkBudg1150;y2030 +0;SSP2|NDC|nocc_hist;PkBudg500; C_SSP2EU-PkBudg500;y2030 +0;SSP5|NPI|nocc_hist;Base; C_SSP5-Base;y2150 +0;SSP5|NDC|nocc_hist;NDC; C_SSP5-NDC;y2150 +0;SSP5|NDC|nocc_hist;PkBudg1150; C_SSP5-PkBudg1150;y2030 +0;SSP5|NDC|nocc_hist;PkBudg500; C_SSP5-PkBudg500;y2030 diff --git a/config/scenario_fsec.csv b/config/scenario_fsec.csv index 5210788d95..28569804a8 100644 --- a/config/scenario_fsec.csv +++ b/config/scenario_fsec.csv @@ -5,6 +5,7 @@ gms$c09_pal_scenario;;;;SSP1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$s12_interest_lic;;;0.06;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$s12_interest_hic;;;0.04;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$food;anthro_iso_jun22;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$s14_use_yield_calib;1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$s15_exo_waste;;;;;;;;0;0;0;0;0;0;0;0;1;;;;;;;;;;;;;;;;;0;1;;;;;;;;;;;;;;; gms$s15_exo_diet;;;;;;;;1;1;1;1;1;1;1;1;0;;;;;;;;;;;;;;;;;1;1;;;;;;;;;;;;;;; gms$c15_kcal_scen;;;;;;;;no_underweight;half_overweight;endo;endo;endo;endo;endo;endo;endo;;;;;;;;;;;;;;;;;no_underweight_half_overweight;no_underweight_half_overweight;;;;;;;;;;;;;;; @@ -65,9 +66,9 @@ gms$s62_max_dem_bioplastic;0;;;;400;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$c70_fac_req_regr;reg;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$c70_feed_scen;;;;;;;;;;;;;;;;;;ssp1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$c73_build_demand;;;;;;;;;;;;;;;;;;;;;;;;50pc;;;;;;;;;;;;;;;;;;;;;;;;; -input['cellular'];rev4.87_FSEC_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;rev4.87_FSEC_0bd54110_cellularmagpie_c200_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz;rev4.87_FSEC_6819938d_cellularmagpie_c200_MRI-ESM2-0-ssp126_lpjml-8e6c5eb1.tgz;;rev4.87_FSEC_1b5c3817_cellularmagpie_c200_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz;rev4.87_FSEC_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;rev4.87_FSEC_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz;rev4.87_FSEC_09a63995_cellularmagpie_c200_MRI-ESM2-0-ssp585_lpjml-8e6c5eb1.tgz; -input['regional'];rev4.87_FSEC_magpie.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -input['validation'];rev4.87_FSEC_validation.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -input['additional'];additional_data_rev4.43.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +input['cellular'];rev4.94_FSEC_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;rev4.94_FSEC_0bd54110_cellularmagpie_c200_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz;rev4.94_FSEC_6819938d_cellularmagpie_c200_MRI-ESM2-0-ssp126_lpjml-8e6c5eb1.tgz;;rev4.94_FSEC_1b5c3817_cellularmagpie_c200_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz;rev4.94_FSEC_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;rev4.94_FSEC_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz;rev4.94_FSEC_09a63995_cellularmagpie_c200_MRI-ESM2-0-ssp585_lpjml-8e6c5eb1.tgz; +input['regional'];rev4.94_FSEC_magpie.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +input['validation'];rev4.94_FSEC_validation.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +input['additional'];additional_data_rev4.46.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; input['calibration'];calibration_FSEC_24Mar23.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; magicc_emis_scen;bjoernAR6_C_SSP2-NDC.mif;;;bjoernAR6_C_SSP2-PkBudg900.mif;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;bjoernAR6_C_SSP1-NDC.mif;;;;;;;;;;;;bjoernAR6_C_SSP1-PkBudg900.mif diff --git a/literature.bib b/literature.bib index 3478c9b626..697d7d6b71 100644 --- a/literature.bib +++ b/literature.bib @@ -881,6 +881,35 @@ @article{humpenoder_peatland_2020 pages = {104093}, } + +@article{leifeld_2018, + title = {The underappreciated potential of peatlands in global climate change mitigation strategies}, + volume = {9}, + copyright = {2018 The Author(s)}, + issn = {2041-1723}, + url = {https://www.nature.com/articles/s41467-018-03406-6}, + doi = {10.1038/s41467-018-03406-6}, + abstract = {Human activity, such as draining and mining of peatlands, is transforming these long-term carbon sinks into sources. Here, the authors assess current and future greenhouse gas (GHG) emissions from degrading peatlands and estimate the magnitude of potential GHG savings that could be achieved by restoring them.}, + language = {en}, + number = {1}, + urldate = {2018-05-11}, + journal = {Nature Communications}, + author = {Leifeld, J. and Menichetti, L.}, + month = mar, + year = {2018}, + pages = {1071}, +} + + +@book{IPCC_wetland_2013, + address = {Switzerland}, + title = {2013 {Supplement} to the 2006 {IPCC} {Guidelines} for {National} {Greenhouse} {Gas} {Inventories}: {Wetlands}}, + url = {http://www.ipcc-nggip.iges.or.jp/public/wetlands/}, + publisher = {IPCC}, + editor = {Hiraishi, T and Krug, T and Tanabe, K and Srivastava, N and Baasansuren, J and Fukuda, M and Troxler, T.G.}, + year = {2014}, +} + @article{valin_fooddemand_2013, title = {The future of food demand: understanding differences in global economic models}, issn = {1574-0862}, @@ -1472,3 +1501,85 @@ @article{olson_biome_2001 year = {2001}, pages = {933--938}, } + + +@article{tiemeyer_peatland_2020, + title = {A new methodology for organic soils in national greenhouse gas inventories: {Data} synthesis, derivation and application}, + volume = {109}, + issn = {1470160X}, + shorttitle = {A new methodology for organic soils in national greenhouse gas inventories}, + url = {https://linkinghub.elsevier.com/retrieve/pii/S1470160X19308325}, + doi = {10.1016/j.ecolind.2019.105838}, + abstract = {Drained organic soils are large sources of anthropogenic greenhouse gases (GHG) in many European and Asian countries. Therefore, these soils urgently need to be considered and adequately accounted for when attempting to decrease emissions from the Agriculture and Land Use, Land Use Change and Forestry (LULUCF) sectors. Here, we describe the methodology, data and results of the German approach for measurement, reporting and verification (MRV) of anthropogenic GHG emissions from drained organic soils and outline ways forward towards tracking drainage and rewetting. The methodology was developed for and is currently applied in the German GHG inventory under the United Nations Framework Convention on Climate Change (UNFCCC) and the Kyoto Protocol.}, + language = {en}, + urldate = {2023-06-19}, + journal = {Ecological Indicators}, + author = {Tiemeyer, Bärbel and Freibauer, Annette and Borraz, Elisa Albiac and Augustin, Jürgen and Bechtold, Michel and Beetz, Sascha and Beyer, Colja and Ebli, Martin and Eickenscheidt, Tim and Fiedler, Sabine and Förster, Christoph and Gensior, Andreas and Giebels, Michael and Glatzel, Stephan and Heinichen, Jan and Hoffmann, Mathias and Höper, Heinrich and Jurasinski, Gerald and Laggner, Andreas and Leiber-Sauheitl, Katharina and Peichl-Brak, Mandy and Drösler, Matthias}, + month = feb, + year = {2020}, + pages = {105838}, +} + + +@article{humpenoeder_overcoming_2022, + title = {Overcoming global inequality is critical for land-based mitigation in line with the {Paris} {Agreement}}, + volume = {13}, + copyright = {2022 The Author(s)}, + issn = {2041-1723}, + url = {https://www.nature.com/articles/s41467-022-35114-7}, + doi = {10.1038/s41467-022-35114-7}, + abstract = {Transformation pathways for the land sector in line with the Paris Agreement depend on the assumption of globally implemented greenhouse gas (GHG) emission pricing, and in some cases also on inclusive socio-economic development and sustainable land-use practices. In such pathways, the majority of GHG emission reductions in the land system is expected to come from low- and middle-income countries, which currently account for a large share of emissions from agriculture, forestry and other land use (AFOLU). However, in low- and middle-income countries the economic, financial and institutional barriers for such transformative changes are high. Here, we show that if sustainable development in the land sector remained highly unequal and limited to high-income countries only, global AFOLU emissions would remain substantial throughout the 21st century. Our model-based projections highlight that overcoming global inequality is critical for land-based mitigation in line with the Paris Agreement. While also a scenario purely based on either global GHG emission pricing or on inclusive socio-economic development would achieve the stringent emissions reductions required, only the latter ensures major co-benefits for other Sustainable Development Goals, especially in low- and middle-income regions.}, + language = {en}, + number = {1}, + urldate = {2022-12-02}, + journal = {Nature Communications}, + author = {Humpenöder, Florian and Popp, Alexander and Schleussner, Carl-Friedrich and Orlov, Anton and Windisch, Michael Gregory and Menke, Inga and Pongratz, Julia and Havermann, Felix and Thiery, Wim and Luo, Fei and v. Jeetze, Patrick and Dietrich, Jan Philipp and Lotze-Campen, Hermann and Weindl, Isabelle and Lejeune, Quentin}, + month = dec, + year = {2022}, + note = {Number: 1 +Publisher: Nature Publishing Group}, + keywords = {Sustainability, Climate-change policy, Climate-change mitigation, Socioeconomic scenarios}, + pages = {7453}, +} + + +@article{mishra_forestry_2021, + title = {Estimating global land system impacts of timber plantations using {MAgPIE} 4.3.5}, + volume = {14}, + copyright = {All rights reserved}, + issn = {1991-959X}, + url = {https://gmd.copernicus.org/articles/14/6467/2021/}, + doi = {10.5194/gmd-14-6467-2021}, + abstract = {{\textless}p{\textgreater}{\textless}strong class="journal-contentHeaderColor"{\textgreater}Abstract.{\textless}/strong{\textgreater} Out of 1150 {\textless}span class="inline-formula"{\textgreater}Mha{\textless}/span{\textgreater} (million hectares) of forest designated primarily for production purposes in 2020, plantations accounted for 11 \% (131 {\textless}span class="inline-formula"{\textgreater}Mha{\textless}/span{\textgreater}) of this area and fulfilled more than 33 \% of the global industrial roundwood demand. However, adding additional timber plantations to meet increasing timber demand intensifies competition for scarce land resources between different land uses such as food, feed, livestock and timber production. Despite the significance of plantations with respect to roundwood production, their importance in meeting the long-term timber demand and the implications of plantation expansion for overall land-use dynamics have not been studied in detail, in particular regarding the competition for land between agriculture and forestry in existing land-use models.{\textless}/p{\textgreater} {\textless}p{\textgreater}This paper describes the extension of the modular, open-source land system Model of Agricultural Production and its Impact on the Environment (MAgPIE) using a detailed representation of forest land, timber production and timber demand dynamics. These extensions allow for a better understanding of the land-use dynamics (including competition for land) and the associated land-use change emissions of timber production.{\textless}/p{\textgreater} {\textless}p{\textgreater}We show that the spatial cropland patterns differ when timber production is accounted for, indicating that timber plantations compete with cropland for the same scarce land resources. When plantations are established on cropland, it causes cropland expansion and deforestation elsewhere. Using the exogenous extrapolation of historical roundwood production from plantations, future timber demand and plantation rotation lengths, we model the future spatial expansion of forest plantations. As a result of increasing timber demand, we show a 177 \% increase in plantation area by the end of the century ({\textless}span class="inline-formula"{\textgreater}+{\textless}/span{\textgreater}171 {\textless}span class="inline-formula"{\textgreater}Mha{\textless}/span{\textgreater} in 1995–2100). We also observe (in our model results) that the increasing demand for timber amplifies the scarcity of land, which is indicated by shifting agricultural land-use patterns and increasing yields from cropland compared with a case without forestry. Through the inclusion of new forest plantation and natural forest dynamics, our estimates of land-related {\textless}span class="inline-formula"{\textgreater}CO$_{\textrm{2}}${\textless}/span{\textgreater} emissions better match with observed data, in particular the gross land-use change emissions and carbon uptake (via regrowth), reflecting higher deforestation with the expansion of managed land and timber production as well as higher regrowth in natural forests and plantations.{\textless}/p{\textgreater}}, + language = {English}, + number = {10}, + urldate = {2021-10-27}, + journal = {Geoscientific Model Development}, + author = {Mishra, Abhijeet and Humpenöder, Florian and Dietrich, Jan Philipp and Bodirsky, Benjamin Leon and Sohngen, Brent and P. O. Reyer, Christopher and Lotze-Campen, Hermann and Popp, Alexander}, + month = oct, + year = {2021}, + note = {Publisher: Copernicus GmbH}, + pages = {6467--6494}, +} + + +@article{mishra_timbercities_2022, + title = {Land use change and carbon emissions of a transformation to timber cities}, + volume = {13}, + copyright = {2022 The Author(s)}, + issn = {2041-1723}, + url = {https://www.nature.com/articles/s41467-022-32244-w}, + doi = {10.1038/s41467-022-32244-w}, + abstract = {Using engineered wood for construction has been discussed for climate change mitigation. It remains unclear where and in which way the additional demand for wooden construction material shall be fulfilled. Here we assess the global and regional impacts of increased demand for engineered wood on land use and associated CO2 emissions until 2100 using an open-source land system model. We show that if 90\% of the new urban population would be housed in newly built urban mid-rise buildings with wooden constructions, 106 Gt of additional CO2 could be saved by 2100. Forest plantations would need to expand by up to 149 Mha by 2100 and harvests from unprotected natural forests would increase. Our results indicate that expansion of timber plantations for wooden buildings is possible without major repercussions on agricultural production. Strong governance and careful planning are required to ensure a sustainable transition to timber cities even if frontier forests and biodiversity hotspots are protected.}, + language = {en}, + number = {1}, + urldate = {2022-08-30}, + journal = {Nature Communications}, + author = {Mishra, Abhijeet and Humpenöder, Florian and Churkina, Galina and Reyer, Christopher P. O. and Beier, Felicitas and Bodirsky, Benjamin Leon and Schellnhuber, Hans Joachim and Lotze-Campen, Hermann and Popp, Alexander}, + month = aug, + year = {2022}, + note = {Number: 1 +Publisher: Nature Publishing Group}, + keywords = {Forestry, Climate-change mitigation}, + pages = {4889}, +} diff --git a/main.gms b/main.gms index 3595e9c073..74151a0464 100644 --- a/main.gms +++ b/main.gms @@ -148,25 +148,25 @@ $title magpie *##################### R SECTION START (VERSION INFO) ########################## * -* Used data set: rev4.87_h12_magpie.tgz -* md5sum: 658398f1dcbef89198bd85d61b1db9ad -* Repository: /p/projects/rd3mod/inputdata/output +* Used data set: rev4.88_h12_magpie.tgz +* md5sum: 740da40ceda04850eb374df215837c1b +* Repository: /p/projects/rd3mod/mirror/rse.pik-potsdam.de/data/magpie/public * -* Used data set: rev4.87_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz -* md5sum: 8a1d668acfe66a700eb5da2143b31cb2 -* Repository: /p/projects/rd3mod/inputdata/output +* Used data set: rev4.88_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz +* md5sum: 9edbcc62e75b663eada84524402bccbf +* Repository: /p/projects/rd3mod/mirror/rse.pik-potsdam.de/data/magpie/public * -* Used data set: rev4.87_h12_validation.tgz -* md5sum: d02217d791b58400e6e3be7186527ed5 -* Repository: /p/projects/rd3mod/inputdata/output +* Used data set: rev4.88_h12_validation.tgz +* md5sum: d42abd58de683506a807b411d7fe87cb +* Repository: /p/projects/rd3mod/mirror/rse.pik-potsdam.de/data/magpie/public * -* Used data set: additional_data_rev4.43.tgz -* md5sum: NA -* Repository: https://rse.pik-potsdam.de/data/magpie/public +* Used data set: additional_data_rev4.45.tgz +* md5sum: bb51c8c8608b8b9363582eb4aa220754 +* Repository: /p/projects/landuse/data/input/archive * -* Used data set: calibration_H12_per_ton_fao_may22_glo_08Jul23.tgz -* md5sum: 7315d0f268d6225805a4c1f1c3c05b13 -* Repository: /p/projects/landuse/data/input/calibration +* Used data set: calibration_H12_per_ton_fao_may22_glo_08Aug23.tgz +* md5sum: 5d34e4b54112db10f330f1e59dd60cc9 +* Repository: /p/projects/rd3mod/mirror/rse.pik-potsdam.de/data/magpie/public * * Low resolution: c200 * High resolution: 0.5 @@ -179,11 +179,11 @@ $title magpie * * Regionscode: 62eff8f7 * -* Regions data revision: 4.87 +* Regions data revision: 4.88 * * lpj2magpie settings: * * LPJmL data: MRI-ESM2-0:ssp370 -* * Revision: 4.87 +* * Revision: 4.88 * * aggregation settings: * * Input resolution: 0.5 @@ -195,7 +195,7 @@ $title magpie * * Call: withCallingHandlers(expr, message = messageHandler, warning = warningHandler, error = errorHandler) * * -* Last modification (input data): Thu Jul 13 10:36:10 2023 +* Last modification (input data): Fri Sep 22 15:20:24 2023 * *###################### R SECTION END (VERSION INFO) ########################### @@ -284,7 +284,7 @@ $setglobal bioenergy 1stgen_priced_dec18 $setglobal material exo_flexreg_apr16 $setglobal livestock fbask_jan16 -$setglobal disagg_lvst foragebased_aug18 +$setglobal disagg_lvst foragebased_jul23 $setglobal timber default diff --git a/modules/14_yields/input/files b/modules/14_yields/input/files index 428a25e981..984b93ee32 100644 --- a/modules/14_yields/input/files +++ b/modules/14_yields/input/files @@ -5,3 +5,4 @@ lpj_yields_0.5.mz f14_pasture_yields_hist.csv f14_ipcc_bce.cs3 f14_aboveground_fraction.csv +f14_kcr_pollinator_dependence.csv diff --git a/modules/14_yields/managementcalib_aug19/input.gms b/modules/14_yields/managementcalib_aug19/input.gms index 2eea9d4afb..ffab5eb9ee 100644 --- a/modules/14_yields/managementcalib_aug19/input.gms +++ b/modules/14_yields/managementcalib_aug19/input.gms @@ -14,8 +14,13 @@ scalar s14_limit_calib Relative managament calibration switch (1=limited 0=pur scalar s14_calib_ir2rf Switch to calibrate rainfed to irrigated yield ratios (1=calib 0=not calib) / 1 /; +scalar s14_degradation Switch to include yield impacts of land degradation(0=no degradation 1=with degradation) / 0 /; + +scalar s14_use_yield_calib Switch for using or not using yield calibration factors from the preprocessing (1=use facs 0=not use facs) / 0 /; + scalars s14_yld_past_switch Spillover parameter for translating technological change in the crop sector into pasture yield increases (1) / 0.25 / + s14_yld_reduction_soil_loss Decline of land productivity in areas with severe soil loss (1) / 0.08 / ; scalars @@ -77,3 +82,19 @@ $include "./modules/14_yields/input/f14_aboveground_fraction.csv" $offdelim / ; + +$onEmpty +table f14_yld_ncp_report(t_all,j,ncp_type14) Share of land with intact natures contributions to people (NCP) (1) +$ondelim +$if exist "./modules/14_yields/input/f14_yld_ncp_report.cs3" $include "./modules/14_yields/input/f14_yld_ncp_report.cs3" +$offdelim +; +$offEmpty + +parameter f14_kcr_pollinator_dependence(kcr) Share of total yield dependent on biotic pollination (1) +/ +$ondelim +$include "./modules/14_yields/input/f14_kcr_pollinator_dependence.csv" +$offdelim +/ +; diff --git a/modules/14_yields/managementcalib_aug19/preloop.gms b/modules/14_yields/managementcalib_aug19/preloop.gms index b674237a64..9785cbea2a 100644 --- a/modules/14_yields/managementcalib_aug19/preloop.gms +++ b/modules/14_yields/managementcalib_aug19/preloop.gms @@ -144,22 +144,48 @@ if ((s14_calib_ir2rf = 1), ***YIELD CALIBRATION*********************************************************************** *' @code -*' Calibrated yields are additionally adjusted by calibration factors 'f14_yld_calib' +*' Calibrated yields can additionally be adjusted by calibration factors 'f14_yld_calib' *' determined in a calibration run. As MAgPIE optimizes yield patterns and FAO regional -*' yields are outlier corrected, historical production and croparea can only be reproduced -*' with this additional step of correction: +*' yields are outlier corrected, historical production and croparea can in some cases +*' be better represented with this additional correction: -* set default values in case of missing input file -if(sum((i,ltype14),f14_yld_calib(i,ltype14)) = 0, +* set yield calib factors to 1 in case of no use of yield calibration factors (s14_use_yield_calib = 0) +* or missing input file +if(s14_use_yield_calib = 0 OR sum((i,ltype14),f14_yld_calib(i,ltype14)) = 0, f14_yld_calib(i,ltype14) = 1; ); -i14_yields_calib(t,j,kcr,w) = i14_yields_calib(t,j,kcr,w) *sum(cell(i,j),f14_yld_calib(i,"crop")); -i14_yields_calib(t,j,"pasture",w) = i14_yields_calib(t,j,"pasture",w)*sum(cell(i,j),f14_yld_calib(i,"past")); +i14_yields_calib(t,j,kcr,w) = i14_yields_calib(t,j,kcr,w) + * sum(cell(i,j),f14_yld_calib(i,"crop")); +i14_yields_calib(t,j,"pasture",w) = i14_yields_calib(t,j,"pasture",w) + * sum(cell(i,j),f14_yld_calib(i,"past")); *' @stop +*' @code +*' Land degradation can negatively affect yields. Soil loss for example can +*' notably affect land productivity. Similarly, the yield of pollinator-dependent crops +*' is reduced when there is a lack of pollinators. To account for the impacts of degradation, +*' calibrated yields are multiplied by the share of land with intact NCP in each cell and specific +*' yield reduction coefficients that represent yield loss due to soil erosion and pollination +*' deficiency on non-intact land. + +* set default values in case of missing input file. +if(sum((t,j,ncp_type14),f14_yld_ncp_report(t,j,ncp_type14)) = 0, + f14_yld_ncp_report(t,j,ncp_type14) = 1; +); + +if ((s14_degradation = 1), + i14_yields_calib(t,j,kcr,w) = i14_yields_calib(t,j,kcr,w) * (1 - s14_yld_reduction_soil_loss) + + i14_yields_calib(t,j,kcr,w) * s14_yld_reduction_soil_loss * f14_yld_ncp_report(t,j,"soil_intact"); + i14_yields_calib(t,j,kcr,w) = i14_yields_calib(t,j,kcr,w) * (1 - f14_kcr_pollinator_dependence(kcr)) + + i14_yields_calib(t,j,kcr,w) * f14_kcr_pollinator_dependence(kcr) * f14_yld_ncp_report(t,j,"poll_suff"); +); + +*' @stop + + **** **** **** diff --git a/modules/14_yields/managementcalib_aug19/sets.gms b/modules/14_yields/managementcalib_aug19/sets.gms index 5fac9eba23..350db0d55f 100644 --- a/modules/14_yields/managementcalib_aug19/sets.gms +++ b/modules/14_yields/managementcalib_aug19/sets.gms @@ -25,8 +25,13 @@ sets oilpalm, puls_pro, potato, cassav_sp, sugr_cane, sugr_beet, others, foddr, cottn_pro, begr, betr / - knbe14(kcr) Cropping activities excluding bioenergy plants + knbe14(kcr) Cropping activities excluding bioenergy plants / tece, maiz, trce, rice_pro, soybean, rapeseed, groundnut, sunflower, oilpalm, puls_pro, potato, cassav_sp, sugr_cane, sugr_beet, others, foddr, cottn_pro / + + ncp_type14 natures contributions to people (NCP) relevant for agricultural yields + / soil_intact, poll_suff / + ; + diff --git a/modules/18_residues/flexcluster_jul23/declarations.gms b/modules/18_residues/flexcluster_jul23/declarations.gms new file mode 100644 index 0000000000..3add0dc21d --- /dev/null +++ b/modules/18_residues/flexcluster_jul23/declarations.gms @@ -0,0 +1,76 @@ +*** | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) +*** | authors, and contributors see CITATION.cff file. This file is part +*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of +*** | AGPL-3.0, you are granted additional permissions described in the +*** | MAgPIE License Exception, version 1.0 (see LICENSE file). +*** | Contact: magpie@pik-potsdam.de + + +positive variables + v18_prod_res(j,kres) Cluster-level production of residues (mio. tDM) + v18_res_biomass_ag_clust(j,kcr) Production of aboveground residues in each cluster (mio. tDM) + vm_res_biomass_ag(i,kcr,attributes) Production of aboveground residues in each region (mio. tDM) + vm_res_biomass_bg(i,kcr,dm_nr) Production of belowground residues in each region (mio. tDM) + + v18_res_ag_removal(j,kcr,attributes) Removal of crop residues in respective attribute units DM GJ Nr P K WM C (mio. tX) + v18_res_ag_removal_reg(i,kcr,attributes) Regional removal of crop residues in respective attribute units DM GJ Nr P K WM C (mio. tX) + v18_res_ag_recycling(i,kcr,attributes) Recycling of crop residues to soils in respective attribute units DM GJ Nr P K WM C (mio. tX) + vm_res_ag_burn(i,kcr,attributes) Regional residues burned on fields in respective attribute units DM GJ Nr P K WM C (mio. tX) + + vm_res_recycling(i,npk) Residues recycled to croplands in respective nutrients Nr P K units (mio. tX) + vm_cost_prod_kres(i,kres) Production costs of harvesting crop residues (mio. USD05MER per yr) +; + +equations + + q18_prod_res_ag_clust(j,kcr) Cluster-level production constraint of aboveground residues (mio. tDM) + q18_prod_res_ag_reg(i,kcr,attributes) Regional production constraint of aboveground residues (mio. tDM) + + q18_prod_res_bg_clust(i,kcr,dm_nr) Cluster-level production constraint of belowground residues (mio. tDM) + + q18_regional_removals(i,kcr,attributes) Calculation of regional level removals (mio. tX) + q18_res_field_balance(i,kcr,attributes) Calculation of the residues amount recycled to soils (mio. tDM) + q18_clust_field_constraint(j,kres) Make sure the amount removed in any cluster does not exceed the amount available (mio. tDM) + q18_res_field_burn(i,kcr,attributes) Fixing of the residues amount burned in a region in respective attribute units DM GJ Nr P K WM C (mio. tX) + q18_translate(j,kres,attributes) Transformation of the multiple crop residues into supply balance crop residues in respective attribute units DM GJ Nr P K WM C (mio. tX) + + q18_res_recycling_nr(i) Nutrient recycling of reaactive nitrogen (mio. tNr) + q18_res_recycling_pk(i,pk18) Nutrient recycling of phosphorus and potash (mio. tX) + q18_cost_prod_res(i,kres) Production costs of harvesting crop residues (mio. USD05MER) + + q18_prod_res_reg(i,kall) Regional production of residues (mio. tDM) + +; + +parameters + i18_res_use_burn(t_all,dev18,kcr) Share of residues burned on field (1) +; + +*#################### R SECTION START (OUTPUT DECLARATIONS) #################### +parameters + ov18_prod_res(t,j,kres,type) Cluster-level production of residues (mio. tDM) + ov18_res_biomass_ag_clust(t,j,kcr,type) Production of aboveground residues in each cluster (mio. tDM) + ov_res_biomass_ag(t,i,kcr,attributes,type) Production of aboveground residues in each region (mio. tDM) + ov_res_biomass_bg(t,i,kcr,dm_nr,type) Production of belowground residues in each region (mio. tDM) + ov18_res_ag_removal(t,j,kcr,attributes,type) Removal of crop residues in respective attribute units DM GJ Nr P K WM C (mio. tX) + ov18_res_ag_removal_reg(t,i,kcr,attributes,type) Regional removal of crop residues in respective attribute units DM GJ Nr P K WM C (mio. tX) + ov18_res_ag_recycling(t,i,kcr,attributes,type) Recycling of crop residues to soils in respective attribute units DM GJ Nr P K WM C (mio. tX) + ov_res_ag_burn(t,i,kcr,attributes,type) Regional residues burned on fields in respective attribute units DM GJ Nr P K WM C (mio. tX) + ov_res_recycling(t,i,npk,type) Residues recycled to croplands in respective nutrients Nr P K units (mio. tX) + ov_cost_prod_kres(t,i,kres,type) Production costs of harvesting crop residues (mio. USD05MER per yr) + oq18_prod_res_ag_clust(t,j,kcr,type) Cluster-level production constraint of aboveground residues (mio. tDM) + oq18_prod_res_ag_reg(t,i,kcr,attributes,type) Regional production constraint of aboveground residues (mio. tDM) + oq18_prod_res_bg_clust(t,i,kcr,dm_nr,type) Cluster-level production constraint of belowground residues (mio. tDM) + oq18_regional_removals(t,i,kcr,attributes,type) Calculation of regional level removals (mio. tX) + oq18_res_field_balance(t,i,kcr,attributes,type) Calculation of the residues amount recycled to soils (mio. tDM) + oq18_clust_field_constraint(t,j,kres,type) Make sure the amount removed in any cluster does not exceed the amount available (mio. tDM) + oq18_res_field_burn(t,i,kcr,attributes,type) Fixing of the residues amount burned in a region in respective attribute units DM GJ Nr P K WM C (mio. tX) + oq18_translate(t,j,kres,attributes,type) Transformation of the multiple crop residues into supply balance crop residues in respective attribute units DM GJ Nr P K WM C (mio. tX) + oq18_res_recycling_nr(t,i,type) Nutrient recycling of reaactive nitrogen (mio. tNr) + oq18_res_recycling_pk(t,i,pk18,type) Nutrient recycling of phosphorus and potash (mio. tX) + oq18_cost_prod_res(t,i,kres,type) Production costs of harvesting crop residues (mio. USD05MER) + oq18_prod_res_reg(t,i,kall,type) Regional production of residues (mio. tDM) +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### + +*** EOF declarations.gms *** diff --git a/modules/18_residues/flexcluster_jul23/equations.gms b/modules/18_residues/flexcluster_jul23/equations.gms new file mode 100644 index 0000000000..68e0a0d6c8 --- /dev/null +++ b/modules/18_residues/flexcluster_jul23/equations.gms @@ -0,0 +1,150 @@ +*** | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) +*** | authors, and contributors see CITATION.cff file. This file is part +*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of +*** | AGPL-3.0, you are granted additional permissions described in the +*** | MAgPIE License Exception, version 1.0 (see LICENSE file). +*** | Contact: magpie@pik-potsdam.de + +*' @equations + +*' The AG crop residue biomass `vm_res_biomass_ag` is calculated as a function +*' of harvested area `vm_area` and production `vm_prod_reg`. `f18_cgf` contains +*' slope and intercept parameters of the CGFs. + + q18_prod_res_ag_clust(j2,kcr) .. + v18_res_biomass_ag_clust(j2,kcr) + =e= + (sum(w, vm_area(j2,kcr,w)) * sum((ct, cell(i2,j2)), f18_multicropping(ct,i2)) * f18_cgf("intercept",kcr) + + vm_prod(j2,kcr) * f18_cgf("slope",kcr)); + + q18_prod_res_ag_reg(i2,kcr,attributes) .. + vm_res_biomass_ag(i2,kcr,attributes) + =e= + sum(cell(i2,j2), v18_res_biomass_ag_clust(j2,kcr)) + * f18_attributes_residue_ag(attributes,kcr); + +*' The BG crop residue biomass `vm_res_biomass_bg` is calculated as a function of +*' total aboveground biomass. + + q18_prod_res_bg_clust(i2,kcr,dm_nr) .. + vm_res_biomass_bg(i2,kcr,dm_nr) + =e= + (vm_prod_reg(i2,kcr) + vm_res_biomass_ag(i2,kcr,"dm")) * f18_cgf("bg_to_ag",kcr) + * f18_attributes_residue_bg(dm_nr,kcr); + +*' Variable of removals at regional level needs to be greater than +*' the regionally-summed cluster-level variable. This is not an equal-to +*' for run-time considerations, but should be noted if regional removals +*' vm_res_biomass_ag are to be incentivised. + + q18_regional_removals(i2,kcr,attributes) .. + sum(cell(i2,j2), v18_res_ag_removal(j2,kcr,attributes)) + =e= + v18_res_ag_removal_reg(i2,kcr,attributes); + + +*' In contrast to AG biomass, AG production `vm_res_biomass_ag(i,kcr,attributes)` +*' is defined as the part of residues which is removed from the field. The +*' difference between biomass and production is either burned on field or +*' remains on the fields (either incorporated in soils or not) and decays. +*' The field balance equations ensures that the production of AG residues +*' `vm_res_biomass_ag(i,kcr,attributes)` is properly assigned to different uses: +*' removal, on-field burning and recycling of AG residues. + + q18_res_field_balance(i2,kcr,attributes) .. + vm_res_biomass_ag(i2,kcr,attributes) + =e= + v18_res_ag_removal_reg(i2,kcr,attributes) + + vm_res_ag_burn(i2,kcr,attributes) + + v18_res_ag_recycling(i2,kcr,attributes); + +*' make sure removal is less than biomass produced in each cluster + q18_clust_field_constraint(j2,kres) .. + sum(kres_kcr(kres,kcr), v18_res_biomass_ag_clust(j2,kcr)) + =g= + v18_prod_res(j2, kres); + +*' The amount of residues burned on fields in a region `vm_res_ag_burn` is +*' determined by the share (ic18_res_use_min_shr) of AG residue biomass. +*' Based on @smil_nitrogen_1999, residue burning is fixed to 15% of total AG +*' crop residue dry matter in developed and 25% in developing regions for each +*' crop. For future time steps, these rates are scenario dependent, and either +*' kept constant or reduced to 10% and 0% in 2050. + + q18_res_field_burn(i2,kcr,attributes) .. + vm_res_ag_burn(i2,kcr,attributes) + =e= + sum(ct, im_development_state(ct,i2) * i18_res_use_burn(ct,"high_income",kcr) + + (1-im_development_state(ct,i2)) * i18_res_use_burn(ct,"low_income",kcr)) + * vm_res_biomass_ag(i2,kcr,attributes); + + +*' While the residue biomass is estimated with a crop-specific nutrient +*' composition (which is required for consistent nutrient budgets), the +*' removed residues are assumed to have homogeneous properties +*' (to reduce the number of commodities in MAgPIE) within three crop residue +*' groups (cereal straw, fibrous residues that cannot be digested +*' by monogastrics, and non-fibrous residues that can be digested). +*' The following constraint, in combination with the field balance equation, +*' guarantees that mass balances are not violated while a homogeneous +*' good is extracted from heterogeneous goods. + + q18_translate(j2,kres,attributes).. + sum(kres_kcr(kres,kcr), v18_res_ag_removal(j2,kcr,attributes)) + =e= + v18_prod_res(j2,kres) * fm_attributes(attributes,kres); + +*' sum to the regional amount of residues produced for the regional interface + q18_prod_res_reg(i2,kres).. + vm_prod_reg(i2,kres) + =e= + sum(cell(i2,j2), v18_prod_res(j2,kres)) ; + + +*' Residues recycled to croplands in nutrients `vm_res_recycling(i2,"nr")` are +*' calculated based on the amount of AG residues left on field for recycling, the +*' nutrients coming from burned residues, and on biomass that is left in +*' BG residues. They are calculated to be transmitted to the nitrogen budget +*' module [50_nr_soil_budget]. + + q18_res_recycling_nr(i2) .. + vm_res_recycling(i2,"nr") + =e= + sum(kcr, v18_res_ag_recycling(i2,kcr,"nr") + + vm_res_ag_burn(i2,kcr,"nr")*(1-f18_res_combust_eff(kcr)) + + vm_res_biomass_bg(i2,kcr,"nr") + ); + +*' Similar to the recycled nutrients, the potash recycling is determined by the +*' amount of AG residues with the potash content and the amounts of potash from +*' burning residues. As P and K are not volatile and hardly water soluble, only +*' removed aboveground crop residues have to be considered, while nutrients from +*' burned AG as well as BG stay on the field. + + q18_res_recycling_pk(i2,pk18) .. + vm_res_recycling(i2,pk18) + =e= + sum(kcr, + v18_res_ag_recycling(i2,kcr,pk18) + + vm_res_ag_burn(i2,kcr,pk18) + ); + +*' Costs of residues production are determined as factor costs per ton +*' assuming 15 USD per ton, using the lower range from +*' [this source](hwww1.agric.gov.ab.ca/$Department/deptdocs.nsf/All/faq7514), +*' 10USD baling costs per large round bale plus 2USD pro bale stocking and hauling, +*' 1 large round bale is approximately 500 kg, resulting in 24USD per ton, +*' for developing prices see [here](citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.557.5823&rep=rep1&type=pdf). +*' Tha calcuated factor costs per ton are therefore 24 for `res_cereals`, `res_fibrous` +*' and `res_nonfibrous`. + + q18_cost_prod_res(i2,kres) .. + vm_cost_prod_kres(i2,kres) + =e= + vm_prod_reg(i2,kres) * fm_attributes("wm",kres) * f18_fac_req_kres(kres); + +*' Trade of AG residues is not considered, so that all produced AG residues have +*' to be assigned to uses within the respective world region. + + +*** EOF constraints.gms *** diff --git a/modules/18_residues/flexcluster_jul23/input.gms b/modules/18_residues/flexcluster_jul23/input.gms new file mode 100644 index 0000000000..cc9039bfa6 --- /dev/null +++ b/modules/18_residues/flexcluster_jul23/input.gms @@ -0,0 +1,51 @@ +*** | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) +*** | authors, and contributors see CITATION.cff file. This file is part +*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of +*** | AGPL-3.0, you are granted additional permissions described in the +*** | MAgPIE License Exception, version 1.0 (see LICENSE file). +*** | Contact: magpie@pik-potsdam.de + +$setglobal c18_burn_scen phaseout +* options: phaseout,constant + +table f18_multicropping(t_all,i) Multicropping indicator as ratio of area harvested by physical area (1) +$ondelim +$include "./modules/18_residues/input/f18_multicropping.csv" +$offdelim; + +table f18_attributes_residue_ag(attributes,kve) Nutrient content of aboveground crop residues in respective attribute units DM GJ Nr P K WM C (X per DM) +$ondelim +$include "./modules/18_residues/input/f18_attributes_residue_ag.csv" +$offdelim; + + +table f18_attributes_residue_bg(dm_nr,kve) Nutrient content of belowground crop residues in reactive nitorgen and carbon units Nr C (X per DM) +$ondelim +$include "./modules/18_residues/input/f18_attributes_residue_bg.csv" +$offdelim; + +table f18_cgf(cgf,kve) Crop growth functions for all vegetation types containing slope intercept and belowground to aboveground ratio (1) +$ondelim +$include "./modules/18_residues/flexcluster_jul23/input/f18_cgf.csv" +$offdelim; + +table f18_res_use_burn(t_all,burn_scen18,dev18,kcr) Minimum and maximum burn share use for residues developing over time (1) +$ondelim +$include "./modules/18_residues/flexcluster_jul23/input/f18_res_use_burn.cs3" +$offdelim; + +parameter f18_res_combust_eff(kve) Combustion efficiency of residue burning (1) +/ +$ondelim +$include "./modules/18_residues/input/f18_res_combust_eff.cs4" +$offdelim +/; + +parameter f18_fac_req_kres(kres) Factor requirements (USD05MER per tDM) +/ +$ondelim +$include "./modules/18_residues/flexcluster_jul23/input/f18_fac_req_kres.csv" +$offdelim +/; + +*** EOF input.gms *** diff --git a/modules/18_residues/flexcluster_jul23/input/files b/modules/18_residues/flexcluster_jul23/input/files new file mode 100644 index 0000000000..45135c7cef --- /dev/null +++ b/modules/18_residues/flexcluster_jul23/input/files @@ -0,0 +1,4 @@ +* list of files that are required here +f18_cgf.csv +f18_res_use_burn.cs3 +f18_fac_req_kres.csv diff --git a/modules/18_residues/flexcluster_jul23/postsolve.gms b/modules/18_residues/flexcluster_jul23/postsolve.gms new file mode 100644 index 0000000000..9de0597987 --- /dev/null +++ b/modules/18_residues/flexcluster_jul23/postsolve.gms @@ -0,0 +1,102 @@ +*** | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) +*** | authors, and contributors see CITATION.cff file. This file is part +*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of +*** | AGPL-3.0, you are granted additional permissions described in the +*** | MAgPIE License Exception, version 1.0 (see LICENSE file). +*** | Contact: magpie@pik-potsdam.de + +****** Residues + +*** EOF postsolve.gms *** + +*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + ov18_prod_res(t,j,kres,"marginal") = v18_prod_res.m(j,kres); + ov18_res_biomass_ag_clust(t,j,kcr,"marginal") = v18_res_biomass_ag_clust.m(j,kcr); + ov_res_biomass_ag(t,i,kcr,attributes,"marginal") = vm_res_biomass_ag.m(i,kcr,attributes); + ov_res_biomass_bg(t,i,kcr,dm_nr,"marginal") = vm_res_biomass_bg.m(i,kcr,dm_nr); + ov18_res_ag_removal(t,j,kcr,attributes,"marginal") = v18_res_ag_removal.m(j,kcr,attributes); + ov18_res_ag_removal_reg(t,i,kcr,attributes,"marginal") = v18_res_ag_removal_reg.m(i,kcr,attributes); + ov18_res_ag_recycling(t,i,kcr,attributes,"marginal") = v18_res_ag_recycling.m(i,kcr,attributes); + ov_res_ag_burn(t,i,kcr,attributes,"marginal") = vm_res_ag_burn.m(i,kcr,attributes); + ov_res_recycling(t,i,npk,"marginal") = vm_res_recycling.m(i,npk); + ov_cost_prod_kres(t,i,kres,"marginal") = vm_cost_prod_kres.m(i,kres); + oq18_prod_res_ag_clust(t,j,kcr,"marginal") = q18_prod_res_ag_clust.m(j,kcr); + oq18_prod_res_ag_reg(t,i,kcr,attributes,"marginal") = q18_prod_res_ag_reg.m(i,kcr,attributes); + oq18_prod_res_bg_clust(t,i,kcr,dm_nr,"marginal") = q18_prod_res_bg_clust.m(i,kcr,dm_nr); + oq18_regional_removals(t,i,kcr,attributes,"marginal") = q18_regional_removals.m(i,kcr,attributes); + oq18_res_field_balance(t,i,kcr,attributes,"marginal") = q18_res_field_balance.m(i,kcr,attributes); + oq18_clust_field_constraint(t,j,kres,"marginal") = q18_clust_field_constraint.m(j,kres); + oq18_res_field_burn(t,i,kcr,attributes,"marginal") = q18_res_field_burn.m(i,kcr,attributes); + oq18_translate(t,j,kres,attributes,"marginal") = q18_translate.m(j,kres,attributes); + oq18_res_recycling_nr(t,i,"marginal") = q18_res_recycling_nr.m(i); + oq18_res_recycling_pk(t,i,pk18,"marginal") = q18_res_recycling_pk.m(i,pk18); + oq18_cost_prod_res(t,i,kres,"marginal") = q18_cost_prod_res.m(i,kres); + oq18_prod_res_reg(t,i,kall,"marginal") = q18_prod_res_reg.m(i,kall); + ov18_prod_res(t,j,kres,"level") = v18_prod_res.l(j,kres); + ov18_res_biomass_ag_clust(t,j,kcr,"level") = v18_res_biomass_ag_clust.l(j,kcr); + ov_res_biomass_ag(t,i,kcr,attributes,"level") = vm_res_biomass_ag.l(i,kcr,attributes); + ov_res_biomass_bg(t,i,kcr,dm_nr,"level") = vm_res_biomass_bg.l(i,kcr,dm_nr); + ov18_res_ag_removal(t,j,kcr,attributes,"level") = v18_res_ag_removal.l(j,kcr,attributes); + ov18_res_ag_removal_reg(t,i,kcr,attributes,"level") = v18_res_ag_removal_reg.l(i,kcr,attributes); + ov18_res_ag_recycling(t,i,kcr,attributes,"level") = v18_res_ag_recycling.l(i,kcr,attributes); + ov_res_ag_burn(t,i,kcr,attributes,"level") = vm_res_ag_burn.l(i,kcr,attributes); + ov_res_recycling(t,i,npk,"level") = vm_res_recycling.l(i,npk); + ov_cost_prod_kres(t,i,kres,"level") = vm_cost_prod_kres.l(i,kres); + oq18_prod_res_ag_clust(t,j,kcr,"level") = q18_prod_res_ag_clust.l(j,kcr); + oq18_prod_res_ag_reg(t,i,kcr,attributes,"level") = q18_prod_res_ag_reg.l(i,kcr,attributes); + oq18_prod_res_bg_clust(t,i,kcr,dm_nr,"level") = q18_prod_res_bg_clust.l(i,kcr,dm_nr); + oq18_regional_removals(t,i,kcr,attributes,"level") = q18_regional_removals.l(i,kcr,attributes); + oq18_res_field_balance(t,i,kcr,attributes,"level") = q18_res_field_balance.l(i,kcr,attributes); + oq18_clust_field_constraint(t,j,kres,"level") = q18_clust_field_constraint.l(j,kres); + oq18_res_field_burn(t,i,kcr,attributes,"level") = q18_res_field_burn.l(i,kcr,attributes); + oq18_translate(t,j,kres,attributes,"level") = q18_translate.l(j,kres,attributes); + oq18_res_recycling_nr(t,i,"level") = q18_res_recycling_nr.l(i); + oq18_res_recycling_pk(t,i,pk18,"level") = q18_res_recycling_pk.l(i,pk18); + oq18_cost_prod_res(t,i,kres,"level") = q18_cost_prod_res.l(i,kres); + oq18_prod_res_reg(t,i,kall,"level") = q18_prod_res_reg.l(i,kall); + ov18_prod_res(t,j,kres,"upper") = v18_prod_res.up(j,kres); + ov18_res_biomass_ag_clust(t,j,kcr,"upper") = v18_res_biomass_ag_clust.up(j,kcr); + ov_res_biomass_ag(t,i,kcr,attributes,"upper") = vm_res_biomass_ag.up(i,kcr,attributes); + ov_res_biomass_bg(t,i,kcr,dm_nr,"upper") = vm_res_biomass_bg.up(i,kcr,dm_nr); + ov18_res_ag_removal(t,j,kcr,attributes,"upper") = v18_res_ag_removal.up(j,kcr,attributes); + ov18_res_ag_removal_reg(t,i,kcr,attributes,"upper") = v18_res_ag_removal_reg.up(i,kcr,attributes); + ov18_res_ag_recycling(t,i,kcr,attributes,"upper") = v18_res_ag_recycling.up(i,kcr,attributes); + ov_res_ag_burn(t,i,kcr,attributes,"upper") = vm_res_ag_burn.up(i,kcr,attributes); + ov_res_recycling(t,i,npk,"upper") = vm_res_recycling.up(i,npk); + ov_cost_prod_kres(t,i,kres,"upper") = vm_cost_prod_kres.up(i,kres); + oq18_prod_res_ag_clust(t,j,kcr,"upper") = q18_prod_res_ag_clust.up(j,kcr); + oq18_prod_res_ag_reg(t,i,kcr,attributes,"upper") = q18_prod_res_ag_reg.up(i,kcr,attributes); + oq18_prod_res_bg_clust(t,i,kcr,dm_nr,"upper") = q18_prod_res_bg_clust.up(i,kcr,dm_nr); + oq18_regional_removals(t,i,kcr,attributes,"upper") = q18_regional_removals.up(i,kcr,attributes); + oq18_res_field_balance(t,i,kcr,attributes,"upper") = q18_res_field_balance.up(i,kcr,attributes); + oq18_clust_field_constraint(t,j,kres,"upper") = q18_clust_field_constraint.up(j,kres); + oq18_res_field_burn(t,i,kcr,attributes,"upper") = q18_res_field_burn.up(i,kcr,attributes); + oq18_translate(t,j,kres,attributes,"upper") = q18_translate.up(j,kres,attributes); + oq18_res_recycling_nr(t,i,"upper") = q18_res_recycling_nr.up(i); + oq18_res_recycling_pk(t,i,pk18,"upper") = q18_res_recycling_pk.up(i,pk18); + oq18_cost_prod_res(t,i,kres,"upper") = q18_cost_prod_res.up(i,kres); + oq18_prod_res_reg(t,i,kall,"upper") = q18_prod_res_reg.up(i,kall); + ov18_prod_res(t,j,kres,"lower") = v18_prod_res.lo(j,kres); + ov18_res_biomass_ag_clust(t,j,kcr,"lower") = v18_res_biomass_ag_clust.lo(j,kcr); + ov_res_biomass_ag(t,i,kcr,attributes,"lower") = vm_res_biomass_ag.lo(i,kcr,attributes); + ov_res_biomass_bg(t,i,kcr,dm_nr,"lower") = vm_res_biomass_bg.lo(i,kcr,dm_nr); + ov18_res_ag_removal(t,j,kcr,attributes,"lower") = v18_res_ag_removal.lo(j,kcr,attributes); + ov18_res_ag_removal_reg(t,i,kcr,attributes,"lower") = v18_res_ag_removal_reg.lo(i,kcr,attributes); + ov18_res_ag_recycling(t,i,kcr,attributes,"lower") = v18_res_ag_recycling.lo(i,kcr,attributes); + ov_res_ag_burn(t,i,kcr,attributes,"lower") = vm_res_ag_burn.lo(i,kcr,attributes); + ov_res_recycling(t,i,npk,"lower") = vm_res_recycling.lo(i,npk); + ov_cost_prod_kres(t,i,kres,"lower") = vm_cost_prod_kres.lo(i,kres); + oq18_prod_res_ag_clust(t,j,kcr,"lower") = q18_prod_res_ag_clust.lo(j,kcr); + oq18_prod_res_ag_reg(t,i,kcr,attributes,"lower") = q18_prod_res_ag_reg.lo(i,kcr,attributes); + oq18_prod_res_bg_clust(t,i,kcr,dm_nr,"lower") = q18_prod_res_bg_clust.lo(i,kcr,dm_nr); + oq18_regional_removals(t,i,kcr,attributes,"lower") = q18_regional_removals.lo(i,kcr,attributes); + oq18_res_field_balance(t,i,kcr,attributes,"lower") = q18_res_field_balance.lo(i,kcr,attributes); + oq18_clust_field_constraint(t,j,kres,"lower") = q18_clust_field_constraint.lo(j,kres); + oq18_res_field_burn(t,i,kcr,attributes,"lower") = q18_res_field_burn.lo(i,kcr,attributes); + oq18_translate(t,j,kres,attributes,"lower") = q18_translate.lo(j,kres,attributes); + oq18_res_recycling_nr(t,i,"lower") = q18_res_recycling_nr.lo(i); + oq18_res_recycling_pk(t,i,pk18,"lower") = q18_res_recycling_pk.lo(i,pk18); + oq18_cost_prod_res(t,i,kres,"lower") = q18_cost_prod_res.lo(i,kres); + oq18_prod_res_reg(t,i,kall,"lower") = q18_prod_res_reg.lo(i,kall); +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### + diff --git a/modules/18_residues/flexcluster_jul23/preloop.gms b/modules/18_residues/flexcluster_jul23/preloop.gms new file mode 100644 index 0000000000..dd1bb671f2 --- /dev/null +++ b/modules/18_residues/flexcluster_jul23/preloop.gms @@ -0,0 +1,9 @@ +*** | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) +*** | authors, and contributors see CITATION.cff file. This file is part +*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of +*** | AGPL-3.0, you are granted additional permissions described in the +*** | MAgPIE License Exception, version 1.0 (see LICENSE file). +*** | Contact: magpie@pik-potsdam.de + + +i18_res_use_burn(t_all,dev18,kcr) = f18_res_use_burn(t_all,"%c18_burn_scen%",dev18,kcr); diff --git a/modules/18_residues/flexcluster_jul23/presolve.gms b/modules/18_residues/flexcluster_jul23/presolve.gms new file mode 100644 index 0000000000..df3fd6721f --- /dev/null +++ b/modules/18_residues/flexcluster_jul23/presolve.gms @@ -0,0 +1,10 @@ +*** | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) +*** | authors, and contributors see CITATION.cff file. This file is part +*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of +*** | AGPL-3.0, you are granted additional permissions described in the +*** | MAgPIE License Exception, version 1.0 (see LICENSE file). +*** | Contact: magpie@pik-potsdam.de + +v18_res_ag_removal.fx(j,nonused18,attributes)=0; + +*** EOF solve.gms *** diff --git a/modules/18_residues/flexcluster_jul23/realization.gms b/modules/18_residues/flexcluster_jul23/realization.gms new file mode 100644 index 0000000000..a1c737e440 --- /dev/null +++ b/modules/18_residues/flexcluster_jul23/realization.gms @@ -0,0 +1,42 @@ +*** | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) +*** | authors, and contributors see CITATION.cff file. This file is part +*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of +*** | AGPL-3.0, you are granted additional permissions described in the +*** | MAgPIE License Exception, version 1.0 (see LICENSE file). +*** | Contact: magpie@pik-potsdam.de + +*' @description As official global statistics exist only for crop production and not for crop +*' residue production, the biomass of residues is obtained in MAgPIE by using +*' crop-type specific plant growth functions based on crop production and area harvested. +*' Plant biomass is divided into three components: the harvested organ as listed +*' in FAO, the aboveground (AG) and the belowground (BG) residues. +*' +*' @ipcc_2006_2006 offers one of the few consistent datasets to estimate +*' both AG and BG residues. Also, by providing crop-growth functions (CGF, `f18_cgf`) +*' instead of fixed harvest indices, it can be used to depict current +*' international differences of harvest indices and their development in the future. +*' The methodology is thus well eligible for global long-term modelling. +*' @ipcc_2006_2006 provides linear CGFs with positive slope and intercept +*' for cereals, leguminous crops, potatoes and grasses. As no values are +*' available for the oilcrops rapeseed, sunflower, oilpalms as well as +*' sugar crops, tropical roots, cotton and others, we use fixed harvest-indices +*' (positive slope without intercept) for these crops based +*' on @wirsenius_human_2000, @lal_world_2005 and @feller_dungung_2007. If different CGFs are available +*' for crops within a crop group, we build a weighted average based on the +*' production in 1995. +*' +*' This realization enforces cluster-level agricultural residue production, based on agricultural production +*' at the same level. However, other uses such as burning and recycling are allowed to be balanced at the +*' regional level, in order to reduce computational complexity. + + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/18_residues/flexcluster_jul23/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/18_residues/flexcluster_jul23/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/18_residues/flexcluster_jul23/input.gms" +$Ifi "%phase%" == "equations" $include "./modules/18_residues/flexcluster_jul23/equations.gms" +$Ifi "%phase%" == "scaling" $include "./modules/18_residues/flexcluster_jul23/scaling.gms" +$Ifi "%phase%" == "preloop" $include "./modules/18_residues/flexcluster_jul23/preloop.gms" +$Ifi "%phase%" == "presolve" $include "./modules/18_residues/flexcluster_jul23/presolve.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/18_residues/flexcluster_jul23/postsolve.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/18_residues/flexcluster_jul23/scaling.gms b/modules/18_residues/flexcluster_jul23/scaling.gms new file mode 100644 index 0000000000..2e8ecb4d44 --- /dev/null +++ b/modules/18_residues/flexcluster_jul23/scaling.gms @@ -0,0 +1,8 @@ +*** | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) +*** | authors, and contributors see CITATION.cff file. This file is part +*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of +*** | AGPL-3.0, you are granted additional permissions described in the +*** | MAgPIE License Exception, version 1.0 (see LICENSE file). +*** | Contact: magpie@pik-potsdam.de + +vm_cost_prod_kres.scale(i,kres) = 10e3; diff --git a/modules/18_residues/flexcluster_jul23/sets.gms b/modules/18_residues/flexcluster_jul23/sets.gms new file mode 100644 index 0000000000..37140313ef --- /dev/null +++ b/modules/18_residues/flexcluster_jul23/sets.gms @@ -0,0 +1,40 @@ +*** | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) +*** | authors, and contributors see CITATION.cff file. This file is part +*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of +*** | AGPL-3.0, you are granted additional permissions described in the +*** | MAgPIE License Exception, version 1.0 (see LICENSE file). +*** | Contact: magpie@pik-potsdam.de + + +sets + +dm_nr(attributes) dry matter and nr +/dm, nr, c/ + +pk18(npk) subset of npk containing P and K nutrients +/p, k/ + +dev18 country development indicator +/high_income,low_income/ + +burn_scen18 scenario for burning residues on field +/constant,phaseout/ + +nonused18(kcr) crops that are not used as residues +/sunflower, oilpalm, foddr, begr, betr/ + +***Feeding groups*** + + kres_kcr(kres,kcr) mapping of crops to different residue types + / res_cereals .(tece,maiz,trce,rice_pro) + res_fibrous .(soybean,rapeseed,groundnut, + puls_pro,sugr_beet,sugr_cane, + cottn_pro) + res_nonfibrous .(potato,cassav_sp,others) + / + + + +; + +*** EOF sets.gms *** diff --git a/modules/18_residues/flexreg_apr16/declarations.gms b/modules/18_residues/flexreg_apr16/declarations.gms index 426853f7bd..f5ecba6dc3 100644 --- a/modules/18_residues/flexreg_apr16/declarations.gms +++ b/modules/18_residues/flexreg_apr16/declarations.gms @@ -7,6 +7,7 @@ positive variables + v18_prod_res(j,kres) Cellular production of residues (mio. tDM) vm_res_biomass_ag(i,kcr,attributes) Production of aboveground residues in each region (mio. tDM) vm_res_biomass_bg(i,kcr,dm_nr) Production of belowground residues in each region (mio. tDM) v18_res_ag_removal(i,kcr,attributes) Removal of crop residues in respective attribute units DM GJ Nr P K WM C (mio. tX) @@ -24,6 +25,7 @@ equations q18_res_field_balance(i,kcr,attributes) Calculation of the residues amount recycled to soils (mio. tDM) q18_res_field_burn(i,kcr,attributes) Fixing of the residues amount burned in a region in respective attribute units DM GJ Nr P K WM C (mio. tX) q18_translate(i,kres,attributes) Transformation of the multiple crop residues into supply balance crop redisues in respective attribute units DM GJ Nr P K WM C (mio. tX) + q18_prod_res_cell(j,kres) Allows for distribution of residues to cellular level (mio. tDM) q18_res_recycling_nr(i) Nutrient recycling of reaactive nitrogen (mio. tNr) q18_res_recycling_pk(i,pk18) Nutrient recycling of phosphorus and potash (mio. tX) @@ -37,6 +39,7 @@ parameters *#################### R SECTION START (OUTPUT DECLARATIONS) #################### parameters + ov18_prod_res(t,j,kres,type) Cellular production of residues (mio. tDM) ov_res_biomass_ag(t,i,kcr,attributes,type) Production of aboveground residues in each region (mio. tDM) ov_res_biomass_bg(t,i,kcr,dm_nr,type) Production of belowground residues in each region (mio. tDM) ov18_res_ag_removal(t,i,kcr,attributes,type) Removal of crop residues in respective attribute units DM GJ Nr P K WM C (mio. tX) @@ -49,6 +52,7 @@ parameters oq18_res_field_balance(t,i,kcr,attributes,type) Calculation of the residues amount recycled to soils (mio. tDM) oq18_res_field_burn(t,i,kcr,attributes,type) Fixing of the residues amount burned in a region in respective attribute units DM GJ Nr P K WM C (mio. tX) oq18_translate(t,i,kres,attributes,type) Transformation of the multiple crop residues into supply balance crop redisues in respective attribute units DM GJ Nr P K WM C (mio. tX) + oq18_prod_res_cell(t,j,kres,type) Allows for distribution of residues to cellular level (mio. tDM) oq18_res_recycling_nr(t,i,type) Nutrient recycling of reaactive nitrogen (mio. tNr) oq18_res_recycling_pk(t,i,pk18,type) Nutrient recycling of phosphorus and potash (mio. tX) oq18_cost_prod_res(t,i,kres,type) Production costs of harvesting crop residues (mio. USD05MER) diff --git a/modules/18_residues/flexreg_apr16/equations.gms b/modules/18_residues/flexreg_apr16/equations.gms index 2384a6976d..daf7e3c797 100644 --- a/modules/18_residues/flexreg_apr16/equations.gms +++ b/modules/18_residues/flexreg_apr16/equations.gms @@ -72,6 +72,13 @@ =e= vm_prod_reg(i2,kres) * fm_attributes(attributes,kres); +*' Amount produced at cellular level is flexible, can be distributed as it wants + q18_prod_res_cell(j2,kres).. + sum(cell(i2,j2), vm_prod_reg(i2,kres)) + =e= + v18_prod_res(j2,kres) ; + + *' Residues recycled to croplands in nutrients `vm_res_recycling(i2,"nr")` are *' calcualted based on the amount of AG residues left on field for recycling, the *' nutrients coming from burned residues, and on biomass that is left in diff --git a/modules/18_residues/flexreg_apr16/not_used.txt b/modules/18_residues/flexreg_apr16/not_used.txt new file mode 100644 index 0000000000..07cb618a78 --- /dev/null +++ b/modules/18_residues/flexreg_apr16/not_used.txt @@ -0,0 +1,2 @@ +name,type,reason +vm_prod,input,not needed \ No newline at end of file diff --git a/modules/18_residues/flexreg_apr16/postsolve.gms b/modules/18_residues/flexreg_apr16/postsolve.gms index 31c4585f65..8512944ed4 100644 --- a/modules/18_residues/flexreg_apr16/postsolve.gms +++ b/modules/18_residues/flexreg_apr16/postsolve.gms @@ -10,6 +10,7 @@ *** EOF postsolve.gms *** *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + ov18_prod_res(t,j,kres,"marginal") = v18_prod_res.m(j,kres); ov_res_biomass_ag(t,i,kcr,attributes,"marginal") = vm_res_biomass_ag.m(i,kcr,attributes); ov_res_biomass_bg(t,i,kcr,dm_nr,"marginal") = vm_res_biomass_bg.m(i,kcr,dm_nr); ov18_res_ag_removal(t,i,kcr,attributes,"marginal") = v18_res_ag_removal.m(i,kcr,attributes); @@ -22,9 +23,11 @@ oq18_res_field_balance(t,i,kcr,attributes,"marginal") = q18_res_field_balance.m(i,kcr,attributes); oq18_res_field_burn(t,i,kcr,attributes,"marginal") = q18_res_field_burn.m(i,kcr,attributes); oq18_translate(t,i,kres,attributes,"marginal") = q18_translate.m(i,kres,attributes); + oq18_prod_res_cell(t,j,kres,"marginal") = q18_prod_res_cell.m(j,kres); oq18_res_recycling_nr(t,i,"marginal") = q18_res_recycling_nr.m(i); oq18_res_recycling_pk(t,i,pk18,"marginal") = q18_res_recycling_pk.m(i,pk18); oq18_cost_prod_res(t,i,kres,"marginal") = q18_cost_prod_res.m(i,kres); + ov18_prod_res(t,j,kres,"level") = v18_prod_res.l(j,kres); ov_res_biomass_ag(t,i,kcr,attributes,"level") = vm_res_biomass_ag.l(i,kcr,attributes); ov_res_biomass_bg(t,i,kcr,dm_nr,"level") = vm_res_biomass_bg.l(i,kcr,dm_nr); ov18_res_ag_removal(t,i,kcr,attributes,"level") = v18_res_ag_removal.l(i,kcr,attributes); @@ -37,9 +40,11 @@ oq18_res_field_balance(t,i,kcr,attributes,"level") = q18_res_field_balance.l(i,kcr,attributes); oq18_res_field_burn(t,i,kcr,attributes,"level") = q18_res_field_burn.l(i,kcr,attributes); oq18_translate(t,i,kres,attributes,"level") = q18_translate.l(i,kres,attributes); + oq18_prod_res_cell(t,j,kres,"level") = q18_prod_res_cell.l(j,kres); oq18_res_recycling_nr(t,i,"level") = q18_res_recycling_nr.l(i); oq18_res_recycling_pk(t,i,pk18,"level") = q18_res_recycling_pk.l(i,pk18); oq18_cost_prod_res(t,i,kres,"level") = q18_cost_prod_res.l(i,kres); + ov18_prod_res(t,j,kres,"upper") = v18_prod_res.up(j,kres); ov_res_biomass_ag(t,i,kcr,attributes,"upper") = vm_res_biomass_ag.up(i,kcr,attributes); ov_res_biomass_bg(t,i,kcr,dm_nr,"upper") = vm_res_biomass_bg.up(i,kcr,dm_nr); ov18_res_ag_removal(t,i,kcr,attributes,"upper") = v18_res_ag_removal.up(i,kcr,attributes); @@ -52,9 +57,11 @@ oq18_res_field_balance(t,i,kcr,attributes,"upper") = q18_res_field_balance.up(i,kcr,attributes); oq18_res_field_burn(t,i,kcr,attributes,"upper") = q18_res_field_burn.up(i,kcr,attributes); oq18_translate(t,i,kres,attributes,"upper") = q18_translate.up(i,kres,attributes); + oq18_prod_res_cell(t,j,kres,"upper") = q18_prod_res_cell.up(j,kres); oq18_res_recycling_nr(t,i,"upper") = q18_res_recycling_nr.up(i); oq18_res_recycling_pk(t,i,pk18,"upper") = q18_res_recycling_pk.up(i,pk18); oq18_cost_prod_res(t,i,kres,"upper") = q18_cost_prod_res.up(i,kres); + ov18_prod_res(t,j,kres,"lower") = v18_prod_res.lo(j,kres); ov_res_biomass_ag(t,i,kcr,attributes,"lower") = vm_res_biomass_ag.lo(i,kcr,attributes); ov_res_biomass_bg(t,i,kcr,dm_nr,"lower") = vm_res_biomass_bg.lo(i,kcr,dm_nr); ov18_res_ag_removal(t,i,kcr,attributes,"lower") = v18_res_ag_removal.lo(i,kcr,attributes); @@ -67,6 +74,7 @@ oq18_res_field_balance(t,i,kcr,attributes,"lower") = q18_res_field_balance.lo(i,kcr,attributes); oq18_res_field_burn(t,i,kcr,attributes,"lower") = q18_res_field_burn.lo(i,kcr,attributes); oq18_translate(t,i,kres,attributes,"lower") = q18_translate.lo(i,kres,attributes); + oq18_prod_res_cell(t,j,kres,"lower") = q18_prod_res_cell.lo(j,kres); oq18_res_recycling_nr(t,i,"lower") = q18_res_recycling_nr.lo(i); oq18_res_recycling_pk(t,i,pk18,"lower") = q18_res_recycling_pk.lo(i,pk18); oq18_cost_prod_res(t,i,kres,"lower") = q18_cost_prod_res.lo(i,kres); diff --git a/modules/18_residues/module.gms b/modules/18_residues/module.gms index 3ef463f67b..da6f79ebef 100644 --- a/modules/18_residues/module.gms +++ b/modules/18_residues/module.gms @@ -17,6 +17,7 @@ *' @authors Benjamin Leon Bodirsky *###################### R SECTION START (MODULETYPES) ########################## +$Ifi "%residues%" == "flexcluster_jul23" $include "./modules/18_residues/flexcluster_jul23/realization.gms" $Ifi "%residues%" == "flexreg_apr16" $include "./modules/18_residues/flexreg_apr16/realization.gms" $Ifi "%residues%" == "off" $include "./modules/18_residues/off/realization.gms" *###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/18_residues/off/not_used.txt b/modules/18_residues/off/not_used.txt index 90acf4b328..85051d6636 100644 --- a/modules/18_residues/off/not_used.txt +++ b/modules/18_residues/off/not_used.txt @@ -3,3 +3,4 @@ im_development_state,input,questionnaire fm_attributes,input,questionnaire vm_prod_reg,input,questionnaire vm_area,input,questionnaire +vm_prod,input,questionnaire \ No newline at end of file diff --git a/modules/32_forestry/dynamic_feb21/declarations.gms b/modules/32_forestry/dynamic_feb21/declarations.gms index 112cf412b6..02cfec92c9 100644 --- a/modules/32_forestry/dynamic_feb21/declarations.gms +++ b/modules/32_forestry/dynamic_feb21/declarations.gms @@ -59,6 +59,7 @@ parameters p32_bii_coeff(type32,bii_class_secd,potnatveg) bii coeff (1) p32_c_density_ac_fast_forestry(t_all,j,ac) Carbon densities in plantations based on Braakhekke et al (tC per ha) p32_disturbance_loss_ftype32(t,j,type32,ac) Loss due to disturbances in all plantation type forests (mio. ha) + pcm_land_forestry(j,type32) Forestry land (mio. ha) ; positive variables @@ -73,6 +74,7 @@ positive variables v32_cost_establishment(i) Cost of establishment calculated at the current time step (mio. USD) v32_hvarea_forestry(j,ac) Harvested area from timber plantations (mio. ha) vm_prod_forestry(j,kforestry) Production of woody biomass from commercial plantations (mio. tDM per yr) + vm_land_forestry(j,type32) Forestry land (mio. ha) ; variables @@ -104,6 +106,7 @@ equations q32_bv_aff(j,potnatveg) Biodiversity value for aff forestry land (Mha) q32_bv_ndc(j,potnatveg) Biodiversity value for ndc forestry land (Mha) q32_bv_plant(j,potnatveg) Biodiversity value for plantations (Mha) + q32_land_forestry(j,type32) Forestry land (Mha) ; @@ -120,6 +123,7 @@ parameters ov32_cost_establishment(t,i,type) Cost of establishment calculated at the current time step (mio. USD) ov32_hvarea_forestry(t,j,ac,type) Harvested area from timber plantations (mio. ha) ov_prod_forestry(t,j,kforestry,type) Production of woody biomass from commercial plantations (mio. tDM per yr) + ov_land_forestry(t,j,type32,type) Forestry land (mio. ha) ov_cdr_aff(t,j,ac,aff_effect,type) Expected bgc (CDR) and local bph effects of afforestation depending on planning horizon (mio. tC) oq32_cost_total(t,i,type) Total forestry costs constraint (mio. USD) oq32_land(t,j,type) Land constraint (mio. ha) @@ -145,5 +149,6 @@ parameters oq32_bv_aff(t,j,potnatveg,type) Biodiversity value for aff forestry land (Mha) oq32_bv_ndc(t,j,potnatveg,type) Biodiversity value for ndc forestry land (Mha) oq32_bv_plant(t,j,potnatveg,type) Biodiversity value for plantations (Mha) + oq32_land_forestry(t,j,type32,type) Forestry land (Mha) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/32_forestry/dynamic_feb21/equations.gms b/modules/32_forestry/dynamic_feb21/equations.gms index d17234cce2..08a5a60016 100644 --- a/modules/32_forestry/dynamic_feb21/equations.gms +++ b/modules/32_forestry/dynamic_feb21/equations.gms @@ -56,6 +56,9 @@ sum(ac_est, v32_land(j2,"aff",ac_est)) =l= sum(ac, v32_land(j2,"aff",ac)) - sum( q32_land(j2) .. vm_land(j2,"forestry") =e= sum((type32,ac), v32_land(j2,type32,ac)); + q32_land_forestry(j2,type32) .. + vm_land_forestry(j2,type32) =e= sum(ac, v32_land(j2,type32,ac)); + *' The constraint `q32_aff_pol` accounts for the exogenous afforestation prescribed by NPI/NDC policies. q32_aff_pol(j2) .. diff --git a/modules/32_forestry/dynamic_feb21/postsolve.gms b/modules/32_forestry/dynamic_feb21/postsolve.gms index c8d03d0a2e..71a9bd11c6 100644 --- a/modules/32_forestry/dynamic_feb21/postsolve.gms +++ b/modules/32_forestry/dynamic_feb21/postsolve.gms @@ -7,6 +7,7 @@ *' @code *' Exchange land information after optimization p32_land(t,j,type32,ac) = v32_land.l(j,type32,ac); +pcm_land_forestry(j,type32) = vm_land_forestry.l(j,type32); *' @stop *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### @@ -21,6 +22,7 @@ p32_land(t,j,type32,ac) = v32_land.l(j,type32,ac); ov32_cost_establishment(t,i,"marginal") = v32_cost_establishment.m(i); ov32_hvarea_forestry(t,j,ac,"marginal") = v32_hvarea_forestry.m(j,ac); ov_prod_forestry(t,j,kforestry,"marginal") = vm_prod_forestry.m(j,kforestry); + ov_land_forestry(t,j,type32,"marginal") = vm_land_forestry.m(j,type32); ov_cdr_aff(t,j,ac,aff_effect,"marginal") = vm_cdr_aff.m(j,ac,aff_effect); oq32_cost_total(t,i,"marginal") = q32_cost_total.m(i); oq32_land(t,j,"marginal") = q32_land.m(j); @@ -46,6 +48,7 @@ p32_land(t,j,type32,ac) = v32_land.l(j,type32,ac); oq32_bv_aff(t,j,potnatveg,"marginal") = q32_bv_aff.m(j,potnatveg); oq32_bv_ndc(t,j,potnatveg,"marginal") = q32_bv_ndc.m(j,potnatveg); oq32_bv_plant(t,j,potnatveg,"marginal") = q32_bv_plant.m(j,potnatveg); + oq32_land_forestry(t,j,type32,"marginal") = q32_land_forestry.m(j,type32); ov_cost_fore(t,i,"level") = vm_cost_fore.l(i); ov32_cost_hvarea(t,i,"level") = v32_cost_hvarea.l(i); ov32_land(t,j,type32,ac,"level") = v32_land.l(j,type32,ac); @@ -57,6 +60,7 @@ p32_land(t,j,type32,ac) = v32_land.l(j,type32,ac); ov32_cost_establishment(t,i,"level") = v32_cost_establishment.l(i); ov32_hvarea_forestry(t,j,ac,"level") = v32_hvarea_forestry.l(j,ac); ov_prod_forestry(t,j,kforestry,"level") = vm_prod_forestry.l(j,kforestry); + ov_land_forestry(t,j,type32,"level") = vm_land_forestry.l(j,type32); ov_cdr_aff(t,j,ac,aff_effect,"level") = vm_cdr_aff.l(j,ac,aff_effect); oq32_cost_total(t,i,"level") = q32_cost_total.l(i); oq32_land(t,j,"level") = q32_land.l(j); @@ -82,6 +86,7 @@ p32_land(t,j,type32,ac) = v32_land.l(j,type32,ac); oq32_bv_aff(t,j,potnatveg,"level") = q32_bv_aff.l(j,potnatveg); oq32_bv_ndc(t,j,potnatveg,"level") = q32_bv_ndc.l(j,potnatveg); oq32_bv_plant(t,j,potnatveg,"level") = q32_bv_plant.l(j,potnatveg); + oq32_land_forestry(t,j,type32,"level") = q32_land_forestry.l(j,type32); ov_cost_fore(t,i,"upper") = vm_cost_fore.up(i); ov32_cost_hvarea(t,i,"upper") = v32_cost_hvarea.up(i); ov32_land(t,j,type32,ac,"upper") = v32_land.up(j,type32,ac); @@ -93,6 +98,7 @@ p32_land(t,j,type32,ac) = v32_land.l(j,type32,ac); ov32_cost_establishment(t,i,"upper") = v32_cost_establishment.up(i); ov32_hvarea_forestry(t,j,ac,"upper") = v32_hvarea_forestry.up(j,ac); ov_prod_forestry(t,j,kforestry,"upper") = vm_prod_forestry.up(j,kforestry); + ov_land_forestry(t,j,type32,"upper") = vm_land_forestry.up(j,type32); ov_cdr_aff(t,j,ac,aff_effect,"upper") = vm_cdr_aff.up(j,ac,aff_effect); oq32_cost_total(t,i,"upper") = q32_cost_total.up(i); oq32_land(t,j,"upper") = q32_land.up(j); @@ -118,6 +124,7 @@ p32_land(t,j,type32,ac) = v32_land.l(j,type32,ac); oq32_bv_aff(t,j,potnatveg,"upper") = q32_bv_aff.up(j,potnatveg); oq32_bv_ndc(t,j,potnatveg,"upper") = q32_bv_ndc.up(j,potnatveg); oq32_bv_plant(t,j,potnatveg,"upper") = q32_bv_plant.up(j,potnatveg); + oq32_land_forestry(t,j,type32,"upper") = q32_land_forestry.up(j,type32); ov_cost_fore(t,i,"lower") = vm_cost_fore.lo(i); ov32_cost_hvarea(t,i,"lower") = v32_cost_hvarea.lo(i); ov32_land(t,j,type32,ac,"lower") = v32_land.lo(j,type32,ac); @@ -129,6 +136,7 @@ p32_land(t,j,type32,ac) = v32_land.l(j,type32,ac); ov32_cost_establishment(t,i,"lower") = v32_cost_establishment.lo(i); ov32_hvarea_forestry(t,j,ac,"lower") = v32_hvarea_forestry.lo(j,ac); ov_prod_forestry(t,j,kforestry,"lower") = vm_prod_forestry.lo(j,kforestry); + ov_land_forestry(t,j,type32,"lower") = vm_land_forestry.lo(j,type32); ov_cdr_aff(t,j,ac,aff_effect,"lower") = vm_cdr_aff.lo(j,ac,aff_effect); oq32_cost_total(t,i,"lower") = q32_cost_total.lo(i); oq32_land(t,j,"lower") = q32_land.lo(j); @@ -154,4 +162,5 @@ p32_land(t,j,type32,ac) = v32_land.l(j,type32,ac); oq32_bv_aff(t,j,potnatveg,"lower") = q32_bv_aff.lo(j,potnatveg); oq32_bv_ndc(t,j,potnatveg,"lower") = q32_bv_ndc.lo(j,potnatveg); oq32_bv_plant(t,j,potnatveg,"lower") = q32_bv_plant.lo(j,potnatveg); + oq32_land_forestry(t,j,type32,"lower") = q32_land_forestry.lo(j,type32); *##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/32_forestry/dynamic_feb21/preloop.gms b/modules/32_forestry/dynamic_feb21/preloop.gms index 4702a2457f..a1754a92d2 100644 --- a/modules/32_forestry/dynamic_feb21/preloop.gms +++ b/modules/32_forestry/dynamic_feb21/preloop.gms @@ -216,7 +216,8 @@ loop(j, ); ); ** Initialization of land -*p32_land_start_ac(j,type32,ac) = p32_land("y1995",j,type32,ac); +vm_land_forestry.l(j,type32) = sum(ac, p32_land_start_ac(j,type32,ac)); +pcm_land_forestry(j,type32) = vm_land_forestry.l(j,type32); *** NPI/NDC policies BEGIN ** Afforestation policies NPI and NDCs diff --git a/modules/32_forestry/dynamic_feb21/realization.gms b/modules/32_forestry/dynamic_feb21/realization.gms index 9d61742870..996c9c38e4 100644 --- a/modules/32_forestry/dynamic_feb21/realization.gms +++ b/modules/32_forestry/dynamic_feb21/realization.gms @@ -29,7 +29,7 @@ *' For harvesting decisions we assume that land owners stick to their establishment decision, *' e.g. if a plantation has been established with a rotation length of 30 years *' it will be harvested after 30 years, even so the rotation length in the prevailing -*' time step, used for establishment, is shorter or longer. +*' time step, used for establishment, is shorter or longer. See @mishra_forestry_2021 for more details. *' @limitations Rotation lengths for timber plantations are not endogenous. diff --git a/modules/32_forestry/module.gms b/modules/32_forestry/module.gms index f929157732..002538276d 100644 --- a/modules/32_forestry/module.gms +++ b/modules/32_forestry/module.gms @@ -7,11 +7,17 @@ *' @title Forestry *' -*' @description The forestry module describes the constraints under which managed -*' forest (age-class forest) exists. At the same time it calculates the corresponding -*' carbon stocks and biodiversity value. The module provides carbon dioxide removal (CDR) from afforestation -*' to the GHG policy module ([56_ghg_policy]) as well as afforestation related costs -*' to the costs module ([11_costs]). +*' @description The forestry module describes the constraints under which three different +*' types of managed age-class forests exist: plantations used for wood harvesting (plant), +*' prescribed re/afforestation based on existing national policies (ndc) and endogenous +*' CO2-price driven re/afforestation (aff) (@humpenoeder_overcoming_2022). +*' These types of managed forests are made +*' available to other modules via the interface `vm_land_forestry`. At the same time, +*' the module calculates the corresponding carbon stocks and biodiversity values for all +*' three types of managed forest. The module provides expected carbon dioxide removal (CDR) +*' from endogenous re/afforestation to the GHG policy module ([56_ghg_policy]). +*' Costs related to managed forests, including costs for harvesting, establishment and +*' management, are provided to the cost module ([11_costs]). *' *' @authors Florian Humpenöder, Abhijeet Mishra diff --git a/modules/36_employment/exo_may22/preloop.gms b/modules/36_employment/exo_may22/preloop.gms index f2fba081bc..428cfe743a 100644 --- a/modules/36_employment/exo_may22/preloop.gms +++ b/modules/36_employment/exo_may22/preloop.gms @@ -6,19 +6,17 @@ *** | Contact: magpie@pik-potsdam.de * get calibration factors and aggregation weight -p36_calibration_hourly_costs(iso) = sum(t_past$(ord(t_past) eq card(t_past)), f36_hist_hourly_costs(t_past,iso)-(im_gdp_pc_mer_iso(t_past,iso) - *f36_regr_hourly_costs("slope")+f36_regr_hourly_costs("intercept"))); +p36_calibration_hourly_costs(iso) = sum(t_past$(ord(t_past) eq card(t_past)), log(f36_hist_hourly_costs(t_past,iso)) - (log(im_gdp_pc_mer_iso(t_past,iso)) + *f36_regr_hourly_costs("slope") + f36_regr_hourly_costs("intercept"))); p36_total_hours_worked(iso) = sum(t_past$(ord(t_past) eq card(t_past)), f36_historic_ag_empl(t_past,iso)*f36_weekly_hours_iso(t_past,iso)*s36_weeks_in_year); *' @code -*' Hourly labor costs are projected into the future by using a linear regression with +*' Hourly labor costs are projected into the future by using a log-log regression with *' GDPpcMER, which is calibrated such that historic values of agricultural employment -*' are met. A threshold is used in the regression to avoid too low or negative hourly -*' labor costs. -p36_hourly_costs_iso(t_all,iso,"baseline") = max((im_gdp_pc_mer_iso(t_all,iso) * f36_regr_hourly_costs("slope") + - f36_regr_hourly_costs("intercept") + p36_calibration_hourly_costs(iso)), - f36_regr_hourly_costs("threshold")); +*' are met. +p36_hourly_costs_iso(t_all,iso,"baseline") = exp(log(im_gdp_pc_mer_iso(t_all,iso)) * f36_regr_hourly_costs("slope") + + f36_regr_hourly_costs("intercept") + p36_calibration_hourly_costs(iso)); *' @stop diff --git a/modules/36_employment/exo_may22/sets.gms b/modules/36_employment/exo_may22/sets.gms index 8e165f7fc9..f31f93993d 100644 --- a/modules/36_employment/exo_may22/sets.gms +++ b/modules/36_employment/exo_may22/sets.gms @@ -7,7 +7,7 @@ sets reg36 regression coefficients - / slope, intercept, threshold / + / slope, intercept / wage_scen version of wages / baseline, scenario / ; diff --git a/modules/56_ghg_policy/price_aug22/sets.gms b/modules/56_ghg_policy/price_aug22/sets.gms index 93118855d6..f64637e8cb 100644 --- a/modules/56_ghg_policy/price_aug22/sets.gms +++ b/modules/56_ghg_policy/price_aug22/sets.gms @@ -84,12 +84,16 @@ sets all_nosoil, redd_nosoil, redd_nosoil_nopeat, + redd_nosoil_peatCO2only, reddnatveg_nosoil, reddnatveg_nosoil_nopeat, + reddnatveg_nosoil_peatCO2only, redd+_nosoil, redd+_nosoil_nopeat, + redd+_nosoil_peatCO2only, redd+natveg_nosoil, redd+natveg_nosoil_nopeat, + redd+natveg_nosoil_peatCO2only, all_vegc, redd_vegc, reddnatveg_vegc, diff --git a/modules/58_peatland/input/files b/modules/58_peatland/input/files index 8d133b4e46..3509c27c10 100644 --- a/modules/58_peatland/input/files +++ b/modules/58_peatland/input/files @@ -2,3 +2,5 @@ f58_peatland_degrad.cs2 f58_peatland_intact.cs2 f58_ipcc_wetland_ef.cs3 +f58_ipcc_wetland_ef2.cs3 +f58_peatland_area.cs2 diff --git a/modules/58_peatland/module.gms b/modules/58_peatland/module.gms index 66a828b7bf..a69f8bb9a3 100644 --- a/modules/58_peatland/module.gms +++ b/modules/58_peatland/module.gms @@ -14,4 +14,5 @@ *###################### R SECTION START (MODULETYPES) ########################## $Ifi "%peatland%" == "off" $include "./modules/58_peatland/off/realization.gms" $Ifi "%peatland%" == "on" $include "./modules/58_peatland/on/realization.gms" +$Ifi "%peatland%" == "v2" $include "./modules/58_peatland/v2/realization.gms" *###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/58_peatland/off/not_used.txt b/modules/58_peatland/off/not_used.txt index 33f27da3b8..8b45b33bd6 100644 --- a/modules/58_peatland/off/not_used.txt +++ b/modules/58_peatland/off/not_used.txt @@ -3,3 +3,5 @@ vm_land, input, not used pcm_land, input, not used pm_interest, input, not used pm_climate_class, input, not used +vm_land_forestry, input, not used +pcm_land_forestry, input, not used diff --git a/modules/58_peatland/on/equations.gms b/modules/58_peatland/on/equations.gms index b2214146eb..78b8ef032b 100644 --- a/modules/58_peatland/on/equations.gms +++ b/modules/58_peatland/on/equations.gms @@ -69,8 +69,8 @@ *' The following example illustrates the mechanism used for projecting peatland dynamics: *' In a given grid cell, the total land area is 50 Mha and the total peatland area is 10 Mha. *' Therefore, the scaling factor is 0.2 (10 Mha divided by 50 Mha). -*' If cropland expands by 5 Mha, 1 Mha of intact peatland is converted to degraded peatland (5 Mha*0.2). -*' If the total cell would become cropland, degraded peatland would equal to the total peatland area (50 Mha * 0.2 = 10 Mha). +*' If cropland expands by 5 Mha, 1 Mha of intact peatland is converted to degraded peatland (5 Mha x 0.2). +*' If the total cell would become cropland, degraded peatland would equal to the total peatland area (50 Mha x 0.2 = 10 Mha). q58_peatland_degrad(j2,land58)$(sum(ct, m_year(ct)) > s58_fix_peatland) .. v58_peatland_man(j2,"degrad",land58) =e= diff --git a/modules/58_peatland/on/not_used.txt b/modules/58_peatland/on/not_used.txt new file mode 100644 index 0000000000..a2be78997a --- /dev/null +++ b/modules/58_peatland/on/not_used.txt @@ -0,0 +1,3 @@ +name, type, reason +vm_land_forestry, input, not used +pcm_land_forestry, input, not used diff --git a/modules/58_peatland/on/realization.gms b/modules/58_peatland/on/realization.gms index 41418aa77b..8485443ce9 100644 --- a/modules/58_peatland/on/realization.gms +++ b/modules/58_peatland/on/realization.gms @@ -6,10 +6,10 @@ *** | Contact: magpie@pik-potsdam.de *' @description In this realization, the state of peatlands is modelled as described in @humpenoder_peatland_2020. -*' The initial map of peatland area consists of intact and degraded peatland area for the year 2015. -*' Future peatland dynamics depend on the ratio of total peatland area and total land area. -*' GHG emissions from degraded and rewetted peatlands as are calculated based on GHG emission factors from the -*' "2013 Supplement to the 2006 IPCC Guidelines for National Greenhouse Gas Inventories: Wetlands". +*' The initial map of peatland area consists of intact and degraded peatland area for the year 2015, +*' based on @leifeld_2018 and the [Global Peatland Database](https://greifswaldmoor.de/global-peatland-database-en.html). +*' Future peatland dynamics are estimated by scaling changes in managed land with the ratio of total peatland area and total land area (peatland scaling factor). +*' GHG emissions from degraded and rewetted peatlands are calculated using IPCC wetland GHG emission factors from @IPCC_wetland_2013 and @wilson_2016. *' @stop diff --git a/modules/58_peatland/v2/declarations.gms b/modules/58_peatland/v2/declarations.gms new file mode 100644 index 0000000000..79deb095b0 --- /dev/null +++ b/modules/58_peatland/v2/declarations.gms @@ -0,0 +1,68 @@ +*** | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) +*** | authors, and contributors see CITATION.cff file. This file is part +*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of +*** | AGPL-3.0, you are granted additional permissions described in the +*** | MAgPIE License Exception, version 1.0 (see LICENSE file). +*** | Contact: magpie@pik-potsdam.de + +parameters + p58_scaling_factor(j) Scaling factor for managed peatland (1) + pc58_peatland(j,land58) Peatland area (mio. ha) + p58_mapping_cell_climate(j,clcl58) Mapping between cells and climate regions (binary) + i58_cost_rewet_recur(t) Recurring costs for rewetted peatland (USD05MER per ha) + i58_cost_rewet_onetime(t) One-time costs for peatland restoration (USD05MER per ha) + i58_cost_degrad_recur(t) Recurring costs for degraded peatland (USD05MER per ha) + i58_cost_degrad_onetime(t) One-time costs for peatland degradation (USD05MER per ha) +; + +equations + q58_peatland(j) Constraint for peatland area (mio. ha) + q58_expansion(j,land58) Peatland expansion (mio. ha) + q58_reduction(j,land58) Peatland reduction (mio. ha) + q58_peatland_rewet(j) Constraint for peatland rewetting (mio. ha) + q58_peatland_crop(j) Degraded peatland used as cropland (mio. ha) + q58_peatland_past(j) Degraded peatland used as pasture (mio. ha) + q58_peatland_forestry(j) Degraded peatland used for forestry (mio. ha) + q58_peatland_cost_full(j) One-time and recurring cost of peatland conversion and management including artifical balance cost (mio. USD05MER per yr) + q58_peatland_cost(j) One-time and recurring cost of peatland conversion and management (mio. USD05MER per yr) + q58_peatland_cost_annuity(j) Annuity costs of peatland conversion in the current timestep (mio. USD05MER per yr) + q58_peatland_emis_detail(j,land58,emis58) Detailed GHG emissions from peatlands (Tg per yr) + q58_peatland_emis(i,poll58) GHG emissions from managed peatland (Tg per yr) +; + +variables + vm_peatland_cost(j) One-time and recurring cost of managed peatland including artifical balance cost (mio. USD05MER per yr) + v58_peatland_cost(j) One-time and recurring cost of managed peatland (mio. USD05MER per yr) + v58_peatland_cost_annuity(j) Annuity costs of managed peatland expansion in the current timestep (mio. USD05MER per yr) + v58_peatland_emis(j,land58,emis58) Detailed GHG peatland GHG emissions (Tg per yr) +; + +positive variables + v58_expansion(j,land58) Peatland expansion (mio. ha) + v58_reduction(j,land58) Peatland reduction (mio. ha) + v58_peatland(j,land58) Managed peatland (mio. ha) +; + +*#################### R SECTION START (OUTPUT DECLARATIONS) #################### +parameters + ov_peatland_cost(t,j,type) One-time and recurring cost of managed peatland including artifical balance cost (mio. USD05MER per yr) + ov58_peatland_cost(t,j,type) One-time and recurring cost of managed peatland (mio. USD05MER per yr) + ov58_peatland_cost_annuity(t,j,type) Annuity costs of managed peatland expansion in the current timestep (mio. USD05MER per yr) + ov58_peatland_emis(t,j,land58,emis58,type) Detailed GHG peatland GHG emissions (Tg per yr) + ov58_expansion(t,j,land58,type) Peatland expansion (mio. ha) + ov58_reduction(t,j,land58,type) Peatland reduction (mio. ha) + ov58_peatland(t,j,land58,type) Managed peatland (mio. ha) + oq58_peatland(t,j,type) Constraint for peatland area (mio. ha) + oq58_expansion(t,j,land58,type) Peatland expansion (mio. ha) + oq58_reduction(t,j,land58,type) Peatland reduction (mio. ha) + oq58_peatland_rewet(t,j,type) Constraint for peatland rewetting (mio. ha) + oq58_peatland_crop(t,j,type) Degraded peatland used as cropland (mio. ha) + oq58_peatland_past(t,j,type) Degraded peatland used as pasture (mio. ha) + oq58_peatland_forestry(t,j,type) Degraded peatland used for forestry (mio. ha) + oq58_peatland_cost_full(t,j,type) One-time and recurring cost of peatland conversion and management including artifical balance cost (mio. USD05MER per yr) + oq58_peatland_cost(t,j,type) One-time and recurring cost of peatland conversion and management (mio. USD05MER per yr) + oq58_peatland_cost_annuity(t,j,type) Annuity costs of peatland conversion in the current timestep (mio. USD05MER per yr) + oq58_peatland_emis_detail(t,j,land58,emis58,type) Detailed GHG emissions from peatlands (Tg per yr) + oq58_peatland_emis(t,i,poll58,type) GHG emissions from managed peatland (Tg per yr) +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/58_peatland/v2/equations.gms b/modules/58_peatland/v2/equations.gms new file mode 100644 index 0000000000..93a71cee3a --- /dev/null +++ b/modules/58_peatland/v2/equations.gms @@ -0,0 +1,83 @@ +*** | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) +*** | authors, and contributors see CITATION.cff file. This file is part +*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of +*** | AGPL-3.0, you are granted additional permissions described in the +*** | MAgPIE License Exception, version 1.0 (see LICENSE file). +*** | Contact: magpie@pik-potsdam.de + +*' @equations + +*' Constraint for constant total peatland area: + + q58_peatland(j2)$(sum(ct, m_year(ct)) > s58_fix_peatland) .. + sum(land58, v58_peatland(j2,land58)) =e= sum(land58, pc58_peatland(j2,land58)); + +*' Constraints for peatland area expansion and reduction: + + q58_expansion(j2,land58) .. + v58_expansion(j2,land58) =g= v58_peatland(j2,land58)-pc58_peatland(j2,land58); + + q58_reduction(j2,land58) .. + v58_reduction(j2,land58) =g= pc58_peatland(j2,land58)-v58_peatland(j2,land58); + +*' Future peatland degradation (`v58_peatland`) depends on managed land (`vm_land`, `vm_land_forestry`), +*' scaled with the ratio of total peatland area and total land area (`p58_scaling_factor`). +*' By multiplying changes in managed land with the scaling factor we implicitly assume +*' that intact peatlands are distributed equally within a grid cell. +*' The following example illustrates the mechanism used for projecting peatland dynamics: +*' In a given grid cell, the total land area is 50 Mha and the total peatland area is 10 Mha. +*' Therefore, the scaling factor is 0.2 (10 Mha divided by 50 Mha). +*' If cropland expands by 5 Mha, 1 Mha of intact peatland is converted to degraded peatland (5 Mha x 0.2). +*' If the total cell would become cropland, degraded peatland would equal to the total peatland area (50 Mha x 0.2 = 10 Mha). + + q58_peatland_crop(j2)$(sum(ct, m_year(ct)) > s58_fix_peatland) .. + v58_peatland(j2,"crop") =e= + pc58_peatland(j2,"crop") + + ((vm_land(j2,"crop")-pcm_land(j2,"crop"))*p58_scaling_factor(j2)); + + q58_peatland_past(j2)$(sum(ct, m_year(ct)) > s58_fix_peatland) .. + v58_peatland(j2,"past") =e= + pc58_peatland(j2,"past") + + ((vm_land(j2,"past")-pcm_land(j2,"past"))*p58_scaling_factor(j2)); + + q58_peatland_forestry(j2)$(sum(ct, m_year(ct)) > s58_fix_peatland) .. + v58_peatland(j2,"forestry") =e= + pc58_peatland(j2,"forestry") + + ((vm_land_forestry(j2,"plant")-pcm_land_forestry(j2,"plant"))*p58_scaling_factor(j2)); + +*' This constraint avoids the conversion of intact peatland into rewetted peatland. +*' In each cluster, rewetted peatland area can only increase if no intact peatland area is lost. +*' Therefore, rewetted peatland area can only increase if degraded peatland area (`landDrained58`) declines. + + q58_peatland_rewet(j2) .. + v58_expansion(j2,"rewetted") * v58_reduction(j2,"intact") =e= 0; + +*' Costs for peatland degradation and rewetting + + q58_peatland_cost_full(j2) .. + vm_peatland_cost(j2) =e= v58_peatland_cost(j2); + + q58_peatland_cost(j2) .. + v58_peatland_cost(j2) =e= v58_peatland_cost_annuity(j2) + + v58_peatland(j2,"rewetted") * sum(ct, i58_cost_rewet_recur(ct)) + + sum(landDrainedUsed58, v58_peatland(j2,landDrainedUsed58)) * sum(ct, i58_cost_degrad_recur(ct)); + + q58_peatland_cost_annuity(j2) .. + v58_peatland_cost_annuity(j2) =e= + (v58_expansion(j2,"rewetted") * sum(ct, i58_cost_rewet_onetime(ct)) + + v58_reduction(j2,"intact") * sum(ct, i58_cost_degrad_onetime(ct))) + * sum((cell(i2,j2),ct),pm_interest(ct,i2)/(1+pm_interest(ct,i2))); + +*' Detailed peatland GHG emissions + + q58_peatland_emis_detail(j2,land58,emis58) .. + v58_peatland_emis(j2,land58,emis58) =e= + sum(clcl58, v58_peatland(j2,land58) * + p58_mapping_cell_climate(j2,clcl58) * f58_ipcc_wetland_ef(clcl58,land58,emis58)); + +*' Aggregation of detailed peatland GHG emissions for interface `vm_emissions_reg` + + q58_peatland_emis(i2,poll58) .. + vm_emissions_reg(i2,"peatland",poll58) =e= + sum((cell(i2,j2),land58,emisSub58_to_poll58(emisSub58,poll58)), + v58_peatland_emis(j2,land58,emisSub58)); diff --git a/modules/58_peatland/v2/input.gms b/modules/58_peatland/v2/input.gms new file mode 100644 index 0000000000..3dfd0ee85b --- /dev/null +++ b/modules/58_peatland/v2/input.gms @@ -0,0 +1,30 @@ +*** | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) +*** | authors, and contributors see CITATION.cff file. This file is part +*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of +*** | AGPL-3.0, you are granted additional permissions described in the +*** | MAgPIE License Exception, version 1.0 (see LICENSE file). +*** | Contact: magpie@pik-potsdam.de + +scalars + s58_cost_rewet_recur Recurring costs for rewetted peatland (USD05MER per ha) / 200 / + s58_cost_rewet_onetime One-time costs for peatland restoration (USD05MER per ha) / 7000 / + s58_cost_degrad_recur Recurring costs for degraded peatland (USD05MER per ha) / 0 / + s58_cost_degrad_onetime One-time costs for peatland degradation (USD05MER per ha) / 0 / + s58_rewetting_switch Peatland rewetting on (Inf) or off (0) / Inf / + s58_fix_peatland Year indicating until when peatland area should be fixed to 2020 levels (year) / 2015 / + s58_cost_balance Artificial cost for balance variable (USD05MER per ha) / 1e+06 / +; + +*Peatland area based on Global Peatland Map 2.0 and Global Peatland Database +table f58_peatland_area(j,land58) Peatland area (mio. ha) +$ondelim +$include "./modules/58_peatland/input/f58_peatland_area.cs2" +$offdelim +; + +*Wetland GHG emission factors based on IPCC Wetlands 2014 and Tiemeyer et al. 2020 +table f58_ipcc_wetland_ef(clcl58,land58,emis58) Wetland emission factors (Tg per yr) +$ondelim +$include "./modules/58_peatland/input/f58_ipcc_wetland_ef2.cs3" +$offdelim +; diff --git a/modules/58_peatland/v2/postsolve.gms b/modules/58_peatland/v2/postsolve.gms new file mode 100644 index 0000000000..a8ac15872b --- /dev/null +++ b/modules/58_peatland/v2/postsolve.gms @@ -0,0 +1,87 @@ +*** | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) +*** | authors, and contributors see CITATION.cff file. This file is part +*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of +*** | AGPL-3.0, you are granted additional permissions described in the +*** | MAgPIE License Exception, version 1.0 (see LICENSE file). +*** | Contact: magpie@pik-potsdam.de + +pc58_peatland(j,land58) = v58_peatland.l(j,land58); + +*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + ov_peatland_cost(t,j,"marginal") = vm_peatland_cost.m(j); + ov58_peatland_cost(t,j,"marginal") = v58_peatland_cost.m(j); + ov58_peatland_cost_annuity(t,j,"marginal") = v58_peatland_cost_annuity.m(j); + ov58_peatland_emis(t,j,land58,emis58,"marginal") = v58_peatland_emis.m(j,land58,emis58); + ov58_expansion(t,j,land58,"marginal") = v58_expansion.m(j,land58); + ov58_reduction(t,j,land58,"marginal") = v58_reduction.m(j,land58); + ov58_peatland(t,j,land58,"marginal") = v58_peatland.m(j,land58); + oq58_peatland(t,j,"marginal") = q58_peatland.m(j); + oq58_expansion(t,j,land58,"marginal") = q58_expansion.m(j,land58); + oq58_reduction(t,j,land58,"marginal") = q58_reduction.m(j,land58); + oq58_peatland_rewet(t,j,"marginal") = q58_peatland_rewet.m(j); + oq58_peatland_crop(t,j,"marginal") = q58_peatland_crop.m(j); + oq58_peatland_past(t,j,"marginal") = q58_peatland_past.m(j); + oq58_peatland_forestry(t,j,"marginal") = q58_peatland_forestry.m(j); + oq58_peatland_cost_full(t,j,"marginal") = q58_peatland_cost_full.m(j); + oq58_peatland_cost(t,j,"marginal") = q58_peatland_cost.m(j); + oq58_peatland_cost_annuity(t,j,"marginal") = q58_peatland_cost_annuity.m(j); + oq58_peatland_emis_detail(t,j,land58,emis58,"marginal") = q58_peatland_emis_detail.m(j,land58,emis58); + oq58_peatland_emis(t,i,poll58,"marginal") = q58_peatland_emis.m(i,poll58); + ov_peatland_cost(t,j,"level") = vm_peatland_cost.l(j); + ov58_peatland_cost(t,j,"level") = v58_peatland_cost.l(j); + ov58_peatland_cost_annuity(t,j,"level") = v58_peatland_cost_annuity.l(j); + ov58_peatland_emis(t,j,land58,emis58,"level") = v58_peatland_emis.l(j,land58,emis58); + ov58_expansion(t,j,land58,"level") = v58_expansion.l(j,land58); + ov58_reduction(t,j,land58,"level") = v58_reduction.l(j,land58); + ov58_peatland(t,j,land58,"level") = v58_peatland.l(j,land58); + oq58_peatland(t,j,"level") = q58_peatland.l(j); + oq58_expansion(t,j,land58,"level") = q58_expansion.l(j,land58); + oq58_reduction(t,j,land58,"level") = q58_reduction.l(j,land58); + oq58_peatland_rewet(t,j,"level") = q58_peatland_rewet.l(j); + oq58_peatland_crop(t,j,"level") = q58_peatland_crop.l(j); + oq58_peatland_past(t,j,"level") = q58_peatland_past.l(j); + oq58_peatland_forestry(t,j,"level") = q58_peatland_forestry.l(j); + oq58_peatland_cost_full(t,j,"level") = q58_peatland_cost_full.l(j); + oq58_peatland_cost(t,j,"level") = q58_peatland_cost.l(j); + oq58_peatland_cost_annuity(t,j,"level") = q58_peatland_cost_annuity.l(j); + oq58_peatland_emis_detail(t,j,land58,emis58,"level") = q58_peatland_emis_detail.l(j,land58,emis58); + oq58_peatland_emis(t,i,poll58,"level") = q58_peatland_emis.l(i,poll58); + ov_peatland_cost(t,j,"upper") = vm_peatland_cost.up(j); + ov58_peatland_cost(t,j,"upper") = v58_peatland_cost.up(j); + ov58_peatland_cost_annuity(t,j,"upper") = v58_peatland_cost_annuity.up(j); + ov58_peatland_emis(t,j,land58,emis58,"upper") = v58_peatland_emis.up(j,land58,emis58); + ov58_expansion(t,j,land58,"upper") = v58_expansion.up(j,land58); + ov58_reduction(t,j,land58,"upper") = v58_reduction.up(j,land58); + ov58_peatland(t,j,land58,"upper") = v58_peatland.up(j,land58); + oq58_peatland(t,j,"upper") = q58_peatland.up(j); + oq58_expansion(t,j,land58,"upper") = q58_expansion.up(j,land58); + oq58_reduction(t,j,land58,"upper") = q58_reduction.up(j,land58); + oq58_peatland_rewet(t,j,"upper") = q58_peatland_rewet.up(j); + oq58_peatland_crop(t,j,"upper") = q58_peatland_crop.up(j); + oq58_peatland_past(t,j,"upper") = q58_peatland_past.up(j); + oq58_peatland_forestry(t,j,"upper") = q58_peatland_forestry.up(j); + oq58_peatland_cost_full(t,j,"upper") = q58_peatland_cost_full.up(j); + oq58_peatland_cost(t,j,"upper") = q58_peatland_cost.up(j); + oq58_peatland_cost_annuity(t,j,"upper") = q58_peatland_cost_annuity.up(j); + oq58_peatland_emis_detail(t,j,land58,emis58,"upper") = q58_peatland_emis_detail.up(j,land58,emis58); + oq58_peatland_emis(t,i,poll58,"upper") = q58_peatland_emis.up(i,poll58); + ov_peatland_cost(t,j,"lower") = vm_peatland_cost.lo(j); + ov58_peatland_cost(t,j,"lower") = v58_peatland_cost.lo(j); + ov58_peatland_cost_annuity(t,j,"lower") = v58_peatland_cost_annuity.lo(j); + ov58_peatland_emis(t,j,land58,emis58,"lower") = v58_peatland_emis.lo(j,land58,emis58); + ov58_expansion(t,j,land58,"lower") = v58_expansion.lo(j,land58); + ov58_reduction(t,j,land58,"lower") = v58_reduction.lo(j,land58); + ov58_peatland(t,j,land58,"lower") = v58_peatland.lo(j,land58); + oq58_peatland(t,j,"lower") = q58_peatland.lo(j); + oq58_expansion(t,j,land58,"lower") = q58_expansion.lo(j,land58); + oq58_reduction(t,j,land58,"lower") = q58_reduction.lo(j,land58); + oq58_peatland_rewet(t,j,"lower") = q58_peatland_rewet.lo(j); + oq58_peatland_crop(t,j,"lower") = q58_peatland_crop.lo(j); + oq58_peatland_past(t,j,"lower") = q58_peatland_past.lo(j); + oq58_peatland_forestry(t,j,"lower") = q58_peatland_forestry.lo(j); + oq58_peatland_cost_full(t,j,"lower") = q58_peatland_cost_full.lo(j); + oq58_peatland_cost(t,j,"lower") = q58_peatland_cost.lo(j); + oq58_peatland_cost_annuity(t,j,"lower") = q58_peatland_cost_annuity.lo(j); + oq58_peatland_emis_detail(t,j,land58,emis58,"lower") = q58_peatland_emis_detail.lo(j,land58,emis58); + oq58_peatland_emis(t,i,poll58,"lower") = q58_peatland_emis.lo(i,poll58); +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/58_peatland/v2/preloop.gms b/modules/58_peatland/v2/preloop.gms new file mode 100644 index 0000000000..2b06e06be0 --- /dev/null +++ b/modules/58_peatland/v2/preloop.gms @@ -0,0 +1,18 @@ +*** | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) +*** | authors, and contributors see CITATION.cff file. This file is part +*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of +*** | AGPL-3.0, you are granted additional permissions described in the +*** | MAgPIE License Exception, version 1.0 (see LICENSE file). +*** | Contact: magpie@pik-potsdam.de + +vm_emissions_reg.fx(i,"peatland",pollutants) = 0; +vm_emissions_reg.lo(i,"peatland",poll58) = -Inf; +vm_emissions_reg.up(i,"peatland",poll58) = Inf; + +p58_mapping_cell_climate(j,clcl58) = sum(clcl_mapping(clcl,clcl58),pm_climate_class(j,clcl)); + +* Peatland scaling factor: ratio of total peatland area and total land area +p58_scaling_factor(j)$(sum(land, pcm_land(j,land)) > 1e-20) = sum(land58, f58_peatland_area(j,land58)) / sum(land, pcm_land(j,land)); + +* Initialization of peatland area +pc58_peatland(j,land58) = 0; diff --git a/modules/58_peatland/v2/presolve.gms b/modules/58_peatland/v2/presolve.gms new file mode 100644 index 0000000000..bb84a16ec5 --- /dev/null +++ b/modules/58_peatland/v2/presolve.gms @@ -0,0 +1,41 @@ +*** | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) +*** | authors, and contributors see CITATION.cff file. This file is part +*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of +*** | AGPL-3.0, you are granted additional permissions described in the +*** | MAgPIE License Exception, version 1.0 (see LICENSE file). +*** | Contact: magpie@pik-potsdam.de + + +if (m_year(t) <= s58_fix_peatland, +* For initialization, degraded peatland is estimated by multiplication of managed land (cropland, pasture, forestry) with the peatland scaling factor (p58_scaling_factor) +* and simultaneously constrained by observed degraded peatland area (f58_peatland_area). + p58_scaling_factor(j)$(sum(land, pcm_land(j,land)) > 1e-20) = sum(land58, f58_peatland_area(j,land58)) / sum(land, pcm_land(j,land)); + pc58_peatland(j,"crop") = min(f58_peatland_area(j,"crop"),pcm_land(j,"crop") * p58_scaling_factor(j)); + pc58_peatland(j,"past") = min(f58_peatland_area(j,"past"), pcm_land(j,"past") * p58_scaling_factor(j)); + pc58_peatland(j,"forestry") = min(f58_peatland_area(j,"forestry"), pcm_land_forestry(j,"plant") * p58_scaling_factor(j)); +* The residual is added to an "unused" category, which represents degraded but unused peatland. + pc58_peatland(j,"unused") = sum(landDrainedUsed58, f58_peatland_area(j,landDrainedUsed58) - pc58_peatland(j,landDrainedUsed58)); +* Area used for peat extraction + pc58_peatland(j,"peatExtract") = f58_peatland_area(j,"peatExtract"); +* Intact peatland area + pc58_peatland(j,"intact") = f58_peatland_area(j,"intact"); + +* Peatland area is fixed to `pc58_peatland` until the year given by s58_fix_peatland + v58_peatland.fx(j,land58) = pc58_peatland(j,land58); + i58_cost_rewet_recur(t) = 0; + i58_cost_rewet_onetime(t) = 0; + i58_cost_degrad_recur(t) = 0; + i58_cost_degrad_onetime(t) = 0; +else +* Define bounds and costs for peatland area after the year given by s58_fix_peatland + v58_peatland.lo(j,land58) = 0; + v58_peatland.l(j,land58) = pc58_peatland(j,land58); + v58_peatland.up(j,landDrained58) = Inf; + v58_peatland.up(j,"rewetted") = s58_rewetting_switch; + v58_peatland.up(j,"intact") = pc58_peatland(j,"intact"); + v58_peatland.fx(j,"peatExtract") = pc58_peatland(j,"peatExtract"); + i58_cost_rewet_recur(t) = s58_cost_rewet_recur; + i58_cost_rewet_onetime(t) = s58_cost_rewet_onetime; + i58_cost_degrad_recur(t) = s58_cost_degrad_recur; + i58_cost_degrad_onetime(t) = s58_cost_degrad_onetime; +); diff --git a/modules/58_peatland/v2/realization.gms b/modules/58_peatland/v2/realization.gms new file mode 100644 index 0000000000..1a521c029c --- /dev/null +++ b/modules/58_peatland/v2/realization.gms @@ -0,0 +1,39 @@ +*** | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) +*** | authors, and contributors see CITATION.cff file. This file is part +*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of +*** | AGPL-3.0, you are granted additional permissions described in the +*** | MAgPIE License Exception, version 1.0 (see LICENSE file). +*** | Contact: magpie@pik-potsdam.de + +*' @description In this realization, the state of peatlands is modelled based on the +*' methodology described in @humpenoder_peatland_2020. +*' The initial map for intact, degraded and rewetted peatland is based on the +*' [Global Peatland Map 2.0](https://globalpeatlands.org/resource-library/global-peatland-map-20) +*' and the [Global Peatland Database](https://greifswaldmoor.de/global-peatland-database-en.html), both for the year 2020. +*' Therefore, it is advised to set `s58_fix_peatland` to `2020` when using this realisation. +*' Future peatland dynamics are estimated by scaling changes in managed land with the ratio of total peatland area and total land area (peatland scaling factor). +*' GHG emissions from drained and rewetted peatlands as well as from peat extraction are calculated based on GHG emission factors. +*' In this realisation, peatland GHG emission factors for boreal and tropical climates are based on @IPCC_wetland_2013 and @wilson_2016. +*' Peatland GHG emission factors for temperate climates are based on more recent estimates from @tiemeyer_peatland_2020. +*' Assumed rules for changes in peatland area: +*' Sum over total peatland area (degraded, intact, rewetted) is assumed constant. +*' Intact peatland area can only decrease. +*' Degraded peatland area (crop, past, forestry and unused) depends on managed land. +*' Area for peat extraction (peatExtract) is fixed. +*' Rewetted peatland area can only increase if degraded peatland area declines and intact peatland area remains constant. +*' @stop + + +*' +*' @limitations Peatland area and GHG emissions are fixed to 2015/2020 levels for the historic period, +*' depending on `s58_fix_peatland`. Organic carbon stocks in peatlands are not accounted for. + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/58_peatland/v2/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/58_peatland/v2/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/58_peatland/v2/input.gms" +$Ifi "%phase%" == "equations" $include "./modules/58_peatland/v2/equations.gms" +$Ifi "%phase%" == "preloop" $include "./modules/58_peatland/v2/preloop.gms" +$Ifi "%phase%" == "presolve" $include "./modules/58_peatland/v2/presolve.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/58_peatland/v2/postsolve.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/58_peatland/v2/sets.gms b/modules/58_peatland/v2/sets.gms new file mode 100644 index 0000000000..0abd629107 --- /dev/null +++ b/modules/58_peatland/v2/sets.gms @@ -0,0 +1,71 @@ +*** | (C) 2008-2023 Potsdam Institute for Climate Impact Research (PIK) +*** | authors, and contributors see CITATION.cff file. This file is part +*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of +*** | AGPL-3.0, you are granted additional permissions described in the +*** | MAgPIE License Exception, version 1.0 (see LICENSE file). +*** | Contact: magpie@pik-potsdam.de + +sets + + land58 Peatland land types + / intact, crop, past, forestry, peatExtract, unused, rewetted / + + landDrained58(land58) Peatland land types + / crop, past, forestry, unused / + + landDrainedUsed58(land58) Peatland land types + / crop, past, forestry / + + emis58 Wetland emission types + / co2, doc, ch4, n2o / + + emisSub58(emis58) Wetland emission types + / co2, ch4, n2o / + + poll58(pollutants) Wetland emissions that can be taxed + / co2_c, ch4, n2o_n_direct / + + emisSub58_to_poll58(emisSub58,poll58) Mapping + / co2 .(co2_c) + ch4 .(ch4) + n2o .(n2o_n_direct) / + + clcl58 simple climate classes + / tropical, temperate, boreal / + + clcl_mapping(clcl,clcl58) Mapping between detailed and simple climate classes + / + Af .(tropical) "Tropical rainforest climate" + Am .(tropical) "Tropical monsoon climate" + As .(tropical) "Tropical dry savanna climate" + Aw .(tropical) "Tropical savanna, wet" + BSh .(tropical) "Hot semi-arid (steppe) climate" + BSk .(tropical) "Cold semi-arid (steppe) climate" + BWh .(tropical) "Hot deserts climate" + BWk .(tropical) "Cold desert climate" + Cfa .(tropical) "Humid subtropical climate" + Cfb .(temperate) "Temperate oceanic climate" + Cfc .(boreal) "Subpolar oceanic climate" + Csa .(temperate) "Hot-summer Mediterranean climate" + Csb .(temperate) "Warm-summer Mediterranean climate" + Csc .(temperate) "Cool-summer Mediterranean climate" + Cwa .(tropical) "Monsoon-influenced humid subtropical climate" + Cwb .(tropical) "Dry-winter subtropical highland climate" + Cwc .(boreal) "Dry-winter subpolar oceanic climate" + Dfa .(temperate) "Hot-summer humid continental climate" + Dfb .(boreal) "Warm-summer humid continental climate" + Dfc .(boreal) "Subarctic climate" + Dfd .(boreal) "Extremely cold subarctic climate" + Dsa .(temperate) "Hot, dry-summer continental climate" + Dsb .(boreal) "Warm, dry-summer continental climate" + Dsc .(boreal) "Dry-summer subarctic climate" + Dsd .(boreal) "snow summer dry extremely continental" + Dwa .(temperate) "Monsoon-influenced hot-summer humid continental climate" + Dwb .(boreal) "Monsoon-influenced warm-summer humid continental climate" + Dwc .(boreal) "Monsoon-influenced subarctic climate" + Dwd .(boreal) "Monsoon-influenced extremely cold subarctic climate" + EF .(boreal) "Ice cap climate" + ET .(boreal) "Tundra" + / + +; diff --git a/modules/73_timber/default/realization.gms b/modules/73_timber/default/realization.gms index 15fa94b41d..54b2e821a3 100644 --- a/modules/73_timber/default/realization.gms +++ b/modules/73_timber/default/realization.gms @@ -11,9 +11,9 @@ *' available plantations to meet a portion of overall timber demand. Rest of the timber *' production comes by harvesting natural vegetation. Aggregated timber demand for *' wood and woodfuel is calculated based on demand equation from @lauri_timber_demand -*' and income elasticities from @morland2018supply. This realization can also account for -*' construction wood demand based on @churkina2020buildings which is added on top of -*' industrial roundwood demand. +*' and income elasticities from @morland2018supply. See @mishra_forestry_2021 for more details. +*' This realization can also account for construction wood demand based on +*' @churkina2020buildings which is added on top of industrial roundwood demand (see @mishra_timbercities_2022). *' @limitations Timber demand cannot be determined endogenously diff --git a/scripts/npi_ndc/start_npi_ndc.R b/scripts/npi_ndc/start_npi_ndc.R index 237650a8df..38cbabf597 100644 --- a/scripts/npi_ndc/start_npi_ndc.R +++ b/scripts/npi_ndc/start_npi_ndc.R @@ -258,7 +258,11 @@ calc_policy <- function(policy, stock, pol_type="aff", pol_mapping=pol_mapping, #set stock to zero or Inf for countries without policies # (representing no constraint for min and max constraints) if(pol_type=="ad"){ - stock[!(sub("\\..*$","",getCells(stock)) %in% policy_countries),,] <- 0 + if(dim(stock)[1] == 59199) { + stock[!(sub("\\..*$","",getCells(stock)) %in% policy_countries),,] <- 0 + } else { + stock[!(getItems(stock, "iso", full = TRUE) %in% policy_countries),,] <- 0 + } #calculate flows flow <- calc_flows(stock) #account only for positive flows, i.e. deforestation diff --git a/scripts/output/extra/disaggregation_LUH2.R b/scripts/output/extra/disaggregation_LUH2.R index dba0a2affc..b90dded6a7 100644 --- a/scripts/output/extra/disaggregation_LUH2.R +++ b/scripts/output/extra/disaggregation_LUH2.R @@ -6,7 +6,7 @@ # | Contact: magpie@pik-potsdam.de # ------------------------------------------------------------------------------------------------ -# description: Interpolates MAgPIE results to 0.5 degree resolution in LUH2 format for ISIMIP 3b +# description: Downscale MAgPIE results to 0.25 degree resolution in LUH2 format for ISIMIP 3b # comparison script: FALSE # ------------------------------------------------------------------------------------------------ @@ -92,7 +92,7 @@ grarea <- new.magpie(cells_and_regions=mapping_spatial$cell, fill=cal_area(coord[,"lon"],coord[,"lat"], mha=10^-10)) #grarea <- round(grarea,6) -# adjust total grid land area so that it is smaller than the gridcell area (some cells have a larger area acually; should be investigated) +# adjust total grid land area so that it is smaller than the gridcell area (some cells have a larger area actually; should be investigated) frac <- grarea/dimSums(land_hr, dim=3) frac[frac>1] <- 1 land_hr <- land_hr*frac @@ -175,8 +175,10 @@ other_hr_shr <- other_hr_shr * setNames(land_hr_shr[,,"other"],NULL) if(!file.exists(paste0(out_dir,"/LUH2_states.nc"))){ states <- mbind(dimSums(crop_hr_shr_LUH2_FAO,dim=3.2), + setNames(dimSums(crop_hr_shr_LUH2_FAO, dim = 3), "cropland"), setNames(past_range_hr_shr[,,"past"],"pastr"), setNames(past_range_hr_shr[,,"range"],"range"), + setNames(dimSums(past_range_hr_shr,dim=3),"grazing"), setNames(land_hr_shr[,,"primforest"],"primf"), setNames(forestry_hr_shr[,,"plant"],"timber"), setNames(land_hr_shr[,,"secdforest"]+forestry_hr_shr[,,"ndc"]+forestry_hr_shr[,,"aff"],"secdf"), @@ -191,7 +193,7 @@ saveRDS(states,paste0(outputdir,"/states.rds")) gc() states <- convertLUH2(states) gc() -write.magpie(states,paste0(out_dir,"/LUH2_states.nc"),comment = "unit: fraction of grid-cell area") +write.magpie(states, paste0(out_dir, "/LUH2_states.nc"), comment = "unit: fraction of grid-cell area", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") rm(states) gc() } @@ -214,7 +216,7 @@ gc() if(!file.exists(paste0(out_dir,"/LUH2_protected_area.nc"))){ b <- convertLUH2(b) gc() -write.magpie(b,paste0(out_dir,"/LUH2_protected_area.nc"),comment = "unit: fraction of grid-cell") +write.magpie(b, paste0(out_dir, "/LUH2_protected_area.nc"), comment = "unit: fraction of grid-cell", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") rm(b) gc() } @@ -242,7 +244,7 @@ if(!is.null(harvested_area_timber(gdx,level = "cell"))) { if(!file.exists(paste0(out_dir,"/LUH2_wood_harvest_area.nc"))){ b <- convertLUH2(b) gc() - write.magpie(b,paste0(out_dir,"/LUH2_wood_harvest_area.nc"),comment = "unit: fraction of grid-cell area per year") + write.magpie(b, paste0(out_dir, "/LUH2_wood_harvest_area.nc"), comment = "unit: fraction of grid-cell area per year", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") rm(a,b) gc() } @@ -268,7 +270,7 @@ if(!is.null(harvested_area_timber(gdx,level = "cell"))) { if(!file.exists(paste0(out_dir,"/LUH2_wood_harvest_yields.nc"))){ b <- convertLUH2(b) gc() - write.magpie(b,paste0(out_dir,"/LUH2_wood_harvest_yields.nc"),comment = "unit: m3 per ha per year") + write.magpie(b, paste0(out_dir, "/LUH2_wood_harvest_yields.nc"), comment = "unit: m3 per ha per year", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") rm(a,b) gc() } @@ -282,7 +284,7 @@ if(!is.null(harvested_area_timber(gdx,level = "cell"))) { if(!file.exists(paste0(out_dir,"/LUH2_wood_harvest_biomass_split.nc"))){ b <- convertLUH2(b) gc() - write.magpie(b,paste0(out_dir,"/LUH2_wood_harvest_biomass_split.nc"),comment = "unit: fraction of wood harvest biomass") + write.magpie(b, paste0(out_dir, "/LUH2_wood_harvest_biomass_split.nc"), comment = "unit: fraction of wood harvest biomass", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") rm(b) gc() } @@ -301,36 +303,30 @@ if (any(abs(d) > 0.1 )) message(paste0("Difference between cluster and grid cell if(!file.exists(paste0(out_dir,"/LUH2_irrigation.nc"))){ irrig_hr_shr <- convertLUH2(irrig_hr_shr) gc() -write.magpie(irrig_hr_shr,paste0(out_dir,"/LUH2_irrigation.nc"),comment = "unit: fraction of crop area") +write.magpie(irrig_hr_shr, paste0(out_dir, "/LUH2_irrigation.nc"), comment = "unit: fraction of crop area", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") rm(irrig_hr_shr,d) gc() } #### Flood -rice_historical<-calcOutput("Ricearea",cellular=TRUE,aggregate=FALSE, share = FALSE) -rice_historical<-speed_aggregate(rice_historical,rel=mapping_spatial,from="cell",to="region",weight=NULL) -share_rice_flooded<-setNames(1-(rice_historical[,,"nonflooded"]/rice_historical[,,"total"])[,c(1995,2000,2005,2010),],NULL) -share<-speed_aggregate(share_rice_flooded,rel=mapping_spatial,from="region",to="cell",weight=NULL) - -rice <- dimSums(crop_hr_shr[,,"rice_pro"],dim=3.2) -rice[,c(1995,2000,2005,2010),]<-rice[,c(1995,2000,2005,2010),]*share[,c(1995,2000,2005,2010),] -ye<-getYears(rice, as.integer=T)[!(getYears(rice, as.integer=T) %in% c(1995,2000,2005,2010))] -rice[,ye,]<-rice[,ye,]*setYears(share[,2010,],NULL) -flooded<-round(rice,3) -getNames(flooded,dim=1) <- "flood" -flooded <- flooded / dimSums(crop_hr_shr_LUH2_FAO[,,"c3ann"],dim=3) -flooded[!is.finite(flooded)]<-0 -d <- dimSums(flooded* dimSums(crop_hr_shr_LUH2_FAO[,,"c3ann"],dim=3)*dimSums(land_hr,dim=3),dim=c(1,3))-croparea(gdx,level="glo",product_aggr = F,water_aggr = T)[,,"rice_pro"] -if (any(abs(d) > 0.1 )) message(paste0("Difference between cluster and grid cell production > 0.1 detected!")) -if(!file.exists(paste0(out_dir,"/LUH2_flood.nc"))){ -flooded <- convertLUH2(flooded) -gc() -write.magpie(flooded,paste0(out_dir,"/LUH2_flood.nc"),comment = "unit: flooded fraction of C3 annual crop area") -rm(flooded,d) -gc() +rice <- dimSums(crop_hr[, , "rice_pro"], dim = 3.2) +crop_hr_c3ann <- dimSums(crop_hr_LUH[, , "c3ann"], dim = 3.2) + +flooded <- rice / crop_hr_c3ann +flooded[!is.finite(flooded)] <- 0 + +d <- dimSums(flooded * dimSums(crop_hr_shr_LUH2_FAO[, , "c3ann"], dim = 3) * dimSums(land_hr, dim = 3), dim = c(1, 3)) - croparea(gdx, level = "glo", product_aggr = F, water_aggr = T)[, , "rice_pro"] +if (any(abs(d) > 0.1)) message(paste0("Difference between cluster and grid cell production > 0.1 detected!")) +if (!file.exists(paste0(out_dir, "/LUH2_flood.nc"))) { + flooded <- convertLUH2(flooded) + gc() + write.magpie(flooded, paste0(out_dir, "/LUH2_flood.nc"), comment = "unit: flooded fraction of C3 annual crop area", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") + rm(flooded, d) + gc() } + #### Bioenergy bio_hr_shr <- dimSums(crop_hr_shr[,,c("begr","betr")],dim=3.2) getNames(bio_hr_shr,dim=1) <- c("c4per","c3per") @@ -344,7 +340,7 @@ getNames(bio_hr_shr,dim=1) <- c("crpbf_c4per","crpbf_c3per") if(!file.exists(paste0(out_dir,"/LUH2_bioenergy.nc"))){ bio_hr_shr <- convertLUH2(bio_hr_shr) gc() -write.magpie(bio_hr_shr,paste0(out_dir,"/LUH2_bioenergy.nc"),comment = "unit: fraction of crop type area occupied by biofuel crops") +write.magpie(bio_hr_shr, paste0(out_dir, "/LUH2_bioenergy.nc"), comment = "unit: fraction of crop type area occupied by biofuel crops", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") rm(bio_hr_shr,d) gc() } @@ -401,19 +397,19 @@ x <- NULL if(!file.exists(paste0(out_dir,"/LUH2_Nitrogen_fertilizer.nc"))){ x <- convertLUH2(clean_magpie(collapseNames(a[,,"fertilizer"],collapsedim = 3.1))) gc() -write.magpie(x,paste0(out_dir,"/LUH2_Nitrogen_fertilizer.nc"),comment = "unit: kgN-per-ha") +write.magpie(x, paste0(out_dir, "/LUH2_Nitrogen_fertilizer.nc"), comment = "unit: kgN-per-ha", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") } if(!file.exists(paste0(out_dir,"/LUH2_Nitrogen_manure.nc"))){ x <- convertLUH2(clean_magpie(collapseNames(a[,,"manure"],collapsedim = 3.1))) gc() -write.magpie(x,paste0(out_dir,"/LUH2_Nitrogen_manure.nc"),comment = "unit: kgN-per-ha") +write.magpie(x, paste0(out_dir, "/LUH2_Nitrogen_manure.nc"), comment = "unit: kgN-per-ha", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") } if(!file.exists(paste0(out_dir,"/LUH2_Nitrogen_surplus.nc"))){ x <- convertLUH2(clean_magpie(collapseNames(a[,,"surplus"],collapsedim = 3.1))) gc() -write.magpie(x,paste0(out_dir,"/LUH2_Nitrogen_surplus.nc"),comment = "unit: kgN-per-ha") +write.magpie(x, paste0(out_dir, "/LUH2_Nitrogen_surplus.nc"), comment = "unit: kgN-per-ha", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") } rm(a,x,weight) @@ -433,7 +429,7 @@ a[,,n]<-dimSums(yield_kr_su[,,n],dim=3)/dimSums(map_LUHMAg_grid[,,n],dim=3) if(!file.exists(paste0(out_dir,"/LUH2_Yield_DM.nc"))){ a <- convertLUH2(a) gc() -write.magpie(a,paste0(out_dir,"/LUH2_Yield_DM.nc"),comment = "unit: tDM-per-ha") +write.magpie(a, paste0(out_dir, "/LUH2_Yield_DM.nc"), comment = "unit: tDM-per-ha", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") rm(a,yield_kr,yield_kr_su) gc() } @@ -452,7 +448,7 @@ a[,,n]<-dimSums(yield_kr_su[,,n],dim=3)/dimSums(map_LUHMAg_grid[,,n],dim=3) if(!file.exists(paste0(out_dir,"/LUH2_Yield_DM_rainfed.nc"))){ a <- convertLUH2(a) gc() -write.magpie(a,paste0(out_dir,"/LUH2_Yield_DM_rainfed.nc"),comment = "unit: tDM-per-ha") +write.magpie(a, paste0(out_dir, "/LUH2_Yield_DM_rainfed.nc"), comment = "unit: tDM-per-ha", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") rm(a,yield_kr,yield_kr_su) gc() } @@ -471,7 +467,7 @@ a[,,n]<-dimSums(yield_kr_su[,,n],dim=3)/dimSums(map_LUHMAg_grid[,,n],dim=3) if(!file.exists(paste0(out_dir,"/LUH2_Yield_DM_irrigated.nc"))){ a <- convertLUH2(a) gc() -write.magpie(a,paste0(out_dir,"/LUH2_Yield_DM_irrigated.nc"),comment = "unit: tDM-per-ha") +write.magpie(a, paste0(out_dir, "/LUH2_Yield_DM_irrigated.nc"), comment = "unit: tDM-per-ha", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") rm(a,yield_kr,yield_kr_su) gc() } @@ -490,7 +486,7 @@ a[,,n]<-dimSums(yield_kr_su[,,n],dim=3)/dimSums(map_LUHMAg_grid[,,n],dim=3) if(!file.exists(paste0(out_dir,"/LUH2_Yield_Nr.nc"))){ a <- convertLUH2(a) gc() -write.magpie(a,paste0(out_dir,"/LUH2_Yield_Nr.nc"),comment = "unit: kgN-per-ha") +write.magpie(a, paste0(out_dir, "/LUH2_Yield_Nr.nc"), comment = "unit: kgN-per-ha", datatype = "FLT8S", zname = "time", xname = "lon", yname = "lat") rm(a,yield_kr,yield_kr_su) gc() } diff --git a/scripts/output/extra/emulator.R b/scripts/output/extra/emulator.R index 68adaa910c..5af6da2122 100644 --- a/scripts/output/extra/emulator.R +++ b/scripts/output/extra/emulator.R @@ -121,61 +121,36 @@ collect_data_and_make_emulator <- function(outputdir,name_of_fit="linear") { # Prices|Bioenergy (US$05/GJ) # Clean data + "Demand|Bioenergy|2nd generation|++|Bioenergy crops (EJ/yr)" + "Prices|Bioenergy (US$05/GJ)" # 1. Exclude points with zero production (there are cases where production is zero but there is a price) - x[,,"Demand|Bioenergy|++|2nd generation (EJ/yr)"][x[,,"Demand|Bioenergy|++|2nd generation (EJ/yr)"]==0] <- NA - x[,,"Prices|Bioenergy (US$05/GJ)"][is.na(x[,,"Demand|Bioenergy|++|2nd generation (EJ/yr)"])] <- NA + x[,,"Demand|Bioenergy|2nd generation|++|Bioenergy crops (EJ/yr)"][x[,,"Demand|Bioenergy|2nd generation|++|Bioenergy crops (EJ/yr)"]==0] <- NA + x[,,"Prices|Bioenergy (US$05/GJ)"][is.na(x[,,"Demand|Bioenergy|2nd generation|++|Bioenergy crops (EJ/yr)"])] <- NA # 2. Normally, where production (x) is zero resulting prices (y) are NA -> set production to NA where prices are NA - x[,,"Demand|Bioenergy|++|2nd generation (EJ/yr)"][is.na(x[,,"Prices|Bioenergy (US$05/GJ)"])] <- NA + x[,,"Demand|Bioenergy|2nd generation|++|Bioenergy crops (EJ/yr)"][is.na(x[,,"Prices|Bioenergy (US$05/GJ)"])] <- NA x[,,"Modelstatus (-)"] <- x["GLO",,"Modelstatus (-)"] # Convert units to REMIND units TWa_2_EJ <- 365.25*24*3600/1E6 - tmp1 <- x[,,"Demand|Bioenergy|++|2nd generation (EJ/yr)"] / TWa_2_EJ # EJ -> TWa + tmp1 <- x[,,"Demand|Bioenergy|2nd generation|++|Bioenergy crops (EJ/yr)"] / TWa_2_EJ # EJ -> TWa tmp2 <- x[,,"Prices|Bioenergy (US$05/GJ)"] * TWa_2_EJ/1000 # $/GJ -> T$/TWa getNames(tmp1,dim=4) <- gsub("EJ/yr","TWa/yr", getNames(tmp1,dim=4),fixed=TRUE) getNames(tmp2,dim=4) <- gsub("US$05/GJ","T$/TWa",getNames(tmp2,dim=4),fixed=TRUE) x <- mbind(x,tmp1,tmp2) + + # transfer regionscode from mag_res to x since it was erased above everywhere where x was 'mbind'ed + regionscode <- attributes(mag_res)$regionscode + attributes(x)$regionscode <- regionscode ############################################################### ############# C A L C U L A T E E M U L A T O R ############# ############################################################### - # vars <- c("Demand|Bioenergy|++|2nd generation (EJ/yr)", - # "Prices|Bioenergy (US$05/GJ)", - # "Modelstatus (-)") - # - # y <- x[,,vars] - # - # # Make up model data for fitting: If in current year not enough data is availalbe copy it from other years - # # Criteria for "enough" data available: - # # number of - # # 1. non-zero and - # # 2. feasible and - # # 3. unique and - # # 4. non-NA elements - # # > n - # - # # 1. non-zero: set zero elements to NA - # # has been done before -> does not have to be checked here - # - # # 2. feasible: set data to NA in infeasible years and the years after - # y <- mute_infes(data = y, name="Modelstatus (-)", infeasible = 5) - # - # # 3. unique elements: set duplicated samples to NA - # y <- mute_duplicated(y) - # - # # 4. non-NA: find number of non-NA elements - # n_exist <- as.magpie(apply(unwrap(y),c(1,2,3,5,6),function(x)sum(!is.na(x)))) - # nodata <- n_exist[,,"Demand|Bioenergy|++|2nd generation (EJ/yr)"]<1 - # - # # Finally: Copy data from other years where data is not availalbe - # z <- fill_missing_years(y,nodata) - # Calculate emulator fc <- emulator(data=x, - name_x="Demand|Bioenergy|++|2nd generation (TWa/yr)", + name_x="Demand|Bioenergy|2nd generation|++|Bioenergy crops (TWa/yr)", name_y="Prices|Bioenergy (T$/TWa)", name_modelstat="Modelstatus (-)", userfun=function(param,x)return(param[[1]] + param[[2]] * x), @@ -190,8 +165,6 @@ collect_data_and_make_emulator <- function(outputdir,name_of_fit="linear") { print(fc) print(attributes(fc)) - regionscode <- attributes(mag_res)$regionscode - # write fit coefficients to REMIND input file for (scen in getNames(fc,dim="scenario")) { write.magpie(fc,file_name = paste0("f30_bioen_price_",scen,"_",regionscode,".cs4r"), file_folder = file.path(emu_path,scen,name_of_fit)) diff --git a/scripts/start/extra/emulator.R b/scripts/start/extra/emulator.R index 7a5b65bd1c..8926a6a775 100644 --- a/scripts/start/extra/emulator.R +++ b/scripts/start/extra/emulator.R @@ -9,7 +9,6 @@ # description: run simulations for calculation of MAgPIE emulators # --------------------------------------------------------------- - ######################################################### #### Start MAgPIE runs to derive price emulator from #### ######################################################### @@ -26,16 +25,10 @@ source("config/default.cfg") ##################### General settings ######################## ############################################################### +cfg$qos <- "standby" cfg$results_folder <- "output/:title:" -cfg$output <- c("report","emulator") #unique(c(cfg$output,"remind","bioenergy","coupling_report","david")) - -# use old regions: c30c1c580039c2b300d86cc46ff4036a -# use H12 regions: 690d3718e151be1b450b394c1064b1c5 -#cfg$input <- c("isimip_rcp-IPSL_CM5A_LR-rcp2p6-noco2_rev29_h200_690d3718e151be1b450b394c1064b1c5.tgz", -# "rev3.15_690d3718e151be1b450b394c1064b1c5_magpie.tgz", -# "rev3.15_690d3718e151be1b450b394c1064b1c5_validation.tgz", -# "additional_data_rev3.28.tgz", -# "npi_ndc_base_SSP2_fixed.tgz") +cfg$output <- c("rds_report","extra/emulator") #unique(c(cfg$output,"remind","bioenergy","coupling_report","david")) +cfg$gms$s60_2ndgen_bioenergy_dem_min <- 0 # Download bioenergy demand scenarios filemap <- gms::download_unpack(input="emulator.tgz", targetdir="input", repositories=list("/p/projects/landuse/data/input/archive"=NULL), debug=FALSE) @@ -47,9 +40,6 @@ demand <- add_columns(demand,dim = 2.1,addnm = c("y2110","y2130","y2150")) # keep demand constant after 2100 demand[,c("y2110","y2130","y2150"),] <- setYears(demand[,"y2100",]) -#reg <- read.csv2(cfg$regionmapping) # read regional resolution, used for ghg tax -reg <- list(RegionCode = "GLO") - scenarios <- read.csv2("config/scenario_config_emulator.csv",strip.white=TRUE,stringsAsFactors=FALSE) scenarios <- subset(scenarios, subset=(start == "1")) @@ -57,62 +47,36 @@ scenarios <- subset(scenarios, subset=(start == "1")) ######################## Functions ############################ ############################################################### -# calculate expoLinear tax with transition in 2060 -write.ghgtax <- function(co2tax_2025=NULL,regions=NULL,out="./modules/56_ghg_policy/input/f56_pollutant_prices_emulator.cs3") { - - fname <- paste0(scenarios[scen,"co2tax_2025"],".mif") - - if (file.exists(fname)) { - - # If there is a REMIND report with the name, read the GHG prices from the file, otherwise calculate expo-linear tax - cat("Loading CO2 prices from",fname,"\n") - tmp <- read.report(fname, as.list = FALSE) +# Read GHG prices from REMIND or coupled mif file +write.ghgtax <- function(mifname, outfile) { - # Select variables from REMIND report - ghg_price_names <- c("Price|Carbon (US$2005/t CO2)", - "Price|N2O (US$2005/t N2O)", - "Price|CH4 (US$2005/t CH4)") - tmp <- collapseNames(tmp[,,ghg_price_names]) - # remove global dimension - tmp <- tmp["GLO",,,invert=TRUE] + fname <- paste0(mifname, ".mif") - # interpolate missing years (REMIND has less_TS only, emulator script need 5 year time steps) - time <- seq(1995,2100,5) - tmp <- time_interpolate(tmp,interpolated_year=time,extrapolation_type="constant") + if(!file.exists(fname)) stop("Could not find ",fname) - ghgtax <- new.magpie(cells_and_regions = getRegions(tmp),years = time,fill = NA,sets = c("regions","years","gas"),names = c("n2o_n_direct","n2o_n_indirect","ch4","co2_c")) + # If there is a REMIND report with the name, read the GHG prices from the file, otherwise calculate expo-linear tax + cat("Loading GHG prices from",fname,"\n") + tmp <- read.report(fname, as.list = FALSE) - # unit defined in modules/56_ghg_policy/input/f56_pollutant_prices.cs3: US$ 2005 per Mg N2O-N CH4 and CO2-C - ghgtax[,,"co2_c"] <- tmp[,,"Price|Carbon (US$2005/t CO2)"] * 44/12 # US$2005/tCO2 -> US$2005/tC - ghgtax[,,"ch4"] <- tmp[,,"Price|CH4 (US$2005/t CH4)"] - ghgtax[,,"n2o_n_direct"] <- tmp[,,"Price|N2O (US$2005/t N2O)"] * 44/28 # US$2005/tN2O -> US$2005/tN - ghgtax[,,"n2o_n_indirect"] <- tmp[,,"Price|N2O (US$2005/t N2O)"] * 44/28 # US$2005/tN2O -> US$2005/tN + # Select variables from REMIND report + ghg_price_names <- c("Price|Carbon (US$2005/t CO2)", + "Price|N2O (US$2005/t N2O)", + "Price|CH4 (US$2005/t CH4)") + tmp <- collapseNames(tmp[,,ghg_price_names]) + # remove global dimension + tmp <- tmp["GLO",,,invert=TRUE] - } else { - - stop("Could not find ", fname) - - # Calculate expo-linear tax - - if(is.null(co2tax_2025)) stop("No initial value for ghg tax supplied.") - if(is.null(regions)) stop("Please supply regions for ghg tax.") + # interpolate missing years (REMIND has less_TS only, emulator script need 5 year time steps) + time <- seq(1995,2100,5) + tmp <- time_interpolate(tmp,interpolated_year=time,extrapolation_type="constant") - # construct combination of exponential tax (5% increase) until 2050 and linear continuation thereafter (using the slope of 2045-2050) - time <- seq(1995,2100,5) - co2tax <- as.numeric(co2tax_2025) * 1.05 ^(time-2025) - names(co2tax)<-time - slope <- (co2tax["2050"] - co2tax["2045"]) / (2050 - 2045) - co2tax[names(co2tax)>"2050"] <- co2tax["2050"] + slope * (time[time>2050] - 2050) + ghgtax <- new.magpie(cells_and_regions = getRegions(tmp),years = time,fill = NA,sets = c("regions","years","gas"),names = c("n2o_n_direct","n2o_n_indirect","ch4","co2_c")) - ghgtax <- new.magpie(cells_and_regions = regions,years = time,fill = NA,sets = c("regions","years","gas"),names = c("n2o_n_direct","n2o_n_indirect","ch4","co2_c")) - - # unit defined in modules/56_ghg_policy/input/f56_pollutant_prices.cs3: US$ 2005 per Mg N2O-N CH4 and CO2-C - ghgtax[,,"co2_c"] <- as.magpie(co2tax) * 44/12 # US$2005/tCO2 -> US$2005/tC - ghgtax[,,"ch4"] <- as.magpie(co2tax) * 28 # US$2005/tCO2 -> US$2005/tCH4 (using Global Warming Potentials from AR5 WG1 CH08 Table 8.7) - ghgtax[,,"n2o_n_direct"] <- as.magpie(co2tax) * 44/28 * 265 # US$2005/tCO2 -> US$2005/tN (using Global Warming Potentials from AR5 WG1 CH08 Table 8.7) - ghgtax[,,"n2o_n_indirect"] <- as.magpie(co2tax) * 44/28 * 265 # US$2005/tCO2 -> US$2005/tN (using Global Warming Potentials from AR5 WG1 CH08 Table 8.7) - - } + # unit defined in modules/56_ghg_policy/input/f56_pollutant_prices.cs3: US$ 2005 per Mg N2O-N CH4 and CO2-C + ghgtax[,,"co2_c"] <- tmp[,,"Price|Carbon (US$2005/t CO2)"] * 44/12 # US$2005/tCO2 -> US$2005/tC + ghgtax[,,"ch4"] <- tmp[,,"Price|CH4 (US$2005/t CH4)"] + ghgtax[,,"n2o_n_direct"] <- tmp[,,"Price|N2O (US$2005/t N2O)"] * 44/28 # US$2005/tN2O -> US$2005/tN + ghgtax[,,"n2o_n_indirect"] <- tmp[,,"Price|N2O (US$2005/t N2O)"] * 44/28 # US$2005/tN2O -> US$2005/tN # set ghg prices before and in 2020 to zero ghgtax[,getYears(ghgtax)<="y2020",] <- 0 @@ -127,8 +91,8 @@ write.ghgtax <- function(co2tax_2025=NULL,regions=NULL,out="./modules/56_ghg_pol #for_plot <- for_plot[,c("y1995","y2110","y2130","y2150"),,invert=TRUE] txtplot(as.numeric(gsub("y","",getYears(for_plot))),for_plot,ylab="US$2005/tCO2") - cat("Writing GHG tax scenario",scenarios[scen,"co2tax_name"],"\n\n") - write.magpie(ghgtax,file_name = out) + cat("Writing GHG tax scenario",scenarios[scen,"ghgtax_name"],"\n\n") + write.magpie(ghgtax, file_name = outfile) #library(ggplot2) #library(luplot) @@ -144,28 +108,28 @@ for (scen in rownames(scenarios)) { cat("\n################ Scenario",scen,"################\n") # Configure MAgPIE # Set scenario - cfg<-setScenario(cfg,scenario = c(trimws(unlist(strsplit(scenarios[scen,"mag_scen"],split=","))))) + cfg<-setScenario(cfg,scenario = c(trimws(unlist(strsplit(scenarios[scen,"mag_scen"],split="\\|"))))) # emulator has to be set AFTER SSP because SSP would set bioenergy demand to predefined scenario and not to input from this script cfg<-setScenario(cfg,scenario="emulator") # Choose GHG tax scenario - if (scenarios[scen,"co2tax_2025"] == "built-in") { + if (scenarios[scen,"mifname"] == "built-in") { # see magpie/config/default.cfg for available scenarios - cfg$gms$c56_pollutant_prices <- scenarios[scen,"co2tax_name"] + cfg$gms$c56_pollutant_prices <- scenarios[scen,"ghgtax_name"] } else { - # If none of the built-in GHG price scenarios was chosen, provide GHG prices + # If no built-in GHG price scenario was chosen, take GHG prices from REMIND report cfg$gms$c56_pollutant_prices <- "emulator" - write.ghgtax(co2tax_2025=scenarios[scen,"co2tax_2025"],regions=unique(reg$RegionCode)) + cfg$gms$c56_mute_ghgprices_until <- scenarios[scen, "no_ghgprices_land_until"] + write.ghgtax(mifname = scenarios[scen, "mifname"], outfile = "./modules/56_ghg_policy/input/f56_pollutant_prices_emulator.cs3") } # Compose string with scenario name - expname <- paste0(gsub(",","-",scenarios[scen,"mag_scen"]),"-",scenarios[scen,"co2tax_name"]) + expname <- paste0(gsub("\\|","-",scenarios[scen,"mag_scen"]),"-",scenarios[scen,"ghgtax_name"]) - # run numbers sorted in descending by runtime (taken from former SSP2-26 emulator runs) - runtime_order <- c("4","17","34","12","11","22","32","15","21","2","58","18","20","16","19", - "31","67","41","48","54","65","47","13","44","70","28","52","53","62","36","40","9","14","46", - "10","29","38","71","57","50","60","37","64","69","68","51","61","5","27","7","66","6","49", - "35","45","59","56","24","72","25","63","42","30","1","55","43","26","3","39","73","23","33","8") + # run numbers sorted descending by runtime (determined with script sort_runtimes.R from dklein) + runtime_order <- c('32','68','5','46','22','58','41','53','65','11','10','12','47','70','17','34','56','18','54','29', + '62','57','2','26','48','51','20','8','15','52','21','44','16','30','71','38','13','50','67','35','45','1','37','6','31', + '49','40','24','60','69','14','4','9','33','66','61','64','25','42','55','28','23','19','7','43','59','63','39','3','72','73','36','27') # the intersect command in the for-loop below keeps the order of the vector given first # Copy bioenergy demand files and start runs @@ -179,7 +143,7 @@ for (scen in rownames(scenarios)) { #for_plot <- for_plot[,c("y1995","y2110","y2130","y2150"),,invert=TRUE] txtplot(as.numeric(gsub("y","",getYears(for_plot))),for_plot,ylab="EJ/yr") write.magpie(setNames(dem,NULL), file_name = "./modules/60_bioenergy/input/glo.2ndgen_bioenergy_demand.csv") - manipulateConfig("scripts/run_submit/submit.sh","--job-name"=cfg$title,line_endings = "NOTwin") + manipulateConfig(paste0("scripts/run_submit/submit_", cfg$qos, ".sh"), "--job-name" = cfg$title, line_endings = "NOTwin") start_run(cfg,codeCheck=FALSE) } } diff --git a/scripts/start/extra/recalibrate_FSEC.R b/scripts/start/extra/recalibrate_FSEC.R index 5833ccaf5b..22c894b2d1 100644 --- a/scripts/start/extra/recalibrate_FSEC.R +++ b/scripts/start/extra/recalibrate_FSEC.R @@ -22,7 +22,7 @@ source("scripts/projects/fsec.R") cfg <- fsecScenario(scenario = "c_BAU") cfg$title <- "FSEC24Mar23" cfg$results_folder <- "output/:title:" -cfg$recalibrate <- TRUE +cfg$recalibrate <- TRUE # required when penality_apr22 activated cfg$best_calib <- TRUE cfg$recalibrate_landconversion_cost <- TRUE cfg$best_calib_landconversion_cost <- FALSE diff --git a/standalone/HOWTO.md b/standalone/HOWTO.md index 98ec2668e2..6a69274151 100644 --- a/standalone/HOWTO.md +++ b/standalone/HOWTO.md @@ -4,7 +4,7 @@ Standalone models can be used to run simulations which only require a subset of modules coming with the model. It can also be used to run a module isolated from the rest of the code. -A new standalone model is created by copying the template.gms within the standalone folder to a gms file with the name of the new model. The new model file needs to include all modules relevant for the calculation (done by adding a line for each module in the "MODULE SETUP" section) and make sure that all interfaces of the modules are properly adressed. Especially, interfaces to modules not part of that reduced model need to be fed with information coming from that new model file. +A new standalone model is created by copying the template.gms within the standalone folder to a gms file with the name of the new model. The new model file needs to include all modules relevant for the calculation (done by adding a line for each module in the "MODULE SETUP" section) and make sure that all interfaces of the modules are properly addressed. Especially, interfaces to modules not part of that reduced model need to be fed with information coming from that new model file. The standalone model file needs to follow the coding etiquette as any other file, meaning that it is only allowed to interact through interfaces with the modules. This is necessary to allow the reduced model to work with all realizations of a coupled module.