diff --git a/DESCRIPTION b/DESCRIPTION index c9ad0f5232..6d634c4b00 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -13,6 +13,7 @@ Depends: R (>= 4.0.0) Imports: callr, + climbed (>= 1.2.0), colorspace, crayon, data.table, @@ -54,6 +55,7 @@ Imports: piamPlotComparison (>= 0.0.10), piamutils, plotly, + pracma, purrr, quitte (>= 0.3149.0), R.utils, diff --git a/core/declarations.gms b/core/declarations.gms index dcce51c823..ef24712c73 100644 --- a/core/declarations.gms +++ b/core/declarations.gms @@ -302,6 +302,7 @@ p_prodAllReference(ttot,all_regi,all_te) "Sum of the above in the re *** CES calibration tarjectories industry and buildings pm_fedemandInd(tall,all_regi,all_in) "read-in parameter for final energy and production trajectories used for the CES parameter calibration in industry [EJ, ue_primary_steel, ue_secondary_steel: Gt, ue_otherInd: $tn]" pm_fedemandBuild(tall,all_regi,all_in) "read-in parameter for final energy and production trajectories used for the CES parameter calibration in buildings [EJ]" +pm_climateCorrection(ttot,all_regi,all_in) "climate correction factors for building energy demand [unitless]" *** parameters for setting final energy shares pm_shfe_up(ttot,all_regi,all_enty,emi_sectors) "Final energy shares exogenous upper bounds per sector [share]" diff --git a/core/sets.gms b/core/sets.gms index a36e5358f8..2b6edc38b6 100755 --- a/core/sets.gms +++ b/core/sets.gms @@ -80,7 +80,7 @@ all_SSP_forcing_adjust "all possible forcing targets and budgets according to S / all_rcp_scen "all possible RCP scenarios" -/none,rcp20,rcp26,rcp37,rcp45,rcp60,rcp85/ +/none,rcp19,rcp20,rcp26,rcp37,rcp45,rcp60,rcp70,rcp85/ all_delayPolicy "all possible SPA policy choices" / diff --git a/main.gms b/main.gms index d621c8c7b9..da96eedf5e 100755 --- a/main.gms +++ b/main.gms @@ -1910,6 +1910,13 @@ $setGlobal cm_reducCostB none !! def = none *** cfg$gms$cm_effHP <- 5 #def <- 5 , efficiency of heat pumps $setGlobal cm_effHP 5 !! def = 5 +*** cm_climateCorrection "enable or disable climate correction for buildings energy demand" +*** def = "off", climate correction is disabled and pm_climateCorrection is set to 1.0 for all iterations +*** (on): climate correction is enabled and correction factors are calculated iteratively using +*** external R scripts (climateAssessmentInterimRun.R and calculateClimateCorrection.R) +*** to adjust building energy demand based on climate conditions +$setGlobal cm_climateCorrection off !! def = off + *** Note on CES markup cost: *** They represent the sector-specific demand-side transformation cost, can also *** be used to influence efficiencies during calibration as higher markup-cost diff --git a/modules/36_buildings/simple/equations.gms b/modules/36_buildings/simple/equations.gms index c2c6409159..cdfd0a47db 100644 --- a/modules/36_buildings/simple/equations.gms +++ b/modules/36_buildings/simple/equations.gms @@ -19,7 +19,8 @@ q36_demFeBuild(ttot,regi,entyFe,emiMkt)$(ttot.val ge cm_startyear sum(in$(fe2ppfEn(entyFe,in) AND ppfen_buildings_dyn36(in)), vm_cesIO(ttot,regi,in) - + pm_cesdata(ttot,regi,in,"offset_quantity") + + (pm_climateCorrection(ttot,regi,in) - 1) * vm_cesIO.l(ttot,regi,in) + + pm_cesdata(ttot,regi,in,"offset_quantity") )$(sameas(emiMkt,"ES")) ; diff --git a/modules/36_buildings/simple/postsolve.gms b/modules/36_buildings/simple/postsolve.gms index 7d86c2393a..f7e6d16aae 100644 --- a/modules/36_buildings/simple/postsolve.gms +++ b/modules/36_buildings/simple/postsolve.gms @@ -7,8 +7,28 @@ *** SOF ./modules/36_buildings/simple/postsolve.gms *** calculation of FE Buildings Prices (useful for internal use and reporting purposes) -pm_FEPrice(ttot,regi,entyFe,"build",emiMkt)$(abs(qm_budget.m(ttot,regi)) gt sm_eps) = +pm_FEPrice(ttot,regi,entyFe,"build",emiMkt)$(abs(qm_budget.m(ttot,regi)) gt sm_eps) = q36_demFeBuild.m(ttot,regi,entyFe,emiMkt) / qm_budget.m(ttot,regi); +*** Climate correction handling +*** Only run climate assessment from iteration 2 onwards to ensure all postsolve calculations are complete +*** (reportEmiForClimateAssessment requires industry variables calculated in module 37) +$ifthen.climateCorr not "%cm_climateCorrection%" == "off" +if(iteration.val gt 1, + +Execute_Unload 'fulldata_postsolve'; + +*** Execute climate assessment script +Execute "Rscript climateAssessmentInterimRun.R"; + +*** Call R script to calculate climate correction factors +Execute "Rscript calculateClimateCorrection.R"; + +*** Load climate correction factors +execute_load "pm_ClimateCorrection.gdx", pm_climateCorrection; + +); +$endif.climateCorr + *** EOF ./modules/36_buildings/simple/postsolve.gms diff --git a/modules/36_buildings/simple/presolve.gms b/modules/36_buildings/simple/presolve.gms new file mode 100644 index 0000000000..e74b850159 --- /dev/null +++ b/modules/36_buildings/simple/presolve.gms @@ -0,0 +1,6 @@ +*** Initialize climate correction factors to 1.0 +*** - Always if climate correction is off +*** - In first iteration if climate correction is on +if(iteration.val eq 1 OR sameas("%cm_climateCorrection%","off"), + pm_climateCorrection(ttot,all_regi,ppfen_buildings_dyn36) = 1.0; +); \ No newline at end of file diff --git a/modules/36_buildings/simple/realization.gms b/modules/36_buildings/simple/realization.gms index 8b4e99410f..8f0e205dc9 100644 --- a/modules/36_buildings/simple/realization.gms +++ b/modules/36_buildings/simple/realization.gms @@ -27,6 +27,7 @@ $Ifi "%phase%" == "declarations" $include "./modules/36_buildings/simple/declara $Ifi "%phase%" == "datainput" $include "./modules/36_buildings/simple/datainput.gms" $Ifi "%phase%" == "equations" $include "./modules/36_buildings/simple/equations.gms" $Ifi "%phase%" == "bounds" $include "./modules/36_buildings/simple/bounds.gms" +$Ifi "%phase%" == "presolve" $include "./modules/36_buildings/simple/presolve.gms" $Ifi "%phase%" == "postsolve" $include "./modules/36_buildings/simple/postsolve.gms" *######################## R SECTION END (PHASES) ############################### *** EOF ./modules/36_buildings/simple/realization.gms diff --git a/scripts/input/calculateClimateCorrection.R b/scripts/input/calculateClimateCorrection.R new file mode 100644 index 0000000000..cb03e60418 --- /dev/null +++ b/scripts/input/calculateClimateCorrection.R @@ -0,0 +1,12 @@ +# | (C) 2006-2024 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 + +# Load the local climbed package for development +devtools::load_all("/p/tmp/hagento/dev/climbed") + +# Calculate climate correction factors +climbed::computeClimateCorrection() diff --git a/scripts/input/climateAssessmentInterimRun.R b/scripts/input/climateAssessmentInterimRun.R index afe5bad7cf..73662b2fe6 100644 --- a/scripts/input/climateAssessmentInterimRun.R +++ b/scripts/input/climateAssessmentInterimRun.R @@ -111,7 +111,8 @@ runTimes <- c(runTimes, "write_gdx start" = Sys.time()) # Map climate assessment variables to REMIND/GAMS varmap <- c( 'Surface Air Temperature Change' = 'pm_globalMeanTemperature', - 'Effective Radiative Forcing|Anthropogenic' = 'p15_forc_magicc' + 'Effective Radiative Forcing|Anthropogenic' = 'p15_forc_magicc', + 'Atmospheric Concentrations|CO2' = 'p15_co2_conc' ) # Postprocess by renaming IAMC-style `period` (year) column to REMIND compatible `tall` set & using this as sole index