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

34_urban exo_nov21 Realisation PR #340

Merged
merged 21 commits into from
Nov 15, 2021
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- **scripts** scripts/start/projects/project_LAMACLIMA.R -> scripts/start/projects/project_LAMACLIMA_WP4.R

### added
- **34_urban** New exo_nov21 exogenous realization of urban land expansion
- **21_trade** Missing interface parameter for failing exo realization runs
- **59_som** exogenous pathway for vm_nr_som via f59_som_exogenous
- **config** Addition of a new scenario column (Tland) in scenario_config.csv
Expand Down
16 changes: 9 additions & 7 deletions config/default.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -644,8 +644,9 @@ cfg$gms$s32_hvarea = 0 # def = 0
cfg$gms$c32_rot_calc_type = "current_annual_increment"

# ***--------------------- 34_urban ---------------------------------------
# * (static): static urban
cfg$gms$urban <- "static" # def = static
# * 34_urban includes urban land
# * (exo_nov21) has exogenous future urban land patterns based on LUH2v2
cfg$gms$urban <- "exo_nov21" # def = exo_nov21

# ***--------------------- 35_natveg --------------------------------------
# * 35_natveg includes primforest, secdforest and other land
Expand Down Expand Up @@ -716,9 +717,9 @@ cfg$gms$c35_forest_damage_end <- "by2050" # def = "by2050"
cfg$gms$s35_hvarea = 0 # def = 0

# ***--------------------- 37_labor_prod ---------------------------------
# * This module provides a labour productivity factor (0-1),
# * This module provides a labour productivity factor (0-1),
# * which reflects the efficiency of labour under changing environmental conditions (1 = no change).
# * The labour productivity factor is currently only considered in the sticky_labour
# * The labour productivity factor is currently only considered in the sticky_labour
# * realization of the [38_factor_costs] module.
# * (off): labour productivity factor fixed to 1
# * (exo): labour productivity factor is affected by climate change impacts
Expand Down Expand Up @@ -1348,12 +1349,12 @@ cfg$gms$s73_expansion <- 0 # def = 0
# * (lp_nlp_apr17): alternative approach in which the nonlinear terms are
# * fixed first so that the linear problem can be solved
# * before the full problem is solved
# * (nlp_par): Parallel optimization of regions. Allows to use higher
# * spatial resolution but works only with exogenous trade patterns
# * (nlp_par): Parallel optimization of regions. Allows to use higher
# * spatial resolution but works only with exogenous trade patterns
# * from a run with lower resolution solved with nlp_apr17.
# * Usage: add "extra/highres" as output script. This will start a
# * second model run with higher resolution.
# * Make sure that the cellular input file specified in
# * Make sure that the cellular input file specified in
# * scripts/output/extra/highres.R exists.
# * See scripts/output/extra/highres.R for details.

