Skip to content

Latest commit

 

History

History
72 lines (51 loc) · 2.34 KB

7_advanced_changeCode.md

File metadata and controls

72 lines (51 loc) · 2.34 KB

Advanced: Change MAgPIE GAMS Code

Florian Humpenöder (humpenoeder@pik-potsdam.de) 25 April, 2019

Learning objectives

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:

  1. create new realization via copying existing one
  2. include it properly via lucode::update_modules_embedding()
  3. do simple modification in new realization
  4. choose realization in cfg and run model

Getting started

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".

Step 1

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.

Step 2

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()

Step 3

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;

Step 4

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