From 41435c05a4d797ebee1f143fccc1035771474b9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20F=C3=BChrlich?= Date: Thu, 16 Mar 2023 13:58:46 +0100 Subject: [PATCH 01/62] add individual crops to land_cluster script --- scripts/output/extra/land_cluster_shapefile.R | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/scripts/output/extra/land_cluster_shapefile.R b/scripts/output/extra/land_cluster_shapefile.R index ec89d56ebb..c9d20d7ab0 100644 --- a/scripts/output/extra/land_cluster_shapefile.R +++ b/scripts/output/extra/land_cluster_shapefile.R @@ -15,13 +15,18 @@ if (packageVersion("magpie4") < "1.180.0") { } if (!exists("source_include")) { - outputdir <- Sys.glob("output/*")[[1]] + outputdir <- utils::tail(Sys.glob("output/default_*"), 1) lucode2::readArgs("outputdir") } -landUse <- magpie4::land(file.path(outputdir, "fulldata.gdx"), - dir = outputdir, - level = "cell") +landUse <- magpie4::land(file.path(outputdir, "fulldata.gdx"), level = "cell") +cropArea <- magpie4::croparea(file.path(outputdir, "fulldata.gdx"), level = "cell", product_aggr = FALSE) +x <- magclass::mbind(landUse, cropArea) +if (!isTRUE(all.equal(x[, , "crop"], + magclass::dimSums(x[, , dimnames(cropArea)[[3]]]), + check.attributes = FALSE))) { + stop("Summing up crop area for all crops from magpie4::croparea != crop area from magpie4::land") +} clustermap <- Sys.glob(file.path(outputdir, "clustermap_*.rds")) if (length(clustermap) == 0) { @@ -32,8 +37,8 @@ if (length(clustermap) == 0) { } clustermap <- readRDS(clustermap) -clusterPolygons <- magpie4::clusterOutputToTerraVector(landUse, clustermap) +clusterPolygons <- magpie4::clusterOutputToTerraVector(x, clustermap) -outfile <- file.path(outputdir, "cluster_resolution.shp") +outfile <- file.path(outputdir, "land_cluster.shp") message("Writing ", outfile) terra::writeVector(clusterPolygons, outfile, overwrite = TRUE) From df6285c4e7e6df4068cae22fbd2df97c27927a27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20F=C3=BChrlich?= Date: Thu, 16 Mar 2023 14:39:07 +0100 Subject: [PATCH 02/62] use gpkg instead of shp --- .../output/extra/{land_cluster_shapefile.R => land_cluster.R} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename scripts/output/extra/{land_cluster_shapefile.R => land_cluster.R} (97%) diff --git a/scripts/output/extra/land_cluster_shapefile.R b/scripts/output/extra/land_cluster.R similarity index 97% rename from scripts/output/extra/land_cluster_shapefile.R rename to scripts/output/extra/land_cluster.R index c9d20d7ab0..769ab6d1e8 100644 --- a/scripts/output/extra/land_cluster_shapefile.R +++ b/scripts/output/extra/land_cluster.R @@ -39,6 +39,6 @@ clustermap <- readRDS(clustermap) clusterPolygons <- magpie4::clusterOutputToTerraVector(x, clustermap) -outfile <- file.path(outputdir, "land_cluster.shp") +outfile <- file.path(outputdir, "land_cluster.gpkg") message("Writing ", outfile) terra::writeVector(clusterPolygons, outfile, overwrite = TRUE) From 8246f18c76e824326b5521cd8064aa60b875eb45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20F=C3=BChrlich?= Date: Thu, 16 Mar 2023 14:41:06 +0100 Subject: [PATCH 03/62] no more shapefile --- CHANGELOG.md | 2 +- scripts/output/extra/land_cluster.R | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 15645e97b2..012fdabd1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### added - **56_ghg_policy** added switch `s56_minimum_cprice` - **config** minimum CO2 price (`s56_minimum_cprice`) of 5 USD per tCO2 (18 USD per tC) for all future time steps in case of NDC policy to guide land-use decisions -- **scripts** added output script which writes landuse data on cluster resolution to a shapefile +- **scripts** added output script which writes landuse data on cluster resolution to a GeoPackage file ### removed - **56_ghg_policy** removed `s56_ghgprice_phase_in` and `s56_ghgprice_start` diff --git a/scripts/output/extra/land_cluster.R b/scripts/output/extra/land_cluster.R index 769ab6d1e8..796b9ac083 100644 --- a/scripts/output/extra/land_cluster.R +++ b/scripts/output/extra/land_cluster.R @@ -6,12 +6,12 @@ # | Contact: magpie@pik-potsdam.de # -------------------------------------------------------------- -# description: Write land use information on cluster level to a shapefile +# description: Write land use information on cluster level to land_cluster.gpkg (GeoPackage) # comparison script: FALSE # --------------------------------------------------------------- if (packageVersion("magpie4") < "1.180.0") { - stop("land_cluster_shapefile.R requires magpie4 >= 1.180.0, please update magpie4") + stop("land_cluster.R requires magpie4 >= 1.180.0, please update magpie4") } if (!exists("source_include")) { From fbb4d7f34c91f6916940bac5fabe7354ea49788e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20F=C3=BChrlich?= Date: Thu, 30 Mar 2023 16:12:40 +0200 Subject: [PATCH 04/62] on.exit -> withr::defer --- scripts/insertheader/insertheader.R | 2 +- scripts/output/extra/disaggregation.R | 4 +--- scripts/output/extra/disaggregation_LUH2.R | 4 +--- scripts/output/extra/emulator.R | 2 +- scripts/output/projects/inms_reporting_reg.R | 2 +- scripts/performance_test.R | 2 +- scripts/start/Rprofile.R | 4 ++-- scripts/start_functions.R | 6 +++--- 8 files changed, 11 insertions(+), 15 deletions(-) diff --git a/scripts/insertheader/insertheader.R b/scripts/insertheader/insertheader.R index 5353b92306..38b1508290 100644 --- a/scripts/insertheader/insertheader.R +++ b/scripts/insertheader/insertheader.R @@ -34,7 +34,7 @@ insertheader <- function(maindir=".", } cwd <- getwd() - on.exit(setwd(cwd)) + withr::defer(setwd(cwd)) setwd(maindir) if(is.null(oldkey)) oldkey <- key diff --git a/scripts/output/extra/disaggregation.R b/scripts/output/extra/disaggregation.R index e41f08cdf1..41c2438ab2 100644 --- a/scripts/output/extra/disaggregation.R +++ b/scripts/output/extra/disaggregation.R @@ -38,9 +38,7 @@ bii_hr_out_file <- file.path(outputdir, "cell.bii_0.5.mz") cfg <- gms::loadConfig(file.path(outputdir, "config.yml")) -sizelimit <- getOption("magclass_sizeLimit") -options(magclass_sizeLimit = 1e+12) -on.exit(options(magclass_sizeLimit = sizelimit)) +withr::local_options(list(magclass_sizeLimit = 1e+12)) if (length(map_file) == 0) stop("Could not find map file!") if (length(map_file) > 1) { diff --git a/scripts/output/extra/disaggregation_LUH2.R b/scripts/output/extra/disaggregation_LUH2.R index abef0a37aa..0d013240de 100644 --- a/scripts/output/extra/disaggregation_LUH2.R +++ b/scripts/output/extra/disaggregation_LUH2.R @@ -59,9 +59,7 @@ convertLUH2 <- function(x) { } -sizelimit <- getOption("magclass_sizeLimit") -options(magclass_sizeLimit = 1e+12) -on.exit(options(magclass_sizeLimit = sizelimit)) +withr::local_options(list(magclass_sizeLimit = 1e+12)) #### Spatial mapping diff --git a/scripts/output/extra/emulator.R b/scripts/output/extra/emulator.R index ddc270fb5a..68adaa910c 100644 --- a/scripts/output/extra/emulator.R +++ b/scripts/output/extra/emulator.R @@ -33,7 +33,7 @@ collect_data_and_make_emulator <- function(outputdir,name_of_fit="linear") { # lock the model (other emulaotr scripts have to wait until this one finished) lock_id <- gms::model_lock(file=".lockemu") - on.exit(gms::model_unlock(lock_id,file=".lockemu")) + withr::defer(gms::model_unlock(lock_id,file=".lockemu")) results_path <- "output" diff --git a/scripts/output/projects/inms_reporting_reg.R b/scripts/output/projects/inms_reporting_reg.R index 8a3f922cff..26b691243c 100644 --- a/scripts/output/projects/inms_reporting_reg.R +++ b/scripts/output/projects/inms_reporting_reg.R @@ -35,7 +35,7 @@ if(!exists("source_include")) { print(paste0("script started for output directory",outputdir)) wdbefore=getwd() -on.exit(setwd(wdbefore)) +withr::defer(setwd(wdbefore)) setwd(outputdir) cfg <- gms::loadConfig("config.yml") diff --git a/scripts/performance_test.R b/scripts/performance_test.R index 8f0f2c6188..890aae12e2 100644 --- a/scripts/performance_test.R +++ b/scripts/performance_test.R @@ -53,7 +53,7 @@ performance_collect <- function(id="performance",results_folder="output/",plot=T require(magpie4) require(lucode2) maindir <- getwd() - on.exit(setwd(maindir)) + withr::defer(setwd(maindir)) setwd(results_folder) folders <- grep(paste("^",id,"__",sep=""),list.dirs(full.names = FALSE, recursive = FALSE),value=TRUE) tmp <- grep(paste("^",id,"__default",sep=""),folders) diff --git a/scripts/start/Rprofile.R b/scripts/start/Rprofile.R index 53a6a41391..46001513cf 100644 --- a/scripts/start/Rprofile.R +++ b/scripts/start/Rprofile.R @@ -30,12 +30,12 @@ setSnapshot <- function(snapshotdir=NULL) { if(is.null(snapshotdir)) { fc <- file(".Rprofile") - on.exit(close(fc)) + withr::defer(close(fc)) writeLines(c('if(file.exists("~/.Rprofile")) source("~/.Rprofile")'), fc) } else { fc <- file(".Rprofile") - on.exit(close(fc)) + withr::defer(close(fc)) writeLines(c('if(file.exists("~/.Rprofile")) source("~/.Rprofile")', paste0('.libPaths(',deparse(snapshotdir),')'), paste0('print("Setting libPaths to ',snapshotdir,'")')), diff --git a/scripts/start_functions.R b/scripts/start_functions.R index fd59372c71..40197a195c 100644 --- a/scripts/start_functions.R +++ b/scripts/start_functions.R @@ -227,11 +227,11 @@ start_run <- function(cfg, scenario = NULL, codeCheck = TRUE, lock_model = TRUE) Sys.setlocale(locale="C") maindir <- getwd() - on.exit(setwd(maindir)) + withr::defer(setwd(maindir)) if(lock_model) { lock_id <- gms::model_lock(timeout1=1) - on.exit(gms::model_unlock(lock_id), add=TRUE) + withr::defer(gms::model_unlock(lock_id)) } # Apply scenario settings ans check configuration file for consistency @@ -481,7 +481,7 @@ start_run <- function(cfg, scenario = NULL, codeCheck = TRUE, lock_model = TRUE) gms::singleGAMSfile(mainfile=cfg$model, output=file.path(cfg$results_folder, "full.gms")) if(lock_model) { gms::model_unlock(lock_id) - on.exit(setwd(maindir)) + withr::defer(setwd(maindir)) } setwd(cfg$results_folder) From f66e02195ea44346466889a592c7bc92c373b89a Mon Sep 17 00:00:00 2001 From: Felicitas Date: Fri, 28 Apr 2023 14:19:12 +0200 Subject: [PATCH 05/62] update to Mehta AEI --- config/default.cfg | 14 ++-- .../endo_apr13/declarations.gms | 2 +- .../endo_apr13/input.gms | 14 +--- .../endo_apr13/postsolve.gms | 3 - .../endo_apr13/preloop.gms | 5 +- .../endo_apr13/presolve.gms | 4 +- .../endo_apr13/sets.gms | 3 + .../input/files | 1 - .../static/declarations.gms | 2 +- .../static/input.gms | 11 +--- .../static/presolve.gms | 5 +- .../static/sets.gms | 3 + renv/activate.R | 66 +++++++++++++++---- 13 files changed, 76 insertions(+), 57 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index b429981853..a882270c24 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -22,9 +22,9 @@ cfg$model <- "main.gms" #def = "main.gms" #### input settings #### # which input data sets should be used? -cfg$input <- c(regional = "rev4.84_h12_magpie.tgz", - cellular = "rev4.84_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", - validation = "rev4.84_h12_validation.tgz", +cfg$input <- c(regional = "rev4.86AEI_h12_magpie.tgz", + cellular = "rev4.86AEI_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", + validation = "WARNINGS2_rev4.86AEI_h12_validation.tgz", additional = "additional_data_rev4.43.tgz", calibration = "calibration_H12_per_ton_fao_may22_glo_23Mar23.tgz") @@ -1017,12 +1017,12 @@ cfg$gms$s40_pasture_transport_costs <- 0 # def = 0 # ***--------------------- 41_area_equipped_for_irrigation --------------- # * (static): no expansion # * (endo_apr13): endogenous, cost driven expansion -cfg$gms$area_equipped_for_irrigation <- "endo_apr13" # def = endo_apr13 +cfg$gms$area_equipped_for_irrigation <- "endo_apr13" # def = endo_apr13 # * switch for initialization area -# * (LUH2v2): area equipped for irrigation based on LUH2v2 -# * (Siebert): area equipped for irrigation from Siebert et al. -cfg$gms$c41_initial_irrigation_area <- "LUH2v2" # def = LUH2v2 +# * (LUH2v2): area equipped for irrigation based on LUH2v2 irrigated areas +# * (Mehta2022): area equipped for irrigation from Mehta et al. (2022) +cfg$gms$c41_initial_irrigation_area <- "LUH2v2" # def = LUH2v2 # * Sets the rate of depreciation of irrigation infrastructure in every timestep. # * Only applicable when (endo_apr13) realization is selected diff --git a/modules/41_area_equipped_for_irrigation/endo_apr13/declarations.gms b/modules/41_area_equipped_for_irrigation/endo_apr13/declarations.gms index 42d1d51c11..b61b9f5166 100644 --- a/modules/41_area_equipped_for_irrigation/endo_apr13/declarations.gms +++ b/modules/41_area_equipped_for_irrigation/endo_apr13/declarations.gms @@ -16,7 +16,7 @@ variables ; positive variables - vm_AEI(j) Area equipped for irrigation in each grid cell (mio. ha) + vm_AEI(j) Area equipped for irrigation in each grid cell (mio. ha) ; equations diff --git a/modules/41_area_equipped_for_irrigation/endo_apr13/input.gms b/modules/41_area_equipped_for_irrigation/endo_apr13/input.gms index 24beccec4b..37a50666bf 100644 --- a/modules/41_area_equipped_for_irrigation/endo_apr13/input.gms +++ b/modules/41_area_equipped_for_irrigation/endo_apr13/input.gms @@ -11,7 +11,6 @@ scalars s41_AEI_depreciation Depreciation rate in capital value of irrigation infrastructure (USD05PPP per USD05PPP) / 0 / ; - table f41_c_irrig(t_all,i) Irrigation investment costs (USD04MER per ha) $ondelim $include "./modules/41_area_equipped_for_irrigation/endo_apr13/input/f41_c_irrig.csv" @@ -19,19 +18,10 @@ $offdelim ; parameters -f41_irrig(j) Available area equipped for irrigation according to Siebert [AVL] (mio. ha) -/ -$ondelim -$include "./modules/41_area_equipped_for_irrigation/input/avl_irrig.cs2" -$offdelim -/ -; - -parameters -f41_irrig_luh(t_ini41,j) Available area equipped for irrigation according to LUH [AVL] (mio. ha) +f41_irrig(t_ini41,j,aei41) Available area equipped for irrigation [AVL] (mio. ha) / $ondelim -$include "./modules/41_area_equipped_for_irrigation/input/avl_irrig_luh_t.cs2" +$include "./modules/41_area_equipped_for_irrigation/input/avl_irrig.cs3" $offdelim / ; diff --git a/modules/41_area_equipped_for_irrigation/endo_apr13/postsolve.gms b/modules/41_area_equipped_for_irrigation/endo_apr13/postsolve.gms index 7bf8c056d4..a71cb0733f 100644 --- a/modules/41_area_equipped_for_irrigation/endo_apr13/postsolve.gms +++ b/modules/41_area_equipped_for_irrigation/endo_apr13/postsolve.gms @@ -5,11 +5,8 @@ *** | MAgPIE License Exception, version 1.0 (see LICENSE file). *** | Contact: magpie@pik-potsdam.de - - pc41_AEI_start(j)=vm_AEI.l(j) ; - *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### ov_cost_AEI(t,i,"marginal") = vm_cost_AEI.m(i); ov_AEI(t,j,"marginal") = vm_AEI.m(j); diff --git a/modules/41_area_equipped_for_irrigation/endo_apr13/preloop.gms b/modules/41_area_equipped_for_irrigation/endo_apr13/preloop.gms index 5ffaf199fa..dfec267f1e 100644 --- a/modules/41_area_equipped_for_irrigation/endo_apr13/preloop.gms +++ b/modules/41_area_equipped_for_irrigation/endo_apr13/preloop.gms @@ -5,6 +5,5 @@ *** | MAgPIE License Exception, version 1.0 (see LICENSE file). *** | Contact: magpie@pik-potsdam.de -$ifthen "%c41_initial_irrigation_area%" == "Siebert" pc41_AEI_start(j) = f41_irrig(j); -$elseif "%c41_initial_irrigation_area%" == "LUH2v2" pc41_AEI_start(j) = f41_irrig_luh("y1995",j); -$endif +*' Area equipped for irrigation in initialization year +pc41_AEI_start(j) = f41_irrig("y1995",j,"%c41_initial_irrigation_area%"); diff --git a/modules/41_area_equipped_for_irrigation/endo_apr13/presolve.gms b/modules/41_area_equipped_for_irrigation/endo_apr13/presolve.gms index c2f630a0da..02bfed4c8f 100644 --- a/modules/41_area_equipped_for_irrigation/endo_apr13/presolve.gms +++ b/modules/41_area_equipped_for_irrigation/endo_apr13/presolve.gms @@ -8,7 +8,7 @@ p41_AEI_start(t,j) = pc41_AEI_start(j); *' Updating existing capital stocks to account for depreciation -vm_AEI.lo(j) = pc41_AEI_start(j)/((1- s41_AEI_depreciation)**(m_timestep_length)); - +vm_AEI.lo(j) = pc41_AEI_start(j) / ((1 - s41_AEI_depreciation)**(m_timestep_length)); +*' Unit costs for irrigation expansion pc41_unitcost_AEI(i) = f41_c_irrig(t,i); diff --git a/modules/41_area_equipped_for_irrigation/endo_apr13/sets.gms b/modules/41_area_equipped_for_irrigation/endo_apr13/sets.gms index 92dee76fbe..0eb6194be7 100644 --- a/modules/41_area_equipped_for_irrigation/endo_apr13/sets.gms +++ b/modules/41_area_equipped_for_irrigation/endo_apr13/sets.gms @@ -8,4 +8,7 @@ sets t_ini41 Time periods with area equipped for irrigation initialization data / y1995, y2000, y2005, y2010, y2015 / + + aei41 Data source for area equipped for irrigation + / LUH2v2, Mehta2022 / ; diff --git a/modules/41_area_equipped_for_irrigation/input/files b/modules/41_area_equipped_for_irrigation/input/files index 17d076cde1..91b604379e 100644 --- a/modules/41_area_equipped_for_irrigation/input/files +++ b/modules/41_area_equipped_for_irrigation/input/files @@ -1,3 +1,2 @@ * list of files that are required here avl_irrig.cs2 -avl_irrig_luh_t.cs2 diff --git a/modules/41_area_equipped_for_irrigation/static/declarations.gms b/modules/41_area_equipped_for_irrigation/static/declarations.gms index dd88de4a3d..fa4ffdbb5a 100644 --- a/modules/41_area_equipped_for_irrigation/static/declarations.gms +++ b/modules/41_area_equipped_for_irrigation/static/declarations.gms @@ -10,7 +10,7 @@ variables ; positive variables - vm_AEI(j) Area equipped for irrigation in each grid cell (mio. ha) + vm_AEI(j) Area equipped for irrigation in each grid cell (mio. ha) ; equations diff --git a/modules/41_area_equipped_for_irrigation/static/input.gms b/modules/41_area_equipped_for_irrigation/static/input.gms index d5519ef955..8fab4ffdf0 100644 --- a/modules/41_area_equipped_for_irrigation/static/input.gms +++ b/modules/41_area_equipped_for_irrigation/static/input.gms @@ -8,19 +8,10 @@ $setglobal c41_initial_irrigation_area LUH2v2 parameters -f41_irrig(j) Available area equipped for irrigation according to Siebert [AVL] (mio. ha) +f41_irrig(t_ini41,j,aei41) Available area equipped for irrigation [AVL] (mio. ha) / $ondelim $include "./modules/41_area_equipped_for_irrigation/input/avl_irrig.cs2" $offdelim / ; - -parameters -f41_irrig_luh(t_ini41,j) Available area equipped for irrigation according to LUH [AVL] (mio. ha) -/ -$ondelim -$include "./modules/41_area_equipped_for_irrigation/input/avl_irrig_luh_t.cs2" -$offdelim -/ -; diff --git a/modules/41_area_equipped_for_irrigation/static/presolve.gms b/modules/41_area_equipped_for_irrigation/static/presolve.gms index 708110003e..3428e65569 100644 --- a/modules/41_area_equipped_for_irrigation/static/presolve.gms +++ b/modules/41_area_equipped_for_irrigation/static/presolve.gms @@ -5,8 +5,7 @@ *** | MAgPIE License Exception, version 1.0 (see LICENSE file). *** | Contact: magpie@pik-potsdam.de -$ifthen "%c41_initial_irrigation_area%" == "Siebert" vm_AEI.fx(j) = f41_irrig(j); -$elseif "%c41_initial_irrigation_area%" == "LUH2v2" vm_AEI.fx(j) = f41_irrig_luh("y1995",j); -$endif +*' Area equipped for irrigation in initialization year +vm_AEI.fx(j) = f41_irrig("y1995",j,"%c41_initial_irrigation_area%"); vm_cost_AEI.fx(i) = 0; diff --git a/modules/41_area_equipped_for_irrigation/static/sets.gms b/modules/41_area_equipped_for_irrigation/static/sets.gms index 92dee76fbe..0eb6194be7 100644 --- a/modules/41_area_equipped_for_irrigation/static/sets.gms +++ b/modules/41_area_equipped_for_irrigation/static/sets.gms @@ -8,4 +8,7 @@ sets t_ini41 Time periods with area equipped for irrigation initialization data / y1995, y2000, y2005, y2010, y2015 / + + aei41 Data source for area equipped for irrigation + / LUH2v2, Mehta2022 / ; diff --git a/renv/activate.R b/renv/activate.R index 019b5a6693..4564b9ddf0 100644 --- a/renv/activate.R +++ b/renv/activate.R @@ -63,6 +63,10 @@ local({ if (is.environment(x) || length(x)) x else y } + `%??%` <- function(x, y) { + if (is.null(x)) y else x + } + bootstrap <- function(version, library) { # attempt to download renv @@ -83,28 +87,39 @@ local({ renv_bootstrap_repos <- function() { + # get CRAN repository + cran <- getOption("renv.repos.cran", "https://cloud.r-project.org") + # check for repos override repos <- Sys.getenv("RENV_CONFIG_REPOS_OVERRIDE", unset = NA) - if (!is.na(repos)) + if (!is.na(repos)) { + + # check for RSPM; if set, use a fallback repository for renv + rspm <- Sys.getenv("RSPM", unset = NA) + if (identical(rspm, repos)) + repos <- c(RSPM = rspm, CRAN = cran) + return(repos) + } + # check for lockfile repositories repos <- tryCatch(renv_bootstrap_repos_lockfile(), error = identity) if (!inherits(repos, "error") && length(repos)) return(repos) # if we're testing, re-use the test repositories - if (renv_bootstrap_tests_running()) - return(getOption("renv.tests.repos")) + if (renv_bootstrap_tests_running()) { + repos <- getOption("renv.tests.repos") + if (!is.null(repos)) + return(repos) + } # retrieve current repos repos <- getOption("repos") # ensure @CRAN@ entries are resolved - repos[repos == "@CRAN@"] <- getOption( - "renv.repos.cran", - "https://cloud.r-project.org" - ) + repos[repos == "@CRAN@"] <- cran # add in renv.bootstrap.repos if set default <- c(FALLBACK = "https://cloud.r-project.org") @@ -344,8 +359,7 @@ local({ return() # allow directories - info <- file.info(tarball, extra_cols = FALSE) - if (identical(info$isdir, TRUE)) { + if (dir.exists(tarball)) { name <- sprintf("renv_%s.tar.gz", version) tarball <- file.path(tarball, name) } @@ -659,8 +673,8 @@ local({ if (version == loadedversion) return(TRUE) - # assume four-component versions are from GitHub; three-component - # versions are from CRAN + # assume four-component versions are from GitHub; + # three-component versions are from CRAN components <- strsplit(loadedversion, "[.-]")[[1]] remote <- if (length(components) == 4L) paste("rstudio/renv", loadedversion, sep = "@") @@ -700,6 +714,12 @@ local({ # warn if the version of renv loaded does not match renv_bootstrap_validate_version(version) + # execute renv load hooks, if any + hooks <- getHook("renv::autoload") + for (hook in hooks) + if (is.function(hook)) + tryCatch(hook(), error = warning) + # load the project renv::load(project) @@ -842,11 +862,29 @@ local({ renv_json_read <- function(file = NULL, text = NULL) { + jlerr <- NULL + # if jsonlite is loaded, use that instead - if ("jsonlite" %in% loadedNamespaces()) - renv_json_read_jsonlite(file, text) + if ("jsonlite" %in% loadedNamespaces()) { + + json <- catch(renv_json_read_jsonlite(file, text)) + if (!inherits(json, "error")) + return(json) + + jlerr <- json + + } + + # otherwise, fall back to the default JSON reader + json <- catch(renv_json_read_default(file, text)) + if (!inherits(json, "error")) + return(json) + + # report an error + if (!is.null(jlerr)) + stop(jlerr) else - renv_json_read_default(file, text) + stop(json) } From bc09f73b67341b719dcef538441c1fe255366f59 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Tue, 2 May 2023 10:55:15 +0200 Subject: [PATCH 06/62] changes related to cs3 format of aei --- .../41_area_equipped_for_irrigation/endo_apr13/input.gms | 4 +--- modules/41_area_equipped_for_irrigation/input/files | 2 +- modules/41_area_equipped_for_irrigation/static/input.gms | 6 ++---- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/modules/41_area_equipped_for_irrigation/endo_apr13/input.gms b/modules/41_area_equipped_for_irrigation/endo_apr13/input.gms index 37a50666bf..ec5094b9c2 100644 --- a/modules/41_area_equipped_for_irrigation/endo_apr13/input.gms +++ b/modules/41_area_equipped_for_irrigation/endo_apr13/input.gms @@ -17,11 +17,9 @@ $include "./modules/41_area_equipped_for_irrigation/endo_apr13/input/f41_c_irrig $offdelim ; -parameters +table f41_irrig(t_ini41,j,aei41) Available area equipped for irrigation [AVL] (mio. ha) -/ $ondelim $include "./modules/41_area_equipped_for_irrigation/input/avl_irrig.cs3" $offdelim -/ ; diff --git a/modules/41_area_equipped_for_irrigation/input/files b/modules/41_area_equipped_for_irrigation/input/files index 91b604379e..94f0346458 100644 --- a/modules/41_area_equipped_for_irrigation/input/files +++ b/modules/41_area_equipped_for_irrigation/input/files @@ -1,2 +1,2 @@ * list of files that are required here -avl_irrig.cs2 +avl_irrig.cs3 diff --git a/modules/41_area_equipped_for_irrigation/static/input.gms b/modules/41_area_equipped_for_irrigation/static/input.gms index 8fab4ffdf0..09202692df 100644 --- a/modules/41_area_equipped_for_irrigation/static/input.gms +++ b/modules/41_area_equipped_for_irrigation/static/input.gms @@ -7,11 +7,9 @@ $setglobal c41_initial_irrigation_area LUH2v2 -parameters +table f41_irrig(t_ini41,j,aei41) Available area equipped for irrigation [AVL] (mio. ha) -/ $ondelim -$include "./modules/41_area_equipped_for_irrigation/input/avl_irrig.cs2" +$include "./modules/41_area_equipped_for_irrigation/input/avl_irrig.cs3" $offdelim -/ ; From c270bc4b4d19e6bea1c892166ecc129a1b81ddf3 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Fri, 5 May 2023 12:15:05 +0200 Subject: [PATCH 07/62] updated changelog --- CHANGELOG.md | 4 +++- config/default.cfg | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 283401c862..438960bb09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,13 +8,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] ### changed +- **config** new area equipped for irrigation data in preprocessing (v 4.87) +- **41_area_equipped_for_irrigation** new area equipped for irrigation data (Mehta2022) replacing old Siebert data - **config** added scenario `SSP2EU` in scenario_config.csv - **config** modified `eat_lancet_diet` in scenario_config.csv - **config** update of additional data to rev4.43 - **56_ghg_policy** added emission policies without GHG emissions from peatlands - **scripts** NDC/NPI calculations can now handle 59k and 67k cell inputs - **config** update of regional and cellular inputs to 4.85 in default.cfg and scenario_config.csv -- **09_drivers** Harmonization of sets for population, gdp, pal and demography +- **09_drivers** Harmonization of sets for population, gdp, pal and demography ### added - **15_food** added an option in `s15_exo_diet` to allow for exogenous diet scenario for India diff --git a/config/default.cfg b/config/default.cfg index 61e9420009..e55b5b8c50 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -22,9 +22,9 @@ cfg$model <- "main.gms" #def = "main.gms" #### input settings #### # which input data sets should be used? -cfg$input <- c(regional = "rev4.85_h12_magpie.tgz", - cellular = "rev4.85_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", - validation = "rev4.85_h12_validation.tgz", +cfg$input <- c(regional = "rev4.87_h12_magpie.tgz", + cellular = "rev4.87_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", + validation = "rev4.87_h12_validation.tgz", additional = "additional_data_rev4.43.tgz", calibration = "calibration_H12_per_ton_fao_may22_glo_23Mar23.tgz") From f8e16fdf6eecd8159fb15a6042bef29c2a24e9b3 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Fri, 5 May 2023 12:18:53 +0200 Subject: [PATCH 08/62] committed renv settings file --- renv/settings.json | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 renv/settings.json diff --git a/renv/settings.json b/renv/settings.json new file mode 100644 index 0000000000..3331ef2535 --- /dev/null +++ b/renv/settings.json @@ -0,0 +1,17 @@ +{ + "bioconductor.version": [], + "external.libraries": [], + "ignored.packages": [], + "package.dependency.fields": [ + "Imports", + "Depends", + "LinkingTo" + ], + "r.version": [], + "snapshot.type": "implicit", + "use.cache": true, + "vcs.ignore.cellar": true, + "vcs.ignore.library": true, + "vcs.ignore.local": true, + "vcs.manage.ignores": true +} From 64a68790b736ce7f94de02ae063d8114e0a6e292 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20F=C3=BChrlich?= Date: Mon, 8 May 2023 10:56:29 +0200 Subject: [PATCH 09/62] reset to renv 0.16.0 in .Rprofile --- .Rprofile | 9 +++++++++ renv/activate.R | 44 +++++++++++++++++++++++++++++++++++--------- 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/.Rprofile b/.Rprofile index ccfe3ebf9b..e8d4f1facc 100644 --- a/.Rprofile +++ b/.Rprofile @@ -8,6 +8,15 @@ Sys.setenv(RENV_PATHS_LIBRARY = "renv/library") source("renv/activate.R") +renvVersion <- "0.16.0" +if (packageVersion("renv") != renvVersion) { + renvLockExisted <- file.exists(renv::paths$lockfile()) + renv::upgrade(version = renvVersion, reload = TRUE, prompt = FALSE) + if (!renvLockExisted) { + unlink(renv::paths$lockfile()) + } +} + if (!"https://rse.pik-potsdam.de/r/packages" %in% getOption("repos")) { options(repos = c(getOption("repos"), pik = "https://rse.pik-potsdam.de/r/packages")) } diff --git a/renv/activate.R b/renv/activate.R index 019b5a6693..026b3f94bb 100644 --- a/renv/activate.R +++ b/renv/activate.R @@ -94,8 +94,11 @@ local({ return(repos) # if we're testing, re-use the test repositories - if (renv_bootstrap_tests_running()) - return(getOption("renv.tests.repos")) + if (renv_bootstrap_tests_running()) { + repos <- getOption("renv.tests.repos") + if (!is.null(repos)) + return(repos) + } # retrieve current repos repos <- getOption("repos") @@ -344,8 +347,7 @@ local({ return() # allow directories - info <- file.info(tarball, extra_cols = FALSE) - if (identical(info$isdir, TRUE)) { + if (dir.exists(tarball)) { name <- sprintf("renv_%s.tar.gz", version) tarball <- file.path(tarball, name) } @@ -659,8 +661,8 @@ local({ if (version == loadedversion) return(TRUE) - # assume four-component versions are from GitHub; three-component - # versions are from CRAN + # assume four-component versions are from GitHub; + # three-component versions are from CRAN components <- strsplit(loadedversion, "[.-]")[[1]] remote <- if (length(components) == 4L) paste("rstudio/renv", loadedversion, sep = "@") @@ -700,6 +702,12 @@ local({ # warn if the version of renv loaded does not match renv_bootstrap_validate_version(version) + # execute renv load hooks, if any + hooks <- getHook("renv::autoload") + for (hook in hooks) + if (is.function(hook)) + tryCatch(hook(), error = warning) + # load the project renv::load(project) @@ -842,11 +850,29 @@ local({ renv_json_read <- function(file = NULL, text = NULL) { + jlerr <- NULL + # if jsonlite is loaded, use that instead - if ("jsonlite" %in% loadedNamespaces()) - renv_json_read_jsonlite(file, text) + if ("jsonlite" %in% loadedNamespaces()) { + + json <- catch(renv_json_read_jsonlite(file, text)) + if (!inherits(json, "error")) + return(json) + + jlerr <- json + + } + + # otherwise, fall back to the default JSON reader + json <- catch(renv_json_read_default(file, text)) + if (!inherits(json, "error")) + return(json) + + # report an error + if (!is.null(jlerr)) + stop(jlerr) else - renv_json_read_default(file, text) + stop(json) } From 930f97baa1f11c0cfe74128a6e51b3bd6061fbb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20F=C3=BChrlich?= Date: Thu, 11 May 2023 09:04:26 +0200 Subject: [PATCH 10/62] merge master into develop --- .zenodo.json | 2 +- CITATION.cff | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.zenodo.json b/.zenodo.json index d33ef2c3d7..0374c30b02 100644 --- a/.zenodo.json +++ b/.zenodo.json @@ -1,6 +1,6 @@ { "title": "MAgPIE - An Open Source land-use modeling framework", - "version": "4.6.7", + "version": "4.6.7dev", "creators": [ { "name": "Dietrich, Jan Philipp", diff --git a/CITATION.cff b/CITATION.cff index d298f0f5df..3ef58fe565 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -125,7 +125,7 @@ authors: email: popp@pik-potsdam.de title: MAgPIE - An Open Source land-use modeling framework -version: 4.6.7 +version: 4.6.7dev date-released: 2023-05-10 repository-code: https://github.com/magpiemodel/magpie keywords: From 4fb4d9457f54b7b823132346420493badec9563f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20F=C3=BChrlich?= Date: Thu, 11 May 2023 09:07:52 +0200 Subject: [PATCH 11/62] merge master into develop --- CHANGELOG.md | 15 +++++++++++++++ scripts/postRelease.R | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4777e041ab..d966db286b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,21 @@ 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/). +## [Unreleased] + +### changed +- + +### added +- + +### removed +- + +### fixed +- + + ## [4.6.7] - 2023-05-10 ### changed diff --git a/scripts/postRelease.R b/scripts/postRelease.R index 6c5f3195bf..5330da3fca 100644 --- a/scripts/postRelease.R +++ b/scripts/postRelease.R @@ -2,7 +2,8 @@ postRelease <- function() { gert::git_fetch("upstream") gert::git_merge("upstream/master") - pattern <- "and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)." + pattern <- "The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)." + stopifnot(any(grepl(pattern, readLines("CHANGELOG.md"), fixed = TRUE))) textToAdd <- paste("", "", "", From 9fc175734aed825d826dddc98f6be567869d5c50 Mon Sep 17 00:00:00 2001 From: Felicitas Beier <39262100+FelicitasBeier@users.noreply.github.com> Date: Thu, 11 May 2023 16:38:38 +0200 Subject: [PATCH 12/62] Update CHANGELOG.md --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 42017faa52..b050bf704a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### added - **config** new area equipped for irrigation (AEI) data in preprocessing (4.87) +### removed +- + +### fixed +- + ## [4.6.7] - 2023-05-10 ### changed From 6d3b63dcd2acccd3fb888ac5eccc71c766dfe521 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Tue, 16 May 2023 10:56:45 +0200 Subject: [PATCH 13/62] update start_functions.R such that different cluster sets are possible --- CHANGELOG.md | 3 +- scripts/start_functions.R | 116 ++++++++++++++++++++------------------ 2 files changed, 64 insertions(+), 55 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b050bf704a..42eb85cc19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] ### changed +- **scripts** start_functions.R can now handle clusters per region flexibly - **41_area_equipped_for_irrigation** new AEI data (Mehta2022) replacing old Siebert data ### added @@ -17,7 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - ### fixed -- +- ## [4.6.7] - 2023-05-10 diff --git a/scripts/start_functions.R b/scripts/start_functions.R index 3e9cf03c01..83a4423ced 100644 --- a/scripts/start_functions.R +++ b/scripts/start_functions.R @@ -9,7 +9,24 @@ # Define internal functions ################################################################################ -.update_sets_core <- function(cpr,map) { +.calcClusterCells <- function(x) { + cells <- noCells <- NULL + for (i in magclass::getItems(x, dim = 1.1)) { + max <- max(as.numeric(magclass::getItems(x[i, , ], dim = 1.2))) + min <- min(as.numeric(magclass::getItems(x[i, , ], dim = 1.2))) + count <- length(magclass::getItems(x[i, , ], dim = 1.2)) + + tmp <- paste0(paste(i, min, sep = "_"), "*" , paste(i, max, sep = "_")) + cells <- c(cells, tmp) + noCells <- c(noCells, count) + } + out <- data.frame(i = magclass::getItems(x, dim = 1.1), + j = cells, + n = noCells) + return(out) +} + +.update_sets_core <- function(x, map) { require(gms) if (!("region" %in% names(map))) map$region <- map$RegionCode @@ -17,25 +34,14 @@ if (!("superregion" %in% names(map))) map$superregion <- map$region reg1 <- unique(as.character(map$region)) - reg2 <- names(cpr) - if(!all(union(reg1,reg2) %in% intersect(reg1,reg2))) { + reg2 <- magclass::getItems(x, dim = 1.1) + if (!all(union(reg1,reg2) %in% intersect(reg1, reg2))) { stop("Inconsistent region information!", - "\n cpr info: ",paste(reg2,collapse=", "), - "\n spatial header info: ", paste(reg1,collapse=", ")) + "\n cpr info: ", paste(reg2, collapse = ", "), + "\n spatial header info: ", paste(reg1, collapse = ", ")) } - - j <- 0; cells <- NULL - for (i in 1:length(cpr)) { - if (cpr[i] == 1) { - cells <- c(cells, paste0(names(cpr)[i], "_", j + 1)) - } else { - cells <- c(cells, paste0(names(cpr)[i], "_", j + 1, "*", - names(cpr)[i], "_", j + cpr[i])) - } - j <- j + cpr[i] - } - ij <- data.frame(i = names(cpr), j = cells) + ij <- .calcClusterCells(x = x)[c("i", "j")] hi <- unique(map[c("superregion", "region")]) hi <- hi[order(hi$superregion),] @@ -45,7 +51,7 @@ items = sort(unique(as.character(map$superregion)))), list(name = "i", desc = "all economic regions", - items = names(cpr)), + items = ij[["i"]]), list(name = "supreg(h,i)", desc = "mapping of superregions to its regions", items = hi), @@ -54,7 +60,7 @@ items = as.character(map$country)), list(name = "j", desc = "number of LPJ cells", - items = cells), + items = ij[["j"]]), list(name = "cell(i,j)", desc = "number of LPJ cells per region i", items = ij), @@ -96,36 +102,39 @@ } # Function to extract information from info.txt -.get_info <- function(file, grep_expression, sep, pattern="", replacement="") { +.get_info <- function(file, grep_expression, sep, pattern = "", replacement = "") { if(!file.exists(file)) return("#MISSING#") file <- readLines(file, warn=FALSE) tmp <- grep(grep_expression, file, value=TRUE) tmp <- strsplit(tmp, sep) tmp <- sapply(tmp, "[[", 2) - tmp <- gsub(pattern, replacement ,tmp) + tmp <- gsub(pattern, replacement, tmp) if(all(!is.na(as.logical(tmp)))) return(as.vector(sapply(tmp, as.logical))) - if (all(!(regexpr("[a-zA-Z]",tmp) > 0))) { + if (all(!(regexpr("[a-zA-Z]", tmp) > 0))) { tmp <- as.numeric(tmp) } return(tmp) } -#Define routine to update info file in input folder and info in main.gms -.update_info <- function(datasets, cpr, regionscode, reg_revision, warnings=NULL) { +# Define routine to update info file in input folder and info in main.gms +.update_info <- function(datasets, x, regionscode, reg_revision, warnings = NULL) { + + # extract cluster information from file: + ijn <- .calcClusterCells(x = x) - low_res <- .get_info("input/info.txt","^\\* Output ?resolution:",": ") - high_res <- .get_info("input/info.txt","^\\* Input ?resolution:",": ") + low_res <- .get_info("input/info.txt", "^\\* Output ?resolution:", ": ") + high_res <- .get_info("input/info.txt", "^\\* Input ?resolution:", ": ") - info <- readLines('input/info.txt') + info <- readLines('input/info.txt') subject <- 'VERSION INFO' useddata <- NULL for(dataset in rownames(datasets)) { useddata <- c(useddata, '', - paste('Used data set:',dataset), - paste('md5sum:',datasets[dataset,"md5"]), - paste('Repository:',datasets[dataset,"repo"])) + paste('Used data set:', dataset), + paste('md5sum:', datasets[dataset, "md5"]), + paste('Repository:', datasets[dataset, "repo"])) } warnings <- attr(datasets,"warnings") @@ -135,18 +144,18 @@ content <- c(useddata, '', - paste('Low resolution:',low_res), - paste('High resolution:',high_res), + paste('Low resolution:', low_res), + paste('High resolution:', high_res), '', - paste('Total number of cells:',sum(cpr)), + paste('Total number of cells:', sum(ijn["n"])), '', 'Number of cells per region:', - paste(format(names(cpr),width=5,justify="right"),collapse=""), - paste(format(cpr,width=5),collapse=""), + paste(format(ijn[["i"]], width = 5, justify = "right"), collapse = ""), + paste(format(ijn[["n"]], width = 5), collapse = ""), '', - paste('Regionscode:',regionscode), + paste('Regionscode:', regionscode), '', - paste('Regions data revision:',reg_revision), + paste('Regions data revision:', reg_revision), '', info, '', @@ -166,10 +175,10 @@ sp <- luscale::read.spam(spamfile) a <- apply(sp, 2, function(x) return(which(x == 1))) out <- data.frame(cell = cells_tmp, region = sub("\\..*$","",spatial_header), - country = sub("\\..*$","",cells_tmp), global = "GLO") - out$cluster <- paste0(out$region,".",a) - out <- out[,c("cell", "cluster","region","country","global")] - saveRDS(out, paste0("input/",outfile), version = 2) + country = sub("\\..*$", "", cells_tmp), global = "GLO") + out$cluster <- paste0(out$region,".", a) + out <- out[,c("cell", "cluster", "region", "country", "global")] + saveRDS(out, paste0("input/", outfile), version = 2) } @@ -197,15 +206,14 @@ download_and_update <- function(cfg) { # and .update_sets, which is updating the resolution- and region-depending # sets in core/sets.gms tmp <- magclass::read.magpie("modules/10_land/input/avl_land_t.cs3") - cpr <- magclass::getCPR(tmp) tmp2 <- magclass::read.magpie("modules/10_land/input/avl_land_t_0.5.mz") - cel <- magclass::getItems(tmp2,1) + cel <- magclass::getItems(tmp2, dim = 1) # read spatial_header, map, reg_revision and regionscode load("input/spatial_header.rda") - rds <- any(grepl(pattern = "clustermap_rev.*.rds", x=list.files("input"))) - if(!rds) .spam2rds(spatial_header, cel, "clustermap_rev0_dummy.rds") - .update_info(filemap,cpr,regionscode,reg_revision, warnings) - .update_sets_core(cpr,map) + rds <- any(grepl(pattern = "clustermap_rev.*.rds", x = list.files("input"))) + if (!rds) .spam2rds(spatial_header, cel, "clustermap_rev0_dummy.rds") + .update_info(filemap, x = tmp, regionscode, reg_revision, warnings) + .update_sets_core(x = tmp, map = map) .update_sets_modules() } @@ -225,12 +233,12 @@ start_run <- function(cfg, scenario = NULL, codeCheck = TRUE, lock_model = TRUE) checkNamespace("gms", "lucode2", "magclass") - Sys.setlocale(locale="C") + Sys.setlocale(locale = "C") maindir <- getwd() withr::defer(setwd(maindir)) if(lock_model) { - lock_id <- gms::model_lock(timeout1=1) + lock_id <- gms::model_lock(timeout1 = 1) withr::defer(gms::model_unlock(lock_id)) } @@ -403,9 +411,9 @@ start_run <- function(cfg, scenario = NULL, codeCheck = TRUE, lock_model = TRUE) user = Sys.info()[["user"]], date = rundate, version_management = "git", - revision = try(system("git rev-parse HEAD", intern=TRUE), silent=TRUE), - revision_date = try(as.POSIXct(system("git show -s --format=%ci", intern=TRUE), silent=TRUE)), - status = try(system("git status", intern=TRUE), silent=TRUE)) + revision = try(system("git rev-parse HEAD", intern = TRUE), silent=TRUE), + revision_date = try(as.POSIXct(system("git show -s --format=%ci", intern = TRUE), silent = TRUE)), + status = try(system("git status", intern = TRUE), silent = TRUE)) ############################################################################## @@ -475,12 +483,12 @@ start_run <- function(cfg, scenario = NULL, codeCheck = TRUE, lock_model = TRUE) # copy important files into output_folder (before MAgPIE execution) for(file in cfg$files2export$start) { - try(file.copy(Sys.glob(file), cfg$results_folder, overwrite=TRUE)) + try(file.copy(Sys.glob(file), cfg$results_folder, overwrite = TRUE)) } cfg$magpie_folder <- getwd() # only store repository paths, not their credentials - cfg$repositories <- sapply(names(cfg$repositories),function(x) NULL) + cfg$repositories <- sapply(names(cfg$repositories), function(x) NULL) # store config in human and machine readable form gms::saveConfig(cfg, file.path(cfg$results_folder, "config.yml")) From 29ab82636ddce464cbc998edaa16c82a08e63040 Mon Sep 17 00:00:00 2001 From: mishkos Date: Wed, 17 May 2023 11:11:04 +0200 Subject: [PATCH 14/62] added a scenario for NGFS_o_lowdem --- config/scenario_config.csv | 170 ++++++++++++++++++------------------- 1 file changed, 85 insertions(+), 85 deletions(-) diff --git a/config/scenario_config.csv b/config/scenario_config.csv index 5d45847bd7..7a474615a0 100644 --- a/config/scenario_config.csv +++ b/config/scenario_config.csv @@ -1,85 +1,85 @@ -;cc;nocc;nocc_hist;SSP1;SSP2;SSP2EU;SSP3;SSP4;SSP5;SDP;SDP-EI;SDP-RC;SDP-MC;BASE;NPI;NDC;coupling;emulator;input;Tland;eat_lancet_diet;LAMA_Inequal;LAMA_Inequal-SustDemand;LAMA_Inequal-EnvirProt;LAMA_Inequal-GHGPrice;LAMA_Sustainability;NAVIGATE_AllOff;NAVIGATE_LandSup;NAVIGATE_LandDem;NAVIGATE_AllOn;ForestryEndo;ForestryExo;ForestryOff;frst_shock_none;frst_shock_002lin2030;frst_shock_004lin2030;frst_shock_008lin2030;frst_shock_016lin2030;rcp1p9;rcp2p6;rcp4p5;rcp6p0;rcp7p0;rcp8p5 -gms$c09_pop_scenario;;;;SSP1;SSP2;SSP2EU;SSP3;SSP4;SSP5;SSP1;SSP1;SSP1;SSP1;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;; -gms$c09_gdp_scenario;;;;SSP1;SSP2;SSP2EU;SSP3;SSP4;SSP5;SSP1;SDP_EI;SDP_RC;SDP_MC;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;; -gms$c09_pal_scenario;;;;SSP1;SSP2;SSP2EU;SSP3;SSP4;SSP5;SSP1;SSP2;SSP1;SSP1;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;; -gms$c15_food_scenario;;;;SSP1;SSP2;SSP2;SSP3;SSP4;SSP5;SSP1;SSP2;SSP1;SSP1;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;; -gms$c15_food_scenario_noselect;;;;;;;;;;;;;;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;; -gms$s15_elastic_demand;;;;0;0;0;0;0;0;0;0;0;0;;;;;;;0;0;0;0;0;0;0;;;;;;;;;;;;;;;;;; -gms$c15_rumdairy_scp_scen;;;;constant;constant;constant;constant;constant;constant;constant;sigmoid_50pc_20_50;constant;constant;;;;;;;constant;;;;;;;;;;;;;;;;;;;;;;;; -gms$kfo_rd;;;;;;;;;;;livst_rum;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -gms$c15_exo_foodscen;;;;;;;;;;lin_zero_20_50;lin_zero_20_50;lin_zero_20_50;lin_zero_20_70;;;;;;;lin_zero_20_50;lin_zero_20_50;;lin_zero_20_50;;;lin_zero_20_50;;;;;;;;;;;;;;;;;; -gms$s15_exo_waste;;;;0;0;0;0;0;0;1;1;1;1;;;;;;;1;0;0;1;0;0;1;0;0;1;1;;;;;;;;;;;;;; -gms$s15_waste_scen;;;;;;;;;;1.2;1.3;1.2;1.25;;;;;;;1.2;1.2;;1.2;;;1.2;;;;;;;;;;;;;;;;;; -gms$s15_exo_diet;;;;0;0;0;0;0;0;1;1;1;1;;;;;;;1;1;0;1;0;0;1;0;0;1;1;;;;;;;;;;;;;; -gms$c15_kcal_scen;;;;;;;;;;healthy_BMI;no_underweight;healthy_BMI;healthy_BMI;;;;;;;healthy_BMI;healthy_BMI;;healthy_BMI;;;healthy_BMI;;;;;;;;;;;;;;;;;; -gms$c15_EAT_scen;;;;;;;;;;FLX;;FLX;FLX;;;;;;;FLX;FLX;;FLX;;;FLX;;;;;;;;;;;;;;;;;; -gms$s15_exo_monogastric;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;; -gms$s15_exo_ruminant;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;; -gms$s15_exo_fish;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;; -gms$s15_exo_fruitvegnut;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;; -gms$s15_exo_pulses;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;; -gms$s15_exo_sugar;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;; -gms$s15_exo_oils;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;; -gms$s15_exo_brans;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;; -gms$s15_exo_scp;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;; -gms$s15_exo_alcohol;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;; -gms$c21_trade_liberalization;;;;l908080r807070;l909090r808080;l909090r808080;l909595r809090;l908080r807070;l908080r807070;l908080r807070;l908080r807070;l909595r809090;l908080r807070;;;;;;;;;l908080r807070;l908080r807070;l908080r807070;l908080r807070;l908080r807070;;;;;;;;;;;;;;;;;; -gms$c22_protect_scenario;;;;none;none;none;none;none;none;BH;none;BH_IFL;BH;;;;;;;BH;;BH_IFL;BH_IFL;BH_IFL;BH_IFL;BH_IFL;;;;;;;;;;;;;;;;;; -gms$c22_protect_scenario_noselect;;;;;;;;;;;;;;;;;;;;;;none;none;BH_IFL;none;BH_IFL;;;;;;;;;;;;;;;;;; -gms$c30_bioen_water;;;;rainfed;rainfed;rainfed;rainfed;rainfed;rainfed;rainfed;all;rainfed;rainfed;;;;;;;rainfed;;;;;;;;;;;;;;;;;;;;;;;; -gms$s30_snv_shr;;;;0;0;0;0;0;0;0;0;0;0.2;;;;;;;0;;0.2;0.2;0.2;0.2;0.2;;;;;;;;;;;;;;;;;; -gms$s30_snv_shr_noselect;;;;;;;;;;;;;;;;;;;;;;0;0;0.2;0;0.2;;;;;;;;;;;;;;;;;; -gms$s30_snv_scenario_target;;;;;;;;;;;;;2030;;;;;;;;;2030;2030;2030;2030;2030;;;;;;;;;;;;;;;;;; -gms$c31_past_suit_scen;;;;ssp126;ssp245;ssp245;ssp370;ssp460;ssp585;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ssp126;ssp126;ssp245;ssp460;ssp370;ssp585 -gms$s32_aff_plantation;;;;0;0;0;0;0;0;0;1;0;0;;;;;;;0;;;;;;;;;;;;;;;;;;;;;;;; -gms$s32_aff_bii_coeff;;;;0;0;0;0;0;0;0;1;0;0;;;;;;;0;;;;;;;;;;;;;;;;;;;;;;;; -gms$s32_max_aff_area;;;;Inf;Inf;Inf;Inf;Inf;Inf;500;350;0;700;;;;;;;500;;Inf;Inf;Inf;500;500;;;;;;;;;;;;;;;;;; -gms$c32_aff_mask;;;;noboreal;noboreal;noboreal;noboreal;noboreal;noboreal;onlytropical;onlytropical;onlytropical;onlytropical;;;;;;;onlytropical;;noboreal;noboreal;noboreal;noboreal;noboreal;;;;;;;;;;;;;;;;;; -gms$c34_urban_scenario;;;;SSP1;SSP2;SSP2;SSP3;SSP4;SSP5;SSP1;SSP1;SSP2;SSP1;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;; -gms$c32_aff_policy;;;;;;;;;;;;;;none;npi;ndc;;;;;;ndc;ndc;ndc;ndc;ndc;;;;;;;;;;;;;;;;;; -gms$s32_planing_horizon;;;;50;50;50;50;50;50;50;30;50;50;;;;;;;50;;;;;;;;;;;;;;;;;;;;;;;; -gms$c35_ad_policy;;;;;;;;;;;;;;none;npi;ndc;;;;;;ndc;ndc;ndc;ndc;ndc;;;;;;;;;;;;;;;;;; -gms$c35_aolc_policy;;;;;;;;;;;;;;none;npi;ndc;;;;;;ndc;ndc;ndc;ndc;ndc;;;;;;;;;;;;;;;;;; -gms$s35_forest_damage_end;;;;2030;2050;2050;2050;2050;2030;2030;2030;2030;2030;;;;;;;2030;;2030;2030;2030;2030;2030;;;;;;;;;;;;;;;;;; -gms$s42_watdem_nonagr_scenario;;;;1;2;2;3;2;1;1;1;3;1;;;;;;;;;2;1;2;2;1;;;;;;;;;;;;;;;;;; -gms$s42_irrig_eff_scenario;;;;2;2;2;2;2;2;3;3;3;3;;;;;;;3;;3;3;3;3;3;;;;;;;;;;;;;;;;;; -gms$c42_env_flow_policy;;;;on;off;off;off;mixed;on;on;on;on;on;;;;;;;on;;on;on;on;on;on;;;;;;;;;;;;;;;;;; -gms$s42_efp_targetyear;;;;2040;2040;2040;2040;2040;2040;2040;2050;2070;2050;;;;;;;2040;;2040;2040;2040;2040;2040;;;;;;;;;;;;;;;;;; -gms$s44_target_price;;;;0;0;0;0;0;0;0;0;0;0;;;;;;;0;;;;;;;;;;;;;;;;;;;;;;;; -gms$c50_scen_neff;;;;baseeff_add3_add10_add20_max75;baseeff_add3_add5_add10_max65;baseeff_add3_add5_add10_max65;baseeff_add3_add0_add0_max55;baseeff_add3_add10_add15_max75;baseeff_add3_add5_add15_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max65;baseeff_add3_add15_add25_max75;;;;;;;baseeff_add3_add15_add25_max75;;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;;;;;;;;;;;;;;;;;; -gms$c50_scen_neff_noselect;;;;baseeff_add3_add10_add20_max75;baseeff_add3_add5_add10_max65;baseeff_add3_add5_add10_max65;baseeff_add3_add0_add0_max55;baseeff_add3_add10_add15_max75;baseeff_add3_add5_add15_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max65;baseeff_add3_add15_add25_max75;;;;;;;baseeff_add3_add15_add25_max75;;baseeff_add3_add10_add15_max75;baseeff_add3_add10_add15_max75;baseeff_add3_add10_add15_max75;baseeff_add3_add10_add15_max75;baseeff_add3_add10_add15_max75;;;;;;;;;;;;;;;;;; -gms$c55_scen_conf;;;;ssp1;ssp2;ssp2;ssp3;ssp4;ssp5;ssp1;ssp1;ssp1;ssp1;;;;;;;ssp1;;ssp1;ssp1;ssp1;ssp1;ssp1;;;;;;;;;;;;;;;;;; -gms$c55_scen_conf_noselect;;;;ssp1;ssp2;ssp2;ssp3;ssp4;ssp5;ssp1;ssp1;ssp1;ssp1;;;;;;;ssp1;;ssp4;ssp4;ssp1;ssp4;ssp1;;;;;;;;;;;;;;;;;; -gms$c56_pollutant_prices;;;;;;;;;;;;;;;;;coupling;emulator;coupling;;;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;;;;;;;;;;;;;;;;;; -gms$c56_pollutant_prices_noselect;;;;;;;;;;;;;;;;;coupling;emulator;coupling;;;R21M42-SDP-NPi;R21M42-SDP-NPi;R21M42-SDP-NPi;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;;;;;;;;;;;;;;;;;; -gms$s56_c_price_exp_aff;;;;50;50;50;50;50;50;50;30;50;50;;;;;;;50;;;;;;;;;;;;;;;;;;;;;;;; -gms$s56_buffer_aff;;;;0.2;0.2;0.2;0.2;0.2;0.2;0.2;0.5;0.2;0.3;;;;;;;0.2;;;;;;;;;;;;;;;;;;;;;;;; -gms$c56_emis_policy;;;;redd+natveg_nosoil;redd+natveg_nosoil;redd+natveg_nosoil;redd+natveg_nosoil;redd+natveg_nosoil;redd+natveg_nosoil;redd+natveg_nosoil;redd+natveg_nosoil;redd+_nosoil;all_nosoil;;;;;;;redd+natveg_nosoil;;;;;;;;;;;;;;;;;;;;;;;; -gms$s56_minimum_cprice;;;;;;;;;;;;;;0;0;18;;;;;;;;;;;;;;;;;;;;;;;;;;;; -gms$maccs;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -gms$c60_2ndgen_biodem;;;;;;;;;;;;;;;;;coupling;emulator;coupling;;;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;;;;;;;;;;;;;;;;;; -gms$c60_2ndgen_biodem_noselect;;;;;;;;;;;;;;;;;coupling;emulator;coupling;;;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;;;;;;;;;;;;;;;;;; -gms$c60_1stgen_biodem;;;;phaseout2020;const2020;const2020;const2030;const2020;phaseout2020;phaseout2020;phaseout2020;phaseout2020;phaseout2020;;;;;;;phaseout2020;;phaseout2020;phaseout2020;phaseout2020;phaseout2020;phaseout2020;;;;;;;;;;;;;;;;;; -gms$c60_biodem_level;;;;;;;;;;;;;;;;;1;0;;;;1;1;1;1;1;;;;;;;;;;;;;;;;;; -gms$c60_bioenergy_subsidy;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -gms$c60_res_2ndgenBE_dem;;;;ssp1;ssp2;ssp2;ssp3;ssp4;ssp5;sdp;ssp2;sdp;sdp;;;;;;;sdp;;ssp4;sdp;ssp4;ssp4;sdp;;;;;;;;;;;;;;;;;; -gms$c70_feed_scen;;;;ssp1;ssp2;ssp2;ssp3;ssp4;ssp5;ssp1;ssp5;ssp1;ssp1;;;;;;;ssp1;;ssp4;ssp1;ssp4;ssp4;ssp1;;;;;;;;;;;;;;;;;; -gms$c_timesteps;;;;;;;;;;;;;;;;;less_TS;less_TS;;;;5year;5year;5year;5year;5year;;;;;;;;;;;;;;;;;; -gms$c14_yields_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;; -gms$c42_watdem_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;; -gms$c43_watavail_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;; -gms$c52_carbon_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;; -gms$c59_som_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;cc;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;; -gms$s32_initial_distribution;;;;;;;;;;;;;;;;;;;;;;4;4;4;4;4;;;;;4;4;0;;;;;;;;;;; -gms$s32_hvarea;;;;;;;;;;;;;;;;;;;;;;2;2;2;2;2;;;;;2;1;0;;;;;;;;;;; -gms$s35_secdf_distribution;;;;;;;;;;;;;;;;;;;;;;2;2;2;2;2;;;;;2;2;0;;;;;;;;;;; -gms$s35_hvarea;;;;;;;;;;;;;;;;;;;;;;2;2;2;2;2;;;;;2;2;0;;;;;;;;;;; -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.85_h12_0bd54110_cellularmagpie_c200_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz;rev4.85_h12_6819938d_cellularmagpie_c200_MRI-ESM2-0-ssp126_lpjml-8e6c5eb1.tgz;rev4.85_h12_1b5c3817_cellularmagpie_c200_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz;rev4.85_h12_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;rev4.85_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz;rev4.85_h12_09a63995_cellularmagpie_c200_MRI-ESM2-0-ssp585_lpjml-8e6c5eb1.tgz -gms$c52_land_carbon_sink_rcp;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;; -gms$s58_rewetting_switch;;;;;;;;;;;;;;;;;;;;;;;;;;;0;1;0;1;;;;;;;;;;;;;; +;cc;nocc;nocc_hist;SSP1;SSP2;SSP2EU;SSP3;SSP4;SSP5;SDP;SDP-EI;SDP-RC;SDP-MC;BASE;NPI;NDC;coupling;emulator;input;Tland;eat_lancet_diet;LAMA_Inequal;LAMA_Inequal-SustDemand;LAMA_Inequal-EnvirProt;LAMA_Inequal-GHGPrice;LAMA_Sustainability;NAVIGATE_AllOff;NAVIGATE_LandSup;NAVIGATE_LandDem;NAVIGATE_AllOn;ForestryEndo;ForestryExo;ForestryOff;frst_shock_none;frst_shock_002lin2030;frst_shock_004lin2030;frst_shock_008lin2030;frst_shock_016lin2030;rcp1p9;rcp2p6;rcp4p5;rcp6p0;rcp7p0;rcp8p5;NGFS_o_lowdem +gms$c09_pop_scenario;;;;SSP1;SSP2;SSP2EU;SSP3;SSP4;SSP5;SSP1;SSP1;SSP1;SSP1;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;;; +gms$c09_gdp_scenario;;;;SSP1;SSP2;SSP2EU;SSP3;SSP4;SSP5;SSP1;SDP_EI;SDP_RC;SDP_MC;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;;; +gms$c09_pal_scenario;;;;SSP1;SSP2;SSP2EU;SSP3;SSP4;SSP5;SSP1;SSP2;SSP1;SSP1;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;;; +gms$c15_food_scenario;;;;SSP1;SSP2;SSP2;SSP3;SSP4;SSP5;SSP1;SSP2;SSP1;SSP1;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;;;SSP2 +gms$c15_food_scenario_noselect;;;;;;;;;;;;;;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;;;SSP2 +gms$s15_elastic_demand;;;;0;0;0;0;0;0;0;0;0;0;;;;;;;0;0;0;0;0;0;0;;;;;;;;;;;;;;;;;;; +gms$c15_rumdairy_scp_scen;;;;constant;constant;constant;constant;constant;constant;constant;sigmoid_50pc_20_50;constant;constant;;;;;;;constant;;;;;;;;;;;;;;;;;;;;;;;;; +gms$kfo_rd;;;;;;;;;;;livst_rum;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c15_exo_foodscen;;;;;;;;;;lin_zero_20_50;lin_zero_20_50;lin_zero_20_50;lin_zero_20_70;;;;;;;lin_zero_20_50;lin_zero_20_50;;lin_zero_20_50;;;lin_zero_20_50;;;;;;;;;;;;;;;;;;;lin_zero_20_50 +gms$s15_exo_waste;;;;0;0;0;0;0;0;1;1;1;1;;;;;;;1;0;0;1;0;0;1;0;0;1;1;;;;;;;;;;;;;;;1 +gms$s15_waste_scen;;;;;;;;;;1.2;1.3;1.2;1.25;;;;;;;1.2;1.2;;1.2;;;1.2;;;;;;;;;;;;;;;;;;;1.2 +gms$s15_exo_diet;;;;0;0;0;0;0;0;1;1;1;1;;;;;;;1;1;0;1;0;0;1;0;0;1;1;;;;;;;;;;;;;;;1 +gms$c15_kcal_scen;;;;;;;;;;healthy_BMI;no_underweight;healthy_BMI;healthy_BMI;;;;;;;healthy_BMI;healthy_BMI;;healthy_BMI;;;healthy_BMI;;;;;;;;;;;;;;;;;;;healthy_BMI +gms$c15_EAT_scen;;;;;;;;;;FLX;;FLX;FLX;;;;;;;FLX;FLX;;FLX;;;FLX;;;;;;;;;;;;;;;;;;; +gms$s15_exo_monogastric;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$s15_exo_ruminant;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$s15_exo_fish;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$s15_exo_fruitvegnut;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$s15_exo_pulses;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$s15_exo_sugar;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$s15_exo_oils;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$s15_exo_brans;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$s15_exo_scp;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$s15_exo_alcohol;;;;;;;;;;1;0;1;1;;;;;;;1;1;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$c21_trade_liberalization;;;;l908080r807070;l909090r808080;l909090r808080;l909595r809090;l908080r807070;l908080r807070;l908080r807070;l908080r807070;l909595r809090;l908080r807070;;;;;;;;;l908080r807070;l908080r807070;l908080r807070;l908080r807070;l908080r807070;;;;;;;;;;;;;;;;;;; +gms$c22_protect_scenario;;;;none;none;none;none;none;none;BH;none;BH_IFL;BH;;;;;;;BH;;BH_IFL;BH_IFL;BH_IFL;BH_IFL;BH_IFL;;;;;;;;;;;;;;;;;;; +gms$c22_protect_scenario_noselect;;;;;;;;;;;;;;;;;;;;;;none;none;BH_IFL;none;BH_IFL;;;;;;;;;;;;;;;;;;; +gms$c30_bioen_water;;;;rainfed;rainfed;rainfed;rainfed;rainfed;rainfed;rainfed;all;rainfed;rainfed;;;;;;;rainfed;;;;;;;;;;;;;;;;;;;;;;;;; +gms$s30_snv_shr;;;;0;0;0;0;0;0;0;0;0;0.2;;;;;;;0;;0.2;0.2;0.2;0.2;0.2;;;;;;;;;;;;;;;;;;; +gms$s30_snv_shr_noselect;;;;;;;;;;;;;;;;;;;;;;0;0;0.2;0;0.2;;;;;;;;;;;;;;;;;;; +gms$s30_snv_scenario_target;;;;;;;;;;;;;2030;;;;;;;;;2030;2030;2030;2030;2030;;;;;;;;;;;;;;;;;;; +gms$c31_past_suit_scen;;;;ssp126;ssp245;ssp245;ssp370;ssp460;ssp585;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ssp126;ssp126;ssp245;ssp460;ssp370;ssp585; +gms$s32_aff_plantation;;;;0;0;0;0;0;0;0;1;0;0;;;;;;;0;;;;;;;;;;;;;;;;;;;;;;;;; +gms$s32_aff_bii_coeff;;;;0;0;0;0;0;0;0;1;0;0;;;;;;;0;;;;;;;;;;;;;;;;;;;;;;;;; +gms$s32_max_aff_area;;;;Inf;Inf;Inf;Inf;Inf;Inf;500;350;0;700;;;;;;;500;;Inf;Inf;Inf;500;500;;;;;;;;;;;;;;;;;;; +gms$c32_aff_mask;;;;noboreal;noboreal;noboreal;noboreal;noboreal;noboreal;onlytropical;onlytropical;onlytropical;onlytropical;;;;;;;onlytropical;;noboreal;noboreal;noboreal;noboreal;noboreal;;;;;;;;;;;;;;;;;;; +gms$c34_urban_scenario;;;;SSP1;SSP2;SSP2;SSP3;SSP4;SSP5;SSP1;SSP1;SSP2;SSP1;;;;;;;;;SSP4;SSP1;SSP4;SSP4;SSP1;;;;;;;;;;;;;;;;;;; +gms$c32_aff_policy;;;;;;;;;;;;;;none;npi;ndc;;;;;;ndc;ndc;ndc;ndc;ndc;;;;;;;;;;;;;;;;;;; +gms$s32_planing_horizon;;;;50;50;50;50;50;50;50;30;50;50;;;;;;;50;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c35_ad_policy;;;;;;;;;;;;;;none;npi;ndc;;;;;;ndc;ndc;ndc;ndc;ndc;;;;;;;;;;;;;;;;;;; +gms$c35_aolc_policy;;;;;;;;;;;;;;none;npi;ndc;;;;;;ndc;ndc;ndc;ndc;ndc;;;;;;;;;;;;;;;;;;; +gms$s35_forest_damage_end;;;;2030;2050;2050;2050;2050;2030;2030;2030;2030;2030;;;;;;;2030;;2030;2030;2030;2030;2030;;;;;;;;;;;;;;;;;;; +gms$s42_watdem_nonagr_scenario;;;;1;2;2;3;2;1;1;1;3;1;;;;;;;;;2;1;2;2;1;;;;;;;;;;;;;;;;;;; +gms$s42_irrig_eff_scenario;;;;2;2;2;2;2;2;3;3;3;3;;;;;;;3;;3;3;3;3;3;;;;;;;;;;;;;;;;;;; +gms$c42_env_flow_policy;;;;on;off;off;off;mixed;on;on;on;on;on;;;;;;;on;;on;on;on;on;on;;;;;;;;;;;;;;;;;;; +gms$s42_efp_targetyear;;;;2040;2040;2040;2040;2040;2040;2040;2050;2070;2050;;;;;;;2040;;2040;2040;2040;2040;2040;;;;;;;;;;;;;;;;;;; +gms$s44_target_price;;;;0;0;0;0;0;0;0;0;0;0;;;;;;;0;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c50_scen_neff;;;;baseeff_add3_add10_add20_max75;baseeff_add3_add5_add10_max65;baseeff_add3_add5_add10_max65;baseeff_add3_add0_add0_max55;baseeff_add3_add10_add15_max75;baseeff_add3_add5_add15_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max65;baseeff_add3_add15_add25_max75;;;;;;;baseeff_add3_add15_add25_max75;;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;;;;;;;;;;;;;;;;;;; +gms$c50_scen_neff_noselect;;;;baseeff_add3_add10_add20_max75;baseeff_add3_add5_add10_max65;baseeff_add3_add5_add10_max65;baseeff_add3_add0_add0_max55;baseeff_add3_add10_add15_max75;baseeff_add3_add5_add15_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max75;baseeff_add3_add15_add25_max65;baseeff_add3_add15_add25_max75;;;;;;;baseeff_add3_add15_add25_max75;;baseeff_add3_add10_add15_max75;baseeff_add3_add10_add15_max75;baseeff_add3_add10_add15_max75;baseeff_add3_add10_add15_max75;baseeff_add3_add10_add15_max75;;;;;;;;;;;;;;;;;;; +gms$c55_scen_conf;;;;ssp1;ssp2;ssp2;ssp3;ssp4;ssp5;ssp1;ssp1;ssp1;ssp1;;;;;;;ssp1;;ssp1;ssp1;ssp1;ssp1;ssp1;;;;;;;;;;;;;;;;;;; +gms$c55_scen_conf_noselect;;;;ssp1;ssp2;ssp2;ssp3;ssp4;ssp5;ssp1;ssp1;ssp1;ssp1;;;;;;;ssp1;;ssp4;ssp4;ssp1;ssp4;ssp1;;;;;;;;;;;;;;;;;;; +gms$c56_pollutant_prices;;;;;;;;;;;;;;;;;coupling;emulator;coupling;;;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;;;;;;;;;;;;;;;;;;; +gms$c56_pollutant_prices_noselect;;;;;;;;;;;;;;;;;coupling;emulator;coupling;;;R21M42-SDP-NPi;R21M42-SDP-NPi;R21M42-SDP-NPi;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;;;;;;;;;;;;;;;;;;; +gms$s56_c_price_exp_aff;;;;50;50;50;50;50;50;50;30;50;50;;;;;;;50;;;;;;;;;;;;;;;;;;;;;;;;; +gms$s56_buffer_aff;;;;0.2;0.2;0.2;0.2;0.2;0.2;0.2;0.5;0.2;0.3;;;;;;;0.2;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c56_emis_policy;;;;redd+natveg_nosoil;redd+natveg_nosoil;redd+natveg_nosoil;redd+natveg_nosoil;redd+natveg_nosoil;redd+natveg_nosoil;redd+natveg_nosoil;redd+natveg_nosoil;redd+_nosoil;all_nosoil;;;;;;;redd+natveg_nosoil;;;;;;;;;;;;;;;;;;;;;;;;; +gms$s56_minimum_cprice;;;;;;;;;;;;;;0;0;18;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$maccs;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c60_2ndgen_biodem;;;;;;;;;;;;;;;;;coupling;emulator;coupling;;;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;;;;;;;;;;;;;;;;;;; +gms$c60_2ndgen_biodem_noselect;;;;;;;;;;;;;;;;;coupling;emulator;coupling;;;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;R21M42-SDP-PkBudg1000;;;;;;;;;;;;;;;;;;; +gms$c60_1stgen_biodem;;;;phaseout2020;const2020;const2020;const2030;const2020;phaseout2020;phaseout2020;phaseout2020;phaseout2020;phaseout2020;;;;;;;phaseout2020;;phaseout2020;phaseout2020;phaseout2020;phaseout2020;phaseout2020;;;;;;;;;;;;;;;;;;; +gms$c60_biodem_level;;;;;;;;;;;;;;;;;1;0;;;;1;1;1;1;1;;;;;;;;;;;;;;;;;;; +gms$c60_bioenergy_subsidy;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c60_res_2ndgenBE_dem;;;;ssp1;ssp2;ssp2;ssp3;ssp4;ssp5;sdp;ssp2;sdp;sdp;;;;;;;sdp;;ssp4;sdp;ssp4;ssp4;sdp;;;;;;;;;;;;;;;;;;; +gms$c70_feed_scen;;;;ssp1;ssp2;ssp2;ssp3;ssp4;ssp5;ssp1;ssp5;ssp1;ssp1;;;;;;;ssp1;;ssp4;ssp1;ssp4;ssp4;ssp1;;;;;;;;;;;;;;;;;;; +gms$c_timesteps;;;;;;;;;;;;;;;;;less_TS;less_TS;;;;5year;5year;5year;5year;5year;;;;;;;;;;;;;;;;;;; +gms$c14_yields_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;;; +gms$c42_watdem_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;;; +gms$c43_watavail_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;;; +gms$c52_carbon_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;;; +gms$c59_som_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;cc;;;cc;cc;cc;cc;cc;;;;;;;;;;;;;;;;;;; +gms$s32_initial_distribution;;;;;;;;;;;;;;;;;;;;;;4;4;4;4;4;;;;;4;4;0;;;;;;;;;;;; +gms$s32_hvarea;;;;;;;;;;;;;;;;;;;;;;2;2;2;2;2;;;;;2;1;0;;;;;;;;;;;; +gms$s35_secdf_distribution;;;;;;;;;;;;;;;;;;;;;;2;2;2;2;2;;;;;2;2;0;;;;;;;;;;;; +gms$s35_hvarea;;;;;;;;;;;;;;;;;;;;;;2;2;2;2;2;;;;;2;2;0;;;;;;;;;;;; +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.85_h12_0bd54110_cellularmagpie_c200_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz;rev4.85_h12_6819938d_cellularmagpie_c200_MRI-ESM2-0-ssp126_lpjml-8e6c5eb1.tgz;rev4.85_h12_1b5c3817_cellularmagpie_c200_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz;rev4.85_h12_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;rev4.85_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz;rev4.85_h12_09a63995_cellularmagpie_c200_MRI-ESM2-0-ssp585_lpjml-8e6c5eb1.tgz; +gms$c52_land_carbon_sink_rcp;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;; +gms$s58_rewetting_switch;;;;;;;;;;;;;;;;;;;;;;;;;;;0;1;0;1;;;;;;;;;;;;;;; From 74c1aa14230a024624327b83fad2b9cb8d597a7f Mon Sep 17 00:00:00 2001 From: mishkos <32301623+mishkos@users.noreply.github.com> Date: Wed, 17 May 2023 13:27:40 +0200 Subject: [PATCH 15/62] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b050bf704a..6f963a697d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **41_area_equipped_for_irrigation** new AEI data (Mehta2022) replacing old Siebert data ### added +- **scenario_config.csv** added a scenario for the NGFS project - **config** new area equipped for irrigation (AEI) data in preprocessing (4.87) ### removed From ffe8a58640a24fed71a0a22a7bf9395d1c334d29 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Fri, 19 May 2023 15:51:48 +0200 Subject: [PATCH 16/62] newest preprocessing in scenario configs --- CHANGELOG.md | 1 + config/scenario_config.csv | 2 +- config/scenario_fsec.csv | 8 ++++---- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c1c789883..9adab83002 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] ### changed +- **config** updated scenario configs to newest preprocessing (4.87) - **scripts** start_functions.R can now handle clusters per region flexibly - **41_area_equipped_for_irrigation** new AEI data (Mehta2022) replacing old Siebert data diff --git a/config/scenario_config.csv b/config/scenario_config.csv index 7a474615a0..2322881379 100644 --- a/config/scenario_config.csv +++ b/config/scenario_config.csv @@ -78,7 +78,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.85_h12_0bd54110_cellularmagpie_c200_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz;rev4.85_h12_6819938d_cellularmagpie_c200_MRI-ESM2-0-ssp126_lpjml-8e6c5eb1.tgz;rev4.85_h12_1b5c3817_cellularmagpie_c200_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz;rev4.85_h12_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;rev4.85_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz;rev4.85_h12_09a63995_cellularmagpie_c200_MRI-ESM2-0-ssp585_lpjml-8e6c5eb1.tgz; +input['cellular'];;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;rev4.87_h12_0bd54110_cellularmagpie_c200_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz;rev4.87_h12_6819938d_cellularmagpie_c200_MRI-ESM2-0-ssp126_lpjml-8e6c5eb1.tgz;rev4.87_h12_1b5c3817_cellularmagpie_c200_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz;rev4.87_h12_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;rev4.87_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz;rev4.87_h12_09a63995_cellularmagpie_c200_MRI-ESM2-0-ssp585_lpjml-8e6c5eb1.tgz; gms$c52_land_carbon_sink_rcp;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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_fsec.csv b/config/scenario_fsec.csv index bacf5d1ae8..5210788d95 100644 --- a/config/scenario_fsec.csv +++ b/config/scenario_fsec.csv @@ -65,9 +65,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.84_FSEC_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;rev4.84_FSEC_0bd54110_cellularmagpie_c200_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz;rev4.84_FSEC_6819938d_cellularmagpie_c200_MRI-ESM2-0-ssp126_lpjml-8e6c5eb1.tgz;;rev4.84_FSEC_1b5c3817_cellularmagpie_c200_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz;rev4.84_FSEC_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;rev4.84_FSEC_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz;rev4.84_FSEC_09a63995_cellularmagpie_c200_MRI-ESM2-0-ssp585_lpjml-8e6c5eb1.tgz; -input['regional'];rev4.84_FSEC_magpie.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -input['validation'];rev4.86_FSEC_validation.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -input['additional'];additional_data_rev4.37.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +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['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 From 03e81cdb0ca53e0f2ea0de8dde4fc10d8e39bed7 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Fri, 19 May 2023 15:52:29 +0200 Subject: [PATCH 17/62] updated changelog --- CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9adab83002..468085734d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] ### changed -- **config** updated scenario configs to newest preprocessing (4.87) - **scripts** start_functions.R can now handle clusters per region flexibly - **41_area_equipped_for_irrigation** new AEI data (Mehta2022) replacing old Siebert data @@ -20,7 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - ### fixed -- +- **config** updated scenario configs to newest preprocessing (4.87) ## [4.6.7] - 2023-05-10 From cc34387dc1384f7e054b450d4f073ead13f6c876 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20F=C3=BChrlich?= Date: Tue, 30 May 2023 14:30:53 +0200 Subject: [PATCH 18/62] renv coupling 2.0 --- config/default.cfg | 2 ++ scripts/start_functions.R | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index e55b5b8c50..5944e2bc4c 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -1923,4 +1923,6 @@ cfg$developer_mode <- FALSE # wrong cfg$debug <- FALSE +cfg$coupling_renv_lock <- NULL + ################################################################################ diff --git a/scripts/start_functions.R b/scripts/start_functions.R index 83a4423ced..e0ca05b45c 100644 --- a/scripts/start_functions.R +++ b/scripts/start_functions.R @@ -273,7 +273,12 @@ start_run <- function(cfg, scenario = NULL, codeCheck = TRUE, lock_model = TRUE) message("No active renv project found, not using renv.") } else { # this script always runs in repo root, so we can check whether the main renv is loaded with: - if (normalizePath(renv::project()) == normalizePath(".")) { + if (!is.null(cfg$coupling_renv_lock)) { + # coupling renv.lock is set, we are presumably running remind magpie coupling + message("Copying lockfile '", normalizePath(cfg$coupling_renv_lock, mustWork = TRUE), + "' into '", cfg$results_folder, "'") + file.copy(cfg$coupling_renv_lock, file.path(cfg$results_folder, "_renv.lock")) + } else if (normalizePath(renv::project()) == normalizePath(".")) { message("Generating lockfile in '", cfg$results_folder, "'... ", appendLF = FALSE) # suppress output of renv::snapshot utils::capture.output({ @@ -512,7 +517,7 @@ start_run <- function(cfg, scenario = NULL, codeCheck = TRUE, lock_model = TRUE) if(is.na(cfg$sequential)) cfg$sequential <- !slurm - if(slurm & !cfg$sequential) { + if(slurm && !cfg$sequential) { if(is.null(cfg$qos)) { # try to select best QOS based on available resources # and available information From 5b997d42c63b8aac48cf4ba29c70114a214f7b90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20F=C3=BChrlich?= Date: Wed, 31 May 2023 16:01:36 +0200 Subject: [PATCH 19/62] changelog coupling renv --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 468085734d..c5201548d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### changed - **scripts** start_functions.R can now handle clusters per region flexibly +- **scripts** the REMIND-MAgPIE coupling now uses renv - **41_area_equipped_for_irrigation** new AEI data (Mehta2022) replacing old Siebert data ### added From 7c91d1eb7536a5d630fa3fd16ed7f97f117f9561 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20F=C3=BChrlich?= Date: Mon, 5 Jun 2023 10:07:26 +0200 Subject: [PATCH 20/62] config comment --- config/default.cfg | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index 5944e2bc4c..3b7888bb80 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -1895,6 +1895,11 @@ cfg$files2export$start <- c("input/info.txt", # Files that should be copied after the MAgPIE run is finished cfg$files2export$end <- NULL +# Path to a renv.lock file defining the package environment for newly started +# runs. Will automatically be set when running the REMIND MAgPIE coupling, +# should generally not be set manually. +cfg$coupling_renv_lock <- NULL + # Folder run statistics should be submitted to cfg$runstatistics <- "/p/projects/rd3mod/models/statistics/magpie" @@ -1923,6 +1928,4 @@ cfg$developer_mode <- FALSE # wrong cfg$debug <- FALSE -cfg$coupling_renv_lock <- NULL - ################################################################################ From ff5b6cb12c8e416d4a45c001950eefd6d8f3d3da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20F=C3=BChrlich?= Date: Mon, 5 Jun 2023 11:02:41 +0200 Subject: [PATCH 21/62] rename coupling_renv_lock to renv_lock --- config/default.cfg | 7 +++---- scripts/start_functions.R | 13 ++++++------- start.R | 3 ++- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index 3b7888bb80..7ba869a8f7 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -1895,10 +1895,9 @@ cfg$files2export$start <- c("input/info.txt", # Files that should be copied after the MAgPIE run is finished cfg$files2export$end <- NULL -# Path to a renv.lock file defining the package environment for newly started -# runs. Will automatically be set when running the REMIND MAgPIE coupling, -# should generally not be set manually. -cfg$coupling_renv_lock <- NULL +# Expert use only, should not be set manually. Path to a renv.lock file +# defining the package environment for newly started runs. +cfg$renv_lock <- NULL # Folder run statistics should be submitted to cfg$runstatistics <- "/p/projects/rd3mod/models/statistics/magpie" diff --git a/scripts/start_functions.R b/scripts/start_functions.R index e0ca05b45c..1b940ccf62 100644 --- a/scripts/start_functions.R +++ b/scripts/start_functions.R @@ -272,13 +272,12 @@ start_run <- function(cfg, scenario = NULL, codeCheck = TRUE, lock_model = TRUE) if (is.null(renv::project())) { message("No active renv project found, not using renv.") } else { - # this script always runs in repo root, so we can check whether the main renv is loaded with: - if (!is.null(cfg$coupling_renv_lock)) { - # coupling renv.lock is set, we are presumably running remind magpie coupling - message("Copying lockfile '", normalizePath(cfg$coupling_renv_lock, mustWork = TRUE), - "' into '", cfg$results_folder, "'") - file.copy(cfg$coupling_renv_lock, file.path(cfg$results_folder, "_renv.lock")) + if (!is.null(cfg$renv_lock)) { + message("Copying cfg$renv_lock (= '", normalizePath(cfg$renv_lock, mustWork = TRUE), "') into '", + cfg$results_folder, "'") + file.copy(cfg$renv_lock, file.path(cfg$results_folder, "_renv.lock")) } else if (normalizePath(renv::project()) == normalizePath(".")) { + # the main renv is loaded message("Generating lockfile in '", cfg$results_folder, "'... ", appendLF = FALSE) # suppress output of renv::snapshot utils::capture.output({ @@ -295,7 +294,7 @@ start_run <- function(cfg, scenario = NULL, codeCheck = TRUE, lock_model = TRUE) } message("done.") } else { - # a run renv is loaded, we are presumably starting a HR follow up run + # a run renv is loaded message("Copying lockfile into '", cfg$results_folder, "'") file.copy(renv::paths$lockfile(), file.path(cfg$results_folder, "_renv.lock")) } diff --git a/start.R b/start.R index 9ca78a4cae..121986e4e7 100644 --- a/start.R +++ b/start.R @@ -129,6 +129,7 @@ runOutputs <- function(runscripts=NULL, submit=NULL) { system("git config core.hooksPath .githooks") -runscripts <- submit <- NULL +submit <- NULL +runscripts <- NULL lucode2::readArgs("runscripts","submit", .silent=TRUE) runOutputs(runscripts=runscripts, submit=submit) From cbd4e420953eda9c6cf46f3a9bd0d40aa1628eed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20F=C3=BChrlich?= Date: Wed, 7 Jun 2023 16:10:35 +0200 Subject: [PATCH 22/62] show renv snapshot errors --- output.R | 6 +++--- scripts/start_functions.R | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/output.R b/output.R index 32c737b2db..a3c9395412 100644 --- a/output.R +++ b/output.R @@ -197,8 +197,8 @@ runOutputs <- function(comp=NULL, output=NULL, outputdir=NULL, submit=NULL) { freshLockfile <- withr::local_tempfile() message("Generating lockfile... ", appendLF = FALSE) - utils::capture.output({ - errorMessage <- utils::capture.output({ + errorMessage1 <- utils::capture.output({ + errorMessage2 <- utils::capture.output({ snapshotSuccess <- tryCatch({ renv::snapshot(lockfile = freshLockfile, prompt = FALSE) TRUE @@ -206,7 +206,7 @@ runOutputs <- function(comp=NULL, output=NULL, outputdir=NULL, submit=NULL) { }, type = "message") }) if (!snapshotSuccess) { - stop(paste(errorMessage, collapse = "\n")) + stop(paste(errorMessage1, collapse = "\n"), paste(errorMessage2, collapse = "\n")) } message("done.") diff --git a/scripts/start_functions.R b/scripts/start_functions.R index 1b940ccf62..25de9122b7 100644 --- a/scripts/start_functions.R +++ b/scripts/start_functions.R @@ -280,8 +280,8 @@ start_run <- function(cfg, scenario = NULL, codeCheck = TRUE, lock_model = TRUE) # the main renv is loaded message("Generating lockfile in '", cfg$results_folder, "'... ", appendLF = FALSE) # suppress output of renv::snapshot - utils::capture.output({ - errorMessage <- utils::capture.output({ + errorMessage1 <- utils::capture.output({ + errorMessage2 <- utils::capture.output({ snapshotSuccess <- tryCatch({ # snapshot current main renv into run folder renv::snapshot(lockfile = file.path(cfg$results_folder, "_renv.lock"), prompt = FALSE) @@ -290,7 +290,7 @@ start_run <- function(cfg, scenario = NULL, codeCheck = TRUE, lock_model = TRUE) }, type = "message") }) if (!snapshotSuccess) { - stop(paste(errorMessage, collapse = "\n")) + stop(paste(errorMessage1, collapse = "\n"), paste(errorMessage2, collapse = "\n")) } message("done.") } else { From c61c9374f45bfb4200bfeabefb62f0f57b041fed Mon Sep 17 00:00:00 2001 From: florianh Date: Wed, 7 Jun 2023 18:11:03 +0200 Subject: [PATCH 23/62] added `nocc` and `nocc_hist` option --- CHANGELOG.md | 2 ++ config/default.cfg | 6 +++++- config/scenario_config.csv | 4 ++-- core/sets.gms | 4 ++-- main.gms | 14 +++++++------- modules/31_past/grasslands_apr22/preloop.gms | 12 ++++++++++-- modules/52_carbon/normal_dec17/input.gms | 9 ++++++++- 7 files changed, 36 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c5201548d1..57d1920f15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### added - **scenario_config.csv** added a scenario for the NGFS project - **config** new area equipped for irrigation (AEI) data in preprocessing (4.87) +- **31_past** added `nocc` and `nocc_hist` option +- **32_carbon** added `nocc` and `nocc_hist` option ### removed - diff --git a/config/default.cfg b/config/default.cfg index 7ba869a8f7..c0dfb0e317 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -696,6 +696,8 @@ cfg$gms$s31_unequal <- 1 # def = 1 # * 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_hist (ssp245 until year defined in sm_fix_cc, fixed thereafter) cfg$gms$c31_past_suit_scen <- "ssp370" # def = "ssp370" # * Switch that allows selecting how yield calibration factors will be calculated. @@ -1272,7 +1274,9 @@ 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 +# * 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" diff --git a/config/scenario_config.csv b/config/scenario_config.csv index 2322881379..5f25674b6f 100644 --- a/config/scenario_config.csv +++ b/config/scenario_config.csv @@ -30,7 +30,7 @@ gms$c30_bioen_water;;;;rainfed;rainfed;rainfed;rainfed;rainfed;rainfed;rainfed;a gms$s30_snv_shr;;;;0;0;0;0;0;0;0;0;0;0.2;;;;;;;0;;0.2;0.2;0.2;0.2;0.2;;;;;;;;;;;;;;;;;;; gms$s30_snv_shr_noselect;;;;;;;;;;;;;;;;;;;;;;0;0;0.2;0;0.2;;;;;;;;;;;;;;;;;;; gms$s30_snv_scenario_target;;;;;;;;;;;;;2030;;;;;;;;;2030;2030;2030;2030;2030;;;;;;;;;;;;;;;;;;; -gms$c31_past_suit_scen;;;;ssp126;ssp245;ssp245;ssp370;ssp460;ssp585;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ssp126;ssp126;ssp245;ssp460;ssp370;ssp585; +gms$c31_past_suit_scen;;nocc;nocc_hist;ssp126;ssp245;ssp245;ssp370;ssp460;ssp585;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ssp126;ssp126;ssp245;ssp460;ssp370;ssp585; gms$s32_aff_plantation;;;;0;0;0;0;0;0;0;1;0;0;;;;;;;0;;;;;;;;;;;;;;;;;;;;;;;;; gms$s32_aff_bii_coeff;;;;0;0;0;0;0;0;0;1;0;0;;;;;;;0;;;;;;;;;;;;;;;;;;;;;;;;; gms$s32_max_aff_area;;;;Inf;Inf;Inf;Inf;Inf;Inf;500;350;0;700;;;;;;;500;;Inf;Inf;Inf;500;500;;;;;;;;;;;;;;;;;;; @@ -79,7 +79,7 @@ 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.87_h12_0bd54110_cellularmagpie_c200_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz;rev4.87_h12_6819938d_cellularmagpie_c200_MRI-ESM2-0-ssp126_lpjml-8e6c5eb1.tgz;rev4.87_h12_1b5c3817_cellularmagpie_c200_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz;rev4.87_h12_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;rev4.87_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz;rev4.87_h12_09a63995_cellularmagpie_c200_MRI-ESM2-0-ssp585_lpjml-8e6c5eb1.tgz; -gms$c52_land_carbon_sink_rcp;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;RCP19;RCP26;RCP45;RCP60;RCPBU;RCPBU; +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;;;;;;;;;;;;;;; gms$s58_rewetting_switch;;;;;;;;;;;;;;;;;;;;;;;;;;;0;1;0;1;;;;;;;;;;;;;;; diff --git a/core/sets.gms b/core/sets.gms index 13be12ee50..844ea9e52f 100644 --- a/core/sets.gms +++ b/core/sets.gms @@ -59,7 +59,7 @@ sets CHA_7*CHA_23, EUR_24*EUR_32, IND_33*IND_40, - JPN_41, + JPN_41*JPN_41, LAM_42*LAM_85, MEA_86*MEA_111, NEU_112*NEU_118, @@ -73,7 +73,7 @@ sets CHA . (CHA_7*CHA_23) EUR . (EUR_24*EUR_32) IND . (IND_33*IND_40) - JPN . (JPN_41) + JPN . (JPN_41*JPN_41) LAM . (LAM_42*LAM_85) MEA . (MEA_86*MEA_111) NEU . (NEU_112*NEU_118) diff --git a/main.gms b/main.gms index d64f7ecb03..704fef5fb2 100644 --- a/main.gms +++ b/main.gms @@ -148,21 +148,21 @@ $title magpie *##################### R SECTION START (VERSION INFO) ########################## * -* Used data set: rev4.85_h12_magpie.tgz +* Used data set: rev4.87_h12_magpie.tgz * md5sum: NA * Repository: scp://cluster.pik-potsdam.de/p/projects/rd3mod/inputdata/output * -* Used data set: rev4.85_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz +* Used data set: rev4.87_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz * md5sum: NA * Repository: scp://cluster.pik-potsdam.de/p/projects/rd3mod/inputdata/output * -* Used data set: rev4.85_h12_validation.tgz +* Used data set: rev4.87_h12_validation.tgz * md5sum: NA * Repository: scp://cluster.pik-potsdam.de/p/projects/rd3mod/inputdata/output * * Used data set: additional_data_rev4.43.tgz * md5sum: NA -* Repository: scp://cluster.pik-potsdam.de/p/projects/landuse/data/input/archive +* Repository: https://rse.pik-potsdam.de/data/magpie/public * * Used data set: calibration_H12_per_ton_fao_may22_glo_23Mar23.tgz * md5sum: NA @@ -179,11 +179,11 @@ $title magpie * * Regionscode: 62eff8f7 * -* Regions data revision: 4.85 +* Regions data revision: 4.87 * * lpj2magpie settings: * * LPJmL data: MRI-ESM2-0:ssp370 -* * Revision: 4.85 +* * Revision: 4.87 * * 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): Fri Apr 28 16:30:54 2023 +* Last modification (input data): Wed Jun 7 17:53:26 2023 * *###################### R SECTION END (VERSION INFO) ########################### diff --git a/modules/31_past/grasslands_apr22/preloop.gms b/modules/31_past/grasslands_apr22/preloop.gms index 3b480a8f1b..e5d9f8d4ad 100644 --- a/modules/31_past/grasslands_apr22/preloop.gms +++ b/modules/31_past/grasslands_apr22/preloop.gms @@ -5,8 +5,16 @@ *** | MAgPIE License Exception, version 1.0 (see LICENSE file). *** | Contact: magpie@pik-potsdam.de -i31_manpast_suit(t_all,j) = f31_pastr_suitability(t_all,j,"%c31_past_suit_scen%"); -i31_manpast_suit(t_all,j)$(m_year(t_all) <= sm_fix_SSP2) = f31_pastr_suitability(t_all,j,"ssp245"); +$ifthen "%c31_past_suit_scen%" == "nocc" + i31_manpast_suit(t_all,j) = f31_pastr_suitability("y1995",j,"ssp245"); +$elseif "%c31_past_suit_scen%" == "nocc_hist" + i31_manpast_suit(t_all,j) = f31_pastr_suitability(t_all,j,"ssp245"); + i31_manpast_suit(t_all,j)$(m_year(t_all) > sm_fix_cc) = f31_pastr_suitability(t_all,j,"ssp245")$(m_year(t_all) = sm_fix_cc); +$else + i31_manpast_suit(t_all,j) = f31_pastr_suitability(t_all,j,"%c31_past_suit_scen%"); + i31_manpast_suit(t_all,j)$(m_year(t_all) <= sm_fix_SSP2) = f31_pastr_suitability(t_all,j,"ssp245"); +$endif + pc31_grass(j,grassland) = f31_LUH2v2("y1995",j,grassland); diff --git a/modules/52_carbon/normal_dec17/input.gms b/modules/52_carbon/normal_dec17/input.gms index 93016aeee8..2e47b1b8f3 100644 --- a/modules/52_carbon/normal_dec17/input.gms +++ b/modules/52_carbon/normal_dec17/input.gms @@ -48,4 +48,11 @@ $offdelim ; $offEmpty -i52_land_carbon_sink(t_all,i) = f52_land_carbon_sink(t_all,i,"%c52_land_carbon_sink_rcp%"); +$ifthen "%c52_land_carbon_sink_rcp%" == "nocc" + i52_land_carbon_sink(t_all,i) = f52_land_carbon_sink("y1995",i,"RCPBU"); +$elseif "%c52_land_carbon_sink_rcp%" == "nocc_hist" + i52_land_carbon_sink(t_all,i) = f52_land_carbon_sink(t_all,i,"RCPBU"); + i52_land_carbon_sink(t_all,i)$(m_year(t_all) > sm_fix_cc) = f52_land_carbon_sink(t_all,i,"RCPBU")$(m_year(t_all) = sm_fix_cc); +$else + i52_land_carbon_sink(t_all,i) = f52_land_carbon_sink(t_all,i,"%c52_land_carbon_sink_rcp%"); +$endif From a6bf308a46b1884cb9b86934283a59b0278ac05b Mon Sep 17 00:00:00 2001 From: florianh Date: Wed, 7 Jun 2023 18:23:09 +0200 Subject: [PATCH 24/62] replace tabs with space --- modules/31_past/grasslands_apr22/preloop.gms | 10 +++++----- modules/52_carbon/normal_dec17/input.gms | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/modules/31_past/grasslands_apr22/preloop.gms b/modules/31_past/grasslands_apr22/preloop.gms index e5d9f8d4ad..41cfe597ab 100644 --- a/modules/31_past/grasslands_apr22/preloop.gms +++ b/modules/31_past/grasslands_apr22/preloop.gms @@ -6,13 +6,13 @@ *** | Contact: magpie@pik-potsdam.de $ifthen "%c31_past_suit_scen%" == "nocc" - i31_manpast_suit(t_all,j) = f31_pastr_suitability("y1995",j,"ssp245"); + i31_manpast_suit(t_all,j) = f31_pastr_suitability("y1995",j,"ssp245"); $elseif "%c31_past_suit_scen%" == "nocc_hist" - i31_manpast_suit(t_all,j) = f31_pastr_suitability(t_all,j,"ssp245"); - i31_manpast_suit(t_all,j)$(m_year(t_all) > sm_fix_cc) = f31_pastr_suitability(t_all,j,"ssp245")$(m_year(t_all) = sm_fix_cc); + i31_manpast_suit(t_all,j) = f31_pastr_suitability(t_all,j,"ssp245"); + i31_manpast_suit(t_all,j)$(m_year(t_all) > sm_fix_cc) = f31_pastr_suitability(t_all,j,"ssp245")$(m_year(t_all) = sm_fix_cc); $else - i31_manpast_suit(t_all,j) = f31_pastr_suitability(t_all,j,"%c31_past_suit_scen%"); - i31_manpast_suit(t_all,j)$(m_year(t_all) <= sm_fix_SSP2) = f31_pastr_suitability(t_all,j,"ssp245"); + i31_manpast_suit(t_all,j) = f31_pastr_suitability(t_all,j,"%c31_past_suit_scen%"); + i31_manpast_suit(t_all,j)$(m_year(t_all) <= sm_fix_SSP2) = f31_pastr_suitability(t_all,j,"ssp245"); $endif pc31_grass(j,grassland) = f31_LUH2v2("y1995",j,grassland); diff --git a/modules/52_carbon/normal_dec17/input.gms b/modules/52_carbon/normal_dec17/input.gms index 2e47b1b8f3..7f4e01d52c 100644 --- a/modules/52_carbon/normal_dec17/input.gms +++ b/modules/52_carbon/normal_dec17/input.gms @@ -49,10 +49,10 @@ $offdelim $offEmpty $ifthen "%c52_land_carbon_sink_rcp%" == "nocc" - i52_land_carbon_sink(t_all,i) = f52_land_carbon_sink("y1995",i,"RCPBU"); + i52_land_carbon_sink(t_all,i) = f52_land_carbon_sink("y1995",i,"RCPBU"); $elseif "%c52_land_carbon_sink_rcp%" == "nocc_hist" - i52_land_carbon_sink(t_all,i) = f52_land_carbon_sink(t_all,i,"RCPBU"); - i52_land_carbon_sink(t_all,i)$(m_year(t_all) > sm_fix_cc) = f52_land_carbon_sink(t_all,i,"RCPBU")$(m_year(t_all) = sm_fix_cc); + i52_land_carbon_sink(t_all,i) = f52_land_carbon_sink(t_all,i,"RCPBU"); + i52_land_carbon_sink(t_all,i)$(m_year(t_all) > sm_fix_cc) = f52_land_carbon_sink(t_all,i,"RCPBU")$(m_year(t_all) = sm_fix_cc); $else - i52_land_carbon_sink(t_all,i) = f52_land_carbon_sink(t_all,i,"%c52_land_carbon_sink_rcp%"); + i52_land_carbon_sink(t_all,i) = f52_land_carbon_sink(t_all,i,"%c52_land_carbon_sink_rcp%"); $endif From c1c095a881207b483efc6604a6ec5e921dc1e916 Mon Sep 17 00:00:00 2001 From: florianh Date: Wed, 7 Jun 2023 18:34:19 +0200 Subject: [PATCH 25/62] replace tabs with space 2 --- config/default.cfg | 8 ++++---- modules/31_past/grasslands_apr22/preloop.gms | 10 +++++----- modules/52_carbon/normal_dec17/input.gms | 8 ++++---- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index c0dfb0e317..1c6722c520 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -696,8 +696,8 @@ cfg$gms$s31_unequal <- 1 # def = 1 # * 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_hist (ssp245 until year defined in sm_fix_cc, fixed thereafter) +# * 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" # * Switch that allows selecting how yield calibration factors will be calculated. @@ -1275,8 +1275,8 @@ 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), -# * nocc_hist (RCPBU until year defined in sm_fix_cc, fixed thereafter) +# * 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" diff --git a/modules/31_past/grasslands_apr22/preloop.gms b/modules/31_past/grasslands_apr22/preloop.gms index 41cfe597ab..5b48e2cfc5 100644 --- a/modules/31_past/grasslands_apr22/preloop.gms +++ b/modules/31_past/grasslands_apr22/preloop.gms @@ -6,13 +6,13 @@ *** | Contact: magpie@pik-potsdam.de $ifthen "%c31_past_suit_scen%" == "nocc" - i31_manpast_suit(t_all,j) = f31_pastr_suitability("y1995",j,"ssp245"); + i31_manpast_suit(t_all,j) = f31_pastr_suitability("y1995",j,"ssp245"); $elseif "%c31_past_suit_scen%" == "nocc_hist" - i31_manpast_suit(t_all,j) = f31_pastr_suitability(t_all,j,"ssp245"); - i31_manpast_suit(t_all,j)$(m_year(t_all) > sm_fix_cc) = f31_pastr_suitability(t_all,j,"ssp245")$(m_year(t_all) = sm_fix_cc); + i31_manpast_suit(t_all,j) = f31_pastr_suitability(t_all,j,"ssp245"); + i31_manpast_suit(t_all,j)$(m_year(t_all) > sm_fix_cc) = f31_pastr_suitability(t_all,j,"ssp245")$(m_year(t_all) = sm_fix_cc); $else - i31_manpast_suit(t_all,j) = f31_pastr_suitability(t_all,j,"%c31_past_suit_scen%"); - i31_manpast_suit(t_all,j)$(m_year(t_all) <= sm_fix_SSP2) = f31_pastr_suitability(t_all,j,"ssp245"); + i31_manpast_suit(t_all,j) = f31_pastr_suitability(t_all,j,"%c31_past_suit_scen%"); + i31_manpast_suit(t_all,j)$(m_year(t_all) <= sm_fix_SSP2) = f31_pastr_suitability(t_all,j,"ssp245"); $endif pc31_grass(j,grassland) = f31_LUH2v2("y1995",j,grassland); diff --git a/modules/52_carbon/normal_dec17/input.gms b/modules/52_carbon/normal_dec17/input.gms index 7f4e01d52c..f9e9d2f35d 100644 --- a/modules/52_carbon/normal_dec17/input.gms +++ b/modules/52_carbon/normal_dec17/input.gms @@ -49,10 +49,10 @@ $offdelim $offEmpty $ifthen "%c52_land_carbon_sink_rcp%" == "nocc" - i52_land_carbon_sink(t_all,i) = f52_land_carbon_sink("y1995",i,"RCPBU"); + i52_land_carbon_sink(t_all,i) = f52_land_carbon_sink("y1995",i,"RCPBU"); $elseif "%c52_land_carbon_sink_rcp%" == "nocc_hist" - i52_land_carbon_sink(t_all,i) = f52_land_carbon_sink(t_all,i,"RCPBU"); - i52_land_carbon_sink(t_all,i)$(m_year(t_all) > sm_fix_cc) = f52_land_carbon_sink(t_all,i,"RCPBU")$(m_year(t_all) = sm_fix_cc); + i52_land_carbon_sink(t_all,i) = f52_land_carbon_sink(t_all,i,"RCPBU"); + i52_land_carbon_sink(t_all,i)$(m_year(t_all) > sm_fix_cc) = f52_land_carbon_sink(t_all,i,"RCPBU")$(m_year(t_all) = sm_fix_cc); $else - i52_land_carbon_sink(t_all,i) = f52_land_carbon_sink(t_all,i,"%c52_land_carbon_sink_rcp%"); + i52_land_carbon_sink(t_all,i) = f52_land_carbon_sink(t_all,i,"%c52_land_carbon_sink_rcp%"); $endif From a9e9f9a6728c5759c7027b73ae2ee1b9e7f29e39 Mon Sep 17 00:00:00 2001 From: florianh Date: Wed, 7 Jun 2023 19:00:04 +0200 Subject: [PATCH 26/62] not used fix --- modules/31_past/endo_jun13/not_used.txt | 1 + modules/31_past/static/not_used.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/modules/31_past/endo_jun13/not_used.txt b/modules/31_past/endo_jun13/not_used.txt index 18bfcce33c..e695835bae 100644 --- a/modules/31_past/endo_jun13/not_used.txt +++ b/modules/31_past/endo_jun13/not_used.txt @@ -3,3 +3,4 @@ pcm_land, input, not needed vm_tau,input,questionnaire fm_pastr_tau_hist,input,questionnaire sm_fix_SSP2, input, not needed +sm_fix_cc, input, not needed diff --git a/modules/31_past/static/not_used.txt b/modules/31_past/static/not_used.txt index 637a12d740..57f7b20c03 100644 --- a/modules/31_past/static/not_used.txt +++ b/modules/31_past/static/not_used.txt @@ -5,3 +5,4 @@ pm_land_conservation,input,questionnaire vm_tau,input,questionnaire fm_pastr_tau_hist,input,questionnaire sm_fix_SSP2, input, not needed +sm_fix_cc, input, not needed From 21bf27b235010cec3d0e3fb6d8ad2dd5b809f749 Mon Sep 17 00:00:00 2001 From: florianh Date: Thu, 8 Jun 2023 13:03:07 +0200 Subject: [PATCH 27/62] bugfix peatland cost parameters --- CHANGELOG.md | 1 + config/default.cfg | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 57d1920f15..1b8a02052c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### fixed - **config** updated scenario configs to newest preprocessing (4.87) +- **config** corrected wrong names of parameters for peatland costs ## [4.6.7] - 2023-05-10 diff --git a/config/default.cfg b/config/default.cfg index 1c6722c520..edb4dca621 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -1518,8 +1518,8 @@ cfg$gms$peatland <- "on" # def = on cfg$gms$s58_rewetting_switch <- Inf # def = Inf # * One-time and recurring costs for peatland rewetting (USD05MER per ha) -cfg$gms$s58_rewet_cost_onetime <- 7000 # def = 7000 -cfg$gms$s58_rewet_cost_recur <- 200 # def = 200 +cfg$gms$s58_cost_rewet_onetime <- 7000 # def = 7000 +cfg$gms$s58_cost_rewet_recur <- 200 # def = 200 # * One-time and recurring costs for peatland degradation (USD05MER per ha) # * Can be used to test area-based incentives for peatland protection and restoration, @@ -1528,8 +1528,8 @@ cfg$gms$s58_rewet_cost_recur <- 200 # def = 200 # * Therefore, one-time costs can used to incentivize the protection of intact peatlands. # * Recurring costs apply on the level of degraded peatland. Therefore, recurring costs, # * in combination with one-time costs, can be used to incentivize peatland restoration. -cfg$gms$s58_degrad_cost_onetime <- 0 # def = 0 -cfg$gms$s58_degrad_cost_recur <- 0 # def = 0 +cfg$gms$s58_cost_degrad_onetime <- 0 # def = 0 +cfg$gms$s58_cost_degrad_recur <- 0 # def = 0 # * Artificial cost for balance variables (USD05MER per ha) # * The balance variables in the peatland module avoid infeasibilities due to From 3e52c8c5dea4fe7e5a8ea88f244df221535751ee Mon Sep 17 00:00:00 2001 From: florianh Date: Mon, 12 Jun 2023 10:44:37 +0200 Subject: [PATCH 28/62] added `cc`, `nocc` and `nocc_hist` options for `c31_grassl_yld_scenario` --- CHANGELOG.md | 4 ++-- config/default.cfg | 7 +++++++ config/scenario_config.csv | 1 + modules/31_past/grasslands_apr22/input.gms | 10 +++++++++- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b8a02052c..1874ca251a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,8 +15,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### added - **scenario_config.csv** added a scenario for the NGFS project - **config** new area equipped for irrigation (AEI) data in preprocessing (4.87) -- **31_past** added `nocc` and `nocc_hist` option -- **32_carbon** added `nocc` and `nocc_hist` option +- **31_past** added `cc`, `nocc` and `nocc_hist` options for `c31_past_suit_scen` and `c31_grassl_yld_scenario` +- **32_carbon** added `nocc` and `nocc_hist` option for `c52_land_carbon_sink_rcp` ### removed - diff --git a/config/default.cfg b/config/default.cfg index edb4dca621..c3dc525c32 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -694,6 +694,13 @@ cfg$gms$s31_fac_req_past <- 1 # def = 1 # * reflecting that not all pasture area is grazed. cfg$gms$s31_unequal <- 1 # def = 1 +# * Scenario for grassland and pasture yields (only take effect for realization grasslands_apr22) +# * options: cc (climate change) +# * nocc (no climate change) +# * nocc_hist (no climate change after year defined by sm_fix_cc) +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), diff --git a/config/scenario_config.csv b/config/scenario_config.csv index 5f25674b6f..c1a5b1695b 100644 --- a/config/scenario_config.csv +++ b/config/scenario_config.csv @@ -31,6 +31,7 @@ gms$s30_snv_shr;;;;0;0;0;0;0;0;0;0;0;0.2;;;;;;;0;;0.2;0.2;0.2;0.2;0.2;;;;;;;;;;; gms$s30_snv_shr_noselect;;;;;;;;;;;;;;;;;;;;;;0;0;0.2;0;0.2;;;;;;;;;;;;;;;;;;; gms$s30_snv_scenario_target;;;;;;;;;;;;;2030;;;;;;;;;2030;2030;2030;2030;2030;;;;;;;;;;;;;;;;;;; gms$c31_past_suit_scen;;nocc;nocc_hist;ssp126;ssp245;ssp245;ssp370;ssp460;ssp585;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ssp126;ssp126;ssp245;ssp460;ssp370;ssp585; +gms$c31_grassl_yld_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$s32_aff_plantation;;;;0;0;0;0;0;0;0;1;0;0;;;;;;;0;;;;;;;;;;;;;;;;;;;;;;;;; gms$s32_aff_bii_coeff;;;;0;0;0;0;0;0;0;1;0;0;;;;;;;0;;;;;;;;;;;;;;;;;;;;;;;;; gms$s32_max_aff_area;;;;Inf;Inf;Inf;Inf;Inf;Inf;500;350;0;700;;;;;;;500;;Inf;Inf;Inf;500;500;;;;;;;;;;;;;;;;;;; diff --git a/modules/31_past/grasslands_apr22/input.gms b/modules/31_past/grasslands_apr22/input.gms index 03a32fcd1c..0896afc475 100644 --- a/modules/31_past/grasslands_apr22/input.gms +++ b/modules/31_past/grasslands_apr22/input.gms @@ -16,7 +16,6 @@ $setglobal c31_past_suit_scen ssp370 table f31_pastr_suitability(t_all,j,ssp_past) Areas suitable for pasture management (mio. ha) $ondelim $include "./modules/31_past/input/f31_pastr_suitability.cs3" - $offdelim ; @@ -28,11 +27,20 @@ $offdelim scalar s31_limit_calib Relative managament calibration switch (1=limited 0=pure relative) / 1 /; +$setglobal c31_grassl_yld_scenario cc +* options: cc (climate change) +* nocc (no climate change) +* nocc_hist (no climate change after year defined by sm_fix_cc) + table f31_grassl_yld(t_all,j,grassland,w) LPJmL potential yields per cell (rainfed only) (tDM per ha) $ondelim $include "./modules/31_past/input/f31_grassl_yld.cs3" $offdelim ; +* set values to 1995 if nocc scenario is used, or to sm_fix_cc after sm_fix_cc if nocc_hist is used +$if "%c31_grassl_yld_scenario%" == "nocc" f31_grassl_yld(t_all,j,grassland,w) = f31_grassl_yld("y1995",j,grassland,w); +$if "%c31_grassl_yld_scenario%" == "nocc_hist" f31_grassl_yld(t_all,j,grassland,w)$(m_year(t_all) > sm_fix_cc) = f31_grassl_yld(t_all,j,grassland,w)$(m_year(t_all) = sm_fix_cc); + table f31_grass_bio(t_all,i, grassland) Estimated regional grass biomass consumption in the past (tDM) $ondelim From 093b0f0b23f7c963b44db3383d167b6348af1a2a Mon Sep 17 00:00:00 2001 From: Felicitas Date: Thu, 15 Jun 2023 13:40:26 +0200 Subject: [PATCH 29/62] re-introduced solprint when solverstat is 7 --- CHANGELOG.md | 1 + modules/80_optimization/lp_nlp_apr17/solve.gms | 4 ++-- modules/80_optimization/nlp_apr17/solve.gms | 4 ++-- modules/80_optimization/nlp_par/solve.gms | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1874ca251a..1eb694b53e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] ### changed +- **80_optimization** printing of solprint when solver status is 7 re-activated - **scripts** start_functions.R can now handle clusters per region flexibly - **scripts** the REMIND-MAgPIE coupling now uses renv - **41_area_equipped_for_irrigation** new AEI data (Mehta2022) replacing old Siebert data diff --git a/modules/80_optimization/lp_nlp_apr17/solve.gms b/modules/80_optimization/lp_nlp_apr17/solve.gms index e01c6323d2..a15358dd95 100644 --- a/modules/80_optimization/lp_nlp_apr17/solve.gms +++ b/modules/80_optimization/lp_nlp_apr17/solve.gms @@ -165,7 +165,7 @@ $batinclude "./modules/include.gms" nl_relax * write extended run information in list file in the case that the final solution is infeasible - if((s80_counter >= s80_maxiter and p80_modelstat(t) > 2 and p80_modelstat(t) ne 7), + if ((s80_counter >= s80_maxiter and p80_modelstat(t) > 2 and p80_modelstat(t)), magpie.solprint = 1 ); @@ -198,7 +198,7 @@ if ((p80_modelstat(t) < 3), put_utility 'shell' / 'mv -f magpie_p.gdx magpie_' t.tl:0'.gdx'; ); -if ((p80_modelstat(t) > 2 and p80_modelstat(t) ne 7), +if ((p80_modelstat(t) > 2 and p80_modelstat(t)), Execute_Unload "fulldata.gdx"; abort "no feasible solution found!"; ); diff --git a/modules/80_optimization/nlp_apr17/solve.gms b/modules/80_optimization/nlp_apr17/solve.gms index 6e28d017f8..8435366a4e 100644 --- a/modules/80_optimization/nlp_apr17/solve.gms +++ b/modules/80_optimization/nlp_apr17/solve.gms @@ -73,7 +73,7 @@ if(magpie.modelstat > 2 OR magpie.numNOpt > s80_num_nonopt_allowed, display vm_cost_glo.l; * write extended run information in list file in the case that the final solution is infeasible - if((s80_counter >= (s80_maxiter-1) and magpie.modelstat > 2 and magpie.modelstat ne 7), + if((s80_counter >= (s80_maxiter-1) and magpie.modelstat > 2 and magpie.modelstat), magpie.solprint = 1 ); @@ -91,7 +91,7 @@ if ((p80_modelstat(t) <= 2), put_utility 'shell' / 'mv -f magpie_p.gdx magpie_' t.tl:0'.gdx'; ); -if ((p80_modelstat(t) > 2 and p80_modelstat(t) ne 7), +if ((p80_modelstat(t) > 2 and p80_modelstat(t)), Execute_Unload "fulldata.gdx"; abort "no feasible solution found!"; ); diff --git a/modules/80_optimization/nlp_par/solve.gms b/modules/80_optimization/nlp_par/solve.gms index 3f1facbac1..72b750db2e 100644 --- a/modules/80_optimization/nlp_par/solve.gms +++ b/modules/80_optimization/nlp_par/solve.gms @@ -69,7 +69,7 @@ repeat display s80_counter; display magpie.modelStat; - if((p80_counter(h) >= s80_maxiter AND p80_modelstat(t,h) > 2 AND p80_modelstat(t,h) ne 7), + if((p80_counter(h) >= s80_maxiter AND p80_modelstat(t,h) > 2 AND p80_modelstat(t,h)), display "No feasible solution found. Writing LST file."; option AsyncSolLst=1; display$handlecollect(p80_handle(h)) 're-collect'; @@ -117,7 +117,7 @@ repeat display$readyCollect(p80_handle,INF) 'Problem waiting for next instance to complete'; until card(p80_handle) = 0 OR smax(h, p80_counter(h)) >= s80_maxiter; -if (smax(h,p80_modelstat(t,h)) > 2 and smax(h,p80_modelstat(t,h)) ne 7, +if (smax(h,p80_modelstat(t,h)) > 2 and smax(h,p80_modelstat(t,h)), Execute_Unload "fulldata.gdx"; abort "No feasible solution found!"; ); From 9d19c07702ff32eb3f68d22edfafae144cf2e3c5 Mon Sep 17 00:00:00 2001 From: Felicitas Beier <39262100+FelicitasBeier@users.noreply.github.com> Date: Thu, 15 Jun 2023 15:43:57 +0200 Subject: [PATCH 30/62] Update modules/80_optimization/lp_nlp_apr17/solve.gms Co-authored-by: Jan Dietrich --- modules/80_optimization/lp_nlp_apr17/solve.gms | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/80_optimization/lp_nlp_apr17/solve.gms b/modules/80_optimization/lp_nlp_apr17/solve.gms index a15358dd95..d6331e8365 100644 --- a/modules/80_optimization/lp_nlp_apr17/solve.gms +++ b/modules/80_optimization/lp_nlp_apr17/solve.gms @@ -165,7 +165,7 @@ $batinclude "./modules/include.gms" nl_relax * write extended run information in list file in the case that the final solution is infeasible - if ((s80_counter >= s80_maxiter and p80_modelstat(t) > 2 and p80_modelstat(t)), + if ((s80_counter >= s80_maxiter and p80_modelstat(t) > 2), magpie.solprint = 1 ); From c413eeafc9687d2a1ff6b33cb8c14101179a1a6a Mon Sep 17 00:00:00 2001 From: Felicitas Beier <39262100+FelicitasBeier@users.noreply.github.com> Date: Thu, 15 Jun 2023 15:44:06 +0200 Subject: [PATCH 31/62] Update modules/80_optimization/nlp_apr17/solve.gms Co-authored-by: Jan Dietrich --- modules/80_optimization/nlp_apr17/solve.gms | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/80_optimization/nlp_apr17/solve.gms b/modules/80_optimization/nlp_apr17/solve.gms index 8435366a4e..678aec186a 100644 --- a/modules/80_optimization/nlp_apr17/solve.gms +++ b/modules/80_optimization/nlp_apr17/solve.gms @@ -73,7 +73,7 @@ if(magpie.modelstat > 2 OR magpie.numNOpt > s80_num_nonopt_allowed, display vm_cost_glo.l; * write extended run information in list file in the case that the final solution is infeasible - if((s80_counter >= (s80_maxiter-1) and magpie.modelstat > 2 and magpie.modelstat), + if((s80_counter >= (s80_maxiter-1) and magpie.modelstat > 2), magpie.solprint = 1 ); From 50f78334d6aeede895bd9b4d6525c5b0cc47bfa2 Mon Sep 17 00:00:00 2001 From: Felicitas Beier <39262100+FelicitasBeier@users.noreply.github.com> Date: Thu, 15 Jun 2023 15:44:20 +0200 Subject: [PATCH 32/62] Update modules/80_optimization/lp_nlp_apr17/solve.gms Co-authored-by: Jan Dietrich --- modules/80_optimization/lp_nlp_apr17/solve.gms | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/80_optimization/lp_nlp_apr17/solve.gms b/modules/80_optimization/lp_nlp_apr17/solve.gms index d6331e8365..c9d014bc4b 100644 --- a/modules/80_optimization/lp_nlp_apr17/solve.gms +++ b/modules/80_optimization/lp_nlp_apr17/solve.gms @@ -198,7 +198,7 @@ if ((p80_modelstat(t) < 3), put_utility 'shell' / 'mv -f magpie_p.gdx magpie_' t.tl:0'.gdx'; ); -if ((p80_modelstat(t) > 2 and p80_modelstat(t)), +if ((p80_modelstat(t) > 2), Execute_Unload "fulldata.gdx"; abort "no feasible solution found!"; ); From 04f0cd19647fedb938fe4f4858c5ca52d2829b93 Mon Sep 17 00:00:00 2001 From: Felicitas Beier <39262100+FelicitasBeier@users.noreply.github.com> Date: Thu, 15 Jun 2023 15:44:33 +0200 Subject: [PATCH 33/62] Update modules/80_optimization/nlp_apr17/solve.gms Co-authored-by: Jan Dietrich --- modules/80_optimization/nlp_apr17/solve.gms | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/80_optimization/nlp_apr17/solve.gms b/modules/80_optimization/nlp_apr17/solve.gms index 678aec186a..e58b7e8af9 100644 --- a/modules/80_optimization/nlp_apr17/solve.gms +++ b/modules/80_optimization/nlp_apr17/solve.gms @@ -91,7 +91,7 @@ if ((p80_modelstat(t) <= 2), put_utility 'shell' / 'mv -f magpie_p.gdx magpie_' t.tl:0'.gdx'; ); -if ((p80_modelstat(t) > 2 and p80_modelstat(t)), +if ((p80_modelstat(t) > 2), Execute_Unload "fulldata.gdx"; abort "no feasible solution found!"; ); From 9d4327d45701d2e67424837b433f7defca525c29 Mon Sep 17 00:00:00 2001 From: Felicitas Beier <39262100+FelicitasBeier@users.noreply.github.com> Date: Thu, 15 Jun 2023 15:44:58 +0200 Subject: [PATCH 34/62] Update modules/80_optimization/nlp_par/solve.gms Co-authored-by: Jan Dietrich --- modules/80_optimization/nlp_par/solve.gms | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/80_optimization/nlp_par/solve.gms b/modules/80_optimization/nlp_par/solve.gms index 72b750db2e..ebd435ef5b 100644 --- a/modules/80_optimization/nlp_par/solve.gms +++ b/modules/80_optimization/nlp_par/solve.gms @@ -69,7 +69,7 @@ repeat display s80_counter; display magpie.modelStat; - if((p80_counter(h) >= s80_maxiter AND p80_modelstat(t,h) > 2 AND p80_modelstat(t,h)), + if((p80_counter(h) >= s80_maxiter AND p80_modelstat(t,h) > 2), display "No feasible solution found. Writing LST file."; option AsyncSolLst=1; display$handlecollect(p80_handle(h)) 're-collect'; From 3755abe4bd5ae78fba7c470b049542b6b81d7371 Mon Sep 17 00:00:00 2001 From: Felicitas Beier <39262100+FelicitasBeier@users.noreply.github.com> Date: Thu, 15 Jun 2023 15:45:12 +0200 Subject: [PATCH 35/62] Update modules/80_optimization/nlp_par/solve.gms Co-authored-by: Jan Dietrich --- modules/80_optimization/nlp_par/solve.gms | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/80_optimization/nlp_par/solve.gms b/modules/80_optimization/nlp_par/solve.gms index ebd435ef5b..8313fa9a3e 100644 --- a/modules/80_optimization/nlp_par/solve.gms +++ b/modules/80_optimization/nlp_par/solve.gms @@ -117,7 +117,7 @@ repeat display$readyCollect(p80_handle,INF) 'Problem waiting for next instance to complete'; until card(p80_handle) = 0 OR smax(h, p80_counter(h)) >= s80_maxiter; -if (smax(h,p80_modelstat(t,h)) > 2 and smax(h,p80_modelstat(t,h)), +if (smax(h,p80_modelstat(t,h)) > 2), Execute_Unload "fulldata.gdx"; abort "No feasible solution found!"; ); From 5aeca789ccece36511d0e5866553270e30cb2515 Mon Sep 17 00:00:00 2001 From: Felicitas Beier <39262100+FelicitasBeier@users.noreply.github.com> Date: Thu, 15 Jun 2023 15:46:01 +0200 Subject: [PATCH 36/62] Update solve.gms --- modules/80_optimization/nlp_par/solve.gms | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/80_optimization/nlp_par/solve.gms b/modules/80_optimization/nlp_par/solve.gms index 8313fa9a3e..288210c7f3 100644 --- a/modules/80_optimization/nlp_par/solve.gms +++ b/modules/80_optimization/nlp_par/solve.gms @@ -117,7 +117,7 @@ repeat display$readyCollect(p80_handle,INF) 'Problem waiting for next instance to complete'; until card(p80_handle) = 0 OR smax(h, p80_counter(h)) >= s80_maxiter; -if (smax(h,p80_modelstat(t,h)) > 2), +if (smax(h,p80_modelstat(t,h)) > 2, Execute_Unload "fulldata.gdx"; abort "No feasible solution found!"; ); From aeebfc7fd3f4bfde4a5b35f84e23ec14b427349c Mon Sep 17 00:00:00 2001 From: bodirsky Date: Thu, 22 Jun 2023 14:46:41 +0200 Subject: [PATCH 37/62] bugfix: fallow was on the wrong side of the equation --- modules/30_crop/penalty_apr22/equations.gms | 1 - modules/30_crop/rotation_apr22/equations.gms | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/30_crop/penalty_apr22/equations.gms b/modules/30_crop/penalty_apr22/equations.gms index 7937ab12bb..6793e47eea 100644 --- a/modules/30_crop/penalty_apr22/equations.gms +++ b/modules/30_crop/penalty_apr22/equations.gms @@ -14,7 +14,6 @@ q30_cropland(j2) .. sum((kcr,w), vm_area(j2,kcr,w)) + vm_fallow(j2) =e= vm_land(j2,"crop"); - *' We assume that crop production can only take place on suitable cropland area. *' We use a suitability index (SI) map from @zabel_global_2014 to exclude areas *' from cropland production that have a low suitability, e.g. due to steep slopes, diff --git a/modules/30_crop/rotation_apr22/equations.gms b/modules/30_crop/rotation_apr22/equations.gms index dd7270bcb4..e2e5602ce9 100644 --- a/modules/30_crop/rotation_apr22/equations.gms +++ b/modules/30_crop/rotation_apr22/equations.gms @@ -8,9 +8,11 @@ *' @equations *' The total land requirements for cropland are calculated as *' the sum of crop and water supply type specific land requirements: +*' Fallow is no explicit landuse type, but the difference between +*' land and harvested vm_area q30_cropland(j2) .. - sum((kcr,w), vm_area(j2,kcr,w)) =e= vm_land(j2,"crop") + vm_fallow(j2); + sum((kcr,w), vm_area(j2,kcr,w)) + vm_fallow(j2) =e= vm_land(j2,"crop"); *' We assume that crop production can only take place on suitable cropland area. *' We use a suitability index (SI) map from @zabel_global_2014 to exclude areas From 032d2ab9843c7a974bf539bfa24d232fd18db0e3 Mon Sep 17 00:00:00 2001 From: bodirsky Date: Thu, 22 Jun 2023 14:50:10 +0200 Subject: [PATCH 38/62] adapted changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1874ca251a..56496fd1e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] ### changed +- **30_crop** in the module realization rotation_apr22 there was a bug, fallow land was on the wrong side of the equation q30_cropland - **scripts** start_functions.R can now handle clusters per region flexibly - **scripts** the REMIND-MAgPIE coupling now uses renv - **41_area_equipped_for_irrigation** new AEI data (Mehta2022) replacing old Siebert data From add204afa98085e71fcc20caabd42d5b47f6197b Mon Sep 17 00:00:00 2001 From: florianh Date: Thu, 22 Jun 2023 15:04:54 +0200 Subject: [PATCH 39/62] results folder for highres runs --- CHANGELOG.md | 1 + config/default.cfg | 6 ++++++ scripts/output/extra/highres.R | 6 +++++- scripts/start/test_runs.R | 1 + 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1874ca251a..cfeba0fda7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **config** new area equipped for irrigation (AEI) data in preprocessing (4.87) - **31_past** added `cc`, `nocc` and `nocc_hist` options for `c31_past_suit_scen` and `c31_grassl_yld_scenario` - **32_carbon** added `nocc` and `nocc_hist` option for `c52_land_carbon_sink_rcp` +- **config** added `cfg$results_folder_highres` which allows to modify the output folder used in the `highres.R` output script ### removed - diff --git a/config/default.cfg b/config/default.cfg index c3dc525c32..b2a7928079 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -1876,6 +1876,12 @@ cfg$output <- c("output_check", "extra/disaggregation", "rds_report") # :title: is a placeholder for the current run title (cfg$title) cfg$results_folder <- "output/:title::date:" +# Results folder used by the "highres.R" output script +# If NULL, the default set in "highres.R" is used (currently a subfolder in "output") +# To place highres runs directly in the "output" folder, change to "output" +# To place highres runs in a specific subfolder change to "output/HR" +cfg$results_folder_highres <- NULL + # Which files should be copied into the output folder? cfg$files2export <- list() # Files that should be copied before MAgPIE is started diff --git a/scripts/output/extra/highres.R b/scripts/output/extra/highres.R index e1707e82e2..370d525b5a 100644 --- a/scripts/output/extra/highres.R +++ b/scripts/output/extra/highres.R @@ -120,7 +120,11 @@ highres <- function(cfg) { tmp[1] <- paste0(tmp[1], paste0("HR", res)) cfg$title <- paste(tmp, collapse = "_") - cfg$results_folder <- paste0("output/HR", res, "/:title:") + if(!is.null(cfg$results_folder_highres)) { + cfg$results_folder <- file.path(cfg$results_folder_highres,":title:") + } else { + cfg$results_folder <- paste0("output/HR", res, "/:title:") + } cfg$force_replace <- TRUE cfg$recalc_npi_ndc <- TRUE diff --git a/scripts/start/test_runs.R b/scripts/start/test_runs.R index b7bf326f92..cf43611cf3 100644 --- a/scripts/start/test_runs.R +++ b/scripts/start/test_runs.R @@ -28,6 +28,7 @@ cfg$info$flag <- "weeklyTests" cfg$output <- c("rds_report") # Only run rds_report after model run cfg$results_folder <- "output/:title:" +cfg$results_folder_highres <- "output" cfg$force_replace <- TRUE # support function to create standardized title From 659d186a9d16e9646006b987bf5df133e6006aa6 Mon Sep 17 00:00:00 2001 From: florianh Date: Thu, 22 Jun 2023 15:16:38 +0200 Subject: [PATCH 40/62] bugfix --- scripts/start/test_runs.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/start/test_runs.R b/scripts/start/test_runs.R index cf43611cf3..7815102f9a 100644 --- a/scripts/start/test_runs.R +++ b/scripts/start/test_runs.R @@ -28,7 +28,6 @@ cfg$info$flag <- "weeklyTests" cfg$output <- c("rds_report") # Only run rds_report after model run cfg$results_folder <- "output/:title:" -cfg$results_folder_highres <- "output" cfg$force_replace <- TRUE # support function to create standardized title @@ -78,9 +77,11 @@ codeCheck <- FALSE ### Business-as-usual cfg <- fsecScenario(scenario = "c_BAU") +cfg$results_folder_highres <- "output" start_run(cfg = cfg, codeCheck = codeCheck) ### FSDP Scenario cfg <- fsecScenario(scenario = "e_FSDP") +cfg$results_folder_highres <- "output" start_run(cfg = cfg, codeCheck = codeCheck) From 8ae010010ab36043e43d4b3fcae83bdafccdd69d Mon Sep 17 00:00:00 2001 From: bodirsky Date: Thu, 22 Jun 2023 16:17:00 +0200 Subject: [PATCH 41/62] update documentation --- CHANGELOG.md | 2 +- modules/30_crop/penalty_apr22/equations.gms | 2 +- modules/30_crop/rotation_apr22/equations.gms | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 56496fd1e0..eb1daf4bc4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] ### changed -- **30_crop** in the module realization rotation_apr22 there was a bug, fallow land was on the wrong side of the equation q30_cropland - **scripts** start_functions.R can now handle clusters per region flexibly - **scripts** the REMIND-MAgPIE coupling now uses renv - **41_area_equipped_for_irrigation** new AEI data (Mehta2022) replacing old Siebert data @@ -23,6 +22,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - ### fixed +- **30_crop** corrected q30_cropland in module realization rotation_apr22, where fallow land was on the wrong side of the equation - **config** updated scenario configs to newest preprocessing (4.87) - **config** corrected wrong names of parameters for peatland costs diff --git a/modules/30_crop/penalty_apr22/equations.gms b/modules/30_crop/penalty_apr22/equations.gms index 6793e47eea..bb649fa47f 100644 --- a/modules/30_crop/penalty_apr22/equations.gms +++ b/modules/30_crop/penalty_apr22/equations.gms @@ -9,7 +9,7 @@ *' The total land requirements for cropland are calculated as *' the sum of crop and water supply type specific land requirements. *' Fallow is no explicit landuse type, but the difference between -*' land and harvested vm_area +*' the land area for crops vm_land and the croparea vm_area q30_cropland(j2) .. sum((kcr,w), vm_area(j2,kcr,w)) + vm_fallow(j2) =e= vm_land(j2,"crop"); diff --git a/modules/30_crop/rotation_apr22/equations.gms b/modules/30_crop/rotation_apr22/equations.gms index e2e5602ce9..d3db06641a 100644 --- a/modules/30_crop/rotation_apr22/equations.gms +++ b/modules/30_crop/rotation_apr22/equations.gms @@ -9,7 +9,7 @@ *' The total land requirements for cropland are calculated as *' the sum of crop and water supply type specific land requirements: *' Fallow is no explicit landuse type, but the difference between -*' land and harvested vm_area +*' the land area for crops vm_land and the croparea vm_area q30_cropland(j2) .. sum((kcr,w), vm_area(j2,kcr,w)) + vm_fallow(j2) =e= vm_land(j2,"crop"); From 5bdf08aca25deecbd287d8eea55306a2ba595608 Mon Sep 17 00:00:00 2001 From: florianh Date: Sun, 2 Jul 2023 22:04:04 +0200 Subject: [PATCH 42/62] main.gms defaults --- main.gms | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/main.gms b/main.gms index 704fef5fb2..47e25fedc8 100644 --- a/main.gms +++ b/main.gms @@ -194,8 +194,10 @@ $title magpie * 6 17 9 8 1 44 26 7 10 13 38 21 * * Call: withCallingHandlers(expr, message = messageHandler, warning = warningHandler, error = errorHandler) * +* Warning message: +* could not retrieve available packages for url 'https://rse.pik-potsdam.de/r/packages/bin/macosx/contrib/4.2' * -* Last modification (input data): Wed Jun 7 17:53:26 2023 +* Last modification (input data): Sun Jul 2 21:46:49 2023 * *###################### R SECTION END (VERSION INFO) ########################### @@ -219,9 +221,9 @@ $offlisting **************************MODEL SPECIFIC SCALARS******************************** * Key parameters during model runs -$setglobal c_timesteps calib +$setglobal c_timesteps coup2100 $setglobal c_past till_2010 -$setglobal c_title BilatPRFade_ON_Nofadeout +$setglobal c_title default scalars s_use_gdx use of gdx files / 0 / @@ -249,7 +251,7 @@ $setglobal land_conservation area_based_apr22 $setglobal ageclass feb21 -$setglobal crop penalty_apr22 +$setglobal crop endo_apr21 $setglobal past endo_jun13 $setglobal forestry dynamic_feb21 @@ -259,7 +261,7 @@ $setglobal natveg dynamic_feb21 $setglobal employment exo_may22 $setglobal labor_prod off -$setglobal factor_costs sticky_feb18 +$setglobal factor_costs per_ton_fao_may22 $setglobal landconversion calib $setglobal transport gtap_nov12 From 2c22871d56e1601a2ddd70bc1eb86a03e3a7546a Mon Sep 17 00:00:00 2001 From: florianh Date: Sun, 2 Jul 2023 22:26:55 +0200 Subject: [PATCH 43/62] bugfix 71_disagg_lvst and 80_optimization --- CHANGELOG.md | 4 +- config/default.cfg | 5 -- modules/51_nitrogen/module.gms | 1 - .../foragebased_aug18/declarations.gms | 30 +++---- .../foragebased_aug18/equations.gms | 22 +++-- .../foragebased_aug18/nl_fix.gms | 10 +-- .../foragebased_aug18/nl_release.gms | 4 +- .../foragebased_aug18/postsolve.gms | 80 +++++++++---------- modules/80_optimization/nlp_par/input.gms | 1 - modules/80_optimization/nlp_par/solve.gms | 2 +- renv/activate.R | 66 ++++----------- 11 files changed, 89 insertions(+), 136 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cfeba0fda7..d260bbe211 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,11 +20,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **config** added `cfg$results_folder_highres` which allows to modify the output folder used in the `highres.R` output script ### removed -- +- **config** s80_num_nonopt_allowed ### fixed - **config** updated scenario configs to newest preprocessing (4.87) - **config** corrected wrong names of parameters for peatland costs +- **71_disagg_lvst** wrong unit of v71_feed_balanceflow and too high values (also resolution-dependent) in case of s71_lp_fix = 0 (default) +- **80_optimization** resolve was not working in nlp_par realization due to s80_num_nonopt_allowed ## [4.6.7] - 2023-05-10 diff --git a/config/default.cfg b/config/default.cfg index b2a7928079..08b5053ec3 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -1818,11 +1818,6 @@ cfg$gms$s80_maxiter <- 30 # * (conopt4+conopt3): conopt4 followed by conopt3 cfg$gms$c80_nlp_solver <- "conopt4" # def = conopt4 -# number of allowed non-optimal variables -# Should be set to 0 for GAMS version 25.x.x or earlier -# Should be set to Inf for GAMS version 26.x.x or later -cfg$gms$s80_num_nonopt_allowed <- Inf - # * 1: using optfile for specified solver settings # * 0: default settings (optfile will be ignored) cfg$gms$s80_optfile <- 1 diff --git a/modules/51_nitrogen/module.gms b/modules/51_nitrogen/module.gms index 4b530725d6..e28a27bf21 100644 --- a/modules/51_nitrogen/module.gms +++ b/modules/51_nitrogen/module.gms @@ -14,7 +14,6 @@ *' @authors Benjamin Leon Bodirsky *###################### R SECTION START (MODULETYPES) ########################## -$Ifi "%nitrogen%" == "ipcc2006_sep16" $include "./modules/51_nitrogen/ipcc2006_sep16/realization.gms" $Ifi "%nitrogen%" == "off" $include "./modules/51_nitrogen/off/realization.gms" $Ifi "%nitrogen%" == "rescaled_jan21" $include "./modules/51_nitrogen/rescaled_jan21/realization.gms" *###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/71_disagg_lvst/foragebased_aug18/declarations.gms b/modules/71_disagg_lvst/foragebased_aug18/declarations.gms index d68611a046..0be0b25043 100644 --- a/modules/71_disagg_lvst/foragebased_aug18/declarations.gms +++ b/modules/71_disagg_lvst/foragebased_aug18/declarations.gms @@ -6,22 +6,22 @@ *** | Contact: magpie@pik-potsdam.de positive variables - v71_prod_rum(j,kli_rum,kforage) Production of forage fed ruminants within a cell (mio. tDM per yr) + v71_prod_rum(j,kli_rum,kforage) Production of forage fed ruminants within a cell (mio. tDM per yr) v71_additional_mon(j, kli_mon) Additional punished production of monogastric livestock (mio. tDM per yr) vm_costs_additional_mon(i) Punishment cost for additionally transported monogastric livst_egg (mio. USD05MER per yr) ; variables - v71_feed_balanceflow(j,kli_rum,kforage) Cellular feed balanceflow for forage feed for ruminant livestock (mio. tDM per yr) + v71_feed_balanceflow(j,kforage) Cellular feed balanceflow for forage feed for ruminant livestock (mio. tDM per yr) ; equations q71_feed_rum_liv(j,kforage) Production constraint for ruminant livestock products (mio. tDM per yr) - q71_balanceflow_constraint_nlp(j,kli_rum,kforage) Nonlinear balanceflow constraint for cellular forage feed products (mio. tDM per yr) - q71_balanceflow_constraint_lp(i,kli_rum,kforage) Linear balanceflow constraint for cellular forage feed product (mio. tDM per yr) + q71_balanceflow_constraint_nlp(j,kforage) Nonlinear balanceflow constraint for cellular forage feed products (mio. tDM per yr) + q71_balanceflow_constraint_lp(i,kforage) Linear balanceflow constraint for cellular forage feed product (mio. tDM per yr) q71_sum_rum_liv(j,kli_rum) Total production of forage fed ruminants (mio. tDM per yr) q71_prod_mon_liv(j,kli_mon) Production constraint for monogastric livestock products (mio. tDM per yr) - q71_punishment_mon(i) Punishment for additional monogastrics (mio. USD05MER per yr) + q71_punishment_mon(i) Punishment for additional monogastrics (mio. USD05MER per yr) ; parameters @@ -36,15 +36,15 @@ scalars *#################### R SECTION START (OUTPUT DECLARATIONS) #################### parameters - ov71_prod_rum(t,j,kli_rum,kforage,type) Production of forage fed ruminants within a cell (mio. tDM per yr) - ov71_additional_mon(t,j,kli_mon,type) Additional punished production of monogastric livestock (mio. tDM per yr) - ov_costs_additional_mon(t,i,type) Punishment cost for additionally transported monogastric livst_egg (mio. USD05MER per yr) - ov71_feed_balanceflow(t,j,kli_rum,kforage,type) Cellular feed balanceflow for forage feed for ruminant livestock (mio. tDM per yr) - oq71_feed_rum_liv(t,j,kforage,type) Production constraint for ruminant livestock products (mio. tDM per yr) - oq71_balanceflow_constraint_nlp(t,j,kli_rum,kforage,type) Nonlinear balanceflow constraint for cellular forage feed products (mio. tDM per yr) - oq71_balanceflow_constraint_lp(t,i,kli_rum,kforage,type) Linear balanceflow constraint for cellular forage feed product (mio. tDM per yr) - oq71_sum_rum_liv(t,j,kli_rum,type) Total production of forage fed ruminants (mio. tDM per yr) - oq71_prod_mon_liv(t,j,kli_mon,type) Production constraint for monogastric livestock products (mio. tDM per yr) - oq71_punishment_mon(t,i,type) Punishment for additional monogastrics (mio. USD05MER per yr) + ov71_prod_rum(t,j,kli_rum,kforage,type) Production of forage fed ruminants within a cell (mio. tDM per yr) + ov71_additional_mon(t,j,kli_mon,type) Additional punished production of monogastric livestock (mio. tDM per yr) + ov_costs_additional_mon(t,i,type) Punishment cost for additionally transported monogastric livst_egg (mio. USD05MER per yr) + ov71_feed_balanceflow(t,j,kforage,type) Cellular feed balanceflow for forage feed for ruminant livestock (mio. tDM per yr) + oq71_feed_rum_liv(t,j,kforage,type) Production constraint for ruminant livestock products (mio. tDM per yr) + oq71_balanceflow_constraint_nlp(t,j,kforage,type) Nonlinear balanceflow constraint for cellular forage feed products (mio. tDM per yr) + oq71_balanceflow_constraint_lp(t,i,kforage,type) Linear balanceflow constraint for cellular forage feed product (mio. tDM per yr) + oq71_sum_rum_liv(t,j,kli_rum,type) Total production of forage fed ruminants (mio. tDM per yr) + oq71_prod_mon_liv(t,j,kli_mon,type) Production constraint for monogastric livestock products (mio. tDM per yr) + oq71_punishment_mon(t,i,type) Punishment for additional monogastrics (mio. USD05MER per yr) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/71_disagg_lvst/foragebased_aug18/equations.gms b/modules/71_disagg_lvst/foragebased_aug18/equations.gms index 575ba6c47b..36467f4f9d 100644 --- a/modules/71_disagg_lvst/foragebased_aug18/equations.gms +++ b/modules/71_disagg_lvst/foragebased_aug18/equations.gms @@ -14,11 +14,8 @@ q71_feed_rum_liv(j2,kforage) .. vm_prod(j2,kforage) =g= sum(kli_rum, v71_prod_rum(j2,kli_rum,kforage) - * sum((ct,cell(i2,j2),kforage2),im_feed_baskets(ct,i2,kli_rum,kforage2)) - * (1 + v71_feed_balanceflow(j2,kli_rum,kforage)$(s71_lp_fix=0)) - + v71_feed_balanceflow(j2,kli_rum,kforage)$(s71_lp_fix=1)) - ; - + * sum((ct,cell(i2,j2)),im_feed_baskets(ct,i2,kli_rum,kforage))) + + v71_feed_balanceflow(j2,kforage); *' The above equation contains a split of pasture and fodder fed ruminants, since we assume that depending *' on the intensity level of the livestock production, ruminants will graze on pastures (extensive systems) @@ -34,9 +31,9 @@ q71_feed_rum_liv(j2,kforage) .. * containing pasture or cropland area in the previous time step ensured by the restrictions * in the nl_fix statement. The balance flow within a region is then determined by -q71_balanceflow_constraint_lp(i2,kli_rum,kforage)$(s71_lp_fix=1) .. - sum(ct, fm_feed_balanceflow(ct,i2,kli_rum,kforage)) =e= - sum(cell(i2,j2), v71_feed_balanceflow(j2,kli_rum,kforage)) +q71_balanceflow_constraint_lp(i2,kforage)$(s71_lp_fix=1) .. + sum(cell(i2,j2), v71_feed_balanceflow(j2,kforage)) =e= + sum((ct,kli_rum), fm_feed_balanceflow(ct,i2,kli_rum,kforage)) ; * Note that for fixation to linear behaviour `q71_balanceflow_constraint_lp` replaces `q71_balanceflow_constraint_nlp`. @@ -45,11 +42,10 @@ q71_balanceflow_constraint_lp(i2,kli_rum,kforage)$(s71_lp_fix=1) .. *' In each cluster the balance flow is constrained by its share of livestock production regarding the regional level by -q71_balanceflow_constraint_nlp(j2,kli_rum,kforage)$(s71_lp_fix=0) .. - v71_feed_balanceflow(j2,kli_rum,kforage) =e= - sum((ct,cell(i2,j2)),fm_feed_balanceflow(ct,i2,kli_rum,kforage) - /(im_feed_baskets(ct,i2,kli_rum,kforage)*vm_prod_reg(i2,kli_rum) + 10**(-6))) - ; +q71_balanceflow_constraint_nlp(j2,kforage)$(s71_lp_fix=0) .. + v71_feed_balanceflow(j2,kforage) =e= + sum((ct,cell(i2,j2),kli_rum), fm_feed_balanceflow(ct,i2,kli_rum,kforage) + * (vm_prod(j2,kli_rum) / (vm_prod_reg(i2,kli_rum) + 10**(-6)))); *' Note that $10^{-6}$ is required to avoid division by zero. *' The regional ruminant production is then given by diff --git a/modules/71_disagg_lvst/foragebased_aug18/nl_fix.gms b/modules/71_disagg_lvst/foragebased_aug18/nl_fix.gms index 3e88e2581d..d0e261fa4b 100644 --- a/modules/71_disagg_lvst/foragebased_aug18/nl_fix.gms +++ b/modules/71_disagg_lvst/foragebased_aug18/nl_fix.gms @@ -7,10 +7,10 @@ * ### nl_fix ### -v71_feed_balanceflow.lo(j,kli_rum,kforage)$(sum(cell(i,j),fm_feed_balanceflow(t,i,kli_rum,kforage)) > 0) = 0; -v71_feed_balanceflow.up(j,kli_rum,kforage)$(sum(cell(i,j),fm_feed_balanceflow(t,i,kli_rum,kforage)) < 0) = 0; -v71_feed_balanceflow.fx(j,kli_rum,kforage)$(sum(cell(i,j),fm_feed_balanceflow(t,i,kli_rum,kforage)) = 0) = 0; -v71_feed_balanceflow.fx(j,kli_rum,"pasture")$(pcm_land(j,"past")=0) = 0; -v71_feed_balanceflow.fx(j,kli_rum,"foddr")$(pcm_land(j,"crop")=0) = 0; +v71_feed_balanceflow.lo(j,kforage)$(sum((cell(i,j),kli_rum),fm_feed_balanceflow(t,i,kli_rum,kforage)) > 0) = 0; +v71_feed_balanceflow.up(j,kforage)$(sum((cell(i,j),kli_rum),fm_feed_balanceflow(t,i,kli_rum,kforage)) < 0) = 0; +v71_feed_balanceflow.fx(j,kforage)$(sum((cell(i,j),kli_rum),fm_feed_balanceflow(t,i,kli_rum,kforage)) = 0) = 0; +v71_feed_balanceflow.fx(j,"pasture")$(pcm_land(j,"past")=0) = 0; +v71_feed_balanceflow.fx(j,"foddr")$(pcm_land(j,"crop")=0) = 0; s71_lp_fix=1; diff --git a/modules/71_disagg_lvst/foragebased_aug18/nl_release.gms b/modules/71_disagg_lvst/foragebased_aug18/nl_release.gms index cbad58b03d..f2d5e64281 100644 --- a/modules/71_disagg_lvst/foragebased_aug18/nl_release.gms +++ b/modules/71_disagg_lvst/foragebased_aug18/nl_release.gms @@ -7,7 +7,7 @@ * ### nl_release ### -v71_feed_balanceflow.lo(j,kli_rum,kforage)= -Inf; -v71_feed_balanceflow.up(j,kli_rum,kforage)= Inf; +v71_feed_balanceflow.lo(j,kforage)= -Inf; +v71_feed_balanceflow.up(j,kforage)= Inf; s71_lp_fix=0; diff --git a/modules/71_disagg_lvst/foragebased_aug18/postsolve.gms b/modules/71_disagg_lvst/foragebased_aug18/postsolve.gms index 9c2b6507f3..c035ac00f7 100644 --- a/modules/71_disagg_lvst/foragebased_aug18/postsolve.gms +++ b/modules/71_disagg_lvst/foragebased_aug18/postsolve.gms @@ -6,44 +6,44 @@ *** | Contact: magpie@pik-potsdam.de *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov71_prod_rum(t,j,kli_rum,kforage,"marginal") = v71_prod_rum.m(j,kli_rum,kforage); - ov71_additional_mon(t,j,kli_mon,"marginal") = v71_additional_mon.m(j,kli_mon); - ov_costs_additional_mon(t,i,"marginal") = vm_costs_additional_mon.m(i); - ov71_feed_balanceflow(t,j,kli_rum,kforage,"marginal") = v71_feed_balanceflow.m(j,kli_rum,kforage); - oq71_feed_rum_liv(t,j,kforage,"marginal") = q71_feed_rum_liv.m(j,kforage); - oq71_balanceflow_constraint_nlp(t,j,kli_rum,kforage,"marginal") = q71_balanceflow_constraint_nlp.m(j,kli_rum,kforage); - oq71_balanceflow_constraint_lp(t,i,kli_rum,kforage,"marginal") = q71_balanceflow_constraint_lp.m(i,kli_rum,kforage); - oq71_sum_rum_liv(t,j,kli_rum,"marginal") = q71_sum_rum_liv.m(j,kli_rum); - oq71_prod_mon_liv(t,j,kli_mon,"marginal") = q71_prod_mon_liv.m(j,kli_mon); - oq71_punishment_mon(t,i,"marginal") = q71_punishment_mon.m(i); - ov71_prod_rum(t,j,kli_rum,kforage,"level") = v71_prod_rum.l(j,kli_rum,kforage); - ov71_additional_mon(t,j,kli_mon,"level") = v71_additional_mon.l(j,kli_mon); - ov_costs_additional_mon(t,i,"level") = vm_costs_additional_mon.l(i); - ov71_feed_balanceflow(t,j,kli_rum,kforage,"level") = v71_feed_balanceflow.l(j,kli_rum,kforage); - oq71_feed_rum_liv(t,j,kforage,"level") = q71_feed_rum_liv.l(j,kforage); - oq71_balanceflow_constraint_nlp(t,j,kli_rum,kforage,"level") = q71_balanceflow_constraint_nlp.l(j,kli_rum,kforage); - oq71_balanceflow_constraint_lp(t,i,kli_rum,kforage,"level") = q71_balanceflow_constraint_lp.l(i,kli_rum,kforage); - oq71_sum_rum_liv(t,j,kli_rum,"level") = q71_sum_rum_liv.l(j,kli_rum); - oq71_prod_mon_liv(t,j,kli_mon,"level") = q71_prod_mon_liv.l(j,kli_mon); - oq71_punishment_mon(t,i,"level") = q71_punishment_mon.l(i); - ov71_prod_rum(t,j,kli_rum,kforage,"upper") = v71_prod_rum.up(j,kli_rum,kforage); - ov71_additional_mon(t,j,kli_mon,"upper") = v71_additional_mon.up(j,kli_mon); - ov_costs_additional_mon(t,i,"upper") = vm_costs_additional_mon.up(i); - ov71_feed_balanceflow(t,j,kli_rum,kforage,"upper") = v71_feed_balanceflow.up(j,kli_rum,kforage); - oq71_feed_rum_liv(t,j,kforage,"upper") = q71_feed_rum_liv.up(j,kforage); - oq71_balanceflow_constraint_nlp(t,j,kli_rum,kforage,"upper") = q71_balanceflow_constraint_nlp.up(j,kli_rum,kforage); - oq71_balanceflow_constraint_lp(t,i,kli_rum,kforage,"upper") = q71_balanceflow_constraint_lp.up(i,kli_rum,kforage); - oq71_sum_rum_liv(t,j,kli_rum,"upper") = q71_sum_rum_liv.up(j,kli_rum); - oq71_prod_mon_liv(t,j,kli_mon,"upper") = q71_prod_mon_liv.up(j,kli_mon); - oq71_punishment_mon(t,i,"upper") = q71_punishment_mon.up(i); - ov71_prod_rum(t,j,kli_rum,kforage,"lower") = v71_prod_rum.lo(j,kli_rum,kforage); - ov71_additional_mon(t,j,kli_mon,"lower") = v71_additional_mon.lo(j,kli_mon); - ov_costs_additional_mon(t,i,"lower") = vm_costs_additional_mon.lo(i); - ov71_feed_balanceflow(t,j,kli_rum,kforage,"lower") = v71_feed_balanceflow.lo(j,kli_rum,kforage); - oq71_feed_rum_liv(t,j,kforage,"lower") = q71_feed_rum_liv.lo(j,kforage); - oq71_balanceflow_constraint_nlp(t,j,kli_rum,kforage,"lower") = q71_balanceflow_constraint_nlp.lo(j,kli_rum,kforage); - oq71_balanceflow_constraint_lp(t,i,kli_rum,kforage,"lower") = q71_balanceflow_constraint_lp.lo(i,kli_rum,kforage); - oq71_sum_rum_liv(t,j,kli_rum,"lower") = q71_sum_rum_liv.lo(j,kli_rum); - oq71_prod_mon_liv(t,j,kli_mon,"lower") = q71_prod_mon_liv.lo(j,kli_mon); - oq71_punishment_mon(t,i,"lower") = q71_punishment_mon.lo(i); + ov71_prod_rum(t,j,kli_rum,kforage,"marginal") = v71_prod_rum.m(j,kli_rum,kforage); + ov71_additional_mon(t,j,kli_mon,"marginal") = v71_additional_mon.m(j,kli_mon); + ov_costs_additional_mon(t,i,"marginal") = vm_costs_additional_mon.m(i); + ov71_feed_balanceflow(t,j,kforage,"marginal") = v71_feed_balanceflow.m(j,kforage); + oq71_feed_rum_liv(t,j,kforage,"marginal") = q71_feed_rum_liv.m(j,kforage); + oq71_balanceflow_constraint_nlp(t,j,kforage,"marginal") = q71_balanceflow_constraint_nlp.m(j,kforage); + oq71_balanceflow_constraint_lp(t,i,kforage,"marginal") = q71_balanceflow_constraint_lp.m(i,kforage); + oq71_sum_rum_liv(t,j,kli_rum,"marginal") = q71_sum_rum_liv.m(j,kli_rum); + oq71_prod_mon_liv(t,j,kli_mon,"marginal") = q71_prod_mon_liv.m(j,kli_mon); + oq71_punishment_mon(t,i,"marginal") = q71_punishment_mon.m(i); + ov71_prod_rum(t,j,kli_rum,kforage,"level") = v71_prod_rum.l(j,kli_rum,kforage); + ov71_additional_mon(t,j,kli_mon,"level") = v71_additional_mon.l(j,kli_mon); + ov_costs_additional_mon(t,i,"level") = vm_costs_additional_mon.l(i); + ov71_feed_balanceflow(t,j,kforage,"level") = v71_feed_balanceflow.l(j,kforage); + oq71_feed_rum_liv(t,j,kforage,"level") = q71_feed_rum_liv.l(j,kforage); + oq71_balanceflow_constraint_nlp(t,j,kforage,"level") = q71_balanceflow_constraint_nlp.l(j,kforage); + oq71_balanceflow_constraint_lp(t,i,kforage,"level") = q71_balanceflow_constraint_lp.l(i,kforage); + oq71_sum_rum_liv(t,j,kli_rum,"level") = q71_sum_rum_liv.l(j,kli_rum); + oq71_prod_mon_liv(t,j,kli_mon,"level") = q71_prod_mon_liv.l(j,kli_mon); + oq71_punishment_mon(t,i,"level") = q71_punishment_mon.l(i); + ov71_prod_rum(t,j,kli_rum,kforage,"upper") = v71_prod_rum.up(j,kli_rum,kforage); + ov71_additional_mon(t,j,kli_mon,"upper") = v71_additional_mon.up(j,kli_mon); + ov_costs_additional_mon(t,i,"upper") = vm_costs_additional_mon.up(i); + ov71_feed_balanceflow(t,j,kforage,"upper") = v71_feed_balanceflow.up(j,kforage); + oq71_feed_rum_liv(t,j,kforage,"upper") = q71_feed_rum_liv.up(j,kforage); + oq71_balanceflow_constraint_nlp(t,j,kforage,"upper") = q71_balanceflow_constraint_nlp.up(j,kforage); + oq71_balanceflow_constraint_lp(t,i,kforage,"upper") = q71_balanceflow_constraint_lp.up(i,kforage); + oq71_sum_rum_liv(t,j,kli_rum,"upper") = q71_sum_rum_liv.up(j,kli_rum); + oq71_prod_mon_liv(t,j,kli_mon,"upper") = q71_prod_mon_liv.up(j,kli_mon); + oq71_punishment_mon(t,i,"upper") = q71_punishment_mon.up(i); + ov71_prod_rum(t,j,kli_rum,kforage,"lower") = v71_prod_rum.lo(j,kli_rum,kforage); + ov71_additional_mon(t,j,kli_mon,"lower") = v71_additional_mon.lo(j,kli_mon); + ov_costs_additional_mon(t,i,"lower") = vm_costs_additional_mon.lo(i); + ov71_feed_balanceflow(t,j,kforage,"lower") = v71_feed_balanceflow.lo(j,kforage); + oq71_feed_rum_liv(t,j,kforage,"lower") = q71_feed_rum_liv.lo(j,kforage); + oq71_balanceflow_constraint_nlp(t,j,kforage,"lower") = q71_balanceflow_constraint_nlp.lo(j,kforage); + oq71_balanceflow_constraint_lp(t,i,kforage,"lower") = q71_balanceflow_constraint_lp.lo(i,kforage); + oq71_sum_rum_liv(t,j,kli_rum,"lower") = q71_sum_rum_liv.lo(j,kli_rum); + oq71_prod_mon_liv(t,j,kli_mon,"lower") = q71_prod_mon_liv.lo(j,kli_mon); + oq71_punishment_mon(t,i,"lower") = q71_punishment_mon.lo(i); *##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/80_optimization/nlp_par/input.gms b/modules/80_optimization/nlp_par/input.gms index d51ef89aa7..00370ae459 100644 --- a/modules/80_optimization/nlp_par/input.gms +++ b/modules/80_optimization/nlp_par/input.gms @@ -8,5 +8,4 @@ scalars s80_maxiter maximal solve iterations if modelstat is > 2 (1) / 30 / s80_optfile switch to use specfied solver settings (1) / 1 / - s80_num_nonopt_allowed number of allowed non-optimal variables (1) / Inf / ; diff --git a/modules/80_optimization/nlp_par/solve.gms b/modules/80_optimization/nlp_par/solve.gms index 3f1facbac1..7aa7f9c536 100644 --- a/modules/80_optimization/nlp_par/solve.gms +++ b/modules/80_optimization/nlp_par/solve.gms @@ -79,7 +79,7 @@ repeat display$handledelete(p80_handle(h)) 'trouble deleting handles' ; - if(p80_modelstat(t,h) <= 2 AND magpie.numNOpt <= s80_num_nonopt_allowed, + if(p80_modelstat(t,h) <= 2, display "Model status <= 2. Handle cleared."; s80_resolve = 0; p80_handle(h) = 0; diff --git a/renv/activate.R b/renv/activate.R index 4564b9ddf0..019b5a6693 100644 --- a/renv/activate.R +++ b/renv/activate.R @@ -63,10 +63,6 @@ local({ if (is.environment(x) || length(x)) x else y } - `%??%` <- function(x, y) { - if (is.null(x)) y else x - } - bootstrap <- function(version, library) { # attempt to download renv @@ -87,39 +83,28 @@ local({ renv_bootstrap_repos <- function() { - # get CRAN repository - cran <- getOption("renv.repos.cran", "https://cloud.r-project.org") - # check for repos override repos <- Sys.getenv("RENV_CONFIG_REPOS_OVERRIDE", unset = NA) - if (!is.na(repos)) { - - # check for RSPM; if set, use a fallback repository for renv - rspm <- Sys.getenv("RSPM", unset = NA) - if (identical(rspm, repos)) - repos <- c(RSPM = rspm, CRAN = cran) - + if (!is.na(repos)) return(repos) - } - # check for lockfile repositories repos <- tryCatch(renv_bootstrap_repos_lockfile(), error = identity) if (!inherits(repos, "error") && length(repos)) return(repos) # if we're testing, re-use the test repositories - if (renv_bootstrap_tests_running()) { - repos <- getOption("renv.tests.repos") - if (!is.null(repos)) - return(repos) - } + if (renv_bootstrap_tests_running()) + return(getOption("renv.tests.repos")) # retrieve current repos repos <- getOption("repos") # ensure @CRAN@ entries are resolved - repos[repos == "@CRAN@"] <- cran + repos[repos == "@CRAN@"] <- getOption( + "renv.repos.cran", + "https://cloud.r-project.org" + ) # add in renv.bootstrap.repos if set default <- c(FALLBACK = "https://cloud.r-project.org") @@ -359,7 +344,8 @@ local({ return() # allow directories - if (dir.exists(tarball)) { + info <- file.info(tarball, extra_cols = FALSE) + if (identical(info$isdir, TRUE)) { name <- sprintf("renv_%s.tar.gz", version) tarball <- file.path(tarball, name) } @@ -673,8 +659,8 @@ local({ if (version == loadedversion) return(TRUE) - # assume four-component versions are from GitHub; - # three-component versions are from CRAN + # assume four-component versions are from GitHub; three-component + # versions are from CRAN components <- strsplit(loadedversion, "[.-]")[[1]] remote <- if (length(components) == 4L) paste("rstudio/renv", loadedversion, sep = "@") @@ -714,12 +700,6 @@ local({ # warn if the version of renv loaded does not match renv_bootstrap_validate_version(version) - # execute renv load hooks, if any - hooks <- getHook("renv::autoload") - for (hook in hooks) - if (is.function(hook)) - tryCatch(hook(), error = warning) - # load the project renv::load(project) @@ -862,29 +842,11 @@ local({ renv_json_read <- function(file = NULL, text = NULL) { - jlerr <- NULL - # if jsonlite is loaded, use that instead - if ("jsonlite" %in% loadedNamespaces()) { - - json <- catch(renv_json_read_jsonlite(file, text)) - if (!inherits(json, "error")) - return(json) - - jlerr <- json - - } - - # otherwise, fall back to the default JSON reader - json <- catch(renv_json_read_default(file, text)) - if (!inherits(json, "error")) - return(json) - - # report an error - if (!is.null(jlerr)) - stop(jlerr) + if ("jsonlite" %in% loadedNamespaces()) + renv_json_read_jsonlite(file, text) else - stop(json) + renv_json_read_default(file, text) } From 3a86205c370c8207cdea84533330bd0436015827 Mon Sep 17 00:00:00 2001 From: florianh Date: Thu, 6 Jul 2023 13:31:45 +0200 Subject: [PATCH 44/62] split-up of equations in 71_disagg_lvst --- .../foragebased_aug18/declarations.gms | 27 +++---- .../foragebased_aug18/equations.gms | 45 ++++------- .../foragebased_aug18/nl_fix.gms | 2 - .../foragebased_aug18/nl_release.gms | 2 - .../foragebased_aug18/postsolve.gms | 76 +++++++++---------- .../foragebased_aug18/preloop.gms | 1 - .../foragebased_aug18/scaling.gms | 2 +- 7 files changed, 64 insertions(+), 91 deletions(-) diff --git a/modules/71_disagg_lvst/foragebased_aug18/declarations.gms b/modules/71_disagg_lvst/foragebased_aug18/declarations.gms index 0be0b25043..dba353e7f2 100644 --- a/modules/71_disagg_lvst/foragebased_aug18/declarations.gms +++ b/modules/71_disagg_lvst/foragebased_aug18/declarations.gms @@ -6,7 +6,7 @@ *** | Contact: magpie@pik-potsdam.de positive variables - v71_prod_rum(j,kli_rum,kforage) Production of forage fed ruminants within a cell (mio. tDM per yr) + v71_feed_forage(j,kforage) Production of forage within a cell (mio. tDM per yr) v71_additional_mon(j, kli_mon) Additional punished production of monogastric livestock (mio. tDM per yr) vm_costs_additional_mon(i) Punishment cost for additionally transported monogastric livst_egg (mio. USD05MER per yr) ; @@ -17,9 +17,8 @@ variables equations q71_feed_rum_liv(j,kforage) Production constraint for ruminant livestock products (mio. tDM per yr) - q71_balanceflow_constraint_nlp(j,kforage) Nonlinear balanceflow constraint for cellular forage feed products (mio. tDM per yr) - q71_balanceflow_constraint_lp(i,kforage) Linear balanceflow constraint for cellular forage feed product (mio. tDM per yr) - q71_sum_rum_liv(j,kli_rum) Total production of forage fed ruminants (mio. tDM per yr) + q71_feed_forage(j) Forage feed constraint (mio. tDM per yr) + q71_feed_balanceflow(j) Balanceflow constraint for forage feed products (mio. tDM per yr) q71_prod_mon_liv(j,kli_mon) Production constraint for monogastric livestock products (mio. tDM per yr) q71_punishment_mon(i) Punishment for additional monogastrics (mio. USD05MER per yr) ; @@ -29,22 +28,20 @@ parameters ; scalars - s71_lp_fix Switch to fix equations to linear relation (Logical) s71_scale_mon Scalar for flexible distribution of monogastrics (1) s71_punish_additional_mon Scaling factor for transport punishment (USD05MER per tDM) ; *#################### R SECTION START (OUTPUT DECLARATIONS) #################### parameters - ov71_prod_rum(t,j,kli_rum,kforage,type) Production of forage fed ruminants within a cell (mio. tDM per yr) - ov71_additional_mon(t,j,kli_mon,type) Additional punished production of monogastric livestock (mio. tDM per yr) - ov_costs_additional_mon(t,i,type) Punishment cost for additionally transported monogastric livst_egg (mio. USD05MER per yr) - ov71_feed_balanceflow(t,j,kforage,type) Cellular feed balanceflow for forage feed for ruminant livestock (mio. tDM per yr) - oq71_feed_rum_liv(t,j,kforage,type) Production constraint for ruminant livestock products (mio. tDM per yr) - oq71_balanceflow_constraint_nlp(t,j,kforage,type) Nonlinear balanceflow constraint for cellular forage feed products (mio. tDM per yr) - oq71_balanceflow_constraint_lp(t,i,kforage,type) Linear balanceflow constraint for cellular forage feed product (mio. tDM per yr) - oq71_sum_rum_liv(t,j,kli_rum,type) Total production of forage fed ruminants (mio. tDM per yr) - oq71_prod_mon_liv(t,j,kli_mon,type) Production constraint for monogastric livestock products (mio. tDM per yr) - oq71_punishment_mon(t,i,type) Punishment for additional monogastrics (mio. USD05MER per yr) + ov71_feed_forage(t,j,kforage,type) Production of forage within a cell (mio. tDM per yr) + ov71_additional_mon(t,j,kli_mon,type) Additional punished production of monogastric livestock (mio. tDM per yr) + ov_costs_additional_mon(t,i,type) Punishment cost for additionally transported monogastric livst_egg (mio. USD05MER per yr) + ov71_feed_balanceflow(t,j,kforage,type) Cellular feed balanceflow for forage feed for ruminant livestock (mio. tDM per yr) + oq71_feed_rum_liv(t,j,kforage,type) Production constraint for ruminant livestock products (mio. tDM per yr) + oq71_feed_forage(t,j,type) Forage feed constraint (mio. tDM per yr) + oq71_feed_balanceflow(t,j,type) Balanceflow constraint for forage feed products (mio. tDM per yr) + oq71_prod_mon_liv(t,j,kli_mon,type) Production constraint for monogastric livestock products (mio. tDM per yr) + oq71_punishment_mon(t,i,type) Punishment for additional monogastrics (mio. USD05MER per yr) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/71_disagg_lvst/foragebased_aug18/equations.gms b/modules/71_disagg_lvst/foragebased_aug18/equations.gms index 36467f4f9d..ba45a895e3 100644 --- a/modules/71_disagg_lvst/foragebased_aug18/equations.gms +++ b/modules/71_disagg_lvst/foragebased_aug18/equations.gms @@ -8,51 +8,36 @@ *' @equations *' Ruminant livestock production within a cell is determined by the production of the non-transportable -*' feed items grazed pasture and fodder. These must be larger than the ruminant feed requirements -*' that are given by the product of ruminant production and the respective feed baskets: +*' feed items grazed pasture and fodder (`kforage`). Forage production must be larger than the ruminant feed requirements +*' (`v71_feed_forage`) adjusted by a balance flow (`v71_feed_forage`). q71_feed_rum_liv(j2,kforage) .. vm_prod(j2,kforage) =g= - sum(kli_rum, v71_prod_rum(j2,kli_rum,kforage) - * sum((ct,cell(i2,j2)),im_feed_baskets(ct,i2,kli_rum,kforage))) + v71_feed_forage(j2,kforage) + v71_feed_balanceflow(j2,kforage); +*' Ruminant feed requirements are given by the product of ruminant production and the respective feed baskets. + +q71_feed_forage(j2) .. + sum(kforage, v71_feed_forage(j2,kforage)) =e= + sum((kli_rum,kforage), vm_prod(j2,kli_rum) + * sum((ct,cell(i2,j2)),im_feed_baskets(ct,i2,kli_rum,kforage))); + *' The above equation contains a split of pasture and fodder fed ruminants, since we assume that depending *' on the intensity level of the livestock production, ruminants will graze on pastures (extensive systems) *' or will be fed via harvested fodder crops (intensive systems). -*' Please note that `s71_lp_fix` is set to zero (for more information please look into the source code). - -*' The balance flow for pasture and fodder (summarized with forage) production, accounts as in -*' [70_livestock] `q70_feed(i2,kap,kall)` for inconsistencies with the FAO inventory of national feed use. -*' @stop - -* If module is fixed to linear behaviour the balance flow is allowed to be used in any cell -* containing pasture or cropland area in the previous time step ensured by the restrictions -* in the nl_fix statement. The balance flow within a region is then determined by - -q71_balanceflow_constraint_lp(i2,kforage)$(s71_lp_fix=1) .. - sum(cell(i2,j2), v71_feed_balanceflow(j2,kforage)) =e= - sum((ct,kli_rum), fm_feed_balanceflow(ct,i2,kli_rum,kforage)) - ; - -* Note that for fixation to linear behaviour `q71_balanceflow_constraint_lp` replaces `q71_balanceflow_constraint_nlp`. - -*' @equations +*' The balance flow for pasture and fodder production (`kforage`) accounts as in +*' [70_livestock] `q70_feed(i2,kap,kall)` for inconsistencies with the FAO inventory of national feed use. *' In each cluster the balance flow is constrained by its share of livestock production regarding the regional level by -q71_balanceflow_constraint_nlp(j2,kforage)$(s71_lp_fix=0) .. - v71_feed_balanceflow(j2,kforage) =e= - sum((ct,cell(i2,j2),kli_rum), fm_feed_balanceflow(ct,i2,kli_rum,kforage) +q71_feed_balanceflow(j2) .. + sum(kforage, v71_feed_balanceflow(j2,kforage)) =e= + sum((ct,cell(i2,j2),kli_rum,kforage), fm_feed_balanceflow(ct,i2,kli_rum,kforage) * (vm_prod(j2,kli_rum) / (vm_prod_reg(i2,kli_rum) + 10**(-6)))); *' Note that $10^{-6}$ is required to avoid division by zero. -*' The regional ruminant production is then given by - -q71_sum_rum_liv(j2,kli_rum) .. - vm_prod(j2,kli_rum) =e= sum(kforage,v71_prod_rum(j2,kli_rum,kforage)) - ; *' To account for the above mentioned fact that monogastric livestock are held close to the population, it is *' distributed based on urban area by the formula diff --git a/modules/71_disagg_lvst/foragebased_aug18/nl_fix.gms b/modules/71_disagg_lvst/foragebased_aug18/nl_fix.gms index d0e261fa4b..c583b2e187 100644 --- a/modules/71_disagg_lvst/foragebased_aug18/nl_fix.gms +++ b/modules/71_disagg_lvst/foragebased_aug18/nl_fix.gms @@ -12,5 +12,3 @@ v71_feed_balanceflow.up(j,kforage)$(sum((cell(i,j),kli_rum),fm_feed_balanceflow( v71_feed_balanceflow.fx(j,kforage)$(sum((cell(i,j),kli_rum),fm_feed_balanceflow(t,i,kli_rum,kforage)) = 0) = 0; v71_feed_balanceflow.fx(j,"pasture")$(pcm_land(j,"past")=0) = 0; v71_feed_balanceflow.fx(j,"foddr")$(pcm_land(j,"crop")=0) = 0; - -s71_lp_fix=1; diff --git a/modules/71_disagg_lvst/foragebased_aug18/nl_release.gms b/modules/71_disagg_lvst/foragebased_aug18/nl_release.gms index f2d5e64281..7b216fd4c5 100644 --- a/modules/71_disagg_lvst/foragebased_aug18/nl_release.gms +++ b/modules/71_disagg_lvst/foragebased_aug18/nl_release.gms @@ -9,5 +9,3 @@ v71_feed_balanceflow.lo(j,kforage)= -Inf; v71_feed_balanceflow.up(j,kforage)= Inf; - -s71_lp_fix=0; diff --git a/modules/71_disagg_lvst/foragebased_aug18/postsolve.gms b/modules/71_disagg_lvst/foragebased_aug18/postsolve.gms index c035ac00f7..17d93693a3 100644 --- a/modules/71_disagg_lvst/foragebased_aug18/postsolve.gms +++ b/modules/71_disagg_lvst/foragebased_aug18/postsolve.gms @@ -6,44 +6,40 @@ *** | Contact: magpie@pik-potsdam.de *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov71_prod_rum(t,j,kli_rum,kforage,"marginal") = v71_prod_rum.m(j,kli_rum,kforage); - ov71_additional_mon(t,j,kli_mon,"marginal") = v71_additional_mon.m(j,kli_mon); - ov_costs_additional_mon(t,i,"marginal") = vm_costs_additional_mon.m(i); - ov71_feed_balanceflow(t,j,kforage,"marginal") = v71_feed_balanceflow.m(j,kforage); - oq71_feed_rum_liv(t,j,kforage,"marginal") = q71_feed_rum_liv.m(j,kforage); - oq71_balanceflow_constraint_nlp(t,j,kforage,"marginal") = q71_balanceflow_constraint_nlp.m(j,kforage); - oq71_balanceflow_constraint_lp(t,i,kforage,"marginal") = q71_balanceflow_constraint_lp.m(i,kforage); - oq71_sum_rum_liv(t,j,kli_rum,"marginal") = q71_sum_rum_liv.m(j,kli_rum); - oq71_prod_mon_liv(t,j,kli_mon,"marginal") = q71_prod_mon_liv.m(j,kli_mon); - oq71_punishment_mon(t,i,"marginal") = q71_punishment_mon.m(i); - ov71_prod_rum(t,j,kli_rum,kforage,"level") = v71_prod_rum.l(j,kli_rum,kforage); - ov71_additional_mon(t,j,kli_mon,"level") = v71_additional_mon.l(j,kli_mon); - ov_costs_additional_mon(t,i,"level") = vm_costs_additional_mon.l(i); - ov71_feed_balanceflow(t,j,kforage,"level") = v71_feed_balanceflow.l(j,kforage); - oq71_feed_rum_liv(t,j,kforage,"level") = q71_feed_rum_liv.l(j,kforage); - oq71_balanceflow_constraint_nlp(t,j,kforage,"level") = q71_balanceflow_constraint_nlp.l(j,kforage); - oq71_balanceflow_constraint_lp(t,i,kforage,"level") = q71_balanceflow_constraint_lp.l(i,kforage); - oq71_sum_rum_liv(t,j,kli_rum,"level") = q71_sum_rum_liv.l(j,kli_rum); - oq71_prod_mon_liv(t,j,kli_mon,"level") = q71_prod_mon_liv.l(j,kli_mon); - oq71_punishment_mon(t,i,"level") = q71_punishment_mon.l(i); - ov71_prod_rum(t,j,kli_rum,kforage,"upper") = v71_prod_rum.up(j,kli_rum,kforage); - ov71_additional_mon(t,j,kli_mon,"upper") = v71_additional_mon.up(j,kli_mon); - ov_costs_additional_mon(t,i,"upper") = vm_costs_additional_mon.up(i); - ov71_feed_balanceflow(t,j,kforage,"upper") = v71_feed_balanceflow.up(j,kforage); - oq71_feed_rum_liv(t,j,kforage,"upper") = q71_feed_rum_liv.up(j,kforage); - oq71_balanceflow_constraint_nlp(t,j,kforage,"upper") = q71_balanceflow_constraint_nlp.up(j,kforage); - oq71_balanceflow_constraint_lp(t,i,kforage,"upper") = q71_balanceflow_constraint_lp.up(i,kforage); - oq71_sum_rum_liv(t,j,kli_rum,"upper") = q71_sum_rum_liv.up(j,kli_rum); - oq71_prod_mon_liv(t,j,kli_mon,"upper") = q71_prod_mon_liv.up(j,kli_mon); - oq71_punishment_mon(t,i,"upper") = q71_punishment_mon.up(i); - ov71_prod_rum(t,j,kli_rum,kforage,"lower") = v71_prod_rum.lo(j,kli_rum,kforage); - ov71_additional_mon(t,j,kli_mon,"lower") = v71_additional_mon.lo(j,kli_mon); - ov_costs_additional_mon(t,i,"lower") = vm_costs_additional_mon.lo(i); - ov71_feed_balanceflow(t,j,kforage,"lower") = v71_feed_balanceflow.lo(j,kforage); - oq71_feed_rum_liv(t,j,kforage,"lower") = q71_feed_rum_liv.lo(j,kforage); - oq71_balanceflow_constraint_nlp(t,j,kforage,"lower") = q71_balanceflow_constraint_nlp.lo(j,kforage); - oq71_balanceflow_constraint_lp(t,i,kforage,"lower") = q71_balanceflow_constraint_lp.lo(i,kforage); - oq71_sum_rum_liv(t,j,kli_rum,"lower") = q71_sum_rum_liv.lo(j,kli_rum); - oq71_prod_mon_liv(t,j,kli_mon,"lower") = q71_prod_mon_liv.lo(j,kli_mon); - oq71_punishment_mon(t,i,"lower") = q71_punishment_mon.lo(i); + ov71_feed_forage(t,j,kforage,"marginal") = v71_feed_forage.m(j,kforage); + ov71_additional_mon(t,j,kli_mon,"marginal") = v71_additional_mon.m(j,kli_mon); + ov_costs_additional_mon(t,i,"marginal") = vm_costs_additional_mon.m(i); + ov71_feed_balanceflow(t,j,kforage,"marginal") = v71_feed_balanceflow.m(j,kforage); + oq71_feed_rum_liv(t,j,kforage,"marginal") = q71_feed_rum_liv.m(j,kforage); + oq71_feed_forage(t,j,"marginal") = q71_feed_forage.m(j); + oq71_feed_balanceflow(t,j,"marginal") = q71_feed_balanceflow.m(j); + oq71_prod_mon_liv(t,j,kli_mon,"marginal") = q71_prod_mon_liv.m(j,kli_mon); + oq71_punishment_mon(t,i,"marginal") = q71_punishment_mon.m(i); + ov71_feed_forage(t,j,kforage,"level") = v71_feed_forage.l(j,kforage); + ov71_additional_mon(t,j,kli_mon,"level") = v71_additional_mon.l(j,kli_mon); + ov_costs_additional_mon(t,i,"level") = vm_costs_additional_mon.l(i); + ov71_feed_balanceflow(t,j,kforage,"level") = v71_feed_balanceflow.l(j,kforage); + oq71_feed_rum_liv(t,j,kforage,"level") = q71_feed_rum_liv.l(j,kforage); + oq71_feed_forage(t,j,"level") = q71_feed_forage.l(j); + oq71_feed_balanceflow(t,j,"level") = q71_feed_balanceflow.l(j); + oq71_prod_mon_liv(t,j,kli_mon,"level") = q71_prod_mon_liv.l(j,kli_mon); + oq71_punishment_mon(t,i,"level") = q71_punishment_mon.l(i); + ov71_feed_forage(t,j,kforage,"upper") = v71_feed_forage.up(j,kforage); + ov71_additional_mon(t,j,kli_mon,"upper") = v71_additional_mon.up(j,kli_mon); + ov_costs_additional_mon(t,i,"upper") = vm_costs_additional_mon.up(i); + ov71_feed_balanceflow(t,j,kforage,"upper") = v71_feed_balanceflow.up(j,kforage); + oq71_feed_rum_liv(t,j,kforage,"upper") = q71_feed_rum_liv.up(j,kforage); + oq71_feed_forage(t,j,"upper") = q71_feed_forage.up(j); + oq71_feed_balanceflow(t,j,"upper") = q71_feed_balanceflow.up(j); + oq71_prod_mon_liv(t,j,kli_mon,"upper") = q71_prod_mon_liv.up(j,kli_mon); + oq71_punishment_mon(t,i,"upper") = q71_punishment_mon.up(i); + ov71_feed_forage(t,j,kforage,"lower") = v71_feed_forage.lo(j,kforage); + ov71_additional_mon(t,j,kli_mon,"lower") = v71_additional_mon.lo(j,kli_mon); + ov_costs_additional_mon(t,i,"lower") = vm_costs_additional_mon.lo(i); + ov71_feed_balanceflow(t,j,kforage,"lower") = v71_feed_balanceflow.lo(j,kforage); + oq71_feed_rum_liv(t,j,kforage,"lower") = q71_feed_rum_liv.lo(j,kforage); + oq71_feed_forage(t,j,"lower") = q71_feed_forage.lo(j); + oq71_feed_balanceflow(t,j,"lower") = q71_feed_balanceflow.lo(j); + oq71_prod_mon_liv(t,j,kli_mon,"lower") = q71_prod_mon_liv.lo(j,kli_mon); + oq71_punishment_mon(t,i,"lower") = q71_punishment_mon.lo(i); *##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/71_disagg_lvst/foragebased_aug18/preloop.gms b/modules/71_disagg_lvst/foragebased_aug18/preloop.gms index e7235b9da5..19c0e2b6aa 100644 --- a/modules/71_disagg_lvst/foragebased_aug18/preloop.gms +++ b/modules/71_disagg_lvst/foragebased_aug18/preloop.gms @@ -9,6 +9,5 @@ i71_urban_area_share(j) = pm_land_start(j,"urban")/sum(cell(i,j),sum(cell2(i,j3),pm_land_start(j3,"urban"))) ; -s71_lp_fix = 0; s71_scale_mon = 1.10; s71_punish_additional_mon = 15000; diff --git a/modules/71_disagg_lvst/foragebased_aug18/scaling.gms b/modules/71_disagg_lvst/foragebased_aug18/scaling.gms index b4939dbc37..f6d1479d6c 100644 --- a/modules/71_disagg_lvst/foragebased_aug18/scaling.gms +++ b/modules/71_disagg_lvst/foragebased_aug18/scaling.gms @@ -7,4 +7,4 @@ vm_costs_additional_mon.scale(i) = 10e4; *Don't scale this variable. Model is very sensitive to scaling this variable and might become infeasible or very slow. -*v71_feed_balanceflow.scale(j,kli_rum,kforage) = 10e3; +*v71_feed_balanceflow.scale(j,kforage) = 10e3; From b167a45069e60fb6de591777d5807b5ff12fb8f7 Mon Sep 17 00:00:00 2001 From: pvjeetze Date: Fri, 7 Jul 2023 16:05:13 +0200 Subject: [PATCH 45/62] new output script for reporting land use to SEALS --- scripts/output/extra/reportMAgPIE2SEALS.R | 40 +++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 scripts/output/extra/reportMAgPIE2SEALS.R diff --git a/scripts/output/extra/reportMAgPIE2SEALS.R b/scripts/output/extra/reportMAgPIE2SEALS.R new file mode 100644 index 0000000000..eb4ea1dacc --- /dev/null +++ b/scripts/output/extra/reportMAgPIE2SEALS.R @@ -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 + +# -------------------------------------------------------------- +# description: Modifies gridded MAgPIE land use patterns so that they can be read in by the Spatial Economic Allocation Landscape Simulator (SEALS) +# comparison script: FALSE +# --------------------------------------------------------------- + +# Version 1.00 - Patrick v. Jeetze +# 1.00: first working version + +library(gms) +library(magpie4) + +message("Starting to report gridded MAgPIE land use for SEALS") + +############################# BASIC CONFIGURATION ####################################### +if (!exists("source_include")) { + title <- NULL + outputdir <- NULL + + # Define arguments that can be read from command line + readArgs("outputdir", "title") +} +######################################################################################### + +message("Script started for output directory: ", outputdir) +cfg <- gms::loadConfig(file.path(outputdir, "config.yml")) +title <- cfg$title + +# Restructure data to conform to SEALS +reportLandUseForSEALS( + magCellLand = "cell.land_0.5_share.nc", + outFile = paste0("cell.land_0.5_SEALS_", title, ".nc"), + dir = outputdir, selectyears = c(2015, 2050) +) From f717c567da5c1c4e0d63e765e2d89c7616f90dd2 Mon Sep 17 00:00:00 2001 From: pvjeetze Date: Fri, 7 Jul 2023 16:13:00 +0200 Subject: [PATCH 46/62] changed CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cfeba0fda7..9b88e25b12 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **41_area_equipped_for_irrigation** new AEI data (Mehta2022) replacing old Siebert data ### added +- **scripts** New output script for reporting disaggregated land use patterns to the SEALS (Spatial Economic Allocation Landscape Simulator) downscaling model - **scenario_config.csv** added a scenario for the NGFS project - **config** new area equipped for irrigation (AEI) data in preprocessing (4.87) - **31_past** added `cc`, `nocc` and `nocc_hist` options for `c31_past_suit_scen` and `c31_grassl_yld_scenario` From d0802a100a5c0f723d6b8a09ed91342073997dea Mon Sep 17 00:00:00 2001 From: florianh Date: Sat, 8 Jul 2023 08:14:52 +0200 Subject: [PATCH 47/62] lower bound for vm_prod livst_rum --- .../foragebased_aug18/declarations.gms | 7 +++++-- .../foragebased_aug18/equations.gms | 18 +++++++++++++++--- .../foragebased_aug18/postsolve.gms | 12 ++++++++---- .../foragebased_aug18/preloop.gms | 4 ++++ 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/modules/71_disagg_lvst/foragebased_aug18/declarations.gms b/modules/71_disagg_lvst/foragebased_aug18/declarations.gms index dba353e7f2..0bbcb46044 100644 --- a/modules/71_disagg_lvst/foragebased_aug18/declarations.gms +++ b/modules/71_disagg_lvst/foragebased_aug18/declarations.gms @@ -18,7 +18,8 @@ variables equations q71_feed_rum_liv(j,kforage) Production constraint for ruminant livestock products (mio. tDM per yr) q71_feed_forage(j) Forage feed constraint (mio. tDM per yr) - q71_feed_balanceflow(j) Balanceflow constraint for forage feed products (mio. tDM per yr) + q71_feed_balanceflow_nlp(j) Non-linear balanceflow constraint for forage feed products (mio. tDM per yr) + q71_feed_balanceflow_lp(i) Linear balanceflow constraint for forage feed products (mio. tDM per yr) q71_prod_mon_liv(j,kli_mon) Production constraint for monogastric livestock products (mio. tDM per yr) q71_punishment_mon(i) Punishment for additional monogastrics (mio. USD05MER per yr) ; @@ -28,6 +29,7 @@ parameters ; scalars + s71_lp_fix Switch to fix equations to linear relation (Logical) s71_scale_mon Scalar for flexible distribution of monogastrics (1) s71_punish_additional_mon Scaling factor for transport punishment (USD05MER per tDM) ; @@ -40,7 +42,8 @@ parameters ov71_feed_balanceflow(t,j,kforage,type) Cellular feed balanceflow for forage feed for ruminant livestock (mio. tDM per yr) oq71_feed_rum_liv(t,j,kforage,type) Production constraint for ruminant livestock products (mio. tDM per yr) oq71_feed_forage(t,j,type) Forage feed constraint (mio. tDM per yr) - oq71_feed_balanceflow(t,j,type) Balanceflow constraint for forage feed products (mio. tDM per yr) + oq71_feed_balanceflow_nlp(t,j,type) Non-linear balanceflow constraint for forage feed products (mio. tDM per yr) + oq71_feed_balanceflow_lp(t,i,type) Linear balanceflow constraint for forage feed products (mio. tDM per yr) oq71_prod_mon_liv(t,j,kli_mon,type) Production constraint for monogastric livestock products (mio. tDM per yr) oq71_punishment_mon(t,i,type) Punishment for additional monogastrics (mio. USD05MER per yr) ; diff --git a/modules/71_disagg_lvst/foragebased_aug18/equations.gms b/modules/71_disagg_lvst/foragebased_aug18/equations.gms index ba45a895e3..e220bc9a52 100644 --- a/modules/71_disagg_lvst/foragebased_aug18/equations.gms +++ b/modules/71_disagg_lvst/foragebased_aug18/equations.gms @@ -32,12 +32,24 @@ q71_feed_forage(j2) .. *' [70_livestock] `q70_feed(i2,kap,kall)` for inconsistencies with the FAO inventory of national feed use. *' In each cluster the balance flow is constrained by its share of livestock production regarding the regional level by -q71_feed_balanceflow(j2) .. +q71_feed_balanceflow_nlp(j2)$(s71_lp_fix=0) .. sum(kforage, v71_feed_balanceflow(j2,kforage)) =e= sum((ct,cell(i2,j2),kli_rum,kforage), fm_feed_balanceflow(ct,i2,kli_rum,kforage) - * (vm_prod(j2,kli_rum) / (vm_prod_reg(i2,kli_rum) + 10**(-6)))); + * (vm_prod(j2,kli_rum) / (vm_prod_reg(i2,kli_rum)))); + +*' @stop + +* If fixed to linear behaviour (`s71_lp_fix=1`) the balance flow for pasture and fodder production (`kforage`) +* can be freely distributed among all cells beloning to a region. + +q71_feed_balanceflow_lp(i2)$(s71_lp_fix=1) .. + sum((cell(i2,j2),kforage), v71_feed_balanceflow(j2,kforage)) =e= + sum((ct,kli_rum,kforage), fm_feed_balanceflow(ct,i2,kli_rum,kforage)); + +* Note that for fixation to linear behaviour `q71_feed_balanceflow_lp` replaces `q71_feed_balanceflow_nlp`. + +*' @equations -*' Note that $10^{-6}$ is required to avoid division by zero. *' To account for the above mentioned fact that monogastric livestock are held close to the population, it is *' distributed based on urban area by the formula diff --git a/modules/71_disagg_lvst/foragebased_aug18/postsolve.gms b/modules/71_disagg_lvst/foragebased_aug18/postsolve.gms index 17d93693a3..959882e6e9 100644 --- a/modules/71_disagg_lvst/foragebased_aug18/postsolve.gms +++ b/modules/71_disagg_lvst/foragebased_aug18/postsolve.gms @@ -12,7 +12,8 @@ ov71_feed_balanceflow(t,j,kforage,"marginal") = v71_feed_balanceflow.m(j,kforage); oq71_feed_rum_liv(t,j,kforage,"marginal") = q71_feed_rum_liv.m(j,kforage); oq71_feed_forage(t,j,"marginal") = q71_feed_forage.m(j); - oq71_feed_balanceflow(t,j,"marginal") = q71_feed_balanceflow.m(j); + oq71_feed_balanceflow_nlp(t,j,"marginal") = q71_feed_balanceflow_nlp.m(j); + oq71_feed_balanceflow_lp(t,i,"marginal") = q71_feed_balanceflow_lp.m(i); oq71_prod_mon_liv(t,j,kli_mon,"marginal") = q71_prod_mon_liv.m(j,kli_mon); oq71_punishment_mon(t,i,"marginal") = q71_punishment_mon.m(i); ov71_feed_forage(t,j,kforage,"level") = v71_feed_forage.l(j,kforage); @@ -21,7 +22,8 @@ ov71_feed_balanceflow(t,j,kforage,"level") = v71_feed_balanceflow.l(j,kforage); oq71_feed_rum_liv(t,j,kforage,"level") = q71_feed_rum_liv.l(j,kforage); oq71_feed_forage(t,j,"level") = q71_feed_forage.l(j); - oq71_feed_balanceflow(t,j,"level") = q71_feed_balanceflow.l(j); + oq71_feed_balanceflow_nlp(t,j,"level") = q71_feed_balanceflow_nlp.l(j); + oq71_feed_balanceflow_lp(t,i,"level") = q71_feed_balanceflow_lp.l(i); oq71_prod_mon_liv(t,j,kli_mon,"level") = q71_prod_mon_liv.l(j,kli_mon); oq71_punishment_mon(t,i,"level") = q71_punishment_mon.l(i); ov71_feed_forage(t,j,kforage,"upper") = v71_feed_forage.up(j,kforage); @@ -30,7 +32,8 @@ ov71_feed_balanceflow(t,j,kforage,"upper") = v71_feed_balanceflow.up(j,kforage); oq71_feed_rum_liv(t,j,kforage,"upper") = q71_feed_rum_liv.up(j,kforage); oq71_feed_forage(t,j,"upper") = q71_feed_forage.up(j); - oq71_feed_balanceflow(t,j,"upper") = q71_feed_balanceflow.up(j); + oq71_feed_balanceflow_nlp(t,j,"upper") = q71_feed_balanceflow_nlp.up(j); + oq71_feed_balanceflow_lp(t,i,"upper") = q71_feed_balanceflow_lp.up(i); oq71_prod_mon_liv(t,j,kli_mon,"upper") = q71_prod_mon_liv.up(j,kli_mon); oq71_punishment_mon(t,i,"upper") = q71_punishment_mon.up(i); ov71_feed_forage(t,j,kforage,"lower") = v71_feed_forage.lo(j,kforage); @@ -39,7 +42,8 @@ ov71_feed_balanceflow(t,j,kforage,"lower") = v71_feed_balanceflow.lo(j,kforage); oq71_feed_rum_liv(t,j,kforage,"lower") = q71_feed_rum_liv.lo(j,kforage); oq71_feed_forage(t,j,"lower") = q71_feed_forage.lo(j); - oq71_feed_balanceflow(t,j,"lower") = q71_feed_balanceflow.lo(j); + oq71_feed_balanceflow_nlp(t,j,"lower") = q71_feed_balanceflow_nlp.lo(j); + oq71_feed_balanceflow_lp(t,i,"lower") = q71_feed_balanceflow_lp.lo(i); oq71_prod_mon_liv(t,j,kli_mon,"lower") = q71_prod_mon_liv.lo(j,kli_mon); oq71_punishment_mon(t,i,"lower") = q71_punishment_mon.lo(i); *##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/71_disagg_lvst/foragebased_aug18/preloop.gms b/modules/71_disagg_lvst/foragebased_aug18/preloop.gms index 19c0e2b6aa..b4a0510e06 100644 --- a/modules/71_disagg_lvst/foragebased_aug18/preloop.gms +++ b/modules/71_disagg_lvst/foragebased_aug18/preloop.gms @@ -9,5 +9,9 @@ i71_urban_area_share(j) = pm_land_start(j,"urban")/sum(cell(i,j),sum(cell2(i,j3),pm_land_start(j3,"urban"))) ; +s71_lp_fix = 0; s71_scale_mon = 1.10; s71_punish_additional_mon = 15000; + +* Minimal regional production of `kli_rum` to avoid division by zero in `q71_feed_balanceflow_nlp`. +vm_prod_reg.lo(i,kli_rum)$(s71_lp_fix=0) = 10**(-6); From e6e70c45a88366afb616013b7f1c607eb9dbe90f Mon Sep 17 00:00:00 2001 From: florianh Date: Sat, 8 Jul 2023 09:27:20 +0200 Subject: [PATCH 48/62] bugfix highres connection --- scripts/output/extra/highres.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/output/extra/highres.R b/scripts/output/extra/highres.R index 370d525b5a..60083fafff 100644 --- a/scripts/output/extra/highres.R +++ b/scripts/output/extra/highres.R @@ -74,9 +74,9 @@ highres <- function(cfg) { #list files with sftp command path <- paste0(sub("scp://","sftp://",repo),"/") h <- try(curl::new_handle(verbose = debug, .list = repositories[[repo]], ftp_use_epsv = TRUE, dirlistonly = TRUE), silent = TRUE) - con <- curl::curl(url = path, "r", handle = h) + con <- try(curl::curl(url = path, "r", handle = h), silent = TRUE) dat <- try(readLines(con), silent = TRUE) - close(con) + try(close(con), silent = TRUE) found <- c(found,grep(glob2rx(file),dat,value = T)) } else if (dir.exists(repo)) { dat <- list.files(repo) From 612ccd994139e73cac414f016fbe3480a2a67e6f Mon Sep 17 00:00:00 2001 From: florianh Date: Sun, 9 Jul 2023 08:24:42 +0200 Subject: [PATCH 49/62] update calib factors --- config/default.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/default.cfg b/config/default.cfg index 08b5053ec3..4510e80153 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -26,7 +26,7 @@ cfg$input <- c(regional = "rev4.87_h12_magpie.tgz", cellular = "rev4.87_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", validation = "rev4.87_h12_validation.tgz", additional = "additional_data_rev4.43.tgz", - calibration = "calibration_H12_per_ton_fao_may22_glo_23Mar23.tgz") + calibration = "calibration_H12_per_ton_fao_may22_glo_08Jul23.tgz") # NOTE: It is recommended to recalibrate the model when changing cellular input data # as well as for any other setting that would affect initial values in the model, From 74545accb283146d1f52e49ae07346fc71f727b7 Mon Sep 17 00:00:00 2001 From: florianh Date: Tue, 11 Jul 2023 10:54:33 +0200 Subject: [PATCH 50/62] added new realisation foragebased_jul23 --- CHANGELOG.md | 2 +- config/default.cfg | 6 +- .../foragebased_aug18/declarations.gms | 32 ++++---- .../foragebased_aug18/equations.gms | 55 +++++++------ .../foragebased_aug18/nl_fix.gms | 12 +-- .../foragebased_aug18/nl_release.gms | 6 +- .../foragebased_aug18/postsolve.gms | 80 +++++++++---------- .../foragebased_aug18/preloop.gms | 3 - .../foragebased_aug18/scaling.gms | 2 +- .../foragebased_jul23/declarations.gms | 50 ++++++++++++ .../foragebased_jul23/equations.gms | 74 +++++++++++++++++ .../foragebased_jul23/nl_fix.gms | 14 ++++ .../foragebased_jul23/nl_release.gms | 11 +++ .../foragebased_jul23/postsolve.gms | 49 ++++++++++++ .../foragebased_jul23/preloop.gms | 17 ++++ .../foragebased_jul23/realization.gms | 27 +++++++ .../foragebased_jul23/scaling.gms | 10 +++ .../71_disagg_lvst/foragebased_jul23/sets.gms | 27 +++++++ modules/71_disagg_lvst/module.gms | 1 + 19 files changed, 385 insertions(+), 93 deletions(-) create mode 100644 modules/71_disagg_lvst/foragebased_jul23/declarations.gms create mode 100644 modules/71_disagg_lvst/foragebased_jul23/equations.gms create mode 100644 modules/71_disagg_lvst/foragebased_jul23/nl_fix.gms create mode 100644 modules/71_disagg_lvst/foragebased_jul23/nl_release.gms create mode 100644 modules/71_disagg_lvst/foragebased_jul23/postsolve.gms create mode 100644 modules/71_disagg_lvst/foragebased_jul23/preloop.gms create mode 100644 modules/71_disagg_lvst/foragebased_jul23/realization.gms create mode 100644 modules/71_disagg_lvst/foragebased_jul23/scaling.gms create mode 100644 modules/71_disagg_lvst/foragebased_jul23/sets.gms diff --git a/CHANGELOG.md b/CHANGELOG.md index d260bbe211..7a5722d190 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **31_past** added `cc`, `nocc` and `nocc_hist` options for `c31_past_suit_scen` and `c31_grassl_yld_scenario` - **32_carbon** added `nocc` and `nocc_hist` option for `c52_land_carbon_sink_rcp` - **config** added `cfg$results_folder_highres` which allows to modify the output folder used in the `highres.R` output script +- **71_disagg_lvst** added new realisation `foragebased_jul23` which solves GAMS issues at higher spatial resolutions ### removed - **config** s80_num_nonopt_allowed @@ -25,7 +26,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### fixed - **config** updated scenario configs to newest preprocessing (4.87) - **config** corrected wrong names of parameters for peatland costs -- **71_disagg_lvst** wrong unit of v71_feed_balanceflow and too high values (also resolution-dependent) in case of s71_lp_fix = 0 (default) - **80_optimization** resolve was not working in nlp_par realization due to s80_num_nonopt_allowed ## [4.6.7] - 2023-05-10 diff --git a/config/default.cfg b/config/default.cfg index 4510e80153..4d952abad4 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -1730,7 +1730,11 @@ cfg$gms$c70_fac_req_regr <- "glo" # def = glo # * (off): default # * (foragebased_aug18): Disaggregation of livestock to cells # * with high pasture and fodder availability -cfg$gms$disagg_lvst <- "foragebased_aug18" # def = foragebased_aug18 +# * (foragebased_jul23): Disaggregation of livestock to cells +# * with high pasture and fodder availability. +# * Includes a minimal lower bound for ruminant production to avoid +# * avoid GAMS corner solutions at higher spatial resolutions. +cfg$gms$disagg_lvst <- "foragebased_jul23" # def = foragebased_jul23 # ***--------------------- 73_timber ----------------------------------- diff --git a/modules/71_disagg_lvst/foragebased_aug18/declarations.gms b/modules/71_disagg_lvst/foragebased_aug18/declarations.gms index 0bbcb46044..d68611a046 100644 --- a/modules/71_disagg_lvst/foragebased_aug18/declarations.gms +++ b/modules/71_disagg_lvst/foragebased_aug18/declarations.gms @@ -6,22 +6,22 @@ *** | Contact: magpie@pik-potsdam.de positive variables - v71_feed_forage(j,kforage) Production of forage within a cell (mio. tDM per yr) + v71_prod_rum(j,kli_rum,kforage) Production of forage fed ruminants within a cell (mio. tDM per yr) v71_additional_mon(j, kli_mon) Additional punished production of monogastric livestock (mio. tDM per yr) vm_costs_additional_mon(i) Punishment cost for additionally transported monogastric livst_egg (mio. USD05MER per yr) ; variables - v71_feed_balanceflow(j,kforage) Cellular feed balanceflow for forage feed for ruminant livestock (mio. tDM per yr) + v71_feed_balanceflow(j,kli_rum,kforage) Cellular feed balanceflow for forage feed for ruminant livestock (mio. tDM per yr) ; equations q71_feed_rum_liv(j,kforage) Production constraint for ruminant livestock products (mio. tDM per yr) - q71_feed_forage(j) Forage feed constraint (mio. tDM per yr) - q71_feed_balanceflow_nlp(j) Non-linear balanceflow constraint for forage feed products (mio. tDM per yr) - q71_feed_balanceflow_lp(i) Linear balanceflow constraint for forage feed products (mio. tDM per yr) + q71_balanceflow_constraint_nlp(j,kli_rum,kforage) Nonlinear balanceflow constraint for cellular forage feed products (mio. tDM per yr) + q71_balanceflow_constraint_lp(i,kli_rum,kforage) Linear balanceflow constraint for cellular forage feed product (mio. tDM per yr) + q71_sum_rum_liv(j,kli_rum) Total production of forage fed ruminants (mio. tDM per yr) q71_prod_mon_liv(j,kli_mon) Production constraint for monogastric livestock products (mio. tDM per yr) - q71_punishment_mon(i) Punishment for additional monogastrics (mio. USD05MER per yr) + q71_punishment_mon(i) Punishment for additional monogastrics (mio. USD05MER per yr) ; parameters @@ -36,15 +36,15 @@ scalars *#################### R SECTION START (OUTPUT DECLARATIONS) #################### parameters - ov71_feed_forage(t,j,kforage,type) Production of forage within a cell (mio. tDM per yr) - ov71_additional_mon(t,j,kli_mon,type) Additional punished production of monogastric livestock (mio. tDM per yr) - ov_costs_additional_mon(t,i,type) Punishment cost for additionally transported monogastric livst_egg (mio. USD05MER per yr) - ov71_feed_balanceflow(t,j,kforage,type) Cellular feed balanceflow for forage feed for ruminant livestock (mio. tDM per yr) - oq71_feed_rum_liv(t,j,kforage,type) Production constraint for ruminant livestock products (mio. tDM per yr) - oq71_feed_forage(t,j,type) Forage feed constraint (mio. tDM per yr) - oq71_feed_balanceflow_nlp(t,j,type) Non-linear balanceflow constraint for forage feed products (mio. tDM per yr) - oq71_feed_balanceflow_lp(t,i,type) Linear balanceflow constraint for forage feed products (mio. tDM per yr) - oq71_prod_mon_liv(t,j,kli_mon,type) Production constraint for monogastric livestock products (mio. tDM per yr) - oq71_punishment_mon(t,i,type) Punishment for additional monogastrics (mio. USD05MER per yr) + ov71_prod_rum(t,j,kli_rum,kforage,type) Production of forage fed ruminants within a cell (mio. tDM per yr) + ov71_additional_mon(t,j,kli_mon,type) Additional punished production of monogastric livestock (mio. tDM per yr) + ov_costs_additional_mon(t,i,type) Punishment cost for additionally transported monogastric livst_egg (mio. USD05MER per yr) + ov71_feed_balanceflow(t,j,kli_rum,kforage,type) Cellular feed balanceflow for forage feed for ruminant livestock (mio. tDM per yr) + oq71_feed_rum_liv(t,j,kforage,type) Production constraint for ruminant livestock products (mio. tDM per yr) + oq71_balanceflow_constraint_nlp(t,j,kli_rum,kforage,type) Nonlinear balanceflow constraint for cellular forage feed products (mio. tDM per yr) + oq71_balanceflow_constraint_lp(t,i,kli_rum,kforage,type) Linear balanceflow constraint for cellular forage feed product (mio. tDM per yr) + oq71_sum_rum_liv(t,j,kli_rum,type) Total production of forage fed ruminants (mio. tDM per yr) + oq71_prod_mon_liv(t,j,kli_mon,type) Production constraint for monogastric livestock products (mio. tDM per yr) + oq71_punishment_mon(t,i,type) Punishment for additional monogastrics (mio. USD05MER per yr) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/71_disagg_lvst/foragebased_aug18/equations.gms b/modules/71_disagg_lvst/foragebased_aug18/equations.gms index e220bc9a52..575ba6c47b 100644 --- a/modules/71_disagg_lvst/foragebased_aug18/equations.gms +++ b/modules/71_disagg_lvst/foragebased_aug18/equations.gms @@ -8,48 +8,55 @@ *' @equations *' Ruminant livestock production within a cell is determined by the production of the non-transportable -*' feed items grazed pasture and fodder (`kforage`). Forage production must be larger than the ruminant feed requirements -*' (`v71_feed_forage`) adjusted by a balance flow (`v71_feed_forage`). +*' feed items grazed pasture and fodder. These must be larger than the ruminant feed requirements +*' that are given by the product of ruminant production and the respective feed baskets: q71_feed_rum_liv(j2,kforage) .. vm_prod(j2,kforage) =g= - v71_feed_forage(j2,kforage) - + v71_feed_balanceflow(j2,kforage); + sum(kli_rum, v71_prod_rum(j2,kli_rum,kforage) + * sum((ct,cell(i2,j2),kforage2),im_feed_baskets(ct,i2,kli_rum,kforage2)) + * (1 + v71_feed_balanceflow(j2,kli_rum,kforage)$(s71_lp_fix=0)) + + v71_feed_balanceflow(j2,kli_rum,kforage)$(s71_lp_fix=1)) + ; -*' Ruminant feed requirements are given by the product of ruminant production and the respective feed baskets. - -q71_feed_forage(j2) .. - sum(kforage, v71_feed_forage(j2,kforage)) =e= - sum((kli_rum,kforage), vm_prod(j2,kli_rum) - * sum((ct,cell(i2,j2)),im_feed_baskets(ct,i2,kli_rum,kforage))); *' The above equation contains a split of pasture and fodder fed ruminants, since we assume that depending *' on the intensity level of the livestock production, ruminants will graze on pastures (extensive systems) *' or will be fed via harvested fodder crops (intensive systems). +*' Please note that `s71_lp_fix` is set to zero (for more information please look into the source code). - -*' The balance flow for pasture and fodder production (`kforage`) accounts as in +*' The balance flow for pasture and fodder (summarized with forage) production, accounts as in *' [70_livestock] `q70_feed(i2,kap,kall)` for inconsistencies with the FAO inventory of national feed use. -*' In each cluster the balance flow is constrained by its share of livestock production regarding the regional level by - -q71_feed_balanceflow_nlp(j2)$(s71_lp_fix=0) .. - sum(kforage, v71_feed_balanceflow(j2,kforage)) =e= - sum((ct,cell(i2,j2),kli_rum,kforage), fm_feed_balanceflow(ct,i2,kli_rum,kforage) - * (vm_prod(j2,kli_rum) / (vm_prod_reg(i2,kli_rum)))); *' @stop -* If fixed to linear behaviour (`s71_lp_fix=1`) the balance flow for pasture and fodder production (`kforage`) -* can be freely distributed among all cells beloning to a region. +* If module is fixed to linear behaviour the balance flow is allowed to be used in any cell +* containing pasture or cropland area in the previous time step ensured by the restrictions +* in the nl_fix statement. The balance flow within a region is then determined by -q71_feed_balanceflow_lp(i2)$(s71_lp_fix=1) .. - sum((cell(i2,j2),kforage), v71_feed_balanceflow(j2,kforage)) =e= - sum((ct,kli_rum,kforage), fm_feed_balanceflow(ct,i2,kli_rum,kforage)); +q71_balanceflow_constraint_lp(i2,kli_rum,kforage)$(s71_lp_fix=1) .. + sum(ct, fm_feed_balanceflow(ct,i2,kli_rum,kforage)) =e= + sum(cell(i2,j2), v71_feed_balanceflow(j2,kli_rum,kforage)) + ; -* Note that for fixation to linear behaviour `q71_feed_balanceflow_lp` replaces `q71_feed_balanceflow_nlp`. +* Note that for fixation to linear behaviour `q71_balanceflow_constraint_lp` replaces `q71_balanceflow_constraint_nlp`. *' @equations +*' In each cluster the balance flow is constrained by its share of livestock production regarding the regional level by + +q71_balanceflow_constraint_nlp(j2,kli_rum,kforage)$(s71_lp_fix=0) .. + v71_feed_balanceflow(j2,kli_rum,kforage) =e= + sum((ct,cell(i2,j2)),fm_feed_balanceflow(ct,i2,kli_rum,kforage) + /(im_feed_baskets(ct,i2,kli_rum,kforage)*vm_prod_reg(i2,kli_rum) + 10**(-6))) + ; + +*' Note that $10^{-6}$ is required to avoid division by zero. +*' The regional ruminant production is then given by + +q71_sum_rum_liv(j2,kli_rum) .. + vm_prod(j2,kli_rum) =e= sum(kforage,v71_prod_rum(j2,kli_rum,kforage)) + ; *' To account for the above mentioned fact that monogastric livestock are held close to the population, it is *' distributed based on urban area by the formula diff --git a/modules/71_disagg_lvst/foragebased_aug18/nl_fix.gms b/modules/71_disagg_lvst/foragebased_aug18/nl_fix.gms index c583b2e187..3e88e2581d 100644 --- a/modules/71_disagg_lvst/foragebased_aug18/nl_fix.gms +++ b/modules/71_disagg_lvst/foragebased_aug18/nl_fix.gms @@ -7,8 +7,10 @@ * ### nl_fix ### -v71_feed_balanceflow.lo(j,kforage)$(sum((cell(i,j),kli_rum),fm_feed_balanceflow(t,i,kli_rum,kforage)) > 0) = 0; -v71_feed_balanceflow.up(j,kforage)$(sum((cell(i,j),kli_rum),fm_feed_balanceflow(t,i,kli_rum,kforage)) < 0) = 0; -v71_feed_balanceflow.fx(j,kforage)$(sum((cell(i,j),kli_rum),fm_feed_balanceflow(t,i,kli_rum,kforage)) = 0) = 0; -v71_feed_balanceflow.fx(j,"pasture")$(pcm_land(j,"past")=0) = 0; -v71_feed_balanceflow.fx(j,"foddr")$(pcm_land(j,"crop")=0) = 0; +v71_feed_balanceflow.lo(j,kli_rum,kforage)$(sum(cell(i,j),fm_feed_balanceflow(t,i,kli_rum,kforage)) > 0) = 0; +v71_feed_balanceflow.up(j,kli_rum,kforage)$(sum(cell(i,j),fm_feed_balanceflow(t,i,kli_rum,kforage)) < 0) = 0; +v71_feed_balanceflow.fx(j,kli_rum,kforage)$(sum(cell(i,j),fm_feed_balanceflow(t,i,kli_rum,kforage)) = 0) = 0; +v71_feed_balanceflow.fx(j,kli_rum,"pasture")$(pcm_land(j,"past")=0) = 0; +v71_feed_balanceflow.fx(j,kli_rum,"foddr")$(pcm_land(j,"crop")=0) = 0; + +s71_lp_fix=1; diff --git a/modules/71_disagg_lvst/foragebased_aug18/nl_release.gms b/modules/71_disagg_lvst/foragebased_aug18/nl_release.gms index 7b216fd4c5..cbad58b03d 100644 --- a/modules/71_disagg_lvst/foragebased_aug18/nl_release.gms +++ b/modules/71_disagg_lvst/foragebased_aug18/nl_release.gms @@ -7,5 +7,7 @@ * ### nl_release ### -v71_feed_balanceflow.lo(j,kforage)= -Inf; -v71_feed_balanceflow.up(j,kforage)= Inf; +v71_feed_balanceflow.lo(j,kli_rum,kforage)= -Inf; +v71_feed_balanceflow.up(j,kli_rum,kforage)= Inf; + +s71_lp_fix=0; diff --git a/modules/71_disagg_lvst/foragebased_aug18/postsolve.gms b/modules/71_disagg_lvst/foragebased_aug18/postsolve.gms index 959882e6e9..9c2b6507f3 100644 --- a/modules/71_disagg_lvst/foragebased_aug18/postsolve.gms +++ b/modules/71_disagg_lvst/foragebased_aug18/postsolve.gms @@ -6,44 +6,44 @@ *** | Contact: magpie@pik-potsdam.de *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov71_feed_forage(t,j,kforage,"marginal") = v71_feed_forage.m(j,kforage); - ov71_additional_mon(t,j,kli_mon,"marginal") = v71_additional_mon.m(j,kli_mon); - ov_costs_additional_mon(t,i,"marginal") = vm_costs_additional_mon.m(i); - ov71_feed_balanceflow(t,j,kforage,"marginal") = v71_feed_balanceflow.m(j,kforage); - oq71_feed_rum_liv(t,j,kforage,"marginal") = q71_feed_rum_liv.m(j,kforage); - oq71_feed_forage(t,j,"marginal") = q71_feed_forage.m(j); - oq71_feed_balanceflow_nlp(t,j,"marginal") = q71_feed_balanceflow_nlp.m(j); - oq71_feed_balanceflow_lp(t,i,"marginal") = q71_feed_balanceflow_lp.m(i); - oq71_prod_mon_liv(t,j,kli_mon,"marginal") = q71_prod_mon_liv.m(j,kli_mon); - oq71_punishment_mon(t,i,"marginal") = q71_punishment_mon.m(i); - ov71_feed_forage(t,j,kforage,"level") = v71_feed_forage.l(j,kforage); - ov71_additional_mon(t,j,kli_mon,"level") = v71_additional_mon.l(j,kli_mon); - ov_costs_additional_mon(t,i,"level") = vm_costs_additional_mon.l(i); - ov71_feed_balanceflow(t,j,kforage,"level") = v71_feed_balanceflow.l(j,kforage); - oq71_feed_rum_liv(t,j,kforage,"level") = q71_feed_rum_liv.l(j,kforage); - oq71_feed_forage(t,j,"level") = q71_feed_forage.l(j); - oq71_feed_balanceflow_nlp(t,j,"level") = q71_feed_balanceflow_nlp.l(j); - oq71_feed_balanceflow_lp(t,i,"level") = q71_feed_balanceflow_lp.l(i); - oq71_prod_mon_liv(t,j,kli_mon,"level") = q71_prod_mon_liv.l(j,kli_mon); - oq71_punishment_mon(t,i,"level") = q71_punishment_mon.l(i); - ov71_feed_forage(t,j,kforage,"upper") = v71_feed_forage.up(j,kforage); - ov71_additional_mon(t,j,kli_mon,"upper") = v71_additional_mon.up(j,kli_mon); - ov_costs_additional_mon(t,i,"upper") = vm_costs_additional_mon.up(i); - ov71_feed_balanceflow(t,j,kforage,"upper") = v71_feed_balanceflow.up(j,kforage); - oq71_feed_rum_liv(t,j,kforage,"upper") = q71_feed_rum_liv.up(j,kforage); - oq71_feed_forage(t,j,"upper") = q71_feed_forage.up(j); - oq71_feed_balanceflow_nlp(t,j,"upper") = q71_feed_balanceflow_nlp.up(j); - oq71_feed_balanceflow_lp(t,i,"upper") = q71_feed_balanceflow_lp.up(i); - oq71_prod_mon_liv(t,j,kli_mon,"upper") = q71_prod_mon_liv.up(j,kli_mon); - oq71_punishment_mon(t,i,"upper") = q71_punishment_mon.up(i); - ov71_feed_forage(t,j,kforage,"lower") = v71_feed_forage.lo(j,kforage); - ov71_additional_mon(t,j,kli_mon,"lower") = v71_additional_mon.lo(j,kli_mon); - ov_costs_additional_mon(t,i,"lower") = vm_costs_additional_mon.lo(i); - ov71_feed_balanceflow(t,j,kforage,"lower") = v71_feed_balanceflow.lo(j,kforage); - oq71_feed_rum_liv(t,j,kforage,"lower") = q71_feed_rum_liv.lo(j,kforage); - oq71_feed_forage(t,j,"lower") = q71_feed_forage.lo(j); - oq71_feed_balanceflow_nlp(t,j,"lower") = q71_feed_balanceflow_nlp.lo(j); - oq71_feed_balanceflow_lp(t,i,"lower") = q71_feed_balanceflow_lp.lo(i); - oq71_prod_mon_liv(t,j,kli_mon,"lower") = q71_prod_mon_liv.lo(j,kli_mon); - oq71_punishment_mon(t,i,"lower") = q71_punishment_mon.lo(i); + ov71_prod_rum(t,j,kli_rum,kforage,"marginal") = v71_prod_rum.m(j,kli_rum,kforage); + ov71_additional_mon(t,j,kli_mon,"marginal") = v71_additional_mon.m(j,kli_mon); + ov_costs_additional_mon(t,i,"marginal") = vm_costs_additional_mon.m(i); + ov71_feed_balanceflow(t,j,kli_rum,kforage,"marginal") = v71_feed_balanceflow.m(j,kli_rum,kforage); + oq71_feed_rum_liv(t,j,kforage,"marginal") = q71_feed_rum_liv.m(j,kforage); + oq71_balanceflow_constraint_nlp(t,j,kli_rum,kforage,"marginal") = q71_balanceflow_constraint_nlp.m(j,kli_rum,kforage); + oq71_balanceflow_constraint_lp(t,i,kli_rum,kforage,"marginal") = q71_balanceflow_constraint_lp.m(i,kli_rum,kforage); + oq71_sum_rum_liv(t,j,kli_rum,"marginal") = q71_sum_rum_liv.m(j,kli_rum); + oq71_prod_mon_liv(t,j,kli_mon,"marginal") = q71_prod_mon_liv.m(j,kli_mon); + oq71_punishment_mon(t,i,"marginal") = q71_punishment_mon.m(i); + ov71_prod_rum(t,j,kli_rum,kforage,"level") = v71_prod_rum.l(j,kli_rum,kforage); + ov71_additional_mon(t,j,kli_mon,"level") = v71_additional_mon.l(j,kli_mon); + ov_costs_additional_mon(t,i,"level") = vm_costs_additional_mon.l(i); + ov71_feed_balanceflow(t,j,kli_rum,kforage,"level") = v71_feed_balanceflow.l(j,kli_rum,kforage); + oq71_feed_rum_liv(t,j,kforage,"level") = q71_feed_rum_liv.l(j,kforage); + oq71_balanceflow_constraint_nlp(t,j,kli_rum,kforage,"level") = q71_balanceflow_constraint_nlp.l(j,kli_rum,kforage); + oq71_balanceflow_constraint_lp(t,i,kli_rum,kforage,"level") = q71_balanceflow_constraint_lp.l(i,kli_rum,kforage); + oq71_sum_rum_liv(t,j,kli_rum,"level") = q71_sum_rum_liv.l(j,kli_rum); + oq71_prod_mon_liv(t,j,kli_mon,"level") = q71_prod_mon_liv.l(j,kli_mon); + oq71_punishment_mon(t,i,"level") = q71_punishment_mon.l(i); + ov71_prod_rum(t,j,kli_rum,kforage,"upper") = v71_prod_rum.up(j,kli_rum,kforage); + ov71_additional_mon(t,j,kli_mon,"upper") = v71_additional_mon.up(j,kli_mon); + ov_costs_additional_mon(t,i,"upper") = vm_costs_additional_mon.up(i); + ov71_feed_balanceflow(t,j,kli_rum,kforage,"upper") = v71_feed_balanceflow.up(j,kli_rum,kforage); + oq71_feed_rum_liv(t,j,kforage,"upper") = q71_feed_rum_liv.up(j,kforage); + oq71_balanceflow_constraint_nlp(t,j,kli_rum,kforage,"upper") = q71_balanceflow_constraint_nlp.up(j,kli_rum,kforage); + oq71_balanceflow_constraint_lp(t,i,kli_rum,kforage,"upper") = q71_balanceflow_constraint_lp.up(i,kli_rum,kforage); + oq71_sum_rum_liv(t,j,kli_rum,"upper") = q71_sum_rum_liv.up(j,kli_rum); + oq71_prod_mon_liv(t,j,kli_mon,"upper") = q71_prod_mon_liv.up(j,kli_mon); + oq71_punishment_mon(t,i,"upper") = q71_punishment_mon.up(i); + ov71_prod_rum(t,j,kli_rum,kforage,"lower") = v71_prod_rum.lo(j,kli_rum,kforage); + ov71_additional_mon(t,j,kli_mon,"lower") = v71_additional_mon.lo(j,kli_mon); + ov_costs_additional_mon(t,i,"lower") = vm_costs_additional_mon.lo(i); + ov71_feed_balanceflow(t,j,kli_rum,kforage,"lower") = v71_feed_balanceflow.lo(j,kli_rum,kforage); + oq71_feed_rum_liv(t,j,kforage,"lower") = q71_feed_rum_liv.lo(j,kforage); + oq71_balanceflow_constraint_nlp(t,j,kli_rum,kforage,"lower") = q71_balanceflow_constraint_nlp.lo(j,kli_rum,kforage); + oq71_balanceflow_constraint_lp(t,i,kli_rum,kforage,"lower") = q71_balanceflow_constraint_lp.lo(i,kli_rum,kforage); + oq71_sum_rum_liv(t,j,kli_rum,"lower") = q71_sum_rum_liv.lo(j,kli_rum); + oq71_prod_mon_liv(t,j,kli_mon,"lower") = q71_prod_mon_liv.lo(j,kli_mon); + oq71_punishment_mon(t,i,"lower") = q71_punishment_mon.lo(i); *##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/71_disagg_lvst/foragebased_aug18/preloop.gms b/modules/71_disagg_lvst/foragebased_aug18/preloop.gms index b4a0510e06..e7235b9da5 100644 --- a/modules/71_disagg_lvst/foragebased_aug18/preloop.gms +++ b/modules/71_disagg_lvst/foragebased_aug18/preloop.gms @@ -12,6 +12,3 @@ i71_urban_area_share(j) = s71_lp_fix = 0; s71_scale_mon = 1.10; s71_punish_additional_mon = 15000; - -* Minimal regional production of `kli_rum` to avoid division by zero in `q71_feed_balanceflow_nlp`. -vm_prod_reg.lo(i,kli_rum)$(s71_lp_fix=0) = 10**(-6); diff --git a/modules/71_disagg_lvst/foragebased_aug18/scaling.gms b/modules/71_disagg_lvst/foragebased_aug18/scaling.gms index f6d1479d6c..b4939dbc37 100644 --- a/modules/71_disagg_lvst/foragebased_aug18/scaling.gms +++ b/modules/71_disagg_lvst/foragebased_aug18/scaling.gms @@ -7,4 +7,4 @@ vm_costs_additional_mon.scale(i) = 10e4; *Don't scale this variable. Model is very sensitive to scaling this variable and might become infeasible or very slow. -*v71_feed_balanceflow.scale(j,kforage) = 10e3; +*v71_feed_balanceflow.scale(j,kli_rum,kforage) = 10e3; diff --git a/modules/71_disagg_lvst/foragebased_jul23/declarations.gms b/modules/71_disagg_lvst/foragebased_jul23/declarations.gms new file mode 100644 index 0000000000..0bbcb46044 --- /dev/null +++ b/modules/71_disagg_lvst/foragebased_jul23/declarations.gms @@ -0,0 +1,50 @@ +*** | (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 + v71_feed_forage(j,kforage) Production of forage within a cell (mio. tDM per yr) + v71_additional_mon(j, kli_mon) Additional punished production of monogastric livestock (mio. tDM per yr) + vm_costs_additional_mon(i) Punishment cost for additionally transported monogastric livst_egg (mio. USD05MER per yr) +; + +variables + v71_feed_balanceflow(j,kforage) Cellular feed balanceflow for forage feed for ruminant livestock (mio. tDM per yr) +; + +equations + q71_feed_rum_liv(j,kforage) Production constraint for ruminant livestock products (mio. tDM per yr) + q71_feed_forage(j) Forage feed constraint (mio. tDM per yr) + q71_feed_balanceflow_nlp(j) Non-linear balanceflow constraint for forage feed products (mio. tDM per yr) + q71_feed_balanceflow_lp(i) Linear balanceflow constraint for forage feed products (mio. tDM per yr) + q71_prod_mon_liv(j,kli_mon) Production constraint for monogastric livestock products (mio. tDM per yr) + q71_punishment_mon(i) Punishment for additional monogastrics (mio. USD05MER per yr) +; + +parameters + i71_urban_area_share(j) Share of urban area within a region (1) +; + +scalars + s71_lp_fix Switch to fix equations to linear relation (Logical) + s71_scale_mon Scalar for flexible distribution of monogastrics (1) + s71_punish_additional_mon Scaling factor for transport punishment (USD05MER per tDM) +; + +*#################### R SECTION START (OUTPUT DECLARATIONS) #################### +parameters + ov71_feed_forage(t,j,kforage,type) Production of forage within a cell (mio. tDM per yr) + ov71_additional_mon(t,j,kli_mon,type) Additional punished production of monogastric livestock (mio. tDM per yr) + ov_costs_additional_mon(t,i,type) Punishment cost for additionally transported monogastric livst_egg (mio. USD05MER per yr) + ov71_feed_balanceflow(t,j,kforage,type) Cellular feed balanceflow for forage feed for ruminant livestock (mio. tDM per yr) + oq71_feed_rum_liv(t,j,kforage,type) Production constraint for ruminant livestock products (mio. tDM per yr) + oq71_feed_forage(t,j,type) Forage feed constraint (mio. tDM per yr) + oq71_feed_balanceflow_nlp(t,j,type) Non-linear balanceflow constraint for forage feed products (mio. tDM per yr) + oq71_feed_balanceflow_lp(t,i,type) Linear balanceflow constraint for forage feed products (mio. tDM per yr) + oq71_prod_mon_liv(t,j,kli_mon,type) Production constraint for monogastric livestock products (mio. tDM per yr) + oq71_punishment_mon(t,i,type) Punishment for additional monogastrics (mio. USD05MER per yr) +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/71_disagg_lvst/foragebased_jul23/equations.gms b/modules/71_disagg_lvst/foragebased_jul23/equations.gms new file mode 100644 index 0000000000..e220bc9a52 --- /dev/null +++ b/modules/71_disagg_lvst/foragebased_jul23/equations.gms @@ -0,0 +1,74 @@ +*** | (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 + +*' Ruminant livestock production within a cell is determined by the production of the non-transportable +*' feed items grazed pasture and fodder (`kforage`). Forage production must be larger than the ruminant feed requirements +*' (`v71_feed_forage`) adjusted by a balance flow (`v71_feed_forage`). + +q71_feed_rum_liv(j2,kforage) .. + vm_prod(j2,kforage) =g= + v71_feed_forage(j2,kforage) + + v71_feed_balanceflow(j2,kforage); + +*' Ruminant feed requirements are given by the product of ruminant production and the respective feed baskets. + +q71_feed_forage(j2) .. + sum(kforage, v71_feed_forage(j2,kforage)) =e= + sum((kli_rum,kforage), vm_prod(j2,kli_rum) + * sum((ct,cell(i2,j2)),im_feed_baskets(ct,i2,kli_rum,kforage))); + +*' The above equation contains a split of pasture and fodder fed ruminants, since we assume that depending +*' on the intensity level of the livestock production, ruminants will graze on pastures (extensive systems) +*' or will be fed via harvested fodder crops (intensive systems). + + +*' The balance flow for pasture and fodder production (`kforage`) accounts as in +*' [70_livestock] `q70_feed(i2,kap,kall)` for inconsistencies with the FAO inventory of national feed use. +*' In each cluster the balance flow is constrained by its share of livestock production regarding the regional level by + +q71_feed_balanceflow_nlp(j2)$(s71_lp_fix=0) .. + sum(kforage, v71_feed_balanceflow(j2,kforage)) =e= + sum((ct,cell(i2,j2),kli_rum,kforage), fm_feed_balanceflow(ct,i2,kli_rum,kforage) + * (vm_prod(j2,kli_rum) / (vm_prod_reg(i2,kli_rum)))); + +*' @stop + +* If fixed to linear behaviour (`s71_lp_fix=1`) the balance flow for pasture and fodder production (`kforage`) +* can be freely distributed among all cells beloning to a region. + +q71_feed_balanceflow_lp(i2)$(s71_lp_fix=1) .. + sum((cell(i2,j2),kforage), v71_feed_balanceflow(j2,kforage)) =e= + sum((ct,kli_rum,kforage), fm_feed_balanceflow(ct,i2,kli_rum,kforage)); + +* Note that for fixation to linear behaviour `q71_feed_balanceflow_lp` replaces `q71_feed_balanceflow_nlp`. + +*' @equations + + +*' To account for the above mentioned fact that monogastric livestock are held close to the population, it is +*' distributed based on urban area by the formula + +q71_prod_mon_liv(j2,kli_mon) .. + vm_prod(j2,kli_mon) =l= + i71_urban_area_share(j2) * s71_scale_mon * sum(cell(i2,j2),vm_prod_reg(i2,kli_mon)) + + v71_additional_mon(j2,kli_mon) + ; + +*' Note that s71_scale_mon relaxes the constraint (per default by 10%) and v71_additional_mon ensures +*' feasability by punishing additonal monogastric production within a cluster. + +*' The punishmment of additional monogastric livestock production are calculated via + +q71_punishment_mon(i2) .. + vm_costs_additional_mon(i2) =e= + sum((cell(i2,j2),kli_mon), v71_additional_mon(j2,kli_mon)) * s71_punish_additional_mon + ; + +*' Note that the punishment costs are based on transport costs and scaled up by one order of magnitude +*' of the average transport costs to account for additional transport between clusters. diff --git a/modules/71_disagg_lvst/foragebased_jul23/nl_fix.gms b/modules/71_disagg_lvst/foragebased_jul23/nl_fix.gms new file mode 100644 index 0000000000..c583b2e187 --- /dev/null +++ b/modules/71_disagg_lvst/foragebased_jul23/nl_fix.gms @@ -0,0 +1,14 @@ +*** | (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 + +* ### nl_fix ### + +v71_feed_balanceflow.lo(j,kforage)$(sum((cell(i,j),kli_rum),fm_feed_balanceflow(t,i,kli_rum,kforage)) > 0) = 0; +v71_feed_balanceflow.up(j,kforage)$(sum((cell(i,j),kli_rum),fm_feed_balanceflow(t,i,kli_rum,kforage)) < 0) = 0; +v71_feed_balanceflow.fx(j,kforage)$(sum((cell(i,j),kli_rum),fm_feed_balanceflow(t,i,kli_rum,kforage)) = 0) = 0; +v71_feed_balanceflow.fx(j,"pasture")$(pcm_land(j,"past")=0) = 0; +v71_feed_balanceflow.fx(j,"foddr")$(pcm_land(j,"crop")=0) = 0; diff --git a/modules/71_disagg_lvst/foragebased_jul23/nl_release.gms b/modules/71_disagg_lvst/foragebased_jul23/nl_release.gms new file mode 100644 index 0000000000..7b216fd4c5 --- /dev/null +++ b/modules/71_disagg_lvst/foragebased_jul23/nl_release.gms @@ -0,0 +1,11 @@ +*** | (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 + +* ### nl_release ### + +v71_feed_balanceflow.lo(j,kforage)= -Inf; +v71_feed_balanceflow.up(j,kforage)= Inf; diff --git a/modules/71_disagg_lvst/foragebased_jul23/postsolve.gms b/modules/71_disagg_lvst/foragebased_jul23/postsolve.gms new file mode 100644 index 0000000000..959882e6e9 --- /dev/null +++ b/modules/71_disagg_lvst/foragebased_jul23/postsolve.gms @@ -0,0 +1,49 @@ +*** | (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 + +*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + ov71_feed_forage(t,j,kforage,"marginal") = v71_feed_forage.m(j,kforage); + ov71_additional_mon(t,j,kli_mon,"marginal") = v71_additional_mon.m(j,kli_mon); + ov_costs_additional_mon(t,i,"marginal") = vm_costs_additional_mon.m(i); + ov71_feed_balanceflow(t,j,kforage,"marginal") = v71_feed_balanceflow.m(j,kforage); + oq71_feed_rum_liv(t,j,kforage,"marginal") = q71_feed_rum_liv.m(j,kforage); + oq71_feed_forage(t,j,"marginal") = q71_feed_forage.m(j); + oq71_feed_balanceflow_nlp(t,j,"marginal") = q71_feed_balanceflow_nlp.m(j); + oq71_feed_balanceflow_lp(t,i,"marginal") = q71_feed_balanceflow_lp.m(i); + oq71_prod_mon_liv(t,j,kli_mon,"marginal") = q71_prod_mon_liv.m(j,kli_mon); + oq71_punishment_mon(t,i,"marginal") = q71_punishment_mon.m(i); + ov71_feed_forage(t,j,kforage,"level") = v71_feed_forage.l(j,kforage); + ov71_additional_mon(t,j,kli_mon,"level") = v71_additional_mon.l(j,kli_mon); + ov_costs_additional_mon(t,i,"level") = vm_costs_additional_mon.l(i); + ov71_feed_balanceflow(t,j,kforage,"level") = v71_feed_balanceflow.l(j,kforage); + oq71_feed_rum_liv(t,j,kforage,"level") = q71_feed_rum_liv.l(j,kforage); + oq71_feed_forage(t,j,"level") = q71_feed_forage.l(j); + oq71_feed_balanceflow_nlp(t,j,"level") = q71_feed_balanceflow_nlp.l(j); + oq71_feed_balanceflow_lp(t,i,"level") = q71_feed_balanceflow_lp.l(i); + oq71_prod_mon_liv(t,j,kli_mon,"level") = q71_prod_mon_liv.l(j,kli_mon); + oq71_punishment_mon(t,i,"level") = q71_punishment_mon.l(i); + ov71_feed_forage(t,j,kforage,"upper") = v71_feed_forage.up(j,kforage); + ov71_additional_mon(t,j,kli_mon,"upper") = v71_additional_mon.up(j,kli_mon); + ov_costs_additional_mon(t,i,"upper") = vm_costs_additional_mon.up(i); + ov71_feed_balanceflow(t,j,kforage,"upper") = v71_feed_balanceflow.up(j,kforage); + oq71_feed_rum_liv(t,j,kforage,"upper") = q71_feed_rum_liv.up(j,kforage); + oq71_feed_forage(t,j,"upper") = q71_feed_forage.up(j); + oq71_feed_balanceflow_nlp(t,j,"upper") = q71_feed_balanceflow_nlp.up(j); + oq71_feed_balanceflow_lp(t,i,"upper") = q71_feed_balanceflow_lp.up(i); + oq71_prod_mon_liv(t,j,kli_mon,"upper") = q71_prod_mon_liv.up(j,kli_mon); + oq71_punishment_mon(t,i,"upper") = q71_punishment_mon.up(i); + ov71_feed_forage(t,j,kforage,"lower") = v71_feed_forage.lo(j,kforage); + ov71_additional_mon(t,j,kli_mon,"lower") = v71_additional_mon.lo(j,kli_mon); + ov_costs_additional_mon(t,i,"lower") = vm_costs_additional_mon.lo(i); + ov71_feed_balanceflow(t,j,kforage,"lower") = v71_feed_balanceflow.lo(j,kforage); + oq71_feed_rum_liv(t,j,kforage,"lower") = q71_feed_rum_liv.lo(j,kforage); + oq71_feed_forage(t,j,"lower") = q71_feed_forage.lo(j); + oq71_feed_balanceflow_nlp(t,j,"lower") = q71_feed_balanceflow_nlp.lo(j); + oq71_feed_balanceflow_lp(t,i,"lower") = q71_feed_balanceflow_lp.lo(i); + oq71_prod_mon_liv(t,j,kli_mon,"lower") = q71_prod_mon_liv.lo(j,kli_mon); + oq71_punishment_mon(t,i,"lower") = q71_punishment_mon.lo(i); +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/71_disagg_lvst/foragebased_jul23/preloop.gms b/modules/71_disagg_lvst/foragebased_jul23/preloop.gms new file mode 100644 index 0000000000..b4a0510e06 --- /dev/null +++ b/modules/71_disagg_lvst/foragebased_jul23/preloop.gms @@ -0,0 +1,17 @@ +*** | (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 + +i71_urban_area_share(j) = + pm_land_start(j,"urban")/sum(cell(i,j),sum(cell2(i,j3),pm_land_start(j3,"urban"))) + ; + +s71_lp_fix = 0; +s71_scale_mon = 1.10; +s71_punish_additional_mon = 15000; + +* Minimal regional production of `kli_rum` to avoid division by zero in `q71_feed_balanceflow_nlp`. +vm_prod_reg.lo(i,kli_rum)$(s71_lp_fix=0) = 10**(-6); diff --git a/modules/71_disagg_lvst/foragebased_jul23/realization.gms b/modules/71_disagg_lvst/foragebased_jul23/realization.gms new file mode 100644 index 0000000000..edb667b5ce --- /dev/null +++ b/modules/71_disagg_lvst/foragebased_jul23/realization.gms @@ -0,0 +1,27 @@ +*** | (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 The foragebased_aug18 realization constrains the cellular ruminant livestock production by +*' the feed availability for grazed pasture and fodder crops. This accounts for the fact that pasture and fodder +*' (summarized with forage) feed stuff is usually not transported over long distances and at the same time +*' is very essential in livestock diets. The monogastric livestock is distributed following the idea +*' that these animals are held close to densely populated areas. For more detailed information on cellular livestock +*' distribution see @robinson_mapping_2014, which inspired this realization. + +*' @limitations Distribution of monogastrics do not account for feed availability within a cell. Crop residue feed stuff +*' for ruminant production is also not considered to restrict livestock production. + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/71_disagg_lvst/foragebased_jul23/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/71_disagg_lvst/foragebased_jul23/declarations.gms" +$Ifi "%phase%" == "equations" $include "./modules/71_disagg_lvst/foragebased_jul23/equations.gms" +$Ifi "%phase%" == "scaling" $include "./modules/71_disagg_lvst/foragebased_jul23/scaling.gms" +$Ifi "%phase%" == "preloop" $include "./modules/71_disagg_lvst/foragebased_jul23/preloop.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/71_disagg_lvst/foragebased_jul23/postsolve.gms" +$Ifi "%phase%" == "nl_fix" $include "./modules/71_disagg_lvst/foragebased_jul23/nl_fix.gms" +$Ifi "%phase%" == "nl_release" $include "./modules/71_disagg_lvst/foragebased_jul23/nl_release.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/71_disagg_lvst/foragebased_jul23/scaling.gms b/modules/71_disagg_lvst/foragebased_jul23/scaling.gms new file mode 100644 index 0000000000..f6d1479d6c --- /dev/null +++ b/modules/71_disagg_lvst/foragebased_jul23/scaling.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 + +vm_costs_additional_mon.scale(i) = 10e4; +*Don't scale this variable. Model is very sensitive to scaling this variable and might become infeasible or very slow. +*v71_feed_balanceflow.scale(j,kforage) = 10e3; diff --git a/modules/71_disagg_lvst/foragebased_jul23/sets.gms b/modules/71_disagg_lvst/foragebased_jul23/sets.gms new file mode 100644 index 0000000000..60573b6015 --- /dev/null +++ b/modules/71_disagg_lvst/foragebased_jul23/sets.gms @@ -0,0 +1,27 @@ +*** | (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 + kli_rum(kli) Ruminant livestock + / + livst_rum, livst_milk + / + + kli_mon(kli) Monogastric livestock + / + livst_pig, livst_chick, livst_egg + / + + kforage(k) Forage feed categories + / + pasture, foddr + / +; + +alias(j,j3); +alias(cell,cell2); +alias(kforage,kforage2); diff --git a/modules/71_disagg_lvst/module.gms b/modules/71_disagg_lvst/module.gms index 388e97797d..68b66dcf67 100644 --- a/modules/71_disagg_lvst/module.gms +++ b/modules/71_disagg_lvst/module.gms @@ -16,5 +16,6 @@ *###################### R SECTION START (MODULETYPES) ########################## $Ifi "%disagg_lvst%" == "foragebased_aug18" $include "./modules/71_disagg_lvst/foragebased_aug18/realization.gms" +$Ifi "%disagg_lvst%" == "foragebased_jul23" $include "./modules/71_disagg_lvst/foragebased_jul23/realization.gms" $Ifi "%disagg_lvst%" == "off" $include "./modules/71_disagg_lvst/off/realization.gms" *###################### R SECTION END (MODULETYPES) ############################ From cb202022383541383eb061944a8e1bbdf48d5fbf Mon Sep 17 00:00:00 2001 From: Felicitas Beier <39262100+FelicitasBeier@users.noreply.github.com> Date: Tue, 11 Jul 2023 16:16:47 +0200 Subject: [PATCH 51/62] Update solve.gms --- modules/80_optimization/nlp_apr17/solve.gms | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/80_optimization/nlp_apr17/solve.gms b/modules/80_optimization/nlp_apr17/solve.gms index e58b7e8af9..6f7ef90ae8 100644 --- a/modules/80_optimization/nlp_apr17/solve.gms +++ b/modules/80_optimization/nlp_apr17/solve.gms @@ -45,7 +45,7 @@ display vm_cost_glo.l; display magpie.modelstat; * in case of problems try different solvers and optfile settings -if(magpie.modelstat > 2 OR magpie.numNOpt > s80_num_nonopt_allowed, +if (magpie.modelstat > 2 OR magpie.numNOpt > s80_num_nonopt_allowed, repeat( s80_counter = s80_counter + 1 ; @@ -91,7 +91,7 @@ if ((p80_modelstat(t) <= 2), put_utility 'shell' / 'mv -f magpie_p.gdx magpie_' t.tl:0'.gdx'; ); -if ((p80_modelstat(t) > 2), +if ((p80_modelstat(t) > 2 and p80_modelstat(t) ne 7) Execute_Unload "fulldata.gdx"; abort "no feasible solution found!"; ); From a7d54e69e912beb2280342038624edb6113e3773 Mon Sep 17 00:00:00 2001 From: Felicitas Beier <39262100+FelicitasBeier@users.noreply.github.com> Date: Tue, 11 Jul 2023 16:18:47 +0200 Subject: [PATCH 52/62] Update solve.gms --- modules/80_optimization/nlp_par/solve.gms | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/80_optimization/nlp_par/solve.gms b/modules/80_optimization/nlp_par/solve.gms index 288210c7f3..ba613ec65f 100644 --- a/modules/80_optimization/nlp_par/solve.gms +++ b/modules/80_optimization/nlp_par/solve.gms @@ -69,7 +69,7 @@ repeat display s80_counter; display magpie.modelStat; - if((p80_counter(h) >= s80_maxiter AND p80_modelstat(t,h) > 2), + if ((p80_counter(h) >= s80_maxiter AND p80_modelstat(t,h) > 2), display "No feasible solution found. Writing LST file."; option AsyncSolLst=1; display$handlecollect(p80_handle(h)) 're-collect'; @@ -79,15 +79,15 @@ repeat display$handledelete(p80_handle(h)) 'trouble deleting handles' ; - if(p80_modelstat(t,h) <= 2 AND magpie.numNOpt <= s80_num_nonopt_allowed, + if (p80_modelstat(t,h) <= 2 AND magpie.numNOpt <= s80_num_nonopt_allowed, display "Model status <= 2. Handle cleared."; s80_resolve = 0; p80_handle(h) = 0; ); - if(s80_resolve = 1, + if (s80_resolve = 1, display "Resolve" - if(p80_modelstat(t,h) ne s80_modelstat_previter, + if (p80_modelstat(t,h) ne s80_modelstat_previter, display "Modelstat > 2 | Retry solve with CONOPT4 default setting"; solve magpie USING nlp MINIMIZING vm_cost_glo ; elseif p80_modelstat(t,h) = s80_modelstat_previter, @@ -117,7 +117,7 @@ repeat display$readyCollect(p80_handle,INF) 'Problem waiting for next instance to complete'; until card(p80_handle) = 0 OR smax(h, p80_counter(h)) >= s80_maxiter; -if (smax(h,p80_modelstat(t,h)) > 2, +if (smax(h,p80_modelstat(t,h)) > 2 and smax(h,p80_modelstat(t,h)) ne 7, Execute_Unload "fulldata.gdx"; abort "No feasible solution found!"; ); From 6961c0ddce087d1ea271ba4056d0d7c5d8344ad9 Mon Sep 17 00:00:00 2001 From: Felicitas Beier <39262100+FelicitasBeier@users.noreply.github.com> Date: Tue, 11 Jul 2023 16:19:46 +0200 Subject: [PATCH 53/62] Update solve.gms --- modules/80_optimization/nlp_apr17/solve.gms | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/80_optimization/nlp_apr17/solve.gms b/modules/80_optimization/nlp_apr17/solve.gms index 6f7ef90ae8..e57222db4d 100644 --- a/modules/80_optimization/nlp_apr17/solve.gms +++ b/modules/80_optimization/nlp_apr17/solve.gms @@ -49,7 +49,7 @@ if (magpie.modelstat > 2 OR magpie.numNOpt > s80_num_nonopt_allowed, repeat( s80_counter = s80_counter + 1 ; - if(magpie.modelstat ne s80_modelstat_previter, + if (magpie.modelstat ne s80_modelstat_previter, display "Modelstat > 2 | Retry solve with CONOPT4 default setting"; solve magpie USING nlp MINIMIZING vm_cost_glo ; elseif magpie.modelstat = s80_modelstat_previter, @@ -73,7 +73,7 @@ if (magpie.modelstat > 2 OR magpie.numNOpt > s80_num_nonopt_allowed, display vm_cost_glo.l; * write extended run information in list file in the case that the final solution is infeasible - if((s80_counter >= (s80_maxiter-1) and magpie.modelstat > 2), + if ((s80_counter >= (s80_maxiter-1) and magpie.modelstat > 2), magpie.solprint = 1 ); @@ -91,7 +91,7 @@ if ((p80_modelstat(t) <= 2), put_utility 'shell' / 'mv -f magpie_p.gdx magpie_' t.tl:0'.gdx'; ); -if ((p80_modelstat(t) > 2 and p80_modelstat(t) ne 7) +if ((p80_modelstat(t) > 2 and p80_modelstat(t) ne 7), Execute_Unload "fulldata.gdx"; abort "no feasible solution found!"; ); From 5b521ad7863477018880eebe66a6452c419578f4 Mon Sep 17 00:00:00 2001 From: Felicitas Beier <39262100+FelicitasBeier@users.noreply.github.com> Date: Tue, 11 Jul 2023 16:20:44 +0200 Subject: [PATCH 54/62] Update solve.gms --- modules/80_optimization/lp_nlp_apr17/solve.gms | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/80_optimization/lp_nlp_apr17/solve.gms b/modules/80_optimization/lp_nlp_apr17/solve.gms index c9d014bc4b..48da9e205d 100644 --- a/modules/80_optimization/lp_nlp_apr17/solve.gms +++ b/modules/80_optimization/lp_nlp_apr17/solve.gms @@ -72,7 +72,7 @@ $batinclude "./modules/include.gms" nl_fix *' of the previous optimization as upper bound and minimizing the land *' differences. - if((magpie.modelstat=1 or magpie.modelstat = 7), + if ((magpie.modelstat=1 or magpie.modelstat = 7), vm_cost_glo.up = vm_cost_glo.l; solve magpie USING nlp MINIMIZING vm_landdiff; vm_cost_glo.up = Inf; @@ -148,7 +148,7 @@ $batinclude "./modules/include.gms" nl_relax ); * if solve stopped with an error, try it again with conopt3 - if((magpie.modelstat = 13), + if ((magpie.modelstat = 13), display "WARNING: Modelstat 13 | retry with CONOPT3!"; option nlp = conopt; solve magpie USING nlp MINIMIZING vm_cost_glo; @@ -198,7 +198,7 @@ if ((p80_modelstat(t) < 3), put_utility 'shell' / 'mv -f magpie_p.gdx magpie_' t.tl:0'.gdx'; ); -if ((p80_modelstat(t) > 2), +if ((p80_modelstat(t) > 2 and p80_modelstat(t) ne 7), Execute_Unload "fulldata.gdx"; abort "no feasible solution found!"; ); From 3634e7426d273e52e70b4be03d186eac4fd1d981 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20F=C3=BChrlich?= Date: Thu, 13 Jul 2023 10:09:42 +0200 Subject: [PATCH 55/62] remove snapshot support --- .snapshot.Rprofile | 23 ----------------- CHANGELOG.md | 2 +- scripts/start/Rprofile.R | 53 ---------------------------------------- 3 files changed, 1 insertion(+), 77 deletions(-) delete mode 100644 .snapshot.Rprofile delete mode 100644 scripts/start/Rprofile.R diff --git a/.snapshot.Rprofile b/.snapshot.Rprofile deleted file mode 100644 index cb4dc70c79..0000000000 --- a/.snapshot.Rprofile +++ /dev/null @@ -1,23 +0,0 @@ -# source global .Rprofile (very important to load user specific settings) -# DO NOT EDIT THIS LINE! -if(file.exists("~/.Rprofile")) source("~/.Rprofile") - - -# This profile can be used to link the model to a specified library snapshot -# (e.g. if your model version is from an older date and does not work with the -# newest libraries anymore). -# By default it is not active. Just uncomment the following lines and set the -# snapshot path to a path of your choice. -# Please make also sure that in your config file this .Rprofile file is copied -# to the model output folder. Otherwise, the run itself will again use the -# default library set! - -# PLEASE NOTE: snapshots ending with '_R4' require R 4.1 (piam/1.24 and newer), -# other snapshots require R 3.6 (piam/1.20) -# snapshot <- "/p/projects/rd3mod/R/libraries/snapshots/2022_10_28_R4" -# if(file.exists(snapshot)) { -# cat("Setting libPaths to",snapshot,"\n") -# .libPaths(snapshot, include.site = FALSE) -# } else { -# cat("Could not find",snapshot,"\n") -# } diff --git a/CHANGELOG.md b/CHANGELOG.md index a803ed3de1..c29c06c01d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,7 +21,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **config** added `cfg$results_folder_highres` which allows to modify the output folder used in the `highres.R` output script ### removed -- +- **scripts** removed .snapshot.Rprofile and the Rprofile.R script, renv now fully supersedes snapshots ### fixed - **30_crop** corrected q30_cropland in module realization rotation_apr22, where fallow land was on the wrong side of the equation diff --git a/scripts/start/Rprofile.R b/scripts/start/Rprofile.R deleted file mode 100644 index 46001513cf..0000000000 --- a/scripts/start/Rprofile.R +++ /dev/null @@ -1,53 +0,0 @@ -# | (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: Add R snapshot to ".Rprofile" -# position: 4 -# ------------------------------------------------- - -setSnapshot <- function(snapshotdir=NULL) { - choose_snapshot <- function(title="Please choose a R snapshot") { - if(dir.exists("/p/projects/rd3mod/R/libraries/snapshots/")) { - dirs <- base::list.dirs("/p/projects/rd3mod/R/libraries/snapshots/",recursive=F,full.names=F) - dirs <- sort(dirs) - cat("\n",title,":\n", sep="") - cat("0: No snapshot\n") - cat(paste(1:length(dirs), dirs, sep=": " ),sep="\n") - cat("Number: ") - identifier <- as.numeric(gms::getLine()) - if(identifier > 0 & identifier <= length(dirs)) { - return(paste0("/p/projects/rd3mod/R/libraries/snapshots/",dirs[identifier])) - } else return(invisible(NULL)) - } else stop("R snapshot folder is only available on PIK cluster") - } - - if(is.null(snapshotdir)) snapshotdir <- choose_snapshot("Please choose a R snapshot") - - if(is.null(snapshotdir)) { - fc <- file(".Rprofile") - withr::defer(close(fc)) - writeLines(c('if(file.exists("~/.Rprofile")) source("~/.Rprofile")'), - fc) - } else { - fc <- file(".Rprofile") - withr::defer(close(fc)) - writeLines(c('if(file.exists("~/.Rprofile")) source("~/.Rprofile")', - paste0('.libPaths(',deparse(snapshotdir),')'), - paste0('print("Setting libPaths to ',snapshotdir,'")')), - fc) - } - message(".Rprofile written") -} -if(!exists("source_include")) { - snapshotdir <- NULL - lucode2::readArgs("snapshotdir", .silent=TRUE) -} - -setSnapshot(snapshotdir = snapshotdir) - - From 7816d97eba69388e98fc55a797e1301ed7e4c392 Mon Sep 17 00:00:00 2001 From: Kristine Karstens Date: Thu, 13 Jul 2023 10:38:11 +0200 Subject: [PATCH 56/62] update old disagg_livst realization + improved realization description for both foragebased realizations --- config/default.cfg | 5 +- main.gms | 22 +++--- .../foragebased_aug18/declarations.gms | 31 ++++---- .../foragebased_aug18/equations.gms | 50 ++++-------- .../foragebased_aug18/nl_fix.gms | 16 ---- .../foragebased_aug18/nl_release.gms | 13 ---- .../foragebased_aug18/not_used.txt | 2 + .../foragebased_aug18/postsolve.gms | 76 +++++++++---------- .../foragebased_aug18/preloop.gms | 5 +- .../foragebased_aug18/realization.gms | 17 +++-- .../foragebased_jul23/declarations.gms | 10 +-- .../foragebased_jul23/equations.gms | 12 ++- .../foragebased_jul23/realization.gms | 19 +++-- 13 files changed, 115 insertions(+), 163 deletions(-) delete mode 100644 modules/71_disagg_lvst/foragebased_aug18/nl_fix.gms delete mode 100644 modules/71_disagg_lvst/foragebased_aug18/nl_release.gms create mode 100644 modules/71_disagg_lvst/foragebased_aug18/not_used.txt diff --git a/config/default.cfg b/config/default.cfg index 4d952abad4..821203f355 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -1731,9 +1731,8 @@ cfg$gms$c70_fac_req_regr <- "glo" # def = glo # * (foragebased_aug18): Disaggregation of livestock to cells # * with high pasture and fodder availability # * (foragebased_jul23): Disaggregation of livestock to cells -# * with high pasture and fodder availability. -# * Includes a minimal lower bound for ruminant production to avoid -# * avoid GAMS corner solutions at higher spatial resolutions. +# * with high pasture and fodder availability +# * (improved and flexibitized) cfg$gms$disagg_lvst <- "foragebased_jul23" # def = foragebased_jul23 diff --git a/main.gms b/main.gms index 47e25fedc8..3595e9c073 100644 --- a/main.gms +++ b/main.gms @@ -149,24 +149,24 @@ $title magpie *##################### R SECTION START (VERSION INFO) ########################## * * Used data set: rev4.87_h12_magpie.tgz -* md5sum: NA -* Repository: scp://cluster.pik-potsdam.de/p/projects/rd3mod/inputdata/output +* md5sum: 658398f1dcbef89198bd85d61b1db9ad +* Repository: /p/projects/rd3mod/inputdata/output * * Used data set: rev4.87_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz -* md5sum: NA -* Repository: scp://cluster.pik-potsdam.de/p/projects/rd3mod/inputdata/output +* md5sum: 8a1d668acfe66a700eb5da2143b31cb2 +* Repository: /p/projects/rd3mod/inputdata/output * * Used data set: rev4.87_h12_validation.tgz -* md5sum: NA -* Repository: scp://cluster.pik-potsdam.de/p/projects/rd3mod/inputdata/output +* md5sum: d02217d791b58400e6e3be7186527ed5 +* Repository: /p/projects/rd3mod/inputdata/output * * Used data set: additional_data_rev4.43.tgz * md5sum: NA * Repository: https://rse.pik-potsdam.de/data/magpie/public * -* Used data set: calibration_H12_per_ton_fao_may22_glo_23Mar23.tgz -* md5sum: NA -* Repository: https://rse.pik-potsdam.de/data/magpie/public +* Used data set: calibration_H12_per_ton_fao_may22_glo_08Jul23.tgz +* md5sum: 7315d0f268d6225805a4c1f1c3c05b13 +* Repository: /p/projects/landuse/data/input/calibration * * Low resolution: c200 * High resolution: 0.5 @@ -194,10 +194,8 @@ $title magpie * 6 17 9 8 1 44 26 7 10 13 38 21 * * Call: withCallingHandlers(expr, message = messageHandler, warning = warningHandler, error = errorHandler) * -* Warning message: -* could not retrieve available packages for url 'https://rse.pik-potsdam.de/r/packages/bin/macosx/contrib/4.2' * -* Last modification (input data): Sun Jul 2 21:46:49 2023 +* Last modification (input data): Thu Jul 13 10:36:10 2023 * *###################### R SECTION END (VERSION INFO) ########################### diff --git a/modules/71_disagg_lvst/foragebased_aug18/declarations.gms b/modules/71_disagg_lvst/foragebased_aug18/declarations.gms index d68611a046..2c48587fb5 100644 --- a/modules/71_disagg_lvst/foragebased_aug18/declarations.gms +++ b/modules/71_disagg_lvst/foragebased_aug18/declarations.gms @@ -7,21 +7,20 @@ positive variables v71_prod_rum(j,kli_rum,kforage) Production of forage fed ruminants within a cell (mio. tDM per yr) - v71_additional_mon(j, kli_mon) Additional punished production of monogastric livestock (mio. tDM per yr) - vm_costs_additional_mon(i) Punishment cost for additionally transported monogastric livst_egg (mio. USD05MER per yr) + v71_additional_mon(j, kli_mon) Additional punished production of monogastric livestock (mio. tDM per yr) + vm_costs_additional_mon(i) Punishment cost for additionally transported monogastric livst_egg (mio. USD05MER per yr) ; variables - v71_feed_balanceflow(j,kli_rum,kforage) Cellular feed balanceflow for forage feed for ruminant livestock (mio. tDM per yr) + v71_feed_balanceflow_share(j,kli_rum,kforage) Cellular feed balanceflow multiplier for forage feed for ruminant livestock (mio. tDM per yr) ; equations q71_feed_rum_liv(j,kforage) Production constraint for ruminant livestock products (mio. tDM per yr) - q71_balanceflow_constraint_nlp(j,kli_rum,kforage) Nonlinear balanceflow constraint for cellular forage feed products (mio. tDM per yr) - q71_balanceflow_constraint_lp(i,kli_rum,kforage) Linear balanceflow constraint for cellular forage feed product (mio. tDM per yr) + q71_balanceflow_constraint(j,kli_rum,kforage) Nonlinear balanceflow constraint for cellular forage feed products (mio. tDM per yr) q71_sum_rum_liv(j,kli_rum) Total production of forage fed ruminants (mio. tDM per yr) q71_prod_mon_liv(j,kli_mon) Production constraint for monogastric livestock products (mio. tDM per yr) - q71_punishment_mon(i) Punishment for additional monogastrics (mio. USD05MER per yr) + q71_punishment_mon(i) Punishment for additional monogastrics (mio. USD05MER per yr) ; parameters @@ -29,22 +28,20 @@ parameters ; scalars - s71_lp_fix Switch to fix equations to linear relation (Logical) s71_scale_mon Scalar for flexible distribution of monogastrics (1) s71_punish_additional_mon Scaling factor for transport punishment (USD05MER per tDM) ; *#################### R SECTION START (OUTPUT DECLARATIONS) #################### parameters - ov71_prod_rum(t,j,kli_rum,kforage,type) Production of forage fed ruminants within a cell (mio. tDM per yr) - ov71_additional_mon(t,j,kli_mon,type) Additional punished production of monogastric livestock (mio. tDM per yr) - ov_costs_additional_mon(t,i,type) Punishment cost for additionally transported monogastric livst_egg (mio. USD05MER per yr) - ov71_feed_balanceflow(t,j,kli_rum,kforage,type) Cellular feed balanceflow for forage feed for ruminant livestock (mio. tDM per yr) - oq71_feed_rum_liv(t,j,kforage,type) Production constraint for ruminant livestock products (mio. tDM per yr) - oq71_balanceflow_constraint_nlp(t,j,kli_rum,kforage,type) Nonlinear balanceflow constraint for cellular forage feed products (mio. tDM per yr) - oq71_balanceflow_constraint_lp(t,i,kli_rum,kforage,type) Linear balanceflow constraint for cellular forage feed product (mio. tDM per yr) - oq71_sum_rum_liv(t,j,kli_rum,type) Total production of forage fed ruminants (mio. tDM per yr) - oq71_prod_mon_liv(t,j,kli_mon,type) Production constraint for monogastric livestock products (mio. tDM per yr) - oq71_punishment_mon(t,i,type) Punishment for additional monogastrics (mio. USD05MER per yr) + ov71_prod_rum(t,j,kli_rum,kforage,type) Production of forage fed ruminants within a cell (mio. tDM per yr) + ov71_additional_mon(t,j,kli_mon,type) Additional punished production of monogastric livestock (mio. tDM per yr) + ov_costs_additional_mon(t,i,type) Punishment cost for additionally transported monogastric livst_egg (mio. USD05MER per yr) + ov71_feed_balanceflow_share(t,j,kli_rum,kforage,type) Cellular feed balanceflow multiplier for forage feed for ruminant livestock (mio. tDM per yr) + oq71_feed_rum_liv(t,j,kforage,type) Production constraint for ruminant livestock products (mio. tDM per yr) + oq71_balanceflow_constraint(t,j,kli_rum,kforage,type) Nonlinear balanceflow constraint for cellular forage feed products (mio. tDM per yr) + oq71_sum_rum_liv(t,j,kli_rum,type) Total production of forage fed ruminants (mio. tDM per yr) + oq71_prod_mon_liv(t,j,kli_mon,type) Production constraint for monogastric livestock products (mio. tDM per yr) + oq71_punishment_mon(t,i,type) Punishment for additional monogastrics (mio. USD05MER per yr) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/71_disagg_lvst/foragebased_aug18/equations.gms b/modules/71_disagg_lvst/foragebased_aug18/equations.gms index 575ba6c47b..6d7e6a067a 100644 --- a/modules/71_disagg_lvst/foragebased_aug18/equations.gms +++ b/modules/71_disagg_lvst/foragebased_aug18/equations.gms @@ -11,48 +11,28 @@ *' feed items grazed pasture and fodder. These must be larger than the ruminant feed requirements *' that are given by the product of ruminant production and the respective feed baskets: -q71_feed_rum_liv(j2,kforage) .. - vm_prod(j2,kforage) =g= - sum(kli_rum, v71_prod_rum(j2,kli_rum,kforage) - * sum((ct,cell(i2,j2),kforage2),im_feed_baskets(ct,i2,kli_rum,kforage2)) - * (1 + v71_feed_balanceflow(j2,kli_rum,kforage)$(s71_lp_fix=0)) - + v71_feed_balanceflow(j2,kli_rum,kforage)$(s71_lp_fix=1)) - ; - +q71_feed_rum_liv(j2, kforage) .. + vm_prod(j2, kforage) =g= + sum(kli_rum, v71_prod_rum(j2, kli_rum, kforage) + * sum((ct, cell(i2,j2), kforage2), im_feed_baskets(ct, i2, kli_rum,kforage2)) * + v71_feed_balanceflow_share(j2, kli_rum, kforage)) + ; *' The above equation contains a split of pasture and fodder fed ruminants, since we assume that depending *' on the intensity level of the livestock production, ruminants will graze on pastures (extensive systems) *' or will be fed via harvested fodder crops (intensive systems). -*' Please note that `s71_lp_fix` is set to zero (for more information please look into the source code). - -*' The balance flow for pasture and fodder (summarized with forage) production, accounts as in -*' [70_livestock] `q70_feed(i2,kap,kall)` for inconsistencies with the FAO inventory of national feed use. -*' @stop - -* If module is fixed to linear behaviour the balance flow is allowed to be used in any cell -* containing pasture or cropland area in the previous time step ensured by the restrictions -* in the nl_fix statement. The balance flow within a region is then determined by - -q71_balanceflow_constraint_lp(i2,kli_rum,kforage)$(s71_lp_fix=1) .. - sum(ct, fm_feed_balanceflow(ct,i2,kli_rum,kforage)) =e= - sum(cell(i2,j2), v71_feed_balanceflow(j2,kli_rum,kforage)) - ; +*' A regional balance flow accounts in [70_livestock] `q70_feed(i2,kap,kall)` for inconsistencies with +*' the FAO inventory of national feed use. On cellular level we distribute the regional balance flow as +*' a multiplicative correction term (introduced in `q71_feed_rum_liv`) that is given by -* Note that for fixation to linear behaviour `q71_balanceflow_constraint_lp` replaces `q71_balanceflow_constraint_nlp`. - -*' @equations - -*' In each cluster the balance flow is constrained by its share of livestock production regarding the regional level by - -q71_balanceflow_constraint_nlp(j2,kli_rum,kforage)$(s71_lp_fix=0) .. - v71_feed_balanceflow(j2,kli_rum,kforage) =e= - sum((ct,cell(i2,j2)),fm_feed_balanceflow(ct,i2,kli_rum,kforage) - /(im_feed_baskets(ct,i2,kli_rum,kforage)*vm_prod_reg(i2,kli_rum) + 10**(-6))) - ; +q71_balanceflow_constraint(j2, kli_rum, kforage) .. + v71_feed_balanceflow_share(j2, kli_rum, kforage) =e= + 1 + sum((ct, cell(i2,j2)), fm_feed_balanceflow(ct, i2, kli_rum, kforage) / + (im_feed_baskets(ct, i2, kli_rum, kforage) * vm_prod_reg(i2, kli_rum))) + ; -*' Note that $10^{-6}$ is required to avoid division by zero. -*' The regional ruminant production is then given by +*' The total cellular ruminant production is then given by q71_sum_rum_liv(j2,kli_rum) .. vm_prod(j2,kli_rum) =e= sum(kforage,v71_prod_rum(j2,kli_rum,kforage)) diff --git a/modules/71_disagg_lvst/foragebased_aug18/nl_fix.gms b/modules/71_disagg_lvst/foragebased_aug18/nl_fix.gms deleted file mode 100644 index 3e88e2581d..0000000000 --- a/modules/71_disagg_lvst/foragebased_aug18/nl_fix.gms +++ /dev/null @@ -1,16 +0,0 @@ -*** | (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 - -* ### nl_fix ### - -v71_feed_balanceflow.lo(j,kli_rum,kforage)$(sum(cell(i,j),fm_feed_balanceflow(t,i,kli_rum,kforage)) > 0) = 0; -v71_feed_balanceflow.up(j,kli_rum,kforage)$(sum(cell(i,j),fm_feed_balanceflow(t,i,kli_rum,kforage)) < 0) = 0; -v71_feed_balanceflow.fx(j,kli_rum,kforage)$(sum(cell(i,j),fm_feed_balanceflow(t,i,kli_rum,kforage)) = 0) = 0; -v71_feed_balanceflow.fx(j,kli_rum,"pasture")$(pcm_land(j,"past")=0) = 0; -v71_feed_balanceflow.fx(j,kli_rum,"foddr")$(pcm_land(j,"crop")=0) = 0; - -s71_lp_fix=1; diff --git a/modules/71_disagg_lvst/foragebased_aug18/nl_release.gms b/modules/71_disagg_lvst/foragebased_aug18/nl_release.gms deleted file mode 100644 index cbad58b03d..0000000000 --- a/modules/71_disagg_lvst/foragebased_aug18/nl_release.gms +++ /dev/null @@ -1,13 +0,0 @@ -*** | (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 - -* ### nl_release ### - -v71_feed_balanceflow.lo(j,kli_rum,kforage)= -Inf; -v71_feed_balanceflow.up(j,kli_rum,kforage)= Inf; - -s71_lp_fix=0; diff --git a/modules/71_disagg_lvst/foragebased_aug18/not_used.txt b/modules/71_disagg_lvst/foragebased_aug18/not_used.txt new file mode 100644 index 0000000000..2feaafe196 --- /dev/null +++ b/modules/71_disagg_lvst/foragebased_aug18/not_used.txt @@ -0,0 +1,2 @@ +name,type,reason +pcm_land,input,questionnaire diff --git a/modules/71_disagg_lvst/foragebased_aug18/postsolve.gms b/modules/71_disagg_lvst/foragebased_aug18/postsolve.gms index 9c2b6507f3..ca1e1eacf6 100644 --- a/modules/71_disagg_lvst/foragebased_aug18/postsolve.gms +++ b/modules/71_disagg_lvst/foragebased_aug18/postsolve.gms @@ -6,44 +6,40 @@ *** | Contact: magpie@pik-potsdam.de *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov71_prod_rum(t,j,kli_rum,kforage,"marginal") = v71_prod_rum.m(j,kli_rum,kforage); - ov71_additional_mon(t,j,kli_mon,"marginal") = v71_additional_mon.m(j,kli_mon); - ov_costs_additional_mon(t,i,"marginal") = vm_costs_additional_mon.m(i); - ov71_feed_balanceflow(t,j,kli_rum,kforage,"marginal") = v71_feed_balanceflow.m(j,kli_rum,kforage); - oq71_feed_rum_liv(t,j,kforage,"marginal") = q71_feed_rum_liv.m(j,kforage); - oq71_balanceflow_constraint_nlp(t,j,kli_rum,kforage,"marginal") = q71_balanceflow_constraint_nlp.m(j,kli_rum,kforage); - oq71_balanceflow_constraint_lp(t,i,kli_rum,kforage,"marginal") = q71_balanceflow_constraint_lp.m(i,kli_rum,kforage); - oq71_sum_rum_liv(t,j,kli_rum,"marginal") = q71_sum_rum_liv.m(j,kli_rum); - oq71_prod_mon_liv(t,j,kli_mon,"marginal") = q71_prod_mon_liv.m(j,kli_mon); - oq71_punishment_mon(t,i,"marginal") = q71_punishment_mon.m(i); - ov71_prod_rum(t,j,kli_rum,kforage,"level") = v71_prod_rum.l(j,kli_rum,kforage); - ov71_additional_mon(t,j,kli_mon,"level") = v71_additional_mon.l(j,kli_mon); - ov_costs_additional_mon(t,i,"level") = vm_costs_additional_mon.l(i); - ov71_feed_balanceflow(t,j,kli_rum,kforage,"level") = v71_feed_balanceflow.l(j,kli_rum,kforage); - oq71_feed_rum_liv(t,j,kforage,"level") = q71_feed_rum_liv.l(j,kforage); - oq71_balanceflow_constraint_nlp(t,j,kli_rum,kforage,"level") = q71_balanceflow_constraint_nlp.l(j,kli_rum,kforage); - oq71_balanceflow_constraint_lp(t,i,kli_rum,kforage,"level") = q71_balanceflow_constraint_lp.l(i,kli_rum,kforage); - oq71_sum_rum_liv(t,j,kli_rum,"level") = q71_sum_rum_liv.l(j,kli_rum); - oq71_prod_mon_liv(t,j,kli_mon,"level") = q71_prod_mon_liv.l(j,kli_mon); - oq71_punishment_mon(t,i,"level") = q71_punishment_mon.l(i); - ov71_prod_rum(t,j,kli_rum,kforage,"upper") = v71_prod_rum.up(j,kli_rum,kforage); - ov71_additional_mon(t,j,kli_mon,"upper") = v71_additional_mon.up(j,kli_mon); - ov_costs_additional_mon(t,i,"upper") = vm_costs_additional_mon.up(i); - ov71_feed_balanceflow(t,j,kli_rum,kforage,"upper") = v71_feed_balanceflow.up(j,kli_rum,kforage); - oq71_feed_rum_liv(t,j,kforage,"upper") = q71_feed_rum_liv.up(j,kforage); - oq71_balanceflow_constraint_nlp(t,j,kli_rum,kforage,"upper") = q71_balanceflow_constraint_nlp.up(j,kli_rum,kforage); - oq71_balanceflow_constraint_lp(t,i,kli_rum,kforage,"upper") = q71_balanceflow_constraint_lp.up(i,kli_rum,kforage); - oq71_sum_rum_liv(t,j,kli_rum,"upper") = q71_sum_rum_liv.up(j,kli_rum); - oq71_prod_mon_liv(t,j,kli_mon,"upper") = q71_prod_mon_liv.up(j,kli_mon); - oq71_punishment_mon(t,i,"upper") = q71_punishment_mon.up(i); - ov71_prod_rum(t,j,kli_rum,kforage,"lower") = v71_prod_rum.lo(j,kli_rum,kforage); - ov71_additional_mon(t,j,kli_mon,"lower") = v71_additional_mon.lo(j,kli_mon); - ov_costs_additional_mon(t,i,"lower") = vm_costs_additional_mon.lo(i); - ov71_feed_balanceflow(t,j,kli_rum,kforage,"lower") = v71_feed_balanceflow.lo(j,kli_rum,kforage); - oq71_feed_rum_liv(t,j,kforage,"lower") = q71_feed_rum_liv.lo(j,kforage); - oq71_balanceflow_constraint_nlp(t,j,kli_rum,kforage,"lower") = q71_balanceflow_constraint_nlp.lo(j,kli_rum,kforage); - oq71_balanceflow_constraint_lp(t,i,kli_rum,kforage,"lower") = q71_balanceflow_constraint_lp.lo(i,kli_rum,kforage); - oq71_sum_rum_liv(t,j,kli_rum,"lower") = q71_sum_rum_liv.lo(j,kli_rum); - oq71_prod_mon_liv(t,j,kli_mon,"lower") = q71_prod_mon_liv.lo(j,kli_mon); - oq71_punishment_mon(t,i,"lower") = q71_punishment_mon.lo(i); + ov71_prod_rum(t,j,kli_rum,kforage,"marginal") = v71_prod_rum.m(j,kli_rum,kforage); + ov71_additional_mon(t,j,kli_mon,"marginal") = v71_additional_mon.m(j,kli_mon); + ov_costs_additional_mon(t,i,"marginal") = vm_costs_additional_mon.m(i); + ov71_feed_balanceflow_share(t,j,kli_rum,kforage,"marginal") = v71_feed_balanceflow_share.m(j,kli_rum,kforage); + oq71_feed_rum_liv(t,j,kforage,"marginal") = q71_feed_rum_liv.m(j,kforage); + oq71_balanceflow_constraint(t,j,kli_rum,kforage,"marginal") = q71_balanceflow_constraint.m(j,kli_rum,kforage); + oq71_sum_rum_liv(t,j,kli_rum,"marginal") = q71_sum_rum_liv.m(j,kli_rum); + oq71_prod_mon_liv(t,j,kli_mon,"marginal") = q71_prod_mon_liv.m(j,kli_mon); + oq71_punishment_mon(t,i,"marginal") = q71_punishment_mon.m(i); + ov71_prod_rum(t,j,kli_rum,kforage,"level") = v71_prod_rum.l(j,kli_rum,kforage); + ov71_additional_mon(t,j,kli_mon,"level") = v71_additional_mon.l(j,kli_mon); + ov_costs_additional_mon(t,i,"level") = vm_costs_additional_mon.l(i); + ov71_feed_balanceflow_share(t,j,kli_rum,kforage,"level") = v71_feed_balanceflow_share.l(j,kli_rum,kforage); + oq71_feed_rum_liv(t,j,kforage,"level") = q71_feed_rum_liv.l(j,kforage); + oq71_balanceflow_constraint(t,j,kli_rum,kforage,"level") = q71_balanceflow_constraint.l(j,kli_rum,kforage); + oq71_sum_rum_liv(t,j,kli_rum,"level") = q71_sum_rum_liv.l(j,kli_rum); + oq71_prod_mon_liv(t,j,kli_mon,"level") = q71_prod_mon_liv.l(j,kli_mon); + oq71_punishment_mon(t,i,"level") = q71_punishment_mon.l(i); + ov71_prod_rum(t,j,kli_rum,kforage,"upper") = v71_prod_rum.up(j,kli_rum,kforage); + ov71_additional_mon(t,j,kli_mon,"upper") = v71_additional_mon.up(j,kli_mon); + ov_costs_additional_mon(t,i,"upper") = vm_costs_additional_mon.up(i); + ov71_feed_balanceflow_share(t,j,kli_rum,kforage,"upper") = v71_feed_balanceflow_share.up(j,kli_rum,kforage); + oq71_feed_rum_liv(t,j,kforage,"upper") = q71_feed_rum_liv.up(j,kforage); + oq71_balanceflow_constraint(t,j,kli_rum,kforage,"upper") = q71_balanceflow_constraint.up(j,kli_rum,kforage); + oq71_sum_rum_liv(t,j,kli_rum,"upper") = q71_sum_rum_liv.up(j,kli_rum); + oq71_prod_mon_liv(t,j,kli_mon,"upper") = q71_prod_mon_liv.up(j,kli_mon); + oq71_punishment_mon(t,i,"upper") = q71_punishment_mon.up(i); + ov71_prod_rum(t,j,kli_rum,kforage,"lower") = v71_prod_rum.lo(j,kli_rum,kforage); + ov71_additional_mon(t,j,kli_mon,"lower") = v71_additional_mon.lo(j,kli_mon); + ov_costs_additional_mon(t,i,"lower") = vm_costs_additional_mon.lo(i); + ov71_feed_balanceflow_share(t,j,kli_rum,kforage,"lower") = v71_feed_balanceflow_share.lo(j,kli_rum,kforage); + oq71_feed_rum_liv(t,j,kforage,"lower") = q71_feed_rum_liv.lo(j,kforage); + oq71_balanceflow_constraint(t,j,kli_rum,kforage,"lower") = q71_balanceflow_constraint.lo(j,kli_rum,kforage); + oq71_sum_rum_liv(t,j,kli_rum,"lower") = q71_sum_rum_liv.lo(j,kli_rum); + oq71_prod_mon_liv(t,j,kli_mon,"lower") = q71_prod_mon_liv.lo(j,kli_mon); + oq71_punishment_mon(t,i,"lower") = q71_punishment_mon.lo(i); *##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/71_disagg_lvst/foragebased_aug18/preloop.gms b/modules/71_disagg_lvst/foragebased_aug18/preloop.gms index e7235b9da5..c28ebc62d7 100644 --- a/modules/71_disagg_lvst/foragebased_aug18/preloop.gms +++ b/modules/71_disagg_lvst/foragebased_aug18/preloop.gms @@ -9,6 +9,9 @@ i71_urban_area_share(j) = pm_land_start(j,"urban")/sum(cell(i,j),sum(cell2(i,j3),pm_land_start(j3,"urban"))) ; -s71_lp_fix = 0; s71_scale_mon = 1.10; s71_punish_additional_mon = 15000; + +* Minimal regional production of `kli_rum` to avoid division by zero in `q71_feed_balanceflow`. +vm_prod_reg.lo(i,kli_rum) = 10**(-6); + diff --git a/modules/71_disagg_lvst/foragebased_aug18/realization.gms b/modules/71_disagg_lvst/foragebased_aug18/realization.gms index dfea6fd299..11effc8e81 100644 --- a/modules/71_disagg_lvst/foragebased_aug18/realization.gms +++ b/modules/71_disagg_lvst/foragebased_aug18/realization.gms @@ -8,12 +8,17 @@ *' @description The foragebased_aug18 realization constrains the cellular ruminant livestock production by *' the feed availability for grazed pasture and fodder crops. This accounts for the fact that pasture and fodder *' (summarized with forage) feed stuff is usually not transported over long distances and at the same time -*' is very essential in livestock diets. The monogastric livestock is distributed following the idea -*' that these animals are held close to densely populated areas. For more detailed information on cellular livestock -*' distribution see @robinson_mapping_2014, which inspired this realization. +*' is very essential in livestock diets. Internally it distinguishs between extensively and intensively fed ruminants. +*' The monogastric livestock is distributed following the idea that these animals are held close to densely populated +*' areas. For more detailed information on cellular livestock distribution see @robinson_mapping_2014, which inspired +*' this realization. -*' @limitations Distribution of monogastrics do not account for feed availability within a cell. Crop residue feed stuff -*' for ruminant production is also not considered to restrict livestock production. +*' This realization includes a minimal lower bound for ruminant production to avoid avoid GAMS corner solutions at +*' higher spatial resolutions. + +*' @limitations Distribution of monogastrics do not account for feed availability within a cell. +*' Crop residue feed stuff for ruminant production is also not considered to restrict livestock +*' production. Forage feed stuff is consider not to be transported, but is in reality. *####################### R SECTION START (PHASES) ############################## $Ifi "%phase%" == "sets" $include "./modules/71_disagg_lvst/foragebased_aug18/sets.gms" @@ -22,6 +27,4 @@ $Ifi "%phase%" == "equations" $include "./modules/71_disagg_lvst/foragebased_aug $Ifi "%phase%" == "scaling" $include "./modules/71_disagg_lvst/foragebased_aug18/scaling.gms" $Ifi "%phase%" == "preloop" $include "./modules/71_disagg_lvst/foragebased_aug18/preloop.gms" $Ifi "%phase%" == "postsolve" $include "./modules/71_disagg_lvst/foragebased_aug18/postsolve.gms" -$Ifi "%phase%" == "nl_fix" $include "./modules/71_disagg_lvst/foragebased_aug18/nl_fix.gms" -$Ifi "%phase%" == "nl_release" $include "./modules/71_disagg_lvst/foragebased_aug18/nl_release.gms" *######################## R SECTION END (PHASES) ############################### diff --git a/modules/71_disagg_lvst/foragebased_jul23/declarations.gms b/modules/71_disagg_lvst/foragebased_jul23/declarations.gms index 0bbcb46044..b663054aa8 100644 --- a/modules/71_disagg_lvst/foragebased_jul23/declarations.gms +++ b/modules/71_disagg_lvst/foragebased_jul23/declarations.gms @@ -6,17 +6,17 @@ *** | Contact: magpie@pik-potsdam.de positive variables - v71_feed_forage(j,kforage) Production of forage within a cell (mio. tDM per yr) - v71_additional_mon(j, kli_mon) Additional punished production of monogastric livestock (mio. tDM per yr) - vm_costs_additional_mon(i) Punishment cost for additionally transported monogastric livst_egg (mio. USD05MER per yr) + v71_feed_forage(j, kforage) Production of forage within a cell (mio. tDM per yr) + v71_additional_mon(j, kli_mon) Additional punished production of monogastric livestock (mio. tDM per yr) + vm_costs_additional_mon(i) Punishment cost for additionally transported monogastric livst_egg (mio. USD05MER per yr) ; variables - v71_feed_balanceflow(j,kforage) Cellular feed balanceflow for forage feed for ruminant livestock (mio. tDM per yr) + v71_feed_balanceflow(j, kforage) Cellular feed balanceflow for forage feed for ruminant livestock (mio. tDM per yr) ; equations - q71_feed_rum_liv(j,kforage) Production constraint for ruminant livestock products (mio. tDM per yr) + q71_feed_rum_liv(j, kforage) Production constraint for ruminant livestock products (mio. tDM per yr) q71_feed_forage(j) Forage feed constraint (mio. tDM per yr) q71_feed_balanceflow_nlp(j) Non-linear balanceflow constraint for forage feed products (mio. tDM per yr) q71_feed_balanceflow_lp(i) Linear balanceflow constraint for forage feed products (mio. tDM per yr) diff --git a/modules/71_disagg_lvst/foragebased_jul23/equations.gms b/modules/71_disagg_lvst/foragebased_jul23/equations.gms index e220bc9a52..8c18f57f44 100644 --- a/modules/71_disagg_lvst/foragebased_jul23/equations.gms +++ b/modules/71_disagg_lvst/foragebased_jul23/equations.gms @@ -23,14 +23,13 @@ q71_feed_forage(j2) .. sum((kli_rum,kforage), vm_prod(j2,kli_rum) * sum((ct,cell(i2,j2)),im_feed_baskets(ct,i2,kli_rum,kforage))); -*' The above equation contains a split of pasture and fodder fed ruminants, since we assume that depending -*' on the intensity level of the livestock production, ruminants will graze on pastures (extensive systems) +*' The above equation contains a split of pasture and fodder fed ruminant feed requirements, since we assume +*' that depending on the intensity level of the livestock production, ruminants will graze on pastures (extensive systems) *' or will be fed via harvested fodder crops (intensive systems). - -*' The balance flow for pasture and fodder production (`kforage`) accounts as in -*' [70_livestock] `q70_feed(i2,kap,kall)` for inconsistencies with the FAO inventory of national feed use. -*' In each cluster the balance flow is constrained by its share of livestock production regarding the regional level by +*' The balance flow for pasture and fodder production (`kforage`) accounts as in [70_livestock] `q70_feed(i2,kap,kall)` +*' for inconsistencies with the FAO inventory of national feed use. In each cluster the balance flow is constrained by +*' its share of livestock production regarding the regional level by q71_feed_balanceflow_nlp(j2)$(s71_lp_fix=0) .. sum(kforage, v71_feed_balanceflow(j2,kforage)) =e= @@ -50,7 +49,6 @@ q71_feed_balanceflow_lp(i2)$(s71_lp_fix=1) .. *' @equations - *' To account for the above mentioned fact that monogastric livestock are held close to the population, it is *' distributed based on urban area by the formula diff --git a/modules/71_disagg_lvst/foragebased_jul23/realization.gms b/modules/71_disagg_lvst/foragebased_jul23/realization.gms index edb667b5ce..cb46c66113 100644 --- a/modules/71_disagg_lvst/foragebased_jul23/realization.gms +++ b/modules/71_disagg_lvst/foragebased_jul23/realization.gms @@ -5,15 +5,20 @@ *** | MAgPIE License Exception, version 1.0 (see LICENSE file). *** | Contact: magpie@pik-potsdam.de -*' @description The foragebased_aug18 realization constrains the cellular ruminant livestock production by -*' the feed availability for grazed pasture and fodder crops. This accounts for the fact that pasture and fodder -*' (summarized with forage) feed stuff is usually not transported over long distances and at the same time -*' is very essential in livestock diets. The monogastric livestock is distributed following the idea -*' that these animals are held close to densely populated areas. For more detailed information on cellular livestock +*' @description The foragebased_jul23 realization constrains the cellular ruminant livestock production by +*' the feed availability for grazed pasture and fodder crops. This accounts for the fact that pasture and fodder +*' (summarized with forage) feed stuff is usually not transported over long distances and at the same time +*' is very essential in livestock diets. The monogastric livestock is distributed following the idea +*' that these animals are held close to densely populated areas. For more detailed information on cellular livestock *' distribution see @robinson_mapping_2014, which inspired this realization. -*' @limitations Distribution of monogastrics do not account for feed availability within a cell. Crop residue feed stuff -*' for ruminant production is also not considered to restrict livestock production. +*' This realization includes a minimal lower bound for ruminant production to avoid avoid GAMS corner solutions at +*' higher spatial resolutions. It also has a linearized version, which can be switch on via `s71_lp_fix`. + +*' @limitations Distribution of monogastrics do not account for feed availability within a cell. +*' Crop residue feed stuff for ruminant production is also not considered to restrict livestock +*' production. Forage feed stuff is consider not to be transported, but is in reality. + *####################### R SECTION START (PHASES) ############################## $Ifi "%phase%" == "sets" $include "./modules/71_disagg_lvst/foragebased_jul23/sets.gms" From 053ddaadd2cd9f3474b0a5ba6e458c7531736d3d Mon Sep 17 00:00:00 2001 From: Kristine Karstens Date: Thu, 13 Jul 2023 10:42:48 +0200 Subject: [PATCH 57/62] bugfix unit of balanceflow multiplier --- modules/71_disagg_lvst/foragebased_aug18/declarations.gms | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/71_disagg_lvst/foragebased_aug18/declarations.gms b/modules/71_disagg_lvst/foragebased_aug18/declarations.gms index 2c48587fb5..0656adaad4 100644 --- a/modules/71_disagg_lvst/foragebased_aug18/declarations.gms +++ b/modules/71_disagg_lvst/foragebased_aug18/declarations.gms @@ -12,7 +12,7 @@ positive variables ; variables - v71_feed_balanceflow_share(j,kli_rum,kforage) Cellular feed balanceflow multiplier for forage feed for ruminant livestock (mio. tDM per yr) + v71_feed_balanceflow_share(j,kli_rum,kforage) Cellular feed balanceflow multiplier for forage feed for ruminant livestock (1) ; equations From 2290c07c208f523f97c0135488c2455d62ada057 Mon Sep 17 00:00:00 2001 From: Kristine Karstens Date: Thu, 13 Jul 2023 11:04:39 +0200 Subject: [PATCH 58/62] reintroduce small number addition to avoid devision by zero for feed basket with zeros --- modules/71_disagg_lvst/foragebased_aug18/equations.gms | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/71_disagg_lvst/foragebased_aug18/equations.gms b/modules/71_disagg_lvst/foragebased_aug18/equations.gms index 6d7e6a067a..b81e576e6b 100644 --- a/modules/71_disagg_lvst/foragebased_aug18/equations.gms +++ b/modules/71_disagg_lvst/foragebased_aug18/equations.gms @@ -29,7 +29,7 @@ q71_feed_rum_liv(j2, kforage) .. q71_balanceflow_constraint(j2, kli_rum, kforage) .. v71_feed_balanceflow_share(j2, kli_rum, kforage) =e= 1 + sum((ct, cell(i2,j2)), fm_feed_balanceflow(ct, i2, kli_rum, kforage) / - (im_feed_baskets(ct, i2, kli_rum, kforage) * vm_prod_reg(i2, kli_rum))) + (im_feed_baskets(ct, i2, kli_rum, kforage) * vm_prod_reg(i2, kli_rum) + 10^(-10))) ; *' The total cellular ruminant production is then given by From fc067a918e9b61131ecf3731a481d23700d8fc5a Mon Sep 17 00:00:00 2001 From: Kristine Karstens Date: Thu, 13 Jul 2023 15:07:02 +0200 Subject: [PATCH 59/62] bugfix math --- modules/71_disagg_lvst/foragebased_aug18/declarations.gms | 2 +- modules/71_disagg_lvst/foragebased_aug18/equations.gms | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/71_disagg_lvst/foragebased_aug18/declarations.gms b/modules/71_disagg_lvst/foragebased_aug18/declarations.gms index 0656adaad4..f3a74d5b78 100644 --- a/modules/71_disagg_lvst/foragebased_aug18/declarations.gms +++ b/modules/71_disagg_lvst/foragebased_aug18/declarations.gms @@ -37,7 +37,7 @@ parameters ov71_prod_rum(t,j,kli_rum,kforage,type) Production of forage fed ruminants within a cell (mio. tDM per yr) ov71_additional_mon(t,j,kli_mon,type) Additional punished production of monogastric livestock (mio. tDM per yr) ov_costs_additional_mon(t,i,type) Punishment cost for additionally transported monogastric livst_egg (mio. USD05MER per yr) - ov71_feed_balanceflow_share(t,j,kli_rum,kforage,type) Cellular feed balanceflow multiplier for forage feed for ruminant livestock (mio. tDM per yr) + ov71_feed_balanceflow_share(t,j,kli_rum,kforage,type) Cellular feed balanceflow multiplier for forage feed for ruminant livestock (1) oq71_feed_rum_liv(t,j,kforage,type) Production constraint for ruminant livestock products (mio. tDM per yr) oq71_balanceflow_constraint(t,j,kli_rum,kforage,type) Nonlinear balanceflow constraint for cellular forage feed products (mio. tDM per yr) oq71_sum_rum_liv(t,j,kli_rum,type) Total production of forage fed ruminants (mio. tDM per yr) diff --git a/modules/71_disagg_lvst/foragebased_aug18/equations.gms b/modules/71_disagg_lvst/foragebased_aug18/equations.gms index b81e576e6b..be1490c045 100644 --- a/modules/71_disagg_lvst/foragebased_aug18/equations.gms +++ b/modules/71_disagg_lvst/foragebased_aug18/equations.gms @@ -29,7 +29,7 @@ q71_feed_rum_liv(j2, kforage) .. q71_balanceflow_constraint(j2, kli_rum, kforage) .. v71_feed_balanceflow_share(j2, kli_rum, kforage) =e= 1 + sum((ct, cell(i2,j2)), fm_feed_balanceflow(ct, i2, kli_rum, kforage) / - (im_feed_baskets(ct, i2, kli_rum, kforage) * vm_prod_reg(i2, kli_rum) + 10^(-10))) + (im_feed_baskets(ct, i2, kli_rum, kforage) * vm_prod_reg(i2, kli_rum) + 10**(-10))) ; *' The total cellular ruminant production is then given by From 0f559b681d4da1ce4feabbeb5dfd9986ceaf7125 Mon Sep 17 00:00:00 2001 From: florianh Date: Fri, 14 Jul 2023 14:50:53 +0200 Subject: [PATCH 60/62] added missing changelog from PR571 --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e20a9323f3..6fcb076eb5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,14 +20,17 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **31_past** added `cc`, `nocc` and `nocc_hist` options for `c31_past_suit_scen` and `c31_grassl_yld_scenario` - **32_carbon** added `nocc` and `nocc_hist` option for `c52_land_carbon_sink_rcp` - **config** added `cfg$results_folder_highres` which allows to modify the output folder used in the `highres.R` output script +- **71_disagg_lvst** added new realisation `foragebased_jul23` which solves GAMS issues at higher spatial resolutions ### removed +- **config** `s80_num_nonopt_allowed - **scripts** removed .snapshot.Rprofile and the Rprofile.R script, renv now fully supersedes snapshots ### fixed - **30_crop** corrected q30_cropland in module realization rotation_apr22, where fallow land was on the wrong side of the equation - **config** updated scenario configs to newest preprocessing (4.87) - **config** corrected wrong names of parameters for peatland costs +- **80_optimization** resolve was not working in nlp_par realization due to `s80_num_nonopt_allowed` ## [4.6.7] - 2023-05-10 From e48dd55b3a24e9e1ae75ef2aa0f385a0bf992252 Mon Sep 17 00:00:00 2001 From: Kristine Karstens <33092354+k4rst3ns@users.noreply.github.com> Date: Fri, 14 Jul 2023 23:36:17 +0200 Subject: [PATCH 61/62] Update CHANGELOG.md also add fising of the old realization to changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6fcb076eb5..f13d624bb5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **30_crop** corrected q30_cropland in module realization rotation_apr22, where fallow land was on the wrong side of the equation - **config** updated scenario configs to newest preprocessing (4.87) - **config** corrected wrong names of parameters for peatland costs +- **71_disagg_lvst** reworked `foragebased_aug18` (including removal of linear version and correction of balance flow calculation) - **80_optimization** resolve was not working in nlp_par realization due to `s80_num_nonopt_allowed` ## [4.6.7] - 2023-05-10 From 5879a3eaec5e54085374b26165c189b38e5b92db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20F=C3=BChrlich?= Date: Mon, 17 Jul 2023 14:50:10 +0200 Subject: [PATCH 62/62] magpie release 4.6.8 --- .zenodo.json | 4 ++-- CHANGELOG.md | 21 +++++++++++---------- CITATION.cff | 4 ++-- README.md | 6 +++--- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/.zenodo.json b/.zenodo.json index 0374c30b02..5e69eaa32a 100644 --- a/.zenodo.json +++ b/.zenodo.json @@ -1,6 +1,6 @@ { "title": "MAgPIE - An Open Source land-use modeling framework", - "version": "4.6.7dev", + "version": "4.6.8", "creators": [ { "name": "Dietrich, Jan Philipp", @@ -109,5 +109,5 @@ "license": { "id": "AGPL-3.0-or-later" }, - "publication_date": "2023-05-10" + "publication_date": "2023-07-17" } diff --git a/CHANGELOG.md b/CHANGELOG.md index f13d624bb5..6840e5850a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,33 +5,33 @@ 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/). -## [Unreleased] +## [4.6.8] - 2023-07-17 ### changed +- **41_area_equipped_for_irrigation** new AEI data (Mehta2022) replacing old Siebert data - **80_optimization** printing of solprint when solver status is 7 re-activated - **scripts** start_functions.R can now handle clusters per region flexibly - **scripts** the REMIND-MAgPIE coupling now uses renv -- **41_area_equipped_for_irrigation** new AEI data (Mehta2022) replacing old Siebert data ### added -- **scripts** New output script for reporting disaggregated land use patterns to the SEALS (Spatial Economic Allocation Landscape Simulator) downscaling model -- **scenario_config.csv** added a scenario for the NGFS project -- **config** new area equipped for irrigation (AEI) data in preprocessing (4.87) - **31_past** added `cc`, `nocc` and `nocc_hist` options for `c31_past_suit_scen` and `c31_grassl_yld_scenario` - **32_carbon** added `nocc` and `nocc_hist` option for `c52_land_carbon_sink_rcp` -- **config** added `cfg$results_folder_highres` which allows to modify the output folder used in the `highres.R` output script - **71_disagg_lvst** added new realisation `foragebased_jul23` which solves GAMS issues at higher spatial resolutions +- **config** added `cfg$results_folder_highres` which allows to modify the output folder used in the `highres.R` output script +- **config** new area equipped for irrigation (AEI) data in preprocessing (4.87) +- **scenario_config.csv** added a scenario for the NGFS project +- **scripts** New output script for reporting disaggregated land use patterns to the SEALS (Spatial Economic Allocation Landscape Simulator) downscaling model ### removed -- **config** `s80_num_nonopt_allowed +- **config** `s80_num_nonopt_allowed` - **scripts** removed .snapshot.Rprofile and the Rprofile.R script, renv now fully supersedes snapshots ### fixed - **30_crop** corrected q30_cropland in module realization rotation_apr22, where fallow land was on the wrong side of the equation -- **config** updated scenario configs to newest preprocessing (4.87) -- **config** corrected wrong names of parameters for peatland costs - **71_disagg_lvst** reworked `foragebased_aug18` (including removal of linear version and correction of balance flow calculation) - **80_optimization** resolve was not working in nlp_par realization due to `s80_num_nonopt_allowed` +- **config** corrected wrong names of parameters for peatland costs +- **config** updated scenario configs to newest preprocessing (4.87) ## [4.6.7] - 2023-05-10 @@ -729,7 +729,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.7...develop +[Unreleased]: https://github.com/magpiemodel/magpie/compare/v4.6.8...develop +[4.6.8]: https://github.com/magpiemodel/magpie/compare/v4.6.7...v4.6.8 [4.6.7]: https://github.com/magpiemodel/magpie/compare/v4.6.6...v4.6.7 [4.6.6]: https://github.com/magpiemodel/magpie/compare/v4.6.5...v4.6.6 [4.6.5]: https://github.com/magpiemodel/magpie/compare/v4.6.4...v4.6.5 diff --git a/CITATION.cff b/CITATION.cff index 3ef58fe565..6ebb15977b 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -125,8 +125,8 @@ authors: email: popp@pik-potsdam.de title: MAgPIE - An Open Source land-use modeling framework -version: 4.6.7dev -date-released: 2023-05-10 +version: 4.6.8 +date-released: 2023-07-17 repository-code: https://github.com/magpiemodel/magpie keywords: - landuse diff --git a/README.md b/README.md index 72cb867ea6..5f15852147 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.7 can be found at -https://rse.pik-potsdam.de/doc/magpie/4.6.7/ +The model documentation for version 4.6.8 can be found at +https://rse.pik-potsdam.de/doc/magpie/4.6.8/ A most recent version of the documentation can also be extracted from the model source code via the R package goxygen @@ -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.7/#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.6.8/#how-to-cite) in the model documentation for information how to cite the model. ## AUTHORS See list of authors in CITATION.cff