Florian Humpenöder ([email protected]) 07 September, 2019
MAgPIE has a modular concept. Each module (e.g. cropland) can have several realization (e.g. dynamic and static). This tutorial shows how to add a new realization to a module in 4 steps:
- create new realization via copying existing one
- include it properly via lucode::update_modules_embedding()
- do simple modification in new realization
- choose realization in cfg and run model
We want to add a new realization to the cropland module. In the MAgPIE 4.0 release the cropland module (30_crop) has only one realization called "endo_jun13". In this realization irrigation of bioenergy crops is prohibited. We will add a new realization, based on "endo_jun13", which allows for irrigation of bioenergy crops. We will call the new new realization "bioen_irrig".
We first copy-paste the folder "endo_jun13" and the file "endo_jun13.gms" (both located in "modules/30_crop"), and rename them to "bioen_irrig" and "bioen_irrig.gms" respectivly.
To include the new realization "bioen_irrig" properly into the GAMS code we run a specific R command in the main folder. First navigate in your command line to the MAgPIE main folder, then open a new R session (type "R" followed by ENTER), and then copy-paste the following R command:
lucode::update_modules_embedding()
The prohibition of irrigated bioenergy is specified in the file "presolve.gms" within the "bioen_irrig" realization. We just have to remove (or comment out) lines 7-9 from this file to allow for irrigation of bioenergy crops.
*vm_area.fx(j,"begr","irrigated")=0;
*vm_area.fx(j,"begr","irrigated")=0;
*vm_area.fx(j,"betr","irrigated")=0;
To test the new realization we have to make a change in the file "config/default.cfg" in line 218. We change
cfg$gms$crop <- "endo_jun13"
to
cfg$gms$crop <- "bioen_irrig"
We can then start the model run with
Rscript start.R -> 1: default -> 1: Direct execution