Expand Down Expand Up @@ -1424,6 +1425,7 @@ cfg$files2export$start <- c("input/info.txt",
"modules/30_crop/endo_apr21/input/avl_cropland_0.5.mz",
"modules/50_nr_soil_budget/input/f50_NitrogenFixationRateNatural_0.5.mz",
"modules/50_nr_soil_budget/input/f50_AtmosphericDepositionRates_0.5.mz",
"input/f34_urbanland_0.5.mz",
"input/spatial_header.rda",
"scripts/run_submit/submit.R",
"scripts/run_submit/submit_*.sh",
Expand Down
2 changes: 1 addition & 1 deletion modules/10_land/landmatrix_dec18/input.gms
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*** | Contact: magpie@pik-potsdam.de

scalars
s10_cost_balance Artificial cost for balance variable (USD05MER per ha) / 1000000 /
s10_cost_balance Artificial cost for balance variable (USD05MER per ha) / 1e+06 /
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe 1e+5 is sufficient. Not sure whether high costs are good (punishmnet) or bad (scaling9

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strange name "s10_cost_balance"; shouldnt it be rather "s10_punishment_area_deviation" or something like that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not one of my changes. It is just a renaming of the unit, I think it comes from Florian's branch when i cloned it.

;

table f10_land(t_ini10,j,land) Different land type areas (mio. ha)
Expand Down
5 changes: 0 additions & 5 deletions modules/10_land/landmatrix_dec18/presolve.gms
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ v10_lu_transitions.up(j,"primforest","primforest") = Inf;
*v10_lu_transitions.fx(j,land_from10,"secdforest") = 0;
*v10_lu_transitions.up(j,"secdforest","secdforest") = Inf;

*' Urban land is fixed
v10_lu_transitions.fx(j,land_from10,"urban") = 0;
v10_lu_transitions.fx(j,"urban",land_to10) = 0;
v10_lu_transitions.fx(j,"urban","urban") = pcm_land(j,"urban");

*' @stop

m_boundfix(vm_land,(j,land),up,10e-5);
1 change: 1 addition & 0 deletions modules/11_costs/default/equations.gms
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
+ sum(cell(i2,j2), vm_peatland_cost(j2))
+ vm_peatland_emis_cost(i2)
+ sum(cell(i2,j2),vm_cost_bv_loss(j2))
+ sum(cell(i2,j2),vm_cost_urban(j2))
;

*' The total regional production cost calculation is based on the sum of different
Expand Down
2 changes: 1 addition & 1 deletion modules/13_tc/endo_jun18/scaling.gms
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
*** | MAgPIE License Exception, version 1.0 (see LICENSE file).
*** | Contact: magpie@pik-potsdam.de

v13_cost_tc.scale(i) = 10e7;
v13_cost_tc.scale(i) = 10e6;
vm_tech_cost.scale(i) = 10e3;
35 changes: 35 additions & 0 deletions modules/34_urban/exo_nov21/declarations.gms
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
*** | (C) 2008-2021 Potsdam Institute for Climate Impact Research (PIK)
*** | authors, and contributors see CITATION.cff file. This file is part
*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of
*** | AGPL-3.0, you are granted additional permissions described in the
*** | MAgPIE License Exception, version 1.0 (see LICENSE file).
*** | Contact: magpie@pik-potsdam.de

parameters
i34_urban_area(t_all, j) Cellular urban area
;

positive variables
vm_cost_urban(j) Technical adjustment costs
v34_cost1(j) Technical adjustment costs
v34_cost2(j) Technical adjustment costs
;

equations
q34_urban_cell(j) Constraint for urban land
q34_urban_land(i) Prescribe total regional urban land
q34_urban_cost1(j) Technical punishment equation
q34_urban_cost2(j) Technical punishment equation
;

*#################### R SECTION START (OUTPUT DECLARATIONS) ####################
parameters
ov_cost_urban(t,j,type) Technical adjustment costs
ov34_cost1(t,j,type) Technical adjustment costs
ov34_cost2(t,j,type) Technical adjustment costs
oq34_urban_cell(t,j,type) Constraint for urban land
oq34_urban_land(t,i,type) Prescribe total regional urban land
oq34_urban_cost1(t,j,type) Technical punishment equation
oq34_urban_cost2(t,j,type) Technical punishment equation
;
*##################### R SECTION END (OUTPUT DECLARATIONS) #####################
31 changes: 31 additions & 0 deletions modules/34_urban/exo_nov21/equations.gms
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
*** | (C) 2008-2020 Potsdam Institute for Climate Impact Research (PIK)
*** | authors, and contributors see CITATION.cff file. This file is part
*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of
*** | AGPL-3.0, you are granted additional permissions described in the
*** | MAgPIE License Exception, version 1.0 (see LICENSE file).
*** | Contact: magpie@pik-potsdam.de

*' @equations
*' Cellular level land is prescribed via a very strong incentive not to deviate
*' from cellular input data. v34_cost1 and v34_cost2 are the cost variables that
*' implement this, for when vm_land(j2,"urban") is less than and greater than the input data
*' i.e. when reducing or establishing more urban land than in input.This safeguards against infeasible outcomes,
*' where urban land should expand but can not due to NPI or other protected land constraints. In this case it incurs the cost and shifts the land elsewhere in the region.



q34_urban_cost1(j2) ..
v34_cost1(j2) =g= sum(ct, i34_urban_area(ct, j2)) - vm_land(j2,"urban");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is that required? why not just use vm_land.fx(j2,"urban") = i34_urban_area(ct,j2)?

Copy link
Contributor Author

@caviddhen caviddhen Nov 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We thought that this way safeguards against infeasible outcomes. Where urban land should expand but can not due to NPI or other protected land constraints. In this case it can have high costs and shift it elsewhere in the region.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be added to the explanation text above


q34_urban_cost2(j2) ..
v34_cost2(j2) =g= vm_land(j2,"urban") - sum(ct, i34_urban_area(ct, j2));

*' Sum up cost terms with high punishment

q34_urban_cell(j2) ..
vm_cost_urban(j2) =e= (v34_cost1(j2) + v34_cost2(j2)) * s34_urban_deviation_cost;

*' Regional level urban land must match

q34_urban_land(i2) ..
sum(cell(i2,j2), vm_land(j2,"urban")) =e= sum((ct,cell(i2,j2)), i34_urban_area(ct,j2));
17 changes: 17 additions & 0 deletions modules/34_urban/exo_nov21/input.gms
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
*** | (C) 2008-2021 Potsdam Institute for Climate Impact Research (PIK)
*** | authors, and contributors see CITATION.cff file. This file is part
*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of
*** | AGPL-3.0, you are granted additional permissions described in the
*** | MAgPIE License Exception, version 1.0 (see LICENSE file).
*** | Contact: magpie@pik-potsdam.de


scalars
s34_urban_deviation_cost Artificial cost for urban deviation variables (USD05MER per ha) / 1e+06 /
;

table f34_urbanland(t_all, j, gdp_scen09) Urban land
$ondelim
$include "./modules/34_urban/exo_nov21/input/f34_urbanland.cs3"
$offdelim
;
2 changes: 2 additions & 0 deletions modules/34_urban/exo_nov21/input/files
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* list of files that are required here
f34_urbanland.cs3
32 changes: 32 additions & 0 deletions modules/34_urban/exo_nov21/postsolve.gms
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

*#################### R SECTION START (OUTPUT DEFINITIONS) #####################
ov_cost_urban(t,j,"marginal") = vm_cost_urban.m(j);
ov34_cost1(t,j,"marginal") = v34_cost1.m(j);
ov34_cost2(t,j,"marginal") = v34_cost2.m(j);
oq34_urban_cell(t,j,"marginal") = q34_urban_cell.m(j);
oq34_urban_land(t,i,"marginal") = q34_urban_land.m(i);
oq34_urban_cost1(t,j,"marginal") = q34_urban_cost1.m(j);
oq34_urban_cost2(t,j,"marginal") = q34_urban_cost2.m(j);
ov_cost_urban(t,j,"level") = vm_cost_urban.l(j);
ov34_cost1(t,j,"level") = v34_cost1.l(j);
ov34_cost2(t,j,"level") = v34_cost2.l(j);
oq34_urban_cell(t,j,"level") = q34_urban_cell.l(j);
oq34_urban_land(t,i,"level") = q34_urban_land.l(i);
oq34_urban_cost1(t,j,"level") = q34_urban_cost1.l(j);
oq34_urban_cost2(t,j,"level") = q34_urban_cost2.l(j);
ov_cost_urban(t,j,"upper") = vm_cost_urban.up(j);
ov34_cost1(t,j,"upper") = v34_cost1.up(j);
ov34_cost2(t,j,"upper") = v34_cost2.up(j);
oq34_urban_cell(t,j,"upper") = q34_urban_cell.up(j);
oq34_urban_land(t,i,"upper") = q34_urban_land.up(i);
oq34_urban_cost1(t,j,"upper") = q34_urban_cost1.up(j);
oq34_urban_cost2(t,j,"upper") = q34_urban_cost2.up(j);
ov_cost_urban(t,j,"lower") = vm_cost_urban.lo(j);
ov34_cost1(t,j,"lower") = v34_cost1.lo(j);
ov34_cost2(t,j,"lower") = v34_cost2.lo(j);
oq34_urban_cell(t,j,"lower") = q34_urban_cell.lo(j);
oq34_urban_land(t,i,"lower") = q34_urban_land.lo(i);
oq34_urban_cost1(t,j,"lower") = q34_urban_cost1.lo(j);
oq34_urban_cost2(t,j,"lower") = q34_urban_cost2.lo(j);
*##################### R SECTION END (OUTPUT DEFINITIONS) ######################

17 changes: 17 additions & 0 deletions modules/34_urban/exo_nov21/preloop.gms
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
*** | (C) 2008-2021 Potsdam Institute for Climate Impact Research (PIK)
*** | authors, and contributors see CITATION.cff file. This file is part
*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of
*** | AGPL-3.0, you are granted additional permissions described in the
*** | MAgPIE License Exception, version 1.0 (see LICENSE file).
*** | Contact: magpie@pik-potsdam.de

* get the scenario GDP & Populaiton data for iso countries
loop(t_all,
if(m_year(t_all) <= sm_fix_SSP2,
i34_urban_area(t_all, j) = f34_urbanland(t_all, j,"SSP2");
else
i34_urban_area(t_all, j) = f34_urbanland(t_all, j,"%c09_gdp_scenario%");
);
);

pcm_land(j,"urban") = i34_urban_area("y1995",j);
10 changes: 10 additions & 0 deletions modules/34_urban/exo_nov21/presolve.gms
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
*** | (C) 2008-2021 Potsdam Institute for Climate Impact Research (PIK)
*** | authors, and contributors see CITATION.cff file. This file is part
*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of
*** | AGPL-3.0, you are granted additional permissions described in the
*** | MAgPIE License Exception, version 1.0 (see LICENSE file).
*** | Contact: magpie@pik-potsdam.de

vm_carbon_stock.fx(j,"urban",c_pools) = 0;
*' Biodiversity value (BV)
vm_bv.fx(j,"urban", potnatveg) = pcm_land(j,"urban") * fm_bii_coeff("urban",potnatveg) * fm_luh2_side_layers(j,potnatveg);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is exisiting code, but all these biodiv variable names are quite cryptic... no idea what side-layers should mean, and bv=biodiv is not clear, and bii is also only clear to insiders...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, there is room for improvement. Also the "Bending the curve" paper should be added as reference. But this should be done as part of a dedicated PR, not as part of this PR.

22 changes: 22 additions & 0 deletions modules/34_urban/exo_nov21/realization.gms
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
*** | (C) 2008-2021 Potsdam Institute for Climate Impact Research (PIK)
*** | authors, and contributors see CITATION.cff file. This file is part
*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of
*** | AGPL-3.0, you are granted additional permissions described in the
*** | MAgPIE License Exception, version 1.0 (see LICENSE file).
*** | Contact: magpie@pik-potsdam.de

*' @description Urban Land based on LUH2v2 (Hurtt 2020) cellular (0.5 degree) input dataset, varying with SSP.
*' Cellular level is prescribed via a very high punishment term for deviating from original input values.
*' Regional sums of urban land must add be equal for both model and input data.

*' @limitations Urban land is exogenous and does not interact with other model dynamics, except for reducing available non-urban land pool.
*' Cellular urban land may not exactly match input data due to other land needs in the same cell.

*####################### R SECTION START (PHASES) ##############################
$Ifi "%phase%" == "declarations" $include "./modules/34_urban/exo_nov21/declarations.gms"
$Ifi "%phase%" == "input" $include "./modules/34_urban/exo_nov21/input.gms"
$Ifi "%phase%" == "equations" $include "./modules/34_urban/exo_nov21/equations.gms"
$Ifi "%phase%" == "preloop" $include "./modules/34_urban/exo_nov21/preloop.gms"
$Ifi "%phase%" == "presolve" $include "./modules/34_urban/exo_nov21/presolve.gms"
$Ifi "%phase%" == "postsolve" $include "./modules/34_urban/exo_nov21/postsolve.gms"
*######################## R SECTION END (PHASES) ###############################
3 changes: 2 additions & 1 deletion modules/34_urban/module.gms
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
*' (see also the other land modules: [30_crop], [31_past], [32_forestry], [35_natveg]).
*' It describes urban settlement areas and estimates their corresponding carbon content.
*'
*' @authors Jan Philipp Dietrich, Florian Humpenöder
*' @authors Jan Philipp Dietrich, Florian Humpenöder, David Meng-Chuen Chen, Benjamin Leon Bodirsky

*###################### R SECTION START (MODULETYPES) ##########################
$Ifi "%urban%" == "exo_nov21" $include "./modules/34_urban/exo_nov21/realization.gms"
$Ifi "%urban%" == "static" $include "./modules/34_urban/static/realization.gms"
*###################### R SECTION END (MODULETYPES) ############################
18 changes: 18 additions & 0 deletions modules/34_urban/static/declarations.gms
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
*** | (C) 2008-2021 Potsdam Institute for Climate Impact Research (PIK)
*** | authors, and contributors see CITATION.cff file. This file is part
*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of
*** | AGPL-3.0, you are granted additional permissions described in the
*** | MAgPIE License Exception, version 1.0 (see LICENSE file).
*** | Contact: magpie@pik-potsdam.de


positive variables
vm_cost_urban(j) Technical adjustment cost
;

*#################### R SECTION START (OUTPUT DECLARATIONS) ####################
parameters
ov_cost_urban(t,j,type) Technical adjustment cost
;
*##################### R SECTION END (OUTPUT DECLARATIONS) #####################

9 changes: 9 additions & 0 deletions modules/34_urban/static/not_used.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# | (C) 2008-2021 Potsdam Institute for Climate Impact Research (PIK)
# | authors, and contributors see CITATION.cff file. This file is part
# | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of
# | AGPL-3.0, you are granted additional permissions described in the
# | MAgPIE License Exception, version 1.0 (see LICENSE file).
# | Contact: magpie@pik-potsdam.de

name,type,reason
sm_fix_SSP2, input, not needed
8 changes: 8 additions & 0 deletions modules/34_urban/static/postsolve.gms
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

*#################### R SECTION START (OUTPUT DEFINITIONS) #####################
ov_cost_urban(t,j,"marginal") = vm_cost_urban.m(j);
ov_cost_urban(t,j,"level") = vm_cost_urban.l(j);
ov_cost_urban(t,j,"upper") = vm_cost_urban.up(j);
ov_cost_urban(t,j,"lower") = vm_cost_urban.lo(j);
*##################### R SECTION END (OUTPUT DEFINITIONS) ######################

2 changes: 2 additions & 0 deletions modules/34_urban/static/presolve.gms
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ vm_land.fx(j,"urban") = pcm_land(j,"urban");
vm_carbon_stock.fx(j,"urban",c_pools) = 0;
*' Biodiveristy value (BV)
vm_bv.fx(j,"urban", potnatveg) = pcm_land(j,"urban") * fm_bii_coeff("urban",potnatveg) * fm_luh2_side_layers(j,potnatveg);

vm_cost_urban.fx(j) = 0;
2 changes: 2 additions & 0 deletions modules/34_urban/static/realization.gms
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@
*' corresponding carbon stocks are assumed zero

*####################### R SECTION START (PHASES) ##############################
$Ifi "%phase%" == "declarations" $include "./modules/34_urban/static/declarations.gms"
$Ifi "%phase%" == "presolve" $include "./modules/34_urban/static/presolve.gms"
$Ifi "%phase%" == "postsolve" $include "./modules/34_urban/static/postsolve.gms"
*######################## R SECTION END (PHASES) ###############################
4 changes: 2 additions & 2 deletions modules/38_factor_costs/sticky_labor/declarations.gms
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ parameters
ov_cost_inv(t,i,type) Investment capital costs (mio USD05MER per yr)
ov38_investment_immobile(t,j,kcr,type) Investment costs in immobile farm capital (mio USD05MER per yr)
ov38_investment_mobile(t,j,type) Investment costs in mobile farm capital (mio USD05MER per yr)
ov38_labor_need(t,j,kcr,type) Labor required for one unit of output (hours per ton DM)
ov38_capital_need(t,j,kcr,mobil38,type) Captial required for one unit of output (USD05MER per ton DM)
ov38_labor_need(t,j,kcr,type) Labor required per unit of output (hours per ton DM)
ov38_capital_need(t,j,kcr,mobil38,type) Captial required per unit of output (USD05MER per ton DM)
oq38_cost_prod_crop(t,i,kcr,type) Regional factor input costs for plant production (mio USD05MER)
oq38_cost_prod_inv(t,i,type) Regional investment costs in capital (mio USD05MER)
oq38_investment_immobile(t,j,kcr,type) Cellular immobile investments into farm capital (mio USD05MER)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
*** | MAgPIE License Exception, version 1.0 (see LICENSE file).
*** | Contact: magpie@pik-potsdam.de

v43_watavail.scale(wat_src,j) = 10e5;
v43_watavail.scale(wat_src,j) = 10e4;
Loading