Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix on reference run: landuse in REMIND standalone runs + MAGICC6 #1565

Merged
merged 2 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
[[#1500](https://github.com/remindmodel/remind/pull/1500)]
- prevent tradtional biomass spillover to other sectors than buildings
[[#1519](https://github.com/remindmodel/remind/pull/1519)]
- fully fix landuse and MAGICC6 variables in delayed transition runs to reference run
[[#1565](https://github.com/remindmodel/remind/pull/1565)]

### removed
- **45_carbonprice** remove outdated realizations:
Expand Down
2 changes: 1 addition & 1 deletion config/default.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ cfg$repositories <- getOption("remind_repos")
cfg$runstatistics <- "/p/projects/rd3mod/models/statistics/remind"

#### Folder containing magicc files that can not be published open source. These files are automatically
# copied into remind when starting a run and required to calcualte climate responses (e.g. temperature).
# copied into remind when starting a run and required to calculate climate responses (e.g. temperature).
cfg$magicc_template <- "/p/projects/rd3mod/magicc/"

#### Output folder of the modeltests generated by running config/scenario_config_AMT.csv
Expand Down
4 changes: 1 addition & 3 deletions modules/21_tax/off/not_used.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@ cm_bioenergy_EF_for_tax,input,questionnaire
cm_startyear, switch, ???
cm_fetaxscen, switch, ???
cm_gdximport_target, switch, ???
pm_gdp_gdx,parameter,???
pm_pop,parameter,???
cm_so2tax_scen,switch,???
sm_DpGJ_2_TDpTWa,switch,???
vm_cesIO,variable,???
vm_co2eq,variable,???
cm_emiscen,input,questionnaire
pm_taxCO2eqSCC,input,questionnaire
vm_co2CCS,input,questionnaire
pm_dataccs,input,questionnaire
pm_data,input,questionnaire
Expand All @@ -56,7 +54,6 @@ vm_Mport,input,questionnaire
vm_deltaCap, variable, ???
sm_TWa_2_MWh,input,questionnaire
vm_emiCO2Sector,input,questionnaire
pm_taxCO2eqRegi,input,questionnare
pm_taxCO2eqSum,input,questionnare
pm_tau_pe_tax,input,questionnaire
pm_ccsinjecrate,input,questionaire
Expand All @@ -72,3 +69,4 @@ vm_changeProdStartyearCost, variable, ???
vm_costInvTeDir,input,only needed if tax is on
vm_costInvTeAdj,input,only needed if tax is on
pm_cintraw,input,only needed if tax is on
pm_gdp,input,only needed if tax is on
5 changes: 5 additions & 0 deletions modules/21_tax/on/datainput.gms
Original file line number Diff line number Diff line change
Expand Up @@ -247,4 +247,9 @@ Execute_Loadpoint 'input_ref' p21_ref_costInvTeDir_RE = vm_costInvTeDir.l;
Execute_Loadpoint 'input_ref' p21_ref_costInvTeAdj_RE = vm_costInvTeAdj.l;
$endif.importtaxrc

if (cm_startyear gt 2005,
execute_load "input_ref.gdx", pm_taxrevCO2LUC0;
execute_load "input_ref.gdx", pm_taxrevGHG0;
);

*** EOF ./modules/21_tax/on/datainput.gms
4 changes: 2 additions & 2 deletions modules/21_tax/on/postsolve.gms
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ OPTION decimals =3;
*GL* save reference level value of taxes for revenue recycling
*JH* !!Warning!! The same allocation block exists in presolve.gms.
*** Do not forget to update the other file.
pm_taxrevGHG0(ttot,regi) = pm_taxCO2eqSum(ttot,regi) * (vm_co2eq.l(ttot,regi) - vm_emiMacSector.l(ttot,regi,"co2luc")$(cm_multigasscen ne 3));
pm_taxrevGHG0(t,regi) = pm_taxCO2eqSum(t,regi) * (vm_co2eq.l(t,regi) - vm_emiMacSector.l(t,regi,"co2luc")$(cm_multigasscen ne 3));
pm_taxrevCO2Sector0(ttot,regi,emi_sectors) = p21_CO2TaxSectorMarkup(ttot,regi,emi_sectors) * pm_taxCO2eqSum(ttot,regi) * vm_emiCO2Sector.l(ttot,regi,emi_sectors);
pm_taxrevCO2LUC0(ttot,regi) = pm_taxCO2eqSum(ttot,regi) * vm_emiMacSector.l(ttot,regi,"co2luc")$(cm_multigasscen ne 3);
pm_taxrevCO2LUC0(t,regi) = pm_taxCO2eqSum(t,regi) * vm_emiMacSector.l(t,regi,"co2luc")$(cm_multigasscen ne 3);
p21_taxrevCCS0(ttot,regi) = cm_frac_CCS * pm_data(regi,"omf","ccsinje") * pm_inco0_t(ttot,regi,"ccsinje")
* ( sum(teCCS2rlf(te,rlf), sum(ccs2te(ccsCO2(enty),enty2,te), vm_co2CCS.l(ttot,regi,enty,enty2,te,rlf) ) ) )
* (1/pm_ccsinjecrate(regi)) * sum(teCCS2rlf(te,rlf), sum(ccs2te(ccsCO2(enty),enty2,te), vm_co2CCS.l(ttot,regi,enty,enty2,te,rlf) ) ) / pm_dataccs(regi,"quan","1");
Expand Down
8 changes: 4 additions & 4 deletions modules/21_tax/on/presolve.gms
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
*** SOF ./modules/21_tax/on/presolve.gms
*JS*
*** calculation of tax rate, as a function of per-capita gdp levels
p21_tau_so2_tax(ttot,regi)$(ttot.val ge 2005)=s21_so2_tax_2010*pm_gdp_gdx(ttot,regi)/pm_pop(ttot,regi); !! scaled by GDP/cap in the unit [trn US$/bn people]
p21_tau_so2_tax(ttot,regi)$(ttot.val ge 2005)=s21_so2_tax_2010*pm_gdp(ttot,regi)/pm_pop(ttot,regi); !! scaled by GDP/cap in the unit [trn US$/bn people]
p21_tau_so2_tax("2005",regi)=0;
p21_tau_so2_tax("2100",regi)=s21_so2_tax_2010*pm_gdp_gdx("2100",regi)/pm_pop("2100",regi);
p21_tau_so2_tax("2100",regi)=s21_so2_tax_2010*pm_gdp("2100",regi)/pm_pop("2100",regi);
p21_tau_so2_tax(ttot,regi)$(ttot.val>2100)=p21_tau_so2_tax("2100",regi);

*GL* save reference level value of taxed variables for revenue recycling
*JH* !!Warning!! The same allocation block exists in postsolve.gms.
*** Do not forget to update the other file.
*** save level value of all taxes
pm_taxrevGHG0(ttot,regi) = pm_taxCO2eqSum(ttot,regi) * (vm_co2eq.l(ttot,regi) - vm_emiMacSector.l(ttot,regi,"co2luc")$(cm_multigasscen ne 3));
pm_taxrevGHG0(t,regi) = pm_taxCO2eqSum(t,regi) * (vm_co2eq.l(t,regi) - vm_emiMacSector.l(t,regi,"co2luc")$(cm_multigasscen ne 3));
pm_taxrevCO2Sector0(ttot,regi,emi_sectors) = p21_CO2TaxSectorMarkup(ttot,regi,emi_sectors) * pm_taxCO2eqSum(ttot,regi) * vm_emiCO2Sector.l(ttot,regi,emi_sectors);
pm_taxrevCO2LUC0(ttot,regi) = pm_taxCO2eqSum(ttot,regi) * vm_emiMacSector.l(ttot,regi,"co2luc")$(cm_multigasscen ne 3);
pm_taxrevCO2LUC0(t,regi) = pm_taxCO2eqSum(t,regi) * vm_emiMacSector.l(t,regi,"co2luc")$(cm_multigasscen ne 3);
p21_taxrevCCS0(ttot,regi) = cm_frac_CCS * pm_data(regi,"omf","ccsinje") * pm_inco0_t(ttot,regi,"ccsinje")
* ( sum(teCCS2rlf(te,rlf), sum(ccs2te(ccsCO2(enty),enty2,te), vm_co2CCS.l(ttot,regi,enty,enty2,te,rlf) ) ) )
* (1/pm_ccsinjecrate(regi)) * sum(teCCS2rlf(te,rlf), sum(ccs2te(ccsCO2(enty),enty2,te), vm_co2CCS.l(ttot,regi,enty,enty2,te,rlf) ) ) / pm_dataccs(regi,"quan","1");
Expand Down
2 changes: 1 addition & 1 deletion modules/26_agCosts/costs/datainput.gms
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ $if %cm_MAgPIE_coupling% == "off" p26_totLUcosts_withMAC(ttot,regi) = p26_totLUc
$if %cm_MAgPIE_coupling% == "on" p26_totLUcosts_withMAC(ttot,regi) = p26_totLUcost_coupling(ttot,regi);

*' **Land use emissions MAC cost**
*' In *standalone runs* land use MAC costs are calcualted endogenously in REMIND. Since they are also included
*' In *standalone runs* land use MAC costs are calculated endogenously in REMIND. Since they are also included
*' in the exogenous total landuse costs (p26_totLUcostLookup) they need to besubstracted from these total
*' landuse costs. In coupled runs the land use MAC is deactivated in REMIND and MAC costs are included in the total land use
*' costs that are transferred from MAgPIE.
Expand Down
5 changes: 5 additions & 0 deletions modules/30_biomass/magpie_40/datainput.gms
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ $offdelim
/
;


if (cm_startyear gt 2005,
execute_load "input_ref.gdx", p30_pebiolc_costs_emu_preloop;
);

*** Select bioenergy bioenergy supply curve according to SSP scenario
i30_bioen_price_a(ttot,regi) = f30_bioen_price(ttot,regi,"%cm_LU_emi_scen%","%cm_rcp_scen%","a");
i30_bioen_price_b(ttot,regi) = f30_bioen_price(ttot,regi,"%cm_LU_emi_scen%","%cm_rcp_scen%","b");
Expand Down
2 changes: 1 addition & 1 deletion modules/30_biomass/magpie_40/equations.gms
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ q30_costFuBio(ttot,regi)$(ttot.val ge cm_startyear)..
+
$if %cm_MAgPIE_coupling% == "on" (v30_pebiolc_costs(ttot,regi) * v30_multcost(ttot,regi))
$if %cm_MAgPIE_coupling% == "off" (v30_pebiolc_costs(ttot,regi))
- p30_pebiolc_costs_emu_preloop(ttot,regi) !! Need to be substracted since they are also inculded in the total agricultural production costs
- p30_pebiolc_costs_emu_preloop(ttot,regi) !! Need to be substracted since they are also included in the total agricultural production costs
+
sum(peren2cont30(enty,rlf), vm_fuExtr(ttot,regi,enty,rlf) * pm_costsTradePeFinancial(regi,"use",enty));

Expand Down
4 changes: 2 additions & 2 deletions modules/30_biomass/magpie_40/preloop.gms
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ $endif
***------------ Step 3: calculate bioenergy costs -------------
*** The costs are calculated applying the regular cost equation.
*** This equation integrates the shifted (!) price supply curve over the demand.
*** It requires the price shift factor to be calcualted before (see above).
*** It requires the price shift factor to be calculated before (see above).

if (execError > 0,
execute_unload "abort.gdx";
Expand All @@ -102,7 +102,7 @@ if (execError > 0,

solve model_biopresolve_c using cns; !!! nothing has to be optimized here, just pure calculation

p30_pebiolc_costs_emu_preloop(ttot,regi) = v30_pebiolc_costs.l(ttot,regi);
p30_pebiolc_costs_emu_preloop(t,regi) = v30_pebiolc_costs.l(t,regi);

display p30_pebiolc_costs_emu_preloop;

Expand Down
14 changes: 14 additions & 0 deletions scripts/output/single/fixOnRef.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ findRefMif <- function(outputdir, envi) {
return(refmif)
}

fixMAGICC <- function(d, dref, startyear) {
magiccgrep <- "^Forcing|^Temperature|^Concentration"
message("Fixing MAGICC6 data before ", startyear)
dnew <-
rbind(
filter(dref, grepl(magiccgrep, .data$variable),
.data$period < startyear),
filter(d, ! grepl(magiccgrep, .data$variable) |
.data$period >= startyear)
)
return(dnew)
}

fixOnMif <- function(outputdir) {

gdxs <- file.path(outputdir, "fulldata.gdx")
Expand Down Expand Up @@ -64,6 +77,7 @@ fixOnMif <- function(outputdir) {
refname <- basename(dirname(refmif))
d <- quitte::as.quitte(mifs)
dref <- quitte::as.quitte(refmif)
d <- fixMAGICC(d, dref, startyear)
failfile <- file.path(outputdir, "log_fixOnRef.csv")
fixeddata <- piamInterfaces::fixOnRef(d, dref, ret = "fixed", startyear = startyear, failfile = failfile)

Expand Down
5 changes: 4 additions & 1 deletion scripts/start/configureCfg.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ configureCfg <- function(icfg, iscen, iscenarios, verboseGamsCompile = TRUE) {
strptime(format='%Y-%m-%d_%H.%M.%S') %>%
as.numeric %>%
which.max -> latest_fulldata
message(paste0(" Use newest normally completed run for ", path_to_gdx, " = ", iscenarios[iscen, path_to_gdx], ":\n ", str_sub(dirs[latest_fulldata],if (dirfolder == icfg$modeltests_folder) 0 else 10 ,-14)))
msg_latest <- gsub(file.path("", "fulldata.gdx"), "",
gsub(file.path(dirname(icfg$results_folder), ""), "", dirs[latest_fulldata], fixed = TRUE), fixed = TRUE)
message(paste0(" Use newest normally completed run for ", path_to_gdx, " = ", iscenarios[iscen, path_to_gdx],
":\n ", msg_latest))
iscenarios[iscen, path_to_gdx] <- dirs[latest_fulldata]
if (dirfolder == icfg$modeltests_folder) modeltestRunsUsed <<- modeltestRunsUsed + 1
}
Expand Down
Loading