From b222f21a2537371defa15607e1b633adc418d665 Mon Sep 17 00:00:00 2001 From: Renato-Rodrigues Date: Tue, 13 Jun 2023 14:54:50 +0200 Subject: [PATCH 01/15] updating LULUCF grassi shift calculation --- modules/47_regipol/regiCarbonPrice/datainput.gms | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/modules/47_regipol/regiCarbonPrice/datainput.gms b/modules/47_regipol/regiCarbonPrice/datainput.gms index d8764ac13..e1d69dc25 100644 --- a/modules/47_regipol/regiCarbonPrice/datainput.gms +++ b/modules/47_regipol/regiCarbonPrice/datainput.gms @@ -238,9 +238,19 @@ $offdelim / ; -*** difference between 2015 land-use change emissions from Magpie and UNFCCC 2015 land-use change emissions -p47_LULUCFEmi_GrassiShift(t,regi)$(p47_EmiLULUCFCountryAcc("2015",regi)) = (pm_macBaseMagpie("2015",regi,"co2luc") - p47_EmiLULUCFCountryAcc("2015",regi)* 1e-3/sm_c_2_co2); - +*** difference between 2020 land-use change emissions from Magpie and UNFCCC 2015 and 2020 moving average land-use change emissions +p47_LULUCFEmi_GrassiShift(t,regi)$(p47_EmiLULUCFCountryAcc("2020",regi)) = + pm_macBaseMagpie("2020",regi,"co2luc") + - + ( + ( + ((p47_EmiLULUCFCountryAcc("2013",regi) + p47_EmiLULUCFCountryAcc("2014",regi) + p47_EmiLULUCFCountryAcc("2015",regi) + p47_EmiLULUCFCountryAcc("2016",regi) + p47_EmiLULUCFCountryAcc("2017",regi))/5) + + + ((p47_EmiLULUCFCountryAcc("2018",regi) + p47_EmiLULUCFCountryAcc("2019",regi) + p47_EmiLULUCFCountryAcc("2020",regi) + p47_EmiLULUCFCountryAcc("2021",regi))/4) + )/2 + * 1e-3/sm_c_2_co2 + ) +; *** -------------------------Primary Energy Tax-------------------------- From f9af7663669c71f4988a481b3c54e6c87a23b1cf Mon Sep 17 00:00:00 2001 From: fbenke-pik Date: Tue, 11 Jul 2023 16:36:26 +0200 Subject: [PATCH 02/15] introduce data validation tests --- Makefile | 3 ++ .../testthat/validation/test_01-mifs_exist.R | 20 ++++++++++ .../testthat/validation/test_02-fe_liquids.R | 37 ++++++++++++++++++ .../validation/test_03-negative_electrictiy.R | 32 +++++++++++++++ .../testthat/validation/test_04-invest_esm.R | 39 +++++++++++++++++++ 5 files changed, 131 insertions(+) create mode 100644 tests/testthat/validation/test_01-mifs_exist.R create mode 100644 tests/testthat/validation/test_02-fe_liquids.R create mode 100644 tests/testthat/validation/test_03-negative_electrictiy.R create mode 100644 tests/testthat/validation/test_04-invest_esm.R diff --git a/Makefile b/Makefile index bc0e047da..a748d15f9 100644 --- a/Makefile +++ b/Makefile @@ -63,3 +63,6 @@ test-full: ## Run all tests, including coupling tests and a default ## REMIND scenario. Takes significantly longer than 10 minutes to run. $(info Full tests take more than an hour to run, please be patient) @R_PROFILE_USER= TESTTHAT_RUN_SLOW=TRUE Rscript -e 'testthat::test_dir("tests/testthat")' +test-validation: ## Run validation tests, requires a full set of runs in the output folder + $(info Run validation tests, requires a full set of runs in the output folder) + @R_PROFILE_USER= TESTTHAT_RUN_SLOW=TRUE Rscript -e 'testthat::test_dir("tests/testthat/validation")' diff --git a/tests/testthat/validation/test_01-mifs_exist.R b/tests/testthat/validation/test_01-mifs_exist.R new file mode 100644 index 000000000..e8c1139a5 --- /dev/null +++ b/tests/testthat/validation/test_01-mifs_exist.R @@ -0,0 +1,20 @@ +# | (C) 2006-2023 Potsdam Institute for Climate Impact Research (PIK) +# | authors, and contributors see CITATION.cff file. This file is part +# | of REMIND and licensed under AGPL-3.0-or-later. Under Section 7 of +# | AGPL-3.0, you are granted additional permissions described in the +# | REMIND License Exception, version 1.0 (see LICENSE file). +# | Contact: remind@pik-potsdam.de +test_that("each output folder contains standard mif files", { + dirs <- list.dirs("../../../output", recursive = FALSE, full.names = FALSE) + for (dir in dirs) { + d <- paste0("../../../output/", dir) + r <- expect_true( + length(list.files(path = d, pattern = "REMIND_generic_.*.mif")) == 2 && + length(list.files(path = d, pattern = "REMIND_climate_.*.mif")) == 1 + ) + + if (!r) { + print(paste0("some mifs are missing in ", dir)) + } + } +}) diff --git a/tests/testthat/validation/test_02-fe_liquids.R b/tests/testthat/validation/test_02-fe_liquids.R new file mode 100644 index 000000000..bfadc523c --- /dev/null +++ b/tests/testthat/validation/test_02-fe_liquids.R @@ -0,0 +1,37 @@ +# | (C) 2006-2023 Potsdam Institute for Climate Impact Research (PIK) +# | authors, and contributors see CITATION.cff file. This file is part +# | of REMIND and licensed under AGPL-3.0-or-later. Under Section 7 of +# | AGPL-3.0, you are granted additional permissions described in the +# | REMIND License Exception, version 1.0 (see LICENSE file). +# | Contact: remind@pik-potsdam.de +# Source: https://github.com/remindmodel/development_issues/issues/168 +library(magclass) +library(quitte) +library(dplyr) +test_that("liquids demand in buildings in NPi and NDC is not higher than baseline", { + dirs <- list.dirs("../../../output", recursive = FALSE) + data <- NULL + for (d in dirs) { + mifs <- list.files(path = d, pattern = "REMIND_generic_.*_withoutPlus.mif", full.names = TRUE) + if (length(mifs) == 1) { + m <- suppressWarnings(read.report(mifs[1], as.list = FALSE)["GLO", , "FE|Buildings|Liquids (EJ/yr)"]) + data <- mbind(data, m) + } + } + + if (all(c("SSP2EU-Base", "SSP2EU-NPi", "SSP2EU-NDC") %in% getNames(data, dim = 1))) { + xBase <- as.quitte(data[, , "SSP2EU-Base"]) + x <- as.quitte(data[, , c("SSP2EU-NPi", "SSP2EU-NDC")]) + # data frame with all data points where Base value is greater than NPi/NDC value, + # excluding historical values + x <- left_join(x, xBase, by = c("model", "region", "variable", "unit", "period")) %>% + filter(value.x > value.y, period > 2025) + } + + r <- expect_true(nrow(x) == 0) + + if (!r) { + print("Examples of test violation:") + print(head(x)) + } +}) diff --git a/tests/testthat/validation/test_03-negative_electrictiy.R b/tests/testthat/validation/test_03-negative_electrictiy.R new file mode 100644 index 000000000..0c56148f7 --- /dev/null +++ b/tests/testthat/validation/test_03-negative_electrictiy.R @@ -0,0 +1,32 @@ +# | (C) 2006-2023 Potsdam Institute for Climate Impact Research (PIK) +# | authors, and contributors see CITATION.cff file. This file is part +# | of REMIND and licensed under AGPL-3.0-or-later. Under Section 7 of +# | AGPL-3.0, you are granted additional permissions described in the +# | REMIND License Exception, version 1.0 (see LICENSE file). +# | Contact: remind@pik-potsdam.de +# Source: https://github.com/remindmodel/development_issues/issues/91 +library(magclass) +test_that("there are no negative electricity prices in historic years in EU regions", { + dirs <- list.dirs("../../../output", recursive = FALSE) + data <- NULL + reg <- c("EU27", "DEU", "ECE", "ECS", "ENC", "ESC", "ESW", "EWN", "FRA") + for (d in dirs) { + mifs <- list.files(path = d, pattern = "REMIND_generic_.*_withoutPlus.mif", full.names = TRUE) + if (length(mifs) == 1) { + m <- suppressWarnings( + read.report(mifs[1], as.list = FALSE)[ + , , + c( + "Price|Secondary Energy|Electricity (US$2005/GJ)", + "Price|Final Energy|Industry|Electricity (US$2005/GJ)" + ) + ] + ) + if (all(reg %in% getRegions(m))) { + data <- mbind(data, m[reg, seq(2005, 2025, 5), ]) + } + } + } + + expect_true(length(data[data < 0 & !is.na(data)]) == 0) +}) diff --git a/tests/testthat/validation/test_04-invest_esm.R b/tests/testthat/validation/test_04-invest_esm.R new file mode 100644 index 000000000..0030b211e --- /dev/null +++ b/tests/testthat/validation/test_04-invest_esm.R @@ -0,0 +1,39 @@ +# | (C) 2006-2023 Potsdam Institute for Climate Impact Research (PIK) +# | authors, and contributors see CITATION.cff file. This file is part +# | of REMIND and licensed under AGPL-3.0-or-later. Under Section 7 of +# | AGPL-3.0, you are granted additional permissions described in the +# | REMIND License Exception, version 1.0 (see LICENSE file). +# | Contact: remind@pik-potsdam.de +library(magclass) +library(quitte) +library(dplyr) +test_that("Non-ESM Investments never drop more than 50% in comparison to previous timestep until 2100", { + dirs <- list.dirs("../../../output", recursive = FALSE) + data <- NULL + reg <- c( + "CAZ", "CHA", "EUR", "IND", "JPN", "LAM", "MEA", + "NEU", "OAS", "REF", "SSA", "USA", "GLO" + ) + for (d in dirs) { + mifs <- list.files(path = d, pattern = "REMIND_generic_.*_withoutPlus.mif", full.names = TRUE) + if (length(mifs) == 1) { + m <- suppressWarnings( + read.report(mifs[1], as.list = FALSE) + )[reg, , "Investments|Non-ESM (billion US$2005/yr)"] + data <- mbind(data, m) + } + } + data <- data[, getYears(data, as.integer = TRUE) <= 2100, ] + x <- as.quitte(data) + xPrev <- mutate(x, period_next := period + 5) + xDiff <- inner_join(x, xPrev, by = c("period" = "period_next", "model", "scenario", "region", "variable", "unit")) %>% + mutate(value := (value.x - value.y) / value.x) %>% + filter(value < -0.5) + + r <- expect_true(nrow(xDiff) == 0) + + if (!r) { + print("Examples of test violation:") + print(head(xDiff)) + } +}) From 2eb5d3fb721db74aea46efbb8f814251dd57e291 Mon Sep 17 00:00:00 2001 From: orichters Date: Wed, 2 Aug 2023 10:49:08 +0200 Subject: [PATCH 03/15] remove unused switch cm_fixCO2price --- main.gms | 1 - scripts/start/readCheckScenarioConfig.R | 5 +++-- standalone/MOFEX/MOFEX.gms | 2 -- standalone/trade/trade.gms | 2 -- 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/main.gms b/main.gms index 9ee75420b..1915ed637 100755 --- a/main.gms +++ b/main.gms @@ -1639,7 +1639,6 @@ $setglobal cm_CES_configuration indu_subsectors-buil_simple-tran_edge_esm-POP_p $setglobal c_CES_calibration_iterations 10 !! def = 10 $setglobal c_CES_calibration_industry_FE_target 1 $setglobal c_testOneRegi_region EUR !! def = EUR !! regexp = [A-Z]{3} -$setglobal cm_fixCO2price off !! def = off *' @stop diff --git a/scripts/start/readCheckScenarioConfig.R b/scripts/start/readCheckScenarioConfig.R index 420bf2490..07026804e 100644 --- a/scripts/start/readCheckScenarioConfig.R +++ b/scripts/start/readCheckScenarioConfig.R @@ -115,8 +115,9 @@ readCheckScenarioConfig <- function(filename, remindPath = ".", testmode = FALSE "cm_BioImportTax_EU" = "Use more flexible cm_import_tax switch instead, see https://github.com/remindmodel/remind/issues/1157", "cm_trdcst" = "Now always fixed to 1.5, see https://github.com/remindmodel/remind/pull/1052", "cm_trdadj" = "Now always fixed to 2, see https://github.com/remindmodel/remind/pull/1052", - "cm_OILRETIRE" = "Now always on by default, see https://github.com/remindmodel/remind/pull/1102" - ) + "cm_OILRETIRE" = "Now always on by default, see https://github.com/remindmodel/remind/pull/1102", + "cm_fixCO2price" = "Was never in use, removed in https://github.com/remindmodel/remind/pull/1369", + NULL) for (i in intersect(names(forbiddenColumnNames), unknownColumnNames)) { if (testmode) { warning("Column name ", i, " in remind settings is outdated. ", forbiddenColumnNames[i]) diff --git a/standalone/MOFEX/MOFEX.gms b/standalone/MOFEX/MOFEX.gms index b87982797..cf13351c7 100644 --- a/standalone/MOFEX/MOFEX.gms +++ b/standalone/MOFEX/MOFEX.gms @@ -496,8 +496,6 @@ $setglobal cm_DAC_eff off !! def = off $setglobal cm_sehe_upper off !! def = off -$setglobal cm_fixCO2price off !! def = off - $setglobal cm_feShareLimits off !! def = off $setglobal c_fuelprice_init off !! def = off diff --git a/standalone/trade/trade.gms b/standalone/trade/trade.gms index 5bf3dea66..dadbb0b08 100644 --- a/standalone/trade/trade.gms +++ b/standalone/trade/trade.gms @@ -501,8 +501,6 @@ $setglobal cm_DAC_eff off !! def = off $setglobal cm_sehe_upper off !! def = off -$setglobal cm_fixCO2price off !! def = off - $setglobal cm_feShareLimits off !! def = off $setglobal c_fuelprice_init off !! def = off From 443e0c4d640f62e42cfc4b056e7f30434d3992bf Mon Sep 17 00:00:00 2001 From: orichters Date: Wed, 2 Aug 2023 13:14:48 +0200 Subject: [PATCH 04/15] suppress madrat standard config for start.R --- scripts/start/readCheckScenarioConfig.R | 2 +- start.R | 3 +++ start_bundle_coupled.R | 3 +++ tests/testthat/test_01-readCheckScenarioConfig.R | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/start/readCheckScenarioConfig.R b/scripts/start/readCheckScenarioConfig.R index 9908d5b3a..822e5c508 100644 --- a/scripts/start/readCheckScenarioConfig.R +++ b/scripts/start/readCheckScenarioConfig.R @@ -36,7 +36,7 @@ readCheckScenarioConfig <- function(filename, remindPath = ".", testmode = FALSE } nameisNA <- grepl("^NA$", rownames(scenConf)) if (any(nameisNA)) { - warning("Don't use 'NA' as scenario name, you fool. Stopping now.") + warning("Do not use 'NA' as scenario name, you fool. Stopping now.") } illegalchars <- grepl("[^[:alnum:]_-]", rownames(scenConf)) if (any(illegalchars)) { diff --git a/start.R b/start.R index 431a23685..f2c250aff 100755 --- a/start.R +++ b/start.R @@ -110,6 +110,9 @@ if ( 'TRUE' != Sys.getenv('ignoreRenvUpdates') Sys.sleep(1) } +# initialize madrat settings +invisible(madrat::getConfig(verbose = FALSE)) + errorsfound <- 0 # counts ignored errors in --test mode startedRuns <- 0 waitingRuns <- 0 diff --git a/start_bundle_coupled.R b/start_bundle_coupled.R index ab309942d..8c8d79589 100755 --- a/start_bundle_coupled.R +++ b/start_bundle_coupled.R @@ -270,6 +270,9 @@ if (file.exists("/p") && sum(scenarios_coupled[common, "qos"] == "priority", na. ######## PREPARE AND START COUPLED RUNS ############ #################################################### +# initialize madrat settings +invisible(madrat::getConfig(verbose = FALSE)) + # prepare runs: write RData files for(scen in common){ message("\n################################\nPreparing run ", scen, "\n") diff --git a/tests/testthat/test_01-readCheckScenarioConfig.R b/tests/testthat/test_01-readCheckScenarioConfig.R index 90f9d2b0c..37c254402 100644 --- a/tests/testthat/test_01-readCheckScenarioConfig.R +++ b/tests/testthat/test_01-readCheckScenarioConfig.R @@ -35,6 +35,7 @@ test_that("readCheckScenarioConfig fails on error-loaden config", { expect_match(w, "scenario names indicated in copyConfigFrom column were not found", all = FALSE, fixed = TRUE) expect_match(w, "specify in copyConfigFrom column a scenario name defined below in the file", all = FALSE, fixed = TRUE) expect_match(w, "which requires a reference gdx", all = FALSE, fixed = TRUE) + expect_match(w, "Do not use 'NA' as scenario name", all = FALSE, fixed = TRUE) expect_match(m, "no column path_gdx_refpolicycost for policy cost comparison found, using path_gdx_ref instead", all = FALSE, fixed = TRUE) expect_match(m, "In 1 scenarios, neither 'carbonprice'", all = FALSE, fixed = TRUE) copiedFromPBS <- c("c_budgetCO2", "path_gdx", "path_gdx_ref") From 2c8316689fcc67308ea648666eb96d107c5c032c Mon Sep 17 00:00:00 2001 From: Lavinia Baumstark Date: Wed, 9 Aug 2023 11:05:42 +0200 Subject: [PATCH 05/15] delete outdated script validationSummary.R --- scripts/output/single/validationSummary.R | 32 ----------------------- 1 file changed, 32 deletions(-) delete mode 100644 scripts/output/single/validationSummary.R diff --git a/scripts/output/single/validationSummary.R b/scripts/output/single/validationSummary.R deleted file mode 100644 index 3f71a51ca..000000000 --- a/scripts/output/single/validationSummary.R +++ /dev/null @@ -1,32 +0,0 @@ -# | (C) 2006-2023 Potsdam Institute for Climate Impact Research (PIK) -# | authors, and contributors see CITATION.cff file. This file is part -# | of REMIND and licensed under AGPL-3.0-or-later. Under Section 7 of -# | AGPL-3.0, you are granted additional permissions described in the -# | REMIND License Exception, version 1.0 (see LICENSE file). -# | Contact: remind@pik-potsdam.de - -library(remind2) -library(lucode2) - -############################# BASIC CONFIGURATION ############################# - -if(!exists("source_include")) { - #Define arguments that can be read from command line - outputdir <- "output/R17IH_SSP2_postIIASA-26_2016-12-23_16.03.23" # path to the output folder - readArgs("outputdir") -} - -scenario <- getScenNames(outputdir) -remind_reporting_file <- file.path(outputdir,paste0("REMIND_generic_",scenario,".mif")) -gdx <- file.path(outputdir,"fulldata.gdx") -hist <- c(paste0(outputdir, "/historical.mif"), "./core/input/historical/historical.mif") -name_of_output_pdf <- file.path(outputdir,paste0("REMIND_summary_",scenario,".pdf")) - -#### Choose validation data ### -# Use first hist file that can be found -for(h in hist) { - if(file.exists(h)) break -} - -# generate validation for REMIND -validationSummary(gdx=gdx, hist=h, reportfile=remind_reporting_file, outfile=name_of_output_pdf) From 7079d00b51a9f25f86ce9f2eb3720326c38865a0 Mon Sep 17 00:00:00 2001 From: Falk Benke Date: Wed, 9 Aug 2023 16:22:05 +0200 Subject: [PATCH 06/15] fix bug in plotIterations.R --- scripts/output/single/plotIterations.R | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/output/single/plotIterations.R b/scripts/output/single/plotIterations.R index bdc2abdb7..a87ee5378 100644 --- a/scripts/output/single/plotIterations.R +++ b/scripts/output/single/plotIterations.R @@ -39,14 +39,14 @@ if (!identical(trimws(answer), "")) { } symbolNames <- trimws(strsplit(symbolNames, ",")[[1]]) - # choose plot mapping - for (s in symbolNames) { +for (s in symbolNames) { cat("\n\nHow do you want to map the dimensions of ", s, "in the plot?", "Unused aesthetics need to be set to NULL. Combine dimensions with +.\n(default: ", plotMappingDefault, ")\n") answer <- getLineCoerce() if (!identical(trimws(answer), "")) { pm <- answer + # user input contains combined dimensions if (grepl("\\+", pm)) { cd <- strsplit(pm, ",")[[1]] cd <- cd[grepl("\\+", cd)] @@ -72,6 +72,10 @@ symbolNames <- trimws(strsplit(symbolNames, ",")[[1]]) ) combineDims[[s]] <- cd plotMapping[[s]] <- pm + # user input does not contain combined dimensions + } else{ + plotMapping[[s]] <- pm + combineDims[[s]] <- "" } } else { plotMapping[[s]] <- plotMappingDefault From f3abf7d65966e331783389ebcbfe22e31ea79bf9 Mon Sep 17 00:00:00 2001 From: Michaja Pehl Date: Wed, 9 Aug 2023 16:54:58 +0200 Subject: [PATCH 07/15] add lower bound for feel_steel_secondary that is markedly higher than sm_eps to improve CONOPT convergence close #206 --- modules/37_industry/subsectors/bounds.gms | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/modules/37_industry/subsectors/bounds.gms b/modules/37_industry/subsectors/bounds.gms index 097117795..18f1386aa 100755 --- a/modules/37_industry/subsectors/bounds.gms +++ b/modules/37_industry/subsectors/bounds.gms @@ -89,6 +89,23 @@ $endif.CES_parameters vm_cesIO.fx("2005",regi,ppfkap_industry_dyn37(in)) = pm_cesdata("2005",regi,in,"quantity"); +*** Set lower bound for secondary steel electricity to 1 % of the lowest +*** existing lower bound (should be far above sm_eps) to avoid CONOPT getting +*** lost in the woods. +loop (in$( sameas(in,"feel_steel_secondary") ), + vm_cesIO.lo(t,regi,in)$( t.val ge cm_startyear + AND vm_cesIO.lo(t,regi,in) le sm_eps ) + = max( + sm_eps, + ( 0.01 + * smax(ttot$( vm_cesIO.lo(ttot,regi,in) gt sm_eps), + vm_cesIO.lo(ttot,regi,in) + ) + ) + ); +); + +*** Default lower bounds on all industry pfs vm_cesIO.lo(t,regi_dyn29(regi),in_industry_dyn37(in))$( 0 eq vm_cesIO.lo(t,regi,in) ) = sm_eps; From 740943c2f8fa23865bcbd322d8dc574c8a404e4b Mon Sep 17 00:00:00 2001 From: orichters Date: Tue, 15 Aug 2023 13:36:04 +0200 Subject: [PATCH 08/15] in readCheckScenarioConfig, don't ask user to ignore unknown columns if failing anyway --- scripts/start/readCheckScenarioConfig.R | 34 ++++++++++++++----------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/scripts/start/readCheckScenarioConfig.R b/scripts/start/readCheckScenarioConfig.R index 495cde109..e692f8f67 100644 --- a/scripts/start/readCheckScenarioConfig.R +++ b/scripts/start/readCheckScenarioConfig.R @@ -114,21 +114,6 @@ readCheckScenarioConfig <- function(filename, remindPath = ".", testmode = FALSE } unknownColumnNames <- names(scenConf)[! names(scenConf) %in% knownColumnNames] if (length(unknownColumnNames) > 0) { - message("\nAutomated checks did not find counterparts in main.gms and default.cfg for these columns in ", - basename(filename), ":") - message(" ", paste(unknownColumnNames, collapse = ", ")) - message("This check was added Jan. 2022. ", - "If you find false positives, add them to knownColumnNames in start/scripts/readCheckScenarioConfig.R.\n") - unknownColumnNamesNoComments <- unknownColumnNames[! grepl("^\\.", unknownColumnNames)] - if (length(unknownColumnNamesNoComments) > 0) { - if (testmode) { - warning("Unknown column names: ", paste(unknownColumnNamesNoComments, collapse = ", ")) - } else { - message("Do you want to continue and simply ignore them? Y/n") - userinput <- tolower(gms::getLine()) - if (! userinput %in% c("y", "")) stop("Ok, so let's stop.") - } - } forbiddenColumnNames <- list( # specify forbidden column name and what should be done with it "c_budgetCO2" = "Rename to c_budgetCO2from2020, adapt emission budgets, see https://github.com/remindmodel/remind/pull/640", "c_budgetCO2FFI" = "Rename to c_budgetCO2from2020FFI, adapt emission budgets, see https://github.com/remindmodel/remind/pull/640", @@ -158,6 +143,25 @@ readCheckScenarioConfig <- function(filename, remindPath = ".", testmode = FALSE warning("Outdated column names found that must not be used.") errorsfound <- errorsfound + length(intersect(names(forbiddenColumnNames), unknownColumnNames)) } + # sort out known but forbidden names from unknown + unknownColumnNames <- setdiff(unknownColumnNames, names(forbiddenColumnNames)) + if (length(unknownColumnNames) > 0) { + message("\nAutomated checks did not find counterparts in main.gms and default.cfg for these columns in ", + basename(filename), ":") + message(" ", paste(unknownColumnNames, collapse = ", ")) + message("This check was added Jan. 2022. ", + "If you find false positives, add them to knownColumnNames in start/scripts/readCheckScenarioConfig.R.\n") + unknownColumnNamesNoComments <- unknownColumnNames[! grepl("^\\.", unknownColumnNames)] + if (length(unknownColumnNamesNoComments) > 0) { + if (testmode) { + warning("Unknown column names: ", paste(unknownColumnNamesNoComments, collapse = ", ")) + } else if (errorsfound == 0) { + message("Do you want to continue and simply ignore them? Y/n") + userinput <- tolower(gms::getLine()) + if (! userinput %in% c("y", "")) stop("Ok, so let's stop.") + } + } + } } if (errorsfound > 0) { if (testmode) warning(errorsfound, " errors found.") From aba9d1d2d5df81a5f034996561d9fed532923493 Mon Sep 17 00:00:00 2001 From: Katarzyna Kowalczyk Date: Wed, 16 Aug 2023 08:35:22 +0200 Subject: [PATCH 09/15] Rename grindrock to weathering --- config/default.cfg | 2 +- core/input/generisdata_tech.prn | 2 +- core/input/generisdata_tech_SSP1.prn | 2 +- core/input/generisdata_tech_SSP5.prn | 2 +- core/sets.gms | 3 ++- modules/33_CDR/all/equations.gms | 2 +- modules/33_CDR/all/sets.gms | 12 ++++++------ modules/33_CDR/off/bounds.gms | 2 +- modules/33_CDR/weathering/equations.gms | 2 +- modules/33_CDR/weathering/sets.gms | 6 +++--- 10 files changed, 18 insertions(+), 17 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index 6179cfabc..1b558c3fd 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -27,7 +27,7 @@ cfg$regionmapping <- "config/regionmappingH12.csv" ### Additional (optional) region mapping, so that those validation data can be loaded that contain the corresponding additional regions. cfg$extramappings_historic <- "" #### Current input data revision (.) #### -cfg$inputRevision <- "6.543" +cfg$inputRevision <- "6.544" #### Current CES parameter and GDX revision (commit hash) #### cfg$CESandGDXversion <- "ce96f1f97389c0b49757726259a40754a3c930b3" diff --git a/core/input/generisdata_tech.prn b/core/input/generisdata_tech.prn index f549f2368..44a698e5e 100644 --- a/core/input/generisdata_tech.prn +++ b/core/input/generisdata_tech.prn @@ -165,7 +165,7 @@ incolearn 19000 0.00 29000 ccap0 0.003 0.003 learn 0.10 0.10 -+ rockgrind dac ++ weathering dac tech_stat 4 inco0 0.01 18800 mix0 0 0 diff --git a/core/input/generisdata_tech_SSP1.prn b/core/input/generisdata_tech_SSP1.prn index 8d37e1ced..a87dd053f 100644 --- a/core/input/generisdata_tech_SSP1.prn +++ b/core/input/generisdata_tech_SSP1.prn @@ -163,7 +163,7 @@ incolearn 20000 0.00 29000 ccap0 0.003 0.003 learn 0.10 0.10 -+ rockgrind dac ++ weathering dac tech_stat 4 inco0 0.01 18800 mix0 0 0 diff --git a/core/input/generisdata_tech_SSP5.prn b/core/input/generisdata_tech_SSP5.prn index de4a22496..1e6c73828 100644 --- a/core/input/generisdata_tech_SSP5.prn +++ b/core/input/generisdata_tech_SSP5.prn @@ -162,7 +162,7 @@ incolearn 18400 0.00 29000 ccap0 0.003 0.003 learn 0.10 0.10 -+ rockgrind dac ++ weathering dac tech_stat 4 inco0 0.01 18800 mix0 0 0 diff --git a/core/sets.gms b/core/sets.gms index 4383cd2db..a852797aa 100755 --- a/core/sets.gms +++ b/core/sets.gms @@ -275,7 +275,8 @@ $ENDIF.WindOff apCarElT "Cars using final energy electricity (FEELT) to produce useful energy as electricity for transport (UEELT)" apTrnElT "Trains using final energy electricity (FEELT) to produce useful energy as electricity for transport (UEELT)" *** appCarGaT "Cars using FEGAT to produce ESGAT." ??? - rockgrind "grinding rock for enhanced weathering" + rockgrind "grinding rock for enhanced weathering" !! deprecated, will be removed with CDR module refactoring + weathering "enhanced weathering" dac "direct air capture" x_gas2elec d_bio2elec "d_* transmission and distribution losses" diff --git a/modules/33_CDR/all/equations.gms b/modules/33_CDR/all/equations.gms index c6cb94556..9d37e50b8 100644 --- a/modules/33_CDR/all/equations.gms +++ b/modules/33_CDR/all/equations.gms @@ -21,7 +21,7 @@ q33_demFeCDR(t,regi,entyFe)$(entyFe2Sector(entyFe,"cdr")) .. q33_capconst_grindrock(t,regi).. sum(rlf2,sum(rlf, v33_grindrock_onfield(t,regi,rlf,rlf2))) =l= - sum(teNoTransform2rlf_dyn33("rockgrind",rlf2), vm_capFac(t,regi,"rockgrind") * vm_cap(t,regi,"rockgrind",rlf2)) + sum(teNoTransform2rlf_dyn33("weathering",rlf2), vm_capFac(t,regi,"weathering") * vm_cap(t,regi,"weathering",rlf2)) ; ***--------------------------------------------------------------------------- diff --git a/modules/33_CDR/all/sets.gms b/modules/33_CDR/all/sets.gms index e70338f06..6e207b134 100644 --- a/modules/33_CDR/all/sets.gms +++ b/modules/33_CDR/all/sets.gms @@ -9,20 +9,20 @@ sets te_dyn33(all_te) "all technologies" / - rockgrind "grinding rock for enhanced weathering" - dac "direct air capture" + weathering "enhanced weathering" + dac "direct air capture" / teNoTransform_dyn33(all_te) "all technologies that do not transform energy but still have investment and O&M costs (like storage or grid)" / - rockgrind "grinding rock for enhanced weathering" - dac "grinding rock for enhanced weathering" + weathering "enhanced weathering" + dac "direct air capture" / teNoTransform2rlf_dyn33(all_te,rlf) "mapping for final energy to grades" / - (rockgrind) . 1 - (dac) . 1 + (weathering) . 1 + (dac) . 1 / adjte_dyn33(all_te) "technologies with linearly growing constraint on control variable" diff --git a/modules/33_CDR/off/bounds.gms b/modules/33_CDR/off/bounds.gms index 951d52c06..c1dc8c534 100644 --- a/modules/33_CDR/off/bounds.gms +++ b/modules/33_CDR/off/bounds.gms @@ -6,7 +6,7 @@ *** | Contact: remind@pik-potsdam.de *** SOF ./modules/33_CDR/off/bounds.gms vm_otherFEdemand.fx(t,regi,entyFe) = 0; -vm_cap.fx(t,regi,"rockgrind",rlf) = 0; +vm_cap.fx(t,regi,"weathering",rlf) = 0; vm_emiCdr.fx(t,regi,enty) = 0; vm_omcosts_cdr.fx(t,regi) = 0; vm_ccs_cdr.fx(t,regi,enty,enty2,te,rlf)$ccs2te(enty,enty2,te) = 0; diff --git a/modules/33_CDR/weathering/equations.gms b/modules/33_CDR/weathering/equations.gms index 9455211e0..77136fc2d 100644 --- a/modules/33_CDR/weathering/equations.gms +++ b/modules/33_CDR/weathering/equations.gms @@ -32,7 +32,7 @@ q33_otherFEdemand(t,regi,entyFe)$(sameas(entyFe,"feels") OR sameas(entyFe,"fedie q33_capconst_grindrock(t,regi).. sum(rlf2,sum(rlf$(rlf.val le 2), v33_grindrock_onfield(t,regi,rlf,rlf2))) =l= - sum(teNoTransform2rlf_dyn33(te,rlf2), vm_capFac(t,regi,"rockgrind") * vm_cap(t,regi,"rockgrind",rlf2)) + sum(teNoTransform2rlf_dyn33(te,rlf2), vm_capFac(t,regi,"weathering") * vm_cap(t,regi,"weathering",rlf2)) ; ***--------------------------------------------------------------------------- diff --git a/modules/33_CDR/weathering/sets.gms b/modules/33_CDR/weathering/sets.gms index 6b666254c..5a43d8348 100644 --- a/modules/33_CDR/weathering/sets.gms +++ b/modules/33_CDR/weathering/sets.gms @@ -9,17 +9,17 @@ sets te_dyn33(all_te) "all technologies" / - rockgrind "grinding rock for enhanced weathering" + weathering "grinding rock for enhanced weathering" / teNoTransform_dyn33(all_te) "all technologies that do not transform energy but still have investment and O&M costs (like storage or grid)" / - rockgrind "grinding rock for enhanced weathering" + weathering "grinding rock for enhanced weathering" / teNoTransform2rlf_dyn33(all_te,rlf) "mapping for final energy to grades" / - (rockgrind) . 1 + (weathering) . 1 / ; From 8346135e1d4e3a33349f50f0f6bea48ee5c0ef6f Mon Sep 17 00:00:00 2001 From: Michaja Pehl Date: Mon, 3 Jul 2023 14:54:34 +0200 Subject: [PATCH 10/15] respect different FE emission factors in pm_IndstCO2Captured calculation --- core/sets.gms | 2 +- .../37_industry/subsectors/declarations.gms | 2 +- modules/37_industry/subsectors/postsolve.gms | 43 +++++++++++++------ 3 files changed, 33 insertions(+), 14 deletions(-) diff --git a/core/sets.gms b/core/sets.gms index a852797aa..eb6a9c726 100755 --- a/core/sets.gms +++ b/core/sets.gms @@ -2315,7 +2315,7 @@ alias(te,te2,te3); alias(all_enty,all_enty2); alias(enty,enty2,enty3,enty4,enty5,enty6,enty7); alias(entyPE,entyPE2); -alias(entySe,entySe2); +alias(entySE,entySE2,entySE3); alias(entyFe,entyFe2); alias(teEs,teEs2); alias(esty,esty2); diff --git a/modules/37_industry/subsectors/declarations.gms b/modules/37_industry/subsectors/declarations.gms index 0af6b5f2e..39aaf454b 100644 --- a/modules/37_industry/subsectors/declarations.gms +++ b/modules/37_industry/subsectors/declarations.gms @@ -16,7 +16,7 @@ Parameters p37_energy_limit_slope(tall,all_regi,all_in) "limit for subsector specific energy demand that converges towards the thermodynamic/technical limit [GJ/t product]" p37_clinker_cement_ratio(ttot,all_regi) "clinker content per unit cement used" pm_ue_eff_target(all_in) "energy efficiency target trajectories [% p.a.]" - pm_IndstCO2Captured(ttot,all_regi,all_enty,all_enty,secInd37,all_emiMkt) "Captured CO2 in industry by energy carrier, subsector and emissions market" + pm_IndstCO2Captured(ttot,all_regi,all_enty,all_enty,secInd37,all_emiMkt) "Captured CO2 in industry by energy carrier, subsector and emissions market [GtC/a]" p37_CESMkup(ttot,all_regi,all_in) "parameter for those CES markup cost accounted as investment cost in the budget [trUSD/CES input]" p37_cesIO_up_steel_secondary(tall,all_regi,all_GDPscen) "upper limit to secondary steel production based on scrap availability" p37_steel_secondary_max_share(tall,all_regi) "maximum share of secondary steel production" diff --git a/modules/37_industry/subsectors/postsolve.gms b/modules/37_industry/subsectors/postsolve.gms index 2a28045c0..cdccfe181 100644 --- a/modules/37_industry/subsectors/postsolve.gms +++ b/modules/37_industry/subsectors/postsolve.gms @@ -42,26 +42,45 @@ o37_demFeIndSub(ttot,regi,entySe,entyFe,secInd37,emiMkt) * vm_demFeSector_afterTax.l(ttot,regi,entySe,entyFe,"indst",emiMkt) ); - *** FE per subsector whose emissions can be captured (helper parameter for *** calculation of industry captured CO2 below) +*** NOTE: not used for pm_IndstCO2Captured anymore since it did not take into +*** account the different emission factors of FE carriers. But used in remind2, +*** so kept for backwards compatibility. o37_demFeIndSub_SecCC(ttot,regi,secInd37) = sum((se2fe(entySe,entyFe,te),macBaseInd37(entyFe,secInd37), sector2emiMkt("indst",emiMkt)), o37_demFeIndSub(ttot,regi,entySe,entyFe,secInd37,emiMkt) ); -*** industry captured CO2 -pm_IndstCO2Captured(ttot,regi,entySe,entyFe,secInd37,emiMkt)$( - entyFeCC37(entyFe) - AND o37_demFeIndSub_SecCC(ttot,regi,secInd37) - AND macBaseInd37(entyFe,secInd37)) - = sum( secInd37_2_emiInd37(secInd37,emiInd37)$(emiInd37_fuel(emiInd37)), - vm_emiIndCCS.l(ttot,regi,emiInd37) - ) - * o37_demFeIndSub(ttot,regi,entySe,entyFe,secInd37,emiMkt) - / o37_demFeIndSub_SecCC(ttot,regi,secInd37); +*** industry captured fuel CO2 +pm_IndstCO2Captured(ttot,regi,entySE,entyFE(entyFEcc37),secInd37,emiMkt)$( + macBaseInd37(entyFE,secInd37) + AND sum(se2fe(entySE2,entyFE,te), + o37_demFEindsub(ttot,regi,entySE2,entyFE,secInd37,emiMkt)) ) + = ( o37_demFEindsub(ttot,regi,entySE,entyFE,secInd37,emiMkt) + * sum(se2fe(entySE2,entyFE,te), + !! collapse entySE dimension, so emission factors apply to all entyFE + !! regardless or origin, and therefore entySEbio and entySEsyn have + !! non-zero emission factors + pm_emifac(ttot,regi,entySE2,entyFE,te,"co2") + ) + ) !! subsector emissions + * ( sum(secInd37_2_emiInd37(secInd37,emiInd37(emiInd37_fuel)), + vm_emiIndCCS.l(ttot,regi,emiInd37) + ) !! subsector captured energy emissions -*** EOF ./modules/37_industry/subsectors/postsolve.gms + / sum(se2fe(entySE2,entyFE2,te), + o37_demFEindsub(ttot,regi,entySE2,entyFE2,secInd37,emiMkt) + * sum(se2fe2(entySE3,entyFE2,te2), + !! collapse entySE dimension, so emission factors apply to all entyFE2 + !! regardless or origin, and therefore entySEbio and entySEsyn have + !! non-zero emission factors + pm_emifac(ttot,regi,entySE3,entyFE,te2,"co2") + ) + ) !! subsector total emissions + ) !! subsector capture share +; +*** EOF ./modules/37_industry/subsectors/postsolve.gms From 498b3afdd5e36e302cd4defcb419b7cf8817e86f Mon Sep 17 00:00:00 2001 From: Michaja Pehl Date: Tue, 4 Jul 2023 17:18:00 +0200 Subject: [PATCH 11/15] clean files --- modules/37_industry/subsectors/datainput.gms | 22 +++++++++---------- .../37_industry/subsectors/declarations.gms | 19 ++++++++-------- modules/37_industry/subsectors/equations.gms | 8 +++---- modules/37_industry/subsectors/postsolve.gms | 14 ++++++------ modules/37_industry/subsectors/preloop.gms | 1 - modules/37_industry/subsectors/presolve.gms | 7 +++--- .../37_industry/subsectors/realization.gms | 1 - modules/37_industry/subsectors/sets.gms | 10 ++++----- 8 files changed, 39 insertions(+), 43 deletions(-) diff --git a/modules/37_industry/subsectors/datainput.gms b/modules/37_industry/subsectors/datainput.gms index e8b329339..57205e0e1 100644 --- a/modules/37_industry/subsectors/datainput.gms +++ b/modules/37_industry/subsectors/datainput.gms @@ -16,12 +16,12 @@ PARAMETERS p37_specMatsDem(mats,teMats,opModes) "Specific materials demand of a production technology and operation mode [t_input/t_output]" / ironore.idr.(ng,h2) 1.5 !! Iron ore demand of iron direct-reduction (independent of fuel source) - + dri.eaf.pri 1.0 !! DRI demand of EAF scrap.eaf.sec 1.0 !! Scrap demand of EAF dri.eaf.sec 0.0 scrap.eaf.pri 0.0 - + ironore.bfbof.pri 1.5 !! Iron ore demand of BF-BOF scrap.bfbof.sec 1.0 !! Scrap demand of BF-BOF scrap.bfbof.pri 0.0 @@ -33,10 +33,10 @@ PARAMETERS feels.idr.(ng,h2) 0.33 !! Specific electric demand for both H2 and NG operation. fegas.idr.ng 2.94 !! Specific natural gas demand when operating with NG. feh2s.idr.h2 1.91 !! Specific hydrogen demand when operating with H2. - + feels.eaf.pri 0.91 !! Specific electricy demand of EAF when operating with DRI. feels.eaf.sec 0.67 !! Specific electricy demand of EAF when operating with scrap. - + fesos.bfbof.pri 2.0 !! Specific coal demand of BF-BOF when operating with DRI -- this number is just a guess fesos.bfbof.sec 0.5 !! Specific coal demand of BF-BOF when operating with scrap -- this number is just a guess / @@ -175,7 +175,7 @@ loop (industry_ue_calibration_target_dyn37(out)$( pm_energy_limit(out) ), *** Specific energy demand limits for other industry and chemicals in TWa/trUSD *** exponential decrease of minimum specific energy demand per value added up to 90% by 2100 -sm_tmp2 = 0.9; !! maximum "efficiency gain" relative to 2015 baseline value +sm_tmp2 = 0.9; !! maximum "efficiency gain" relative to 2015 baseline value sm_tmp = 2100; !! period in which closing could be achieved loop (industry_ue_calibration_target_dyn37(out)$( sameas(out,"ue_chemicals") OR sameas(out,"ue_otherInd")), @@ -415,17 +415,17 @@ pm_ue_eff_target("ue_otherInd") = 0.008; *` CES mark-up cost industry *` The Mark-up cost on primary production factors (final energy) of the CES tree have two functions. -*` (1) They represent sectoral end-use cost not captured by the energy system. -*` (2) As they alter prices to of the CES function inputs, they affect the CES efficiency parameters during calibration +*` (1) They represent sectoral end-use cost not captured by the energy system. +*` (2) As they alter prices to of the CES function inputs, they affect the CES efficiency parameters during calibration *` and therefore influence the efficiency of different FE CES inputs. The resulting economic subsitution rates *` are given by the marginal rate of subsitution (MRS) in the parameter o01_CESmrs. -*` Mark-up cost were tuned as to obtain similar or slightly higher marginal rate of substitution (MRS) to gas/liquids than technical subsitution rates and -*` obtain similar specific energy consumption per value added in chemicals and other industry across high and low electrification scenarios. +*` Mark-up cost were tuned as to obtain similar or slightly higher marginal rate of substitution (MRS) to gas/liquids than technical subsitution rates and +*` obtain similar specific energy consumption per value added in chemicals and other industry across high and low electrification scenarios. *` There are two ways in which mark-up cost can be set: -*` (a) Mark-up cost on inputs in ppfen_MkupCost37: Those are counted as expenses in the budget and set by the parameter p37_CESMkup. -*` (b) Mark-up cost on other inputs: Those are budget-neutral and implemented as a tax. They are set by the parameter pm_tau_ces_tax. +*` (a) Mark-up cost on inputs in ppfen_MkupCost37: Those are counted as expenses in the budget and set by the parameter p37_CESMkup. +*` (b) Mark-up cost on other inputs: Those are budget-neutral and implemented as a tax. They are set by the parameter pm_tau_ces_tax. *` Mark-up cost in industry are modeled without budget-effect (b). diff --git a/modules/37_industry/subsectors/declarations.gms b/modules/37_industry/subsectors/declarations.gms index 39aaf454b..ac97a3060 100644 --- a/modules/37_industry/subsectors/declarations.gms +++ b/modules/37_industry/subsectors/declarations.gms @@ -14,11 +14,11 @@ Parameters pm_abatparam_Ind(ttot,all_regi,all_enty,steps) "industry CCS MAC curves [ratio @ US$2005]" pm_energy_limit(all_in) "thermodynamic/technical limits of subsector energy use [GJ/t product]" p37_energy_limit_slope(tall,all_regi,all_in) "limit for subsector specific energy demand that converges towards the thermodynamic/technical limit [GJ/t product]" - p37_clinker_cement_ratio(ttot,all_regi) "clinker content per unit cement used" - pm_ue_eff_target(all_in) "energy efficiency target trajectories [% p.a.]" + p37_clinker_cement_ratio(ttot,all_regi) "clinker content per unit cement used" + pm_ue_eff_target(all_in) "energy efficiency target trajectories [% p.a.]" pm_IndstCO2Captured(ttot,all_regi,all_enty,all_enty,secInd37,all_emiMkt) "Captured CO2 in industry by energy carrier, subsector and emissions market [GtC/a]" - p37_CESMkup(ttot,all_regi,all_in) "parameter for those CES markup cost accounted as investment cost in the budget [trUSD/CES input]" - p37_cesIO_up_steel_secondary(tall,all_regi,all_GDPscen) "upper limit to secondary steel production based on scrap availability" + p37_CESMkup(ttot,all_regi,all_in) "parameter for those CES markup cost accounted as investment cost in the budget [trUSD/CES input]" + p37_cesIO_up_steel_secondary(tall,all_regi,all_GDPscen) "upper limit to secondary steel production based on scrap availability" p37_steel_secondary_max_share(tall,all_regi) "maximum share of secondary steel production" p37_BAU_industry_ETS_solids(tall,all_regi) "industry solids demand in baseline scenario" p37_cesIO_baseline(tall,all_regi,all_in) "vm_cesIO from the baseline scenario" @@ -28,12 +28,12 @@ $ifthen.process_based_steel "%cm_process_based_steel%" == "on" ! $endif.process_based_steel *** output parameters only for reporting - o37_emiInd(ttot,all_regi,all_enty,secInd37,all_enty) "industry CCS emissions [GtC/a]" - o37_cementProcessEmissions(ttot,all_regi,all_enty) "cement process emissions [GtC/a]" + o37_emiInd(ttot,all_regi,all_enty,secInd37,all_enty) "industry CCS emissions [GtC/a]" + o37_cementProcessEmissions(ttot,all_regi,all_enty) "cement process emissions [GtC/a]" o37_demFeIndTotEn(ttot,all_regi,all_enty,all_emiMkt) "total FE per energy carrier and emissions market in industry (sum over subsectors)" - o37_shIndFE(ttot,all_regi,all_enty,secInd37,all_emiMkt) "share of subsector in FE industry energy carriers and emissions markets" - o37_demFeIndSub(ttot,all_regi,all_enty,all_enty,secInd37,all_emiMkt) "FE demand per industry subsector" - o37_demFeIndSub_SecCC(ttot,all_regi,secInd37) "FE per subsector whose emissions can be captured, helper parameter for calculation of industry captured CO2" + o37_shIndFE(ttot,all_regi,all_enty,secInd37,all_emiMkt) "share of subsector in FE industry energy carriers and emissions markets" + o37_demFeIndSub(ttot,all_regi,all_enty,all_enty,secInd37,all_emiMkt) "FE demand per industry subsector" + o37_demFeIndSub_SecCC(ttot,all_regi,secInd37) "FE per subsector whose emissions can be captured, helper parameter for calculation of industry captured CO2" $ifThen.CESMkup not "%cm_CESMkup_ind%" == "standard" p37_CESMkup_input(all_in) "markup cost parameter read in from config for CES levels in industry to influence demand-side cost and efficiencies in CES tree [trUSD/CES input]" / %cm_CESMkup_ind% / @@ -81,4 +81,3 @@ $endif.process_based_steel ; *** EOF ./modules/37_industry/subsectors/declarations.gms - diff --git a/modules/37_industry/subsectors/equations.gms b/modules/37_industry/subsectors/equations.gms index d881384af..1890d00d5 100644 --- a/modules/37_industry/subsectors/equations.gms +++ b/modules/37_industry/subsectors/equations.gms @@ -10,8 +10,8 @@ ***------------------------------------------------------------------------------- *** MATERIAL-FLOW IMPLEMENTATION ***------------------------------------------------------------------------------- -* Balance equation: Demand of materials equals to production of those materials, -* accounting for trade. Demand of materials arises either due to external demand +* Balance equation: Demand of materials equals to production of those materials, +* accounting for trade. Demand of materials arises either due to external demand * from the economy (i.e. steel) or due to internal demand of the processes modelled * in the materials-flow model (i.e. directly reduced iron). * @@ -106,10 +106,10 @@ $ifthen.fixed_production "%cm_import_EU%" == "bal" !! cm_import_EU !! do not limit steel production shares for fixed production AND p37_industry_quantity_targets(ttot,regi,"ue_steel_secondary") eq 0 $endif.fixed_production -$ifthen.exogDem_scen NOT "%cm_exogDem_scen%" == "off" +$ifthen.exogDem_scen NOT "%cm_exogDem_scen%" == "off" !! do not limit steel production shares for fixed production AND pm_exogDemScen(ttot,regi,"%cm_exogDem_scen%","ue_steel_secondary") eq 0 -$endif.exogDem_scen +$endif.exogDem_scen ) .. vm_cesIO(ttot,regi,"ue_steel_secondary") diff --git a/modules/37_industry/subsectors/postsolve.gms b/modules/37_industry/subsectors/postsolve.gms index cdccfe181..a514fb8ab 100644 --- a/modules/37_industry/subsectors/postsolve.gms +++ b/modules/37_industry/subsectors/postsolve.gms @@ -14,21 +14,21 @@ pm_FEPrice(ttot,regi,entyFE,"indst",emiMkt)$( abs(qm_budget.m(ttot,regi)) gt sm_ *** calculate reporting parameters for FE per subsector and SE origin to make R *** reporting easier -*** total FE per energy carrier and emissions market in industry (sum over +*** total FE per energy carrier and emissions market in industry (sum over *** subsectors) o37_demFeIndTotEn(ttot,regi,entyFe,emiMkt) = sum((fe2ppfEn37(entyFe,in),secInd37_2_pf(secInd37,in), - secInd37_emiMkt(secInd37,emiMkt)), + secInd37_emiMkt(secInd37,emiMkt)), (vm_cesIO.l(ttot,regi,in) +pm_cesdata(ttot,regi,in,"offset_quantity")) ); *** share of subsector in FE industry energy carriers and emissions markets -o37_shIndFE(ttot,regi,entyFe,secInd37,emiMkt)$( +o37_shIndFE(ttot,regi,entyFe,secInd37,emiMkt)$( o37_demFeIndTotEn(ttot,regi,entyFe,emiMkt) ) = sum(( fe2ppfEn37(entyFe,in), secInd37_2_pf(secInd37,in), - secInd37_emiMkt(secInd37,emiMkt)), + secInd37_emiMkt(secInd37,emiMkt)), (vm_cesIO.l(ttot,regi,in) +pm_cesdata(ttot,regi,in,"offset_quantity")) ) @@ -47,16 +47,16 @@ o37_demFeIndSub(ttot,regi,entySe,entyFe,secInd37,emiMkt) *** NOTE: not used for pm_IndstCO2Captured anymore since it did not take into *** account the different emission factors of FE carriers. But used in remind2, *** so kept for backwards compatibility. -o37_demFeIndSub_SecCC(ttot,regi,secInd37) +o37_demFeIndSub_SecCC(ttot,regi,secInd37) = sum((se2fe(entySe,entyFe,te),macBaseInd37(entyFe,secInd37), - sector2emiMkt("indst",emiMkt)), + sector2emiMkt("indst",emiMkt)), o37_demFeIndSub(ttot,regi,entySe,entyFe,secInd37,emiMkt) ); *** industry captured fuel CO2 pm_IndstCO2Captured(ttot,regi,entySE,entyFE(entyFEcc37),secInd37,emiMkt)$( macBaseInd37(entyFE,secInd37) - AND sum(se2fe(entySE2,entyFE,te), + AND sum(se2fe(entySE2,entyFE,te), o37_demFEindsub(ttot,regi,entySE2,entyFE,secInd37,emiMkt)) ) = ( o37_demFEindsub(ttot,regi,entySE,entyFE,secInd37,emiMkt) * sum(se2fe(entySE2,entyFE,te), diff --git a/modules/37_industry/subsectors/preloop.gms b/modules/37_industry/subsectors/preloop.gms index fe6931268..f9515d70f 100644 --- a/modules/37_industry/subsectors/preloop.gms +++ b/modules/37_industry/subsectors/preloop.gms @@ -10,4 +10,3 @@ pm_IndstCO2Captured(t,regi,entySe,entyFe,secInd37,emiMkt) = 0; *** EOF ./modules/37_industry/subsectors/preloop.gms - diff --git a/modules/37_industry/subsectors/presolve.gms b/modules/37_industry/subsectors/presolve.gms index 945faf123..df38262d6 100644 --- a/modules/37_industry/subsectors/presolve.gms +++ b/modules/37_industry/subsectors/presolve.gms @@ -7,12 +7,12 @@ *** SOF ./modules/37_industry/subsectors/presolve.gms *' The process emissions from cement production are calculated using a fixed -*' CO2-to-clinker ratio (0.5262 kg CO2/kg clinker), region-specific -*' clinker-to-cement ratios, and the cement production from the production +*' CO2-to-clinker ratio (0.5262 kg CO2/kg clinker), region-specific +*' clinker-to-cement ratios, and the cement production from the production *' function. *' Last iteration's cement production value is used, since the MAC mechanism is *' outside of the optimisation loop. -vm_macBaseInd.fx(ttot,regi,"co2cement_process","cement")$( ttot.val ge 2005 ) +vm_macBaseInd.fx(ttot,regi,"co2cement_process","cement")$( ttot.val ge 2005 ) = s37_clinker_process_CO2 * p37_clinker_cement_ratio(ttot,regi) * vm_cesIO.l(ttot,regi,"ue_cement") @@ -22,4 +22,3 @@ vm_macBaseInd.fx(ttot,regi,"co2cement_process","cement")$( ttot.val ge 2005 ) ***p37_emiFac(ttot,regi,entyFe) = sum((entySe,te)$(se2fe(entySe,entyFe,te) and entySeFos(entySe)), pm_emifac(ttot,regi,entySe,entyFe,te,"co2")); *** EOF ./modules/37_industry/subsectors/presolve.gms - diff --git a/modules/37_industry/subsectors/realization.gms b/modules/37_industry/subsectors/realization.gms index d9debb53d..2aed846f0 100644 --- a/modules/37_industry/subsectors/realization.gms +++ b/modules/37_industry/subsectors/realization.gms @@ -20,4 +20,3 @@ $Ifi "%phase%" == "presolve" $include "./modules/37_industry/subsectors/presolve $Ifi "%phase%" == "postsolve" $include "./modules/37_industry/subsectors/postsolve.gms" *######################## R SECTION END (PHASES) ############################### *** EOF ./modules/37_industry/subsectors/realization.gms - diff --git a/modules/37_industry/subsectors/sets.gms b/modules/37_industry/subsectors/sets.gms index 6e6e43808..b5cbdb011 100644 --- a/modules/37_industry/subsectors/sets.gms +++ b/modules/37_industry/subsectors/sets.gms @@ -15,14 +15,14 @@ $ifthen.process_based_steel "%cm_process_based_steel%" == "on" ! scrap "Steel scrap" ironore "Iron ore" / - + teMats(all_te) "Technologies used in material-flow model" / idr "Iron direct reduction" eaf "Electric-arc furnace" bfbof "Blast furnace/basic-oxygen furnace" / - + opModes "Operation modes for technologies in material-flow model" / ng "Direct reduction using natural gas" @@ -30,21 +30,21 @@ $ifthen.process_based_steel "%cm_process_based_steel%" == "on" ! pri "Primary production of steel (based on iron ore or DRI)" sec "Secondary production of steel (based on scrap)" / - + teMats2matsIn(teMats,mats) "Mapping of technologies onto input materials" / idr . ironore eaf . (dri,scrap) bfbof . (ironore,scrap) / - + teMats2opModes(teMats,opModes) "Mapping of technologies onto available operation modes" / idr . (ng,h2) eaf . (pri,sec) bfbof . (pri,sec) / - + matsOut2teMats(mats,teMats) "Mapping of output materials onto technologies producing these" / dri . idr From 128d2ec3bbaa43baafecc82bef59fd44d498ed69 Mon Sep 17 00:00:00 2001 From: Michaja Pehl Date: Wed, 9 Aug 2023 14:39:50 +0200 Subject: [PATCH 12/15] use vm_macBaseInd for baseline emissions in calculating capture share --- core/sets.gms | 2 +- modules/37_industry/subsectors/postsolve.gms | 17 +++++------------ 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/core/sets.gms b/core/sets.gms index eb6a9c726..1cc44b79f 100755 --- a/core/sets.gms +++ b/core/sets.gms @@ -2315,7 +2315,7 @@ alias(te,te2,te3); alias(all_enty,all_enty2); alias(enty,enty2,enty3,enty4,enty5,enty6,enty7); alias(entyPE,entyPE2); -alias(entySE,entySE2,entySE3); +alias(entySE,entySE2); alias(entyFe,entyFe2); alias(teEs,teEs2); alias(esty,esty2); diff --git a/modules/37_industry/subsectors/postsolve.gms b/modules/37_industry/subsectors/postsolve.gms index a514fb8ab..760e1dcd8 100644 --- a/modules/37_industry/subsectors/postsolve.gms +++ b/modules/37_industry/subsectors/postsolve.gms @@ -55,9 +55,8 @@ o37_demFeIndSub_SecCC(ttot,regi,secInd37) *** industry captured fuel CO2 pm_IndstCO2Captured(ttot,regi,entySE,entyFE(entyFEcc37),secInd37,emiMkt)$( - macBaseInd37(entyFE,secInd37) - AND sum(se2fe(entySE2,entyFE,te), - o37_demFEindsub(ttot,regi,entySE2,entyFE,secInd37,emiMkt)) ) + macBaseInd37(entyFE,secInd37) + AND sum(entyFE2, vm_macBaseInd.l(ttot,regi,entyFE2,secInd37)) ) = ( o37_demFEindsub(ttot,regi,entySE,entyFE,secInd37,emiMkt) * sum(se2fe(entySE2,entyFE,te), !! collapse entySE dimension, so emission factors apply to all entyFE @@ -71,15 +70,9 @@ pm_IndstCO2Captured(ttot,regi,entySE,entyFE(entyFEcc37),secInd37,emiMkt)$( vm_emiIndCCS.l(ttot,regi,emiInd37) ) !! subsector captured energy emissions - / sum(se2fe(entySE2,entyFE2,te), - o37_demFEindsub(ttot,regi,entySE2,entyFE2,secInd37,emiMkt) - * sum(se2fe2(entySE3,entyFE2,te2), - !! collapse entySE dimension, so emission factors apply to all entyFE2 - !! regardless or origin, and therefore entySEbio and entySEsyn have - !! non-zero emission factors - pm_emifac(ttot,regi,entySE3,entyFE,te2,"co2") - ) - ) !! subsector total emissions + / sum(entyFE2, + vm_macBaseInd.l(ttot,regi,entyFE2,secInd37) + ) !! subsector total energy emissions ) !! subsector capture share ; From 72c3d02be3e2ddcdb61598fe0f01a0219f9c1f2a Mon Sep 17 00:00:00 2001 From: Michaja Pehl Date: Fri, 11 Aug 2023 13:15:56 +0200 Subject: [PATCH 13/15] add clarifying comment --- modules/37_industry/subsectors/postsolve.gms | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/37_industry/subsectors/postsolve.gms b/modules/37_industry/subsectors/postsolve.gms index 760e1dcd8..0e0ba73b1 100644 --- a/modules/37_industry/subsectors/postsolve.gms +++ b/modules/37_industry/subsectors/postsolve.gms @@ -64,7 +64,7 @@ pm_IndstCO2Captured(ttot,regi,entySE,entyFE(entyFEcc37),secInd37,emiMkt)$( !! non-zero emission factors pm_emifac(ttot,regi,entySE2,entyFE,te,"co2") ) - ) !! subsector emissions + ) !! subsector emissions (smokestack, i.e. including biomass & synfuels) * ( sum(secInd37_2_emiInd37(secInd37,emiInd37(emiInd37_fuel)), vm_emiIndCCS.l(ttot,regi,emiInd37) From 0af33ac569d05043a891fb90e02e90c78eeb0403 Mon Sep 17 00:00:00 2001 From: Michaja Pehl Date: Fri, 11 Aug 2023 13:22:27 +0200 Subject: [PATCH 14/15] update change log --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2fb840c07..742d82a79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **config** regex tests for many parameters - **testthat** test and compile all config files +### fixed +- fixed weights of energy carriers in `pm_IndstCO2Captured` + [[#1354](https://github.com/remindmodel/remind/pull/1354)] + ## [3.2.1] - 2023-07-13 (incomplete) ### changed From 8eaebb4a25563c5a11d7cdbefd17dc648ecbaf2b Mon Sep 17 00:00:00 2001 From: robinhasse Date: Mon, 21 Aug 2023 10:45:35 +0200 Subject: [PATCH 15/15] Add CAMPAIGNers scenarios --- core/sets.gms | 2 ++ modules/35_transport/edge_esm/sets.gms | 2 ++ 2 files changed, 4 insertions(+) diff --git a/core/sets.gms b/core/sets.gms index 1cc44b79f..66534baaa 100755 --- a/core/sets.gms +++ b/core/sets.gms @@ -74,6 +74,8 @@ gdp_SSP2EU_NAV_act "NAVIGATE demand scenarios: Activity reduction and activity s gdp_SSP2EU_NAV_tec "NAVIGATE demand scenarios: Technological improvements - energy efficiency" gdp_SSP2EU_NAV_lce "NAVIGATE demand scenarios: Low consumption energy (act + tec)" gdp_SSP2EU_NAV_all "NAVIGATE demand scenarios: All measures (ele + act + tec)" +gdp_SSP2EU_CAMP_weak "CAMPAIGNers scenario with low ambition lifestyle change" +gdp_SSP2EU_CAMP_strong "CAMPAIGNers scenario with high ambition lifestyle change" / all_GDPpcScen "all possible GDP per capita scenarios (GDP and Population from the same SSP-scenario" diff --git a/modules/35_transport/edge_esm/sets.gms b/modules/35_transport/edge_esm/sets.gms index 94198060d..236dfb964 100644 --- a/modules/35_transport/edge_esm/sets.gms +++ b/modules/35_transport/edge_esm/sets.gms @@ -147,6 +147,8 @@ NAV_tec NAV_ele NAV_lce NAV_all +CAMP_lscWeak +CAMP_lscStrong / EDGE_scenario(EDGE_scenario_all) "Selected EDGE-T scenario"