From 367222a3d40403c8d9ab71310ba01dbc33378861 Mon Sep 17 00:00:00 2001 From: florianh Date: Sat, 9 Mar 2024 17:01:48 +0100 Subject: [PATCH 001/133] tree cover cropland --- core/macros.gms | 4 ++-- modules/30_crop/endo_apr21/declarations.gms | 12 +++++++++++ modules/30_crop/endo_apr21/equations.gms | 10 ++++++++-- modules/30_crop/endo_apr21/input.gms | 12 +++++++++++ modules/30_crop/endo_apr21/input/files | 2 ++ modules/30_crop/endo_apr21/postsolve.gms | 9 +++++++++ modules/30_crop/endo_apr21/preloop.gms | 20 +++++++++++++++++++ modules/30_crop/endo_apr21/presolve.gms | 11 ++++++++++ modules/44_biodiversity/bii_target/sets.gms | 4 ++-- modules/44_biodiversity/bv_btc_mar21/sets.gms | 4 ++-- 10 files changed, 80 insertions(+), 8 deletions(-) diff --git a/core/macros.gms b/core/macros.gms index 0cb9567bd1..67dfedc1ed 100644 --- a/core/macros.gms +++ b/core/macros.gms @@ -97,12 +97,12 @@ $macro m_linear_cell_data_interpol(output,x,input_x1,input_x2,input_y1,input_y2) * macro for simple carbon stocks $macro m_carbon_stock(land,carbon_density,item) \ (land(j2,item) * sum(ct,carbon_density(ct,j2,item,ag_pools)))$(sameas(stockType,"actual")) + \ - (land(j2,item) * sum(ct,carbon_density(ct,j2,item,ag_pools)))$(sameas(stockType,"actualNoAcEst")); + (land(j2,item) * sum(ct,carbon_density(ct,j2,item,ag_pools)))$(sameas(stockType,"actualNoAcEst")) * macro for carbon stocks with age classes $macro m_carbon_stock_ac(land,carbon_density,sets,sets_sub) \ sum((&&sets), land(j2,&&sets) * sum(ct, carbon_density(ct,j2,&&sets,ag_pools)))$(sameas(stockType,"actual")) + \ - sum((&&sets_sub), land(j2,&&sets_sub) * sum(ct, carbon_density(ct,j2,&&sets_sub,ag_pools)))$(sameas(stockType,"actualNoAcEst")); + sum((&&sets_sub), land(j2,&&sets_sub) * sum(ct, carbon_density(ct,j2,&&sets_sub,ag_pools)))$(sameas(stockType,"actualNoAcEst")) * macros for peatland module $macro m58_LandMerge(land,landForestry,set) \ diff --git a/modules/30_crop/endo_apr21/declarations.gms b/modules/30_crop/endo_apr21/declarations.gms index 0ab0da5cad..d945f199fb 100644 --- a/modules/30_crop/endo_apr21/declarations.gms +++ b/modules/30_crop/endo_apr21/declarations.gms @@ -5,6 +5,10 @@ *** | MAgPIE License Exception, version 1.0 (see LICENSE file). *** | Contact: magpie@pik-potsdam.de +scalars + s30_shift number of 5-year age-classes corresponding to current time step length (1) +; + parameters p30_avl_cropland(t,j) Total available land for crop cultivation (mio. ha) p30_country_snv_weight(i) SNV policy country weight per region (1) @@ -16,6 +20,10 @@ parameters i30_avl_cropland_iso(iso) Available land area for cropland at ISO level (mio. ha) p30_snv_scenario_fader(t_all) SNV scenario fader (1) p30_rotation_scenario_fader(t_all) Crop rotation scenario fader (1) + p30_treecover(t,j,ac) Cropland tree cover per age class (mio. ha) + pc30_treecover(j,ac) Cropland tree cover per age class in current time step (mio. ha) + p30_carbon_density_ac(t,j,ac,ag_pools) Carbon density cropland tree cover (tC per ha) + p30_treecover_bii_coeff(bii_class_secd,potnatveg) bii coeff (1) ; positive variables @@ -23,6 +31,7 @@ positive variables vm_fallow(j) Fallow land (mio. ha) vm_area(j,kcr,w) Agricultural production area (mio. ha) vm_rotation_penalty(i) Penalty for violating rotational constraints (USD05MER) + v30_treecover(j,ac) Cropland tree cover per age class (mio. ha) ; equations @@ -36,6 +45,7 @@ equations q30_bv_per(j,potnatveg) Biodiversity value of perennial cropland (mio. ha) q30_land_snv(j) Land constraint for the SNV policy in cropland areas (mio. ha) q30_land_snv_trans(j) Land transition constraint for SNV policy in cropland areas (mio. ha) + q30_bv_treecover(j,potnatveg) Biodiversity value for cropland treecover (Mha) ; *#################### R SECTION START (OUTPUT DECLARATIONS) #################### @@ -43,6 +53,7 @@ parameters ov_fallow(t,j,type) Fallow land (mio. ha) ov_area(t,j,kcr,w,type) Agricultural production area (mio. ha) ov_rotation_penalty(t,i,type) Penalty for violating rotational constraints (USD05MER) + ov30_treecover(t,j,ac,type) Cropland tree cover per age class (mio. ha) oq30_cropland(t,j,type) Total cropland calculation (mio. ha) oq30_avl_cropland(t,j,type) Available cropland constraint (mio. ha) oq30_rotation_max(t,j,crp30,w,type) Local maximum rotational constraints (mio. ha) @@ -53,6 +64,7 @@ parameters oq30_bv_per(t,j,potnatveg,type) Biodiversity value of perennial cropland (mio. ha) oq30_land_snv(t,j,type) Land constraint for the SNV policy in cropland areas (mio. ha) oq30_land_snv_trans(t,j,type) Land transition constraint for SNV policy in cropland areas (mio. ha) + oq30_bv_treecover(t,j,potnatveg,type) Biodiversity value for cropland treecover (Mha) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/30_crop/endo_apr21/equations.gms b/modules/30_crop/endo_apr21/equations.gms index a4c495c099..11e3f6add8 100644 --- a/modules/30_crop/endo_apr21/equations.gms +++ b/modules/30_crop/endo_apr21/equations.gms @@ -10,7 +10,7 @@ *' the sum of crop and water supply type specific land requirements: q30_cropland(j2) .. - sum((kcr,w), vm_area(j2,kcr,w)) =e= vm_land(j2,"crop"); + sum((kcr,w), vm_area(j2,kcr,w)) + vm_fallow(j2) + sum(ac, v30_treecover(j2,ac)) =e= vm_land(j2,"crop"); *' We assume that crop production can only take place on suitable cropland area. *' We use a suitability index (SI) map from @zabel_global_2014 to exclude areas @@ -68,7 +68,8 @@ q30_carbon(j2,ag_pools,stockType) .. vm_carbon_stock(j2,"crop",ag_pools,stockType) =e= - m_carbon_stock(vm_land,fm_carbon_density,"crop"); + m_carbon_stock(vm_land,fm_carbon_density,"crop") + + m_carbon_stock_ac(v30_treecover,p30_carbon_density_ac,"ac","ac_sub"); *' The biodiversity value for cropland is calculated separately for annual and perennial crops: q30_bv_ann(j2,potnatveg) .. vm_bv(j2,"crop_ann",potnatveg) @@ -79,3 +80,8 @@ =e= (vm_land(j2,"crop") - sum((crop_ann30,w), vm_area(j2,crop_ann30,w))) * fm_bii_coeff("crop_per",potnatveg) * fm_luh2_side_layers(j2,potnatveg); + + q30_bv_treecover(j2,potnatveg) .. vm_bv(j2,"crop_tree",potnatveg) + =e= + sum(bii_class_secd, sum(ac_to_bii_class_secd(ac,bii_class_secd), v30_treecover(j2,ac)) * + p30_treecover_bii_coeff(bii_class_secd,potnatveg)) * fm_luh2_side_layers(j2,potnatveg); diff --git a/modules/30_crop/endo_apr21/input.gms b/modules/30_crop/endo_apr21/input.gms index a8c1656d83..b5dbb6f6d7 100644 --- a/modules/30_crop/endo_apr21/input.gms +++ b/modules/30_crop/endo_apr21/input.gms @@ -29,6 +29,8 @@ s30_snv_relocation_data_x1 First reference value in SNV target cropland dat s30_snv_relocation_data_x2 Second reference value in SNV target cropland data (1) / 0.5 / s30_rotation_scenario_start Rotation scenario start year / 2020 / s30_rotation_scenario_target Rotation scenario target year / 2050 / +s30_treecover_plantation Growth curve switch for tree cover on cropland 0=natveg 1=plantations (1) / 0 / +s30_treecover_bii_coeff BII coefficent to be used for tree cover on cropland 0=natural vegetation 1=plantation (1) / 0 / ; * Set-switch for countries affected by regional SNV policy @@ -122,3 +124,13 @@ $ondelim $include "./modules/30_crop/endo_apr21/input/SNVTargetCropland.cs3" $offdelim ; + +********* Cropland tree cover ******************************************* + +parameter f30_treecover(j) Tree cover on cropland in 2019 (mio. ha) +/ +$ondelim +$include "./modules/30_crop/endo_apr21/input/CroplandTreecover.cs2" +$offdelim +/ +; diff --git a/modules/30_crop/endo_apr21/input/files b/modules/30_crop/endo_apr21/input/files index d0cfbda228..77cc6324da 100644 --- a/modules/30_crop/endo_apr21/input/files +++ b/modules/30_crop/endo_apr21/input/files @@ -7,3 +7,5 @@ f30_croparea_w_initialisation.cs3 avl_cropland_iso.cs3 SNVTargetCropland.cs3 SNVTargetCropland_0.5.mz +CroplandTreecover.cs2 +CroplandTreecover_0.5.mz diff --git a/modules/30_crop/endo_apr21/postsolve.gms b/modules/30_crop/endo_apr21/postsolve.gms index d15f95065c..e2fd3d3478 100644 --- a/modules/30_crop/endo_apr21/postsolve.gms +++ b/modules/30_crop/endo_apr21/postsolve.gms @@ -5,11 +5,13 @@ *** | MAgPIE License Exception, version 1.0 (see LICENSE file). *** | Contact: magpie@pik-potsdam.de +pc30_treecover(j,ac) = v30_treecover.l(j,ac); *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### ov_fallow(t,j,"marginal") = vm_fallow.m(j); ov_area(t,j,kcr,w,"marginal") = vm_area.m(j,kcr,w); ov_rotation_penalty(t,i,"marginal") = vm_rotation_penalty.m(i); + ov30_treecover(t,j,ac,"marginal") = v30_treecover.m(j,ac); oq30_cropland(t,j,"marginal") = q30_cropland.m(j); oq30_avl_cropland(t,j,"marginal") = q30_avl_cropland.m(j); oq30_rotation_max(t,j,crp30,w,"marginal") = q30_rotation_max.m(j,crp30,w); @@ -20,9 +22,11 @@ oq30_bv_per(t,j,potnatveg,"marginal") = q30_bv_per.m(j,potnatveg); oq30_land_snv(t,j,"marginal") = q30_land_snv.m(j); oq30_land_snv_trans(t,j,"marginal") = q30_land_snv_trans.m(j); + oq30_bv_treecover(t,j,potnatveg,"marginal") = q30_bv_treecover.m(j,potnatveg); ov_fallow(t,j,"level") = vm_fallow.l(j); ov_area(t,j,kcr,w,"level") = vm_area.l(j,kcr,w); ov_rotation_penalty(t,i,"level") = vm_rotation_penalty.l(i); + ov30_treecover(t,j,ac,"level") = v30_treecover.l(j,ac); oq30_cropland(t,j,"level") = q30_cropland.l(j); oq30_avl_cropland(t,j,"level") = q30_avl_cropland.l(j); oq30_rotation_max(t,j,crp30,w,"level") = q30_rotation_max.l(j,crp30,w); @@ -33,9 +37,11 @@ oq30_bv_per(t,j,potnatveg,"level") = q30_bv_per.l(j,potnatveg); oq30_land_snv(t,j,"level") = q30_land_snv.l(j); oq30_land_snv_trans(t,j,"level") = q30_land_snv_trans.l(j); + oq30_bv_treecover(t,j,potnatveg,"level") = q30_bv_treecover.l(j,potnatveg); ov_fallow(t,j,"upper") = vm_fallow.up(j); ov_area(t,j,kcr,w,"upper") = vm_area.up(j,kcr,w); ov_rotation_penalty(t,i,"upper") = vm_rotation_penalty.up(i); + ov30_treecover(t,j,ac,"upper") = v30_treecover.up(j,ac); oq30_cropland(t,j,"upper") = q30_cropland.up(j); oq30_avl_cropland(t,j,"upper") = q30_avl_cropland.up(j); oq30_rotation_max(t,j,crp30,w,"upper") = q30_rotation_max.up(j,crp30,w); @@ -46,9 +52,11 @@ oq30_bv_per(t,j,potnatveg,"upper") = q30_bv_per.up(j,potnatveg); oq30_land_snv(t,j,"upper") = q30_land_snv.up(j); oq30_land_snv_trans(t,j,"upper") = q30_land_snv_trans.up(j); + oq30_bv_treecover(t,j,potnatveg,"upper") = q30_bv_treecover.up(j,potnatveg); ov_fallow(t,j,"lower") = vm_fallow.lo(j); ov_area(t,j,kcr,w,"lower") = vm_area.lo(j,kcr,w); ov_rotation_penalty(t,i,"lower") = vm_rotation_penalty.lo(i); + ov30_treecover(t,j,ac,"lower") = v30_treecover.lo(j,ac); oq30_cropland(t,j,"lower") = q30_cropland.lo(j); oq30_avl_cropland(t,j,"lower") = q30_avl_cropland.lo(j); oq30_rotation_max(t,j,crp30,w,"lower") = q30_rotation_max.lo(j,crp30,w); @@ -59,4 +67,5 @@ oq30_bv_per(t,j,potnatveg,"lower") = q30_bv_per.lo(j,potnatveg); oq30_land_snv(t,j,"lower") = q30_land_snv.lo(j); oq30_land_snv_trans(t,j,"lower") = q30_land_snv_trans.lo(j); + oq30_bv_treecover(t,j,potnatveg,"lower") = q30_bv_treecover.lo(j,potnatveg); *##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/30_crop/endo_apr21/preloop.gms b/modules/30_crop/endo_apr21/preloop.gms index 12c01058e1..a4017421f1 100644 --- a/modules/30_crop/endo_apr21/preloop.gms +++ b/modules/30_crop/endo_apr21/preloop.gms @@ -37,3 +37,23 @@ p30_country_dummy(policy_countries30) = 1; * Countries are weighted by available cropland area. i30_avl_cropland_iso(iso) = f30_avl_cropland_iso(iso,"%c30_marginal_land%"); p30_country_snv_weight(i) = sum(i_to_iso(i,iso), p30_country_dummy(iso) * i30_avl_cropland_iso(iso)) / sum(i_to_iso(i,iso), i30_avl_cropland_iso(iso)); + +* Initial tree cover on cropland is assumed to be equally distributed among all age-classes +pc30_treecover(j,ac) = f30_treecover(j)/card(ac); + +*' Switch for tree cover on cropland: +*' 0 = Use natveg growth curve towards LPJmL natural vegetation +*' 1 = Use plantation growth curve (faster than natveg) towards LPJmL natural vegetation +if(s30_treecover_plantation = 0, + p30_carbon_density_ac(t,j,ac,ag_pools) = pm_carbon_density_ac(t,j,ac,ag_pools); +elseif s30_treecover_plantation = 1, + p30_carbon_density_ac(t,j,ac,ag_pools) = pm_carbon_density_ac_forestry(t,j,ac,ag_pools); +); + +** set bii coefficients +p30_treecover_bii_coeff(bii_class_secd,potnatveg) = 0; +if(s30_treecover_bii_coeff = 0, + p30_treecover_bii_coeff(bii_class_secd,potnatveg) = fm_bii_coeff(bii_class_secd,potnatveg) +elseif s30_treecover_bii_coeff = 1, + p30_treecover_bii_coeff(bii_class_secd,potnatveg) = fm_bii_coeff("timber",potnatveg) +); diff --git a/modules/30_crop/endo_apr21/presolve.gms b/modules/30_crop/endo_apr21/presolve.gms index b88ac26965..eacbee0043 100644 --- a/modules/30_crop/endo_apr21/presolve.gms +++ b/modules/30_crop/endo_apr21/presolve.gms @@ -50,3 +50,14 @@ p30_snv_relocation(t,j)$(p30_snv_relocation(t, j) > p30_max_snv_relocation(t,j)) *' Area potentially available for cropping p30_avl_cropland(t,j) = f30_avl_cropland(j,"%c30_marginal_land%") * (1 - p30_snv_shr(t,j)); *' @stop + +* Growth of trees on cropland is modelled by shifting age-classes according to time step length. +s30_shift = m_timestep_length_forestry/5; +* example: ac10 in t = ac5 (ac10-1) in t-1 for a 5 yr time step (s30_shift = 1) + p30_treecover(t,j,ac)$(ord(ac) > s30_shift) = pc30_treecover(j,ac-s30_shift); +* account for cases at the end of the age class set (s30_shift > 1) which are not shifted by the above calculation + p30_treecover(t,j,"acx") = p30_treecover(t,j,"acx") + + sum(ac$(ord(ac) > card(ac)-s30_shift), pc30_treecover(j,ac)); + +pc30_treecover(j,ac) = p30_treecover(t,j,ac); +v30_treecover.l(j,ac) = p30_treecover(t,j,ac); diff --git a/modules/44_biodiversity/bii_target/sets.gms b/modules/44_biodiversity/bii_target/sets.gms index 0a826f7791..feed8500b3 100644 --- a/modules/44_biodiversity/bii_target/sets.gms +++ b/modules/44_biodiversity/bii_target/sets.gms @@ -8,10 +8,10 @@ sets landcover44 land cover classes used in bii calculation - / crop_ann, crop_per, manpast, rangeland, urban, aff_ndc, aff_co2p, primforest, secdforest, other, plant / + / crop_ann, crop_per, crop_tree, manpast, rangeland, urban, aff_ndc, aff_co2p, primforest, secdforest, other, plant / bii_class44 bii coefficent land cover classes - / crop_ann, crop_per, manpast, rangeland, urban, primary, secd_mature, secd_young, timber / + / crop_ann, crop_per, crop_tree, manpast, rangeland, urban, primary, secd_mature, secd_young, timber / bii_class_secd(bii_class44) bii coefficent land cover classes secondary vegetation / secd_mature, secd_young / diff --git a/modules/44_biodiversity/bv_btc_mar21/sets.gms b/modules/44_biodiversity/bv_btc_mar21/sets.gms index 14323240b8..4d75f058b6 100644 --- a/modules/44_biodiversity/bv_btc_mar21/sets.gms +++ b/modules/44_biodiversity/bv_btc_mar21/sets.gms @@ -8,10 +8,10 @@ sets landcover44 land cover classes used in bii calculation - / crop_ann, crop_per, manpast, rangeland, urban, aff_ndc, aff_co2p, primforest, secdforest, other, plant / + / crop_ann, crop_per, crop_tree, manpast, rangeland, urban, aff_ndc, aff_co2p, primforest, secdforest, other, plant / bii_class44 bii coefficent land cover classes - / crop_ann, crop_per, manpast, rangeland, urban, primary, secd_mature, secd_young, timber / + / crop_ann, crop_per, crop_tree, manpast, rangeland, urban, primary, secd_mature, secd_young, timber / bii_class_secd(bii_class44) bii coefficent land cover classes secondary vegetation / secd_mature, secd_young / From aecdaffe273e791fe8a6c84719aff32d86c897ca Mon Sep 17 00:00:00 2001 From: florianh Date: Mon, 11 Mar 2024 13:55:57 +0100 Subject: [PATCH 002/133] treecover and betr scenario --- modules/30_crop/endo_apr21/declarations.gms | 10 +++++++ modules/30_crop/endo_apr21/equations.gms | 13 +++++++++ modules/30_crop/endo_apr21/input.gms | 9 ++++++ modules/30_crop/endo_apr21/postsolve.gms | 12 ++++++++ modules/30_crop/endo_apr21/preloop.gms | 2 ++ modules/30_crop/endo_apr21/presolve.gms | 29 +++++++++++++++++++ .../32_forestry/dynamic_feb21/presolve.gms | 7 ----- 7 files changed, 75 insertions(+), 7 deletions(-) diff --git a/modules/30_crop/endo_apr21/declarations.gms b/modules/30_crop/endo_apr21/declarations.gms index d945f199fb..460e861628 100644 --- a/modules/30_crop/endo_apr21/declarations.gms +++ b/modules/30_crop/endo_apr21/declarations.gms @@ -24,6 +24,10 @@ parameters pc30_treecover(j,ac) Cropland tree cover per age class in current time step (mio. ha) p30_carbon_density_ac(t,j,ac,ag_pools) Carbon density cropland tree cover (tC per ha) p30_treecover_bii_coeff(bii_class_secd,potnatveg) bii coeff (1) + p30_treecover_shr(t,j) Share of treecover on cropland (1) + p30_treecover_scenario_fader(t_all) Cropland treecover scenario fader (1) + p30_betr_shr(t,j) Share of betr on cropland (1) + p30_betr_scenario_fader(t_all) betr scenario fader (1) ; positive variables @@ -45,6 +49,9 @@ equations q30_bv_per(j,potnatveg) Biodiversity value of perennial cropland (mio. ha) q30_land_snv(j) Land constraint for the SNV policy in cropland areas (mio. ha) q30_land_snv_trans(j) Land transition constraint for SNV policy in cropland areas (mio. ha) + q30_treecover(j) Land constraint cropland treecover (mio. ha) + q30_treecover_est(j,ac) Land constraint cropland treecover (mio. ha) + q30_betr(j) Land constraint betr (mio. ha) q30_bv_treecover(j,potnatveg) Biodiversity value for cropland treecover (Mha) ; @@ -64,6 +71,9 @@ parameters oq30_bv_per(t,j,potnatveg,type) Biodiversity value of perennial cropland (mio. ha) oq30_land_snv(t,j,type) Land constraint for the SNV policy in cropland areas (mio. ha) oq30_land_snv_trans(t,j,type) Land transition constraint for SNV policy in cropland areas (mio. ha) + oq30_treecover(t,j,type) Land constraint cropland treecover (mio. ha) + oq30_treecover_est(t,j,ac,type) Land constraint cropland treecover (mio. ha) + oq30_betr(t,j,type) Land constraint betr (mio. ha) oq30_bv_treecover(t,j,potnatveg,type) Biodiversity value for cropland treecover (Mha) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/30_crop/endo_apr21/equations.gms b/modules/30_crop/endo_apr21/equations.gms index 11e3f6add8..6009272a16 100644 --- a/modules/30_crop/endo_apr21/equations.gms +++ b/modules/30_crop/endo_apr21/equations.gms @@ -40,6 +40,19 @@ q30_land_snv_trans(j2) .. sum(land_snv, vm_lu_transitions(j2,"crop",land_snv)) =g= sum(ct, p30_snv_relocation(ct,j2)); + q30_treecover(j2) .. + sum(ac, v30_treecover(j2,ac)) =g= sum(ct, p30_treecover_shr(ct,j2)) * vm_land(j2,"crop"); + + q30_betr(j2) .. + sum(w, vm_area(j2,"betr",w)) =g= + vm_land(j2,"crop") * sum(ct, p30_betr_shr(ct,j2)); + +*' This constraint distributes additions to forestry land over ac_est, +*' which depends on the time step length (e.g. ac0 and ac5 for a 10 year time step). + + q30_treecover_est(j2,ac_est) .. + v30_treecover(j2,ac_est) =e= sum(ac_est2, v30_treecover(j2,ac_est2))/card(ac_est2); + *' As additional constraints minimum and maximum rotational constraints limit *' the placing of crops. On the one hand, these rotational constraints reflect *' crop rotations limiting the share a specific crop can cover of the total area diff --git a/modules/30_crop/endo_apr21/input.gms b/modules/30_crop/endo_apr21/input.gms index b5dbb6f6d7..1b797df00a 100644 --- a/modules/30_crop/endo_apr21/input.gms +++ b/modules/30_crop/endo_apr21/input.gms @@ -31,6 +31,15 @@ s30_rotation_scenario_start Rotation scenario start year / 2020 / s30_rotation_scenario_target Rotation scenario target year / 2050 / s30_treecover_plantation Growth curve switch for tree cover on cropland 0=natveg 1=plantations (1) / 0 / s30_treecover_bii_coeff BII coefficent to be used for tree cover on cropland 0=natural vegetation 1=plantation (1) / 0 / +s30_treecover_shr Share of treecover on cropland (1) / 0 / +s30_treecover_shr_noselect Share of treecover on cropland (1) / 0 / +s30_treecover_scenario_start Cropland treecover scenario start year / 2020 / +s30_treecover_scenario_target Cropland treecover scenario target year / 2030 / +s30_treecover_decrease Cropland treecover can decrease (1) or not (0) / 0 / +s30_betr_shr Share of bioenergy trees on cropland (1) / 0.25 / +s30_betr_shr_noselect Share of betr on cropland (1) / 0 / +s30_betr_scenario_start betr scenario start year / 2020 / +s30_betr_scenario_target betr scenario target year / 2030 / ; * Set-switch for countries affected by regional SNV policy diff --git a/modules/30_crop/endo_apr21/postsolve.gms b/modules/30_crop/endo_apr21/postsolve.gms index e2fd3d3478..1f5f5279aa 100644 --- a/modules/30_crop/endo_apr21/postsolve.gms +++ b/modules/30_crop/endo_apr21/postsolve.gms @@ -22,6 +22,9 @@ pc30_treecover(j,ac) = v30_treecover.l(j,ac); oq30_bv_per(t,j,potnatveg,"marginal") = q30_bv_per.m(j,potnatveg); oq30_land_snv(t,j,"marginal") = q30_land_snv.m(j); oq30_land_snv_trans(t,j,"marginal") = q30_land_snv_trans.m(j); + oq30_treecover(t,j,"marginal") = q30_treecover.m(j); + oq30_treecover_est(t,j,ac,"marginal") = q30_treecover_est.m(j,ac); + oq30_betr(t,j,"marginal") = q30_betr.m(j); oq30_bv_treecover(t,j,potnatveg,"marginal") = q30_bv_treecover.m(j,potnatveg); ov_fallow(t,j,"level") = vm_fallow.l(j); ov_area(t,j,kcr,w,"level") = vm_area.l(j,kcr,w); @@ -37,6 +40,9 @@ pc30_treecover(j,ac) = v30_treecover.l(j,ac); oq30_bv_per(t,j,potnatveg,"level") = q30_bv_per.l(j,potnatveg); oq30_land_snv(t,j,"level") = q30_land_snv.l(j); oq30_land_snv_trans(t,j,"level") = q30_land_snv_trans.l(j); + oq30_treecover(t,j,"level") = q30_treecover.l(j); + oq30_treecover_est(t,j,ac,"level") = q30_treecover_est.l(j,ac); + oq30_betr(t,j,"level") = q30_betr.l(j); oq30_bv_treecover(t,j,potnatveg,"level") = q30_bv_treecover.l(j,potnatveg); ov_fallow(t,j,"upper") = vm_fallow.up(j); ov_area(t,j,kcr,w,"upper") = vm_area.up(j,kcr,w); @@ -52,6 +58,9 @@ pc30_treecover(j,ac) = v30_treecover.l(j,ac); oq30_bv_per(t,j,potnatveg,"upper") = q30_bv_per.up(j,potnatveg); oq30_land_snv(t,j,"upper") = q30_land_snv.up(j); oq30_land_snv_trans(t,j,"upper") = q30_land_snv_trans.up(j); + oq30_treecover(t,j,"upper") = q30_treecover.up(j); + oq30_treecover_est(t,j,ac,"upper") = q30_treecover_est.up(j,ac); + oq30_betr(t,j,"upper") = q30_betr.up(j); oq30_bv_treecover(t,j,potnatveg,"upper") = q30_bv_treecover.up(j,potnatveg); ov_fallow(t,j,"lower") = vm_fallow.lo(j); ov_area(t,j,kcr,w,"lower") = vm_area.lo(j,kcr,w); @@ -67,5 +76,8 @@ pc30_treecover(j,ac) = v30_treecover.l(j,ac); oq30_bv_per(t,j,potnatveg,"lower") = q30_bv_per.lo(j,potnatveg); oq30_land_snv(t,j,"lower") = q30_land_snv.lo(j); oq30_land_snv_trans(t,j,"lower") = q30_land_snv_trans.lo(j); + oq30_treecover(t,j,"lower") = q30_treecover.lo(j); + oq30_treecover_est(t,j,ac,"lower") = q30_treecover_est.lo(j,ac); + oq30_betr(t,j,"lower") = q30_betr.lo(j); oq30_bv_treecover(t,j,potnatveg,"lower") = q30_bv_treecover.lo(j,potnatveg); *##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/30_crop/endo_apr21/preloop.gms b/modules/30_crop/endo_apr21/preloop.gms index a4017421f1..167ce4300f 100644 --- a/modules/30_crop/endo_apr21/preloop.gms +++ b/modules/30_crop/endo_apr21/preloop.gms @@ -9,6 +9,8 @@ * sigmoidal interpolation between start year and target year m_sigmoid_time_interpol(p30_snv_scenario_fader,s30_snv_scenario_start,s30_snv_scenario_target,0,1); m_sigmoid_time_interpol(p30_rotation_scenario_fader,s30_rotation_scenario_start,s30_rotation_scenario_target,0,1); +m_sigmoid_time_interpol(p30_treecover_scenario_fader,s30_treecover_scenario_start,s30_treecover_scenario_target,0,1); +m_sigmoid_time_interpol(p30_betr_scenario_fader,s30_betr_scenario_start,s30_betr_scenario_target,0,1); * linear interpolation to estimate the cropland that * requires relocation due to SNV policy diff --git a/modules/30_crop/endo_apr21/presolve.gms b/modules/30_crop/endo_apr21/presolve.gms index eacbee0043..c8ba583062 100644 --- a/modules/30_crop/endo_apr21/presolve.gms +++ b/modules/30_crop/endo_apr21/presolve.gms @@ -61,3 +61,32 @@ s30_shift = m_timestep_length_forestry/5; pc30_treecover(j,ac) = p30_treecover(t,j,ac); v30_treecover.l(j,ac) = p30_treecover(t,j,ac); + +p30_treecover_shr(t,j) = p30_treecover_scenario_fader(t) * + (s30_treecover_shr * sum(cell(i,j), p30_country_snv_weight(i)) + + s30_treecover_shr_noselect * sum(cell(i,j), 1-p30_country_snv_weight(i))); + +*define ac_est and ac_sub +ac_est(ac) = no; +ac_est(ac) = yes$(ord(ac) <= (m_yeardiff_forestry(t)/5)); + +ac_sub(ac) = no; +ac_sub(ac) = yes$(ord(ac) > (m_yeardiff_forestry(t)/5)); + +* fix before s30_treecover_scenario_start to pc30_treecover(j,ac)? +if(m_year(t) <= s30_treecover_scenario_start, + v30_treecover.fx(j,ac) = pc30_treecover(j,ac); +else + v30_treecover.lo(j,ac_est) = 0; + v30_treecover.up(j,ac_est) = Inf; + if(s30_treecover_decrease = 1, + v30_treecover.lo(j,ac_sub) = 0; + v30_treecover.up(j,ac_sub) = pc30_treecover(j,ac_sub); + else + v30_treecover.fx(j,ac_sub) = pc30_treecover(j,ac_sub); + ); +); + +p30_betr_shr(t,j) = p30_betr_scenario_fader(t) * + (s30_betr_shr * sum(cell(i,j), p30_country_snv_weight(i)) + + s30_betr_shr_noselect * sum(cell(i,j), 1-p30_country_snv_weight(i))); diff --git a/modules/32_forestry/dynamic_feb21/presolve.gms b/modules/32_forestry/dynamic_feb21/presolve.gms index 97b4f3db0b..9bd762216c 100644 --- a/modules/32_forestry/dynamic_feb21/presolve.gms +++ b/modules/32_forestry/dynamic_feb21/presolve.gms @@ -5,13 +5,6 @@ *** | MAgPIE License Exception, version 1.0 (see LICENSE file). *** | Contact: magpie@pik-potsdam.de -*define ac_est and ac_sub -ac_est(ac) = no; -ac_est(ac) = yes$(ord(ac) <= (m_yeardiff_forestry(t)/5)); - -ac_sub(ac) = no; -ac_sub(ac) = yes$(ord(ac) > (m_yeardiff_forestry(t)/5)); - *Reduction of ac_est is not possible. v32_hvarea_forestry.fx(j,ac_est) = 0; v32_land_reduction.fx(j,type32,ac_est) = 0; From 3ea3246c1c822360fe2b0c90d886be1108dae5ad Mon Sep 17 00:00:00 2001 From: florianh Date: Tue, 12 Mar 2024 09:52:36 +0100 Subject: [PATCH 003/133] code revisions --- modules/30_crop/endo_apr21/declarations.gms | 12 ++++++------ modules/30_crop/endo_apr21/equations.gms | 4 ++-- modules/30_crop/endo_apr21/input.gms | 20 ++++++++++---------- modules/30_crop/endo_apr21/presolve.gms | 12 ++++++------ 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/modules/30_crop/endo_apr21/declarations.gms b/modules/30_crop/endo_apr21/declarations.gms index 460e861628..f13886f1d0 100644 --- a/modules/30_crop/endo_apr21/declarations.gms +++ b/modules/30_crop/endo_apr21/declarations.gms @@ -22,12 +22,12 @@ parameters p30_rotation_scenario_fader(t_all) Crop rotation scenario fader (1) p30_treecover(t,j,ac) Cropland tree cover per age class (mio. ha) pc30_treecover(j,ac) Cropland tree cover per age class in current time step (mio. ha) - p30_carbon_density_ac(t,j,ac,ag_pools) Carbon density cropland tree cover (tC per ha) - p30_treecover_bii_coeff(bii_class_secd,potnatveg) bii coeff (1) - p30_treecover_shr(t,j) Share of treecover on cropland (1) - p30_treecover_scenario_fader(t_all) Cropland treecover scenario fader (1) - p30_betr_shr(t,j) Share of betr on cropland (1) - p30_betr_scenario_fader(t_all) betr scenario fader (1) + p30_carbon_density_ac(t,j,ac,ag_pools) Carbon density cropland tree cover (tC per ha) + p30_treecover_bii_coeff(bii_class_secd,potnatveg) BII coefficient for cropland treecover (1) + p30_treecover_min_shr(t,j) Minimum share of treecover on cropland (1) + p30_treecover_scenario_fader(t_all) Cropland treecover scenario fader (1) + p30_betr_min_shr(t,j) Minimum share of bioenergy trees on cropland (1) + p30_betr_scenario_fader(t_all) Bioenergy trees scenario fader (1) ; positive variables diff --git a/modules/30_crop/endo_apr21/equations.gms b/modules/30_crop/endo_apr21/equations.gms index 6009272a16..e2cda3e18c 100644 --- a/modules/30_crop/endo_apr21/equations.gms +++ b/modules/30_crop/endo_apr21/equations.gms @@ -41,11 +41,11 @@ sum(land_snv, vm_lu_transitions(j2,"crop",land_snv)) =g= sum(ct, p30_snv_relocation(ct,j2)); q30_treecover(j2) .. - sum(ac, v30_treecover(j2,ac)) =g= sum(ct, p30_treecover_shr(ct,j2)) * vm_land(j2,"crop"); + sum(ac, v30_treecover(j2,ac)) =g= sum(ct, p30_treecover_min_shr(ct,j2)) * vm_land(j2,"crop"); q30_betr(j2) .. sum(w, vm_area(j2,"betr",w)) =g= - vm_land(j2,"crop") * sum(ct, p30_betr_shr(ct,j2)); + vm_land(j2,"crop") * sum(ct, p30_betr_min_shr(ct,j2)); *' This constraint distributes additions to forestry land over ac_est, *' which depends on the time step length (e.g. ac0 and ac5 for a 10 year time step). diff --git a/modules/30_crop/endo_apr21/input.gms b/modules/30_crop/endo_apr21/input.gms index 1b797df00a..90aac4cc9f 100644 --- a/modules/30_crop/endo_apr21/input.gms +++ b/modules/30_crop/endo_apr21/input.gms @@ -30,16 +30,16 @@ s30_snv_relocation_data_x2 Second reference value in SNV target cropland da s30_rotation_scenario_start Rotation scenario start year / 2020 / s30_rotation_scenario_target Rotation scenario target year / 2050 / s30_treecover_plantation Growth curve switch for tree cover on cropland 0=natveg 1=plantations (1) / 0 / -s30_treecover_bii_coeff BII coefficent to be used for tree cover on cropland 0=natural vegetation 1=plantation (1) / 0 / -s30_treecover_shr Share of treecover on cropland (1) / 0 / -s30_treecover_shr_noselect Share of treecover on cropland (1) / 0 / -s30_treecover_scenario_start Cropland treecover scenario start year / 2020 / -s30_treecover_scenario_target Cropland treecover scenario target year / 2030 / -s30_treecover_decrease Cropland treecover can decrease (1) or not (0) / 0 / -s30_betr_shr Share of bioenergy trees on cropland (1) / 0.25 / -s30_betr_shr_noselect Share of betr on cropland (1) / 0 / -s30_betr_scenario_start betr scenario start year / 2020 / -s30_betr_scenario_target betr scenario target year / 2030 / +s30_treecover_bii_coeff BII coefficent to be used for tree cover on cropland 0=secondary vegetation 1=timber plantations (1) / 0 / +s30_treecover_min_shr Share of treecover on cropland (1) / 0 / +s30_treecover_min_shr_noselect Share of treecover on cropland (1) / 0 / +s30_treecover_scenario_start Cropland treecover scenario start year / 2020 / +s30_treecover_scenario_target Cropland treecover scenario target year / 2030 / +s30_treecover_decrease Cropland treecover can decrease (1) or not (0) / 0 / +s30_betr_min_shr Minimum share of bioenergy trees on cropland (1) / 0 / +s30_betr_min_shr_noselect Minimum share of bioenergy trees on cropland (1) / 0 / +s30_betr_scenario_start Bioenergy trees scenario start year / 2020 / +s30_betr_scenario_target Bioenergy trees scenario target year / 2050 / ; * Set-switch for countries affected by regional SNV policy diff --git a/modules/30_crop/endo_apr21/presolve.gms b/modules/30_crop/endo_apr21/presolve.gms index c8ba583062..7b22389795 100644 --- a/modules/30_crop/endo_apr21/presolve.gms +++ b/modules/30_crop/endo_apr21/presolve.gms @@ -62,9 +62,9 @@ s30_shift = m_timestep_length_forestry/5; pc30_treecover(j,ac) = p30_treecover(t,j,ac); v30_treecover.l(j,ac) = p30_treecover(t,j,ac); -p30_treecover_shr(t,j) = p30_treecover_scenario_fader(t) * - (s30_treecover_shr * sum(cell(i,j), p30_country_snv_weight(i)) - + s30_treecover_shr_noselect * sum(cell(i,j), 1-p30_country_snv_weight(i))); +p30_treecover_min_shr(t,j) = p30_treecover_scenario_fader(t) * + (s30_treecover_min_shr * sum(cell(i,j), p30_country_snv_weight(i)) + + s30_treecover_min_shr_noselect * sum(cell(i,j), 1-p30_country_snv_weight(i))); *define ac_est and ac_sub ac_est(ac) = no; @@ -87,6 +87,6 @@ else ); ); -p30_betr_shr(t,j) = p30_betr_scenario_fader(t) * - (s30_betr_shr * sum(cell(i,j), p30_country_snv_weight(i)) - + s30_betr_shr_noselect * sum(cell(i,j), 1-p30_country_snv_weight(i))); +p30_betr_min_shr(t,j) = p30_betr_scenario_fader(t) * + (s30_betr_min_shr * sum(cell(i,j), p30_country_snv_weight(i)) + + s30_betr_min_shr_noselect * sum(cell(i,j), 1-p30_country_snv_weight(i))); From aa676cfd022adc255d1c754b2a96156759aea3eb Mon Sep 17 00:00:00 2001 From: florianh Date: Wed, 13 Mar 2024 10:56:56 +0100 Subject: [PATCH 004/133] new module 61_agroforestry. reverted code in 30_crop --- modules/10_land/input/files | 2 + .../10_land/landmatrix_dec18/declarations.gms | 1 + modules/10_land/landmatrix_dec18/input.gms | 15 ++++ modules/10_land/landmatrix_dec18/start.gms | 8 +- modules/11_costs/default/equations.gms | 1 + modules/29_ageclass/feb21/presolve.gms | 13 +++ modules/29_ageclass/feb21/realization.gms | 1 + modules/30_crop/endo_apr21/declarations.gms | 22 ------ modules/30_crop/endo_apr21/equations.gms | 25 +----- modules/30_crop/endo_apr21/input.gms | 21 ----- modules/30_crop/endo_apr21/input/files | 2 - modules/30_crop/endo_apr21/postsolve.gms | 21 ----- modules/30_crop/endo_apr21/preloop.gms | 22 ------ modules/30_crop/endo_apr21/presolve.gms | 40 ---------- modules/30_crop/penalty_apr22/equations.gms | 6 +- modules/30_crop/rotation_apr22/equations.gms | 6 +- modules/61_agroforestry/endo/declarations.gms | 67 ++++++++++++++++ modules/61_agroforestry/endo/equations.gms | 55 +++++++++++++ modules/61_agroforestry/endo/input.gms | 18 +++++ modules/61_agroforestry/endo/not_used.txt | 3 + modules/61_agroforestry/endo/postsolve.gms | 79 +++++++++++++++++++ modules/61_agroforestry/endo/preloop.gms | 26 ++++++ modules/61_agroforestry/endo/presolve.gms | 34 ++++++++ modules/61_agroforestry/endo/realization.gms | 21 +++++ modules/61_agroforestry/exo/declarations.gms | 65 +++++++++++++++ modules/61_agroforestry/exo/equations.gms | 54 +++++++++++++ modules/61_agroforestry/exo/input.gms | 20 +++++ modules/61_agroforestry/exo/postsolve.gms | 71 +++++++++++++++++ modules/61_agroforestry/exo/preloop.gms | 29 +++++++ modules/61_agroforestry/exo/presolve.gms | 36 +++++++++ modules/61_agroforestry/exo/realization.gms | 21 +++++ modules/61_agroforestry/module.gms | 22 ++++++ modules/61_agroforestry/off/declarations.gms | 25 ++++++ modules/61_agroforestry/off/not_used.txt | 10 +++ modules/61_agroforestry/off/postsolve.gms | 22 ++++++ modules/61_agroforestry/off/preloop.gms | 11 +++ modules/61_agroforestry/off/realization.gms | 17 ++++ modules/include.gms | 1 + 38 files changed, 753 insertions(+), 160 deletions(-) create mode 100644 modules/29_ageclass/feb21/presolve.gms create mode 100644 modules/61_agroforestry/endo/declarations.gms create mode 100644 modules/61_agroforestry/endo/equations.gms create mode 100644 modules/61_agroforestry/endo/input.gms create mode 100644 modules/61_agroforestry/endo/not_used.txt create mode 100644 modules/61_agroforestry/endo/postsolve.gms create mode 100644 modules/61_agroforestry/endo/preloop.gms create mode 100644 modules/61_agroforestry/endo/presolve.gms create mode 100644 modules/61_agroforestry/endo/realization.gms create mode 100644 modules/61_agroforestry/exo/declarations.gms create mode 100644 modules/61_agroforestry/exo/equations.gms create mode 100644 modules/61_agroforestry/exo/input.gms create mode 100644 modules/61_agroforestry/exo/postsolve.gms create mode 100644 modules/61_agroforestry/exo/preloop.gms create mode 100644 modules/61_agroforestry/exo/presolve.gms create mode 100644 modules/61_agroforestry/exo/realization.gms create mode 100644 modules/61_agroforestry/module.gms create mode 100644 modules/61_agroforestry/off/declarations.gms create mode 100644 modules/61_agroforestry/off/not_used.txt create mode 100644 modules/61_agroforestry/off/postsolve.gms create mode 100644 modules/61_agroforestry/off/preloop.gms create mode 100644 modules/61_agroforestry/off/realization.gms diff --git a/modules/10_land/input/files b/modules/10_land/input/files index 27b769596d..d6124da3a7 100644 --- a/modules/10_land/input/files +++ b/modules/10_land/input/files @@ -3,3 +3,5 @@ avl_land_t.cs3 avl_land_t_0.5.mz luh2_side_layers.cs3 avl_land_t_iso.cs3 +CroplandTreecover.cs2 +CroplandTreecover_0.5.mz diff --git a/modules/10_land/landmatrix_dec18/declarations.gms b/modules/10_land/landmatrix_dec18/declarations.gms index 7b53d1b487..03199d7f26 100644 --- a/modules/10_land/landmatrix_dec18/declarations.gms +++ b/modules/10_land/landmatrix_dec18/declarations.gms @@ -8,6 +8,7 @@ parameters pm_land_start(j,land) Land initialization area (mio. ha) pcm_land(j,land) Land area in previous time step including possible changes after optimization (mio. ha) + pm_treecover_shr(j) Cropland tree cover share (1) ; variables diff --git a/modules/10_land/landmatrix_dec18/input.gms b/modules/10_land/landmatrix_dec18/input.gms index 56f4edb78c..a90961d614 100644 --- a/modules/10_land/landmatrix_dec18/input.gms +++ b/modules/10_land/landmatrix_dec18/input.gms @@ -14,6 +14,11 @@ $ondelim $include "./modules/10_land/input/avl_land_t.cs3" $offdelim ; +*due to some rounding errors the input data currently may contain in some cases +*very small, negative numbers. These numbers have to be set to 0 as area +*cannot be smaller than 0! +f10_land(t_ini10,j,land)$(f10_land(t_ini10,j,land)<0) = 0; + table fm_luh2_side_layers(j,luh2_side_layers10) luh2 side layers (grid cell share) $ondelim @@ -26,3 +31,13 @@ $ondelim $include "./modules/10_land/input/avl_land_t_iso.cs3" $offdelim ; + +********* Cropland tree cover ******************************************* + +parameter f10_treecover(j) Tree cover on cropland in 2019 (mio. ha) +/ +$ondelim +$include "./modules/10_land/input/CroplandTreecover.cs2" +$offdelim +/ +; diff --git a/modules/10_land/landmatrix_dec18/start.gms b/modules/10_land/landmatrix_dec18/start.gms index 2211b09058..2da9a6f646 100644 --- a/modules/10_land/landmatrix_dec18/start.gms +++ b/modules/10_land/landmatrix_dec18/start.gms @@ -5,13 +5,13 @@ *** | MAgPIE License Exception, version 1.0 (see LICENSE file). *** | Contact: magpie@pik-potsdam.de -*due to some rounding errors the input data currently may contain in some cases -*very small, negative numbers. These numbers have to be set to 0 as area -*cannot be smaller than 0! pm_land_start(j,land) = f10_land("y1995",j,land); -pm_land_start(j,land)$(pm_land_start(j,land)<0) = 0; pcm_land(j,land) = pm_land_start(j,land); vm_land.l(j,land) = pcm_land(j,land); +pm_treecover_shr(j) = 0; +pm_treecover_shr(j)$(f10_land("y2015",j,"crop") > 1e-10) = + (f10_treecover(j)/f10_land("y2015",j,"crop")); + *** EOF pre.gms *** diff --git a/modules/11_costs/default/equations.gms b/modules/11_costs/default/equations.gms index ce57618e07..616bfdd8fa 100644 --- a/modules/11_costs/default/equations.gms +++ b/modules/11_costs/default/equations.gms @@ -37,6 +37,7 @@ + vm_costs_additional_mon(i2) + sum(cell(i2,j2),vm_cost_land_transition(j2)) + sum(cell(i2,j2), vm_peatland_cost(j2)) + + sum(cell(i2,j2), vm_cost_agroforestry(j2)) + sum(cell(i2,j2),vm_cost_bv_loss(j2)) + sum(cell(i2,j2),vm_cost_urban(j2)) + sum(cell(i2,j2),vm_water_cost(i2)) diff --git a/modules/29_ageclass/feb21/presolve.gms b/modules/29_ageclass/feb21/presolve.gms new file mode 100644 index 0000000000..ae9b575c01 --- /dev/null +++ b/modules/29_ageclass/feb21/presolve.gms @@ -0,0 +1,13 @@ +*** | (C) 2008-2023 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 + +*define ac_est and ac_sub +ac_est(ac) = no; +ac_est(ac) = yes$(ord(ac) <= (m_yeardiff_forestry(t)/5)); + +ac_sub(ac) = no; +ac_sub(ac) = yes$(ord(ac) > (m_yeardiff_forestry(t)/5)); diff --git a/modules/29_ageclass/feb21/realization.gms b/modules/29_ageclass/feb21/realization.gms index 7fe7990889..59ad5ce66c 100644 --- a/modules/29_ageclass/feb21/realization.gms +++ b/modules/29_ageclass/feb21/realization.gms @@ -22,4 +22,5 @@ $Ifi "%phase%" == "sets" $include "./modules/29_ageclass/feb21/sets.gms" $Ifi "%phase%" == "declarations" $include "./modules/29_ageclass/feb21/declarations.gms" $Ifi "%phase%" == "input" $include "./modules/29_ageclass/feb21/input.gms" $Ifi "%phase%" == "preloop" $include "./modules/29_ageclass/feb21/preloop.gms" +$Ifi "%phase%" == "presolve" $include "./modules/29_ageclass/feb21/presolve.gms" *######################## R SECTION END (PHASES) ############################### diff --git a/modules/30_crop/endo_apr21/declarations.gms b/modules/30_crop/endo_apr21/declarations.gms index f13886f1d0..0ab0da5cad 100644 --- a/modules/30_crop/endo_apr21/declarations.gms +++ b/modules/30_crop/endo_apr21/declarations.gms @@ -5,10 +5,6 @@ *** | MAgPIE License Exception, version 1.0 (see LICENSE file). *** | Contact: magpie@pik-potsdam.de -scalars - s30_shift number of 5-year age-classes corresponding to current time step length (1) -; - parameters p30_avl_cropland(t,j) Total available land for crop cultivation (mio. ha) p30_country_snv_weight(i) SNV policy country weight per region (1) @@ -20,14 +16,6 @@ parameters i30_avl_cropland_iso(iso) Available land area for cropland at ISO level (mio. ha) p30_snv_scenario_fader(t_all) SNV scenario fader (1) p30_rotation_scenario_fader(t_all) Crop rotation scenario fader (1) - p30_treecover(t,j,ac) Cropland tree cover per age class (mio. ha) - pc30_treecover(j,ac) Cropland tree cover per age class in current time step (mio. ha) - p30_carbon_density_ac(t,j,ac,ag_pools) Carbon density cropland tree cover (tC per ha) - p30_treecover_bii_coeff(bii_class_secd,potnatveg) BII coefficient for cropland treecover (1) - p30_treecover_min_shr(t,j) Minimum share of treecover on cropland (1) - p30_treecover_scenario_fader(t_all) Cropland treecover scenario fader (1) - p30_betr_min_shr(t,j) Minimum share of bioenergy trees on cropland (1) - p30_betr_scenario_fader(t_all) Bioenergy trees scenario fader (1) ; positive variables @@ -35,7 +23,6 @@ positive variables vm_fallow(j) Fallow land (mio. ha) vm_area(j,kcr,w) Agricultural production area (mio. ha) vm_rotation_penalty(i) Penalty for violating rotational constraints (USD05MER) - v30_treecover(j,ac) Cropland tree cover per age class (mio. ha) ; equations @@ -49,10 +36,6 @@ equations q30_bv_per(j,potnatveg) Biodiversity value of perennial cropland (mio. ha) q30_land_snv(j) Land constraint for the SNV policy in cropland areas (mio. ha) q30_land_snv_trans(j) Land transition constraint for SNV policy in cropland areas (mio. ha) - q30_treecover(j) Land constraint cropland treecover (mio. ha) - q30_treecover_est(j,ac) Land constraint cropland treecover (mio. ha) - q30_betr(j) Land constraint betr (mio. ha) - q30_bv_treecover(j,potnatveg) Biodiversity value for cropland treecover (Mha) ; *#################### R SECTION START (OUTPUT DECLARATIONS) #################### @@ -60,7 +43,6 @@ parameters ov_fallow(t,j,type) Fallow land (mio. ha) ov_area(t,j,kcr,w,type) Agricultural production area (mio. ha) ov_rotation_penalty(t,i,type) Penalty for violating rotational constraints (USD05MER) - ov30_treecover(t,j,ac,type) Cropland tree cover per age class (mio. ha) oq30_cropland(t,j,type) Total cropland calculation (mio. ha) oq30_avl_cropland(t,j,type) Available cropland constraint (mio. ha) oq30_rotation_max(t,j,crp30,w,type) Local maximum rotational constraints (mio. ha) @@ -71,10 +53,6 @@ parameters oq30_bv_per(t,j,potnatveg,type) Biodiversity value of perennial cropland (mio. ha) oq30_land_snv(t,j,type) Land constraint for the SNV policy in cropland areas (mio. ha) oq30_land_snv_trans(t,j,type) Land transition constraint for SNV policy in cropland areas (mio. ha) - oq30_treecover(t,j,type) Land constraint cropland treecover (mio. ha) - oq30_treecover_est(t,j,ac,type) Land constraint cropland treecover (mio. ha) - oq30_betr(t,j,type) Land constraint betr (mio. ha) - oq30_bv_treecover(t,j,potnatveg,type) Biodiversity value for cropland treecover (Mha) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/30_crop/endo_apr21/equations.gms b/modules/30_crop/endo_apr21/equations.gms index e2cda3e18c..539c3a61a0 100644 --- a/modules/30_crop/endo_apr21/equations.gms +++ b/modules/30_crop/endo_apr21/equations.gms @@ -10,7 +10,7 @@ *' the sum of crop and water supply type specific land requirements: q30_cropland(j2) .. - sum((kcr,w), vm_area(j2,kcr,w)) + vm_fallow(j2) + sum(ac, v30_treecover(j2,ac)) =e= vm_land(j2,"crop"); + sum((kcr,w), vm_area(j2,kcr,w)) + vm_fallow(j2) + vm_treecover_area(j2) =e= vm_land(j2,"crop"); *' We assume that crop production can only take place on suitable cropland area. *' We use a suitability index (SI) map from @zabel_global_2014 to exclude areas @@ -40,19 +40,6 @@ q30_land_snv_trans(j2) .. sum(land_snv, vm_lu_transitions(j2,"crop",land_snv)) =g= sum(ct, p30_snv_relocation(ct,j2)); - q30_treecover(j2) .. - sum(ac, v30_treecover(j2,ac)) =g= sum(ct, p30_treecover_min_shr(ct,j2)) * vm_land(j2,"crop"); - - q30_betr(j2) .. - sum(w, vm_area(j2,"betr",w)) =g= - vm_land(j2,"crop") * sum(ct, p30_betr_min_shr(ct,j2)); - -*' This constraint distributes additions to forestry land over ac_est, -*' which depends on the time step length (e.g. ac0 and ac5 for a 10 year time step). - - q30_treecover_est(j2,ac_est) .. - v30_treecover(j2,ac_est) =e= sum(ac_est2, v30_treecover(j2,ac_est2))/card(ac_est2); - *' As additional constraints minimum and maximum rotational constraints limit *' the placing of crops. On the one hand, these rotational constraints reflect *' crop rotations limiting the share a specific crop can cover of the total area @@ -80,9 +67,8 @@ *' for all cropland : q30_carbon(j2,ag_pools,stockType) .. - vm_carbon_stock(j2,"crop",ag_pools,stockType) =e= - m_carbon_stock(vm_land,fm_carbon_density,"crop") + - m_carbon_stock_ac(v30_treecover,p30_carbon_density_ac,"ac","ac_sub"); + vm_carbon_stock(j2,"crop",ag_pools,stockType) =e= + m_carbon_stock(vm_land,fm_carbon_density,"crop") + vm_treecover_carbon(j2,ag_pools,stockType); *' The biodiversity value for cropland is calculated separately for annual and perennial crops: q30_bv_ann(j2,potnatveg) .. vm_bv(j2,"crop_ann",potnatveg) @@ -93,8 +79,3 @@ =e= (vm_land(j2,"crop") - sum((crop_ann30,w), vm_area(j2,crop_ann30,w))) * fm_bii_coeff("crop_per",potnatveg) * fm_luh2_side_layers(j2,potnatveg); - - q30_bv_treecover(j2,potnatveg) .. vm_bv(j2,"crop_tree",potnatveg) - =e= - sum(bii_class_secd, sum(ac_to_bii_class_secd(ac,bii_class_secd), v30_treecover(j2,ac)) * - p30_treecover_bii_coeff(bii_class_secd,potnatveg)) * fm_luh2_side_layers(j2,potnatveg); diff --git a/modules/30_crop/endo_apr21/input.gms b/modules/30_crop/endo_apr21/input.gms index 90aac4cc9f..a8c1656d83 100644 --- a/modules/30_crop/endo_apr21/input.gms +++ b/modules/30_crop/endo_apr21/input.gms @@ -29,17 +29,6 @@ s30_snv_relocation_data_x1 First reference value in SNV target cropland dat s30_snv_relocation_data_x2 Second reference value in SNV target cropland data (1) / 0.5 / s30_rotation_scenario_start Rotation scenario start year / 2020 / s30_rotation_scenario_target Rotation scenario target year / 2050 / -s30_treecover_plantation Growth curve switch for tree cover on cropland 0=natveg 1=plantations (1) / 0 / -s30_treecover_bii_coeff BII coefficent to be used for tree cover on cropland 0=secondary vegetation 1=timber plantations (1) / 0 / -s30_treecover_min_shr Share of treecover on cropland (1) / 0 / -s30_treecover_min_shr_noselect Share of treecover on cropland (1) / 0 / -s30_treecover_scenario_start Cropland treecover scenario start year / 2020 / -s30_treecover_scenario_target Cropland treecover scenario target year / 2030 / -s30_treecover_decrease Cropland treecover can decrease (1) or not (0) / 0 / -s30_betr_min_shr Minimum share of bioenergy trees on cropland (1) / 0 / -s30_betr_min_shr_noselect Minimum share of bioenergy trees on cropland (1) / 0 / -s30_betr_scenario_start Bioenergy trees scenario start year / 2020 / -s30_betr_scenario_target Bioenergy trees scenario target year / 2050 / ; * Set-switch for countries affected by regional SNV policy @@ -133,13 +122,3 @@ $ondelim $include "./modules/30_crop/endo_apr21/input/SNVTargetCropland.cs3" $offdelim ; - -********* Cropland tree cover ******************************************* - -parameter f30_treecover(j) Tree cover on cropland in 2019 (mio. ha) -/ -$ondelim -$include "./modules/30_crop/endo_apr21/input/CroplandTreecover.cs2" -$offdelim -/ -; diff --git a/modules/30_crop/endo_apr21/input/files b/modules/30_crop/endo_apr21/input/files index 77cc6324da..d0cfbda228 100644 --- a/modules/30_crop/endo_apr21/input/files +++ b/modules/30_crop/endo_apr21/input/files @@ -7,5 +7,3 @@ f30_croparea_w_initialisation.cs3 avl_cropland_iso.cs3 SNVTargetCropland.cs3 SNVTargetCropland_0.5.mz -CroplandTreecover.cs2 -CroplandTreecover_0.5.mz diff --git a/modules/30_crop/endo_apr21/postsolve.gms b/modules/30_crop/endo_apr21/postsolve.gms index 1f5f5279aa..d15f95065c 100644 --- a/modules/30_crop/endo_apr21/postsolve.gms +++ b/modules/30_crop/endo_apr21/postsolve.gms @@ -5,13 +5,11 @@ *** | MAgPIE License Exception, version 1.0 (see LICENSE file). *** | Contact: magpie@pik-potsdam.de -pc30_treecover(j,ac) = v30_treecover.l(j,ac); *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### ov_fallow(t,j,"marginal") = vm_fallow.m(j); ov_area(t,j,kcr,w,"marginal") = vm_area.m(j,kcr,w); ov_rotation_penalty(t,i,"marginal") = vm_rotation_penalty.m(i); - ov30_treecover(t,j,ac,"marginal") = v30_treecover.m(j,ac); oq30_cropland(t,j,"marginal") = q30_cropland.m(j); oq30_avl_cropland(t,j,"marginal") = q30_avl_cropland.m(j); oq30_rotation_max(t,j,crp30,w,"marginal") = q30_rotation_max.m(j,crp30,w); @@ -22,14 +20,9 @@ pc30_treecover(j,ac) = v30_treecover.l(j,ac); oq30_bv_per(t,j,potnatveg,"marginal") = q30_bv_per.m(j,potnatveg); oq30_land_snv(t,j,"marginal") = q30_land_snv.m(j); oq30_land_snv_trans(t,j,"marginal") = q30_land_snv_trans.m(j); - oq30_treecover(t,j,"marginal") = q30_treecover.m(j); - oq30_treecover_est(t,j,ac,"marginal") = q30_treecover_est.m(j,ac); - oq30_betr(t,j,"marginal") = q30_betr.m(j); - oq30_bv_treecover(t,j,potnatveg,"marginal") = q30_bv_treecover.m(j,potnatveg); ov_fallow(t,j,"level") = vm_fallow.l(j); ov_area(t,j,kcr,w,"level") = vm_area.l(j,kcr,w); ov_rotation_penalty(t,i,"level") = vm_rotation_penalty.l(i); - ov30_treecover(t,j,ac,"level") = v30_treecover.l(j,ac); oq30_cropland(t,j,"level") = q30_cropland.l(j); oq30_avl_cropland(t,j,"level") = q30_avl_cropland.l(j); oq30_rotation_max(t,j,crp30,w,"level") = q30_rotation_max.l(j,crp30,w); @@ -40,14 +33,9 @@ pc30_treecover(j,ac) = v30_treecover.l(j,ac); oq30_bv_per(t,j,potnatveg,"level") = q30_bv_per.l(j,potnatveg); oq30_land_snv(t,j,"level") = q30_land_snv.l(j); oq30_land_snv_trans(t,j,"level") = q30_land_snv_trans.l(j); - oq30_treecover(t,j,"level") = q30_treecover.l(j); - oq30_treecover_est(t,j,ac,"level") = q30_treecover_est.l(j,ac); - oq30_betr(t,j,"level") = q30_betr.l(j); - oq30_bv_treecover(t,j,potnatveg,"level") = q30_bv_treecover.l(j,potnatveg); ov_fallow(t,j,"upper") = vm_fallow.up(j); ov_area(t,j,kcr,w,"upper") = vm_area.up(j,kcr,w); ov_rotation_penalty(t,i,"upper") = vm_rotation_penalty.up(i); - ov30_treecover(t,j,ac,"upper") = v30_treecover.up(j,ac); oq30_cropland(t,j,"upper") = q30_cropland.up(j); oq30_avl_cropland(t,j,"upper") = q30_avl_cropland.up(j); oq30_rotation_max(t,j,crp30,w,"upper") = q30_rotation_max.up(j,crp30,w); @@ -58,14 +46,9 @@ pc30_treecover(j,ac) = v30_treecover.l(j,ac); oq30_bv_per(t,j,potnatveg,"upper") = q30_bv_per.up(j,potnatveg); oq30_land_snv(t,j,"upper") = q30_land_snv.up(j); oq30_land_snv_trans(t,j,"upper") = q30_land_snv_trans.up(j); - oq30_treecover(t,j,"upper") = q30_treecover.up(j); - oq30_treecover_est(t,j,ac,"upper") = q30_treecover_est.up(j,ac); - oq30_betr(t,j,"upper") = q30_betr.up(j); - oq30_bv_treecover(t,j,potnatveg,"upper") = q30_bv_treecover.up(j,potnatveg); ov_fallow(t,j,"lower") = vm_fallow.lo(j); ov_area(t,j,kcr,w,"lower") = vm_area.lo(j,kcr,w); ov_rotation_penalty(t,i,"lower") = vm_rotation_penalty.lo(i); - ov30_treecover(t,j,ac,"lower") = v30_treecover.lo(j,ac); oq30_cropland(t,j,"lower") = q30_cropland.lo(j); oq30_avl_cropland(t,j,"lower") = q30_avl_cropland.lo(j); oq30_rotation_max(t,j,crp30,w,"lower") = q30_rotation_max.lo(j,crp30,w); @@ -76,8 +59,4 @@ pc30_treecover(j,ac) = v30_treecover.l(j,ac); oq30_bv_per(t,j,potnatveg,"lower") = q30_bv_per.lo(j,potnatveg); oq30_land_snv(t,j,"lower") = q30_land_snv.lo(j); oq30_land_snv_trans(t,j,"lower") = q30_land_snv_trans.lo(j); - oq30_treecover(t,j,"lower") = q30_treecover.lo(j); - oq30_treecover_est(t,j,ac,"lower") = q30_treecover_est.lo(j,ac); - oq30_betr(t,j,"lower") = q30_betr.lo(j); - oq30_bv_treecover(t,j,potnatveg,"lower") = q30_bv_treecover.lo(j,potnatveg); *##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/30_crop/endo_apr21/preloop.gms b/modules/30_crop/endo_apr21/preloop.gms index 167ce4300f..12c01058e1 100644 --- a/modules/30_crop/endo_apr21/preloop.gms +++ b/modules/30_crop/endo_apr21/preloop.gms @@ -9,8 +9,6 @@ * sigmoidal interpolation between start year and target year m_sigmoid_time_interpol(p30_snv_scenario_fader,s30_snv_scenario_start,s30_snv_scenario_target,0,1); m_sigmoid_time_interpol(p30_rotation_scenario_fader,s30_rotation_scenario_start,s30_rotation_scenario_target,0,1); -m_sigmoid_time_interpol(p30_treecover_scenario_fader,s30_treecover_scenario_start,s30_treecover_scenario_target,0,1); -m_sigmoid_time_interpol(p30_betr_scenario_fader,s30_betr_scenario_start,s30_betr_scenario_target,0,1); * linear interpolation to estimate the cropland that * requires relocation due to SNV policy @@ -39,23 +37,3 @@ p30_country_dummy(policy_countries30) = 1; * Countries are weighted by available cropland area. i30_avl_cropland_iso(iso) = f30_avl_cropland_iso(iso,"%c30_marginal_land%"); p30_country_snv_weight(i) = sum(i_to_iso(i,iso), p30_country_dummy(iso) * i30_avl_cropland_iso(iso)) / sum(i_to_iso(i,iso), i30_avl_cropland_iso(iso)); - -* Initial tree cover on cropland is assumed to be equally distributed among all age-classes -pc30_treecover(j,ac) = f30_treecover(j)/card(ac); - -*' Switch for tree cover on cropland: -*' 0 = Use natveg growth curve towards LPJmL natural vegetation -*' 1 = Use plantation growth curve (faster than natveg) towards LPJmL natural vegetation -if(s30_treecover_plantation = 0, - p30_carbon_density_ac(t,j,ac,ag_pools) = pm_carbon_density_ac(t,j,ac,ag_pools); -elseif s30_treecover_plantation = 1, - p30_carbon_density_ac(t,j,ac,ag_pools) = pm_carbon_density_ac_forestry(t,j,ac,ag_pools); -); - -** set bii coefficients -p30_treecover_bii_coeff(bii_class_secd,potnatveg) = 0; -if(s30_treecover_bii_coeff = 0, - p30_treecover_bii_coeff(bii_class_secd,potnatveg) = fm_bii_coeff(bii_class_secd,potnatveg) -elseif s30_treecover_bii_coeff = 1, - p30_treecover_bii_coeff(bii_class_secd,potnatveg) = fm_bii_coeff("timber",potnatveg) -); diff --git a/modules/30_crop/endo_apr21/presolve.gms b/modules/30_crop/endo_apr21/presolve.gms index 7b22389795..b88ac26965 100644 --- a/modules/30_crop/endo_apr21/presolve.gms +++ b/modules/30_crop/endo_apr21/presolve.gms @@ -50,43 +50,3 @@ p30_snv_relocation(t,j)$(p30_snv_relocation(t, j) > p30_max_snv_relocation(t,j)) *' Area potentially available for cropping p30_avl_cropland(t,j) = f30_avl_cropland(j,"%c30_marginal_land%") * (1 - p30_snv_shr(t,j)); *' @stop - -* Growth of trees on cropland is modelled by shifting age-classes according to time step length. -s30_shift = m_timestep_length_forestry/5; -* example: ac10 in t = ac5 (ac10-1) in t-1 for a 5 yr time step (s30_shift = 1) - p30_treecover(t,j,ac)$(ord(ac) > s30_shift) = pc30_treecover(j,ac-s30_shift); -* account for cases at the end of the age class set (s30_shift > 1) which are not shifted by the above calculation - p30_treecover(t,j,"acx") = p30_treecover(t,j,"acx") - + sum(ac$(ord(ac) > card(ac)-s30_shift), pc30_treecover(j,ac)); - -pc30_treecover(j,ac) = p30_treecover(t,j,ac); -v30_treecover.l(j,ac) = p30_treecover(t,j,ac); - -p30_treecover_min_shr(t,j) = p30_treecover_scenario_fader(t) * - (s30_treecover_min_shr * sum(cell(i,j), p30_country_snv_weight(i)) - + s30_treecover_min_shr_noselect * sum(cell(i,j), 1-p30_country_snv_weight(i))); - -*define ac_est and ac_sub -ac_est(ac) = no; -ac_est(ac) = yes$(ord(ac) <= (m_yeardiff_forestry(t)/5)); - -ac_sub(ac) = no; -ac_sub(ac) = yes$(ord(ac) > (m_yeardiff_forestry(t)/5)); - -* fix before s30_treecover_scenario_start to pc30_treecover(j,ac)? -if(m_year(t) <= s30_treecover_scenario_start, - v30_treecover.fx(j,ac) = pc30_treecover(j,ac); -else - v30_treecover.lo(j,ac_est) = 0; - v30_treecover.up(j,ac_est) = Inf; - if(s30_treecover_decrease = 1, - v30_treecover.lo(j,ac_sub) = 0; - v30_treecover.up(j,ac_sub) = pc30_treecover(j,ac_sub); - else - v30_treecover.fx(j,ac_sub) = pc30_treecover(j,ac_sub); - ); -); - -p30_betr_min_shr(t,j) = p30_betr_scenario_fader(t) * - (s30_betr_min_shr * sum(cell(i,j), p30_country_snv_weight(i)) - + s30_betr_min_shr_noselect * sum(cell(i,j), 1-p30_country_snv_weight(i))); diff --git a/modules/30_crop/penalty_apr22/equations.gms b/modules/30_crop/penalty_apr22/equations.gms index 5dd3f2c2bc..edcf6d8dd3 100644 --- a/modules/30_crop/penalty_apr22/equations.gms +++ b/modules/30_crop/penalty_apr22/equations.gms @@ -12,7 +12,7 @@ *' the land area for crops vm_land and the croparea vm_area q30_cropland(j2) .. - sum((kcr,w), vm_area(j2,kcr,w)) + vm_fallow(j2) =e= vm_land(j2,"crop"); + sum((kcr,w), vm_area(j2,kcr,w)) + vm_fallow(j2) + vm_treecover_area(j2) =e= vm_land(j2,"crop"); *' We assume that crop production can only take place on suitable cropland area. *' We use a suitability index (SI) map from @zabel_global_2014 to exclude areas @@ -95,8 +95,8 @@ q30_rotation_penalty(i2) .. *' for all cropland : q30_carbon(j2,ag_pools,stockType) .. - vm_carbon_stock(j2,"crop",ag_pools,stockType) =e= - m_carbon_stock(vm_land,fm_carbon_density,"crop"); + vm_carbon_stock(j2,"crop",ag_pools,stockType) =e= + m_carbon_stock(vm_land,fm_carbon_density,"crop") + vm_treecover_carbon(j2,ag_pools,stockType); *' The biodiversity value for cropland is calculated separately for annual and perennial crops: q30_bv_ann(j2,potnatveg) .. diff --git a/modules/30_crop/rotation_apr22/equations.gms b/modules/30_crop/rotation_apr22/equations.gms index c208b6e5b3..3e429ab9da 100644 --- a/modules/30_crop/rotation_apr22/equations.gms +++ b/modules/30_crop/rotation_apr22/equations.gms @@ -12,7 +12,7 @@ *' the land area for crops vm_land and the croparea vm_area q30_cropland(j2) .. - sum((kcr,w), vm_area(j2,kcr,w)) + vm_fallow(j2) =e= vm_land(j2,"crop"); + sum((kcr,w), vm_area(j2,kcr,w)) + vm_fallow(j2) + vm_treecover_area(j2) =e= vm_land(j2,"crop"); *' We assume that crop production can only take place on suitable cropland area. *' We use a suitability index (SI) map from @zabel_global_2014 to exclude areas @@ -76,8 +76,8 @@ *' for all cropland : q30_carbon(j2,ag_pools,stockType) .. - vm_carbon_stock(j2,"crop",ag_pools,stockType) =e= - m_carbon_stock(vm_land,fm_carbon_density,"crop"); + vm_carbon_stock(j2,"crop",ag_pools,stockType) =e= + m_carbon_stock(vm_land,fm_carbon_density,"crop") + vm_treecover_carbon(j2,ag_pools,stockType); *' The biodiversity value for cropland is calculated separately for annual and perennial crops: q30_bv_ann(j2,potnatveg) .. diff --git a/modules/61_agroforestry/endo/declarations.gms b/modules/61_agroforestry/endo/declarations.gms new file mode 100644 index 0000000000..5503ad7181 --- /dev/null +++ b/modules/61_agroforestry/endo/declarations.gms @@ -0,0 +1,67 @@ +*** | (C) 2008-2023 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 + s61_shift number of 5-year age-classes corresponding to current time step length (1) +; + +parameters + p61_treecover_bii_coeff(bii_class_secd,potnatveg) BII coefficient for cropland treecover (1) + p61_carbon_density_ac(t,j,ac,ag_pools) Carbon density for ac and ag_pools (tC per ha) + p61_treecover(t,j,ac) Cropland tree cover per age class (mio. ha) + pc61_treecover(j,ac) Cropland tree cover per age class in current time step (mio. ha) + i61_reward_treecover Area reward for cropland treecover (USD per ha) + i61_reward_betr Area reward for bioenergy trees (USD per ha) +; + +equations + q61_cost_agroforestry(j) Costs and benefits related to agroforestry (mio. USD05MER per yr) + q61_cost_treecover_est(j) Establishment cost for cropland tree cover (mio. USD05MER per yr) + q61_cost_treecover_recur(j) Recurring cost for cropland tree cover (mio. USD05MER per yr) + q61_treecover_area(j) Cropland treecover interface (mio. ha) + q61_reward_treecover(j) Reward for cropland treecover (mio. USD05MER per yr) + q61_reward_betr(j) Reward for bioenergy trees (mio. USD05MER per yr) + q61_treecover_est(j,ac) Cropland treecover establishment (mio. ha) + q61_treecover_carbon(j,ag_pools,stockType) Cropland tree cover above ground carbon content (mio. tC) + q61_treecover_bv(j,potnatveg) Biodiversity value for cropland treecover (Mha) +; + +variables + vm_cost_agroforestry(j) Cost and rewards related to agroforestry (mio. USD05MER per yr) +; + +positive variables + v61_cost_treecover_est(j) Establishment cost for cropland tree cover (mio. USD05MER per yr) + v61_cost_treecover_recur(j) Recurring cost for cropland tree cover (mio. USD05MER per yr) + v61_reward_treecover(j) Reward for cropland treecover (mio. USD05MER per yr) + v61_reward_betr(j) Reward for bioenergy trees (mio. USD05MER per yr) + vm_treecover_area(j) Cropland tree cover (mio. ha) + v61_treecover(j,ac) Cropland tree cover per age class (mio. ha) + vm_treecover_carbon(j,ag_pools,stockType) Cropland tree cover above ground carbon content (mio. tC) +; + +*#################### R SECTION START (OUTPUT DECLARATIONS) #################### +parameters + ov_cost_agroforestry(t,j,type) Cost and rewards related to agroforestry (mio. USD05MER per yr) + ov61_cost_treecover_est(t,j,type) Establishment cost for cropland tree cover (mio. USD05MER per yr) + ov61_cost_treecover_recur(t,j,type) Recurring cost for cropland tree cover (mio. USD05MER per yr) + ov61_reward_treecover(t,j,type) Reward for cropland treecover (mio. USD05MER per yr) + ov61_reward_betr(t,j,type) Reward for bioenergy trees (mio. USD05MER per yr) + ov_treecover_area(t,j,type) Cropland tree cover (mio. ha) + ov61_treecover(t,j,ac,type) Cropland tree cover per age class (mio. ha) + ov_treecover_carbon(t,j,ag_pools,stockType,type) Cropland tree cover above ground carbon content (mio. tC) + oq61_cost_agroforestry(t,j,type) Costs and benefits related to agroforestry (mio. USD05MER per yr) + oq61_cost_treecover_est(t,j,type) Establishment cost for cropland tree cover (mio. USD05MER per yr) + oq61_cost_treecover_recur(t,j,type) Recurring cost for cropland tree cover (mio. USD05MER per yr) + oq61_treecover_area(t,j,type) Cropland treecover interface (mio. ha) + oq61_reward_treecover(t,j,type) Reward for cropland treecover (mio. USD05MER per yr) + oq61_reward_betr(t,j,type) Reward for bioenergy trees (mio. USD05MER per yr) + oq61_treecover_est(t,j,ac,type) Cropland treecover establishment (mio. ha) + oq61_treecover_carbon(t,j,ag_pools,stockType,type) Cropland tree cover above ground carbon content (mio. tC) + oq61_treecover_bv(t,j,potnatveg,type) Biodiversity value for cropland treecover (Mha) +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/61_agroforestry/endo/equations.gms b/modules/61_agroforestry/endo/equations.gms new file mode 100644 index 0000000000..c1cda77e71 --- /dev/null +++ b/modules/61_agroforestry/endo/equations.gms @@ -0,0 +1,55 @@ +*** | (C) 2008-2023 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 + +*' Total agroforestry cost. +*' Cost for bioenergy trees are accounted for in the [30_crop] module. +q61_cost_agroforestry(j2) .. + vm_cost_agroforestry(j2) =e= + v61_cost_treecover_est(j2) + v61_cost_treecover_recur(j2) + - v61_reward_treecover(j2) - v61_reward_betr(j2); + +*' Tree cover establishment cost +q61_cost_treecover_est(j2) .. + v61_cost_treecover_est(j2) =e= + sum(ac_est, v61_treecover(j2,ac_est)) * s61_cost_treecover_est * + sum((cell(i2,j2),ct),pm_interest(ct,i2)/(1+pm_interest(ct,i2))); + +*' Tree cover recurring cost +q61_cost_treecover_recur(j2) .. + v61_cost_treecover_recur(j2) =e= + sum(ac_sub, v61_treecover(j2,ac_sub)) * s61_cost_treecover_recur; + +*' Tree cover reward +q61_reward_treecover(j2) .. + v61_reward_treecover(j2) =e= + sum(ac, v61_treecover(j2,ac)) * i61_reward_treecover; + +*' Bioenergy tree reward +q61_reward_betr(j2) .. + v61_reward_betr(j2) =e= + sum(ac, v61_treecover(j2,ac)) * i61_reward_betr; + +*' Tree cover establishment +q61_treecover_est(j2,ac_est) .. + v61_treecover(j2,ac_est) =e= sum(ac_est2, v61_treecover(j2,ac_est2))/card(ac_est2); + +*' Tree cover area interface +q61_treecover_area(j2) .. + vm_treecover_area(j2) =e= sum(ac, v61_treecover(j2,ac)); + +*' Tree cover carbon stock interface +q61_treecover_carbon(j2,ag_pools,stockType) .. + vm_treecover_carbon(j2,ag_pools,stockType) =e= + m_carbon_stock_ac(v61_treecover,p61_carbon_density_ac,"ac","ac_sub"); + +*' Tree cover biodiversity value +q61_treecover_bv(j2,potnatveg) .. + vm_bv(j2,"crop_tree",potnatveg) =e= + sum(bii_class_secd, sum(ac_to_bii_class_secd(ac,bii_class_secd), v61_treecover(j2,ac)) * + p61_treecover_bii_coeff(bii_class_secd,potnatveg)) * fm_luh2_side_layers(j2,potnatveg); diff --git a/modules/61_agroforestry/endo/input.gms b/modules/61_agroforestry/endo/input.gms new file mode 100644 index 0000000000..f7969d71dd --- /dev/null +++ b/modules/61_agroforestry/endo/input.gms @@ -0,0 +1,18 @@ +*** | (C) 2008-2023 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 + s61_cost_treecover_est Tree cover establishment cost (USD per ha) / 2000 / + s61_cost_treecover_recur Tree cover recurring cost (USD per ha) / 500 / + s61_treecover_plantation Growth curve switch for tree cover on cropland 0=natveg 1=plantations (1) / 0 / + s61_treecover_bii_coeff BII coefficent to be used for tree cover on cropland 0=secondary vegetation 1=timber plantations (1) / 0 / + s61_treecover_decrease Cropland treecover can decrease (1) or not (0) / 0 / + s61_reward_treecover Area reward for cropland treecover (USD per ha) / 5000 / + s61_reward_betr Area reward for bioenergy trees on cropland (USD per ha) / 5000 / + s61_treecover_scenario_start Cropland treecover scenario start year / 2020 / + s61_betr_scenario_start Bioenergy trees scenario start year / 2020 / +; diff --git a/modules/61_agroforestry/endo/not_used.txt b/modules/61_agroforestry/endo/not_used.txt new file mode 100644 index 0000000000..9747c9f19b --- /dev/null +++ b/modules/61_agroforestry/endo/not_used.txt @@ -0,0 +1,3 @@ +name,type,reason +vm_land,input,not used +vm_area,input,not used diff --git a/modules/61_agroforestry/endo/postsolve.gms b/modules/61_agroforestry/endo/postsolve.gms new file mode 100644 index 0000000000..1afb2c367e --- /dev/null +++ b/modules/61_agroforestry/endo/postsolve.gms @@ -0,0 +1,79 @@ +*** | (C) 2008-2023 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 + +pc61_treecover(j,ac) = v61_treecover.l(j,ac); + +*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + ov_cost_agroforestry(t,j,"marginal") = vm_cost_agroforestry.m(j); + ov61_cost_treecover_est(t,j,"marginal") = v61_cost_treecover_est.m(j); + ov61_cost_treecover_recur(t,j,"marginal") = v61_cost_treecover_recur.m(j); + ov61_reward_treecover(t,j,"marginal") = v61_reward_treecover.m(j); + ov61_reward_betr(t,j,"marginal") = v61_reward_betr.m(j); + ov_treecover_area(t,j,"marginal") = vm_treecover_area.m(j); + ov61_treecover(t,j,ac,"marginal") = v61_treecover.m(j,ac); + ov_treecover_carbon(t,j,ag_pools,stockType,"marginal") = vm_treecover_carbon.m(j,ag_pools,stockType); + oq61_cost_agroforestry(t,j,"marginal") = q61_cost_agroforestry.m(j); + oq61_cost_treecover_est(t,j,"marginal") = q61_cost_treecover_est.m(j); + oq61_cost_treecover_recur(t,j,"marginal") = q61_cost_treecover_recur.m(j); + oq61_treecover_area(t,j,"marginal") = q61_treecover_area.m(j); + oq61_reward_treecover(t,j,"marginal") = q61_reward_treecover.m(j); + oq61_reward_betr(t,j,"marginal") = q61_reward_betr.m(j); + oq61_treecover_est(t,j,ac,"marginal") = q61_treecover_est.m(j,ac); + oq61_treecover_carbon(t,j,ag_pools,stockType,"marginal") = q61_treecover_carbon.m(j,ag_pools,stockType); + oq61_treecover_bv(t,j,potnatveg,"marginal") = q61_treecover_bv.m(j,potnatveg); + ov_cost_agroforestry(t,j,"level") = vm_cost_agroforestry.l(j); + ov61_cost_treecover_est(t,j,"level") = v61_cost_treecover_est.l(j); + ov61_cost_treecover_recur(t,j,"level") = v61_cost_treecover_recur.l(j); + ov61_reward_treecover(t,j,"level") = v61_reward_treecover.l(j); + ov61_reward_betr(t,j,"level") = v61_reward_betr.l(j); + ov_treecover_area(t,j,"level") = vm_treecover_area.l(j); + ov61_treecover(t,j,ac,"level") = v61_treecover.l(j,ac); + ov_treecover_carbon(t,j,ag_pools,stockType,"level") = vm_treecover_carbon.l(j,ag_pools,stockType); + oq61_cost_agroforestry(t,j,"level") = q61_cost_agroforestry.l(j); + oq61_cost_treecover_est(t,j,"level") = q61_cost_treecover_est.l(j); + oq61_cost_treecover_recur(t,j,"level") = q61_cost_treecover_recur.l(j); + oq61_treecover_area(t,j,"level") = q61_treecover_area.l(j); + oq61_reward_treecover(t,j,"level") = q61_reward_treecover.l(j); + oq61_reward_betr(t,j,"level") = q61_reward_betr.l(j); + oq61_treecover_est(t,j,ac,"level") = q61_treecover_est.l(j,ac); + oq61_treecover_carbon(t,j,ag_pools,stockType,"level") = q61_treecover_carbon.l(j,ag_pools,stockType); + oq61_treecover_bv(t,j,potnatveg,"level") = q61_treecover_bv.l(j,potnatveg); + ov_cost_agroforestry(t,j,"upper") = vm_cost_agroforestry.up(j); + ov61_cost_treecover_est(t,j,"upper") = v61_cost_treecover_est.up(j); + ov61_cost_treecover_recur(t,j,"upper") = v61_cost_treecover_recur.up(j); + ov61_reward_treecover(t,j,"upper") = v61_reward_treecover.up(j); + ov61_reward_betr(t,j,"upper") = v61_reward_betr.up(j); + ov_treecover_area(t,j,"upper") = vm_treecover_area.up(j); + ov61_treecover(t,j,ac,"upper") = v61_treecover.up(j,ac); + ov_treecover_carbon(t,j,ag_pools,stockType,"upper") = vm_treecover_carbon.up(j,ag_pools,stockType); + oq61_cost_agroforestry(t,j,"upper") = q61_cost_agroforestry.up(j); + oq61_cost_treecover_est(t,j,"upper") = q61_cost_treecover_est.up(j); + oq61_cost_treecover_recur(t,j,"upper") = q61_cost_treecover_recur.up(j); + oq61_treecover_area(t,j,"upper") = q61_treecover_area.up(j); + oq61_reward_treecover(t,j,"upper") = q61_reward_treecover.up(j); + oq61_reward_betr(t,j,"upper") = q61_reward_betr.up(j); + oq61_treecover_est(t,j,ac,"upper") = q61_treecover_est.up(j,ac); + oq61_treecover_carbon(t,j,ag_pools,stockType,"upper") = q61_treecover_carbon.up(j,ag_pools,stockType); + oq61_treecover_bv(t,j,potnatveg,"upper") = q61_treecover_bv.up(j,potnatveg); + ov_cost_agroforestry(t,j,"lower") = vm_cost_agroforestry.lo(j); + ov61_cost_treecover_est(t,j,"lower") = v61_cost_treecover_est.lo(j); + ov61_cost_treecover_recur(t,j,"lower") = v61_cost_treecover_recur.lo(j); + ov61_reward_treecover(t,j,"lower") = v61_reward_treecover.lo(j); + ov61_reward_betr(t,j,"lower") = v61_reward_betr.lo(j); + ov_treecover_area(t,j,"lower") = vm_treecover_area.lo(j); + ov61_treecover(t,j,ac,"lower") = v61_treecover.lo(j,ac); + ov_treecover_carbon(t,j,ag_pools,stockType,"lower") = vm_treecover_carbon.lo(j,ag_pools,stockType); + oq61_cost_agroforestry(t,j,"lower") = q61_cost_agroforestry.lo(j); + oq61_cost_treecover_est(t,j,"lower") = q61_cost_treecover_est.lo(j); + oq61_cost_treecover_recur(t,j,"lower") = q61_cost_treecover_recur.lo(j); + oq61_treecover_area(t,j,"lower") = q61_treecover_area.lo(j); + oq61_reward_treecover(t,j,"lower") = q61_reward_treecover.lo(j); + oq61_reward_betr(t,j,"lower") = q61_reward_betr.lo(j); + oq61_treecover_est(t,j,ac,"lower") = q61_treecover_est.lo(j,ac); + oq61_treecover_carbon(t,j,ag_pools,stockType,"lower") = q61_treecover_carbon.lo(j,ag_pools,stockType); + oq61_treecover_bv(t,j,potnatveg,"lower") = q61_treecover_bv.lo(j,potnatveg); +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/61_agroforestry/endo/preloop.gms b/modules/61_agroforestry/endo/preloop.gms new file mode 100644 index 0000000000..a60e56e0b7 --- /dev/null +++ b/modules/61_agroforestry/endo/preloop.gms @@ -0,0 +1,26 @@ +*** | (C) 2008-2023 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 + +* Initial tree cover on cropland is assumed to be equally distributed among all age-classes +pc61_treecover(j,ac) = (pm_treecover_shr(j)*pm_land_start(j,"crop"))/card(ac); + +*' Switch for tree cover on cropland: +*' 0 = Use natveg growth curve towards LPJmL natural vegetation +*' 1 = Use plantation growth curve (faster than natveg) towards LPJmL natural vegetation +if(s61_treecover_plantation = 0, + p61_carbon_density_ac(t,j,ac,ag_pools) = pm_carbon_density_ac(t,j,ac,ag_pools); +elseif s61_treecover_plantation = 1, + p61_carbon_density_ac(t,j,ac,ag_pools) = pm_carbon_density_ac_forestry(t,j,ac,ag_pools); +); + +** set bii coefficients +p61_treecover_bii_coeff(bii_class_secd,potnatveg) = 0; +if(s61_treecover_bii_coeff = 0, + p61_treecover_bii_coeff(bii_class_secd,potnatveg) = fm_bii_coeff(bii_class_secd,potnatveg) +elseif s61_treecover_bii_coeff = 1, + p61_treecover_bii_coeff(bii_class_secd,potnatveg) = fm_bii_coeff("timber",potnatveg) +); diff --git a/modules/61_agroforestry/endo/presolve.gms b/modules/61_agroforestry/endo/presolve.gms new file mode 100644 index 0000000000..f123728309 --- /dev/null +++ b/modules/61_agroforestry/endo/presolve.gms @@ -0,0 +1,34 @@ +*** | (C) 2008-2023 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 + +* Growth of trees on cropland is modelled by shifting age-classes according to time step length. +s61_shift = m_timestep_length_forestry/5; +* example: ac10 in t = ac5 (ac10-1) in t-1 for a 5 yr time step (s61_shift = 1) + p61_treecover(t,j,ac)$(ord(ac) > s61_shift) = pc61_treecover(j,ac-s61_shift); +* account for cases at the end of the age class set (s61_shift > 1) which are not shifted by the above calculation + p61_treecover(t,j,"acx") = p61_treecover(t,j,"acx") + + sum(ac$(ord(ac) > card(ac)-s61_shift), pc61_treecover(j,ac)); + +pc61_treecover(j,ac) = p61_treecover(t,j,ac); +v61_treecover.l(j,ac) = p61_treecover(t,j,ac); + +if(m_year(t) <= s61_treecover_scenario_start, + v61_treecover.fx(j,ac) = pc61_treecover(j,ac); + i61_reward_treecover = 0; + i61_reward_betr = 0; +else + i61_reward_treecover = s61_reward_treecover; + i61_reward_betr = s61_reward_betr; + v61_treecover.lo(j,ac_est) = 0; + v61_treecover.up(j,ac_est) = Inf; + if(s61_treecover_decrease = 1, + v61_treecover.lo(j,ac_sub) = 0; + v61_treecover.up(j,ac_sub) = pc61_treecover(j,ac_sub); + else + v61_treecover.fx(j,ac_sub) = pc61_treecover(j,ac_sub); + ); +); diff --git a/modules/61_agroforestry/endo/realization.gms b/modules/61_agroforestry/endo/realization.gms new file mode 100644 index 0000000000..7f22f40dff --- /dev/null +++ b/modules/61_agroforestry/endo/realization.gms @@ -0,0 +1,21 @@ +*** | (C) 2008-2023 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 In this realization, future shares of tree cover and bioenergy trees +*' on cropland at cluster level follow exogenous assumptions. +*' @stop +*' +*' @limitations There are currently no known limitations of this realization. + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "declarations" $include "./modules/61_agroforestry/endo/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/61_agroforestry/endo/input.gms" +$Ifi "%phase%" == "equations" $include "./modules/61_agroforestry/endo/equations.gms" +$Ifi "%phase%" == "preloop" $include "./modules/61_agroforestry/endo/preloop.gms" +$Ifi "%phase%" == "presolve" $include "./modules/61_agroforestry/endo/presolve.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/61_agroforestry/endo/postsolve.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/61_agroforestry/exo/declarations.gms b/modules/61_agroforestry/exo/declarations.gms new file mode 100644 index 0000000000..0262c0e59e --- /dev/null +++ b/modules/61_agroforestry/exo/declarations.gms @@ -0,0 +1,65 @@ +*** | (C) 2008-2023 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 + s61_shift number of 5-year age-classes corresponding to current time step length (1) +; + +parameters + p61_treecover_min_shr(t,j) Minimum share of treecover on cropland (1) + p61_betr_min_shr(t,j) Minimum share of bioenergy trees on cropland (1) + p61_treecover_scenario_fader(t_all) Cropland treecover scenario fader (1) + p61_betr_scenario_fader(t_all) Bioenergy trees scenario fader (1) + p61_treecover_bii_coeff(bii_class_secd,potnatveg) BII coefficient for cropland treecover (1) + p61_carbon_density_ac(t,j,ac,ag_pools) Carbon density for ac and ag_pools (tC per ha) + p61_treecover(t,j,ac) Cropland tree cover per age class (mio. ha) + pc61_treecover(j,ac) Cropland tree cover per age class in current time step (mio. ha) +; + +equations + q61_cost_agroforestry(j) Costs and benefits related to agroforestry (mio. USD05MER per yr) + q61_cost_treecover_est(j) Establishment cost for cropland tree cover (mio. USD05MER per yr) + q61_cost_treecover_recur(j) Recurring cost for cropland tree cover (mio. USD05MER per yr) + q61_treecover_area(j) Cropland treecover interface (mio. ha) + q61_treecover_shr(j) Cropland treecover minimum share (mio. ha) + q61_betr_shr(j) Bioenergy trees minimum share (mio. ha) + q61_treecover_est(j,ac) Cropland treecover establishment (mio. ha) + q61_treecover_carbon(j,ag_pools,stockType) Cropland tree cover above ground carbon content (mio. tC) + q61_treecover_bv(j,potnatveg) Biodiversity value for cropland treecover (Mha) +; + +variables + vm_cost_agroforestry(j) Cost and rewards related to agroforestry (mio. USD05MER per yr) +; + +positive variables + v61_cost_treecover_est(j) Establishment cost for cropland tree cover (mio. USD05MER per yr) + v61_cost_treecover_recur(j) Recurring cost for cropland tree cover (mio. USD05MER per yr) + vm_treecover_area(j) Cropland tree cover (mio. ha) + v61_treecover(j,ac) Cropland tree cover per age class (mio. ha) + vm_treecover_carbon(j,ag_pools,stockType) Cropland tree cover above ground carbon content (mio. tC) +; + +*#################### R SECTION START (OUTPUT DECLARATIONS) #################### +parameters + ov_cost_agroforestry(t,j,type) Cost and rewards related to agroforestry (mio. USD05MER per yr) + ov61_cost_treecover_est(t,j,type) Establishment cost for cropland tree cover (mio. USD05MER per yr) + ov61_cost_treecover_recur(t,j,type) Recurring cost for cropland tree cover (mio. USD05MER per yr) + ov_treecover_area(t,j,type) Cropland tree cover (mio. ha) + ov61_treecover(t,j,ac,type) Cropland tree cover per age class (mio. ha) + ov_treecover_carbon(t,j,ag_pools,stockType,type) Cropland tree cover above ground carbon content (mio. tC) + oq61_cost_agroforestry(t,j,type) Costs and benefits related to agroforestry (mio. USD05MER per yr) + oq61_cost_treecover_est(t,j,type) Establishment cost for cropland tree cover (mio. USD05MER per yr) + oq61_cost_treecover_recur(t,j,type) Recurring cost for cropland tree cover (mio. USD05MER per yr) + oq61_treecover_area(t,j,type) Cropland treecover interface (mio. ha) + oq61_treecover_shr(t,j,type) Cropland treecover minimum share (mio. ha) + oq61_betr_shr(t,j,type) Bioenergy trees minimum share (mio. ha) + oq61_treecover_est(t,j,ac,type) Cropland treecover establishment (mio. ha) + oq61_treecover_carbon(t,j,ag_pools,stockType,type) Cropland tree cover above ground carbon content (mio. tC) + oq61_treecover_bv(t,j,potnatveg,type) Biodiversity value for cropland treecover (Mha) +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/61_agroforestry/exo/equations.gms b/modules/61_agroforestry/exo/equations.gms new file mode 100644 index 0000000000..6a052bea65 --- /dev/null +++ b/modules/61_agroforestry/exo/equations.gms @@ -0,0 +1,54 @@ +*** | (C) 2008-2023 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 + +*' Total agroforestry cost. +*' Cost for bioenergy trees are accounted for in the [30_crop] module. +q61_cost_agroforestry(j2) .. + vm_cost_agroforestry(j2) =e= + v61_cost_treecover_est(j2) + v61_cost_treecover_recur(j2); + +*' Tree cover establishment cost +q61_cost_treecover_est(j2) .. + v61_cost_treecover_est(j2) =e= + sum(ac_est, v61_treecover(j2,ac_est)) * s61_cost_treecover_est * + sum((cell(i2,j2),ct),pm_interest(ct,i2)/(1+pm_interest(ct,i2))); + +*' Tree cover recurring cost +q61_cost_treecover_recur(j2) .. + v61_cost_treecover_recur(j2) =e= + sum(ac_sub, v61_treecover(j2,ac_sub)) * s61_cost_treecover_recur; + +*' Tree cover minimum share +q61_treecover_shr(j2) .. + sum(ac, v61_treecover(j2,ac)) =g= + sum(ct, p61_treecover_min_shr(ct,j2)) * vm_land(j2,"crop"); + +*' Bioenergy tree minimum share +q61_betr_shr(j2) .. + sum(w, vm_area(j2,"betr",w)) =g= + sum(ct, p61_betr_min_shr(ct,j2)) * vm_land(j2,"crop"); + +*' Tree cover establishment +q61_treecover_est(j2,ac_est) .. + v61_treecover(j2,ac_est) =e= sum(ac_est2, v61_treecover(j2,ac_est2))/card(ac_est2); + +*' Tree cover area interface +q61_treecover_area(j2) .. + vm_treecover_area(j2) =e= sum(ac, v61_treecover(j2,ac)); + +*' Tree cover carbon stock interface +q61_treecover_carbon(j2,ag_pools,stockType) .. + vm_treecover_carbon(j2,ag_pools,stockType) =e= + m_carbon_stock_ac(v61_treecover,p61_carbon_density_ac,"ac","ac_sub"); + +*' Tree cover biodiversity value +q61_treecover_bv(j2,potnatveg) .. + vm_bv(j2,"crop_tree",potnatveg) =e= + sum(bii_class_secd, sum(ac_to_bii_class_secd(ac,bii_class_secd), v61_treecover(j2,ac)) * + p61_treecover_bii_coeff(bii_class_secd,potnatveg)) * fm_luh2_side_layers(j2,potnatveg); diff --git a/modules/61_agroforestry/exo/input.gms b/modules/61_agroforestry/exo/input.gms new file mode 100644 index 0000000000..8d198c6bd0 --- /dev/null +++ b/modules/61_agroforestry/exo/input.gms @@ -0,0 +1,20 @@ +*** | (C) 2008-2023 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 + s61_cost_treecover_est Tree cover establishment cost (USD per ha) / 2000 / + s61_cost_treecover_recur Tree cover recurring cost (USD per ha) / 500 / + s61_treecover_plantation Growth curve switch for tree cover on cropland 0=natveg 1=plantations (1) / 0 / + s61_treecover_bii_coeff BII coefficent to be used for tree cover on cropland 0=secondary vegetation 1=timber plantations (1) / 0 / + s61_treecover_decrease Cropland treecover can decrease (1) or not (0) / 0 / + s61_treecover_scenario_start Cropland treecover scenario start year / 2020 / + s61_treecover_scenario_target Cropland treecover scenario target year / 2050 / + s61_treecover_min_shr Share of treecover on cropland (1) / 0.2 / + s61_betr_scenario_start Bioenergy trees scenario start year / 2020 / + s61_betr_scenario_target Bioenergy trees scenario target year / 2050 / + s61_betr_min_shr Minimum share of bioenergy trees on cropland (1) / 0 / +; diff --git a/modules/61_agroforestry/exo/postsolve.gms b/modules/61_agroforestry/exo/postsolve.gms new file mode 100644 index 0000000000..557cf4f306 --- /dev/null +++ b/modules/61_agroforestry/exo/postsolve.gms @@ -0,0 +1,71 @@ +*** | (C) 2008-2023 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 + +pc61_treecover(j,ac) = v61_treecover.l(j,ac); + +*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + ov_cost_agroforestry(t,j,"marginal") = vm_cost_agroforestry.m(j); + ov61_cost_treecover_est(t,j,"marginal") = v61_cost_treecover_est.m(j); + ov61_cost_treecover_recur(t,j,"marginal") = v61_cost_treecover_recur.m(j); + ov_treecover_area(t,j,"marginal") = vm_treecover_area.m(j); + ov61_treecover(t,j,ac,"marginal") = v61_treecover.m(j,ac); + ov_treecover_carbon(t,j,ag_pools,stockType,"marginal") = vm_treecover_carbon.m(j,ag_pools,stockType); + oq61_cost_agroforestry(t,j,"marginal") = q61_cost_agroforestry.m(j); + oq61_cost_treecover_est(t,j,"marginal") = q61_cost_treecover_est.m(j); + oq61_cost_treecover_recur(t,j,"marginal") = q61_cost_treecover_recur.m(j); + oq61_treecover_area(t,j,"marginal") = q61_treecover_area.m(j); + oq61_treecover_shr(t,j,"marginal") = q61_treecover_shr.m(j); + oq61_betr_shr(t,j,"marginal") = q61_betr_shr.m(j); + oq61_treecover_est(t,j,ac,"marginal") = q61_treecover_est.m(j,ac); + oq61_treecover_carbon(t,j,ag_pools,stockType,"marginal") = q61_treecover_carbon.m(j,ag_pools,stockType); + oq61_treecover_bv(t,j,potnatveg,"marginal") = q61_treecover_bv.m(j,potnatveg); + ov_cost_agroforestry(t,j,"level") = vm_cost_agroforestry.l(j); + ov61_cost_treecover_est(t,j,"level") = v61_cost_treecover_est.l(j); + ov61_cost_treecover_recur(t,j,"level") = v61_cost_treecover_recur.l(j); + ov_treecover_area(t,j,"level") = vm_treecover_area.l(j); + ov61_treecover(t,j,ac,"level") = v61_treecover.l(j,ac); + ov_treecover_carbon(t,j,ag_pools,stockType,"level") = vm_treecover_carbon.l(j,ag_pools,stockType); + oq61_cost_agroforestry(t,j,"level") = q61_cost_agroforestry.l(j); + oq61_cost_treecover_est(t,j,"level") = q61_cost_treecover_est.l(j); + oq61_cost_treecover_recur(t,j,"level") = q61_cost_treecover_recur.l(j); + oq61_treecover_area(t,j,"level") = q61_treecover_area.l(j); + oq61_treecover_shr(t,j,"level") = q61_treecover_shr.l(j); + oq61_betr_shr(t,j,"level") = q61_betr_shr.l(j); + oq61_treecover_est(t,j,ac,"level") = q61_treecover_est.l(j,ac); + oq61_treecover_carbon(t,j,ag_pools,stockType,"level") = q61_treecover_carbon.l(j,ag_pools,stockType); + oq61_treecover_bv(t,j,potnatveg,"level") = q61_treecover_bv.l(j,potnatveg); + ov_cost_agroforestry(t,j,"upper") = vm_cost_agroforestry.up(j); + ov61_cost_treecover_est(t,j,"upper") = v61_cost_treecover_est.up(j); + ov61_cost_treecover_recur(t,j,"upper") = v61_cost_treecover_recur.up(j); + ov_treecover_area(t,j,"upper") = vm_treecover_area.up(j); + ov61_treecover(t,j,ac,"upper") = v61_treecover.up(j,ac); + ov_treecover_carbon(t,j,ag_pools,stockType,"upper") = vm_treecover_carbon.up(j,ag_pools,stockType); + oq61_cost_agroforestry(t,j,"upper") = q61_cost_agroforestry.up(j); + oq61_cost_treecover_est(t,j,"upper") = q61_cost_treecover_est.up(j); + oq61_cost_treecover_recur(t,j,"upper") = q61_cost_treecover_recur.up(j); + oq61_treecover_area(t,j,"upper") = q61_treecover_area.up(j); + oq61_treecover_shr(t,j,"upper") = q61_treecover_shr.up(j); + oq61_betr_shr(t,j,"upper") = q61_betr_shr.up(j); + oq61_treecover_est(t,j,ac,"upper") = q61_treecover_est.up(j,ac); + oq61_treecover_carbon(t,j,ag_pools,stockType,"upper") = q61_treecover_carbon.up(j,ag_pools,stockType); + oq61_treecover_bv(t,j,potnatveg,"upper") = q61_treecover_bv.up(j,potnatveg); + ov_cost_agroforestry(t,j,"lower") = vm_cost_agroforestry.lo(j); + ov61_cost_treecover_est(t,j,"lower") = v61_cost_treecover_est.lo(j); + ov61_cost_treecover_recur(t,j,"lower") = v61_cost_treecover_recur.lo(j); + ov_treecover_area(t,j,"lower") = vm_treecover_area.lo(j); + ov61_treecover(t,j,ac,"lower") = v61_treecover.lo(j,ac); + ov_treecover_carbon(t,j,ag_pools,stockType,"lower") = vm_treecover_carbon.lo(j,ag_pools,stockType); + oq61_cost_agroforestry(t,j,"lower") = q61_cost_agroforestry.lo(j); + oq61_cost_treecover_est(t,j,"lower") = q61_cost_treecover_est.lo(j); + oq61_cost_treecover_recur(t,j,"lower") = q61_cost_treecover_recur.lo(j); + oq61_treecover_area(t,j,"lower") = q61_treecover_area.lo(j); + oq61_treecover_shr(t,j,"lower") = q61_treecover_shr.lo(j); + oq61_betr_shr(t,j,"lower") = q61_betr_shr.lo(j); + oq61_treecover_est(t,j,ac,"lower") = q61_treecover_est.lo(j,ac); + oq61_treecover_carbon(t,j,ag_pools,stockType,"lower") = q61_treecover_carbon.lo(j,ag_pools,stockType); + oq61_treecover_bv(t,j,potnatveg,"lower") = q61_treecover_bv.lo(j,potnatveg); +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/61_agroforestry/exo/preloop.gms b/modules/61_agroforestry/exo/preloop.gms new file mode 100644 index 0000000000..382d670b01 --- /dev/null +++ b/modules/61_agroforestry/exo/preloop.gms @@ -0,0 +1,29 @@ +*** | (C) 2008-2023 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 + +m_sigmoid_time_interpol(p61_treecover_scenario_fader,s61_treecover_scenario_start,s61_treecover_scenario_target,0,1); +m_sigmoid_time_interpol(p61_betr_scenario_fader,s61_betr_scenario_start,s61_betr_scenario_target,0,1); + +* Initial tree cover on cropland is assumed to be equally distributed among all age-classes +pc61_treecover(j,ac) = (pm_treecover_shr(j)*pm_land_start(j,"crop"))/card(ac); + +*' Switch for tree cover on cropland: +*' 0 = Use natveg growth curve towards LPJmL natural vegetation +*' 1 = Use plantation growth curve (faster than natveg) towards LPJmL natural vegetation +if(s61_treecover_plantation = 0, + p61_carbon_density_ac(t,j,ac,ag_pools) = pm_carbon_density_ac(t,j,ac,ag_pools); +elseif s61_treecover_plantation = 1, + p61_carbon_density_ac(t,j,ac,ag_pools) = pm_carbon_density_ac_forestry(t,j,ac,ag_pools); +); + +** set bii coefficients +p61_treecover_bii_coeff(bii_class_secd,potnatveg) = 0; +if(s61_treecover_bii_coeff = 0, + p61_treecover_bii_coeff(bii_class_secd,potnatveg) = fm_bii_coeff(bii_class_secd,potnatveg) +elseif s61_treecover_bii_coeff = 1, + p61_treecover_bii_coeff(bii_class_secd,potnatveg) = fm_bii_coeff("timber",potnatveg) +); diff --git a/modules/61_agroforestry/exo/presolve.gms b/modules/61_agroforestry/exo/presolve.gms new file mode 100644 index 0000000000..40d24e22ea --- /dev/null +++ b/modules/61_agroforestry/exo/presolve.gms @@ -0,0 +1,36 @@ +*** | (C) 2008-2023 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 + +* Growth of trees on cropland is modelled by shifting age-classes according to time step length. +s61_shift = m_timestep_length_forestry/5; +* example: ac10 in t = ac5 (ac10-1) in t-1 for a 5 yr time step (s61_shift = 1) + p61_treecover(t,j,ac)$(ord(ac) > s61_shift) = pc61_treecover(j,ac-s61_shift); +* account for cases at the end of the age class set (s61_shift > 1) which are not shifted by the above calculation + p61_treecover(t,j,"acx") = p61_treecover(t,j,"acx") + + sum(ac$(ord(ac) > card(ac)-s61_shift), pc61_treecover(j,ac)); + +pc61_treecover(j,ac) = p61_treecover(t,j,ac); +v61_treecover.l(j,ac) = p61_treecover(t,j,ac); + +if(m_year(t) <= s61_treecover_scenario_start, + v61_treecover.fx(j,ac) = pc61_treecover(j,ac); +else + v61_treecover.lo(j,ac_est) = 0; + v61_treecover.up(j,ac_est) = Inf; + if(s61_treecover_decrease = 1, + v61_treecover.lo(j,ac_sub) = 0; + v61_treecover.up(j,ac_sub) = pc61_treecover(j,ac_sub); + else + v61_treecover.fx(j,ac_sub) = pc61_treecover(j,ac_sub); + ); +); + +p61_treecover_min_shr(t,j) = + ((1-p61_treecover_scenario_fader(t)) * pm_treecover_shr(j)) + + (p61_treecover_scenario_fader(t) * s61_treecover_min_shr); + +p61_betr_min_shr(t,j) = p61_betr_scenario_fader(t) * s61_betr_min_shr; diff --git a/modules/61_agroforestry/exo/realization.gms b/modules/61_agroforestry/exo/realization.gms new file mode 100644 index 0000000000..09b54d0aa4 --- /dev/null +++ b/modules/61_agroforestry/exo/realization.gms @@ -0,0 +1,21 @@ +*** | (C) 2008-2023 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 In this realization, future shares of tree cover and bioenergy trees +*' on cropland at cluster level follow exogenous assumptions. +*' @stop +*' +*' @limitations There are currently no known limitations of this realization. + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "declarations" $include "./modules/61_agroforestry/exo/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/61_agroforestry/exo/input.gms" +$Ifi "%phase%" == "equations" $include "./modules/61_agroforestry/exo/equations.gms" +$Ifi "%phase%" == "preloop" $include "./modules/61_agroforestry/exo/preloop.gms" +$Ifi "%phase%" == "presolve" $include "./modules/61_agroforestry/exo/presolve.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/61_agroforestry/exo/postsolve.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/61_agroforestry/module.gms b/modules/61_agroforestry/module.gms new file mode 100644 index 0000000000..a1f82ca32e --- /dev/null +++ b/modules/61_agroforestry/module.gms @@ -0,0 +1,22 @@ +*** | (C) 2008-2023 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 + +*' @title Agroforestry +*' +*' @description The purpose of the agroforestry module is to model different agroforestry +*' systems such as bioenergy trees and tree cover on cropland (hedgerows). +*' The agroforestry module interacts via the interfaces $vm\_area$ and $vm\_land$ with +*' the [30_crop] module. Furthermore, the agroforestry module provides cropland tree cover +*' ($vm\_treecover\_area$) and corresponding carbon stocks $vm\_treecover\_carbon$ to the [30_crop] module. +*' +*' @authors Florian Humpenöder + +*###################### R SECTION START (MODULETYPES) ########################## +$Ifi "%agroforestry%" == "endo" $include "./modules/61_agroforestry/endo/realization.gms" +$Ifi "%agroforestry%" == "exo" $include "./modules/61_agroforestry/exo/realization.gms" +$Ifi "%agroforestry%" == "off" $include "./modules/61_agroforestry/off/realization.gms" +*###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/61_agroforestry/off/declarations.gms b/modules/61_agroforestry/off/declarations.gms new file mode 100644 index 0000000000..c60ff969c2 --- /dev/null +++ b/modules/61_agroforestry/off/declarations.gms @@ -0,0 +1,25 @@ +*** | (C) 2008-2023 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 + +variables + vm_cost_agroforestry(j) Cost and rewards related to agroforestry (mio. USD05MER per yr) +; + +positive variables + vm_treecover_area(j) Cropland tree cover (mio. ha) + vm_treecover_carbon(j,ag_pools,stockType) Cropland tree cover above ground carbon content (mio. tC) +; + + +*#################### R SECTION START (OUTPUT DECLARATIONS) #################### +parameters + ov_cost_agroforestry(t,j,type) Cost and rewards related to agroforestry (mio. USD05MER per yr) + ov_treecover_area(t,j,type) Cropland tree cover (mio. ha) + ov_treecover_carbon(t,j,ag_pools,stockType,type) Cropland tree cover above ground carbon content (mio. tC) +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### + diff --git a/modules/61_agroforestry/off/not_used.txt b/modules/61_agroforestry/off/not_used.txt new file mode 100644 index 0000000000..2162d9dc96 --- /dev/null +++ b/modules/61_agroforestry/off/not_used.txt @@ -0,0 +1,10 @@ +name,type,reason +vm_land, input, not used +pm_interest, input, not used +pm_land_start,input,not used +pm_treecover_shr,input,not used +fm_luh2_side_layers,input,not used +vm_area,input,not used +fm_bii_coeff,input,not used +pm_carbon_density_ac,input,not used +pm_carbon_density_ac_forestry,input,not used diff --git a/modules/61_agroforestry/off/postsolve.gms b/modules/61_agroforestry/off/postsolve.gms new file mode 100644 index 0000000000..2f4f4d4362 --- /dev/null +++ b/modules/61_agroforestry/off/postsolve.gms @@ -0,0 +1,22 @@ +*** | (C) 2008-2023 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 + +*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + ov_cost_agroforestry(t,j,"marginal") = vm_cost_agroforestry.m(j); + ov_treecover_area(t,j,"marginal") = vm_treecover_area.m(j); + ov_treecover_carbon(t,j,ag_pools,stockType,"marginal") = vm_treecover_carbon.m(j,ag_pools,stockType); + ov_cost_agroforestry(t,j,"level") = vm_cost_agroforestry.l(j); + ov_treecover_area(t,j,"level") = vm_treecover_area.l(j); + ov_treecover_carbon(t,j,ag_pools,stockType,"level") = vm_treecover_carbon.l(j,ag_pools,stockType); + ov_cost_agroforestry(t,j,"upper") = vm_cost_agroforestry.up(j); + ov_treecover_area(t,j,"upper") = vm_treecover_area.up(j); + ov_treecover_carbon(t,j,ag_pools,stockType,"upper") = vm_treecover_carbon.up(j,ag_pools,stockType); + ov_cost_agroforestry(t,j,"lower") = vm_cost_agroforestry.lo(j); + ov_treecover_area(t,j,"lower") = vm_treecover_area.lo(j); + ov_treecover_carbon(t,j,ag_pools,stockType,"lower") = vm_treecover_carbon.lo(j,ag_pools,stockType); +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### + diff --git a/modules/61_agroforestry/off/preloop.gms b/modules/61_agroforestry/off/preloop.gms new file mode 100644 index 0000000000..a03dad3015 --- /dev/null +++ b/modules/61_agroforestry/off/preloop.gms @@ -0,0 +1,11 @@ +*** | (C) 2008-2023 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_cost_agroforestry.fx(j) = 0; +vm_treecover_area.fx(j) = 0; +vm_treecover_carbon.fx(j,ag_pools,stockType) = 0; +vm_bv(j,"crop_tree",potnatveg) = 0; diff --git a/modules/61_agroforestry/off/realization.gms b/modules/61_agroforestry/off/realization.gms new file mode 100644 index 0000000000..58dab000af --- /dev/null +++ b/modules/61_agroforestry/off/realization.gms @@ -0,0 +1,17 @@ +*** | (C) 2008-2023 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 In this realization, agroforestry does not exist. Therefore, +*' cropland tree cover and corresponding carbon stocks are fixed to zero. + +*' @limitations Cropland tree cover and corresponding carbon stocks are fixed to zero. + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "declarations" $include "./modules/61_agroforestry/off/declarations.gms" +$Ifi "%phase%" == "preloop" $include "./modules/61_agroforestry/off/preloop.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/61_agroforestry/off/postsolve.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/include.gms b/modules/include.gms index 0729ba1b54..bfac547e0a 100644 --- a/modules/include.gms +++ b/modules/include.gms @@ -49,6 +49,7 @@ $include "./modules/57_maccs/module.gms" $include "./modules/58_peatland/module.gms" $include "./modules/59_som/module.gms" $include "./modules/60_bioenergy/module.gms" +$include "./modules/61_agroforestry/module.gms" $include "./modules/62_material/module.gms" $include "./modules/70_livestock/module.gms" $include "./modules/71_disagg_lvst/module.gms" From 39738dfd09919cab210d30e54e25a4be006da619 Mon Sep 17 00:00:00 2001 From: florianh Date: Wed, 13 Mar 2024 12:34:52 +0100 Subject: [PATCH 005/133] missing code --- main.gms | 1 + 1 file changed, 1 insertion(+) diff --git a/main.gms b/main.gms index a758d51937..c6770fc572 100644 --- a/main.gms +++ b/main.gms @@ -281,6 +281,7 @@ $setglobal peatland v2 $setglobal som static_jan19 $setglobal bioenergy 1stgen_priced_dec18 +$setglobal agroforestry exo $setglobal material exo_flexreg_apr16 $setglobal livestock fbask_jan16 From 41cdffe1cc87448c5193b9530aef263d5617597f Mon Sep 17 00:00:00 2001 From: florianh Date: Wed, 13 Mar 2024 15:07:26 +0100 Subject: [PATCH 006/133] bugfix --- modules/61_agroforestry/endo/equations.gms | 2 +- modules/61_agroforestry/endo/input.gms | 4 ++-- modules/61_agroforestry/endo/not_used.txt | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/modules/61_agroforestry/endo/equations.gms b/modules/61_agroforestry/endo/equations.gms index c1cda77e71..6a4d138b1d 100644 --- a/modules/61_agroforestry/endo/equations.gms +++ b/modules/61_agroforestry/endo/equations.gms @@ -33,7 +33,7 @@ q61_reward_treecover(j2) .. *' Bioenergy tree reward q61_reward_betr(j2) .. v61_reward_betr(j2) =e= - sum(ac, v61_treecover(j2,ac)) * i61_reward_betr; + sum(w, vm_area(j2,"betr",w)) * i61_reward_betr; *' Tree cover establishment q61_treecover_est(j2,ac_est) .. diff --git a/modules/61_agroforestry/endo/input.gms b/modules/61_agroforestry/endo/input.gms index f7969d71dd..875fb470ad 100644 --- a/modules/61_agroforestry/endo/input.gms +++ b/modules/61_agroforestry/endo/input.gms @@ -11,8 +11,8 @@ scalars s61_treecover_plantation Growth curve switch for tree cover on cropland 0=natveg 1=plantations (1) / 0 / s61_treecover_bii_coeff BII coefficent to be used for tree cover on cropland 0=secondary vegetation 1=timber plantations (1) / 0 / s61_treecover_decrease Cropland treecover can decrease (1) or not (0) / 0 / - s61_reward_treecover Area reward for cropland treecover (USD per ha) / 5000 / - s61_reward_betr Area reward for bioenergy trees on cropland (USD per ha) / 5000 / + s61_reward_treecover Area reward for cropland treecover (USD per ha) / 250 / + s61_reward_betr Area reward for bioenergy trees on cropland (USD per ha) / 250 / s61_treecover_scenario_start Cropland treecover scenario start year / 2020 / s61_betr_scenario_start Bioenergy trees scenario start year / 2020 / ; diff --git a/modules/61_agroforestry/endo/not_used.txt b/modules/61_agroforestry/endo/not_used.txt index 9747c9f19b..c3c4a63e3d 100644 --- a/modules/61_agroforestry/endo/not_used.txt +++ b/modules/61_agroforestry/endo/not_used.txt @@ -1,3 +1,2 @@ name,type,reason vm_land,input,not used -vm_area,input,not used From 6725072f545d65a52be3c2cea31e62e39e7c4a4b Mon Sep 17 00:00:00 2001 From: florianh Date: Fri, 15 Mar 2024 10:12:53 +0100 Subject: [PATCH 007/133] bugfix --- main.gms | 2 +- modules/61_agroforestry/endo/input.gms | 4 ++-- modules/61_agroforestry/off/preloop.gms | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/main.gms b/main.gms index c6770fc572..2058df4375 100644 --- a/main.gms +++ b/main.gms @@ -281,7 +281,7 @@ $setglobal peatland v2 $setglobal som static_jan19 $setglobal bioenergy 1stgen_priced_dec18 -$setglobal agroforestry exo +$setglobal agroforestry off $setglobal material exo_flexreg_apr16 $setglobal livestock fbask_jan16 diff --git a/modules/61_agroforestry/endo/input.gms b/modules/61_agroforestry/endo/input.gms index 875fb470ad..b9aa3f15e0 100644 --- a/modules/61_agroforestry/endo/input.gms +++ b/modules/61_agroforestry/endo/input.gms @@ -11,8 +11,8 @@ scalars s61_treecover_plantation Growth curve switch for tree cover on cropland 0=natveg 1=plantations (1) / 0 / s61_treecover_bii_coeff BII coefficent to be used for tree cover on cropland 0=secondary vegetation 1=timber plantations (1) / 0 / s61_treecover_decrease Cropland treecover can decrease (1) or not (0) / 0 / - s61_reward_treecover Area reward for cropland treecover (USD per ha) / 250 / - s61_reward_betr Area reward for bioenergy trees on cropland (USD per ha) / 250 / + s61_reward_treecover Area reward for cropland treecover (USD per ha) / 0 / + s61_reward_betr Area reward for bioenergy trees on cropland (USD per ha) / 0 / s61_treecover_scenario_start Cropland treecover scenario start year / 2020 / s61_betr_scenario_start Bioenergy trees scenario start year / 2020 / ; diff --git a/modules/61_agroforestry/off/preloop.gms b/modules/61_agroforestry/off/preloop.gms index a03dad3015..46c7e61bb3 100644 --- a/modules/61_agroforestry/off/preloop.gms +++ b/modules/61_agroforestry/off/preloop.gms @@ -8,4 +8,4 @@ vm_cost_agroforestry.fx(j) = 0; vm_treecover_area.fx(j) = 0; vm_treecover_carbon.fx(j,ag_pools,stockType) = 0; -vm_bv(j,"crop_tree",potnatveg) = 0; +vm_bv.fx(j,"crop_tree",potnatveg) = 0; From d2e21cea412d44d02dce4908c65dc17780758d9d Mon Sep 17 00:00:00 2001 From: florianh Date: Thu, 11 Apr 2024 13:43:56 +0200 Subject: [PATCH 008/133] partial commit to save work --- config/default.cfg | 11 ++- .../10_land/landmatrix_dec18/declarations.gms | 1 + modules/10_land/landmatrix_dec18/input.gms | 10 -- modules/10_land/landmatrix_dec18/start.gms | 5 +- .../feb21/declarations.gms | 0 .../feb21/input.gms | 4 +- .../feb21/preloop.gms | 4 +- .../feb21/presolve.gms | 0 .../feb21/realization.gms | 10 +- .../feb21/sets.gms | 0 .../{29_ageclass => 28_ageclass}/input/files | 0 .../{29_ageclass => 28_ageclass}/module.gms | 2 +- modules/29_cropland/input/files | 8 ++ modules/29_cropland/module.gms | 18 ++++ .../29_cropland/rulebased/declarations.gms | 52 +++++++++++ modules/29_cropland/rulebased/equations.gms | 91 +++++++++++++++++++ modules/29_cropland/rulebased/input.gms | 52 +++++++++++ modules/29_cropland/rulebased/postsolve.gms | 8 ++ modules/29_cropland/rulebased/preloop.gms | 52 +++++++++++ modules/29_cropland/rulebased/presolve.gms | 61 +++++++++++++ modules/29_cropland/rulebased/realization.gms | 18 ++++ modules/29_cropland/rulebased/sets.gms | 19 ++++ modules/30_crop/endo_apr21/declarations.gms | 22 +---- modules/30_crop/endo_apr21/equations.gms | 66 +++++--------- modules/30_crop/endo_apr21/input.gms | 23 ----- modules/30_crop/endo_apr21/preloop.gms | 13 --- modules/30_crop/endo_apr21/presolve.gms | 27 +----- modules/30_crop/endo_apr21/sets.gms | 9 -- .../30_crop/penalty_apr22/declarations.gms | 17 +--- modules/30_crop/penalty_apr22/equations.gms | 55 ++--------- modules/30_crop/penalty_apr22/preloop.gms | 14 --- modules/30_crop/penalty_apr22/presolve.gms | 24 ----- modules/30_crop/penalty_apr22/sets.gms | 8 -- .../30_crop/rotation_apr22/declarations.gms | 17 +--- modules/30_crop/rotation_apr22/equations.gms | 46 +--------- modules/30_crop/rotation_apr22/preloop.gms | 13 --- modules/30_crop/rotation_apr22/presolve.gms | 23 ----- modules/30_crop/rotation_apr22/sets.gms | 8 -- modules/61_agroforestry/exo/input.gms | 13 --- modules/61_agroforestry/exo/postsolve.gms | 1 - modules/61_agroforestry/exo/preloop.gms | 21 ----- modules/61_agroforestry/exo/presolve.gms | 29 ------ modules/include.gms | 2 +- 43 files changed, 444 insertions(+), 433 deletions(-) rename modules/{29_ageclass => 28_ageclass}/feb21/declarations.gms (100%) rename modules/{29_ageclass => 28_ageclass}/feb21/input.gms (77%) rename modules/{29_ageclass => 28_ageclass}/feb21/preloop.gms (88%) rename modules/{29_ageclass => 28_ageclass}/feb21/presolve.gms (100%) rename modules/{29_ageclass => 28_ageclass}/feb21/realization.gms (82%) rename modules/{29_ageclass => 28_ageclass}/feb21/sets.gms (100%) rename modules/{29_ageclass => 28_ageclass}/input/files (100%) rename modules/{29_ageclass => 28_ageclass}/module.gms (93%) create mode 100644 modules/29_cropland/input/files create mode 100644 modules/29_cropland/module.gms create mode 100644 modules/29_cropland/rulebased/declarations.gms create mode 100644 modules/29_cropland/rulebased/equations.gms create mode 100644 modules/29_cropland/rulebased/input.gms create mode 100644 modules/29_cropland/rulebased/postsolve.gms create mode 100644 modules/29_cropland/rulebased/preloop.gms create mode 100644 modules/29_cropland/rulebased/presolve.gms create mode 100644 modules/29_cropland/rulebased/realization.gms create mode 100644 modules/29_cropland/rulebased/sets.gms diff --git a/config/default.cfg b/config/default.cfg index 7d519e85f4..6a64d3aed1 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -664,11 +664,20 @@ cfg$gms$s22_conservation_start <- 2020 # def = 2020 # * Target year (year when full protection is reached): cfg$gms$s22_conservation_target <- 2030 # def = 2030 -# ***--------------------- 29_ageclass ----------------------------------- +# ***--------------------- 28_ageclass ----------------------------------- # * (feb21): Distribution of age-classes according to Poulter et al 2018 cfg$gms$ageclass <- "feb21" # def = feb21 +# ***--------------------- 29_cropland ----------------------------------- +# * Cropland is the sum of croparea, fallow land and tree cover +# * Croparea is proved from 30_crop. +# * Fallow land and tree cover are defined by 29_cropland, either exogenous via prescribed rules or endognous via monetary incentives. +# * (rulebased_apr24): Fallow land and tree cover are prescribed by rules. +# * (incentive_apr24): Fallow land and tree cover develop endogenously based on monetary incentives +cfg$gms$cropland <- "rulebased_apr24" # def = rulebased_apr24 + # ***--------------------- 30_crop --------------------------------------- +# * 30_crop defines the croparea, which is a subcomponent of total cropland defined in 29_cropland. # * (endo_apr21): Hard rotational constraints. Dynamic cropland and detailed cropland availability data at grid cell level. # * (rotation_apr22): hard rotational constraints and fallow constraints with the option of different future scenarios. Dynamic cropland and detailed cropland availability data at grid cell level. # * (penalty_apr22): rotational and fallow constraints are incentivized via penalty payments. Dynamic cropland and detailed cropland availability data at grid cell level. diff --git a/modules/10_land/landmatrix_dec18/declarations.gms b/modules/10_land/landmatrix_dec18/declarations.gms index 78886c1063..8ac9b52b8f 100644 --- a/modules/10_land/landmatrix_dec18/declarations.gms +++ b/modules/10_land/landmatrix_dec18/declarations.gms @@ -7,6 +7,7 @@ parameters pm_land_start(j,land) Land initialization area (mio. ha) + pm_land_hist(t_ini10,j,land) Land area for historial time steps (mio. ha) pcm_land(j,land) Land area in previous time step including possible changes after optimization (mio. ha) pm_treecover_shr(j) Cropland tree cover share (1) ; diff --git a/modules/10_land/landmatrix_dec18/input.gms b/modules/10_land/landmatrix_dec18/input.gms index 0e1fc99de1..092ae72b41 100644 --- a/modules/10_land/landmatrix_dec18/input.gms +++ b/modules/10_land/landmatrix_dec18/input.gms @@ -31,13 +31,3 @@ $ondelim $include "./modules/10_land/input/avl_land_t_iso.cs3" $offdelim ; - -********* Cropland tree cover ******************************************* - -parameter f10_treecover(j) Tree cover on cropland in 2019 (mio. ha) -/ -$ondelim -$include "./modules/10_land/input/CroplandTreecover.cs2" -$offdelim -/ -; diff --git a/modules/10_land/landmatrix_dec18/start.gms b/modules/10_land/landmatrix_dec18/start.gms index fd3ac13b7e..b8d25847d5 100644 --- a/modules/10_land/landmatrix_dec18/start.gms +++ b/modules/10_land/landmatrix_dec18/start.gms @@ -6,12 +6,9 @@ *** | Contact: magpie@pik-potsdam.de pm_land_start(j,land) = f10_land("y1995",j,land); +pm_land_hist(t_ini10,j,land) = f10_land(t_ini10,j,land); pcm_land(j,land) = pm_land_start(j,land); vm_land.l(j,land) = pcm_land(j,land); -pm_treecover_shr(j) = 0; -pm_treecover_shr(j)$(f10_land("y2015",j,"crop") > 1e-10) = - (f10_treecover(j)/f10_land("y2015",j,"crop")); - *** EOF pre.gms *** diff --git a/modules/29_ageclass/feb21/declarations.gms b/modules/28_ageclass/feb21/declarations.gms similarity index 100% rename from modules/29_ageclass/feb21/declarations.gms rename to modules/28_ageclass/feb21/declarations.gms diff --git a/modules/29_ageclass/feb21/input.gms b/modules/28_ageclass/feb21/input.gms similarity index 77% rename from modules/29_ageclass/feb21/input.gms rename to modules/28_ageclass/feb21/input.gms index 5bfacde746..7e645fecdb 100644 --- a/modules/29_ageclass/feb21/input.gms +++ b/modules/28_ageclass/feb21/input.gms @@ -5,8 +5,8 @@ *** | MAgPIE License Exception, version 1.0 (see LICENSE file). *** | Contact: magpie@pik-potsdam.de -table f29_forestageclasses(j,ac_poulter) Poulter age-class area in each cluster (1) +table f28_forestageclasses(j,ac_poulter) Poulter age-class area in each cluster (1) $ondelim -$include "./modules/29_ageclass/input/forestageclasses.cs3" +$include "./modules/28_ageclass/input/forestageclasses.cs3" $offdelim ; diff --git a/modules/29_ageclass/feb21/preloop.gms b/modules/28_ageclass/feb21/preloop.gms similarity index 88% rename from modules/29_ageclass/feb21/preloop.gms rename to modules/28_ageclass/feb21/preloop.gms index a8581ef8cd..12cffe2e9c 100644 --- a/modules/29_ageclass/feb21/preloop.gms +++ b/modules/28_ageclass/feb21/preloop.gms @@ -7,8 +7,8 @@ * Ben Poulter age class distribution im_plantedclass_ac(j,ac) = 0; -*im_plantedclass_ac(j,ac) = sum(ac_poulter_to_ac(ac_poulter,ac),f29_forestageclasses(j,ac_poulter)$(not sameas(ac_poulter,"class15"))); -im_plantedclass_ac(j,ac) = sum(ac_poulter_to_ac(ac_poulter,ac),f29_forestageclasses(j,ac_poulter)); +*im_plantedclass_ac(j,ac) = sum(ac_poulter_to_ac(ac_poulter,ac),f28_forestageclasses(j,ac_poulter)$(not sameas(ac_poulter,"class15"))); +im_plantedclass_ac(j,ac) = sum(ac_poulter_to_ac(ac_poulter,ac),f28_forestageclasses(j,ac_poulter)); * As summing over makes double counting (two magpie age classes in one poulter class) * We divide by 2 diff --git a/modules/29_ageclass/feb21/presolve.gms b/modules/28_ageclass/feb21/presolve.gms similarity index 100% rename from modules/29_ageclass/feb21/presolve.gms rename to modules/28_ageclass/feb21/presolve.gms diff --git a/modules/29_ageclass/feb21/realization.gms b/modules/28_ageclass/feb21/realization.gms similarity index 82% rename from modules/29_ageclass/feb21/realization.gms rename to modules/28_ageclass/feb21/realization.gms index 2ae4d5728a..f88a2c1b85 100644 --- a/modules/29_ageclass/feb21/realization.gms +++ b/modules/28_ageclass/feb21/realization.gms @@ -18,9 +18,9 @@ *' in MAgPIE and hence using these numbers directly in the model might generate biases. *####################### R SECTION START (PHASES) ############################## -$Ifi "%phase%" == "sets" $include "./modules/29_ageclass/feb21/sets.gms" -$Ifi "%phase%" == "declarations" $include "./modules/29_ageclass/feb21/declarations.gms" -$Ifi "%phase%" == "input" $include "./modules/29_ageclass/feb21/input.gms" -$Ifi "%phase%" == "preloop" $include "./modules/29_ageclass/feb21/preloop.gms" -$Ifi "%phase%" == "presolve" $include "./modules/29_ageclass/feb21/presolve.gms" +$Ifi "%phase%" == "sets" $include "./modules/28_ageclass/feb21/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/28_ageclass/feb21/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/28_ageclass/feb21/input.gms" +$Ifi "%phase%" == "preloop" $include "./modules/28_ageclass/feb21/preloop.gms" +$Ifi "%phase%" == "presolve" $include "./modules/28_ageclass/feb21/presolve.gms" *######################## R SECTION END (PHASES) ############################### diff --git a/modules/29_ageclass/feb21/sets.gms b/modules/28_ageclass/feb21/sets.gms similarity index 100% rename from modules/29_ageclass/feb21/sets.gms rename to modules/28_ageclass/feb21/sets.gms diff --git a/modules/29_ageclass/input/files b/modules/28_ageclass/input/files similarity index 100% rename from modules/29_ageclass/input/files rename to modules/28_ageclass/input/files diff --git a/modules/29_ageclass/module.gms b/modules/28_ageclass/module.gms similarity index 93% rename from modules/29_ageclass/module.gms rename to modules/28_ageclass/module.gms index f196dbbbab..27f03a3081 100644 --- a/modules/29_ageclass/module.gms +++ b/modules/28_ageclass/module.gms @@ -14,5 +14,5 @@ *' @authors Abhijeet Mishra, Florian Humpenöder *###################### R SECTION START (MODULETYPES) ########################## -$Ifi "%ageclass%" == "feb21" $include "./modules/29_ageclass/feb21/realization.gms" +$Ifi "%ageclass%" == "feb21" $include "./modules/28_ageclass/feb21/realization.gms" *###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/29_cropland/input/files b/modules/29_cropland/input/files new file mode 100644 index 0000000000..c4a894d426 --- /dev/null +++ b/modules/29_cropland/input/files @@ -0,0 +1,8 @@ +* list of files that are required here +avl_cropland.cs3 +avl_cropland_0.5.mz +avl_cropland_iso.cs3 +SNVTargetCropland.cs3 +SNVTargetCropland_0.5.mz +CroplandTreecover.cs2 +CroplandTreecover_0.5.mz diff --git a/modules/29_cropland/module.gms b/modules/29_cropland/module.gms new file mode 100644 index 0000000000..2c03a898ba --- /dev/null +++ b/modules/29_cropland/module.gms @@ -0,0 +1,18 @@ +*** | (C) 2008-2024 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 + +*' @title Cropland + +*' @description Cropland is the sum of croparea, fallow land and tree cover. Croparea is provided from [30_crop]. +*' Fallow land and tree cover are defined in this module, either exogenous via prescribed rules or endognous via monetary incentives. + + +*' @authors Florian Humpenöder + +*###################### R SECTION START (MODULETYPES) ########################## +$Ifi "%ageclass%" == "feb21" $include "./modules/28_ageclass/feb21/realization.gms" +*###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/29_cropland/rulebased/declarations.gms b/modules/29_cropland/rulebased/declarations.gms new file mode 100644 index 0000000000..90d9bf2aa9 --- /dev/null +++ b/modules/29_cropland/rulebased/declarations.gms @@ -0,0 +1,52 @@ +*** | (C) 2008-2024 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 + s29_shift number of 5-year age-classes corresponding to current time step length (1) +; + + +parameters + p29_avl_cropland(t,j) Total available land for crop cultivation (mio. ha) + p29_country_snv_weight(i) SNV policy country weight per region (1) + p29_snv_shr(t,j) Share of semi-natural vegetation in cropland areas (1) + i29_snv_relocation_target(j) Overall cropland area that requires relocation due to SNV policy (mio. ha) + p29_snv_relocation(t,j) Cropland area that is actually relocated during time step (mio. ha) + p29_max_snv_relocation(t,j) Maximum cropland relocation during time step (mio. ha) + p29_country_dummy(iso) Dummy parameter indicating whether country is affected by selected cropland policy (1) + i29_avl_cropland_iso(iso) Available land area for cropland at ISO level (mio. ha) + p29_snv_scenario_fader(t_all) SNV scenario fader (1) + p29_rotation_scenario_fader(t_all) Crop rotation scenario fader (1) + + + p29_treecover_min_shr(t,j) Minimum share of treecover on cropland (1) + p29_betr_min_shr(t,j) Minimum share of bioenergy trees on cropland (1) + p29_treecover_scenario_fader(t_all) Cropland treecover scenario fader (1) + p29_betr_scenario_fader(t_all) Bioenergy trees scenario fader (1) + p29_treecover_bii_coeff(bii_class_secd,potnatveg) BII coefficient for cropland treecover (1) + p29_carbon_density_ac(t,j,ac,ag_pools) Carbon density for ac and ag_pools (tC per ha) + p29_treecover(t,j,ac) Cropland tree cover per age class (mio. ha) + pc29_treecover(j,ac) Cropland tree cover per age class in current time step (mio. ha) +; + +positive variables + vm_fallow(j) Fallow land is temporarily fallow cropland (mio. ha) + v29_treecover(j,ac) Cropland tree cover per age class (mio. ha) +; + +equations + q29_cropland(j) Total cropland calculation (mio. ha) + q29_avl_cropland(j) Available cropland constraint (mio. ha) + q29_rotation_max(j,crp29,w) Local maximum rotational constraints (mio. ha) + q29_rotation_min(j,crp29,w) Local minimum rotational constraints (mio. ha) + q29_prod(j,kcr) Production of cropped products (mio. tDM) + q29_carbon(j,ag_pools,stockType) Cropland above ground carbon content calculation (mio. tC) + q29_bv_ann(j,potnatveg) Biodiversity value of annual cropland (mio. ha) + q29_bv_per(j,potnatveg) Biodiversity value of perennial cropland (mio. ha) + q29_land_snv(j) Land constraint for the SNV policy in cropland areas (mio. ha) + q29_land_snv_trans(j) Land transition constraint for SNV policy in cropland areas (mio. ha) +; diff --git a/modules/29_cropland/rulebased/equations.gms b/modules/29_cropland/rulebased/equations.gms new file mode 100644 index 0000000000..97bb93f8ad --- /dev/null +++ b/modules/29_cropland/rulebased/equations.gms @@ -0,0 +1,91 @@ +*** | (C) 2008-2024 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 +*' Total cropland is calculated as the sum of croparea, fallow land and tree cover area. + + q29_cropland(j2) .. + vm_land(j2,"crop") =e= sum((kcr,w), vm_area(j2,kcr,w)) + vm_fallow(j2) + sum(ac, v29_treecover(j2,ac)); + + +*' We assume that crop production can only take place on suitable cropland area. +*' We use a suitability index (SI) map from @zabel_global_2014 to exclude areas +*' from cropland production that have a low suitability, e.g. due to steep slopes, +*' to estimate the available cropland area. The cultivated area therefore has +*' to be smaller than the available cropland area. Moreover, the available cropland +*' can be reduced by constraining the cropland area in favour of other land types, +*' in order to increase compositional heterogeneity of land types at the cell level. + + q29_avl_cropland(j2) .. + vm_land(j2,"crop") =l= sum(ct, p29_avl_cropland(ct,j2)); + + +*' The semi-natural land constraint in cropland areas for sustaining critical regulating NCP +*' for agricultural production is added on top of land conserved for other reasons +*' (e.g. conservation of intact ecosystems or protection of biodiversity hotspots). + + q29_land_snv(j2) .. + sum(land_snv, vm_land(j2,land_snv)) + =g= + sum(ct, p29_snv_shr(ct,j2)) * vm_land(j2,"crop") + + sum((ct,land_snv,consv_type), pm_land_conservation(ct,j2,land_snv,consv_type)); + + +*' The semi-natural vegetation constraint for cropland areas has been suggested at the per square +*' kilometer scale. The amount of cropland requiring relocation has therefore been derived from +*' exogeneous high-resolution land cover information from the Copernicus Global Land Service +*' (@buchhorn_copernicus_2020). + + q29_land_snv_trans(j2) .. + sum(land_snv, vm_lu_transitions(j2,"crop",land_snv)) =g= sum(ct, p29_snv_relocation(ct,j2)); + + +*' The carbon stocks of total cropland are calculated as the sum of carbon stocks in cropland, fallow land and tree cover area. + + q29_carbon(j2,ag_pools,stockType) .. + vm_carbon_stock(j2,"crop",ag_pools,stockType) =e= + vm_carbon_stock_crop(j2,ag_pools) + + vm_fallow(j2) * sum(ct, fm_carbon_density(ct,j2,"crop",ag_pools)) + + m_carbon_stock_ac(v29_treecover,p31_carbon_density_ac,"ac","ac_sub"); + + +*' Total agroforestry cost. +*' Cost for bioenergy trees are accounted for in the [30_crop] module. +q61_cost_cropland(j2) .. + vm_cost_cropland(j2) =e= + v61_cost_treecover_est(j2) + v61_cost_treecover_recur(j2); + +*' Tree cover establishment cost +q61_cost_treecover_est(j2) .. + v61_cost_treecover_est(j2) =e= + sum(ac_est, v61_treecover(j2,ac_est)) * s61_cost_treecover_est * + sum((cell(i2,j2),ct),pm_interest(ct,i2)/(1+pm_interest(ct,i2))); + +*' Tree cover recurring cost +q61_cost_treecover_recur(j2) .. + v61_cost_treecover_recur(j2) =e= + sum(ac_sub, v61_treecover(j2,ac_sub)) * s61_cost_treecover_recur; + +*' Tree cover minimum share +q61_treecover_shr(j2) .. + sum(ac, v61_treecover(j2,ac)) =g= + sum(ct, p61_treecover_min_shr(ct,j2)) * vm_land(j2,"crop"); + +*' Bioenergy tree minimum share +q61_betr_shr(j2) .. + sum(w, vm_area(j2,"betr",w)) =g= + sum(ct, p61_betr_min_shr(ct,j2)) * vm_land(j2,"crop"); + +*' Tree cover establishment +q61_treecover_est(j2,ac_est) .. + v61_treecover(j2,ac_est) =e= sum(ac_est2, v61_treecover(j2,ac_est2))/card(ac_est2); + +*' Tree cover biodiversity value +q61_treecover_bv(j2,potnatveg) .. + vm_bv(j2,"crop_tree",potnatveg) =e= + sum(bii_class_secd, sum(ac_to_bii_class_secd(ac,bii_class_secd), v61_treecover(j2,ac)) * + p61_treecover_bii_coeff(bii_class_secd,potnatveg)) * fm_luh2_side_layers(j2,potnatveg); diff --git a/modules/29_cropland/rulebased/input.gms b/modules/29_cropland/rulebased/input.gms new file mode 100644 index 0000000000..e8d7c5028a --- /dev/null +++ b/modules/29_cropland/rulebased/input.gms @@ -0,0 +1,52 @@ +*** | (C) 2008-2024 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 + s61_cost_treecover_est Tree cover establishment cost (USD per ha) / 2000 / + s61_cost_treecover_recur Tree cover recurring cost (USD per ha) / 500 / + s61_treecover_plantation Growth curve switch for tree cover on cropland 0=natveg 1=plantations (1) / 0 / + s61_treecover_bii_coeff BII coefficent to be used for tree cover on cropland 0=secondary vegetation 1=timber plantations (1) / 0 / + s61_treecover_decrease Cropland treecover can decrease (1) or not (0) / 0 / + s61_treecover_scenario_start Cropland treecover scenario start year / 2020 / + s61_treecover_scenario_target Cropland treecover scenario target year / 2050 / + s61_treecover_min_shr Share of treecover on cropland (1) / 0.2 / + s61_betr_scenario_start Bioenergy trees scenario start year / 2020 / + s61_betr_scenario_target Bioenergy trees scenario target year / 2050 / + s61_betr_min_shr Minimum share of bioenergy trees on cropland (1) / 0 / +; + +********* AVAILABLE CROPLAND ******************************************* + +table f29_avl_cropland(j,marginal_land29) Available land area for cropland (mio. ha) +$ondelim +$include "./modules/29_cropland/input/avl_cropland.cs3" +$offdelim +; + +table f29_avl_cropland_iso(iso,marginal_land29) Available land area for cropland at ISO level (mio. ha) +$ondelim +$include "./modules/29_cropland/input/avl_cropland_iso.cs3" +$offdelim +; + +********* SNV TARGET CROPLAND ******************************************* + +table f29_snv_target_cropland(j,relocation_target29) Cropland in 2019 requiring relocation due to SNV policy (mio. ha) +$ondelim +$include "./modules/29_cropland/input/SNVTargetCropland.cs3" +$offdelim +; + +********* Cropland tree cover ******************************************* + +parameter f29_treecover(j) Tree cover on cropland in 2019 (mio. ha) +/ +$ondelim +$include "./modules/29_cropland/input/CroplandTreecover.cs2" +$offdelim +/ +; diff --git a/modules/29_cropland/rulebased/postsolve.gms b/modules/29_cropland/rulebased/postsolve.gms new file mode 100644 index 0000000000..fe2b94164a --- /dev/null +++ b/modules/29_cropland/rulebased/postsolve.gms @@ -0,0 +1,8 @@ +*** | (C) 2008-2024 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 + +pc29_treecover(j,ac) = v29_treecover.l(j,ac); diff --git a/modules/29_cropland/rulebased/preloop.gms b/modules/29_cropland/rulebased/preloop.gms new file mode 100644 index 0000000000..391e38fe5a --- /dev/null +++ b/modules/29_cropland/rulebased/preloop.gms @@ -0,0 +1,52 @@ +*** | (C) 2008-2024 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_fallow.fx(j) = 0; + +** Trajectory for cropland scenarios +* sigmoidal interpolation between start year and target year +m_sigmoid_time_interpol(p29_snv_scenario_fader,s29_snv_scenario_start,s29_snv_scenario_target,0,1); +m_sigmoid_time_interpol(p29_rotation_scenario_fader,s29_rotation_scenario_start,s29_rotation_scenario_target,0,1); + +* linear interpolation to estimate the cropland that +* requires relocation due to SNV policy +if (s29_snv_shr = 0, +i29_snv_relocation_target(j) = 0; + +elseif s29_snv_shr <= s29_snv_relocation_data_x1, +m_linear_cell_data_interpol(i29_snv_relocation_target, s29_snv_shr,0,s29_snv_relocation_data_x1,0, f29_snv_target_cropland(j, "SNV20TargetCropland")); + +elseif s29_snv_shr > s29_snv_relocation_data_x1, +m_linear_cell_data_interpol(i29_snv_relocation_target, s29_snv_shr,s29_snv_relocation_data_x1, s29_snv_relocation_data_x2,f29_snv_target_cropland(j, "SNV20TargetCropland"), f29_snv_target_cropland(j, "SNV50TargetCropland")); +); + + +m_sigmoid_time_interpol(p29_treecover_scenario_fader,s29_treecover_scenario_start,s29_treecover_scenario_target,0,1); +m_sigmoid_time_interpol(p29_betr_scenario_fader,s29_betr_scenario_start,s29_betr_scenario_target,0,1); + +* Initial tree cover on cropland is assumed to be equally distributed among all age-classes +pc29_treecover(j,ac) = 0; +pc29_treecover(j,ac)$(pm_land_hist("y2015",j,"crop") > 1e-10) = + (f29_treecover(j) / pm_land_hist("y2015",j,"crop") * pm_land_hist("y1995",j,"crop")) / card(ac); + + +*' Switch for tree cover on cropland: +*' 0 = Use natveg growth curve towards LPJmL natural vegetation +*' 1 = Use plantation growth curve (faster than natveg) towards LPJmL natural vegetation +if(s29_treecover_plantation = 0, + p29_carbon_density_ac(t,j,ac,ag_pools) = pm_carbon_density_ac(t,j,ac,ag_pools); +elseif s29_treecover_plantation = 1, + p29_carbon_density_ac(t,j,ac,ag_pools) = pm_carbon_density_ac_forestry(t,j,ac,ag_pools); +); + +** set bii coefficients +p29_treecover_bii_coeff(bii_class_secd,potnatveg) = 0; +if(s29_treecover_bii_coeff = 0, + p29_treecover_bii_coeff(bii_class_secd,potnatveg) = fm_bii_coeff(bii_class_secd,potnatveg) +elseif s29_treecover_bii_coeff = 1, + p29_treecover_bii_coeff(bii_class_secd,potnatveg) = fm_bii_coeff("timber",potnatveg) +); diff --git a/modules/29_cropland/rulebased/presolve.gms b/modules/29_cropland/rulebased/presolve.gms new file mode 100644 index 0000000000..8c36c85212 --- /dev/null +++ b/modules/29_cropland/rulebased/presolve.gms @@ -0,0 +1,61 @@ +*** | (C) 2008-2023 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 + +*' @code +*' Minimum semi-natural vegetation (SNV) share is fading in after 2020 +p29_snv_shr(t,j) = p29_snv_scenario_fader(t) * + (s29_snv_shr * sum(cell(i,j), p29_country_snv_weight(i)) + + s29_snv_shr_noselect * sum(cell(i,j), 1-p29_country_snv_weight(i))); + +*' Cropland relocation in response to SNV policy is based on exogeneous land +*' cover information from the Copernicus Global Land Service (@buchhorn_copernicus_2020). +*' The rate of the policy implementation is derived based +*' on the difference of scenario fader values in consecutive time steps +p29_snv_relocation(t,j) = (p29_snv_scenario_fader(t) - p29_snv_scenario_fader(t-1)) * + (i29_snv_relocation_target(j) * sum(cell(i,j), p29_country_snv_weight(i)) + + s29_snv_shr_noselect * sum(cell(i,j), 1-p29_country_snv_weight(i))); +*' The following lines take care of mismatches in the input +*' data (derived from satellite imagery from the Copernicus +*' Global Land Service (@buchhorn_copernicus_2020)) and in +*' cases of cropland reduction +p29_max_snv_relocation(t,j) = p29_snv_shr(t,j) * (p29_snv_scenario_fader(t) - p29_snv_scenario_fader(t-1)) * pcm_land(j,"crop"); +p29_snv_relocation(t,j)$(p29_snv_relocation(t, j) > p29_max_snv_relocation(t,j)) = p29_max_snv_relocation(t,j); + +*' Area potentially available for cropping +p29_avl_cropland(t,j) = f29_avl_cropland(j,"%c29_marginal_land%") * (1 - p29_snv_shr(t,j)); +*' @stop + + +* Growth of trees on cropland is modelled by shifting age-classes according to time step length. +s61_shift = m_timestep_length_forestry/5; +* example: ac10 in t = ac5 (ac10-1) in t-1 for a 5 yr time step (s61_shift = 1) + p61_treecover(t,j,ac)$(ord(ac) > s61_shift) = pc61_treecover(j,ac-s61_shift); +* account for cases at the end of the age class set (s61_shift > 1) which are not shifted by the above calculation + p61_treecover(t,j,"acx") = p61_treecover(t,j,"acx") + + sum(ac$(ord(ac) > card(ac)-s61_shift), pc61_treecover(j,ac)); + +pc61_treecover(j,ac) = p61_treecover(t,j,ac); +v61_treecover.l(j,ac) = p61_treecover(t,j,ac); + +if(m_year(t) <= s61_treecover_scenario_start, + v61_treecover.fx(j,ac) = pc61_treecover(j,ac); +else + v61_treecover.lo(j,ac_est) = 0; + v61_treecover.up(j,ac_est) = Inf; + if(s61_treecover_decrease = 1, + v61_treecover.lo(j,ac_sub) = 0; + v61_treecover.up(j,ac_sub) = pc61_treecover(j,ac_sub); + else + v61_treecover.fx(j,ac_sub) = pc61_treecover(j,ac_sub); + ); +); + +p61_treecover_min_shr(t,j) = + ((1-p61_treecover_scenario_fader(t)) * pm_treecover_shr(j)) + + (p61_treecover_scenario_fader(t) * s61_treecover_min_shr); + +p61_betr_min_shr(t,j) = p61_betr_scenario_fader(t) * s61_betr_min_shr; diff --git a/modules/29_cropland/rulebased/realization.gms b/modules/29_cropland/rulebased/realization.gms new file mode 100644 index 0000000000..4c07116378 --- /dev/null +++ b/modules/29_cropland/rulebased/realization.gms @@ -0,0 +1,18 @@ +*** | (C) 2008-2024 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 todo + +*' @limitations todo + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/28_ageclass/feb21/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/28_ageclass/feb21/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/28_ageclass/feb21/input.gms" +$Ifi "%phase%" == "preloop" $include "./modules/28_ageclass/feb21/preloop.gms" +$Ifi "%phase%" == "presolve" $include "./modules/28_ageclass/feb21/presolve.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/29_cropland/rulebased/sets.gms b/modules/29_cropland/rulebased/sets.gms new file mode 100644 index 0000000000..a74b51c7de --- /dev/null +++ b/modules/29_cropland/rulebased/sets.gms @@ -0,0 +1,19 @@ +*** | (C) 2008-2024 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 + +sets + + marginal_land30 Marginal land scenarios + / all_marginal, q33_marginal, no_marginal / + + policy_target30 Target year for cropland policy + / none, by2030, by2050 / + + relocation_target30 Cropland requiring relocation based on different SNV targets + / SNV20TargetCropland, SNV50TargetCropland / + +; diff --git a/modules/30_crop/endo_apr21/declarations.gms b/modules/30_crop/endo_apr21/declarations.gms index ddea2ea686..07792a6246 100644 --- a/modules/30_crop/endo_apr21/declarations.gms +++ b/modules/30_crop/endo_apr21/declarations.gms @@ -6,36 +6,22 @@ *** | Contact: magpie@pik-potsdam.de parameters - p30_avl_cropland(t,j) Total available land for crop cultivation (mio. ha) - p30_country_snv_weight(i) SNV policy country weight per region (1) - p30_snv_shr(t,j) Share of semi-natural vegetation in cropland areas (1) - i30_snv_relocation_target(j) Overall cropland area that requires relocation due to SNV policy (mio. ha) - p30_snv_relocation(t,j) Cropland area that is actually relocated during time step (mio. ha) - p30_max_snv_relocation(t,j) Maximum cropland relocation during time step (mio. ha) - p30_country_dummy(iso) Dummy parameter indicating whether country is affected by selected cropland policy (1) - i30_avl_cropland_iso(iso) Available land area for cropland at ISO level (mio. ha) - p30_snv_scenario_fader(t_all) SNV scenario fader (1) p30_rotation_scenario_fader(t_all) Crop rotation scenario fader (1) ; positive variables -* Fallow land is cropland which is temporarily fallow. Croparea+fallow=cropland - vm_fallow(j) Fallow land (mio. ha) - vm_area(j,kcr,w) Agricultural production area (mio. ha) - vm_rotation_penalty(i) Penalty for violating rotational constraints (USD05MER) + vm_area(j,kcr,w) Agricultural production area (mio. ha) + vm_rotation_penalty(i) Penalty for violating rotational constraints (USD05MER) + vm_carbon_stock_croparea(j,ag_pools) Carbon stock in croparea (tC) ; equations - q30_cropland(j) Total cropland calculation (mio. ha) - q30_avl_cropland(j) Available cropland constraint (mio. ha) q30_rotation_max(j,crp30,w) Local maximum rotational constraints (mio. ha) q30_rotation_min(j,crp30,w) Local minimum rotational constraints (mio. ha) q30_prod(j,kcr) Production of cropped products (mio. tDM) - q30_carbon(j,ag_pools,stockType) Cropland above ground carbon content calculation (mio. tC) + q30_carbon(j,ag_pools) Croplarea above ground carbon content calculation (mio. tC) q30_bv_ann(j,potnatveg) Biodiversity value of annual cropland (mio. ha) q30_bv_per(j,potnatveg) Biodiversity value of perennial cropland (mio. ha) - q30_land_snv(j) Land constraint for the SNV policy in cropland areas (mio. ha) - q30_land_snv_trans(j) Land transition constraint for SNV policy in cropland areas (mio. ha) ; *#################### R SECTION START (OUTPUT DECLARATIONS) #################### diff --git a/modules/30_crop/endo_apr21/equations.gms b/modules/30_crop/endo_apr21/equations.gms index c240ddc8a8..ad815cdec0 100644 --- a/modules/30_crop/endo_apr21/equations.gms +++ b/modules/30_crop/endo_apr21/equations.gms @@ -6,39 +6,14 @@ *** | Contact: magpie@pik-potsdam.de *' @equations -*' The total land requirements for cropland are calculated as -*' the sum of crop and water supply type specific land requirements: - - q30_cropland(j2) .. - sum((kcr,w), vm_area(j2,kcr,w)) + vm_fallow(j2) + vm_treecover_area(j2) =e= vm_land(j2,"crop"); - -*' We assume that crop production can only take place on suitable cropland area. -*' We use a suitability index (SI) map from @zabel_global_2014 to exclude areas -*' from cropland production that have a low suitability, e.g. due to steep slopes, -*' to estimate the available cropland area. The cultivated area therefore has -*' to be smaller than the available cropland area. Moreover, the available cropland -*' can be reduced by constraining the cropland area in favour of other land types, -*' in order to increase compositional heterogeneity of land types at the cell level. - - q30_avl_cropland(j2) .. - vm_land(j2,"crop") =l= sum(ct, p30_avl_cropland(ct,j2)); - -*' The semi-natural land constraint in cropland areas for sustaining critical regulating NCP -*' for agricultural production is added on top of land conserved for other reasons -*' (e.g. conservation of intact ecosystems or protection of biodiversity hotspots). - q30_land_snv(j2) .. - sum(land_snv, vm_land(j2,land_snv)) - =g= - sum(ct, p30_snv_shr(ct,j2)) * vm_land(j2,"crop") - + sum((ct,land_snv,consv_type), pm_land_conservation(ct,j2,land_snv,consv_type)); - -*' The semi-natural vegetation constraint for cropland areas has been suggested at the per square -*' kilometer scale. The amount of cropland requiring relocation has therefore been derived from -*' exogeneous high-resolution land cover information from the Copernicus Global Land Service -*' (@buchhorn_copernicus_2020). - - q30_land_snv_trans(j2) .. - sum(land_snv, vm_lu_transitions(j2,"crop",land_snv)) =g= sum(ct, p30_snv_relocation(ct,j2)); + +*' Agricultural production is calculated by multiplying the area under +*' production with corresponding yields. Production from rainfed and irrigated +*' areas is summed up: + + q30_prod(j2,kcr) .. + vm_prod(j2,kcr) =e= sum(w, vm_area(j2,kcr,w) * vm_yld(j2,kcr,w)); + *' As additional constraints minimum and maximum rotational constraints limit *' the placing of crops. On the one hand, these rotational constraints reflect @@ -49,6 +24,7 @@ sum((crp_kcr30(crpmax30,kcr)), vm_area(j2,kcr,w)) =l= sum(kcr, vm_area(j2,kcr,w)) * f30_rotation_max_shr(crpmax30); + *' On the other hand, it reflects boundary conditions such as minimum self *' sufficiency constraints: @@ -56,26 +32,26 @@ sum((crp_kcr30(crpmin30,kcr)), vm_area(j2,kcr,w)) =g= sum(kcr, vm_area(j2,kcr,w)) * f30_rotation_min_shr(crpmin30); -*' Agricultural production is calculated by multiplying the area under -*' production with corresponding yields. Production from rainfed and irrigated -*' areas is summed up: - q30_prod(j2,kcr) .. - vm_prod(j2,kcr) =e= sum(w, vm_area(j2,kcr,w) * vm_yld(j2,kcr,w)); +*' Bioenergy tree minimum share +q30_betr_shr(j2) .. + sum(w, vm_area(j2,"betr",w)) =g= + sum(ct, p30_betr_min_shr(ct,j2)) * vm_land(j2,"crop"); + -*' The carbon content of the above ground carbon pools are calculated as a total -*' for all cropland : +*' The carbon stocks of the above ground carbon pools are calculated based on croparea and related carbon density. + + q30_carbon(j2,ag_pools) .. + vm_carbon_stock_croparea(j2,ag_pools) =e= + sum((kcr,w), vm_area(j2,kcr,w)) * sum(ct, fm_carbon_density(ct,j2,"crop",ag_pools)); - q30_carbon(j2,ag_pools,stockType) .. - vm_carbon_stock(j2,"crop",ag_pools,stockType) =e= - m_carbon_stock(vm_land,fm_carbon_density,"crop") + vm_treecover_carbon(j2,ag_pools,stockType); *' The biodiversity value for cropland is calculated separately for annual and perennial crops: + q30_bv_ann(j2,potnatveg) .. vm_bv(j2,"crop_ann",potnatveg) =e= sum((crop_ann30,w), vm_area(j2,crop_ann30,w)) * fm_bii_coeff("crop_ann",potnatveg) * fm_luh2_side_layers(j2,potnatveg); q30_bv_per(j2,potnatveg) .. vm_bv(j2,"crop_per",potnatveg) =e= - (vm_land(j2,"crop") - sum((crop_ann30,w), vm_area(j2,crop_ann30,w))) - * fm_bii_coeff("crop_per",potnatveg) * fm_luh2_side_layers(j2,potnatveg); + sum((crop_per30,w), vm_area(j2,crop_per30,w)) * fm_bii_coeff("crop_per",potnatveg) * fm_luh2_side_layers(j2,potnatveg); diff --git a/modules/30_crop/endo_apr21/input.gms b/modules/30_crop/endo_apr21/input.gms index cdd3e6f56a..2ccc267364 100644 --- a/modules/30_crop/endo_apr21/input.gms +++ b/modules/30_crop/endo_apr21/input.gms @@ -99,26 +99,3 @@ $offdelim /; $if "%c30_rotation_constraints%" == "off" f30_rotation_min_shr(crp30) = 0; - -********* AVAILABLE CROPLAND ******************************************* - - -table f30_avl_cropland(j,marginal_land30) Available land area for cropland (mio. ha) -$ondelim -$include "./modules/30_crop/endo_apr21/input/avl_cropland.cs3" -$offdelim -; - -table f30_avl_cropland_iso(iso,marginal_land30) Available land area for cropland at ISO level (mio. ha) -$ondelim -$include "./modules/30_crop/endo_apr21/input/avl_cropland_iso.cs3" -$offdelim -; - -********* SNV TARGET CROPLAND ******************************************* - -table f30_snv_target_cropland(j,relocation_target30) Cropland in 2019 requiring relocation due to SNV policy (mio. ha) -$ondelim -$include "./modules/30_crop/endo_apr21/input/SNVTargetCropland.cs3" -$offdelim -; diff --git a/modules/30_crop/endo_apr21/preloop.gms b/modules/30_crop/endo_apr21/preloop.gms index d121c0dbab..e4b01bc732 100644 --- a/modules/30_crop/endo_apr21/preloop.gms +++ b/modules/30_crop/endo_apr21/preloop.gms @@ -7,21 +7,8 @@ ** Trajectory for cropland scenarios * sigmoidal interpolation between start year and target year -m_sigmoid_time_interpol(p30_snv_scenario_fader,s30_snv_scenario_start,s30_snv_scenario_target,0,1); m_sigmoid_time_interpol(p30_rotation_scenario_fader,s30_rotation_scenario_start,s30_rotation_scenario_target,0,1); -* linear interpolation to estimate the cropland that -* requires relocation due to SNV policy -if (s30_snv_shr = 0, -i30_snv_relocation_target(j) = 0; - -elseif s30_snv_shr <= s30_snv_relocation_data_x1, -m_linear_cell_data_interpol(i30_snv_relocation_target, s30_snv_shr,0,s30_snv_relocation_data_x1,0, f30_snv_target_cropland(j, "SNV20TargetCropland")); - -elseif s30_snv_shr > s30_snv_relocation_data_x1, -m_linear_cell_data_interpol(i30_snv_relocation_target, s30_snv_shr,s30_snv_relocation_data_x1, s30_snv_relocation_data_x2,f30_snv_target_cropland(j, "SNV20TargetCropland"), f30_snv_target_cropland(j, "SNV50TargetCropland")); -); - *due to some rounding errors the input data currently may contain in some cases *very small, negative numbers. These numbers have to be set to 0 as area *cannot be smaller than 0! diff --git a/modules/30_crop/endo_apr21/presolve.gms b/modules/30_crop/endo_apr21/presolve.gms index 528e492ec4..942042b0e9 100644 --- a/modules/30_crop/endo_apr21/presolve.gms +++ b/modules/30_crop/endo_apr21/presolve.gms @@ -20,33 +20,8 @@ else *' @stop -*' No penalties or fallows exist in this realization +*' No penalties exist in this realization vm_rotation_penalty.fx(i)=0; -vm_fallow.fx(j)=0; crpmax30(crp30) = yes$(f30_rotation_max_shr(crp30) < 1); crpmin30(crp30) = yes$(f30_rotation_min_shr(crp30) > 0); - -*' @code -*' Minimum semi-natural vegetation (SNV) share is fading in after 2020 -p30_snv_shr(t,j) = p30_snv_scenario_fader(t) * - (s30_snv_shr * sum(cell(i,j), p30_country_snv_weight(i)) - + s30_snv_shr_noselect * sum(cell(i,j), 1-p30_country_snv_weight(i))); - -*' Cropland relocation in response to SNV policy is based on exogeneous land -*' cover information from the Copernicus Global Land Service (@buchhorn_copernicus_2020). -*' The rate of the policy implementation is derived based -*' on the difference of scenario fader values in consecutive time steps -p30_snv_relocation(t,j) = (p30_snv_scenario_fader(t) - p30_snv_scenario_fader(t-1)) * - (i30_snv_relocation_target(j) * sum(cell(i,j), p30_country_snv_weight(i)) - + s30_snv_shr_noselect * sum(cell(i,j), 1-p30_country_snv_weight(i))); -*' The following lines take care of mismatches in the input -*' data (derived from satellite imagery from the Copernicus -*' Global Land Service (@buchhorn_copernicus_2020)) and in -*' cases of cropland reduction -p30_max_snv_relocation(t,j) = p30_snv_shr(t,j) * (p30_snv_scenario_fader(t) - p30_snv_scenario_fader(t-1)) * pcm_land(j,"crop"); -p30_snv_relocation(t,j)$(p30_snv_relocation(t, j) > p30_max_snv_relocation(t,j)) = p30_max_snv_relocation(t,j); - -*' Area potentially available for cropping -p30_avl_cropland(t,j) = f30_avl_cropland(j,"%c30_marginal_land%") * (1 - p30_snv_shr(t,j)); -*' @stop diff --git a/modules/30_crop/endo_apr21/sets.gms b/modules/30_crop/endo_apr21/sets.gms index 0c18871533..4d37950315 100644 --- a/modules/30_crop/endo_apr21/sets.gms +++ b/modules/30_crop/endo_apr21/sets.gms @@ -48,13 +48,4 @@ sets crop_per30(kcr) perennial crops / oilpalm, begr, sugr_cane, betr / - marginal_land30 Marginal land scenarios - / all_marginal, q33_marginal, no_marginal / - - policy_target30 Target year for cropland policy - / none, by2030, by2050 / - - relocation_target30 Cropland requiring relocation based on different SNV targets - / SNV20TargetCropland, SNV50TargetCropland / - ; diff --git a/modules/30_crop/penalty_apr22/declarations.gms b/modules/30_crop/penalty_apr22/declarations.gms index 9a06747dda..6c6ce00698 100644 --- a/modules/30_crop/penalty_apr22/declarations.gms +++ b/modules/30_crop/penalty_apr22/declarations.gms @@ -6,22 +6,11 @@ *** | Contact: magpie@pik-potsdam.de parameters - p30_avl_cropland(t,j) Total available land for crop cultivation (mio. ha) - p30_country_snv_weight(i) SNV policy country weight per region (1) - p30_snv_shr(t,j) Share of semi-natural vegetation in cropland areas (1) - i30_snv_relocation_target(j) Overall cropland area that requires relocation due to SNV policy (mio. ha) - p30_snv_relocation(t,j) Cropland area that is actually relocated during time step (mio. ha) - p30_max_snv_relocation(t,j) Maximum cropland relocation during time step (mio. ha) - p30_country_dummy(iso) Dummy parameter indicating whether country is affected by selected cropland policy (1) - i30_avl_cropland_iso(iso) Available land area for cropland at ISO level (mio. ha) i30_rotation_incentives(t_all,rota30) Penalty for violating rotational constraints (USD05MER per ha) - p30_snv_scenario_fader(t_all) SNV scenario fader (1) p30_rotation_scenario_fader(t_all) Crop rotation scenario fader (1) ; positive variables -* Fallow land is cropland which is temporarily fallow. Croparea+fallow=cropland - vm_fallow(j) Fallow land (mio. ha) vm_area(j,kcr,w) Agricultural production area (mio. ha) vm_rotation_penalty(i) Penalty for violating rotational constraints (mio. USD05MER) v30_penalty_max_irrig(j,rotamax30) Penalty for violating max rotational constraints on irrigated land (mio. USD05MER) @@ -29,18 +18,14 @@ positive variables ; equations - q30_cropland(j) Total cropland calculation (mio. ha) - q30_avl_cropland(j) Available cropland constraint (mio. ha) q30_rotation_penalty(i) Total penalty for rotational constraint violations (mio. USD05MER) q30_rotation_max(j,rotamax30) Local maximum rotational constraints (mio. ha) q30_rotation_min(j,rotamin30) Local minimum rotational constraints (mio. ha) q30_rotation_max_irrig(j,rotamax30) Local maximum rotational constraints (mio. ha) q30_prod(j,kcr) Production of cropped products (mio. tDM) - q30_carbon(j,ag_pools,stockType) Cropland above ground carbon content calculation (mio. tC) + q30_carbon(j,ag_pools) Croparea above ground carbon content calculation (mio. tC) q30_bv_ann(j,potnatveg) Biodiversity value of annual cropland (mio. ha) q30_bv_per(j,potnatveg) Biodiversity value of perennial cropland (mio. ha) - q30_land_snv(j) Land constraint for the SNV policy in cropland areas (mio. ha) - q30_land_snv_trans(j) Land transition constraint for SNV policy in cropland areas (mio. ha) ; *#################### R SECTION START (OUTPUT DECLARATIONS) #################### diff --git a/modules/30_crop/penalty_apr22/equations.gms b/modules/30_crop/penalty_apr22/equations.gms index 93d6b11164..669ed0fa84 100644 --- a/modules/30_crop/penalty_apr22/equations.gms +++ b/modules/30_crop/penalty_apr22/equations.gms @@ -6,41 +6,13 @@ *** | Contact: magpie@pik-potsdam.de *' @equations -*' The total land requirements for cropland are calculated as -*' the sum of crop and water supply type specific land requirements. -*' Fallow is no explicit landuse type, but the difference between -*' the land area for crops vm_land and the croparea vm_area - q30_cropland(j2) .. - sum((kcr,w), vm_area(j2,kcr,w)) + vm_fallow(j2) + vm_treecover_area(j2) =e= vm_land(j2,"crop"); - -*' We assume that crop production can only take place on suitable cropland area. -*' We use a suitability index (SI) map from @zabel_global_2014 to exclude areas -*' from cropland production that have a low suitability, e.g. due to steep slopes, -*' to estimate the available cropland area. The cultivated area therefore has -*' to be smaller than the available cropland area. Moreover, the available cropland -*' can be reduced by constraining the cropland area in favour of other land types, -*' in order to increase compositional heterogeneity of land types at the cell level. - - q30_avl_cropland(j2) .. - vm_land(j2,"crop") =l= sum(ct, p30_avl_cropland(ct,j2)); - -*' The semi-natural land constraint in cropland areas for sustaining critical regulating NCP -*' for agricultural production is added on top of land conserved for other reasons -*' (e.g. conservation of intact ecosystems or protection of biodiversity hotspots). - q30_land_snv(j2) .. - sum(land_snv, vm_land(j2,land_snv)) - =g= - sum(ct, p30_snv_shr(ct,j2)) * vm_land(j2,"crop") - + sum((ct,land_snv,consv_type), pm_land_conservation(ct,j2,land_snv,consv_type)); - -*' The semi-natural vegetation constraint for cropland areas has been suggested at the per square -*' kilometer scale. The amount of cropland requiring relocation has therefore been derived from -*' exogeneous high-resolution land cover information from the Copernicus Global Land Service -*' (@buchhorn_copernicus_2020). +*' Agricultural production is calculated by multiplying the area under +*' production with corresponding yields. Production from rainfed and irrigated +*' areas is summed up: - q30_land_snv_trans(j2) .. - sum(land_snv, vm_lu_transitions(j2,"crop",land_snv)) =g= sum(ct, p30_snv_relocation(ct,j2)); + q30_prod(j2,kcr) .. + vm_prod(j2,kcr) =e= sum(w, vm_area(j2,kcr,w) * vm_yld(j2,kcr,w)); *' Rotational constraints prevent over-specialization. In this module realization, *' they are implemented via a penalty payment if the constraints are violated. @@ -83,20 +55,11 @@ q30_rotation_penalty(i2) .. sum((rota_kcr30(rotamax_red30,kcr)), vm_area(j2,kcr,"irrigated")) - vm_AEI(j2) * f30_rotation_rules(rotamax_red30); +*' The carbon stocks of the above ground carbon pools are calculated based on croparea and related carbon density. -*' Agricultural production is calculated by multiplying the area under -*' production with corresponding yields. Production from rainfed and irrigated -*' areas is summed up: - - q30_prod(j2,kcr) .. - vm_prod(j2,kcr) =e= sum(w, vm_area(j2,kcr,w) * vm_yld(j2,kcr,w)); - -*' The carbon content of the above ground carbon pools are calculated as a total -*' for all cropland : - - q30_carbon(j2,ag_pools,stockType) .. - vm_carbon_stock(j2,"crop",ag_pools,stockType) =e= - m_carbon_stock(vm_land,fm_carbon_density,"crop") + vm_treecover_carbon(j2,ag_pools,stockType); + q30_carbon(j2,ag_pools) .. + vm_carbon_stock_croparea(j2,ag_pools) =e= + sum((kcr,w), vm_area(j2,kcr,w)) * sum(ct, fm_carbon_density(ct,j2,"crop",ag_pools)); *' The biodiversity value for cropland is calculated separately for annual and perennial crops: q30_bv_ann(j2,potnatveg) .. diff --git a/modules/30_crop/penalty_apr22/preloop.gms b/modules/30_crop/penalty_apr22/preloop.gms index a5b75b7935..d628775aff 100644 --- a/modules/30_crop/penalty_apr22/preloop.gms +++ b/modules/30_crop/penalty_apr22/preloop.gms @@ -7,22 +7,8 @@ ** Trajectory for cropland scenarios * sigmoidal interpolation between start year and target year -m_sigmoid_time_interpol(p30_snv_scenario_fader,s30_snv_scenario_start,s30_snv_scenario_target,0,1); m_sigmoid_time_interpol(p30_rotation_scenario_fader,s30_rotation_scenario_start,s30_rotation_scenario_target,0,1); -* linear interpolation to estimate the cropland that -* requires relocation due to SNV policy -if (s30_snv_shr = 0, -i30_snv_relocation_target(j) = 0; - -elseif s30_snv_shr <= s30_snv_relocation_data_x1, -m_linear_cell_data_interpol(i30_snv_relocation_target, s30_snv_shr,0,s30_snv_relocation_data_x1,0, f30_snv_target_cropland(j, "SNV20TargetCropland")); - -elseif s30_snv_shr > s30_snv_relocation_data_x1, -m_linear_cell_data_interpol(i30_snv_relocation_target, s30_snv_shr,s30_snv_relocation_data_x1, s30_snv_relocation_data_x2,f30_snv_target_cropland(j, "SNV20TargetCropland"), f30_snv_target_cropland(j, "SNV50TargetCropland")); -); - - ** create crop rotation scenario i30_rotation_incentives(t_all,rota30)= f30_rotation_incentives(rota30,"default") * (1-p30_rotation_scenario_fader(t_all)) + diff --git a/modules/30_crop/penalty_apr22/presolve.gms b/modules/30_crop/penalty_apr22/presolve.gms index 77ae685190..4c8d3a4fa8 100644 --- a/modules/30_crop/penalty_apr22/presolve.gms +++ b/modules/30_crop/penalty_apr22/presolve.gms @@ -19,30 +19,6 @@ else ); *' @stop -*' @code -*' Minimum semi-natural vegetation (SNV) share is fading in after 2020 -p30_snv_shr(t,j) = p30_snv_scenario_fader(t) * - (s30_snv_shr * sum(cell(i,j), p30_country_snv_weight(i)) - + s30_snv_shr_noselect * sum(cell(i,j), 1-p30_country_snv_weight(i))); - -*' Cropland relocation in response to SNV policy is based on exogeneous land -*' cover information from the Copernicus Global Land Service (@buchhorn_copernicus_2020). -*' The rate of the policy implementation is derived based -*' on the difference of scenario fader values in consecutive time steps -p30_snv_relocation(t,j) = (p30_snv_scenario_fader(t) - p30_snv_scenario_fader(t-1)) * - (i30_snv_relocation_target(j) * sum(cell(i,j), p30_country_snv_weight(i)) - + s30_snv_shr_noselect * sum(cell(i,j), 1-p30_country_snv_weight(i))); -*' The following lines take care of mismatches in the input -*' data (derived from satellite imagery from the Copernicus -*' Global Land Service (@buchhorn_copernicus_2020)) and in -*' cases of cropland reduction -p30_max_snv_relocation(t,j) = p30_snv_shr(t,j) * (p30_snv_scenario_fader(t) - p30_snv_scenario_fader(t-1)) * pcm_land(j,"crop"); -p30_snv_relocation(t,j)$(p30_snv_relocation(t, j) > p30_max_snv_relocation(t,j)) = p30_max_snv_relocation(t,j); - -*' Area potentially available for cropping -p30_avl_cropland(t,j) = f30_avl_cropland(j,"%c30_marginal_land%") * (1 - p30_snv_shr(t,j)); -*' @stop - * only activate constraints which are binding rotamax_red30(rotamax30) = yes$(i30_rotation_incentives(t,rotamax30) > 0); rotamin_red30(rotamin30) = yes$(i30_rotation_incentives(t,rotamin30) > 0); diff --git a/modules/30_crop/penalty_apr22/sets.gms b/modules/30_crop/penalty_apr22/sets.gms index 91881757d7..c03627a506 100644 --- a/modules/30_crop/penalty_apr22/sets.gms +++ b/modules/30_crop/penalty_apr22/sets.gms @@ -84,12 +84,4 @@ sets crop_per30(kcr) perennial crops / oilpalm, begr, sugr_cane, betr / - marginal_land30 Marginal land scenarios - / all_marginal, q33_marginal, no_marginal / - - policy_target30 Target year for cropland policy - / none, by2030, by2050 / - - relocation_target30 Cropland requiring relocation based on different SNV targets - / SNV20TargetCropland, SNV50TargetCropland / ; diff --git a/modules/30_crop/rotation_apr22/declarations.gms b/modules/30_crop/rotation_apr22/declarations.gms index 126d50b51e..93e3da8bfb 100644 --- a/modules/30_crop/rotation_apr22/declarations.gms +++ b/modules/30_crop/rotation_apr22/declarations.gms @@ -6,39 +6,24 @@ *** | Contact: magpie@pik-potsdam.de parameters - p30_avl_cropland(t,j) Total available land for crop cultivation (mio. ha) - p30_country_snv_weight(i) SNV policy country weight per region (1) - p30_snv_shr(t,j) Share of semi-natural vegetation in cropland areas (1) - i30_snv_relocation_target(j) Overall cropland area that requires relocation due SNV policy (mio. ha) - p30_snv_relocation(t,j) Cropland area that is actually relocated during time step (mio. ha) - p30_max_snv_relocation(t,j) Maximum cropland relocation during time step (mio. ha) - p30_country_dummy(iso) Dummy parameter indicating whether country is affected by selected cropland policy (1) - i30_avl_cropland_iso(iso) Available land area for cropland at ISO level (mio. ha) i30_rotation_max_shr(t_all,rotamax30) Maximum share of a certain crop group on cropland (ha per ha) i30_rotation_min_shr(t_all,rotamin30) Minimum share of a certain crop group on cropland (ha per ha) - p30_snv_scenario_fader(t_all) SNV scenario fader (1) p30_rotation_scenario_fader(t_all) Crop rotation scenario fader (1) ; positive variables -* Fallow land is cropland which is temporarily fallow. Croparea+fallow=cropland - vm_fallow(j) Fallow land (mio. ha) vm_area(j,kcr,w) Agricultural production area (mio. ha) vm_rotation_penalty(i) Penalty for violating rotational constraints (USD05MER) ; equations - q30_cropland(j) Total cropland calculation (mio. ha) - q30_avl_cropland(j) Available cropland constraint (mio. ha) q30_rotation_max(j,rotamax30) Local maximum rotational constraints (mio. ha) q30_rotation_min(j,rotamin30) Local minimum rotational constraints (mio. ha) q30_rotation_max_irrig(j,rotamax30) Local maximum rotational constraints (mio. ha) q30_prod(j,kcr) Production of cropped products (mio. tDM) - q30_carbon(j,ag_pools,stockType) Cropland above ground carbon content calculation (mio. tC) + q30_carbon(j,ag_pools) Croplarea above ground carbon content calculation (mio. tC) q30_bv_ann(j,potnatveg) Biodiversity value of annual cropland (mio. ha) q30_bv_per(j,potnatveg) Biodiversity value of perennial cropland (mio. ha) - q30_land_snv(j) Land constraint for the SNV policy in cropland areas (mio. ha) - q30_land_snv_trans(j) Land transition constraint for SNV policy in cropland areas (mio. ha) ; *#################### R SECTION START (OUTPUT DECLARATIONS) #################### diff --git a/modules/30_crop/rotation_apr22/equations.gms b/modules/30_crop/rotation_apr22/equations.gms index 379ed62cf6..fef0d2c511 100644 --- a/modules/30_crop/rotation_apr22/equations.gms +++ b/modules/30_crop/rotation_apr22/equations.gms @@ -6,41 +6,13 @@ *** | Contact: magpie@pik-potsdam.de *' @equations -*' The total land requirements for cropland are calculated as -*' the sum of crop and water supply type specific land requirements: -*' Fallow is no explicit landuse type, but the difference between -*' the land area for crops vm_land and the croparea vm_area - q30_cropland(j2) .. - sum((kcr,w), vm_area(j2,kcr,w)) + vm_fallow(j2) + vm_treecover_area(j2) =e= vm_land(j2,"crop"); - -*' We assume that crop production can only take place on suitable cropland area. -*' We use a suitability index (SI) map from @zabel_global_2014 to exclude areas -*' from cropland production that have a low suitability, e.g. due to steep slopes, -*' to estimate the available cropland area. The cultivated area therefore has -*' to be smaller than the available cropland area. Moreover, the available cropland -*' can be reduced by constraining the cropland area in favour of other land types, -*' in order to increase compositional heterogeneity of land types at the cell level. - - q30_avl_cropland(j2) .. - vm_land(j2,"crop") =l= sum(ct, p30_avl_cropland(ct,j2)); - -*' The semi-natural land constraint in cropland areas for sustaining critical regulating NCP -*' for agricultural production is added on top of land conserved for other reasons -*' (e.g. conservation of intact ecosystems or protection of biodiversity hotspots). - q30_land_snv(j2) .. - sum(land_snv, vm_land(j2,land_snv)) - =g= - sum(ct, p30_snv_shr(ct,j2)) * vm_land(j2,"crop") - + sum((ct,land_snv,consv_type), pm_land_conservation(ct,j2,land_snv,consv_type)); - -*' The semi-natural vegetation constraint for cropland areas has been suggested at the per square -*' kilometer scale. The amount of cropland requiring relocation has therefore been derived from -*' exogeneous high-resolution land cover information from the Copernicus Global Land Service -*' (@buchhorn_copernicus_2020). +*' Agricultural production is calculated by multiplying the area under +*' production with corresponding yields. Production from rainfed and irrigated +*' areas is summed up: - q30_land_snv_trans(j2) .. - sum(land_snv, vm_lu_transitions(j2,"crop",land_snv)) =g= sum(ct, p30_snv_relocation(ct,j2)); + q30_prod(j2,kcr) .. + vm_prod(j2,kcr) =e= sum(w, vm_area(j2,kcr,w) * vm_yld(j2,kcr,w)); *' As additional constraints minimum and maximum rotational constraints limit *' the placing of crops. On the one hand, these rotational constraints reflect @@ -64,7 +36,6 @@ sum((rotamax_kcr30(rotamax_red30,kcr)), vm_area(j2,kcr,"irrigated")) =l= vm_AEI(j2) * sum(ct,i30_rotation_max_shr(ct,rotamax_red30)); - *' Agricultural production is calculated by multiplying the area under *' production with corresponding yields. Production from rainfed and irrigated *' areas is summed up: @@ -72,13 +43,6 @@ q30_prod(j2,kcr) .. vm_prod(j2,kcr) =e= sum(w, vm_area(j2,kcr,w) * vm_yld(j2,kcr,w)); -*' The carbon content of the above ground carbon pools are calculated as a total -*' for all cropland : - - q30_carbon(j2,ag_pools,stockType) .. - vm_carbon_stock(j2,"crop",ag_pools,stockType) =e= - m_carbon_stock(vm_land,fm_carbon_density,"crop") + vm_treecover_carbon(j2,ag_pools,stockType); - *' The biodiversity value for cropland is calculated separately for annual and perennial crops: q30_bv_ann(j2,potnatveg) .. vm_bv(j2,"crop_ann",potnatveg) diff --git a/modules/30_crop/rotation_apr22/preloop.gms b/modules/30_crop/rotation_apr22/preloop.gms index c6dd29d8d5..43fe8bdd10 100644 --- a/modules/30_crop/rotation_apr22/preloop.gms +++ b/modules/30_crop/rotation_apr22/preloop.gms @@ -8,21 +8,8 @@ ** Trajectory for cropland scenarios * sigmoidal interpolation between start year and target year -m_sigmoid_time_interpol(p30_snv_scenario_fader,s30_snv_scenario_start,s30_snv_scenario_target,0,1); m_sigmoid_time_interpol(p30_rotation_scenario_fader,s30_rotation_scenario_start,s30_rotation_scenario_target,0,1); -* linear interpolation to estimate the cropland that -* requires relocation due to SNV policy -if (s30_snv_shr = 0, -i30_snv_relocation_target(j) = 0; - -elseif s30_snv_shr <= s30_snv_relocation_data_x1, -m_linear_cell_data_interpol(i30_snv_relocation_target, s30_snv_shr,0,s30_snv_relocation_data_x1,0, f30_snv_target_cropland(j, "SNV20TargetCropland")); - -elseif s30_snv_shr > s30_snv_relocation_data_x1, -m_linear_cell_data_interpol(i30_snv_relocation_target, s30_snv_shr,s30_snv_relocation_data_x1, s30_snv_relocation_data_x2,f30_snv_target_cropland(j, "SNV20TargetCropland"), f30_snv_target_cropland(j, "SNV50TargetCropland")); -); - ** create crop rotation scenario i30_rotation_max_shr(t_all,rotamax30)= f30_rotation_max_shr(rotamax30,"default") * (1-p30_rotation_scenario_fader(t_all))+ diff --git a/modules/30_crop/rotation_apr22/presolve.gms b/modules/30_crop/rotation_apr22/presolve.gms index 2c3fa21de2..1b847385d9 100644 --- a/modules/30_crop/rotation_apr22/presolve.gms +++ b/modules/30_crop/rotation_apr22/presolve.gms @@ -19,29 +19,6 @@ else ); *' @stop -*' @code -*' Minimum semi-natural vegetation (SNV) share is fading in after 2020 -p30_snv_shr(t,j) = p30_snv_scenario_fader(t) * - (s30_snv_shr * sum(cell(i,j), p30_country_snv_weight(i)) - + s30_snv_shr_noselect * sum(cell(i,j), 1-p30_country_snv_weight(i))); - -*' Cropland relocation in response to SNV policy is based on exogeneous land -*' cover information from the Copernicus Global Land Service (@buchhorn_copernicus_2020). -*' The rate of the policy implementation is derived based -*' on the difference of scenario fader values in consecutive time steps -p30_snv_relocation(t,j) = (p30_snv_scenario_fader(t) - p30_snv_scenario_fader(t-1)) * - (i30_snv_relocation_target(j) * sum(cell(i,j), p30_country_snv_weight(i)) - + s30_snv_shr_noselect * sum(cell(i,j), 1-p30_country_snv_weight(i))); -*' The following lines take care of mismatches in the input -*' data (derived from satellite imagery) and in -*' cases of cropland reduction -p30_max_snv_relocation(t,j) = p30_snv_shr(t,j) * (p30_snv_scenario_fader(t) - p30_snv_scenario_fader(t-1)) * pcm_land(j,"crop"); -p30_snv_relocation(t,j)$(p30_snv_relocation(t, j) > p30_max_snv_relocation(t,j)) = p30_max_snv_relocation(t,j); - -*' Area potentially available for cropping -p30_avl_cropland(t,j) = f30_avl_cropland(j,"%c30_marginal_land%") * (1 - p30_snv_shr(t,j)); -*' @stop - * only activate constraints which are binding rotamax_red30(rotamax30) = yes$(i30_rotation_max_shr(t,rotamax30) < 1); rotamin_red30(rotamin30) = yes$(i30_rotation_min_shr(t,rotamin30) > 0); diff --git a/modules/30_crop/rotation_apr22/sets.gms b/modules/30_crop/rotation_apr22/sets.gms index 72b3040f6a..e23397fecc 100644 --- a/modules/30_crop/rotation_apr22/sets.gms +++ b/modules/30_crop/rotation_apr22/sets.gms @@ -96,12 +96,4 @@ sets crop_per30(kcr) perennial crops / oilpalm, begr, sugr_cane, betr / - marginal_land30 Marginal land scenarios - / all_marginal, q33_marginal, no_marginal / - - policy_target30 Target year for cropland policy - / none, by2030, by2050 / - - relocation_target30 Cropland requiring relocation based on different SNV targets - / SNV20TargetCropland, SNV50TargetCropland / ; diff --git a/modules/61_agroforestry/exo/input.gms b/modules/61_agroforestry/exo/input.gms index 8d198c6bd0..c10a69cca2 100644 --- a/modules/61_agroforestry/exo/input.gms +++ b/modules/61_agroforestry/exo/input.gms @@ -5,16 +5,3 @@ *** | MAgPIE License Exception, version 1.0 (see LICENSE file). *** | Contact: magpie@pik-potsdam.de -scalars - s61_cost_treecover_est Tree cover establishment cost (USD per ha) / 2000 / - s61_cost_treecover_recur Tree cover recurring cost (USD per ha) / 500 / - s61_treecover_plantation Growth curve switch for tree cover on cropland 0=natveg 1=plantations (1) / 0 / - s61_treecover_bii_coeff BII coefficent to be used for tree cover on cropland 0=secondary vegetation 1=timber plantations (1) / 0 / - s61_treecover_decrease Cropland treecover can decrease (1) or not (0) / 0 / - s61_treecover_scenario_start Cropland treecover scenario start year / 2020 / - s61_treecover_scenario_target Cropland treecover scenario target year / 2050 / - s61_treecover_min_shr Share of treecover on cropland (1) / 0.2 / - s61_betr_scenario_start Bioenergy trees scenario start year / 2020 / - s61_betr_scenario_target Bioenergy trees scenario target year / 2050 / - s61_betr_min_shr Minimum share of bioenergy trees on cropland (1) / 0 / -; diff --git a/modules/61_agroforestry/exo/postsolve.gms b/modules/61_agroforestry/exo/postsolve.gms index 557cf4f306..0f01d44bb7 100644 --- a/modules/61_agroforestry/exo/postsolve.gms +++ b/modules/61_agroforestry/exo/postsolve.gms @@ -5,7 +5,6 @@ *** | MAgPIE License Exception, version 1.0 (see LICENSE file). *** | Contact: magpie@pik-potsdam.de -pc61_treecover(j,ac) = v61_treecover.l(j,ac); *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### ov_cost_agroforestry(t,j,"marginal") = vm_cost_agroforestry.m(j); diff --git a/modules/61_agroforestry/exo/preloop.gms b/modules/61_agroforestry/exo/preloop.gms index 382d670b01..637d6609c8 100644 --- a/modules/61_agroforestry/exo/preloop.gms +++ b/modules/61_agroforestry/exo/preloop.gms @@ -5,25 +5,4 @@ *** | MAgPIE License Exception, version 1.0 (see LICENSE file). *** | Contact: magpie@pik-potsdam.de -m_sigmoid_time_interpol(p61_treecover_scenario_fader,s61_treecover_scenario_start,s61_treecover_scenario_target,0,1); -m_sigmoid_time_interpol(p61_betr_scenario_fader,s61_betr_scenario_start,s61_betr_scenario_target,0,1); - -* Initial tree cover on cropland is assumed to be equally distributed among all age-classes -pc61_treecover(j,ac) = (pm_treecover_shr(j)*pm_land_start(j,"crop"))/card(ac); -*' Switch for tree cover on cropland: -*' 0 = Use natveg growth curve towards LPJmL natural vegetation -*' 1 = Use plantation growth curve (faster than natveg) towards LPJmL natural vegetation -if(s61_treecover_plantation = 0, - p61_carbon_density_ac(t,j,ac,ag_pools) = pm_carbon_density_ac(t,j,ac,ag_pools); -elseif s61_treecover_plantation = 1, - p61_carbon_density_ac(t,j,ac,ag_pools) = pm_carbon_density_ac_forestry(t,j,ac,ag_pools); -); - -** set bii coefficients -p61_treecover_bii_coeff(bii_class_secd,potnatveg) = 0; -if(s61_treecover_bii_coeff = 0, - p61_treecover_bii_coeff(bii_class_secd,potnatveg) = fm_bii_coeff(bii_class_secd,potnatveg) -elseif s61_treecover_bii_coeff = 1, - p61_treecover_bii_coeff(bii_class_secd,potnatveg) = fm_bii_coeff("timber",potnatveg) -); diff --git a/modules/61_agroforestry/exo/presolve.gms b/modules/61_agroforestry/exo/presolve.gms index 40d24e22ea..c10a69cca2 100644 --- a/modules/61_agroforestry/exo/presolve.gms +++ b/modules/61_agroforestry/exo/presolve.gms @@ -5,32 +5,3 @@ *** | MAgPIE License Exception, version 1.0 (see LICENSE file). *** | Contact: magpie@pik-potsdam.de -* Growth of trees on cropland is modelled by shifting age-classes according to time step length. -s61_shift = m_timestep_length_forestry/5; -* example: ac10 in t = ac5 (ac10-1) in t-1 for a 5 yr time step (s61_shift = 1) - p61_treecover(t,j,ac)$(ord(ac) > s61_shift) = pc61_treecover(j,ac-s61_shift); -* account for cases at the end of the age class set (s61_shift > 1) which are not shifted by the above calculation - p61_treecover(t,j,"acx") = p61_treecover(t,j,"acx") - + sum(ac$(ord(ac) > card(ac)-s61_shift), pc61_treecover(j,ac)); - -pc61_treecover(j,ac) = p61_treecover(t,j,ac); -v61_treecover.l(j,ac) = p61_treecover(t,j,ac); - -if(m_year(t) <= s61_treecover_scenario_start, - v61_treecover.fx(j,ac) = pc61_treecover(j,ac); -else - v61_treecover.lo(j,ac_est) = 0; - v61_treecover.up(j,ac_est) = Inf; - if(s61_treecover_decrease = 1, - v61_treecover.lo(j,ac_sub) = 0; - v61_treecover.up(j,ac_sub) = pc61_treecover(j,ac_sub); - else - v61_treecover.fx(j,ac_sub) = pc61_treecover(j,ac_sub); - ); -); - -p61_treecover_min_shr(t,j) = - ((1-p61_treecover_scenario_fader(t)) * pm_treecover_shr(j)) + - (p61_treecover_scenario_fader(t) * s61_treecover_min_shr); - -p61_betr_min_shr(t,j) = p61_betr_scenario_fader(t) * s61_betr_min_shr; diff --git a/modules/include.gms b/modules/include.gms index 8b99f45da2..13ff07c83e 100644 --- a/modules/include.gms +++ b/modules/include.gms @@ -22,7 +22,7 @@ $include "./modules/18_residues/module.gms" $include "./modules/20_processing/module.gms" $include "./modules/21_trade/module.gms" $include "./modules/22_land_conservation/module.gms" -$include "./modules/29_ageclass/module.gms" +$include "./modules/28_ageclass/module.gms" $include "./modules/30_crop/module.gms" $include "./modules/31_past/module.gms" $include "./modules/32_forestry/module.gms" From 531ffad5cd3d40062bdc0593f4a7f43d23880a33 Mon Sep 17 00:00:00 2001 From: florianh Date: Tue, 16 Apr 2024 12:37:16 +0200 Subject: [PATCH 009/133] partial commit to save work --- config/default.cfg | 72 +++++++------- main.gms | 2 +- modules/11_costs/default/equations.gms | 2 +- modules/29_cropland/module.gms | 2 +- modules/29_cropland/rulebased/input.gms | 52 ---------- modules/29_cropland/rulebased/postsolve.gms | 8 -- modules/29_cropland/rulebased/realization.gms | 18 ---- .../declarations.gms | 38 ++++++-- .../equations.gms | 44 ++++----- modules/29_cropland/rulebased_apr24/input.gms | 94 +++++++++++++++++++ .../29_cropland/rulebased_apr24/postsolve.gms | 76 +++++++++++++++ .../preloop.gms | 15 ++- .../presolve.gms | 44 ++++----- .../rulebased_apr24/realization.gms | 20 ++++ .../{rulebased => rulebased_apr24}/sets.gms | 8 +- modules/30_crop/endo_apr21/declarations.gms | 28 +++--- modules/30_crop/endo_apr21/equations.gms | 3 +- modules/30_crop/endo_apr21/input.gms | 51 +--------- modules/30_crop/endo_apr21/input/files | 5 - modules/30_crop/endo_apr21/postsolve.gms | 92 ++++++++---------- modules/30_crop/endo_apr21/preloop.gms | 11 +-- modules/30_crop/endo_apr21/presolve.gms | 2 + .../30_crop/penalty_apr22/declarations.gms | 17 ++-- modules/30_crop/penalty_apr22/equations.gms | 16 ++-- modules/30_crop/penalty_apr22/input.gms | 69 +------------- modules/30_crop/penalty_apr22/input/files | 5 - modules/30_crop/penalty_apr22/postsolve.gms | 40 +++----- modules/30_crop/penalty_apr22/preloop.gms | 11 --- .../30_crop/rotation_apr22/declarations.gms | 17 ++-- modules/30_crop/rotation_apr22/equations.gms | 29 +++--- modules/30_crop/rotation_apr22/input.gms | 72 +------------- modules/30_crop/rotation_apr22/input/files | 5 - modules/30_crop/rotation_apr22/postsolve.gms | 44 ++++----- modules/30_crop/rotation_apr22/preloop.gms | 13 +-- modules/30_crop/rotation_apr22/presolve.gms | 2 + modules/61_agroforestry/endo/declarations.gms | 67 ------------- modules/61_agroforestry/endo/equations.gms | 55 ----------- modules/61_agroforestry/endo/input.gms | 18 ---- modules/61_agroforestry/endo/not_used.txt | 2 - modules/61_agroforestry/endo/postsolve.gms | 79 ---------------- modules/61_agroforestry/endo/preloop.gms | 26 ----- modules/61_agroforestry/endo/presolve.gms | 34 ------- modules/61_agroforestry/endo/realization.gms | 21 ----- modules/61_agroforestry/exo/declarations.gms | 65 ------------- modules/61_agroforestry/exo/equations.gms | 54 ----------- modules/61_agroforestry/exo/input.gms | 7 -- modules/61_agroforestry/exo/postsolve.gms | 70 -------------- modules/61_agroforestry/exo/preloop.gms | 8 -- modules/61_agroforestry/exo/presolve.gms | 7 -- modules/61_agroforestry/exo/realization.gms | 21 ----- modules/61_agroforestry/module.gms | 22 ----- modules/61_agroforestry/off/declarations.gms | 25 ----- modules/61_agroforestry/off/not_used.txt | 10 -- modules/61_agroforestry/off/postsolve.gms | 22 ----- modules/61_agroforestry/off/preloop.gms | 11 --- modules/61_agroforestry/off/realization.gms | 17 ---- modules/include.gms | 2 +- 57 files changed, 464 insertions(+), 1206 deletions(-) delete mode 100644 modules/29_cropland/rulebased/input.gms delete mode 100644 modules/29_cropland/rulebased/postsolve.gms delete mode 100644 modules/29_cropland/rulebased/realization.gms rename modules/29_cropland/{rulebased => rulebased_apr24}/declarations.gms (51%) rename modules/29_cropland/{rulebased => rulebased_apr24}/equations.gms (73%) create mode 100644 modules/29_cropland/rulebased_apr24/input.gms create mode 100644 modules/29_cropland/rulebased_apr24/postsolve.gms rename modules/29_cropland/{rulebased => rulebased_apr24}/preloop.gms (75%) rename modules/29_cropland/{rulebased => rulebased_apr24}/presolve.gms (67%) create mode 100644 modules/29_cropland/rulebased_apr24/realization.gms rename modules/29_cropland/{rulebased => rulebased_apr24}/sets.gms (73%) delete mode 100644 modules/61_agroforestry/endo/declarations.gms delete mode 100644 modules/61_agroforestry/endo/equations.gms delete mode 100644 modules/61_agroforestry/endo/input.gms delete mode 100644 modules/61_agroforestry/endo/not_used.txt delete mode 100644 modules/61_agroforestry/endo/postsolve.gms delete mode 100644 modules/61_agroforestry/endo/preloop.gms delete mode 100644 modules/61_agroforestry/endo/presolve.gms delete mode 100644 modules/61_agroforestry/endo/realization.gms delete mode 100644 modules/61_agroforestry/exo/declarations.gms delete mode 100644 modules/61_agroforestry/exo/equations.gms delete mode 100644 modules/61_agroforestry/exo/input.gms delete mode 100644 modules/61_agroforestry/exo/postsolve.gms delete mode 100644 modules/61_agroforestry/exo/preloop.gms delete mode 100644 modules/61_agroforestry/exo/presolve.gms delete mode 100644 modules/61_agroforestry/exo/realization.gms delete mode 100644 modules/61_agroforestry/module.gms delete mode 100644 modules/61_agroforestry/off/declarations.gms delete mode 100644 modules/61_agroforestry/off/not_used.txt delete mode 100644 modules/61_agroforestry/off/postsolve.gms delete mode 100644 modules/61_agroforestry/off/preloop.gms delete mode 100644 modules/61_agroforestry/off/realization.gms diff --git a/config/default.cfg b/config/default.cfg index 6a64d3aed1..65dac22111 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -676,6 +676,42 @@ cfg$gms$ageclass <- "feb21" # def = feb21 # * (incentive_apr24): Fallow land and tree cover develop endogenously based on monetary incentives cfg$gms$cropland <- "rulebased_apr24" # def = rulebased_apr24 +# * Switch to determine whether marginal land (suitability index below 0.33) should be included +# * in the total available cropland. Options are: +# * ("all_marginal"): All marginal land can be used for crop cultivation +# * ("q33_marginal"): The bottom tertile of marginal land is excluded +# * ("no_marginal"): Marginal land is completely excluded from crop cultivation +# * Note: Option "q33_marginal" produces the highest spatial correlation +# * with observed cropland patterns and is recommended for productive runs. +cfg$gms$c29_marginal_land <- "q33_marginal" # def = "q33_marginal" + +# * Share of available cropland that is withheld for maintaining semi-natural vegetation (SNV) +# * in each square km in cropland areas, including grassland, forest and other land. For example, +# * a share of 0.2 corresponds to 20 % of SNV in terms of the available cropland. +# * The amount of cropland relocation is estimated based on external high resolution +# * land cover information from the Copernicus Global Land Service for the year 2019. +# * Accepted sensible values are between 0 and 0.5 +# Note: s29_snv_shr applies to countries selected in policy_countries29 +# s29_snv_shr_noselect applies to all other countries. +cfg$gms$s29_snv_shr <- 0 # def = 0 +cfg$gms$s29_snv_shr_noselect <- 0 # def = 0 +# * Year by which SNV policy ('s29_snv_shr') is fully implemented. +# * Start year (should be close to 2019): +cfg$gms$s29_snv_scenario_start <- 2020 # def = 2020 +# * Target year (year when full implementation is reached): +cfg$gms$s29_snv_scenario_target <- 2029 # def = 2029 +# * Switch and specification of countries for which SNV policy in +# * s29_snv_shr apply. +# * Options: list of iso-codes of countries where SNV policy should be applied +# * Note: must be written in the format: "IND, BRA, DEU" +# * Default: all iso countries +cfg$gms$policy_countries29 <- all_iso_countries +# * Land types included in the SNV policy. This option allows for sensitivity analyses. +# * plausible options: "secdforest, forestry, past, other", +# * "secdforest, other", +# * "secdforest, past, other" etc. +cfg$gms$land_snv <- "secdforest, forestry, past, other" #def = "secdforest, forestry, past, other" + # ***--------------------- 30_crop --------------------------------------- # * 30_crop defines the croparea, which is a subcomponent of total cropland defined in 29_cropland. # * (endo_apr21): Hard rotational constraints. Dynamic cropland and detailed cropland availability data at grid cell level. @@ -705,42 +741,6 @@ cfg$gms$s30_rotation_scenario_start <- 2020 # def = 2020 cfg$gms$s30_rotation_scenario_target <- 2050 # def = 2050 -# * Switch to determine whether marginal land (suitability index below 0.33) should be included -# * in the total available cropland. Options are: -# * ("all_marginal"): All marginal land can be used for crop cultivation -# * ("q33_marginal"): The bottom tertile of marginal land is excluded -# * ("no_marginal"): Marginal land is completely excluded from crop cultivation -# * Note: Option "q33_marginal" produces the highest spatial correlation -# * with observed cropland patterns and is recommended for productive runs. -cfg$gms$c30_marginal_land <- "q33_marginal" # def = "q33_marginal" - -# * Share of available cropland that is withheld for maintaining semi-natural vegetation (SNV) -# * in each square km in cropland areas, including grassland, forest and other land. For example, -# * a share of 0.2 corresponds to 20 % of SNV in terms of the available cropland. -# * The amount of cropland relocation is estimated based on external high resolution -# * land cover information from the Copernicus Global Land Service for the year 2019. -# * Accepted sensible values are between 0 and 0.5 -# Note: s30_snv_shr applies to countries selected in policy_countries30 -# s30_snv_shr_noselect applies to all other countries. -cfg$gms$s30_snv_shr <- 0 # def = 0 -cfg$gms$s30_snv_shr_noselect <- 0 # def = 0 -# * Year by which SNV policy ('s30_snv_shr') is fully implemented. -# * Start year (should be close to 2019): -cfg$gms$s30_snv_scenario_start <- 2020 # def = 2020 -# * Target year (year when full implementation is reached): -cfg$gms$s30_snv_scenario_target <- 2030 # def = 2030 -# * Switch and specification of countries for which SNV policy in -# * s30_snv_shr apply. -# * Options: list of iso-codes of countries where SNV policy should be applied -# * Note: must be written in the format: "IND, BRA, DEU" -# * Default: all iso countries -cfg$gms$policy_countries30 <- all_iso_countries -# * Land types included in the SNV policy. This option allows for sensitivity analyses. -# * plausible options: "secdforest, forestry, past, other", -# * "secdforest, other", -# * "secdforest, past, other" etc. -cfg$gms$land_snv <- "secdforest, forestry, past, other" #def = "secdforest, forestry, past, other" - # ***--------------------- 31_past --------------------------------------- # * (static): static pasture # * (endo_jun13): dynamic pasture diff --git a/main.gms b/main.gms index fc45c7c121..c2a738f7b5 100644 --- a/main.gms +++ b/main.gms @@ -249,6 +249,7 @@ $setglobal land_conservation area_based_apr22 $setglobal ageclass feb21 +$setglobal cropland rulebased_apr24 $setglobal crop endo_apr21 $setglobal past endo_jun13 @@ -281,7 +282,6 @@ $setglobal peatland v2 $setglobal som static_jan19 $setglobal bioenergy 1stgen_priced_dec18 -$setglobal agroforestry off $setglobal material exo_flexreg_apr16 $setglobal livestock fbask_jan16 diff --git a/modules/11_costs/default/equations.gms b/modules/11_costs/default/equations.gms index 3c3a57f893..c3d758a20d 100644 --- a/modules/11_costs/default/equations.gms +++ b/modules/11_costs/default/equations.gms @@ -37,7 +37,7 @@ + vm_costs_additional_mon(i2) + sum(cell(i2,j2),vm_cost_land_transition(j2)) + sum(cell(i2,j2), vm_peatland_cost(j2)) - + sum(cell(i2,j2), vm_cost_agroforestry(j2)) + + sum(cell(i2,j2), vm_cost_cropland(j2)) + sum(cell(i2,j2),vm_cost_bv_loss(j2)) + sum(cell(i2,j2),vm_cost_urban(j2)) + sum(cell(i2,j2),vm_water_cost(i2)) diff --git a/modules/29_cropland/module.gms b/modules/29_cropland/module.gms index 2c03a898ba..7f406b8b7c 100644 --- a/modules/29_cropland/module.gms +++ b/modules/29_cropland/module.gms @@ -14,5 +14,5 @@ *' @authors Florian Humpenöder *###################### R SECTION START (MODULETYPES) ########################## -$Ifi "%ageclass%" == "feb21" $include "./modules/28_ageclass/feb21/realization.gms" +$Ifi "%cropland%" == "rulebased_apr24" $include "./modules/29_cropland/rulebased_apr24/realization.gms" *###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/29_cropland/rulebased/input.gms b/modules/29_cropland/rulebased/input.gms deleted file mode 100644 index e8d7c5028a..0000000000 --- a/modules/29_cropland/rulebased/input.gms +++ /dev/null @@ -1,52 +0,0 @@ -*** | (C) 2008-2024 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 - s61_cost_treecover_est Tree cover establishment cost (USD per ha) / 2000 / - s61_cost_treecover_recur Tree cover recurring cost (USD per ha) / 500 / - s61_treecover_plantation Growth curve switch for tree cover on cropland 0=natveg 1=plantations (1) / 0 / - s61_treecover_bii_coeff BII coefficent to be used for tree cover on cropland 0=secondary vegetation 1=timber plantations (1) / 0 / - s61_treecover_decrease Cropland treecover can decrease (1) or not (0) / 0 / - s61_treecover_scenario_start Cropland treecover scenario start year / 2020 / - s61_treecover_scenario_target Cropland treecover scenario target year / 2050 / - s61_treecover_min_shr Share of treecover on cropland (1) / 0.2 / - s61_betr_scenario_start Bioenergy trees scenario start year / 2020 / - s61_betr_scenario_target Bioenergy trees scenario target year / 2050 / - s61_betr_min_shr Minimum share of bioenergy trees on cropland (1) / 0 / -; - -********* AVAILABLE CROPLAND ******************************************* - -table f29_avl_cropland(j,marginal_land29) Available land area for cropland (mio. ha) -$ondelim -$include "./modules/29_cropland/input/avl_cropland.cs3" -$offdelim -; - -table f29_avl_cropland_iso(iso,marginal_land29) Available land area for cropland at ISO level (mio. ha) -$ondelim -$include "./modules/29_cropland/input/avl_cropland_iso.cs3" -$offdelim -; - -********* SNV TARGET CROPLAND ******************************************* - -table f29_snv_target_cropland(j,relocation_target29) Cropland in 2019 requiring relocation due to SNV policy (mio. ha) -$ondelim -$include "./modules/29_cropland/input/SNVTargetCropland.cs3" -$offdelim -; - -********* Cropland tree cover ******************************************* - -parameter f29_treecover(j) Tree cover on cropland in 2019 (mio. ha) -/ -$ondelim -$include "./modules/29_cropland/input/CroplandTreecover.cs2" -$offdelim -/ -; diff --git a/modules/29_cropland/rulebased/postsolve.gms b/modules/29_cropland/rulebased/postsolve.gms deleted file mode 100644 index fe2b94164a..0000000000 --- a/modules/29_cropland/rulebased/postsolve.gms +++ /dev/null @@ -1,8 +0,0 @@ -*** | (C) 2008-2024 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 - -pc29_treecover(j,ac) = v29_treecover.l(j,ac); diff --git a/modules/29_cropland/rulebased/realization.gms b/modules/29_cropland/rulebased/realization.gms deleted file mode 100644 index 4c07116378..0000000000 --- a/modules/29_cropland/rulebased/realization.gms +++ /dev/null @@ -1,18 +0,0 @@ -*** | (C) 2008-2024 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 todo - -*' @limitations todo - -*####################### R SECTION START (PHASES) ############################## -$Ifi "%phase%" == "sets" $include "./modules/28_ageclass/feb21/sets.gms" -$Ifi "%phase%" == "declarations" $include "./modules/28_ageclass/feb21/declarations.gms" -$Ifi "%phase%" == "input" $include "./modules/28_ageclass/feb21/input.gms" -$Ifi "%phase%" == "preloop" $include "./modules/28_ageclass/feb21/preloop.gms" -$Ifi "%phase%" == "presolve" $include "./modules/28_ageclass/feb21/presolve.gms" -*######################## R SECTION END (PHASES) ############################### diff --git a/modules/29_cropland/rulebased/declarations.gms b/modules/29_cropland/rulebased_apr24/declarations.gms similarity index 51% rename from modules/29_cropland/rulebased/declarations.gms rename to modules/29_cropland/rulebased_apr24/declarations.gms index 90d9bf2aa9..de1325dffa 100644 --- a/modules/29_cropland/rulebased/declarations.gms +++ b/modules/29_cropland/rulebased_apr24/declarations.gms @@ -24,9 +24,7 @@ parameters p29_treecover_min_shr(t,j) Minimum share of treecover on cropland (1) - p29_betr_min_shr(t,j) Minimum share of bioenergy trees on cropland (1) p29_treecover_scenario_fader(t_all) Cropland treecover scenario fader (1) - p29_betr_scenario_fader(t_all) Bioenergy trees scenario fader (1) p29_treecover_bii_coeff(bii_class_secd,potnatveg) BII coefficient for cropland treecover (1) p29_carbon_density_ac(t,j,ac,ag_pools) Carbon density for ac and ag_pools (tC per ha) p29_treecover(t,j,ac) Cropland tree cover per age class (mio. ha) @@ -36,17 +34,43 @@ parameters positive variables vm_fallow(j) Fallow land is temporarily fallow cropland (mio. ha) v29_treecover(j,ac) Cropland tree cover per age class (mio. ha) + vm_cost_cropland(j) + v29_cost_treecover_est(j) Establishment cost for cropland tree cover (mio. USD05MER per yr) + v29_cost_treecover_recur(j) Recurring cost for cropland tree cover (mio. USD05MER per yr) ; equations q29_cropland(j) Total cropland calculation (mio. ha) q29_avl_cropland(j) Available cropland constraint (mio. ha) - q29_rotation_max(j,crp29,w) Local maximum rotational constraints (mio. ha) - q29_rotation_min(j,crp29,w) Local minimum rotational constraints (mio. ha) - q29_prod(j,kcr) Production of cropped products (mio. tDM) q29_carbon(j,ag_pools,stockType) Cropland above ground carbon content calculation (mio. tC) - q29_bv_ann(j,potnatveg) Biodiversity value of annual cropland (mio. ha) - q29_bv_per(j,potnatveg) Biodiversity value of perennial cropland (mio. ha) q29_land_snv(j) Land constraint for the SNV policy in cropland areas (mio. ha) q29_land_snv_trans(j) Land transition constraint for SNV policy in cropland areas (mio. ha) + q29_cost_cropland(j) Costs and benefits related to agroforestry (mio. USD05MER per yr) + q29_cost_treecover_est(j) Establishment cost for cropland tree cover (mio. USD05MER per yr) + q29_cost_treecover_recur(j) Recurring cost for cropland tree cover (mio. USD05MER per yr) + q29_treecover_shr(j) Cropland treecover minimum share (mio. ha) + q29_treecover_est(j,ac) Cropland treecover establishment (mio. ha) + q29_treecover_bv(j,potnatveg) Biodiversity value for cropland treecover (Mha) ; + +*#################### R SECTION START (OUTPUT DECLARATIONS) #################### +parameters + ov_fallow(t,j,type) Fallow land is temporarily fallow cropland (mio. ha) + ov29_treecover(t,j,ac,type) Cropland tree cover per age class (mio. ha) + ov_cost_cropland(t,j,type) + ov29_cost_treecover_est(t,j,type) Establishment cost for cropland tree cover (mio. USD05MER per yr) + ov29_cost_treecover_recur(t,j,type) Recurring cost for cropland tree cover (mio. USD05MER per yr) + oq29_cropland(t,j,type) Total cropland calculation (mio. ha) + oq29_avl_cropland(t,j,type) Available cropland constraint (mio. ha) + oq29_carbon(t,j,ag_pools,stockType,type) Cropland above ground carbon content calculation (mio. tC) + oq29_land_snv(t,j,type) Land constraint for the SNV policy in cropland areas (mio. ha) + oq29_land_snv_trans(t,j,type) Land transition constraint for SNV policy in cropland areas (mio. ha) + oq29_cost_cropland(t,j,type) Costs and benefits related to agroforestry (mio. USD05MER per yr) + oq29_cost_treecover_est(t,j,type) Establishment cost for cropland tree cover (mio. USD05MER per yr) + oq29_cost_treecover_recur(t,j,type) Recurring cost for cropland tree cover (mio. USD05MER per yr) + oq29_treecover_shr(t,j,type) Cropland treecover minimum share (mio. ha) + oq29_treecover_est(t,j,ac,type) Cropland treecover establishment (mio. ha) + oq29_treecover_bv(t,j,potnatveg,type) Biodiversity value for cropland treecover (Mha) +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### + diff --git a/modules/29_cropland/rulebased/equations.gms b/modules/29_cropland/rulebased_apr24/equations.gms similarity index 73% rename from modules/29_cropland/rulebased/equations.gms rename to modules/29_cropland/rulebased_apr24/equations.gms index 97bb93f8ad..311a61051c 100644 --- a/modules/29_cropland/rulebased/equations.gms +++ b/modules/29_cropland/rulebased_apr24/equations.gms @@ -48,44 +48,36 @@ q29_carbon(j2,ag_pools,stockType) .. vm_carbon_stock(j2,"crop",ag_pools,stockType) =e= - vm_carbon_stock_crop(j2,ag_pools) + vm_carbon_stock_croparea(j2,ag_pools) + vm_fallow(j2) * sum(ct, fm_carbon_density(ct,j2,"crop",ag_pools)) - + m_carbon_stock_ac(v29_treecover,p31_carbon_density_ac,"ac","ac_sub"); + + m_carbon_stock_ac(v29_treecover,p29_carbon_density_ac,"ac","ac_sub"); - -*' Total agroforestry cost. -*' Cost for bioenergy trees are accounted for in the [30_crop] module. -q61_cost_cropland(j2) .. +q29_cost_cropland(j2) .. vm_cost_cropland(j2) =e= - v61_cost_treecover_est(j2) + v61_cost_treecover_recur(j2); + v29_cost_treecover_est(j2) + v29_cost_treecover_recur(j2); *' Tree cover establishment cost -q61_cost_treecover_est(j2) .. - v61_cost_treecover_est(j2) =e= - sum(ac_est, v61_treecover(j2,ac_est)) * s61_cost_treecover_est * +q29_cost_treecover_est(j2) .. + v29_cost_treecover_est(j2) =e= + sum(ac_est, v29_treecover(j2,ac_est)) * s29_cost_treecover_est * sum((cell(i2,j2),ct),pm_interest(ct,i2)/(1+pm_interest(ct,i2))); *' Tree cover recurring cost -q61_cost_treecover_recur(j2) .. - v61_cost_treecover_recur(j2) =e= - sum(ac_sub, v61_treecover(j2,ac_sub)) * s61_cost_treecover_recur; +q29_cost_treecover_recur(j2) .. + v29_cost_treecover_recur(j2) =e= + sum(ac_sub, v29_treecover(j2,ac_sub)) * s29_cost_treecover_recur; *' Tree cover minimum share -q61_treecover_shr(j2) .. - sum(ac, v61_treecover(j2,ac)) =g= - sum(ct, p61_treecover_min_shr(ct,j2)) * vm_land(j2,"crop"); - -*' Bioenergy tree minimum share -q61_betr_shr(j2) .. - sum(w, vm_area(j2,"betr",w)) =g= - sum(ct, p61_betr_min_shr(ct,j2)) * vm_land(j2,"crop"); +q29_treecover_shr(j2) .. + sum(ac, v29_treecover(j2,ac)) =g= + sum(ct, p29_treecover_min_shr(ct,j2)) * vm_land(j2,"crop"); *' Tree cover establishment -q61_treecover_est(j2,ac_est) .. - v61_treecover(j2,ac_est) =e= sum(ac_est2, v61_treecover(j2,ac_est2))/card(ac_est2); +q29_treecover_est(j2,ac_est) .. + v29_treecover(j2,ac_est) =e= sum(ac_est2, v29_treecover(j2,ac_est2))/card(ac_est2); *' Tree cover biodiversity value -q61_treecover_bv(j2,potnatveg) .. +q29_treecover_bv(j2,potnatveg) .. vm_bv(j2,"crop_tree",potnatveg) =e= - sum(bii_class_secd, sum(ac_to_bii_class_secd(ac,bii_class_secd), v61_treecover(j2,ac)) * - p61_treecover_bii_coeff(bii_class_secd,potnatveg)) * fm_luh2_side_layers(j2,potnatveg); + sum(bii_class_secd, sum(ac_to_bii_class_secd(ac,bii_class_secd), v29_treecover(j2,ac)) * + p29_treecover_bii_coeff(bii_class_secd,potnatveg)) * fm_luh2_side_layers(j2,potnatveg); diff --git a/modules/29_cropland/rulebased_apr24/input.gms b/modules/29_cropland/rulebased_apr24/input.gms new file mode 100644 index 0000000000..658dcd38c1 --- /dev/null +++ b/modules/29_cropland/rulebased_apr24/input.gms @@ -0,0 +1,94 @@ +*** | (C) 2008-2024 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 + +* $setglobal c29_snv_target none +* options: none, by2030, by2020 + +$setglobal c29_marginal_land q33_marginal +* options: all_marginal, q33_marginal, no_marginal + +scalars +s29_snv_shr Share of available cropland that is witheld for other land cover types (1) / 0 / +s29_snv_shr_noselect Share of available cropland that is witheld for other land cover types (1) / 0 / +s29_snv_scenario_start SNV scenario start year / 2020 / +s29_snv_scenario_target SNV scenario target year / 2029 / +s29_snv_relocation_data_x1 First reference value in SNV target cropland data (1) / 0.2 / +s29_snv_relocation_data_x2 Second reference value in SNV target cropland data (1) / 0.5 / + s29_cost_treecover_est Tree cover establishment cost (USD per ha) / 2000 / + s29_cost_treecover_recur Tree cover recurring cost (USD per ha) / 500 / + s29_treecover_plantation Growth curve switch for tree cover on cropland 0=natveg 1=plantations (1) / 0 / + s29_treecover_bii_coeff BII coefficent to be used for tree cover on cropland 0=secondary vegetation 1=timber plantations (1) / 0 / + s29_treecover_decrease Cropland treecover can decrease (1) or not (0) / 0 / + s29_treecover_scenario_start Cropland treecover scenario start year / 2020 / + s29_treecover_scenario_target Cropland treecover scenario target year / 2050 / + s29_treecover_min_shr Share of treecover on cropland (1) / 0.2 / +; + + +* Set-switch for countries affected by regional SNV policy +* Default: all iso countries selected +sets + policy_countries29(iso) countries to be affected by SNV policy / ABW,AFG,AGO,AIA,ALA,ALB,AND,ARE,ARG,ARM, + ASM,ATA,ATF,ATG,AUS,AUT,AZE,BDI,BEL,BEN, + BES,BFA,BGD,BGR,BHR,BHS,BIH,BLM,BLR,BLZ, + BMU,BOL,BRA,BRB,BRN,BTN,BVT,BWA,CAF,CAN, + CCK,CHN,CHE,CHL,CIV,CMR,COD,COG,COK,COL, + COM,CPV,CRI,CUB,CUW,CXR,CYM,CYP,CZE,DEU, + DJI,DMA,DNK,DOM,DZA,ECU,EGY,ERI,ESH,ESP, + EST,ETH,FIN,FJI,FLK,FRA,FRO,FSM,GAB,GBR, + GEO,GGY,GHA,GIB,GIN,GLP,GMB,GNB,GNQ,GRC, + GRD,GRL,GTM,GUF,GUM,GUY,HKG,HMD,HND,HRV, + HTI,HUN,IDN,IMN,IND,IOT,IRL,IRN,IRQ,ISL, + ISR,ITA,JAM,JEY,JOR,JPN,KAZ,KEN,KGZ,KHM, + KIR,KNA,KOR,KWT,LAO,LBN,LBR,LBY,LCA,LIE, + LKA,LSO,LTU,LUX,LVA,MAC,MAF,MAR,MCO,MDA, + MDG,MDV,MEX,MHL,MKD,MLI,MLT,MMR,MNE,MNG, + MNP,MOZ,MRT,MSR,MTQ,MUS,MWI,MYS,MYT,NAM, + NCL,NER,NFK,NGA,NIC,NIU,NLD,NOR,NPL,NRU, + NZL,OMN,PAK,PAN,PCN,PER,PHL,PLW,PNG,POL, + PRI,PRK,PRT,PRY,PSE,PYF,QAT,REU,ROU,RUS, + RWA,SAU,SDN,SEN,SGP,SGS,SHN,SJM,SLB,SLE, + SLV,SMR,SOM,SPM,SRB,SSD,STP,SUR,SVK,SVN, + SWE,SWZ,SXM,SYC,SYR,TCA,TCD,TGO,THA,TJK, + TKL,TKM,TLS,TON,TTO,TUN,TUR,TUV,TWN,TZA, + UGA,UKR,UMI,URY,USA,UZB,VAT,VCT,VEN,VGB, + VIR,VNM,VUT,WLF,WSM,YEM,ZAF,ZMB,ZWE / + +land_snv(land) land types allowed in the SNV policy / secdforest, forestry, past, other / +; + +********* AVAILABLE CROPLAND ******************************************* + +table f29_avl_cropland(j,marginal_land29) Available land area for cropland (mio. ha) +$ondelim +$include "./modules/29_cropland/input/avl_cropland.cs3" +$offdelim +; + +table f29_avl_cropland_iso(iso,marginal_land29) Available land area for cropland at ISO level (mio. ha) +$ondelim +$include "./modules/29_cropland/input/avl_cropland_iso.cs3" +$offdelim +; + +********* SNV TARGET CROPLAND ******************************************* + +table f29_snv_target_cropland(j,relocation_target29) Cropland in 2019 requiring relocation due to SNV policy (mio. ha) +$ondelim +$include "./modules/29_cropland/input/SNVTargetCropland.cs3" +$offdelim +; + +********* Cropland tree cover ******************************************* + +parameter f29_treecover(j) Tree cover on cropland in 2019 (mio. ha) +/ +$ondelim +$include "./modules/29_cropland/input/CroplandTreecover.cs2" +$offdelim +/ +; diff --git a/modules/29_cropland/rulebased_apr24/postsolve.gms b/modules/29_cropland/rulebased_apr24/postsolve.gms new file mode 100644 index 0000000000..eaad1f7dbd --- /dev/null +++ b/modules/29_cropland/rulebased_apr24/postsolve.gms @@ -0,0 +1,76 @@ +*** | (C) 2008-2024 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 + +pc29_treecover(j,ac) = v29_treecover.l(j,ac); + +*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + ov_fallow(t,j,"marginal") = vm_fallow.m(j); + ov29_treecover(t,j,ac,"marginal") = v29_treecover.m(j,ac); + ov_cost_cropland(t,j,"marginal") = vm_cost_cropland.m(j); + ov29_cost_treecover_est(t,j,"marginal") = v29_cost_treecover_est.m(j); + ov29_cost_treecover_recur(t,j,"marginal") = v29_cost_treecover_recur.m(j); + oq29_cropland(t,j,"marginal") = q29_cropland.m(j); + oq29_avl_cropland(t,j,"marginal") = q29_avl_cropland.m(j); + oq29_carbon(t,j,ag_pools,stockType,"marginal") = q29_carbon.m(j,ag_pools,stockType); + oq29_land_snv(t,j,"marginal") = q29_land_snv.m(j); + oq29_land_snv_trans(t,j,"marginal") = q29_land_snv_trans.m(j); + oq29_cost_cropland(t,j,"marginal") = q29_cost_cropland.m(j); + oq29_cost_treecover_est(t,j,"marginal") = q29_cost_treecover_est.m(j); + oq29_cost_treecover_recur(t,j,"marginal") = q29_cost_treecover_recur.m(j); + oq29_treecover_shr(t,j,"marginal") = q29_treecover_shr.m(j); + oq29_treecover_est(t,j,ac,"marginal") = q29_treecover_est.m(j,ac); + oq29_treecover_bv(t,j,potnatveg,"marginal") = q29_treecover_bv.m(j,potnatveg); + ov_fallow(t,j,"level") = vm_fallow.l(j); + ov29_treecover(t,j,ac,"level") = v29_treecover.l(j,ac); + ov_cost_cropland(t,j,"level") = vm_cost_cropland.l(j); + ov29_cost_treecover_est(t,j,"level") = v29_cost_treecover_est.l(j); + ov29_cost_treecover_recur(t,j,"level") = v29_cost_treecover_recur.l(j); + oq29_cropland(t,j,"level") = q29_cropland.l(j); + oq29_avl_cropland(t,j,"level") = q29_avl_cropland.l(j); + oq29_carbon(t,j,ag_pools,stockType,"level") = q29_carbon.l(j,ag_pools,stockType); + oq29_land_snv(t,j,"level") = q29_land_snv.l(j); + oq29_land_snv_trans(t,j,"level") = q29_land_snv_trans.l(j); + oq29_cost_cropland(t,j,"level") = q29_cost_cropland.l(j); + oq29_cost_treecover_est(t,j,"level") = q29_cost_treecover_est.l(j); + oq29_cost_treecover_recur(t,j,"level") = q29_cost_treecover_recur.l(j); + oq29_treecover_shr(t,j,"level") = q29_treecover_shr.l(j); + oq29_treecover_est(t,j,ac,"level") = q29_treecover_est.l(j,ac); + oq29_treecover_bv(t,j,potnatveg,"level") = q29_treecover_bv.l(j,potnatveg); + ov_fallow(t,j,"upper") = vm_fallow.up(j); + ov29_treecover(t,j,ac,"upper") = v29_treecover.up(j,ac); + ov_cost_cropland(t,j,"upper") = vm_cost_cropland.up(j); + ov29_cost_treecover_est(t,j,"upper") = v29_cost_treecover_est.up(j); + ov29_cost_treecover_recur(t,j,"upper") = v29_cost_treecover_recur.up(j); + oq29_cropland(t,j,"upper") = q29_cropland.up(j); + oq29_avl_cropland(t,j,"upper") = q29_avl_cropland.up(j); + oq29_carbon(t,j,ag_pools,stockType,"upper") = q29_carbon.up(j,ag_pools,stockType); + oq29_land_snv(t,j,"upper") = q29_land_snv.up(j); + oq29_land_snv_trans(t,j,"upper") = q29_land_snv_trans.up(j); + oq29_cost_cropland(t,j,"upper") = q29_cost_cropland.up(j); + oq29_cost_treecover_est(t,j,"upper") = q29_cost_treecover_est.up(j); + oq29_cost_treecover_recur(t,j,"upper") = q29_cost_treecover_recur.up(j); + oq29_treecover_shr(t,j,"upper") = q29_treecover_shr.up(j); + oq29_treecover_est(t,j,ac,"upper") = q29_treecover_est.up(j,ac); + oq29_treecover_bv(t,j,potnatveg,"upper") = q29_treecover_bv.up(j,potnatveg); + ov_fallow(t,j,"lower") = vm_fallow.lo(j); + ov29_treecover(t,j,ac,"lower") = v29_treecover.lo(j,ac); + ov_cost_cropland(t,j,"lower") = vm_cost_cropland.lo(j); + ov29_cost_treecover_est(t,j,"lower") = v29_cost_treecover_est.lo(j); + ov29_cost_treecover_recur(t,j,"lower") = v29_cost_treecover_recur.lo(j); + oq29_cropland(t,j,"lower") = q29_cropland.lo(j); + oq29_avl_cropland(t,j,"lower") = q29_avl_cropland.lo(j); + oq29_carbon(t,j,ag_pools,stockType,"lower") = q29_carbon.lo(j,ag_pools,stockType); + oq29_land_snv(t,j,"lower") = q29_land_snv.lo(j); + oq29_land_snv_trans(t,j,"lower") = q29_land_snv_trans.lo(j); + oq29_cost_cropland(t,j,"lower") = q29_cost_cropland.lo(j); + oq29_cost_treecover_est(t,j,"lower") = q29_cost_treecover_est.lo(j); + oq29_cost_treecover_recur(t,j,"lower") = q29_cost_treecover_recur.lo(j); + oq29_treecover_shr(t,j,"lower") = q29_treecover_shr.lo(j); + oq29_treecover_est(t,j,ac,"lower") = q29_treecover_est.lo(j,ac); + oq29_treecover_bv(t,j,potnatveg,"lower") = q29_treecover_bv.lo(j,potnatveg); +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### + diff --git a/modules/29_cropland/rulebased/preloop.gms b/modules/29_cropland/rulebased_apr24/preloop.gms similarity index 75% rename from modules/29_cropland/rulebased/preloop.gms rename to modules/29_cropland/rulebased_apr24/preloop.gms index 391e38fe5a..3405958479 100644 --- a/modules/29_cropland/rulebased/preloop.gms +++ b/modules/29_cropland/rulebased_apr24/preloop.gms @@ -10,7 +10,6 @@ vm_fallow.fx(j) = 0; ** Trajectory for cropland scenarios * sigmoidal interpolation between start year and target year m_sigmoid_time_interpol(p29_snv_scenario_fader,s29_snv_scenario_start,s29_snv_scenario_target,0,1); -m_sigmoid_time_interpol(p29_rotation_scenario_fader,s29_rotation_scenario_start,s29_rotation_scenario_target,0,1); * linear interpolation to estimate the cropland that * requires relocation due to SNV policy @@ -26,7 +25,7 @@ m_linear_cell_data_interpol(i29_snv_relocation_target, s29_snv_shr,s29_snv_reloc m_sigmoid_time_interpol(p29_treecover_scenario_fader,s29_treecover_scenario_start,s29_treecover_scenario_target,0,1); -m_sigmoid_time_interpol(p29_betr_scenario_fader,s29_betr_scenario_start,s29_betr_scenario_target,0,1); + * Initial tree cover on cropland is assumed to be equally distributed among all age-classes pc29_treecover(j,ac) = 0; @@ -50,3 +49,15 @@ if(s29_treecover_bii_coeff = 0, elseif s29_treecover_bii_coeff = 1, p29_treecover_bii_coeff(bii_class_secd,potnatveg) = fm_bii_coeff("timber",potnatveg) ); + + +****** Regional share of semi-natural vegetation (SNV) in cropland areas for selective countries: +* Country switch to determine countries for which a SNV policy shall be applied. +* In the default case, the SNV policy affects all countries when activated. +p29_country_dummy(iso) = 0; +p29_country_dummy(policy_countries29) = 1; +* Because MAgPIE is not run at country-level, but at region level, a region +* share is calculated that translates the countries' influence to regional level. +* Countries are weighted by available cropland area. +i29_avl_cropland_iso(iso) = f29_avl_cropland_iso(iso,"%c29_marginal_land%"); +p29_country_snv_weight(i) = sum(i_to_iso(i,iso), p29_country_dummy(iso) * i29_avl_cropland_iso(iso)) / sum(i_to_iso(i,iso), i29_avl_cropland_iso(iso)); diff --git a/modules/29_cropland/rulebased/presolve.gms b/modules/29_cropland/rulebased_apr24/presolve.gms similarity index 67% rename from modules/29_cropland/rulebased/presolve.gms rename to modules/29_cropland/rulebased_apr24/presolve.gms index 8c36c85212..19a3b0a657 100644 --- a/modules/29_cropland/rulebased/presolve.gms +++ b/modules/29_cropland/rulebased_apr24/presolve.gms @@ -31,31 +31,31 @@ p29_avl_cropland(t,j) = f29_avl_cropland(j,"%c29_marginal_land%") * (1 - p29_snv * Growth of trees on cropland is modelled by shifting age-classes according to time step length. -s61_shift = m_timestep_length_forestry/5; -* example: ac10 in t = ac5 (ac10-1) in t-1 for a 5 yr time step (s61_shift = 1) - p61_treecover(t,j,ac)$(ord(ac) > s61_shift) = pc61_treecover(j,ac-s61_shift); -* account for cases at the end of the age class set (s61_shift > 1) which are not shifted by the above calculation - p61_treecover(t,j,"acx") = p61_treecover(t,j,"acx") - + sum(ac$(ord(ac) > card(ac)-s61_shift), pc61_treecover(j,ac)); - -pc61_treecover(j,ac) = p61_treecover(t,j,ac); -v61_treecover.l(j,ac) = p61_treecover(t,j,ac); - -if(m_year(t) <= s61_treecover_scenario_start, - v61_treecover.fx(j,ac) = pc61_treecover(j,ac); +s29_shift = m_timestep_length_forestry/5; +* example: ac10 in t = ac5 (ac10-1) in t-1 for a 5 yr time step (s29_shift = 1) + p29_treecover(t,j,ac)$(ord(ac) > s29_shift) = pc29_treecover(j,ac-s29_shift); +* account for cases at the end of the age class set (s29_shift > 1) which are not shifted by the above calculation + p29_treecover(t,j,"acx") = p29_treecover(t,j,"acx") + + sum(ac$(ord(ac) > card(ac)-s29_shift), pc29_treecover(j,ac)); + +pc29_treecover(j,ac) = p29_treecover(t,j,ac); +v29_treecover.l(j,ac) = p29_treecover(t,j,ac); + +if(m_year(t) <= s29_treecover_scenario_start, + v29_treecover.fx(j,ac) = pc29_treecover(j,ac); else - v61_treecover.lo(j,ac_est) = 0; - v61_treecover.up(j,ac_est) = Inf; - if(s61_treecover_decrease = 1, - v61_treecover.lo(j,ac_sub) = 0; - v61_treecover.up(j,ac_sub) = pc61_treecover(j,ac_sub); + v29_treecover.lo(j,ac_est) = 0; + v29_treecover.up(j,ac_est) = Inf; + if(s29_treecover_decrease = 1, + v29_treecover.lo(j,ac_sub) = 0; + v29_treecover.up(j,ac_sub) = pc29_treecover(j,ac_sub); else - v61_treecover.fx(j,ac_sub) = pc61_treecover(j,ac_sub); + v29_treecover.fx(j,ac_sub) = pc29_treecover(j,ac_sub); ); ); -p61_treecover_min_shr(t,j) = - ((1-p61_treecover_scenario_fader(t)) * pm_treecover_shr(j)) + - (p61_treecover_scenario_fader(t) * s61_treecover_min_shr); +p29_treecover_min_shr(t,j) = + ((1-p29_treecover_scenario_fader(t)) * sum(ac, pc29_treecover(j,ac))/pcm_land(j,"crop"))$(pcm_land(j,"crop") > 1e-10) + + (p29_treecover_scenario_fader(t) * s29_treecover_min_shr); + -p61_betr_min_shr(t,j) = p61_betr_scenario_fader(t) * s61_betr_min_shr; diff --git a/modules/29_cropland/rulebased_apr24/realization.gms b/modules/29_cropland/rulebased_apr24/realization.gms new file mode 100644 index 0000000000..cec1ad89fc --- /dev/null +++ b/modules/29_cropland/rulebased_apr24/realization.gms @@ -0,0 +1,20 @@ +*** | (C) 2008-2024 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 todo + +*' @limitations todo + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/29_cropland/rulebased_apr24/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/29_cropland/rulebased_apr24/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/29_cropland/rulebased_apr24/input.gms" +$Ifi "%phase%" == "equations" $include "./modules/29_cropland/rulebased_apr24/equations.gms" +$Ifi "%phase%" == "preloop" $include "./modules/29_cropland/rulebased_apr24/preloop.gms" +$Ifi "%phase%" == "presolve" $include "./modules/29_cropland/rulebased_apr24/presolve.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/29_cropland/rulebased_apr24/postsolve.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/29_cropland/rulebased/sets.gms b/modules/29_cropland/rulebased_apr24/sets.gms similarity index 73% rename from modules/29_cropland/rulebased/sets.gms rename to modules/29_cropland/rulebased_apr24/sets.gms index a74b51c7de..e5d8286326 100644 --- a/modules/29_cropland/rulebased/sets.gms +++ b/modules/29_cropland/rulebased_apr24/sets.gms @@ -7,13 +7,13 @@ sets - marginal_land30 Marginal land scenarios + marginal_land29 Marginal land scenarios / all_marginal, q33_marginal, no_marginal / - policy_target30 Target year for cropland policy - / none, by2030, by2050 / + policy_target29 Target year for cropland policy + / none, by2029, by2050 / - relocation_target30 Cropland requiring relocation based on different SNV targets + relocation_target29 Cropland requiring relocation based on different SNV targets / SNV20TargetCropland, SNV50TargetCropland / ; diff --git a/modules/30_crop/endo_apr21/declarations.gms b/modules/30_crop/endo_apr21/declarations.gms index 07792a6246..fe0f504c4d 100644 --- a/modules/30_crop/endo_apr21/declarations.gms +++ b/modules/30_crop/endo_apr21/declarations.gms @@ -7,6 +7,8 @@ parameters p30_rotation_scenario_fader(t_all) Crop rotation scenario fader (1) + p30_betr_scenario_fader(t_all) Bioenergy trees scenario fader (1) + p30_betr_min_shr(t,j) Minimum share of bioenergy trees on cropland (1) ; positive variables @@ -16,9 +18,10 @@ positive variables ; equations + q30_prod(j,kcr) Production of cropped products (mio. tDM) q30_rotation_max(j,crp30,w) Local maximum rotational constraints (mio. ha) q30_rotation_min(j,crp30,w) Local minimum rotational constraints (mio. ha) - q30_prod(j,kcr) Production of cropped products (mio. tDM) + q30_betr_shr(j) Bioenergy trees minimum share (mio. ha) q30_carbon(j,ag_pools) Croplarea above ground carbon content calculation (mio. tC) q30_bv_ann(j,potnatveg) Biodiversity value of annual cropland (mio. ha) q30_bv_per(j,potnatveg) Biodiversity value of perennial cropland (mio. ha) @@ -26,19 +29,16 @@ equations *#################### R SECTION START (OUTPUT DECLARATIONS) #################### parameters - ov_fallow(t,j,type) Fallow land (mio. ha) - ov_area(t,j,kcr,w,type) Agricultural production area (mio. ha) - ov_rotation_penalty(t,i,type) Penalty for violating rotational constraints (USD05MER) - oq30_cropland(t,j,type) Total cropland calculation (mio. ha) - oq30_avl_cropland(t,j,type) Available cropland constraint (mio. ha) - oq30_rotation_max(t,j,crp30,w,type) Local maximum rotational constraints (mio. ha) - oq30_rotation_min(t,j,crp30,w,type) Local minimum rotational constraints (mio. ha) - oq30_prod(t,j,kcr,type) Production of cropped products (mio. tDM) - oq30_carbon(t,j,ag_pools,stockType,type) Cropland above ground carbon content calculation (mio. tC) - oq30_bv_ann(t,j,potnatveg,type) Biodiversity value of annual cropland (mio. ha) - oq30_bv_per(t,j,potnatveg,type) Biodiversity value of perennial cropland (mio. ha) - oq30_land_snv(t,j,type) Land constraint for the SNV policy in cropland areas (mio. ha) - oq30_land_snv_trans(t,j,type) Land transition constraint for SNV policy in cropland areas (mio. ha) + ov_area(t,j,kcr,w,type) Agricultural production area (mio. ha) + ov_rotation_penalty(t,i,type) Penalty for violating rotational constraints (USD05MER) + ov_carbon_stock_croparea(t,j,ag_pools,type) Carbon stock in croparea (tC) + oq30_prod(t,j,kcr,type) Production of cropped products (mio. tDM) + oq30_rotation_max(t,j,crp30,w,type) Local maximum rotational constraints (mio. ha) + oq30_rotation_min(t,j,crp30,w,type) Local minimum rotational constraints (mio. ha) + oq30_betr_shr(t,j,type) Bioenergy trees minimum share (mio. ha) + oq30_carbon(t,j,ag_pools,type) Croplarea above ground carbon content calculation (mio. tC) + oq30_bv_ann(t,j,potnatveg,type) Biodiversity value of annual cropland (mio. ha) + oq30_bv_per(t,j,potnatveg,type) Biodiversity value of perennial cropland (mio. ha) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/30_crop/endo_apr21/equations.gms b/modules/30_crop/endo_apr21/equations.gms index ad815cdec0..abb8d23f5e 100644 --- a/modules/30_crop/endo_apr21/equations.gms +++ b/modules/30_crop/endo_apr21/equations.gms @@ -33,7 +33,8 @@ sum(kcr, vm_area(j2,kcr,w)) * f30_rotation_min_shr(crpmin30); -*' Bioenergy tree minimum share +*' Bioenergy tree minimum share on cropland + q30_betr_shr(j2) .. sum(w, vm_area(j2,"betr",w)) =g= sum(ct, p30_betr_min_shr(ct,j2)) * vm_land(j2,"crop"); diff --git a/modules/30_crop/endo_apr21/input.gms b/modules/30_crop/endo_apr21/input.gms index 2ccc267364..1ae154a2a6 100644 --- a/modules/30_crop/endo_apr21/input.gms +++ b/modules/30_crop/endo_apr21/input.gms @@ -11,56 +11,15 @@ $setglobal c30_bioen_type all $setglobal c30_bioen_water rainfed * options: rainfed, irrigated, all -$setglobal c30_marginal_land q33_marginal -* options: all_marginal, q33_marginal, no_marginal - -$setglobal c30_snv_target none -* options: none, by2030, by2020 - $setglobal c30_rotation_constraints on *options: on, off scalars -s30_snv_shr Share of available cropland that is witheld for other land cover types (1) / 0 / -s30_snv_shr_noselect Share of available cropland that is witheld for other land cover types (1) / 0 / -s30_snv_scenario_start SNV scenario start year / 2020 / -s30_snv_scenario_target SNV scenario target year / 2030 / -s30_snv_relocation_data_x1 First reference value in SNV target cropland data (1) / 0.2 / -s30_snv_relocation_data_x2 Second reference value in SNV target cropland data (1) / 0.5 / -s30_rotation_scenario_start Rotation scenario start year / 2020 / -s30_rotation_scenario_target Rotation scenario target year / 2050 / -; - -* Set-switch for countries affected by regional SNV policy -* Default: all iso countries selected -sets - policy_countries30(iso) countries to be affected by SNV policy / ABW,AFG,AGO,AIA,ALA,ALB,AND,ARE,ARG,ARM, - ASM,ATA,ATF,ATG,AUS,AUT,AZE,BDI,BEL,BEN, - BES,BFA,BGD,BGR,BHR,BHS,BIH,BLM,BLR,BLZ, - BMU,BOL,BRA,BRB,BRN,BTN,BVT,BWA,CAF,CAN, - CCK,CHN,CHE,CHL,CIV,CMR,COD,COG,COK,COL, - COM,CPV,CRI,CUB,CUW,CXR,CYM,CYP,CZE,DEU, - DJI,DMA,DNK,DOM,DZA,ECU,EGY,ERI,ESH,ESP, - EST,ETH,FIN,FJI,FLK,FRA,FRO,FSM,GAB,GBR, - GEO,GGY,GHA,GIB,GIN,GLP,GMB,GNB,GNQ,GRC, - GRD,GRL,GTM,GUF,GUM,GUY,HKG,HMD,HND,HRV, - HTI,HUN,IDN,IMN,IND,IOT,IRL,IRN,IRQ,ISL, - ISR,ITA,JAM,JEY,JOR,JPN,KAZ,KEN,KGZ,KHM, - KIR,KNA,KOR,KWT,LAO,LBN,LBR,LBY,LCA,LIE, - LKA,LSO,LTU,LUX,LVA,MAC,MAF,MAR,MCO,MDA, - MDG,MDV,MEX,MHL,MKD,MLI,MLT,MMR,MNE,MNG, - MNP,MOZ,MRT,MSR,MTQ,MUS,MWI,MYS,MYT,NAM, - NCL,NER,NFK,NGA,NIC,NIU,NLD,NOR,NPL,NRU, - NZL,OMN,PAK,PAN,PCN,PER,PHL,PLW,PNG,POL, - PRI,PRK,PRT,PRY,PSE,PYF,QAT,REU,ROU,RUS, - RWA,SAU,SDN,SEN,SGP,SGS,SHN,SJM,SLB,SLE, - SLV,SMR,SOM,SPM,SRB,SSD,STP,SUR,SVK,SVN, - SWE,SWZ,SXM,SYC,SYR,TCA,TCD,TGO,THA,TJK, - TKL,TKM,TLS,TON,TTO,TUN,TUR,TUV,TWN,TZA, - UGA,UKR,UMI,URY,USA,UZB,VAT,VCT,VEN,VGB, - VIR,VNM,VUT,WLF,WSM,YEM,ZAF,ZMB,ZWE / - -land_snv(land) land types allowed in the SNV policy / secdforest, forestry, past, other / + s30_rotation_scenario_start Rotation scenario start year / 2020 / + s30_rotation_scenario_target Rotation scenario target year / 2050 / + s30_betr_min_shr Minimum share of bioenergy trees on cropland (1) / 0 / + s30_betr_scenario_start Bioenergy trees scenario start year / 2020 / + s30_betr_scenario_target Bioenergy trees scenario target year / 2050 / ; $ifthen "%c30_bioen_type%" == "all" bioen_type_30(kbe30) = yes; diff --git a/modules/30_crop/endo_apr21/input/files b/modules/30_crop/endo_apr21/input/files index d0cfbda228..f87525bfbd 100644 --- a/modules/30_crop/endo_apr21/input/files +++ b/modules/30_crop/endo_apr21/input/files @@ -1,9 +1,4 @@ * list of files that are required here f30_rotation_max.csv f30_rotation_min.csv -avl_cropland.cs3 -avl_cropland_0.5.mz f30_croparea_w_initialisation.cs3 -avl_cropland_iso.cs3 -SNVTargetCropland.cs3 -SNVTargetCropland_0.5.mz diff --git a/modules/30_crop/endo_apr21/postsolve.gms b/modules/30_crop/endo_apr21/postsolve.gms index c423e44bba..99044317e0 100644 --- a/modules/30_crop/endo_apr21/postsolve.gms +++ b/modules/30_crop/endo_apr21/postsolve.gms @@ -7,56 +7,44 @@ *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov_fallow(t,j,"marginal") = vm_fallow.m(j); - ov_area(t,j,kcr,w,"marginal") = vm_area.m(j,kcr,w); - ov_rotation_penalty(t,i,"marginal") = vm_rotation_penalty.m(i); - oq30_cropland(t,j,"marginal") = q30_cropland.m(j); - oq30_avl_cropland(t,j,"marginal") = q30_avl_cropland.m(j); - oq30_rotation_max(t,j,crp30,w,"marginal") = q30_rotation_max.m(j,crp30,w); - oq30_rotation_min(t,j,crp30,w,"marginal") = q30_rotation_min.m(j,crp30,w); - oq30_prod(t,j,kcr,"marginal") = q30_prod.m(j,kcr); - oq30_carbon(t,j,ag_pools,stockType,"marginal") = q30_carbon.m(j,ag_pools,stockType); - oq30_bv_ann(t,j,potnatveg,"marginal") = q30_bv_ann.m(j,potnatveg); - oq30_bv_per(t,j,potnatveg,"marginal") = q30_bv_per.m(j,potnatveg); - oq30_land_snv(t,j,"marginal") = q30_land_snv.m(j); - oq30_land_snv_trans(t,j,"marginal") = q30_land_snv_trans.m(j); - ov_fallow(t,j,"level") = vm_fallow.l(j); - ov_area(t,j,kcr,w,"level") = vm_area.l(j,kcr,w); - ov_rotation_penalty(t,i,"level") = vm_rotation_penalty.l(i); - oq30_cropland(t,j,"level") = q30_cropland.l(j); - oq30_avl_cropland(t,j,"level") = q30_avl_cropland.l(j); - oq30_rotation_max(t,j,crp30,w,"level") = q30_rotation_max.l(j,crp30,w); - oq30_rotation_min(t,j,crp30,w,"level") = q30_rotation_min.l(j,crp30,w); - oq30_prod(t,j,kcr,"level") = q30_prod.l(j,kcr); - oq30_carbon(t,j,ag_pools,stockType,"level") = q30_carbon.l(j,ag_pools,stockType); - oq30_bv_ann(t,j,potnatveg,"level") = q30_bv_ann.l(j,potnatveg); - oq30_bv_per(t,j,potnatveg,"level") = q30_bv_per.l(j,potnatveg); - oq30_land_snv(t,j,"level") = q30_land_snv.l(j); - oq30_land_snv_trans(t,j,"level") = q30_land_snv_trans.l(j); - ov_fallow(t,j,"upper") = vm_fallow.up(j); - ov_area(t,j,kcr,w,"upper") = vm_area.up(j,kcr,w); - ov_rotation_penalty(t,i,"upper") = vm_rotation_penalty.up(i); - oq30_cropland(t,j,"upper") = q30_cropland.up(j); - oq30_avl_cropland(t,j,"upper") = q30_avl_cropland.up(j); - oq30_rotation_max(t,j,crp30,w,"upper") = q30_rotation_max.up(j,crp30,w); - oq30_rotation_min(t,j,crp30,w,"upper") = q30_rotation_min.up(j,crp30,w); - oq30_prod(t,j,kcr,"upper") = q30_prod.up(j,kcr); - oq30_carbon(t,j,ag_pools,stockType,"upper") = q30_carbon.up(j,ag_pools,stockType); - oq30_bv_ann(t,j,potnatveg,"upper") = q30_bv_ann.up(j,potnatveg); - oq30_bv_per(t,j,potnatveg,"upper") = q30_bv_per.up(j,potnatveg); - oq30_land_snv(t,j,"upper") = q30_land_snv.up(j); - oq30_land_snv_trans(t,j,"upper") = q30_land_snv_trans.up(j); - ov_fallow(t,j,"lower") = vm_fallow.lo(j); - ov_area(t,j,kcr,w,"lower") = vm_area.lo(j,kcr,w); - ov_rotation_penalty(t,i,"lower") = vm_rotation_penalty.lo(i); - oq30_cropland(t,j,"lower") = q30_cropland.lo(j); - oq30_avl_cropland(t,j,"lower") = q30_avl_cropland.lo(j); - oq30_rotation_max(t,j,crp30,w,"lower") = q30_rotation_max.lo(j,crp30,w); - oq30_rotation_min(t,j,crp30,w,"lower") = q30_rotation_min.lo(j,crp30,w); - oq30_prod(t,j,kcr,"lower") = q30_prod.lo(j,kcr); - oq30_carbon(t,j,ag_pools,stockType,"lower") = q30_carbon.lo(j,ag_pools,stockType); - oq30_bv_ann(t,j,potnatveg,"lower") = q30_bv_ann.lo(j,potnatveg); - oq30_bv_per(t,j,potnatveg,"lower") = q30_bv_per.lo(j,potnatveg); - oq30_land_snv(t,j,"lower") = q30_land_snv.lo(j); - oq30_land_snv_trans(t,j,"lower") = q30_land_snv_trans.lo(j); + ov_area(t,j,kcr,w,"marginal") = vm_area.m(j,kcr,w); + ov_rotation_penalty(t,i,"marginal") = vm_rotation_penalty.m(i); + ov_carbon_stock_croparea(t,j,ag_pools,"marginal") = vm_carbon_stock_croparea.m(j,ag_pools); + oq30_prod(t,j,kcr,"marginal") = q30_prod.m(j,kcr); + oq30_rotation_max(t,j,crp30,w,"marginal") = q30_rotation_max.m(j,crp30,w); + oq30_rotation_min(t,j,crp30,w,"marginal") = q30_rotation_min.m(j,crp30,w); + oq30_betr_shr(t,j,"marginal") = q30_betr_shr.m(j); + oq30_carbon(t,j,ag_pools,"marginal") = q30_carbon.m(j,ag_pools); + oq30_bv_ann(t,j,potnatveg,"marginal") = q30_bv_ann.m(j,potnatveg); + oq30_bv_per(t,j,potnatveg,"marginal") = q30_bv_per.m(j,potnatveg); + ov_area(t,j,kcr,w,"level") = vm_area.l(j,kcr,w); + ov_rotation_penalty(t,i,"level") = vm_rotation_penalty.l(i); + ov_carbon_stock_croparea(t,j,ag_pools,"level") = vm_carbon_stock_croparea.l(j,ag_pools); + oq30_prod(t,j,kcr,"level") = q30_prod.l(j,kcr); + oq30_rotation_max(t,j,crp30,w,"level") = q30_rotation_max.l(j,crp30,w); + oq30_rotation_min(t,j,crp30,w,"level") = q30_rotation_min.l(j,crp30,w); + oq30_betr_shr(t,j,"level") = q30_betr_shr.l(j); + oq30_carbon(t,j,ag_pools,"level") = q30_carbon.l(j,ag_pools); + oq30_bv_ann(t,j,potnatveg,"level") = q30_bv_ann.l(j,potnatveg); + oq30_bv_per(t,j,potnatveg,"level") = q30_bv_per.l(j,potnatveg); + ov_area(t,j,kcr,w,"upper") = vm_area.up(j,kcr,w); + ov_rotation_penalty(t,i,"upper") = vm_rotation_penalty.up(i); + ov_carbon_stock_croparea(t,j,ag_pools,"upper") = vm_carbon_stock_croparea.up(j,ag_pools); + oq30_prod(t,j,kcr,"upper") = q30_prod.up(j,kcr); + oq30_rotation_max(t,j,crp30,w,"upper") = q30_rotation_max.up(j,crp30,w); + oq30_rotation_min(t,j,crp30,w,"upper") = q30_rotation_min.up(j,crp30,w); + oq30_betr_shr(t,j,"upper") = q30_betr_shr.up(j); + oq30_carbon(t,j,ag_pools,"upper") = q30_carbon.up(j,ag_pools); + oq30_bv_ann(t,j,potnatveg,"upper") = q30_bv_ann.up(j,potnatveg); + oq30_bv_per(t,j,potnatveg,"upper") = q30_bv_per.up(j,potnatveg); + ov_area(t,j,kcr,w,"lower") = vm_area.lo(j,kcr,w); + ov_rotation_penalty(t,i,"lower") = vm_rotation_penalty.lo(i); + ov_carbon_stock_croparea(t,j,ag_pools,"lower") = vm_carbon_stock_croparea.lo(j,ag_pools); + oq30_prod(t,j,kcr,"lower") = q30_prod.lo(j,kcr); + oq30_rotation_max(t,j,crp30,w,"lower") = q30_rotation_max.lo(j,crp30,w); + oq30_rotation_min(t,j,crp30,w,"lower") = q30_rotation_min.lo(j,crp30,w); + oq30_betr_shr(t,j,"lower") = q30_betr_shr.lo(j); + oq30_carbon(t,j,ag_pools,"lower") = q30_carbon.lo(j,ag_pools); + oq30_bv_ann(t,j,potnatveg,"lower") = q30_bv_ann.lo(j,potnatveg); + oq30_bv_per(t,j,potnatveg,"lower") = q30_bv_per.lo(j,potnatveg); *##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/30_crop/endo_apr21/preloop.gms b/modules/30_crop/endo_apr21/preloop.gms index e4b01bc732..a837359f18 100644 --- a/modules/30_crop/endo_apr21/preloop.gms +++ b/modules/30_crop/endo_apr21/preloop.gms @@ -8,19 +8,10 @@ ** Trajectory for cropland scenarios * sigmoidal interpolation between start year and target year m_sigmoid_time_interpol(p30_rotation_scenario_fader,s30_rotation_scenario_start,s30_rotation_scenario_target,0,1); +m_sigmoid_time_interpol(p30_betr_scenario_fader,s30_betr_scenario_start,s30_betr_scenario_target,0,1); *due to some rounding errors the input data currently may contain in some cases *very small, negative numbers. These numbers have to be set to 0 as area *cannot be smaller than 0! fm_croparea(t_past,j,w,kcr)$(fm_croparea(t_past,j,w,kcr)<0) = 0; -****** Regional share of semi-natural vegetation (SNV) in cropland areas for selective countries: -* Country switch to determine countries for which a SNV policy shall be applied. -* In the default case, the SNV policy affects all countries when activated. -p30_country_dummy(iso) = 0; -p30_country_dummy(policy_countries30) = 1; -* Because MAgPIE is not run at country-level, but at region level, a region -* share is calculated that translates the countries' influence to regional level. -* Countries are weighted by available cropland area. -i30_avl_cropland_iso(iso) = f30_avl_cropland_iso(iso,"%c30_marginal_land%"); -p30_country_snv_weight(i) = sum(i_to_iso(i,iso), p30_country_dummy(iso) * i30_avl_cropland_iso(iso)) / sum(i_to_iso(i,iso), i30_avl_cropland_iso(iso)); diff --git a/modules/30_crop/endo_apr21/presolve.gms b/modules/30_crop/endo_apr21/presolve.gms index 942042b0e9..57661d9303 100644 --- a/modules/30_crop/endo_apr21/presolve.gms +++ b/modules/30_crop/endo_apr21/presolve.gms @@ -25,3 +25,5 @@ vm_rotation_penalty.fx(i)=0; crpmax30(crp30) = yes$(f30_rotation_max_shr(crp30) < 1); crpmin30(crp30) = yes$(f30_rotation_min_shr(crp30) > 0); + +p30_betr_min_shr(t,j) = p30_betr_scenario_fader(t) * s30_betr_min_shr; diff --git a/modules/30_crop/penalty_apr22/declarations.gms b/modules/30_crop/penalty_apr22/declarations.gms index 6c6ce00698..2d3d2eeebe 100644 --- a/modules/30_crop/penalty_apr22/declarations.gms +++ b/modules/30_crop/penalty_apr22/declarations.gms @@ -13,40 +13,37 @@ parameters positive variables vm_area(j,kcr,w) Agricultural production area (mio. ha) vm_rotation_penalty(i) Penalty for violating rotational constraints (mio. USD05MER) + vm_carbon_stock_croparea(j,ag_pools) Carbon stock in croparea (tC) v30_penalty_max_irrig(j,rotamax30) Penalty for violating max rotational constraints on irrigated land (mio. USD05MER) - v30_penalty(j,rota30) Penalty for violating rotational constraints (mio. USD05MER) + v30_penalty(j,rota30) Penalty for violating rotational constraints (mio. USD05MER) ; equations + q30_prod(j,kcr) Production of cropped products (mio. tDM) q30_rotation_penalty(i) Total penalty for rotational constraint violations (mio. USD05MER) q30_rotation_max(j,rotamax30) Local maximum rotational constraints (mio. ha) q30_rotation_min(j,rotamin30) Local minimum rotational constraints (mio. ha) q30_rotation_max_irrig(j,rotamax30) Local maximum rotational constraints (mio. ha) - q30_prod(j,kcr) Production of cropped products (mio. tDM) - q30_carbon(j,ag_pools) Croparea above ground carbon content calculation (mio. tC) + q30_carbon(j,ag_pools) Croplarea above ground carbon content calculation (mio. tC) q30_bv_ann(j,potnatveg) Biodiversity value of annual cropland (mio. ha) q30_bv_per(j,potnatveg) Biodiversity value of perennial cropland (mio. ha) ; *#################### R SECTION START (OUTPUT DECLARATIONS) #################### parameters - ov_fallow(t,j,type) Fallow land (mio. ha) ov_area(t,j,kcr,w,type) Agricultural production area (mio. ha) ov_rotation_penalty(t,i,type) Penalty for violating rotational constraints (mio. USD05MER) + ov_carbon_stock_croparea(t,j,ag_pools,type) Carbon stock in croparea (tC) ov30_penalty_max_irrig(t,j,rotamax30,type) Penalty for violating max rotational constraints on irrigated land (mio. USD05MER) ov30_penalty(t,j,rota30,type) Penalty for violating rotational constraints (mio. USD05MER) - oq30_cropland(t,j,type) Total cropland calculation (mio. ha) - oq30_avl_cropland(t,j,type) Available cropland constraint (mio. ha) + oq30_prod(t,j,kcr,type) Production of cropped products (mio. tDM) oq30_rotation_penalty(t,i,type) Total penalty for rotational constraint violations (mio. USD05MER) oq30_rotation_max(t,j,rotamax30,type) Local maximum rotational constraints (mio. ha) oq30_rotation_min(t,j,rotamin30,type) Local minimum rotational constraints (mio. ha) oq30_rotation_max_irrig(t,j,rotamax30,type) Local maximum rotational constraints (mio. ha) - oq30_prod(t,j,kcr,type) Production of cropped products (mio. tDM) - oq30_carbon(t,j,ag_pools,stockType,type) Cropland above ground carbon content calculation (mio. tC) + oq30_carbon(t,j,ag_pools,type) Croplarea above ground carbon content calculation (mio. tC) oq30_bv_ann(t,j,potnatveg,type) Biodiversity value of annual cropland (mio. ha) oq30_bv_per(t,j,potnatveg,type) Biodiversity value of perennial cropland (mio. ha) - oq30_land_snv(t,j,type) Land constraint for the SNV policy in cropland areas (mio. ha) - oq30_land_snv_trans(t,j,type) Land transition constraint for SNV policy in cropland areas (mio. ha) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/30_crop/penalty_apr22/equations.gms b/modules/30_crop/penalty_apr22/equations.gms index 669ed0fa84..a44fe1e809 100644 --- a/modules/30_crop/penalty_apr22/equations.gms +++ b/modules/30_crop/penalty_apr22/equations.gms @@ -14,6 +14,7 @@ q30_prod(j2,kcr) .. vm_prod(j2,kcr) =e= sum(w, vm_area(j2,kcr,w) * vm_yld(j2,kcr,w)); + *' Rotational constraints prevent over-specialization. In this module realization, *' they are implemented via a penalty payment if the constraints are violated. @@ -25,6 +26,7 @@ q30_rotation_penalty(i2) .. + sum(rotamax_red30, v30_penalty_max_irrig(j2,rotamax_red30) * sum(ct, i30_rotation_incentives(ct,rotamax_red30))) ); + *' The penalty applies to the areas which exceed a certain maximum *' share of the land. Below this share, negative benefits are *' avoided by defining the penalty to be positive. @@ -35,6 +37,7 @@ q30_rotation_penalty(i2) .. sum((rota_kcr30(rotamax_red30,kcr),w),vm_area(j2,kcr,w)) - vm_land(j2,"crop") * f30_rotation_rules(rotamax_red30); + *' Minimum constraints apply penalties when a certain mimimum *' share of a group is not achieved. This is used to guarantee a minimum *' crop group diversity withing cells. @@ -45,6 +48,7 @@ q30_rotation_penalty(i2) .. vm_land(j2,"crop") * f30_rotation_rules(rotamin_red30) - sum((rota_kcr30(rotamin_red30,kcr),w), vm_area(j2,kcr,w)); + *' The following maximum constraint avoids over-specialization in irrigated systems. *' No minimum constraint is included for irrigated areas for computational *' reasons. Minimum constraints just need to be met on total areas. @@ -55,21 +59,21 @@ q30_rotation_penalty(i2) .. sum((rota_kcr30(rotamax_red30,kcr)), vm_area(j2,kcr,"irrigated")) - vm_AEI(j2) * f30_rotation_rules(rotamax_red30); + *' The carbon stocks of the above ground carbon pools are calculated based on croparea and related carbon density. q30_carbon(j2,ag_pools) .. vm_carbon_stock_croparea(j2,ag_pools) =e= sum((kcr,w), vm_area(j2,kcr,w)) * sum(ct, fm_carbon_density(ct,j2,"crop",ag_pools)); + *' The biodiversity value for cropland is calculated separately for annual and perennial crops: + q30_bv_ann(j2,potnatveg) .. vm_bv(j2,"crop_ann",potnatveg) =e= sum((crop_ann30,w), vm_area(j2,crop_ann30,w)) * fm_bii_coeff("crop_ann",potnatveg) * fm_luh2_side_layers(j2,potnatveg); -*' perennial crops are calculated as difference, as they shall also include fallow land - q30_bv_per(j2,potnatveg) .. - vm_bv(j2,"crop_per",potnatveg) - =e= - (vm_land(j2,"crop") - sum((crop_ann30,w), vm_area(j2,crop_ann30,w))) - * fm_bii_coeff("crop_per",potnatveg) * fm_luh2_side_layers(j2,potnatveg); + q30_bv_per(j2,potnatveg) .. vm_bv(j2,"crop_per",potnatveg) + =e= + sum((crop_per30,w), vm_area(j2,crop_per30,w)) * fm_bii_coeff("crop_per",potnatveg) * fm_luh2_side_layers(j2,potnatveg); diff --git a/modules/30_crop/penalty_apr22/input.gms b/modules/30_crop/penalty_apr22/input.gms index e2f9c2fbac..91befb168a 100644 --- a/modules/30_crop/penalty_apr22/input.gms +++ b/modules/30_crop/penalty_apr22/input.gms @@ -11,12 +11,6 @@ $setglobal c30_bioen_type all $setglobal c30_bioen_water rainfed * options: rainfed, irrigated, all -$setglobal c30_marginal_land q33_marginal -* options: all_marginal, q33_marginal, no_marginal - -$setglobal c30_snv_target none -* options: none, by2030, by2020 - $setglobal c30_rotation_constraints on *options: on, off @@ -27,47 +21,10 @@ $setglobal c30_rotation_scenario_speed by2050 * options: none, by2030, by2020 scalars -s30_snv_shr Share of available cropland that is witheld for other land cover types (1) / 0 / -s30_snv_shr_noselect Share of available cropland that is witheld for other land cover types (1) / 0 / -s30_snv_scenario_start SNV scenario start year / 2020 / -s30_snv_scenario_target SNV scenario target year / 2030 / -s30_rotation_scenario_start Rotation scenario start year / 2020 / -s30_rotation_scenario_target Rotation scenario target year / 2050 / -s30_snv_relocation_data_x1 First reference value in SNV target cropland data (1) / 0.2 / -s30_snv_relocation_data_x2 Second reference value in SNV target cropland data (1) / 0.5 / + s30_rotation_scenario_start Rotation scenario start year / 2020 / + s30_rotation_scenario_target Rotation scenario target year / 2050 / ; -* Set-switch for countries affected by regional SNV policy -* Default: all iso countries selected -sets - policy_countries30(iso) countries to be affected by SNV policy / ABW,AFG,AGO,AIA,ALA,ALB,AND,ARE,ARG,ARM, - ASM,ATA,ATF,ATG,AUS,AUT,AZE,BDI,BEL,BEN, - BES,BFA,BGD,BGR,BHR,BHS,BIH,BLM,BLR,BLZ, - BMU,BOL,BRA,BRB,BRN,BTN,BVT,BWA,CAF,CAN, - CCK,CHN,CHE,CHL,CIV,CMR,COD,COG,COK,COL, - COM,CPV,CRI,CUB,CUW,CXR,CYM,CYP,CZE,DEU, - DJI,DMA,DNK,DOM,DZA,ECU,EGY,ERI,ESH,ESP, - EST,ETH,FIN,FJI,FLK,FRA,FRO,FSM,GAB,GBR, - GEO,GGY,GHA,GIB,GIN,GLP,GMB,GNB,GNQ,GRC, - GRD,GRL,GTM,GUF,GUM,GUY,HKG,HMD,HND,HRV, - HTI,HUN,IDN,IMN,IND,IOT,IRL,IRN,IRQ,ISL, - ISR,ITA,JAM,JEY,JOR,JPN,KAZ,KEN,KGZ,KHM, - KIR,KNA,KOR,KWT,LAO,LBN,LBR,LBY,LCA,LIE, - LKA,LSO,LTU,LUX,LVA,MAC,MAF,MAR,MCO,MDA, - MDG,MDV,MEX,MHL,MKD,MLI,MLT,MMR,MNE,MNG, - MNP,MOZ,MRT,MSR,MTQ,MUS,MWI,MYS,MYT,NAM, - NCL,NER,NFK,NGA,NIC,NIU,NLD,NOR,NPL,NRU, - NZL,OMN,PAK,PAN,PCN,PER,PHL,PLW,PNG,POL, - PRI,PRK,PRT,PRY,PSE,PYF,QAT,REU,ROU,RUS, - RWA,SAU,SDN,SEN,SGP,SGS,SHN,SJM,SLB,SLE, - SLV,SMR,SOM,SPM,SRB,SSD,STP,SUR,SVK,SVN, - SWE,SWZ,SXM,SYC,SYR,TCA,TCD,TGO,THA,TJK, - TKL,TKM,TLS,TON,TTO,TUN,TUR,TUV,TWN,TZA, - UGA,UKR,UMI,URY,USA,UZB,VAT,VCT,VEN,VGB, - VIR,VNM,VUT,WLF,WSM,YEM,ZAF,ZMB,ZWE / - -land_snv(land) land types allowed in the SNV policy / secdforest, forestry, past, other / -; $ifthen "%c30_bioen_type%" == "all" bioen_type_30(kbe30) = yes; $else bioen_type_30("%c30_bioen_type%") = yes; @@ -102,25 +59,3 @@ $offdelim / ; - -********* AVAILABLE CROPLAND ******************************************* - -table f30_avl_cropland(j,marginal_land30) Available land area for cropland (mio. ha) -$ondelim -$include "./modules/30_crop/penalty_apr22/input/avl_cropland.cs3" -$offdelim -; - -table f30_avl_cropland_iso(iso,marginal_land30) Available land area for cropland at ISO level (mio. ha) -$ondelim -$include "./modules/30_crop/penalty_apr22/input/avl_cropland_iso.cs3" -$offdelim -; - -********* SNV TARGET CROPLAND ******************************************* - -table f30_snv_target_cropland(j,relocation_target30) Cropland in 2019 requiring relocation due to SNV policy (mio. ha) -$ondelim -$include "./modules/30_crop/penalty_apr22/input/SNVTargetCropland.cs3" -$offdelim -; diff --git a/modules/30_crop/penalty_apr22/input/files b/modules/30_crop/penalty_apr22/input/files index b1795d1c21..5f3d3ac1e2 100644 --- a/modules/30_crop/penalty_apr22/input/files +++ b/modules/30_crop/penalty_apr22/input/files @@ -1,9 +1,4 @@ * list of files that are required here f30_rotation_incentives.csv f30_rotation_rules.csv -avl_cropland.cs3 -avl_cropland_0.5.mz f30_croparea_w_initialisation.cs3 -avl_cropland_iso.cs3 -SNVTargetCropland.cs3 -SNVTargetCropland_0.5.mz diff --git a/modules/30_crop/penalty_apr22/postsolve.gms b/modules/30_crop/penalty_apr22/postsolve.gms index 9b690da029..84a11fd02a 100644 --- a/modules/30_crop/penalty_apr22/postsolve.gms +++ b/modules/30_crop/penalty_apr22/postsolve.gms @@ -7,72 +7,56 @@ *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov_fallow(t,j,"marginal") = vm_fallow.m(j); ov_area(t,j,kcr,w,"marginal") = vm_area.m(j,kcr,w); ov_rotation_penalty(t,i,"marginal") = vm_rotation_penalty.m(i); + ov_carbon_stock_croparea(t,j,ag_pools,"marginal") = vm_carbon_stock_croparea.m(j,ag_pools); ov30_penalty_max_irrig(t,j,rotamax30,"marginal") = v30_penalty_max_irrig.m(j,rotamax30); ov30_penalty(t,j,rota30,"marginal") = v30_penalty.m(j,rota30); - oq30_cropland(t,j,"marginal") = q30_cropland.m(j); - oq30_avl_cropland(t,j,"marginal") = q30_avl_cropland.m(j); + oq30_prod(t,j,kcr,"marginal") = q30_prod.m(j,kcr); oq30_rotation_penalty(t,i,"marginal") = q30_rotation_penalty.m(i); oq30_rotation_max(t,j,rotamax30,"marginal") = q30_rotation_max.m(j,rotamax30); oq30_rotation_min(t,j,rotamin30,"marginal") = q30_rotation_min.m(j,rotamin30); oq30_rotation_max_irrig(t,j,rotamax30,"marginal") = q30_rotation_max_irrig.m(j,rotamax30); - oq30_prod(t,j,kcr,"marginal") = q30_prod.m(j,kcr); - oq30_carbon(t,j,ag_pools,stockType,"marginal") = q30_carbon.m(j,ag_pools,stockType); + oq30_carbon(t,j,ag_pools,"marginal") = q30_carbon.m(j,ag_pools); oq30_bv_ann(t,j,potnatveg,"marginal") = q30_bv_ann.m(j,potnatveg); oq30_bv_per(t,j,potnatveg,"marginal") = q30_bv_per.m(j,potnatveg); - oq30_land_snv(t,j,"marginal") = q30_land_snv.m(j); - oq30_land_snv_trans(t,j,"marginal") = q30_land_snv_trans.m(j); - ov_fallow(t,j,"level") = vm_fallow.l(j); ov_area(t,j,kcr,w,"level") = vm_area.l(j,kcr,w); ov_rotation_penalty(t,i,"level") = vm_rotation_penalty.l(i); + ov_carbon_stock_croparea(t,j,ag_pools,"level") = vm_carbon_stock_croparea.l(j,ag_pools); ov30_penalty_max_irrig(t,j,rotamax30,"level") = v30_penalty_max_irrig.l(j,rotamax30); ov30_penalty(t,j,rota30,"level") = v30_penalty.l(j,rota30); - oq30_cropland(t,j,"level") = q30_cropland.l(j); - oq30_avl_cropland(t,j,"level") = q30_avl_cropland.l(j); + oq30_prod(t,j,kcr,"level") = q30_prod.l(j,kcr); oq30_rotation_penalty(t,i,"level") = q30_rotation_penalty.l(i); oq30_rotation_max(t,j,rotamax30,"level") = q30_rotation_max.l(j,rotamax30); oq30_rotation_min(t,j,rotamin30,"level") = q30_rotation_min.l(j,rotamin30); oq30_rotation_max_irrig(t,j,rotamax30,"level") = q30_rotation_max_irrig.l(j,rotamax30); - oq30_prod(t,j,kcr,"level") = q30_prod.l(j,kcr); - oq30_carbon(t,j,ag_pools,stockType,"level") = q30_carbon.l(j,ag_pools,stockType); + oq30_carbon(t,j,ag_pools,"level") = q30_carbon.l(j,ag_pools); oq30_bv_ann(t,j,potnatveg,"level") = q30_bv_ann.l(j,potnatveg); oq30_bv_per(t,j,potnatveg,"level") = q30_bv_per.l(j,potnatveg); - oq30_land_snv(t,j,"level") = q30_land_snv.l(j); - oq30_land_snv_trans(t,j,"level") = q30_land_snv_trans.l(j); - ov_fallow(t,j,"upper") = vm_fallow.up(j); ov_area(t,j,kcr,w,"upper") = vm_area.up(j,kcr,w); ov_rotation_penalty(t,i,"upper") = vm_rotation_penalty.up(i); + ov_carbon_stock_croparea(t,j,ag_pools,"upper") = vm_carbon_stock_croparea.up(j,ag_pools); ov30_penalty_max_irrig(t,j,rotamax30,"upper") = v30_penalty_max_irrig.up(j,rotamax30); ov30_penalty(t,j,rota30,"upper") = v30_penalty.up(j,rota30); - oq30_cropland(t,j,"upper") = q30_cropland.up(j); - oq30_avl_cropland(t,j,"upper") = q30_avl_cropland.up(j); + oq30_prod(t,j,kcr,"upper") = q30_prod.up(j,kcr); oq30_rotation_penalty(t,i,"upper") = q30_rotation_penalty.up(i); oq30_rotation_max(t,j,rotamax30,"upper") = q30_rotation_max.up(j,rotamax30); oq30_rotation_min(t,j,rotamin30,"upper") = q30_rotation_min.up(j,rotamin30); oq30_rotation_max_irrig(t,j,rotamax30,"upper") = q30_rotation_max_irrig.up(j,rotamax30); - oq30_prod(t,j,kcr,"upper") = q30_prod.up(j,kcr); - oq30_carbon(t,j,ag_pools,stockType,"upper") = q30_carbon.up(j,ag_pools,stockType); + oq30_carbon(t,j,ag_pools,"upper") = q30_carbon.up(j,ag_pools); oq30_bv_ann(t,j,potnatveg,"upper") = q30_bv_ann.up(j,potnatveg); oq30_bv_per(t,j,potnatveg,"upper") = q30_bv_per.up(j,potnatveg); - oq30_land_snv(t,j,"upper") = q30_land_snv.up(j); - oq30_land_snv_trans(t,j,"upper") = q30_land_snv_trans.up(j); - ov_fallow(t,j,"lower") = vm_fallow.lo(j); ov_area(t,j,kcr,w,"lower") = vm_area.lo(j,kcr,w); ov_rotation_penalty(t,i,"lower") = vm_rotation_penalty.lo(i); + ov_carbon_stock_croparea(t,j,ag_pools,"lower") = vm_carbon_stock_croparea.lo(j,ag_pools); ov30_penalty_max_irrig(t,j,rotamax30,"lower") = v30_penalty_max_irrig.lo(j,rotamax30); ov30_penalty(t,j,rota30,"lower") = v30_penalty.lo(j,rota30); - oq30_cropland(t,j,"lower") = q30_cropland.lo(j); - oq30_avl_cropland(t,j,"lower") = q30_avl_cropland.lo(j); + oq30_prod(t,j,kcr,"lower") = q30_prod.lo(j,kcr); oq30_rotation_penalty(t,i,"lower") = q30_rotation_penalty.lo(i); oq30_rotation_max(t,j,rotamax30,"lower") = q30_rotation_max.lo(j,rotamax30); oq30_rotation_min(t,j,rotamin30,"lower") = q30_rotation_min.lo(j,rotamin30); oq30_rotation_max_irrig(t,j,rotamax30,"lower") = q30_rotation_max_irrig.lo(j,rotamax30); - oq30_prod(t,j,kcr,"lower") = q30_prod.lo(j,kcr); - oq30_carbon(t,j,ag_pools,stockType,"lower") = q30_carbon.lo(j,ag_pools,stockType); + oq30_carbon(t,j,ag_pools,"lower") = q30_carbon.lo(j,ag_pools); oq30_bv_ann(t,j,potnatveg,"lower") = q30_bv_ann.lo(j,potnatveg); oq30_bv_per(t,j,potnatveg,"lower") = q30_bv_per.lo(j,potnatveg); - oq30_land_snv(t,j,"lower") = q30_land_snv.lo(j); - oq30_land_snv_trans(t,j,"lower") = q30_land_snv_trans.lo(j); *##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/30_crop/penalty_apr22/preloop.gms b/modules/30_crop/penalty_apr22/preloop.gms index d628775aff..075f0c5e82 100644 --- a/modules/30_crop/penalty_apr22/preloop.gms +++ b/modules/30_crop/penalty_apr22/preloop.gms @@ -19,14 +19,3 @@ i30_rotation_incentives(t_all,rota30)= *very small, negative numbers. These numbers have to be set to 0 as area *cannot be smaller than 0! fm_croparea(t_past,j,w,kcr)$(fm_croparea(t_past,j,w,kcr)<0) = 0; - -****** Regional share of semi-natural vegetation (SNV) in cropland areas for selective countries: -* Country switch to determine countries for which a SNV policy shall be applied. -* In the default case, the SNV policy affects all countries when activated. -p30_country_dummy(iso) = 0; -p30_country_dummy(policy_countries30) = 1; -* Because MAgPIE is not run at country-level, but at region level, a region -* share is calculated that translates the countries' influence to regional level. -* Countries are weighted by available cropland area. -i30_avl_cropland_iso(iso) = f30_avl_cropland_iso(iso,"%c30_marginal_land%"); -p30_country_snv_weight(i) = sum(i_to_iso(i,iso), p30_country_dummy(iso) * i30_avl_cropland_iso(iso)) / sum(i_to_iso(i,iso), i30_avl_cropland_iso(iso)); diff --git a/modules/30_crop/rotation_apr22/declarations.gms b/modules/30_crop/rotation_apr22/declarations.gms index 93e3da8bfb..21611b7eb4 100644 --- a/modules/30_crop/rotation_apr22/declarations.gms +++ b/modules/30_crop/rotation_apr22/declarations.gms @@ -9,18 +9,22 @@ parameters i30_rotation_max_shr(t_all,rotamax30) Maximum share of a certain crop group on cropland (ha per ha) i30_rotation_min_shr(t_all,rotamin30) Minimum share of a certain crop group on cropland (ha per ha) p30_rotation_scenario_fader(t_all) Crop rotation scenario fader (1) + p30_betr_scenario_fader(t_all) Bioenergy trees scenario fader (1) + p30_betr_min_shr(t,j) Minimum share of bioenergy trees on cropland (1) ; positive variables vm_area(j,kcr,w) Agricultural production area (mio. ha) vm_rotation_penalty(i) Penalty for violating rotational constraints (USD05MER) + vm_carbon_stock_croparea(j,ag_pools) Carbon stock in croparea (tC) ; equations + q30_prod(j,kcr) Production of cropped products (mio. tDM) q30_rotation_max(j,rotamax30) Local maximum rotational constraints (mio. ha) q30_rotation_min(j,rotamin30) Local minimum rotational constraints (mio. ha) q30_rotation_max_irrig(j,rotamax30) Local maximum rotational constraints (mio. ha) - q30_prod(j,kcr) Production of cropped products (mio. tDM) + q30_betr_shr(j) Bioenergy trees minimum share (mio. ha) q30_carbon(j,ag_pools) Croplarea above ground carbon content calculation (mio. tC) q30_bv_ann(j,potnatveg) Biodiversity value of annual cropland (mio. ha) q30_bv_per(j,potnatveg) Biodiversity value of perennial cropland (mio. ha) @@ -28,20 +32,17 @@ equations *#################### R SECTION START (OUTPUT DECLARATIONS) #################### parameters - ov_fallow(t,j,type) Fallow land (mio. ha) ov_area(t,j,kcr,w,type) Agricultural production area (mio. ha) ov_rotation_penalty(t,i,type) Penalty for violating rotational constraints (USD05MER) - oq30_cropland(t,j,type) Total cropland calculation (mio. ha) - oq30_avl_cropland(t,j,type) Available cropland constraint (mio. ha) + ov_carbon_stock_croparea(t,j,ag_pools,type) Carbon stock in croparea (tC) + oq30_prod(t,j,kcr,type) Production of cropped products (mio. tDM) oq30_rotation_max(t,j,rotamax30,type) Local maximum rotational constraints (mio. ha) oq30_rotation_min(t,j,rotamin30,type) Local minimum rotational constraints (mio. ha) oq30_rotation_max_irrig(t,j,rotamax30,type) Local maximum rotational constraints (mio. ha) - oq30_prod(t,j,kcr,type) Production of cropped products (mio. tDM) - oq30_carbon(t,j,ag_pools,stockType,type) Cropland above ground carbon content calculation (mio. tC) + oq30_betr_shr(t,j,type) Bioenergy trees minimum share (mio. ha) + oq30_carbon(t,j,ag_pools,type) Croplarea above ground carbon content calculation (mio. tC) oq30_bv_ann(t,j,potnatveg,type) Biodiversity value of annual cropland (mio. ha) oq30_bv_per(t,j,potnatveg,type) Biodiversity value of perennial cropland (mio. ha) - oq30_land_snv(t,j,type) Land constraint for the SNV policy in cropland areas (mio. ha) - oq30_land_snv_trans(t,j,type) Land transition constraint for SNV policy in cropland areas (mio. ha) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/30_crop/rotation_apr22/equations.gms b/modules/30_crop/rotation_apr22/equations.gms index fef0d2c511..6f0eda73d1 100644 --- a/modules/30_crop/rotation_apr22/equations.gms +++ b/modules/30_crop/rotation_apr22/equations.gms @@ -14,6 +14,7 @@ q30_prod(j2,kcr) .. vm_prod(j2,kcr) =e= sum(w, vm_area(j2,kcr,w) * vm_yld(j2,kcr,w)); + *' As additional constraints minimum and maximum rotational constraints limit *' the placing of crops. On the one hand, these rotational constraints reflect *' crop rotations limiting the share a specific crop can cover of the total area @@ -23,11 +24,11 @@ sum((rotamax_kcr30(rotamax_red30,kcr),w), vm_area(j2,kcr,w)) =l= vm_land(j2,"crop") * sum(ct,i30_rotation_max_shr(ct,rotamax_red30)); - q30_rotation_min(j2,rotamin_red30) .. sum((rotamin_kcr30(rotamin_red30,kcr),w), vm_area(j2,kcr,w)) =g= vm_land(j2,"crop") * sum(ct,i30_rotation_min_shr(ct,rotamin_red30)); + * The following maximum constraint avoids over-specialization in irrigated systems. * No minimum constraint is included for irrigated areas for computational * reasons. Minimum constraints just need to be met on total areas. @@ -36,22 +37,28 @@ sum((rotamax_kcr30(rotamax_red30,kcr)), vm_area(j2,kcr,"irrigated")) =l= vm_AEI(j2) * sum(ct,i30_rotation_max_shr(ct,rotamax_red30)); -*' Agricultural production is calculated by multiplying the area under -*' production with corresponding yields. Production from rainfed and irrigated -*' areas is summed up: - q30_prod(j2,kcr) .. - vm_prod(j2,kcr) =e= sum(w, vm_area(j2,kcr,w) * vm_yld(j2,kcr,w)); +*' Bioenergy tree minimum share on cropland + +q30_betr_shr(j2) .. + sum(w, vm_area(j2,"betr",w)) =g= + sum(ct, p30_betr_min_shr(ct,j2)) * vm_land(j2,"crop"); + + +*' The carbon stocks of the above ground carbon pools are calculated based on croparea and related carbon density. + + q30_carbon(j2,ag_pools) .. + vm_carbon_stock_croparea(j2,ag_pools) =e= + sum((kcr,w), vm_area(j2,kcr,w)) * sum(ct, fm_carbon_density(ct,j2,"crop",ag_pools)); + *' The biodiversity value for cropland is calculated separately for annual and perennial crops: + q30_bv_ann(j2,potnatveg) .. vm_bv(j2,"crop_ann",potnatveg) =e= sum((crop_ann30,w), vm_area(j2,crop_ann30,w)) * fm_bii_coeff("crop_ann",potnatveg) * fm_luh2_side_layers(j2,potnatveg); -* perennial crops are calculated as difference, as they shall also include fallow land - q30_bv_per(j2,potnatveg) .. - vm_bv(j2,"crop_per",potnatveg) + q30_bv_per(j2,potnatveg) .. vm_bv(j2,"crop_per",potnatveg) =e= - (vm_land(j2,"crop") - sum((crop_ann30,w), vm_area(j2,crop_ann30,w))) - * fm_bii_coeff("crop_per",potnatveg) * fm_luh2_side_layers(j2,potnatveg); + sum((crop_per30,w), vm_area(j2,crop_per30,w)) * fm_bii_coeff("crop_per",potnatveg) * fm_luh2_side_layers(j2,potnatveg); diff --git a/modules/30_crop/rotation_apr22/input.gms b/modules/30_crop/rotation_apr22/input.gms index da0b8f80b6..8d0f252920 100644 --- a/modules/30_crop/rotation_apr22/input.gms +++ b/modules/30_crop/rotation_apr22/input.gms @@ -11,12 +11,6 @@ $setglobal c30_bioen_type all $setglobal c30_bioen_water rainfed * options: rainfed, irrigated, all -$setglobal c30_marginal_land q33_marginal -* options: all_marginal, q33_marginal, no_marginal - -$setglobal c30_snv_target none -* options: none, by2030, by2020 - $setglobal c30_rotation_constraints on *options: on, off @@ -27,47 +21,13 @@ $setglobal c30_rotation_scenario_speed by2050 * options: none, by2030, by2020 scalars -s30_snv_shr Share of available cropland that is witheld for other land cover types (1) / 0 / -s30_snv_shr_noselect Share of available cropland that is witheld for other land cover types (1) / 0 / -s30_snv_scenario_start SNV scenario start year / 2020 / -s30_snv_scenario_target SNV scenario target year / 2030 / -s30_rotation_scenario_start Rotation scenario start year / 2020 / -s30_rotation_scenario_target Rotation scenario target year / 2050 / -s30_snv_relocation_data_x1 First reference value in SNV target cropland data (1) / 0.2 / -s30_snv_relocation_data_x2 Second reference value in SNV target cropland data (1) / 0.5 / + s30_rotation_scenario_start Rotation scenario start year / 2020 / + s30_rotation_scenario_target Rotation scenario target year / 2050 / + s30_betr_min_shr Minimum share of bioenergy trees on cropland (1) / 0 / + s30_betr_scenario_start Bioenergy trees scenario start year / 2020 / + s30_betr_scenario_target Bioenergy trees scenario target year / 2050 / ; -* Set-switch for countries affected by regional SNV policy -* Default: all iso countries selected -sets - policy_countries30(iso) countries to be affected by SNV policy / ABW,AFG,AGO,AIA,ALA,ALB,AND,ARE,ARG,ARM, - ASM,ATA,ATF,ATG,AUS,AUT,AZE,BDI,BEL,BEN, - BES,BFA,BGD,BGR,BHR,BHS,BIH,BLM,BLR,BLZ, - BMU,BOL,BRA,BRB,BRN,BTN,BVT,BWA,CAF,CAN, - CCK,CHN,CHE,CHL,CIV,CMR,COD,COG,COK,COL, - COM,CPV,CRI,CUB,CUW,CXR,CYM,CYP,CZE,DEU, - DJI,DMA,DNK,DOM,DZA,ECU,EGY,ERI,ESH,ESP, - EST,ETH,FIN,FJI,FLK,FRA,FRO,FSM,GAB,GBR, - GEO,GGY,GHA,GIB,GIN,GLP,GMB,GNB,GNQ,GRC, - GRD,GRL,GTM,GUF,GUM,GUY,HKG,HMD,HND,HRV, - HTI,HUN,IDN,IMN,IND,IOT,IRL,IRN,IRQ,ISL, - ISR,ITA,JAM,JEY,JOR,JPN,KAZ,KEN,KGZ,KHM, - KIR,KNA,KOR,KWT,LAO,LBN,LBR,LBY,LCA,LIE, - LKA,LSO,LTU,LUX,LVA,MAC,MAF,MAR,MCO,MDA, - MDG,MDV,MEX,MHL,MKD,MLI,MLT,MMR,MNE,MNG, - MNP,MOZ,MRT,MSR,MTQ,MUS,MWI,MYS,MYT,NAM, - NCL,NER,NFK,NGA,NIC,NIU,NLD,NOR,NPL,NRU, - NZL,OMN,PAK,PAN,PCN,PER,PHL,PLW,PNG,POL, - PRI,PRK,PRT,PRY,PSE,PYF,QAT,REU,ROU,RUS, - RWA,SAU,SDN,SEN,SGP,SGS,SHN,SJM,SLB,SLE, - SLV,SMR,SOM,SPM,SRB,SSD,STP,SUR,SVK,SVN, - SWE,SWZ,SXM,SYC,SYR,TCA,TCD,TGO,THA,TJK, - TKL,TKM,TLS,TON,TTO,TUN,TUR,TUV,TWN,TZA, - UGA,UKR,UMI,URY,USA,UZB,VAT,VCT,VEN,VGB, - VIR,VNM,VUT,WLF,WSM,YEM,ZAF,ZMB,ZWE / - -land_snv(land) land types allowed in the SNV policy / secdforest, forestry, past, other / -; $ifthen "%c30_bioen_type%" == "all" bioen_type_30(kbe30) = yes; $else bioen_type_30("%c30_bioen_type%") = yes; @@ -103,25 +63,3 @@ $offdelim ; $if "%c30_rotation_constraints%" == "off" f30_rotation_min_shr(crp30) = 0; - -********* AVAILABLE CROPLAND ******************************************* - -table f30_avl_cropland(j,marginal_land30) Available land area for cropland (mio. ha) -$ondelim -$include "./modules/30_crop/rotation_apr22/input/avl_cropland.cs3" -$offdelim -; - -table f30_avl_cropland_iso(iso,marginal_land30) Available land area for cropland at ISO level (mio. ha) -$ondelim -$include "./modules/30_crop/rotation_apr22/input/avl_cropland_iso.cs3" -$offdelim -; - -********* SNV TARGET CROPLAND ******************************************* - -table f30_snv_target_cropland(j,relocation_target30) Cropland in 2019 requiring relocation due to SNV policy (mio. ha) -$ondelim -$include "./modules/30_crop/rotation_apr22/input/SNVTargetCropland.cs3" -$offdelim -; diff --git a/modules/30_crop/rotation_apr22/input/files b/modules/30_crop/rotation_apr22/input/files index 6fe1594cf5..c20b7be222 100644 --- a/modules/30_crop/rotation_apr22/input/files +++ b/modules/30_crop/rotation_apr22/input/files @@ -1,9 +1,4 @@ * list of files that are required here f30_rotation_max_scen.csv f30_rotation_min_scen.csv -avl_cropland.cs3 -avl_cropland_0.5.mz f30_croparea_w_initialisation.cs3 -avl_cropland_iso.cs3 -SNVTargetCropland.cs3 -SNVTargetCropland_0.5.mz diff --git a/modules/30_crop/rotation_apr22/postsolve.gms b/modules/30_crop/rotation_apr22/postsolve.gms index 52d998a6e7..66c916304c 100644 --- a/modules/30_crop/rotation_apr22/postsolve.gms +++ b/modules/30_crop/rotation_apr22/postsolve.gms @@ -7,60 +7,48 @@ *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov_fallow(t,j,"marginal") = vm_fallow.m(j); ov_area(t,j,kcr,w,"marginal") = vm_area.m(j,kcr,w); ov_rotation_penalty(t,i,"marginal") = vm_rotation_penalty.m(i); - oq30_cropland(t,j,"marginal") = q30_cropland.m(j); - oq30_avl_cropland(t,j,"marginal") = q30_avl_cropland.m(j); + ov_carbon_stock_croparea(t,j,ag_pools,"marginal") = vm_carbon_stock_croparea.m(j,ag_pools); + oq30_prod(t,j,kcr,"marginal") = q30_prod.m(j,kcr); oq30_rotation_max(t,j,rotamax30,"marginal") = q30_rotation_max.m(j,rotamax30); oq30_rotation_min(t,j,rotamin30,"marginal") = q30_rotation_min.m(j,rotamin30); oq30_rotation_max_irrig(t,j,rotamax30,"marginal") = q30_rotation_max_irrig.m(j,rotamax30); - oq30_prod(t,j,kcr,"marginal") = q30_prod.m(j,kcr); - oq30_carbon(t,j,ag_pools,stockType,"marginal") = q30_carbon.m(j,ag_pools,stockType); + oq30_betr_shr(t,j,"marginal") = q30_betr_shr.m(j); + oq30_carbon(t,j,ag_pools,"marginal") = q30_carbon.m(j,ag_pools); oq30_bv_ann(t,j,potnatveg,"marginal") = q30_bv_ann.m(j,potnatveg); oq30_bv_per(t,j,potnatveg,"marginal") = q30_bv_per.m(j,potnatveg); - oq30_land_snv(t,j,"marginal") = q30_land_snv.m(j); - oq30_land_snv_trans(t,j,"marginal") = q30_land_snv_trans.m(j); - ov_fallow(t,j,"level") = vm_fallow.l(j); ov_area(t,j,kcr,w,"level") = vm_area.l(j,kcr,w); ov_rotation_penalty(t,i,"level") = vm_rotation_penalty.l(i); - oq30_cropland(t,j,"level") = q30_cropland.l(j); - oq30_avl_cropland(t,j,"level") = q30_avl_cropland.l(j); + ov_carbon_stock_croparea(t,j,ag_pools,"level") = vm_carbon_stock_croparea.l(j,ag_pools); + oq30_prod(t,j,kcr,"level") = q30_prod.l(j,kcr); oq30_rotation_max(t,j,rotamax30,"level") = q30_rotation_max.l(j,rotamax30); oq30_rotation_min(t,j,rotamin30,"level") = q30_rotation_min.l(j,rotamin30); oq30_rotation_max_irrig(t,j,rotamax30,"level") = q30_rotation_max_irrig.l(j,rotamax30); - oq30_prod(t,j,kcr,"level") = q30_prod.l(j,kcr); - oq30_carbon(t,j,ag_pools,stockType,"level") = q30_carbon.l(j,ag_pools,stockType); + oq30_betr_shr(t,j,"level") = q30_betr_shr.l(j); + oq30_carbon(t,j,ag_pools,"level") = q30_carbon.l(j,ag_pools); oq30_bv_ann(t,j,potnatveg,"level") = q30_bv_ann.l(j,potnatveg); oq30_bv_per(t,j,potnatveg,"level") = q30_bv_per.l(j,potnatveg); - oq30_land_snv(t,j,"level") = q30_land_snv.l(j); - oq30_land_snv_trans(t,j,"level") = q30_land_snv_trans.l(j); - ov_fallow(t,j,"upper") = vm_fallow.up(j); ov_area(t,j,kcr,w,"upper") = vm_area.up(j,kcr,w); ov_rotation_penalty(t,i,"upper") = vm_rotation_penalty.up(i); - oq30_cropland(t,j,"upper") = q30_cropland.up(j); - oq30_avl_cropland(t,j,"upper") = q30_avl_cropland.up(j); + ov_carbon_stock_croparea(t,j,ag_pools,"upper") = vm_carbon_stock_croparea.up(j,ag_pools); + oq30_prod(t,j,kcr,"upper") = q30_prod.up(j,kcr); oq30_rotation_max(t,j,rotamax30,"upper") = q30_rotation_max.up(j,rotamax30); oq30_rotation_min(t,j,rotamin30,"upper") = q30_rotation_min.up(j,rotamin30); oq30_rotation_max_irrig(t,j,rotamax30,"upper") = q30_rotation_max_irrig.up(j,rotamax30); - oq30_prod(t,j,kcr,"upper") = q30_prod.up(j,kcr); - oq30_carbon(t,j,ag_pools,stockType,"upper") = q30_carbon.up(j,ag_pools,stockType); + oq30_betr_shr(t,j,"upper") = q30_betr_shr.up(j); + oq30_carbon(t,j,ag_pools,"upper") = q30_carbon.up(j,ag_pools); oq30_bv_ann(t,j,potnatveg,"upper") = q30_bv_ann.up(j,potnatveg); oq30_bv_per(t,j,potnatveg,"upper") = q30_bv_per.up(j,potnatveg); - oq30_land_snv(t,j,"upper") = q30_land_snv.up(j); - oq30_land_snv_trans(t,j,"upper") = q30_land_snv_trans.up(j); - ov_fallow(t,j,"lower") = vm_fallow.lo(j); ov_area(t,j,kcr,w,"lower") = vm_area.lo(j,kcr,w); ov_rotation_penalty(t,i,"lower") = vm_rotation_penalty.lo(i); - oq30_cropland(t,j,"lower") = q30_cropland.lo(j); - oq30_avl_cropland(t,j,"lower") = q30_avl_cropland.lo(j); + ov_carbon_stock_croparea(t,j,ag_pools,"lower") = vm_carbon_stock_croparea.lo(j,ag_pools); + oq30_prod(t,j,kcr,"lower") = q30_prod.lo(j,kcr); oq30_rotation_max(t,j,rotamax30,"lower") = q30_rotation_max.lo(j,rotamax30); oq30_rotation_min(t,j,rotamin30,"lower") = q30_rotation_min.lo(j,rotamin30); oq30_rotation_max_irrig(t,j,rotamax30,"lower") = q30_rotation_max_irrig.lo(j,rotamax30); - oq30_prod(t,j,kcr,"lower") = q30_prod.lo(j,kcr); - oq30_carbon(t,j,ag_pools,stockType,"lower") = q30_carbon.lo(j,ag_pools,stockType); + oq30_betr_shr(t,j,"lower") = q30_betr_shr.lo(j); + oq30_carbon(t,j,ag_pools,"lower") = q30_carbon.lo(j,ag_pools); oq30_bv_ann(t,j,potnatveg,"lower") = q30_bv_ann.lo(j,potnatveg); oq30_bv_per(t,j,potnatveg,"lower") = q30_bv_per.lo(j,potnatveg); - oq30_land_snv(t,j,"lower") = q30_land_snv.lo(j); - oq30_land_snv_trans(t,j,"lower") = q30_land_snv_trans.lo(j); *##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/30_crop/rotation_apr22/preloop.gms b/modules/30_crop/rotation_apr22/preloop.gms index 43fe8bdd10..7c4e100664 100644 --- a/modules/30_crop/rotation_apr22/preloop.gms +++ b/modules/30_crop/rotation_apr22/preloop.gms @@ -9,6 +9,7 @@ ** Trajectory for cropland scenarios * sigmoidal interpolation between start year and target year m_sigmoid_time_interpol(p30_rotation_scenario_fader,s30_rotation_scenario_start,s30_rotation_scenario_target,0,1); +m_sigmoid_time_interpol(p30_betr_scenario_fader,s30_betr_scenario_start,s30_betr_scenario_target,0,1); ** create crop rotation scenario i30_rotation_max_shr(t_all,rotamax30)= @@ -24,15 +25,3 @@ i30_rotation_min_shr(t_all,rotamin30)= *very small, negative numbers. These numbers have to be set to 0 as area *cannot be smaller than 0! fm_croparea(t_past,j,w,kcr)$(fm_croparea(t_past,j,w,kcr)<0) = 0; - -****** Regional share of semi-natural vegetation (SNV) in cropland areas for selective countries: -* Country switch to determine countries for which a SNV policy shall be applied. -* In the default case, the SNV policy affects all countries when activated. -p30_country_dummy(iso) = 0; -p30_country_dummy(policy_countries30) = 1; -* Because MAgPIE is not run at country-level, but at region level, a region -* share is calculated that translates the countries' influence to regional level. -* Countries are weighted by available cropland area. -i30_avl_cropland_iso(iso) = f30_avl_cropland_iso(iso,"%c30_marginal_land%"); -p30_country_snv_weight(i) = sum(i_to_iso(i,iso), p30_country_dummy(iso) * i30_avl_cropland_iso(iso)) / sum(i_to_iso(i,iso), i30_avl_cropland_iso(iso)); - diff --git a/modules/30_crop/rotation_apr22/presolve.gms b/modules/30_crop/rotation_apr22/presolve.gms index 1b847385d9..97a83f26a8 100644 --- a/modules/30_crop/rotation_apr22/presolve.gms +++ b/modules/30_crop/rotation_apr22/presolve.gms @@ -24,3 +24,5 @@ rotamax_red30(rotamax30) = yes$(i30_rotation_max_shr(t,rotamax30) < 1); rotamin_red30(rotamin30) = yes$(i30_rotation_min_shr(t,rotamin30) > 0); vm_rotation_penalty.fx(i)=0; + +p30_betr_min_shr(t,j) = p30_betr_scenario_fader(t) * s30_betr_min_shr; diff --git a/modules/61_agroforestry/endo/declarations.gms b/modules/61_agroforestry/endo/declarations.gms deleted file mode 100644 index 5503ad7181..0000000000 --- a/modules/61_agroforestry/endo/declarations.gms +++ /dev/null @@ -1,67 +0,0 @@ -*** | (C) 2008-2023 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 - s61_shift number of 5-year age-classes corresponding to current time step length (1) -; - -parameters - p61_treecover_bii_coeff(bii_class_secd,potnatveg) BII coefficient for cropland treecover (1) - p61_carbon_density_ac(t,j,ac,ag_pools) Carbon density for ac and ag_pools (tC per ha) - p61_treecover(t,j,ac) Cropland tree cover per age class (mio. ha) - pc61_treecover(j,ac) Cropland tree cover per age class in current time step (mio. ha) - i61_reward_treecover Area reward for cropland treecover (USD per ha) - i61_reward_betr Area reward for bioenergy trees (USD per ha) -; - -equations - q61_cost_agroforestry(j) Costs and benefits related to agroforestry (mio. USD05MER per yr) - q61_cost_treecover_est(j) Establishment cost for cropland tree cover (mio. USD05MER per yr) - q61_cost_treecover_recur(j) Recurring cost for cropland tree cover (mio. USD05MER per yr) - q61_treecover_area(j) Cropland treecover interface (mio. ha) - q61_reward_treecover(j) Reward for cropland treecover (mio. USD05MER per yr) - q61_reward_betr(j) Reward for bioenergy trees (mio. USD05MER per yr) - q61_treecover_est(j,ac) Cropland treecover establishment (mio. ha) - q61_treecover_carbon(j,ag_pools,stockType) Cropland tree cover above ground carbon content (mio. tC) - q61_treecover_bv(j,potnatveg) Biodiversity value for cropland treecover (Mha) -; - -variables - vm_cost_agroforestry(j) Cost and rewards related to agroforestry (mio. USD05MER per yr) -; - -positive variables - v61_cost_treecover_est(j) Establishment cost for cropland tree cover (mio. USD05MER per yr) - v61_cost_treecover_recur(j) Recurring cost for cropland tree cover (mio. USD05MER per yr) - v61_reward_treecover(j) Reward for cropland treecover (mio. USD05MER per yr) - v61_reward_betr(j) Reward for bioenergy trees (mio. USD05MER per yr) - vm_treecover_area(j) Cropland tree cover (mio. ha) - v61_treecover(j,ac) Cropland tree cover per age class (mio. ha) - vm_treecover_carbon(j,ag_pools,stockType) Cropland tree cover above ground carbon content (mio. tC) -; - -*#################### R SECTION START (OUTPUT DECLARATIONS) #################### -parameters - ov_cost_agroforestry(t,j,type) Cost and rewards related to agroforestry (mio. USD05MER per yr) - ov61_cost_treecover_est(t,j,type) Establishment cost for cropland tree cover (mio. USD05MER per yr) - ov61_cost_treecover_recur(t,j,type) Recurring cost for cropland tree cover (mio. USD05MER per yr) - ov61_reward_treecover(t,j,type) Reward for cropland treecover (mio. USD05MER per yr) - ov61_reward_betr(t,j,type) Reward for bioenergy trees (mio. USD05MER per yr) - ov_treecover_area(t,j,type) Cropland tree cover (mio. ha) - ov61_treecover(t,j,ac,type) Cropland tree cover per age class (mio. ha) - ov_treecover_carbon(t,j,ag_pools,stockType,type) Cropland tree cover above ground carbon content (mio. tC) - oq61_cost_agroforestry(t,j,type) Costs and benefits related to agroforestry (mio. USD05MER per yr) - oq61_cost_treecover_est(t,j,type) Establishment cost for cropland tree cover (mio. USD05MER per yr) - oq61_cost_treecover_recur(t,j,type) Recurring cost for cropland tree cover (mio. USD05MER per yr) - oq61_treecover_area(t,j,type) Cropland treecover interface (mio. ha) - oq61_reward_treecover(t,j,type) Reward for cropland treecover (mio. USD05MER per yr) - oq61_reward_betr(t,j,type) Reward for bioenergy trees (mio. USD05MER per yr) - oq61_treecover_est(t,j,ac,type) Cropland treecover establishment (mio. ha) - oq61_treecover_carbon(t,j,ag_pools,stockType,type) Cropland tree cover above ground carbon content (mio. tC) - oq61_treecover_bv(t,j,potnatveg,type) Biodiversity value for cropland treecover (Mha) -; -*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/61_agroforestry/endo/equations.gms b/modules/61_agroforestry/endo/equations.gms deleted file mode 100644 index 6a4d138b1d..0000000000 --- a/modules/61_agroforestry/endo/equations.gms +++ /dev/null @@ -1,55 +0,0 @@ -*** | (C) 2008-2023 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 - -*' Total agroforestry cost. -*' Cost for bioenergy trees are accounted for in the [30_crop] module. -q61_cost_agroforestry(j2) .. - vm_cost_agroforestry(j2) =e= - v61_cost_treecover_est(j2) + v61_cost_treecover_recur(j2) - - v61_reward_treecover(j2) - v61_reward_betr(j2); - -*' Tree cover establishment cost -q61_cost_treecover_est(j2) .. - v61_cost_treecover_est(j2) =e= - sum(ac_est, v61_treecover(j2,ac_est)) * s61_cost_treecover_est * - sum((cell(i2,j2),ct),pm_interest(ct,i2)/(1+pm_interest(ct,i2))); - -*' Tree cover recurring cost -q61_cost_treecover_recur(j2) .. - v61_cost_treecover_recur(j2) =e= - sum(ac_sub, v61_treecover(j2,ac_sub)) * s61_cost_treecover_recur; - -*' Tree cover reward -q61_reward_treecover(j2) .. - v61_reward_treecover(j2) =e= - sum(ac, v61_treecover(j2,ac)) * i61_reward_treecover; - -*' Bioenergy tree reward -q61_reward_betr(j2) .. - v61_reward_betr(j2) =e= - sum(w, vm_area(j2,"betr",w)) * i61_reward_betr; - -*' Tree cover establishment -q61_treecover_est(j2,ac_est) .. - v61_treecover(j2,ac_est) =e= sum(ac_est2, v61_treecover(j2,ac_est2))/card(ac_est2); - -*' Tree cover area interface -q61_treecover_area(j2) .. - vm_treecover_area(j2) =e= sum(ac, v61_treecover(j2,ac)); - -*' Tree cover carbon stock interface -q61_treecover_carbon(j2,ag_pools,stockType) .. - vm_treecover_carbon(j2,ag_pools,stockType) =e= - m_carbon_stock_ac(v61_treecover,p61_carbon_density_ac,"ac","ac_sub"); - -*' Tree cover biodiversity value -q61_treecover_bv(j2,potnatveg) .. - vm_bv(j2,"crop_tree",potnatveg) =e= - sum(bii_class_secd, sum(ac_to_bii_class_secd(ac,bii_class_secd), v61_treecover(j2,ac)) * - p61_treecover_bii_coeff(bii_class_secd,potnatveg)) * fm_luh2_side_layers(j2,potnatveg); diff --git a/modules/61_agroforestry/endo/input.gms b/modules/61_agroforestry/endo/input.gms deleted file mode 100644 index b9aa3f15e0..0000000000 --- a/modules/61_agroforestry/endo/input.gms +++ /dev/null @@ -1,18 +0,0 @@ -*** | (C) 2008-2023 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 - s61_cost_treecover_est Tree cover establishment cost (USD per ha) / 2000 / - s61_cost_treecover_recur Tree cover recurring cost (USD per ha) / 500 / - s61_treecover_plantation Growth curve switch for tree cover on cropland 0=natveg 1=plantations (1) / 0 / - s61_treecover_bii_coeff BII coefficent to be used for tree cover on cropland 0=secondary vegetation 1=timber plantations (1) / 0 / - s61_treecover_decrease Cropland treecover can decrease (1) or not (0) / 0 / - s61_reward_treecover Area reward for cropland treecover (USD per ha) / 0 / - s61_reward_betr Area reward for bioenergy trees on cropland (USD per ha) / 0 / - s61_treecover_scenario_start Cropland treecover scenario start year / 2020 / - s61_betr_scenario_start Bioenergy trees scenario start year / 2020 / -; diff --git a/modules/61_agroforestry/endo/not_used.txt b/modules/61_agroforestry/endo/not_used.txt deleted file mode 100644 index c3c4a63e3d..0000000000 --- a/modules/61_agroforestry/endo/not_used.txt +++ /dev/null @@ -1,2 +0,0 @@ -name,type,reason -vm_land,input,not used diff --git a/modules/61_agroforestry/endo/postsolve.gms b/modules/61_agroforestry/endo/postsolve.gms deleted file mode 100644 index 1afb2c367e..0000000000 --- a/modules/61_agroforestry/endo/postsolve.gms +++ /dev/null @@ -1,79 +0,0 @@ -*** | (C) 2008-2023 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 - -pc61_treecover(j,ac) = v61_treecover.l(j,ac); - -*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov_cost_agroforestry(t,j,"marginal") = vm_cost_agroforestry.m(j); - ov61_cost_treecover_est(t,j,"marginal") = v61_cost_treecover_est.m(j); - ov61_cost_treecover_recur(t,j,"marginal") = v61_cost_treecover_recur.m(j); - ov61_reward_treecover(t,j,"marginal") = v61_reward_treecover.m(j); - ov61_reward_betr(t,j,"marginal") = v61_reward_betr.m(j); - ov_treecover_area(t,j,"marginal") = vm_treecover_area.m(j); - ov61_treecover(t,j,ac,"marginal") = v61_treecover.m(j,ac); - ov_treecover_carbon(t,j,ag_pools,stockType,"marginal") = vm_treecover_carbon.m(j,ag_pools,stockType); - oq61_cost_agroforestry(t,j,"marginal") = q61_cost_agroforestry.m(j); - oq61_cost_treecover_est(t,j,"marginal") = q61_cost_treecover_est.m(j); - oq61_cost_treecover_recur(t,j,"marginal") = q61_cost_treecover_recur.m(j); - oq61_treecover_area(t,j,"marginal") = q61_treecover_area.m(j); - oq61_reward_treecover(t,j,"marginal") = q61_reward_treecover.m(j); - oq61_reward_betr(t,j,"marginal") = q61_reward_betr.m(j); - oq61_treecover_est(t,j,ac,"marginal") = q61_treecover_est.m(j,ac); - oq61_treecover_carbon(t,j,ag_pools,stockType,"marginal") = q61_treecover_carbon.m(j,ag_pools,stockType); - oq61_treecover_bv(t,j,potnatveg,"marginal") = q61_treecover_bv.m(j,potnatveg); - ov_cost_agroforestry(t,j,"level") = vm_cost_agroforestry.l(j); - ov61_cost_treecover_est(t,j,"level") = v61_cost_treecover_est.l(j); - ov61_cost_treecover_recur(t,j,"level") = v61_cost_treecover_recur.l(j); - ov61_reward_treecover(t,j,"level") = v61_reward_treecover.l(j); - ov61_reward_betr(t,j,"level") = v61_reward_betr.l(j); - ov_treecover_area(t,j,"level") = vm_treecover_area.l(j); - ov61_treecover(t,j,ac,"level") = v61_treecover.l(j,ac); - ov_treecover_carbon(t,j,ag_pools,stockType,"level") = vm_treecover_carbon.l(j,ag_pools,stockType); - oq61_cost_agroforestry(t,j,"level") = q61_cost_agroforestry.l(j); - oq61_cost_treecover_est(t,j,"level") = q61_cost_treecover_est.l(j); - oq61_cost_treecover_recur(t,j,"level") = q61_cost_treecover_recur.l(j); - oq61_treecover_area(t,j,"level") = q61_treecover_area.l(j); - oq61_reward_treecover(t,j,"level") = q61_reward_treecover.l(j); - oq61_reward_betr(t,j,"level") = q61_reward_betr.l(j); - oq61_treecover_est(t,j,ac,"level") = q61_treecover_est.l(j,ac); - oq61_treecover_carbon(t,j,ag_pools,stockType,"level") = q61_treecover_carbon.l(j,ag_pools,stockType); - oq61_treecover_bv(t,j,potnatveg,"level") = q61_treecover_bv.l(j,potnatveg); - ov_cost_agroforestry(t,j,"upper") = vm_cost_agroforestry.up(j); - ov61_cost_treecover_est(t,j,"upper") = v61_cost_treecover_est.up(j); - ov61_cost_treecover_recur(t,j,"upper") = v61_cost_treecover_recur.up(j); - ov61_reward_treecover(t,j,"upper") = v61_reward_treecover.up(j); - ov61_reward_betr(t,j,"upper") = v61_reward_betr.up(j); - ov_treecover_area(t,j,"upper") = vm_treecover_area.up(j); - ov61_treecover(t,j,ac,"upper") = v61_treecover.up(j,ac); - ov_treecover_carbon(t,j,ag_pools,stockType,"upper") = vm_treecover_carbon.up(j,ag_pools,stockType); - oq61_cost_agroforestry(t,j,"upper") = q61_cost_agroforestry.up(j); - oq61_cost_treecover_est(t,j,"upper") = q61_cost_treecover_est.up(j); - oq61_cost_treecover_recur(t,j,"upper") = q61_cost_treecover_recur.up(j); - oq61_treecover_area(t,j,"upper") = q61_treecover_area.up(j); - oq61_reward_treecover(t,j,"upper") = q61_reward_treecover.up(j); - oq61_reward_betr(t,j,"upper") = q61_reward_betr.up(j); - oq61_treecover_est(t,j,ac,"upper") = q61_treecover_est.up(j,ac); - oq61_treecover_carbon(t,j,ag_pools,stockType,"upper") = q61_treecover_carbon.up(j,ag_pools,stockType); - oq61_treecover_bv(t,j,potnatveg,"upper") = q61_treecover_bv.up(j,potnatveg); - ov_cost_agroforestry(t,j,"lower") = vm_cost_agroforestry.lo(j); - ov61_cost_treecover_est(t,j,"lower") = v61_cost_treecover_est.lo(j); - ov61_cost_treecover_recur(t,j,"lower") = v61_cost_treecover_recur.lo(j); - ov61_reward_treecover(t,j,"lower") = v61_reward_treecover.lo(j); - ov61_reward_betr(t,j,"lower") = v61_reward_betr.lo(j); - ov_treecover_area(t,j,"lower") = vm_treecover_area.lo(j); - ov61_treecover(t,j,ac,"lower") = v61_treecover.lo(j,ac); - ov_treecover_carbon(t,j,ag_pools,stockType,"lower") = vm_treecover_carbon.lo(j,ag_pools,stockType); - oq61_cost_agroforestry(t,j,"lower") = q61_cost_agroforestry.lo(j); - oq61_cost_treecover_est(t,j,"lower") = q61_cost_treecover_est.lo(j); - oq61_cost_treecover_recur(t,j,"lower") = q61_cost_treecover_recur.lo(j); - oq61_treecover_area(t,j,"lower") = q61_treecover_area.lo(j); - oq61_reward_treecover(t,j,"lower") = q61_reward_treecover.lo(j); - oq61_reward_betr(t,j,"lower") = q61_reward_betr.lo(j); - oq61_treecover_est(t,j,ac,"lower") = q61_treecover_est.lo(j,ac); - oq61_treecover_carbon(t,j,ag_pools,stockType,"lower") = q61_treecover_carbon.lo(j,ag_pools,stockType); - oq61_treecover_bv(t,j,potnatveg,"lower") = q61_treecover_bv.lo(j,potnatveg); -*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/61_agroforestry/endo/preloop.gms b/modules/61_agroforestry/endo/preloop.gms deleted file mode 100644 index a60e56e0b7..0000000000 --- a/modules/61_agroforestry/endo/preloop.gms +++ /dev/null @@ -1,26 +0,0 @@ -*** | (C) 2008-2023 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 - -* Initial tree cover on cropland is assumed to be equally distributed among all age-classes -pc61_treecover(j,ac) = (pm_treecover_shr(j)*pm_land_start(j,"crop"))/card(ac); - -*' Switch for tree cover on cropland: -*' 0 = Use natveg growth curve towards LPJmL natural vegetation -*' 1 = Use plantation growth curve (faster than natveg) towards LPJmL natural vegetation -if(s61_treecover_plantation = 0, - p61_carbon_density_ac(t,j,ac,ag_pools) = pm_carbon_density_ac(t,j,ac,ag_pools); -elseif s61_treecover_plantation = 1, - p61_carbon_density_ac(t,j,ac,ag_pools) = pm_carbon_density_ac_forestry(t,j,ac,ag_pools); -); - -** set bii coefficients -p61_treecover_bii_coeff(bii_class_secd,potnatveg) = 0; -if(s61_treecover_bii_coeff = 0, - p61_treecover_bii_coeff(bii_class_secd,potnatveg) = fm_bii_coeff(bii_class_secd,potnatveg) -elseif s61_treecover_bii_coeff = 1, - p61_treecover_bii_coeff(bii_class_secd,potnatveg) = fm_bii_coeff("timber",potnatveg) -); diff --git a/modules/61_agroforestry/endo/presolve.gms b/modules/61_agroforestry/endo/presolve.gms deleted file mode 100644 index f123728309..0000000000 --- a/modules/61_agroforestry/endo/presolve.gms +++ /dev/null @@ -1,34 +0,0 @@ -*** | (C) 2008-2023 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 - -* Growth of trees on cropland is modelled by shifting age-classes according to time step length. -s61_shift = m_timestep_length_forestry/5; -* example: ac10 in t = ac5 (ac10-1) in t-1 for a 5 yr time step (s61_shift = 1) - p61_treecover(t,j,ac)$(ord(ac) > s61_shift) = pc61_treecover(j,ac-s61_shift); -* account for cases at the end of the age class set (s61_shift > 1) which are not shifted by the above calculation - p61_treecover(t,j,"acx") = p61_treecover(t,j,"acx") - + sum(ac$(ord(ac) > card(ac)-s61_shift), pc61_treecover(j,ac)); - -pc61_treecover(j,ac) = p61_treecover(t,j,ac); -v61_treecover.l(j,ac) = p61_treecover(t,j,ac); - -if(m_year(t) <= s61_treecover_scenario_start, - v61_treecover.fx(j,ac) = pc61_treecover(j,ac); - i61_reward_treecover = 0; - i61_reward_betr = 0; -else - i61_reward_treecover = s61_reward_treecover; - i61_reward_betr = s61_reward_betr; - v61_treecover.lo(j,ac_est) = 0; - v61_treecover.up(j,ac_est) = Inf; - if(s61_treecover_decrease = 1, - v61_treecover.lo(j,ac_sub) = 0; - v61_treecover.up(j,ac_sub) = pc61_treecover(j,ac_sub); - else - v61_treecover.fx(j,ac_sub) = pc61_treecover(j,ac_sub); - ); -); diff --git a/modules/61_agroforestry/endo/realization.gms b/modules/61_agroforestry/endo/realization.gms deleted file mode 100644 index 7f22f40dff..0000000000 --- a/modules/61_agroforestry/endo/realization.gms +++ /dev/null @@ -1,21 +0,0 @@ -*** | (C) 2008-2023 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 In this realization, future shares of tree cover and bioenergy trees -*' on cropland at cluster level follow exogenous assumptions. -*' @stop -*' -*' @limitations There are currently no known limitations of this realization. - -*####################### R SECTION START (PHASES) ############################## -$Ifi "%phase%" == "declarations" $include "./modules/61_agroforestry/endo/declarations.gms" -$Ifi "%phase%" == "input" $include "./modules/61_agroforestry/endo/input.gms" -$Ifi "%phase%" == "equations" $include "./modules/61_agroforestry/endo/equations.gms" -$Ifi "%phase%" == "preloop" $include "./modules/61_agroforestry/endo/preloop.gms" -$Ifi "%phase%" == "presolve" $include "./modules/61_agroforestry/endo/presolve.gms" -$Ifi "%phase%" == "postsolve" $include "./modules/61_agroforestry/endo/postsolve.gms" -*######################## R SECTION END (PHASES) ############################### diff --git a/modules/61_agroforestry/exo/declarations.gms b/modules/61_agroforestry/exo/declarations.gms deleted file mode 100644 index 0262c0e59e..0000000000 --- a/modules/61_agroforestry/exo/declarations.gms +++ /dev/null @@ -1,65 +0,0 @@ -*** | (C) 2008-2023 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 - s61_shift number of 5-year age-classes corresponding to current time step length (1) -; - -parameters - p61_treecover_min_shr(t,j) Minimum share of treecover on cropland (1) - p61_betr_min_shr(t,j) Minimum share of bioenergy trees on cropland (1) - p61_treecover_scenario_fader(t_all) Cropland treecover scenario fader (1) - p61_betr_scenario_fader(t_all) Bioenergy trees scenario fader (1) - p61_treecover_bii_coeff(bii_class_secd,potnatveg) BII coefficient for cropland treecover (1) - p61_carbon_density_ac(t,j,ac,ag_pools) Carbon density for ac and ag_pools (tC per ha) - p61_treecover(t,j,ac) Cropland tree cover per age class (mio. ha) - pc61_treecover(j,ac) Cropland tree cover per age class in current time step (mio. ha) -; - -equations - q61_cost_agroforestry(j) Costs and benefits related to agroforestry (mio. USD05MER per yr) - q61_cost_treecover_est(j) Establishment cost for cropland tree cover (mio. USD05MER per yr) - q61_cost_treecover_recur(j) Recurring cost for cropland tree cover (mio. USD05MER per yr) - q61_treecover_area(j) Cropland treecover interface (mio. ha) - q61_treecover_shr(j) Cropland treecover minimum share (mio. ha) - q61_betr_shr(j) Bioenergy trees minimum share (mio. ha) - q61_treecover_est(j,ac) Cropland treecover establishment (mio. ha) - q61_treecover_carbon(j,ag_pools,stockType) Cropland tree cover above ground carbon content (mio. tC) - q61_treecover_bv(j,potnatveg) Biodiversity value for cropland treecover (Mha) -; - -variables - vm_cost_agroforestry(j) Cost and rewards related to agroforestry (mio. USD05MER per yr) -; - -positive variables - v61_cost_treecover_est(j) Establishment cost for cropland tree cover (mio. USD05MER per yr) - v61_cost_treecover_recur(j) Recurring cost for cropland tree cover (mio. USD05MER per yr) - vm_treecover_area(j) Cropland tree cover (mio. ha) - v61_treecover(j,ac) Cropland tree cover per age class (mio. ha) - vm_treecover_carbon(j,ag_pools,stockType) Cropland tree cover above ground carbon content (mio. tC) -; - -*#################### R SECTION START (OUTPUT DECLARATIONS) #################### -parameters - ov_cost_agroforestry(t,j,type) Cost and rewards related to agroforestry (mio. USD05MER per yr) - ov61_cost_treecover_est(t,j,type) Establishment cost for cropland tree cover (mio. USD05MER per yr) - ov61_cost_treecover_recur(t,j,type) Recurring cost for cropland tree cover (mio. USD05MER per yr) - ov_treecover_area(t,j,type) Cropland tree cover (mio. ha) - ov61_treecover(t,j,ac,type) Cropland tree cover per age class (mio. ha) - ov_treecover_carbon(t,j,ag_pools,stockType,type) Cropland tree cover above ground carbon content (mio. tC) - oq61_cost_agroforestry(t,j,type) Costs and benefits related to agroforestry (mio. USD05MER per yr) - oq61_cost_treecover_est(t,j,type) Establishment cost for cropland tree cover (mio. USD05MER per yr) - oq61_cost_treecover_recur(t,j,type) Recurring cost for cropland tree cover (mio. USD05MER per yr) - oq61_treecover_area(t,j,type) Cropland treecover interface (mio. ha) - oq61_treecover_shr(t,j,type) Cropland treecover minimum share (mio. ha) - oq61_betr_shr(t,j,type) Bioenergy trees minimum share (mio. ha) - oq61_treecover_est(t,j,ac,type) Cropland treecover establishment (mio. ha) - oq61_treecover_carbon(t,j,ag_pools,stockType,type) Cropland tree cover above ground carbon content (mio. tC) - oq61_treecover_bv(t,j,potnatveg,type) Biodiversity value for cropland treecover (Mha) -; -*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/61_agroforestry/exo/equations.gms b/modules/61_agroforestry/exo/equations.gms deleted file mode 100644 index 6a052bea65..0000000000 --- a/modules/61_agroforestry/exo/equations.gms +++ /dev/null @@ -1,54 +0,0 @@ -*** | (C) 2008-2023 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 - -*' Total agroforestry cost. -*' Cost for bioenergy trees are accounted for in the [30_crop] module. -q61_cost_agroforestry(j2) .. - vm_cost_agroforestry(j2) =e= - v61_cost_treecover_est(j2) + v61_cost_treecover_recur(j2); - -*' Tree cover establishment cost -q61_cost_treecover_est(j2) .. - v61_cost_treecover_est(j2) =e= - sum(ac_est, v61_treecover(j2,ac_est)) * s61_cost_treecover_est * - sum((cell(i2,j2),ct),pm_interest(ct,i2)/(1+pm_interest(ct,i2))); - -*' Tree cover recurring cost -q61_cost_treecover_recur(j2) .. - v61_cost_treecover_recur(j2) =e= - sum(ac_sub, v61_treecover(j2,ac_sub)) * s61_cost_treecover_recur; - -*' Tree cover minimum share -q61_treecover_shr(j2) .. - sum(ac, v61_treecover(j2,ac)) =g= - sum(ct, p61_treecover_min_shr(ct,j2)) * vm_land(j2,"crop"); - -*' Bioenergy tree minimum share -q61_betr_shr(j2) .. - sum(w, vm_area(j2,"betr",w)) =g= - sum(ct, p61_betr_min_shr(ct,j2)) * vm_land(j2,"crop"); - -*' Tree cover establishment -q61_treecover_est(j2,ac_est) .. - v61_treecover(j2,ac_est) =e= sum(ac_est2, v61_treecover(j2,ac_est2))/card(ac_est2); - -*' Tree cover area interface -q61_treecover_area(j2) .. - vm_treecover_area(j2) =e= sum(ac, v61_treecover(j2,ac)); - -*' Tree cover carbon stock interface -q61_treecover_carbon(j2,ag_pools,stockType) .. - vm_treecover_carbon(j2,ag_pools,stockType) =e= - m_carbon_stock_ac(v61_treecover,p61_carbon_density_ac,"ac","ac_sub"); - -*' Tree cover biodiversity value -q61_treecover_bv(j2,potnatveg) .. - vm_bv(j2,"crop_tree",potnatveg) =e= - sum(bii_class_secd, sum(ac_to_bii_class_secd(ac,bii_class_secd), v61_treecover(j2,ac)) * - p61_treecover_bii_coeff(bii_class_secd,potnatveg)) * fm_luh2_side_layers(j2,potnatveg); diff --git a/modules/61_agroforestry/exo/input.gms b/modules/61_agroforestry/exo/input.gms deleted file mode 100644 index c10a69cca2..0000000000 --- a/modules/61_agroforestry/exo/input.gms +++ /dev/null @@ -1,7 +0,0 @@ -*** | (C) 2008-2023 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 - diff --git a/modules/61_agroforestry/exo/postsolve.gms b/modules/61_agroforestry/exo/postsolve.gms deleted file mode 100644 index 0f01d44bb7..0000000000 --- a/modules/61_agroforestry/exo/postsolve.gms +++ /dev/null @@ -1,70 +0,0 @@ -*** | (C) 2008-2023 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 - - -*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov_cost_agroforestry(t,j,"marginal") = vm_cost_agroforestry.m(j); - ov61_cost_treecover_est(t,j,"marginal") = v61_cost_treecover_est.m(j); - ov61_cost_treecover_recur(t,j,"marginal") = v61_cost_treecover_recur.m(j); - ov_treecover_area(t,j,"marginal") = vm_treecover_area.m(j); - ov61_treecover(t,j,ac,"marginal") = v61_treecover.m(j,ac); - ov_treecover_carbon(t,j,ag_pools,stockType,"marginal") = vm_treecover_carbon.m(j,ag_pools,stockType); - oq61_cost_agroforestry(t,j,"marginal") = q61_cost_agroforestry.m(j); - oq61_cost_treecover_est(t,j,"marginal") = q61_cost_treecover_est.m(j); - oq61_cost_treecover_recur(t,j,"marginal") = q61_cost_treecover_recur.m(j); - oq61_treecover_area(t,j,"marginal") = q61_treecover_area.m(j); - oq61_treecover_shr(t,j,"marginal") = q61_treecover_shr.m(j); - oq61_betr_shr(t,j,"marginal") = q61_betr_shr.m(j); - oq61_treecover_est(t,j,ac,"marginal") = q61_treecover_est.m(j,ac); - oq61_treecover_carbon(t,j,ag_pools,stockType,"marginal") = q61_treecover_carbon.m(j,ag_pools,stockType); - oq61_treecover_bv(t,j,potnatveg,"marginal") = q61_treecover_bv.m(j,potnatveg); - ov_cost_agroforestry(t,j,"level") = vm_cost_agroforestry.l(j); - ov61_cost_treecover_est(t,j,"level") = v61_cost_treecover_est.l(j); - ov61_cost_treecover_recur(t,j,"level") = v61_cost_treecover_recur.l(j); - ov_treecover_area(t,j,"level") = vm_treecover_area.l(j); - ov61_treecover(t,j,ac,"level") = v61_treecover.l(j,ac); - ov_treecover_carbon(t,j,ag_pools,stockType,"level") = vm_treecover_carbon.l(j,ag_pools,stockType); - oq61_cost_agroforestry(t,j,"level") = q61_cost_agroforestry.l(j); - oq61_cost_treecover_est(t,j,"level") = q61_cost_treecover_est.l(j); - oq61_cost_treecover_recur(t,j,"level") = q61_cost_treecover_recur.l(j); - oq61_treecover_area(t,j,"level") = q61_treecover_area.l(j); - oq61_treecover_shr(t,j,"level") = q61_treecover_shr.l(j); - oq61_betr_shr(t,j,"level") = q61_betr_shr.l(j); - oq61_treecover_est(t,j,ac,"level") = q61_treecover_est.l(j,ac); - oq61_treecover_carbon(t,j,ag_pools,stockType,"level") = q61_treecover_carbon.l(j,ag_pools,stockType); - oq61_treecover_bv(t,j,potnatveg,"level") = q61_treecover_bv.l(j,potnatveg); - ov_cost_agroforestry(t,j,"upper") = vm_cost_agroforestry.up(j); - ov61_cost_treecover_est(t,j,"upper") = v61_cost_treecover_est.up(j); - ov61_cost_treecover_recur(t,j,"upper") = v61_cost_treecover_recur.up(j); - ov_treecover_area(t,j,"upper") = vm_treecover_area.up(j); - ov61_treecover(t,j,ac,"upper") = v61_treecover.up(j,ac); - ov_treecover_carbon(t,j,ag_pools,stockType,"upper") = vm_treecover_carbon.up(j,ag_pools,stockType); - oq61_cost_agroforestry(t,j,"upper") = q61_cost_agroforestry.up(j); - oq61_cost_treecover_est(t,j,"upper") = q61_cost_treecover_est.up(j); - oq61_cost_treecover_recur(t,j,"upper") = q61_cost_treecover_recur.up(j); - oq61_treecover_area(t,j,"upper") = q61_treecover_area.up(j); - oq61_treecover_shr(t,j,"upper") = q61_treecover_shr.up(j); - oq61_betr_shr(t,j,"upper") = q61_betr_shr.up(j); - oq61_treecover_est(t,j,ac,"upper") = q61_treecover_est.up(j,ac); - oq61_treecover_carbon(t,j,ag_pools,stockType,"upper") = q61_treecover_carbon.up(j,ag_pools,stockType); - oq61_treecover_bv(t,j,potnatveg,"upper") = q61_treecover_bv.up(j,potnatveg); - ov_cost_agroforestry(t,j,"lower") = vm_cost_agroforestry.lo(j); - ov61_cost_treecover_est(t,j,"lower") = v61_cost_treecover_est.lo(j); - ov61_cost_treecover_recur(t,j,"lower") = v61_cost_treecover_recur.lo(j); - ov_treecover_area(t,j,"lower") = vm_treecover_area.lo(j); - ov61_treecover(t,j,ac,"lower") = v61_treecover.lo(j,ac); - ov_treecover_carbon(t,j,ag_pools,stockType,"lower") = vm_treecover_carbon.lo(j,ag_pools,stockType); - oq61_cost_agroforestry(t,j,"lower") = q61_cost_agroforestry.lo(j); - oq61_cost_treecover_est(t,j,"lower") = q61_cost_treecover_est.lo(j); - oq61_cost_treecover_recur(t,j,"lower") = q61_cost_treecover_recur.lo(j); - oq61_treecover_area(t,j,"lower") = q61_treecover_area.lo(j); - oq61_treecover_shr(t,j,"lower") = q61_treecover_shr.lo(j); - oq61_betr_shr(t,j,"lower") = q61_betr_shr.lo(j); - oq61_treecover_est(t,j,ac,"lower") = q61_treecover_est.lo(j,ac); - oq61_treecover_carbon(t,j,ag_pools,stockType,"lower") = q61_treecover_carbon.lo(j,ag_pools,stockType); - oq61_treecover_bv(t,j,potnatveg,"lower") = q61_treecover_bv.lo(j,potnatveg); -*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/61_agroforestry/exo/preloop.gms b/modules/61_agroforestry/exo/preloop.gms deleted file mode 100644 index 637d6609c8..0000000000 --- a/modules/61_agroforestry/exo/preloop.gms +++ /dev/null @@ -1,8 +0,0 @@ -*** | (C) 2008-2023 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 - - diff --git a/modules/61_agroforestry/exo/presolve.gms b/modules/61_agroforestry/exo/presolve.gms deleted file mode 100644 index c10a69cca2..0000000000 --- a/modules/61_agroforestry/exo/presolve.gms +++ /dev/null @@ -1,7 +0,0 @@ -*** | (C) 2008-2023 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 - diff --git a/modules/61_agroforestry/exo/realization.gms b/modules/61_agroforestry/exo/realization.gms deleted file mode 100644 index 09b54d0aa4..0000000000 --- a/modules/61_agroforestry/exo/realization.gms +++ /dev/null @@ -1,21 +0,0 @@ -*** | (C) 2008-2023 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 In this realization, future shares of tree cover and bioenergy trees -*' on cropland at cluster level follow exogenous assumptions. -*' @stop -*' -*' @limitations There are currently no known limitations of this realization. - -*####################### R SECTION START (PHASES) ############################## -$Ifi "%phase%" == "declarations" $include "./modules/61_agroforestry/exo/declarations.gms" -$Ifi "%phase%" == "input" $include "./modules/61_agroforestry/exo/input.gms" -$Ifi "%phase%" == "equations" $include "./modules/61_agroforestry/exo/equations.gms" -$Ifi "%phase%" == "preloop" $include "./modules/61_agroforestry/exo/preloop.gms" -$Ifi "%phase%" == "presolve" $include "./modules/61_agroforestry/exo/presolve.gms" -$Ifi "%phase%" == "postsolve" $include "./modules/61_agroforestry/exo/postsolve.gms" -*######################## R SECTION END (PHASES) ############################### diff --git a/modules/61_agroforestry/module.gms b/modules/61_agroforestry/module.gms deleted file mode 100644 index a1f82ca32e..0000000000 --- a/modules/61_agroforestry/module.gms +++ /dev/null @@ -1,22 +0,0 @@ -*** | (C) 2008-2023 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 - -*' @title Agroforestry -*' -*' @description The purpose of the agroforestry module is to model different agroforestry -*' systems such as bioenergy trees and tree cover on cropland (hedgerows). -*' The agroforestry module interacts via the interfaces $vm\_area$ and $vm\_land$ with -*' the [30_crop] module. Furthermore, the agroforestry module provides cropland tree cover -*' ($vm\_treecover\_area$) and corresponding carbon stocks $vm\_treecover\_carbon$ to the [30_crop] module. -*' -*' @authors Florian Humpenöder - -*###################### R SECTION START (MODULETYPES) ########################## -$Ifi "%agroforestry%" == "endo" $include "./modules/61_agroforestry/endo/realization.gms" -$Ifi "%agroforestry%" == "exo" $include "./modules/61_agroforestry/exo/realization.gms" -$Ifi "%agroforestry%" == "off" $include "./modules/61_agroforestry/off/realization.gms" -*###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/61_agroforestry/off/declarations.gms b/modules/61_agroforestry/off/declarations.gms deleted file mode 100644 index c60ff969c2..0000000000 --- a/modules/61_agroforestry/off/declarations.gms +++ /dev/null @@ -1,25 +0,0 @@ -*** | (C) 2008-2023 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 - -variables - vm_cost_agroforestry(j) Cost and rewards related to agroforestry (mio. USD05MER per yr) -; - -positive variables - vm_treecover_area(j) Cropland tree cover (mio. ha) - vm_treecover_carbon(j,ag_pools,stockType) Cropland tree cover above ground carbon content (mio. tC) -; - - -*#################### R SECTION START (OUTPUT DECLARATIONS) #################### -parameters - ov_cost_agroforestry(t,j,type) Cost and rewards related to agroforestry (mio. USD05MER per yr) - ov_treecover_area(t,j,type) Cropland tree cover (mio. ha) - ov_treecover_carbon(t,j,ag_pools,stockType,type) Cropland tree cover above ground carbon content (mio. tC) -; -*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### - diff --git a/modules/61_agroforestry/off/not_used.txt b/modules/61_agroforestry/off/not_used.txt deleted file mode 100644 index 2162d9dc96..0000000000 --- a/modules/61_agroforestry/off/not_used.txt +++ /dev/null @@ -1,10 +0,0 @@ -name,type,reason -vm_land, input, not used -pm_interest, input, not used -pm_land_start,input,not used -pm_treecover_shr,input,not used -fm_luh2_side_layers,input,not used -vm_area,input,not used -fm_bii_coeff,input,not used -pm_carbon_density_ac,input,not used -pm_carbon_density_ac_forestry,input,not used diff --git a/modules/61_agroforestry/off/postsolve.gms b/modules/61_agroforestry/off/postsolve.gms deleted file mode 100644 index 2f4f4d4362..0000000000 --- a/modules/61_agroforestry/off/postsolve.gms +++ /dev/null @@ -1,22 +0,0 @@ -*** | (C) 2008-2023 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 - -*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov_cost_agroforestry(t,j,"marginal") = vm_cost_agroforestry.m(j); - ov_treecover_area(t,j,"marginal") = vm_treecover_area.m(j); - ov_treecover_carbon(t,j,ag_pools,stockType,"marginal") = vm_treecover_carbon.m(j,ag_pools,stockType); - ov_cost_agroforestry(t,j,"level") = vm_cost_agroforestry.l(j); - ov_treecover_area(t,j,"level") = vm_treecover_area.l(j); - ov_treecover_carbon(t,j,ag_pools,stockType,"level") = vm_treecover_carbon.l(j,ag_pools,stockType); - ov_cost_agroforestry(t,j,"upper") = vm_cost_agroforestry.up(j); - ov_treecover_area(t,j,"upper") = vm_treecover_area.up(j); - ov_treecover_carbon(t,j,ag_pools,stockType,"upper") = vm_treecover_carbon.up(j,ag_pools,stockType); - ov_cost_agroforestry(t,j,"lower") = vm_cost_agroforestry.lo(j); - ov_treecover_area(t,j,"lower") = vm_treecover_area.lo(j); - ov_treecover_carbon(t,j,ag_pools,stockType,"lower") = vm_treecover_carbon.lo(j,ag_pools,stockType); -*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### - diff --git a/modules/61_agroforestry/off/preloop.gms b/modules/61_agroforestry/off/preloop.gms deleted file mode 100644 index 46c7e61bb3..0000000000 --- a/modules/61_agroforestry/off/preloop.gms +++ /dev/null @@ -1,11 +0,0 @@ -*** | (C) 2008-2023 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_cost_agroforestry.fx(j) = 0; -vm_treecover_area.fx(j) = 0; -vm_treecover_carbon.fx(j,ag_pools,stockType) = 0; -vm_bv.fx(j,"crop_tree",potnatveg) = 0; diff --git a/modules/61_agroforestry/off/realization.gms b/modules/61_agroforestry/off/realization.gms deleted file mode 100644 index 58dab000af..0000000000 --- a/modules/61_agroforestry/off/realization.gms +++ /dev/null @@ -1,17 +0,0 @@ -*** | (C) 2008-2023 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 In this realization, agroforestry does not exist. Therefore, -*' cropland tree cover and corresponding carbon stocks are fixed to zero. - -*' @limitations Cropland tree cover and corresponding carbon stocks are fixed to zero. - -*####################### R SECTION START (PHASES) ############################## -$Ifi "%phase%" == "declarations" $include "./modules/61_agroforestry/off/declarations.gms" -$Ifi "%phase%" == "preloop" $include "./modules/61_agroforestry/off/preloop.gms" -$Ifi "%phase%" == "postsolve" $include "./modules/61_agroforestry/off/postsolve.gms" -*######################## R SECTION END (PHASES) ############################### diff --git a/modules/include.gms b/modules/include.gms index 13ff07c83e..e46128a47c 100644 --- a/modules/include.gms +++ b/modules/include.gms @@ -23,6 +23,7 @@ $include "./modules/20_processing/module.gms" $include "./modules/21_trade/module.gms" $include "./modules/22_land_conservation/module.gms" $include "./modules/28_ageclass/module.gms" +$include "./modules/29_cropland/module.gms" $include "./modules/30_crop/module.gms" $include "./modules/31_past/module.gms" $include "./modules/32_forestry/module.gms" @@ -49,7 +50,6 @@ $include "./modules/57_maccs/module.gms" $include "./modules/58_peatland/module.gms" $include "./modules/59_som/module.gms" $include "./modules/60_bioenergy/module.gms" -$include "./modules/61_agroforestry/module.gms" $include "./modules/62_material/module.gms" $include "./modules/70_livestock/module.gms" $include "./modules/71_disagg_lvst/module.gms" From 94679847e2713bb28d8b6061cba60d79520cc020 Mon Sep 17 00:00:00 2001 From: florianh Date: Fri, 19 Apr 2024 15:43:56 +0200 Subject: [PATCH 010/133] partial commit to save work --- config/default.cfg | 16 +++++++++++++ .../10_land/landmatrix_dec18/declarations.gms | 1 - .../rulebased_apr24/declarations.gms | 24 +++++++++---------- .../29_cropland/rulebased_apr24/equations.gms | 5 ++++ modules/29_cropland/rulebased_apr24/input.gms | 7 ++---- modules/30_crop/endo_apr21/input.gms | 2 +- modules/44_biodiversity/bv_btc_mar21/sets.gms | 2 +- 7 files changed, 37 insertions(+), 20 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index 65dac22111..d30443bc7a 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -712,6 +712,15 @@ cfg$gms$policy_countries29 <- all_iso_countries # * "secdforest, past, other" etc. cfg$gms$land_snv <- "secdforest, forestry, past, other" #def = "secdforest, forestry, past, other" +# * Minimum share of treecover on cropland reached in s29_treecover_scenario_target: +# * Minimum share of treecover on total cropland area (including croparea, fallow land and tree cover). +# * s29_treecover_min_shr is faded in linearly between s29_treecover_scenario_start and s29_treecover_scenario_target. +cfg$gms$s29_treecover_min_shr <- 0 #def = 0 +# * Start year of tree cover share fade-in: +cfg$gms$s29_treecover_scenario_start <- 2020 # def = 2020 +# * Target year (year when full implementation is reached): +cfg$gms$s29_treecover_scenario_target <- 2040 # def = 2040 + # ***--------------------- 30_crop --------------------------------------- # * 30_crop defines the croparea, which is a subcomponent of total cropland defined in 29_cropland. # * (endo_apr21): Hard rotational constraints. Dynamic cropland and detailed cropland availability data at grid cell level. @@ -740,6 +749,13 @@ cfg$gms$s30_rotation_scenario_start <- 2020 # def = 2020 # * Target year (year when full implementation is reached): cfg$gms$s30_rotation_scenario_target <- 2050 # def = 2050 +# * Minimum share of bioenergy trees on total cropland area (including croparea, fallow land and tree cover). +# * s30_betr_min_shr is faded in linearly between s30_betr_scenario_start and s30_betr_scenario_target. +cfg$gms$s30_betr_min_shr <- 0 #def = 0 +# * Start year of tree cover share fade-in: +cfg$gms$s30_betr_scenario_start <- 2020 # def = 2020 +# * Target year (year when full implementation is reached): +cfg$gms$s30_betr_scenario_target <- 2040 # def = 2040 # ***--------------------- 31_past --------------------------------------- # * (static): static pasture diff --git a/modules/10_land/landmatrix_dec18/declarations.gms b/modules/10_land/landmatrix_dec18/declarations.gms index 8ac9b52b8f..8a7737a301 100644 --- a/modules/10_land/landmatrix_dec18/declarations.gms +++ b/modules/10_land/landmatrix_dec18/declarations.gms @@ -9,7 +9,6 @@ parameters pm_land_start(j,land) Land initialization area (mio. ha) pm_land_hist(t_ini10,j,land) Land area for historial time steps (mio. ha) pcm_land(j,land) Land area in previous time step including possible changes after optimization (mio. ha) - pm_treecover_shr(j) Cropland tree cover share (1) ; variables diff --git a/modules/29_cropland/rulebased_apr24/declarations.gms b/modules/29_cropland/rulebased_apr24/declarations.gms index de1325dffa..aadfb3a404 100644 --- a/modules/29_cropland/rulebased_apr24/declarations.gms +++ b/modules/29_cropland/rulebased_apr24/declarations.gms @@ -23,8 +23,8 @@ parameters p29_rotation_scenario_fader(t_all) Crop rotation scenario fader (1) - p29_treecover_min_shr(t,j) Minimum share of treecover on cropland (1) - p29_treecover_scenario_fader(t_all) Cropland treecover scenario fader (1) + p29_treecover_min_shr(t,j) Minimum share of treecover on cropland (1) + p29_treecover_scenario_fader(t_all) Cropland treecover scenario fader (1) p29_treecover_bii_coeff(bii_class_secd,potnatveg) BII coefficient for cropland treecover (1) p29_carbon_density_ac(t,j,ac,ag_pools) Carbon density for ac and ag_pools (tC per ha) p29_treecover(t,j,ac) Cropland tree cover per age class (mio. ha) @@ -34,18 +34,18 @@ parameters positive variables vm_fallow(j) Fallow land is temporarily fallow cropland (mio. ha) v29_treecover(j,ac) Cropland tree cover per age class (mio. ha) - vm_cost_cropland(j) - v29_cost_treecover_est(j) Establishment cost for cropland tree cover (mio. USD05MER per yr) - v29_cost_treecover_recur(j) Recurring cost for cropland tree cover (mio. USD05MER per yr) + vm_cost_cropland(j) Cost for total cropland (mio. USD05MER per yr) + v29_cost_treecover_est(j) Establishment cost for cropland tree cover (mio. USD05MER per yr) + v29_cost_treecover_recur(j) Recurring cost for cropland tree cover (mio. USD05MER per yr) ; equations - q29_cropland(j) Total cropland calculation (mio. ha) - q29_avl_cropland(j) Available cropland constraint (mio. ha) - q29_carbon(j,ag_pools,stockType) Cropland above ground carbon content calculation (mio. tC) - q29_land_snv(j) Land constraint for the SNV policy in cropland areas (mio. ha) - q29_land_snv_trans(j) Land transition constraint for SNV policy in cropland areas (mio. ha) - q29_cost_cropland(j) Costs and benefits related to agroforestry (mio. USD05MER per yr) + q29_cropland(j) Total cropland calculation (mio. ha) + q29_avl_cropland(j) Available cropland constraint (mio. ha) + q29_carbon(j,ag_pools,stockType) Cropland above ground carbon content calculation (mio. tC) + q29_land_snv(j) Land constraint for the SNV policy in cropland areas (mio. ha) + q29_land_snv_trans(j) Land transition constraint for SNV policy in cropland areas (mio. ha) + q29_cost_cropland(j) Costs and benefits related to agroforestry (mio. USD05MER per yr) q29_cost_treecover_est(j) Establishment cost for cropland tree cover (mio. USD05MER per yr) q29_cost_treecover_recur(j) Recurring cost for cropland tree cover (mio. USD05MER per yr) q29_treecover_shr(j) Cropland treecover minimum share (mio. ha) @@ -57,7 +57,7 @@ equations parameters ov_fallow(t,j,type) Fallow land is temporarily fallow cropland (mio. ha) ov29_treecover(t,j,ac,type) Cropland tree cover per age class (mio. ha) - ov_cost_cropland(t,j,type) + ov_cost_cropland(t,j,type) Cost for total cropland (mio. USD05MER per yr) ov29_cost_treecover_est(t,j,type) Establishment cost for cropland tree cover (mio. USD05MER per yr) ov29_cost_treecover_recur(t,j,type) Recurring cost for cropland tree cover (mio. USD05MER per yr) oq29_cropland(t,j,type) Total cropland calculation (mio. ha) diff --git a/modules/29_cropland/rulebased_apr24/equations.gms b/modules/29_cropland/rulebased_apr24/equations.gms index 311a61051c..9b6cbac2de 100644 --- a/modules/29_cropland/rulebased_apr24/equations.gms +++ b/modules/29_cropland/rulebased_apr24/equations.gms @@ -81,3 +81,8 @@ q29_treecover_bv(j2,potnatveg) .. vm_bv(j2,"crop_tree",potnatveg) =e= sum(bii_class_secd, sum(ac_to_bii_class_secd(ac,bii_class_secd), v29_treecover(j2,ac)) * p29_treecover_bii_coeff(bii_class_secd,potnatveg)) * fm_luh2_side_layers(j2,potnatveg); + +*' Tree cover biodiversity value +q29_fallow_bv(j2,potnatveg) .. + vm_bv(j2,"crop_fallow",potnatveg) =e= + vm_fallow(j2) * fm_bii_coeff("crop_per",potnatveg) * fm_luh2_side_layers(j2,potnatveg); diff --git a/modules/29_cropland/rulebased_apr24/input.gms b/modules/29_cropland/rulebased_apr24/input.gms index 658dcd38c1..416abde01d 100644 --- a/modules/29_cropland/rulebased_apr24/input.gms +++ b/modules/29_cropland/rulebased_apr24/input.gms @@ -5,9 +5,6 @@ *** | MAgPIE License Exception, version 1.0 (see LICENSE file). *** | Contact: magpie@pik-potsdam.de -* $setglobal c29_snv_target none -* options: none, by2030, by2020 - $setglobal c29_marginal_land q33_marginal * options: all_marginal, q33_marginal, no_marginal @@ -24,8 +21,8 @@ s29_snv_relocation_data_x2 Second reference value in SNV target cropland da s29_treecover_bii_coeff BII coefficent to be used for tree cover on cropland 0=secondary vegetation 1=timber plantations (1) / 0 / s29_treecover_decrease Cropland treecover can decrease (1) or not (0) / 0 / s29_treecover_scenario_start Cropland treecover scenario start year / 2020 / - s29_treecover_scenario_target Cropland treecover scenario target year / 2050 / - s29_treecover_min_shr Share of treecover on cropland (1) / 0.2 / + s29_treecover_scenario_target Cropland treecover scenario target year / 2040 / + s29_treecover_min_shr Share of treecover on cropland (1) / 0 / ; diff --git a/modules/30_crop/endo_apr21/input.gms b/modules/30_crop/endo_apr21/input.gms index 1ae154a2a6..9910b3c134 100644 --- a/modules/30_crop/endo_apr21/input.gms +++ b/modules/30_crop/endo_apr21/input.gms @@ -19,7 +19,7 @@ scalars s30_rotation_scenario_target Rotation scenario target year / 2050 / s30_betr_min_shr Minimum share of bioenergy trees on cropland (1) / 0 / s30_betr_scenario_start Bioenergy trees scenario start year / 2020 / - s30_betr_scenario_target Bioenergy trees scenario target year / 2050 / + s30_betr_scenario_target Bioenergy trees scenario target year / 2040 / ; $ifthen "%c30_bioen_type%" == "all" bioen_type_30(kbe30) = yes; diff --git a/modules/44_biodiversity/bv_btc_mar21/sets.gms b/modules/44_biodiversity/bv_btc_mar21/sets.gms index 1e37a7898a..f5918dd210 100644 --- a/modules/44_biodiversity/bv_btc_mar21/sets.gms +++ b/modules/44_biodiversity/bv_btc_mar21/sets.gms @@ -11,7 +11,7 @@ sets / crop_ann, crop_per, crop_tree, manpast, rangeland, urban, aff_ndc, aff_co2p, primforest, secdforest, other, plant / bii_class44 bii coefficent land cover classes - / crop_ann, crop_per, crop_tree, manpast, rangeland, urban, primary, secd_mature, secd_young, timber / + / crop_ann, crop_per, crop_tree, crop_fallow, manpast, rangeland, urban, primary, secd_mature, secd_young, timber / bii_class_secd(bii_class44) bii coefficent land cover classes secondary vegetation / secd_mature, secd_young / From 20e42a29bd1f071defb38e496333606e86a5a5cf Mon Sep 17 00:00:00 2001 From: florianh Date: Fri, 19 Apr 2024 17:19:42 +0200 Subject: [PATCH 011/133] partial commit to save work --- modules/29_cropland/rulebased_apr24/declarations.gms | 6 ++++-- modules/29_cropland/rulebased_apr24/input.gms | 12 ++++++------ modules/29_cropland/rulebased_apr24/postsolve.gms | 4 ++++ modules/44_biodiversity/bii_target/sets.gms | 4 ++-- modules/44_biodiversity/bv_btc_mar21/sets.gms | 4 ++-- 5 files changed, 18 insertions(+), 12 deletions(-) diff --git a/modules/29_cropland/rulebased_apr24/declarations.gms b/modules/29_cropland/rulebased_apr24/declarations.gms index aadfb3a404..ee142ef286 100644 --- a/modules/29_cropland/rulebased_apr24/declarations.gms +++ b/modules/29_cropland/rulebased_apr24/declarations.gms @@ -50,7 +50,8 @@ equations q29_cost_treecover_recur(j) Recurring cost for cropland tree cover (mio. USD05MER per yr) q29_treecover_shr(j) Cropland treecover minimum share (mio. ha) q29_treecover_est(j,ac) Cropland treecover establishment (mio. ha) - q29_treecover_bv(j,potnatveg) Biodiversity value for cropland treecover (Mha) + q29_treecover_bv(j,potnatveg) Biodiversity value for cropland treecover (mio. ha) + q29_fallow_bv(j,potnatveg) Biodiversity value for fallow land (mio. ha) ; *#################### R SECTION START (OUTPUT DECLARATIONS) #################### @@ -70,7 +71,8 @@ parameters oq29_cost_treecover_recur(t,j,type) Recurring cost for cropland tree cover (mio. USD05MER per yr) oq29_treecover_shr(t,j,type) Cropland treecover minimum share (mio. ha) oq29_treecover_est(t,j,ac,type) Cropland treecover establishment (mio. ha) - oq29_treecover_bv(t,j,potnatveg,type) Biodiversity value for cropland treecover (Mha) + oq29_treecover_bv(t,j,potnatveg,type) Biodiversity value for cropland treecover (mio. ha) + oq29_fallow_bv(t,j,potnatveg,type) Biodiversity value for fallow land (mio. ha) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/29_cropland/rulebased_apr24/input.gms b/modules/29_cropland/rulebased_apr24/input.gms index 416abde01d..da26e33c3d 100644 --- a/modules/29_cropland/rulebased_apr24/input.gms +++ b/modules/29_cropland/rulebased_apr24/input.gms @@ -9,12 +9,12 @@ $setglobal c29_marginal_land q33_marginal * options: all_marginal, q33_marginal, no_marginal scalars -s29_snv_shr Share of available cropland that is witheld for other land cover types (1) / 0 / -s29_snv_shr_noselect Share of available cropland that is witheld for other land cover types (1) / 0 / -s29_snv_scenario_start SNV scenario start year / 2020 / -s29_snv_scenario_target SNV scenario target year / 2029 / -s29_snv_relocation_data_x1 First reference value in SNV target cropland data (1) / 0.2 / -s29_snv_relocation_data_x2 Second reference value in SNV target cropland data (1) / 0.5 / + s29_snv_shr Share of available cropland that is witheld for other land cover types (1) / 0 / + s29_snv_shr_noselect Share of available cropland that is witheld for other land cover types (1) / 0 / + s29_snv_scenario_start SNV scenario start year / 2020 / + s29_snv_scenario_target SNV scenario target year / 2029 / + s29_snv_relocation_data_x1 First reference value in SNV target cropland data (1) / 0.2 / + s29_snv_relocation_data_x2 Second reference value in SNV target cropland data (1) / 0.5 / s29_cost_treecover_est Tree cover establishment cost (USD per ha) / 2000 / s29_cost_treecover_recur Tree cover recurring cost (USD per ha) / 500 / s29_treecover_plantation Growth curve switch for tree cover on cropland 0=natveg 1=plantations (1) / 0 / diff --git a/modules/29_cropland/rulebased_apr24/postsolve.gms b/modules/29_cropland/rulebased_apr24/postsolve.gms index eaad1f7dbd..2fb2d6991f 100644 --- a/modules/29_cropland/rulebased_apr24/postsolve.gms +++ b/modules/29_cropland/rulebased_apr24/postsolve.gms @@ -24,6 +24,7 @@ pc29_treecover(j,ac) = v29_treecover.l(j,ac); oq29_treecover_shr(t,j,"marginal") = q29_treecover_shr.m(j); oq29_treecover_est(t,j,ac,"marginal") = q29_treecover_est.m(j,ac); oq29_treecover_bv(t,j,potnatveg,"marginal") = q29_treecover_bv.m(j,potnatveg); + oq29_fallow_bv(t,j,potnatveg,"marginal") = q29_fallow_bv.m(j,potnatveg); ov_fallow(t,j,"level") = vm_fallow.l(j); ov29_treecover(t,j,ac,"level") = v29_treecover.l(j,ac); ov_cost_cropland(t,j,"level") = vm_cost_cropland.l(j); @@ -40,6 +41,7 @@ pc29_treecover(j,ac) = v29_treecover.l(j,ac); oq29_treecover_shr(t,j,"level") = q29_treecover_shr.l(j); oq29_treecover_est(t,j,ac,"level") = q29_treecover_est.l(j,ac); oq29_treecover_bv(t,j,potnatveg,"level") = q29_treecover_bv.l(j,potnatveg); + oq29_fallow_bv(t,j,potnatveg,"level") = q29_fallow_bv.l(j,potnatveg); ov_fallow(t,j,"upper") = vm_fallow.up(j); ov29_treecover(t,j,ac,"upper") = v29_treecover.up(j,ac); ov_cost_cropland(t,j,"upper") = vm_cost_cropland.up(j); @@ -56,6 +58,7 @@ pc29_treecover(j,ac) = v29_treecover.l(j,ac); oq29_treecover_shr(t,j,"upper") = q29_treecover_shr.up(j); oq29_treecover_est(t,j,ac,"upper") = q29_treecover_est.up(j,ac); oq29_treecover_bv(t,j,potnatveg,"upper") = q29_treecover_bv.up(j,potnatveg); + oq29_fallow_bv(t,j,potnatveg,"upper") = q29_fallow_bv.up(j,potnatveg); ov_fallow(t,j,"lower") = vm_fallow.lo(j); ov29_treecover(t,j,ac,"lower") = v29_treecover.lo(j,ac); ov_cost_cropland(t,j,"lower") = vm_cost_cropland.lo(j); @@ -72,5 +75,6 @@ pc29_treecover(j,ac) = v29_treecover.l(j,ac); oq29_treecover_shr(t,j,"lower") = q29_treecover_shr.lo(j); oq29_treecover_est(t,j,ac,"lower") = q29_treecover_est.lo(j,ac); oq29_treecover_bv(t,j,potnatveg,"lower") = q29_treecover_bv.lo(j,potnatveg); + oq29_fallow_bv(t,j,potnatveg,"lower") = q29_fallow_bv.lo(j,potnatveg); *##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/44_biodiversity/bii_target/sets.gms b/modules/44_biodiversity/bii_target/sets.gms index 1c3ee18597..fb93906e40 100644 --- a/modules/44_biodiversity/bii_target/sets.gms +++ b/modules/44_biodiversity/bii_target/sets.gms @@ -8,10 +8,10 @@ sets landcover44 land cover classes used in bii calculation - / crop_ann, crop_per, crop_tree, manpast, rangeland, urban, aff_ndc, aff_co2p, primforest, secdforest, other, plant / + / crop_ann, crop_per, crop_tree, crop_fallow, manpast, rangeland, urban, aff_ndc, aff_co2p, primforest, secdforest, other, plant / bii_class44 bii coefficent land cover classes - / crop_ann, crop_per, crop_tree, manpast, rangeland, urban, primary, secd_mature, secd_young, timber / + / crop_ann, crop_per, manpast, rangeland, urban, primary, secd_mature, secd_young, timber / bii_class_secd(bii_class44) bii coefficent land cover classes secondary vegetation / secd_mature, secd_young / diff --git a/modules/44_biodiversity/bv_btc_mar21/sets.gms b/modules/44_biodiversity/bv_btc_mar21/sets.gms index f5918dd210..ebee4de5cf 100644 --- a/modules/44_biodiversity/bv_btc_mar21/sets.gms +++ b/modules/44_biodiversity/bv_btc_mar21/sets.gms @@ -8,10 +8,10 @@ sets landcover44 land cover classes used in bii calculation - / crop_ann, crop_per, crop_tree, manpast, rangeland, urban, aff_ndc, aff_co2p, primforest, secdforest, other, plant / + / crop_ann, crop_per, crop_tree, crop_fallow, manpast, rangeland, urban, aff_ndc, aff_co2p, primforest, secdforest, other, plant / bii_class44 bii coefficent land cover classes - / crop_ann, crop_per, crop_tree, crop_fallow, manpast, rangeland, urban, primary, secd_mature, secd_young, timber / + / crop_ann, crop_per, manpast, rangeland, urban, primary, secd_mature, secd_young, timber / bii_class_secd(bii_class44) bii coefficent land cover classes secondary vegetation / secd_mature, secd_young / From f96fbb00b4f55c774cfdb41eb5cdb0e9ffc2fb5f Mon Sep 17 00:00:00 2001 From: florianh Date: Fri, 19 Apr 2024 18:16:48 +0200 Subject: [PATCH 012/133] partial commit to save work --- config/default.cfg | 13 +++-------- .../rulebased_apr24/declarations.gms | 7 +++++- .../29_cropland/rulebased_apr24/equations.gms | 10 ++++++++- modules/29_cropland/rulebased_apr24/input.gms | 5 ++++- .../29_cropland/rulebased_apr24/postsolve.gms | 4 ++++ .../29_cropland/rulebased_apr24/preloop.gms | 1 + .../29_cropland/rulebased_apr24/presolve.gms | 2 ++ modules/30_crop/endo_apr21/declarations.gms | 4 ---- modules/30_crop/endo_apr21/equations.gms | 7 ------ modules/30_crop/endo_apr21/input.gms | 3 --- modules/30_crop/endo_apr21/postsolve.gms | 4 ---- modules/30_crop/endo_apr21/preloop.gms | 1 - modules/30_crop/endo_apr21/presolve.gms | 2 -- modules/30_crop/penalty_apr22/sets.gms | 22 ++++++------------- .../30_crop/rotation_apr22/declarations.gms | 4 ---- modules/30_crop/rotation_apr22/equations.gms | 7 ------ modules/30_crop/rotation_apr22/input.gms | 6 ++--- modules/30_crop/rotation_apr22/postsolve.gms | 4 ---- modules/30_crop/rotation_apr22/preloop.gms | 1 - modules/30_crop/rotation_apr22/presolve.gms | 2 -- modules/30_crop/rotation_apr22/sets.gms | 8 ++++--- 21 files changed, 43 insertions(+), 74 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index d30443bc7a..65b72072a6 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -737,8 +737,9 @@ cfg$gms$c30_rotation_constraints <- "on" # def = "on" # * (c30_rotation_scenario): scenarios for constraints. # * In realization rotation_apr22: min (minimal constraints), default (best guess), good (good practice), # * good_20div (good practice - 20% for other crops), setaside (default plus fallow), -# * legumes (minimum share of legumes), agroforestry (minimum share of perennials), sixfoldrotation -# * (crops can only repeat after 6 years), agroecology (mix of previous scenarios) +# * legumes (minimum share of legumes), sixfoldrotation (crops can only repeat after 6 years), +# * agroecology (mix of previous scenarios), +# * betr0 (minimum share of short rotation agroforestry trees), betr10, betr20, betr25, betr30, betr40, betr50. # * In realization penalty_apr22: none (no incentives), default (best guess), fallow (increased fallow incentives), # * legumes (increased incentives for legumes), agroforestry (increased incentives for perennials), agroecology (mix) # * In realization endo_apr21: no scenarios exist. @@ -749,14 +750,6 @@ cfg$gms$s30_rotation_scenario_start <- 2020 # def = 2020 # * Target year (year when full implementation is reached): cfg$gms$s30_rotation_scenario_target <- 2050 # def = 2050 -# * Minimum share of bioenergy trees on total cropland area (including croparea, fallow land and tree cover). -# * s30_betr_min_shr is faded in linearly between s30_betr_scenario_start and s30_betr_scenario_target. -cfg$gms$s30_betr_min_shr <- 0 #def = 0 -# * Start year of tree cover share fade-in: -cfg$gms$s30_betr_scenario_start <- 2020 # def = 2020 -# * Target year (year when full implementation is reached): -cfg$gms$s30_betr_scenario_target <- 2040 # def = 2040 - # ***--------------------- 31_past --------------------------------------- # * (static): static pasture # * (endo_jun13): dynamic pasture diff --git a/modules/29_cropland/rulebased_apr24/declarations.gms b/modules/29_cropland/rulebased_apr24/declarations.gms index ee142ef286..86b2c02637 100644 --- a/modules/29_cropland/rulebased_apr24/declarations.gms +++ b/modules/29_cropland/rulebased_apr24/declarations.gms @@ -25,6 +25,9 @@ parameters p29_treecover_min_shr(t,j) Minimum share of treecover on cropland (1) p29_treecover_scenario_fader(t_all) Cropland treecover scenario fader (1) + p29_fallow_min_shr(t,j) Minimum share of fallow land (1) + p29_fallow_scenario_fader(t_all) Fallow land scenario fader (1) + p29_treecover_bii_coeff(bii_class_secd,potnatveg) BII coefficient for cropland treecover (1) p29_carbon_density_ac(t,j,ac,ag_pools) Carbon density for ac and ag_pools (tC per ha) p29_treecover(t,j,ac) Cropland tree cover per age class (mio. ha) @@ -48,10 +51,11 @@ equations q29_cost_cropland(j) Costs and benefits related to agroforestry (mio. USD05MER per yr) q29_cost_treecover_est(j) Establishment cost for cropland tree cover (mio. USD05MER per yr) q29_cost_treecover_recur(j) Recurring cost for cropland tree cover (mio. USD05MER per yr) + q29_fallow_shr(j) Fallow land share (mio. ha) q29_treecover_shr(j) Cropland treecover minimum share (mio. ha) q29_treecover_est(j,ac) Cropland treecover establishment (mio. ha) q29_treecover_bv(j,potnatveg) Biodiversity value for cropland treecover (mio. ha) - q29_fallow_bv(j,potnatveg) Biodiversity value for fallow land (mio. ha) + q29_fallow_bv(j,potnatveg) Biodiversity value for fallow land (mio. ha) ; *#################### R SECTION START (OUTPUT DECLARATIONS) #################### @@ -69,6 +73,7 @@ parameters oq29_cost_cropland(t,j,type) Costs and benefits related to agroforestry (mio. USD05MER per yr) oq29_cost_treecover_est(t,j,type) Establishment cost for cropland tree cover (mio. USD05MER per yr) oq29_cost_treecover_recur(t,j,type) Recurring cost for cropland tree cover (mio. USD05MER per yr) + oq29_fallow_shr(t,j,type) Fallow land share (mio. ha) oq29_treecover_shr(t,j,type) Cropland treecover minimum share (mio. ha) oq29_treecover_est(t,j,ac,type) Cropland treecover establishment (mio. ha) oq29_treecover_bv(t,j,potnatveg,type) Biodiversity value for cropland treecover (mio. ha) diff --git a/modules/29_cropland/rulebased_apr24/equations.gms b/modules/29_cropland/rulebased_apr24/equations.gms index 9b6cbac2de..1f5649f9a2 100644 --- a/modules/29_cropland/rulebased_apr24/equations.gms +++ b/modules/29_cropland/rulebased_apr24/equations.gms @@ -34,7 +34,6 @@ sum(ct, p29_snv_shr(ct,j2)) * vm_land(j2,"crop") + sum((ct,land_snv,consv_type), pm_land_conservation(ct,j2,land_snv,consv_type)); - *' The semi-natural vegetation constraint for cropland areas has been suggested at the per square *' kilometer scale. The amount of cropland requiring relocation has therefore been derived from *' exogeneous high-resolution land cover information from the Copernicus Global Land Service @@ -52,10 +51,19 @@ + vm_fallow(j2) * sum(ct, fm_carbon_density(ct,j2,"crop",ag_pools)) + m_carbon_stock_ac(v29_treecover,p29_carbon_density_ac,"ac","ac_sub"); + +*' Total cost q29_cost_cropland(j2) .. vm_cost_cropland(j2) =e= v29_cost_treecover_est(j2) + v29_cost_treecover_recur(j2); + +*' Fallow land minimum share +q29_fallow_shr(j2) .. + vm_fallow(j2) =g= + sum(ct, p29_fallow_min_shr(ct,j2)) * vm_land(j2,"crop"); + + *' Tree cover establishment cost q29_cost_treecover_est(j2) .. v29_cost_treecover_est(j2) =e= diff --git a/modules/29_cropland/rulebased_apr24/input.gms b/modules/29_cropland/rulebased_apr24/input.gms index da26e33c3d..0cee55f7fa 100644 --- a/modules/29_cropland/rulebased_apr24/input.gms +++ b/modules/29_cropland/rulebased_apr24/input.gms @@ -21,8 +21,11 @@ scalars s29_treecover_bii_coeff BII coefficent to be used for tree cover on cropland 0=secondary vegetation 1=timber plantations (1) / 0 / s29_treecover_decrease Cropland treecover can decrease (1) or not (0) / 0 / s29_treecover_scenario_start Cropland treecover scenario start year / 2020 / - s29_treecover_scenario_target Cropland treecover scenario target year / 2040 / + s29_treecover_scenario_target Cropland treecover scenario target year / 2050 / s29_treecover_min_shr Share of treecover on cropland (1) / 0 / + s29_fallow_scenario_start Fallow land scenario start year / 2020 / + s29_fallow_scenario_target Fallow land scenario target year / 2050 / + s29_fallow_min_shr Share of fallow land (1) / 0 / ; diff --git a/modules/29_cropland/rulebased_apr24/postsolve.gms b/modules/29_cropland/rulebased_apr24/postsolve.gms index 2fb2d6991f..60c46e7c92 100644 --- a/modules/29_cropland/rulebased_apr24/postsolve.gms +++ b/modules/29_cropland/rulebased_apr24/postsolve.gms @@ -21,6 +21,7 @@ pc29_treecover(j,ac) = v29_treecover.l(j,ac); oq29_cost_cropland(t,j,"marginal") = q29_cost_cropland.m(j); oq29_cost_treecover_est(t,j,"marginal") = q29_cost_treecover_est.m(j); oq29_cost_treecover_recur(t,j,"marginal") = q29_cost_treecover_recur.m(j); + oq29_fallow_shr(t,j,"marginal") = q29_fallow_shr.m(j); oq29_treecover_shr(t,j,"marginal") = q29_treecover_shr.m(j); oq29_treecover_est(t,j,ac,"marginal") = q29_treecover_est.m(j,ac); oq29_treecover_bv(t,j,potnatveg,"marginal") = q29_treecover_bv.m(j,potnatveg); @@ -38,6 +39,7 @@ pc29_treecover(j,ac) = v29_treecover.l(j,ac); oq29_cost_cropland(t,j,"level") = q29_cost_cropland.l(j); oq29_cost_treecover_est(t,j,"level") = q29_cost_treecover_est.l(j); oq29_cost_treecover_recur(t,j,"level") = q29_cost_treecover_recur.l(j); + oq29_fallow_shr(t,j,"level") = q29_fallow_shr.l(j); oq29_treecover_shr(t,j,"level") = q29_treecover_shr.l(j); oq29_treecover_est(t,j,ac,"level") = q29_treecover_est.l(j,ac); oq29_treecover_bv(t,j,potnatveg,"level") = q29_treecover_bv.l(j,potnatveg); @@ -55,6 +57,7 @@ pc29_treecover(j,ac) = v29_treecover.l(j,ac); oq29_cost_cropland(t,j,"upper") = q29_cost_cropland.up(j); oq29_cost_treecover_est(t,j,"upper") = q29_cost_treecover_est.up(j); oq29_cost_treecover_recur(t,j,"upper") = q29_cost_treecover_recur.up(j); + oq29_fallow_shr(t,j,"upper") = q29_fallow_shr.up(j); oq29_treecover_shr(t,j,"upper") = q29_treecover_shr.up(j); oq29_treecover_est(t,j,ac,"upper") = q29_treecover_est.up(j,ac); oq29_treecover_bv(t,j,potnatveg,"upper") = q29_treecover_bv.up(j,potnatveg); @@ -72,6 +75,7 @@ pc29_treecover(j,ac) = v29_treecover.l(j,ac); oq29_cost_cropland(t,j,"lower") = q29_cost_cropland.lo(j); oq29_cost_treecover_est(t,j,"lower") = q29_cost_treecover_est.lo(j); oq29_cost_treecover_recur(t,j,"lower") = q29_cost_treecover_recur.lo(j); + oq29_fallow_shr(t,j,"lower") = q29_fallow_shr.lo(j); oq29_treecover_shr(t,j,"lower") = q29_treecover_shr.lo(j); oq29_treecover_est(t,j,ac,"lower") = q29_treecover_est.lo(j,ac); oq29_treecover_bv(t,j,potnatveg,"lower") = q29_treecover_bv.lo(j,potnatveg); diff --git a/modules/29_cropland/rulebased_apr24/preloop.gms b/modules/29_cropland/rulebased_apr24/preloop.gms index 3405958479..6ac9c3fee1 100644 --- a/modules/29_cropland/rulebased_apr24/preloop.gms +++ b/modules/29_cropland/rulebased_apr24/preloop.gms @@ -25,6 +25,7 @@ m_linear_cell_data_interpol(i29_snv_relocation_target, s29_snv_shr,s29_snv_reloc m_sigmoid_time_interpol(p29_treecover_scenario_fader,s29_treecover_scenario_start,s29_treecover_scenario_target,0,1); +m_sigmoid_time_interpol(p29_fallow_scenario_fader,s29_fallow_scenario_start,s29_fallow_scenario_target,0,1); * Initial tree cover on cropland is assumed to be equally distributed among all age-classes diff --git a/modules/29_cropland/rulebased_apr24/presolve.gms b/modules/29_cropland/rulebased_apr24/presolve.gms index 19a3b0a657..d53e7658cb 100644 --- a/modules/29_cropland/rulebased_apr24/presolve.gms +++ b/modules/29_cropland/rulebased_apr24/presolve.gms @@ -58,4 +58,6 @@ p29_treecover_min_shr(t,j) = ((1-p29_treecover_scenario_fader(t)) * sum(ac, pc29_treecover(j,ac))/pcm_land(j,"crop"))$(pcm_land(j,"crop") > 1e-10) + (p29_treecover_scenario_fader(t) * s29_treecover_min_shr); +p29_fallow_min_shr(t,j) = p29_fallow_scenario_fader(t) * s29_fallow_min_shr; + diff --git a/modules/30_crop/endo_apr21/declarations.gms b/modules/30_crop/endo_apr21/declarations.gms index fe0f504c4d..f3930b04c2 100644 --- a/modules/30_crop/endo_apr21/declarations.gms +++ b/modules/30_crop/endo_apr21/declarations.gms @@ -7,8 +7,6 @@ parameters p30_rotation_scenario_fader(t_all) Crop rotation scenario fader (1) - p30_betr_scenario_fader(t_all) Bioenergy trees scenario fader (1) - p30_betr_min_shr(t,j) Minimum share of bioenergy trees on cropland (1) ; positive variables @@ -21,7 +19,6 @@ equations q30_prod(j,kcr) Production of cropped products (mio. tDM) q30_rotation_max(j,crp30,w) Local maximum rotational constraints (mio. ha) q30_rotation_min(j,crp30,w) Local minimum rotational constraints (mio. ha) - q30_betr_shr(j) Bioenergy trees minimum share (mio. ha) q30_carbon(j,ag_pools) Croplarea above ground carbon content calculation (mio. tC) q30_bv_ann(j,potnatveg) Biodiversity value of annual cropland (mio. ha) q30_bv_per(j,potnatveg) Biodiversity value of perennial cropland (mio. ha) @@ -35,7 +32,6 @@ parameters oq30_prod(t,j,kcr,type) Production of cropped products (mio. tDM) oq30_rotation_max(t,j,crp30,w,type) Local maximum rotational constraints (mio. ha) oq30_rotation_min(t,j,crp30,w,type) Local minimum rotational constraints (mio. ha) - oq30_betr_shr(t,j,type) Bioenergy trees minimum share (mio. ha) oq30_carbon(t,j,ag_pools,type) Croplarea above ground carbon content calculation (mio. tC) oq30_bv_ann(t,j,potnatveg,type) Biodiversity value of annual cropland (mio. ha) oq30_bv_per(t,j,potnatveg,type) Biodiversity value of perennial cropland (mio. ha) diff --git a/modules/30_crop/endo_apr21/equations.gms b/modules/30_crop/endo_apr21/equations.gms index abb8d23f5e..626f0ce4a6 100644 --- a/modules/30_crop/endo_apr21/equations.gms +++ b/modules/30_crop/endo_apr21/equations.gms @@ -33,13 +33,6 @@ sum(kcr, vm_area(j2,kcr,w)) * f30_rotation_min_shr(crpmin30); -*' Bioenergy tree minimum share on cropland - -q30_betr_shr(j2) .. - sum(w, vm_area(j2,"betr",w)) =g= - sum(ct, p30_betr_min_shr(ct,j2)) * vm_land(j2,"crop"); - - *' The carbon stocks of the above ground carbon pools are calculated based on croparea and related carbon density. q30_carbon(j2,ag_pools) .. diff --git a/modules/30_crop/endo_apr21/input.gms b/modules/30_crop/endo_apr21/input.gms index 9910b3c134..aeacce22d7 100644 --- a/modules/30_crop/endo_apr21/input.gms +++ b/modules/30_crop/endo_apr21/input.gms @@ -17,9 +17,6 @@ $setglobal c30_rotation_constraints on scalars s30_rotation_scenario_start Rotation scenario start year / 2020 / s30_rotation_scenario_target Rotation scenario target year / 2050 / - s30_betr_min_shr Minimum share of bioenergy trees on cropland (1) / 0 / - s30_betr_scenario_start Bioenergy trees scenario start year / 2020 / - s30_betr_scenario_target Bioenergy trees scenario target year / 2040 / ; $ifthen "%c30_bioen_type%" == "all" bioen_type_30(kbe30) = yes; diff --git a/modules/30_crop/endo_apr21/postsolve.gms b/modules/30_crop/endo_apr21/postsolve.gms index 99044317e0..a9ba060e13 100644 --- a/modules/30_crop/endo_apr21/postsolve.gms +++ b/modules/30_crop/endo_apr21/postsolve.gms @@ -13,7 +13,6 @@ oq30_prod(t,j,kcr,"marginal") = q30_prod.m(j,kcr); oq30_rotation_max(t,j,crp30,w,"marginal") = q30_rotation_max.m(j,crp30,w); oq30_rotation_min(t,j,crp30,w,"marginal") = q30_rotation_min.m(j,crp30,w); - oq30_betr_shr(t,j,"marginal") = q30_betr_shr.m(j); oq30_carbon(t,j,ag_pools,"marginal") = q30_carbon.m(j,ag_pools); oq30_bv_ann(t,j,potnatveg,"marginal") = q30_bv_ann.m(j,potnatveg); oq30_bv_per(t,j,potnatveg,"marginal") = q30_bv_per.m(j,potnatveg); @@ -23,7 +22,6 @@ oq30_prod(t,j,kcr,"level") = q30_prod.l(j,kcr); oq30_rotation_max(t,j,crp30,w,"level") = q30_rotation_max.l(j,crp30,w); oq30_rotation_min(t,j,crp30,w,"level") = q30_rotation_min.l(j,crp30,w); - oq30_betr_shr(t,j,"level") = q30_betr_shr.l(j); oq30_carbon(t,j,ag_pools,"level") = q30_carbon.l(j,ag_pools); oq30_bv_ann(t,j,potnatveg,"level") = q30_bv_ann.l(j,potnatveg); oq30_bv_per(t,j,potnatveg,"level") = q30_bv_per.l(j,potnatveg); @@ -33,7 +31,6 @@ oq30_prod(t,j,kcr,"upper") = q30_prod.up(j,kcr); oq30_rotation_max(t,j,crp30,w,"upper") = q30_rotation_max.up(j,crp30,w); oq30_rotation_min(t,j,crp30,w,"upper") = q30_rotation_min.up(j,crp30,w); - oq30_betr_shr(t,j,"upper") = q30_betr_shr.up(j); oq30_carbon(t,j,ag_pools,"upper") = q30_carbon.up(j,ag_pools); oq30_bv_ann(t,j,potnatveg,"upper") = q30_bv_ann.up(j,potnatveg); oq30_bv_per(t,j,potnatveg,"upper") = q30_bv_per.up(j,potnatveg); @@ -43,7 +40,6 @@ oq30_prod(t,j,kcr,"lower") = q30_prod.lo(j,kcr); oq30_rotation_max(t,j,crp30,w,"lower") = q30_rotation_max.lo(j,crp30,w); oq30_rotation_min(t,j,crp30,w,"lower") = q30_rotation_min.lo(j,crp30,w); - oq30_betr_shr(t,j,"lower") = q30_betr_shr.lo(j); oq30_carbon(t,j,ag_pools,"lower") = q30_carbon.lo(j,ag_pools); oq30_bv_ann(t,j,potnatveg,"lower") = q30_bv_ann.lo(j,potnatveg); oq30_bv_per(t,j,potnatveg,"lower") = q30_bv_per.lo(j,potnatveg); diff --git a/modules/30_crop/endo_apr21/preloop.gms b/modules/30_crop/endo_apr21/preloop.gms index a837359f18..4cfa6b7f3b 100644 --- a/modules/30_crop/endo_apr21/preloop.gms +++ b/modules/30_crop/endo_apr21/preloop.gms @@ -8,7 +8,6 @@ ** Trajectory for cropland scenarios * sigmoidal interpolation between start year and target year m_sigmoid_time_interpol(p30_rotation_scenario_fader,s30_rotation_scenario_start,s30_rotation_scenario_target,0,1); -m_sigmoid_time_interpol(p30_betr_scenario_fader,s30_betr_scenario_start,s30_betr_scenario_target,0,1); *due to some rounding errors the input data currently may contain in some cases *very small, negative numbers. These numbers have to be set to 0 as area diff --git a/modules/30_crop/endo_apr21/presolve.gms b/modules/30_crop/endo_apr21/presolve.gms index 57661d9303..942042b0e9 100644 --- a/modules/30_crop/endo_apr21/presolve.gms +++ b/modules/30_crop/endo_apr21/presolve.gms @@ -25,5 +25,3 @@ vm_rotation_penalty.fx(i)=0; crpmax30(crp30) = yes$(f30_rotation_max_shr(crp30) < 1); crpmin30(crp30) = yes$(f30_rotation_min_shr(crp30) > 0); - -p30_betr_min_shr(t,j) = p30_betr_scenario_fader(t) * s30_betr_min_shr; diff --git a/modules/30_crop/penalty_apr22/sets.gms b/modules/30_crop/penalty_apr22/sets.gms index c03627a506..768e906278 100644 --- a/modules/30_crop/penalty_apr22/sets.gms +++ b/modules/30_crop/penalty_apr22/sets.gms @@ -7,22 +7,20 @@ sets rotascen30 rotation constraint scenarios - /none, default, fallow, legumes, agroforestry, agroecology/ + /none,default,legumes,betr500,betr1000,agroecology/ rota30 rotational rules - /all1_max, all2_max, - cereals1_max, cereals2_max, + /cereals1_max, cereals2_max, resistant_max, oilcrops_max, legumes_max, rootsrape_max, rice_pro_max, tece_max trce_max, maiz_max, biomass_min, legumes_min, - minor_min, cereals_min/ + minor_min, cereals_min, betr_min/ rotamax30(rota30) rotational maximum rules - /all1_max, all2_max, - cereals1_max, cereals2_max, + /cereals1_max, cereals2_max, resistant_max, oilcrops_max, legumes_max, rootsrape_max, rice_pro_max, tece_max @@ -30,7 +28,7 @@ sets / rotamin30(rota30) rotational minimum rules - /biomass_min, legumes_min, minor_min, cereals_min/ + /biomass_min, legumes_min, minor_min, cereals_min, betr_min/ rotamax_red30(rotamax30) Maximum crop rotation reduced set rotamin_red30(rotamin30) Minimum crop rotation reduced set @@ -49,13 +47,7 @@ sets * one percent fruits and vegs in each cell for regional demand rota_kcr30(rota30, kcr) Mapping of crop types into crop rotation types - / all1_max . (tece, maiz, trce, rice_pro, soybean, rapeseed, groundnut, sunflower, - oilpalm, puls_pro, potato, cassav_sp, sugr_cane, sugr_beet, others, - foddr, cottn_pro, begr, betr) - all2_max . (tece, maiz, trce, rice_pro, soybean, rapeseed, groundnut, sunflower, - oilpalm, puls_pro, potato, cassav_sp, sugr_cane, sugr_beet, others, - foddr, cottn_pro, begr, betr) - cereals1_max . (tece, maiz, trce, rice_pro) + / cereals1_max . (tece, maiz, trce, rice_pro) cereals2_max . (tece, maiz, trce, rice_pro) resistant_max . (begr,betr,foddr,sugr_cane,cottn_pro,oilpalm,others) oilcrops_max . (sunflower, rapeseed) @@ -69,9 +61,9 @@ sets legumes_min . (soybean, groundnut, puls_pro, foddr) minor_min . (sunflower, rapeseed, sugr_beet, cassav_sp, potato, others) cereals_min . (tece, maiz, trce, rice_pro) + betr_min . (betr) / - kbe30(kcr) bio energy activities / betr, begr / diff --git a/modules/30_crop/rotation_apr22/declarations.gms b/modules/30_crop/rotation_apr22/declarations.gms index 21611b7eb4..dc41cb568f 100644 --- a/modules/30_crop/rotation_apr22/declarations.gms +++ b/modules/30_crop/rotation_apr22/declarations.gms @@ -9,8 +9,6 @@ parameters i30_rotation_max_shr(t_all,rotamax30) Maximum share of a certain crop group on cropland (ha per ha) i30_rotation_min_shr(t_all,rotamin30) Minimum share of a certain crop group on cropland (ha per ha) p30_rotation_scenario_fader(t_all) Crop rotation scenario fader (1) - p30_betr_scenario_fader(t_all) Bioenergy trees scenario fader (1) - p30_betr_min_shr(t,j) Minimum share of bioenergy trees on cropland (1) ; positive variables @@ -24,7 +22,6 @@ equations q30_rotation_max(j,rotamax30) Local maximum rotational constraints (mio. ha) q30_rotation_min(j,rotamin30) Local minimum rotational constraints (mio. ha) q30_rotation_max_irrig(j,rotamax30) Local maximum rotational constraints (mio. ha) - q30_betr_shr(j) Bioenergy trees minimum share (mio. ha) q30_carbon(j,ag_pools) Croplarea above ground carbon content calculation (mio. tC) q30_bv_ann(j,potnatveg) Biodiversity value of annual cropland (mio. ha) q30_bv_per(j,potnatveg) Biodiversity value of perennial cropland (mio. ha) @@ -39,7 +36,6 @@ parameters oq30_rotation_max(t,j,rotamax30,type) Local maximum rotational constraints (mio. ha) oq30_rotation_min(t,j,rotamin30,type) Local minimum rotational constraints (mio. ha) oq30_rotation_max_irrig(t,j,rotamax30,type) Local maximum rotational constraints (mio. ha) - oq30_betr_shr(t,j,type) Bioenergy trees minimum share (mio. ha) oq30_carbon(t,j,ag_pools,type) Croplarea above ground carbon content calculation (mio. tC) oq30_bv_ann(t,j,potnatveg,type) Biodiversity value of annual cropland (mio. ha) oq30_bv_per(t,j,potnatveg,type) Biodiversity value of perennial cropland (mio. ha) diff --git a/modules/30_crop/rotation_apr22/equations.gms b/modules/30_crop/rotation_apr22/equations.gms index 6f0eda73d1..3cd5ee574c 100644 --- a/modules/30_crop/rotation_apr22/equations.gms +++ b/modules/30_crop/rotation_apr22/equations.gms @@ -38,13 +38,6 @@ vm_AEI(j2) * sum(ct,i30_rotation_max_shr(ct,rotamax_red30)); -*' Bioenergy tree minimum share on cropland - -q30_betr_shr(j2) .. - sum(w, vm_area(j2,"betr",w)) =g= - sum(ct, p30_betr_min_shr(ct,j2)) * vm_land(j2,"crop"); - - *' The carbon stocks of the above ground carbon pools are calculated based on croparea and related carbon density. q30_carbon(j2,ag_pools) .. diff --git a/modules/30_crop/rotation_apr22/input.gms b/modules/30_crop/rotation_apr22/input.gms index 8d0f252920..97dfc19ca4 100644 --- a/modules/30_crop/rotation_apr22/input.gms +++ b/modules/30_crop/rotation_apr22/input.gms @@ -15,7 +15,8 @@ $setglobal c30_rotation_constraints on *options: on, off $setglobal c30_rotation_scenario default -*options: min,default,good,good_20div,setaside,legumes,agroforestry,sixfoldrotation,agroecology +*options: min,default,good,good_20div,setaside,legumes,betr0,betr10,betr20,betr25,betr30, +* betr40,betr50,sixfoldrotation,agroecology $setglobal c30_rotation_scenario_speed by2050 * options: none, by2030, by2020 @@ -23,9 +24,6 @@ $setglobal c30_rotation_scenario_speed by2050 scalars s30_rotation_scenario_start Rotation scenario start year / 2020 / s30_rotation_scenario_target Rotation scenario target year / 2050 / - s30_betr_min_shr Minimum share of bioenergy trees on cropland (1) / 0 / - s30_betr_scenario_start Bioenergy trees scenario start year / 2020 / - s30_betr_scenario_target Bioenergy trees scenario target year / 2050 / ; diff --git a/modules/30_crop/rotation_apr22/postsolve.gms b/modules/30_crop/rotation_apr22/postsolve.gms index 66c916304c..18031392c2 100644 --- a/modules/30_crop/rotation_apr22/postsolve.gms +++ b/modules/30_crop/rotation_apr22/postsolve.gms @@ -14,7 +14,6 @@ oq30_rotation_max(t,j,rotamax30,"marginal") = q30_rotation_max.m(j,rotamax30); oq30_rotation_min(t,j,rotamin30,"marginal") = q30_rotation_min.m(j,rotamin30); oq30_rotation_max_irrig(t,j,rotamax30,"marginal") = q30_rotation_max_irrig.m(j,rotamax30); - oq30_betr_shr(t,j,"marginal") = q30_betr_shr.m(j); oq30_carbon(t,j,ag_pools,"marginal") = q30_carbon.m(j,ag_pools); oq30_bv_ann(t,j,potnatveg,"marginal") = q30_bv_ann.m(j,potnatveg); oq30_bv_per(t,j,potnatveg,"marginal") = q30_bv_per.m(j,potnatveg); @@ -25,7 +24,6 @@ oq30_rotation_max(t,j,rotamax30,"level") = q30_rotation_max.l(j,rotamax30); oq30_rotation_min(t,j,rotamin30,"level") = q30_rotation_min.l(j,rotamin30); oq30_rotation_max_irrig(t,j,rotamax30,"level") = q30_rotation_max_irrig.l(j,rotamax30); - oq30_betr_shr(t,j,"level") = q30_betr_shr.l(j); oq30_carbon(t,j,ag_pools,"level") = q30_carbon.l(j,ag_pools); oq30_bv_ann(t,j,potnatveg,"level") = q30_bv_ann.l(j,potnatveg); oq30_bv_per(t,j,potnatveg,"level") = q30_bv_per.l(j,potnatveg); @@ -36,7 +34,6 @@ oq30_rotation_max(t,j,rotamax30,"upper") = q30_rotation_max.up(j,rotamax30); oq30_rotation_min(t,j,rotamin30,"upper") = q30_rotation_min.up(j,rotamin30); oq30_rotation_max_irrig(t,j,rotamax30,"upper") = q30_rotation_max_irrig.up(j,rotamax30); - oq30_betr_shr(t,j,"upper") = q30_betr_shr.up(j); oq30_carbon(t,j,ag_pools,"upper") = q30_carbon.up(j,ag_pools); oq30_bv_ann(t,j,potnatveg,"upper") = q30_bv_ann.up(j,potnatveg); oq30_bv_per(t,j,potnatveg,"upper") = q30_bv_per.up(j,potnatveg); @@ -47,7 +44,6 @@ oq30_rotation_max(t,j,rotamax30,"lower") = q30_rotation_max.lo(j,rotamax30); oq30_rotation_min(t,j,rotamin30,"lower") = q30_rotation_min.lo(j,rotamin30); oq30_rotation_max_irrig(t,j,rotamax30,"lower") = q30_rotation_max_irrig.lo(j,rotamax30); - oq30_betr_shr(t,j,"lower") = q30_betr_shr.lo(j); oq30_carbon(t,j,ag_pools,"lower") = q30_carbon.lo(j,ag_pools); oq30_bv_ann(t,j,potnatveg,"lower") = q30_bv_ann.lo(j,potnatveg); oq30_bv_per(t,j,potnatveg,"lower") = q30_bv_per.lo(j,potnatveg); diff --git a/modules/30_crop/rotation_apr22/preloop.gms b/modules/30_crop/rotation_apr22/preloop.gms index 7c4e100664..df6a30816f 100644 --- a/modules/30_crop/rotation_apr22/preloop.gms +++ b/modules/30_crop/rotation_apr22/preloop.gms @@ -9,7 +9,6 @@ ** Trajectory for cropland scenarios * sigmoidal interpolation between start year and target year m_sigmoid_time_interpol(p30_rotation_scenario_fader,s30_rotation_scenario_start,s30_rotation_scenario_target,0,1); -m_sigmoid_time_interpol(p30_betr_scenario_fader,s30_betr_scenario_start,s30_betr_scenario_target,0,1); ** create crop rotation scenario i30_rotation_max_shr(t_all,rotamax30)= diff --git a/modules/30_crop/rotation_apr22/presolve.gms b/modules/30_crop/rotation_apr22/presolve.gms index 97a83f26a8..1b847385d9 100644 --- a/modules/30_crop/rotation_apr22/presolve.gms +++ b/modules/30_crop/rotation_apr22/presolve.gms @@ -24,5 +24,3 @@ rotamax_red30(rotamax30) = yes$(i30_rotation_max_shr(t,rotamax30) < 1); rotamin_red30(rotamin30) = yes$(i30_rotation_min_shr(t,rotamin30) > 0); vm_rotation_penalty.fx(i)=0; - -p30_betr_min_shr(t,j) = p30_betr_scenario_fader(t) * s30_betr_min_shr; diff --git a/modules/30_crop/rotation_apr22/sets.gms b/modules/30_crop/rotation_apr22/sets.gms index e23397fecc..b8264aa0fd 100644 --- a/modules/30_crop/rotation_apr22/sets.gms +++ b/modules/30_crop/rotation_apr22/sets.gms @@ -7,7 +7,9 @@ sets rotascen30 rotation constraint scenarios - /min,default,good,good_20div,setaside,legumes,agroforestry,sixfoldrotation,agroecology/ + /min,default,good,good_20div,setaside,legumes, + betr0,betr10,betr20,betr25,betr30,betr40,betr50, + sixfoldrotation,agroecology/ rotamax30 Maximum crop rotation categories / all_max, cereals_excl_rice_max, stalk_max, @@ -22,7 +24,7 @@ sets rotamin30 Minimum crop rotation categories / all_min, stalk_min, biomass_min, - legume_min, others_min + legume_min, others_min, betr_min / rotamax_red30(rotamax30) Maximum crop rotation reduced set @@ -81,9 +83,9 @@ sets biomass_min . (sugr_cane, oilpalm, begr, betr) legume_min . (soybean, groundnut, puls_pro, foddr) others_min . (others) + betr_min . (betr) / - kbe30(kcr) bio energy activities / betr, begr / From 9b4b009d9a4c9f5f7bcb6397e0dcc0a253d8f3c6 Mon Sep 17 00:00:00 2001 From: florianh Date: Sat, 20 Apr 2024 20:01:06 +0200 Subject: [PATCH 013/133] partial commit to save work --- modules/29_cropland/module.gms | 1 + .../penalty_apr24/declarations.gms | 96 ++++++++++++++ .../29_cropland/penalty_apr24/equations.gms | 124 ++++++++++++++++++ modules/29_cropland/penalty_apr24/input.gms | 96 ++++++++++++++ .../29_cropland/penalty_apr24/postsolve.gms | 108 +++++++++++++++ modules/29_cropland/penalty_apr24/preloop.gms | 58 ++++++++ .../29_cropland/penalty_apr24/presolve.gms | 66 ++++++++++ .../29_cropland/penalty_apr24/realization.gms | 20 +++ modules/29_cropland/penalty_apr24/sets.gms | 22 ++++ .../rulebased_apr24/declarations.gms | 17 ++- .../29_cropland/rulebased_apr24/equations.gms | 74 ++++++----- modules/29_cropland/rulebased_apr24/input.gms | 8 +- .../29_cropland/rulebased_apr24/preloop.gms | 19 +-- .../29_cropland/rulebased_apr24/presolve.gms | 18 +-- modules/30_crop/penalty_apr22/input.gms | 2 +- 15 files changed, 660 insertions(+), 69 deletions(-) create mode 100644 modules/29_cropland/penalty_apr24/declarations.gms create mode 100644 modules/29_cropland/penalty_apr24/equations.gms create mode 100644 modules/29_cropland/penalty_apr24/input.gms create mode 100644 modules/29_cropland/penalty_apr24/postsolve.gms create mode 100644 modules/29_cropland/penalty_apr24/preloop.gms create mode 100644 modules/29_cropland/penalty_apr24/presolve.gms create mode 100644 modules/29_cropland/penalty_apr24/realization.gms create mode 100644 modules/29_cropland/penalty_apr24/sets.gms diff --git a/modules/29_cropland/module.gms b/modules/29_cropland/module.gms index 7f406b8b7c..dc8cb77e50 100644 --- a/modules/29_cropland/module.gms +++ b/modules/29_cropland/module.gms @@ -14,5 +14,6 @@ *' @authors Florian Humpenöder *###################### R SECTION START (MODULETYPES) ########################## +$Ifi "%cropland%" == "penalty_apr24" $include "./modules/29_cropland/penalty_apr24/realization.gms" $Ifi "%cropland%" == "rulebased_apr24" $include "./modules/29_cropland/rulebased_apr24/realization.gms" *###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/29_cropland/penalty_apr24/declarations.gms b/modules/29_cropland/penalty_apr24/declarations.gms new file mode 100644 index 0000000000..86f165a043 --- /dev/null +++ b/modules/29_cropland/penalty_apr24/declarations.gms @@ -0,0 +1,96 @@ +*** | (C) 2008-2024 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 + s29_shift number of 5-year age-classes corresponding to current time step length (1) +; + + +parameters + p29_avl_cropland(t,j) Total available land for crop cultivation (mio. ha) + p29_country_snv_weight(i) SNV policy country weight per region (1) + p29_snv_shr(t,j) Share of semi-natural vegetation in cropland areas (1) + i29_snv_relocation_target(j) Overall cropland area that requires relocation due to SNV policy (mio. ha) + p29_snv_relocation(t,j) Cropland area that is actually relocated during time step (mio. ha) + p29_max_snv_relocation(t,j) Maximum cropland relocation during time step (mio. ha) + p29_country_dummy(iso) Dummy parameter indicating whether country is affected by selected cropland policy (1) + i29_avl_cropland_iso(iso) Available land area for cropland at ISO level (mio. ha) + i29_snv_scenario_fader(t_all) SNV scenario fader (1) + + i29_treecover_scenario_fader(t_all) Cropland treecover scenario fader (1) + i29_treecover_target(t,j) Target share for treecover on total cropland (1) + i29_treecover_penalty(t_all) Penalty for violation of treecover target (USD05MER per ha) + + p29_treecover_bii_coeff(bii_class_secd,potnatveg) BII coefficient for cropland treecover (1) + p29_carbon_density_ac(t,j,ac,ag_pools) Carbon density for ac and ag_pools (tC per ha) + p29_treecover(t,j,ac) Cropland tree cover per age class (mio. ha) + pc29_treecover(j,ac) Cropland tree cover per age class in current time step (mio. ha) + + i29_fallow_scenario_fader(t_all) Fallow land scenario fader (1) + i29_fallow_target(t_all) Target share for fallow land on total cropland (1) + i29_fallow_penalty(t_all) Penalty for violation of fallow target (USD05MER per ha) +; + +positive variables + vm_fallow(j) Fallow land is temporarily fallow cropland (mio. ha) + v29_treecover(j,ac) Cropland tree cover per age class (mio. ha) + vm_cost_cropland(j) Cost for total cropland (mio. USD05MER per yr) + v29_cost_treecover_est(j) Establishment cost for cropland tree cover (mio. USD05MER per yr) + v29_cost_treecover_recur(j) Recurring cost for cropland tree cover (mio. USD05MER per yr) + v29_treecover_penalty(j) Penalty for violation of treecover target (mio. USD05MER per yr) + v29_treecover_missing(j) Missing treecover area towards target (mio. ha) + v29_fallow_penalty(j) Penalty for violation of fallow target (mio. USD05MER per yr) + v29_fallow_missing(j) Missing fallow land towards target (mio. ha) +; + +equations + q29_cropland(j) Total cropland calculation (mio. ha) + q29_avl_cropland(j) Available cropland constraint (mio. ha) + q29_carbon(j,ag_pools,stockType) Cropland above ground carbon content calculation (mio. tC) + q29_land_snv(j) Land constraint for the SNV policy in cropland areas (mio. ha) + q29_land_snv_trans(j) Land transition constraint for SNV policy in cropland areas (mio. ha) + q29_cost_cropland(j) Costs and benefits related to agroforestry (mio. USD05MER per yr) + q29_cost_treecover_est(j) Establishment cost for cropland tree cover (mio. USD05MER per yr) + q29_cost_treecover_recur(j) Recurring cost for cropland tree cover (mio. USD05MER per yr) + q29_treecover_penalty(j) Penalty for violation of treecover target (mio. USD05MER per yr) + q29_treecover_missing(j) Missing treecover area towards target (mio. ha) + q29_treecover_est(j,ac) Cropland treecover establishment (mio. ha) + q29_treecover_bv(j,potnatveg) Biodiversity value for cropland treecover (mio. ha) + q29_fallow_bv(j,potnatveg) Biodiversity value for fallow land (mio. ha) + q29_fallow_penalty(j) Penalty for violation of fallow target (mio. USD05MER per yr) + q29_fallow_missing(j) Missing fallow land towards target (mio. ha) +; + +*#################### R SECTION START (OUTPUT DECLARATIONS) #################### +parameters + ov_fallow(t,j,type) Fallow land is temporarily fallow cropland (mio. ha) + ov29_treecover(t,j,ac,type) Cropland tree cover per age class (mio. ha) + ov_cost_cropland(t,j,type) Cost for total cropland (mio. USD05MER per yr) + ov29_cost_treecover_est(t,j,type) Establishment cost for cropland tree cover (mio. USD05MER per yr) + ov29_cost_treecover_recur(t,j,type) Recurring cost for cropland tree cover (mio. USD05MER per yr) + ov29_treecover_penalty(t,j,type) Penalty for violation of treecover target (mio. USD05MER per yr) + ov29_treecover_missing(t,j,type) Missing treecover area towards target (mio. ha) + ov29_fallow_penalty(t,j,type) Penalty for violation of fallow target (mio. USD05MER per yr) + ov29_fallow_missing(t,j,type) Missing fallow land towards target (mio. ha) + oq29_cropland(t,j,type) Total cropland calculation (mio. ha) + oq29_avl_cropland(t,j,type) Available cropland constraint (mio. ha) + oq29_carbon(t,j,ag_pools,stockType,type) Cropland above ground carbon content calculation (mio. tC) + oq29_land_snv(t,j,type) Land constraint for the SNV policy in cropland areas (mio. ha) + oq29_land_snv_trans(t,j,type) Land transition constraint for SNV policy in cropland areas (mio. ha) + oq29_cost_cropland(t,j,type) Costs and benefits related to agroforestry (mio. USD05MER per yr) + oq29_cost_treecover_est(t,j,type) Establishment cost for cropland tree cover (mio. USD05MER per yr) + oq29_cost_treecover_recur(t,j,type) Recurring cost for cropland tree cover (mio. USD05MER per yr) + oq29_treecover_penalty(t,j,type) Penalty for violation of treecover target (mio. USD05MER per yr) + oq29_treecover_missing(t,j,type) Missing treecover area towards target (mio. ha) + oq29_treecover_est(t,j,ac,type) Cropland treecover establishment (mio. ha) + oq29_treecover_bv(t,j,potnatveg,type) Biodiversity value for cropland treecover (mio. ha) + oq29_fallow_bv(t,j,potnatveg,type) Biodiversity value for fallow land (mio. ha) + oq29_fallow_penalty(t,j,type) Penalty for violation of fallow target (mio. USD05MER per yr) + oq29_fallow_missing(t,j,type) Missing fallow land towards target (mio. ha) +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### + diff --git a/modules/29_cropland/penalty_apr24/equations.gms b/modules/29_cropland/penalty_apr24/equations.gms new file mode 100644 index 0000000000..8bfe211a1f --- /dev/null +++ b/modules/29_cropland/penalty_apr24/equations.gms @@ -0,0 +1,124 @@ +*** | (C) 2008-2024 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 +*' Total cropland is calculated as the sum of croparea, fallow land and tree cover area. + + q29_cropland(j2) .. + vm_land(j2,"crop") =e= sum((kcr,w), vm_area(j2,kcr,w)) + vm_fallow(j2) + sum(ac, v29_treecover(j2,ac)); + +*' We assume that crop production can only take place on suitable cropland area. +*' We use a suitability index (SI) map from @zabel_global_2014 to exclude areas +*' from cropland production that have a low suitability, e.g. due to steep slopes, +*' to estimate the available cropland area. The cultivated area therefore has +*' to be smaller than the available cropland area. Moreover, the available cropland +*' can be reduced by constraining the cropland area in favour of other land types, +*' in order to increase compositional heterogeneity of land types at the cell level. + + q29_avl_cropland(j2) .. + vm_land(j2,"crop") =l= sum(ct, p29_avl_cropland(ct,j2)); + + +*' Total costs for the cropland module: + +q29_cost_cropland(j2) .. + vm_cost_cropland(j2) =e= + v29_cost_treecover_est(j2) + v29_cost_treecover_recur(j2) + + v29_fallow_penalty(j2) + v29_treecover_penalty(j2); + + +*' The carbon stocks of total cropland are calculated as the sum of carbon stocks in +*' cropland, fallow land and tree cover area. + + q29_carbon(j2,ag_pools,stockType) .. + vm_carbon_stock(j2,"crop",ag_pools,stockType) =e= + vm_carbon_stock_croparea(j2,ag_pools) + + vm_fallow(j2) * sum(ct, fm_carbon_density(ct,j2,"crop",ag_pools)) + + m_carbon_stock_ac(v29_treecover,p29_carbon_density_ac,"ac","ac_sub"); + + +*' The semi-natural land constraint in cropland areas for sustaining critical regulating NCP +*' for agricultural production is added on top of land conserved for other reasons +*' (e.g. conservation of intact ecosystems or protection of biodiversity hotspots). + + q29_land_snv(j2) .. + sum(land_snv, vm_land(j2,land_snv)) + =g= + sum(ct, p29_snv_shr(ct,j2)) * vm_land(j2,"crop") + + sum((ct,land_snv,consv_type), pm_land_conservation(ct,j2,land_snv,consv_type)); + +*' The semi-natural vegetation constraint for cropland areas has been suggested at the per square +*' kilometer scale. The amount of cropland requiring relocation has therefore been derived from +*' exogeneous high-resolution land cover information from the Copernicus Global Land Service +*' (@buchhorn_copernicus_2020). + + q29_land_snv_trans(j2) .. + sum(land_snv, vm_lu_transitions(j2,"crop",land_snv)) =g= sum(ct, p29_snv_relocation(ct,j2)); + + +*' A penalty is applied for the violation of fallow land rules. + +q29_fallow_penalty(j2) .. + v29_fallow_penalty(j2) + =g= + v29_fallow_missing(j2) * sum(ct, i29_fallow_penalty(ct)); + +*' The penalty applies to the missing fallow land, i.e. where fallow land +*' is lower than a certain fraction of total cropland. + + q29_fallow_missing(j2) .. + v29_fallow_missing(j2) + =g= + vm_land(j2,"crop") * sum(ct, i29_fallow_target(ct)) - vm_fallow(j2); + +*' Fallow land biodiversity value: + +q29_fallow_bv(j2,potnatveg) .. + vm_bv(j2,"crop_fallow",potnatveg) =e= + vm_fallow(j2) * fm_bii_coeff("crop_per",potnatveg) * fm_luh2_side_layers(j2,potnatveg); + + +*' A penalty is applied for the violation of treecover rules. + +q29_treecover_penalty(j2) .. + v29_treecover_penalty(j2) + =g= + v29_treecover_missing(j2) * sum(ct, i29_treecover_penalty(ct)); + +*' The penalty applies to the missing treecover area, i.e. where treecover area +*' is lower than a certain fraction of total cropland. + + q29_treecover_missing(j2) .. + v29_treecover_missing(j2) + =g= + vm_land(j2,"crop") * sum(ct, i29_treecover_target(ct,j2)) - sum(ac, v29_treecover(j2,ac)); + + +*' Cropland tree cover biodiversity value: + +q29_treecover_bv(j2,potnatveg) .. + vm_bv(j2,"crop_tree",potnatveg) =e= + sum(bii_class_secd, sum(ac_to_bii_class_secd(ac,bii_class_secd), v29_treecover(j2,ac)) * + p29_treecover_bii_coeff(bii_class_secd,potnatveg)) * fm_luh2_side_layers(j2,potnatveg); + +*' Cropland tree cover annuity cost + +q29_cost_treecover_est(j2) .. + v29_cost_treecover_est(j2) =e= + sum(ac_est, v29_treecover(j2,ac_est)) * s29_cost_treecover_est * + sum((cell(i2,j2),ct),pm_interest(ct,i2)/(1+pm_interest(ct,i2))); + +*' Cropland tree cover recurring cost + +q29_cost_treecover_recur(j2) .. + v29_cost_treecover_recur(j2) =e= + sum(ac_sub, v29_treecover(j2,ac_sub)) * s29_cost_treecover_recur; + +*' Cropland tree cover establishment rules: + +q29_treecover_est(j2,ac_est) .. + v29_treecover(j2,ac_est) =e= sum(ac_est2, v29_treecover(j2,ac_est2))/card(ac_est2); diff --git a/modules/29_cropland/penalty_apr24/input.gms b/modules/29_cropland/penalty_apr24/input.gms new file mode 100644 index 0000000000..ad8d2a60e8 --- /dev/null +++ b/modules/29_cropland/penalty_apr24/input.gms @@ -0,0 +1,96 @@ +*** | (C) 2008-2024 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 + +$setglobal c29_marginal_land q33_marginal +* options: all_marginal, q33_marginal, no_marginal + +scalars + s29_snv_shr Share of available cropland that is witheld for other land cover types (1) / 0 / + s29_snv_shr_noselect Share of available cropland that is witheld for other land cover types (1) / 0 / + s29_snv_scenario_start SNV scenario start year / 2020 / + s29_snv_scenario_target SNV scenario target year / 2029 / + s29_snv_relocation_data_x1 First reference value in SNV target cropland data (1) / 0.2 / + s29_snv_relocation_data_x2 Second reference value in SNV target cropland data (1) / 0.5 / + s29_cost_treecover_est Tree cover establishment cost (USD05MER per ha) / 2000 / + s29_cost_treecover_recur Tree cover recurring cost (USD05MER per ha) / 500 / + s29_treecover_plantation Growth curve switch for tree cover on cropland 0=natveg 1=plantations (1) / 0 / + s29_treecover_bii_coeff BII coefficent to be used for tree cover on cropland 0=secondary vegetation 1=timber plantations (1) / 0 / + s29_treecover_decrease Cropland treecover can decrease (1) or not (0) / 0 / + s29_treecover_scenario_start Cropland treecover scenario start year / 2020 / + s29_treecover_scenario_target Cropland treecover scenario target year / 2050 / + s29_treecover_target Target share of treecover on total cropland (1) / 0.3 / + s29_treecover_penalty Penalty for violation of treecover target (USD05MER per ha) / 500 / + s29_fallow_scenario_start Fallow land scenario start year / 2020 / + s29_fallow_scenario_target Fallow land scenario target year / 2050 / + s29_fallow_target Target share of fallow land on total cropland (1) / 0.3 / + s29_fallow_penalty Penalty for violation of fallow target (USD05MER per ha) / 500 / +; + + +* Set-switch for countries affected by regional SNV policy +* Default: all iso countries selected +sets + policy_countries29(iso) countries to be affected by SNV policy / ABW,AFG,AGO,AIA,ALA,ALB,AND,ARE,ARG,ARM, + ASM,ATA,ATF,ATG,AUS,AUT,AZE,BDI,BEL,BEN, + BES,BFA,BGD,BGR,BHR,BHS,BIH,BLM,BLR,BLZ, + BMU,BOL,BRA,BRB,BRN,BTN,BVT,BWA,CAF,CAN, + CCK,CHN,CHE,CHL,CIV,CMR,COD,COG,COK,COL, + COM,CPV,CRI,CUB,CUW,CXR,CYM,CYP,CZE,DEU, + DJI,DMA,DNK,DOM,DZA,ECU,EGY,ERI,ESH,ESP, + EST,ETH,FIN,FJI,FLK,FRA,FRO,FSM,GAB,GBR, + GEO,GGY,GHA,GIB,GIN,GLP,GMB,GNB,GNQ,GRC, + GRD,GRL,GTM,GUF,GUM,GUY,HKG,HMD,HND,HRV, + HTI,HUN,IDN,IMN,IND,IOT,IRL,IRN,IRQ,ISL, + ISR,ITA,JAM,JEY,JOR,JPN,KAZ,KEN,KGZ,KHM, + KIR,KNA,KOR,KWT,LAO,LBN,LBR,LBY,LCA,LIE, + LKA,LSO,LTU,LUX,LVA,MAC,MAF,MAR,MCO,MDA, + MDG,MDV,MEX,MHL,MKD,MLI,MLT,MMR,MNE,MNG, + MNP,MOZ,MRT,MSR,MTQ,MUS,MWI,MYS,MYT,NAM, + NCL,NER,NFK,NGA,NIC,NIU,NLD,NOR,NPL,NRU, + NZL,OMN,PAK,PAN,PCN,PER,PHL,PLW,PNG,POL, + PRI,PRK,PRT,PRY,PSE,PYF,QAT,REU,ROU,RUS, + RWA,SAU,SDN,SEN,SGP,SGS,SHN,SJM,SLB,SLE, + SLV,SMR,SOM,SPM,SRB,SSD,STP,SUR,SVK,SVN, + SWE,SWZ,SXM,SYC,SYR,TCA,TCD,TGO,THA,TJK, + TKL,TKM,TLS,TON,TTO,TUN,TUR,TUV,TWN,TZA, + UGA,UKR,UMI,URY,USA,UZB,VAT,VCT,VEN,VGB, + VIR,VNM,VUT,WLF,WSM,YEM,ZAF,ZMB,ZWE / + +land_snv(land) land types allowed in the SNV policy / secdforest, forestry, past, other / +; + +********* AVAILABLE CROPLAND ******************************************* + +table f29_avl_cropland(j,marginal_land29) Available land area for cropland (mio. ha) +$ondelim +$include "./modules/29_cropland/input/avl_cropland.cs3" +$offdelim +; + +table f29_avl_cropland_iso(iso,marginal_land29) Available land area for cropland at ISO level (mio. ha) +$ondelim +$include "./modules/29_cropland/input/avl_cropland_iso.cs3" +$offdelim +; + +********* SNV TARGET CROPLAND ******************************************* + +table f29_snv_target_cropland(j,relocation_target29) Cropland in 2019 requiring relocation due to SNV policy (mio. ha) +$ondelim +$include "./modules/29_cropland/input/SNVTargetCropland.cs3" +$offdelim +; + +********* Cropland tree cover ******************************************* + +parameter f29_treecover(j) Tree cover on cropland in 2019 (mio. ha) +/ +$ondelim +$include "./modules/29_cropland/input/CroplandTreecover.cs2" +$offdelim +/ +; diff --git a/modules/29_cropland/penalty_apr24/postsolve.gms b/modules/29_cropland/penalty_apr24/postsolve.gms new file mode 100644 index 0000000000..32b9181e7d --- /dev/null +++ b/modules/29_cropland/penalty_apr24/postsolve.gms @@ -0,0 +1,108 @@ +*** | (C) 2008-2024 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 + +pc29_treecover(j,ac) = v29_treecover.l(j,ac); + +*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + ov_fallow(t,j,"marginal") = vm_fallow.m(j); + ov29_treecover(t,j,ac,"marginal") = v29_treecover.m(j,ac); + ov_cost_cropland(t,j,"marginal") = vm_cost_cropland.m(j); + ov29_cost_treecover_est(t,j,"marginal") = v29_cost_treecover_est.m(j); + ov29_cost_treecover_recur(t,j,"marginal") = v29_cost_treecover_recur.m(j); + ov29_treecover_penalty(t,j,"marginal") = v29_treecover_penalty.m(j); + ov29_treecover_missing(t,j,"marginal") = v29_treecover_missing.m(j); + ov29_fallow_penalty(t,j,"marginal") = v29_fallow_penalty.m(j); + ov29_fallow_missing(t,j,"marginal") = v29_fallow_missing.m(j); + oq29_cropland(t,j,"marginal") = q29_cropland.m(j); + oq29_avl_cropland(t,j,"marginal") = q29_avl_cropland.m(j); + oq29_carbon(t,j,ag_pools,stockType,"marginal") = q29_carbon.m(j,ag_pools,stockType); + oq29_land_snv(t,j,"marginal") = q29_land_snv.m(j); + oq29_land_snv_trans(t,j,"marginal") = q29_land_snv_trans.m(j); + oq29_cost_cropland(t,j,"marginal") = q29_cost_cropland.m(j); + oq29_cost_treecover_est(t,j,"marginal") = q29_cost_treecover_est.m(j); + oq29_cost_treecover_recur(t,j,"marginal") = q29_cost_treecover_recur.m(j); + oq29_treecover_penalty(t,j,"marginal") = q29_treecover_penalty.m(j); + oq29_treecover_missing(t,j,"marginal") = q29_treecover_missing.m(j); + oq29_treecover_est(t,j,ac,"marginal") = q29_treecover_est.m(j,ac); + oq29_treecover_bv(t,j,potnatveg,"marginal") = q29_treecover_bv.m(j,potnatveg); + oq29_fallow_bv(t,j,potnatveg,"marginal") = q29_fallow_bv.m(j,potnatveg); + oq29_fallow_penalty(t,j,"marginal") = q29_fallow_penalty.m(j); + oq29_fallow_missing(t,j,"marginal") = q29_fallow_missing.m(j); + ov_fallow(t,j,"level") = vm_fallow.l(j); + ov29_treecover(t,j,ac,"level") = v29_treecover.l(j,ac); + ov_cost_cropland(t,j,"level") = vm_cost_cropland.l(j); + ov29_cost_treecover_est(t,j,"level") = v29_cost_treecover_est.l(j); + ov29_cost_treecover_recur(t,j,"level") = v29_cost_treecover_recur.l(j); + ov29_treecover_penalty(t,j,"level") = v29_treecover_penalty.l(j); + ov29_treecover_missing(t,j,"level") = v29_treecover_missing.l(j); + ov29_fallow_penalty(t,j,"level") = v29_fallow_penalty.l(j); + ov29_fallow_missing(t,j,"level") = v29_fallow_missing.l(j); + oq29_cropland(t,j,"level") = q29_cropland.l(j); + oq29_avl_cropland(t,j,"level") = q29_avl_cropland.l(j); + oq29_carbon(t,j,ag_pools,stockType,"level") = q29_carbon.l(j,ag_pools,stockType); + oq29_land_snv(t,j,"level") = q29_land_snv.l(j); + oq29_land_snv_trans(t,j,"level") = q29_land_snv_trans.l(j); + oq29_cost_cropland(t,j,"level") = q29_cost_cropland.l(j); + oq29_cost_treecover_est(t,j,"level") = q29_cost_treecover_est.l(j); + oq29_cost_treecover_recur(t,j,"level") = q29_cost_treecover_recur.l(j); + oq29_treecover_penalty(t,j,"level") = q29_treecover_penalty.l(j); + oq29_treecover_missing(t,j,"level") = q29_treecover_missing.l(j); + oq29_treecover_est(t,j,ac,"level") = q29_treecover_est.l(j,ac); + oq29_treecover_bv(t,j,potnatveg,"level") = q29_treecover_bv.l(j,potnatveg); + oq29_fallow_bv(t,j,potnatveg,"level") = q29_fallow_bv.l(j,potnatveg); + oq29_fallow_penalty(t,j,"level") = q29_fallow_penalty.l(j); + oq29_fallow_missing(t,j,"level") = q29_fallow_missing.l(j); + ov_fallow(t,j,"upper") = vm_fallow.up(j); + ov29_treecover(t,j,ac,"upper") = v29_treecover.up(j,ac); + ov_cost_cropland(t,j,"upper") = vm_cost_cropland.up(j); + ov29_cost_treecover_est(t,j,"upper") = v29_cost_treecover_est.up(j); + ov29_cost_treecover_recur(t,j,"upper") = v29_cost_treecover_recur.up(j); + ov29_treecover_penalty(t,j,"upper") = v29_treecover_penalty.up(j); + ov29_treecover_missing(t,j,"upper") = v29_treecover_missing.up(j); + ov29_fallow_penalty(t,j,"upper") = v29_fallow_penalty.up(j); + ov29_fallow_missing(t,j,"upper") = v29_fallow_missing.up(j); + oq29_cropland(t,j,"upper") = q29_cropland.up(j); + oq29_avl_cropland(t,j,"upper") = q29_avl_cropland.up(j); + oq29_carbon(t,j,ag_pools,stockType,"upper") = q29_carbon.up(j,ag_pools,stockType); + oq29_land_snv(t,j,"upper") = q29_land_snv.up(j); + oq29_land_snv_trans(t,j,"upper") = q29_land_snv_trans.up(j); + oq29_cost_cropland(t,j,"upper") = q29_cost_cropland.up(j); + oq29_cost_treecover_est(t,j,"upper") = q29_cost_treecover_est.up(j); + oq29_cost_treecover_recur(t,j,"upper") = q29_cost_treecover_recur.up(j); + oq29_treecover_penalty(t,j,"upper") = q29_treecover_penalty.up(j); + oq29_treecover_missing(t,j,"upper") = q29_treecover_missing.up(j); + oq29_treecover_est(t,j,ac,"upper") = q29_treecover_est.up(j,ac); + oq29_treecover_bv(t,j,potnatveg,"upper") = q29_treecover_bv.up(j,potnatveg); + oq29_fallow_bv(t,j,potnatveg,"upper") = q29_fallow_bv.up(j,potnatveg); + oq29_fallow_penalty(t,j,"upper") = q29_fallow_penalty.up(j); + oq29_fallow_missing(t,j,"upper") = q29_fallow_missing.up(j); + ov_fallow(t,j,"lower") = vm_fallow.lo(j); + ov29_treecover(t,j,ac,"lower") = v29_treecover.lo(j,ac); + ov_cost_cropland(t,j,"lower") = vm_cost_cropland.lo(j); + ov29_cost_treecover_est(t,j,"lower") = v29_cost_treecover_est.lo(j); + ov29_cost_treecover_recur(t,j,"lower") = v29_cost_treecover_recur.lo(j); + ov29_treecover_penalty(t,j,"lower") = v29_treecover_penalty.lo(j); + ov29_treecover_missing(t,j,"lower") = v29_treecover_missing.lo(j); + ov29_fallow_penalty(t,j,"lower") = v29_fallow_penalty.lo(j); + ov29_fallow_missing(t,j,"lower") = v29_fallow_missing.lo(j); + oq29_cropland(t,j,"lower") = q29_cropland.lo(j); + oq29_avl_cropland(t,j,"lower") = q29_avl_cropland.lo(j); + oq29_carbon(t,j,ag_pools,stockType,"lower") = q29_carbon.lo(j,ag_pools,stockType); + oq29_land_snv(t,j,"lower") = q29_land_snv.lo(j); + oq29_land_snv_trans(t,j,"lower") = q29_land_snv_trans.lo(j); + oq29_cost_cropland(t,j,"lower") = q29_cost_cropland.lo(j); + oq29_cost_treecover_est(t,j,"lower") = q29_cost_treecover_est.lo(j); + oq29_cost_treecover_recur(t,j,"lower") = q29_cost_treecover_recur.lo(j); + oq29_treecover_penalty(t,j,"lower") = q29_treecover_penalty.lo(j); + oq29_treecover_missing(t,j,"lower") = q29_treecover_missing.lo(j); + oq29_treecover_est(t,j,ac,"lower") = q29_treecover_est.lo(j,ac); + oq29_treecover_bv(t,j,potnatveg,"lower") = q29_treecover_bv.lo(j,potnatveg); + oq29_fallow_bv(t,j,potnatveg,"lower") = q29_fallow_bv.lo(j,potnatveg); + oq29_fallow_penalty(t,j,"lower") = q29_fallow_penalty.lo(j); + oq29_fallow_missing(t,j,"lower") = q29_fallow_missing.lo(j); +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### + diff --git a/modules/29_cropland/penalty_apr24/preloop.gms b/modules/29_cropland/penalty_apr24/preloop.gms new file mode 100644 index 0000000000..a7e39c8c8e --- /dev/null +++ b/modules/29_cropland/penalty_apr24/preloop.gms @@ -0,0 +1,58 @@ +*** | (C) 2008-2024 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 + +** Trajectory for cropland scenarios +* sigmoidal interpolation between start year and target year +m_sigmoid_time_interpol(i29_snv_scenario_fader,s29_snv_scenario_start,s29_snv_scenario_target,0,1); +m_sigmoid_time_interpol(i29_treecover_scenario_fader,s29_treecover_scenario_start,s29_treecover_scenario_target,0,1); +m_sigmoid_time_interpol(i29_fallow_scenario_fader,s29_fallow_scenario_start,s29_fallow_scenario_target,0,1); + +* linear interpolation to estimate the cropland that +* requires relocation due to SNV policy +if (s29_snv_shr = 0, + i29_snv_relocation_target(j) = 0; +elseif s29_snv_shr <= s29_snv_relocation_data_x1, + m_linear_cell_data_interpol(i29_snv_relocation_target, s29_snv_shr,0,s29_snv_relocation_data_x1,0, f29_snv_target_cropland(j, "SNV20TargetCropland")); +elseif s29_snv_shr > s29_snv_relocation_data_x1, + m_linear_cell_data_interpol(i29_snv_relocation_target, s29_snv_shr,s29_snv_relocation_data_x1, s29_snv_relocation_data_x2,f29_snv_target_cropland(j, "SNV20TargetCropland"), f29_snv_target_cropland(j, "SNV50TargetCropland")); +); + + +* Initial tree cover on cropland is assumed to be equally distributed among all age-classes +pc29_treecover(j,ac) = 0; +pc29_treecover(j,ac)$(pm_land_hist("y2015",j,"crop") > 1e-10) = + (f29_treecover(j) / pm_land_hist("y2015",j,"crop") * pm_land_hist("y1995",j,"crop")) / card(ac); + + +*' Switch for tree cover on cropland: +*' 0 = Use natveg growth curve towards LPJmL natural vegetation +*' 1 = Use plantation growth curve (faster than natveg) towards LPJmL natural vegetation +if(s29_treecover_plantation = 0, + p29_carbon_density_ac(t,j,ac,ag_pools) = pm_carbon_density_ac(t,j,ac,ag_pools); +elseif s29_treecover_plantation = 1, + p29_carbon_density_ac(t,j,ac,ag_pools) = pm_carbon_density_ac_forestry(t,j,ac,ag_pools); +); + +** set bii coefficients +p29_treecover_bii_coeff(bii_class_secd,potnatveg) = 0; +if(s29_treecover_bii_coeff = 0, + p29_treecover_bii_coeff(bii_class_secd,potnatveg) = fm_bii_coeff(bii_class_secd,potnatveg) +elseif s29_treecover_bii_coeff = 1, + p29_treecover_bii_coeff(bii_class_secd,potnatveg) = fm_bii_coeff("timber",potnatveg) +); + + +****** Regional share of semi-natural vegetation (SNV) in cropland areas for selective countries: +* Country switch to determine countries for which a SNV policy shall be applied. +* In the default case, the SNV policy affects all countries when activated. +p29_country_dummy(iso) = 0; +p29_country_dummy(policy_countries29) = 1; +* Because MAgPIE is not run at country-level, but at region level, a region +* share is calculated that translates the countries' influence to regional level. +* Countries are weighted by available cropland area. +i29_avl_cropland_iso(iso) = f29_avl_cropland_iso(iso,"%c29_marginal_land%"); +p29_country_snv_weight(i) = sum(i_to_iso(i,iso), p29_country_dummy(iso) * i29_avl_cropland_iso(iso)) / sum(i_to_iso(i,iso), i29_avl_cropland_iso(iso)); diff --git a/modules/29_cropland/penalty_apr24/presolve.gms b/modules/29_cropland/penalty_apr24/presolve.gms new file mode 100644 index 0000000000..4fb606c500 --- /dev/null +++ b/modules/29_cropland/penalty_apr24/presolve.gms @@ -0,0 +1,66 @@ +*** | (C) 2008-2023 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 + +*' @code +*' Minimum semi-natural vegetation (SNV) share is fading in after 2020 +p29_snv_shr(t,j) = i29_snv_scenario_fader(t) * + (s29_snv_shr * sum(cell(i,j), p29_country_snv_weight(i)) + + s29_snv_shr_noselect * sum(cell(i,j), 1-p29_country_snv_weight(i))); + +*' Cropland relocation in response to SNV policy is based on exogeneous land +*' cover information from the Copernicus Global Land Service (@buchhorn_copernicus_2020). +*' The rate of the policy implementation is derived based +*' on the difference of scenario fader values in consecutive time steps +p29_snv_relocation(t,j) = (i29_snv_scenario_fader(t) - i29_snv_scenario_fader(t-1)) * + (i29_snv_relocation_target(j) * sum(cell(i,j), p29_country_snv_weight(i)) + + s29_snv_shr_noselect * sum(cell(i,j), 1-p29_country_snv_weight(i))); +*' The following lines take care of mismatches in the input +*' data (derived from satellite imagery from the Copernicus +*' Global Land Service (@buchhorn_copernicus_2020)) and in +*' cases of cropland reduction +p29_max_snv_relocation(t,j) = p29_snv_shr(t,j) * (i29_snv_scenario_fader(t) - i29_snv_scenario_fader(t-1)) * pcm_land(j,"crop"); +p29_snv_relocation(t,j)$(p29_snv_relocation(t, j) > p29_max_snv_relocation(t,j)) = p29_max_snv_relocation(t,j); + +*' Area potentially available for cropping +p29_avl_cropland(t,j) = f29_avl_cropland(j,"%c29_marginal_land%") * (1 - p29_snv_shr(t,j)); +*' @stop + + +* Growth of trees on cropland is modelled by shifting age-classes according to time step length. +s29_shift = m_timestep_length_forestry/5; +* example: ac10 in t = ac5 (ac10-1) in t-1 for a 5 yr time step (s29_shift = 1) + p29_treecover(t,j,ac)$(ord(ac) > s29_shift) = pc29_treecover(j,ac-s29_shift); +* account for cases at the end of the age class set (s29_shift > 1) which are not shifted by the above calculation + p29_treecover(t,j,"acx") = p29_treecover(t,j,"acx") + + sum(ac$(ord(ac) > card(ac)-s29_shift), pc29_treecover(j,ac)); + +pc29_treecover(j,ac) = p29_treecover(t,j,ac); +v29_treecover.l(j,ac) = p29_treecover(t,j,ac); + +if(m_year(t) <= s29_treecover_scenario_start, + v29_treecover.fx(j,ac) = pc29_treecover(j,ac); +else + v29_treecover.lo(j,ac_est) = 0; + v29_treecover.up(j,ac_est) = Inf; + if(s29_treecover_decrease = 1, + v29_treecover.lo(j,ac_sub) = 0; + v29_treecover.up(j,ac_sub) = pc29_treecover(j,ac_sub); + else + v29_treecover.fx(j,ac_sub) = pc29_treecover(j,ac_sub); + ); +); + + +* create treecover target and penalty scenario +i29_treecover_target(t,j) = + ((1-i29_treecover_scenario_fader(t)) * sum(ac, pc29_treecover(j,ac))/pcm_land(j,"crop"))$(pcm_land(j,"crop") > 1e-10) + + (i29_treecover_scenario_fader(t) * s29_treecover_target); +i29_treecover_penalty(t_all) = s29_treecover_penalty * i29_treecover_scenario_fader(t_all); + +* create fallow land target and penalty scenario +i29_fallow_target(t_all) = s29_fallow_target * i29_fallow_scenario_fader(t_all); +i29_fallow_penalty(t_all) = s29_fallow_penalty * i29_fallow_scenario_fader(t_all); diff --git a/modules/29_cropland/penalty_apr24/realization.gms b/modules/29_cropland/penalty_apr24/realization.gms new file mode 100644 index 0000000000..3eaac0d2d8 --- /dev/null +++ b/modules/29_cropland/penalty_apr24/realization.gms @@ -0,0 +1,20 @@ +*** | (C) 2008-2024 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 todo + +*' @limitations todo + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/29_cropland/penalty_apr24/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/29_cropland/penalty_apr24/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/29_cropland/penalty_apr24/input.gms" +$Ifi "%phase%" == "equations" $include "./modules/29_cropland/penalty_apr24/equations.gms" +$Ifi "%phase%" == "preloop" $include "./modules/29_cropland/penalty_apr24/preloop.gms" +$Ifi "%phase%" == "presolve" $include "./modules/29_cropland/penalty_apr24/presolve.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/29_cropland/penalty_apr24/postsolve.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/29_cropland/penalty_apr24/sets.gms b/modules/29_cropland/penalty_apr24/sets.gms new file mode 100644 index 0000000000..ce67e81d5a --- /dev/null +++ b/modules/29_cropland/penalty_apr24/sets.gms @@ -0,0 +1,22 @@ +*** | (C) 2008-2024 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 + +sets + + marginal_land29 Marginal land scenarios + / all_marginal, q33_marginal, no_marginal / + + policy_target29 Target year for cropland policy + / none, by2029, by2050 / + + relocation_target29 Cropland requiring relocation based on different SNV targets + / SNV20TargetCropland, SNV50TargetCropland / + + fallow29 fallow rules + / fallow20, fallow80 / + +; diff --git a/modules/29_cropland/rulebased_apr24/declarations.gms b/modules/29_cropland/rulebased_apr24/declarations.gms index 86b2c02637..bb538f8803 100644 --- a/modules/29_cropland/rulebased_apr24/declarations.gms +++ b/modules/29_cropland/rulebased_apr24/declarations.gms @@ -19,19 +19,18 @@ parameters p29_max_snv_relocation(t,j) Maximum cropland relocation during time step (mio. ha) p29_country_dummy(iso) Dummy parameter indicating whether country is affected by selected cropland policy (1) i29_avl_cropland_iso(iso) Available land area for cropland at ISO level (mio. ha) - p29_snv_scenario_fader(t_all) SNV scenario fader (1) - p29_rotation_scenario_fader(t_all) Crop rotation scenario fader (1) + i29_snv_scenario_fader(t_all) SNV scenario fader (1) - - p29_treecover_min_shr(t,j) Minimum share of treecover on cropland (1) - p29_treecover_scenario_fader(t_all) Cropland treecover scenario fader (1) - p29_fallow_min_shr(t,j) Minimum share of fallow land (1) - p29_fallow_scenario_fader(t_all) Fallow land scenario fader (1) + i29_treecover_scenario_fader(t_all) Cropland treecover scenario fader (1) + i29_treecover_target(t,j) Target share for treecover on total cropland (1) p29_treecover_bii_coeff(bii_class_secd,potnatveg) BII coefficient for cropland treecover (1) p29_carbon_density_ac(t,j,ac,ag_pools) Carbon density for ac and ag_pools (tC per ha) p29_treecover(t,j,ac) Cropland tree cover per age class (mio. ha) pc29_treecover(j,ac) Cropland tree cover per age class in current time step (mio. ha) + + i29_fallow_scenario_fader(t_all) Fallow land scenario fader (1) + i29_fallow_target(t_all) Target share for fallow land on total cropland (1) ; positive variables @@ -51,7 +50,7 @@ equations q29_cost_cropland(j) Costs and benefits related to agroforestry (mio. USD05MER per yr) q29_cost_treecover_est(j) Establishment cost for cropland tree cover (mio. USD05MER per yr) q29_cost_treecover_recur(j) Recurring cost for cropland tree cover (mio. USD05MER per yr) - q29_fallow_shr(j) Fallow land share (mio. ha) + q29_fallow_shr(j) Fallow land minimum share (mio. ha) q29_treecover_shr(j) Cropland treecover minimum share (mio. ha) q29_treecover_est(j,ac) Cropland treecover establishment (mio. ha) q29_treecover_bv(j,potnatveg) Biodiversity value for cropland treecover (mio. ha) @@ -73,7 +72,7 @@ parameters oq29_cost_cropland(t,j,type) Costs and benefits related to agroforestry (mio. USD05MER per yr) oq29_cost_treecover_est(t,j,type) Establishment cost for cropland tree cover (mio. USD05MER per yr) oq29_cost_treecover_recur(t,j,type) Recurring cost for cropland tree cover (mio. USD05MER per yr) - oq29_fallow_shr(t,j,type) Fallow land share (mio. ha) + oq29_fallow_shr(t,j,type) Fallow land minimum share (mio. ha) oq29_treecover_shr(t,j,type) Cropland treecover minimum share (mio. ha) oq29_treecover_est(t,j,ac,type) Cropland treecover establishment (mio. ha) oq29_treecover_bv(t,j,potnatveg,type) Biodiversity value for cropland treecover (mio. ha) diff --git a/modules/29_cropland/rulebased_apr24/equations.gms b/modules/29_cropland/rulebased_apr24/equations.gms index 1f5649f9a2..88f7bb1ab4 100644 --- a/modules/29_cropland/rulebased_apr24/equations.gms +++ b/modules/29_cropland/rulebased_apr24/equations.gms @@ -11,7 +11,6 @@ q29_cropland(j2) .. vm_land(j2,"crop") =e= sum((kcr,w), vm_area(j2,kcr,w)) + vm_fallow(j2) + sum(ac, v29_treecover(j2,ac)); - *' We assume that crop production can only take place on suitable cropland area. *' We use a suitability index (SI) map from @zabel_global_2014 to exclude areas *' from cropland production that have a low suitability, e.g. due to steep slopes, @@ -24,6 +23,23 @@ vm_land(j2,"crop") =l= sum(ct, p29_avl_cropland(ct,j2)); +*' Total costs for the cropland module: + +q29_cost_cropland(j2) .. + vm_cost_cropland(j2) =e= + v29_cost_treecover_est(j2) + v29_cost_treecover_recur(j2); + + +*' The carbon stocks of total cropland are calculated as the sum of carbon stocks in +*' cropland, fallow land and tree cover area. + + q29_carbon(j2,ag_pools,stockType) .. + vm_carbon_stock(j2,"crop",ag_pools,stockType) =e= + vm_carbon_stock_croparea(j2,ag_pools) + + vm_fallow(j2) * sum(ct, fm_carbon_density(ct,j2,"crop",ag_pools)) + + m_carbon_stock_ac(v29_treecover,p29_carbon_density_ac,"ac","ac_sub"); + + *' The semi-natural land constraint in cropland areas for sustaining critical regulating NCP *' for agricultural production is added on top of land conserved for other reasons *' (e.g. conservation of intact ecosystems or protection of biodiversity hotspots). @@ -43,54 +59,46 @@ sum(land_snv, vm_lu_transitions(j2,"crop",land_snv)) =g= sum(ct, p29_snv_relocation(ct,j2)); -*' The carbon stocks of total cropland are calculated as the sum of carbon stocks in cropland, fallow land and tree cover area. +*' Fallow land is greater or equal a certain share of total cropland: - q29_carbon(j2,ag_pools,stockType) .. - vm_carbon_stock(j2,"crop",ag_pools,stockType) =e= - vm_carbon_stock_croparea(j2,ag_pools) - + vm_fallow(j2) * sum(ct, fm_carbon_density(ct,j2,"crop",ag_pools)) - + m_carbon_stock_ac(v29_treecover,p29_carbon_density_ac,"ac","ac_sub"); +q29_fallow_shr(j2) .. + vm_fallow(j2) =g= + sum(ct, i29_fallow_target(ct)) * vm_land(j2,"crop"); +*' Fallow land biodiversity value: -*' Total cost -q29_cost_cropland(j2) .. - vm_cost_cropland(j2) =e= - v29_cost_treecover_est(j2) + v29_cost_treecover_recur(j2); +q29_fallow_bv(j2,potnatveg) .. + vm_bv(j2,"crop_fallow",potnatveg) =e= + vm_fallow(j2) * fm_bii_coeff("crop_per",potnatveg) * fm_luh2_side_layers(j2,potnatveg); -*' Fallow land minimum share -q29_fallow_shr(j2) .. - vm_fallow(j2) =g= - sum(ct, p29_fallow_min_shr(ct,j2)) * vm_land(j2,"crop"); +*' Cropland tree cover is greater or equal a certain share of total cropland: + +q29_treecover_shr(j2) .. + sum(ac, v29_treecover(j2,ac)) =g= + sum(ct, i29_treecover_target(ct,j2)) * vm_land(j2,"crop"); + +*' Cropland tree cover biodiversity value: + +q29_treecover_bv(j2,potnatveg) .. + vm_bv(j2,"crop_tree",potnatveg) =e= + sum(bii_class_secd, sum(ac_to_bii_class_secd(ac,bii_class_secd), v29_treecover(j2,ac)) * + p29_treecover_bii_coeff(bii_class_secd,potnatveg)) * fm_luh2_side_layers(j2,potnatveg); +*' Cropland tree cover annuity cost -*' Tree cover establishment cost q29_cost_treecover_est(j2) .. v29_cost_treecover_est(j2) =e= sum(ac_est, v29_treecover(j2,ac_est)) * s29_cost_treecover_est * sum((cell(i2,j2),ct),pm_interest(ct,i2)/(1+pm_interest(ct,i2))); -*' Tree cover recurring cost +*' Cropland tree cover recurring cost + q29_cost_treecover_recur(j2) .. v29_cost_treecover_recur(j2) =e= sum(ac_sub, v29_treecover(j2,ac_sub)) * s29_cost_treecover_recur; -*' Tree cover minimum share -q29_treecover_shr(j2) .. - sum(ac, v29_treecover(j2,ac)) =g= - sum(ct, p29_treecover_min_shr(ct,j2)) * vm_land(j2,"crop"); +*' Cropland tree cover establishment rules: -*' Tree cover establishment q29_treecover_est(j2,ac_est) .. v29_treecover(j2,ac_est) =e= sum(ac_est2, v29_treecover(j2,ac_est2))/card(ac_est2); - -*' Tree cover biodiversity value -q29_treecover_bv(j2,potnatveg) .. - vm_bv(j2,"crop_tree",potnatveg) =e= - sum(bii_class_secd, sum(ac_to_bii_class_secd(ac,bii_class_secd), v29_treecover(j2,ac)) * - p29_treecover_bii_coeff(bii_class_secd,potnatveg)) * fm_luh2_side_layers(j2,potnatveg); - -*' Tree cover biodiversity value -q29_fallow_bv(j2,potnatveg) .. - vm_bv(j2,"crop_fallow",potnatveg) =e= - vm_fallow(j2) * fm_bii_coeff("crop_per",potnatveg) * fm_luh2_side_layers(j2,potnatveg); diff --git a/modules/29_cropland/rulebased_apr24/input.gms b/modules/29_cropland/rulebased_apr24/input.gms index 0cee55f7fa..232c4ceabc 100644 --- a/modules/29_cropland/rulebased_apr24/input.gms +++ b/modules/29_cropland/rulebased_apr24/input.gms @@ -15,17 +15,17 @@ scalars s29_snv_scenario_target SNV scenario target year / 2029 / s29_snv_relocation_data_x1 First reference value in SNV target cropland data (1) / 0.2 / s29_snv_relocation_data_x2 Second reference value in SNV target cropland data (1) / 0.5 / - s29_cost_treecover_est Tree cover establishment cost (USD per ha) / 2000 / - s29_cost_treecover_recur Tree cover recurring cost (USD per ha) / 500 / + s29_cost_treecover_est Tree cover establishment cost (USD05MER per ha) / 2000 / + s29_cost_treecover_recur Tree cover recurring cost (USD05MER per ha) / 500 / s29_treecover_plantation Growth curve switch for tree cover on cropland 0=natveg 1=plantations (1) / 0 / s29_treecover_bii_coeff BII coefficent to be used for tree cover on cropland 0=secondary vegetation 1=timber plantations (1) / 0 / s29_treecover_decrease Cropland treecover can decrease (1) or not (0) / 0 / s29_treecover_scenario_start Cropland treecover scenario start year / 2020 / s29_treecover_scenario_target Cropland treecover scenario target year / 2050 / - s29_treecover_min_shr Share of treecover on cropland (1) / 0 / + s29_treecover_target Target share of treecover on total cropland (1) / 0.3 / s29_fallow_scenario_start Fallow land scenario start year / 2020 / s29_fallow_scenario_target Fallow land scenario target year / 2050 / - s29_fallow_min_shr Share of fallow land (1) / 0 / + s29_fallow_target Target share of fallow land on total cropland (1) / 0.3 / ; diff --git a/modules/29_cropland/rulebased_apr24/preloop.gms b/modules/29_cropland/rulebased_apr24/preloop.gms index 6ac9c3fee1..cc295eccf7 100644 --- a/modules/29_cropland/rulebased_apr24/preloop.gms +++ b/modules/29_cropland/rulebased_apr24/preloop.gms @@ -5,29 +5,22 @@ *** | MAgPIE License Exception, version 1.0 (see LICENSE file). *** | Contact: magpie@pik-potsdam.de -vm_fallow.fx(j) = 0; - ** Trajectory for cropland scenarios * sigmoidal interpolation between start year and target year -m_sigmoid_time_interpol(p29_snv_scenario_fader,s29_snv_scenario_start,s29_snv_scenario_target,0,1); +m_sigmoid_time_interpol(i29_snv_scenario_fader,s29_snv_scenario_start,s29_snv_scenario_target,0,1); +m_sigmoid_time_interpol(i29_treecover_scenario_fader,s29_treecover_scenario_start,s29_treecover_scenario_target,0,1); +m_sigmoid_time_interpol(i29_fallow_scenario_fader,s29_fallow_scenario_start,s29_fallow_scenario_target,0,1); * linear interpolation to estimate the cropland that * requires relocation due to SNV policy if (s29_snv_shr = 0, -i29_snv_relocation_target(j) = 0; - + i29_snv_relocation_target(j) = 0; elseif s29_snv_shr <= s29_snv_relocation_data_x1, -m_linear_cell_data_interpol(i29_snv_relocation_target, s29_snv_shr,0,s29_snv_relocation_data_x1,0, f29_snv_target_cropland(j, "SNV20TargetCropland")); - + m_linear_cell_data_interpol(i29_snv_relocation_target, s29_snv_shr,0,s29_snv_relocation_data_x1,0, f29_snv_target_cropland(j, "SNV20TargetCropland")); elseif s29_snv_shr > s29_snv_relocation_data_x1, -m_linear_cell_data_interpol(i29_snv_relocation_target, s29_snv_shr,s29_snv_relocation_data_x1, s29_snv_relocation_data_x2,f29_snv_target_cropland(j, "SNV20TargetCropland"), f29_snv_target_cropland(j, "SNV50TargetCropland")); + m_linear_cell_data_interpol(i29_snv_relocation_target, s29_snv_shr,s29_snv_relocation_data_x1, s29_snv_relocation_data_x2,f29_snv_target_cropland(j, "SNV20TargetCropland"), f29_snv_target_cropland(j, "SNV50TargetCropland")); ); - -m_sigmoid_time_interpol(p29_treecover_scenario_fader,s29_treecover_scenario_start,s29_treecover_scenario_target,0,1); -m_sigmoid_time_interpol(p29_fallow_scenario_fader,s29_fallow_scenario_start,s29_fallow_scenario_target,0,1); - - * Initial tree cover on cropland is assumed to be equally distributed among all age-classes pc29_treecover(j,ac) = 0; pc29_treecover(j,ac)$(pm_land_hist("y2015",j,"crop") > 1e-10) = diff --git a/modules/29_cropland/rulebased_apr24/presolve.gms b/modules/29_cropland/rulebased_apr24/presolve.gms index d53e7658cb..e4a8c98fc9 100644 --- a/modules/29_cropland/rulebased_apr24/presolve.gms +++ b/modules/29_cropland/rulebased_apr24/presolve.gms @@ -7,7 +7,7 @@ *' @code *' Minimum semi-natural vegetation (SNV) share is fading in after 2020 -p29_snv_shr(t,j) = p29_snv_scenario_fader(t) * +p29_snv_shr(t,j) = i29_snv_scenario_fader(t) * (s29_snv_shr * sum(cell(i,j), p29_country_snv_weight(i)) + s29_snv_shr_noselect * sum(cell(i,j), 1-p29_country_snv_weight(i))); @@ -15,14 +15,14 @@ p29_snv_shr(t,j) = p29_snv_scenario_fader(t) * *' cover information from the Copernicus Global Land Service (@buchhorn_copernicus_2020). *' The rate of the policy implementation is derived based *' on the difference of scenario fader values in consecutive time steps -p29_snv_relocation(t,j) = (p29_snv_scenario_fader(t) - p29_snv_scenario_fader(t-1)) * +p29_snv_relocation(t,j) = (i29_snv_scenario_fader(t) - i29_snv_scenario_fader(t-1)) * (i29_snv_relocation_target(j) * sum(cell(i,j), p29_country_snv_weight(i)) + s29_snv_shr_noselect * sum(cell(i,j), 1-p29_country_snv_weight(i))); *' The following lines take care of mismatches in the input *' data (derived from satellite imagery from the Copernicus *' Global Land Service (@buchhorn_copernicus_2020)) and in *' cases of cropland reduction -p29_max_snv_relocation(t,j) = p29_snv_shr(t,j) * (p29_snv_scenario_fader(t) - p29_snv_scenario_fader(t-1)) * pcm_land(j,"crop"); +p29_max_snv_relocation(t,j) = p29_snv_shr(t,j) * (i29_snv_scenario_fader(t) - i29_snv_scenario_fader(t-1)) * pcm_land(j,"crop"); p29_snv_relocation(t,j)$(p29_snv_relocation(t, j) > p29_max_snv_relocation(t,j)) = p29_max_snv_relocation(t,j); *' Area potentially available for cropping @@ -54,10 +54,10 @@ else ); ); -p29_treecover_min_shr(t,j) = - ((1-p29_treecover_scenario_fader(t)) * sum(ac, pc29_treecover(j,ac))/pcm_land(j,"crop"))$(pcm_land(j,"crop") > 1e-10) + - (p29_treecover_scenario_fader(t) * s29_treecover_min_shr); - -p29_fallow_min_shr(t,j) = p29_fallow_scenario_fader(t) * s29_fallow_min_shr; - +* create treecover target and penalty scenario +i29_treecover_target(t,j) = + ((1-i29_treecover_scenario_fader(t)) * sum(ac, pc29_treecover(j,ac))/pcm_land(j,"crop"))$(pcm_land(j,"crop") > 1e-10) + + (i29_treecover_scenario_fader(t) * s29_treecover_target); +* create fallow land target and penalty scenario +i29_fallow_target(t_all) = s29_fallow_target * i29_fallow_scenario_fader(t_all); diff --git a/modules/30_crop/penalty_apr22/input.gms b/modules/30_crop/penalty_apr22/input.gms index 91befb168a..3cadd0b059 100644 --- a/modules/30_crop/penalty_apr22/input.gms +++ b/modules/30_crop/penalty_apr22/input.gms @@ -15,7 +15,7 @@ $setglobal c30_rotation_constraints on *options: on, off $setglobal c30_rotation_scenario default -*options: none, default, fallow, legumes, agroforestry, agroecology +*options: none, default, legumes, betr500, betr1000, agroecology $setglobal c30_rotation_scenario_speed by2050 * options: none, by2030, by2020 From 384526237f5c8fd2cd45b8a7e192f16cd948b515 Mon Sep 17 00:00:00 2001 From: florianh Date: Sat, 20 Apr 2024 22:07:06 +0200 Subject: [PATCH 014/133] partial commit to save work --- config/default.cfg | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index 65b72072a6..1e252da7fa 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -673,7 +673,7 @@ cfg$gms$ageclass <- "feb21" # def = feb21 # * Croparea is proved from 30_crop. # * Fallow land and tree cover are defined by 29_cropland, either exogenous via prescribed rules or endognous via monetary incentives. # * (rulebased_apr24): Fallow land and tree cover are prescribed by rules. -# * (incentive_apr24): Fallow land and tree cover develop endogenously based on monetary incentives +# * (penalty_apr24): Fallow land and tree cover are incentivized by penalties cfg$gms$cropland <- "rulebased_apr24" # def = rulebased_apr24 # * Switch to determine whether marginal land (suitability index below 0.33) should be included @@ -712,14 +712,25 @@ cfg$gms$policy_countries29 <- all_iso_countries # * "secdforest, past, other" etc. cfg$gms$land_snv <- "secdforest, forestry, past, other" #def = "secdforest, forestry, past, other" -# * Minimum share of treecover on cropland reached in s29_treecover_scenario_target: # * Minimum share of treecover on total cropland area (including croparea, fallow land and tree cover). -# * s29_treecover_min_shr is faded in linearly between s29_treecover_scenario_start and s29_treecover_scenario_target. -cfg$gms$s29_treecover_min_shr <- 0 #def = 0 +# * s29_treecover_target is faded in linearly between s29_treecover_scenario_start and s29_treecover_scenario_target. +cfg$gms$s29_treecover_target <- 0 #def = 0 # * Start year of tree cover share fade-in: cfg$gms$s29_treecover_scenario_start <- 2020 # def = 2020 # * Target year (year when full implementation is reached): -cfg$gms$s29_treecover_scenario_target <- 2040 # def = 2040 +cfg$gms$s29_treecover_scenario_target <- 2050 # def = 2050 +# * Penalty for violation of treecover target (only used in realization penalty_apr24) +cfg$gms$s29_treecover_penalty <- 0 #def = 0 + +# * Minimum share of fallow land on total cropland area (including croparea, fallow land and tree cover). +# * s29_fallow_target is faded in linearly between s29_fallow_scenario_start and s29_fallow_scenario_target. +cfg$gms$s29_fallow_target <- 0 #def = 0 +# * Start year of tree cover share fade-in: +cfg$gms$s29_fallow_scenario_start <- 2020 # def = 2020 +# * Target year (year when full implementation is reached): +cfg$gms$s29_fallow_scenario_target <- 2050 # def = 2050 +# * Penalty for violation of fallow target (only used in realization penalty_apr24) +cfg$gms$s29_fallow_penalty <- 0 #def = 0 # ***--------------------- 30_crop --------------------------------------- # * 30_crop defines the croparea, which is a subcomponent of total cropland defined in 29_cropland. @@ -740,8 +751,9 @@ cfg$gms$c30_rotation_constraints <- "on" # def = "on" # * legumes (minimum share of legumes), sixfoldrotation (crops can only repeat after 6 years), # * agroecology (mix of previous scenarios), # * betr0 (minimum share of short rotation agroforestry trees), betr10, betr20, betr25, betr30, betr40, betr50. -# * In realization penalty_apr22: none (no incentives), default (best guess), fallow (increased fallow incentives), -# * legumes (increased incentives for legumes), agroforestry (increased incentives for perennials), agroecology (mix) +# * In realization penalty_apr22: none (no incentives), default (best guess), +# * legumes (increased incentives for legumes), agroecology (mix), +# * betr500 and betr1000 (incentives for short rotation agroforestry trees) # * In realization endo_apr21: no scenarios exist. cfg$gms$c30_rotation_scenario <- "default" # def = "default" # * Year by which rotation scenario is fully implemented: From e7f8e4068e8bd5da3d46e1579b24de2bb5b2fbc8 Mon Sep 17 00:00:00 2001 From: florianh Date: Sat, 20 Apr 2024 22:14:52 +0200 Subject: [PATCH 015/133] partial commit to save work --- config/scenario_config.csv | 6 +++--- config/scenario_fsec.csv | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/config/scenario_config.csv b/config/scenario_config.csv index 4c1657a7d8..a514bfd165 100755 --- a/config/scenario_config.csv +++ b/config/scenario_config.csv @@ -31,9 +31,9 @@ gms$c21_trade_liberalization;;;;l908080r807070;l909090r808080;l909090r808080;l90 gms$c22_protect_scenario;;;;none;none;none;none;none;none;BH;none;BH_IFL;BH;;;;;;;BH;;;;;BH_IFL;BH_IFL;BH_IFL;BH_IFL;BH_IFL;;;;;;;;;;;;;;;;;;; gms$c22_protect_scenario_noselect;;;;;;;;;;;;;;;;;;;;;;;;;none;none;BH_IFL;none;BH_IFL;;;;;;;;;;;;;;;;;;; gms$c30_bioen_water;;;;rainfed;rainfed;rainfed;rainfed;rainfed;rainfed;rainfed;all;rainfed;rainfed;;;;;;;rainfed;;;rainfed;all;;;;;;;;;;;;;;;;;;;;;;;; -gms$s30_snv_shr;;;;0;0;0;0;0;0;0;0;0;0.2;;;;;;;0;;;;;0.2;0.2;0.2;0.2;0.2;;;;;;;;;;;;;;;;;;; -gms$s30_snv_shr_noselect;;;;;;;;;;;;;;;;;;;;;;;;;0;0;0.2;0;0.2;;;;;;;;;;;;;;;;;;; -gms$s30_snv_scenario_target;;;;;;;;;;;;;2030;;;;;;;;;;;;2030;2030;2030;2030;2030;;;;;;;;;;;;;;;;;;; +gms$s29_snv_shr;;;;0;0;0;0;0;0;0;0;0;0.2;;;;;;;0;;;;;0.2;0.2;0.2;0.2;0.2;;;;;;;;;;;;;;;;;;; +gms$s29_snv_shr_noselect;;;;;;;;;;;;;;;;;;;;;;;;;0;0;0.2;0;0.2;;;;;;;;;;;;;;;;;;; +gms$s29_snv_scenario_target;;;;;;;;;;;;;2030;;;;;;;;;;;;2030;2030;2030;2030;2030;;;;;;;;;;;;;;;;;;; gms$c31_grassl_yld_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$s32_aff_plantation;;;;0;0;0;0;0;0;0;1;0;0;;;;;;;0;;;0;1;;;;;;;;;;;;;;;;;;;;;;;; gms$s32_aff_bii_coeff;;;;0;0;0;0;0;0;0;1;0;0;;;;;;;0;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/config/scenario_fsec.csv b/config/scenario_fsec.csv index b4b96c2a90..8f6ee53db2 100644 --- a/config/scenario_fsec.csv +++ b/config/scenario_fsec.csv @@ -29,10 +29,10 @@ gms$c22_protect_scenario;;;;;;;;;;;;;;;;;;;;;;;;;;;;;BH_IFL;;;;;;;;;;;;;;;;;;;;; gms$crop;penalty_apr22;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$c30_rotation_scenario;default;;;;;;;;;;;;;;;;;;;;;;;;;;;agroecology;;;;;;;;;;;;;;;;;;;;;;; gms$s30_rotation_scenario_target;2050;;;;;;;;;;;;;;;;;;;;;;;;;;;2050;;;;;;;;;;;;;;;;;;;;;;; -gms$c30_marginal_land;q33_marginal;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c29_marginal_land;q33_marginal;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$c30_bioen_water;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;rainfed;;;;;;;;;;;;;;;;;;;;; -gms$s30_snv_scenario_target;;;;;;;;;;;;;;;;;;;;;;;;;;;2050;;;;;;;;;;;;;;;;;;;;;;;; -gms$s30_snv_shr;;;;;;;;;;;;;;;;;;;;;;;;;;;0.2;;;;;;;;;;;;;;;;;;;;;;;; +gms$s29_snv_scenario_target;;;;;;;;;;;;;;;;;;;;;;;;;;;2050;;;;;;;;;;;;;;;;;;;;;;;; +gms$s29_snv_shr;;;;;;;;;;;;;;;;;;;;;;;;;;;0.2;;;;;;;;;;;;;;;;;;;;;;;; gms$past;endo_jun13;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$c32_aff_policy;ndc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$c32_aff_mask;;;;;;;;;;;;;;;;;;;;;;;;;onlytropical;;;;;;;;;;;;;;;;;;;;;;;;;; From 3923e34c5d935e4f4afac374efb8bf78ca019d28 Mon Sep 17 00:00:00 2001 From: florianh Date: Sun, 21 Apr 2024 15:40:19 +0200 Subject: [PATCH 016/133] partial commit to save work --- config/default.cfg | 62 ++++++--- main.gms | 4 +- .../declarations.gms | 56 ++++---- .../29_cropland/detail_apr24/equations.gms | 131 ++++++++++++++++++ .../{penalty_apr24 => detail_apr24}/input.gms | 1 + .../postsolve.gms | 96 +++++++------ .../preloop.gms | 5 + .../presolve.gms | 0 .../29_cropland/detail_apr24/realization.gms | 31 +++++ .../{penalty_apr24 => detail_apr24}/sets.gms | 0 modules/29_cropland/module.gms | 9 +- .../29_cropland/penalty_apr24/equations.gms | 124 ----------------- .../29_cropland/penalty_apr24/realization.gms | 20 --- .../rulebased_apr24/declarations.gms | 82 ----------- .../29_cropland/rulebased_apr24/equations.gms | 104 -------------- modules/29_cropland/rulebased_apr24/input.gms | 94 ------------- .../29_cropland/rulebased_apr24/postsolve.gms | 84 ----------- .../29_cropland/rulebased_apr24/preloop.gms | 57 -------- .../29_cropland/rulebased_apr24/presolve.gms | 63 --------- .../rulebased_apr24/realization.gms | 20 --- .../29_cropland/simple_apr24/declarations.gms | 32 +++++ .../29_cropland/simple_apr24/equations.gms | 32 +++++ modules/29_cropland/simple_apr24/input.gms | 17 +++ modules/29_cropland/simple_apr24/not_used.txt | 11 ++ .../29_cropland/simple_apr24/postsolve.gms | 30 ++++ modules/29_cropland/simple_apr24/preloop.gms | 14 ++ modules/29_cropland/simple_apr24/presolve.gms | 6 + .../29_cropland/simple_apr24/realization.gms | 25 ++++ .../sets.gms | 6 - modules/30_crop/endo_apr21/realization.gms | 35 ----- modules/30_crop/penalty_apr22/equations.gms | 79 ----------- modules/30_crop/penalty_apr22/realization.gms | 40 ------ modules/30_crop/penalty_apr22/sets.gms | 79 ----------- .../30_crop/rotation_apr22/declarations.gms | 45 ------ modules/30_crop/rotation_apr22/equations.gms | 57 -------- modules/30_crop/rotation_apr22/input.gms | 63 --------- modules/30_crop/rotation_apr22/input/files | 4 - modules/30_crop/rotation_apr22/postsolve.gms | 50 ------- modules/30_crop/rotation_apr22/preloop.gms | 26 ---- modules/30_crop/rotation_apr22/presolve.gms | 26 ---- .../30_crop/rotation_apr22/realization.gms | 41 ------ modules/30_crop/rotation_apr22/sets.gms | 101 -------------- .../detail_apr24}/declarations.gms | 5 + .../30_croparea/detail_apr24/equations.gms | 83 +++++++++++ .../detail_apr24}/input.gms | 21 ++- .../detail_apr24}/input/files | 0 .../detail_apr24}/postsolve.gms | 8 ++ .../detail_apr24}/preloop.gms | 13 +- .../detail_apr24}/presolve.gms | 0 .../30_croparea/detail_apr24/realization.gms | 33 +++++ modules/30_croparea/detail_apr24/sets.gms | 114 +++++++++++++++ modules/{30_crop => 30_croparea}/module.gms | 5 +- .../simple_apr24}/declarations.gms | 0 .../simple_apr24}/equations.gms | 18 +-- .../simple_apr24}/input.gms | 6 +- .../simple_apr24}/input/files | 0 .../simple_apr24}/not_used.txt | 0 .../simple_apr24}/postsolve.gms | 0 .../simple_apr24}/preloop.gms | 0 .../simple_apr24}/presolve.gms | 0 .../30_croparea/simple_apr24/realization.gms | 28 ++++ .../simple_apr24}/sets.gms | 0 modules/include.gms | 2 +- 63 files changed, 771 insertions(+), 1427 deletions(-) rename modules/29_cropland/{penalty_apr24 => detail_apr24}/declarations.gms (92%) create mode 100644 modules/29_cropland/detail_apr24/equations.gms rename modules/29_cropland/{penalty_apr24 => detail_apr24}/input.gms (97%) rename modules/29_cropland/{penalty_apr24 => detail_apr24}/postsolve.gms (93%) rename modules/29_cropland/{penalty_apr24 => detail_apr24}/preloop.gms (97%) rename modules/29_cropland/{penalty_apr24 => detail_apr24}/presolve.gms (100%) create mode 100644 modules/29_cropland/detail_apr24/realization.gms rename modules/29_cropland/{penalty_apr24 => detail_apr24}/sets.gms (100%) delete mode 100644 modules/29_cropland/penalty_apr24/equations.gms delete mode 100644 modules/29_cropland/penalty_apr24/realization.gms delete mode 100644 modules/29_cropland/rulebased_apr24/declarations.gms delete mode 100644 modules/29_cropland/rulebased_apr24/equations.gms delete mode 100644 modules/29_cropland/rulebased_apr24/input.gms delete mode 100644 modules/29_cropland/rulebased_apr24/postsolve.gms delete mode 100644 modules/29_cropland/rulebased_apr24/preloop.gms delete mode 100644 modules/29_cropland/rulebased_apr24/presolve.gms delete mode 100644 modules/29_cropland/rulebased_apr24/realization.gms create mode 100644 modules/29_cropland/simple_apr24/declarations.gms create mode 100644 modules/29_cropland/simple_apr24/equations.gms create mode 100644 modules/29_cropland/simple_apr24/input.gms create mode 100644 modules/29_cropland/simple_apr24/not_used.txt create mode 100644 modules/29_cropland/simple_apr24/postsolve.gms create mode 100644 modules/29_cropland/simple_apr24/preloop.gms create mode 100644 modules/29_cropland/simple_apr24/presolve.gms create mode 100644 modules/29_cropland/simple_apr24/realization.gms rename modules/29_cropland/{rulebased_apr24 => simple_apr24}/sets.gms (70%) delete mode 100644 modules/30_crop/endo_apr21/realization.gms delete mode 100644 modules/30_crop/penalty_apr22/equations.gms delete mode 100644 modules/30_crop/penalty_apr22/realization.gms delete mode 100644 modules/30_crop/penalty_apr22/sets.gms delete mode 100644 modules/30_crop/rotation_apr22/declarations.gms delete mode 100644 modules/30_crop/rotation_apr22/equations.gms delete mode 100644 modules/30_crop/rotation_apr22/input.gms delete mode 100644 modules/30_crop/rotation_apr22/input/files delete mode 100644 modules/30_crop/rotation_apr22/postsolve.gms delete mode 100644 modules/30_crop/rotation_apr22/preloop.gms delete mode 100644 modules/30_crop/rotation_apr22/presolve.gms delete mode 100644 modules/30_crop/rotation_apr22/realization.gms delete mode 100644 modules/30_crop/rotation_apr22/sets.gms rename modules/{30_crop/penalty_apr22 => 30_croparea/detail_apr24}/declarations.gms (88%) create mode 100644 modules/30_croparea/detail_apr24/equations.gms rename modules/{30_crop/penalty_apr22 => 30_croparea/detail_apr24}/input.gms (66%) rename modules/{30_crop/penalty_apr22 => 30_croparea/detail_apr24}/input/files (100%) rename modules/{30_crop/penalty_apr22 => 30_croparea/detail_apr24}/postsolve.gms (87%) rename modules/{30_crop/penalty_apr22 => 30_croparea/detail_apr24}/preloop.gms (68%) rename modules/{30_crop/penalty_apr22 => 30_croparea/detail_apr24}/presolve.gms (100%) create mode 100644 modules/30_croparea/detail_apr24/realization.gms create mode 100644 modules/30_croparea/detail_apr24/sets.gms rename modules/{30_crop => 30_croparea}/module.gms (76%) rename modules/{30_crop/endo_apr21 => 30_croparea/simple_apr24}/declarations.gms (100%) rename modules/{30_crop/endo_apr21 => 30_croparea/simple_apr24}/equations.gms (73%) rename modules/{30_crop/endo_apr21 => 30_croparea/simple_apr24}/input.gms (87%) rename modules/{30_crop/endo_apr21 => 30_croparea/simple_apr24}/input/files (100%) rename modules/{30_crop/endo_apr21 => 30_croparea/simple_apr24}/not_used.txt (100%) rename modules/{30_crop/endo_apr21 => 30_croparea/simple_apr24}/postsolve.gms (100%) rename modules/{30_crop/endo_apr21 => 30_croparea/simple_apr24}/preloop.gms (100%) rename modules/{30_crop/endo_apr21 => 30_croparea/simple_apr24}/presolve.gms (100%) create mode 100644 modules/30_croparea/simple_apr24/realization.gms rename modules/{30_crop/endo_apr21 => 30_croparea/simple_apr24}/sets.gms (100%) diff --git a/config/default.cfg b/config/default.cfg index 1e252da7fa..22ec4d5252 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -669,12 +669,15 @@ cfg$gms$s22_conservation_target <- 2030 # def = 2030 cfg$gms$ageclass <- "feb21" # def = feb21 # ***--------------------- 29_cropland ----------------------------------- -# * Cropland is the sum of croparea, fallow land and tree cover -# * Croparea is proved from 30_crop. -# * Fallow land and tree cover are defined by 29_cropland, either exogenous via prescribed rules or endognous via monetary incentives. -# * (rulebased_apr24): Fallow land and tree cover are prescribed by rules. -# * (penalty_apr24): Fallow land and tree cover are incentivized by penalties -cfg$gms$cropland <- "rulebased_apr24" # def = rulebased_apr24 +# * Cropland is defined as the sum of croparea, fallow land and tree cover +# * Croparea is provided by 30_crop. +# * Fallow land and tree cover are defined by 29_cropland, +# * (simple_apr24): Fallow land is fixed to zero and tree cover on cropland does not exist, no SNV options +# * (detail_apr24): Fallow land and tree cover based on rules or incentives, SNV options included +# NOTE: It is recommended to recalibrate the model when changing this setting! +cfg$gms$cropland <- "detail_apr24" # def = detail_apr24 + +# *** Options for all cropland realizations *** # * Switch to determine whether marginal land (suitability index below 0.33) should be included # * in the total available cropland. Options are: @@ -685,6 +688,8 @@ cfg$gms$cropland <- "rulebased_apr24" # def = rulebased_apr24 # * with observed cropland patterns and is recommended for productive runs. cfg$gms$c29_marginal_land <- "q33_marginal" # def = "q33_marginal" +# *** Options only available for `detail_apr24` realization *** + # * Share of available cropland that is withheld for maintaining semi-natural vegetation (SNV) # * in each square km in cropland areas, including grassland, forest and other land. For example, # * a share of 0.2 corresponds to 20 % of SNV in terms of the available cropland. @@ -712,6 +717,9 @@ cfg$gms$policy_countries29 <- all_iso_countries # * "secdforest, past, other" etc. cfg$gms$land_snv <- "secdforest, forestry, past, other" #def = "secdforest, forestry, past, other" +# * Switch for rule-based (1) or penalty-based (0) implementation of fallow and treecover targets +cfg$gms$s29_implementation <- 1 # def = 1 + # * Minimum share of treecover on total cropland area (including croparea, fallow land and tree cover). # * s29_treecover_target is faded in linearly between s29_treecover_scenario_start and s29_treecover_scenario_target. cfg$gms$s29_treecover_target <- 0 #def = 0 @@ -719,7 +727,7 @@ cfg$gms$s29_treecover_target <- 0 #def = 0 cfg$gms$s29_treecover_scenario_start <- 2020 # def = 2020 # * Target year (year when full implementation is reached): cfg$gms$s29_treecover_scenario_target <- 2050 # def = 2050 -# * Penalty for violation of treecover target (only used in realization penalty_apr24) +# * Penalty for violation of treecover target cfg$gms$s29_treecover_penalty <- 0 #def = 0 # * Minimum share of fallow land on total cropland area (including croparea, fallow land and tree cover). @@ -729,33 +737,47 @@ cfg$gms$s29_fallow_target <- 0 #def = 0 cfg$gms$s29_fallow_scenario_start <- 2020 # def = 2020 # * Target year (year when full implementation is reached): cfg$gms$s29_fallow_scenario_target <- 2050 # def = 2050 -# * Penalty for violation of fallow target (only used in realization penalty_apr24) +# * Penalty for violation of fallow target cfg$gms$s29_fallow_penalty <- 0 #def = 0 -# ***--------------------- 30_crop --------------------------------------- -# * 30_crop defines the croparea, which is a subcomponent of total cropland defined in 29_cropland. -# * (endo_apr21): Hard rotational constraints. Dynamic cropland and detailed cropland availability data at grid cell level. -# * (rotation_apr22): hard rotational constraints and fallow constraints with the option of different future scenarios. Dynamic cropland and detailed cropland availability data at grid cell level. -# * (penalty_apr22): rotational and fallow constraints are incentivized via penalty payments. Dynamic cropland and detailed cropland availability data at grid cell level. +# ***--------------------- 30_croparea --------------------------------------- +# * 30_croparea defines the croparea, which is a subcomponent of total cropland defined in 29_cropland. +# * (simple_apr24): Dynamic croparea with simple rotational constraints +# * (detail_apr24): Dynamic croparea with detailed rules and incentives for rotational constraints # NOTE: It is recommended to recalibrate the model when changing this setting! -cfg$gms$crop <- "endo_apr21" # def = endo_apr21 +cfg$gms$croparea <- "simple_apr24" # def = simple_apr24 + +# *** Options for all croparea realizations *** + # * (c30_bioen_type): switch for type of bioenergy crops; options: begr, betr, all cfg$gms$c30_bioen_type <- "all" # def = "all" # * (c30_bioen_water): switch for irrigation of bioenergy crops; options: rainfed, irrigated, all cfg$gms$c30_bioen_water <- "rainfed" # def = "rainfed" + +# *** Options only available for `simple_apr24` realization *** + # * (c30_rotation_constraints): switch for rotational constraints: on, off cfg$gms$c30_rotation_constraints <- "on" # def = "on" -# * (c30_rotation_scenario): scenarios for constraints. -# * In realization rotation_apr22: min (minimal constraints), default (best guess), good (good practice), + +# *** Options only available for `detail_apr24` realization *** + +# * Switch for rule-based (1) or penalty-based (0) implementation of rotation scenarios +cfg$gms$s30_implementation <- 1 # def = 1 + +# * Rotation rules: +# * min (minimal constraints), default (best guess), good (good practice), # * good_20div (good practice - 20% for other crops), setaside (default plus fallow), # * legumes (minimum share of legumes), sixfoldrotation (crops can only repeat after 6 years), -# * agroecology (mix of previous scenarios), +# * agroecology (mix of previous scenarios), FSEC (similar to agroecology) # * betr0 (minimum share of short rotation agroforestry trees), betr10, betr20, betr25, betr30, betr40, betr50. -# * In realization penalty_apr22: none (no incentives), default (best guess), +cfg$gms$c30_rotation_rules <- "default" # def = "default" + +# * Rotation incentives: +# * none (no incentives), default (best guess), # * legumes (increased incentives for legumes), agroecology (mix), # * betr500 and betr1000 (incentives for short rotation agroforestry trees) -# * In realization endo_apr21: no scenarios exist. -cfg$gms$c30_rotation_scenario <- "default" # def = "default" +cfg$gms$c30_rotation_incentives <- "default" # def = "default" + # * Year by which rotation scenario is fully implemented: # * Start year: cfg$gms$s30_rotation_scenario_start <- 2020 # def = 2020 diff --git a/main.gms b/main.gms index c2a738f7b5..939c2a3839 100644 --- a/main.gms +++ b/main.gms @@ -249,8 +249,8 @@ $setglobal land_conservation area_based_apr22 $setglobal ageclass feb21 -$setglobal cropland rulebased_apr24 -$setglobal crop endo_apr21 +$setglobal cropland detail_apr24 +$setglobal croparea simple_apr24 $setglobal past endo_jun13 $setglobal forestry dynamic_feb21 diff --git a/modules/29_cropland/penalty_apr24/declarations.gms b/modules/29_cropland/detail_apr24/declarations.gms similarity index 92% rename from modules/29_cropland/penalty_apr24/declarations.gms rename to modules/29_cropland/detail_apr24/declarations.gms index 86f165a043..14405e207a 100644 --- a/modules/29_cropland/penalty_apr24/declarations.gms +++ b/modules/29_cropland/detail_apr24/declarations.gms @@ -9,7 +9,6 @@ scalars s29_shift number of 5-year age-classes corresponding to current time step length (1) ; - parameters p29_avl_cropland(t,j) Total available land for crop cultivation (mio. ha) p29_country_snv_weight(i) SNV policy country weight per region (1) @@ -21,10 +20,9 @@ parameters i29_avl_cropland_iso(iso) Available land area for cropland at ISO level (mio. ha) i29_snv_scenario_fader(t_all) SNV scenario fader (1) - i29_treecover_scenario_fader(t_all) Cropland treecover scenario fader (1) - i29_treecover_target(t,j) Target share for treecover on total cropland (1) - i29_treecover_penalty(t_all) Penalty for violation of treecover target (USD05MER per ha) - + i29_treecover_scenario_fader(t_all) Cropland treecover scenario fader (1) + i29_treecover_target(t,j) Target share for treecover on total cropland (1) + i29_treecover_penalty(t_all) Penalty for violation of treecover target (USD05MER per ha) p29_treecover_bii_coeff(bii_class_secd,potnatveg) BII coefficient for cropland treecover (1) p29_carbon_density_ac(t,j,ac,ag_pools) Carbon density for ac and ag_pools (tC per ha) p29_treecover(t,j,ac) Cropland tree cover per age class (mio. ha) @@ -36,13 +34,13 @@ parameters ; positive variables - vm_fallow(j) Fallow land is temporarily fallow cropland (mio. ha) - v29_treecover(j,ac) Cropland tree cover per age class (mio. ha) vm_cost_cropland(j) Cost for total cropland (mio. USD05MER per yr) - v29_cost_treecover_est(j) Establishment cost for cropland tree cover (mio. USD05MER per yr) - v29_cost_treecover_recur(j) Recurring cost for cropland tree cover (mio. USD05MER per yr) + v29_treecover(j,ac) Cropland tree cover per age class (mio. ha) v29_treecover_penalty(j) Penalty for violation of treecover target (mio. USD05MER per yr) v29_treecover_missing(j) Missing treecover area towards target (mio. ha) + v29_cost_treecover_est(j) Establishment cost for cropland tree cover (mio. USD05MER per yr) + v29_cost_treecover_recur(j) Recurring cost for cropland tree cover (mio. USD05MER per yr) + vm_fallow(j) Fallow land is temporarily fallow cropland (mio. ha) v29_fallow_penalty(j) Penalty for violation of fallow target (mio. USD05MER per yr) v29_fallow_missing(j) Missing fallow land towards target (mio. ha) ; @@ -50,47 +48,51 @@ positive variables equations q29_cropland(j) Total cropland calculation (mio. ha) q29_avl_cropland(j) Available cropland constraint (mio. ha) + q29_cost_cropland(j) Costs and benefits related to agroforestry (mio. USD05MER per yr) q29_carbon(j,ag_pools,stockType) Cropland above ground carbon content calculation (mio. tC) q29_land_snv(j) Land constraint for the SNV policy in cropland areas (mio. ha) q29_land_snv_trans(j) Land transition constraint for SNV policy in cropland areas (mio. ha) - q29_cost_cropland(j) Costs and benefits related to agroforestry (mio. USD05MER per yr) - q29_cost_treecover_est(j) Establishment cost for cropland tree cover (mio. USD05MER per yr) - q29_cost_treecover_recur(j) Recurring cost for cropland tree cover (mio. USD05MER per yr) + q29_fallow_shr(j) Fallow land minimum share (mio. ha) + q29_fallow_penalty(j) Penalty for violation of fallow target (mio. USD05MER per yr) + q29_fallow_missing(j) Missing fallow land towards target (mio. ha) + q29_fallow_bv(j,potnatveg) Biodiversity value for fallow land (mio. ha) + q29_treecover_shr(j) Cropland treecover minimum share (mio. ha) q29_treecover_penalty(j) Penalty for violation of treecover target (mio. USD05MER per yr) q29_treecover_missing(j) Missing treecover area towards target (mio. ha) - q29_treecover_est(j,ac) Cropland treecover establishment (mio. ha) q29_treecover_bv(j,potnatveg) Biodiversity value for cropland treecover (mio. ha) - q29_fallow_bv(j,potnatveg) Biodiversity value for fallow land (mio. ha) - q29_fallow_penalty(j) Penalty for violation of fallow target (mio. USD05MER per yr) - q29_fallow_missing(j) Missing fallow land towards target (mio. ha) + q29_cost_treecover_est(j) Establishment cost for cropland tree cover (mio. USD05MER per yr) + q29_cost_treecover_recur(j) Recurring cost for cropland tree cover (mio. USD05MER per yr) + q29_treecover_est(j,ac) Cropland treecover establishment (mio. ha) ; *#################### R SECTION START (OUTPUT DECLARATIONS) #################### parameters - ov_fallow(t,j,type) Fallow land is temporarily fallow cropland (mio. ha) - ov29_treecover(t,j,ac,type) Cropland tree cover per age class (mio. ha) ov_cost_cropland(t,j,type) Cost for total cropland (mio. USD05MER per yr) - ov29_cost_treecover_est(t,j,type) Establishment cost for cropland tree cover (mio. USD05MER per yr) - ov29_cost_treecover_recur(t,j,type) Recurring cost for cropland tree cover (mio. USD05MER per yr) + ov29_treecover(t,j,ac,type) Cropland tree cover per age class (mio. ha) ov29_treecover_penalty(t,j,type) Penalty for violation of treecover target (mio. USD05MER per yr) ov29_treecover_missing(t,j,type) Missing treecover area towards target (mio. ha) + ov29_cost_treecover_est(t,j,type) Establishment cost for cropland tree cover (mio. USD05MER per yr) + ov29_cost_treecover_recur(t,j,type) Recurring cost for cropland tree cover (mio. USD05MER per yr) + ov_fallow(t,j,type) Fallow land is temporarily fallow cropland (mio. ha) ov29_fallow_penalty(t,j,type) Penalty for violation of fallow target (mio. USD05MER per yr) ov29_fallow_missing(t,j,type) Missing fallow land towards target (mio. ha) oq29_cropland(t,j,type) Total cropland calculation (mio. ha) oq29_avl_cropland(t,j,type) Available cropland constraint (mio. ha) + oq29_cost_cropland(t,j,type) Costs and benefits related to agroforestry (mio. USD05MER per yr) oq29_carbon(t,j,ag_pools,stockType,type) Cropland above ground carbon content calculation (mio. tC) oq29_land_snv(t,j,type) Land constraint for the SNV policy in cropland areas (mio. ha) oq29_land_snv_trans(t,j,type) Land transition constraint for SNV policy in cropland areas (mio. ha) - oq29_cost_cropland(t,j,type) Costs and benefits related to agroforestry (mio. USD05MER per yr) - oq29_cost_treecover_est(t,j,type) Establishment cost for cropland tree cover (mio. USD05MER per yr) - oq29_cost_treecover_recur(t,j,type) Recurring cost for cropland tree cover (mio. USD05MER per yr) + oq29_fallow_shr(t,j,type) Fallow land minimum share (mio. ha) + oq29_fallow_penalty(t,j,type) Penalty for violation of fallow target (mio. USD05MER per yr) + oq29_fallow_missing(t,j,type) Missing fallow land towards target (mio. ha) + oq29_fallow_bv(t,j,potnatveg,type) Biodiversity value for fallow land (mio. ha) + oq29_treecover_shr(t,j,type) Cropland treecover minimum share (mio. ha) oq29_treecover_penalty(t,j,type) Penalty for violation of treecover target (mio. USD05MER per yr) oq29_treecover_missing(t,j,type) Missing treecover area towards target (mio. ha) - oq29_treecover_est(t,j,ac,type) Cropland treecover establishment (mio. ha) oq29_treecover_bv(t,j,potnatveg,type) Biodiversity value for cropland treecover (mio. ha) - oq29_fallow_bv(t,j,potnatveg,type) Biodiversity value for fallow land (mio. ha) - oq29_fallow_penalty(t,j,type) Penalty for violation of fallow target (mio. USD05MER per yr) - oq29_fallow_missing(t,j,type) Missing fallow land towards target (mio. ha) + oq29_cost_treecover_est(t,j,type) Establishment cost for cropland tree cover (mio. USD05MER per yr) + oq29_cost_treecover_recur(t,j,type) Recurring cost for cropland tree cover (mio. USD05MER per yr) + oq29_treecover_est(t,j,ac,type) Cropland treecover establishment (mio. ha) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/29_cropland/detail_apr24/equations.gms b/modules/29_cropland/detail_apr24/equations.gms new file mode 100644 index 0000000000..566441173f --- /dev/null +++ b/modules/29_cropland/detail_apr24/equations.gms @@ -0,0 +1,131 @@ +*** | (C) 2008-2024 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 +*' Total cropland is calculated as the sum of croparea, fallow land and tree cover area. + + q29_cropland(j2) .. + vm_land(j2,"crop") =e= sum((kcr,w), vm_area(j2,kcr,w)) + vm_fallow(j2) + sum(ac, v29_treecover(j2,ac)); + +*' We assume that crop production can only take place on suitable cropland area. +*' We use a suitability index (SI) map from @zabel_global_2014 to exclude areas +*' from cropland production that have a low suitability, e.g. due to steep slopes, +*' to estimate the available cropland area. The cultivated area therefore has +*' to be smaller than the available cropland area. Moreover, the available cropland +*' can be reduced by constraining the cropland area in favour of other land types, +*' in order to increase compositional heterogeneity of land types at the cell level. + + q29_avl_cropland(j2) .. + vm_land(j2,"crop") =l= sum(ct, p29_avl_cropland(ct,j2)); + + +*' Total cost for the cropland module. + + q29_cost_cropland(j2) .. + vm_cost_cropland(j2) =e= + v29_cost_treecover_est(j2) + v29_cost_treecover_recur(j2) + + v29_fallow_penalty(j2) + v29_treecover_penalty(j2); + + +*' The carbon stocks of total cropland are calculated as the sum of carbon stocks in +*' cropland, fallow land and tree cover area. + + q29_carbon(j2,ag_pools,stockType) .. + vm_carbon_stock(j2,"crop",ag_pools,stockType) =e= + vm_carbon_stock_croparea(j2,ag_pools) + + vm_fallow(j2) * sum(ct, fm_carbon_density(ct,j2,"crop",ag_pools)) + + m_carbon_stock_ac(v29_treecover,p29_carbon_density_ac,"ac","ac_sub"); + + +*' The semi-natural land constraint in cropland areas for sustaining critical regulating NCP +*' for agricultural production is added on top of land conserved for other reasons +*' (e.g. conservation of intact ecosystems or protection of biodiversity hotspots). + + q29_land_snv(j2) .. + sum(land_snv, vm_land(j2,land_snv)) =g= + sum(ct, p29_snv_shr(ct,j2)) * vm_land(j2,"crop") + + sum((ct,land_snv,consv_type), pm_land_conservation(ct,j2,land_snv,consv_type)); + +*' The semi-natural vegetation constraint for cropland areas has been suggested at the per square +*' kilometer scale. The amount of cropland requiring relocation has therefore been derived from +*' exogeneous high-resolution land cover information from the Copernicus Global Land Service +*' (@buchhorn_copernicus_2020). + + q29_land_snv_trans(j2) .. + sum(land_snv, vm_lu_transitions(j2,"crop",land_snv)) =g= sum(ct, p29_snv_relocation(ct,j2)); + + +*' In case of no penalty, fallow land is greater or equal a certain fraction of total cropland: + + q29_fallow_shr(j2)$(s29_implementation = 1) .. + vm_fallow(j2) =g= + sum(ct, i29_fallow_target(ct)) * vm_land(j2,"crop"); + +*' Otherwise, a penalty is applied for the violation of fallow land rules. +*' The penalty applies to the missing fallow land, i.e. where fallow land +*' is lower than a certain fraction of total cropland. + + q29_fallow_missing(j2)$(s29_implementation = 0) .. + v29_fallow_missing(j2) =g= + vm_land(j2,"crop") * sum(ct, i29_fallow_target(ct)) - vm_fallow(j2); + + q29_fallow_penalty(j2) .. + v29_fallow_penalty(j2) =e= + v29_fallow_missing(j2) * sum(ct, i29_fallow_penalty(ct)); + + +*' Fallow land biodiversity value is based on perennial crops. + + q29_fallow_bv(j2,potnatveg) .. + vm_bv(j2,"crop_fallow",potnatveg) =e= + vm_fallow(j2) * fm_bii_coeff("crop_per",potnatveg) * fm_luh2_side_layers(j2,potnatveg); + + +*' In case of no penalty, tree cover is greater or equal a certain fraction of total cropland. + + q29_treecover_shr(j2)$(s29_implementation = 1) .. + sum(ac, v29_treecover(j2,ac)) =g= + sum(ct, i29_treecover_target(ct,j2)) * vm_land(j2,"crop"); + +*' Otherwise, a penalty is applied for the violation of treecover rules. +*' The penalty applies to the missing treecover area, i.e. where treecover area +*' is lower than a certain fraction of total cropland. + + q29_treecover_missing(j2)$(s29_implementation = 0) .. + v29_treecover_missing(j2) =g= + vm_land(j2,"crop") * sum(ct, i29_treecover_target(ct,j2)) - sum(ac, v29_treecover(j2,ac)); + + q29_treecover_penalty(j2) .. + v29_treecover_penalty(j2) =e= + v29_treecover_missing(j2) * sum(ct, i29_treecover_penalty(ct)); + + +*' Depending on `s29_treecover_bii_coeff`, tree cover biodiversity value +*' is based on natural vegetation or plantation BII coefficients. + + q29_treecover_bv(j2,potnatveg) .. + vm_bv(j2,"crop_tree",potnatveg) =e= + sum(bii_class_secd, sum(ac_to_bii_class_secd(ac,bii_class_secd), v29_treecover(j2,ac)) * + p29_treecover_bii_coeff(bii_class_secd,potnatveg)) * fm_luh2_side_layers(j2,potnatveg); + +*' Cropland tree cover annuity cost. + + q29_cost_treecover_est(j2) .. + v29_cost_treecover_est(j2) =e= + sum(ac_est, v29_treecover(j2,ac_est)) * s29_cost_treecover_est * + sum((cell(i2,j2),ct),pm_interest(ct,i2)/(1+pm_interest(ct,i2))); + +*' Cropland tree cover recurring cost. + + q29_cost_treecover_recur(j2) .. + v29_cost_treecover_recur(j2) =e= + sum(ac_sub, v29_treecover(j2,ac_sub)) * s29_cost_treecover_recur; + +*' Cropland tree cover establishment rules. + + q29_treecover_est(j2,ac_est) .. + v29_treecover(j2,ac_est) =e= sum(ac_est2, v29_treecover(j2,ac_est2))/card(ac_est2); diff --git a/modules/29_cropland/penalty_apr24/input.gms b/modules/29_cropland/detail_apr24/input.gms similarity index 97% rename from modules/29_cropland/penalty_apr24/input.gms rename to modules/29_cropland/detail_apr24/input.gms index ad8d2a60e8..f2458f3ece 100644 --- a/modules/29_cropland/penalty_apr24/input.gms +++ b/modules/29_cropland/detail_apr24/input.gms @@ -28,6 +28,7 @@ scalars s29_fallow_scenario_target Fallow land scenario target year / 2050 / s29_fallow_target Target share of fallow land on total cropland (1) / 0.3 / s29_fallow_penalty Penalty for violation of fallow target (USD05MER per ha) / 500 / + s29_implementation Switch for rule-based (1) or penalty-based (0) implementation of fallow and treecover targets / 1 / ; diff --git a/modules/29_cropland/penalty_apr24/postsolve.gms b/modules/29_cropland/detail_apr24/postsolve.gms similarity index 93% rename from modules/29_cropland/penalty_apr24/postsolve.gms rename to modules/29_cropland/detail_apr24/postsolve.gms index 32b9181e7d..5070d341f2 100644 --- a/modules/29_cropland/penalty_apr24/postsolve.gms +++ b/modules/29_cropland/detail_apr24/postsolve.gms @@ -8,101 +8,109 @@ pc29_treecover(j,ac) = v29_treecover.l(j,ac); *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov_fallow(t,j,"marginal") = vm_fallow.m(j); - ov29_treecover(t,j,ac,"marginal") = v29_treecover.m(j,ac); ov_cost_cropland(t,j,"marginal") = vm_cost_cropland.m(j); - ov29_cost_treecover_est(t,j,"marginal") = v29_cost_treecover_est.m(j); - ov29_cost_treecover_recur(t,j,"marginal") = v29_cost_treecover_recur.m(j); + ov29_treecover(t,j,ac,"marginal") = v29_treecover.m(j,ac); ov29_treecover_penalty(t,j,"marginal") = v29_treecover_penalty.m(j); ov29_treecover_missing(t,j,"marginal") = v29_treecover_missing.m(j); + ov29_cost_treecover_est(t,j,"marginal") = v29_cost_treecover_est.m(j); + ov29_cost_treecover_recur(t,j,"marginal") = v29_cost_treecover_recur.m(j); + ov_fallow(t,j,"marginal") = vm_fallow.m(j); ov29_fallow_penalty(t,j,"marginal") = v29_fallow_penalty.m(j); ov29_fallow_missing(t,j,"marginal") = v29_fallow_missing.m(j); oq29_cropland(t,j,"marginal") = q29_cropland.m(j); oq29_avl_cropland(t,j,"marginal") = q29_avl_cropland.m(j); + oq29_cost_cropland(t,j,"marginal") = q29_cost_cropland.m(j); oq29_carbon(t,j,ag_pools,stockType,"marginal") = q29_carbon.m(j,ag_pools,stockType); oq29_land_snv(t,j,"marginal") = q29_land_snv.m(j); oq29_land_snv_trans(t,j,"marginal") = q29_land_snv_trans.m(j); - oq29_cost_cropland(t,j,"marginal") = q29_cost_cropland.m(j); - oq29_cost_treecover_est(t,j,"marginal") = q29_cost_treecover_est.m(j); - oq29_cost_treecover_recur(t,j,"marginal") = q29_cost_treecover_recur.m(j); + oq29_fallow_shr(t,j,"marginal") = q29_fallow_shr.m(j); + oq29_fallow_penalty(t,j,"marginal") = q29_fallow_penalty.m(j); + oq29_fallow_missing(t,j,"marginal") = q29_fallow_missing.m(j); + oq29_fallow_bv(t,j,potnatveg,"marginal") = q29_fallow_bv.m(j,potnatveg); + oq29_treecover_shr(t,j,"marginal") = q29_treecover_shr.m(j); oq29_treecover_penalty(t,j,"marginal") = q29_treecover_penalty.m(j); oq29_treecover_missing(t,j,"marginal") = q29_treecover_missing.m(j); - oq29_treecover_est(t,j,ac,"marginal") = q29_treecover_est.m(j,ac); oq29_treecover_bv(t,j,potnatveg,"marginal") = q29_treecover_bv.m(j,potnatveg); - oq29_fallow_bv(t,j,potnatveg,"marginal") = q29_fallow_bv.m(j,potnatveg); - oq29_fallow_penalty(t,j,"marginal") = q29_fallow_penalty.m(j); - oq29_fallow_missing(t,j,"marginal") = q29_fallow_missing.m(j); - ov_fallow(t,j,"level") = vm_fallow.l(j); - ov29_treecover(t,j,ac,"level") = v29_treecover.l(j,ac); + oq29_cost_treecover_est(t,j,"marginal") = q29_cost_treecover_est.m(j); + oq29_cost_treecover_recur(t,j,"marginal") = q29_cost_treecover_recur.m(j); + oq29_treecover_est(t,j,ac,"marginal") = q29_treecover_est.m(j,ac); ov_cost_cropland(t,j,"level") = vm_cost_cropland.l(j); - ov29_cost_treecover_est(t,j,"level") = v29_cost_treecover_est.l(j); - ov29_cost_treecover_recur(t,j,"level") = v29_cost_treecover_recur.l(j); + ov29_treecover(t,j,ac,"level") = v29_treecover.l(j,ac); ov29_treecover_penalty(t,j,"level") = v29_treecover_penalty.l(j); ov29_treecover_missing(t,j,"level") = v29_treecover_missing.l(j); + ov29_cost_treecover_est(t,j,"level") = v29_cost_treecover_est.l(j); + ov29_cost_treecover_recur(t,j,"level") = v29_cost_treecover_recur.l(j); + ov_fallow(t,j,"level") = vm_fallow.l(j); ov29_fallow_penalty(t,j,"level") = v29_fallow_penalty.l(j); ov29_fallow_missing(t,j,"level") = v29_fallow_missing.l(j); oq29_cropland(t,j,"level") = q29_cropland.l(j); oq29_avl_cropland(t,j,"level") = q29_avl_cropland.l(j); + oq29_cost_cropland(t,j,"level") = q29_cost_cropland.l(j); oq29_carbon(t,j,ag_pools,stockType,"level") = q29_carbon.l(j,ag_pools,stockType); oq29_land_snv(t,j,"level") = q29_land_snv.l(j); oq29_land_snv_trans(t,j,"level") = q29_land_snv_trans.l(j); - oq29_cost_cropland(t,j,"level") = q29_cost_cropland.l(j); - oq29_cost_treecover_est(t,j,"level") = q29_cost_treecover_est.l(j); - oq29_cost_treecover_recur(t,j,"level") = q29_cost_treecover_recur.l(j); + oq29_fallow_shr(t,j,"level") = q29_fallow_shr.l(j); + oq29_fallow_penalty(t,j,"level") = q29_fallow_penalty.l(j); + oq29_fallow_missing(t,j,"level") = q29_fallow_missing.l(j); + oq29_fallow_bv(t,j,potnatveg,"level") = q29_fallow_bv.l(j,potnatveg); + oq29_treecover_shr(t,j,"level") = q29_treecover_shr.l(j); oq29_treecover_penalty(t,j,"level") = q29_treecover_penalty.l(j); oq29_treecover_missing(t,j,"level") = q29_treecover_missing.l(j); - oq29_treecover_est(t,j,ac,"level") = q29_treecover_est.l(j,ac); oq29_treecover_bv(t,j,potnatveg,"level") = q29_treecover_bv.l(j,potnatveg); - oq29_fallow_bv(t,j,potnatveg,"level") = q29_fallow_bv.l(j,potnatveg); - oq29_fallow_penalty(t,j,"level") = q29_fallow_penalty.l(j); - oq29_fallow_missing(t,j,"level") = q29_fallow_missing.l(j); - ov_fallow(t,j,"upper") = vm_fallow.up(j); - ov29_treecover(t,j,ac,"upper") = v29_treecover.up(j,ac); + oq29_cost_treecover_est(t,j,"level") = q29_cost_treecover_est.l(j); + oq29_cost_treecover_recur(t,j,"level") = q29_cost_treecover_recur.l(j); + oq29_treecover_est(t,j,ac,"level") = q29_treecover_est.l(j,ac); ov_cost_cropland(t,j,"upper") = vm_cost_cropland.up(j); - ov29_cost_treecover_est(t,j,"upper") = v29_cost_treecover_est.up(j); - ov29_cost_treecover_recur(t,j,"upper") = v29_cost_treecover_recur.up(j); + ov29_treecover(t,j,ac,"upper") = v29_treecover.up(j,ac); ov29_treecover_penalty(t,j,"upper") = v29_treecover_penalty.up(j); ov29_treecover_missing(t,j,"upper") = v29_treecover_missing.up(j); + ov29_cost_treecover_est(t,j,"upper") = v29_cost_treecover_est.up(j); + ov29_cost_treecover_recur(t,j,"upper") = v29_cost_treecover_recur.up(j); + ov_fallow(t,j,"upper") = vm_fallow.up(j); ov29_fallow_penalty(t,j,"upper") = v29_fallow_penalty.up(j); ov29_fallow_missing(t,j,"upper") = v29_fallow_missing.up(j); oq29_cropland(t,j,"upper") = q29_cropland.up(j); oq29_avl_cropland(t,j,"upper") = q29_avl_cropland.up(j); + oq29_cost_cropland(t,j,"upper") = q29_cost_cropland.up(j); oq29_carbon(t,j,ag_pools,stockType,"upper") = q29_carbon.up(j,ag_pools,stockType); oq29_land_snv(t,j,"upper") = q29_land_snv.up(j); oq29_land_snv_trans(t,j,"upper") = q29_land_snv_trans.up(j); - oq29_cost_cropland(t,j,"upper") = q29_cost_cropland.up(j); - oq29_cost_treecover_est(t,j,"upper") = q29_cost_treecover_est.up(j); - oq29_cost_treecover_recur(t,j,"upper") = q29_cost_treecover_recur.up(j); + oq29_fallow_shr(t,j,"upper") = q29_fallow_shr.up(j); + oq29_fallow_penalty(t,j,"upper") = q29_fallow_penalty.up(j); + oq29_fallow_missing(t,j,"upper") = q29_fallow_missing.up(j); + oq29_fallow_bv(t,j,potnatveg,"upper") = q29_fallow_bv.up(j,potnatveg); + oq29_treecover_shr(t,j,"upper") = q29_treecover_shr.up(j); oq29_treecover_penalty(t,j,"upper") = q29_treecover_penalty.up(j); oq29_treecover_missing(t,j,"upper") = q29_treecover_missing.up(j); - oq29_treecover_est(t,j,ac,"upper") = q29_treecover_est.up(j,ac); oq29_treecover_bv(t,j,potnatveg,"upper") = q29_treecover_bv.up(j,potnatveg); - oq29_fallow_bv(t,j,potnatveg,"upper") = q29_fallow_bv.up(j,potnatveg); - oq29_fallow_penalty(t,j,"upper") = q29_fallow_penalty.up(j); - oq29_fallow_missing(t,j,"upper") = q29_fallow_missing.up(j); - ov_fallow(t,j,"lower") = vm_fallow.lo(j); - ov29_treecover(t,j,ac,"lower") = v29_treecover.lo(j,ac); + oq29_cost_treecover_est(t,j,"upper") = q29_cost_treecover_est.up(j); + oq29_cost_treecover_recur(t,j,"upper") = q29_cost_treecover_recur.up(j); + oq29_treecover_est(t,j,ac,"upper") = q29_treecover_est.up(j,ac); ov_cost_cropland(t,j,"lower") = vm_cost_cropland.lo(j); - ov29_cost_treecover_est(t,j,"lower") = v29_cost_treecover_est.lo(j); - ov29_cost_treecover_recur(t,j,"lower") = v29_cost_treecover_recur.lo(j); + ov29_treecover(t,j,ac,"lower") = v29_treecover.lo(j,ac); ov29_treecover_penalty(t,j,"lower") = v29_treecover_penalty.lo(j); ov29_treecover_missing(t,j,"lower") = v29_treecover_missing.lo(j); + ov29_cost_treecover_est(t,j,"lower") = v29_cost_treecover_est.lo(j); + ov29_cost_treecover_recur(t,j,"lower") = v29_cost_treecover_recur.lo(j); + ov_fallow(t,j,"lower") = vm_fallow.lo(j); ov29_fallow_penalty(t,j,"lower") = v29_fallow_penalty.lo(j); ov29_fallow_missing(t,j,"lower") = v29_fallow_missing.lo(j); oq29_cropland(t,j,"lower") = q29_cropland.lo(j); oq29_avl_cropland(t,j,"lower") = q29_avl_cropland.lo(j); + oq29_cost_cropland(t,j,"lower") = q29_cost_cropland.lo(j); oq29_carbon(t,j,ag_pools,stockType,"lower") = q29_carbon.lo(j,ag_pools,stockType); oq29_land_snv(t,j,"lower") = q29_land_snv.lo(j); oq29_land_snv_trans(t,j,"lower") = q29_land_snv_trans.lo(j); - oq29_cost_cropland(t,j,"lower") = q29_cost_cropland.lo(j); - oq29_cost_treecover_est(t,j,"lower") = q29_cost_treecover_est.lo(j); - oq29_cost_treecover_recur(t,j,"lower") = q29_cost_treecover_recur.lo(j); + oq29_fallow_shr(t,j,"lower") = q29_fallow_shr.lo(j); + oq29_fallow_penalty(t,j,"lower") = q29_fallow_penalty.lo(j); + oq29_fallow_missing(t,j,"lower") = q29_fallow_missing.lo(j); + oq29_fallow_bv(t,j,potnatveg,"lower") = q29_fallow_bv.lo(j,potnatveg); + oq29_treecover_shr(t,j,"lower") = q29_treecover_shr.lo(j); oq29_treecover_penalty(t,j,"lower") = q29_treecover_penalty.lo(j); oq29_treecover_missing(t,j,"lower") = q29_treecover_missing.lo(j); - oq29_treecover_est(t,j,ac,"lower") = q29_treecover_est.lo(j,ac); oq29_treecover_bv(t,j,potnatveg,"lower") = q29_treecover_bv.lo(j,potnatveg); - oq29_fallow_bv(t,j,potnatveg,"lower") = q29_fallow_bv.lo(j,potnatveg); - oq29_fallow_penalty(t,j,"lower") = q29_fallow_penalty.lo(j); - oq29_fallow_missing(t,j,"lower") = q29_fallow_missing.lo(j); + oq29_cost_treecover_est(t,j,"lower") = q29_cost_treecover_est.lo(j); + oq29_cost_treecover_recur(t,j,"lower") = q29_cost_treecover_recur.lo(j); + oq29_treecover_est(t,j,ac,"lower") = q29_treecover_est.lo(j,ac); *##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/29_cropland/penalty_apr24/preloop.gms b/modules/29_cropland/detail_apr24/preloop.gms similarity index 97% rename from modules/29_cropland/penalty_apr24/preloop.gms rename to modules/29_cropland/detail_apr24/preloop.gms index a7e39c8c8e..e245094629 100644 --- a/modules/29_cropland/penalty_apr24/preloop.gms +++ b/modules/29_cropland/detail_apr24/preloop.gms @@ -56,3 +56,8 @@ p29_country_dummy(policy_countries29) = 1; * Countries are weighted by available cropland area. i29_avl_cropland_iso(iso) = f29_avl_cropland_iso(iso,"%c29_marginal_land%"); p29_country_snv_weight(i) = sum(i_to_iso(i,iso), p29_country_dummy(iso) * i29_avl_cropland_iso(iso)) / sum(i_to_iso(i,iso), i29_avl_cropland_iso(iso)); + +if(s29_implementation = 1, + v29_treecover_missing.fx(j) = 0; + v29_fallow_missing.fx(j) = 0; +); diff --git a/modules/29_cropland/penalty_apr24/presolve.gms b/modules/29_cropland/detail_apr24/presolve.gms similarity index 100% rename from modules/29_cropland/penalty_apr24/presolve.gms rename to modules/29_cropland/detail_apr24/presolve.gms diff --git a/modules/29_cropland/detail_apr24/realization.gms b/modules/29_cropland/detail_apr24/realization.gms new file mode 100644 index 0000000000..071000bd1e --- /dev/null +++ b/modules/29_cropland/detail_apr24/realization.gms @@ -0,0 +1,31 @@ +*** | (C) 2008-2024 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 In this realization, total cropland equals the sum of croparea, +*' fallow land and tree cover on cropland. Correspondingly, cropland carbon stocks consist +*' of carbons stocks for croparea, fallow land and tree cover on cropland. +*' The development of fallow land and tree cover on cropland depends on targets defined +*' as a certain fraction of total cropland. These targets can be either exogenously enforced +*' (rule-based) or endogenously incentivized by a penalty term, which enters the objective function. + +*' This realisation also includes the option to reserve a minimum semi-natural +*' vegetation share within the total available cropland for other land cover +*' classes, including grassland, forest, and other land (by a given target year), +*' in order to provide species habitats and to benefit from ecosystem ervices in +*' agricultural landscapes. + +*' @limitations There are currently no known limitations of this realization. + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/29_cropland/detail_apr24/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/29_cropland/detail_apr24/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/29_cropland/detail_apr24/input.gms" +$Ifi "%phase%" == "equations" $include "./modules/29_cropland/detail_apr24/equations.gms" +$Ifi "%phase%" == "preloop" $include "./modules/29_cropland/detail_apr24/preloop.gms" +$Ifi "%phase%" == "presolve" $include "./modules/29_cropland/detail_apr24/presolve.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/29_cropland/detail_apr24/postsolve.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/29_cropland/penalty_apr24/sets.gms b/modules/29_cropland/detail_apr24/sets.gms similarity index 100% rename from modules/29_cropland/penalty_apr24/sets.gms rename to modules/29_cropland/detail_apr24/sets.gms diff --git a/modules/29_cropland/module.gms b/modules/29_cropland/module.gms index dc8cb77e50..e330dbc7e6 100644 --- a/modules/29_cropland/module.gms +++ b/modules/29_cropland/module.gms @@ -7,13 +7,14 @@ *' @title Cropland -*' @description Cropland is the sum of croparea, fallow land and tree cover. Croparea is provided from [30_crop]. -*' Fallow land and tree cover are defined in this module, either exogenous via prescribed rules or endognous via monetary incentives. +*' @description Cropland is defined as the sum of croparea, fallow land and tree cover on cropland. +*' Croparea and corresponding carbon stocks are provided from [30_crop]. +*' Area and carbon stocks for fallow land and tree cover are defined in this module. *' @authors Florian Humpenöder *###################### R SECTION START (MODULETYPES) ########################## -$Ifi "%cropland%" == "penalty_apr24" $include "./modules/29_cropland/penalty_apr24/realization.gms" -$Ifi "%cropland%" == "rulebased_apr24" $include "./modules/29_cropland/rulebased_apr24/realization.gms" +$Ifi "%cropland%" == "detail_apr24" $include "./modules/29_cropland/detail_apr24/realization.gms" +$Ifi "%cropland%" == "simple_apr24" $include "./modules/29_cropland/simple_apr24/realization.gms" *###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/29_cropland/penalty_apr24/equations.gms b/modules/29_cropland/penalty_apr24/equations.gms deleted file mode 100644 index 8bfe211a1f..0000000000 --- a/modules/29_cropland/penalty_apr24/equations.gms +++ /dev/null @@ -1,124 +0,0 @@ -*** | (C) 2008-2024 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 -*' Total cropland is calculated as the sum of croparea, fallow land and tree cover area. - - q29_cropland(j2) .. - vm_land(j2,"crop") =e= sum((kcr,w), vm_area(j2,kcr,w)) + vm_fallow(j2) + sum(ac, v29_treecover(j2,ac)); - -*' We assume that crop production can only take place on suitable cropland area. -*' We use a suitability index (SI) map from @zabel_global_2014 to exclude areas -*' from cropland production that have a low suitability, e.g. due to steep slopes, -*' to estimate the available cropland area. The cultivated area therefore has -*' to be smaller than the available cropland area. Moreover, the available cropland -*' can be reduced by constraining the cropland area in favour of other land types, -*' in order to increase compositional heterogeneity of land types at the cell level. - - q29_avl_cropland(j2) .. - vm_land(j2,"crop") =l= sum(ct, p29_avl_cropland(ct,j2)); - - -*' Total costs for the cropland module: - -q29_cost_cropland(j2) .. - vm_cost_cropland(j2) =e= - v29_cost_treecover_est(j2) + v29_cost_treecover_recur(j2) - + v29_fallow_penalty(j2) + v29_treecover_penalty(j2); - - -*' The carbon stocks of total cropland are calculated as the sum of carbon stocks in -*' cropland, fallow land and tree cover area. - - q29_carbon(j2,ag_pools,stockType) .. - vm_carbon_stock(j2,"crop",ag_pools,stockType) =e= - vm_carbon_stock_croparea(j2,ag_pools) - + vm_fallow(j2) * sum(ct, fm_carbon_density(ct,j2,"crop",ag_pools)) - + m_carbon_stock_ac(v29_treecover,p29_carbon_density_ac,"ac","ac_sub"); - - -*' The semi-natural land constraint in cropland areas for sustaining critical regulating NCP -*' for agricultural production is added on top of land conserved for other reasons -*' (e.g. conservation of intact ecosystems or protection of biodiversity hotspots). - - q29_land_snv(j2) .. - sum(land_snv, vm_land(j2,land_snv)) - =g= - sum(ct, p29_snv_shr(ct,j2)) * vm_land(j2,"crop") - + sum((ct,land_snv,consv_type), pm_land_conservation(ct,j2,land_snv,consv_type)); - -*' The semi-natural vegetation constraint for cropland areas has been suggested at the per square -*' kilometer scale. The amount of cropland requiring relocation has therefore been derived from -*' exogeneous high-resolution land cover information from the Copernicus Global Land Service -*' (@buchhorn_copernicus_2020). - - q29_land_snv_trans(j2) .. - sum(land_snv, vm_lu_transitions(j2,"crop",land_snv)) =g= sum(ct, p29_snv_relocation(ct,j2)); - - -*' A penalty is applied for the violation of fallow land rules. - -q29_fallow_penalty(j2) .. - v29_fallow_penalty(j2) - =g= - v29_fallow_missing(j2) * sum(ct, i29_fallow_penalty(ct)); - -*' The penalty applies to the missing fallow land, i.e. where fallow land -*' is lower than a certain fraction of total cropland. - - q29_fallow_missing(j2) .. - v29_fallow_missing(j2) - =g= - vm_land(j2,"crop") * sum(ct, i29_fallow_target(ct)) - vm_fallow(j2); - -*' Fallow land biodiversity value: - -q29_fallow_bv(j2,potnatveg) .. - vm_bv(j2,"crop_fallow",potnatveg) =e= - vm_fallow(j2) * fm_bii_coeff("crop_per",potnatveg) * fm_luh2_side_layers(j2,potnatveg); - - -*' A penalty is applied for the violation of treecover rules. - -q29_treecover_penalty(j2) .. - v29_treecover_penalty(j2) - =g= - v29_treecover_missing(j2) * sum(ct, i29_treecover_penalty(ct)); - -*' The penalty applies to the missing treecover area, i.e. where treecover area -*' is lower than a certain fraction of total cropland. - - q29_treecover_missing(j2) .. - v29_treecover_missing(j2) - =g= - vm_land(j2,"crop") * sum(ct, i29_treecover_target(ct,j2)) - sum(ac, v29_treecover(j2,ac)); - - -*' Cropland tree cover biodiversity value: - -q29_treecover_bv(j2,potnatveg) .. - vm_bv(j2,"crop_tree",potnatveg) =e= - sum(bii_class_secd, sum(ac_to_bii_class_secd(ac,bii_class_secd), v29_treecover(j2,ac)) * - p29_treecover_bii_coeff(bii_class_secd,potnatveg)) * fm_luh2_side_layers(j2,potnatveg); - -*' Cropland tree cover annuity cost - -q29_cost_treecover_est(j2) .. - v29_cost_treecover_est(j2) =e= - sum(ac_est, v29_treecover(j2,ac_est)) * s29_cost_treecover_est * - sum((cell(i2,j2),ct),pm_interest(ct,i2)/(1+pm_interest(ct,i2))); - -*' Cropland tree cover recurring cost - -q29_cost_treecover_recur(j2) .. - v29_cost_treecover_recur(j2) =e= - sum(ac_sub, v29_treecover(j2,ac_sub)) * s29_cost_treecover_recur; - -*' Cropland tree cover establishment rules: - -q29_treecover_est(j2,ac_est) .. - v29_treecover(j2,ac_est) =e= sum(ac_est2, v29_treecover(j2,ac_est2))/card(ac_est2); diff --git a/modules/29_cropland/penalty_apr24/realization.gms b/modules/29_cropland/penalty_apr24/realization.gms deleted file mode 100644 index 3eaac0d2d8..0000000000 --- a/modules/29_cropland/penalty_apr24/realization.gms +++ /dev/null @@ -1,20 +0,0 @@ -*** | (C) 2008-2024 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 todo - -*' @limitations todo - -*####################### R SECTION START (PHASES) ############################## -$Ifi "%phase%" == "sets" $include "./modules/29_cropland/penalty_apr24/sets.gms" -$Ifi "%phase%" == "declarations" $include "./modules/29_cropland/penalty_apr24/declarations.gms" -$Ifi "%phase%" == "input" $include "./modules/29_cropland/penalty_apr24/input.gms" -$Ifi "%phase%" == "equations" $include "./modules/29_cropland/penalty_apr24/equations.gms" -$Ifi "%phase%" == "preloop" $include "./modules/29_cropland/penalty_apr24/preloop.gms" -$Ifi "%phase%" == "presolve" $include "./modules/29_cropland/penalty_apr24/presolve.gms" -$Ifi "%phase%" == "postsolve" $include "./modules/29_cropland/penalty_apr24/postsolve.gms" -*######################## R SECTION END (PHASES) ############################### diff --git a/modules/29_cropland/rulebased_apr24/declarations.gms b/modules/29_cropland/rulebased_apr24/declarations.gms deleted file mode 100644 index bb538f8803..0000000000 --- a/modules/29_cropland/rulebased_apr24/declarations.gms +++ /dev/null @@ -1,82 +0,0 @@ -*** | (C) 2008-2024 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 - s29_shift number of 5-year age-classes corresponding to current time step length (1) -; - - -parameters - p29_avl_cropland(t,j) Total available land for crop cultivation (mio. ha) - p29_country_snv_weight(i) SNV policy country weight per region (1) - p29_snv_shr(t,j) Share of semi-natural vegetation in cropland areas (1) - i29_snv_relocation_target(j) Overall cropland area that requires relocation due to SNV policy (mio. ha) - p29_snv_relocation(t,j) Cropland area that is actually relocated during time step (mio. ha) - p29_max_snv_relocation(t,j) Maximum cropland relocation during time step (mio. ha) - p29_country_dummy(iso) Dummy parameter indicating whether country is affected by selected cropland policy (1) - i29_avl_cropland_iso(iso) Available land area for cropland at ISO level (mio. ha) - i29_snv_scenario_fader(t_all) SNV scenario fader (1) - - i29_treecover_scenario_fader(t_all) Cropland treecover scenario fader (1) - i29_treecover_target(t,j) Target share for treecover on total cropland (1) - - p29_treecover_bii_coeff(bii_class_secd,potnatveg) BII coefficient for cropland treecover (1) - p29_carbon_density_ac(t,j,ac,ag_pools) Carbon density for ac and ag_pools (tC per ha) - p29_treecover(t,j,ac) Cropland tree cover per age class (mio. ha) - pc29_treecover(j,ac) Cropland tree cover per age class in current time step (mio. ha) - - i29_fallow_scenario_fader(t_all) Fallow land scenario fader (1) - i29_fallow_target(t_all) Target share for fallow land on total cropland (1) -; - -positive variables - vm_fallow(j) Fallow land is temporarily fallow cropland (mio. ha) - v29_treecover(j,ac) Cropland tree cover per age class (mio. ha) - vm_cost_cropland(j) Cost for total cropland (mio. USD05MER per yr) - v29_cost_treecover_est(j) Establishment cost for cropland tree cover (mio. USD05MER per yr) - v29_cost_treecover_recur(j) Recurring cost for cropland tree cover (mio. USD05MER per yr) -; - -equations - q29_cropland(j) Total cropland calculation (mio. ha) - q29_avl_cropland(j) Available cropland constraint (mio. ha) - q29_carbon(j,ag_pools,stockType) Cropland above ground carbon content calculation (mio. tC) - q29_land_snv(j) Land constraint for the SNV policy in cropland areas (mio. ha) - q29_land_snv_trans(j) Land transition constraint for SNV policy in cropland areas (mio. ha) - q29_cost_cropland(j) Costs and benefits related to agroforestry (mio. USD05MER per yr) - q29_cost_treecover_est(j) Establishment cost for cropland tree cover (mio. USD05MER per yr) - q29_cost_treecover_recur(j) Recurring cost for cropland tree cover (mio. USD05MER per yr) - q29_fallow_shr(j) Fallow land minimum share (mio. ha) - q29_treecover_shr(j) Cropland treecover minimum share (mio. ha) - q29_treecover_est(j,ac) Cropland treecover establishment (mio. ha) - q29_treecover_bv(j,potnatveg) Biodiversity value for cropland treecover (mio. ha) - q29_fallow_bv(j,potnatveg) Biodiversity value for fallow land (mio. ha) -; - -*#################### R SECTION START (OUTPUT DECLARATIONS) #################### -parameters - ov_fallow(t,j,type) Fallow land is temporarily fallow cropland (mio. ha) - ov29_treecover(t,j,ac,type) Cropland tree cover per age class (mio. ha) - ov_cost_cropland(t,j,type) Cost for total cropland (mio. USD05MER per yr) - ov29_cost_treecover_est(t,j,type) Establishment cost for cropland tree cover (mio. USD05MER per yr) - ov29_cost_treecover_recur(t,j,type) Recurring cost for cropland tree cover (mio. USD05MER per yr) - oq29_cropland(t,j,type) Total cropland calculation (mio. ha) - oq29_avl_cropland(t,j,type) Available cropland constraint (mio. ha) - oq29_carbon(t,j,ag_pools,stockType,type) Cropland above ground carbon content calculation (mio. tC) - oq29_land_snv(t,j,type) Land constraint for the SNV policy in cropland areas (mio. ha) - oq29_land_snv_trans(t,j,type) Land transition constraint for SNV policy in cropland areas (mio. ha) - oq29_cost_cropland(t,j,type) Costs and benefits related to agroforestry (mio. USD05MER per yr) - oq29_cost_treecover_est(t,j,type) Establishment cost for cropland tree cover (mio. USD05MER per yr) - oq29_cost_treecover_recur(t,j,type) Recurring cost for cropland tree cover (mio. USD05MER per yr) - oq29_fallow_shr(t,j,type) Fallow land minimum share (mio. ha) - oq29_treecover_shr(t,j,type) Cropland treecover minimum share (mio. ha) - oq29_treecover_est(t,j,ac,type) Cropland treecover establishment (mio. ha) - oq29_treecover_bv(t,j,potnatveg,type) Biodiversity value for cropland treecover (mio. ha) - oq29_fallow_bv(t,j,potnatveg,type) Biodiversity value for fallow land (mio. ha) -; -*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### - diff --git a/modules/29_cropland/rulebased_apr24/equations.gms b/modules/29_cropland/rulebased_apr24/equations.gms deleted file mode 100644 index 88f7bb1ab4..0000000000 --- a/modules/29_cropland/rulebased_apr24/equations.gms +++ /dev/null @@ -1,104 +0,0 @@ -*** | (C) 2008-2024 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 -*' Total cropland is calculated as the sum of croparea, fallow land and tree cover area. - - q29_cropland(j2) .. - vm_land(j2,"crop") =e= sum((kcr,w), vm_area(j2,kcr,w)) + vm_fallow(j2) + sum(ac, v29_treecover(j2,ac)); - -*' We assume that crop production can only take place on suitable cropland area. -*' We use a suitability index (SI) map from @zabel_global_2014 to exclude areas -*' from cropland production that have a low suitability, e.g. due to steep slopes, -*' to estimate the available cropland area. The cultivated area therefore has -*' to be smaller than the available cropland area. Moreover, the available cropland -*' can be reduced by constraining the cropland area in favour of other land types, -*' in order to increase compositional heterogeneity of land types at the cell level. - - q29_avl_cropland(j2) .. - vm_land(j2,"crop") =l= sum(ct, p29_avl_cropland(ct,j2)); - - -*' Total costs for the cropland module: - -q29_cost_cropland(j2) .. - vm_cost_cropland(j2) =e= - v29_cost_treecover_est(j2) + v29_cost_treecover_recur(j2); - - -*' The carbon stocks of total cropland are calculated as the sum of carbon stocks in -*' cropland, fallow land and tree cover area. - - q29_carbon(j2,ag_pools,stockType) .. - vm_carbon_stock(j2,"crop",ag_pools,stockType) =e= - vm_carbon_stock_croparea(j2,ag_pools) - + vm_fallow(j2) * sum(ct, fm_carbon_density(ct,j2,"crop",ag_pools)) - + m_carbon_stock_ac(v29_treecover,p29_carbon_density_ac,"ac","ac_sub"); - - -*' The semi-natural land constraint in cropland areas for sustaining critical regulating NCP -*' for agricultural production is added on top of land conserved for other reasons -*' (e.g. conservation of intact ecosystems or protection of biodiversity hotspots). - - q29_land_snv(j2) .. - sum(land_snv, vm_land(j2,land_snv)) - =g= - sum(ct, p29_snv_shr(ct,j2)) * vm_land(j2,"crop") - + sum((ct,land_snv,consv_type), pm_land_conservation(ct,j2,land_snv,consv_type)); - -*' The semi-natural vegetation constraint for cropland areas has been suggested at the per square -*' kilometer scale. The amount of cropland requiring relocation has therefore been derived from -*' exogeneous high-resolution land cover information from the Copernicus Global Land Service -*' (@buchhorn_copernicus_2020). - - q29_land_snv_trans(j2) .. - sum(land_snv, vm_lu_transitions(j2,"crop",land_snv)) =g= sum(ct, p29_snv_relocation(ct,j2)); - - -*' Fallow land is greater or equal a certain share of total cropland: - -q29_fallow_shr(j2) .. - vm_fallow(j2) =g= - sum(ct, i29_fallow_target(ct)) * vm_land(j2,"crop"); - -*' Fallow land biodiversity value: - -q29_fallow_bv(j2,potnatveg) .. - vm_bv(j2,"crop_fallow",potnatveg) =e= - vm_fallow(j2) * fm_bii_coeff("crop_per",potnatveg) * fm_luh2_side_layers(j2,potnatveg); - - -*' Cropland tree cover is greater or equal a certain share of total cropland: - -q29_treecover_shr(j2) .. - sum(ac, v29_treecover(j2,ac)) =g= - sum(ct, i29_treecover_target(ct,j2)) * vm_land(j2,"crop"); - -*' Cropland tree cover biodiversity value: - -q29_treecover_bv(j2,potnatveg) .. - vm_bv(j2,"crop_tree",potnatveg) =e= - sum(bii_class_secd, sum(ac_to_bii_class_secd(ac,bii_class_secd), v29_treecover(j2,ac)) * - p29_treecover_bii_coeff(bii_class_secd,potnatveg)) * fm_luh2_side_layers(j2,potnatveg); - -*' Cropland tree cover annuity cost - -q29_cost_treecover_est(j2) .. - v29_cost_treecover_est(j2) =e= - sum(ac_est, v29_treecover(j2,ac_est)) * s29_cost_treecover_est * - sum((cell(i2,j2),ct),pm_interest(ct,i2)/(1+pm_interest(ct,i2))); - -*' Cropland tree cover recurring cost - -q29_cost_treecover_recur(j2) .. - v29_cost_treecover_recur(j2) =e= - sum(ac_sub, v29_treecover(j2,ac_sub)) * s29_cost_treecover_recur; - -*' Cropland tree cover establishment rules: - -q29_treecover_est(j2,ac_est) .. - v29_treecover(j2,ac_est) =e= sum(ac_est2, v29_treecover(j2,ac_est2))/card(ac_est2); diff --git a/modules/29_cropland/rulebased_apr24/input.gms b/modules/29_cropland/rulebased_apr24/input.gms deleted file mode 100644 index 232c4ceabc..0000000000 --- a/modules/29_cropland/rulebased_apr24/input.gms +++ /dev/null @@ -1,94 +0,0 @@ -*** | (C) 2008-2024 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 - -$setglobal c29_marginal_land q33_marginal -* options: all_marginal, q33_marginal, no_marginal - -scalars - s29_snv_shr Share of available cropland that is witheld for other land cover types (1) / 0 / - s29_snv_shr_noselect Share of available cropland that is witheld for other land cover types (1) / 0 / - s29_snv_scenario_start SNV scenario start year / 2020 / - s29_snv_scenario_target SNV scenario target year / 2029 / - s29_snv_relocation_data_x1 First reference value in SNV target cropland data (1) / 0.2 / - s29_snv_relocation_data_x2 Second reference value in SNV target cropland data (1) / 0.5 / - s29_cost_treecover_est Tree cover establishment cost (USD05MER per ha) / 2000 / - s29_cost_treecover_recur Tree cover recurring cost (USD05MER per ha) / 500 / - s29_treecover_plantation Growth curve switch for tree cover on cropland 0=natveg 1=plantations (1) / 0 / - s29_treecover_bii_coeff BII coefficent to be used for tree cover on cropland 0=secondary vegetation 1=timber plantations (1) / 0 / - s29_treecover_decrease Cropland treecover can decrease (1) or not (0) / 0 / - s29_treecover_scenario_start Cropland treecover scenario start year / 2020 / - s29_treecover_scenario_target Cropland treecover scenario target year / 2050 / - s29_treecover_target Target share of treecover on total cropland (1) / 0.3 / - s29_fallow_scenario_start Fallow land scenario start year / 2020 / - s29_fallow_scenario_target Fallow land scenario target year / 2050 / - s29_fallow_target Target share of fallow land on total cropland (1) / 0.3 / -; - - -* Set-switch for countries affected by regional SNV policy -* Default: all iso countries selected -sets - policy_countries29(iso) countries to be affected by SNV policy / ABW,AFG,AGO,AIA,ALA,ALB,AND,ARE,ARG,ARM, - ASM,ATA,ATF,ATG,AUS,AUT,AZE,BDI,BEL,BEN, - BES,BFA,BGD,BGR,BHR,BHS,BIH,BLM,BLR,BLZ, - BMU,BOL,BRA,BRB,BRN,BTN,BVT,BWA,CAF,CAN, - CCK,CHN,CHE,CHL,CIV,CMR,COD,COG,COK,COL, - COM,CPV,CRI,CUB,CUW,CXR,CYM,CYP,CZE,DEU, - DJI,DMA,DNK,DOM,DZA,ECU,EGY,ERI,ESH,ESP, - EST,ETH,FIN,FJI,FLK,FRA,FRO,FSM,GAB,GBR, - GEO,GGY,GHA,GIB,GIN,GLP,GMB,GNB,GNQ,GRC, - GRD,GRL,GTM,GUF,GUM,GUY,HKG,HMD,HND,HRV, - HTI,HUN,IDN,IMN,IND,IOT,IRL,IRN,IRQ,ISL, - ISR,ITA,JAM,JEY,JOR,JPN,KAZ,KEN,KGZ,KHM, - KIR,KNA,KOR,KWT,LAO,LBN,LBR,LBY,LCA,LIE, - LKA,LSO,LTU,LUX,LVA,MAC,MAF,MAR,MCO,MDA, - MDG,MDV,MEX,MHL,MKD,MLI,MLT,MMR,MNE,MNG, - MNP,MOZ,MRT,MSR,MTQ,MUS,MWI,MYS,MYT,NAM, - NCL,NER,NFK,NGA,NIC,NIU,NLD,NOR,NPL,NRU, - NZL,OMN,PAK,PAN,PCN,PER,PHL,PLW,PNG,POL, - PRI,PRK,PRT,PRY,PSE,PYF,QAT,REU,ROU,RUS, - RWA,SAU,SDN,SEN,SGP,SGS,SHN,SJM,SLB,SLE, - SLV,SMR,SOM,SPM,SRB,SSD,STP,SUR,SVK,SVN, - SWE,SWZ,SXM,SYC,SYR,TCA,TCD,TGO,THA,TJK, - TKL,TKM,TLS,TON,TTO,TUN,TUR,TUV,TWN,TZA, - UGA,UKR,UMI,URY,USA,UZB,VAT,VCT,VEN,VGB, - VIR,VNM,VUT,WLF,WSM,YEM,ZAF,ZMB,ZWE / - -land_snv(land) land types allowed in the SNV policy / secdforest, forestry, past, other / -; - -********* AVAILABLE CROPLAND ******************************************* - -table f29_avl_cropland(j,marginal_land29) Available land area for cropland (mio. ha) -$ondelim -$include "./modules/29_cropland/input/avl_cropland.cs3" -$offdelim -; - -table f29_avl_cropland_iso(iso,marginal_land29) Available land area for cropland at ISO level (mio. ha) -$ondelim -$include "./modules/29_cropland/input/avl_cropland_iso.cs3" -$offdelim -; - -********* SNV TARGET CROPLAND ******************************************* - -table f29_snv_target_cropland(j,relocation_target29) Cropland in 2019 requiring relocation due to SNV policy (mio. ha) -$ondelim -$include "./modules/29_cropland/input/SNVTargetCropland.cs3" -$offdelim -; - -********* Cropland tree cover ******************************************* - -parameter f29_treecover(j) Tree cover on cropland in 2019 (mio. ha) -/ -$ondelim -$include "./modules/29_cropland/input/CroplandTreecover.cs2" -$offdelim -/ -; diff --git a/modules/29_cropland/rulebased_apr24/postsolve.gms b/modules/29_cropland/rulebased_apr24/postsolve.gms deleted file mode 100644 index 60c46e7c92..0000000000 --- a/modules/29_cropland/rulebased_apr24/postsolve.gms +++ /dev/null @@ -1,84 +0,0 @@ -*** | (C) 2008-2024 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 - -pc29_treecover(j,ac) = v29_treecover.l(j,ac); - -*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov_fallow(t,j,"marginal") = vm_fallow.m(j); - ov29_treecover(t,j,ac,"marginal") = v29_treecover.m(j,ac); - ov_cost_cropland(t,j,"marginal") = vm_cost_cropland.m(j); - ov29_cost_treecover_est(t,j,"marginal") = v29_cost_treecover_est.m(j); - ov29_cost_treecover_recur(t,j,"marginal") = v29_cost_treecover_recur.m(j); - oq29_cropland(t,j,"marginal") = q29_cropland.m(j); - oq29_avl_cropland(t,j,"marginal") = q29_avl_cropland.m(j); - oq29_carbon(t,j,ag_pools,stockType,"marginal") = q29_carbon.m(j,ag_pools,stockType); - oq29_land_snv(t,j,"marginal") = q29_land_snv.m(j); - oq29_land_snv_trans(t,j,"marginal") = q29_land_snv_trans.m(j); - oq29_cost_cropland(t,j,"marginal") = q29_cost_cropland.m(j); - oq29_cost_treecover_est(t,j,"marginal") = q29_cost_treecover_est.m(j); - oq29_cost_treecover_recur(t,j,"marginal") = q29_cost_treecover_recur.m(j); - oq29_fallow_shr(t,j,"marginal") = q29_fallow_shr.m(j); - oq29_treecover_shr(t,j,"marginal") = q29_treecover_shr.m(j); - oq29_treecover_est(t,j,ac,"marginal") = q29_treecover_est.m(j,ac); - oq29_treecover_bv(t,j,potnatveg,"marginal") = q29_treecover_bv.m(j,potnatveg); - oq29_fallow_bv(t,j,potnatveg,"marginal") = q29_fallow_bv.m(j,potnatveg); - ov_fallow(t,j,"level") = vm_fallow.l(j); - ov29_treecover(t,j,ac,"level") = v29_treecover.l(j,ac); - ov_cost_cropland(t,j,"level") = vm_cost_cropland.l(j); - ov29_cost_treecover_est(t,j,"level") = v29_cost_treecover_est.l(j); - ov29_cost_treecover_recur(t,j,"level") = v29_cost_treecover_recur.l(j); - oq29_cropland(t,j,"level") = q29_cropland.l(j); - oq29_avl_cropland(t,j,"level") = q29_avl_cropland.l(j); - oq29_carbon(t,j,ag_pools,stockType,"level") = q29_carbon.l(j,ag_pools,stockType); - oq29_land_snv(t,j,"level") = q29_land_snv.l(j); - oq29_land_snv_trans(t,j,"level") = q29_land_snv_trans.l(j); - oq29_cost_cropland(t,j,"level") = q29_cost_cropland.l(j); - oq29_cost_treecover_est(t,j,"level") = q29_cost_treecover_est.l(j); - oq29_cost_treecover_recur(t,j,"level") = q29_cost_treecover_recur.l(j); - oq29_fallow_shr(t,j,"level") = q29_fallow_shr.l(j); - oq29_treecover_shr(t,j,"level") = q29_treecover_shr.l(j); - oq29_treecover_est(t,j,ac,"level") = q29_treecover_est.l(j,ac); - oq29_treecover_bv(t,j,potnatveg,"level") = q29_treecover_bv.l(j,potnatveg); - oq29_fallow_bv(t,j,potnatveg,"level") = q29_fallow_bv.l(j,potnatveg); - ov_fallow(t,j,"upper") = vm_fallow.up(j); - ov29_treecover(t,j,ac,"upper") = v29_treecover.up(j,ac); - ov_cost_cropland(t,j,"upper") = vm_cost_cropland.up(j); - ov29_cost_treecover_est(t,j,"upper") = v29_cost_treecover_est.up(j); - ov29_cost_treecover_recur(t,j,"upper") = v29_cost_treecover_recur.up(j); - oq29_cropland(t,j,"upper") = q29_cropland.up(j); - oq29_avl_cropland(t,j,"upper") = q29_avl_cropland.up(j); - oq29_carbon(t,j,ag_pools,stockType,"upper") = q29_carbon.up(j,ag_pools,stockType); - oq29_land_snv(t,j,"upper") = q29_land_snv.up(j); - oq29_land_snv_trans(t,j,"upper") = q29_land_snv_trans.up(j); - oq29_cost_cropland(t,j,"upper") = q29_cost_cropland.up(j); - oq29_cost_treecover_est(t,j,"upper") = q29_cost_treecover_est.up(j); - oq29_cost_treecover_recur(t,j,"upper") = q29_cost_treecover_recur.up(j); - oq29_fallow_shr(t,j,"upper") = q29_fallow_shr.up(j); - oq29_treecover_shr(t,j,"upper") = q29_treecover_shr.up(j); - oq29_treecover_est(t,j,ac,"upper") = q29_treecover_est.up(j,ac); - oq29_treecover_bv(t,j,potnatveg,"upper") = q29_treecover_bv.up(j,potnatveg); - oq29_fallow_bv(t,j,potnatveg,"upper") = q29_fallow_bv.up(j,potnatveg); - ov_fallow(t,j,"lower") = vm_fallow.lo(j); - ov29_treecover(t,j,ac,"lower") = v29_treecover.lo(j,ac); - ov_cost_cropland(t,j,"lower") = vm_cost_cropland.lo(j); - ov29_cost_treecover_est(t,j,"lower") = v29_cost_treecover_est.lo(j); - ov29_cost_treecover_recur(t,j,"lower") = v29_cost_treecover_recur.lo(j); - oq29_cropland(t,j,"lower") = q29_cropland.lo(j); - oq29_avl_cropland(t,j,"lower") = q29_avl_cropland.lo(j); - oq29_carbon(t,j,ag_pools,stockType,"lower") = q29_carbon.lo(j,ag_pools,stockType); - oq29_land_snv(t,j,"lower") = q29_land_snv.lo(j); - oq29_land_snv_trans(t,j,"lower") = q29_land_snv_trans.lo(j); - oq29_cost_cropland(t,j,"lower") = q29_cost_cropland.lo(j); - oq29_cost_treecover_est(t,j,"lower") = q29_cost_treecover_est.lo(j); - oq29_cost_treecover_recur(t,j,"lower") = q29_cost_treecover_recur.lo(j); - oq29_fallow_shr(t,j,"lower") = q29_fallow_shr.lo(j); - oq29_treecover_shr(t,j,"lower") = q29_treecover_shr.lo(j); - oq29_treecover_est(t,j,ac,"lower") = q29_treecover_est.lo(j,ac); - oq29_treecover_bv(t,j,potnatveg,"lower") = q29_treecover_bv.lo(j,potnatveg); - oq29_fallow_bv(t,j,potnatveg,"lower") = q29_fallow_bv.lo(j,potnatveg); -*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### - diff --git a/modules/29_cropland/rulebased_apr24/preloop.gms b/modules/29_cropland/rulebased_apr24/preloop.gms deleted file mode 100644 index cc295eccf7..0000000000 --- a/modules/29_cropland/rulebased_apr24/preloop.gms +++ /dev/null @@ -1,57 +0,0 @@ -*** | (C) 2008-2024 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 - -** Trajectory for cropland scenarios -* sigmoidal interpolation between start year and target year -m_sigmoid_time_interpol(i29_snv_scenario_fader,s29_snv_scenario_start,s29_snv_scenario_target,0,1); -m_sigmoid_time_interpol(i29_treecover_scenario_fader,s29_treecover_scenario_start,s29_treecover_scenario_target,0,1); -m_sigmoid_time_interpol(i29_fallow_scenario_fader,s29_fallow_scenario_start,s29_fallow_scenario_target,0,1); - -* linear interpolation to estimate the cropland that -* requires relocation due to SNV policy -if (s29_snv_shr = 0, - i29_snv_relocation_target(j) = 0; -elseif s29_snv_shr <= s29_snv_relocation_data_x1, - m_linear_cell_data_interpol(i29_snv_relocation_target, s29_snv_shr,0,s29_snv_relocation_data_x1,0, f29_snv_target_cropland(j, "SNV20TargetCropland")); -elseif s29_snv_shr > s29_snv_relocation_data_x1, - m_linear_cell_data_interpol(i29_snv_relocation_target, s29_snv_shr,s29_snv_relocation_data_x1, s29_snv_relocation_data_x2,f29_snv_target_cropland(j, "SNV20TargetCropland"), f29_snv_target_cropland(j, "SNV50TargetCropland")); -); - -* Initial tree cover on cropland is assumed to be equally distributed among all age-classes -pc29_treecover(j,ac) = 0; -pc29_treecover(j,ac)$(pm_land_hist("y2015",j,"crop") > 1e-10) = - (f29_treecover(j) / pm_land_hist("y2015",j,"crop") * pm_land_hist("y1995",j,"crop")) / card(ac); - - -*' Switch for tree cover on cropland: -*' 0 = Use natveg growth curve towards LPJmL natural vegetation -*' 1 = Use plantation growth curve (faster than natveg) towards LPJmL natural vegetation -if(s29_treecover_plantation = 0, - p29_carbon_density_ac(t,j,ac,ag_pools) = pm_carbon_density_ac(t,j,ac,ag_pools); -elseif s29_treecover_plantation = 1, - p29_carbon_density_ac(t,j,ac,ag_pools) = pm_carbon_density_ac_forestry(t,j,ac,ag_pools); -); - -** set bii coefficients -p29_treecover_bii_coeff(bii_class_secd,potnatveg) = 0; -if(s29_treecover_bii_coeff = 0, - p29_treecover_bii_coeff(bii_class_secd,potnatveg) = fm_bii_coeff(bii_class_secd,potnatveg) -elseif s29_treecover_bii_coeff = 1, - p29_treecover_bii_coeff(bii_class_secd,potnatveg) = fm_bii_coeff("timber",potnatveg) -); - - -****** Regional share of semi-natural vegetation (SNV) in cropland areas for selective countries: -* Country switch to determine countries for which a SNV policy shall be applied. -* In the default case, the SNV policy affects all countries when activated. -p29_country_dummy(iso) = 0; -p29_country_dummy(policy_countries29) = 1; -* Because MAgPIE is not run at country-level, but at region level, a region -* share is calculated that translates the countries' influence to regional level. -* Countries are weighted by available cropland area. -i29_avl_cropland_iso(iso) = f29_avl_cropland_iso(iso,"%c29_marginal_land%"); -p29_country_snv_weight(i) = sum(i_to_iso(i,iso), p29_country_dummy(iso) * i29_avl_cropland_iso(iso)) / sum(i_to_iso(i,iso), i29_avl_cropland_iso(iso)); diff --git a/modules/29_cropland/rulebased_apr24/presolve.gms b/modules/29_cropland/rulebased_apr24/presolve.gms deleted file mode 100644 index e4a8c98fc9..0000000000 --- a/modules/29_cropland/rulebased_apr24/presolve.gms +++ /dev/null @@ -1,63 +0,0 @@ -*** | (C) 2008-2023 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 - -*' @code -*' Minimum semi-natural vegetation (SNV) share is fading in after 2020 -p29_snv_shr(t,j) = i29_snv_scenario_fader(t) * - (s29_snv_shr * sum(cell(i,j), p29_country_snv_weight(i)) - + s29_snv_shr_noselect * sum(cell(i,j), 1-p29_country_snv_weight(i))); - -*' Cropland relocation in response to SNV policy is based on exogeneous land -*' cover information from the Copernicus Global Land Service (@buchhorn_copernicus_2020). -*' The rate of the policy implementation is derived based -*' on the difference of scenario fader values in consecutive time steps -p29_snv_relocation(t,j) = (i29_snv_scenario_fader(t) - i29_snv_scenario_fader(t-1)) * - (i29_snv_relocation_target(j) * sum(cell(i,j), p29_country_snv_weight(i)) - + s29_snv_shr_noselect * sum(cell(i,j), 1-p29_country_snv_weight(i))); -*' The following lines take care of mismatches in the input -*' data (derived from satellite imagery from the Copernicus -*' Global Land Service (@buchhorn_copernicus_2020)) and in -*' cases of cropland reduction -p29_max_snv_relocation(t,j) = p29_snv_shr(t,j) * (i29_snv_scenario_fader(t) - i29_snv_scenario_fader(t-1)) * pcm_land(j,"crop"); -p29_snv_relocation(t,j)$(p29_snv_relocation(t, j) > p29_max_snv_relocation(t,j)) = p29_max_snv_relocation(t,j); - -*' Area potentially available for cropping -p29_avl_cropland(t,j) = f29_avl_cropland(j,"%c29_marginal_land%") * (1 - p29_snv_shr(t,j)); -*' @stop - - -* Growth of trees on cropland is modelled by shifting age-classes according to time step length. -s29_shift = m_timestep_length_forestry/5; -* example: ac10 in t = ac5 (ac10-1) in t-1 for a 5 yr time step (s29_shift = 1) - p29_treecover(t,j,ac)$(ord(ac) > s29_shift) = pc29_treecover(j,ac-s29_shift); -* account for cases at the end of the age class set (s29_shift > 1) which are not shifted by the above calculation - p29_treecover(t,j,"acx") = p29_treecover(t,j,"acx") - + sum(ac$(ord(ac) > card(ac)-s29_shift), pc29_treecover(j,ac)); - -pc29_treecover(j,ac) = p29_treecover(t,j,ac); -v29_treecover.l(j,ac) = p29_treecover(t,j,ac); - -if(m_year(t) <= s29_treecover_scenario_start, - v29_treecover.fx(j,ac) = pc29_treecover(j,ac); -else - v29_treecover.lo(j,ac_est) = 0; - v29_treecover.up(j,ac_est) = Inf; - if(s29_treecover_decrease = 1, - v29_treecover.lo(j,ac_sub) = 0; - v29_treecover.up(j,ac_sub) = pc29_treecover(j,ac_sub); - else - v29_treecover.fx(j,ac_sub) = pc29_treecover(j,ac_sub); - ); -); - -* create treecover target and penalty scenario -i29_treecover_target(t,j) = - ((1-i29_treecover_scenario_fader(t)) * sum(ac, pc29_treecover(j,ac))/pcm_land(j,"crop"))$(pcm_land(j,"crop") > 1e-10) + - (i29_treecover_scenario_fader(t) * s29_treecover_target); - -* create fallow land target and penalty scenario -i29_fallow_target(t_all) = s29_fallow_target * i29_fallow_scenario_fader(t_all); diff --git a/modules/29_cropland/rulebased_apr24/realization.gms b/modules/29_cropland/rulebased_apr24/realization.gms deleted file mode 100644 index cec1ad89fc..0000000000 --- a/modules/29_cropland/rulebased_apr24/realization.gms +++ /dev/null @@ -1,20 +0,0 @@ -*** | (C) 2008-2024 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 todo - -*' @limitations todo - -*####################### R SECTION START (PHASES) ############################## -$Ifi "%phase%" == "sets" $include "./modules/29_cropland/rulebased_apr24/sets.gms" -$Ifi "%phase%" == "declarations" $include "./modules/29_cropland/rulebased_apr24/declarations.gms" -$Ifi "%phase%" == "input" $include "./modules/29_cropland/rulebased_apr24/input.gms" -$Ifi "%phase%" == "equations" $include "./modules/29_cropland/rulebased_apr24/equations.gms" -$Ifi "%phase%" == "preloop" $include "./modules/29_cropland/rulebased_apr24/preloop.gms" -$Ifi "%phase%" == "presolve" $include "./modules/29_cropland/rulebased_apr24/presolve.gms" -$Ifi "%phase%" == "postsolve" $include "./modules/29_cropland/rulebased_apr24/postsolve.gms" -*######################## R SECTION END (PHASES) ############################### diff --git a/modules/29_cropland/simple_apr24/declarations.gms b/modules/29_cropland/simple_apr24/declarations.gms new file mode 100644 index 0000000000..c63daf0be8 --- /dev/null +++ b/modules/29_cropland/simple_apr24/declarations.gms @@ -0,0 +1,32 @@ +*** | (C) 2008-2024 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 + p29_avl_cropland(t,j) Total available land for crop cultivation (mio. ha) +; + +positive variables + vm_cost_cropland(j) Cost for total cropland (mio. USD05MER per yr) + vm_fallow(j) Fallow land is temporarily fallow cropland (mio. ha) +; + +equations + q29_cropland(j) Total cropland calculation (mio. ha) + q29_avl_cropland(j) Available cropland constraint (mio. ha) + q29_carbon(j,ag_pools,stockType) Cropland above ground carbon content calculation (mio. tC) +; + +*#################### R SECTION START (OUTPUT DECLARATIONS) #################### +parameters + ov_cost_cropland(t,j,type) Cost for total cropland (mio. USD05MER per yr) + ov_fallow(t,j,type) Fallow land is temporarily fallow cropland (mio. ha) + oq29_cropland(t,j,type) Total cropland calculation (mio. ha) + oq29_avl_cropland(t,j,type) Available cropland constraint (mio. ha) + oq29_carbon(t,j,ag_pools,stockType,type) Cropland above ground carbon content calculation (mio. tC) +; +*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### + diff --git a/modules/29_cropland/simple_apr24/equations.gms b/modules/29_cropland/simple_apr24/equations.gms new file mode 100644 index 0000000000..1088543e1c --- /dev/null +++ b/modules/29_cropland/simple_apr24/equations.gms @@ -0,0 +1,32 @@ +*** | (C) 2008-2024 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 +*' Total cropland equals croparea, because fallow land is fixed to zero +*' and tree cover on cropland does not exist in this realization. + + q29_cropland(j2) .. + vm_land(j2,"crop") =e= sum((kcr,w), vm_area(j2,kcr,w)); + +*' We assume that crop production can only take place on suitable cropland area. +*' We use a suitability index (SI) map from @zabel_global_2014 to exclude areas +*' from cropland production that have a low suitability, e.g. due to steep slopes, +*' to estimate the available cropland area. The cultivated area therefore has +*' to be smaller than the available cropland area. Moreover, the available cropland +*' can be reduced by constraining the cropland area in favour of other land types, +*' in order to increase compositional heterogeneity of land types at the cell level. + + q29_avl_cropland(j2) .. + vm_land(j2,"crop") =l= sum(ct, p29_avl_cropland(ct,j2)); + + +*' The carbon stocks of total cropland are calculated as the sum of carbon stocks in +*' cropland, fallow land and tree cover area. + + q29_carbon(j2,ag_pools,stockType) .. + vm_carbon_stock(j2,"crop",ag_pools,stockType) =e= + vm_carbon_stock_croparea(j2,ag_pools); diff --git a/modules/29_cropland/simple_apr24/input.gms b/modules/29_cropland/simple_apr24/input.gms new file mode 100644 index 0000000000..8780993d11 --- /dev/null +++ b/modules/29_cropland/simple_apr24/input.gms @@ -0,0 +1,17 @@ +*** | (C) 2008-2024 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 + +$setglobal c29_marginal_land q33_marginal +* options: all_marginal, q33_marginal, no_marginal + +********* AVAILABLE CROPLAND ******************************************* + +table f29_avl_cropland(j,marginal_land29) Available land area for cropland (mio. ha) +$ondelim +$include "./modules/29_cropland/input/avl_cropland.cs3" +$offdelim +; diff --git a/modules/29_cropland/simple_apr24/not_used.txt b/modules/29_cropland/simple_apr24/not_used.txt new file mode 100644 index 0000000000..6102fa8d55 --- /dev/null +++ b/modules/29_cropland/simple_apr24/not_used.txt @@ -0,0 +1,11 @@ +name,type,reason +vm_lu_transitions,input,not needed +pm_land_hist,input,not needed +pcm_land,input,not needed +fm_luh2_side_layers,input,not needed +pm_interest,input,not needed +pm_land_conservation,input,not needed +fm_bii_coeff,input,not needed +pm_carbon_density_ac,input,not needed +pm_carbon_density_ac_forestry,input,not needed +fm_carbon_density,input,not needed diff --git a/modules/29_cropland/simple_apr24/postsolve.gms b/modules/29_cropland/simple_apr24/postsolve.gms new file mode 100644 index 0000000000..3a389fbe97 --- /dev/null +++ b/modules/29_cropland/simple_apr24/postsolve.gms @@ -0,0 +1,30 @@ +*** | (C) 2008-2024 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 + +*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### + ov_cost_cropland(t,j,"marginal") = vm_cost_cropland.m(j); + ov_fallow(t,j,"marginal") = vm_fallow.m(j); + oq29_cropland(t,j,"marginal") = q29_cropland.m(j); + oq29_avl_cropland(t,j,"marginal") = q29_avl_cropland.m(j); + oq29_carbon(t,j,ag_pools,stockType,"marginal") = q29_carbon.m(j,ag_pools,stockType); + ov_cost_cropland(t,j,"level") = vm_cost_cropland.l(j); + ov_fallow(t,j,"level") = vm_fallow.l(j); + oq29_cropland(t,j,"level") = q29_cropland.l(j); + oq29_avl_cropland(t,j,"level") = q29_avl_cropland.l(j); + oq29_carbon(t,j,ag_pools,stockType,"level") = q29_carbon.l(j,ag_pools,stockType); + ov_cost_cropland(t,j,"upper") = vm_cost_cropland.up(j); + ov_fallow(t,j,"upper") = vm_fallow.up(j); + oq29_cropland(t,j,"upper") = q29_cropland.up(j); + oq29_avl_cropland(t,j,"upper") = q29_avl_cropland.up(j); + oq29_carbon(t,j,ag_pools,stockType,"upper") = q29_carbon.up(j,ag_pools,stockType); + ov_cost_cropland(t,j,"lower") = vm_cost_cropland.lo(j); + ov_fallow(t,j,"lower") = vm_fallow.lo(j); + oq29_cropland(t,j,"lower") = q29_cropland.lo(j); + oq29_avl_cropland(t,j,"lower") = q29_avl_cropland.lo(j); + oq29_carbon(t,j,ag_pools,stockType,"lower") = q29_carbon.lo(j,ag_pools,stockType); +*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### + diff --git a/modules/29_cropland/simple_apr24/preloop.gms b/modules/29_cropland/simple_apr24/preloop.gms new file mode 100644 index 0000000000..9ac96ee8aa --- /dev/null +++ b/modules/29_cropland/simple_apr24/preloop.gms @@ -0,0 +1,14 @@ +*** | (C) 2008-2024 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_cost_cropland.fx(j) = 0; +vm_fallow.fx(j) = 0; +vm_bv.fx(j,"crop_fallow",potnatveg) = 0; +vm_bv.fx(j,"crop_tree",potnatveg) = 0; + +*' Area potentially available for cropping +p29_avl_cropland(t,j) = f29_avl_cropland(j,"%c29_marginal_land%"); diff --git a/modules/29_cropland/simple_apr24/presolve.gms b/modules/29_cropland/simple_apr24/presolve.gms new file mode 100644 index 0000000000..ae47145544 --- /dev/null +++ b/modules/29_cropland/simple_apr24/presolve.gms @@ -0,0 +1,6 @@ +*** | (C) 2008-2023 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 diff --git a/modules/29_cropland/simple_apr24/realization.gms b/modules/29_cropland/simple_apr24/realization.gms new file mode 100644 index 0000000000..7abf5c89fa --- /dev/null +++ b/modules/29_cropland/simple_apr24/realization.gms @@ -0,0 +1,25 @@ +*** | (C) 2008-2024 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 In this realization, total cropland equals croparea because +*' fallow land is fixed to zero and tree cover on cropland does not exist. +*' Therefore, also cropland carbon stocks consist only of croparea carbon stocks. +*' Biodiversity BII values are fixed to zero. +*' Costs are fixed to zero. +*' No options for semi-natural land in cropland landscapes exist. + +*' @limitations Fallow land is fixed to zero and tree cover on cropland does not exist + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/29_cropland/simple_apr24/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/29_cropland/simple_apr24/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/29_cropland/simple_apr24/input.gms" +$Ifi "%phase%" == "equations" $include "./modules/29_cropland/simple_apr24/equations.gms" +$Ifi "%phase%" == "preloop" $include "./modules/29_cropland/simple_apr24/preloop.gms" +$Ifi "%phase%" == "presolve" $include "./modules/29_cropland/simple_apr24/presolve.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/29_cropland/simple_apr24/postsolve.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/29_cropland/rulebased_apr24/sets.gms b/modules/29_cropland/simple_apr24/sets.gms similarity index 70% rename from modules/29_cropland/rulebased_apr24/sets.gms rename to modules/29_cropland/simple_apr24/sets.gms index e5d8286326..6c56fcb13d 100644 --- a/modules/29_cropland/rulebased_apr24/sets.gms +++ b/modules/29_cropland/simple_apr24/sets.gms @@ -10,10 +10,4 @@ sets marginal_land29 Marginal land scenarios / all_marginal, q33_marginal, no_marginal / - policy_target29 Target year for cropland policy - / none, by2029, by2050 / - - relocation_target29 Cropland requiring relocation based on different SNV targets - / SNV20TargetCropland, SNV50TargetCropland / - ; diff --git a/modules/30_crop/endo_apr21/realization.gms b/modules/30_crop/endo_apr21/realization.gms deleted file mode 100644 index af702a13ba..0000000000 --- a/modules/30_crop/endo_apr21/realization.gms +++ /dev/null @@ -1,35 +0,0 @@ -*** | (C) 2008-2024 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 The endo_apr21 realization calculates the crop specific -*' agricultural land use endogenously based on yield data coming from the -*' module [14_yields] and the rotational as well as suitability constraints -*' stated in the input data of the module. -*' -*' Cropland areas are linked to the crop specific production and the carbon -*' content of the different land carbon pools. The crop specific land use areas -*' are also used in [18_residues], [38_factor_costs], -*' [41_area_equipped_for_irrigation], [42_water_demand], [50_nr_soil_budget], -*' [53_methane] and [59_som]. - -*' This realisation also includes the option to reserve a minimum semi-natural -*' vegetation share within the total available cropland for other land cover -*' classes, including grassland, forest, and other land (by a given target year), -*' in order to provide species habitats and to benefit from ecosystem ervices in -*' agricultural landscapes. - -*' @limitations There are currently no known limitations of this realization. - -*####################### R SECTION START (PHASES) ############################## -$Ifi "%phase%" == "sets" $include "./modules/30_crop/endo_apr21/sets.gms" -$Ifi "%phase%" == "declarations" $include "./modules/30_crop/endo_apr21/declarations.gms" -$Ifi "%phase%" == "input" $include "./modules/30_crop/endo_apr21/input.gms" -$Ifi "%phase%" == "equations" $include "./modules/30_crop/endo_apr21/equations.gms" -$Ifi "%phase%" == "preloop" $include "./modules/30_crop/endo_apr21/preloop.gms" -$Ifi "%phase%" == "presolve" $include "./modules/30_crop/endo_apr21/presolve.gms" -$Ifi "%phase%" == "postsolve" $include "./modules/30_crop/endo_apr21/postsolve.gms" -*######################## R SECTION END (PHASES) ############################### diff --git a/modules/30_crop/penalty_apr22/equations.gms b/modules/30_crop/penalty_apr22/equations.gms deleted file mode 100644 index a44fe1e809..0000000000 --- a/modules/30_crop/penalty_apr22/equations.gms +++ /dev/null @@ -1,79 +0,0 @@ -*** | (C) 2008-2024 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 - -*' Agricultural production is calculated by multiplying the area under -*' production with corresponding yields. Production from rainfed and irrigated -*' areas is summed up: - - q30_prod(j2,kcr) .. - vm_prod(j2,kcr) =e= sum(w, vm_area(j2,kcr,w) * vm_yld(j2,kcr,w)); - - -*' Rotational constraints prevent over-specialization. In this module realization, -*' they are implemented via a penalty payment if the constraints are violated. - -q30_rotation_penalty(i2) .. - vm_rotation_penalty(i2) - =g= - sum(cell(i2,j2), - sum(rota30, v30_penalty(j2,rota30) * sum(ct, i30_rotation_incentives(ct,rota30))) - + sum(rotamax_red30, v30_penalty_max_irrig(j2,rotamax_red30) * sum(ct, i30_rotation_incentives(ct,rotamax_red30))) - ); - - -*' The penalty applies to the areas which exceed a certain maximum -*' share of the land. Below this share, negative benefits are -*' avoided by defining the penalty to be positive. - - q30_rotation_max(j2,rotamax_red30) .. - v30_penalty(j2,rotamax_red30) - =g= - sum((rota_kcr30(rotamax_red30,kcr),w),vm_area(j2,kcr,w)) - - vm_land(j2,"crop") * f30_rotation_rules(rotamax_red30); - - -*' Minimum constraints apply penalties when a certain mimimum -*' share of a group is not achieved. This is used to guarantee a minimum -*' crop group diversity withing cells. - - q30_rotation_min(j2,rotamin_red30) .. - v30_penalty(j2,rotamin_red30) - =g= - vm_land(j2,"crop") * f30_rotation_rules(rotamin_red30) - - sum((rota_kcr30(rotamin_red30,kcr),w), vm_area(j2,kcr,w)); - - -*' The following maximum constraint avoids over-specialization in irrigated systems. -*' No minimum constraint is included for irrigated areas for computational -*' reasons. Minimum constraints just need to be met on total areas. - - q30_rotation_max_irrig(j2,rotamax_red30) .. - v30_penalty_max_irrig(j2,rotamax_red30) - =g= - sum((rota_kcr30(rotamax_red30,kcr)), vm_area(j2,kcr,"irrigated")) - - vm_AEI(j2) * f30_rotation_rules(rotamax_red30); - - -*' The carbon stocks of the above ground carbon pools are calculated based on croparea and related carbon density. - - q30_carbon(j2,ag_pools) .. - vm_carbon_stock_croparea(j2,ag_pools) =e= - sum((kcr,w), vm_area(j2,kcr,w)) * sum(ct, fm_carbon_density(ct,j2,"crop",ag_pools)); - - -*' The biodiversity value for cropland is calculated separately for annual and perennial crops: - - q30_bv_ann(j2,potnatveg) .. - vm_bv(j2,"crop_ann",potnatveg) - =e= - sum((crop_ann30,w), vm_area(j2,crop_ann30,w)) * fm_bii_coeff("crop_ann",potnatveg) * fm_luh2_side_layers(j2,potnatveg); - - q30_bv_per(j2,potnatveg) .. vm_bv(j2,"crop_per",potnatveg) - =e= - sum((crop_per30,w), vm_area(j2,crop_per30,w)) * fm_bii_coeff("crop_per",potnatveg) * fm_luh2_side_layers(j2,potnatveg); diff --git a/modules/30_crop/penalty_apr22/realization.gms b/modules/30_crop/penalty_apr22/realization.gms deleted file mode 100644 index 993a8d461a..0000000000 --- a/modules/30_crop/penalty_apr22/realization.gms +++ /dev/null @@ -1,40 +0,0 @@ -*** | (C) 2008-2024 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 The endo_apr21 realization calculates the crop specific -*' agricultural land use endogenously based on yield data coming from the -*' module [14_yields] and the rotational incentives as well as suitability -*' constraints stated in the input data of the module. -*' -*' Cropland areas are linked to the crop specific production and the carbon -*' content of the different land carbon pools. The crop specific land use areas -*' are also used in [18_residues], [38_factor_costs], -*' [41_area_equipped_for_irrigation], [42_water_demand], [50_nr_soil_budget], -*' [53_methane] and [59_som]. - -*' This module realization allows for different scenarios of rotational -*' constraints which are implemented via penalty payments if constraints are -*' exceeded. Rotational constraints are defined for total land as well as -*' for irrigated areas only to avoid overspecialization on irrigated land. - -*' This realisation also includes the option to reserve a minimum semi-natural -*' vegetation share within the total available cropland for other land cover -*' classes, including grassland, forest, and other land (by a given target year), -*' in order to provide species habitats and to benefit from ecosystem ervices in -*' agricultural landscapes. - -*' @limitations There are currently no known limitations of this realization. - -*####################### R SECTION START (PHASES) ############################## -$Ifi "%phase%" == "sets" $include "./modules/30_crop/penalty_apr22/sets.gms" -$Ifi "%phase%" == "declarations" $include "./modules/30_crop/penalty_apr22/declarations.gms" -$Ifi "%phase%" == "input" $include "./modules/30_crop/penalty_apr22/input.gms" -$Ifi "%phase%" == "equations" $include "./modules/30_crop/penalty_apr22/equations.gms" -$Ifi "%phase%" == "preloop" $include "./modules/30_crop/penalty_apr22/preloop.gms" -$Ifi "%phase%" == "presolve" $include "./modules/30_crop/penalty_apr22/presolve.gms" -$Ifi "%phase%" == "postsolve" $include "./modules/30_crop/penalty_apr22/postsolve.gms" -*######################## R SECTION END (PHASES) ############################### diff --git a/modules/30_crop/penalty_apr22/sets.gms b/modules/30_crop/penalty_apr22/sets.gms deleted file mode 100644 index 768e906278..0000000000 --- a/modules/30_crop/penalty_apr22/sets.gms +++ /dev/null @@ -1,79 +0,0 @@ -*** | (C) 2008-2024 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 - -sets - rotascen30 rotation constraint scenarios - /none,default,legumes,betr500,betr1000,agroecology/ - - rota30 rotational rules - /cereals1_max, cereals2_max, - resistant_max, oilcrops_max, - legumes_max, rootsrape_max, - rice_pro_max, tece_max - trce_max, maiz_max, - biomass_min, legumes_min, - minor_min, cereals_min, betr_min/ - - - rotamax30(rota30) rotational maximum rules - /cereals1_max, cereals2_max, - resistant_max, oilcrops_max, - legumes_max, rootsrape_max, - rice_pro_max, tece_max - trce_max, maiz_max - / - - rotamin30(rota30) rotational minimum rules - /biomass_min, legumes_min, minor_min, cereals_min, betr_min/ - - rotamax_red30(rotamax30) Maximum crop rotation reduced set - rotamin_red30(rotamin30) Minimum crop rotation reduced set - -* crop rotation groups: -* cereals or grasses are very favourable to loosen soils, therefore minimum constraint -* legumes need longer rotations, only soybean can and is cultivated every 2 years -* rapeseed and beets have same nematodes -* root crops have similar diseases - -* Sustainable practices: -* >=5% set-aside, >=5% biomass crops that approximate agroforestry systems -* six fold crop rotation of the remaining 90% -* at least one legume slot in crop rotation -* crop groups with multiple members like tece or foddr are allowed multiple slots -* one percent fruits and vegs in each cell for regional demand - - rota_kcr30(rota30, kcr) Mapping of crop types into crop rotation types - / cereals1_max . (tece, maiz, trce, rice_pro) - cereals2_max . (tece, maiz, trce, rice_pro) - resistant_max . (begr,betr,foddr,sugr_cane,cottn_pro,oilpalm,others) - oilcrops_max . (sunflower, rapeseed) - legumes_max . (foddr,puls_pro, soybean, groundnut) - rootsrape_max . (sugr_beet, cassav_sp, potato, rapeseed) - rice_pro_max . (rice_pro) - tece_max . (tece) - trce_max . (trce) - maiz_max . (maiz) - biomass_min . (sugr_cane, oilpalm, begr, betr) - legumes_min . (soybean, groundnut, puls_pro, foddr) - minor_min . (sunflower, rapeseed, sugr_beet, cassav_sp, potato, others) - cereals_min . (tece, maiz, trce, rice_pro) - betr_min . (betr) - / - - kbe30(kcr) bio energy activities - / betr, begr / - - bioen_type_30(kbe30) dynamic set bioen type - bioen_water_30(w) dynamic set bioen water - - crop_ann30(kcr) annual crops - / tece, maiz, trce, rice_pro, rapeseed, sunflower, potato, cassav_sp, sugr_beet, others, cottn_pro, foddr, soybean, groundnut, puls_pro / - - crop_per30(kcr) perennial crops - / oilpalm, begr, sugr_cane, betr / - -; diff --git a/modules/30_crop/rotation_apr22/declarations.gms b/modules/30_crop/rotation_apr22/declarations.gms deleted file mode 100644 index dc41cb568f..0000000000 --- a/modules/30_crop/rotation_apr22/declarations.gms +++ /dev/null @@ -1,45 +0,0 @@ -*** | (C) 2008-2024 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 - i30_rotation_max_shr(t_all,rotamax30) Maximum share of a certain crop group on cropland (ha per ha) - i30_rotation_min_shr(t_all,rotamin30) Minimum share of a certain crop group on cropland (ha per ha) - p30_rotation_scenario_fader(t_all) Crop rotation scenario fader (1) -; - -positive variables - vm_area(j,kcr,w) Agricultural production area (mio. ha) - vm_rotation_penalty(i) Penalty for violating rotational constraints (USD05MER) - vm_carbon_stock_croparea(j,ag_pools) Carbon stock in croparea (tC) -; - -equations - q30_prod(j,kcr) Production of cropped products (mio. tDM) - q30_rotation_max(j,rotamax30) Local maximum rotational constraints (mio. ha) - q30_rotation_min(j,rotamin30) Local minimum rotational constraints (mio. ha) - q30_rotation_max_irrig(j,rotamax30) Local maximum rotational constraints (mio. ha) - q30_carbon(j,ag_pools) Croplarea above ground carbon content calculation (mio. tC) - q30_bv_ann(j,potnatveg) Biodiversity value of annual cropland (mio. ha) - q30_bv_per(j,potnatveg) Biodiversity value of perennial cropland (mio. ha) -; - -*#################### R SECTION START (OUTPUT DECLARATIONS) #################### -parameters - ov_area(t,j,kcr,w,type) Agricultural production area (mio. ha) - ov_rotation_penalty(t,i,type) Penalty for violating rotational constraints (USD05MER) - ov_carbon_stock_croparea(t,j,ag_pools,type) Carbon stock in croparea (tC) - oq30_prod(t,j,kcr,type) Production of cropped products (mio. tDM) - oq30_rotation_max(t,j,rotamax30,type) Local maximum rotational constraints (mio. ha) - oq30_rotation_min(t,j,rotamin30,type) Local minimum rotational constraints (mio. ha) - oq30_rotation_max_irrig(t,j,rotamax30,type) Local maximum rotational constraints (mio. ha) - oq30_carbon(t,j,ag_pools,type) Croplarea above ground carbon content calculation (mio. tC) - oq30_bv_ann(t,j,potnatveg,type) Biodiversity value of annual cropland (mio. ha) - oq30_bv_per(t,j,potnatveg,type) Biodiversity value of perennial cropland (mio. ha) -; -*##################### R SECTION END (OUTPUT DECLARATIONS) ##################### - -*** EOF declarations.gms *** diff --git a/modules/30_crop/rotation_apr22/equations.gms b/modules/30_crop/rotation_apr22/equations.gms deleted file mode 100644 index 3cd5ee574c..0000000000 --- a/modules/30_crop/rotation_apr22/equations.gms +++ /dev/null @@ -1,57 +0,0 @@ -*** | (C) 2008-2024 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 - -*' Agricultural production is calculated by multiplying the area under -*' production with corresponding yields. Production from rainfed and irrigated -*' areas is summed up: - - q30_prod(j2,kcr) .. - vm_prod(j2,kcr) =e= sum(w, vm_area(j2,kcr,w) * vm_yld(j2,kcr,w)); - - -*' As additional constraints minimum and maximum rotational constraints limit -*' the placing of crops. On the one hand, these rotational constraints reflect -*' crop rotations limiting the share a specific crop can cover of the total area -*' of a cluster: - - q30_rotation_max(j2,rotamax_red30) .. - sum((rotamax_kcr30(rotamax_red30,kcr),w), vm_area(j2,kcr,w)) =l= - vm_land(j2,"crop") * sum(ct,i30_rotation_max_shr(ct,rotamax_red30)); - - q30_rotation_min(j2,rotamin_red30) .. - sum((rotamin_kcr30(rotamin_red30,kcr),w), vm_area(j2,kcr,w)) =g= - vm_land(j2,"crop") * sum(ct,i30_rotation_min_shr(ct,rotamin_red30)); - - -* The following maximum constraint avoids over-specialization in irrigated systems. -* No minimum constraint is included for irrigated areas for computational -* reasons. Minimum constraints just need to be met on total areas. - - q30_rotation_max_irrig(j2,rotamax_red30) .. - sum((rotamax_kcr30(rotamax_red30,kcr)), vm_area(j2,kcr,"irrigated")) =l= - vm_AEI(j2) * sum(ct,i30_rotation_max_shr(ct,rotamax_red30)); - - -*' The carbon stocks of the above ground carbon pools are calculated based on croparea and related carbon density. - - q30_carbon(j2,ag_pools) .. - vm_carbon_stock_croparea(j2,ag_pools) =e= - sum((kcr,w), vm_area(j2,kcr,w)) * sum(ct, fm_carbon_density(ct,j2,"crop",ag_pools)); - - -*' The biodiversity value for cropland is calculated separately for annual and perennial crops: - - q30_bv_ann(j2,potnatveg) .. - vm_bv(j2,"crop_ann",potnatveg) - =e= - sum((crop_ann30,w), vm_area(j2,crop_ann30,w)) * fm_bii_coeff("crop_ann",potnatveg) * fm_luh2_side_layers(j2,potnatveg); - - q30_bv_per(j2,potnatveg) .. vm_bv(j2,"crop_per",potnatveg) - =e= - sum((crop_per30,w), vm_area(j2,crop_per30,w)) * fm_bii_coeff("crop_per",potnatveg) * fm_luh2_side_layers(j2,potnatveg); diff --git a/modules/30_crop/rotation_apr22/input.gms b/modules/30_crop/rotation_apr22/input.gms deleted file mode 100644 index 97dfc19ca4..0000000000 --- a/modules/30_crop/rotation_apr22/input.gms +++ /dev/null @@ -1,63 +0,0 @@ -*** | (C) 2008-2024 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 - -$setglobal c30_bioen_type all -* options: begr, betr, all - -$setglobal c30_bioen_water rainfed -* options: rainfed, irrigated, all - -$setglobal c30_rotation_constraints on -*options: on, off - -$setglobal c30_rotation_scenario default -*options: min,default,good,good_20div,setaside,legumes,betr0,betr10,betr20,betr25,betr30, -* betr40,betr50,sixfoldrotation,agroecology - -$setglobal c30_rotation_scenario_speed by2050 -* options: none, by2030, by2020 - -scalars - s30_rotation_scenario_start Rotation scenario start year / 2020 / - s30_rotation_scenario_target Rotation scenario target year / 2050 / -; - - -$ifthen "%c30_bioen_type%" == "all" bioen_type_30(kbe30) = yes; -$else bioen_type_30("%c30_bioen_type%") = yes; -$endif - -$ifthen "%c30_bioen_water%" == "all" bioen_water_30(w) = yes; -$else bioen_water_30("%c30_bioen_water%") = yes; -$endif - -********* CROPAREA INITIALISATION ********************************************** - -table fm_croparea(t_all,j,w,kcr) Different croparea type areas (mio. ha) -$ondelim -$include "./modules/30_crop/rotation_apr22/input/f30_croparea_w_initialisation.cs3" -$offdelim -; -m_fillmissingyears(fm_croparea,"j,w,kcr"); - -********* CROP-ROTATIONAL CONSTRAINT ******************************************* - -table f30_rotation_max_shr(rotamax30,rotascen30) Maximum allowed area shares for each crop type (1) -$ondelim -$include "./modules/30_crop/rotation_apr22/input/f30_rotation_max_scen.csv" -$offdelim -; -$if "%c30_rotation_constraints%" == "off" f30_rotation_max_shr(crp30) = 1; - - -table f30_rotation_min_shr(rotamin30,rotascen30) Minimum allowed area shares for each crop type (1) -$ondelim -$include "./modules/30_crop/rotation_apr22/input/f30_rotation_min_scen.csv" -$offdelim -; -$if "%c30_rotation_constraints%" == "off" f30_rotation_min_shr(crp30) = 0; - diff --git a/modules/30_crop/rotation_apr22/input/files b/modules/30_crop/rotation_apr22/input/files deleted file mode 100644 index c20b7be222..0000000000 --- a/modules/30_crop/rotation_apr22/input/files +++ /dev/null @@ -1,4 +0,0 @@ -* list of files that are required here -f30_rotation_max_scen.csv -f30_rotation_min_scen.csv -f30_croparea_w_initialisation.cs3 diff --git a/modules/30_crop/rotation_apr22/postsolve.gms b/modules/30_crop/rotation_apr22/postsolve.gms deleted file mode 100644 index 18031392c2..0000000000 --- a/modules/30_crop/rotation_apr22/postsolve.gms +++ /dev/null @@ -1,50 +0,0 @@ -*** | (C) 2008-2024 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 - - -*#################### R SECTION START (OUTPUT DEFINITIONS) ##################### - ov_area(t,j,kcr,w,"marginal") = vm_area.m(j,kcr,w); - ov_rotation_penalty(t,i,"marginal") = vm_rotation_penalty.m(i); - ov_carbon_stock_croparea(t,j,ag_pools,"marginal") = vm_carbon_stock_croparea.m(j,ag_pools); - oq30_prod(t,j,kcr,"marginal") = q30_prod.m(j,kcr); - oq30_rotation_max(t,j,rotamax30,"marginal") = q30_rotation_max.m(j,rotamax30); - oq30_rotation_min(t,j,rotamin30,"marginal") = q30_rotation_min.m(j,rotamin30); - oq30_rotation_max_irrig(t,j,rotamax30,"marginal") = q30_rotation_max_irrig.m(j,rotamax30); - oq30_carbon(t,j,ag_pools,"marginal") = q30_carbon.m(j,ag_pools); - oq30_bv_ann(t,j,potnatveg,"marginal") = q30_bv_ann.m(j,potnatveg); - oq30_bv_per(t,j,potnatveg,"marginal") = q30_bv_per.m(j,potnatveg); - ov_area(t,j,kcr,w,"level") = vm_area.l(j,kcr,w); - ov_rotation_penalty(t,i,"level") = vm_rotation_penalty.l(i); - ov_carbon_stock_croparea(t,j,ag_pools,"level") = vm_carbon_stock_croparea.l(j,ag_pools); - oq30_prod(t,j,kcr,"level") = q30_prod.l(j,kcr); - oq30_rotation_max(t,j,rotamax30,"level") = q30_rotation_max.l(j,rotamax30); - oq30_rotation_min(t,j,rotamin30,"level") = q30_rotation_min.l(j,rotamin30); - oq30_rotation_max_irrig(t,j,rotamax30,"level") = q30_rotation_max_irrig.l(j,rotamax30); - oq30_carbon(t,j,ag_pools,"level") = q30_carbon.l(j,ag_pools); - oq30_bv_ann(t,j,potnatveg,"level") = q30_bv_ann.l(j,potnatveg); - oq30_bv_per(t,j,potnatveg,"level") = q30_bv_per.l(j,potnatveg); - ov_area(t,j,kcr,w,"upper") = vm_area.up(j,kcr,w); - ov_rotation_penalty(t,i,"upper") = vm_rotation_penalty.up(i); - ov_carbon_stock_croparea(t,j,ag_pools,"upper") = vm_carbon_stock_croparea.up(j,ag_pools); - oq30_prod(t,j,kcr,"upper") = q30_prod.up(j,kcr); - oq30_rotation_max(t,j,rotamax30,"upper") = q30_rotation_max.up(j,rotamax30); - oq30_rotation_min(t,j,rotamin30,"upper") = q30_rotation_min.up(j,rotamin30); - oq30_rotation_max_irrig(t,j,rotamax30,"upper") = q30_rotation_max_irrig.up(j,rotamax30); - oq30_carbon(t,j,ag_pools,"upper") = q30_carbon.up(j,ag_pools); - oq30_bv_ann(t,j,potnatveg,"upper") = q30_bv_ann.up(j,potnatveg); - oq30_bv_per(t,j,potnatveg,"upper") = q30_bv_per.up(j,potnatveg); - ov_area(t,j,kcr,w,"lower") = vm_area.lo(j,kcr,w); - ov_rotation_penalty(t,i,"lower") = vm_rotation_penalty.lo(i); - ov_carbon_stock_croparea(t,j,ag_pools,"lower") = vm_carbon_stock_croparea.lo(j,ag_pools); - oq30_prod(t,j,kcr,"lower") = q30_prod.lo(j,kcr); - oq30_rotation_max(t,j,rotamax30,"lower") = q30_rotation_max.lo(j,rotamax30); - oq30_rotation_min(t,j,rotamin30,"lower") = q30_rotation_min.lo(j,rotamin30); - oq30_rotation_max_irrig(t,j,rotamax30,"lower") = q30_rotation_max_irrig.lo(j,rotamax30); - oq30_carbon(t,j,ag_pools,"lower") = q30_carbon.lo(j,ag_pools); - oq30_bv_ann(t,j,potnatveg,"lower") = q30_bv_ann.lo(j,potnatveg); - oq30_bv_per(t,j,potnatveg,"lower") = q30_bv_per.lo(j,potnatveg); -*##################### R SECTION END (OUTPUT DEFINITIONS) ###################### diff --git a/modules/30_crop/rotation_apr22/preloop.gms b/modules/30_crop/rotation_apr22/preloop.gms deleted file mode 100644 index df6a30816f..0000000000 --- a/modules/30_crop/rotation_apr22/preloop.gms +++ /dev/null @@ -1,26 +0,0 @@ -*** | (C) 2008-2024 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 - - -** Trajectory for cropland scenarios -* sigmoidal interpolation between start year and target year -m_sigmoid_time_interpol(p30_rotation_scenario_fader,s30_rotation_scenario_start,s30_rotation_scenario_target,0,1); - -** create crop rotation scenario -i30_rotation_max_shr(t_all,rotamax30)= - f30_rotation_max_shr(rotamax30,"default") * (1-p30_rotation_scenario_fader(t_all))+ - f30_rotation_max_shr(rotamax30,"%c30_rotation_scenario%") * (p30_rotation_scenario_fader(t_all)); - -i30_rotation_min_shr(t_all,rotamin30)= - f30_rotation_min_shr(rotamin30,"default") * (1-p30_rotation_scenario_fader(t_all))+ - f30_rotation_min_shr(rotamin30,"%c30_rotation_scenario%") * (p30_rotation_scenario_fader(t_all)); - - -*due to some rounding errors the input data currently may contain in some cases -*very small, negative numbers. These numbers have to be set to 0 as area -*cannot be smaller than 0! -fm_croparea(t_past,j,w,kcr)$(fm_croparea(t_past,j,w,kcr)<0) = 0; diff --git a/modules/30_crop/rotation_apr22/presolve.gms b/modules/30_crop/rotation_apr22/presolve.gms deleted file mode 100644 index 1b847385d9..0000000000 --- a/modules/30_crop/rotation_apr22/presolve.gms +++ /dev/null @@ -1,26 +0,0 @@ -*** | (C) 2008-2024 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 - -*' @code -*' First, all 2nd generation bioenergy area is fixed to zero, irrespective of type and -*' rainfed/irrigation. -vm_area.fx(j,kbe30,w)=0; -*' Second, the bounds for 2nd generation bioenergy area are released depending on -*' the dynamic sets bioen_type_30 and bioen_water_30. -*' SSP2 default settings are used for the historic period. -if(m_year(t) <= sm_fix_SSP2, - vm_area.up(j,kbe30,"rainfed") = Inf; -else - vm_area.up(j,bioen_type_30,bioen_water_30) = Inf; -); -*' @stop - -* only activate constraints which are binding -rotamax_red30(rotamax30) = yes$(i30_rotation_max_shr(t,rotamax30) < 1); -rotamin_red30(rotamin30) = yes$(i30_rotation_min_shr(t,rotamin30) > 0); - -vm_rotation_penalty.fx(i)=0; diff --git a/modules/30_crop/rotation_apr22/realization.gms b/modules/30_crop/rotation_apr22/realization.gms deleted file mode 100644 index 3e2f37077f..0000000000 --- a/modules/30_crop/rotation_apr22/realization.gms +++ /dev/null @@ -1,41 +0,0 @@ -*** | (C) 2008-2024 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 The rotation_apr21 realization calculates the crop specific -*' agricultural land use endogenously based on yield data coming from the -*' module [14_yields] and the rotational as well as suitability constraints -*' stated in the input data of the module. -*' -*' Cropland areas are linked to the crop specific production and the carbon -*' content of the different land carbon pools. The crop specific land use areas -*' are also used in [18_residues], [38_factor_costs], -*' [41_area_equipped_for_irrigation], [42_water_demand], [50_nr_soil_budget], -*' [53_methane] and [59_som]. - -*' This module realization allows for different scenarios of rotational -*' constraints. These are implemented as hard constraints. Maximum rotational -*' constraints are defined for total cropland as well as for irrigated areas -*' only to avoid overspecialization on irrigated land. Minimum constraints are -*' just valid for total cropland areas. - -*' This realisation also includes the option to reserve a minimum semi-natural -*' vegetation share within the total available cropland for other land cover -*' classes, including grassland, forest, and other land (by a given target year), -*' in order to provide species habitats and to benefit from ecosystem ervices in -*' agricultural landscapes. - -*' @limitations There are currently no known limitations of this realization. - -*####################### R SECTION START (PHASES) ############################## -$Ifi "%phase%" == "sets" $include "./modules/30_crop/rotation_apr22/sets.gms" -$Ifi "%phase%" == "declarations" $include "./modules/30_crop/rotation_apr22/declarations.gms" -$Ifi "%phase%" == "input" $include "./modules/30_crop/rotation_apr22/input.gms" -$Ifi "%phase%" == "equations" $include "./modules/30_crop/rotation_apr22/equations.gms" -$Ifi "%phase%" == "preloop" $include "./modules/30_crop/rotation_apr22/preloop.gms" -$Ifi "%phase%" == "presolve" $include "./modules/30_crop/rotation_apr22/presolve.gms" -$Ifi "%phase%" == "postsolve" $include "./modules/30_crop/rotation_apr22/postsolve.gms" -*######################## R SECTION END (PHASES) ############################### diff --git a/modules/30_crop/rotation_apr22/sets.gms b/modules/30_crop/rotation_apr22/sets.gms deleted file mode 100644 index b8264aa0fd..0000000000 --- a/modules/30_crop/rotation_apr22/sets.gms +++ /dev/null @@ -1,101 +0,0 @@ -*** | (C) 2008-2024 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 - -sets - rotascen30 rotation constraint scenarios - /min,default,good,good_20div,setaside,legumes, - betr0,betr10,betr20,betr25,betr30,betr40,betr50, - sixfoldrotation,agroecology/ - - rotamax30 Maximum crop rotation categories - / all_max, cereals_excl_rice_max, stalk_max, - biomass_max, roots_max, legume_max, rape_sugr_max, - tece_max, maiz_max, trce_max, rice_max, - rapeseed_max, soybean_max, sunflower_max, groundnut_max, - oilpalm_max, puls_max, potato_max, cassava_max, - sugr_cane_max, sugr_beet_max, others_max, foddr_max, - fiber_max, begr_max, betr_max - / - - rotamin30 Minimum crop rotation categories - / - all_min, stalk_min, biomass_min, - legume_min, others_min, betr_min - / - - rotamax_red30(rotamax30) Maximum crop rotation reduced set - rotamin_red30(rotamin30) Minimum crop rotation reduced set - -* crop rotation groups: -* cereals or grasses are very favourable to loosen soils, therefore minimum constraint -* legumes need longer rotations, only soybean can and is cultivated every 2 years -* rapeseed and beets have same nematodes -* root crops have similar diseases - -* Sustainable practices: -* >=5% set-aside, >=5% biomass crops that approximate agroforestry systems -* six fold crop rotation of the remaining 90% -* at least one legume slot in crop rotation -* crop groups with multiple members like tece or foddr are allowed multiple slots -* one percent fruits and vegs in each cell for regional demand - - rotamax_kcr30(rotamax30, kcr) Mapping of crop types into crop rotation types - / all_max . (tece, maiz, trce, rice_pro, soybean, rapeseed, groundnut, sunflower, - oilpalm, puls_pro, potato, cassav_sp, sugr_cane, sugr_beet, others, - foddr, cottn_pro, begr, betr) - cereals_excl_rice_max . (tece, maiz, trce) - stalk_max . (tece, maiz, trce, rice_pro, sugr_cane, begr, foddr) - roots_max . (potato, cassav_sp, sugr_beet) - legume_max . (soybean, groundnut, puls_pro, foddr) - biomass_max . (sugr_cane, oilpalm, begr, betr) - rape_sugr_max . (rapeseed, sugr_beet) - - tece_max . (tece) - maiz_max . (maiz) - trce_max . (trce) - rice_max . (rice_pro) - rapeseed_max . (rapeseed) - soybean_max . (soybean) - sunflower_max . (sunflower) - groundnut_max . (groundnut) - oilpalm_max . (oilpalm) - puls_max . (puls_pro) - potato_max . (potato) - cassava_max . (cassav_sp) - sugr_cane_max . (sugr_cane) - sugr_beet_max . (sugr_beet) - others_max . (others) - foddr_max . (foddr) - fiber_max . (cottn_pro) - begr_max . (begr) - betr_max . (betr) / - - rotamin_kcr30(rotamin30,kcr) Mapping of crop types into crop rotation types - / all_min . (tece, maiz, trce, rice_pro, soybean, rapeseed, groundnut, sunflower, - oilpalm, puls_pro, potato, cassav_sp, sugr_cane, sugr_beet, others, - foddr, cottn_pro, begr, betr) - - stalk_min . (tece, maiz, trce, rice_pro, sugr_cane, foddr) - biomass_min . (sugr_cane, oilpalm, begr, betr) - legume_min . (soybean, groundnut, puls_pro, foddr) - others_min . (others) - betr_min . (betr) - / - - kbe30(kcr) bio energy activities - / betr, begr / - - bioen_type_30(kbe30) dynamic set bioen type - bioen_water_30(w) dynamic set bioen water - - crop_ann30(kcr) annual crops - / tece, maiz, trce, rice_pro, rapeseed, sunflower, potato, cassav_sp, sugr_beet, others, cottn_pro, foddr, soybean, groundnut, puls_pro / - - crop_per30(kcr) perennial crops - / oilpalm, begr, sugr_cane, betr / - -; diff --git a/modules/30_crop/penalty_apr22/declarations.gms b/modules/30_croparea/detail_apr24/declarations.gms similarity index 88% rename from modules/30_crop/penalty_apr22/declarations.gms rename to modules/30_croparea/detail_apr24/declarations.gms index 2d3d2eeebe..ff46199365 100644 --- a/modules/30_crop/penalty_apr22/declarations.gms +++ b/modules/30_croparea/detail_apr24/declarations.gms @@ -6,6 +6,7 @@ *** | Contact: magpie@pik-potsdam.de parameters + i30_rotation_rules(t_all,rota30) Rotational constraints (1) i30_rotation_incentives(t_all,rota30) Penalty for violating rotational constraints (USD05MER per ha) p30_rotation_scenario_fader(t_all) Crop rotation scenario fader (1) ; @@ -23,6 +24,8 @@ equations q30_rotation_penalty(i) Total penalty for rotational constraint violations (mio. USD05MER) q30_rotation_max(j,rotamax30) Local maximum rotational constraints (mio. ha) q30_rotation_min(j,rotamin30) Local minimum rotational constraints (mio. ha) + q30_rotation_max2(j,rotamax30) Local maximum rotational constraints (mio. ha) + q30_rotation_min2(j,rotamin30) Local minimum rotational constraints (mio. ha) q30_rotation_max_irrig(j,rotamax30) Local maximum rotational constraints (mio. ha) q30_carbon(j,ag_pools) Croplarea above ground carbon content calculation (mio. tC) q30_bv_ann(j,potnatveg) Biodiversity value of annual cropland (mio. ha) @@ -40,6 +43,8 @@ parameters oq30_rotation_penalty(t,i,type) Total penalty for rotational constraint violations (mio. USD05MER) oq30_rotation_max(t,j,rotamax30,type) Local maximum rotational constraints (mio. ha) oq30_rotation_min(t,j,rotamin30,type) Local minimum rotational constraints (mio. ha) + oq30_rotation_max2(t,j,rotamax30,type) Local maximum rotational constraints (mio. ha) + oq30_rotation_min2(t,j,rotamin30,type) Local minimum rotational constraints (mio. ha) oq30_rotation_max_irrig(t,j,rotamax30,type) Local maximum rotational constraints (mio. ha) oq30_carbon(t,j,ag_pools,type) Croplarea above ground carbon content calculation (mio. tC) oq30_bv_ann(t,j,potnatveg,type) Biodiversity value of annual cropland (mio. ha) diff --git a/modules/30_croparea/detail_apr24/equations.gms b/modules/30_croparea/detail_apr24/equations.gms new file mode 100644 index 0000000000..034de74216 --- /dev/null +++ b/modules/30_croparea/detail_apr24/equations.gms @@ -0,0 +1,83 @@ +*** | (C) 2008-2024 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 + +*' Agricultural production is calculated by multiplying the area under +*' production with corresponding yields. Production from rainfed and irrigated +*' areas is summed up: + + q30_prod(j2,kcr) .. + vm_prod(j2,kcr) =e= sum(w, vm_area(j2,kcr,w) * vm_yld(j2,kcr,w)); + +*' Rotational constraints prevent over-specialization. In this realization, +*' they are either implemented via a rules (s30_implementation = 1) or +*' a penalty payment if the constraints are violated (s30_implementation = 0). + + q30_rotation_penalty(i2) .. + vm_rotation_penalty(i2) =g= + sum(cell(i2,j2), + sum(rota30, v30_penalty(j2,rota30) * sum(ct, i30_rotation_incentives(ct,rota30))) + + sum(rotamax_red30, v30_penalty_max_irrig(j2,rotamax_red30) + * sum(ct, i30_rotation_incentives(ct,rotamax_red30))) + ); + + q30_rotation_max(j2,rotamax_red30)$(s30_implementation = 1) .. + sum((rota_kcr30(rotamax_red30,kcr),w), vm_area(j2,kcr,w)) =l= + sum((kcr,w),vm_area(j2,kcr,w)) * sum(ct,i30_rotation_rules(ct,rotamax_red30)); + + q30_rotation_min(j2,rotamin_red30)$(s30_implementation = 1) .. + sum((rota_kcr30(rotamin_red30,kcr),w), vm_area(j2,kcr,w)) =g= + sum((kcr,w),vm_area(j2,kcr,w)) * sum(ct,i30_rotation_rules(ct,rotamin_red30)); + +*' The penalty applies to the areas which exceed a certain maximum +*' share of the land. Below this share, negative benefits are +*' avoided by defining the penalty to be positive. + + q30_rotation_max2(j2,rotamax_red30)$(s30_implementation = 0) .. + v30_penalty(j2,rotamax_red30) =g= + sum((rota_kcr30(rotamax_red30,kcr),w),vm_area(j2,kcr,w)) + - sum((kcr,w),vm_area(j2,kcr,w)) * sum(ct,i30_rotation_rules(ct,rotamax_red30)); + + +*' Minimum constraints apply penalties when a certain mimimum +*' share of a group is not achieved. This is used to guarantee a minimum +*' crop group diversity withing cells. + + q30_rotation_min2(j2,rotamin_red30)$(s30_implementation = 0) .. + v30_penalty(j2,rotamin_red30) =g= + sum((kcr,w),vm_area(j2,kcr,w)) * sum(ct,i30_rotation_rules(ct,rotamin_red30)) + - sum((rota_kcr30(rotamin_red30,kcr),w), vm_area(j2,kcr,w)); + + +*' The following maximum constraint avoids over-specialization in irrigated systems. +*' No minimum constraint is included for irrigated areas for computational +*' reasons. Minimum constraints just need to be met on total areas. + + q30_rotation_max_irrig(j2,rotamax_red30) .. + v30_penalty_max_irrig(j2,rotamax_red30) =g= + sum((rota_kcr30(rotamax_red30,kcr)), vm_area(j2,kcr,"irrigated")) + - vm_AEI(j2) * sum(ct,i30_rotation_rules(ct,rotamax_red30)); + + +*' The carbon stocks of the above ground carbon pools are calculated based on croparea and related carbon density. + + q30_carbon(j2,ag_pools) .. + vm_carbon_stock_croparea(j2,ag_pools) =e= + sum((kcr,w), vm_area(j2,kcr,w)) * sum(ct, fm_carbon_density(ct,j2,"crop",ag_pools)); + + +*' The biodiversity value for cropland is calculated separately for annual and perennial crops: + + q30_bv_ann(j2,potnatveg) .. + vm_bv(j2,"crop_ann",potnatveg) =e= + sum((crop_ann30,w), vm_area(j2,crop_ann30,w)) * fm_bii_coeff("crop_ann",potnatveg) + * fm_luh2_side_layers(j2,potnatveg); + + q30_bv_per(j2,potnatveg) .. vm_bv(j2,"crop_per",potnatveg) =e= + sum((crop_per30,w), vm_area(j2,crop_per30,w)) * fm_bii_coeff("crop_per",potnatveg) + * fm_luh2_side_layers(j2,potnatveg); diff --git a/modules/30_crop/penalty_apr22/input.gms b/modules/30_croparea/detail_apr24/input.gms similarity index 66% rename from modules/30_crop/penalty_apr22/input.gms rename to modules/30_croparea/detail_apr24/input.gms index 3cadd0b059..6db7c4dfeb 100644 --- a/modules/30_crop/penalty_apr22/input.gms +++ b/modules/30_croparea/detail_apr24/input.gms @@ -11,18 +11,17 @@ $setglobal c30_bioen_type all $setglobal c30_bioen_water rainfed * options: rainfed, irrigated, all -$setglobal c30_rotation_constraints on -*options: on, off +$setglobal c30_rotation_rules default +*options: none, default, legumes, betr500, betr1000, agroecology -$setglobal c30_rotation_scenario default +$setglobal c30_rotation_incentives default *options: none, default, legumes, betr500, betr1000, agroecology -$setglobal c30_rotation_scenario_speed by2050 -* options: none, by2030, by2020 scalars s30_rotation_scenario_start Rotation scenario start year / 2020 / s30_rotation_scenario_target Rotation scenario target year / 2050 / + s30_implementation Switch for rule-based (1) or penalty-based (0) implementation of rotation scenarios / 1 / ; @@ -38,24 +37,22 @@ $endif table fm_croparea(t_all,j,w,kcr) Different croparea type areas (mio. ha) $ondelim -$include "./modules/30_crop/penalty_apr22/input/f30_croparea_w_initialisation.cs3" +$include "./modules/30_croparea/detail_apr24/input/f30_croparea_w_initialisation.cs3" $offdelim ; m_fillmissingyears(fm_croparea,"j,w,kcr"); ********* CROP-ROTATIONAL CONSTRAINT ******************************************* -table f30_rotation_incentives(rota30,rotascen30) penalties for violating rotation rules (USD05MER) +table f30_rotation_incentives(rota30,incentscen30) penalties for violating rotation rules (USD05MER) $ondelim -$include "./modules/30_crop/penalty_apr22/input/f30_rotation_incentives.csv" +$include "./modules/30_croparea/detail_apr24/input/f30_rotation_incentives.csv" $offdelim ; -parameter f30_rotation_rules(rota30) Rotation min or max shares (1) -/ +table f30_rotation_rules(rota30,rotascen30) Rotation min or max shares (1) $ondelim -$include "./modules/30_crop/penalty_apr22/input/f30_rotation_rules.csv" +$include "./modules/30_croparea/detail_apr24/input/f30_rotation_rules.csv" $offdelim -/ ; diff --git a/modules/30_crop/penalty_apr22/input/files b/modules/30_croparea/detail_apr24/input/files similarity index 100% rename from modules/30_crop/penalty_apr22/input/files rename to modules/30_croparea/detail_apr24/input/files diff --git a/modules/30_crop/penalty_apr22/postsolve.gms b/modules/30_croparea/detail_apr24/postsolve.gms similarity index 87% rename from modules/30_crop/penalty_apr22/postsolve.gms rename to modules/30_croparea/detail_apr24/postsolve.gms index 84a11fd02a..481fb9e1c9 100644 --- a/modules/30_crop/penalty_apr22/postsolve.gms +++ b/modules/30_croparea/detail_apr24/postsolve.gms @@ -16,6 +16,8 @@ oq30_rotation_penalty(t,i,"marginal") = q30_rotation_penalty.m(i); oq30_rotation_max(t,j,rotamax30,"marginal") = q30_rotation_max.m(j,rotamax30); oq30_rotation_min(t,j,rotamin30,"marginal") = q30_rotation_min.m(j,rotamin30); + oq30_rotation_max2(t,j,rotamax30,"marginal") = q30_rotation_max2.m(j,rotamax30); + oq30_rotation_min2(t,j,rotamin30,"marginal") = q30_rotation_min2.m(j,rotamin30); oq30_rotation_max_irrig(t,j,rotamax30,"marginal") = q30_rotation_max_irrig.m(j,rotamax30); oq30_carbon(t,j,ag_pools,"marginal") = q30_carbon.m(j,ag_pools); oq30_bv_ann(t,j,potnatveg,"marginal") = q30_bv_ann.m(j,potnatveg); @@ -29,6 +31,8 @@ oq30_rotation_penalty(t,i,"level") = q30_rotation_penalty.l(i); oq30_rotation_max(t,j,rotamax30,"level") = q30_rotation_max.l(j,rotamax30); oq30_rotation_min(t,j,rotamin30,"level") = q30_rotation_min.l(j,rotamin30); + oq30_rotation_max2(t,j,rotamax30,"level") = q30_rotation_max2.l(j,rotamax30); + oq30_rotation_min2(t,j,rotamin30,"level") = q30_rotation_min2.l(j,rotamin30); oq30_rotation_max_irrig(t,j,rotamax30,"level") = q30_rotation_max_irrig.l(j,rotamax30); oq30_carbon(t,j,ag_pools,"level") = q30_carbon.l(j,ag_pools); oq30_bv_ann(t,j,potnatveg,"level") = q30_bv_ann.l(j,potnatveg); @@ -42,6 +46,8 @@ oq30_rotation_penalty(t,i,"upper") = q30_rotation_penalty.up(i); oq30_rotation_max(t,j,rotamax30,"upper") = q30_rotation_max.up(j,rotamax30); oq30_rotation_min(t,j,rotamin30,"upper") = q30_rotation_min.up(j,rotamin30); + oq30_rotation_max2(t,j,rotamax30,"upper") = q30_rotation_max2.up(j,rotamax30); + oq30_rotation_min2(t,j,rotamin30,"upper") = q30_rotation_min2.up(j,rotamin30); oq30_rotation_max_irrig(t,j,rotamax30,"upper") = q30_rotation_max_irrig.up(j,rotamax30); oq30_carbon(t,j,ag_pools,"upper") = q30_carbon.up(j,ag_pools); oq30_bv_ann(t,j,potnatveg,"upper") = q30_bv_ann.up(j,potnatveg); @@ -55,6 +61,8 @@ oq30_rotation_penalty(t,i,"lower") = q30_rotation_penalty.lo(i); oq30_rotation_max(t,j,rotamax30,"lower") = q30_rotation_max.lo(j,rotamax30); oq30_rotation_min(t,j,rotamin30,"lower") = q30_rotation_min.lo(j,rotamin30); + oq30_rotation_max2(t,j,rotamax30,"lower") = q30_rotation_max2.lo(j,rotamax30); + oq30_rotation_min2(t,j,rotamin30,"lower") = q30_rotation_min2.lo(j,rotamin30); oq30_rotation_max_irrig(t,j,rotamax30,"lower") = q30_rotation_max_irrig.lo(j,rotamax30); oq30_carbon(t,j,ag_pools,"lower") = q30_carbon.lo(j,ag_pools); oq30_bv_ann(t,j,potnatveg,"lower") = q30_bv_ann.lo(j,potnatveg); diff --git a/modules/30_crop/penalty_apr22/preloop.gms b/modules/30_croparea/detail_apr24/preloop.gms similarity index 68% rename from modules/30_crop/penalty_apr22/preloop.gms rename to modules/30_croparea/detail_apr24/preloop.gms index 075f0c5e82..51e2d0cfaa 100644 --- a/modules/30_crop/penalty_apr22/preloop.gms +++ b/modules/30_croparea/detail_apr24/preloop.gms @@ -10,12 +10,21 @@ m_sigmoid_time_interpol(p30_rotation_scenario_fader,s30_rotation_scenario_start,s30_rotation_scenario_target,0,1); ** create crop rotation scenario -i30_rotation_incentives(t_all,rota30)= +i30_rotation_rules(t_all,rota30) = + f30_rotation_rules(rota30,"default") * (1-p30_rotation_scenario_fader(t_all)) + + f30_rotation_rules(rota30,"%c30_rotation_rules%") * (p30_rotation_scenario_fader(t_all)); + +** create crop rotation scenario +i30_rotation_incentives(t_all,rota30) = f30_rotation_incentives(rota30,"default") * (1-p30_rotation_scenario_fader(t_all)) + - f30_rotation_incentives(rota30,"%c30_rotation_scenario%") * (p30_rotation_scenario_fader(t_all)); + f30_rotation_incentives(rota30,"%c30_rotation_incentives%") * (p30_rotation_scenario_fader(t_all)); *due to some rounding errors the input data currently may contain in some cases *very small, negative numbers. These numbers have to be set to 0 as area *cannot be smaller than 0! fm_croparea(t_past,j,w,kcr)$(fm_croparea(t_past,j,w,kcr)<0) = 0; + +if(s30_implementation = 1, + v30_penalty.fx(j,rota30) = 0; +); diff --git a/modules/30_crop/penalty_apr22/presolve.gms b/modules/30_croparea/detail_apr24/presolve.gms similarity index 100% rename from modules/30_crop/penalty_apr22/presolve.gms rename to modules/30_croparea/detail_apr24/presolve.gms diff --git a/modules/30_croparea/detail_apr24/realization.gms b/modules/30_croparea/detail_apr24/realization.gms new file mode 100644 index 0000000000..42d40a5156 --- /dev/null +++ b/modules/30_croparea/detail_apr24/realization.gms @@ -0,0 +1,33 @@ +*** | (C) 2008-2024 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 This realization calculates the crop specific +*' agricultural crop area endogenously based on yield data provided by +*' module [14_yields] and detailed rotational constraints. +*' In addition, corresponding carbons stocks and BII values are calculated. +*' +*' The crop specific interface `vm_area` is used in many other modules, +*' including [18_residues], [38_factor_costs], +*' [41_area_equipped_for_irrigation], [42_water_demand], [50_nr_soil_budget], +*' [53_methane] and [59_som]. +*' +*' This realization allows for different scenarios of rotational +*' constraints which are either implemented via hard constraints or penalty payments +*' if constraints are exceeded. Rotational constraints are defined for total croparea +*' as well as for irrigated areas only to avoid overspecialization on irrigated land. + +*' @limitations There are currently no known limitations of this realization. + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/30_croparea/detail_apr24/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/30_croparea/detail_apr24/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/30_croparea/detail_apr24/input.gms" +$Ifi "%phase%" == "equations" $include "./modules/30_croparea/detail_apr24/equations.gms" +$Ifi "%phase%" == "preloop" $include "./modules/30_croparea/detail_apr24/preloop.gms" +$Ifi "%phase%" == "presolve" $include "./modules/30_croparea/detail_apr24/presolve.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/30_croparea/detail_apr24/postsolve.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/30_croparea/detail_apr24/sets.gms b/modules/30_croparea/detail_apr24/sets.gms new file mode 100644 index 0000000000..e0fa90cefe --- /dev/null +++ b/modules/30_croparea/detail_apr24/sets.gms @@ -0,0 +1,114 @@ +*** | (C) 2008-2024 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 + +sets + incentscen30 rotation inventive scenarios + /none,default,legumes,betr500,betr1000,agroecology/ + + rotascen30 rotation constraint scenarios + /min,default,good,good_20div,setaside,legumes, + betr0,betr10,betr20,betr25,betr30,betr40,betr50, + sixfoldrotation,agroecology,FSEC/ + + rota30 rotational rules + /cereals1_max, cereals2_max, cereals_excl_rice_max, stalk_max, + resistant_max, oilcrops_max, + legumes_max, rootsrape_max, roots_max, rape_sugr_max, biomass_max, + tece_max, maiz_max, trce_max, rice_max, + rapeseed_max, soybean_max, sunflower_max, groundnut_max, + oilpalm_max, puls_max, potato_max, cassava_max, + sugr_cane_max, sugr_beet_max, others_max, foddr_max, + fiber_max, begr_max, betr_max + biomass_min, legumes_min, stalk_min, others_min, + minor_min, cereals_min, betr_min/ + + + rotamax30(rota30) rotational maximum rules + /cereals1_max, cereals2_max, cereals_excl_rice_max, stalk_max, + resistant_max, oilcrops_max, + legumes_max, rootsrape_max, roots_max, rape_sugr_max, biomass_max, + tece_max, maiz_max, trce_max, rice_max, + rapeseed_max, soybean_max, sunflower_max, groundnut_max, + oilpalm_max, puls_max, potato_max, cassava_max, + sugr_cane_max, sugr_beet_max, others_max, foddr_max, + fiber_max, begr_max, betr_max/ + + rotamin30(rota30) rotational minimum rules + /biomass_min, legumes_min, stalk_min, others_min, + minor_min, cereals_min, betr_min/ + + rotamax_red30(rotamax30) Maximum crop rotation reduced set + rotamin_red30(rotamin30) Minimum crop rotation reduced set + +* crop rotation groups: +* cereals or grasses are very favourable to loosen soils, therefore minimum constraint +* legumes need longer rotations, only soybean can and is cultivated every 2 years +* rapeseed and beets have same nematodes +* root crops have similar diseases + +* Sustainable practices: +* >=5% set-aside, >=5% biomass crops that approximate agroforestry systems +* six fold crop rotation of the remaining 90% +* at least one legume slot in crop rotation +* crop groups with multiple members like tece or foddr are allowed multiple slots +* one percent fruits and vegs in each cell for regional demand + + rota_kcr30(rota30, kcr) Mapping of crop types into crop rotation types + / cereals1_max . (tece, maiz, trce, rice_pro) + cereals2_max . (tece, maiz, trce, rice_pro) + cereals_excl_rice_max . (tece, maiz, trce) + stalk_max . (tece, maiz, trce, rice_pro, sugr_cane, begr, foddr) + resistant_max . (begr,betr,foddr,sugr_cane,cottn_pro,oilpalm,others) + oilcrops_max . (sunflower, rapeseed) + legumes_max . (foddr, puls_pro, soybean, groundnut) + rootsrape_max . (sugr_beet, cassav_sp, potato, rapeseed) + roots_max . (sugr_beet, cassav_sp, potato) + rape_sugr_max . (rapeseed, sugr_beet) + biomass_max . (sugr_cane, oilpalm, begr, betr) + + tece_max . (tece) + maiz_max . (maiz) + trce_max . (trce) + rice_max . (rice_pro) + rapeseed_max . (rapeseed) + soybean_max . (soybean) + sunflower_max . (sunflower) + groundnut_max . (groundnut) + oilpalm_max . (oilpalm) + puls_max . (puls_pro) + potato_max . (potato) + cassava_max . (cassav_sp) + sugr_cane_max . (sugr_cane) + sugr_beet_max . (sugr_beet) + others_max . (others) + foddr_max . (foddr) + fiber_max . (cottn_pro) + begr_max . (begr) + betr_max . (betr) + + biomass_min . (sugr_cane, oilpalm, begr, betr) + legumes_min . (soybean, groundnut, puls_pro, foddr) + minor_min . (sunflower, rapeseed, sugr_beet, cassav_sp, potato, others) + cereals_min . (tece, maiz, trce, rice_pro) + stalk_min . (tece, maiz, trce, rice_pro, sugr_cane, foddr) + others_min . (others) + betr_min . (betr) + / + + kbe30(kcr) bio energy activities + / betr, begr / + + bioen_type_30(kbe30) dynamic set bioen type + bioen_water_30(w) dynamic set bioen water + + crop_ann30(kcr) annual crops + / tece, maiz, trce, rice_pro, rapeseed, sunflower, potato, cassav_sp, sugr_beet, others, cottn_pro, foddr, soybean, groundnut, puls_pro / + + crop_per30(kcr) perennial crops + / oilpalm, begr, sugr_cane, betr / + +; diff --git a/modules/30_crop/module.gms b/modules/30_croparea/module.gms similarity index 76% rename from modules/30_crop/module.gms rename to modules/30_croparea/module.gms index 2c80e2a8db..3b8eedc704 100644 --- a/modules/30_crop/module.gms +++ b/modules/30_croparea/module.gms @@ -15,7 +15,6 @@ *' @authors Jan Philipp Dietrich, Florian Humpenöder, Benjamin Bodirsky *###################### R SECTION START (MODULETYPES) ########################## -$Ifi "%crop%" == "endo_apr21" $include "./modules/30_crop/endo_apr21/realization.gms" -$Ifi "%crop%" == "penalty_apr22" $include "./modules/30_crop/penalty_apr22/realization.gms" -$Ifi "%crop%" == "rotation_apr22" $include "./modules/30_crop/rotation_apr22/realization.gms" +$Ifi "%croparea%" == "detail_apr24" $include "./modules/30_croparea/detail_apr24/realization.gms" +$Ifi "%croparea%" == "simple_apr24" $include "./modules/30_croparea/simple_apr24/realization.gms" *###################### R SECTION END (MODULETYPES) ############################ diff --git a/modules/30_crop/endo_apr21/declarations.gms b/modules/30_croparea/simple_apr24/declarations.gms similarity index 100% rename from modules/30_crop/endo_apr21/declarations.gms rename to modules/30_croparea/simple_apr24/declarations.gms diff --git a/modules/30_crop/endo_apr21/equations.gms b/modules/30_croparea/simple_apr24/equations.gms similarity index 73% rename from modules/30_crop/endo_apr21/equations.gms rename to modules/30_croparea/simple_apr24/equations.gms index 626f0ce4a6..40b4ff85d8 100644 --- a/modules/30_crop/endo_apr21/equations.gms +++ b/modules/30_croparea/simple_apr24/equations.gms @@ -35,17 +35,17 @@ *' The carbon stocks of the above ground carbon pools are calculated based on croparea and related carbon density. - q30_carbon(j2,ag_pools) .. - vm_carbon_stock_croparea(j2,ag_pools) =e= - sum((kcr,w), vm_area(j2,kcr,w)) * sum(ct, fm_carbon_density(ct,j2,"crop",ag_pools)); + q30_carbon(j2,ag_pools) .. + vm_carbon_stock_croparea(j2,ag_pools) =e= + sum((kcr,w), vm_area(j2,kcr,w)) * sum(ct, fm_carbon_density(ct,j2,"crop",ag_pools)); *' The biodiversity value for cropland is calculated separately for annual and perennial crops: - q30_bv_ann(j2,potnatveg) .. vm_bv(j2,"crop_ann",potnatveg) - =e= - sum((crop_ann30,w), vm_area(j2,crop_ann30,w)) * fm_bii_coeff("crop_ann",potnatveg) * fm_luh2_side_layers(j2,potnatveg); + q30_bv_ann(j2,potnatveg) .. + vm_bv(j2,"crop_ann",potnatveg) =e= + sum((crop_ann30,w), vm_area(j2,crop_ann30,w)) * fm_bii_coeff("crop_ann",potnatveg) * fm_luh2_side_layers(j2,potnatveg); - q30_bv_per(j2,potnatveg) .. vm_bv(j2,"crop_per",potnatveg) - =e= - sum((crop_per30,w), vm_area(j2,crop_per30,w)) * fm_bii_coeff("crop_per",potnatveg) * fm_luh2_side_layers(j2,potnatveg); + q30_bv_per(j2,potnatveg) .. + vm_bv(j2,"crop_per",potnatveg) =e= + sum((crop_per30,w), vm_area(j2,crop_per30,w)) * fm_bii_coeff("crop_per",potnatveg) * fm_luh2_side_layers(j2,potnatveg); diff --git a/modules/30_crop/endo_apr21/input.gms b/modules/30_croparea/simple_apr24/input.gms similarity index 87% rename from modules/30_crop/endo_apr21/input.gms rename to modules/30_croparea/simple_apr24/input.gms index aeacce22d7..02c72d13d3 100644 --- a/modules/30_crop/endo_apr21/input.gms +++ b/modules/30_croparea/simple_apr24/input.gms @@ -31,7 +31,7 @@ $endif table fm_croparea(t_all,j,w,kcr) Different croparea type areas (mio. ha) $ondelim -$include "./modules/30_crop/endo_apr21/input/f30_croparea_w_initialisation.cs3" +$include "./modules/30_croparea/simple_apr24/input/f30_croparea_w_initialisation.cs3" $offdelim ; m_fillmissingyears(fm_croparea,"j,w,kcr"); @@ -41,7 +41,7 @@ m_fillmissingyears(fm_croparea,"j,w,kcr"); parameter f30_rotation_max_shr(crp30) Maximum allowed area shares for each crop type (1) / $ondelim -$include "./modules/30_crop/endo_apr21/input/f30_rotation_max.csv" +$include "./modules/30_croparea/simple_apr24/input/f30_rotation_max.csv" $offdelim /; $if "%c30_rotation_constraints%" == "off" f30_rotation_max_shr(crp30) = 1; @@ -50,7 +50,7 @@ $if "%c30_rotation_constraints%" == "off" f30_rotation_max_shr(crp30) = 1; parameter f30_rotation_min_shr(crp30) Minimum allowed area shares for each crop type (1) / $ondelim -$include "./modules/30_crop/endo_apr21/input/f30_rotation_min.csv" +$include "./modules/30_croparea/simple_apr24/input/f30_rotation_min.csv" $offdelim /; $if "%c30_rotation_constraints%" == "off" f30_rotation_min_shr(crp30) = 0; diff --git a/modules/30_crop/endo_apr21/input/files b/modules/30_croparea/simple_apr24/input/files similarity index 100% rename from modules/30_crop/endo_apr21/input/files rename to modules/30_croparea/simple_apr24/input/files diff --git a/modules/30_crop/endo_apr21/not_used.txt b/modules/30_croparea/simple_apr24/not_used.txt similarity index 100% rename from modules/30_crop/endo_apr21/not_used.txt rename to modules/30_croparea/simple_apr24/not_used.txt diff --git a/modules/30_crop/endo_apr21/postsolve.gms b/modules/30_croparea/simple_apr24/postsolve.gms similarity index 100% rename from modules/30_crop/endo_apr21/postsolve.gms rename to modules/30_croparea/simple_apr24/postsolve.gms diff --git a/modules/30_crop/endo_apr21/preloop.gms b/modules/30_croparea/simple_apr24/preloop.gms similarity index 100% rename from modules/30_crop/endo_apr21/preloop.gms rename to modules/30_croparea/simple_apr24/preloop.gms diff --git a/modules/30_crop/endo_apr21/presolve.gms b/modules/30_croparea/simple_apr24/presolve.gms similarity index 100% rename from modules/30_crop/endo_apr21/presolve.gms rename to modules/30_croparea/simple_apr24/presolve.gms diff --git a/modules/30_croparea/simple_apr24/realization.gms b/modules/30_croparea/simple_apr24/realization.gms new file mode 100644 index 0000000000..f4c9140600 --- /dev/null +++ b/modules/30_croparea/simple_apr24/realization.gms @@ -0,0 +1,28 @@ +*** | (C) 2008-2024 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 This realization calculates the crop specific +*' agricultural crop area endogenously based on yield data provided by +*' module [14_yields] and simplified rotational constraints. +*' In addition, corresponding carbons stocks and BII values are calculated. +*' +*' The crop specific interface `vm_area` is used in many other modules, +*' including [18_residues], [38_factor_costs], +*' [41_area_equipped_for_irrigation], [42_water_demand], [50_nr_soil_budget], +*' [53_methane] and [59_som]. + +*' @limitations There are currently no known limitations of this realization. + +*####################### R SECTION START (PHASES) ############################## +$Ifi "%phase%" == "sets" $include "./modules/30_croparea/simple_apr24/sets.gms" +$Ifi "%phase%" == "declarations" $include "./modules/30_croparea/simple_apr24/declarations.gms" +$Ifi "%phase%" == "input" $include "./modules/30_croparea/simple_apr24/input.gms" +$Ifi "%phase%" == "equations" $include "./modules/30_croparea/simple_apr24/equations.gms" +$Ifi "%phase%" == "preloop" $include "./modules/30_croparea/simple_apr24/preloop.gms" +$Ifi "%phase%" == "presolve" $include "./modules/30_croparea/simple_apr24/presolve.gms" +$Ifi "%phase%" == "postsolve" $include "./modules/30_croparea/simple_apr24/postsolve.gms" +*######################## R SECTION END (PHASES) ############################### diff --git a/modules/30_crop/endo_apr21/sets.gms b/modules/30_croparea/simple_apr24/sets.gms similarity index 100% rename from modules/30_crop/endo_apr21/sets.gms rename to modules/30_croparea/simple_apr24/sets.gms diff --git a/modules/include.gms b/modules/include.gms index e46128a47c..d00709aaec 100644 --- a/modules/include.gms +++ b/modules/include.gms @@ -24,7 +24,7 @@ $include "./modules/21_trade/module.gms" $include "./modules/22_land_conservation/module.gms" $include "./modules/28_ageclass/module.gms" $include "./modules/29_cropland/module.gms" -$include "./modules/30_crop/module.gms" +$include "./modules/30_croparea/module.gms" $include "./modules/31_past/module.gms" $include "./modules/32_forestry/module.gms" $include "./modules/34_urban/module.gms" From 350667aeb418410e7a029cab529764aaee0baacb Mon Sep 17 00:00:00 2001 From: florianh Date: Sun, 21 Apr 2024 16:18:41 +0200 Subject: [PATCH 017/133] partial commit to save work --- config/default.cfg | 2 +- modules/30_croparea/detail_apr24/input.gms | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index 22ec4d5252..b3cb85f97b 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -776,7 +776,7 @@ cfg$gms$c30_rotation_rules <- "default" # def = "default" # * none (no incentives), default (best guess), # * legumes (increased incentives for legumes), agroecology (mix), # * betr500 and betr1000 (incentives for short rotation agroforestry trees) -cfg$gms$c30_rotation_incentives <- "default" # def = "default" +cfg$gms$c30_rotation_incentives <- "none" # def = "none" # * Year by which rotation scenario is fully implemented: # * Start year: diff --git a/modules/30_croparea/detail_apr24/input.gms b/modules/30_croparea/detail_apr24/input.gms index 6db7c4dfeb..4a915b8a8f 100644 --- a/modules/30_croparea/detail_apr24/input.gms +++ b/modules/30_croparea/detail_apr24/input.gms @@ -12,9 +12,10 @@ $setglobal c30_bioen_water rainfed * options: rainfed, irrigated, all $setglobal c30_rotation_rules default -*options: none, default, legumes, betr500, betr1000, agroecology +*options: min, default, good, good_20div, setaside, legumes, sixfoldrotation, agroecology, +* betr0, betr10, betr20, betr25, betr30, betr40, betr50, FSEC -$setglobal c30_rotation_incentives default +$setglobal c30_rotation_incentives none *options: none, default, legumes, betr500, betr1000, agroecology From abdc8c86dabef84b60746edc154a5aa0abfe16b0 Mon Sep 17 00:00:00 2001 From: florianh Date: Sun, 21 Apr 2024 16:30:43 +0200 Subject: [PATCH 018/133] partial commit to save work --- config/scenario_fsec.csv | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/config/scenario_fsec.csv b/config/scenario_fsec.csv index 8f6ee53db2..705bbe9beb 100644 --- a/config/scenario_fsec.csv +++ b/config/scenario_fsec.csv @@ -26,8 +26,9 @@ gms$c15_food_scenario;;;SSP1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$c21_trade_liberalization;;;;;;;;;;;;;;;;;;;;;;;l908080r807070;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$s21_trade_bal_damper;0.65;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$c22_protect_scenario;;;;;;;;;;;;;;;;;;;;;;;;;;;;;BH_IFL;;;;;;;;;;;;;;;;;;;;;; -gms$crop;penalty_apr22;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -gms$c30_rotation_scenario;default;;;;;;;;;;;;;;;;;;;;;;;;;;;agroecology;;;;;;;;;;;;;;;;;;;;;;; +gms$croparea;detail_apr24;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c30_rotation_rules;FSEC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +gms$c30_rotation_incentives;default;;;;;;;;;;;;;;;;;;;;;;;;;;;agroecology;;;;;;;;;;;;;;;;;;;;;;; gms$s30_rotation_scenario_target;2050;;;;;;;;;;;;;;;;;;;;;;;;;;;2050;;;;;;;;;;;;;;;;;;;;;;; gms$c29_marginal_land;q33_marginal;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$c30_bioen_water;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;rainfed;;;;;;;;;;;;;;;;;;;;; From 67b57fc3c94c37b71bfe1205099dd3185ae03f80 Mon Sep 17 00:00:00 2001 From: florianh Date: Sun, 21 Apr 2024 18:27:41 +0200 Subject: [PATCH 019/133] partial commit to save work --- config/default.cfg | 2 ++ modules/29_cropland/detail_apr24/declarations.gms | 8 ++++---- modules/29_cropland/detail_apr24/equations.gms | 4 ++-- modules/29_cropland/detail_apr24/input.gms | 8 ++++---- modules/29_cropland/detail_apr24/presolve.gms | 10 ++++------ 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index b3cb85f97b..f639240e8f 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -729,6 +729,8 @@ cfg$gms$s29_treecover_scenario_start <- 2020 # def = 2020 cfg$gms$s29_treecover_scenario_target <- 2050 # def = 2050 # * Penalty for violation of treecover target cfg$gms$s29_treecover_penalty <- 0 #def = 0 +# * Cropland treecover can decrease (1) or not (0) +cfg$gms$s29_treecover_decrease <- 0 #def = 0 # * Minimum share of fallow land on total cropland area (including croparea, fallow land and tree cover). # * s29_fallow_target is faded in linearly between s29_fallow_scenario_start and s29_fallow_scenario_target. diff --git a/modules/29_cropland/detail_apr24/declarations.gms b/modules/29_cropland/detail_apr24/declarations.gms index 14405e207a..0d3aaf5d0e 100644 --- a/modules/29_cropland/detail_apr24/declarations.gms +++ b/modules/29_cropland/detail_apr24/declarations.gms @@ -21,16 +21,16 @@ parameters i29_snv_scenario_fader(t_all) SNV scenario fader (1) i29_treecover_scenario_fader(t_all) Cropland treecover scenario fader (1) - i29_treecover_target(t,j) Target share for treecover on total cropland (1) - i29_treecover_penalty(t_all) Penalty for violation of treecover target (USD05MER per ha) + i29_treecover_target(t) Target share for treecover on total cropland (1) + i29_treecover_penalty(t) Penalty for violation of treecover target (USD05MER per ha) p29_treecover_bii_coeff(bii_class_secd,potnatveg) BII coefficient for cropland treecover (1) p29_carbon_density_ac(t,j,ac,ag_pools) Carbon density for ac and ag_pools (tC per ha) p29_treecover(t,j,ac) Cropland tree cover per age class (mio. ha) pc29_treecover(j,ac) Cropland tree cover per age class in current time step (mio. ha) i29_fallow_scenario_fader(t_all) Fallow land scenario fader (1) - i29_fallow_target(t_all) Target share for fallow land on total cropland (1) - i29_fallow_penalty(t_all) Penalty for violation of fallow target (USD05MER per ha) + i29_fallow_target(t) Target share for fallow land on total cropland (1) + i29_fallow_penalty(t) Penalty for violation of fallow target (USD05MER per ha) ; positive variables diff --git a/modules/29_cropland/detail_apr24/equations.gms b/modules/29_cropland/detail_apr24/equations.gms index 566441173f..9887e23df8 100644 --- a/modules/29_cropland/detail_apr24/equations.gms +++ b/modules/29_cropland/detail_apr24/equations.gms @@ -89,7 +89,7 @@ q29_treecover_shr(j2)$(s29_implementation = 1) .. sum(ac, v29_treecover(j2,ac)) =g= - sum(ct, i29_treecover_target(ct,j2)) * vm_land(j2,"crop"); + sum(ct, i29_treecover_target(ct)) * vm_land(j2,"crop"); *' Otherwise, a penalty is applied for the violation of treecover rules. *' The penalty applies to the missing treecover area, i.e. where treecover area @@ -97,7 +97,7 @@ q29_treecover_missing(j2)$(s29_implementation = 0) .. v29_treecover_missing(j2) =g= - vm_land(j2,"crop") * sum(ct, i29_treecover_target(ct,j2)) - sum(ac, v29_treecover(j2,ac)); + vm_land(j2,"crop") * sum(ct, i29_treecover_target(ct)) - sum(ac, v29_treecover(j2,ac)); q29_treecover_penalty(j2) .. v29_treecover_penalty(j2) =e= diff --git a/modules/29_cropland/detail_apr24/input.gms b/modules/29_cropland/detail_apr24/input.gms index f2458f3ece..e050123544 100644 --- a/modules/29_cropland/detail_apr24/input.gms +++ b/modules/29_cropland/detail_apr24/input.gms @@ -22,12 +22,12 @@ scalars s29_treecover_decrease Cropland treecover can decrease (1) or not (0) / 0 / s29_treecover_scenario_start Cropland treecover scenario start year / 2020 / s29_treecover_scenario_target Cropland treecover scenario target year / 2050 / - s29_treecover_target Target share of treecover on total cropland (1) / 0.3 / - s29_treecover_penalty Penalty for violation of treecover target (USD05MER per ha) / 500 / + s29_treecover_target Target share of treecover on total cropland (1) / 0 / + s29_treecover_penalty Penalty for violation of treecover target (USD05MER per ha) / 0 / s29_fallow_scenario_start Fallow land scenario start year / 2020 / s29_fallow_scenario_target Fallow land scenario target year / 2050 / - s29_fallow_target Target share of fallow land on total cropland (1) / 0.3 / - s29_fallow_penalty Penalty for violation of fallow target (USD05MER per ha) / 500 / + s29_fallow_target Target share of fallow land on total cropland (1) / 0 / + s29_fallow_penalty Penalty for violation of fallow target (USD05MER per ha) / 0 / s29_implementation Switch for rule-based (1) or penalty-based (0) implementation of fallow and treecover targets / 1 / ; diff --git a/modules/29_cropland/detail_apr24/presolve.gms b/modules/29_cropland/detail_apr24/presolve.gms index 4fb606c500..b865150ab0 100644 --- a/modules/29_cropland/detail_apr24/presolve.gms +++ b/modules/29_cropland/detail_apr24/presolve.gms @@ -56,11 +56,9 @@ else * create treecover target and penalty scenario -i29_treecover_target(t,j) = - ((1-i29_treecover_scenario_fader(t)) * sum(ac, pc29_treecover(j,ac))/pcm_land(j,"crop"))$(pcm_land(j,"crop") > 1e-10) + - (i29_treecover_scenario_fader(t) * s29_treecover_target); -i29_treecover_penalty(t_all) = s29_treecover_penalty * i29_treecover_scenario_fader(t_all); +i29_treecover_target(t) = s29_treecover_target * i29_treecover_scenario_fader(t); +i29_treecover_penalty(t) = s29_treecover_penalty * i29_treecover_scenario_fader(t); * create fallow land target and penalty scenario -i29_fallow_target(t_all) = s29_fallow_target * i29_fallow_scenario_fader(t_all); -i29_fallow_penalty(t_all) = s29_fallow_penalty * i29_fallow_scenario_fader(t_all); +i29_fallow_target(t) = s29_fallow_target * i29_fallow_scenario_fader(t); +i29_fallow_penalty(t) = s29_fallow_penalty * i29_fallow_scenario_fader(t); From a0b0e153b2756204260efdc4c34306564f59381d Mon Sep 17 00:00:00 2001 From: florianh Date: Sun, 21 Apr 2024 21:01:06 +0200 Subject: [PATCH 020/133] bugfix --- modules/29_cropland/simple_apr24/equations.gms | 4 +--- modules/32_forestry/dynamic_feb21/presolve.gms | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/29_cropland/simple_apr24/equations.gms b/modules/29_cropland/simple_apr24/equations.gms index 1088543e1c..a5cd2a0dd2 100644 --- a/modules/29_cropland/simple_apr24/equations.gms +++ b/modules/29_cropland/simple_apr24/equations.gms @@ -16,9 +16,7 @@ *' We use a suitability index (SI) map from @zabel_global_2014 to exclude areas *' from cropland production that have a low suitability, e.g. due to steep slopes, *' to estimate the available cropland area. The cultivated area therefore has -*' to be smaller than the available cropland area. Moreover, the available cropland -*' can be reduced by constraining the cropland area in favour of other land types, -*' in order to increase compositional heterogeneity of land types at the cell level. +*' to be smaller than the available cropland area. q29_avl_cropland(j2) .. vm_land(j2,"crop") =l= sum(ct, p29_avl_cropland(ct,j2)); diff --git a/modules/32_forestry/dynamic_feb21/presolve.gms b/modules/32_forestry/dynamic_feb21/presolve.gms index 4ad3a9b119..3491620843 100644 --- a/modules/32_forestry/dynamic_feb21/presolve.gms +++ b/modules/32_forestry/dynamic_feb21/presolve.gms @@ -14,7 +14,7 @@ v32_land_reduction.fx(j,type32,ac_est) = 0; p32_aff_pol_timestep("y1995",j) = 0; p32_aff_pol_timestep(t,j)$(ord(t)>1) = p32_aff_pol(t,j) - p32_aff_pol(t-1,j); * Suitable area (`p32_aff_pot`) for NPI/NDC afforestation - p32_aff_pot(t,j) = (vm_land.l(j,"crop") - vm_land.lo(j,"crop")) + (vm_land.l(j,"past") - vm_land.lo(j,"past")) - pm_land_conservation(t,j,"other","restore"); + p32_aff_pot(t,j) = sum((kcr,w),vm_area.l(j,kcr,w) - vm_area.lo(j,kcr,w)) + (vm_land.l(j,"past") - vm_land.lo(j,"past")) - pm_land_conservation(t,j,"other","restore"); * suitable area `p32_aff_pot` can be negative, if land restoration is switched on (level smaller than lower bound), therefore set negative values to 0 p32_aff_pot(t,j)$(p32_aff_pot(t,j) < 0) = 0; * Limit prescribed NPI/NDC afforestation in `p32_aff_pol_timestep` if not enough suitable area (`p32_aff_pot`) for afforestation is available From 43fd4fd215611a4c2389237f930531685ea1e541 Mon Sep 17 00:00:00 2001 From: florianh Date: Sun, 21 Apr 2024 21:23:57 +0200 Subject: [PATCH 021/133] bugfix --- config/scenario_fsec.csv | 1 + 1 file changed, 1 insertion(+) diff --git a/config/scenario_fsec.csv b/config/scenario_fsec.csv index 705bbe9beb..cd0fc1a682 100644 --- a/config/scenario_fsec.csv +++ b/config/scenario_fsec.csv @@ -29,6 +29,7 @@ gms$c22_protect_scenario;;;;;;;;;;;;;;;;;;;;;;;;;;;;;BH_IFL;;;;;;;;;;;;;;;;;;;;; gms$croparea;detail_apr24;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$c30_rotation_rules;FSEC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$c30_rotation_incentives;default;;;;;;;;;;;;;;;;;;;;;;;;;;;agroecology;;;;;;;;;;;;;;;;;;;;;;; +gms$s30_implementation;0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$s30_rotation_scenario_target;2050;;;;;;;;;;;;;;;;;;;;;;;;;;;2050;;;;;;;;;;;;;;;;;;;;;;; gms$c29_marginal_land;q33_marginal;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$c30_bioen_water;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;rainfed;;;;;;;;;;;;;;;;;;;;; From 8333584f2d89a2e8499a2e1bc0fa09f98d9548bd Mon Sep 17 00:00:00 2001 From: florianh Date: Mon, 22 Apr 2024 09:28:44 +0200 Subject: [PATCH 022/133] balance variable NPI NDC reforestation --- modules/32_forestry/dynamic_feb21/declarations.gms | 6 ++++-- modules/32_forestry/dynamic_feb21/equations.gms | 4 ++-- modules/32_forestry/dynamic_feb21/input.gms | 2 +- modules/32_forestry/dynamic_feb21/postsolve.gms | 4 ++++ 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/modules/32_forestry/dynamic_feb21/declarations.gms b/modules/32_forestry/dynamic_feb21/declarations.gms index 199e78df99..b5ee97415c 100644 --- a/modules/32_forestry/dynamic_feb21/declarations.gms +++ b/modules/32_forestry/dynamic_feb21/declarations.gms @@ -66,7 +66,8 @@ positive variables vm_cost_fore(i) Forestry costs (Mio USD) v32_cost_hvarea(i) Cost of harvesting timber from forests (mio. USD per yr) v32_land(j,type32,ac) Forestry land pools (mio. ha) - v32_land_missing(j) Forestry land which can be used at extrmemly high costs in case not enough area is available for new establishment (mio. ha) + v32_land_missing(j) Technical area balance term for timber plantation establishment (mio. ha) + v32_land_missing_ndc(j) Technical area balance term for NPI NDC reforestation (mio. ha) vm_landdiff_forestry Aggregated difference in forestry land compared to previous timestep (mio. ha) v32_cost_recur(i) Recurring forest management costs (USD per ha) v32_land_expansion(j,type32) Forestry land expansion (mio. ha) @@ -119,7 +120,8 @@ parameters ov_cost_fore(t,i,type) Forestry costs (Mio USD) ov32_cost_hvarea(t,i,type) Cost of harvesting timber from forests (mio. USD per yr) ov32_land(t,j,type32,ac,type) Forestry land pools (mio. ha) - ov32_land_missing(t,j,type) Forestry land which can be used at extrmemly high costs in case not enough area is available for new establishment (mio. ha) + ov32_land_missing(t,j,type) Technical area balance term for timber plantation establishment (mio. ha) + ov32_land_missing_ndc(t,j,type) Technical area balance term for NPI NDC reforestation (mio. ha) ov_landdiff_forestry(t,type) Aggregated difference in forestry land compared to previous timestep (mio. ha) ov32_cost_recur(t,i,type) Recurring forest management costs (USD per ha) ov32_land_expansion(t,j,type32,type) Forestry land expansion (mio. ha) diff --git a/modules/32_forestry/dynamic_feb21/equations.gms b/modules/32_forestry/dynamic_feb21/equations.gms index 259fdc7206..483ced9c3c 100644 --- a/modules/32_forestry/dynamic_feb21/equations.gms +++ b/modules/32_forestry/dynamic_feb21/equations.gms @@ -24,7 +24,7 @@ q32_cost_total(i2) .. vm_cost_fore(i2) =e= v32_cost_recur(i2) + v32_cost_establishment(i2) + v32_cost_hvarea(i2) - + sum(cell(i2,j2), v32_land_missing(j2)) * s32_free_land_cost + + sum(cell(i2,j2), v32_land_missing(j2) + v32_land_missing_ndc(j2)) * s32_free_land_cost ; *----------------------------------------------- @@ -68,7 +68,7 @@ sum(ac_est, v32_land(j2,"aff",ac_est)) =l= sum(ac, v32_land(j2,"aff",ac)) - sum( *' The constraint `q32_aff_pol` accounts for the exogenous afforestation prescribed by NPI/NDC policies. q32_aff_pol(j2) .. - sum(ac_est, v32_land(j2,"ndc",ac_est)) =e= sum(ct, p32_aff_pol_timestep(ct,j2)); + sum(ac_est, v32_land(j2,"ndc",ac_est)) =e= sum(ct, p32_aff_pol_timestep(ct,j2)) + v32_land_missing_ndc(j2); *' The constraint `q32_max_aff` accounts for the allowed maximum global endogenous *' afforestation defined in `i32_max_aff_area_glo`. diff --git a/modules/32_forestry/dynamic_feb21/input.gms b/modules/32_forestry/dynamic_feb21/input.gms index 961bb68cb5..7535dd5077 100644 --- a/modules/32_forestry/dynamic_feb21/input.gms +++ b/modules/32_forestry/dynamic_feb21/input.gms @@ -38,7 +38,7 @@ scalars s32_faustmann_rotation Switch to activate faustmann rotations (1=on 0=off) / 0 / s32_initial_distribution Switch to Activate ageclass distribution in plantations 0=off 1=equal distribution 2=FAO distribution 3=Poulter distribution 4=Manual distribution (1) / 0 / s32_price Price for timber (USD) / 45 / - s32_free_land_cost Very high cost for using non existing land for plantation establishment (USD per ha) /1000000/ + s32_free_land_cost Penalty for technial area balance term (USD per ha) /1000000/ s32_max_aff_area Maximum total global afforestation (mio. ha) / Inf / s32_aff_plantation Switch for using growth curves for afforestation 0=natveg 1=plantations (1) / 0 / s32_tcre_local Switch for local (1) or global (0) TRCE factors (1) / 1 / diff --git a/modules/32_forestry/dynamic_feb21/postsolve.gms b/modules/32_forestry/dynamic_feb21/postsolve.gms index 69a4b4e0de..6ac3f7ed22 100644 --- a/modules/32_forestry/dynamic_feb21/postsolve.gms +++ b/modules/32_forestry/dynamic_feb21/postsolve.gms @@ -14,6 +14,7 @@ p32_land(t,j,type32,ac) = v32_land.l(j,type32,ac); ov32_cost_hvarea(t,i,"marginal") = v32_cost_hvarea.m(i); ov32_land(t,j,type32,ac,"marginal") = v32_land.m(j,type32,ac); ov32_land_missing(t,j,"marginal") = v32_land_missing.m(j); + ov32_land_missing_ndc(t,j,"marginal") = v32_land_missing_ndc.m(j); ov_landdiff_forestry(t,"marginal") = vm_landdiff_forestry.m; ov32_cost_recur(t,i,"marginal") = v32_cost_recur.m(i); ov32_land_expansion(t,j,type32,"marginal") = v32_land_expansion.m(j,type32); @@ -56,6 +57,7 @@ p32_land(t,j,type32,ac) = v32_land.l(j,type32,ac); ov32_cost_hvarea(t,i,"level") = v32_cost_hvarea.l(i); ov32_land(t,j,type32,ac,"level") = v32_land.l(j,type32,ac); ov32_land_missing(t,j,"level") = v32_land_missing.l(j); + ov32_land_missing_ndc(t,j,"level") = v32_land_missing_ndc.l(j); ov_landdiff_forestry(t,"level") = vm_landdiff_forestry.l; ov32_cost_recur(t,i,"level") = v32_cost_recur.l(i); ov32_land_expansion(t,j,type32,"level") = v32_land_expansion.l(j,type32); @@ -98,6 +100,7 @@ p32_land(t,j,type32,ac) = v32_land.l(j,type32,ac); ov32_cost_hvarea(t,i,"upper") = v32_cost_hvarea.up(i); ov32_land(t,j,type32,ac,"upper") = v32_land.up(j,type32,ac); ov32_land_missing(t,j,"upper") = v32_land_missing.up(j); + ov32_land_missing_ndc(t,j,"upper") = v32_land_missing_ndc.up(j); ov_landdiff_forestry(t,"upper") = vm_landdiff_forestry.up; ov32_cost_recur(t,i,"upper") = v32_cost_recur.up(i); ov32_land_expansion(t,j,type32,"upper") = v32_land_expansion.up(j,type32); @@ -140,6 +143,7 @@ p32_land(t,j,type32,ac) = v32_land.l(j,type32,ac); ov32_cost_hvarea(t,i,"lower") = v32_cost_hvarea.lo(i); ov32_land(t,j,type32,ac,"lower") = v32_land.lo(j,type32,ac); ov32_land_missing(t,j,"lower") = v32_land_missing.lo(j); + ov32_land_missing_ndc(t,j,"lower") = v32_land_missing_ndc.lo(j); ov_landdiff_forestry(t,"lower") = vm_landdiff_forestry.lo; ov32_cost_recur(t,i,"lower") = v32_cost_recur.lo(i); ov32_land_expansion(t,j,type32,"lower") = v32_land_expansion.lo(j,type32); From 10142261c0cdeceeec30f1c3e79c86e3a5491ac1 Mon Sep 17 00:00:00 2001 From: florianh Date: Mon, 22 Apr 2024 11:03:24 +0200 Subject: [PATCH 023/133] bugfixes --- config/default.cfg | 2 +- .../30_croparea/detail_apr24/declarations.gms | 1 + .../30_croparea/detail_apr24/equations.gms | 20 +++++++++---------- modules/30_croparea/detail_apr24/presolve.gms | 6 ++++-- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index 5ab3f0bf1d..c1b4cde3a3 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -26,7 +26,7 @@ cfg$input <- c(regional = "rev4.104_h12_magpie.tgz", cellular = "rev4.104_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", validation = "rev4.104_h12_validation.tgz", additional = "additional_data_rev4.48.tgz", - calibration = "calibration_H12_26Mar24.tgz") + calibration = "calibration_H12_cropareaSimple_21Apr24.tgz") # NOTE: It is recommended to recalibrate the model when changing cellular input data # as well as for any other setting that would affect initial values in the model, diff --git a/modules/30_croparea/detail_apr24/declarations.gms b/modules/30_croparea/detail_apr24/declarations.gms index ff46199365..b0ef264b21 100644 --- a/modules/30_croparea/detail_apr24/declarations.gms +++ b/modules/30_croparea/detail_apr24/declarations.gms @@ -9,6 +9,7 @@ parameters i30_rotation_rules(t_all,rota30) Rotational constraints (1) i30_rotation_incentives(t_all,rota30) Penalty for violating rotational constraints (USD05MER per ha) p30_rotation_scenario_fader(t_all) Crop rotation scenario fader (1) + i30_implementation Switch for rule-based (1) or penalty-based (0) implementation of rotation scenarios ; positive variables diff --git a/modules/30_croparea/detail_apr24/equations.gms b/modules/30_croparea/detail_apr24/equations.gms index 034de74216..4b58d4e001 100644 --- a/modules/30_croparea/detail_apr24/equations.gms +++ b/modules/30_croparea/detail_apr24/equations.gms @@ -15,8 +15,8 @@ vm_prod(j2,kcr) =e= sum(w, vm_area(j2,kcr,w) * vm_yld(j2,kcr,w)); *' Rotational constraints prevent over-specialization. In this realization, -*' they are either implemented via a rules (s30_implementation = 1) or -*' a penalty payment if the constraints are violated (s30_implementation = 0). +*' they are either implemented via a rules (i30_implementation = 1) or +*' a penalty payment if the constraints are violated (i30_implementation = 0). q30_rotation_penalty(i2) .. vm_rotation_penalty(i2) =g= @@ -26,31 +26,31 @@ * sum(ct, i30_rotation_incentives(ct,rotamax_red30))) ); - q30_rotation_max(j2,rotamax_red30)$(s30_implementation = 1) .. + q30_rotation_max(j2,rotamax_red30)$(i30_implementation = 1) .. sum((rota_kcr30(rotamax_red30,kcr),w), vm_area(j2,kcr,w)) =l= - sum((kcr,w),vm_area(j2,kcr,w)) * sum(ct,i30_rotation_rules(ct,rotamax_red30)); + vm_land(j2,"crop") * sum(ct,i30_rotation_rules(ct,rotamax_red30)); - q30_rotation_min(j2,rotamin_red30)$(s30_implementation = 1) .. + q30_rotation_min(j2,rotamin_red30)$(i30_implementation = 1) .. sum((rota_kcr30(rotamin_red30,kcr),w), vm_area(j2,kcr,w)) =g= - sum((kcr,w),vm_area(j2,kcr,w)) * sum(ct,i30_rotation_rules(ct,rotamin_red30)); + vm_land(j2,"crop") * sum(ct,i30_rotation_rules(ct,rotamin_red30)); *' The penalty applies to the areas which exceed a certain maximum *' share of the land. Below this share, negative benefits are *' avoided by defining the penalty to be positive. - q30_rotation_max2(j2,rotamax_red30)$(s30_implementation = 0) .. + q30_rotation_max2(j2,rotamax_red30)$(i30_implementation = 0) .. v30_penalty(j2,rotamax_red30) =g= sum((rota_kcr30(rotamax_red30,kcr),w),vm_area(j2,kcr,w)) - - sum((kcr,w),vm_area(j2,kcr,w)) * sum(ct,i30_rotation_rules(ct,rotamax_red30)); + - vm_land(j2,"crop") * sum(ct,i30_rotation_rules(ct,rotamax_red30)); *' Minimum constraints apply penalties when a certain mimimum *' share of a group is not achieved. This is used to guarantee a minimum *' crop group diversity withing cells. - q30_rotation_min2(j2,rotamin_red30)$(s30_implementation = 0) .. + q30_rotation_min2(j2,rotamin_red30)$(i30_implementation = 0) .. v30_penalty(j2,rotamin_red30) =g= - sum((kcr,w),vm_area(j2,kcr,w)) * sum(ct,i30_rotation_rules(ct,rotamin_red30)) + vm_land(j2,"crop") * sum(ct,i30_rotation_rules(ct,rotamin_red30)) - sum((rota_kcr30(rotamin_red30,kcr),w), vm_area(j2,kcr,w)); diff --git a/modules/30_croparea/detail_apr24/presolve.gms b/modules/30_croparea/detail_apr24/presolve.gms index 4c8d3a4fa8..d95c14a256 100644 --- a/modules/30_croparea/detail_apr24/presolve.gms +++ b/modules/30_croparea/detail_apr24/presolve.gms @@ -14,11 +14,13 @@ vm_area.fx(j,kbe30,w)=0; *' SSP2 default settings are used for the historic period. if(m_year(t) <= sm_fix_SSP2, vm_area.up(j,kbe30,"rainfed") = Inf; + i30_implementation = 1; else vm_area.up(j,bioen_type_30,bioen_water_30) = Inf; + i30_implementation = s30_implementation; ); *' @stop * only activate constraints which are binding -rotamax_red30(rotamax30) = yes$(i30_rotation_incentives(t,rotamax30) > 0); -rotamin_red30(rotamin30) = yes$(i30_rotation_incentives(t,rotamin30) > 0); +rotamax_red30(rotamax30) = yes$(i30_rotation_rules(t,rotamax30) < 1); +rotamin_red30(rotamin30) = yes$(i30_rotation_rules(t,rotamin30) > 0); From ec92cc655a7e99f1f3dfa36fa5ed64ff48459b3e Mon Sep 17 00:00:00 2001 From: florianh Date: Mon, 22 Apr 2024 12:39:50 +0200 Subject: [PATCH 024/133] bugfix --- modules/30_croparea/simple_apr24/not_used.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/30_croparea/simple_apr24/not_used.txt b/modules/30_croparea/simple_apr24/not_used.txt index 1fd7a8461c..50edb3866a 100644 --- a/modules/30_croparea/simple_apr24/not_used.txt +++ b/modules/30_croparea/simple_apr24/not_used.txt @@ -1,2 +1,3 @@ name,type,reason vm_AEI,input,questionnaire +vm_land,input,not needed From 876fc9d891e918cbf20b61ab91ac58123ba5053e Mon Sep 17 00:00:00 2001 From: florianh Date: Mon, 22 Apr 2024 12:58:33 +0200 Subject: [PATCH 025/133] bugfix --- modules/30_croparea/detail_apr24/equations.gms | 8 ++++---- modules/30_croparea/simple_apr24/not_used.txt | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/modules/30_croparea/detail_apr24/equations.gms b/modules/30_croparea/detail_apr24/equations.gms index 4b58d4e001..95d5c18c24 100644 --- a/modules/30_croparea/detail_apr24/equations.gms +++ b/modules/30_croparea/detail_apr24/equations.gms @@ -28,11 +28,11 @@ q30_rotation_max(j2,rotamax_red30)$(i30_implementation = 1) .. sum((rota_kcr30(rotamax_red30,kcr),w), vm_area(j2,kcr,w)) =l= - vm_land(j2,"crop") * sum(ct,i30_rotation_rules(ct,rotamax_red30)); + sum((kcr,w),vm_area(j2,kcr,w)) * sum(ct,i30_rotation_rules(ct,rotamax_red30)); q30_rotation_min(j2,rotamin_red30)$(i30_implementation = 1) .. sum((rota_kcr30(rotamin_red30,kcr),w), vm_area(j2,kcr,w)) =g= - vm_land(j2,"crop") * sum(ct,i30_rotation_rules(ct,rotamin_red30)); + sum((kcr,w),vm_area(j2,kcr,w)) * sum(ct,i30_rotation_rules(ct,rotamin_red30)); *' The penalty applies to the areas which exceed a certain maximum *' share of the land. Below this share, negative benefits are @@ -41,7 +41,7 @@ q30_rotation_max2(j2,rotamax_red30)$(i30_implementation = 0) .. v30_penalty(j2,rotamax_red30) =g= sum((rota_kcr30(rotamax_red30,kcr),w),vm_area(j2,kcr,w)) - - vm_land(j2,"crop") * sum(ct,i30_rotation_rules(ct,rotamax_red30)); + - sum((kcr,w),vm_area(j2,kcr,w)) * sum(ct,i30_rotation_rules(ct,rotamax_red30)); *' Minimum constraints apply penalties when a certain mimimum @@ -50,7 +50,7 @@ q30_rotation_min2(j2,rotamin_red30)$(i30_implementation = 0) .. v30_penalty(j2,rotamin_red30) =g= - vm_land(j2,"crop") * sum(ct,i30_rotation_rules(ct,rotamin_red30)) + sum((kcr,w),vm_area(j2,kcr,w)) * sum(ct,i30_rotation_rules(ct,rotamin_red30)) - sum((rota_kcr30(rotamin_red30,kcr),w), vm_area(j2,kcr,w)); diff --git a/modules/30_croparea/simple_apr24/not_used.txt b/modules/30_croparea/simple_apr24/not_used.txt index 50edb3866a..1fd7a8461c 100644 --- a/modules/30_croparea/simple_apr24/not_used.txt +++ b/modules/30_croparea/simple_apr24/not_used.txt @@ -1,3 +1,2 @@ name,type,reason vm_AEI,input,questionnaire -vm_land,input,not needed From 8063487c11dd0a0c96ad09fef46d3f7457894e9a Mon Sep 17 00:00:00 2001 From: florianh Date: Mon, 22 Apr 2024 13:45:52 +0200 Subject: [PATCH 026/133] bugfix --- modules/32_forestry/dynamic_feb21/equations.gms | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/32_forestry/dynamic_feb21/equations.gms b/modules/32_forestry/dynamic_feb21/equations.gms index 483ced9c3c..46945a28a1 100644 --- a/modules/32_forestry/dynamic_feb21/equations.gms +++ b/modules/32_forestry/dynamic_feb21/equations.gms @@ -68,7 +68,7 @@ sum(ac_est, v32_land(j2,"aff",ac_est)) =l= sum(ac, v32_land(j2,"aff",ac)) - sum( *' The constraint `q32_aff_pol` accounts for the exogenous afforestation prescribed by NPI/NDC policies. q32_aff_pol(j2) .. - sum(ac_est, v32_land(j2,"ndc",ac_est)) =e= sum(ct, p32_aff_pol_timestep(ct,j2)) + v32_land_missing_ndc(j2); + sum(ac_est, v32_land(j2,"ndc",ac_est)) + v32_land_missing_ndc(j2) =e= sum(ct, p32_aff_pol_timestep(ct,j2)); *' The constraint `q32_max_aff` accounts for the allowed maximum global endogenous *' afforestation defined in `i32_max_aff_area_glo`. From a26ece2382e190a51cf0aa2d300a0144232b32d8 Mon Sep 17 00:00:00 2001 From: florianh Date: Mon, 22 Apr 2024 18:23:01 +0200 Subject: [PATCH 027/133] bugfixes --- config/default.cfg | 10 ++++---- .../29_cropland/detail_apr24/declarations.gms | 3 ++- .../29_cropland/detail_apr24/equations.gms | 4 ++-- modules/29_cropland/detail_apr24/input.gms | 6 ++--- modules/29_cropland/detail_apr24/presolve.gms | 24 ++++++++++--------- 5 files changed, 25 insertions(+), 22 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index c1b4cde3a3..b2765a6057 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -718,7 +718,7 @@ cfg$gms$policy_countries29 <- all_iso_countries cfg$gms$land_snv <- "secdforest, forestry, past, other" #def = "secdforest, forestry, past, other" # * Switch for rule-based (1) or penalty-based (0) implementation of fallow and treecover targets -cfg$gms$s29_implementation <- 1 # def = 1 +cfg$gms$s29_implementation <- 0 # def = 0 # * Minimum share of treecover on total cropland area (including croparea, fallow land and tree cover). # * s29_treecover_target is faded in linearly between s29_treecover_scenario_start and s29_treecover_scenario_target. @@ -727,10 +727,10 @@ cfg$gms$s29_treecover_target <- 0 #def = 0 cfg$gms$s29_treecover_scenario_start <- 2020 # def = 2020 # * Target year (year when full implementation is reached): cfg$gms$s29_treecover_scenario_target <- 2050 # def = 2050 -# * Penalty for violation of treecover target -cfg$gms$s29_treecover_penalty <- 0 #def = 0 -# * Cropland treecover can decrease (1) or not (0) -cfg$gms$s29_treecover_decrease <- 0 #def = 0 +# * Penalty for violation of treecover target (USD per ha) +cfg$gms$s29_treecover_penalty <- 500 #def = 500 +# * Keep existing treecover on cropland (1) or allow decrease (0) +cfg$gms$s29_treecover_keep <- 1 #def = 1 # * Minimum share of fallow land on total cropland area (including croparea, fallow land and tree cover). # * s29_fallow_target is faded in linearly between s29_fallow_scenario_start and s29_fallow_scenario_target. diff --git a/modules/29_cropland/detail_apr24/declarations.gms b/modules/29_cropland/detail_apr24/declarations.gms index 0d3aaf5d0e..cb534f2b53 100644 --- a/modules/29_cropland/detail_apr24/declarations.gms +++ b/modules/29_cropland/detail_apr24/declarations.gms @@ -21,12 +21,13 @@ parameters i29_snv_scenario_fader(t_all) SNV scenario fader (1) i29_treecover_scenario_fader(t_all) Cropland treecover scenario fader (1) - i29_treecover_target(t) Target share for treecover on total cropland (1) + i29_treecover_target(t,j) Target share for treecover on total cropland (1) i29_treecover_penalty(t) Penalty for violation of treecover target (USD05MER per ha) p29_treecover_bii_coeff(bii_class_secd,potnatveg) BII coefficient for cropland treecover (1) p29_carbon_density_ac(t,j,ac,ag_pools) Carbon density for ac and ag_pools (tC per ha) p29_treecover(t,j,ac) Cropland tree cover per age class (mio. ha) pc29_treecover(j,ac) Cropland tree cover per age class in current time step (mio. ha) + p29_treecover_share(t,j) Share of treecover on total cropland (1) i29_fallow_scenario_fader(t_all) Fallow land scenario fader (1) i29_fallow_target(t) Target share for fallow land on total cropland (1) diff --git a/modules/29_cropland/detail_apr24/equations.gms b/modules/29_cropland/detail_apr24/equations.gms index 9887e23df8..566441173f 100644 --- a/modules/29_cropland/detail_apr24/equations.gms +++ b/modules/29_cropland/detail_apr24/equations.gms @@ -89,7 +89,7 @@ q29_treecover_shr(j2)$(s29_implementation = 1) .. sum(ac, v29_treecover(j2,ac)) =g= - sum(ct, i29_treecover_target(ct)) * vm_land(j2,"crop"); + sum(ct, i29_treecover_target(ct,j2)) * vm_land(j2,"crop"); *' Otherwise, a penalty is applied for the violation of treecover rules. *' The penalty applies to the missing treecover area, i.e. where treecover area @@ -97,7 +97,7 @@ q29_treecover_missing(j2)$(s29_implementation = 0) .. v29_treecover_missing(j2) =g= - vm_land(j2,"crop") * sum(ct, i29_treecover_target(ct)) - sum(ac, v29_treecover(j2,ac)); + vm_land(j2,"crop") * sum(ct, i29_treecover_target(ct,j2)) - sum(ac, v29_treecover(j2,ac)); q29_treecover_penalty(j2) .. v29_treecover_penalty(j2) =e= diff --git a/modules/29_cropland/detail_apr24/input.gms b/modules/29_cropland/detail_apr24/input.gms index e050123544..198ea4001a 100644 --- a/modules/29_cropland/detail_apr24/input.gms +++ b/modules/29_cropland/detail_apr24/input.gms @@ -19,16 +19,16 @@ scalars s29_cost_treecover_recur Tree cover recurring cost (USD05MER per ha) / 500 / s29_treecover_plantation Growth curve switch for tree cover on cropland 0=natveg 1=plantations (1) / 0 / s29_treecover_bii_coeff BII coefficent to be used for tree cover on cropland 0=secondary vegetation 1=timber plantations (1) / 0 / - s29_treecover_decrease Cropland treecover can decrease (1) or not (0) / 0 / s29_treecover_scenario_start Cropland treecover scenario start year / 2020 / s29_treecover_scenario_target Cropland treecover scenario target year / 2050 / s29_treecover_target Target share of treecover on total cropland (1) / 0 / - s29_treecover_penalty Penalty for violation of treecover target (USD05MER per ha) / 0 / + s29_treecover_keep Keep existing treecover on cropland (1) or allow decrease (0) / 1 / + s29_treecover_penalty Penalty for violation of treecover target (USD05MER per ha) / 500 / s29_fallow_scenario_start Fallow land scenario start year / 2020 / s29_fallow_scenario_target Fallow land scenario target year / 2050 / s29_fallow_target Target share of fallow land on total cropland (1) / 0 / s29_fallow_penalty Penalty for violation of fallow target (USD05MER per ha) / 0 / - s29_implementation Switch for rule-based (1) or penalty-based (0) implementation of fallow and treecover targets / 1 / + s29_implementation Switch for rule-based (1) or penalty-based (0) implementation of fallow and treecover targets / 0 / ; diff --git a/modules/29_cropland/detail_apr24/presolve.gms b/modules/29_cropland/detail_apr24/presolve.gms index b865150ab0..ef1eb80ee3 100644 --- a/modules/29_cropland/detail_apr24/presolve.gms +++ b/modules/29_cropland/detail_apr24/presolve.gms @@ -22,7 +22,8 @@ p29_snv_relocation(t,j) = (i29_snv_scenario_fader(t) - i29_snv_scenario_fader(t- *' data (derived from satellite imagery from the Copernicus *' Global Land Service (@buchhorn_copernicus_2020)) and in *' cases of cropland reduction -p29_max_snv_relocation(t,j) = p29_snv_shr(t,j) * (i29_snv_scenario_fader(t) - i29_snv_scenario_fader(t-1)) * pcm_land(j,"crop"); +p29_max_snv_relocation(t,j) = p29_snv_shr(t,j) * (i29_snv_scenario_fader(t) - i29_snv_scenario_fader(t-1)) * pcm_land(j,"crop") + - sum(ac, pc29_treecover(j,ac)); p29_snv_relocation(t,j)$(p29_snv_relocation(t, j) > p29_max_snv_relocation(t,j)) = p29_max_snv_relocation(t,j); *' Area potentially available for cropping @@ -41,23 +42,24 @@ s29_shift = m_timestep_length_forestry/5; pc29_treecover(j,ac) = p29_treecover(t,j,ac); v29_treecover.l(j,ac) = p29_treecover(t,j,ac); +* create treecover target and penalty scenario +i29_treecover_target(t,j) = s29_treecover_target * i29_treecover_scenario_fader(t); +i29_treecover_penalty(t) = s29_treecover_penalty * i29_treecover_scenario_fader(t); + if(m_year(t) <= s29_treecover_scenario_start, v29_treecover.fx(j,ac) = pc29_treecover(j,ac); else v29_treecover.lo(j,ac_est) = 0; v29_treecover.up(j,ac_est) = Inf; - if(s29_treecover_decrease = 1, - v29_treecover.lo(j,ac_sub) = 0; - v29_treecover.up(j,ac_sub) = pc29_treecover(j,ac_sub); - else - v29_treecover.fx(j,ac_sub) = pc29_treecover(j,ac_sub); - ); + v29_treecover.lo(j,ac_sub) = 0; + v29_treecover.up(j,ac_sub) = pc29_treecover(j,ac_sub); ); - -* create treecover target and penalty scenario -i29_treecover_target(t) = s29_treecover_target * i29_treecover_scenario_fader(t); -i29_treecover_penalty(t) = s29_treecover_penalty * i29_treecover_scenario_fader(t); +p29_treecover_share(t,j) = 0; +p29_treecover_share(t,j)$(pcm_land(j,"crop") > 1e-10) = sum(ac, pc29_treecover(j,ac)) / pcm_land(j,"crop"); +if (s29_treecover_keep = 1, + i29_treecover_target(t,j)$(i29_treecover_target(t,j) < p29_treecover_share(t,j)) = p29_treecover_share(t,j); +); * create fallow land target and penalty scenario i29_fallow_target(t) = s29_fallow_target * i29_fallow_scenario_fader(t); From 3feb873ef1ea0773bb8d9a345e2b89a8601d0807 Mon Sep 17 00:00:00 2001 From: florianh Date: Mon, 22 Apr 2024 21:49:08 +0200 Subject: [PATCH 028/133] partial commit to save work --- config/default.cfg | 52 ++++++++++++------- .../29_cropland/detail_apr24/declarations.gms | 12 ----- .../29_cropland/detail_apr24/equations.gms | 33 +++--------- modules/29_cropland/detail_apr24/input.gms | 7 ++- .../29_cropland/detail_apr24/postsolve.gms | 24 --------- modules/29_cropland/detail_apr24/preloop.gms | 5 -- .../30_croparea/detail_apr24/declarations.gms | 13 +++-- .../30_croparea/detail_apr24/equations.gms | 9 ++++ modules/30_croparea/detail_apr24/input.gms | 4 ++ .../30_croparea/detail_apr24/postsolve.gms | 8 +++ modules/30_croparea/detail_apr24/preloop.gms | 11 ++-- modules/30_croparea/detail_apr24/presolve.gms | 4 ++ modules/30_croparea/detail_apr24/sets.gms | 2 +- .../30_croparea/simple_apr24/declarations.gms | 15 ++++-- .../30_croparea/simple_apr24/equations.gms | 11 ++++ modules/30_croparea/simple_apr24/input.gms | 4 ++ .../30_croparea/simple_apr24/postsolve.gms | 12 +++++ modules/30_croparea/simple_apr24/preloop.gms | 3 +- modules/30_croparea/simple_apr24/presolve.gms | 4 ++ .../80_optimization/lp_nlp_apr17/input.gms | 1 + .../80_optimization/lp_nlp_apr17/solve.gms | 3 +- modules/80_optimization/nlp_apr17/input.gms | 1 + modules/80_optimization/nlp_apr17/solve.gms | 4 +- modules/80_optimization/nlp_par/input.gms | 1 + modules/80_optimization/nlp_par/solve.gms | 4 +- 25 files changed, 141 insertions(+), 106 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index b2765a6057..3142852022 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -717,30 +717,31 @@ cfg$gms$policy_countries29 <- all_iso_countries # * "secdforest, past, other" etc. cfg$gms$land_snv <- "secdforest, forestry, past, other" #def = "secdforest, forestry, past, other" -# * Switch for rule-based (1) or penalty-based (0) implementation of fallow and treecover targets -cfg$gms$s29_implementation <- 0 # def = 0 - -# * Minimum share of treecover on total cropland area (including croparea, fallow land and tree cover). +# * Minimum cluster share of treecover on total cropland area (including croparea, fallow land and tree cover). # * s29_treecover_target is faded in linearly between s29_treecover_scenario_start and s29_treecover_scenario_target. -cfg$gms$s29_treecover_target <- 0 #def = 0 +cfg$gms$s29_treecover_target <- 0 # def = 0 +# * Adjust s29_treecover_target to avoid loss of existing treecover (1=yes 0=no) +cfg$gms$s29_treecover_keep <- 1 # def = 1 # * Start year of tree cover share fade-in: -cfg$gms$s29_treecover_scenario_start <- 2020 # def = 2020 +cfg$gms$s29_treecover_scenario_start <- 2020 # def = 2020 # * Target year (year when full implementation is reached): -cfg$gms$s29_treecover_scenario_target <- 2050 # def = 2050 -# * Penalty for violation of treecover target (USD per ha) -cfg$gms$s29_treecover_penalty <- 500 #def = 500 -# * Keep existing treecover on cropland (1) or allow decrease (0) -cfg$gms$s29_treecover_keep <- 1 #def = 1 - -# * Minimum share of fallow land on total cropland area (including croparea, fallow land and tree cover). +cfg$gms$s29_treecover_scenario_target <- 2050 # def = 2050 +# * Tree cover establishment cost (USD05MER per ha) +cfg$gms$s29_cost_treecover_est <- 2000 # def = 2000 +# * Tree cover recurring cost (USD05MER per ha) +cfg$gms$s29_cost_treecover_recur <- 500 # def = 500 +# * Penalty for violation of treecover target (USD05MER per ha) +cfg$gms$s29_treecover_penalty <- 1000 # def = 1000 + +# * Minimum cluster share of fallow land on total cropland area (including croparea, fallow land and tree cover). # * s29_fallow_target is faded in linearly between s29_fallow_scenario_start and s29_fallow_scenario_target. -cfg$gms$s29_fallow_target <- 0 #def = 0 +cfg$gms$s29_fallow_target <- 0 # def = 0 # * Start year of tree cover share fade-in: -cfg$gms$s29_fallow_scenario_start <- 2020 # def = 2020 +cfg$gms$s29_fallow_scenario_start <- 2020 # def = 2020 # * Target year (year when full implementation is reached): -cfg$gms$s29_fallow_scenario_target <- 2050 # def = 2050 -# * Penalty for violation of fallow target -cfg$gms$s29_fallow_penalty <- 0 #def = 0 +cfg$gms$s29_fallow_scenario_target <- 2050 # def = 2050 +# * Penalty for violation of fallow target (USD05MER per ha) +cfg$gms$s29_fallow_penalty <- 500 # def = 500 # ***--------------------- 30_croparea --------------------------------------- # * 30_croparea defines the croparea, which is a subcomponent of total cropland defined in 29_cropland. @@ -756,6 +757,16 @@ cfg$gms$c30_bioen_type <- "all" # def = "all" # * (c30_bioen_water): switch for irrigation of bioenergy crops; options: rainfed, irrigated, all cfg$gms$c30_bioen_water <- "rainfed" # def = "rainfed" +# * Minimum cluster share of bioenergy trees (betr) on total cropland area +# * s30_betr_target is faded in linearly between s30_betr_scenario_start and s30_betr_scenario_target. +cfg$gms$s30_betr_target <- 0 # def = 0 +# * Start year of tree cover share fade-in: +cfg$gms$s30_betr_scenario_start <- 2020 # def = 2020 +# * Target year (year when full implementation is reached): +cfg$gms$s30_betr_scenario_target <- 2050 # def = 2050 +# * Penalty for violation of fallow target (USD05MER per ha) +cfg$gms$s30_betr_penalty <- 500 # def = 500 + # *** Options only available for `simple_apr24` realization *** # * (c30_rotation_constraints): switch for rotational constraints: on, off @@ -1950,6 +1961,11 @@ cfg$gms$c80_nlp_solver <- "conopt4" # def = conopt4 # * 0: default settings (optfile will be ignored) cfg$gms$s80_optfile <- 0 # def = 0 +# switch to use alternative solver settings if CONOPT4 fails +# * 0: not used +# * 1: additional solve statements for CONOPT4 without preprocessing and CONOPT3 +# * Note: Option 1 is very time-consuming and usually does not provide a feasible solution. +cfg$gms$s80_debug <- 0 # def = 0 #*******************************END MODULE SETUP******************************** diff --git a/modules/29_cropland/detail_apr24/declarations.gms b/modules/29_cropland/detail_apr24/declarations.gms index cb534f2b53..e9aa88f83d 100644 --- a/modules/29_cropland/detail_apr24/declarations.gms +++ b/modules/29_cropland/detail_apr24/declarations.gms @@ -37,12 +37,10 @@ parameters positive variables vm_cost_cropland(j) Cost for total cropland (mio. USD05MER per yr) v29_treecover(j,ac) Cropland tree cover per age class (mio. ha) - v29_treecover_penalty(j) Penalty for violation of treecover target (mio. USD05MER per yr) v29_treecover_missing(j) Missing treecover area towards target (mio. ha) v29_cost_treecover_est(j) Establishment cost for cropland tree cover (mio. USD05MER per yr) v29_cost_treecover_recur(j) Recurring cost for cropland tree cover (mio. USD05MER per yr) vm_fallow(j) Fallow land is temporarily fallow cropland (mio. ha) - v29_fallow_penalty(j) Penalty for violation of fallow target (mio. USD05MER per yr) v29_fallow_missing(j) Missing fallow land towards target (mio. ha) ; @@ -53,12 +51,8 @@ equations q29_carbon(j,ag_pools,stockType) Cropland above ground carbon content calculation (mio. tC) q29_land_snv(j) Land constraint for the SNV policy in cropland areas (mio. ha) q29_land_snv_trans(j) Land transition constraint for SNV policy in cropland areas (mio. ha) - q29_fallow_shr(j) Fallow land minimum share (mio. ha) - q29_fallow_penalty(j) Penalty for violation of fallow target (mio. USD05MER per yr) q29_fallow_missing(j) Missing fallow land towards target (mio. ha) q29_fallow_bv(j,potnatveg) Biodiversity value for fallow land (mio. ha) - q29_treecover_shr(j) Cropland treecover minimum share (mio. ha) - q29_treecover_penalty(j) Penalty for violation of treecover target (mio. USD05MER per yr) q29_treecover_missing(j) Missing treecover area towards target (mio. ha) q29_treecover_bv(j,potnatveg) Biodiversity value for cropland treecover (mio. ha) q29_cost_treecover_est(j) Establishment cost for cropland tree cover (mio. USD05MER per yr) @@ -70,12 +64,10 @@ equations parameters ov_cost_cropland(t,j,type) Cost for total cropland (mio. USD05MER per yr) ov29_treecover(t,j,ac,type) Cropland tree cover per age class (mio. ha) - ov29_treecover_penalty(t,j,type) Penalty for violation of treecover target (mio. USD05MER per yr) ov29_treecover_missing(t,j,type) Missing treecover area towards target (mio. ha) ov29_cost_treecover_est(t,j,type) Establishment cost for cropland tree cover (mio. USD05MER per yr) ov29_cost_treecover_recur(t,j,type) Recurring cost for cropland tree cover (mio. USD05MER per yr) ov_fallow(t,j,type) Fallow land is temporarily fallow cropland (mio. ha) - ov29_fallow_penalty(t,j,type) Penalty for violation of fallow target (mio. USD05MER per yr) ov29_fallow_missing(t,j,type) Missing fallow land towards target (mio. ha) oq29_cropland(t,j,type) Total cropland calculation (mio. ha) oq29_avl_cropland(t,j,type) Available cropland constraint (mio. ha) @@ -83,12 +75,8 @@ parameters oq29_carbon(t,j,ag_pools,stockType,type) Cropland above ground carbon content calculation (mio. tC) oq29_land_snv(t,j,type) Land constraint for the SNV policy in cropland areas (mio. ha) oq29_land_snv_trans(t,j,type) Land transition constraint for SNV policy in cropland areas (mio. ha) - oq29_fallow_shr(t,j,type) Fallow land minimum share (mio. ha) - oq29_fallow_penalty(t,j,type) Penalty for violation of fallow target (mio. USD05MER per yr) oq29_fallow_missing(t,j,type) Missing fallow land towards target (mio. ha) oq29_fallow_bv(t,j,potnatveg,type) Biodiversity value for fallow land (mio. ha) - oq29_treecover_shr(t,j,type) Cropland treecover minimum share (mio. ha) - oq29_treecover_penalty(t,j,type) Penalty for violation of treecover target (mio. USD05MER per yr) oq29_treecover_missing(t,j,type) Missing treecover area towards target (mio. ha) oq29_treecover_bv(t,j,potnatveg,type) Biodiversity value for cropland treecover (mio. ha) oq29_cost_treecover_est(t,j,type) Establishment cost for cropland tree cover (mio. USD05MER per yr) diff --git a/modules/29_cropland/detail_apr24/equations.gms b/modules/29_cropland/detail_apr24/equations.gms index 566441173f..0faf477aca 100644 --- a/modules/29_cropland/detail_apr24/equations.gms +++ b/modules/29_cropland/detail_apr24/equations.gms @@ -28,7 +28,8 @@ q29_cost_cropland(j2) .. vm_cost_cropland(j2) =e= v29_cost_treecover_est(j2) + v29_cost_treecover_recur(j2) - + v29_fallow_penalty(j2) + v29_treecover_penalty(j2); + + v29_fallow_missing(j2) * sum(ct, i29_fallow_penalty(ct)) + + v29_treecover_missing(j2) * sum(ct, i29_treecover_penalty(ct)); *' The carbon stocks of total cropland are calculated as the sum of carbon stocks in @@ -59,25 +60,14 @@ sum(land_snv, vm_lu_transitions(j2,"crop",land_snv)) =g= sum(ct, p29_snv_relocation(ct,j2)); -*' In case of no penalty, fallow land is greater or equal a certain fraction of total cropland: - - q29_fallow_shr(j2)$(s29_implementation = 1) .. - vm_fallow(j2) =g= - sum(ct, i29_fallow_target(ct)) * vm_land(j2,"crop"); - -*' Otherwise, a penalty is applied for the violation of fallow land rules. +*' A penalty is applied for the violation of fallow land rules. *' The penalty applies to the missing fallow land, i.e. where fallow land *' is lower than a certain fraction of total cropland. - q29_fallow_missing(j2)$(s29_implementation = 0) .. + q29_fallow_missing(j2) .. v29_fallow_missing(j2) =g= vm_land(j2,"crop") * sum(ct, i29_fallow_target(ct)) - vm_fallow(j2); - q29_fallow_penalty(j2) .. - v29_fallow_penalty(j2) =e= - v29_fallow_missing(j2) * sum(ct, i29_fallow_penalty(ct)); - - *' Fallow land biodiversity value is based on perennial crops. q29_fallow_bv(j2,potnatveg) .. @@ -85,25 +75,14 @@ vm_fallow(j2) * fm_bii_coeff("crop_per",potnatveg) * fm_luh2_side_layers(j2,potnatveg); -*' In case of no penalty, tree cover is greater or equal a certain fraction of total cropland. - - q29_treecover_shr(j2)$(s29_implementation = 1) .. - sum(ac, v29_treecover(j2,ac)) =g= - sum(ct, i29_treecover_target(ct,j2)) * vm_land(j2,"crop"); - -*' Otherwise, a penalty is applied for the violation of treecover rules. +*' A penalty is applied for the violation of treecover rules. *' The penalty applies to the missing treecover area, i.e. where treecover area *' is lower than a certain fraction of total cropland. - q29_treecover_missing(j2)$(s29_implementation = 0) .. + q29_treecover_missing(j2) .. v29_treecover_missing(j2) =g= vm_land(j2,"crop") * sum(ct, i29_treecover_target(ct,j2)) - sum(ac, v29_treecover(j2,ac)); - q29_treecover_penalty(j2) .. - v29_treecover_penalty(j2) =e= - v29_treecover_missing(j2) * sum(ct, i29_treecover_penalty(ct)); - - *' Depending on `s29_treecover_bii_coeff`, tree cover biodiversity value *' is based on natural vegetation or plantation BII coefficients. diff --git a/modules/29_cropland/detail_apr24/input.gms b/modules/29_cropland/detail_apr24/input.gms index 198ea4001a..ab00ed8a46 100644 --- a/modules/29_cropland/detail_apr24/input.gms +++ b/modules/29_cropland/detail_apr24/input.gms @@ -22,13 +22,12 @@ scalars s29_treecover_scenario_start Cropland treecover scenario start year / 2020 / s29_treecover_scenario_target Cropland treecover scenario target year / 2050 / s29_treecover_target Target share of treecover on total cropland (1) / 0 / - s29_treecover_keep Keep existing treecover on cropland (1) or allow decrease (0) / 1 / - s29_treecover_penalty Penalty for violation of treecover target (USD05MER per ha) / 500 / + s29_treecover_keep Adjust s29_treecover_target to avoid loss of existing treecover (1=yes 0=no) / 1 / + s29_treecover_penalty Penalty for violation of treecover target (USD05MER per ha) / 1000 / s29_fallow_scenario_start Fallow land scenario start year / 2020 / s29_fallow_scenario_target Fallow land scenario target year / 2050 / s29_fallow_target Target share of fallow land on total cropland (1) / 0 / - s29_fallow_penalty Penalty for violation of fallow target (USD05MER per ha) / 0 / - s29_implementation Switch for rule-based (1) or penalty-based (0) implementation of fallow and treecover targets / 0 / + s29_fallow_penalty Penalty for violation of fallow target (USD05MER per ha) / 500 / ; diff --git a/modules/29_cropland/detail_apr24/postsolve.gms b/modules/29_cropland/detail_apr24/postsolve.gms index 5070d341f2..0d05aea001 100644 --- a/modules/29_cropland/detail_apr24/postsolve.gms +++ b/modules/29_cropland/detail_apr24/postsolve.gms @@ -10,12 +10,10 @@ pc29_treecover(j,ac) = v29_treecover.l(j,ac); *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### ov_cost_cropland(t,j,"marginal") = vm_cost_cropland.m(j); ov29_treecover(t,j,ac,"marginal") = v29_treecover.m(j,ac); - ov29_treecover_penalty(t,j,"marginal") = v29_treecover_penalty.m(j); ov29_treecover_missing(t,j,"marginal") = v29_treecover_missing.m(j); ov29_cost_treecover_est(t,j,"marginal") = v29_cost_treecover_est.m(j); ov29_cost_treecover_recur(t,j,"marginal") = v29_cost_treecover_recur.m(j); ov_fallow(t,j,"marginal") = vm_fallow.m(j); - ov29_fallow_penalty(t,j,"marginal") = v29_fallow_penalty.m(j); ov29_fallow_missing(t,j,"marginal") = v29_fallow_missing.m(j); oq29_cropland(t,j,"marginal") = q29_cropland.m(j); oq29_avl_cropland(t,j,"marginal") = q29_avl_cropland.m(j); @@ -23,12 +21,8 @@ pc29_treecover(j,ac) = v29_treecover.l(j,ac); oq29_carbon(t,j,ag_pools,stockType,"marginal") = q29_carbon.m(j,ag_pools,stockType); oq29_land_snv(t,j,"marginal") = q29_land_snv.m(j); oq29_land_snv_trans(t,j,"marginal") = q29_land_snv_trans.m(j); - oq29_fallow_shr(t,j,"marginal") = q29_fallow_shr.m(j); - oq29_fallow_penalty(t,j,"marginal") = q29_fallow_penalty.m(j); oq29_fallow_missing(t,j,"marginal") = q29_fallow_missing.m(j); oq29_fallow_bv(t,j,potnatveg,"marginal") = q29_fallow_bv.m(j,potnatveg); - oq29_treecover_shr(t,j,"marginal") = q29_treecover_shr.m(j); - oq29_treecover_penalty(t,j,"marginal") = q29_treecover_penalty.m(j); oq29_treecover_missing(t,j,"marginal") = q29_treecover_missing.m(j); oq29_treecover_bv(t,j,potnatveg,"marginal") = q29_treecover_bv.m(j,potnatveg); oq29_cost_treecover_est(t,j,"marginal") = q29_cost_treecover_est.m(j); @@ -36,12 +30,10 @@ pc29_treecover(j,ac) = v29_treecover.l(j,ac); oq29_treecover_est(t,j,ac,"marginal") = q29_treecover_est.m(j,ac); ov_cost_cropland(t,j,"level") = vm_cost_cropland.l(j); ov29_treecover(t,j,ac,"level") = v29_treecover.l(j,ac); - ov29_treecover_penalty(t,j,"level") = v29_treecover_penalty.l(j); ov29_treecover_missing(t,j,"level") = v29_treecover_missing.l(j); ov29_cost_treecover_est(t,j,"level") = v29_cost_treecover_est.l(j); ov29_cost_treecover_recur(t,j,"level") = v29_cost_treecover_recur.l(j); ov_fallow(t,j,"level") = vm_fallow.l(j); - ov29_fallow_penalty(t,j,"level") = v29_fallow_penalty.l(j); ov29_fallow_missing(t,j,"level") = v29_fallow_missing.l(j); oq29_cropland(t,j,"level") = q29_cropland.l(j); oq29_avl_cropland(t,j,"level") = q29_avl_cropland.l(j); @@ -49,12 +41,8 @@ pc29_treecover(j,ac) = v29_treecover.l(j,ac); oq29_carbon(t,j,ag_pools,stockType,"level") = q29_carbon.l(j,ag_pools,stockType); oq29_land_snv(t,j,"level") = q29_land_snv.l(j); oq29_land_snv_trans(t,j,"level") = q29_land_snv_trans.l(j); - oq29_fallow_shr(t,j,"level") = q29_fallow_shr.l(j); - oq29_fallow_penalty(t,j,"level") = q29_fallow_penalty.l(j); oq29_fallow_missing(t,j,"level") = q29_fallow_missing.l(j); oq29_fallow_bv(t,j,potnatveg,"level") = q29_fallow_bv.l(j,potnatveg); - oq29_treecover_shr(t,j,"level") = q29_treecover_shr.l(j); - oq29_treecover_penalty(t,j,"level") = q29_treecover_penalty.l(j); oq29_treecover_missing(t,j,"level") = q29_treecover_missing.l(j); oq29_treecover_bv(t,j,potnatveg,"level") = q29_treecover_bv.l(j,potnatveg); oq29_cost_treecover_est(t,j,"level") = q29_cost_treecover_est.l(j); @@ -62,12 +50,10 @@ pc29_treecover(j,ac) = v29_treecover.l(j,ac); oq29_treecover_est(t,j,ac,"level") = q29_treecover_est.l(j,ac); ov_cost_cropland(t,j,"upper") = vm_cost_cropland.up(j); ov29_treecover(t,j,ac,"upper") = v29_treecover.up(j,ac); - ov29_treecover_penalty(t,j,"upper") = v29_treecover_penalty.up(j); ov29_treecover_missing(t,j,"upper") = v29_treecover_missing.up(j); ov29_cost_treecover_est(t,j,"upper") = v29_cost_treecover_est.up(j); ov29_cost_treecover_recur(t,j,"upper") = v29_cost_treecover_recur.up(j); ov_fallow(t,j,"upper") = vm_fallow.up(j); - ov29_fallow_penalty(t,j,"upper") = v29_fallow_penalty.up(j); ov29_fallow_missing(t,j,"upper") = v29_fallow_missing.up(j); oq29_cropland(t,j,"upper") = q29_cropland.up(j); oq29_avl_cropland(t,j,"upper") = q29_avl_cropland.up(j); @@ -75,12 +61,8 @@ pc29_treecover(j,ac) = v29_treecover.l(j,ac); oq29_carbon(t,j,ag_pools,stockType,"upper") = q29_carbon.up(j,ag_pools,stockType); oq29_land_snv(t,j,"upper") = q29_land_snv.up(j); oq29_land_snv_trans(t,j,"upper") = q29_land_snv_trans.up(j); - oq29_fallow_shr(t,j,"upper") = q29_fallow_shr.up(j); - oq29_fallow_penalty(t,j,"upper") = q29_fallow_penalty.up(j); oq29_fallow_missing(t,j,"upper") = q29_fallow_missing.up(j); oq29_fallow_bv(t,j,potnatveg,"upper") = q29_fallow_bv.up(j,potnatveg); - oq29_treecover_shr(t,j,"upper") = q29_treecover_shr.up(j); - oq29_treecover_penalty(t,j,"upper") = q29_treecover_penalty.up(j); oq29_treecover_missing(t,j,"upper") = q29_treecover_missing.up(j); oq29_treecover_bv(t,j,potnatveg,"upper") = q29_treecover_bv.up(j,potnatveg); oq29_cost_treecover_est(t,j,"upper") = q29_cost_treecover_est.up(j); @@ -88,12 +70,10 @@ pc29_treecover(j,ac) = v29_treecover.l(j,ac); oq29_treecover_est(t,j,ac,"upper") = q29_treecover_est.up(j,ac); ov_cost_cropland(t,j,"lower") = vm_cost_cropland.lo(j); ov29_treecover(t,j,ac,"lower") = v29_treecover.lo(j,ac); - ov29_treecover_penalty(t,j,"lower") = v29_treecover_penalty.lo(j); ov29_treecover_missing(t,j,"lower") = v29_treecover_missing.lo(j); ov29_cost_treecover_est(t,j,"lower") = v29_cost_treecover_est.lo(j); ov29_cost_treecover_recur(t,j,"lower") = v29_cost_treecover_recur.lo(j); ov_fallow(t,j,"lower") = vm_fallow.lo(j); - ov29_fallow_penalty(t,j,"lower") = v29_fallow_penalty.lo(j); ov29_fallow_missing(t,j,"lower") = v29_fallow_missing.lo(j); oq29_cropland(t,j,"lower") = q29_cropland.lo(j); oq29_avl_cropland(t,j,"lower") = q29_avl_cropland.lo(j); @@ -101,12 +81,8 @@ pc29_treecover(j,ac) = v29_treecover.l(j,ac); oq29_carbon(t,j,ag_pools,stockType,"lower") = q29_carbon.lo(j,ag_pools,stockType); oq29_land_snv(t,j,"lower") = q29_land_snv.lo(j); oq29_land_snv_trans(t,j,"lower") = q29_land_snv_trans.lo(j); - oq29_fallow_shr(t,j,"lower") = q29_fallow_shr.lo(j); - oq29_fallow_penalty(t,j,"lower") = q29_fallow_penalty.lo(j); oq29_fallow_missing(t,j,"lower") = q29_fallow_missing.lo(j); oq29_fallow_bv(t,j,potnatveg,"lower") = q29_fallow_bv.lo(j,potnatveg); - oq29_treecover_shr(t,j,"lower") = q29_treecover_shr.lo(j); - oq29_treecover_penalty(t,j,"lower") = q29_treecover_penalty.lo(j); oq29_treecover_missing(t,j,"lower") = q29_treecover_missing.lo(j); oq29_treecover_bv(t,j,potnatveg,"lower") = q29_treecover_bv.lo(j,potnatveg); oq29_cost_treecover_est(t,j,"lower") = q29_cost_treecover_est.lo(j); diff --git a/modules/29_cropland/detail_apr24/preloop.gms b/modules/29_cropland/detail_apr24/preloop.gms index e245094629..a7e39c8c8e 100644 --- a/modules/29_cropland/detail_apr24/preloop.gms +++ b/modules/29_cropland/detail_apr24/preloop.gms @@ -56,8 +56,3 @@ p29_country_dummy(policy_countries29) = 1; * Countries are weighted by available cropland area. i29_avl_cropland_iso(iso) = f29_avl_cropland_iso(iso,"%c29_marginal_land%"); p29_country_snv_weight(i) = sum(i_to_iso(i,iso), p29_country_dummy(iso) * i29_avl_cropland_iso(iso)) / sum(i_to_iso(i,iso), i29_avl_cropland_iso(iso)); - -if(s29_implementation = 1, - v29_treecover_missing.fx(j) = 0; - v29_fallow_missing.fx(j) = 0; -); diff --git a/modules/30_croparea/detail_apr24/declarations.gms b/modules/30_croparea/detail_apr24/declarations.gms index b0ef264b21..844d35ab27 100644 --- a/modules/30_croparea/detail_apr24/declarations.gms +++ b/modules/30_croparea/detail_apr24/declarations.gms @@ -8,8 +8,11 @@ parameters i30_rotation_rules(t_all,rota30) Rotational constraints (1) i30_rotation_incentives(t_all,rota30) Penalty for violating rotational constraints (USD05MER per ha) - p30_rotation_scenario_fader(t_all) Crop rotation scenario fader (1) + i30_rotation_scenario_fader(t_all) Crop rotation scenario fader (1) i30_implementation Switch for rule-based (1) or penalty-based (0) implementation of rotation scenarios + i30_betr_scenario_fader(t_all) Bioenergy land scenario fader (1) + i30_betr_target(t) Target share for bioenergy land on total cropland (1) + i30_betr_penalty(t) Penalty for violation of betr target (USD05MER per ha) ; positive variables @@ -18,15 +21,17 @@ positive variables vm_carbon_stock_croparea(j,ag_pools) Carbon stock in croparea (tC) v30_penalty_max_irrig(j,rotamax30) Penalty for violating max rotational constraints on irrigated land (mio. USD05MER) v30_penalty(j,rota30) Penalty for violating rotational constraints (mio. USD05MER) + v30_betr_missing(j) Missing bioenergy tree land towards target (mio. ha) ; equations q30_prod(j,kcr) Production of cropped products (mio. tDM) + q30_betr_missing(j) Missing bioenergy tree land towards target (mio. ha) q30_rotation_penalty(i) Total penalty for rotational constraint violations (mio. USD05MER) q30_rotation_max(j,rotamax30) Local maximum rotational constraints (mio. ha) q30_rotation_min(j,rotamin30) Local minimum rotational constraints (mio. ha) - q30_rotation_max2(j,rotamax30) Local maximum rotational constraints (mio. ha) - q30_rotation_min2(j,rotamin30) Local minimum rotational constraints (mio. ha) + q30_rotation_max2(j,rotamax30) Local maximum rotational constraints (mio. ha) + q30_rotation_min2(j,rotamin30) Local minimum rotational constraints (mio. ha) q30_rotation_max_irrig(j,rotamax30) Local maximum rotational constraints (mio. ha) q30_carbon(j,ag_pools) Croplarea above ground carbon content calculation (mio. tC) q30_bv_ann(j,potnatveg) Biodiversity value of annual cropland (mio. ha) @@ -40,7 +45,9 @@ parameters ov_carbon_stock_croparea(t,j,ag_pools,type) Carbon stock in croparea (tC) ov30_penalty_max_irrig(t,j,rotamax30,type) Penalty for violating max rotational constraints on irrigated land (mio. USD05MER) ov30_penalty(t,j,rota30,type) Penalty for violating rotational constraints (mio. USD05MER) + ov30_betr_missing(t,j,type) Missing bioenergy tree land towards target (mio. ha) oq30_prod(t,j,kcr,type) Production of cropped products (mio. tDM) + oq30_betr_missing(t,j,type) Missing bioenergy tree land towards target (mio. ha) oq30_rotation_penalty(t,i,type) Total penalty for rotational constraint violations (mio. USD05MER) oq30_rotation_max(t,j,rotamax30,type) Local maximum rotational constraints (mio. ha) oq30_rotation_min(t,j,rotamin30,type) Local minimum rotational constraints (mio. ha) diff --git a/modules/30_croparea/detail_apr24/equations.gms b/modules/30_croparea/detail_apr24/equations.gms index 95d5c18c24..7629f075ca 100644 --- a/modules/30_croparea/detail_apr24/equations.gms +++ b/modules/30_croparea/detail_apr24/equations.gms @@ -14,6 +14,14 @@ q30_prod(j2,kcr) .. vm_prod(j2,kcr) =e= sum(w, vm_area(j2,kcr,w) * vm_yld(j2,kcr,w)); +*' A penalty is applied for the violation of bioenergy tree (betr) rules. +*' The penalty applies to the missing bioenergy tree land, i.e. where bioenergy tree land +*' is lower than a certain fraction of total cropland. + + q30_betr_missing(j2) .. + v30_betr_missing(j2) =g= + vm_land(j2,"crop") * sum(ct, i30_betr_target(ct)) - vm_area(j2,"betr","rainfed"); + *' Rotational constraints prevent over-specialization. In this realization, *' they are either implemented via a rules (i30_implementation = 1) or *' a penalty payment if the constraints are violated (i30_implementation = 0). @@ -24,6 +32,7 @@ sum(rota30, v30_penalty(j2,rota30) * sum(ct, i30_rotation_incentives(ct,rota30))) + sum(rotamax_red30, v30_penalty_max_irrig(j2,rotamax_red30) * sum(ct, i30_rotation_incentives(ct,rotamax_red30))) + + v30_betr_missing(j2) * sum(ct, i30_betr_penalty(ct)) ); q30_rotation_max(j2,rotamax_red30)$(i30_implementation = 1) .. diff --git a/modules/30_croparea/detail_apr24/input.gms b/modules/30_croparea/detail_apr24/input.gms index 4a915b8a8f..72ca248086 100644 --- a/modules/30_croparea/detail_apr24/input.gms +++ b/modules/30_croparea/detail_apr24/input.gms @@ -23,6 +23,10 @@ scalars s30_rotation_scenario_start Rotation scenario start year / 2020 / s30_rotation_scenario_target Rotation scenario target year / 2050 / s30_implementation Switch for rule-based (1) or penalty-based (0) implementation of rotation scenarios / 1 / + s30_betr_scenario_start Bioenergy land scenario start year / 2020 / + s30_betr_scenario_target Bioenergy land scenario target year / 2050 / + s30_betr_target Target share of bioenergy land on total cropland (1) / 0 / + s30_betr_penalty Penalty for violation of betr target (USD05MER per ha) / 500 / ; diff --git a/modules/30_croparea/detail_apr24/postsolve.gms b/modules/30_croparea/detail_apr24/postsolve.gms index 481fb9e1c9..4f0dad15ae 100644 --- a/modules/30_croparea/detail_apr24/postsolve.gms +++ b/modules/30_croparea/detail_apr24/postsolve.gms @@ -12,7 +12,9 @@ ov_carbon_stock_croparea(t,j,ag_pools,"marginal") = vm_carbon_stock_croparea.m(j,ag_pools); ov30_penalty_max_irrig(t,j,rotamax30,"marginal") = v30_penalty_max_irrig.m(j,rotamax30); ov30_penalty(t,j,rota30,"marginal") = v30_penalty.m(j,rota30); + ov30_betr_missing(t,j,"marginal") = v30_betr_missing.m(j); oq30_prod(t,j,kcr,"marginal") = q30_prod.m(j,kcr); + oq30_betr_missing(t,j,"marginal") = q30_betr_missing.m(j); oq30_rotation_penalty(t,i,"marginal") = q30_rotation_penalty.m(i); oq30_rotation_max(t,j,rotamax30,"marginal") = q30_rotation_max.m(j,rotamax30); oq30_rotation_min(t,j,rotamin30,"marginal") = q30_rotation_min.m(j,rotamin30); @@ -27,7 +29,9 @@ ov_carbon_stock_croparea(t,j,ag_pools,"level") = vm_carbon_stock_croparea.l(j,ag_pools); ov30_penalty_max_irrig(t,j,rotamax30,"level") = v30_penalty_max_irrig.l(j,rotamax30); ov30_penalty(t,j,rota30,"level") = v30_penalty.l(j,rota30); + ov30_betr_missing(t,j,"level") = v30_betr_missing.l(j); oq30_prod(t,j,kcr,"level") = q30_prod.l(j,kcr); + oq30_betr_missing(t,j,"level") = q30_betr_missing.l(j); oq30_rotation_penalty(t,i,"level") = q30_rotation_penalty.l(i); oq30_rotation_max(t,j,rotamax30,"level") = q30_rotation_max.l(j,rotamax30); oq30_rotation_min(t,j,rotamin30,"level") = q30_rotation_min.l(j,rotamin30); @@ -42,7 +46,9 @@ ov_carbon_stock_croparea(t,j,ag_pools,"upper") = vm_carbon_stock_croparea.up(j,ag_pools); ov30_penalty_max_irrig(t,j,rotamax30,"upper") = v30_penalty_max_irrig.up(j,rotamax30); ov30_penalty(t,j,rota30,"upper") = v30_penalty.up(j,rota30); + ov30_betr_missing(t,j,"upper") = v30_betr_missing.up(j); oq30_prod(t,j,kcr,"upper") = q30_prod.up(j,kcr); + oq30_betr_missing(t,j,"upper") = q30_betr_missing.up(j); oq30_rotation_penalty(t,i,"upper") = q30_rotation_penalty.up(i); oq30_rotation_max(t,j,rotamax30,"upper") = q30_rotation_max.up(j,rotamax30); oq30_rotation_min(t,j,rotamin30,"upper") = q30_rotation_min.up(j,rotamin30); @@ -57,7 +63,9 @@ ov_carbon_stock_croparea(t,j,ag_pools,"lower") = vm_carbon_stock_croparea.lo(j,ag_pools); ov30_penalty_max_irrig(t,j,rotamax30,"lower") = v30_penalty_max_irrig.lo(j,rotamax30); ov30_penalty(t,j,rota30,"lower") = v30_penalty.lo(j,rota30); + ov30_betr_missing(t,j,"lower") = v30_betr_missing.lo(j); oq30_prod(t,j,kcr,"lower") = q30_prod.lo(j,kcr); + oq30_betr_missing(t,j,"lower") = q30_betr_missing.lo(j); oq30_rotation_penalty(t,i,"lower") = q30_rotation_penalty.lo(i); oq30_rotation_max(t,j,rotamax30,"lower") = q30_rotation_max.lo(j,rotamax30); oq30_rotation_min(t,j,rotamin30,"lower") = q30_rotation_min.lo(j,rotamin30); diff --git a/modules/30_croparea/detail_apr24/preloop.gms b/modules/30_croparea/detail_apr24/preloop.gms index 51e2d0cfaa..8d2ac45a5f 100644 --- a/modules/30_croparea/detail_apr24/preloop.gms +++ b/modules/30_croparea/detail_apr24/preloop.gms @@ -7,17 +7,18 @@ ** Trajectory for cropland scenarios * sigmoidal interpolation between start year and target year -m_sigmoid_time_interpol(p30_rotation_scenario_fader,s30_rotation_scenario_start,s30_rotation_scenario_target,0,1); +m_sigmoid_time_interpol(i30_rotation_scenario_fader,s30_rotation_scenario_start,s30_rotation_scenario_target,0,1); +m_sigmoid_time_interpol(i30_betr_scenario_fader,s30_betr_scenario_start,s30_betr_scenario_target,0,1); ** create crop rotation scenario i30_rotation_rules(t_all,rota30) = - f30_rotation_rules(rota30,"default") * (1-p30_rotation_scenario_fader(t_all)) + - f30_rotation_rules(rota30,"%c30_rotation_rules%") * (p30_rotation_scenario_fader(t_all)); + f30_rotation_rules(rota30,"default") * (1-i30_rotation_scenario_fader(t_all)) + + f30_rotation_rules(rota30,"%c30_rotation_rules%") * (i30_rotation_scenario_fader(t_all)); ** create crop rotation scenario i30_rotation_incentives(t_all,rota30) = - f30_rotation_incentives(rota30,"default") * (1-p30_rotation_scenario_fader(t_all)) + - f30_rotation_incentives(rota30,"%c30_rotation_incentives%") * (p30_rotation_scenario_fader(t_all)); + f30_rotation_incentives(rota30,"default") * (1-i30_rotation_scenario_fader(t_all)) + + f30_rotation_incentives(rota30,"%c30_rotation_incentives%") * (i30_rotation_scenario_fader(t_all)); *due to some rounding errors the input data currently may contain in some cases diff --git a/modules/30_croparea/detail_apr24/presolve.gms b/modules/30_croparea/detail_apr24/presolve.gms index d95c14a256..0efea7ea26 100644 --- a/modules/30_croparea/detail_apr24/presolve.gms +++ b/modules/30_croparea/detail_apr24/presolve.gms @@ -24,3 +24,7 @@ else * only activate constraints which are binding rotamax_red30(rotamax30) = yes$(i30_rotation_rules(t,rotamax30) < 1); rotamin_red30(rotamin30) = yes$(i30_rotation_rules(t,rotamin30) > 0); + +* create betr target and penalty scenario +i30_betr_target(t) = s30_betr_target * i30_betr_scenario_fader(t); +i30_betr_penalty(t) = s30_betr_penalty * i30_betr_scenario_fader(t); diff --git a/modules/30_croparea/detail_apr24/sets.gms b/modules/30_croparea/detail_apr24/sets.gms index e0fa90cefe..addda5290f 100644 --- a/modules/30_croparea/detail_apr24/sets.gms +++ b/modules/30_croparea/detail_apr24/sets.gms @@ -94,7 +94,7 @@ sets legumes_min . (soybean, groundnut, puls_pro, foddr) minor_min . (sunflower, rapeseed, sugr_beet, cassav_sp, potato, others) cereals_min . (tece, maiz, trce, rice_pro) - stalk_min . (tece, maiz, trce, rice_pro, sugr_cane, foddr) + stalk_min . (tece, maiz, trce, rice_pro, sugr_cane, foddr) others_min . (others) betr_min . (betr) / diff --git a/modules/30_croparea/simple_apr24/declarations.gms b/modules/30_croparea/simple_apr24/declarations.gms index f3930b04c2..329674a599 100644 --- a/modules/30_croparea/simple_apr24/declarations.gms +++ b/modules/30_croparea/simple_apr24/declarations.gms @@ -6,17 +6,23 @@ *** | Contact: magpie@pik-potsdam.de parameters - p30_rotation_scenario_fader(t_all) Crop rotation scenario fader (1) + i30_rotation_scenario_fader(t_all) Crop rotation scenario fader (1) + i30_betr_scenario_fader(t_all) Bioenergy land scenario fader (1) + i30_betr_target(t) Target share for bioenergy land on total cropland (1) + i30_betr_penalty(t) Penalty for violation of betr target (USD05MER per ha) ; positive variables vm_area(j,kcr,w) Agricultural production area (mio. ha) - vm_rotation_penalty(i) Penalty for violating rotational constraints (USD05MER) + vm_rotation_penalty(i) Penalty for violating rotational constraints (mio. USD05MER) vm_carbon_stock_croparea(j,ag_pools) Carbon stock in croparea (tC) + v30_betr_missing(j) Missing bioenergy tree land towards target (mio. ha) ; equations q30_prod(j,kcr) Production of cropped products (mio. tDM) + q30_betr_missing(j) Missing bioenergy tree land towards target (mio. ha) + q30_cost(i) Cost (mio. USD05MER) q30_rotation_max(j,crp30,w) Local maximum rotational constraints (mio. ha) q30_rotation_min(j,crp30,w) Local minimum rotational constraints (mio. ha) q30_carbon(j,ag_pools) Croplarea above ground carbon content calculation (mio. tC) @@ -27,9 +33,12 @@ equations *#################### R SECTION START (OUTPUT DECLARATIONS) #################### parameters ov_area(t,j,kcr,w,type) Agricultural production area (mio. ha) - ov_rotation_penalty(t,i,type) Penalty for violating rotational constraints (USD05MER) + ov_rotation_penalty(t,i,type) Penalty for violating rotational constraints (mio. USD05MER) ov_carbon_stock_croparea(t,j,ag_pools,type) Carbon stock in croparea (tC) + ov30_betr_missing(t,j,type) Missing bioenergy tree land towards target (mio. ha) oq30_prod(t,j,kcr,type) Production of cropped products (mio. tDM) + oq30_betr_missing(t,j,type) Missing bioenergy tree land towards target (mio. ha) + oq30_cost(t,i,type) Cost (mio. USD05MER) oq30_rotation_max(t,j,crp30,w,type) Local maximum rotational constraints (mio. ha) oq30_rotation_min(t,j,crp30,w,type) Local minimum rotational constraints (mio. ha) oq30_carbon(t,j,ag_pools,type) Croplarea above ground carbon content calculation (mio. tC) diff --git a/modules/30_croparea/simple_apr24/equations.gms b/modules/30_croparea/simple_apr24/equations.gms index 40b4ff85d8..1e872f1606 100644 --- a/modules/30_croparea/simple_apr24/equations.gms +++ b/modules/30_croparea/simple_apr24/equations.gms @@ -14,6 +14,17 @@ q30_prod(j2,kcr) .. vm_prod(j2,kcr) =e= sum(w, vm_area(j2,kcr,w) * vm_yld(j2,kcr,w)); +*' A penalty is applied for the violation of bioenergy tree (betr) rules. +*' The penalty applies to the missing bioenergy tree land, i.e. where bioenergy tree land +*' is lower than a certain fraction of total cropland. + + q30_betr_missing(j2) .. + v30_betr_missing(j2) =g= + vm_land(j2,"crop") * sum(ct, i30_betr_target(ct)) - vm_area(j2,"betr","rainfed"); + + q30_cost(i2) .. + vm_rotation_penalty(i2) =g= + sum(cell(i2,j2), v30_betr_missing(j2) * sum(ct, i30_betr_penalty(ct))); *' As additional constraints minimum and maximum rotational constraints limit *' the placing of crops. On the one hand, these rotational constraints reflect diff --git a/modules/30_croparea/simple_apr24/input.gms b/modules/30_croparea/simple_apr24/input.gms index 02c72d13d3..e8f919c20f 100644 --- a/modules/30_croparea/simple_apr24/input.gms +++ b/modules/30_croparea/simple_apr24/input.gms @@ -17,6 +17,10 @@ $setglobal c30_rotation_constraints on scalars s30_rotation_scenario_start Rotation scenario start year / 2020 / s30_rotation_scenario_target Rotation scenario target year / 2050 / + s30_betr_scenario_start Bioenergy land scenario start year / 2020 / + s30_betr_scenario_target Bioenergy land scenario target year / 2050 / + s30_betr_target Target share of bioenergy land on total cropland (1) / 0 / + s30_betr_penalty Penalty for violation of betr target (USD05MER per ha) / 500 / ; $ifthen "%c30_bioen_type%" == "all" bioen_type_30(kbe30) = yes; diff --git a/modules/30_croparea/simple_apr24/postsolve.gms b/modules/30_croparea/simple_apr24/postsolve.gms index a9ba060e13..500abbb32e 100644 --- a/modules/30_croparea/simple_apr24/postsolve.gms +++ b/modules/30_croparea/simple_apr24/postsolve.gms @@ -10,7 +10,10 @@ ov_area(t,j,kcr,w,"marginal") = vm_area.m(j,kcr,w); ov_rotation_penalty(t,i,"marginal") = vm_rotation_penalty.m(i); ov_carbon_stock_croparea(t,j,ag_pools,"marginal") = vm_carbon_stock_croparea.m(j,ag_pools); + ov30_betr_missing(t,j,"marginal") = v30_betr_missing.m(j); oq30_prod(t,j,kcr,"marginal") = q30_prod.m(j,kcr); + oq30_betr_missing(t,j,"marginal") = q30_betr_missing.m(j); + oq30_cost(t,i,"marginal") = q30_cost.m(i); oq30_rotation_max(t,j,crp30,w,"marginal") = q30_rotation_max.m(j,crp30,w); oq30_rotation_min(t,j,crp30,w,"marginal") = q30_rotation_min.m(j,crp30,w); oq30_carbon(t,j,ag_pools,"marginal") = q30_carbon.m(j,ag_pools); @@ -19,7 +22,10 @@ ov_area(t,j,kcr,w,"level") = vm_area.l(j,kcr,w); ov_rotation_penalty(t,i,"level") = vm_rotation_penalty.l(i); ov_carbon_stock_croparea(t,j,ag_pools,"level") = vm_carbon_stock_croparea.l(j,ag_pools); + ov30_betr_missing(t,j,"level") = v30_betr_missing.l(j); oq30_prod(t,j,kcr,"level") = q30_prod.l(j,kcr); + oq30_betr_missing(t,j,"level") = q30_betr_missing.l(j); + oq30_cost(t,i,"level") = q30_cost.l(i); oq30_rotation_max(t,j,crp30,w,"level") = q30_rotation_max.l(j,crp30,w); oq30_rotation_min(t,j,crp30,w,"level") = q30_rotation_min.l(j,crp30,w); oq30_carbon(t,j,ag_pools,"level") = q30_carbon.l(j,ag_pools); @@ -28,7 +34,10 @@ ov_area(t,j,kcr,w,"upper") = vm_area.up(j,kcr,w); ov_rotation_penalty(t,i,"upper") = vm_rotation_penalty.up(i); ov_carbon_stock_croparea(t,j,ag_pools,"upper") = vm_carbon_stock_croparea.up(j,ag_pools); + ov30_betr_missing(t,j,"upper") = v30_betr_missing.up(j); oq30_prod(t,j,kcr,"upper") = q30_prod.up(j,kcr); + oq30_betr_missing(t,j,"upper") = q30_betr_missing.up(j); + oq30_cost(t,i,"upper") = q30_cost.up(i); oq30_rotation_max(t,j,crp30,w,"upper") = q30_rotation_max.up(j,crp30,w); oq30_rotation_min(t,j,crp30,w,"upper") = q30_rotation_min.up(j,crp30,w); oq30_carbon(t,j,ag_pools,"upper") = q30_carbon.up(j,ag_pools); @@ -37,7 +46,10 @@ ov_area(t,j,kcr,w,"lower") = vm_area.lo(j,kcr,w); ov_rotation_penalty(t,i,"lower") = vm_rotation_penalty.lo(i); ov_carbon_stock_croparea(t,j,ag_pools,"lower") = vm_carbon_stock_croparea.lo(j,ag_pools); + ov30_betr_missing(t,j,"lower") = v30_betr_missing.lo(j); oq30_prod(t,j,kcr,"lower") = q30_prod.lo(j,kcr); + oq30_betr_missing(t,j,"lower") = q30_betr_missing.lo(j); + oq30_cost(t,i,"lower") = q30_cost.lo(i); oq30_rotation_max(t,j,crp30,w,"lower") = q30_rotation_max.lo(j,crp30,w); oq30_rotation_min(t,j,crp30,w,"lower") = q30_rotation_min.lo(j,crp30,w); oq30_carbon(t,j,ag_pools,"lower") = q30_carbon.lo(j,ag_pools); diff --git a/modules/30_croparea/simple_apr24/preloop.gms b/modules/30_croparea/simple_apr24/preloop.gms index 4cfa6b7f3b..899afc80c9 100644 --- a/modules/30_croparea/simple_apr24/preloop.gms +++ b/modules/30_croparea/simple_apr24/preloop.gms @@ -7,7 +7,8 @@ ** Trajectory for cropland scenarios * sigmoidal interpolation between start year and target year -m_sigmoid_time_interpol(p30_rotation_scenario_fader,s30_rotation_scenario_start,s30_rotation_scenario_target,0,1); +m_sigmoid_time_interpol(i30_rotation_scenario_fader,s30_rotation_scenario_start,s30_rotation_scenario_target,0,1); +m_sigmoid_time_interpol(i30_betr_scenario_fader,s30_betr_scenario_start,s30_betr_scenario_target,0,1); *due to some rounding errors the input data currently may contain in some cases *very small, negative numbers. These numbers have to be set to 0 as area diff --git a/modules/30_croparea/simple_apr24/presolve.gms b/modules/30_croparea/simple_apr24/presolve.gms index 942042b0e9..5dee653207 100644 --- a/modules/30_croparea/simple_apr24/presolve.gms +++ b/modules/30_croparea/simple_apr24/presolve.gms @@ -25,3 +25,7 @@ vm_rotation_penalty.fx(i)=0; crpmax30(crp30) = yes$(f30_rotation_max_shr(crp30) < 1); crpmin30(crp30) = yes$(f30_rotation_min_shr(crp30) > 0); + +* create betr target and penalty scenario +i30_betr_target(t) = s30_betr_target * i30_betr_scenario_fader(t); +i30_betr_penalty(t) = s30_betr_penalty * i30_betr_scenario_fader(t); diff --git a/modules/80_optimization/lp_nlp_apr17/input.gms b/modules/80_optimization/lp_nlp_apr17/input.gms index 3dd0e0a426..ef30bc7517 100644 --- a/modules/80_optimization/lp_nlp_apr17/input.gms +++ b/modules/80_optimization/lp_nlp_apr17/input.gms @@ -10,6 +10,7 @@ scalars s80_optfile switch to use specfied solver settings (1) / 0 / s80_add_cplex add cplex optimization after conopt4 (1) / 0 / s80_add_conopt3 add conopt3 optimization after conopt4 (1) / 0 / + s80_debug switch to use alternative solver settings (1) / 0 / ; diff --git a/modules/80_optimization/lp_nlp_apr17/solve.gms b/modules/80_optimization/lp_nlp_apr17/solve.gms index 881dca8768..ef1e3112f0 100644 --- a/modules/80_optimization/lp_nlp_apr17/solve.gms +++ b/modules/80_optimization/lp_nlp_apr17/solve.gms @@ -143,6 +143,7 @@ $batinclude "./modules/include.gms" nl_relax option nlp = conopt4; ); +if (s80_debug = 1, * if solve stopped with an error, try it again without pre-processing if((magpie.modelstat = 13), display "WARNING: Modelstat 13 | retry without Conopt4 pre-processing"; @@ -160,7 +161,7 @@ $batinclude "./modules/include.gms" nl_relax solve magpie USING nlp MINIMIZING vm_cost_glo; option nlp = conopt4; ); - +); p80_modelstat(t) = magpie.modelstat; p80_num_nonopt(t) = magpie.numNOpt; diff --git a/modules/80_optimization/nlp_apr17/input.gms b/modules/80_optimization/nlp_apr17/input.gms index 8fbcc4271a..e88d3ff306 100644 --- a/modules/80_optimization/nlp_apr17/input.gms +++ b/modules/80_optimization/nlp_apr17/input.gms @@ -8,4 +8,5 @@ scalars s80_maxiter maximal solve iterations if modelstat is > 2 (1) / 30 / s80_optfile switch to use specfied solver settings (1) / 0 / + s80_debug switch to use alternative solver settings (1) / 0 / ; diff --git a/modules/80_optimization/nlp_apr17/solve.gms b/modules/80_optimization/nlp_apr17/solve.gms index bae758fec1..969596f537 100644 --- a/modules/80_optimization/nlp_apr17/solve.gms +++ b/modules/80_optimization/nlp_apr17/solve.gms @@ -41,7 +41,8 @@ display vm_cost_glo.l; display magpie.modelstat; * in case of problems try different solvers and optfile settings -if (magpie.modelstat > 2, +if (s80_debug = 1, + if (magpie.modelstat > 2, repeat( s80_counter = s80_counter + 1 ; @@ -82,6 +83,7 @@ if (magpie.modelstat > 2, until (magpie.modelstat <= 2 or s80_counter >= s80_maxiter) ); + ); ); p80_modelstat(t) = magpie.modelstat; diff --git a/modules/80_optimization/nlp_par/input.gms b/modules/80_optimization/nlp_par/input.gms index 77e8e9f487..3b009a8781 100644 --- a/modules/80_optimization/nlp_par/input.gms +++ b/modules/80_optimization/nlp_par/input.gms @@ -8,4 +8,5 @@ scalars s80_maxiter maximal solve iterations if modelstat is > 2 (1) / 30 / s80_optfile switch to use specfied solver settings (1) / 0 / + s80_debug switch to use alternative solver settings (1) / 0 / ; diff --git a/modules/80_optimization/nlp_par/solve.gms b/modules/80_optimization/nlp_par/solve.gms index d550c5e4ae..c3782fb632 100644 --- a/modules/80_optimization/nlp_par/solve.gms +++ b/modules/80_optimization/nlp_par/solve.gms @@ -85,7 +85,8 @@ repeat p80_handle(h) = 0; ); - if (s80_resolve = 1, + if (s80_debug = 1, + if (s80_resolve = 1, display "Resolve" if (p80_modelstat(t,h) ne s80_modelstat_previter, display "Modelstat > 2 | Retry solve with CONOPT4 default setting"; @@ -108,6 +109,7 @@ repeat magpie.handle = 1; ); p80_handle(h) = magpie.handle; + ); ); h2(h) = no; i2(i) = no; From 629a80924d018daae39cd4e2f7a70e9ed1f2ae26 Mon Sep 17 00:00:00 2001 From: florianh Date: Mon, 22 Apr 2024 22:00:12 +0200 Subject: [PATCH 029/133] bugfix --- scripts/start/test_runs.R | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/start/test_runs.R b/scripts/start/test_runs.R index 93cfc01d17..64b65bdfc9 100644 --- a/scripts/start/test_runs.R +++ b/scripts/start/test_runs.R @@ -42,27 +42,27 @@ cfg$gms$c_timesteps <- timeSteps # Reference and Policy run for SSP1, SSP2 and SSP5 -for(ssp in c("SSP1","SSP2EU","SSP5")) { +for(ssp in c("SSP1","SSP2","SSP5")) { cfg$title <- .title(cfg, paste(ssp,"Ref",sep="-")) cfg <- setScenario(cfg,c(ssp,"NPI","rcp7p0")) cfg$gms$c56_mute_ghgprices_until <- "y2150" - cfg$gms$c56_pollutant_prices <- paste0("R32M46-",ssp,"-NPi") - cfg$gms$c60_2ndgen_biodem <- paste0("R32M46-",ssp,"-NPi") + cfg$gms$c56_pollutant_prices <- paste0("R32M46-",ifelse(ssp=="SSP2",paste0(ssp,"EU"),ssp),"-NPi") + cfg$gms$c60_2ndgen_biodem <- paste0("R32M46-",ifelse(ssp=="SSP2",paste0(ssp,"EU"),ssp),"-NPi") start_run(cfg, codeCheck = FALSE) cfg$title <- .title(cfg, paste(ssp,"NDC",sep="-")) cfg <- setScenario(cfg,c(ssp,"NDC","rcp4p5")) cfg$gms$c56_mute_ghgprices_until <- "y2150" - cfg$gms$c56_pollutant_prices <- paste0("R32M46-",ssp,"-NDC") - cfg$gms$c60_2ndgen_biodem <- paste0("R32M46-",ssp,"-NDC") + cfg$gms$c56_pollutant_prices <- paste0("R32M46-",ifelse(ssp=="SSP2",paste0(ssp,"EU"),ssp),"-NDC") + cfg$gms$c60_2ndgen_biodem <- paste0("R32M46-",ifelse(ssp=="SSP2",paste0(ssp,"EU"),ssp),"-NDC") start_run(cfg, codeCheck = FALSE) cfg$title <- .title(cfg, paste(ssp,"PkBudg650",sep="-")) cfg <- setScenario(cfg,c(ssp,"NDC","rcp1p9")) cfg$gms$c56_mute_ghgprices_until <- "y2030" - cfg$gms$c56_pollutant_prices <- paste0("R32M46-",ssp,"-PkBudg650") - cfg$gms$c60_2ndgen_biodem <- paste0("R32M46-",ssp,"-PkBudg650") + cfg$gms$c56_pollutant_prices <- paste0("R32M46-",ifelse(ssp=="SSP2",paste0(ssp,"EU"),ssp),"-PkBudg650") + cfg$gms$c60_2ndgen_biodem <- paste0("R32M46-",ifelse(ssp=="SSP2",paste0(ssp,"EU"),ssp),"-PkBudg650") start_run(cfg, codeCheck = FALSE) } From 670e8254b2a29465a150e0ed895b34d5951a99e9 Mon Sep 17 00:00:00 2001 From: florianh Date: Tue, 23 Apr 2024 10:00:30 +0200 Subject: [PATCH 030/133] bugfixes --- config/default.cfg | 2 +- modules/29_cropland/detail_apr24/input.gms | 2 +- modules/29_cropland/detail_apr24/presolve.gms | 22 +++++---- modules/30_croparea/detail_apr24/presolve.gms | 7 ++- modules/30_croparea/detail_apr24/sets.gms | 47 +++++++++---------- 5 files changed, 43 insertions(+), 37 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index 3142852022..8a9fc6e0c1 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -731,7 +731,7 @@ cfg$gms$s29_cost_treecover_est <- 2000 # def = 2000 # * Tree cover recurring cost (USD05MER per ha) cfg$gms$s29_cost_treecover_recur <- 500 # def = 500 # * Penalty for violation of treecover target (USD05MER per ha) -cfg$gms$s29_treecover_penalty <- 1000 # def = 1000 +cfg$gms$s29_treecover_penalty <- 2000 # def = 2000 # * Minimum cluster share of fallow land on total cropland area (including croparea, fallow land and tree cover). # * s29_fallow_target is faded in linearly between s29_fallow_scenario_start and s29_fallow_scenario_target. diff --git a/modules/29_cropland/detail_apr24/input.gms b/modules/29_cropland/detail_apr24/input.gms index ab00ed8a46..773fc3c99e 100644 --- a/modules/29_cropland/detail_apr24/input.gms +++ b/modules/29_cropland/detail_apr24/input.gms @@ -23,7 +23,7 @@ scalars s29_treecover_scenario_target Cropland treecover scenario target year / 2050 / s29_treecover_target Target share of treecover on total cropland (1) / 0 / s29_treecover_keep Adjust s29_treecover_target to avoid loss of existing treecover (1=yes 0=no) / 1 / - s29_treecover_penalty Penalty for violation of treecover target (USD05MER per ha) / 1000 / + s29_treecover_penalty Penalty for violation of treecover target (USD05MER per ha) / 2000 / s29_fallow_scenario_start Fallow land scenario start year / 2020 / s29_fallow_scenario_target Fallow land scenario target year / 2050 / s29_fallow_target Target share of fallow land on total cropland (1) / 0 / diff --git a/modules/29_cropland/detail_apr24/presolve.gms b/modules/29_cropland/detail_apr24/presolve.gms index ef1eb80ee3..7cdac2bf19 100644 --- a/modules/29_cropland/detail_apr24/presolve.gms +++ b/modules/29_cropland/detail_apr24/presolve.gms @@ -44,23 +44,29 @@ v29_treecover.l(j,ac) = p29_treecover(t,j,ac); * create treecover target and penalty scenario i29_treecover_target(t,j) = s29_treecover_target * i29_treecover_scenario_fader(t); -i29_treecover_penalty(t) = s29_treecover_penalty * i29_treecover_scenario_fader(t); + +p29_treecover_share(t,j) = 0; +p29_treecover_share(t,j)$(pcm_land(j,"crop") > 1e-10) = sum(ac, pc29_treecover(j,ac)) / pcm_land(j,"crop"); +if (s29_treecover_keep = 1, + i29_treecover_target(t,j)$(i29_treecover_target(t,j) < p29_treecover_share(t,j)) = p29_treecover_share(t,j); +); if(m_year(t) <= s29_treecover_scenario_start, v29_treecover.fx(j,ac) = pc29_treecover(j,ac); + i29_treecover_penalty(t) = 0; else v29_treecover.lo(j,ac_est) = 0; v29_treecover.up(j,ac_est) = Inf; v29_treecover.lo(j,ac_sub) = 0; v29_treecover.up(j,ac_sub) = pc29_treecover(j,ac_sub); -); - -p29_treecover_share(t,j) = 0; -p29_treecover_share(t,j)$(pcm_land(j,"crop") > 1e-10) = sum(ac, pc29_treecover(j,ac)) / pcm_land(j,"crop"); -if (s29_treecover_keep = 1, - i29_treecover_target(t,j)$(i29_treecover_target(t,j) < p29_treecover_share(t,j)) = p29_treecover_share(t,j); + i29_treecover_penalty(t) = s29_treecover_penalty; ); * create fallow land target and penalty scenario i29_fallow_target(t) = s29_fallow_target * i29_fallow_scenario_fader(t); -i29_fallow_penalty(t) = s29_fallow_penalty * i29_fallow_scenario_fader(t); + +if(m_year(t) <= s29_fallow_scenario_start, + i29_fallow_penalty(t) = 0; +else + i29_fallow_penalty(t) = s29_fallow_penalty; +); diff --git a/modules/30_croparea/detail_apr24/presolve.gms b/modules/30_croparea/detail_apr24/presolve.gms index 0efea7ea26..ff63a8c7e4 100644 --- a/modules/30_croparea/detail_apr24/presolve.gms +++ b/modules/30_croparea/detail_apr24/presolve.gms @@ -27,4 +27,9 @@ rotamin_red30(rotamin30) = yes$(i30_rotation_rules(t,rotamin30) > 0); * create betr target and penalty scenario i30_betr_target(t) = s30_betr_target * i30_betr_scenario_fader(t); -i30_betr_penalty(t) = s30_betr_penalty * i30_betr_scenario_fader(t); + +if(m_year(t) <= s30_betr_scenario_start, + i30_betr_penalty(t) = 0; +else + i30_betr_penalty(t) = s30_betr_penalty; +); diff --git a/modules/30_croparea/detail_apr24/sets.gms b/modules/30_croparea/detail_apr24/sets.gms index addda5290f..579e1f82b3 100644 --- a/modules/30_croparea/detail_apr24/sets.gms +++ b/modules/30_croparea/detail_apr24/sets.gms @@ -7,39 +7,35 @@ sets incentscen30 rotation inventive scenarios - /none,default,legumes,betr500,betr1000,agroecology/ + / none, default, legumes, agroecology / rotascen30 rotation constraint scenarios - /min,default,good,good_20div,setaside,legumes, - betr0,betr10,betr20,betr25,betr30,betr40,betr50, - sixfoldrotation,agroecology,FSEC/ + / min, default, good,good_20div, setaside, legumes, sixfoldrotation, agroecology, FSEC / rota30 rotational rules - /cereals1_max, cereals2_max, cereals_excl_rice_max, stalk_max, - resistant_max, oilcrops_max, - legumes_max, rootsrape_max, roots_max, rape_sugr_max, biomass_max, - tece_max, maiz_max, trce_max, rice_max, - rapeseed_max, soybean_max, sunflower_max, groundnut_max, - oilpalm_max, puls_max, potato_max, cassava_max, - sugr_cane_max, sugr_beet_max, others_max, foddr_max, - fiber_max, begr_max, betr_max - biomass_min, legumes_min, stalk_min, others_min, - minor_min, cereals_min, betr_min/ - + / cereals1_max, cereals2_max, cereals_excl_rice_max, stalk_max, + resistant_max, oilcrops_max, + legumes_max, rootsrape_max, roots_max, rape_sugr_max, biomass_max, + tece_max, maiz_max, trce_max, rice_max, + rapeseed_max, soybean_max, sunflower_max, groundnut_max, + oilpalm_max, puls_max, potato_max, cassava_max, + sugr_cane_max, sugr_beet_max, others_max, foddr_max, + fiber_max, begr_max, betr_max + biomass_min, legumes_min, stalk_min, others_min, + minor_min, cereals_min / rotamax30(rota30) rotational maximum rules - /cereals1_max, cereals2_max, cereals_excl_rice_max, stalk_max, - resistant_max, oilcrops_max, - legumes_max, rootsrape_max, roots_max, rape_sugr_max, biomass_max, - tece_max, maiz_max, trce_max, rice_max, - rapeseed_max, soybean_max, sunflower_max, groundnut_max, - oilpalm_max, puls_max, potato_max, cassava_max, - sugr_cane_max, sugr_beet_max, others_max, foddr_max, - fiber_max, begr_max, betr_max/ + / cereals1_max, cereals2_max, cereals_excl_rice_max, stalk_max, + resistant_max, oilcrops_max, + legumes_max, rootsrape_max, roots_max, rape_sugr_max, biomass_max, + tece_max, maiz_max, trce_max, rice_max, + rapeseed_max, soybean_max, sunflower_max, groundnut_max, + oilpalm_max, puls_max, potato_max, cassava_max, + sugr_cane_max, sugr_beet_max, others_max, foddr_max, + fiber_max, begr_max, betr_max / rotamin30(rota30) rotational minimum rules - /biomass_min, legumes_min, stalk_min, others_min, - minor_min, cereals_min, betr_min/ + / biomass_min, legumes_min, stalk_min, others_min, minor_min, cereals_min / rotamax_red30(rotamax30) Maximum crop rotation reduced set rotamin_red30(rotamin30) Minimum crop rotation reduced set @@ -96,7 +92,6 @@ sets cereals_min . (tece, maiz, trce, rice_pro) stalk_min . (tece, maiz, trce, rice_pro, sugr_cane, foddr) others_min . (others) - betr_min . (betr) / kbe30(kcr) bio energy activities From eea0d5fc0339af623b55025b52284a94cad55cba Mon Sep 17 00:00:00 2001 From: florianh Date: Tue, 23 Apr 2024 12:01:45 +0200 Subject: [PATCH 031/133] bugfix --- modules/29_cropland/detail_apr24/presolve.gms | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/29_cropland/detail_apr24/presolve.gms b/modules/29_cropland/detail_apr24/presolve.gms index 7cdac2bf19..2ae6680260 100644 --- a/modules/29_cropland/detail_apr24/presolve.gms +++ b/modules/29_cropland/detail_apr24/presolve.gms @@ -59,6 +59,7 @@ else v29_treecover.up(j,ac_est) = Inf; v29_treecover.lo(j,ac_sub) = 0; v29_treecover.up(j,ac_sub) = pc29_treecover(j,ac_sub); + m_boundfix(v29_treecover,(j,ac_sub),l,10e-5); i29_treecover_penalty(t) = s29_treecover_penalty; ); From b44171cbdace3618842f28c97063d8d2acc4646b Mon Sep 17 00:00:00 2001 From: florianh Date: Tue, 23 Apr 2024 16:00:16 +0200 Subject: [PATCH 032/133] bugfixes --- CHANGELOG.md | 10 ++++++++-- config/default.cfg | 4 +++- modules/29_cropland/detail_apr24/declarations.gms | 2 ++ modules/29_cropland/detail_apr24/equations.gms | 4 ++-- modules/29_cropland/detail_apr24/input.gms | 1 + modules/29_cropland/detail_apr24/postsolve.gms | 4 ++++ modules/32_forestry/dynamic_feb21/equations.gms | 2 +- modules/80_optimization/lp_nlp_apr17/input.gms | 2 +- modules/80_optimization/lp_nlp_apr17/solve.gms | 2 +- modules/80_optimization/nlp_apr17/input.gms | 2 +- modules/80_optimization/nlp_apr17/solve.gms | 2 +- modules/80_optimization/nlp_par/input.gms | 2 +- modules/80_optimization/nlp_par/solve.gms | 2 +- 13 files changed, 27 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2072cddd55..4c91c7a38e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,10 +8,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] ### changed -- +- **29_ageclass** module 29_ageclass has been renamed to 28_ageclass to make space for `29_cropland` just before `30_croparea` +- **30_crop** module `30_crop` renamed to `30_croparea`, which now only accounts for crop area. +- **30_crop** SNV implementation has been moved from `30_crop` to `29_cropland/detail_apr24` +- **30_crop** the two realizations `penalty_apr22` and `rotation_apr22` have been merged into a single `30_croparea/detail_apr24` realization +- **30_crop** the previous `30_crop/endo_apr21` realization has been moved to `30_croparea/simple_apr24` +- **80_optimization** added option `s80_extra_solve`, which is deactivated by default to shorten the run time of infeasible model runs ### added -- +- **29_cropland** new module `29_cropland` accounting for crop area, fallow cropland and tree cover on cropland with two realizations: `detail_apr24` (default) and `simple_apr24`. +- **10_land** added interface `pm_land_hist` with historic land use patterns ### removed - diff --git a/config/default.cfg b/config/default.cfg index 8a9fc6e0c1..824380ef5e 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -716,6 +716,8 @@ cfg$gms$policy_countries29 <- all_iso_countries # * "secdforest, other", # * "secdforest, past, other" etc. cfg$gms$land_snv <- "secdforest, forestry, past, other" #def = "secdforest, forestry, past, other" +# * Penalty for violation of cropland relocation target (USD05MER per ha) +cfg$gms$s29_relocation_penalty <- 1000000 # def = 1000000 # * Minimum cluster share of treecover on total cropland area (including croparea, fallow land and tree cover). # * s29_treecover_target is faded in linearly between s29_treecover_scenario_start and s29_treecover_scenario_target. @@ -1965,7 +1967,7 @@ cfg$gms$s80_optfile <- 0 # def = 0 # * 0: not used # * 1: additional solve statements for CONOPT4 without preprocessing and CONOPT3 # * Note: Option 1 is very time-consuming and usually does not provide a feasible solution. -cfg$gms$s80_debug <- 0 # def = 0 +cfg$gms$s80_extra_solve <- 0 # def = 0 #*******************************END MODULE SETUP******************************** diff --git a/modules/29_cropland/detail_apr24/declarations.gms b/modules/29_cropland/detail_apr24/declarations.gms index e9aa88f83d..a34fad1567 100644 --- a/modules/29_cropland/detail_apr24/declarations.gms +++ b/modules/29_cropland/detail_apr24/declarations.gms @@ -42,6 +42,7 @@ positive variables v29_cost_treecover_recur(j) Recurring cost for cropland tree cover (mio. USD05MER per yr) vm_fallow(j) Fallow land is temporarily fallow cropland (mio. ha) v29_fallow_missing(j) Missing fallow land towards target (mio. ha) + v29_relocation_missing(j) Missing fallow land towards target (mio. ha) ; equations @@ -69,6 +70,7 @@ parameters ov29_cost_treecover_recur(t,j,type) Recurring cost for cropland tree cover (mio. USD05MER per yr) ov_fallow(t,j,type) Fallow land is temporarily fallow cropland (mio. ha) ov29_fallow_missing(t,j,type) Missing fallow land towards target (mio. ha) + ov29_relocation_missing(t,j,type) Missing fallow land towards target (mio. ha) oq29_cropland(t,j,type) Total cropland calculation (mio. ha) oq29_avl_cropland(t,j,type) Available cropland constraint (mio. ha) oq29_cost_cropland(t,j,type) Costs and benefits related to agroforestry (mio. USD05MER per yr) diff --git a/modules/29_cropland/detail_apr24/equations.gms b/modules/29_cropland/detail_apr24/equations.gms index 0faf477aca..352f5210df 100644 --- a/modules/29_cropland/detail_apr24/equations.gms +++ b/modules/29_cropland/detail_apr24/equations.gms @@ -28,6 +28,7 @@ q29_cost_cropland(j2) .. vm_cost_cropland(j2) =e= v29_cost_treecover_est(j2) + v29_cost_treecover_recur(j2) + + v29_relocation_missing(j2) * s29_relocation_penalty + v29_fallow_missing(j2) * sum(ct, i29_fallow_penalty(ct)) + v29_treecover_missing(j2) * sum(ct, i29_treecover_penalty(ct)); @@ -57,8 +58,7 @@ *' (@buchhorn_copernicus_2020). q29_land_snv_trans(j2) .. - sum(land_snv, vm_lu_transitions(j2,"crop",land_snv)) =g= sum(ct, p29_snv_relocation(ct,j2)); - + v29_relocation_missing(j2) =g= sum(ct, p29_snv_relocation(ct,j2)) - sum(land_snv, vm_lu_transitions(j2,"crop",land_snv)); *' A penalty is applied for the violation of fallow land rules. *' The penalty applies to the missing fallow land, i.e. where fallow land diff --git a/modules/29_cropland/detail_apr24/input.gms b/modules/29_cropland/detail_apr24/input.gms index 773fc3c99e..396f1b3e03 100644 --- a/modules/29_cropland/detail_apr24/input.gms +++ b/modules/29_cropland/detail_apr24/input.gms @@ -28,6 +28,7 @@ scalars s29_fallow_scenario_target Fallow land scenario target year / 2050 / s29_fallow_target Target share of fallow land on total cropland (1) / 0 / s29_fallow_penalty Penalty for violation of fallow target (USD05MER per ha) / 500 / + s29_relocation_penalty Penalty for violation of cropland relocation target (USD05MER per ha) / 1000000 / ; diff --git a/modules/29_cropland/detail_apr24/postsolve.gms b/modules/29_cropland/detail_apr24/postsolve.gms index 0d05aea001..27f29b6d99 100644 --- a/modules/29_cropland/detail_apr24/postsolve.gms +++ b/modules/29_cropland/detail_apr24/postsolve.gms @@ -15,6 +15,7 @@ pc29_treecover(j,ac) = v29_treecover.l(j,ac); ov29_cost_treecover_recur(t,j,"marginal") = v29_cost_treecover_recur.m(j); ov_fallow(t,j,"marginal") = vm_fallow.m(j); ov29_fallow_missing(t,j,"marginal") = v29_fallow_missing.m(j); + ov29_relocation_missing(t,j,"marginal") = v29_relocation_missing.m(j); oq29_cropland(t,j,"marginal") = q29_cropland.m(j); oq29_avl_cropland(t,j,"marginal") = q29_avl_cropland.m(j); oq29_cost_cropland(t,j,"marginal") = q29_cost_cropland.m(j); @@ -35,6 +36,7 @@ pc29_treecover(j,ac) = v29_treecover.l(j,ac); ov29_cost_treecover_recur(t,j,"level") = v29_cost_treecover_recur.l(j); ov_fallow(t,j,"level") = vm_fallow.l(j); ov29_fallow_missing(t,j,"level") = v29_fallow_missing.l(j); + ov29_relocation_missing(t,j,"level") = v29_relocation_missing.l(j); oq29_cropland(t,j,"level") = q29_cropland.l(j); oq29_avl_cropland(t,j,"level") = q29_avl_cropland.l(j); oq29_cost_cropland(t,j,"level") = q29_cost_cropland.l(j); @@ -55,6 +57,7 @@ pc29_treecover(j,ac) = v29_treecover.l(j,ac); ov29_cost_treecover_recur(t,j,"upper") = v29_cost_treecover_recur.up(j); ov_fallow(t,j,"upper") = vm_fallow.up(j); ov29_fallow_missing(t,j,"upper") = v29_fallow_missing.up(j); + ov29_relocation_missing(t,j,"upper") = v29_relocation_missing.up(j); oq29_cropland(t,j,"upper") = q29_cropland.up(j); oq29_avl_cropland(t,j,"upper") = q29_avl_cropland.up(j); oq29_cost_cropland(t,j,"upper") = q29_cost_cropland.up(j); @@ -75,6 +78,7 @@ pc29_treecover(j,ac) = v29_treecover.l(j,ac); ov29_cost_treecover_recur(t,j,"lower") = v29_cost_treecover_recur.lo(j); ov_fallow(t,j,"lower") = vm_fallow.lo(j); ov29_fallow_missing(t,j,"lower") = v29_fallow_missing.lo(j); + ov29_relocation_missing(t,j,"lower") = v29_relocation_missing.lo(j); oq29_cropland(t,j,"lower") = q29_cropland.lo(j); oq29_avl_cropland(t,j,"lower") = q29_avl_cropland.lo(j); oq29_cost_cropland(t,j,"lower") = q29_cost_cropland.lo(j); diff --git a/modules/32_forestry/dynamic_feb21/equations.gms b/modules/32_forestry/dynamic_feb21/equations.gms index 46945a28a1..5094f4ba18 100644 --- a/modules/32_forestry/dynamic_feb21/equations.gms +++ b/modules/32_forestry/dynamic_feb21/equations.gms @@ -68,7 +68,7 @@ sum(ac_est, v32_land(j2,"aff",ac_est)) =l= sum(ac, v32_land(j2,"aff",ac)) - sum( *' The constraint `q32_aff_pol` accounts for the exogenous afforestation prescribed by NPI/NDC policies. q32_aff_pol(j2) .. - sum(ac_est, v32_land(j2,"ndc",ac_est)) + v32_land_missing_ndc(j2) =e= sum(ct, p32_aff_pol_timestep(ct,j2)); + v32_land_missing_ndc(j2) =g= sum(ct, p32_aff_pol_timestep(ct,j2)) - sum(ac_est, v32_land(j2,"ndc",ac_est)); *' The constraint `q32_max_aff` accounts for the allowed maximum global endogenous *' afforestation defined in `i32_max_aff_area_glo`. diff --git a/modules/80_optimization/lp_nlp_apr17/input.gms b/modules/80_optimization/lp_nlp_apr17/input.gms index ef30bc7517..a157e8bf5a 100644 --- a/modules/80_optimization/lp_nlp_apr17/input.gms +++ b/modules/80_optimization/lp_nlp_apr17/input.gms @@ -10,7 +10,7 @@ scalars s80_optfile switch to use specfied solver settings (1) / 0 / s80_add_cplex add cplex optimization after conopt4 (1) / 0 / s80_add_conopt3 add conopt3 optimization after conopt4 (1) / 0 / - s80_debug switch to use alternative solver settings (1) / 0 / + s80_extra_solve switch to use alternative solver settings (1) / 0 / ; diff --git a/modules/80_optimization/lp_nlp_apr17/solve.gms b/modules/80_optimization/lp_nlp_apr17/solve.gms index ef1e3112f0..62650b1c1e 100644 --- a/modules/80_optimization/lp_nlp_apr17/solve.gms +++ b/modules/80_optimization/lp_nlp_apr17/solve.gms @@ -143,7 +143,7 @@ $batinclude "./modules/include.gms" nl_relax option nlp = conopt4; ); -if (s80_debug = 1, +if (s80_extra_solve = 1, * if solve stopped with an error, try it again without pre-processing if((magpie.modelstat = 13), display "WARNING: Modelstat 13 | retry without Conopt4 pre-processing"; diff --git a/modules/80_optimization/nlp_apr17/input.gms b/modules/80_optimization/nlp_apr17/input.gms index e88d3ff306..16536ff584 100644 --- a/modules/80_optimization/nlp_apr17/input.gms +++ b/modules/80_optimization/nlp_apr17/input.gms @@ -8,5 +8,5 @@ scalars s80_maxiter maximal solve iterations if modelstat is > 2 (1) / 30 / s80_optfile switch to use specfied solver settings (1) / 0 / - s80_debug switch to use alternative solver settings (1) / 0 / + s80_extra_solve switch to use alternative solver settings (1) / 0 / ; diff --git a/modules/80_optimization/nlp_apr17/solve.gms b/modules/80_optimization/nlp_apr17/solve.gms index 969596f537..bb4edc2c31 100644 --- a/modules/80_optimization/nlp_apr17/solve.gms +++ b/modules/80_optimization/nlp_apr17/solve.gms @@ -41,7 +41,7 @@ display vm_cost_glo.l; display magpie.modelstat; * in case of problems try different solvers and optfile settings -if (s80_debug = 1, +if (s80_extra_solve = 1, if (magpie.modelstat > 2, repeat( s80_counter = s80_counter + 1 ; diff --git a/modules/80_optimization/nlp_par/input.gms b/modules/80_optimization/nlp_par/input.gms index 3b009a8781..c0a8d3303f 100644 --- a/modules/80_optimization/nlp_par/input.gms +++ b/modules/80_optimization/nlp_par/input.gms @@ -8,5 +8,5 @@ scalars s80_maxiter maximal solve iterations if modelstat is > 2 (1) / 30 / s80_optfile switch to use specfied solver settings (1) / 0 / - s80_debug switch to use alternative solver settings (1) / 0 / + s80_extra_solve switch to use alternative solver settings (1) / 0 / ; diff --git a/modules/80_optimization/nlp_par/solve.gms b/modules/80_optimization/nlp_par/solve.gms index c3782fb632..4db21bc22d 100644 --- a/modules/80_optimization/nlp_par/solve.gms +++ b/modules/80_optimization/nlp_par/solve.gms @@ -85,7 +85,7 @@ repeat p80_handle(h) = 0; ); - if (s80_debug = 1, + if (s80_extra_solve = 1, if (s80_resolve = 1, display "Resolve" if (p80_modelstat(t,h) ne s80_modelstat_previter, From abd5d8a8a30ca6ccd64c867c38b98252434ee648 Mon Sep 17 00:00:00 2001 From: florianh Date: Tue, 23 Apr 2024 17:30:57 +0200 Subject: [PATCH 033/133] bugfixes --- config/default.cfg | 4 ++-- modules/29_cropland/detail_apr24/input.gms | 2 +- modules/29_cropland/detail_apr24/realization.gms | 1 + modules/29_cropland/detail_apr24/scaling.gms | 9 +++++++++ modules/32_forestry/dynamic_feb21/input.gms | 2 +- modules/80_optimization/nlp_par/input.gms | 2 +- 6 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 modules/29_cropland/detail_apr24/scaling.gms diff --git a/config/default.cfg b/config/default.cfg index 824380ef5e..3b00828097 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -205,7 +205,7 @@ cfg$gms$land <- "landmatrix_dec18" # def = landmatrix_dec18 # * The balance variables in the land module avoid infeasibilities due to # * differences in accuracy between parameters and variables in GAMS. # * High costs make sure that the balance variables are only used as a last resort. -cfg$gms$s10_cost_balance <- 1000000 # def = 1000000 +cfg$gms$s10_cost_balance <- 1e+06 # def = 1e+06 # ***--------------------- 11_costs ------ -------------------------------- @@ -717,7 +717,7 @@ cfg$gms$policy_countries29 <- all_iso_countries # * "secdforest, past, other" etc. cfg$gms$land_snv <- "secdforest, forestry, past, other" #def = "secdforest, forestry, past, other" # * Penalty for violation of cropland relocation target (USD05MER per ha) -cfg$gms$s29_relocation_penalty <- 1000000 # def = 1000000 +cfg$gms$s29_relocation_penalty <- 1e+06 # def = 1e+06 # * Minimum cluster share of treecover on total cropland area (including croparea, fallow land and tree cover). # * s29_treecover_target is faded in linearly between s29_treecover_scenario_start and s29_treecover_scenario_target. diff --git a/modules/29_cropland/detail_apr24/input.gms b/modules/29_cropland/detail_apr24/input.gms index 396f1b3e03..8b477c3d4a 100644 --- a/modules/29_cropland/detail_apr24/input.gms +++ b/modules/29_cropland/detail_apr24/input.gms @@ -28,7 +28,7 @@ scalars s29_fallow_scenario_target Fallow land scenario target year / 2050 / s29_fallow_target Target share of fallow land on total cropland (1) / 0 / s29_fallow_penalty Penalty for violation of fallow target (USD05MER per ha) / 500 / - s29_relocation_penalty Penalty for violation of cropland relocation target (USD05MER per ha) / 1000000 / + s29_relocation_penalty Penalty for violation of cropland relocation target (USD05MER per ha) / 1e+06 / ; diff --git a/modules/29_cropland/detail_apr24/realization.gms b/modules/29_cropland/detail_apr24/realization.gms index 071000bd1e..c9b62fec84 100644 --- a/modules/29_cropland/detail_apr24/realization.gms +++ b/modules/29_cropland/detail_apr24/realization.gms @@ -25,6 +25,7 @@ $Ifi "%phase%" == "sets" $include "./modules/29_cropland/detail_apr24/sets.gms" $Ifi "%phase%" == "declarations" $include "./modules/29_cropland/detail_apr24/declarations.gms" $Ifi "%phase%" == "input" $include "./modules/29_cropland/detail_apr24/input.gms" $Ifi "%phase%" == "equations" $include "./modules/29_cropland/detail_apr24/equations.gms" +$Ifi "%phase%" == "scaling" $include "./modules/29_cropland/detail_apr24/scaling.gms" $Ifi "%phase%" == "preloop" $include "./modules/29_cropland/detail_apr24/preloop.gms" $Ifi "%phase%" == "presolve" $include "./modules/29_cropland/detail_apr24/presolve.gms" $Ifi "%phase%" == "postsolve" $include "./modules/29_cropland/detail_apr24/postsolve.gms" diff --git a/modules/29_cropland/detail_apr24/scaling.gms b/modules/29_cropland/detail_apr24/scaling.gms new file mode 100644 index 0000000000..2802c2cd18 --- /dev/null +++ b/modules/29_cropland/detail_apr24/scaling.gms @@ -0,0 +1,9 @@ +*** | (C) 2008-2024 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 + +v29_fallow_missing.scale(j) = 10e-6; +v29_relocation_missing.scale(j) = 10e-6; diff --git a/modules/32_forestry/dynamic_feb21/input.gms b/modules/32_forestry/dynamic_feb21/input.gms index 7535dd5077..f9765e58d5 100644 --- a/modules/32_forestry/dynamic_feb21/input.gms +++ b/modules/32_forestry/dynamic_feb21/input.gms @@ -38,7 +38,7 @@ scalars s32_faustmann_rotation Switch to activate faustmann rotations (1=on 0=off) / 0 / s32_initial_distribution Switch to Activate ageclass distribution in plantations 0=off 1=equal distribution 2=FAO distribution 3=Poulter distribution 4=Manual distribution (1) / 0 / s32_price Price for timber (USD) / 45 / - s32_free_land_cost Penalty for technial area balance term (USD per ha) /1000000/ + s32_free_land_cost Penalty for technial area balance term (USD per ha) / 1e+06 / s32_max_aff_area Maximum total global afforestation (mio. ha) / Inf / s32_aff_plantation Switch for using growth curves for afforestation 0=natveg 1=plantations (1) / 0 / s32_tcre_local Switch for local (1) or global (0) TRCE factors (1) / 1 / diff --git a/modules/80_optimization/nlp_par/input.gms b/modules/80_optimization/nlp_par/input.gms index c0a8d3303f..bc0dc6e7ce 100644 --- a/modules/80_optimization/nlp_par/input.gms +++ b/modules/80_optimization/nlp_par/input.gms @@ -8,5 +8,5 @@ scalars s80_maxiter maximal solve iterations if modelstat is > 2 (1) / 30 / s80_optfile switch to use specfied solver settings (1) / 0 / - s80_extra_solve switch to use alternative solver settings (1) / 0 / + s80_extra_solve switch to use alternative solver settings (1) / 0 / ; From 500c08fdb9e19dbaeaaf6e2815808ecc9ead88f6 Mon Sep 17 00:00:00 2001 From: florianh Date: Tue, 23 Apr 2024 20:11:45 +0200 Subject: [PATCH 034/133] bugfix --- modules/29_cropland/detail_apr24/presolve.gms | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/29_cropland/detail_apr24/presolve.gms b/modules/29_cropland/detail_apr24/presolve.gms index 2ae6680260..b83722616d 100644 --- a/modules/29_cropland/detail_apr24/presolve.gms +++ b/modules/29_cropland/detail_apr24/presolve.gms @@ -24,6 +24,7 @@ p29_snv_relocation(t,j) = (i29_snv_scenario_fader(t) - i29_snv_scenario_fader(t- *' cases of cropland reduction p29_max_snv_relocation(t,j) = p29_snv_shr(t,j) * (i29_snv_scenario_fader(t) - i29_snv_scenario_fader(t-1)) * pcm_land(j,"crop") - sum(ac, pc29_treecover(j,ac)); +p29_max_snv_relocation(t,j)$(p29_max_snv_relocation(t,j) < 0) = 0; p29_snv_relocation(t,j)$(p29_snv_relocation(t, j) > p29_max_snv_relocation(t,j)) = p29_max_snv_relocation(t,j); *' Area potentially available for cropping From 4f4fbf46b555e2d5cd595e2c9c76a66859d3a56d Mon Sep 17 00:00:00 2001 From: florianh Date: Tue, 23 Apr 2024 22:11:24 +0200 Subject: [PATCH 035/133] bugfixes --- config/default.cfg | 6 +++--- modules/29_cropland/detail_apr24/declarations.gms | 2 -- modules/29_cropland/detail_apr24/equations.gms | 3 +-- modules/29_cropland/detail_apr24/input.gms | 4 ++-- modules/29_cropland/detail_apr24/postsolve.gms | 4 ---- modules/29_cropland/detail_apr24/presolve.gms | 1 + modules/29_cropland/detail_apr24/realization.gms | 1 - modules/29_cropland/detail_apr24/scaling.gms | 9 --------- modules/32_forestry/dynamic_feb21/equations.gms | 2 +- 9 files changed, 8 insertions(+), 24 deletions(-) delete mode 100644 modules/29_cropland/detail_apr24/scaling.gms diff --git a/config/default.cfg b/config/default.cfg index 3b00828097..b9dc6b1bc3 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -716,14 +716,14 @@ cfg$gms$policy_countries29 <- all_iso_countries # * "secdforest, other", # * "secdforest, past, other" etc. cfg$gms$land_snv <- "secdforest, forestry, past, other" #def = "secdforest, forestry, past, other" -# * Penalty for violation of cropland relocation target (USD05MER per ha) -cfg$gms$s29_relocation_penalty <- 1e+06 # def = 1e+06 # * Minimum cluster share of treecover on total cropland area (including croparea, fallow land and tree cover). # * s29_treecover_target is faded in linearly between s29_treecover_scenario_start and s29_treecover_scenario_target. cfg$gms$s29_treecover_target <- 0 # def = 0 -# * Adjust s29_treecover_target to avoid loss of existing treecover (1=yes 0=no) +# * Avoid loss of existing treecover (1=yes 0=no) cfg$gms$s29_treecover_keep <- 1 # def = 1 +# * Maximum share of existing treecover on total cropland (1) +cfg$gms$s29_treecover_max <- 0.4 # def = 0.4 # * Start year of tree cover share fade-in: cfg$gms$s29_treecover_scenario_start <- 2020 # def = 2020 # * Target year (year when full implementation is reached): diff --git a/modules/29_cropland/detail_apr24/declarations.gms b/modules/29_cropland/detail_apr24/declarations.gms index a34fad1567..e9aa88f83d 100644 --- a/modules/29_cropland/detail_apr24/declarations.gms +++ b/modules/29_cropland/detail_apr24/declarations.gms @@ -42,7 +42,6 @@ positive variables v29_cost_treecover_recur(j) Recurring cost for cropland tree cover (mio. USD05MER per yr) vm_fallow(j) Fallow land is temporarily fallow cropland (mio. ha) v29_fallow_missing(j) Missing fallow land towards target (mio. ha) - v29_relocation_missing(j) Missing fallow land towards target (mio. ha) ; equations @@ -70,7 +69,6 @@ parameters ov29_cost_treecover_recur(t,j,type) Recurring cost for cropland tree cover (mio. USD05MER per yr) ov_fallow(t,j,type) Fallow land is temporarily fallow cropland (mio. ha) ov29_fallow_missing(t,j,type) Missing fallow land towards target (mio. ha) - ov29_relocation_missing(t,j,type) Missing fallow land towards target (mio. ha) oq29_cropland(t,j,type) Total cropland calculation (mio. ha) oq29_avl_cropland(t,j,type) Available cropland constraint (mio. ha) oq29_cost_cropland(t,j,type) Costs and benefits related to agroforestry (mio. USD05MER per yr) diff --git a/modules/29_cropland/detail_apr24/equations.gms b/modules/29_cropland/detail_apr24/equations.gms index 352f5210df..ebee259325 100644 --- a/modules/29_cropland/detail_apr24/equations.gms +++ b/modules/29_cropland/detail_apr24/equations.gms @@ -28,7 +28,6 @@ q29_cost_cropland(j2) .. vm_cost_cropland(j2) =e= v29_cost_treecover_est(j2) + v29_cost_treecover_recur(j2) - + v29_relocation_missing(j2) * s29_relocation_penalty + v29_fallow_missing(j2) * sum(ct, i29_fallow_penalty(ct)) + v29_treecover_missing(j2) * sum(ct, i29_treecover_penalty(ct)); @@ -58,7 +57,7 @@ *' (@buchhorn_copernicus_2020). q29_land_snv_trans(j2) .. - v29_relocation_missing(j2) =g= sum(ct, p29_snv_relocation(ct,j2)) - sum(land_snv, vm_lu_transitions(j2,"crop",land_snv)); + sum(land_snv, vm_lu_transitions(j2,"crop",land_snv)) =g= sum(ct, p29_snv_relocation(ct,j2)); *' A penalty is applied for the violation of fallow land rules. *' The penalty applies to the missing fallow land, i.e. where fallow land diff --git a/modules/29_cropland/detail_apr24/input.gms b/modules/29_cropland/detail_apr24/input.gms index 8b477c3d4a..b7022a5323 100644 --- a/modules/29_cropland/detail_apr24/input.gms +++ b/modules/29_cropland/detail_apr24/input.gms @@ -22,13 +22,13 @@ scalars s29_treecover_scenario_start Cropland treecover scenario start year / 2020 / s29_treecover_scenario_target Cropland treecover scenario target year / 2050 / s29_treecover_target Target share of treecover on total cropland (1) / 0 / - s29_treecover_keep Adjust s29_treecover_target to avoid loss of existing treecover (1=yes 0=no) / 1 / + s29_treecover_keep Avoid loss of existing treecover (1=yes 0=no) / 1 / + s29_treecover_max Maximum share of existing treecover on total cropland (1) / 0.4 / s29_treecover_penalty Penalty for violation of treecover target (USD05MER per ha) / 2000 / s29_fallow_scenario_start Fallow land scenario start year / 2020 / s29_fallow_scenario_target Fallow land scenario target year / 2050 / s29_fallow_target Target share of fallow land on total cropland (1) / 0 / s29_fallow_penalty Penalty for violation of fallow target (USD05MER per ha) / 500 / - s29_relocation_penalty Penalty for violation of cropland relocation target (USD05MER per ha) / 1e+06 / ; diff --git a/modules/29_cropland/detail_apr24/postsolve.gms b/modules/29_cropland/detail_apr24/postsolve.gms index 27f29b6d99..0d05aea001 100644 --- a/modules/29_cropland/detail_apr24/postsolve.gms +++ b/modules/29_cropland/detail_apr24/postsolve.gms @@ -15,7 +15,6 @@ pc29_treecover(j,ac) = v29_treecover.l(j,ac); ov29_cost_treecover_recur(t,j,"marginal") = v29_cost_treecover_recur.m(j); ov_fallow(t,j,"marginal") = vm_fallow.m(j); ov29_fallow_missing(t,j,"marginal") = v29_fallow_missing.m(j); - ov29_relocation_missing(t,j,"marginal") = v29_relocation_missing.m(j); oq29_cropland(t,j,"marginal") = q29_cropland.m(j); oq29_avl_cropland(t,j,"marginal") = q29_avl_cropland.m(j); oq29_cost_cropland(t,j,"marginal") = q29_cost_cropland.m(j); @@ -36,7 +35,6 @@ pc29_treecover(j,ac) = v29_treecover.l(j,ac); ov29_cost_treecover_recur(t,j,"level") = v29_cost_treecover_recur.l(j); ov_fallow(t,j,"level") = vm_fallow.l(j); ov29_fallow_missing(t,j,"level") = v29_fallow_missing.l(j); - ov29_relocation_missing(t,j,"level") = v29_relocation_missing.l(j); oq29_cropland(t,j,"level") = q29_cropland.l(j); oq29_avl_cropland(t,j,"level") = q29_avl_cropland.l(j); oq29_cost_cropland(t,j,"level") = q29_cost_cropland.l(j); @@ -57,7 +55,6 @@ pc29_treecover(j,ac) = v29_treecover.l(j,ac); ov29_cost_treecover_recur(t,j,"upper") = v29_cost_treecover_recur.up(j); ov_fallow(t,j,"upper") = vm_fallow.up(j); ov29_fallow_missing(t,j,"upper") = v29_fallow_missing.up(j); - ov29_relocation_missing(t,j,"upper") = v29_relocation_missing.up(j); oq29_cropland(t,j,"upper") = q29_cropland.up(j); oq29_avl_cropland(t,j,"upper") = q29_avl_cropland.up(j); oq29_cost_cropland(t,j,"upper") = q29_cost_cropland.up(j); @@ -78,7 +75,6 @@ pc29_treecover(j,ac) = v29_treecover.l(j,ac); ov29_cost_treecover_recur(t,j,"lower") = v29_cost_treecover_recur.lo(j); ov_fallow(t,j,"lower") = vm_fallow.lo(j); ov29_fallow_missing(t,j,"lower") = v29_fallow_missing.lo(j); - ov29_relocation_missing(t,j,"lower") = v29_relocation_missing.lo(j); oq29_cropland(t,j,"lower") = q29_cropland.lo(j); oq29_avl_cropland(t,j,"lower") = q29_avl_cropland.lo(j); oq29_cost_cropland(t,j,"lower") = q29_cost_cropland.lo(j); diff --git a/modules/29_cropland/detail_apr24/presolve.gms b/modules/29_cropland/detail_apr24/presolve.gms index b83722616d..d6177b87e7 100644 --- a/modules/29_cropland/detail_apr24/presolve.gms +++ b/modules/29_cropland/detail_apr24/presolve.gms @@ -48,6 +48,7 @@ i29_treecover_target(t,j) = s29_treecover_target * i29_treecover_scenario_fader( p29_treecover_share(t,j) = 0; p29_treecover_share(t,j)$(pcm_land(j,"crop") > 1e-10) = sum(ac, pc29_treecover(j,ac)) / pcm_land(j,"crop"); +p29_treecover_share(t,j)$(p29_treecover_share(t,j) > s29_treecover_max) = s29_treecover_max; if (s29_treecover_keep = 1, i29_treecover_target(t,j)$(i29_treecover_target(t,j) < p29_treecover_share(t,j)) = p29_treecover_share(t,j); ); diff --git a/modules/29_cropland/detail_apr24/realization.gms b/modules/29_cropland/detail_apr24/realization.gms index c9b62fec84..071000bd1e 100644 --- a/modules/29_cropland/detail_apr24/realization.gms +++ b/modules/29_cropland/detail_apr24/realization.gms @@ -25,7 +25,6 @@ $Ifi "%phase%" == "sets" $include "./modules/29_cropland/detail_apr24/sets.gms" $Ifi "%phase%" == "declarations" $include "./modules/29_cropland/detail_apr24/declarations.gms" $Ifi "%phase%" == "input" $include "./modules/29_cropland/detail_apr24/input.gms" $Ifi "%phase%" == "equations" $include "./modules/29_cropland/detail_apr24/equations.gms" -$Ifi "%phase%" == "scaling" $include "./modules/29_cropland/detail_apr24/scaling.gms" $Ifi "%phase%" == "preloop" $include "./modules/29_cropland/detail_apr24/preloop.gms" $Ifi "%phase%" == "presolve" $include "./modules/29_cropland/detail_apr24/presolve.gms" $Ifi "%phase%" == "postsolve" $include "./modules/29_cropland/detail_apr24/postsolve.gms" diff --git a/modules/29_cropland/detail_apr24/scaling.gms b/modules/29_cropland/detail_apr24/scaling.gms deleted file mode 100644 index 2802c2cd18..0000000000 --- a/modules/29_cropland/detail_apr24/scaling.gms +++ /dev/null @@ -1,9 +0,0 @@ -*** | (C) 2008-2024 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 - -v29_fallow_missing.scale(j) = 10e-6; -v29_relocation_missing.scale(j) = 10e-6; diff --git a/modules/32_forestry/dynamic_feb21/equations.gms b/modules/32_forestry/dynamic_feb21/equations.gms index 5094f4ba18..46945a28a1 100644 --- a/modules/32_forestry/dynamic_feb21/equations.gms +++ b/modules/32_forestry/dynamic_feb21/equations.gms @@ -68,7 +68,7 @@ sum(ac_est, v32_land(j2,"aff",ac_est)) =l= sum(ac, v32_land(j2,"aff",ac)) - sum( *' The constraint `q32_aff_pol` accounts for the exogenous afforestation prescribed by NPI/NDC policies. q32_aff_pol(j2) .. - v32_land_missing_ndc(j2) =g= sum(ct, p32_aff_pol_timestep(ct,j2)) - sum(ac_est, v32_land(j2,"ndc",ac_est)); + sum(ac_est, v32_land(j2,"ndc",ac_est)) + v32_land_missing_ndc(j2) =e= sum(ct, p32_aff_pol_timestep(ct,j2)); *' The constraint `q32_max_aff` accounts for the allowed maximum global endogenous *' afforestation defined in `i32_max_aff_area_glo`. From c082921809d8bf46edd7bcbc3ce05eacbce092f9 Mon Sep 17 00:00:00 2001 From: florianh Date: Tue, 23 Apr 2024 23:29:14 +0200 Subject: [PATCH 036/133] bugfixes --- CHANGELOG.md | 1 + .../29_cropland/detail_apr24/declarations.gms | 4 ++- .../29_cropland/detail_apr24/equations.gms | 4 +++ .../29_cropland/detail_apr24/postsolve.gms | 4 +++ modules/29_cropland/detail_apr24/preloop.gms | 8 +++--- modules/29_cropland/detail_apr24/presolve.gms | 25 ++++++++----------- 6 files changed, 26 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c91c7a38e..30703591ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### added - **29_cropland** new module `29_cropland` accounting for crop area, fallow cropland and tree cover on cropland with two realizations: `detail_apr24` (default) and `simple_apr24`. - **10_land** added interface `pm_land_hist` with historic land use patterns +- **32_forestry** added technical balance term `v32_land_missing_ndc` ### removed - diff --git a/modules/29_cropland/detail_apr24/declarations.gms b/modules/29_cropland/detail_apr24/declarations.gms index e9aa88f83d..9a1d38e2cb 100644 --- a/modules/29_cropland/detail_apr24/declarations.gms +++ b/modules/29_cropland/detail_apr24/declarations.gms @@ -27,7 +27,7 @@ parameters p29_carbon_density_ac(t,j,ac,ag_pools) Carbon density for ac and ag_pools (tC per ha) p29_treecover(t,j,ac) Cropland tree cover per age class (mio. ha) pc29_treecover(j,ac) Cropland tree cover per age class in current time step (mio. ha) - p29_treecover_share(t,j) Share of treecover on total cropland (1) + pc29_treecover_share(j) Share of treecover on total cropland (1) i29_fallow_scenario_fader(t_all) Fallow land scenario fader (1) i29_fallow_target(t) Target share for fallow land on total cropland (1) @@ -54,6 +54,7 @@ equations q29_fallow_missing(j) Missing fallow land towards target (mio. ha) q29_fallow_bv(j,potnatveg) Biodiversity value for fallow land (mio. ha) q29_treecover_missing(j) Missing treecover area towards target (mio. ha) + q29_treecover_max(j) Maximum treecover area (mio. ha) q29_treecover_bv(j,potnatveg) Biodiversity value for cropland treecover (mio. ha) q29_cost_treecover_est(j) Establishment cost for cropland tree cover (mio. USD05MER per yr) q29_cost_treecover_recur(j) Recurring cost for cropland tree cover (mio. USD05MER per yr) @@ -78,6 +79,7 @@ parameters oq29_fallow_missing(t,j,type) Missing fallow land towards target (mio. ha) oq29_fallow_bv(t,j,potnatveg,type) Biodiversity value for fallow land (mio. ha) oq29_treecover_missing(t,j,type) Missing treecover area towards target (mio. ha) + oq29_treecover_max(t,j,type) Maximum treecover area (mio. ha) oq29_treecover_bv(t,j,potnatveg,type) Biodiversity value for cropland treecover (mio. ha) oq29_cost_treecover_est(t,j,type) Establishment cost for cropland tree cover (mio. USD05MER per yr) oq29_cost_treecover_recur(t,j,type) Recurring cost for cropland tree cover (mio. USD05MER per yr) diff --git a/modules/29_cropland/detail_apr24/equations.gms b/modules/29_cropland/detail_apr24/equations.gms index ebee259325..5b23f1272d 100644 --- a/modules/29_cropland/detail_apr24/equations.gms +++ b/modules/29_cropland/detail_apr24/equations.gms @@ -82,6 +82,10 @@ v29_treecover_missing(j2) =g= vm_land(j2,"crop") * sum(ct, i29_treecover_target(ct,j2)) - sum(ac, v29_treecover(j2,ac)); + q29_treecover_max(j2) .. + sum(ac, v29_treecover(j2,ac)) =l= + vm_land(j2,"crop") * s29_treecover_max; + *' Depending on `s29_treecover_bii_coeff`, tree cover biodiversity value *' is based on natural vegetation or plantation BII coefficients. diff --git a/modules/29_cropland/detail_apr24/postsolve.gms b/modules/29_cropland/detail_apr24/postsolve.gms index 0d05aea001..9bf9acb70f 100644 --- a/modules/29_cropland/detail_apr24/postsolve.gms +++ b/modules/29_cropland/detail_apr24/postsolve.gms @@ -24,6 +24,7 @@ pc29_treecover(j,ac) = v29_treecover.l(j,ac); oq29_fallow_missing(t,j,"marginal") = q29_fallow_missing.m(j); oq29_fallow_bv(t,j,potnatveg,"marginal") = q29_fallow_bv.m(j,potnatveg); oq29_treecover_missing(t,j,"marginal") = q29_treecover_missing.m(j); + oq29_treecover_max(t,j,"marginal") = q29_treecover_max.m(j); oq29_treecover_bv(t,j,potnatveg,"marginal") = q29_treecover_bv.m(j,potnatveg); oq29_cost_treecover_est(t,j,"marginal") = q29_cost_treecover_est.m(j); oq29_cost_treecover_recur(t,j,"marginal") = q29_cost_treecover_recur.m(j); @@ -44,6 +45,7 @@ pc29_treecover(j,ac) = v29_treecover.l(j,ac); oq29_fallow_missing(t,j,"level") = q29_fallow_missing.l(j); oq29_fallow_bv(t,j,potnatveg,"level") = q29_fallow_bv.l(j,potnatveg); oq29_treecover_missing(t,j,"level") = q29_treecover_missing.l(j); + oq29_treecover_max(t,j,"level") = q29_treecover_max.l(j); oq29_treecover_bv(t,j,potnatveg,"level") = q29_treecover_bv.l(j,potnatveg); oq29_cost_treecover_est(t,j,"level") = q29_cost_treecover_est.l(j); oq29_cost_treecover_recur(t,j,"level") = q29_cost_treecover_recur.l(j); @@ -64,6 +66,7 @@ pc29_treecover(j,ac) = v29_treecover.l(j,ac); oq29_fallow_missing(t,j,"upper") = q29_fallow_missing.up(j); oq29_fallow_bv(t,j,potnatveg,"upper") = q29_fallow_bv.up(j,potnatveg); oq29_treecover_missing(t,j,"upper") = q29_treecover_missing.up(j); + oq29_treecover_max(t,j,"upper") = q29_treecover_max.up(j); oq29_treecover_bv(t,j,potnatveg,"upper") = q29_treecover_bv.up(j,potnatveg); oq29_cost_treecover_est(t,j,"upper") = q29_cost_treecover_est.up(j); oq29_cost_treecover_recur(t,j,"upper") = q29_cost_treecover_recur.up(j); @@ -84,6 +87,7 @@ pc29_treecover(j,ac) = v29_treecover.l(j,ac); oq29_fallow_missing(t,j,"lower") = q29_fallow_missing.lo(j); oq29_fallow_bv(t,j,potnatveg,"lower") = q29_fallow_bv.lo(j,potnatveg); oq29_treecover_missing(t,j,"lower") = q29_treecover_missing.lo(j); + oq29_treecover_max(t,j,"lower") = q29_treecover_max.lo(j); oq29_treecover_bv(t,j,potnatveg,"lower") = q29_treecover_bv.lo(j,potnatveg); oq29_cost_treecover_est(t,j,"lower") = q29_cost_treecover_est.lo(j); oq29_cost_treecover_recur(t,j,"lower") = q29_cost_treecover_recur.lo(j); diff --git a/modules/29_cropland/detail_apr24/preloop.gms b/modules/29_cropland/detail_apr24/preloop.gms index a7e39c8c8e..b65a0c2b43 100644 --- a/modules/29_cropland/detail_apr24/preloop.gms +++ b/modules/29_cropland/detail_apr24/preloop.gms @@ -23,10 +23,10 @@ elseif s29_snv_shr > s29_snv_relocation_data_x1, * Initial tree cover on cropland is assumed to be equally distributed among all age-classes -pc29_treecover(j,ac) = 0; -pc29_treecover(j,ac)$(pm_land_hist("y2015",j,"crop") > 1e-10) = - (f29_treecover(j) / pm_land_hist("y2015",j,"crop") * pm_land_hist("y1995",j,"crop")) / card(ac); - +pc29_treecover_share(j) = 0; +pc29_treecover_share(j)$(pm_land_hist("y2015",j,"crop") > 1e-10) = f29_treecover(j) / pm_land_hist("y2015",j,"crop"); +pc29_treecover_share(j)$(pc29_treecover_share(j) > s29_treecover_max) = s29_treecover_max; +pc29_treecover(j,ac) = (pc29_treecover_share(j) * pm_land_hist("y1995",j,"crop")) / card(ac); *' Switch for tree cover on cropland: *' 0 = Use natveg growth curve towards LPJmL natural vegetation diff --git a/modules/29_cropland/detail_apr24/presolve.gms b/modules/29_cropland/detail_apr24/presolve.gms index d6177b87e7..852e0e93db 100644 --- a/modules/29_cropland/detail_apr24/presolve.gms +++ b/modules/29_cropland/detail_apr24/presolve.gms @@ -46,24 +46,19 @@ v29_treecover.l(j,ac) = p29_treecover(t,j,ac); * create treecover target and penalty scenario i29_treecover_target(t,j) = s29_treecover_target * i29_treecover_scenario_fader(t); -p29_treecover_share(t,j) = 0; -p29_treecover_share(t,j)$(pcm_land(j,"crop") > 1e-10) = sum(ac, pc29_treecover(j,ac)) / pcm_land(j,"crop"); -p29_treecover_share(t,j)$(p29_treecover_share(t,j) > s29_treecover_max) = s29_treecover_max; +pc29_treecover_share(j) = 0; +pc29_treecover_share(j)$(pcm_land(j,"crop") > 1e-10) = sum(ac, pc29_treecover(j,ac)) / pcm_land(j,"crop"); +pc29_treecover_share(j)$(pc29_treecover_share(j) > s29_treecover_max) = s29_treecover_max; if (s29_treecover_keep = 1, - i29_treecover_target(t,j)$(i29_treecover_target(t,j) < p29_treecover_share(t,j)) = p29_treecover_share(t,j); + i29_treecover_target(t,j)$(i29_treecover_target(t,j) < pc29_treecover_share(j)) = pc29_treecover_share(j); ); -if(m_year(t) <= s29_treecover_scenario_start, - v29_treecover.fx(j,ac) = pc29_treecover(j,ac); - i29_treecover_penalty(t) = 0; -else - v29_treecover.lo(j,ac_est) = 0; - v29_treecover.up(j,ac_est) = Inf; - v29_treecover.lo(j,ac_sub) = 0; - v29_treecover.up(j,ac_sub) = pc29_treecover(j,ac_sub); - m_boundfix(v29_treecover,(j,ac_sub),l,10e-5); - i29_treecover_penalty(t) = s29_treecover_penalty; -); +v29_treecover.lo(j,ac_est) = 0; +v29_treecover.up(j,ac_est) = Inf; +v29_treecover.lo(j,ac_sub) = 0; +v29_treecover.up(j,ac_sub) = pc29_treecover(j,ac_sub); +m_boundfix(v29_treecover,(j,ac_sub),l,10e-5); +i29_treecover_penalty(t) = s29_treecover_penalty; * create fallow land target and penalty scenario i29_fallow_target(t) = s29_fallow_target * i29_fallow_scenario_fader(t); From 5c455ed52acf01f85e27d3f6df1f8cdccb064fc9 Mon Sep 17 00:00:00 2001 From: florianh Date: Wed, 24 Apr 2024 06:31:59 +0200 Subject: [PATCH 037/133] bugfixes --- config/default.cfg | 7 +++++- .../29_cropland/detail_apr24/declarations.gms | 12 ++++++---- .../29_cropland/detail_apr24/equations.gms | 11 ++++++--- modules/29_cropland/detail_apr24/input.gms | 4 +++- .../29_cropland/detail_apr24/postsolve.gms | 24 ++++++++++++------- modules/29_cropland/detail_apr24/presolve.gms | 17 ++++++++++++- modules/30_croparea/detail_apr24/presolve.gms | 3 +++ 7 files changed, 60 insertions(+), 18 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index b9dc6b1bc3..c4c5d26b83 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -717,12 +717,15 @@ cfg$gms$policy_countries29 <- all_iso_countries # * "secdforest, past, other" etc. cfg$gms$land_snv <- "secdforest, forestry, past, other" #def = "secdforest, forestry, past, other" +# * Penalty for transgression of available cropland (USD05MER per ha) +cfg$gms$s29_avl_crop_exceed_penalty <- 1e+06 + # * Minimum cluster share of treecover on total cropland area (including croparea, fallow land and tree cover). # * s29_treecover_target is faded in linearly between s29_treecover_scenario_start and s29_treecover_scenario_target. cfg$gms$s29_treecover_target <- 0 # def = 0 # * Avoid loss of existing treecover (1=yes 0=no) cfg$gms$s29_treecover_keep <- 1 # def = 1 -# * Maximum share of existing treecover on total cropland (1) +# * Maximum share of treecover on total cropland (1) cfg$gms$s29_treecover_max <- 0.4 # def = 0.4 # * Start year of tree cover share fade-in: cfg$gms$s29_treecover_scenario_start <- 2020 # def = 2020 @@ -738,6 +741,8 @@ cfg$gms$s29_treecover_penalty <- 2000 # def = 2000 # * Minimum cluster share of fallow land on total cropland area (including croparea, fallow land and tree cover). # * s29_fallow_target is faded in linearly between s29_fallow_scenario_start and s29_fallow_scenario_target. cfg$gms$s29_fallow_target <- 0 # def = 0 +# * Maximum share of fallow land on total cropland (1) +cfg$gms$s29_fallow_max <- 0.4 # def = 0.4 # * Start year of tree cover share fade-in: cfg$gms$s29_fallow_scenario_start <- 2020 # def = 2020 # * Target year (year when full implementation is reached): diff --git a/modules/29_cropland/detail_apr24/declarations.gms b/modules/29_cropland/detail_apr24/declarations.gms index 9a1d38e2cb..bd0b1fd36d 100644 --- a/modules/29_cropland/detail_apr24/declarations.gms +++ b/modules/29_cropland/detail_apr24/declarations.gms @@ -36,6 +36,7 @@ parameters positive variables vm_cost_cropland(j) Cost for total cropland (mio. USD05MER per yr) + v29_avl_crop_exceed(j) Transgression of availabe cropland land (mio. ha) v29_treecover(j,ac) Cropland tree cover per age class (mio. ha) v29_treecover_missing(j) Missing treecover area towards target (mio. ha) v29_cost_treecover_est(j) Establishment cost for cropland tree cover (mio. USD05MER per yr) @@ -51,9 +52,10 @@ equations q29_carbon(j,ag_pools,stockType) Cropland above ground carbon content calculation (mio. tC) q29_land_snv(j) Land constraint for the SNV policy in cropland areas (mio. ha) q29_land_snv_trans(j) Land transition constraint for SNV policy in cropland areas (mio. ha) - q29_fallow_missing(j) Missing fallow land towards target (mio. ha) + q29_fallow_min(j) Missing fallow land towards target (mio. ha) + q29_fallow_max(j) Maximum fallow land towards target (mio. ha) q29_fallow_bv(j,potnatveg) Biodiversity value for fallow land (mio. ha) - q29_treecover_missing(j) Missing treecover area towards target (mio. ha) + q29_treecover_min(j) Missing treecover area towards target (mio. ha) q29_treecover_max(j) Maximum treecover area (mio. ha) q29_treecover_bv(j,potnatveg) Biodiversity value for cropland treecover (mio. ha) q29_cost_treecover_est(j) Establishment cost for cropland tree cover (mio. USD05MER per yr) @@ -64,6 +66,7 @@ equations *#################### R SECTION START (OUTPUT DECLARATIONS) #################### parameters ov_cost_cropland(t,j,type) Cost for total cropland (mio. USD05MER per yr) + ov29_avl_crop_exceed(t,j,type) Transgression of availabe cropland land (mio. ha) ov29_treecover(t,j,ac,type) Cropland tree cover per age class (mio. ha) ov29_treecover_missing(t,j,type) Missing treecover area towards target (mio. ha) ov29_cost_treecover_est(t,j,type) Establishment cost for cropland tree cover (mio. USD05MER per yr) @@ -76,9 +79,10 @@ parameters oq29_carbon(t,j,ag_pools,stockType,type) Cropland above ground carbon content calculation (mio. tC) oq29_land_snv(t,j,type) Land constraint for the SNV policy in cropland areas (mio. ha) oq29_land_snv_trans(t,j,type) Land transition constraint for SNV policy in cropland areas (mio. ha) - oq29_fallow_missing(t,j,type) Missing fallow land towards target (mio. ha) + oq29_fallow_min(t,j,type) Missing fallow land towards target (mio. ha) + oq29_fallow_max(t,j,type) Maximum fallow land towards target (mio. ha) oq29_fallow_bv(t,j,potnatveg,type) Biodiversity value for fallow land (mio. ha) - oq29_treecover_missing(t,j,type) Missing treecover area towards target (mio. ha) + oq29_treecover_min(t,j,type) Missing treecover area towards target (mio. ha) oq29_treecover_max(t,j,type) Maximum treecover area (mio. ha) oq29_treecover_bv(t,j,potnatveg,type) Biodiversity value for cropland treecover (mio. ha) oq29_cost_treecover_est(t,j,type) Establishment cost for cropland tree cover (mio. USD05MER per yr) diff --git a/modules/29_cropland/detail_apr24/equations.gms b/modules/29_cropland/detail_apr24/equations.gms index 5b23f1272d..88000e5bc8 100644 --- a/modules/29_cropland/detail_apr24/equations.gms +++ b/modules/29_cropland/detail_apr24/equations.gms @@ -20,7 +20,7 @@ *' in order to increase compositional heterogeneity of land types at the cell level. q29_avl_cropland(j2) .. - vm_land(j2,"crop") =l= sum(ct, p29_avl_cropland(ct,j2)); + v29_avl_crop_exceed(j2) =g= vm_land(j2,"crop") - sum(ct, p29_avl_cropland(ct,j2)); *' Total cost for the cropland module. @@ -28,6 +28,7 @@ q29_cost_cropland(j2) .. vm_cost_cropland(j2) =e= v29_cost_treecover_est(j2) + v29_cost_treecover_recur(j2) + + v29_avl_crop_exceed(j2) * s29_avl_crop_exceed_penalty + v29_fallow_missing(j2) * sum(ct, i29_fallow_penalty(ct)) + v29_treecover_missing(j2) * sum(ct, i29_treecover_penalty(ct)); @@ -63,10 +64,14 @@ *' The penalty applies to the missing fallow land, i.e. where fallow land *' is lower than a certain fraction of total cropland. - q29_fallow_missing(j2) .. + q29_fallow_min(j2) .. v29_fallow_missing(j2) =g= vm_land(j2,"crop") * sum(ct, i29_fallow_target(ct)) - vm_fallow(j2); + q29_fallow_max(j2) .. + vm_fallow(j2) =l= + vm_land(j2,"crop") * s29_fallow_max; + *' Fallow land biodiversity value is based on perennial crops. q29_fallow_bv(j2,potnatveg) .. @@ -78,7 +83,7 @@ *' The penalty applies to the missing treecover area, i.e. where treecover area *' is lower than a certain fraction of total cropland. - q29_treecover_missing(j2) .. + q29_treecover_min(j2) .. v29_treecover_missing(j2) =g= vm_land(j2,"crop") * sum(ct, i29_treecover_target(ct,j2)) - sum(ac, v29_treecover(j2,ac)); diff --git a/modules/29_cropland/detail_apr24/input.gms b/modules/29_cropland/detail_apr24/input.gms index b7022a5323..52f04d2061 100644 --- a/modules/29_cropland/detail_apr24/input.gms +++ b/modules/29_cropland/detail_apr24/input.gms @@ -17,17 +17,19 @@ scalars s29_snv_relocation_data_x2 Second reference value in SNV target cropland data (1) / 0.5 / s29_cost_treecover_est Tree cover establishment cost (USD05MER per ha) / 2000 / s29_cost_treecover_recur Tree cover recurring cost (USD05MER per ha) / 500 / + s29_avl_crop_exceed_penalty Penalty for transgression of available cropland (USD05MER per ha) / 1e+06 / s29_treecover_plantation Growth curve switch for tree cover on cropland 0=natveg 1=plantations (1) / 0 / s29_treecover_bii_coeff BII coefficent to be used for tree cover on cropland 0=secondary vegetation 1=timber plantations (1) / 0 / s29_treecover_scenario_start Cropland treecover scenario start year / 2020 / s29_treecover_scenario_target Cropland treecover scenario target year / 2050 / s29_treecover_target Target share of treecover on total cropland (1) / 0 / s29_treecover_keep Avoid loss of existing treecover (1=yes 0=no) / 1 / - s29_treecover_max Maximum share of existing treecover on total cropland (1) / 0.4 / + s29_treecover_max Maximum share of treecover on total cropland (1) / 0.4 / s29_treecover_penalty Penalty for violation of treecover target (USD05MER per ha) / 2000 / s29_fallow_scenario_start Fallow land scenario start year / 2020 / s29_fallow_scenario_target Fallow land scenario target year / 2050 / s29_fallow_target Target share of fallow land on total cropland (1) / 0 / + s29_fallow_max Maximum share of fallow land on total cropland (1) / 0.4 / s29_fallow_penalty Penalty for violation of fallow target (USD05MER per ha) / 500 / ; diff --git a/modules/29_cropland/detail_apr24/postsolve.gms b/modules/29_cropland/detail_apr24/postsolve.gms index 9bf9acb70f..79aab84004 100644 --- a/modules/29_cropland/detail_apr24/postsolve.gms +++ b/modules/29_cropland/detail_apr24/postsolve.gms @@ -9,6 +9,7 @@ pc29_treecover(j,ac) = v29_treecover.l(j,ac); *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### ov_cost_cropland(t,j,"marginal") = vm_cost_cropland.m(j); + ov29_avl_crop_exceed(t,j,"marginal") = v29_avl_crop_exceed.m(j); ov29_treecover(t,j,ac,"marginal") = v29_treecover.m(j,ac); ov29_treecover_missing(t,j,"marginal") = v29_treecover_missing.m(j); ov29_cost_treecover_est(t,j,"marginal") = v29_cost_treecover_est.m(j); @@ -21,15 +22,17 @@ pc29_treecover(j,ac) = v29_treecover.l(j,ac); oq29_carbon(t,j,ag_pools,stockType,"marginal") = q29_carbon.m(j,ag_pools,stockType); oq29_land_snv(t,j,"marginal") = q29_land_snv.m(j); oq29_land_snv_trans(t,j,"marginal") = q29_land_snv_trans.m(j); - oq29_fallow_missing(t,j,"marginal") = q29_fallow_missing.m(j); + oq29_fallow_min(t,j,"marginal") = q29_fallow_min.m(j); + oq29_fallow_max(t,j,"marginal") = q29_fallow_max.m(j); oq29_fallow_bv(t,j,potnatveg,"marginal") = q29_fallow_bv.m(j,potnatveg); - oq29_treecover_missing(t,j,"marginal") = q29_treecover_missing.m(j); + oq29_treecover_min(t,j,"marginal") = q29_treecover_min.m(j); oq29_treecover_max(t,j,"marginal") = q29_treecover_max.m(j); oq29_treecover_bv(t,j,potnatveg,"marginal") = q29_treecover_bv.m(j,potnatveg); oq29_cost_treecover_est(t,j,"marginal") = q29_cost_treecover_est.m(j); oq29_cost_treecover_recur(t,j,"marginal") = q29_cost_treecover_recur.m(j); oq29_treecover_est(t,j,ac,"marginal") = q29_treecover_est.m(j,ac); ov_cost_cropland(t,j,"level") = vm_cost_cropland.l(j); + ov29_avl_crop_exceed(t,j,"level") = v29_avl_crop_exceed.l(j); ov29_treecover(t,j,ac,"level") = v29_treecover.l(j,ac); ov29_treecover_missing(t,j,"level") = v29_treecover_missing.l(j); ov29_cost_treecover_est(t,j,"level") = v29_cost_treecover_est.l(j); @@ -42,15 +45,17 @@ pc29_treecover(j,ac) = v29_treecover.l(j,ac); oq29_carbon(t,j,ag_pools,stockType,"level") = q29_carbon.l(j,ag_pools,stockType); oq29_land_snv(t,j,"level") = q29_land_snv.l(j); oq29_land_snv_trans(t,j,"level") = q29_land_snv_trans.l(j); - oq29_fallow_missing(t,j,"level") = q29_fallow_missing.l(j); + oq29_fallow_min(t,j,"level") = q29_fallow_min.l(j); + oq29_fallow_max(t,j,"level") = q29_fallow_max.l(j); oq29_fallow_bv(t,j,potnatveg,"level") = q29_fallow_bv.l(j,potnatveg); - oq29_treecover_missing(t,j,"level") = q29_treecover_missing.l(j); + oq29_treecover_min(t,j,"level") = q29_treecover_min.l(j); oq29_treecover_max(t,j,"level") = q29_treecover_max.l(j); oq29_treecover_bv(t,j,potnatveg,"level") = q29_treecover_bv.l(j,potnatveg); oq29_cost_treecover_est(t,j,"level") = q29_cost_treecover_est.l(j); oq29_cost_treecover_recur(t,j,"level") = q29_cost_treecover_recur.l(j); oq29_treecover_est(t,j,ac,"level") = q29_treecover_est.l(j,ac); ov_cost_cropland(t,j,"upper") = vm_cost_cropland.up(j); + ov29_avl_crop_exceed(t,j,"upper") = v29_avl_crop_exceed.up(j); ov29_treecover(t,j,ac,"upper") = v29_treecover.up(j,ac); ov29_treecover_missing(t,j,"upper") = v29_treecover_missing.up(j); ov29_cost_treecover_est(t,j,"upper") = v29_cost_treecover_est.up(j); @@ -63,15 +68,17 @@ pc29_treecover(j,ac) = v29_treecover.l(j,ac); oq29_carbon(t,j,ag_pools,stockType,"upper") = q29_carbon.up(j,ag_pools,stockType); oq29_land_snv(t,j,"upper") = q29_land_snv.up(j); oq29_land_snv_trans(t,j,"upper") = q29_land_snv_trans.up(j); - oq29_fallow_missing(t,j,"upper") = q29_fallow_missing.up(j); + oq29_fallow_min(t,j,"upper") = q29_fallow_min.up(j); + oq29_fallow_max(t,j,"upper") = q29_fallow_max.up(j); oq29_fallow_bv(t,j,potnatveg,"upper") = q29_fallow_bv.up(j,potnatveg); - oq29_treecover_missing(t,j,"upper") = q29_treecover_missing.up(j); + oq29_treecover_min(t,j,"upper") = q29_treecover_min.up(j); oq29_treecover_max(t,j,"upper") = q29_treecover_max.up(j); oq29_treecover_bv(t,j,potnatveg,"upper") = q29_treecover_bv.up(j,potnatveg); oq29_cost_treecover_est(t,j,"upper") = q29_cost_treecover_est.up(j); oq29_cost_treecover_recur(t,j,"upper") = q29_cost_treecover_recur.up(j); oq29_treecover_est(t,j,ac,"upper") = q29_treecover_est.up(j,ac); ov_cost_cropland(t,j,"lower") = vm_cost_cropland.lo(j); + ov29_avl_crop_exceed(t,j,"lower") = v29_avl_crop_exceed.lo(j); ov29_treecover(t,j,ac,"lower") = v29_treecover.lo(j,ac); ov29_treecover_missing(t,j,"lower") = v29_treecover_missing.lo(j); ov29_cost_treecover_est(t,j,"lower") = v29_cost_treecover_est.lo(j); @@ -84,9 +91,10 @@ pc29_treecover(j,ac) = v29_treecover.l(j,ac); oq29_carbon(t,j,ag_pools,stockType,"lower") = q29_carbon.lo(j,ag_pools,stockType); oq29_land_snv(t,j,"lower") = q29_land_snv.lo(j); oq29_land_snv_trans(t,j,"lower") = q29_land_snv_trans.lo(j); - oq29_fallow_missing(t,j,"lower") = q29_fallow_missing.lo(j); + oq29_fallow_min(t,j,"lower") = q29_fallow_min.lo(j); + oq29_fallow_max(t,j,"lower") = q29_fallow_max.lo(j); oq29_fallow_bv(t,j,potnatveg,"lower") = q29_fallow_bv.lo(j,potnatveg); - oq29_treecover_missing(t,j,"lower") = q29_treecover_missing.lo(j); + oq29_treecover_min(t,j,"lower") = q29_treecover_min.lo(j); oq29_treecover_max(t,j,"lower") = q29_treecover_max.lo(j); oq29_treecover_bv(t,j,potnatveg,"lower") = q29_treecover_bv.lo(j,potnatveg); oq29_cost_treecover_est(t,j,"lower") = q29_cost_treecover_est.lo(j); diff --git a/modules/29_cropland/detail_apr24/presolve.gms b/modules/29_cropland/detail_apr24/presolve.gms index 852e0e93db..c0810c3ec2 100644 --- a/modules/29_cropland/detail_apr24/presolve.gms +++ b/modules/29_cropland/detail_apr24/presolve.gms @@ -58,13 +58,28 @@ v29_treecover.up(j,ac_est) = Inf; v29_treecover.lo(j,ac_sub) = 0; v29_treecover.up(j,ac_sub) = pc29_treecover(j,ac_sub); m_boundfix(v29_treecover,(j,ac_sub),l,10e-5); -i29_treecover_penalty(t) = s29_treecover_penalty; + +if(m_year(t) <= s29_treecover_scenario_start, + i29_treecover_penalty(t) = 0; + v29_treecover_missing.fx(j) = 0; +else + i29_treecover_penalty(t) = s29_treecover_penalty; + v29_treecover_missing.lo(j) = 0; + v29_treecover_missing.up(j) = Inf; +); * create fallow land target and penalty scenario i29_fallow_target(t) = s29_fallow_target * i29_fallow_scenario_fader(t); if(m_year(t) <= s29_fallow_scenario_start, i29_fallow_penalty(t) = 0; + v29_fallow_missing.fx(j) = 0; else i29_fallow_penalty(t) = s29_fallow_penalty; + v29_fallow_missing.lo(j) = 0; + v29_fallow_missing.up(j) = Inf; ); + +vm_fallow.lo(j) = 0; +vm_fallow.up(j) = p29_avl_cropland(t,j); +m_boundfix(vm_fallow,(j),l,10e-5); diff --git a/modules/30_croparea/detail_apr24/presolve.gms b/modules/30_croparea/detail_apr24/presolve.gms index ff63a8c7e4..ef851982a3 100644 --- a/modules/30_croparea/detail_apr24/presolve.gms +++ b/modules/30_croparea/detail_apr24/presolve.gms @@ -30,6 +30,9 @@ i30_betr_target(t) = s30_betr_target * i30_betr_scenario_fader(t); if(m_year(t) <= s30_betr_scenario_start, i30_betr_penalty(t) = 0; + v30_betr_missing.fx(j) = 0; else i30_betr_penalty(t) = s30_betr_penalty; + v30_betr_missing.lo(j) = 0; + v30_betr_missing.up(j) = Inf; ); From 34e0c6bc1fddc8d921b35b8bf4f787fb50531a95 Mon Sep 17 00:00:00 2001 From: florianh Date: Wed, 24 Apr 2024 07:36:59 +0200 Subject: [PATCH 038/133] bugfixes --- modules/29_cropland/detail_apr24/presolve.gms | 28 ++++++++++++------- modules/30_croparea/detail_apr24/presolve.gms | 16 +++++++---- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/modules/29_cropland/detail_apr24/presolve.gms b/modules/29_cropland/detail_apr24/presolve.gms index c0810c3ec2..553aad23b6 100644 --- a/modules/29_cropland/detail_apr24/presolve.gms +++ b/modules/29_cropland/detail_apr24/presolve.gms @@ -59,25 +59,33 @@ v29_treecover.lo(j,ac_sub) = 0; v29_treecover.up(j,ac_sub) = pc29_treecover(j,ac_sub); m_boundfix(v29_treecover,(j,ac_sub),l,10e-5); -if(m_year(t) <= s29_treecover_scenario_start, - i29_treecover_penalty(t) = 0; - v29_treecover_missing.fx(j) = 0; +if (m_year(t) <= s29_treecover_scenario_start, + i29_treecover_penalty(t) = 0; + v29_treecover_missing.fx(j) = 0; else - i29_treecover_penalty(t) = s29_treecover_penalty; - v29_treecover_missing.lo(j) = 0; - v29_treecover_missing.up(j) = Inf; + i29_treecover_penalty(t) = s29_treecover_penalty; + if (i29_treecover_penalty(t) > 0, + v29_treecover_missing.lo(j) = 0; + v29_treecover_missing.up(j) = Inf; + else + v29_treecover_missing.fx(j) = 0; + ); ); * create fallow land target and penalty scenario i29_fallow_target(t) = s29_fallow_target * i29_fallow_scenario_fader(t); -if(m_year(t) <= s29_fallow_scenario_start, +if (m_year(t) <= s29_fallow_scenario_start, i29_fallow_penalty(t) = 0; v29_fallow_missing.fx(j) = 0; else - i29_fallow_penalty(t) = s29_fallow_penalty; - v29_fallow_missing.lo(j) = 0; - v29_fallow_missing.up(j) = Inf; + i29_fallow_penalty(t) = s29_fallow_penalty; + if (i29_fallow_penalty(t) > 0, + v29_fallow_missing.lo(j) = 0; + v29_fallow_missing.up(j) = Inf; + else + v29_fallow_missing.fx(j) = 0; + ); ); vm_fallow.lo(j) = 0; diff --git a/modules/30_croparea/detail_apr24/presolve.gms b/modules/30_croparea/detail_apr24/presolve.gms index ef851982a3..907dd57aaa 100644 --- a/modules/30_croparea/detail_apr24/presolve.gms +++ b/modules/30_croparea/detail_apr24/presolve.gms @@ -28,11 +28,15 @@ rotamin_red30(rotamin30) = yes$(i30_rotation_rules(t,rotamin30) > 0); * create betr target and penalty scenario i30_betr_target(t) = s30_betr_target * i30_betr_scenario_fader(t); -if(m_year(t) <= s30_betr_scenario_start, - i30_betr_penalty(t) = 0; - v30_betr_missing.fx(j) = 0; +if (m_year(t) <= s30_betr_scenario_start, + i30_betr_penalty(t) = 0; + v30_betr_missing.fx(j) = 0; else - i30_betr_penalty(t) = s30_betr_penalty; - v30_betr_missing.lo(j) = 0; - v30_betr_missing.up(j) = Inf; + i30_betr_penalty(t) = s30_betr_penalty; + if (i30_betr_penalty(t) > 0, + v30_betr_missing.lo(j) = 0; + v30_betr_missing.up(j) = Inf; + else + v30_betr_missing.fx(j) = 0; + ); ); From 6279d3445402962f2a08db47c88e9332a335b277 Mon Sep 17 00:00:00 2001 From: florianh Date: Wed, 24 Apr 2024 07:39:43 +0200 Subject: [PATCH 039/133] test without boundfix --- core/macros.gms | 2 +- modules/35_natveg/dynamic_feb21/presolve.gms | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/macros.gms b/core/macros.gms index 2fb013af99..1607fc6bae 100644 --- a/core/macros.gms +++ b/core/macros.gms @@ -10,7 +10,7 @@ * Macro for fixing a variable in the case that lower and upper bound are too * close to each other (closer than argument "sens") * EXAMPLE: ma_boundfix(vm_land,(j,"ifft"),up,10e-5); -$macro m_boundfix(x,arg,sufx,sens) x.fx arg$(x.up arg-x.lo arg0) + 0$(sum(s,w)<=0); diff --git a/modules/35_natveg/dynamic_feb21/presolve.gms b/modules/35_natveg/dynamic_feb21/presolve.gms index 97a6f33b35..6ff22789af 100644 --- a/modules/35_natveg/dynamic_feb21/presolve.gms +++ b/modules/35_natveg/dynamic_feb21/presolve.gms @@ -129,7 +129,7 @@ m_boundfix(v35_secdforest,(j,ac_sub),l,10e-5); * Secondary forest conservation * protection bound fix -pm_land_conservation(t,j,"secdforest","protect")$(abs(pm_land_conservation(t,j,"secdforest","protect") - sum(ac_sub, pc35_secdforest(j,ac_sub))) < 10e-5) = sum(ac_sub, pc35_secdforest(j,ac_sub)); +*pm_land_conservation(t,j,"secdforest","protect")$(abs(pm_land_conservation(t,j,"secdforest","protect") - sum(ac_sub, pc35_secdforest(j,ac_sub))) < 10e-5) = sum(ac_sub, pc35_secdforest(j,ac_sub)); * set restoration target p35_land_restoration(j,"secdforest") = pm_land_conservation(t,j,"secdforest","restore"); * Do not restore secdforest in areas where total natural @@ -149,7 +149,7 @@ m_boundfix(v35_other,(j,ac_sub),l,10e-5); * Other land conservation * protection bound fix -pm_land_conservation(t,j,"other","protect")$(abs(pm_land_conservation(t,j,"other","protect") - sum(ac_sub, pc35_other(j,ac_sub))) < 10e-5) = sum(ac_sub, pc35_other(j,ac_sub)); +*pm_land_conservation(t,j,"other","protect")$(abs(pm_land_conservation(t,j,"other","protect") - sum(ac_sub, pc35_other(j,ac_sub))) < 10e-5) = sum(ac_sub, pc35_other(j,ac_sub)); * set restoration target p35_land_restoration(j,"other") = pm_land_conservation(t,j,"other","restore"); * Do not restore other land in areas where total natural From 274542d8d87e2bb3555d03c261e1524abad11087 Mon Sep 17 00:00:00 2001 From: florianh Date: Wed, 24 Apr 2024 08:04:49 +0200 Subject: [PATCH 040/133] bugfixes --- core/macros.gms | 4 ++-- modules/10_land/landmatrix_dec18/presolve.gms | 2 +- modules/29_cropland/detail_apr24/presolve.gms | 4 ++-- modules/32_forestry/dynamic_feb21/presolve.gms | 2 +- modules/35_natveg/dynamic_feb21/presolve.gms | 8 ++++---- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/core/macros.gms b/core/macros.gms index 1607fc6bae..b067d75936 100644 --- a/core/macros.gms +++ b/core/macros.gms @@ -9,8 +9,8 @@ * Macro for fixing a variable in the case that lower and upper bound are too * close to each other (closer than argument "sens") -* EXAMPLE: ma_boundfix(vm_land,(j,"ifft"),up,10e-5); -$macro m_boundfix(x,arg,sufx,sens) x.l arg$(x.up arg-x.lo arg0) + 0$(sum(s,w)<=0); diff --git a/modules/10_land/landmatrix_dec18/presolve.gms b/modules/10_land/landmatrix_dec18/presolve.gms index edee5163dc..d3628c565a 100644 --- a/modules/10_land/landmatrix_dec18/presolve.gms +++ b/modules/10_land/landmatrix_dec18/presolve.gms @@ -22,4 +22,4 @@ vm_lu_transitions.up(j,"primforest","primforest") = Inf; *' @stop -m_boundfix(vm_land,(j,land),up,10e-5); +m_boundfix(vm_land,(j,land),up,1e-10); diff --git a/modules/29_cropland/detail_apr24/presolve.gms b/modules/29_cropland/detail_apr24/presolve.gms index 553aad23b6..3d1b53e322 100644 --- a/modules/29_cropland/detail_apr24/presolve.gms +++ b/modules/29_cropland/detail_apr24/presolve.gms @@ -57,7 +57,7 @@ v29_treecover.lo(j,ac_est) = 0; v29_treecover.up(j,ac_est) = Inf; v29_treecover.lo(j,ac_sub) = 0; v29_treecover.up(j,ac_sub) = pc29_treecover(j,ac_sub); -m_boundfix(v29_treecover,(j,ac_sub),l,10e-5); +m_boundfix(v29_treecover,(j,ac_sub),l,1e-10); if (m_year(t) <= s29_treecover_scenario_start, i29_treecover_penalty(t) = 0; @@ -90,4 +90,4 @@ else vm_fallow.lo(j) = 0; vm_fallow.up(j) = p29_avl_cropland(t,j); -m_boundfix(vm_fallow,(j),l,10e-5); +m_boundfix(vm_fallow,(j),l,1e-10); diff --git a/modules/32_forestry/dynamic_feb21/presolve.gms b/modules/32_forestry/dynamic_feb21/presolve.gms index 3491620843..7f2659735f 100644 --- a/modules/32_forestry/dynamic_feb21/presolve.gms +++ b/modules/32_forestry/dynamic_feb21/presolve.gms @@ -153,7 +153,7 @@ else *' No afforestation is allowed if carbon density <= 20 tc/ha v32_land.fx(j,"aff",ac_est)$(fm_carbon_density(t,j,"forestry","vegc") <= 20) = 0; -m_boundfix(v32_land,(j,type32,ac_sub),up,10e-5); +m_boundfix(v32_land,(j,type32,ac_sub),up,1e-10); ** Calculate future yield based on rotation length if((ord(t)=1), diff --git a/modules/35_natveg/dynamic_feb21/presolve.gms b/modules/35_natveg/dynamic_feb21/presolve.gms index 6ff22789af..6bff1937f4 100644 --- a/modules/35_natveg/dynamic_feb21/presolve.gms +++ b/modules/35_natveg/dynamic_feb21/presolve.gms @@ -125,11 +125,11 @@ v35_secdforest.lo(j,ac_sub) = max((1-s35_natveg_harvest_shr) * pc35_secdforest(j ); * upper bound v35_secdforest.up(j,ac_sub) = pc35_secdforest(j,ac_sub); -m_boundfix(v35_secdforest,(j,ac_sub),l,10e-5); +m_boundfix(v35_secdforest,(j,ac_sub),l,1e-10); * Secondary forest conservation * protection bound fix -*pm_land_conservation(t,j,"secdforest","protect")$(abs(pm_land_conservation(t,j,"secdforest","protect") - sum(ac_sub, pc35_secdforest(j,ac_sub))) < 10e-5) = sum(ac_sub, pc35_secdforest(j,ac_sub)); +pm_land_conservation(t,j,"secdforest","protect")$(abs(pm_land_conservation(t,j,"secdforest","protect") - sum(ac_sub, pc35_secdforest(j,ac_sub))) < 1e-10) = sum(ac_sub, pc35_secdforest(j,ac_sub)); * set restoration target p35_land_restoration(j,"secdforest") = pm_land_conservation(t,j,"secdforest","restore"); * Do not restore secdforest in areas where total natural @@ -145,11 +145,11 @@ v35_other.lo(j,ac) = 0; v35_other.up(j,ac) = Inf; *set upper bound v35_other.up(j,ac_sub) = pc35_other(j,ac_sub); -m_boundfix(v35_other,(j,ac_sub),l,10e-5); +m_boundfix(v35_other,(j,ac_sub),l,1e-10); * Other land conservation * protection bound fix -*pm_land_conservation(t,j,"other","protect")$(abs(pm_land_conservation(t,j,"other","protect") - sum(ac_sub, pc35_other(j,ac_sub))) < 10e-5) = sum(ac_sub, pc35_other(j,ac_sub)); +pm_land_conservation(t,j,"other","protect")$(abs(pm_land_conservation(t,j,"other","protect") - sum(ac_sub, pc35_other(j,ac_sub))) < 1e-10) = sum(ac_sub, pc35_other(j,ac_sub)); * set restoration target p35_land_restoration(j,"other") = pm_land_conservation(t,j,"other","restore"); * Do not restore other land in areas where total natural From a3eb57696a119426e055c9d09a7c9e1b2fc99639 Mon Sep 17 00:00:00 2001 From: florianh Date: Wed, 24 Apr 2024 08:36:12 +0200 Subject: [PATCH 041/133] reverting back --- core/macros.gms | 2 +- modules/10_land/landmatrix_dec18/presolve.gms | 2 +- modules/29_cropland/detail_apr24/presolve.gms | 6 +++--- modules/32_forestry/dynamic_feb21/presolve.gms | 2 +- modules/35_natveg/dynamic_feb21/presolve.gms | 8 ++++---- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/core/macros.gms b/core/macros.gms index b067d75936..2fb013af99 100644 --- a/core/macros.gms +++ b/core/macros.gms @@ -9,7 +9,7 @@ * Macro for fixing a variable in the case that lower and upper bound are too * close to each other (closer than argument "sens") -* EXAMPLE: ma_boundfix(vm_land,(j,"ifft"),up,1e-10); +* EXAMPLE: ma_boundfix(vm_land,(j,"ifft"),up,10e-5); $macro m_boundfix(x,arg,sufx,sens) x.fx arg$(x.up arg-x.lo arg0) + 0$(sum(s,w)<=0); diff --git a/modules/10_land/landmatrix_dec18/presolve.gms b/modules/10_land/landmatrix_dec18/presolve.gms index d3628c565a..edee5163dc 100644 --- a/modules/10_land/landmatrix_dec18/presolve.gms +++ b/modules/10_land/landmatrix_dec18/presolve.gms @@ -22,4 +22,4 @@ vm_lu_transitions.up(j,"primforest","primforest") = Inf; *' @stop -m_boundfix(vm_land,(j,land),up,1e-10); +m_boundfix(vm_land,(j,land),up,10e-5); diff --git a/modules/29_cropland/detail_apr24/presolve.gms b/modules/29_cropland/detail_apr24/presolve.gms index 3d1b53e322..698fe7b3a1 100644 --- a/modules/29_cropland/detail_apr24/presolve.gms +++ b/modules/29_cropland/detail_apr24/presolve.gms @@ -47,7 +47,7 @@ v29_treecover.l(j,ac) = p29_treecover(t,j,ac); i29_treecover_target(t,j) = s29_treecover_target * i29_treecover_scenario_fader(t); pc29_treecover_share(j) = 0; -pc29_treecover_share(j)$(pcm_land(j,"crop") > 1e-10) = sum(ac, pc29_treecover(j,ac)) / pcm_land(j,"crop"); +pc29_treecover_share(j)$(pcm_land(j,"crop") > 10e-5) = sum(ac, pc29_treecover(j,ac)) / pcm_land(j,"crop"); pc29_treecover_share(j)$(pc29_treecover_share(j) > s29_treecover_max) = s29_treecover_max; if (s29_treecover_keep = 1, i29_treecover_target(t,j)$(i29_treecover_target(t,j) < pc29_treecover_share(j)) = pc29_treecover_share(j); @@ -57,7 +57,7 @@ v29_treecover.lo(j,ac_est) = 0; v29_treecover.up(j,ac_est) = Inf; v29_treecover.lo(j,ac_sub) = 0; v29_treecover.up(j,ac_sub) = pc29_treecover(j,ac_sub); -m_boundfix(v29_treecover,(j,ac_sub),l,1e-10); +m_boundfix(v29_treecover,(j,ac_sub),l,10e-5); if (m_year(t) <= s29_treecover_scenario_start, i29_treecover_penalty(t) = 0; @@ -90,4 +90,4 @@ else vm_fallow.lo(j) = 0; vm_fallow.up(j) = p29_avl_cropland(t,j); -m_boundfix(vm_fallow,(j),l,1e-10); +m_boundfix(vm_fallow,(j),l,10e-5); diff --git a/modules/32_forestry/dynamic_feb21/presolve.gms b/modules/32_forestry/dynamic_feb21/presolve.gms index 7f2659735f..3491620843 100644 --- a/modules/32_forestry/dynamic_feb21/presolve.gms +++ b/modules/32_forestry/dynamic_feb21/presolve.gms @@ -153,7 +153,7 @@ else *' No afforestation is allowed if carbon density <= 20 tc/ha v32_land.fx(j,"aff",ac_est)$(fm_carbon_density(t,j,"forestry","vegc") <= 20) = 0; -m_boundfix(v32_land,(j,type32,ac_sub),up,1e-10); +m_boundfix(v32_land,(j,type32,ac_sub),up,10e-5); ** Calculate future yield based on rotation length if((ord(t)=1), diff --git a/modules/35_natveg/dynamic_feb21/presolve.gms b/modules/35_natveg/dynamic_feb21/presolve.gms index 6bff1937f4..97a6f33b35 100644 --- a/modules/35_natveg/dynamic_feb21/presolve.gms +++ b/modules/35_natveg/dynamic_feb21/presolve.gms @@ -125,11 +125,11 @@ v35_secdforest.lo(j,ac_sub) = max((1-s35_natveg_harvest_shr) * pc35_secdforest(j ); * upper bound v35_secdforest.up(j,ac_sub) = pc35_secdforest(j,ac_sub); -m_boundfix(v35_secdforest,(j,ac_sub),l,1e-10); +m_boundfix(v35_secdforest,(j,ac_sub),l,10e-5); * Secondary forest conservation * protection bound fix -pm_land_conservation(t,j,"secdforest","protect")$(abs(pm_land_conservation(t,j,"secdforest","protect") - sum(ac_sub, pc35_secdforest(j,ac_sub))) < 1e-10) = sum(ac_sub, pc35_secdforest(j,ac_sub)); +pm_land_conservation(t,j,"secdforest","protect")$(abs(pm_land_conservation(t,j,"secdforest","protect") - sum(ac_sub, pc35_secdforest(j,ac_sub))) < 10e-5) = sum(ac_sub, pc35_secdforest(j,ac_sub)); * set restoration target p35_land_restoration(j,"secdforest") = pm_land_conservation(t,j,"secdforest","restore"); * Do not restore secdforest in areas where total natural @@ -145,11 +145,11 @@ v35_other.lo(j,ac) = 0; v35_other.up(j,ac) = Inf; *set upper bound v35_other.up(j,ac_sub) = pc35_other(j,ac_sub); -m_boundfix(v35_other,(j,ac_sub),l,1e-10); +m_boundfix(v35_other,(j,ac_sub),l,10e-5); * Other land conservation * protection bound fix -pm_land_conservation(t,j,"other","protect")$(abs(pm_land_conservation(t,j,"other","protect") - sum(ac_sub, pc35_other(j,ac_sub))) < 1e-10) = sum(ac_sub, pc35_other(j,ac_sub)); +pm_land_conservation(t,j,"other","protect")$(abs(pm_land_conservation(t,j,"other","protect") - sum(ac_sub, pc35_other(j,ac_sub))) < 10e-5) = sum(ac_sub, pc35_other(j,ac_sub)); * set restoration target p35_land_restoration(j,"other") = pm_land_conservation(t,j,"other","restore"); * Do not restore other land in areas where total natural From 34b830b1846e7222707174ea4cb047ea1c2eaff5 Mon Sep 17 00:00:00 2001 From: florianh Date: Wed, 24 Apr 2024 08:57:37 +0200 Subject: [PATCH 042/133] check again with other bounds --- modules/10_land/landmatrix_dec18/presolve.gms | 2 +- modules/29_cropland/detail_apr24/presolve.gms | 6 +++--- modules/32_forestry/dynamic_feb21/presolve.gms | 2 +- modules/35_natveg/dynamic_feb21/presolve.gms | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/modules/10_land/landmatrix_dec18/presolve.gms b/modules/10_land/landmatrix_dec18/presolve.gms index edee5163dc..d3628c565a 100644 --- a/modules/10_land/landmatrix_dec18/presolve.gms +++ b/modules/10_land/landmatrix_dec18/presolve.gms @@ -22,4 +22,4 @@ vm_lu_transitions.up(j,"primforest","primforest") = Inf; *' @stop -m_boundfix(vm_land,(j,land),up,10e-5); +m_boundfix(vm_land,(j,land),up,1e-10); diff --git a/modules/29_cropland/detail_apr24/presolve.gms b/modules/29_cropland/detail_apr24/presolve.gms index 698fe7b3a1..3d1b53e322 100644 --- a/modules/29_cropland/detail_apr24/presolve.gms +++ b/modules/29_cropland/detail_apr24/presolve.gms @@ -47,7 +47,7 @@ v29_treecover.l(j,ac) = p29_treecover(t,j,ac); i29_treecover_target(t,j) = s29_treecover_target * i29_treecover_scenario_fader(t); pc29_treecover_share(j) = 0; -pc29_treecover_share(j)$(pcm_land(j,"crop") > 10e-5) = sum(ac, pc29_treecover(j,ac)) / pcm_land(j,"crop"); +pc29_treecover_share(j)$(pcm_land(j,"crop") > 1e-10) = sum(ac, pc29_treecover(j,ac)) / pcm_land(j,"crop"); pc29_treecover_share(j)$(pc29_treecover_share(j) > s29_treecover_max) = s29_treecover_max; if (s29_treecover_keep = 1, i29_treecover_target(t,j)$(i29_treecover_target(t,j) < pc29_treecover_share(j)) = pc29_treecover_share(j); @@ -57,7 +57,7 @@ v29_treecover.lo(j,ac_est) = 0; v29_treecover.up(j,ac_est) = Inf; v29_treecover.lo(j,ac_sub) = 0; v29_treecover.up(j,ac_sub) = pc29_treecover(j,ac_sub); -m_boundfix(v29_treecover,(j,ac_sub),l,10e-5); +m_boundfix(v29_treecover,(j,ac_sub),l,1e-10); if (m_year(t) <= s29_treecover_scenario_start, i29_treecover_penalty(t) = 0; @@ -90,4 +90,4 @@ else vm_fallow.lo(j) = 0; vm_fallow.up(j) = p29_avl_cropland(t,j); -m_boundfix(vm_fallow,(j),l,10e-5); +m_boundfix(vm_fallow,(j),l,1e-10); diff --git a/modules/32_forestry/dynamic_feb21/presolve.gms b/modules/32_forestry/dynamic_feb21/presolve.gms index 3491620843..7f2659735f 100644 --- a/modules/32_forestry/dynamic_feb21/presolve.gms +++ b/modules/32_forestry/dynamic_feb21/presolve.gms @@ -153,7 +153,7 @@ else *' No afforestation is allowed if carbon density <= 20 tc/ha v32_land.fx(j,"aff",ac_est)$(fm_carbon_density(t,j,"forestry","vegc") <= 20) = 0; -m_boundfix(v32_land,(j,type32,ac_sub),up,10e-5); +m_boundfix(v32_land,(j,type32,ac_sub),up,1e-10); ** Calculate future yield based on rotation length if((ord(t)=1), diff --git a/modules/35_natveg/dynamic_feb21/presolve.gms b/modules/35_natveg/dynamic_feb21/presolve.gms index 97a6f33b35..6bff1937f4 100644 --- a/modules/35_natveg/dynamic_feb21/presolve.gms +++ b/modules/35_natveg/dynamic_feb21/presolve.gms @@ -125,11 +125,11 @@ v35_secdforest.lo(j,ac_sub) = max((1-s35_natveg_harvest_shr) * pc35_secdforest(j ); * upper bound v35_secdforest.up(j,ac_sub) = pc35_secdforest(j,ac_sub); -m_boundfix(v35_secdforest,(j,ac_sub),l,10e-5); +m_boundfix(v35_secdforest,(j,ac_sub),l,1e-10); * Secondary forest conservation * protection bound fix -pm_land_conservation(t,j,"secdforest","protect")$(abs(pm_land_conservation(t,j,"secdforest","protect") - sum(ac_sub, pc35_secdforest(j,ac_sub))) < 10e-5) = sum(ac_sub, pc35_secdforest(j,ac_sub)); +pm_land_conservation(t,j,"secdforest","protect")$(abs(pm_land_conservation(t,j,"secdforest","protect") - sum(ac_sub, pc35_secdforest(j,ac_sub))) < 1e-10) = sum(ac_sub, pc35_secdforest(j,ac_sub)); * set restoration target p35_land_restoration(j,"secdforest") = pm_land_conservation(t,j,"secdforest","restore"); * Do not restore secdforest in areas where total natural @@ -145,11 +145,11 @@ v35_other.lo(j,ac) = 0; v35_other.up(j,ac) = Inf; *set upper bound v35_other.up(j,ac_sub) = pc35_other(j,ac_sub); -m_boundfix(v35_other,(j,ac_sub),l,10e-5); +m_boundfix(v35_other,(j,ac_sub),l,1e-10); * Other land conservation * protection bound fix -pm_land_conservation(t,j,"other","protect")$(abs(pm_land_conservation(t,j,"other","protect") - sum(ac_sub, pc35_other(j,ac_sub))) < 10e-5) = sum(ac_sub, pc35_other(j,ac_sub)); +pm_land_conservation(t,j,"other","protect")$(abs(pm_land_conservation(t,j,"other","protect") - sum(ac_sub, pc35_other(j,ac_sub))) < 1e-10) = sum(ac_sub, pc35_other(j,ac_sub)); * set restoration target p35_land_restoration(j,"other") = pm_land_conservation(t,j,"other","restore"); * Do not restore other land in areas where total natural From 41d1debc165b39a80f732ce258e210df28fbc9b0 Mon Sep 17 00:00:00 2001 From: florianh Date: Wed, 24 Apr 2024 10:05:23 +0200 Subject: [PATCH 043/133] test different boundfix values --- core/macros.gms | 2 +- modules/10_land/landmatrix_dec18/presolve.gms | 2 +- modules/29_cropland/detail_apr24/presolve.gms | 4 ++-- modules/32_forestry/dynamic_feb21/presolve.gms | 2 +- modules/35_natveg/dynamic_feb21/presolve.gms | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/core/macros.gms b/core/macros.gms index 2fb013af99..70830f9d68 100644 --- a/core/macros.gms +++ b/core/macros.gms @@ -9,7 +9,7 @@ * Macro for fixing a variable in the case that lower and upper bound are too * close to each other (closer than argument "sens") -* EXAMPLE: ma_boundfix(vm_land,(j,"ifft"),up,10e-5); +* EXAMPLE: ma_boundfix(vm_land,(j,"ifft"),up,1e-6); $macro m_boundfix(x,arg,sufx,sens) x.fx arg$(x.up arg-x.lo arg0) + 0$(sum(s,w)<=0); diff --git a/modules/10_land/landmatrix_dec18/presolve.gms b/modules/10_land/landmatrix_dec18/presolve.gms index d3628c565a..5a79286fe5 100644 --- a/modules/10_land/landmatrix_dec18/presolve.gms +++ b/modules/10_land/landmatrix_dec18/presolve.gms @@ -22,4 +22,4 @@ vm_lu_transitions.up(j,"primforest","primforest") = Inf; *' @stop -m_boundfix(vm_land,(j,land),up,1e-10); +m_boundfix(vm_land,(j,land),up,1e-6); diff --git a/modules/29_cropland/detail_apr24/presolve.gms b/modules/29_cropland/detail_apr24/presolve.gms index 3d1b53e322..54fe3c9120 100644 --- a/modules/29_cropland/detail_apr24/presolve.gms +++ b/modules/29_cropland/detail_apr24/presolve.gms @@ -57,7 +57,7 @@ v29_treecover.lo(j,ac_est) = 0; v29_treecover.up(j,ac_est) = Inf; v29_treecover.lo(j,ac_sub) = 0; v29_treecover.up(j,ac_sub) = pc29_treecover(j,ac_sub); -m_boundfix(v29_treecover,(j,ac_sub),l,1e-10); +m_boundfix(v29_treecover,(j,ac_sub),l,1e-6); if (m_year(t) <= s29_treecover_scenario_start, i29_treecover_penalty(t) = 0; @@ -90,4 +90,4 @@ else vm_fallow.lo(j) = 0; vm_fallow.up(j) = p29_avl_cropland(t,j); -m_boundfix(vm_fallow,(j),l,1e-10); +m_boundfix(vm_fallow,(j),l,1e-6); diff --git a/modules/32_forestry/dynamic_feb21/presolve.gms b/modules/32_forestry/dynamic_feb21/presolve.gms index 7f2659735f..b36dda9d4e 100644 --- a/modules/32_forestry/dynamic_feb21/presolve.gms +++ b/modules/32_forestry/dynamic_feb21/presolve.gms @@ -153,7 +153,7 @@ else *' No afforestation is allowed if carbon density <= 20 tc/ha v32_land.fx(j,"aff",ac_est)$(fm_carbon_density(t,j,"forestry","vegc") <= 20) = 0; -m_boundfix(v32_land,(j,type32,ac_sub),up,1e-10); +m_boundfix(v32_land,(j,type32,ac_sub),up,1e-6); ** Calculate future yield based on rotation length if((ord(t)=1), diff --git a/modules/35_natveg/dynamic_feb21/presolve.gms b/modules/35_natveg/dynamic_feb21/presolve.gms index 6bff1937f4..9e757cbe3b 100644 --- a/modules/35_natveg/dynamic_feb21/presolve.gms +++ b/modules/35_natveg/dynamic_feb21/presolve.gms @@ -125,7 +125,7 @@ v35_secdforest.lo(j,ac_sub) = max((1-s35_natveg_harvest_shr) * pc35_secdforest(j ); * upper bound v35_secdforest.up(j,ac_sub) = pc35_secdforest(j,ac_sub); -m_boundfix(v35_secdforest,(j,ac_sub),l,1e-10); +m_boundfix(v35_secdforest,(j,ac_sub),l,1e-6); * Secondary forest conservation * protection bound fix @@ -145,7 +145,7 @@ v35_other.lo(j,ac) = 0; v35_other.up(j,ac) = Inf; *set upper bound v35_other.up(j,ac_sub) = pc35_other(j,ac_sub); -m_boundfix(v35_other,(j,ac_sub),l,1e-10); +m_boundfix(v35_other,(j,ac_sub),l,1e-6); * Other land conservation * protection bound fix From a1791296fdb1764e0d47790bac4a5990211e3723 Mon Sep 17 00:00:00 2001 From: florianh Date: Wed, 24 Apr 2024 12:28:54 +0200 Subject: [PATCH 044/133] revert q29_avl_cropland --- config/default.cfg | 3 --- modules/29_cropland/detail_apr24/declarations.gms | 2 -- modules/29_cropland/detail_apr24/equations.gms | 3 +-- modules/29_cropland/detail_apr24/input.gms | 1 - modules/29_cropland/detail_apr24/postsolve.gms | 4 ---- 5 files changed, 1 insertion(+), 12 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index c4c5d26b83..80c48514fb 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -717,9 +717,6 @@ cfg$gms$policy_countries29 <- all_iso_countries # * "secdforest, past, other" etc. cfg$gms$land_snv <- "secdforest, forestry, past, other" #def = "secdforest, forestry, past, other" -# * Penalty for transgression of available cropland (USD05MER per ha) -cfg$gms$s29_avl_crop_exceed_penalty <- 1e+06 - # * Minimum cluster share of treecover on total cropland area (including croparea, fallow land and tree cover). # * s29_treecover_target is faded in linearly between s29_treecover_scenario_start and s29_treecover_scenario_target. cfg$gms$s29_treecover_target <- 0 # def = 0 diff --git a/modules/29_cropland/detail_apr24/declarations.gms b/modules/29_cropland/detail_apr24/declarations.gms index bd0b1fd36d..386fb8b999 100644 --- a/modules/29_cropland/detail_apr24/declarations.gms +++ b/modules/29_cropland/detail_apr24/declarations.gms @@ -36,7 +36,6 @@ parameters positive variables vm_cost_cropland(j) Cost for total cropland (mio. USD05MER per yr) - v29_avl_crop_exceed(j) Transgression of availabe cropland land (mio. ha) v29_treecover(j,ac) Cropland tree cover per age class (mio. ha) v29_treecover_missing(j) Missing treecover area towards target (mio. ha) v29_cost_treecover_est(j) Establishment cost for cropland tree cover (mio. USD05MER per yr) @@ -66,7 +65,6 @@ equations *#################### R SECTION START (OUTPUT DECLARATIONS) #################### parameters ov_cost_cropland(t,j,type) Cost for total cropland (mio. USD05MER per yr) - ov29_avl_crop_exceed(t,j,type) Transgression of availabe cropland land (mio. ha) ov29_treecover(t,j,ac,type) Cropland tree cover per age class (mio. ha) ov29_treecover_missing(t,j,type) Missing treecover area towards target (mio. ha) ov29_cost_treecover_est(t,j,type) Establishment cost for cropland tree cover (mio. USD05MER per yr) diff --git a/modules/29_cropland/detail_apr24/equations.gms b/modules/29_cropland/detail_apr24/equations.gms index 88000e5bc8..e95aa9a0b4 100644 --- a/modules/29_cropland/detail_apr24/equations.gms +++ b/modules/29_cropland/detail_apr24/equations.gms @@ -20,7 +20,7 @@ *' in order to increase compositional heterogeneity of land types at the cell level. q29_avl_cropland(j2) .. - v29_avl_crop_exceed(j2) =g= vm_land(j2,"crop") - sum(ct, p29_avl_cropland(ct,j2)); + vm_land(j2,"crop") =l= sum(ct, p29_avl_cropland(ct,j2)); *' Total cost for the cropland module. @@ -28,7 +28,6 @@ q29_cost_cropland(j2) .. vm_cost_cropland(j2) =e= v29_cost_treecover_est(j2) + v29_cost_treecover_recur(j2) - + v29_avl_crop_exceed(j2) * s29_avl_crop_exceed_penalty + v29_fallow_missing(j2) * sum(ct, i29_fallow_penalty(ct)) + v29_treecover_missing(j2) * sum(ct, i29_treecover_penalty(ct)); diff --git a/modules/29_cropland/detail_apr24/input.gms b/modules/29_cropland/detail_apr24/input.gms index 52f04d2061..af51a029e4 100644 --- a/modules/29_cropland/detail_apr24/input.gms +++ b/modules/29_cropland/detail_apr24/input.gms @@ -17,7 +17,6 @@ scalars s29_snv_relocation_data_x2 Second reference value in SNV target cropland data (1) / 0.5 / s29_cost_treecover_est Tree cover establishment cost (USD05MER per ha) / 2000 / s29_cost_treecover_recur Tree cover recurring cost (USD05MER per ha) / 500 / - s29_avl_crop_exceed_penalty Penalty for transgression of available cropland (USD05MER per ha) / 1e+06 / s29_treecover_plantation Growth curve switch for tree cover on cropland 0=natveg 1=plantations (1) / 0 / s29_treecover_bii_coeff BII coefficent to be used for tree cover on cropland 0=secondary vegetation 1=timber plantations (1) / 0 / s29_treecover_scenario_start Cropland treecover scenario start year / 2020 / diff --git a/modules/29_cropland/detail_apr24/postsolve.gms b/modules/29_cropland/detail_apr24/postsolve.gms index 79aab84004..1f6b4d64e6 100644 --- a/modules/29_cropland/detail_apr24/postsolve.gms +++ b/modules/29_cropland/detail_apr24/postsolve.gms @@ -9,7 +9,6 @@ pc29_treecover(j,ac) = v29_treecover.l(j,ac); *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### ov_cost_cropland(t,j,"marginal") = vm_cost_cropland.m(j); - ov29_avl_crop_exceed(t,j,"marginal") = v29_avl_crop_exceed.m(j); ov29_treecover(t,j,ac,"marginal") = v29_treecover.m(j,ac); ov29_treecover_missing(t,j,"marginal") = v29_treecover_missing.m(j); ov29_cost_treecover_est(t,j,"marginal") = v29_cost_treecover_est.m(j); @@ -32,7 +31,6 @@ pc29_treecover(j,ac) = v29_treecover.l(j,ac); oq29_cost_treecover_recur(t,j,"marginal") = q29_cost_treecover_recur.m(j); oq29_treecover_est(t,j,ac,"marginal") = q29_treecover_est.m(j,ac); ov_cost_cropland(t,j,"level") = vm_cost_cropland.l(j); - ov29_avl_crop_exceed(t,j,"level") = v29_avl_crop_exceed.l(j); ov29_treecover(t,j,ac,"level") = v29_treecover.l(j,ac); ov29_treecover_missing(t,j,"level") = v29_treecover_missing.l(j); ov29_cost_treecover_est(t,j,"level") = v29_cost_treecover_est.l(j); @@ -55,7 +53,6 @@ pc29_treecover(j,ac) = v29_treecover.l(j,ac); oq29_cost_treecover_recur(t,j,"level") = q29_cost_treecover_recur.l(j); oq29_treecover_est(t,j,ac,"level") = q29_treecover_est.l(j,ac); ov_cost_cropland(t,j,"upper") = vm_cost_cropland.up(j); - ov29_avl_crop_exceed(t,j,"upper") = v29_avl_crop_exceed.up(j); ov29_treecover(t,j,ac,"upper") = v29_treecover.up(j,ac); ov29_treecover_missing(t,j,"upper") = v29_treecover_missing.up(j); ov29_cost_treecover_est(t,j,"upper") = v29_cost_treecover_est.up(j); @@ -78,7 +75,6 @@ pc29_treecover(j,ac) = v29_treecover.l(j,ac); oq29_cost_treecover_recur(t,j,"upper") = q29_cost_treecover_recur.up(j); oq29_treecover_est(t,j,ac,"upper") = q29_treecover_est.up(j,ac); ov_cost_cropland(t,j,"lower") = vm_cost_cropland.lo(j); - ov29_avl_crop_exceed(t,j,"lower") = v29_avl_crop_exceed.lo(j); ov29_treecover(t,j,ac,"lower") = v29_treecover.lo(j,ac); ov29_treecover_missing(t,j,"lower") = v29_treecover_missing.lo(j); ov29_cost_treecover_est(t,j,"lower") = v29_cost_treecover_est.lo(j); From 9d3b74a470f4e422cc82434dd7b53b0c1f8fda52 Mon Sep 17 00:00:00 2001 From: florianh Date: Wed, 24 Apr 2024 12:40:43 +0200 Subject: [PATCH 045/133] additional test runs --- scripts/start/test_runs.R | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/start/test_runs.R b/scripts/start/test_runs.R index 64b65bdfc9..8118f9b927 100644 --- a/scripts/start/test_runs.R +++ b/scripts/start/test_runs.R @@ -79,6 +79,16 @@ cfg <- fsecScenario(scenario = "c_BAU") cfg$results_folder_highres <- "output" start_run(cfg = cfg, codeCheck = codeCheck) +### NatureSparing +cfg <- fsecScenario(scenario = "b_NatureSparing") +cfg$results_folder_highres <- "output" +start_run(cfg = cfg, codeCheck = codeCheck) + +### LandscapeElements +cfg <- fsecScenario(scenario = "a_LandscapeElements") +cfg$results_folder_highres <- "output" +start_run(cfg = cfg, codeCheck = codeCheck) + ### FSDP Scenario cfg <- fsecScenario(scenario = "e_FSDP") cfg$results_folder_highres <- "output" From 960767e3b57703d1f3888e31d718c5c745a4d480 Mon Sep 17 00:00:00 2001 From: florianh Date: Wed, 24 Apr 2024 17:32:49 +0200 Subject: [PATCH 046/133] scaling for age-class variables --- modules/29_cropland/detail_apr24/realization.gms | 1 + modules/29_cropland/detail_apr24/scaling.gms | 8 ++++++++ modules/32_forestry/dynamic_feb21/scaling.gms | 1 + modules/35_natveg/dynamic_feb21/scaling.gms | 2 ++ 4 files changed, 12 insertions(+) create mode 100644 modules/29_cropland/detail_apr24/scaling.gms diff --git a/modules/29_cropland/detail_apr24/realization.gms b/modules/29_cropland/detail_apr24/realization.gms index 071000bd1e..c9b62fec84 100644 --- a/modules/29_cropland/detail_apr24/realization.gms +++ b/modules/29_cropland/detail_apr24/realization.gms @@ -25,6 +25,7 @@ $Ifi "%phase%" == "sets" $include "./modules/29_cropland/detail_apr24/sets.gms" $Ifi "%phase%" == "declarations" $include "./modules/29_cropland/detail_apr24/declarations.gms" $Ifi "%phase%" == "input" $include "./modules/29_cropland/detail_apr24/input.gms" $Ifi "%phase%" == "equations" $include "./modules/29_cropland/detail_apr24/equations.gms" +$Ifi "%phase%" == "scaling" $include "./modules/29_cropland/detail_apr24/scaling.gms" $Ifi "%phase%" == "preloop" $include "./modules/29_cropland/detail_apr24/preloop.gms" $Ifi "%phase%" == "presolve" $include "./modules/29_cropland/detail_apr24/presolve.gms" $Ifi "%phase%" == "postsolve" $include "./modules/29_cropland/detail_apr24/postsolve.gms" diff --git a/modules/29_cropland/detail_apr24/scaling.gms b/modules/29_cropland/detail_apr24/scaling.gms new file mode 100644 index 0000000000..d92955e666 --- /dev/null +++ b/modules/29_cropland/detail_apr24/scaling.gms @@ -0,0 +1,8 @@ +*** | (C) 2008-2024 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 + +v29_treecover.scale(j,ac) = 1e6; diff --git a/modules/32_forestry/dynamic_feb21/scaling.gms b/modules/32_forestry/dynamic_feb21/scaling.gms index 284349ec52..4cc23a7c4d 100644 --- a/modules/32_forestry/dynamic_feb21/scaling.gms +++ b/modules/32_forestry/dynamic_feb21/scaling.gms @@ -10,3 +10,4 @@ v32_cost_recur.scale(i) = 10e4; vm_cost_fore.scale(i) = 10e4; v32_cost_hvarea.scale(i)$(s32_hvarea = 1 OR s32_hvarea = 2) = 10e3; vm_cdr_aff.scale(j,ac,aff_effect) = 10e-4; +v32_land.scale(j,type32,ac) = 1e6; diff --git a/modules/35_natveg/dynamic_feb21/scaling.gms b/modules/35_natveg/dynamic_feb21/scaling.gms index c4a52d9d82..1971d125a5 100644 --- a/modules/35_natveg/dynamic_feb21/scaling.gms +++ b/modules/35_natveg/dynamic_feb21/scaling.gms @@ -6,3 +6,5 @@ *** | Contact: magpie@pik-potsdam.de vm_cost_hvarea_natveg.scale(i)$(s35_hvarea = 1 OR s35_hvarea = 2) = 10e4; +v35_other.scale(j,ac) = 1e6; +v35_secdforest.scale(j,ac) = 1e6; From 5b89eeea829069d9645f025e6675be57a75f7f73 Mon Sep 17 00:00:00 2001 From: florianh Date: Wed, 24 Apr 2024 21:51:36 +0200 Subject: [PATCH 047/133] scaling for age-class variables --- modules/29_cropland/detail_apr24/scaling.gms | 2 +- modules/32_forestry/dynamic_feb21/scaling.gms | 2 +- modules/35_natveg/dynamic_feb21/scaling.gms | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/29_cropland/detail_apr24/scaling.gms b/modules/29_cropland/detail_apr24/scaling.gms index d92955e666..ce898e661a 100644 --- a/modules/29_cropland/detail_apr24/scaling.gms +++ b/modules/29_cropland/detail_apr24/scaling.gms @@ -5,4 +5,4 @@ *** | MAgPIE License Exception, version 1.0 (see LICENSE file). *** | Contact: magpie@pik-potsdam.de -v29_treecover.scale(j,ac) = 1e6; +v29_treecover.scale(j,ac) = 1e-6; diff --git a/modules/32_forestry/dynamic_feb21/scaling.gms b/modules/32_forestry/dynamic_feb21/scaling.gms index 4cc23a7c4d..ba76c8104b 100644 --- a/modules/32_forestry/dynamic_feb21/scaling.gms +++ b/modules/32_forestry/dynamic_feb21/scaling.gms @@ -10,4 +10,4 @@ v32_cost_recur.scale(i) = 10e4; vm_cost_fore.scale(i) = 10e4; v32_cost_hvarea.scale(i)$(s32_hvarea = 1 OR s32_hvarea = 2) = 10e3; vm_cdr_aff.scale(j,ac,aff_effect) = 10e-4; -v32_land.scale(j,type32,ac) = 1e6; +v32_land.scale(j,type32,ac) = 1e-6; diff --git a/modules/35_natveg/dynamic_feb21/scaling.gms b/modules/35_natveg/dynamic_feb21/scaling.gms index 1971d125a5..a79952fc6f 100644 --- a/modules/35_natveg/dynamic_feb21/scaling.gms +++ b/modules/35_natveg/dynamic_feb21/scaling.gms @@ -6,5 +6,5 @@ *** | Contact: magpie@pik-potsdam.de vm_cost_hvarea_natveg.scale(i)$(s35_hvarea = 1 OR s35_hvarea = 2) = 10e4; -v35_other.scale(j,ac) = 1e6; -v35_secdforest.scale(j,ac) = 1e6; +v35_other.scale(j,ac) = 1e-6; +v35_secdforest.scale(j,ac) = 1e-6; From 0bdde4ded9900889936bc2a7d816932497aaa2bc Mon Sep 17 00:00:00 2001 From: florianh Date: Thu, 25 Apr 2024 06:26:20 +0200 Subject: [PATCH 048/133] bugfixes --- modules/29_cropland/detail_apr24/equations.gms | 4 ++-- modules/30_croparea/detail_apr24/equations.gms | 2 +- modules/30_croparea/simple_apr24/equations.gms | 2 +- modules/30_croparea/simple_apr24/presolve.gms | 14 +++++++++++++- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/modules/29_cropland/detail_apr24/equations.gms b/modules/29_cropland/detail_apr24/equations.gms index e95aa9a0b4..6767a341d5 100644 --- a/modules/29_cropland/detail_apr24/equations.gms +++ b/modules/29_cropland/detail_apr24/equations.gms @@ -63,7 +63,7 @@ *' The penalty applies to the missing fallow land, i.e. where fallow land *' is lower than a certain fraction of total cropland. - q29_fallow_min(j2) .. + q29_fallow_min(j2)$(sum(ct, i29_fallow_penalty(ct)) > 0) .. v29_fallow_missing(j2) =g= vm_land(j2,"crop") * sum(ct, i29_fallow_target(ct)) - vm_fallow(j2); @@ -82,7 +82,7 @@ *' The penalty applies to the missing treecover area, i.e. where treecover area *' is lower than a certain fraction of total cropland. - q29_treecover_min(j2) .. + q29_treecover_min(j2)$(sum(ct, i29_treecover_penalty(ct)) > 0) .. v29_treecover_missing(j2) =g= vm_land(j2,"crop") * sum(ct, i29_treecover_target(ct,j2)) - sum(ac, v29_treecover(j2,ac)); diff --git a/modules/30_croparea/detail_apr24/equations.gms b/modules/30_croparea/detail_apr24/equations.gms index 7629f075ca..2ddbbc8409 100644 --- a/modules/30_croparea/detail_apr24/equations.gms +++ b/modules/30_croparea/detail_apr24/equations.gms @@ -18,7 +18,7 @@ *' The penalty applies to the missing bioenergy tree land, i.e. where bioenergy tree land *' is lower than a certain fraction of total cropland. - q30_betr_missing(j2) .. + q30_betr_missing(j2)$(sum(ct, i30_betr_penalty(ct)) > 0) .. v30_betr_missing(j2) =g= vm_land(j2,"crop") * sum(ct, i30_betr_target(ct)) - vm_area(j2,"betr","rainfed"); diff --git a/modules/30_croparea/simple_apr24/equations.gms b/modules/30_croparea/simple_apr24/equations.gms index 1e872f1606..dca6bc7c08 100644 --- a/modules/30_croparea/simple_apr24/equations.gms +++ b/modules/30_croparea/simple_apr24/equations.gms @@ -18,7 +18,7 @@ *' The penalty applies to the missing bioenergy tree land, i.e. where bioenergy tree land *' is lower than a certain fraction of total cropland. - q30_betr_missing(j2) .. + q30_betr_missing(j2)$(sum(ct, i30_betr_penalty(ct)) > 0) .. v30_betr_missing(j2) =g= vm_land(j2,"crop") * sum(ct, i30_betr_target(ct)) - vm_area(j2,"betr","rainfed"); diff --git a/modules/30_croparea/simple_apr24/presolve.gms b/modules/30_croparea/simple_apr24/presolve.gms index 5dee653207..f91d1a0cf1 100644 --- a/modules/30_croparea/simple_apr24/presolve.gms +++ b/modules/30_croparea/simple_apr24/presolve.gms @@ -28,4 +28,16 @@ crpmin30(crp30) = yes$(f30_rotation_min_shr(crp30) > 0); * create betr target and penalty scenario i30_betr_target(t) = s30_betr_target * i30_betr_scenario_fader(t); -i30_betr_penalty(t) = s30_betr_penalty * i30_betr_scenario_fader(t); + +if (m_year(t) <= s30_betr_scenario_start, + i30_betr_penalty(t) = 0; + v30_betr_missing.fx(j) = 0; +else + i30_betr_penalty(t) = s30_betr_penalty; + if (i30_betr_penalty(t) > 0, + v30_betr_missing.lo(j) = 0; + v30_betr_missing.up(j) = Inf; + else + v30_betr_missing.fx(j) = 0; + ); +); From 37a8b370b9e4c31cca11fdcf93f5aff914b4bae4 Mon Sep 17 00:00:00 2001 From: florianh Date: Thu, 25 Apr 2024 11:34:05 +0200 Subject: [PATCH 049/133] bugfixes --- modules/30_croparea/detail_apr24/presolve.gms | 9 +++++++-- modules/30_croparea/simple_apr24/presolve.gms | 3 --- modules/58_peatland/v2/scaling.gms | 1 + 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/modules/30_croparea/detail_apr24/presolve.gms b/modules/30_croparea/detail_apr24/presolve.gms index 907dd57aaa..4a028ffad2 100644 --- a/modules/30_croparea/detail_apr24/presolve.gms +++ b/modules/30_croparea/detail_apr24/presolve.gms @@ -22,8 +22,13 @@ else *' @stop * only activate constraints which are binding -rotamax_red30(rotamax30) = yes$(i30_rotation_rules(t,rotamax30) < 1); -rotamin_red30(rotamin30) = yes$(i30_rotation_rules(t,rotamin30) > 0); +if (i30_implementation = 1, + rotamax_red30(rotamax30) = yes$(i30_rotation_rules(t,rotamax30) < 1); + rotamin_red30(rotamin30) = yes$(i30_rotation_rules(t,rotamin30) > 0); +else + rotamax_red30(rotamax30) = yes$(i30_rotation_incentives(t,rotamax30) > 0); + rotamin_red30(rotamin30) = yes$(i30_rotation_incentives(t,rotamin30) > 0); +); * create betr target and penalty scenario i30_betr_target(t) = s30_betr_target * i30_betr_scenario_fader(t); diff --git a/modules/30_croparea/simple_apr24/presolve.gms b/modules/30_croparea/simple_apr24/presolve.gms index f91d1a0cf1..fb57b1d9f4 100644 --- a/modules/30_croparea/simple_apr24/presolve.gms +++ b/modules/30_croparea/simple_apr24/presolve.gms @@ -20,9 +20,6 @@ else *' @stop -*' No penalties exist in this realization -vm_rotation_penalty.fx(i)=0; - crpmax30(crp30) = yes$(f30_rotation_max_shr(crp30) < 1); crpmin30(crp30) = yes$(f30_rotation_min_shr(crp30) > 0); diff --git a/modules/58_peatland/v2/scaling.gms b/modules/58_peatland/v2/scaling.gms index 3acae9e9b6..787936e8ca 100644 --- a/modules/58_peatland/v2/scaling.gms +++ b/modules/58_peatland/v2/scaling.gms @@ -6,3 +6,4 @@ *** | Contact: magpie@pik-potsdam.de v58_peatlandChange.scale(j,land58) = 10e-3; +v58_peatland.scale(j,land58) = 10e-3; From 65f8202cb9e2b4e5857eb97ef8fd86cf8f3a705d Mon Sep 17 00:00:00 2001 From: florianh Date: Thu, 25 Apr 2024 18:13:24 +0200 Subject: [PATCH 050/133] move of shifting from other land to secondary before age-class growth for consistency with carbon stocks and calculations in post-processing --- modules/35_natveg/dynamic_feb21/presolve.gms | 26 +++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/modules/35_natveg/dynamic_feb21/presolve.gms b/modules/35_natveg/dynamic_feb21/presolve.gms index 9e757cbe3b..0a656ec42b 100644 --- a/modules/35_natveg/dynamic_feb21/presolve.gms +++ b/modules/35_natveg/dynamic_feb21/presolve.gms @@ -47,6 +47,20 @@ pc35_secdforest(j,ac_sub) = pc35_secdforest(j,ac_sub) - p35_disturbance_loss_sec pcm_land(j,"primforest") = pcm_land(j,"primforest") - p35_disturbance_loss_primf(t,j); vm_land.l(j,"primforest") = pcm_land(j,"primforest"); +* -------------------------------------- +* Carbon threshold for secondary forest +* -------------------------------------- + +*' @code +*' If the vegetation carbon density in a simulation unit due to regrowth +*' exceeds a threshold of 20 tC/ha the respective area is shifted from other natural land to secondary forest. +p35_recovered_forest(t,j,ac)$(not sameas(ac,"acx")) = + p35_other(t,j,ac)$(pm_carbon_density_ac(t,j,ac,"vegc") > 20); +p35_other(t,j,ac) = p35_other(t,j,ac) - p35_recovered_forest(t,j,ac); +p35_secdforest(t,j,ac) = p35_secdforest(t,j,ac) + p35_recovered_forest(t,j,ac); +*' @stop + + * Regrowth of natural vegetation (natural succession) is modelled by shifting age-classes according to time step length. s35_shift = m_timestep_length_forestry/5; * example: ac10 in t = ac5 (ac10-1) in t-1 for a 5 yr time step (s35_shift = 1) @@ -62,18 +76,6 @@ s35_shift = m_timestep_length_forestry/5; p35_secdforest(t,j,"acx") = p35_secdforest(t,j,"acx") + sum(ac$(ord(ac) > card(ac)-s35_shift), pc35_secdforest(j,ac)); -* -------------------------------------- -* Carbon threshold for secondary forest -* -------------------------------------- - -*' @code -*' If the vegetation carbon density in a simulation unit due to regrowth -*' exceeds a threshold of 20 tC/ha the respective area is shifted from other natural land to secondary forest. -p35_recovered_forest(t,j,ac)$(not sameas(ac,"acx")) = - p35_other(t,j,ac)$(pm_carbon_density_ac(t,j,ac,"vegc") > 20); -p35_other(t,j,ac) = p35_other(t,j,ac) - p35_recovered_forest(t,j,ac); -p35_secdforest(t,j,ac) = p35_secdforest(t,j,ac) + p35_recovered_forest(t,j,ac); -*' @stop pc35_secdforest(j,ac) = p35_secdforest(t,j,ac); v35_secdforest.l(j,ac) = pc35_secdforest(j,ac); From a755ee5ec8ef9f9272947bd084711f8e8e3bbf49 Mon Sep 17 00:00:00 2001 From: florianh Date: Fri, 26 Apr 2024 22:28:29 +0200 Subject: [PATCH 051/133] bugfixes --- modules/29_cropland/detail_apr24/scaling.gms | 2 +- modules/32_forestry/dynamic_feb21/scaling.gms | 2 +- modules/35_natveg/dynamic_feb21/presolve.gms | 6 +++--- modules/35_natveg/dynamic_feb21/scaling.gms | 4 ++-- modules/80_optimization/nlp_par/solve.gms | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/29_cropland/detail_apr24/scaling.gms b/modules/29_cropland/detail_apr24/scaling.gms index ce898e661a..1a421079e2 100644 --- a/modules/29_cropland/detail_apr24/scaling.gms +++ b/modules/29_cropland/detail_apr24/scaling.gms @@ -5,4 +5,4 @@ *** | MAgPIE License Exception, version 1.0 (see LICENSE file). *** | Contact: magpie@pik-potsdam.de -v29_treecover.scale(j,ac) = 1e-6; +v29_treecover.scale(j,ac) = 1e-3; diff --git a/modules/32_forestry/dynamic_feb21/scaling.gms b/modules/32_forestry/dynamic_feb21/scaling.gms index ba76c8104b..7b86cdf19a 100644 --- a/modules/32_forestry/dynamic_feb21/scaling.gms +++ b/modules/32_forestry/dynamic_feb21/scaling.gms @@ -10,4 +10,4 @@ v32_cost_recur.scale(i) = 10e4; vm_cost_fore.scale(i) = 10e4; v32_cost_hvarea.scale(i)$(s32_hvarea = 1 OR s32_hvarea = 2) = 10e3; vm_cdr_aff.scale(j,ac,aff_effect) = 10e-4; -v32_land.scale(j,type32,ac) = 1e-6; +v32_land.scale(j,type32,ac) = 1e-3; diff --git a/modules/35_natveg/dynamic_feb21/presolve.gms b/modules/35_natveg/dynamic_feb21/presolve.gms index 0a656ec42b..c2ad686cbe 100644 --- a/modules/35_natveg/dynamic_feb21/presolve.gms +++ b/modules/35_natveg/dynamic_feb21/presolve.gms @@ -55,9 +55,9 @@ vm_land.l(j,"primforest") = pcm_land(j,"primforest"); *' If the vegetation carbon density in a simulation unit due to regrowth *' exceeds a threshold of 20 tC/ha the respective area is shifted from other natural land to secondary forest. p35_recovered_forest(t,j,ac)$(not sameas(ac,"acx")) = - p35_other(t,j,ac)$(pm_carbon_density_ac(t,j,ac,"vegc") > 20); -p35_other(t,j,ac) = p35_other(t,j,ac) - p35_recovered_forest(t,j,ac); -p35_secdforest(t,j,ac) = p35_secdforest(t,j,ac) + p35_recovered_forest(t,j,ac); + pc35_other(j,ac)$(pm_carbon_density_ac(t,j,ac,"vegc") > 20); +pc35_other(j,ac) = pc35_other(j,ac) - p35_recovered_forest(t,j,ac); +pc35_secdforest(j,ac) = pc35_secdforest(j,ac) + p35_recovered_forest(t,j,ac); *' @stop diff --git a/modules/35_natveg/dynamic_feb21/scaling.gms b/modules/35_natveg/dynamic_feb21/scaling.gms index a79952fc6f..e49ef49e78 100644 --- a/modules/35_natveg/dynamic_feb21/scaling.gms +++ b/modules/35_natveg/dynamic_feb21/scaling.gms @@ -6,5 +6,5 @@ *** | Contact: magpie@pik-potsdam.de vm_cost_hvarea_natveg.scale(i)$(s35_hvarea = 1 OR s35_hvarea = 2) = 10e4; -v35_other.scale(j,ac) = 1e-6; -v35_secdforest.scale(j,ac) = 1e-6; +v35_other.scale(j,ac) = 1e-3; +v35_secdforest.scale(j,ac) = 1e-3; diff --git a/modules/80_optimization/nlp_par/solve.gms b/modules/80_optimization/nlp_par/solve.gms index 4db21bc22d..5af9ddba83 100644 --- a/modules/80_optimization/nlp_par/solve.gms +++ b/modules/80_optimization/nlp_par/solve.gms @@ -116,7 +116,7 @@ repeat j2(j) = no; ); ); -display$readyCollect(p80_handle,INF) 'Problem waiting for next instance to complete'; +*display$readyCollect(p80_handle,INF) 'Problem waiting for next instance to complete'; until card(p80_handle) = 0 OR smax(h, p80_counter(h)) >= s80_maxiter; if (smax(h,p80_modelstat(t,h)) > 2 and smax(h,p80_modelstat(t,h)) ne 7, From b6fb4891433b6d90ca5ea9d099b39ff8b07a9b9e Mon Sep 17 00:00:00 2001 From: florianh Date: Sat, 27 Apr 2024 09:39:25 +0200 Subject: [PATCH 052/133] bugfix --- scripts/output/extra/highres.R | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/output/extra/highres.R b/scripts/output/extra/highres.R index 3d250abb7a..b018934d7f 100644 --- a/scripts/output/extra/highres.R +++ b/scripts/output/extra/highres.R @@ -102,7 +102,6 @@ highres <- function(cfg) { cfg$files2export$start <- c(cfg$files2export$start, paste0(cfg$results_folder, "/", "magpie_y1995.gdx")) cfg$gms$s_use_gdx <- 1 - cfg$gms$s80_optfile <- 1 #max resources for parallel runs cfg$qos <- "standby_maxMem_dayMax" From c6c4756ce3b3c8d5d0488feed98332b7dfe14ad8 Mon Sep 17 00:00:00 2001 From: florianh Date: Sun, 28 Apr 2024 07:19:05 +0200 Subject: [PATCH 053/133] bugfix --- modules/80_optimization/nlp_par/declarations.gms | 2 +- modules/80_optimization/nlp_par/solve.gms | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/modules/80_optimization/nlp_par/declarations.gms b/modules/80_optimization/nlp_par/declarations.gms index 7a8f5e5b71..1cbf6971aa 100644 --- a/modules/80_optimization/nlp_par/declarations.gms +++ b/modules/80_optimization/nlp_par/declarations.gms @@ -9,11 +9,11 @@ parameters p80_modelstat(t,h) modelstat indicator (1) p80_counter(h) counter (1) p80_handle(h) parallel mode handle parameter (1) + p80_resolve(h) indicator for restarting solve (1) ; scalars s80_counter counter (1) s80_modelstat_previter modelstat of previous iteration (1) s80_optfile_previter optfile used in previous iteration (1) - s80_resolve indicator for restarting solve (1) ; diff --git a/modules/80_optimization/nlp_par/solve.gms b/modules/80_optimization/nlp_par/solve.gms index 5af9ddba83..a1ad4bf5cc 100644 --- a/modules/80_optimization/nlp_par/solve.gms +++ b/modules/80_optimization/nlp_par/solve.gms @@ -39,6 +39,7 @@ loop(h, i2(i)$supreg(h,i) = yes; loop(i2, j2(j)$cell(i2,j) = yes); solve magpie USING nlp MINIMIZING vm_cost_glo; + solve magpie USING nlp MINIMIZING vm_cost_glo; h2(h) = no; i2(i) = no; j2(j) = no; @@ -50,7 +51,7 @@ repeat loop(h$p80_handle(h), if(handleStatus(p80_handle(h)) = 2, p80_counter(h) = p80_counter(h) + 1; - s80_resolve = 1; + p80_resolve(h) = 1; magpie.handle = p80_handle(h); execute_loadhandle magpie; @@ -74,19 +75,19 @@ repeat option AsyncSolLst=1; display$handlecollect(p80_handle(h)) 're-collect'; option AsyncSolLst=0; - s80_resolve = 0; + p80_resolve(h) = 0; ); display$handledelete(p80_handle(h)) 'trouble deleting handles' ; if (p80_modelstat(t,h) <= 2, display "Model status <= 2. Handle cleared."; - s80_resolve = 0; + p80_resolve(h) = 0; p80_handle(h) = 0; ); if (s80_extra_solve = 1, - if (s80_resolve = 1, + if (p80_resolve(h) = 1, display "Resolve" if (p80_modelstat(t,h) ne s80_modelstat_previter, display "Modelstat > 2 | Retry solve with CONOPT4 default setting"; @@ -116,6 +117,7 @@ repeat j2(j) = no; ); ); +display$sleep(card(p80_handle)*60) 'sleep some time'; *display$readyCollect(p80_handle,INF) 'Problem waiting for next instance to complete'; until card(p80_handle) = 0 OR smax(h, p80_counter(h)) >= s80_maxiter; From f22f7361b47ee0dc3b6d0dd8897fc20bad027c5f Mon Sep 17 00:00:00 2001 From: florianh Date: Sun, 28 Apr 2024 08:32:32 +0200 Subject: [PATCH 054/133] bugfix --- modules/80_optimization/nlp_par/solve.gms | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/80_optimization/nlp_par/solve.gms b/modules/80_optimization/nlp_par/solve.gms index a1ad4bf5cc..7be1af044b 100644 --- a/modules/80_optimization/nlp_par/solve.gms +++ b/modules/80_optimization/nlp_par/solve.gms @@ -117,8 +117,8 @@ repeat j2(j) = no; ); ); -display$sleep(card(p80_handle)*60) 'sleep some time'; -*display$readyCollect(p80_handle,INF) 'Problem waiting for next instance to complete'; +display$sleep(card(p80_handle)*0.2) 'sleep some time'; +display$readyCollect(p80_handle,INF) 'Problem waiting for next instance to complete'; until card(p80_handle) = 0 OR smax(h, p80_counter(h)) >= s80_maxiter; if (smax(h,p80_modelstat(t,h)) > 2 and smax(h,p80_modelstat(t,h)) ne 7, From 14eea422318b2b562a1a0490496c90439fa35a29 Mon Sep 17 00:00:00 2001 From: florianh Date: Sun, 28 Apr 2024 10:20:54 +0200 Subject: [PATCH 055/133] bugfix --- modules/80_optimization/nlp_par/solve.gms | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/80_optimization/nlp_par/solve.gms b/modules/80_optimization/nlp_par/solve.gms index 7be1af044b..a2753f7565 100644 --- a/modules/80_optimization/nlp_par/solve.gms +++ b/modules/80_optimization/nlp_par/solve.gms @@ -92,15 +92,18 @@ repeat if (p80_modelstat(t,h) ne s80_modelstat_previter, display "Modelstat > 2 | Retry solve with CONOPT4 default setting"; solve magpie USING nlp MINIMIZING vm_cost_glo; + solve magpie USING nlp MINIMIZING vm_cost_glo; elseif p80_modelstat(t,h) = s80_modelstat_previter, if(magpie.optfile = s80_optfile_previter, display "Modelstat > 2 | Retry solve without CONOPT4 pre-processing"; magpie.optfile = 2; solve magpie USING nlp MINIMIZING vm_cost_glo; + solve magpie USING nlp MINIMIZING vm_cost_glo; else display "Modelstat > 2 | Retry solve with CONOPT3"; option nlp = conopt; solve magpie USING nlp MINIMIZING vm_cost_glo; + solve magpie USING nlp MINIMIZING vm_cost_glo; option nlp = conopt4; ); ); From a723bd9180784a88faab8270f095b38ee3b65015 Mon Sep 17 00:00:00 2001 From: florianh Date: Sun, 28 Apr 2024 12:34:54 +0200 Subject: [PATCH 056/133] bugfix --- config/default.cfg | 8 +------- .../80_optimization/lp_nlp_apr17/input.gms | 3 +-- .../80_optimization/lp_nlp_apr17/solve.gms | 19 +++++++++---------- modules/80_optimization/nlp_apr17/input.gms | 3 +-- modules/80_optimization/nlp_apr17/solve.gms | 4 +--- modules/80_optimization/nlp_par/input.gms | 3 +-- modules/80_optimization/nlp_par/solve.gms | 4 +--- 7 files changed, 15 insertions(+), 29 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index 80c48514fb..ed15c35ff4 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -1953,7 +1953,7 @@ cfg$gms$s73_expansion <- 0 # def = 0 cfg$gms$optimization <- "nlp_apr17" # def = nlp_apr17 # maximal number of solve iterations -cfg$gms$s80_maxiter <- 30 +cfg$gms$s80_maxiter <- 10 # def = 10 # Solver settings only for realization `lp_nlp_apr17`. All other realizations use `conopt4`. # * (conopt4): conopt4 @@ -1965,12 +1965,6 @@ cfg$gms$c80_nlp_solver <- "conopt4" # def = conopt4 # * 0: default settings (optfile will be ignored) cfg$gms$s80_optfile <- 0 # def = 0 -# switch to use alternative solver settings if CONOPT4 fails -# * 0: not used -# * 1: additional solve statements for CONOPT4 without preprocessing and CONOPT3 -# * Note: Option 1 is very time-consuming and usually does not provide a feasible solution. -cfg$gms$s80_extra_solve <- 0 # def = 0 - #*******************************END MODULE SETUP******************************** #### Other settings (e.g. clustering, gdx files, ...): #### diff --git a/modules/80_optimization/lp_nlp_apr17/input.gms b/modules/80_optimization/lp_nlp_apr17/input.gms index a157e8bf5a..83427b7cfe 100644 --- a/modules/80_optimization/lp_nlp_apr17/input.gms +++ b/modules/80_optimization/lp_nlp_apr17/input.gms @@ -6,11 +6,10 @@ *** | Contact: magpie@pik-potsdam.de scalars - s80_maxiter maximal solve iterations if modelstat is > 2 (1) / 30 / + s80_maxiter maximal solve iterations if modelstat is > 2 (1) / 10 / s80_optfile switch to use specfied solver settings (1) / 0 / s80_add_cplex add cplex optimization after conopt4 (1) / 0 / s80_add_conopt3 add conopt3 optimization after conopt4 (1) / 0 / - s80_extra_solve switch to use alternative solver settings (1) / 0 / ; diff --git a/modules/80_optimization/lp_nlp_apr17/solve.gms b/modules/80_optimization/lp_nlp_apr17/solve.gms index 62650b1c1e..85ec1ef813 100644 --- a/modules/80_optimization/lp_nlp_apr17/solve.gms +++ b/modules/80_optimization/lp_nlp_apr17/solve.gms @@ -143,25 +143,24 @@ $batinclude "./modules/include.gms" nl_relax option nlp = conopt4; ); -if (s80_extra_solve = 1, * if solve stopped with an error, try it again without pre-processing if((magpie.modelstat = 13), display "WARNING: Modelstat 13 | retry without Conopt4 pre-processing"; - magpie.optfile = 2 + magpie.optfile = 2 solve magpie USING nlp MINIMIZING vm_cost_glo; solve magpie USING nlp MINIMIZING vm_cost_glo; magpie.optfile = s80_optfile ; ); * if solve stopped with an error, try it again with conopt3 - if ((magpie.modelstat = 13), - display "WARNING: Modelstat 13 | retry with CONOPT3!"; - option nlp = conopt; - solve magpie USING nlp MINIMIZING vm_cost_glo; - solve magpie USING nlp MINIMIZING vm_cost_glo; - option nlp = conopt4; - ); -); + if ((magpie.modelstat = 13), + display "WARNING: Modelstat 13 | retry with CONOPT3!"; + option nlp = conopt; + solve magpie USING nlp MINIMIZING vm_cost_glo; + solve magpie USING nlp MINIMIZING vm_cost_glo; + option nlp = conopt4; + ); + p80_modelstat(t) = magpie.modelstat; p80_num_nonopt(t) = magpie.numNOpt; diff --git a/modules/80_optimization/nlp_apr17/input.gms b/modules/80_optimization/nlp_apr17/input.gms index 16536ff584..b26b854d44 100644 --- a/modules/80_optimization/nlp_apr17/input.gms +++ b/modules/80_optimization/nlp_apr17/input.gms @@ -6,7 +6,6 @@ *** | Contact: magpie@pik-potsdam.de scalars - s80_maxiter maximal solve iterations if modelstat is > 2 (1) / 30 / + s80_maxiter maximal solve iterations if modelstat is > 2 (1) / 10 / s80_optfile switch to use specfied solver settings (1) / 0 / - s80_extra_solve switch to use alternative solver settings (1) / 0 / ; diff --git a/modules/80_optimization/nlp_apr17/solve.gms b/modules/80_optimization/nlp_apr17/solve.gms index bb4edc2c31..bae758fec1 100644 --- a/modules/80_optimization/nlp_apr17/solve.gms +++ b/modules/80_optimization/nlp_apr17/solve.gms @@ -41,8 +41,7 @@ display vm_cost_glo.l; display magpie.modelstat; * in case of problems try different solvers and optfile settings -if (s80_extra_solve = 1, - if (magpie.modelstat > 2, +if (magpie.modelstat > 2, repeat( s80_counter = s80_counter + 1 ; @@ -83,7 +82,6 @@ if (s80_extra_solve = 1, until (magpie.modelstat <= 2 or s80_counter >= s80_maxiter) ); - ); ); p80_modelstat(t) = magpie.modelstat; diff --git a/modules/80_optimization/nlp_par/input.gms b/modules/80_optimization/nlp_par/input.gms index bc0dc6e7ce..eaf3fdd672 100644 --- a/modules/80_optimization/nlp_par/input.gms +++ b/modules/80_optimization/nlp_par/input.gms @@ -6,7 +6,6 @@ *** | Contact: magpie@pik-potsdam.de scalars - s80_maxiter maximal solve iterations if modelstat is > 2 (1) / 30 / + s80_maxiter maximal solve iterations if modelstat is > 2 (1) / 10 / s80_optfile switch to use specfied solver settings (1) / 0 / - s80_extra_solve switch to use alternative solver settings (1) / 0 / ; diff --git a/modules/80_optimization/nlp_par/solve.gms b/modules/80_optimization/nlp_par/solve.gms index a2753f7565..8b95ef6ff2 100644 --- a/modules/80_optimization/nlp_par/solve.gms +++ b/modules/80_optimization/nlp_par/solve.gms @@ -86,8 +86,7 @@ repeat p80_handle(h) = 0; ); - if (s80_extra_solve = 1, - if (p80_resolve(h) = 1, + if (p80_resolve(h) = 1, display "Resolve" if (p80_modelstat(t,h) ne s80_modelstat_previter, display "Modelstat > 2 | Retry solve with CONOPT4 default setting"; @@ -113,7 +112,6 @@ repeat magpie.handle = 1; ); p80_handle(h) = magpie.handle; - ); ); h2(h) = no; i2(i) = no; From f80ee75ea92b60ed981b82cb838a942aab6f4b47 Mon Sep 17 00:00:00 2001 From: florianh Date: Sun, 28 Apr 2024 14:40:32 +0200 Subject: [PATCH 057/133] scaling --- modules/29_cropland/detail_apr24/scaling.gms | 2 -- modules/32_forestry/dynamic_feb21/scaling.gms | 1 - modules/35_natveg/dynamic_feb21/scaling.gms | 2 -- 3 files changed, 5 deletions(-) diff --git a/modules/29_cropland/detail_apr24/scaling.gms b/modules/29_cropland/detail_apr24/scaling.gms index 1a421079e2..3a209b115b 100644 --- a/modules/29_cropland/detail_apr24/scaling.gms +++ b/modules/29_cropland/detail_apr24/scaling.gms @@ -4,5 +4,3 @@ *** | 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 - -v29_treecover.scale(j,ac) = 1e-3; diff --git a/modules/32_forestry/dynamic_feb21/scaling.gms b/modules/32_forestry/dynamic_feb21/scaling.gms index 7b86cdf19a..284349ec52 100644 --- a/modules/32_forestry/dynamic_feb21/scaling.gms +++ b/modules/32_forestry/dynamic_feb21/scaling.gms @@ -10,4 +10,3 @@ v32_cost_recur.scale(i) = 10e4; vm_cost_fore.scale(i) = 10e4; v32_cost_hvarea.scale(i)$(s32_hvarea = 1 OR s32_hvarea = 2) = 10e3; vm_cdr_aff.scale(j,ac,aff_effect) = 10e-4; -v32_land.scale(j,type32,ac) = 1e-3; diff --git a/modules/35_natveg/dynamic_feb21/scaling.gms b/modules/35_natveg/dynamic_feb21/scaling.gms index e49ef49e78..c4a52d9d82 100644 --- a/modules/35_natveg/dynamic_feb21/scaling.gms +++ b/modules/35_natveg/dynamic_feb21/scaling.gms @@ -6,5 +6,3 @@ *** | Contact: magpie@pik-potsdam.de vm_cost_hvarea_natveg.scale(i)$(s35_hvarea = 1 OR s35_hvarea = 2) = 10e4; -v35_other.scale(j,ac) = 1e-3; -v35_secdforest.scale(j,ac) = 1e-3; From ea597be7c8d77eb949f8f5154d81e879accf57a3 Mon Sep 17 00:00:00 2001 From: florianh Date: Sun, 28 Apr 2024 15:00:31 +0200 Subject: [PATCH 058/133] scaleopt --- config/default.cfg | 3 +++ modules/80_optimization/lp_nlp_apr17/input.gms | 1 + modules/80_optimization/lp_nlp_apr17/solve.gms | 2 +- modules/80_optimization/nlp_apr17/input.gms | 1 + modules/80_optimization/nlp_apr17/solve.gms | 2 +- modules/80_optimization/nlp_par/input.gms | 1 + modules/80_optimization/nlp_par/solve.gms | 2 +- 7 files changed, 9 insertions(+), 3 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index ed15c35ff4..e9e5d75ce0 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -1965,6 +1965,9 @@ cfg$gms$c80_nlp_solver <- "conopt4" # def = conopt4 # * 0: default settings (optfile will be ignored) cfg$gms$s80_optfile <- 0 # def = 0 +# switch for scaling (1=on 0=off) +cfg$gms$s80_scaleopt <- 1 # def = 1 + #*******************************END MODULE SETUP******************************** #### Other settings (e.g. clustering, gdx files, ...): #### diff --git a/modules/80_optimization/lp_nlp_apr17/input.gms b/modules/80_optimization/lp_nlp_apr17/input.gms index 83427b7cfe..cd820db042 100644 --- a/modules/80_optimization/lp_nlp_apr17/input.gms +++ b/modules/80_optimization/lp_nlp_apr17/input.gms @@ -10,6 +10,7 @@ scalars s80_optfile switch to use specfied solver settings (1) / 0 / s80_add_cplex add cplex optimization after conopt4 (1) / 0 / s80_add_conopt3 add conopt3 optimization after conopt4 (1) / 0 / + s80_scaleopt switch to for scaling (1=on 0=off) / 1 / ; diff --git a/modules/80_optimization/lp_nlp_apr17/solve.gms b/modules/80_optimization/lp_nlp_apr17/solve.gms index 85ec1ef813..829a984953 100644 --- a/modules/80_optimization/lp_nlp_apr17/solve.gms +++ b/modules/80_optimization/lp_nlp_apr17/solve.gms @@ -12,7 +12,7 @@ p80_modelstat(t) = 1; *** solver settings magpie.optfile = s80_optfile ; -magpie.scaleopt = 1 ; +magpie.scaleopt = s80_scaleopt ; magpie.solprint = 0 ; magpie.holdfixed = 1 ; diff --git a/modules/80_optimization/nlp_apr17/input.gms b/modules/80_optimization/nlp_apr17/input.gms index b26b854d44..c1a0df02cc 100644 --- a/modules/80_optimization/nlp_apr17/input.gms +++ b/modules/80_optimization/nlp_apr17/input.gms @@ -8,4 +8,5 @@ scalars s80_maxiter maximal solve iterations if modelstat is > 2 (1) / 10 / s80_optfile switch to use specfied solver settings (1) / 0 / + s80_scaleopt switch to for scaling (1=on 0=off) / 1 / ; diff --git a/modules/80_optimization/nlp_apr17/solve.gms b/modules/80_optimization/nlp_apr17/solve.gms index bae758fec1..bd4ecef577 100644 --- a/modules/80_optimization/nlp_apr17/solve.gms +++ b/modules/80_optimization/nlp_apr17/solve.gms @@ -14,7 +14,7 @@ s80_optfile_previter = s80_optfile; *** solver settings option nlp = conopt4; magpie.optfile = s80_optfile; -magpie.scaleopt = 1 ; +magpie.scaleopt = s80_scaleopt ; magpie.solprint = 0 ; magpie.holdfixed = 1 ; diff --git a/modules/80_optimization/nlp_par/input.gms b/modules/80_optimization/nlp_par/input.gms index eaf3fdd672..24b78e9ea7 100644 --- a/modules/80_optimization/nlp_par/input.gms +++ b/modules/80_optimization/nlp_par/input.gms @@ -8,4 +8,5 @@ scalars s80_maxiter maximal solve iterations if modelstat is > 2 (1) / 10 / s80_optfile switch to use specfied solver settings (1) / 0 / + s80_scaleopt switch to for scaling (1=on 0=off) / 1 / ; diff --git a/modules/80_optimization/nlp_par/solve.gms b/modules/80_optimization/nlp_par/solve.gms index 8b95ef6ff2..2021e8ddcd 100644 --- a/modules/80_optimization/nlp_par/solve.gms +++ b/modules/80_optimization/nlp_par/solve.gms @@ -14,7 +14,7 @@ p80_modelstat(t,h) = 14; option nlp = conopt4; magpie.solvelink = 3; magpie.optfile = s80_optfile ; -magpie.scaleopt = 1 ; +magpie.scaleopt = s80_scaleopt ; magpie.solprint = 0 ; magpie.holdfixed = 1 ; From d0c8388ba44824c575cc0017187f4b8b39d29f18 Mon Sep 17 00:00:00 2001 From: florianh Date: Mon, 29 Apr 2024 17:16:49 +0200 Subject: [PATCH 059/133] revert --- modules/35_natveg/dynamic_feb21/presolve.gms | 27 ++++++++++---------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/modules/35_natveg/dynamic_feb21/presolve.gms b/modules/35_natveg/dynamic_feb21/presolve.gms index c2ad686cbe..861236d9e5 100644 --- a/modules/35_natveg/dynamic_feb21/presolve.gms +++ b/modules/35_natveg/dynamic_feb21/presolve.gms @@ -47,19 +47,6 @@ pc35_secdforest(j,ac_sub) = pc35_secdforest(j,ac_sub) - p35_disturbance_loss_sec pcm_land(j,"primforest") = pcm_land(j,"primforest") - p35_disturbance_loss_primf(t,j); vm_land.l(j,"primforest") = pcm_land(j,"primforest"); -* -------------------------------------- -* Carbon threshold for secondary forest -* -------------------------------------- - -*' @code -*' If the vegetation carbon density in a simulation unit due to regrowth -*' exceeds a threshold of 20 tC/ha the respective area is shifted from other natural land to secondary forest. -p35_recovered_forest(t,j,ac)$(not sameas(ac,"acx")) = - pc35_other(j,ac)$(pm_carbon_density_ac(t,j,ac,"vegc") > 20); -pc35_other(j,ac) = pc35_other(j,ac) - p35_recovered_forest(t,j,ac); -pc35_secdforest(j,ac) = pc35_secdforest(j,ac) + p35_recovered_forest(t,j,ac); -*' @stop - * Regrowth of natural vegetation (natural succession) is modelled by shifting age-classes according to time step length. s35_shift = m_timestep_length_forestry/5; @@ -77,6 +64,20 @@ s35_shift = m_timestep_length_forestry/5; + sum(ac$(ord(ac) > card(ac)-s35_shift), pc35_secdforest(j,ac)); +* -------------------------------------- +* Carbon threshold for secondary forest +* -------------------------------------- + +*' @code +*' If the vegetation carbon density in a simulation unit due to regrowth +*' exceeds a threshold of 20 tC/ha the respective area is shifted from other natural land to secondary forest. +p35_recovered_forest(t,j,ac)$(not sameas(ac,"acx")) = + p35_other(t,j,ac)$(pm_carbon_density_ac(t,j,ac,"vegc") > 20); +p35_other(t,j,ac) = p35_other(t,j,ac) - p35_recovered_forest(t,j,ac); +p35_secdforest(t,j,ac) = p35_secdforest(t,j,ac) + p35_recovered_forest(t,j,ac); +*' @stop + + pc35_secdforest(j,ac) = p35_secdforest(t,j,ac); v35_secdforest.l(j,ac) = pc35_secdforest(j,ac); vm_land.l(j,"secdforest") = sum(ac, pc35_secdforest(j,ac)); From 2143ba22f2092ff17170e127847aee2ecb054d93 Mon Sep 17 00:00:00 2001 From: florianh Date: Mon, 29 Apr 2024 19:38:41 +0200 Subject: [PATCH 060/133] updates --- CHANGELOG.md | 6 +- config/default.cfg | 13 ++--- main.gms | 2 +- .../29_cropland/detail_apr24/declarations.gms | 4 ++ .../29_cropland/detail_apr24/equations.gms | 5 ++ .../29_cropland/detail_apr24/postsolve.gms | 8 +++ modules/29_cropland/detail_apr24/presolve.gms | 2 +- modules/29_cropland/detail_apr24/scaling.gms | 6 -- modules/29_cropland/detail_apr24/sets.gms | 3 - .../29_cropland/simple_apr24/declarations.gms | 12 ++++ .../29_cropland/simple_apr24/equations.gms | 19 +++++++ modules/29_cropland/simple_apr24/input.gms | 55 +++++++++++++++++++ modules/29_cropland/simple_apr24/not_used.txt | 3 - .../29_cropland/simple_apr24/postsolve.gms | 4 ++ modules/29_cropland/simple_apr24/preloop.gms | 28 +++++++++- modules/29_cropland/simple_apr24/presolve.gms | 28 ++++++++++ .../29_cropland/simple_apr24/realization.gms | 5 +- modules/29_cropland/simple_apr24/sets.gms | 6 ++ .../macceff_aug22/equations.gms | 2 + .../59_som/cellpool_aug16/declarations.gms | 3 +- modules/59_som/cellpool_aug16/equations.gms | 7 ++- modules/59_som/cellpool_aug16/preloop.gms | 3 + modules/59_som/cellpool_jan23/equations.gms | 7 ++- modules/59_som/static_jan19/equations.gms | 3 +- modules/59_som/static_jan19/not_used.txt | 2 - .../80_optimization/lp_nlp_apr17/input.gms | 1 - .../80_optimization/lp_nlp_apr17/solve.gms | 2 +- modules/80_optimization/nlp_apr17/input.gms | 1 - modules/80_optimization/nlp_apr17/solve.gms | 2 +- modules/80_optimization/nlp_par/input.gms | 1 - modules/80_optimization/nlp_par/solve.gms | 2 +- 31 files changed, 199 insertions(+), 46 deletions(-) delete mode 100644 modules/29_cropland/detail_apr24/scaling.gms diff --git a/CHANGELOG.md b/CHANGELOG.md index d2d5591367..0ff9dc5957 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,13 +9,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### changed - **29_ageclass** module 29_ageclass has been renamed to 28_ageclass to make space for `29_cropland` just before `30_croparea` - **30_crop** module `30_crop` renamed to `30_croparea`, which now only accounts for crop area. -- **30_crop** SNV implementation has been moved from `30_crop` to `29_cropland/detail_apr24` +- **30_crop** SNV implementation has been moved from `30_crop` to `29_cropland` - **30_crop** the two realizations `penalty_apr22` and `rotation_apr22` have been merged into a single `30_croparea/detail_apr24` realization - **30_crop** the previous `30_crop/endo_apr21` realization has been moved to `30_croparea/simple_apr24` -- **80_optimization** added option `s80_extra_solve`, which is deactivated by default to shorten the run time of infeasible model runs +- **default.cfg** cfg$gms$s80_maxiter reduced from 30 to 10 ### added -- **29_cropland** new module `29_cropland` accounting for crop area, fallow cropland and tree cover on cropland with two realizations: `detail_apr24` (default) and `simple_apr24`. +- **29_cropland** new module `29_cropland` accounting for crop area, fallow cropland and tree cover on cropland with two realizations: `detail_apr24` and `simple_apr24` (default). - **10_land** added interface `pm_land_hist` with historic land use patterns - **32_forestry** added technical balance term `v32_land_missing_ndc` diff --git a/config/default.cfg b/config/default.cfg index e9e5d75ce0..cdaba9e998 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -672,10 +672,10 @@ cfg$gms$ageclass <- "feb21" # def = feb21 # * Cropland is defined as the sum of croparea, fallow land and tree cover # * Croparea is provided by 30_crop. # * Fallow land and tree cover are defined by 29_cropland, -# * (simple_apr24): Fallow land is fixed to zero and tree cover on cropland does not exist, no SNV options -# * (detail_apr24): Fallow land and tree cover based on rules or incentives, SNV options included +# * (simple_apr24): Fallow land and tree cover on cropland are fixed to zero +# * (detail_apr24): Fallow land and tree cover based on rules or incentives # NOTE: It is recommended to recalibrate the model when changing this setting! -cfg$gms$cropland <- "detail_apr24" # def = detail_apr24 +cfg$gms$cropland <- "simple_apr24" # def = simple_apr24 # *** Options for all cropland realizations *** @@ -688,8 +688,6 @@ cfg$gms$cropland <- "detail_apr24" # def = detail_apr24 # * with observed cropland patterns and is recommended for productive runs. cfg$gms$c29_marginal_land <- "q33_marginal" # def = "q33_marginal" -# *** Options only available for `detail_apr24` realization *** - # * Share of available cropland that is withheld for maintaining semi-natural vegetation (SNV) # * in each square km in cropland areas, including grassland, forest and other land. For example, # * a share of 0.2 corresponds to 20 % of SNV in terms of the available cropland. @@ -717,6 +715,8 @@ cfg$gms$policy_countries29 <- all_iso_countries # * "secdforest, past, other" etc. cfg$gms$land_snv <- "secdforest, forestry, past, other" #def = "secdforest, forestry, past, other" +# *** Options only available for `detail_apr24` realization *** + # * Minimum cluster share of treecover on total cropland area (including croparea, fallow land and tree cover). # * s29_treecover_target is faded in linearly between s29_treecover_scenario_start and s29_treecover_scenario_target. cfg$gms$s29_treecover_target <- 0 # def = 0 @@ -1965,9 +1965,6 @@ cfg$gms$c80_nlp_solver <- "conopt4" # def = conopt4 # * 0: default settings (optfile will be ignored) cfg$gms$s80_optfile <- 0 # def = 0 -# switch for scaling (1=on 0=off) -cfg$gms$s80_scaleopt <- 1 # def = 1 - #*******************************END MODULE SETUP******************************** #### Other settings (e.g. clustering, gdx files, ...): #### diff --git a/main.gms b/main.gms index 939c2a3839..f6c8419d44 100644 --- a/main.gms +++ b/main.gms @@ -249,7 +249,7 @@ $setglobal land_conservation area_based_apr22 $setglobal ageclass feb21 -$setglobal cropland detail_apr24 +$setglobal cropland simple_apr24 $setglobal croparea simple_apr24 $setglobal past endo_jun13 diff --git a/modules/29_cropland/detail_apr24/declarations.gms b/modules/29_cropland/detail_apr24/declarations.gms index 386fb8b999..81699b8691 100644 --- a/modules/29_cropland/detail_apr24/declarations.gms +++ b/modules/29_cropland/detail_apr24/declarations.gms @@ -36,6 +36,7 @@ parameters positive variables vm_cost_cropland(j) Cost for total cropland (mio. USD05MER per yr) + vm_treecover(j) Cropland tree cover (mio. ha) v29_treecover(j,ac) Cropland tree cover per age class (mio. ha) v29_treecover_missing(j) Missing treecover area towards target (mio. ha) v29_cost_treecover_est(j) Establishment cost for cropland tree cover (mio. USD05MER per yr) @@ -54,6 +55,7 @@ equations q29_fallow_min(j) Missing fallow land towards target (mio. ha) q29_fallow_max(j) Maximum fallow land towards target (mio. ha) q29_fallow_bv(j,potnatveg) Biodiversity value for fallow land (mio. ha) + q29_treecover(j) Cropland tree cover (mio. ha) q29_treecover_min(j) Missing treecover area towards target (mio. ha) q29_treecover_max(j) Maximum treecover area (mio. ha) q29_treecover_bv(j,potnatveg) Biodiversity value for cropland treecover (mio. ha) @@ -65,6 +67,7 @@ equations *#################### R SECTION START (OUTPUT DECLARATIONS) #################### parameters ov_cost_cropland(t,j,type) Cost for total cropland (mio. USD05MER per yr) + ov_treecover(t,j,type) Cropland tree cover (mio. ha) ov29_treecover(t,j,ac,type) Cropland tree cover per age class (mio. ha) ov29_treecover_missing(t,j,type) Missing treecover area towards target (mio. ha) ov29_cost_treecover_est(t,j,type) Establishment cost for cropland tree cover (mio. USD05MER per yr) @@ -80,6 +83,7 @@ parameters oq29_fallow_min(t,j,type) Missing fallow land towards target (mio. ha) oq29_fallow_max(t,j,type) Maximum fallow land towards target (mio. ha) oq29_fallow_bv(t,j,potnatveg,type) Biodiversity value for fallow land (mio. ha) + oq29_treecover(t,j,type) Cropland tree cover (mio. ha) oq29_treecover_min(t,j,type) Missing treecover area towards target (mio. ha) oq29_treecover_max(t,j,type) Maximum treecover area (mio. ha) oq29_treecover_bv(t,j,potnatveg,type) Biodiversity value for cropland treecover (mio. ha) diff --git a/modules/29_cropland/detail_apr24/equations.gms b/modules/29_cropland/detail_apr24/equations.gms index 6767a341d5..b5eab82988 100644 --- a/modules/29_cropland/detail_apr24/equations.gms +++ b/modules/29_cropland/detail_apr24/equations.gms @@ -78,6 +78,11 @@ vm_fallow(j2) * fm_bii_coeff("crop_per",potnatveg) * fm_luh2_side_layers(j2,potnatveg); +*' Interface vm_treecover for other modules. + + q29_treecover(j2) .. + vm_treecover(j2) =e= sum(ac, v29_treecover(j2,ac)); + *' A penalty is applied for the violation of treecover rules. *' The penalty applies to the missing treecover area, i.e. where treecover area *' is lower than a certain fraction of total cropland. diff --git a/modules/29_cropland/detail_apr24/postsolve.gms b/modules/29_cropland/detail_apr24/postsolve.gms index 1f6b4d64e6..43d88e04c7 100644 --- a/modules/29_cropland/detail_apr24/postsolve.gms +++ b/modules/29_cropland/detail_apr24/postsolve.gms @@ -9,6 +9,7 @@ pc29_treecover(j,ac) = v29_treecover.l(j,ac); *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### ov_cost_cropland(t,j,"marginal") = vm_cost_cropland.m(j); + ov_treecover(t,j,"marginal") = vm_treecover.m(j); ov29_treecover(t,j,ac,"marginal") = v29_treecover.m(j,ac); ov29_treecover_missing(t,j,"marginal") = v29_treecover_missing.m(j); ov29_cost_treecover_est(t,j,"marginal") = v29_cost_treecover_est.m(j); @@ -24,6 +25,7 @@ pc29_treecover(j,ac) = v29_treecover.l(j,ac); oq29_fallow_min(t,j,"marginal") = q29_fallow_min.m(j); oq29_fallow_max(t,j,"marginal") = q29_fallow_max.m(j); oq29_fallow_bv(t,j,potnatveg,"marginal") = q29_fallow_bv.m(j,potnatveg); + oq29_treecover(t,j,"marginal") = q29_treecover.m(j); oq29_treecover_min(t,j,"marginal") = q29_treecover_min.m(j); oq29_treecover_max(t,j,"marginal") = q29_treecover_max.m(j); oq29_treecover_bv(t,j,potnatveg,"marginal") = q29_treecover_bv.m(j,potnatveg); @@ -31,6 +33,7 @@ pc29_treecover(j,ac) = v29_treecover.l(j,ac); oq29_cost_treecover_recur(t,j,"marginal") = q29_cost_treecover_recur.m(j); oq29_treecover_est(t,j,ac,"marginal") = q29_treecover_est.m(j,ac); ov_cost_cropland(t,j,"level") = vm_cost_cropland.l(j); + ov_treecover(t,j,"level") = vm_treecover.l(j); ov29_treecover(t,j,ac,"level") = v29_treecover.l(j,ac); ov29_treecover_missing(t,j,"level") = v29_treecover_missing.l(j); ov29_cost_treecover_est(t,j,"level") = v29_cost_treecover_est.l(j); @@ -46,6 +49,7 @@ pc29_treecover(j,ac) = v29_treecover.l(j,ac); oq29_fallow_min(t,j,"level") = q29_fallow_min.l(j); oq29_fallow_max(t,j,"level") = q29_fallow_max.l(j); oq29_fallow_bv(t,j,potnatveg,"level") = q29_fallow_bv.l(j,potnatveg); + oq29_treecover(t,j,"level") = q29_treecover.l(j); oq29_treecover_min(t,j,"level") = q29_treecover_min.l(j); oq29_treecover_max(t,j,"level") = q29_treecover_max.l(j); oq29_treecover_bv(t,j,potnatveg,"level") = q29_treecover_bv.l(j,potnatveg); @@ -53,6 +57,7 @@ pc29_treecover(j,ac) = v29_treecover.l(j,ac); oq29_cost_treecover_recur(t,j,"level") = q29_cost_treecover_recur.l(j); oq29_treecover_est(t,j,ac,"level") = q29_treecover_est.l(j,ac); ov_cost_cropland(t,j,"upper") = vm_cost_cropland.up(j); + ov_treecover(t,j,"upper") = vm_treecover.up(j); ov29_treecover(t,j,ac,"upper") = v29_treecover.up(j,ac); ov29_treecover_missing(t,j,"upper") = v29_treecover_missing.up(j); ov29_cost_treecover_est(t,j,"upper") = v29_cost_treecover_est.up(j); @@ -68,6 +73,7 @@ pc29_treecover(j,ac) = v29_treecover.l(j,ac); oq29_fallow_min(t,j,"upper") = q29_fallow_min.up(j); oq29_fallow_max(t,j,"upper") = q29_fallow_max.up(j); oq29_fallow_bv(t,j,potnatveg,"upper") = q29_fallow_bv.up(j,potnatveg); + oq29_treecover(t,j,"upper") = q29_treecover.up(j); oq29_treecover_min(t,j,"upper") = q29_treecover_min.up(j); oq29_treecover_max(t,j,"upper") = q29_treecover_max.up(j); oq29_treecover_bv(t,j,potnatveg,"upper") = q29_treecover_bv.up(j,potnatveg); @@ -75,6 +81,7 @@ pc29_treecover(j,ac) = v29_treecover.l(j,ac); oq29_cost_treecover_recur(t,j,"upper") = q29_cost_treecover_recur.up(j); oq29_treecover_est(t,j,ac,"upper") = q29_treecover_est.up(j,ac); ov_cost_cropland(t,j,"lower") = vm_cost_cropland.lo(j); + ov_treecover(t,j,"lower") = vm_treecover.lo(j); ov29_treecover(t,j,ac,"lower") = v29_treecover.lo(j,ac); ov29_treecover_missing(t,j,"lower") = v29_treecover_missing.lo(j); ov29_cost_treecover_est(t,j,"lower") = v29_cost_treecover_est.lo(j); @@ -90,6 +97,7 @@ pc29_treecover(j,ac) = v29_treecover.l(j,ac); oq29_fallow_min(t,j,"lower") = q29_fallow_min.lo(j); oq29_fallow_max(t,j,"lower") = q29_fallow_max.lo(j); oq29_fallow_bv(t,j,potnatveg,"lower") = q29_fallow_bv.lo(j,potnatveg); + oq29_treecover(t,j,"lower") = q29_treecover.lo(j); oq29_treecover_min(t,j,"lower") = q29_treecover_min.lo(j); oq29_treecover_max(t,j,"lower") = q29_treecover_max.lo(j); oq29_treecover_bv(t,j,potnatveg,"lower") = q29_treecover_bv.lo(j,potnatveg); diff --git a/modules/29_cropland/detail_apr24/presolve.gms b/modules/29_cropland/detail_apr24/presolve.gms index 54fe3c9120..39a064bbeb 100644 --- a/modules/29_cropland/detail_apr24/presolve.gms +++ b/modules/29_cropland/detail_apr24/presolve.gms @@ -23,7 +23,7 @@ p29_snv_relocation(t,j) = (i29_snv_scenario_fader(t) - i29_snv_scenario_fader(t- *' Global Land Service (@buchhorn_copernicus_2020)) and in *' cases of cropland reduction p29_max_snv_relocation(t,j) = p29_snv_shr(t,j) * (i29_snv_scenario_fader(t) - i29_snv_scenario_fader(t-1)) * pcm_land(j,"crop") - - sum(ac, pc29_treecover(j,ac)); + - vm_treecover.l(j); p29_max_snv_relocation(t,j)$(p29_max_snv_relocation(t,j) < 0) = 0; p29_snv_relocation(t,j)$(p29_snv_relocation(t, j) > p29_max_snv_relocation(t,j)) = p29_max_snv_relocation(t,j); diff --git a/modules/29_cropland/detail_apr24/scaling.gms b/modules/29_cropland/detail_apr24/scaling.gms deleted file mode 100644 index 3a209b115b..0000000000 --- a/modules/29_cropland/detail_apr24/scaling.gms +++ /dev/null @@ -1,6 +0,0 @@ -*** | (C) 2008-2024 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 diff --git a/modules/29_cropland/detail_apr24/sets.gms b/modules/29_cropland/detail_apr24/sets.gms index ce67e81d5a..e5d8286326 100644 --- a/modules/29_cropland/detail_apr24/sets.gms +++ b/modules/29_cropland/detail_apr24/sets.gms @@ -16,7 +16,4 @@ sets relocation_target29 Cropland requiring relocation based on different SNV targets / SNV20TargetCropland, SNV50TargetCropland / - fallow29 fallow rules - / fallow20, fallow80 / - ; diff --git a/modules/29_cropland/simple_apr24/declarations.gms b/modules/29_cropland/simple_apr24/declarations.gms index c63daf0be8..1f02098fb4 100644 --- a/modules/29_cropland/simple_apr24/declarations.gms +++ b/modules/29_cropland/simple_apr24/declarations.gms @@ -7,23 +7,35 @@ parameters p29_avl_cropland(t,j) Total available land for crop cultivation (mio. ha) + p29_country_snv_weight(i) SNV policy country weight per region (1) + p29_snv_shr(t,j) Share of semi-natural vegetation in cropland areas (1) + i29_snv_relocation_target(j) Overall cropland area that requires relocation due to SNV policy (mio. ha) + p29_snv_relocation(t,j) Cropland area that is actually relocated during time step (mio. ha) + p29_max_snv_relocation(t,j) Maximum cropland relocation during time step (mio. ha) + p29_country_dummy(iso) Dummy parameter indicating whether country is affected by selected cropland policy (1) + i29_avl_cropland_iso(iso) Available land area for cropland at ISO level (mio. ha) + i29_snv_scenario_fader(t_all) SNV scenario fader (1) ; positive variables vm_cost_cropland(j) Cost for total cropland (mio. USD05MER per yr) vm_fallow(j) Fallow land is temporarily fallow cropland (mio. ha) + vm_treecover(j) Cropland tree cover (mio. ha) ; equations q29_cropland(j) Total cropland calculation (mio. ha) q29_avl_cropland(j) Available cropland constraint (mio. ha) q29_carbon(j,ag_pools,stockType) Cropland above ground carbon content calculation (mio. tC) + q29_land_snv(j) Land constraint for the SNV policy in cropland areas (mio. ha) + q29_land_snv_trans(j) Land transition constraint for SNV policy in cropland areas (mio. ha) ; *#################### R SECTION START (OUTPUT DECLARATIONS) #################### parameters ov_cost_cropland(t,j,type) Cost for total cropland (mio. USD05MER per yr) ov_fallow(t,j,type) Fallow land is temporarily fallow cropland (mio. ha) + ov_treecover(t,j,type) Cropland tree cover (mio. ha) oq29_cropland(t,j,type) Total cropland calculation (mio. ha) oq29_avl_cropland(t,j,type) Available cropland constraint (mio. ha) oq29_carbon(t,j,ag_pools,stockType,type) Cropland above ground carbon content calculation (mio. tC) diff --git a/modules/29_cropland/simple_apr24/equations.gms b/modules/29_cropland/simple_apr24/equations.gms index a5cd2a0dd2..376cf3e2c8 100644 --- a/modules/29_cropland/simple_apr24/equations.gms +++ b/modules/29_cropland/simple_apr24/equations.gms @@ -12,6 +12,7 @@ q29_cropland(j2) .. vm_land(j2,"crop") =e= sum((kcr,w), vm_area(j2,kcr,w)); + *' We assume that crop production can only take place on suitable cropland area. *' We use a suitability index (SI) map from @zabel_global_2014 to exclude areas *' from cropland production that have a low suitability, e.g. due to steep slopes, @@ -28,3 +29,21 @@ q29_carbon(j2,ag_pools,stockType) .. vm_carbon_stock(j2,"crop",ag_pools,stockType) =e= vm_carbon_stock_croparea(j2,ag_pools); + + +*' The semi-natural land constraint in cropland areas for sustaining critical regulating NCP +*' for agricultural production is added on top of land conserved for other reasons +*' (e.g. conservation of intact ecosystems or protection of biodiversity hotspots). + + q29_land_snv(j2) .. + sum(land_snv, vm_land(j2,land_snv)) =g= + sum(ct, p29_snv_shr(ct,j2)) * vm_land(j2,"crop") + + sum((ct,land_snv,consv_type), pm_land_conservation(ct,j2,land_snv,consv_type)); + +*' The semi-natural vegetation constraint for cropland areas has been suggested at the per square +*' kilometer scale. The amount of cropland requiring relocation has therefore been derived from +*' exogeneous high-resolution land cover information from the Copernicus Global Land Service +*' (@buchhorn_copernicus_2020). + + q29_land_snv_trans(j2) .. + sum(land_snv, vm_lu_transitions(j2,"crop",land_snv)) =g= sum(ct, p29_snv_relocation(ct,j2)); diff --git a/modules/29_cropland/simple_apr24/input.gms b/modules/29_cropland/simple_apr24/input.gms index 8780993d11..eb33c95ec9 100644 --- a/modules/29_cropland/simple_apr24/input.gms +++ b/modules/29_cropland/simple_apr24/input.gms @@ -8,6 +8,47 @@ $setglobal c29_marginal_land q33_marginal * options: all_marginal, q33_marginal, no_marginal +scalars + s29_snv_shr Share of available cropland that is witheld for other land cover types (1) / 0 / + s29_snv_shr_noselect Share of available cropland that is witheld for other land cover types (1) / 0 / + s29_snv_scenario_start SNV scenario start year / 2020 / + s29_snv_scenario_target SNV scenario target year / 2029 / + s29_snv_relocation_data_x1 First reference value in SNV target cropland data (1) / 0.2 / + s29_snv_relocation_data_x2 Second reference value in SNV target cropland data (1) / 0.5 / +; + +* Set-switch for countries affected by regional SNV policy +* Default: all iso countries selected +sets + policy_countries29(iso) countries to be affected by SNV policy / ABW,AFG,AGO,AIA,ALA,ALB,AND,ARE,ARG,ARM, + ASM,ATA,ATF,ATG,AUS,AUT,AZE,BDI,BEL,BEN, + BES,BFA,BGD,BGR,BHR,BHS,BIH,BLM,BLR,BLZ, + BMU,BOL,BRA,BRB,BRN,BTN,BVT,BWA,CAF,CAN, + CCK,CHN,CHE,CHL,CIV,CMR,COD,COG,COK,COL, + COM,CPV,CRI,CUB,CUW,CXR,CYM,CYP,CZE,DEU, + DJI,DMA,DNK,DOM,DZA,ECU,EGY,ERI,ESH,ESP, + EST,ETH,FIN,FJI,FLK,FRA,FRO,FSM,GAB,GBR, + GEO,GGY,GHA,GIB,GIN,GLP,GMB,GNB,GNQ,GRC, + GRD,GRL,GTM,GUF,GUM,GUY,HKG,HMD,HND,HRV, + HTI,HUN,IDN,IMN,IND,IOT,IRL,IRN,IRQ,ISL, + ISR,ITA,JAM,JEY,JOR,JPN,KAZ,KEN,KGZ,KHM, + KIR,KNA,KOR,KWT,LAO,LBN,LBR,LBY,LCA,LIE, + LKA,LSO,LTU,LUX,LVA,MAC,MAF,MAR,MCO,MDA, + MDG,MDV,MEX,MHL,MKD,MLI,MLT,MMR,MNE,MNG, + MNP,MOZ,MRT,MSR,MTQ,MUS,MWI,MYS,MYT,NAM, + NCL,NER,NFK,NGA,NIC,NIU,NLD,NOR,NPL,NRU, + NZL,OMN,PAK,PAN,PCN,PER,PHL,PLW,PNG,POL, + PRI,PRK,PRT,PRY,PSE,PYF,QAT,REU,ROU,RUS, + RWA,SAU,SDN,SEN,SGP,SGS,SHN,SJM,SLB,SLE, + SLV,SMR,SOM,SPM,SRB,SSD,STP,SUR,SVK,SVN, + SWE,SWZ,SXM,SYC,SYR,TCA,TCD,TGO,THA,TJK, + TKL,TKM,TLS,TON,TTO,TUN,TUR,TUV,TWN,TZA, + UGA,UKR,UMI,URY,USA,UZB,VAT,VCT,VEN,VGB, + VIR,VNM,VUT,WLF,WSM,YEM,ZAF,ZMB,ZWE / + +land_snv(land) land types allowed in the SNV policy / secdforest, forestry, past, other / +; + ********* AVAILABLE CROPLAND ******************************************* table f29_avl_cropland(j,marginal_land29) Available land area for cropland (mio. ha) @@ -15,3 +56,17 @@ $ondelim $include "./modules/29_cropland/input/avl_cropland.cs3" $offdelim ; + +table f29_avl_cropland_iso(iso,marginal_land29) Available land area for cropland at ISO level (mio. ha) +$ondelim +$include "./modules/29_cropland/input/avl_cropland_iso.cs3" +$offdelim +; + +********* SNV TARGET CROPLAND ******************************************* + +table f29_snv_target_cropland(j,relocation_target29) Cropland in 2019 requiring relocation due to SNV policy (mio. ha) +$ondelim +$include "./modules/29_cropland/input/SNVTargetCropland.cs3" +$offdelim +; diff --git a/modules/29_cropland/simple_apr24/not_used.txt b/modules/29_cropland/simple_apr24/not_used.txt index 6102fa8d55..a60069f62b 100644 --- a/modules/29_cropland/simple_apr24/not_used.txt +++ b/modules/29_cropland/simple_apr24/not_used.txt @@ -1,10 +1,7 @@ name,type,reason -vm_lu_transitions,input,not needed pm_land_hist,input,not needed -pcm_land,input,not needed fm_luh2_side_layers,input,not needed pm_interest,input,not needed -pm_land_conservation,input,not needed fm_bii_coeff,input,not needed pm_carbon_density_ac,input,not needed pm_carbon_density_ac_forestry,input,not needed diff --git a/modules/29_cropland/simple_apr24/postsolve.gms b/modules/29_cropland/simple_apr24/postsolve.gms index 3a389fbe97..aaa4624b50 100644 --- a/modules/29_cropland/simple_apr24/postsolve.gms +++ b/modules/29_cropland/simple_apr24/postsolve.gms @@ -8,21 +8,25 @@ *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### ov_cost_cropland(t,j,"marginal") = vm_cost_cropland.m(j); ov_fallow(t,j,"marginal") = vm_fallow.m(j); + ov_treecover(t,j,"marginal") = vm_treecover.m(j); oq29_cropland(t,j,"marginal") = q29_cropland.m(j); oq29_avl_cropland(t,j,"marginal") = q29_avl_cropland.m(j); oq29_carbon(t,j,ag_pools,stockType,"marginal") = q29_carbon.m(j,ag_pools,stockType); ov_cost_cropland(t,j,"level") = vm_cost_cropland.l(j); ov_fallow(t,j,"level") = vm_fallow.l(j); + ov_treecover(t,j,"level") = vm_treecover.l(j); oq29_cropland(t,j,"level") = q29_cropland.l(j); oq29_avl_cropland(t,j,"level") = q29_avl_cropland.l(j); oq29_carbon(t,j,ag_pools,stockType,"level") = q29_carbon.l(j,ag_pools,stockType); ov_cost_cropland(t,j,"upper") = vm_cost_cropland.up(j); ov_fallow(t,j,"upper") = vm_fallow.up(j); + ov_treecover(t,j,"upper") = vm_treecover.up(j); oq29_cropland(t,j,"upper") = q29_cropland.up(j); oq29_avl_cropland(t,j,"upper") = q29_avl_cropland.up(j); oq29_carbon(t,j,ag_pools,stockType,"upper") = q29_carbon.up(j,ag_pools,stockType); ov_cost_cropland(t,j,"lower") = vm_cost_cropland.lo(j); ov_fallow(t,j,"lower") = vm_fallow.lo(j); + ov_treecover(t,j,"lower") = vm_treecover.lo(j); oq29_cropland(t,j,"lower") = q29_cropland.lo(j); oq29_avl_cropland(t,j,"lower") = q29_avl_cropland.lo(j); oq29_carbon(t,j,ag_pools,stockType,"lower") = q29_carbon.lo(j,ag_pools,stockType); diff --git a/modules/29_cropland/simple_apr24/preloop.gms b/modules/29_cropland/simple_apr24/preloop.gms index 9ac96ee8aa..3113ccb053 100644 --- a/modules/29_cropland/simple_apr24/preloop.gms +++ b/modules/29_cropland/simple_apr24/preloop.gms @@ -7,8 +7,32 @@ vm_cost_cropland.fx(j) = 0; vm_fallow.fx(j) = 0; +vm_treecover.fx(j) = 0; vm_bv.fx(j,"crop_fallow",potnatveg) = 0; vm_bv.fx(j,"crop_tree",potnatveg) = 0; -*' Area potentially available for cropping -p29_avl_cropland(t,j) = f29_avl_cropland(j,"%c29_marginal_land%"); +** Trajectory for cropland scenarios +* sigmoidal interpolation between start year and target year +m_sigmoid_time_interpol(i29_snv_scenario_fader,s29_snv_scenario_start,s29_snv_scenario_target,0,1); + +* linear interpolation to estimate the cropland that +* requires relocation due to SNV policy +if (s29_snv_shr = 0, + i29_snv_relocation_target(j) = 0; +elseif s29_snv_shr <= s29_snv_relocation_data_x1, + m_linear_cell_data_interpol(i29_snv_relocation_target, s29_snv_shr,0,s29_snv_relocation_data_x1,0, f29_snv_target_cropland(j, "SNV20TargetCropland")); +elseif s29_snv_shr > s29_snv_relocation_data_x1, + m_linear_cell_data_interpol(i29_snv_relocation_target, s29_snv_shr,s29_snv_relocation_data_x1, s29_snv_relocation_data_x2,f29_snv_target_cropland(j, "SNV20TargetCropland"), f29_snv_target_cropland(j, "SNV50TargetCropland")); +); + +****** Regional share of semi-natural vegetation (SNV) in cropland areas for selective countries: +* Country switch to determine countries for which a SNV policy shall be applied. +* In the default case, the SNV policy affects all countries when activated. +p29_country_dummy(iso) = 0; +p29_country_dummy(policy_countries29) = 1; +* Because MAgPIE is not run at country-level, but at region level, a region +* share is calculated that translates the countries' influence to regional level. +* Countries are weighted by available cropland area. +i29_avl_cropland_iso(iso) = f29_avl_cropland_iso(iso,"%c29_marginal_land%"); +p29_country_snv_weight(i) = sum(i_to_iso(i,iso), p29_country_dummy(iso) * i29_avl_cropland_iso(iso)) / sum(i_to_iso(i,iso), i29_avl_cropland_iso(iso)); + diff --git a/modules/29_cropland/simple_apr24/presolve.gms b/modules/29_cropland/simple_apr24/presolve.gms index ae47145544..cebdb11b33 100644 --- a/modules/29_cropland/simple_apr24/presolve.gms +++ b/modules/29_cropland/simple_apr24/presolve.gms @@ -4,3 +4,31 @@ *** | 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 + + +*' @code +*' Minimum semi-natural vegetation (SNV) share is fading in after 2020 +p29_snv_shr(t,j) = i29_snv_scenario_fader(t) * + (s29_snv_shr * sum(cell(i,j), p29_country_snv_weight(i)) + + s29_snv_shr_noselect * sum(cell(i,j), 1-p29_country_snv_weight(i))); + +*' Cropland relocation in response to SNV policy is based on exogeneous land +*' cover information from the Copernicus Global Land Service (@buchhorn_copernicus_2020). +*' The rate of the policy implementation is derived based +*' on the difference of scenario fader values in consecutive time steps +p29_snv_relocation(t,j) = (i29_snv_scenario_fader(t) - i29_snv_scenario_fader(t-1)) * + (i29_snv_relocation_target(j) * sum(cell(i,j), p29_country_snv_weight(i)) + + s29_snv_shr_noselect * sum(cell(i,j), 1-p29_country_snv_weight(i))); +*' The following lines take care of mismatches in the input +*' data (derived from satellite imagery from the Copernicus +*' Global Land Service (@buchhorn_copernicus_2020)) and in +*' cases of cropland reduction +p29_max_snv_relocation(t,j) = p29_snv_shr(t,j) * (i29_snv_scenario_fader(t) - i29_snv_scenario_fader(t-1)) * pcm_land(j,"crop") + - vm_treecover.l(j); +p29_max_snv_relocation(t,j)$(p29_max_snv_relocation(t,j) < 0) = 0; +p29_snv_relocation(t,j)$(p29_snv_relocation(t, j) > p29_max_snv_relocation(t,j)) = p29_max_snv_relocation(t,j); + +*' Area potentially available for cropping +p29_avl_cropland(t,j) = f29_avl_cropland(j,"%c29_marginal_land%") * (1 - p29_snv_shr(t,j)); +*' @stop + diff --git a/modules/29_cropland/simple_apr24/realization.gms b/modules/29_cropland/simple_apr24/realization.gms index 7abf5c89fa..3257388faa 100644 --- a/modules/29_cropland/simple_apr24/realization.gms +++ b/modules/29_cropland/simple_apr24/realization.gms @@ -6,13 +6,12 @@ *** | Contact: magpie@pik-potsdam.de *' @description In this realization, total cropland equals croparea because -*' fallow land is fixed to zero and tree cover on cropland does not exist. +*' fallow land and tree cover on cropland are fixed to zero. *' Therefore, also cropland carbon stocks consist only of croparea carbon stocks. *' Biodiversity BII values are fixed to zero. *' Costs are fixed to zero. -*' No options for semi-natural land in cropland landscapes exist. -*' @limitations Fallow land is fixed to zero and tree cover on cropland does not exist +*' @limitations Fallow land and tree cover on cropland are fixed to zero *####################### R SECTION START (PHASES) ############################## $Ifi "%phase%" == "sets" $include "./modules/29_cropland/simple_apr24/sets.gms" diff --git a/modules/29_cropland/simple_apr24/sets.gms b/modules/29_cropland/simple_apr24/sets.gms index 6c56fcb13d..e5d8286326 100644 --- a/modules/29_cropland/simple_apr24/sets.gms +++ b/modules/29_cropland/simple_apr24/sets.gms @@ -10,4 +10,10 @@ sets marginal_land29 Marginal land scenarios / all_marginal, q33_marginal, no_marginal / + policy_target29 Target year for cropland policy + / none, by2029, by2050 / + + relocation_target29 Cropland requiring relocation based on different SNV targets + / SNV20TargetCropland, SNV50TargetCropland / + ; diff --git a/modules/50_nr_soil_budget/macceff_aug22/equations.gms b/modules/50_nr_soil_budget/macceff_aug22/equations.gms index b6993d4f3d..f292521c1b 100644 --- a/modules/50_nr_soil_budget/macceff_aug22/equations.gms +++ b/modules/50_nr_soil_budget/macceff_aug22/equations.gms @@ -24,6 +24,8 @@ q50_nr_inputs(i2) .. vm_res_recycling(i2,"nr") + sum((cell(i2,j2),kcr,w), vm_area(j2,kcr,w) * f50_nr_fix_area(kcr)) + sum(cell(i2,j2),vm_fallow(j2) * f50_nr_fix_area("tece")) +* Commented out for consistency with q50_nr_surplus_nonagland +* + sum(cell(i2,j2),vm_treecover(j2)) * sum(ct,f50_nr_fixation_rates_nonagland(ct,i2)) + vm_manure_recycling(i2,"nr") + sum(kli, vm_manure(i2, kli, "stubble_grazing","nr")) + vm_nr_inorg_fert_reg(i2,"crop") diff --git a/modules/59_som/cellpool_aug16/declarations.gms b/modules/59_som/cellpool_aug16/declarations.gms index 46831d6429..80e3155d46 100644 --- a/modules/59_som/cellpool_aug16/declarations.gms +++ b/modules/59_som/cellpool_aug16/declarations.gms @@ -12,7 +12,8 @@ parameters i59_input_share(i,inputs59) Share of land under input class (1) i59_cratio(j,kcr,w) Ratio of carbon density of land relative to natural vegetaion (1) i59_cratio_fallow(j) Ratio of carbon density of fallow land relative to natural vegetation (1) - p59_som_pool(j,land) Actual C pool (mio. tC) + i59_cratio_treecover Ratio of carbon density of tree cover on cropland relative to natural vegetation (1) + p59_som_pool(j,land) Actual C pool (mio. tC) i59_subsoilc_density(t_all,j) Subsoil carbon density of a hectare of land (tC per ha) p59_land_before(j,land) Land area in previous time step (mio. ha) ; diff --git a/modules/59_som/cellpool_aug16/equations.gms b/modules/59_som/cellpool_aug16/equations.gms index ddf8108683..376aa9fe47 100644 --- a/modules/59_som/cellpool_aug16/equations.gms +++ b/modules/59_som/cellpool_aug16/equations.gms @@ -13,9 +13,10 @@ q59_som_target_cropland(j2) .. v59_som_target(j2,"crop") =e= (sum((kcr,w), vm_area(j2,kcr,w) * i59_cratio(j2,kcr,w)) - + vm_fallow(j2) * i59_cratio_fallow(j2)) * - sum(ct,f59_topsoilc_density(ct,j2)) - ; + + vm_fallow(j2) * i59_cratio_fallow(j2) + + vm_treecover(j2) * i59_cratio_treecover) + * sum(ct,f59_topsoilc_density(ct,j2)); + *' as well as for all non cropland given by q59_som_target_noncropland(j2,noncropland59) .. diff --git a/modules/59_som/cellpool_aug16/preloop.gms b/modules/59_som/cellpool_aug16/preloop.gms index b75a85f126..41fc1b9447 100644 --- a/modules/59_som/cellpool_aug16/preloop.gms +++ b/modules/59_som/cellpool_aug16/preloop.gms @@ -73,6 +73,9 @@ i59_cratio_fallow(j) = sum(climate59, * f59_cratio_landuse(climate59,"maiz") * f59_cratio_tillage(climate59,"reduced_tillage") * f59_cratio_inputs(climate59,"low_input")); + +i59_cratio_treecover = 1; + *' @stop p59_carbon_density(t,j,land) = 0; diff --git a/modules/59_som/cellpool_jan23/equations.gms b/modules/59_som/cellpool_jan23/equations.gms index ddf8108683..376aa9fe47 100644 --- a/modules/59_som/cellpool_jan23/equations.gms +++ b/modules/59_som/cellpool_jan23/equations.gms @@ -13,9 +13,10 @@ q59_som_target_cropland(j2) .. v59_som_target(j2,"crop") =e= (sum((kcr,w), vm_area(j2,kcr,w) * i59_cratio(j2,kcr,w)) - + vm_fallow(j2) * i59_cratio_fallow(j2)) * - sum(ct,f59_topsoilc_density(ct,j2)) - ; + + vm_fallow(j2) * i59_cratio_fallow(j2) + + vm_treecover(j2) * i59_cratio_treecover) + * sum(ct,f59_topsoilc_density(ct,j2)); + *' as well as for all non cropland given by q59_som_target_noncropland(j2,noncropland59) .. diff --git a/modules/59_som/static_jan19/equations.gms b/modules/59_som/static_jan19/equations.gms index ce63cccdb9..4bc852de30 100644 --- a/modules/59_som/static_jan19/equations.gms +++ b/modules/59_som/static_jan19/equations.gms @@ -10,7 +10,8 @@ *' and the reference soil carbon densities of the subsoil. q59_soilcarbon_cropland(j2,stockType) .. vm_carbon_stock(j2,"crop","soilc",stockType) =e= - vm_land(j2,"crop") * sum(ct, i59_topsoilc_density(ct,j2) + i59_subsoilc_density(ct,j2)); + (sum((kcr,w), vm_area(j2,kcr,w)) + vm_fallow(j2)) * sum(ct, i59_topsoilc_density(ct,j2) + i59_subsoilc_density(ct,j2)) + + vm_treecover(j2) * sum(ct, fm_carbon_density(ct,j2,"secdforest","soilc")); *' The soil carbon content for all other land use types is calculated based on the full profile soil carbon density: q59_soilcarbon_noncropland(j2,noncropland59,stockType) .. diff --git a/modules/59_som/static_jan19/not_used.txt b/modules/59_som/static_jan19/not_used.txt index 9bd4f91711..22a291399b 100644 --- a/modules/59_som/static_jan19/not_used.txt +++ b/modules/59_som/static_jan19/not_used.txt @@ -1,8 +1,6 @@ name,type,reason pm_land_start,input,questionnaire fm_croparea,input,questionnaire -vm_area,input,questionnaire vm_landexpansion,input,questionnaire vm_lu_transitions,input,questionnaire pm_climate_class,input,questionnaire -vm_fallow,input,questionnaire diff --git a/modules/80_optimization/lp_nlp_apr17/input.gms b/modules/80_optimization/lp_nlp_apr17/input.gms index cd820db042..83427b7cfe 100644 --- a/modules/80_optimization/lp_nlp_apr17/input.gms +++ b/modules/80_optimization/lp_nlp_apr17/input.gms @@ -10,7 +10,6 @@ scalars s80_optfile switch to use specfied solver settings (1) / 0 / s80_add_cplex add cplex optimization after conopt4 (1) / 0 / s80_add_conopt3 add conopt3 optimization after conopt4 (1) / 0 / - s80_scaleopt switch to for scaling (1=on 0=off) / 1 / ; diff --git a/modules/80_optimization/lp_nlp_apr17/solve.gms b/modules/80_optimization/lp_nlp_apr17/solve.gms index 829a984953..85ec1ef813 100644 --- a/modules/80_optimization/lp_nlp_apr17/solve.gms +++ b/modules/80_optimization/lp_nlp_apr17/solve.gms @@ -12,7 +12,7 @@ p80_modelstat(t) = 1; *** solver settings magpie.optfile = s80_optfile ; -magpie.scaleopt = s80_scaleopt ; +magpie.scaleopt = 1 ; magpie.solprint = 0 ; magpie.holdfixed = 1 ; diff --git a/modules/80_optimization/nlp_apr17/input.gms b/modules/80_optimization/nlp_apr17/input.gms index c1a0df02cc..b26b854d44 100644 --- a/modules/80_optimization/nlp_apr17/input.gms +++ b/modules/80_optimization/nlp_apr17/input.gms @@ -8,5 +8,4 @@ scalars s80_maxiter maximal solve iterations if modelstat is > 2 (1) / 10 / s80_optfile switch to use specfied solver settings (1) / 0 / - s80_scaleopt switch to for scaling (1=on 0=off) / 1 / ; diff --git a/modules/80_optimization/nlp_apr17/solve.gms b/modules/80_optimization/nlp_apr17/solve.gms index bd4ecef577..bae758fec1 100644 --- a/modules/80_optimization/nlp_apr17/solve.gms +++ b/modules/80_optimization/nlp_apr17/solve.gms @@ -14,7 +14,7 @@ s80_optfile_previter = s80_optfile; *** solver settings option nlp = conopt4; magpie.optfile = s80_optfile; -magpie.scaleopt = s80_scaleopt ; +magpie.scaleopt = 1 ; magpie.solprint = 0 ; magpie.holdfixed = 1 ; diff --git a/modules/80_optimization/nlp_par/input.gms b/modules/80_optimization/nlp_par/input.gms index 24b78e9ea7..eaf3fdd672 100644 --- a/modules/80_optimization/nlp_par/input.gms +++ b/modules/80_optimization/nlp_par/input.gms @@ -8,5 +8,4 @@ scalars s80_maxiter maximal solve iterations if modelstat is > 2 (1) / 10 / s80_optfile switch to use specfied solver settings (1) / 0 / - s80_scaleopt switch to for scaling (1=on 0=off) / 1 / ; diff --git a/modules/80_optimization/nlp_par/solve.gms b/modules/80_optimization/nlp_par/solve.gms index 2021e8ddcd..8b95ef6ff2 100644 --- a/modules/80_optimization/nlp_par/solve.gms +++ b/modules/80_optimization/nlp_par/solve.gms @@ -14,7 +14,7 @@ p80_modelstat(t,h) = 14; option nlp = conopt4; magpie.solvelink = 3; magpie.optfile = s80_optfile ; -magpie.scaleopt = s80_scaleopt ; +magpie.scaleopt = 1 ; magpie.solprint = 0 ; magpie.holdfixed = 1 ; From 0b74f687e0a63adba30e83f9f14f415820e29953 Mon Sep 17 00:00:00 2001 From: florianh Date: Mon, 29 Apr 2024 19:46:38 +0200 Subject: [PATCH 061/133] lines --- modules/35_natveg/dynamic_feb21/presolve.gms | 3 --- 1 file changed, 3 deletions(-) diff --git a/modules/35_natveg/dynamic_feb21/presolve.gms b/modules/35_natveg/dynamic_feb21/presolve.gms index 861236d9e5..9e757cbe3b 100644 --- a/modules/35_natveg/dynamic_feb21/presolve.gms +++ b/modules/35_natveg/dynamic_feb21/presolve.gms @@ -47,7 +47,6 @@ pc35_secdforest(j,ac_sub) = pc35_secdforest(j,ac_sub) - p35_disturbance_loss_sec pcm_land(j,"primforest") = pcm_land(j,"primforest") - p35_disturbance_loss_primf(t,j); vm_land.l(j,"primforest") = pcm_land(j,"primforest"); - * Regrowth of natural vegetation (natural succession) is modelled by shifting age-classes according to time step length. s35_shift = m_timestep_length_forestry/5; * example: ac10 in t = ac5 (ac10-1) in t-1 for a 5 yr time step (s35_shift = 1) @@ -63,7 +62,6 @@ s35_shift = m_timestep_length_forestry/5; p35_secdforest(t,j,"acx") = p35_secdforest(t,j,"acx") + sum(ac$(ord(ac) > card(ac)-s35_shift), pc35_secdforest(j,ac)); - * -------------------------------------- * Carbon threshold for secondary forest * -------------------------------------- @@ -77,7 +75,6 @@ p35_other(t,j,ac) = p35_other(t,j,ac) - p35_recovered_forest(t,j,ac); p35_secdforest(t,j,ac) = p35_secdforest(t,j,ac) + p35_recovered_forest(t,j,ac); *' @stop - pc35_secdforest(j,ac) = p35_secdforest(t,j,ac); v35_secdforest.l(j,ac) = pc35_secdforest(j,ac); vm_land.l(j,"secdforest") = sum(ac, pc35_secdforest(j,ac)); From 8d3df52dd0e71cb87f345dc26ff5cad3807040f5 Mon Sep 17 00:00:00 2001 From: florianh Date: Mon, 29 Apr 2024 23:18:38 +0200 Subject: [PATCH 062/133] bugfix --- .../80_optimization/nlp_par/declarations.gms | 2 +- modules/80_optimization/nlp_par/solve.gms | 23 +++++++++++-------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/modules/80_optimization/nlp_par/declarations.gms b/modules/80_optimization/nlp_par/declarations.gms index 1cbf6971aa..ef24019753 100644 --- a/modules/80_optimization/nlp_par/declarations.gms +++ b/modules/80_optimization/nlp_par/declarations.gms @@ -9,7 +9,7 @@ parameters p80_modelstat(t,h) modelstat indicator (1) p80_counter(h) counter (1) p80_handle(h) parallel mode handle parameter (1) - p80_resolve(h) indicator for restarting solve (1) + p80_extra_solve(h) indicator for extra solve (1) ; scalars diff --git a/modules/80_optimization/nlp_par/solve.gms b/modules/80_optimization/nlp_par/solve.gms index 8b95ef6ff2..5bb8d12579 100644 --- a/modules/80_optimization/nlp_par/solve.gms +++ b/modules/80_optimization/nlp_par/solve.gms @@ -39,7 +39,6 @@ loop(h, i2(i)$supreg(h,i) = yes; loop(i2, j2(j)$cell(i2,j) = yes); solve magpie USING nlp MINIMIZING vm_cost_glo; - solve magpie USING nlp MINIMIZING vm_cost_glo; h2(h) = no; i2(i) = no; j2(j) = no; @@ -51,7 +50,7 @@ repeat loop(h$p80_handle(h), if(handleStatus(p80_handle(h)) = 2, p80_counter(h) = p80_counter(h) + 1; - p80_resolve(h) = 1; + p80_extra_solve(h) = 1; magpie.handle = p80_handle(h); execute_loadhandle magpie; @@ -75,34 +74,38 @@ repeat option AsyncSolLst=1; display$handlecollect(p80_handle(h)) 're-collect'; option AsyncSolLst=0; - p80_resolve(h) = 0; + p80_extra_solve(h) = 0; ); display$handledelete(p80_handle(h)) 'trouble deleting handles' ; if (p80_modelstat(t,h) <= 2, - display "Model status <= 2. Handle cleared."; - p80_resolve(h) = 0; - p80_handle(h) = 0; + if (p80_counter(h) < 2, + display "Model status <= 2. Starting second solve"; + solve magpie USING nlp MINIMIZING vm_cost_glo; + p80_handle(h) = magpie.handle; + p80_extra_solve(h) = 0; + else + display "Model status <= 2. Handle cleared."; + p80_extra_solve(h) = 0; + p80_handle(h) = 0; + ); ); - if (p80_resolve(h) = 1, + if (p80_extra_solve(h) = 1, display "Resolve" if (p80_modelstat(t,h) ne s80_modelstat_previter, display "Modelstat > 2 | Retry solve with CONOPT4 default setting"; solve magpie USING nlp MINIMIZING vm_cost_glo; - solve magpie USING nlp MINIMIZING vm_cost_glo; elseif p80_modelstat(t,h) = s80_modelstat_previter, if(magpie.optfile = s80_optfile_previter, display "Modelstat > 2 | Retry solve without CONOPT4 pre-processing"; magpie.optfile = 2; solve magpie USING nlp MINIMIZING vm_cost_glo; - solve magpie USING nlp MINIMIZING vm_cost_glo; else display "Modelstat > 2 | Retry solve with CONOPT3"; option nlp = conopt; solve magpie USING nlp MINIMIZING vm_cost_glo; - solve magpie USING nlp MINIMIZING vm_cost_glo; option nlp = conopt4; ); ); From b4064984ae9bec49a96e95ed8045b0ff894fc5fd Mon Sep 17 00:00:00 2001 From: florianh Date: Mon, 29 Apr 2024 23:40:22 +0200 Subject: [PATCH 063/133] bugfix --- modules/80_optimization/nlp_par/declarations.gms | 1 + modules/80_optimization/nlp_par/solve.gms | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/80_optimization/nlp_par/declarations.gms b/modules/80_optimization/nlp_par/declarations.gms index ef24019753..b375d607e3 100644 --- a/modules/80_optimization/nlp_par/declarations.gms +++ b/modules/80_optimization/nlp_par/declarations.gms @@ -10,6 +10,7 @@ parameters p80_counter(h) counter (1) p80_handle(h) parallel mode handle parameter (1) p80_extra_solve(h) indicator for extra solve (1) + p80_counter_modelstat(h) counter for modelstat <= 2 (1) ; scalars diff --git a/modules/80_optimization/nlp_par/solve.gms b/modules/80_optimization/nlp_par/solve.gms index 5bb8d12579..8c7e9d5a1d 100644 --- a/modules/80_optimization/nlp_par/solve.gms +++ b/modules/80_optimization/nlp_par/solve.gms @@ -8,6 +8,7 @@ p80_counter(h) = 0; p80_modelstat(t,h) = 14; +p80_counter_modelstat(h) = 0; *** solver settings @@ -80,7 +81,8 @@ repeat display$handledelete(p80_handle(h)) 'trouble deleting handles' ; if (p80_modelstat(t,h) <= 2, - if (p80_counter(h) < 2, + p80_counter_modelstat(h) = p80_counter_modelstat(h) + 1; + if (p80_counter_modelstat(h) < 2, display "Model status <= 2. Starting second solve"; solve magpie USING nlp MINIMIZING vm_cost_glo; p80_handle(h) = magpie.handle; From 29ec05ac46b0136624650de91caa52660f8d9314 Mon Sep 17 00:00:00 2001 From: florianh Date: Tue, 30 Apr 2024 10:32:06 +0200 Subject: [PATCH 064/133] bugfix --- modules/29_cropland/detail_apr24/realization.gms | 1 - modules/29_cropland/simple_apr24/declarations.gms | 2 ++ modules/29_cropland/simple_apr24/postsolve.gms | 8 ++++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/29_cropland/detail_apr24/realization.gms b/modules/29_cropland/detail_apr24/realization.gms index c9b62fec84..071000bd1e 100644 --- a/modules/29_cropland/detail_apr24/realization.gms +++ b/modules/29_cropland/detail_apr24/realization.gms @@ -25,7 +25,6 @@ $Ifi "%phase%" == "sets" $include "./modules/29_cropland/detail_apr24/sets.gms" $Ifi "%phase%" == "declarations" $include "./modules/29_cropland/detail_apr24/declarations.gms" $Ifi "%phase%" == "input" $include "./modules/29_cropland/detail_apr24/input.gms" $Ifi "%phase%" == "equations" $include "./modules/29_cropland/detail_apr24/equations.gms" -$Ifi "%phase%" == "scaling" $include "./modules/29_cropland/detail_apr24/scaling.gms" $Ifi "%phase%" == "preloop" $include "./modules/29_cropland/detail_apr24/preloop.gms" $Ifi "%phase%" == "presolve" $include "./modules/29_cropland/detail_apr24/presolve.gms" $Ifi "%phase%" == "postsolve" $include "./modules/29_cropland/detail_apr24/postsolve.gms" diff --git a/modules/29_cropland/simple_apr24/declarations.gms b/modules/29_cropland/simple_apr24/declarations.gms index 1f02098fb4..34207a40de 100644 --- a/modules/29_cropland/simple_apr24/declarations.gms +++ b/modules/29_cropland/simple_apr24/declarations.gms @@ -39,6 +39,8 @@ parameters oq29_cropland(t,j,type) Total cropland calculation (mio. ha) oq29_avl_cropland(t,j,type) Available cropland constraint (mio. ha) oq29_carbon(t,j,ag_pools,stockType,type) Cropland above ground carbon content calculation (mio. tC) + oq29_land_snv(t,j,type) Land constraint for the SNV policy in cropland areas (mio. ha) + oq29_land_snv_trans(t,j,type) Land transition constraint for SNV policy in cropland areas (mio. ha) ; *##################### R SECTION END (OUTPUT DECLARATIONS) ##################### diff --git a/modules/29_cropland/simple_apr24/postsolve.gms b/modules/29_cropland/simple_apr24/postsolve.gms index aaa4624b50..450d616814 100644 --- a/modules/29_cropland/simple_apr24/postsolve.gms +++ b/modules/29_cropland/simple_apr24/postsolve.gms @@ -12,23 +12,31 @@ oq29_cropland(t,j,"marginal") = q29_cropland.m(j); oq29_avl_cropland(t,j,"marginal") = q29_avl_cropland.m(j); oq29_carbon(t,j,ag_pools,stockType,"marginal") = q29_carbon.m(j,ag_pools,stockType); + oq29_land_snv(t,j,"marginal") = q29_land_snv.m(j); + oq29_land_snv_trans(t,j,"marginal") = q29_land_snv_trans.m(j); ov_cost_cropland(t,j,"level") = vm_cost_cropland.l(j); ov_fallow(t,j,"level") = vm_fallow.l(j); ov_treecover(t,j,"level") = vm_treecover.l(j); oq29_cropland(t,j,"level") = q29_cropland.l(j); oq29_avl_cropland(t,j,"level") = q29_avl_cropland.l(j); oq29_carbon(t,j,ag_pools,stockType,"level") = q29_carbon.l(j,ag_pools,stockType); + oq29_land_snv(t,j,"level") = q29_land_snv.l(j); + oq29_land_snv_trans(t,j,"level") = q29_land_snv_trans.l(j); ov_cost_cropland(t,j,"upper") = vm_cost_cropland.up(j); ov_fallow(t,j,"upper") = vm_fallow.up(j); ov_treecover(t,j,"upper") = vm_treecover.up(j); oq29_cropland(t,j,"upper") = q29_cropland.up(j); oq29_avl_cropland(t,j,"upper") = q29_avl_cropland.up(j); oq29_carbon(t,j,ag_pools,stockType,"upper") = q29_carbon.up(j,ag_pools,stockType); + oq29_land_snv(t,j,"upper") = q29_land_snv.up(j); + oq29_land_snv_trans(t,j,"upper") = q29_land_snv_trans.up(j); ov_cost_cropland(t,j,"lower") = vm_cost_cropland.lo(j); ov_fallow(t,j,"lower") = vm_fallow.lo(j); ov_treecover(t,j,"lower") = vm_treecover.lo(j); oq29_cropland(t,j,"lower") = q29_cropland.lo(j); oq29_avl_cropland(t,j,"lower") = q29_avl_cropland.lo(j); oq29_carbon(t,j,ag_pools,stockType,"lower") = q29_carbon.lo(j,ag_pools,stockType); + oq29_land_snv(t,j,"lower") = q29_land_snv.lo(j); + oq29_land_snv_trans(t,j,"lower") = q29_land_snv_trans.lo(j); *##################### R SECTION END (OUTPUT DEFINITIONS) ###################### From 176fa1c108cc56130ef823e987f135c70c3bacaf Mon Sep 17 00:00:00 2001 From: florianh Date: Tue, 30 Apr 2024 10:38:10 +0200 Subject: [PATCH 065/133] bugfix --- modules/29_cropland/detail_apr24/presolve.gms | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/29_cropland/detail_apr24/presolve.gms b/modules/29_cropland/detail_apr24/presolve.gms index 39a064bbeb..7d58830fe5 100644 --- a/modules/29_cropland/detail_apr24/presolve.gms +++ b/modules/29_cropland/detail_apr24/presolve.gms @@ -23,7 +23,7 @@ p29_snv_relocation(t,j) = (i29_snv_scenario_fader(t) - i29_snv_scenario_fader(t- *' Global Land Service (@buchhorn_copernicus_2020)) and in *' cases of cropland reduction p29_max_snv_relocation(t,j) = p29_snv_shr(t,j) * (i29_snv_scenario_fader(t) - i29_snv_scenario_fader(t-1)) * pcm_land(j,"crop") - - vm_treecover.l(j); + - sum(ac, pc29_treecover(j,ac_sub)); p29_max_snv_relocation(t,j)$(p29_max_snv_relocation(t,j) < 0) = 0; p29_snv_relocation(t,j)$(p29_snv_relocation(t, j) > p29_max_snv_relocation(t,j)) = p29_max_snv_relocation(t,j); From ccaf380de6c8a5cb4bfd28da11d35606b3872e6a Mon Sep 17 00:00:00 2001 From: florianh Date: Tue, 30 Apr 2024 10:39:00 +0200 Subject: [PATCH 066/133] bugfix --- modules/29_cropland/detail_apr24/presolve.gms | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/29_cropland/detail_apr24/presolve.gms b/modules/29_cropland/detail_apr24/presolve.gms index 7d58830fe5..54fe3c9120 100644 --- a/modules/29_cropland/detail_apr24/presolve.gms +++ b/modules/29_cropland/detail_apr24/presolve.gms @@ -23,7 +23,7 @@ p29_snv_relocation(t,j) = (i29_snv_scenario_fader(t) - i29_snv_scenario_fader(t- *' Global Land Service (@buchhorn_copernicus_2020)) and in *' cases of cropland reduction p29_max_snv_relocation(t,j) = p29_snv_shr(t,j) * (i29_snv_scenario_fader(t) - i29_snv_scenario_fader(t-1)) * pcm_land(j,"crop") - - sum(ac, pc29_treecover(j,ac_sub)); + - sum(ac, pc29_treecover(j,ac)); p29_max_snv_relocation(t,j)$(p29_max_snv_relocation(t,j) < 0) = 0; p29_snv_relocation(t,j)$(p29_snv_relocation(t, j) > p29_max_snv_relocation(t,j)) = p29_max_snv_relocation(t,j); From 1745fcdb2f63bc188f61862b49da6df7f341744d Mon Sep 17 00:00:00 2001 From: florianh Date: Tue, 30 Apr 2024 11:54:51 +0200 Subject: [PATCH 067/133] update calibration --- config/default.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/default.cfg b/config/default.cfg index cdaba9e998..5832345699 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -26,7 +26,7 @@ cfg$input <- c(regional = "rev4.104_h12_magpie.tgz", cellular = "rev4.104_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", validation = "rev4.104_h12_validation.tgz", additional = "additional_data_rev4.48.tgz", - calibration = "calibration_H12_cropareaSimple_21Apr24.tgz") + calibration = "calibration_H12_default_30Apr24.tgz") # NOTE: It is recommended to recalibrate the model when changing cellular input data # as well as for any other setting that would affect initial values in the model, From 4d2b2e3d6fee04de9f3958897997d927a6ce268d Mon Sep 17 00:00:00 2001 From: florianh Date: Wed, 1 May 2024 08:13:03 +0200 Subject: [PATCH 068/133] highres --- CHANGELOG.md | 1 + scripts/output/extra/highres.R | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ff9dc5957..e3e166f765 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **scenario_fsec.csv** scenario settings - **start/projects/fsec.R** scenario settings - **80_optimization** fixed a bug in nlp_apr17; cycling through CONOPT4, CONOPT4 without preprocessing and CONOPT3 was not working +- **80_optimization** bugfix in nlp_par. Double solve statement was not working - **58_peatland** Added balance variable to avoid random infeasibilites diff --git a/scripts/output/extra/highres.R b/scripts/output/extra/highres.R index b018934d7f..809868fef6 100644 --- a/scripts/output/extra/highres.R +++ b/scripts/output/extra/highres.R @@ -100,8 +100,8 @@ highres <- function(cfg) { #copy gdx file for 1st time step from low resolution run for better starting point #note: using gdx files for more than the 1st time step sometimes pushes the model into corner solutions, which might result in infeasibilites. cfg$files2export$start <- c(cfg$files2export$start, - paste0(cfg$results_folder, "/", "magpie_y1995.gdx")) - cfg$gms$s_use_gdx <- 1 + paste0(cfg$results_folder, "/", "magpie_y*.gdx")) + cfg$gms$s_use_gdx <- 2 #max resources for parallel runs cfg$qos <- "standby_maxMem_dayMax" From 584aac53520d0e3ff8fe316267f917eb15ad06a9 Mon Sep 17 00:00:00 2001 From: florianh Date: Thu, 2 May 2024 12:50:37 +0200 Subject: [PATCH 069/133] nlp par update --- modules/80_optimization/lp_nlp_apr17/not_used.txt | 2 ++ modules/80_optimization/nlp_apr17/not_used.txt | 1 + modules/80_optimization/nlp_par/solve.gms | 11 ++++++++++- 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 modules/80_optimization/lp_nlp_apr17/not_used.txt diff --git a/modules/80_optimization/lp_nlp_apr17/not_used.txt b/modules/80_optimization/lp_nlp_apr17/not_used.txt new file mode 100644 index 0000000000..4dd79412da --- /dev/null +++ b/modules/80_optimization/lp_nlp_apr17/not_used.txt @@ -0,0 +1,2 @@ +name,type,reason +sm_fix_SSP2,input,not needed diff --git a/modules/80_optimization/nlp_apr17/not_used.txt b/modules/80_optimization/nlp_apr17/not_used.txt index ea605f3b35..7a59e90855 100644 --- a/modules/80_optimization/nlp_apr17/not_used.txt +++ b/modules/80_optimization/nlp_apr17/not_used.txt @@ -1,2 +1,3 @@ name,type,reason vm_landdiff,input,questionnaire +sm_fix_SSP2,input,not needed diff --git a/modules/80_optimization/nlp_par/solve.gms b/modules/80_optimization/nlp_par/solve.gms index 8c7e9d5a1d..1a79df95d1 100644 --- a/modules/80_optimization/nlp_par/solve.gms +++ b/modules/80_optimization/nlp_par/solve.gms @@ -111,6 +111,9 @@ repeat option nlp = conopt4; ); ); + if (execerror > 0 AND ord(t) > 1, + Execute_Loadpoint "magpie_p.gdx"; + ); execerror = 0; if (magpie.handle = 0, display "Problem. Handle is zero despite resolve. Setting handle to 1 for continuation."; @@ -127,12 +130,18 @@ display$sleep(card(p80_handle)*0.2) 'sleep some time'; display$readyCollect(p80_handle,INF) 'Problem waiting for next instance to complete'; until card(p80_handle) = 0 OR smax(h, p80_counter(h)) >= s80_maxiter; +* Save results to gdx files after historical period. +* Historical period is excluded to avoid diversion of results compared to other model runs if restarted with s_use_gdx = 2. +if (smax(h,p80_modelstat(t,h)) <= 2 AND m_year(t) > sm_fix_SSP2, + put_utility 'shell' / 'cp -f magpie_p.gdx magpie_' t.tl:0'.gdx'; +); + if (smax(h,p80_modelstat(t,h)) > 2 and smax(h,p80_modelstat(t,h)) ne 7, Execute_Unload "fulldata.gdx"; abort "No feasible solution found!"; ); -* handleSubmit does not work as expected. Does not restart from saved state. +* handleSubmit does not work because it requires the script `gmsrerun.cmd` or `gmsrerun.run` in the grid directory. * Therefore, solve statements are used. * display$handleSubmit(p80_handle(h)) 'trouble resubmitting handles' ; From 6c23a00275ecfec965b64587d968b50127b530a8 Mon Sep 17 00:00:00 2001 From: florianh Date: Thu, 2 May 2024 13:26:20 +0200 Subject: [PATCH 070/133] update --- modules/80_optimization/nlp_par/solve.gms | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/80_optimization/nlp_par/solve.gms b/modules/80_optimization/nlp_par/solve.gms index 1a79df95d1..2638d90161 100644 --- a/modules/80_optimization/nlp_par/solve.gms +++ b/modules/80_optimization/nlp_par/solve.gms @@ -112,7 +112,8 @@ repeat ); ); if (execerror > 0 AND ord(t) > 1, - Execute_Loadpoint "magpie_p.gdx"; + display "Execution error. Loading solution from last feasible timestep for retry."; + Execute_Loadpoint "magpie_p_last_timestep.gdx"; ); execerror = 0; if (magpie.handle = 0, @@ -133,7 +134,8 @@ until card(p80_handle) = 0 OR smax(h, p80_counter(h)) >= s80_maxiter; * Save results to gdx files after historical period. * Historical period is excluded to avoid diversion of results compared to other model runs if restarted with s_use_gdx = 2. if (smax(h,p80_modelstat(t,h)) <= 2 AND m_year(t) > sm_fix_SSP2, - put_utility 'shell' / 'cp -f magpie_p.gdx magpie_' t.tl:0'.gdx'; + put_utility 'shell' / 'cp -f magpie_p.gdx magpie_p_last_timestep.gdx'; + put_utility 'shell' / 'mv -f magpie_p.gdx magpie_' t.tl:0'.gdx'; ); if (smax(h,p80_modelstat(t,h)) > 2 and smax(h,p80_modelstat(t,h)) ne 7, From 444eaaf98db2fce2243ca445826aee4fbffa38a2 Mon Sep 17 00:00:00 2001 From: florianh Date: Thu, 2 May 2024 14:56:21 +0200 Subject: [PATCH 071/133] update --- modules/80_optimization/nlp_par/solve.gms | 40 +++++++++++++---------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/modules/80_optimization/nlp_par/solve.gms b/modules/80_optimization/nlp_par/solve.gms index 2638d90161..5c5c8f1d34 100644 --- a/modules/80_optimization/nlp_par/solve.gms +++ b/modules/80_optimization/nlp_par/solve.gms @@ -49,18 +49,12 @@ loop(h, *collection loop repeat loop(h$p80_handle(h), - if(handleStatus(p80_handle(h)) = 2, + if(handleStatus(p80_handle(h)) = 2, // process solutions which are ready p80_counter(h) = p80_counter(h) + 1; p80_extra_solve(h) = 1; - magpie.handle = p80_handle(h); - execute_loadhandle magpie; - magpie.modelStat$(magpie.modelStat=NA) = 13; - - s80_modelstat_previter = p80_modelstat(t,h); - p80_modelstat(t,h) = magpie.modelStat; - s80_optfile_previter = magpie.optfile; - magpie.optfile = s80_optfile; + magpie.handle = p80_handle(h); // assign handle to extract solution + execute_loadhandle magpie; // load point h2(h) = yes; i2(i)$supreg(h,i) = yes; @@ -69,6 +63,18 @@ repeat s80_counter = sum(h2,p80_counter(h2)); display s80_counter; display magpie.modelStat; + magpie.modelStat$(magpie.modelStat=NA) = 13; + + if (magpie.modelStat > 2 AND ord(t) > 1, + display "No feasible solution or Execution error. Loading solution from last feasible timestep for retry."; + Execute_Loadpoint "magpie_p_last_timestep.gdx"; + ); + execerror = 0; + + s80_modelstat_previter = p80_modelstat(t,h); + p80_modelstat(t,h) = magpie.modelStat; + s80_optfile_previter = magpie.optfile; + magpie.optfile = s80_optfile; if ((p80_counter(h) >= s80_maxiter AND p80_modelstat(t,h) > 2), display "No feasible solution found. Writing LST file."; @@ -111,11 +117,6 @@ repeat option nlp = conopt4; ); ); - if (execerror > 0 AND ord(t) > 1, - display "Execution error. Loading solution from last feasible timestep for retry."; - Execute_Loadpoint "magpie_p_last_timestep.gdx"; - ); - execerror = 0; if (magpie.handle = 0, display "Problem. Handle is zero despite resolve. Setting handle to 1 for continuation."; magpie.handle = 1; @@ -131,11 +132,14 @@ display$sleep(card(p80_handle)*0.2) 'sleep some time'; display$readyCollect(p80_handle,INF) 'Problem waiting for next instance to complete'; until card(p80_handle) = 0 OR smax(h, p80_counter(h)) >= s80_maxiter; -* Save results to gdx files after historical period. -* Historical period is excluded to avoid diversion of results compared to other model runs if restarted with s_use_gdx = 2. -if (smax(h,p80_modelstat(t,h)) <= 2 AND m_year(t) > sm_fix_SSP2, +* Save results to gdx point files +* Historical period for magpie_p_y[XXXX].gdx files is excluded to avoid diversion of results compared to other model runs if restarted with s_use_gdx = 2. +if (smax(h,p80_modelstat(t,h)) <= 2, put_utility 'shell' / 'cp -f magpie_p.gdx magpie_p_last_timestep.gdx'; - put_utility 'shell' / 'mv -f magpie_p.gdx magpie_' t.tl:0'.gdx'; + if (m_year(t) > sm_fix_SSP2, + put_utility 'shell' / 'cp -f magpie_p.gdx magpie_' t.tl:0'.gdx'; + ); + put_utility 'shell' / 'rm -f magpie_p.gdx; ); if (smax(h,p80_modelstat(t,h)) > 2 and smax(h,p80_modelstat(t,h)) ne 7, From d4f25ff434815af2c13f0960ee59faee2a2a5907 Mon Sep 17 00:00:00 2001 From: florianh Date: Thu, 2 May 2024 15:00:13 +0200 Subject: [PATCH 072/133] update --- modules/80_optimization/nlp_par/solve.gms | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/80_optimization/nlp_par/solve.gms b/modules/80_optimization/nlp_par/solve.gms index 5c5c8f1d34..49ab922446 100644 --- a/modules/80_optimization/nlp_par/solve.gms +++ b/modules/80_optimization/nlp_par/solve.gms @@ -66,8 +66,13 @@ repeat magpie.modelStat$(magpie.modelStat=NA) = 13; if (magpie.modelStat > 2 AND ord(t) > 1, - display "No feasible solution or Execution error. Loading solution from last feasible timestep for retry."; - Execute_Loadpoint "magpie_p_last_timestep.gdx"; + if (p80_counter_modelstat(h) <= 5, + display "No feasible solution or Execution error. Loading solution from last feasible timestep for retry."; + Execute_Loadpoint "magpie_p_last_timestep.gdx"; + else + display "No feasible solution or Execution error. Loading solution from first feasible timestep for retry."; + Execute_Loadpoint "magpie_y1995.gdx"; + ); ); execerror = 0; From 8e61949073ab4384a3e3abcd996d96d049db10c9 Mon Sep 17 00:00:00 2001 From: florianh Date: Thu, 2 May 2024 15:11:00 +0200 Subject: [PATCH 073/133] bugfix --- modules/80_optimization/nlp_par/solve.gms | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/80_optimization/nlp_par/solve.gms b/modules/80_optimization/nlp_par/solve.gms index 49ab922446..c28ebf840a 100644 --- a/modules/80_optimization/nlp_par/solve.gms +++ b/modules/80_optimization/nlp_par/solve.gms @@ -49,12 +49,12 @@ loop(h, *collection loop repeat loop(h$p80_handle(h), - if(handleStatus(p80_handle(h)) = 2, // process solutions which are ready + if(handleStatus(p80_handle(h)) = 2, p80_counter(h) = p80_counter(h) + 1; p80_extra_solve(h) = 1; - magpie.handle = p80_handle(h); // assign handle to extract solution - execute_loadhandle magpie; // load point + magpie.handle = p80_handle(h); + execute_loadhandle magpie; h2(h) = yes; i2(i)$supreg(h,i) = yes; From 518c25d960efe4f06f9e0a43d41c557074c5b4dc Mon Sep 17 00:00:00 2001 From: florianh Date: Thu, 2 May 2024 16:20:21 +0200 Subject: [PATCH 074/133] bugfix --- modules/80_optimization/nlp_par/solve.gms | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/80_optimization/nlp_par/solve.gms b/modules/80_optimization/nlp_par/solve.gms index c28ebf840a..1bd8bf2691 100644 --- a/modules/80_optimization/nlp_par/solve.gms +++ b/modules/80_optimization/nlp_par/solve.gms @@ -144,7 +144,7 @@ if (smax(h,p80_modelstat(t,h)) <= 2, if (m_year(t) > sm_fix_SSP2, put_utility 'shell' / 'cp -f magpie_p.gdx magpie_' t.tl:0'.gdx'; ); - put_utility 'shell' / 'rm -f magpie_p.gdx; + put_utility 'shell' / 'rm -f magpie_p.gdx'; ); if (smax(h,p80_modelstat(t,h)) > 2 and smax(h,p80_modelstat(t,h)) ne 7, From 9d7befcd92791c791af3e0fce4832dd401ae5778 Mon Sep 17 00:00:00 2001 From: florianh Date: Thu, 2 May 2024 18:43:08 +0200 Subject: [PATCH 075/133] update --- .../80_optimization/nlp_par/declarations.gms | 3 +- modules/80_optimization/nlp_par/solve.gms | 70 +++++++++++-------- 2 files changed, 42 insertions(+), 31 deletions(-) diff --git a/modules/80_optimization/nlp_par/declarations.gms b/modules/80_optimization/nlp_par/declarations.gms index b375d607e3..1f927a251f 100644 --- a/modules/80_optimization/nlp_par/declarations.gms +++ b/modules/80_optimization/nlp_par/declarations.gms @@ -10,7 +10,8 @@ parameters p80_counter(h) counter (1) p80_handle(h) parallel mode handle parameter (1) p80_extra_solve(h) indicator for extra solve (1) - p80_counter_modelstat(h) counter for modelstat <= 2 (1) + p80_counter_modelstat(h) counter for modelstat <= 2 (1) + p80_resolve_option(h) option for resolve (1) ; scalars diff --git a/modules/80_optimization/nlp_par/solve.gms b/modules/80_optimization/nlp_par/solve.gms index 1bd8bf2691..c17c6b97d7 100644 --- a/modules/80_optimization/nlp_par/solve.gms +++ b/modules/80_optimization/nlp_par/solve.gms @@ -9,9 +9,9 @@ p80_counter(h) = 0; p80_modelstat(t,h) = 14; p80_counter_modelstat(h) = 0; +p80_resolve_option(h) = 1; *** solver settings - option nlp = conopt4; magpie.solvelink = 3; magpie.optfile = s80_optfile ; @@ -63,23 +63,12 @@ repeat s80_counter = sum(h2,p80_counter(h2)); display s80_counter; display magpie.modelStat; + display vm_cost_glo.l; magpie.modelStat$(magpie.modelStat=NA) = 13; - if (magpie.modelStat > 2 AND ord(t) > 1, - if (p80_counter_modelstat(h) <= 5, - display "No feasible solution or Execution error. Loading solution from last feasible timestep for retry."; - Execute_Loadpoint "magpie_p_last_timestep.gdx"; - else - display "No feasible solution or Execution error. Loading solution from first feasible timestep for retry."; - Execute_Loadpoint "magpie_y1995.gdx"; - ); - ); - execerror = 0; - s80_modelstat_previter = p80_modelstat(t,h); p80_modelstat(t,h) = magpie.modelStat; s80_optfile_previter = magpie.optfile; - magpie.optfile = s80_optfile; if ((p80_counter(h) >= s80_maxiter AND p80_modelstat(t,h) > 2), display "No feasible solution found. Writing LST file."; @@ -107,32 +96,53 @@ repeat if (p80_extra_solve(h) = 1, display "Resolve" - if (p80_modelstat(t,h) ne s80_modelstat_previter, - display "Modelstat > 2 | Retry solve with CONOPT4 default setting"; - solve magpie USING nlp MINIMIZING vm_cost_glo; - elseif p80_modelstat(t,h) = s80_modelstat_previter, - if(magpie.optfile = s80_optfile_previter, - display "Modelstat > 2 | Retry solve without CONOPT4 pre-processing"; - magpie.optfile = 2; - solve magpie USING nlp MINIMIZING vm_cost_glo; + if (ord(t) > 1, + if (p80_counter(h) <= s80_maxiter/2, + display "No feasible solution or Execution error. Loading solution from last feasible timestep for retry."; + Execute_Loadpoint "magpie_p_last_timestep.gdx"; else - display "Modelstat > 2 | Retry solve with CONOPT3"; - option nlp = conopt; - solve magpie USING nlp MINIMIZING vm_cost_glo; - option nlp = conopt4; + display "No feasible solution or Execution error. Loading solution from first feasible timestep for retry."; + Execute_Loadpoint "magpie_y1995.gdx"; ); ); - if (magpie.handle = 0, - display "Problem. Handle is zero despite resolve. Setting handle to 1 for continuation."; - magpie.handle = 1; + display vm_cost_glo.l; + execerror$(execerror > 0) = 0; + if (p80_resolve_option(h) = 1, + display "Modelstat > 2 | Retry solve with CONOPT4 default setting"; + solve magpie USING nlp MINIMIZING vm_cost_glo; + else if (p80_resolve_option(h) = 2) + display "Modelstat > 2 | Retry solve with CONOPT4 and OPTFILE"; + magpie.optfile = 1; + solve magpie USING nlp MINIMIZING vm_cost_glo; + magpie.optfile = s80_optfile; + else if (p80_resolve_option(h) = 3) + display "Modelstat > 2 | Retry solve without CONOPT4 pre-processing"; + magpie.optfile = 2; + solve magpie USING nlp MINIMIZING vm_cost_glo; + magpie.optfile = s80_optfile; + else if (p80_resolve_option(h) = 4) + display "Modelstat > 2 | Retry solve with CONOPT3"; + option nlp = conopt; + solve magpie USING nlp MINIMIZING vm_cost_glo; + option nlp = conopt4; + ); + if (p80_resolve_option(h) < 4, + p80_resolve_option(h) = p80_resolve_option(h) + 1; + else + p80_resolve_option(h) = 1; ); - p80_handle(h) = magpie.handle; ); + if (magpie.handle = 0, + display "Problem. Handle is zero despite resolve. Setting handle to 1 for continuation."; + magpie.handle = 1; + ); + p80_handle(h) = magpie.handle; + ); h2(h) = no; i2(i) = no; j2(j) = no; - ); ); +); display$sleep(card(p80_handle)*0.2) 'sleep some time'; display$readyCollect(p80_handle,INF) 'Problem waiting for next instance to complete'; until card(p80_handle) = 0 OR smax(h, p80_counter(h)) >= s80_maxiter; From d8eb4e9512d46e75413a740be61f0b9e7fd49d9e Mon Sep 17 00:00:00 2001 From: florianh Date: Thu, 2 May 2024 19:00:56 +0200 Subject: [PATCH 076/133] bugfix --- modules/80_optimization/nlp_par/solve.gms | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/80_optimization/nlp_par/solve.gms b/modules/80_optimization/nlp_par/solve.gms index c17c6b97d7..3ba08aa2c7 100644 --- a/modules/80_optimization/nlp_par/solve.gms +++ b/modules/80_optimization/nlp_par/solve.gms @@ -63,6 +63,7 @@ repeat s80_counter = sum(h2,p80_counter(h2)); display s80_counter; display magpie.modelStat; + display "vm_cost_glo.l"; display vm_cost_glo.l; magpie.modelStat$(magpie.modelStat=NA) = 13; @@ -105,22 +106,23 @@ repeat Execute_Loadpoint "magpie_y1995.gdx"; ); ); + display "vm_cost_glo.l"; display vm_cost_glo.l; execerror$(execerror > 0) = 0; if (p80_resolve_option(h) = 1, display "Modelstat > 2 | Retry solve with CONOPT4 default setting"; solve magpie USING nlp MINIMIZING vm_cost_glo; - else if (p80_resolve_option(h) = 2) + elseif p80_resolve_option(h) = 2, display "Modelstat > 2 | Retry solve with CONOPT4 and OPTFILE"; magpie.optfile = 1; solve magpie USING nlp MINIMIZING vm_cost_glo; magpie.optfile = s80_optfile; - else if (p80_resolve_option(h) = 3) + elseif p80_resolve_option(h) = 3, display "Modelstat > 2 | Retry solve without CONOPT4 pre-processing"; magpie.optfile = 2; solve magpie USING nlp MINIMIZING vm_cost_glo; magpie.optfile = s80_optfile; - else if (p80_resolve_option(h) = 4) + elseif p80_resolve_option(h) = 4, display "Modelstat > 2 | Retry solve with CONOPT3"; option nlp = conopt; solve magpie USING nlp MINIMIZING vm_cost_glo; From 9f2acf41e38eccd84bdefd5aa19001c1cdbbe624 Mon Sep 17 00:00:00 2001 From: florianh Date: Thu, 2 May 2024 19:20:35 +0200 Subject: [PATCH 077/133] bugfix --- modules/80_optimization/nlp_par/solve.gms | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/80_optimization/nlp_par/solve.gms b/modules/80_optimization/nlp_par/solve.gms index 3ba08aa2c7..2fdf169802 100644 --- a/modules/80_optimization/nlp_par/solve.gms +++ b/modules/80_optimization/nlp_par/solve.gms @@ -144,7 +144,6 @@ repeat i2(i) = no; j2(j) = no; ); -); display$sleep(card(p80_handle)*0.2) 'sleep some time'; display$readyCollect(p80_handle,INF) 'Problem waiting for next instance to complete'; until card(p80_handle) = 0 OR smax(h, p80_counter(h)) >= s80_maxiter; From f7125acd51c1b8416eb97d68aef760fd9d09c83d Mon Sep 17 00:00:00 2001 From: florianh Date: Fri, 3 May 2024 00:32:58 +0200 Subject: [PATCH 078/133] bugfix --- modules/80_optimization/nlp_par/solve.gms | 44 +++++++++++------------ 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/modules/80_optimization/nlp_par/solve.gms b/modules/80_optimization/nlp_par/solve.gms index 2fdf169802..5b14cb4475 100644 --- a/modules/80_optimization/nlp_par/solve.gms +++ b/modules/80_optimization/nlp_par/solve.gms @@ -71,19 +71,19 @@ repeat p80_modelstat(t,h) = magpie.modelStat; s80_optfile_previter = magpie.optfile; - if ((p80_counter(h) >= s80_maxiter AND p80_modelstat(t,h) > 2), + if(p80_counter(h) >= s80_maxiter AND p80_modelstat(t,h) > 2, display "No feasible solution found. Writing LST file."; option AsyncSolLst=1; display$handlecollect(p80_handle(h)) 're-collect'; option AsyncSolLst=0; p80_extra_solve(h) = 0; - ); + ); display$handledelete(p80_handle(h)) 'trouble deleting handles' ; - if (p80_modelstat(t,h) <= 2, + if(p80_modelstat(t,h) <= 2, p80_counter_modelstat(h) = p80_counter_modelstat(h) + 1; - if (p80_counter_modelstat(h) < 2, + if(p80_counter_modelstat(h) < 2, display "Model status <= 2. Starting second solve"; solve magpie USING nlp MINIMIZING vm_cost_glo; p80_handle(h) = magpie.handle; @@ -92,24 +92,24 @@ repeat display "Model status <= 2. Handle cleared."; p80_extra_solve(h) = 0; p80_handle(h) = 0; - ); - ); + ); + ); - if (p80_extra_solve(h) = 1, + if(p80_extra_solve(h) = 1, display "Resolve" - if (ord(t) > 1, - if (p80_counter(h) <= s80_maxiter/2, + if(ord(t) > 1, + if(p80_counter(h) <= s80_maxiter/2, display "No feasible solution or Execution error. Loading solution from last feasible timestep for retry."; Execute_Loadpoint "magpie_p_last_timestep.gdx"; else display "No feasible solution or Execution error. Loading solution from first feasible timestep for retry."; Execute_Loadpoint "magpie_y1995.gdx"; - ); - ); + ); + ); display "vm_cost_glo.l"; display vm_cost_glo.l; execerror$(execerror > 0) = 0; - if (p80_resolve_option(h) = 1, + if(p80_resolve_option(h) = 1, display "Modelstat > 2 | Retry solve with CONOPT4 default setting"; solve magpie USING nlp MINIMIZING vm_cost_glo; elseif p80_resolve_option(h) = 2, @@ -127,23 +127,23 @@ repeat option nlp = conopt; solve magpie USING nlp MINIMIZING vm_cost_glo; option nlp = conopt4; - ); + ); if (p80_resolve_option(h) < 4, p80_resolve_option(h) = p80_resolve_option(h) + 1; else p80_resolve_option(h) = 1; - ); - ); - if (magpie.handle = 0, - display "Problem. Handle is zero despite resolve. Setting handle to 1 for continuation."; - magpie.handle = 1; - ); - p80_handle(h) = magpie.handle; - ); + ); + if(magpie.handle = 0, + display "Problem. Handle is zero despite resolve. Setting handle to 1 for continuation."; + magpie.handle = 1; + ); + p80_handle(h) = magpie.handle; + ); h2(h) = no; i2(i) = no; j2(j) = no; - ); + ); + ); display$sleep(card(p80_handle)*0.2) 'sleep some time'; display$readyCollect(p80_handle,INF) 'Problem waiting for next instance to complete'; until card(p80_handle) = 0 OR smax(h, p80_counter(h)) >= s80_maxiter; From 46e2285fa2bb6b3c18f10bb62bde3b8e332b775d Mon Sep 17 00:00:00 2001 From: florianh Date: Fri, 3 May 2024 10:30:17 +0200 Subject: [PATCH 079/133] update --- modules/80_optimization/nlp_par/solve.gms | 54 +++++++++++++---------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/modules/80_optimization/nlp_par/solve.gms b/modules/80_optimization/nlp_par/solve.gms index 5b14cb4475..4fe79bb1a9 100644 --- a/modules/80_optimization/nlp_par/solve.gms +++ b/modules/80_optimization/nlp_par/solve.gms @@ -63,8 +63,8 @@ repeat s80_counter = sum(h2,p80_counter(h2)); display s80_counter; display magpie.modelStat; - display "vm_cost_glo.l"; - display vm_cost_glo.l; + display "v11_cost_reg.l"; + display v11_cost_reg.l; magpie.modelStat$(magpie.modelStat=NA) = 13; s80_modelstat_previter = p80_modelstat(t,h); @@ -72,6 +72,7 @@ repeat s80_optfile_previter = magpie.optfile; if(p80_counter(h) >= s80_maxiter AND p80_modelstat(t,h) > 2, + if (p80_modelstat(t,h) = 13, execute 'gmszip -r magpie_problem_' h.tl:0'_' t.tl:0'.zip "%gams.scrdir%"'); display "No feasible solution found. Writing LST file."; option AsyncSolLst=1; display$handlecollect(p80_handle(h)) 're-collect'; @@ -97,38 +98,43 @@ repeat if(p80_extra_solve(h) = 1, display "Resolve" - if(ord(t) > 1, - if(p80_counter(h) <= s80_maxiter/2, - display "No feasible solution or Execution error. Loading solution from last feasible timestep for retry."; - Execute_Loadpoint "magpie_p_last_timestep.gdx"; - else - display "No feasible solution or Execution error. Loading solution from first feasible timestep for retry."; - Execute_Loadpoint "magpie_y1995.gdx"; - ); - ); - display "vm_cost_glo.l"; - display vm_cost_glo.l; + display "v11_cost_reg.l"; + display v11_cost_reg.l; execerror$(execerror > 0) = 0; if(p80_resolve_option(h) = 1, display "Modelstat > 2 | Retry solve with CONOPT4 default setting"; + magpie.optfile = 0; solve magpie USING nlp MINIMIZING vm_cost_glo; elseif p80_resolve_option(h) = 2, - display "Modelstat > 2 | Retry solve with CONOPT4 and OPTFILE"; - magpie.optfile = 1; + display "Modelstat > 2 | Retry solve with CONOPT4 default setting and magpie_p_last_timestep.gdx"; + magpie.optfile = 0; + Execute_Loadpoint "magpie_p_last_timestep.gdx"; + execerror$(execerror > 0) = 0; solve magpie USING nlp MINIMIZING vm_cost_glo; - magpie.optfile = s80_optfile; - elseif p80_resolve_option(h) = 3, - display "Modelstat > 2 | Retry solve without CONOPT4 pre-processing"; - magpie.optfile = 2; + elseif p80_resolve_option(h) = 3, + display "Modelstat > 2 | Retry solve with CONOPT4 default setting and magpie_y2020.gdx"; + magpie.optfile = 0; + Execute_Loadpoint "magpie_y2020.gdx"; + execerror$(execerror > 0) = 0; solve magpie USING nlp MINIMIZING vm_cost_glo; - magpie.optfile = s80_optfile; elseif p80_resolve_option(h) = 4, - display "Modelstat > 2 | Retry solve with CONOPT3"; - option nlp = conopt; + display "Modelstat > 2 | Retry solve with CONOPT4 OPTFILE"; + magpie.optfile = 1; + solve magpie USING nlp MINIMIZING vm_cost_glo; + elseif p80_resolve_option(h) = 5, + display "Modelstat > 2 | Retry solve with CONOPT4 OPTFILE and magpie_p_last_timestep.gdx"; + magpie.optfile = 1; + Execute_Loadpoint "magpie_p_last_timestep.gdx"; + execerror$(execerror > 0) = 0; + solve magpie USING nlp MINIMIZING vm_cost_glo; + elseif p80_resolve_option(h) = 6, + display "Modelstat > 2 | Retry solve with CONOPT4 OPTFILE and magpie_y2020.gdx"; + magpie.optfile = 1; + Execute_Loadpoint "magpie_y2020.gdx"; + execerror$(execerror > 0) = 0; solve magpie USING nlp MINIMIZING vm_cost_glo; - option nlp = conopt4; ); - if (p80_resolve_option(h) < 4, + if (p80_resolve_option(h) < 6, p80_resolve_option(h) = p80_resolve_option(h) + 1; else p80_resolve_option(h) = 1; From 286d9c581d80d4cb6a7c8ed6b9a18e616e78516e Mon Sep 17 00:00:00 2001 From: florianh Date: Fri, 3 May 2024 10:44:51 +0200 Subject: [PATCH 080/133] bugfix --- modules/80_optimization/nlp_par/solve.gms | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/80_optimization/nlp_par/solve.gms b/modules/80_optimization/nlp_par/solve.gms index 4fe79bb1a9..5aa4c7a959 100644 --- a/modules/80_optimization/nlp_par/solve.gms +++ b/modules/80_optimization/nlp_par/solve.gms @@ -72,7 +72,10 @@ repeat s80_optfile_previter = magpie.optfile; if(p80_counter(h) >= s80_maxiter AND p80_modelstat(t,h) > 2, - if (p80_modelstat(t,h) = 13, execute 'gmszip -r magpie_problem_' h.tl:0'_' t.tl:0'.zip "%gams.scrdir%"'); + if(p80_modelstat(t,h) = 13, + execute 'gmszip -r magpie_problem.zip "%gams.scrdir%"' + put_utility 'shell' / 'mv -f magpie_problem.zip magpie_problem_' h.tl:0'_' t.tl:0'.zip'; + ); display "No feasible solution found. Writing LST file."; option AsyncSolLst=1; display$handlecollect(p80_handle(h)) 're-collect'; From ac4c24976b69a6462085ac49d507ada123ee724e Mon Sep 17 00:00:00 2001 From: florianh Date: Fri, 3 May 2024 12:18:27 +0200 Subject: [PATCH 081/133] update --- modules/80_optimization/nlp_par/declarations.gms | 1 + modules/80_optimization/nlp_par/solve.gms | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/80_optimization/nlp_par/declarations.gms b/modules/80_optimization/nlp_par/declarations.gms index 1f927a251f..95454dded2 100644 --- a/modules/80_optimization/nlp_par/declarations.gms +++ b/modules/80_optimization/nlp_par/declarations.gms @@ -16,6 +16,7 @@ parameters scalars s80_counter counter (1) + s80_objective objective function value (mio. USD05MER per yr) s80_modelstat_previter modelstat of previous iteration (1) s80_optfile_previter optfile used in previous iteration (1) ; diff --git a/modules/80_optimization/nlp_par/solve.gms b/modules/80_optimization/nlp_par/solve.gms index 5aa4c7a959..92ed30b06b 100644 --- a/modules/80_optimization/nlp_par/solve.gms +++ b/modules/80_optimization/nlp_par/solve.gms @@ -61,10 +61,10 @@ repeat loop(i2, j2(j)$cell(i2,j) = yes); display h2; s80_counter = sum(h2,p80_counter(h2)); + s80_objective = sum(h2,v11_cost_reg.l(h2)); display s80_counter; display magpie.modelStat; - display "v11_cost_reg.l"; - display v11_cost_reg.l; + display s80_objective; magpie.modelStat$(magpie.modelStat=NA) = 13; s80_modelstat_previter = p80_modelstat(t,h); @@ -101,8 +101,6 @@ repeat if(p80_extra_solve(h) = 1, display "Resolve" - display "v11_cost_reg.l"; - display v11_cost_reg.l; execerror$(execerror > 0) = 0; if(p80_resolve_option(h) = 1, display "Modelstat > 2 | Retry solve with CONOPT4 default setting"; @@ -137,6 +135,8 @@ repeat execerror$(execerror > 0) = 0; solve magpie USING nlp MINIMIZING vm_cost_glo; ); + s80_objective = sum(h2,v11_cost_reg.l(h2)); + display s80_objective; if (p80_resolve_option(h) < 6, p80_resolve_option(h) = p80_resolve_option(h) + 1; else From bc4c3cf1c4f5599dedd2ab5c715bae6a9853d1a4 Mon Sep 17 00:00:00 2001 From: florianh Date: Fri, 3 May 2024 12:37:14 +0200 Subject: [PATCH 082/133] bugfix --- modules/80_optimization/nlp_par/solve.gms | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/80_optimization/nlp_par/solve.gms b/modules/80_optimization/nlp_par/solve.gms index 92ed30b06b..fe8d5c63b1 100644 --- a/modules/80_optimization/nlp_par/solve.gms +++ b/modules/80_optimization/nlp_par/solve.gms @@ -61,7 +61,7 @@ repeat loop(i2, j2(j)$cell(i2,j) = yes); display h2; s80_counter = sum(h2,p80_counter(h2)); - s80_objective = sum(h2,v11_cost_reg.l(h2)); + s80_objective = sum(i2,v11_cost_reg.l(i2)); display s80_counter; display magpie.modelStat; display s80_objective; @@ -135,7 +135,7 @@ repeat execerror$(execerror > 0) = 0; solve magpie USING nlp MINIMIZING vm_cost_glo; ); - s80_objective = sum(h2,v11_cost_reg.l(h2)); + s80_objective = sum(i2,v11_cost_reg.l(i2)); display s80_objective; if (p80_resolve_option(h) < 6, p80_resolve_option(h) = p80_resolve_option(h) + 1; From 4ff98348fe39edfba36844a06c843f27602d15db Mon Sep 17 00:00:00 2001 From: florianh Date: Fri, 3 May 2024 13:02:56 +0200 Subject: [PATCH 083/133] bugfix --- modules/80_optimization/nlp_par/solve.gms | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/modules/80_optimization/nlp_par/solve.gms b/modules/80_optimization/nlp_par/solve.gms index fe8d5c63b1..ae525173c6 100644 --- a/modules/80_optimization/nlp_par/solve.gms +++ b/modules/80_optimization/nlp_par/solve.gms @@ -101,42 +101,33 @@ repeat if(p80_extra_solve(h) = 1, display "Resolve" - execerror$(execerror > 0) = 0; if(p80_resolve_option(h) = 1, display "Modelstat > 2 | Retry solve with CONOPT4 default setting"; magpie.optfile = 0; - solve magpie USING nlp MINIMIZING vm_cost_glo; elseif p80_resolve_option(h) = 2, display "Modelstat > 2 | Retry solve with CONOPT4 default setting and magpie_p_last_timestep.gdx"; magpie.optfile = 0; Execute_Loadpoint "magpie_p_last_timestep.gdx"; - execerror$(execerror > 0) = 0; - solve magpie USING nlp MINIMIZING vm_cost_glo; elseif p80_resolve_option(h) = 3, display "Modelstat > 2 | Retry solve with CONOPT4 default setting and magpie_y2020.gdx"; magpie.optfile = 0; Execute_Loadpoint "magpie_y2020.gdx"; - execerror$(execerror > 0) = 0; - solve magpie USING nlp MINIMIZING vm_cost_glo; elseif p80_resolve_option(h) = 4, display "Modelstat > 2 | Retry solve with CONOPT4 OPTFILE"; magpie.optfile = 1; - solve magpie USING nlp MINIMIZING vm_cost_glo; elseif p80_resolve_option(h) = 5, display "Modelstat > 2 | Retry solve with CONOPT4 OPTFILE and magpie_p_last_timestep.gdx"; magpie.optfile = 1; Execute_Loadpoint "magpie_p_last_timestep.gdx"; - execerror$(execerror > 0) = 0; - solve magpie USING nlp MINIMIZING vm_cost_glo; elseif p80_resolve_option(h) = 6, display "Modelstat > 2 | Retry solve with CONOPT4 OPTFILE and magpie_y2020.gdx"; magpie.optfile = 1; Execute_Loadpoint "magpie_y2020.gdx"; - execerror$(execerror > 0) = 0; - solve magpie USING nlp MINIMIZING vm_cost_glo; ); + if(execerror > 0, execerror = 0); s80_objective = sum(i2,v11_cost_reg.l(i2)); display s80_objective; + solve magpie USING nlp MINIMIZING vm_cost_glo; if (p80_resolve_option(h) < 6, p80_resolve_option(h) = p80_resolve_option(h) + 1; else From 09535ff25dff9257e5742cc07d39f4cb84d36b43 Mon Sep 17 00:00:00 2001 From: florianh Date: Sat, 4 May 2024 11:15:00 +0200 Subject: [PATCH 084/133] updates --- CHANGELOG.md | 4 +- config/default.cfg | 5 +- .../80_optimization/lp_nlp_apr17/input.gms | 3 +- .../80_optimization/lp_nlp_apr17/solve.gms | 22 ++++---- .../nlp_apr17/declarations.gms | 5 +- modules/80_optimization/nlp_apr17/input.gms | 3 +- modules/80_optimization/nlp_apr17/solve.gms | 51 ++++++++--------- .../80_optimization/nlp_par/declarations.gms | 2 - modules/80_optimization/nlp_par/input.gms | 3 +- modules/80_optimization/nlp_par/solve.gms | 56 +++++-------------- scripts/output/extra/highres.R | 2 +- 11 files changed, 65 insertions(+), 91 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e3e166f765..7f64500b7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,12 +12,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **30_crop** SNV implementation has been moved from `30_crop` to `29_cropland` - **30_crop** the two realizations `penalty_apr22` and `rotation_apr22` have been merged into a single `30_croparea/detail_apr24` realization - **30_crop** the previous `30_crop/endo_apr21` realization has been moved to `30_croparea/simple_apr24` -- **default.cfg** cfg$gms$s80_maxiter reduced from 30 to 10 +- **80_optimization** Simplifed cycling through CONOPT4, CONOPT4 with OPTFILE and CONOPT3. REMOVED CONOPT4 without preprocessing, which usually only increases run time without feasbile solution. ### added - **29_cropland** new module `29_cropland` accounting for crop area, fallow cropland and tree cover on cropland with two realizations: `detail_apr24` and `simple_apr24` (default). - **10_land** added interface `pm_land_hist` with historic land use patterns - **32_forestry** added technical balance term `v32_land_missing_ndc` +- **default.cfg** cfg$gms$s80_secondsolve option for second solve statement with 0=off as default ### removed - **scripts/output/extra** removed scripts disaggregation_cropsplit and disaggregation_transitions @@ -29,7 +30,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **scenario_config.csv** same revision for input files as in default.cfg - **scenario_fsec.csv** scenario settings - **start/projects/fsec.R** scenario settings -- **80_optimization** fixed a bug in nlp_apr17; cycling through CONOPT4, CONOPT4 without preprocessing and CONOPT3 was not working - **80_optimization** bugfix in nlp_par. Double solve statement was not working - **58_peatland** Added balance variable to avoid random infeasibilites diff --git a/config/default.cfg b/config/default.cfg index 5832345699..2457dd5f7d 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -1953,7 +1953,7 @@ cfg$gms$s73_expansion <- 0 # def = 0 cfg$gms$optimization <- "nlp_apr17" # def = nlp_apr17 # maximal number of solve iterations -cfg$gms$s80_maxiter <- 10 # def = 10 +cfg$gms$s80_maxiter <- 30 # def = 30 # Solver settings only for realization `lp_nlp_apr17`. All other realizations use `conopt4`. # * (conopt4): conopt4 @@ -1965,6 +1965,9 @@ cfg$gms$c80_nlp_solver <- "conopt4" # def = conopt4 # * 0: default settings (optfile will be ignored) cfg$gms$s80_optfile <- 0 # def = 0 +# * Optional second solve statement (0=off, 1=on) +cfg$gms$s80_secondsolve <- 0 # def = 0 + #*******************************END MODULE SETUP******************************** #### Other settings (e.g. clustering, gdx files, ...): #### diff --git a/modules/80_optimization/lp_nlp_apr17/input.gms b/modules/80_optimization/lp_nlp_apr17/input.gms index 83427b7cfe..3e8b6bcfd0 100644 --- a/modules/80_optimization/lp_nlp_apr17/input.gms +++ b/modules/80_optimization/lp_nlp_apr17/input.gms @@ -6,10 +6,11 @@ *** | Contact: magpie@pik-potsdam.de scalars - s80_maxiter maximal solve iterations if modelstat is > 2 (1) / 10 / + s80_maxiter maximal solve iterations if modelstat is > 2 (1) / 30 / s80_optfile switch to use specfied solver settings (1) / 0 / s80_add_cplex add cplex optimization after conopt4 (1) / 0 / s80_add_conopt3 add conopt3 optimization after conopt4 (1) / 0 / + s80_secondsolve second solve statement (binary) / 0 / ; diff --git a/modules/80_optimization/lp_nlp_apr17/solve.gms b/modules/80_optimization/lp_nlp_apr17/solve.gms index 85ec1ef813..b399e37c21 100644 --- a/modules/80_optimization/lp_nlp_apr17/solve.gms +++ b/modules/80_optimization/lp_nlp_apr17/solve.gms @@ -65,7 +65,7 @@ $batinclude "./modules/include.gms" nl_fix *' in particular for matching LHS and RHS of equations. solve magpie USING nlp MINIMIZING vm_cost_glo; - solve magpie USING nlp MINIMIZING vm_cost_glo; + if(s80_secondsolve = 1, solve magpie USING nlp MINIMIZING vm_cost_glo; ); *' A second optimization makes sure that in case of a flat optimum that solution *' is chosen for which the difference in land changes compared to the previous @@ -76,7 +76,7 @@ $batinclude "./modules/include.gms" nl_fix if ((magpie.modelstat=1 or magpie.modelstat = 7), vm_cost_glo.up = vm_cost_glo.l; solve magpie USING nlp MINIMIZING vm_landdiff; - solve magpie USING nlp MINIMIZING vm_landdiff; + if(s80_secondsolve = 1, solve magpie USING nlp MINIMIZING vm_landdiff; ); vm_cost_glo.up = Inf; ); @@ -130,7 +130,7 @@ $batinclude "./modules/include.gms" nl_relax *' the nonlinear optimization of the model in its full complexity. solve magpie USING nlp MINIMIZING vm_cost_glo; - solve magpie USING nlp MINIMIZING vm_cost_glo; + if(s80_secondsolve = 1, solve magpie USING nlp MINIMIZING vm_cost_glo; ); *' @stop @@ -139,16 +139,17 @@ $batinclude "./modules/include.gms" nl_relax display "Additional solve with CONOPT3!"; option nlp = conopt; solve magpie USING nlp MINIMIZING vm_cost_glo; - solve magpie USING nlp MINIMIZING vm_cost_glo; + if(s80_secondsolve = 1, solve magpie USING nlp MINIMIZING vm_cost_glo; ); option nlp = conopt4; ); -* if solve stopped with an error, try it again without pre-processing +* if solve stopped with an error, try it again with CONOPT4 and OPTFILE if((magpie.modelstat = 13), - display "WARNING: Modelstat 13 | retry without Conopt4 pre-processing"; - magpie.optfile = 2 - solve magpie USING nlp MINIMIZING vm_cost_glo; + display "WARNING: Modelstat 13 | retry with CONOPT4 OPTFILE"; + option nlp = conopt4; + magpie.optfile = 1 solve magpie USING nlp MINIMIZING vm_cost_glo; + if(s80_secondsolve = 1, solve magpie USING nlp MINIMIZING vm_cost_glo; ); magpie.optfile = s80_optfile ; ); @@ -157,7 +158,7 @@ $batinclude "./modules/include.gms" nl_relax display "WARNING: Modelstat 13 | retry with CONOPT3!"; option nlp = conopt; solve magpie USING nlp MINIMIZING vm_cost_glo; - solve magpie USING nlp MINIMIZING vm_cost_glo; + if(s80_secondsolve = 1, solve magpie USING nlp MINIMIZING vm_cost_glo; ); option nlp = conopt4; ); @@ -188,13 +189,14 @@ magpie.trylinear = 1; $batinclude "./modules/include.gms" nl_fix solve magpie USING nlp MINIMIZING vm_cost_glo; -solve magpie USING nlp MINIMIZING vm_cost_glo; +if(s80_secondsolve = 1, solve magpie USING nlp MINIMIZING vm_cost_glo; ); $batinclude "./modules/include.gms" nl_release if((magpie.modelstat=1 or magpie.modelstat = 7), vm_cost_glo.up = vm_cost_glo.l; solve magpie USING nlp MINIMIZING vm_landdiff; + if(s80_secondsolve = 1, solve magpie USING nlp MINIMIZING vm_landdiff; ); vm_cost_glo.up = Inf; ); diff --git a/modules/80_optimization/nlp_apr17/declarations.gms b/modules/80_optimization/nlp_apr17/declarations.gms index be5b332fc0..df685b2608 100644 --- a/modules/80_optimization/nlp_apr17/declarations.gms +++ b/modules/80_optimization/nlp_apr17/declarations.gms @@ -11,7 +11,6 @@ parameters ; scalars - s80_counter counter (1) - s80_modelstat_previter modelstat of previous iteration (1) - s80_optfile_previter optfile used in previous iteration (1) + s80_counter counter (1) + s80_resolve_option option for resolve (1) ; diff --git a/modules/80_optimization/nlp_apr17/input.gms b/modules/80_optimization/nlp_apr17/input.gms index b26b854d44..5c645af1c2 100644 --- a/modules/80_optimization/nlp_apr17/input.gms +++ b/modules/80_optimization/nlp_apr17/input.gms @@ -6,6 +6,7 @@ *** | Contact: magpie@pik-potsdam.de scalars - s80_maxiter maximal solve iterations if modelstat is > 2 (1) / 10 / + s80_maxiter maximal solve iterations if modelstat is > 2 (1) / 30 / s80_optfile switch to use specfied solver settings (1) / 0 / + s80_secondsolve second solve statement (binary) / 0 / ; diff --git a/modules/80_optimization/nlp_apr17/solve.gms b/modules/80_optimization/nlp_apr17/solve.gms index bae758fec1..5fed3ef9fb 100644 --- a/modules/80_optimization/nlp_apr17/solve.gms +++ b/modules/80_optimization/nlp_apr17/solve.gms @@ -8,8 +8,7 @@ s80_counter = 0; p80_modelstat(t) = 14; -s80_modelstat_previter = 14; -s80_optfile_previter = s80_optfile; +s80_resolve_option = 1; *** solver settings option nlp = conopt4; @@ -30,10 +29,9 @@ Flg_Prep = FALSE $offecho *' @code -*' Solve statement is put twice for improved model results, -*' in particular for matching LHS and RHS of equations. -solve magpie USING nlp MINIMIZING vm_cost_glo; solve magpie USING nlp MINIMIZING vm_cost_glo; +*' Optional second solve statement +if(s80_secondsolve = 1, solve magpie USING nlp MINIMIZING vm_cost_glo; ); *' @stop display "vm_cost_glo.l"; @@ -44,30 +42,24 @@ display magpie.modelstat; if (magpie.modelstat > 2, repeat( s80_counter = s80_counter + 1 ; - - if (magpie.modelstat ne s80_modelstat_previter, + if(s80_resolve_option = 1, display "Modelstat > 2 | Retry solve with CONOPT4 default setting"; - solve magpie USING nlp MINIMIZING vm_cost_glo; - solve magpie USING nlp MINIMIZING vm_cost_glo; - elseif magpie.modelstat = s80_modelstat_previter, - if (magpie.optfile = s80_optfile_previter, - display "Modelstat > 2 | Retry solve without CONOPT4 pre-processing"; - magpie.optfile = 2; - solve magpie USING nlp MINIMIZING vm_cost_glo; - solve magpie USING nlp MINIMIZING vm_cost_glo; - else - display "Modelstat > 2 | Retry solve with CONOPT3"; - option nlp = conopt; - solve magpie USING nlp MINIMIZING vm_cost_glo; - solve magpie USING nlp MINIMIZING vm_cost_glo; - option nlp = conopt4; - ); - ); - - s80_modelstat_previter = magpie.modelstat; - s80_optfile_previter = magpie.optfile; -* reset `magpie.optfile` to default after saving value to `s80_optfile_previter` - magpie.optfile = s80_optfile; + option nlp = conopt4; + magpie.optfile = 0; + elseif s80_resolve_option = 2, + display "Modelstat > 2 | Retry solve with CONOPT4 OPTFILE"; + option nlp = conopt4; + magpie.optfile = 1; + elseif s80_resolve_option = 3, + display "Modelstat > 2 | Retry solve with CONOPT3"; + option nlp = conopt; + magpie.optfile = 0; + ); + + solve magpie USING nlp MINIMIZING vm_cost_glo; + if(s80_secondsolve = 1, solve magpie USING nlp MINIMIZING vm_cost_glo; ); + option nlp = conopt4; + magpie.optfile = s80_optfile; display "vm_cost_glo.l"; display vm_cost_glo.l; @@ -79,6 +71,9 @@ if (magpie.modelstat > 2, display s80_counter; display magpie.modelstat; + + s80_resolve_option$(s80_resolve_option < 3) = s80_resolve_option + 1; + s80_resolve_option$(s80_resolve_option >= 3) = 1; until (magpie.modelstat <= 2 or s80_counter >= s80_maxiter) ); diff --git a/modules/80_optimization/nlp_par/declarations.gms b/modules/80_optimization/nlp_par/declarations.gms index 95454dded2..3627704eb7 100644 --- a/modules/80_optimization/nlp_par/declarations.gms +++ b/modules/80_optimization/nlp_par/declarations.gms @@ -17,6 +17,4 @@ parameters scalars s80_counter counter (1) s80_objective objective function value (mio. USD05MER per yr) - s80_modelstat_previter modelstat of previous iteration (1) - s80_optfile_previter optfile used in previous iteration (1) ; diff --git a/modules/80_optimization/nlp_par/input.gms b/modules/80_optimization/nlp_par/input.gms index eaf3fdd672..1004040b7e 100644 --- a/modules/80_optimization/nlp_par/input.gms +++ b/modules/80_optimization/nlp_par/input.gms @@ -6,6 +6,7 @@ *** | Contact: magpie@pik-potsdam.de scalars - s80_maxiter maximal solve iterations if modelstat is > 2 (1) / 10 / + s80_maxiter maximal solve iterations if modelstat is > 2 (1) / 30 / s80_optfile switch to use specfied solver settings (1) / 0 / + s80_secondsolve second solve statement (binary) / 0 / ; diff --git a/modules/80_optimization/nlp_par/solve.gms b/modules/80_optimization/nlp_par/solve.gms index ae525173c6..e33de6b697 100644 --- a/modules/80_optimization/nlp_par/solve.gms +++ b/modules/80_optimization/nlp_par/solve.gms @@ -67,9 +67,7 @@ repeat display s80_objective; magpie.modelStat$(magpie.modelStat=NA) = 13; - s80_modelstat_previter = p80_modelstat(t,h); p80_modelstat(t,h) = magpie.modelStat; - s80_optfile_previter = magpie.optfile; if(p80_counter(h) >= s80_maxiter AND p80_modelstat(t,h) > 2, if(p80_modelstat(t,h) = 13, @@ -87,7 +85,7 @@ repeat if(p80_modelstat(t,h) <= 2, p80_counter_modelstat(h) = p80_counter_modelstat(h) + 1; - if(p80_counter_modelstat(h) < 2, + if(p80_counter_modelstat(h) < 2 AND s80_secondsolve = 1, display "Model status <= 2. Starting second solve"; solve magpie USING nlp MINIMIZING vm_cost_glo; p80_handle(h) = magpie.handle; @@ -103,41 +101,27 @@ repeat display "Resolve" if(p80_resolve_option(h) = 1, display "Modelstat > 2 | Retry solve with CONOPT4 default setting"; + option nlp = conopt4; magpie.optfile = 0; elseif p80_resolve_option(h) = 2, - display "Modelstat > 2 | Retry solve with CONOPT4 default setting and magpie_p_last_timestep.gdx"; - magpie.optfile = 0; - Execute_Loadpoint "magpie_p_last_timestep.gdx"; - elseif p80_resolve_option(h) = 3, - display "Modelstat > 2 | Retry solve with CONOPT4 default setting and magpie_y2020.gdx"; - magpie.optfile = 0; - Execute_Loadpoint "magpie_y2020.gdx"; - elseif p80_resolve_option(h) = 4, display "Modelstat > 2 | Retry solve with CONOPT4 OPTFILE"; - magpie.optfile = 1; - elseif p80_resolve_option(h) = 5, - display "Modelstat > 2 | Retry solve with CONOPT4 OPTFILE and magpie_p_last_timestep.gdx"; - magpie.optfile = 1; - Execute_Loadpoint "magpie_p_last_timestep.gdx"; - elseif p80_resolve_option(h) = 6, - display "Modelstat > 2 | Retry solve with CONOPT4 OPTFILE and magpie_y2020.gdx"; - magpie.optfile = 1; - Execute_Loadpoint "magpie_y2020.gdx"; + option nlp = conopt4; + magpie.optfile = 1; + elseif p80_resolve_option(h) = 3, + display "Modelstat > 2 | Retry solve with CONOPT3"; + option nlp = conopt; + magpie.optfile = 0; ); if(execerror > 0, execerror = 0); - s80_objective = sum(i2,v11_cost_reg.l(i2)); - display s80_objective; + solve magpie USING nlp MINIMIZING vm_cost_glo; - if (p80_resolve_option(h) < 6, - p80_resolve_option(h) = p80_resolve_option(h) + 1; - else - p80_resolve_option(h) = 1; - ); - if(magpie.handle = 0, - display "Problem. Handle is zero despite resolve. Setting handle to 1 for continuation."; - magpie.handle = 1; - ); + magpie.handle$(magpie.handle = 0) = 1; p80_handle(h) = magpie.handle; + option nlp = conopt4; + magpie.optfile = s80_optfile; + + p80_resolve_option(h)$(p80_resolve_option(h) < 3) = p80_resolve_option(h) + 1; + p80_resolve_option(h)$(p80_resolve_option(h) >= 3) = 1; ); h2(h) = no; i2(i) = no; @@ -148,16 +132,6 @@ display$sleep(card(p80_handle)*0.2) 'sleep some time'; display$readyCollect(p80_handle,INF) 'Problem waiting for next instance to complete'; until card(p80_handle) = 0 OR smax(h, p80_counter(h)) >= s80_maxiter; -* Save results to gdx point files -* Historical period for magpie_p_y[XXXX].gdx files is excluded to avoid diversion of results compared to other model runs if restarted with s_use_gdx = 2. -if (smax(h,p80_modelstat(t,h)) <= 2, - put_utility 'shell' / 'cp -f magpie_p.gdx magpie_p_last_timestep.gdx'; - if (m_year(t) > sm_fix_SSP2, - put_utility 'shell' / 'cp -f magpie_p.gdx magpie_' t.tl:0'.gdx'; - ); - put_utility 'shell' / 'rm -f magpie_p.gdx'; -); - if (smax(h,p80_modelstat(t,h)) > 2 and smax(h,p80_modelstat(t,h)) ne 7, Execute_Unload "fulldata.gdx"; abort "No feasible solution found!"; diff --git a/scripts/output/extra/highres.R b/scripts/output/extra/highres.R index 809868fef6..63c57f0e88 100644 --- a/scripts/output/extra/highres.R +++ b/scripts/output/extra/highres.R @@ -101,7 +101,7 @@ highres <- function(cfg) { #note: using gdx files for more than the 1st time step sometimes pushes the model into corner solutions, which might result in infeasibilites. cfg$files2export$start <- c(cfg$files2export$start, paste0(cfg$results_folder, "/", "magpie_y*.gdx")) - cfg$gms$s_use_gdx <- 2 + cfg$gms$s_use_gdx <- 0 #max resources for parallel runs cfg$qos <- "standby_maxMem_dayMax" From 4e94659b18e923d3a8629ee8c23d0e78e6185ddc Mon Sep 17 00:00:00 2001 From: florianh Date: Sat, 4 May 2024 11:23:09 +0200 Subject: [PATCH 085/133] update --- modules/80_optimization/nlp_apr17/solve.gms | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/80_optimization/nlp_apr17/solve.gms b/modules/80_optimization/nlp_apr17/solve.gms index 5fed3ef9fb..b30a7dfa17 100644 --- a/modules/80_optimization/nlp_apr17/solve.gms +++ b/modules/80_optimization/nlp_apr17/solve.gms @@ -87,6 +87,8 @@ if ((p80_modelstat(t) <= 2), ); if ((p80_modelstat(t) > 2 and p80_modelstat(t) ne 7), + execute 'gmszip -r magpie_problem.zip "%gams.scrdir%"' + put_utility 'shell' / 'mv -f magpie_problem.zip magpie_problem_' t.tl:0'.zip'; Execute_Unload "fulldata.gdx"; abort "no feasible solution found!"; ); From 2f79c13364ec1ef8170daba18bea207c5ea6810e Mon Sep 17 00:00:00 2001 From: florianh Date: Sat, 4 May 2024 15:52:40 +0200 Subject: [PATCH 086/133] bugfix --- modules/80_optimization/nlp_par/declarations.gms | 1 + modules/80_optimization/nlp_par/solve.gms | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/modules/80_optimization/nlp_par/declarations.gms b/modules/80_optimization/nlp_par/declarations.gms index 3627704eb7..1734708bc8 100644 --- a/modules/80_optimization/nlp_par/declarations.gms +++ b/modules/80_optimization/nlp_par/declarations.gms @@ -17,4 +17,5 @@ parameters scalars s80_counter counter (1) s80_objective objective function value (mio. USD05MER per yr) + s80_resolve_option option for resolve (1) ; diff --git a/modules/80_optimization/nlp_par/solve.gms b/modules/80_optimization/nlp_par/solve.gms index e33de6b697..c35af4fa48 100644 --- a/modules/80_optimization/nlp_par/solve.gms +++ b/modules/80_optimization/nlp_par/solve.gms @@ -60,6 +60,7 @@ repeat i2(i)$supreg(h,i) = yes; loop(i2, j2(j)$cell(i2,j) = yes); display h2; + display i2; s80_counter = sum(h2,p80_counter(h2)); s80_objective = sum(i2,v11_cost_reg.l(i2)); display s80_counter; @@ -70,10 +71,8 @@ repeat p80_modelstat(t,h) = magpie.modelStat; if(p80_counter(h) >= s80_maxiter AND p80_modelstat(t,h) > 2, - if(p80_modelstat(t,h) = 13, execute 'gmszip -r magpie_problem.zip "%gams.scrdir%"' put_utility 'shell' / 'mv -f magpie_problem.zip magpie_problem_' h.tl:0'_' t.tl:0'.zip'; - ); display "No feasible solution found. Writing LST file."; option AsyncSolLst=1; display$handlecollect(p80_handle(h)) 're-collect'; @@ -99,6 +98,9 @@ repeat if(p80_extra_solve(h) = 1, display "Resolve" + execute_loadpoint 'fulldata.gdx'; + s80_resolve_option = sum(h2,p80_resolve_option(h2)); + display s80_resolve_option; if(p80_resolve_option(h) = 1, display "Modelstat > 2 | Retry solve with CONOPT4 default setting"; option nlp = conopt4; @@ -108,6 +110,10 @@ repeat option nlp = conopt4; magpie.optfile = 1; elseif p80_resolve_option(h) = 3, + display "Modelstat > 2 | Retry solve with CONOPT4 w/o preprocessing"; + option nlp = conopt4; + magpie.optfile = 2; + elseif p80_resolve_option(h) = 4, display "Modelstat > 2 | Retry solve with CONOPT3"; option nlp = conopt; magpie.optfile = 0; @@ -120,8 +126,8 @@ repeat option nlp = conopt4; magpie.optfile = s80_optfile; - p80_resolve_option(h)$(p80_resolve_option(h) < 3) = p80_resolve_option(h) + 1; - p80_resolve_option(h)$(p80_resolve_option(h) >= 3) = 1; + p80_resolve_option(h)$(p80_resolve_option(h) < 4) = p80_resolve_option(h) + 1; + p80_resolve_option(h)$(p80_resolve_option(h) >= 4) = 1; ); h2(h) = no; i2(i) = no; From 8fa321792a129f288d95e476ddef61c56c237d50 Mon Sep 17 00:00:00 2001 From: florianh Date: Sat, 4 May 2024 16:43:19 +0200 Subject: [PATCH 087/133] test --- modules/80_optimization/nlp_par/solve.gms | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/80_optimization/nlp_par/solve.gms b/modules/80_optimization/nlp_par/solve.gms index c35af4fa48..d0b8e59b2f 100644 --- a/modules/80_optimization/nlp_par/solve.gms +++ b/modules/80_optimization/nlp_par/solve.gms @@ -18,6 +18,7 @@ magpie.optfile = s80_optfile ; magpie.scaleopt = 1 ; magpie.solprint = 0 ; magpie.holdfixed = 1 ; +magpie.savepoint = 2; $onecho > conopt4.opt Tol_Obj_Change = 3.0e-6 @@ -54,6 +55,7 @@ repeat p80_extra_solve(h) = 1; magpie.handle = p80_handle(h); + display magpie.handle; execute_loadhandle magpie; h2(h) = yes; @@ -112,7 +114,7 @@ repeat elseif p80_resolve_option(h) = 3, display "Modelstat > 2 | Retry solve with CONOPT4 w/o preprocessing"; option nlp = conopt4; - magpie.optfile = 2; + magpie.optfile = 0; elseif p80_resolve_option(h) = 4, display "Modelstat > 2 | Retry solve with CONOPT3"; option nlp = conopt; From fdbbc1cffd4dffb77f9fdb5dc9b6188d6e81bc3e Mon Sep 17 00:00:00 2001 From: florianh Date: Sat, 4 May 2024 17:40:45 +0200 Subject: [PATCH 088/133] test --- modules/80_optimization/nlp_par/solve.gms | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/80_optimization/nlp_par/solve.gms b/modules/80_optimization/nlp_par/solve.gms index d0b8e59b2f..3ef2c52736 100644 --- a/modules/80_optimization/nlp_par/solve.gms +++ b/modules/80_optimization/nlp_par/solve.gms @@ -9,7 +9,7 @@ p80_counter(h) = 0; p80_modelstat(t,h) = 14; p80_counter_modelstat(h) = 0; -p80_resolve_option(h) = 1; +p80_resolve_option(h) = 0; *** solver settings option nlp = conopt4; @@ -18,7 +18,7 @@ magpie.optfile = s80_optfile ; magpie.scaleopt = 1 ; magpie.solprint = 0 ; magpie.holdfixed = 1 ; -magpie.savepoint = 2; +magpie.savepoint = 3; $onecho > conopt4.opt Tol_Obj_Change = 3.0e-6 @@ -100,6 +100,7 @@ repeat if(p80_extra_solve(h) = 1, display "Resolve" + p80_resolve_option(h) = p80_resolve_option(h) + 1; execute_loadpoint 'fulldata.gdx'; s80_resolve_option = sum(h2,p80_resolve_option(h2)); display s80_resolve_option; @@ -128,8 +129,7 @@ repeat option nlp = conopt4; magpie.optfile = s80_optfile; - p80_resolve_option(h)$(p80_resolve_option(h) < 4) = p80_resolve_option(h) + 1; - p80_resolve_option(h)$(p80_resolve_option(h) >= 4) = 1; + p80_resolve_option(h)$(p80_resolve_option(h) >= 4) = 0; ); h2(h) = no; i2(i) = no; From 47256b8dc6545ae952911d1007fe1980e50c82ac Mon Sep 17 00:00:00 2001 From: florianh Date: Sat, 4 May 2024 17:51:53 +0200 Subject: [PATCH 089/133] bugfix --- modules/80_optimization/nlp_par/solve.gms | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/80_optimization/nlp_par/solve.gms b/modules/80_optimization/nlp_par/solve.gms index 3ef2c52736..d0d08f9150 100644 --- a/modules/80_optimization/nlp_par/solve.gms +++ b/modules/80_optimization/nlp_par/solve.gms @@ -99,7 +99,7 @@ repeat ); if(p80_extra_solve(h) = 1, - display "Resolve" + display "Resolve"; p80_resolve_option(h) = p80_resolve_option(h) + 1; execute_loadpoint 'fulldata.gdx'; s80_resolve_option = sum(h2,p80_resolve_option(h2)); From ce923a390c5ff487eead41913e64b66c7a5d5bbe Mon Sep 17 00:00:00 2001 From: florianh Date: Sat, 4 May 2024 23:10:28 +0200 Subject: [PATCH 090/133] update --- CHANGELOG.md | 2 +- modules/80_optimization/lp_nlp_apr17/solve.gms | 4 ++-- modules/80_optimization/nlp_apr17/solve.gms | 11 ++++++++--- modules/80_optimization/nlp_par/solve.gms | 4 +--- scripts/output/extra/highres.R | 2 +- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f64500b7b..bd69fe994a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **30_crop** SNV implementation has been moved from `30_crop` to `29_cropland` - **30_crop** the two realizations `penalty_apr22` and `rotation_apr22` have been merged into a single `30_croparea/detail_apr24` realization - **30_crop** the previous `30_crop/endo_apr21` realization has been moved to `30_croparea/simple_apr24` -- **80_optimization** Simplifed cycling through CONOPT4, CONOPT4 with OPTFILE and CONOPT3. REMOVED CONOPT4 without preprocessing, which usually only increases run time without feasbile solution. +- **80_optimization** Simplifed cycling through CONOPT4, CONOPT4 with OPTFILE, CONOPT4 without preprocessing and CONOPT3. ### added - **29_cropland** new module `29_cropland` accounting for crop area, fallow cropland and tree cover on cropland with two realizations: `detail_apr24` and `simple_apr24` (default). diff --git a/modules/80_optimization/lp_nlp_apr17/solve.gms b/modules/80_optimization/lp_nlp_apr17/solve.gms index b399e37c21..5749c3db5a 100644 --- a/modules/80_optimization/lp_nlp_apr17/solve.gms +++ b/modules/80_optimization/lp_nlp_apr17/solve.gms @@ -145,9 +145,9 @@ $batinclude "./modules/include.gms" nl_relax * if solve stopped with an error, try it again with CONOPT4 and OPTFILE if((magpie.modelstat = 13), - display "WARNING: Modelstat 13 | retry with CONOPT4 OPTFILE"; + display "WARNING: Modelstat 13 | retry without Conopt4 pre-processing"; option nlp = conopt4; - magpie.optfile = 1 + magpie.optfile = 2 solve magpie USING nlp MINIMIZING vm_cost_glo; if(s80_secondsolve = 1, solve magpie USING nlp MINIMIZING vm_cost_glo; ); magpie.optfile = s80_optfile ; diff --git a/modules/80_optimization/nlp_apr17/solve.gms b/modules/80_optimization/nlp_apr17/solve.gms index b30a7dfa17..d6a436a21b 100644 --- a/modules/80_optimization/nlp_apr17/solve.gms +++ b/modules/80_optimization/nlp_apr17/solve.gms @@ -8,7 +8,7 @@ s80_counter = 0; p80_modelstat(t) = 14; -s80_resolve_option = 1; +s80_resolve_option = 0; *** solver settings option nlp = conopt4; @@ -42,6 +42,8 @@ display magpie.modelstat; if (magpie.modelstat > 2, repeat( s80_counter = s80_counter + 1 ; + s80_resolve_option = s80_resolve_option + 1; + if(s80_resolve_option = 1, display "Modelstat > 2 | Retry solve with CONOPT4 default setting"; option nlp = conopt4; @@ -51,6 +53,10 @@ if (magpie.modelstat > 2, option nlp = conopt4; magpie.optfile = 1; elseif s80_resolve_option = 3, + display "Modelstat > 2 | Retry solve with CONOPT4 w/o preprocessing"; + option nlp = conopt4; + magpie.optfile = 2; + elseif s80_resolve_option = 4, display "Modelstat > 2 | Retry solve with CONOPT3"; option nlp = conopt; magpie.optfile = 0; @@ -72,8 +78,7 @@ if (magpie.modelstat > 2, display s80_counter; display magpie.modelstat; - s80_resolve_option$(s80_resolve_option < 3) = s80_resolve_option + 1; - s80_resolve_option$(s80_resolve_option >= 3) = 1; + s80_resolve_option$(s80_resolve_option >= 4) = 0; until (magpie.modelstat <= 2 or s80_counter >= s80_maxiter) ); diff --git a/modules/80_optimization/nlp_par/solve.gms b/modules/80_optimization/nlp_par/solve.gms index d0d08f9150..a992c479db 100644 --- a/modules/80_optimization/nlp_par/solve.gms +++ b/modules/80_optimization/nlp_par/solve.gms @@ -55,14 +55,12 @@ repeat p80_extra_solve(h) = 1; magpie.handle = p80_handle(h); - display magpie.handle; execute_loadhandle magpie; h2(h) = yes; i2(i)$supreg(h,i) = yes; loop(i2, j2(j)$cell(i2,j) = yes); display h2; - display i2; s80_counter = sum(h2,p80_counter(h2)); s80_objective = sum(i2,v11_cost_reg.l(i2)); display s80_counter; @@ -115,7 +113,7 @@ repeat elseif p80_resolve_option(h) = 3, display "Modelstat > 2 | Retry solve with CONOPT4 w/o preprocessing"; option nlp = conopt4; - magpie.optfile = 0; + magpie.optfile = 2; elseif p80_resolve_option(h) = 4, display "Modelstat > 2 | Retry solve with CONOPT3"; option nlp = conopt; diff --git a/scripts/output/extra/highres.R b/scripts/output/extra/highres.R index 63c57f0e88..809868fef6 100644 --- a/scripts/output/extra/highres.R +++ b/scripts/output/extra/highres.R @@ -101,7 +101,7 @@ highres <- function(cfg) { #note: using gdx files for more than the 1st time step sometimes pushes the model into corner solutions, which might result in infeasibilites. cfg$files2export$start <- c(cfg$files2export$start, paste0(cfg$results_folder, "/", "magpie_y*.gdx")) - cfg$gms$s_use_gdx <- 0 + cfg$gms$s_use_gdx <- 2 #max resources for parallel runs cfg$qos <- "standby_maxMem_dayMax" From 3747457d0a55e20318fd6fc244196993151eb7ac Mon Sep 17 00:00:00 2001 From: florianh Date: Sat, 4 May 2024 23:13:57 +0200 Subject: [PATCH 091/133] update --- modules/80_optimization/nlp_par/solve.gms | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/80_optimization/nlp_par/solve.gms b/modules/80_optimization/nlp_par/solve.gms index a992c479db..be16edae5f 100644 --- a/modules/80_optimization/nlp_par/solve.gms +++ b/modules/80_optimization/nlp_par/solve.gms @@ -18,7 +18,7 @@ magpie.optfile = s80_optfile ; magpie.scaleopt = 1 ; magpie.solprint = 0 ; magpie.holdfixed = 1 ; -magpie.savepoint = 3; +magpie.savepoint = 0; $onecho > conopt4.opt Tol_Obj_Change = 3.0e-6 From b4a596d710c85191ed926c1ed26309a1dbf1f2e6 Mon Sep 17 00:00:00 2001 From: florianh Date: Sun, 5 May 2024 12:52:57 +0200 Subject: [PATCH 092/133] update --- modules/80_optimization/nlp_par/solve.gms | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/80_optimization/nlp_par/solve.gms b/modules/80_optimization/nlp_par/solve.gms index be16edae5f..3b06cbcbf0 100644 --- a/modules/80_optimization/nlp_par/solve.gms +++ b/modules/80_optimization/nlp_par/solve.gms @@ -99,6 +99,7 @@ repeat if(p80_extra_solve(h) = 1, display "Resolve"; p80_resolve_option(h) = p80_resolve_option(h) + 1; + display "Load solution from last time step as starting point"; execute_loadpoint 'fulldata.gdx'; s80_resolve_option = sum(h2,p80_resolve_option(h2)); display s80_resolve_option; From 9e175b4d3974a5e8c2bb217ca70afb8afd54e394 Mon Sep 17 00:00:00 2001 From: florianh Date: Mon, 6 May 2024 20:06:09 +0200 Subject: [PATCH 093/133] bugfix --- modules/29_cropland/detail_apr24/presolve.gms | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/29_cropland/detail_apr24/presolve.gms b/modules/29_cropland/detail_apr24/presolve.gms index 54fe3c9120..6f0deb94ca 100644 --- a/modules/29_cropland/detail_apr24/presolve.gms +++ b/modules/29_cropland/detail_apr24/presolve.gms @@ -53,15 +53,10 @@ if (s29_treecover_keep = 1, i29_treecover_target(t,j)$(i29_treecover_target(t,j) < pc29_treecover_share(j)) = pc29_treecover_share(j); ); -v29_treecover.lo(j,ac_est) = 0; -v29_treecover.up(j,ac_est) = Inf; -v29_treecover.lo(j,ac_sub) = 0; -v29_treecover.up(j,ac_sub) = pc29_treecover(j,ac_sub); -m_boundfix(v29_treecover,(j,ac_sub),l,1e-6); - if (m_year(t) <= s29_treecover_scenario_start, i29_treecover_penalty(t) = 0; v29_treecover_missing.fx(j) = 0; + v29_treecover.fx(j,ac) = pc29_treecover(j,ac); else i29_treecover_penalty(t) = s29_treecover_penalty; if (i29_treecover_penalty(t) > 0, @@ -70,6 +65,11 @@ else else v29_treecover_missing.fx(j) = 0; ); + v29_treecover.lo(j,ac_est) = 0; + v29_treecover.up(j,ac_est) = Inf; + v29_treecover.lo(j,ac_sub) = 0; + v29_treecover.up(j,ac_sub) = pc29_treecover(j,ac_sub); + m_boundfix(v29_treecover,(j,ac_sub),l,1e-6); ); * create fallow land target and penalty scenario From 72ce77ef0fd55579ad6a54b2079447c00e04f16f Mon Sep 17 00:00:00 2001 From: florianh Date: Tue, 7 May 2024 08:19:11 +0200 Subject: [PATCH 094/133] updates --- config/default.cfg | 9 ++++-- modules/29_cropland/detail_apr24/presolve.gms | 28 +++++++++---------- modules/80_optimization/nlp_apr17/solve.gms | 8 +++++- 3 files changed, 27 insertions(+), 18 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index 2457dd5f7d..4f4d18ab7d 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -720,7 +720,8 @@ cfg$gms$land_snv <- "secdforest, forestry, past, other" #def = "secdforest, f # * Minimum cluster share of treecover on total cropland area (including croparea, fallow land and tree cover). # * s29_treecover_target is faded in linearly between s29_treecover_scenario_start and s29_treecover_scenario_target. cfg$gms$s29_treecover_target <- 0 # def = 0 -# * Avoid loss of existing treecover (1=yes 0=no) +# * Avoid loss of existing treecover (1=yes 0=no). +# * If set to 1, `s29_treecover_target` will be adjusted based existing treecover area. cfg$gms$s29_treecover_keep <- 1 # def = 1 # * Maximum share of treecover on total cropland (1) cfg$gms$s29_treecover_max <- 0.4 # def = 0.4 @@ -728,12 +729,14 @@ cfg$gms$s29_treecover_max <- 0.4 # def = 0.4 cfg$gms$s29_treecover_scenario_start <- 2020 # def = 2020 # * Target year (year when full implementation is reached): cfg$gms$s29_treecover_scenario_target <- 2050 # def = 2050 +# * Penalty for violation of treecover target before scenario start (USD05MER per ha) +cfg$gms$s29_treecover_penalty_before <- 2000 # def = 2000 +# * Penalty for violation of treecover target after scenario start (USD05MER per ha) +cfg$gms$s29_treecover_penalty <- 2000 # def = 2000 # * Tree cover establishment cost (USD05MER per ha) cfg$gms$s29_cost_treecover_est <- 2000 # def = 2000 # * Tree cover recurring cost (USD05MER per ha) cfg$gms$s29_cost_treecover_recur <- 500 # def = 500 -# * Penalty for violation of treecover target (USD05MER per ha) -cfg$gms$s29_treecover_penalty <- 2000 # def = 2000 # * Minimum cluster share of fallow land on total cropland area (including croparea, fallow land and tree cover). # * s29_fallow_target is faded in linearly between s29_fallow_scenario_start and s29_fallow_scenario_target. diff --git a/modules/29_cropland/detail_apr24/presolve.gms b/modules/29_cropland/detail_apr24/presolve.gms index 6f0deb94ca..6894f2bacd 100644 --- a/modules/29_cropland/detail_apr24/presolve.gms +++ b/modules/29_cropland/detail_apr24/presolve.gms @@ -53,23 +53,23 @@ if (s29_treecover_keep = 1, i29_treecover_target(t,j)$(i29_treecover_target(t,j) < pc29_treecover_share(j)) = pc29_treecover_share(j); ); +v29_treecover.lo(j,ac_est) = 0; +v29_treecover.up(j,ac_est) = Inf; +v29_treecover.lo(j,ac_sub) = 0; +v29_treecover.up(j,ac_sub) = pc29_treecover(j,ac_sub); +m_boundfix(v29_treecover,(j,ac_sub),l,1e-6); + if (m_year(t) <= s29_treecover_scenario_start, - i29_treecover_penalty(t) = 0; - v29_treecover_missing.fx(j) = 0; - v29_treecover.fx(j,ac) = pc29_treecover(j,ac); + i29_treecover_penalty(t) = s29_treecover_penalty_before; else i29_treecover_penalty(t) = s29_treecover_penalty; - if (i29_treecover_penalty(t) > 0, - v29_treecover_missing.lo(j) = 0; - v29_treecover_missing.up(j) = Inf; - else - v29_treecover_missing.fx(j) = 0; - ); - v29_treecover.lo(j,ac_est) = 0; - v29_treecover.up(j,ac_est) = Inf; - v29_treecover.lo(j,ac_sub) = 0; - v29_treecover.up(j,ac_sub) = pc29_treecover(j,ac_sub); - m_boundfix(v29_treecover,(j,ac_sub),l,1e-6); +); + +if (i29_treecover_penalty(t) > 0, + v29_treecover_missing.lo(j) = 0; + v29_treecover_missing.up(j) = Inf; +else + v29_treecover_missing.fx(j) = 0; ); * create fallow land target and penalty scenario diff --git a/modules/80_optimization/nlp_apr17/solve.gms b/modules/80_optimization/nlp_apr17/solve.gms index d6a436a21b..165044891f 100644 --- a/modules/80_optimization/nlp_apr17/solve.gms +++ b/modules/80_optimization/nlp_apr17/solve.gms @@ -38,6 +38,9 @@ display "vm_cost_glo.l"; display vm_cost_glo.l; display magpie.modelstat; +* set modelstat to 13 in case of NA for continuation +magpie.modelStat$(magpie.modelStat=NA) = 13; + * in case of problems try different solvers and optfile settings if (magpie.modelstat > 2, repeat( @@ -70,13 +73,16 @@ if (magpie.modelstat > 2, display "vm_cost_glo.l"; display vm_cost_glo.l; -* write extended run information in list file in the case that the final solution is infeasible +* write extended run information in list file in the case that the final solution is infeasible if ((s80_counter >= (s80_maxiter-1) and magpie.modelstat > 2), magpie.solprint = 1 ); display s80_counter; display magpie.modelstat; +* Set modelstat to 13 in case of NA for the `until` check of the repeat loop. +* Otherwise, the repeat loop will never end. + magpie.modelStat$(magpie.modelStat=NA) = 13; s80_resolve_option$(s80_resolve_option >= 4) = 0; From 2ce5f4b0ad1db633d9673d7e7e1852825a6581e3 Mon Sep 17 00:00:00 2001 From: florianh Date: Tue, 7 May 2024 08:50:20 +0200 Subject: [PATCH 095/133] bugfix --- modules/29_cropland/detail_apr24/input.gms | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/29_cropland/detail_apr24/input.gms b/modules/29_cropland/detail_apr24/input.gms index af51a029e4..ad9fa127b3 100644 --- a/modules/29_cropland/detail_apr24/input.gms +++ b/modules/29_cropland/detail_apr24/input.gms @@ -24,7 +24,8 @@ scalars s29_treecover_target Target share of treecover on total cropland (1) / 0 / s29_treecover_keep Avoid loss of existing treecover (1=yes 0=no) / 1 / s29_treecover_max Maximum share of treecover on total cropland (1) / 0.4 / - s29_treecover_penalty Penalty for violation of treecover target (USD05MER per ha) / 2000 / + s29_treecover_penalty_before Penalty for violation of treecover target before scenario start (USD05MER per ha) / 2000 / + s29_treecover_penalty Penalty for violation of treecover target after sceanrio start (USD05MER per ha) / 2000 / s29_fallow_scenario_start Fallow land scenario start year / 2020 / s29_fallow_scenario_target Fallow land scenario target year / 2050 / s29_fallow_target Target share of fallow land on total cropland (1) / 0 / From 7be483eb293ed60f824399b9bce4e842bcea4644 Mon Sep 17 00:00:00 2001 From: florianh Date: Tue, 7 May 2024 16:03:06 +0200 Subject: [PATCH 096/133] update optfile --- modules/80_optimization/lp_nlp_apr17/solve.gms | 5 +---- modules/80_optimization/nlp_apr17/solve.gms | 5 +---- modules/80_optimization/nlp_par/solve.gms | 5 +---- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/modules/80_optimization/lp_nlp_apr17/solve.gms b/modules/80_optimization/lp_nlp_apr17/solve.gms index 5749c3db5a..7252140a62 100644 --- a/modules/80_optimization/lp_nlp_apr17/solve.gms +++ b/modules/80_optimization/lp_nlp_apr17/solve.gms @@ -34,10 +34,7 @@ $elseif "%c80_nlp_solver%" == "conopt4+conopt3" $endif $onecho > conopt4.opt -Tol_Obj_Change = 3.0e-6 -Tol_Feas_Min = 4.0e-10 -Tol_Feas_Max = 4.0e-6 -Tol_Feas_Tria = 4.0e-6 +Lim_Variable = 1.e25 $offecho $onecho > conopt4.op2 diff --git a/modules/80_optimization/nlp_apr17/solve.gms b/modules/80_optimization/nlp_apr17/solve.gms index 165044891f..42984f030b 100644 --- a/modules/80_optimization/nlp_apr17/solve.gms +++ b/modules/80_optimization/nlp_apr17/solve.gms @@ -18,10 +18,7 @@ magpie.solprint = 0 ; magpie.holdfixed = 1 ; $onecho > conopt4.opt -Tol_Obj_Change = 3.0e-6 -Tol_Feas_Min = 4.0e-10 -Tol_Feas_Max = 4.0e-6 -Tol_Feas_Tria = 4.0e-6 +Lim_Variable = 1.e25 $offecho $onecho > conopt4.op2 diff --git a/modules/80_optimization/nlp_par/solve.gms b/modules/80_optimization/nlp_par/solve.gms index 3b06cbcbf0..64beff7501 100644 --- a/modules/80_optimization/nlp_par/solve.gms +++ b/modules/80_optimization/nlp_par/solve.gms @@ -21,10 +21,7 @@ magpie.holdfixed = 1 ; magpie.savepoint = 0; $onecho > conopt4.opt -Tol_Obj_Change = 3.0e-6 -Tol_Feas_Min = 4.0e-10 -Tol_Feas_Max = 4.0e-6 -Tol_Feas_Tria = 4.0e-6 +Lim_Variable = 1.e25 $offecho $onecho > conopt4.op2 From 1d7b333ff0947e42ef17f9f8320dc084f01135ba Mon Sep 17 00:00:00 2001 From: florianh Date: Tue, 7 May 2024 18:03:19 +0200 Subject: [PATCH 097/133] update additional data --- config/default.cfg | 2 +- modules/15_food/anthro_iso_jun22/sets.gms | 46 ++++++++++++++++--- .../15_food/anthropometrics_jan18/sets.gms | 46 ++++++++++++++++--- modules/56_ghg_policy/price_aug22/sets.gms | 4 ++ modules/70_livestock/fbask_jan16/sets.gms | 45 ++++++++++++++++-- scripts/start_functions.R | 20 ++++++++ 6 files changed, 145 insertions(+), 18 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index 4f4d18ab7d..1062936334 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -25,7 +25,7 @@ cfg$model <- "main.gms" #def = "main.gms" cfg$input <- c(regional = "rev4.104_h12_magpie.tgz", cellular = "rev4.104_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", validation = "rev4.104_h12_validation.tgz", - additional = "additional_data_rev4.48.tgz", + additional = "additional_data_rev4.51.tgz", calibration = "calibration_H12_default_30Apr24.tgz") # NOTE: It is recommended to recalibrate the model when changing cellular input data diff --git a/modules/15_food/anthro_iso_jun22/sets.gms b/modules/15_food/anthro_iso_jun22/sets.gms index 269ae4f7ad..99b6b94959 100644 --- a/modules/15_food/anthro_iso_jun22/sets.gms +++ b/modules/15_food/anthro_iso_jun22/sets.gms @@ -5,6 +5,46 @@ *** | MAgPIE License Exception, version 1.0 (see LICENSE file). *** | Contact: magpie@pik-potsdam.de +*############################################################################### +*######################## R SECTION START (SETS) ############################### +* THIS CODE IS CREATED AUTOMATICALLY, DO NOT MODIFY THESE LINES DIRECTLY +* ANY DIRECT MODIFICATION WILL BE LOST AFTER NEXT AUTOMATIC UPDATE! + +sets + + fadeoutscen15 Food substitution scenarios including functional forms with targets and transition periods + / constant, + lin_zero_10_50, + lin_50pc_10_50_extend90, + lin_75pc_10_50_extend90, + lin_zero_20_50, + lin_zero_20_30, + lin_zero_20_70, + lin_50pc_20_50, + lin_50pc_20_50_extend65, + lin_50pc_20_50_extend80, + lin_80pc_20_50, + lin_80pc_20_50_extend95, + lin_90pc_20_50_extend95, + lin_99-98-90pc_20_50-60-100, + lin_zero_25_50, + lin_zero_25_30, + lin_zero_25_70, + lin_zero_25_75, + lin_50pc_25_50, + lin_50pc_25_50_extend65, + lin_50pc_25_50_extend75, + sigmoid_20pc_20_50, + sigmoid_50pc_20_50, + sigmoid_80pc_20_50, + sigmoid_25pc_25_50, + sigmoid_50pc_25_50, + sigmoid_75pc_25_50 / + +; +*######################### R SECTION END (SETS) ################################ +*############################################################################### + sets iter15 iterations between food demand model and magpie @@ -155,12 +195,6 @@ sets kfo_rd(kfo) Ruminant meat and dairy food products / livst_rum,livst_milk / - fadeoutscen15 Food substitution scenarios including functional forms with targets and transition periods - / constant, - lin_zero_10_50, lin_zero_20_50, lin_zero_20_30, lin_zero_20_70, lin_50pc_20_50, lin_50pc_20_50_extend65, lin_50pc_20_50_extend80, - lin_50pc_10_50_extend90, lin_75pc_10_50_extend90, lin_80pc_20_50, lin_80pc_20_50_extend95, lin_90pc_20_50_extend95, - lin_99-98-90pc_20_50-60-100, sigmoid_20pc_20_50, sigmoid_50pc_20_50, sigmoid_80pc_20_50 / - t_scen15(t_all) Target years for transition to exogenous scenario diets / y2010, y2030, y2050 / diff --git a/modules/15_food/anthropometrics_jan18/sets.gms b/modules/15_food/anthropometrics_jan18/sets.gms index 86a7bbe4a9..2bee821a5e 100644 --- a/modules/15_food/anthropometrics_jan18/sets.gms +++ b/modules/15_food/anthropometrics_jan18/sets.gms @@ -5,6 +5,46 @@ *** | MAgPIE License Exception, version 1.0 (see LICENSE file). *** | Contact: magpie@pik-potsdam.de +*############################################################################### +*######################## R SECTION START (SETS) ############################### +* THIS CODE IS CREATED AUTOMATICALLY, DO NOT MODIFY THESE LINES DIRECTLY +* ANY DIRECT MODIFICATION WILL BE LOST AFTER NEXT AUTOMATIC UPDATE! + +sets + + fadeoutscen15 Food substitution scenarios including functional forms with targets and transition periods + / constant, + lin_zero_10_50, + lin_50pc_10_50_extend90, + lin_75pc_10_50_extend90, + lin_zero_20_50, + lin_zero_20_30, + lin_zero_20_70, + lin_50pc_20_50, + lin_50pc_20_50_extend65, + lin_50pc_20_50_extend80, + lin_80pc_20_50, + lin_80pc_20_50_extend95, + lin_90pc_20_50_extend95, + lin_99-98-90pc_20_50-60-100, + lin_zero_25_50, + lin_zero_25_30, + lin_zero_25_70, + lin_zero_25_75, + lin_50pc_25_50, + lin_50pc_25_50_extend65, + lin_50pc_25_50_extend75, + sigmoid_20pc_20_50, + sigmoid_50pc_20_50, + sigmoid_80pc_20_50, + sigmoid_25pc_25_50, + sigmoid_50pc_25_50, + sigmoid_75pc_25_50 / + +; +*######################### R SECTION END (SETS) ################################ +*############################################################################### + sets iter15 iterations between food demand model and magpie @@ -149,12 +189,6 @@ sets kfo_rd(kfo) Ruminant meat and dairy food products / livst_rum,livst_milk / - fadeoutscen15 Food substitution scenarios including functional forms with targets and transition periods - / constant, - lin_zero_10_50, lin_zero_20_50, lin_zero_20_30, lin_zero_20_70, lin_50pc_20_50, lin_50pc_20_50_extend65, lin_50pc_20_50_extend80, - lin_50pc_10_50_extend90, lin_75pc_10_50_extend90, lin_80pc_20_50, lin_80pc_20_50_extend95, lin_90pc_20_50_extend95, - lin_99-98-90pc_20_50-60-100, sigmoid_20pc_20_50, sigmoid_50pc_20_50, sigmoid_80pc_20_50 / - t_scen15(t_all) Target years for transition to exogenous scenario diets / y2010, y2030, y2050 / diff --git a/modules/56_ghg_policy/price_aug22/sets.gms b/modules/56_ghg_policy/price_aug22/sets.gms index 7bb8f6bde9..014de3106f 100644 --- a/modules/56_ghg_policy/price_aug22/sets.gms +++ b/modules/56_ghg_policy/price_aug22/sets.gms @@ -102,15 +102,19 @@ sets all, all_nosoil, redd_nosoil, + redd_nosoil_CH4GWP20, redd_nosoil_nopeat, redd_nosoil_peatCO2only, reddnatveg_nosoil, + reddnatveg_nosoil_CH4GWP20, reddnatveg_nosoil_nopeat, reddnatveg_nosoil_peatCO2only, redd+_nosoil, + redd+_nosoil_CH4GWP20, redd+_nosoil_nopeat, redd+_nosoil_peatCO2only, redd+natveg_nosoil, + redd+natveg_nosoil_CH4GWP20, redd+natveg_nosoil_nopeat, redd+natveg_nosoil_peatCO2only, all_vegc, diff --git a/modules/70_livestock/fbask_jan16/sets.gms b/modules/70_livestock/fbask_jan16/sets.gms index 2382b598f7..3c219ab94b 100644 --- a/modules/70_livestock/fbask_jan16/sets.gms +++ b/modules/70_livestock/fbask_jan16/sets.gms @@ -5,6 +5,46 @@ *** | MAgPIE License Exception, version 1.0 (see LICENSE file). *** | Contact: magpie@pik-potsdam.de +*############################################################################### +*######################## R SECTION START (SETS) ############################### +* THIS CODE IS CREATED AUTOMATICALLY, DO NOT MODIFY THESE LINES DIRECTLY +* ANY DIRECT MODIFICATION WILL BE LOST AFTER NEXT AUTOMATIC UPDATE! + +sets + + fadeoutscen70 Feed substitution scenarios including functional forms with targets and transition periods + / constant, + lin_zero_10_50, + lin_50pc_10_50_extend90, + lin_75pc_10_50_extend90, + lin_zero_20_50, + lin_zero_20_30, + lin_zero_20_70, + lin_50pc_20_50, + lin_50pc_20_50_extend65, + lin_50pc_20_50_extend80, + lin_80pc_20_50, + lin_80pc_20_50_extend95, + lin_90pc_20_50_extend95, + lin_99-98-90pc_20_50-60-100, + lin_zero_25_50, + lin_zero_25_30, + lin_zero_25_70, + lin_zero_25_75, + lin_50pc_25_50, + lin_50pc_25_50_extend65, + lin_50pc_25_50_extend75, + sigmoid_20pc_20_50, + sigmoid_50pc_20_50, + sigmoid_80pc_20_50, + sigmoid_25pc_25_50, + sigmoid_50pc_25_50, + sigmoid_75pc_25_50 / + +; +*######################### R SECTION END (SETS) ################################ +*############################################################################### + sets cost_regr Cost regression parameters @@ -38,9 +78,4 @@ sets kcer70(kall) Cereals / tece, maiz, trce, rice_pro / - fadeoutscen70 Feed substitution scenarios including functional forms with targets and transition periods - / constant, - lin_zero_10_50, lin_zero_20_50, lin_zero_20_30, lin_zero_20_70, lin_50pc_20_50, lin_50pc_20_50_extend65, lin_50pc_20_50_extend80, - lin_50pc_10_50_extend90, lin_75pc_10_50_extend90, lin_80pc_20_50, lin_80pc_20_50_extend95, lin_90pc_20_50_extend95, - lin_99-98-90pc_20_50-60-100, sigmoid_20pc_20_50, sigmoid_50pc_20_50, sigmoid_80pc_20_50 / ; diff --git a/scripts/start_functions.R b/scripts/start_functions.R index 4074b48c69..871544aeab 100644 --- a/scripts/start_functions.R +++ b/scripts/start_functions.R @@ -73,6 +73,16 @@ .update_sets_modules <- function() { require(gms) + ### 15_food + fadeoutscen15 <- magclass::read.magpie("modules/15_food/input/f15_food_substitution_fader.csv") + fadeoutscen15 <- magclass::getNames(fadeoutscen15,dim=1) + + sets <- list(list(name = "fadeoutscen15", + desc = "Food substitution scenarios including functional forms with targets and transition periods", + items = fadeoutscen15)) + + gms::writeSets(sets , "modules/15_food/anthropometrics_jan18/sets.gms") + gms::writeSets(sets , "modules/15_food/anthro_iso_jun22/sets.gms") ### 56_ghg_policy ghgscen56 <- magclass::read.magpie("modules/56_ghg_policy/input/f56_pollutant_prices.cs3") @@ -99,6 +109,16 @@ items = scen2nd60)) gms::writeSets(sets , "modules/60_bioenergy/1stgen_priced_dec18/sets.gms") + + ### 70_livestock + fadeoutscen70 <- magclass::read.magpie("modules/70_livestock/fbask_jan16/input/f70_feed_substitution_fader.csv") + fadeoutscen70 <- magclass::getNames(fadeoutscen70,dim=1) + + sets <- list(list(name = "fadeoutscen70", + desc = "Feed substitution scenarios including functional forms with targets and transition periods", + items = fadeoutscen70)) + + gms::writeSets(sets , "modules/70_livestock/fbask_jan16/sets.gms") } # Function to extract information from info.txt From 574f54d4912c33218c8e6bfe8eee5a88108fb827 Mon Sep 17 00:00:00 2001 From: florianh Date: Wed, 8 May 2024 07:17:42 +0200 Subject: [PATCH 098/133] bugfix --- config/scenario_fsec.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/scenario_fsec.csv b/config/scenario_fsec.csv index cd0fc1a682..e3d78a8b9e 100644 --- a/config/scenario_fsec.csv +++ b/config/scenario_fsec.csv @@ -79,6 +79,6 @@ gms$c73_build_demand;;;;;;;;;;;;;;;;;;;;;;;;50pc;;;;;;;;;;;;;;;;;;;;;;;;;;; input['cellular'];rev4.104_FSEC_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;rev4.104_FSEC_0bd54110_cellularmagpie_c200_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz;rev4.104_FSEC_6819938d_cellularmagpie_c200_MRI-ESM2-0-ssp126_lpjml-8e6c5eb1.tgz;;rev4.104_FSEC_1b5c3817_cellularmagpie_c200_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz;rev4.104_FSEC_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;rev4.104_FSEC_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz;rev4.104_FSEC_09a63995_cellularmagpie_c200_MRI-ESM2-0-ssp585_lpjml-8e6c5eb1.tgz;;; input['regional'];rev4.104_FSEC_magpie.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; input['validation'];rev4.104_FSEC_validation.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -input['additional'];additional_data_rev4.48.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +input['additional'];additional_data_rev4.51.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; input['calibration'];calibration_FSEC_26Mar24.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; magicc_emis_scen;bjoernAR6_C_SSP2-NDC.mif;;;bjoernAR6_C_SSP2-PkBudg900.mif;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;bjoernAR6_C_SSP1-NDC.mif;;;;;;;;;;;;bjoernAR6_C_RemSDP-900-MagSSP1.mif;; From 95c0f43a9646664990fcfa8b102dc684e0cf2da8 Mon Sep 17 00:00:00 2001 From: florianh Date: Thu, 9 May 2024 18:15:07 +0200 Subject: [PATCH 099/133] reverting back faders --- modules/15_food/anthro_iso_jun22/sets.gms | 46 +++---------------- .../15_food/anthropometrics_jan18/sets.gms | 46 +++---------------- modules/70_livestock/fbask_jan16/sets.gms | 45 ++---------------- scripts/start_functions.R | 20 -------- 4 files changed, 17 insertions(+), 140 deletions(-) diff --git a/modules/15_food/anthro_iso_jun22/sets.gms b/modules/15_food/anthro_iso_jun22/sets.gms index 99b6b94959..269ae4f7ad 100644 --- a/modules/15_food/anthro_iso_jun22/sets.gms +++ b/modules/15_food/anthro_iso_jun22/sets.gms @@ -5,46 +5,6 @@ *** | MAgPIE License Exception, version 1.0 (see LICENSE file). *** | Contact: magpie@pik-potsdam.de -*############################################################################### -*######################## R SECTION START (SETS) ############################### -* THIS CODE IS CREATED AUTOMATICALLY, DO NOT MODIFY THESE LINES DIRECTLY -* ANY DIRECT MODIFICATION WILL BE LOST AFTER NEXT AUTOMATIC UPDATE! - -sets - - fadeoutscen15 Food substitution scenarios including functional forms with targets and transition periods - / constant, - lin_zero_10_50, - lin_50pc_10_50_extend90, - lin_75pc_10_50_extend90, - lin_zero_20_50, - lin_zero_20_30, - lin_zero_20_70, - lin_50pc_20_50, - lin_50pc_20_50_extend65, - lin_50pc_20_50_extend80, - lin_80pc_20_50, - lin_80pc_20_50_extend95, - lin_90pc_20_50_extend95, - lin_99-98-90pc_20_50-60-100, - lin_zero_25_50, - lin_zero_25_30, - lin_zero_25_70, - lin_zero_25_75, - lin_50pc_25_50, - lin_50pc_25_50_extend65, - lin_50pc_25_50_extend75, - sigmoid_20pc_20_50, - sigmoid_50pc_20_50, - sigmoid_80pc_20_50, - sigmoid_25pc_25_50, - sigmoid_50pc_25_50, - sigmoid_75pc_25_50 / - -; -*######################### R SECTION END (SETS) ################################ -*############################################################################### - sets iter15 iterations between food demand model and magpie @@ -195,6 +155,12 @@ sets kfo_rd(kfo) Ruminant meat and dairy food products / livst_rum,livst_milk / + fadeoutscen15 Food substitution scenarios including functional forms with targets and transition periods + / constant, + lin_zero_10_50, lin_zero_20_50, lin_zero_20_30, lin_zero_20_70, lin_50pc_20_50, lin_50pc_20_50_extend65, lin_50pc_20_50_extend80, + lin_50pc_10_50_extend90, lin_75pc_10_50_extend90, lin_80pc_20_50, lin_80pc_20_50_extend95, lin_90pc_20_50_extend95, + lin_99-98-90pc_20_50-60-100, sigmoid_20pc_20_50, sigmoid_50pc_20_50, sigmoid_80pc_20_50 / + t_scen15(t_all) Target years for transition to exogenous scenario diets / y2010, y2030, y2050 / diff --git a/modules/15_food/anthropometrics_jan18/sets.gms b/modules/15_food/anthropometrics_jan18/sets.gms index 2bee821a5e..86a7bbe4a9 100644 --- a/modules/15_food/anthropometrics_jan18/sets.gms +++ b/modules/15_food/anthropometrics_jan18/sets.gms @@ -5,46 +5,6 @@ *** | MAgPIE License Exception, version 1.0 (see LICENSE file). *** | Contact: magpie@pik-potsdam.de -*############################################################################### -*######################## R SECTION START (SETS) ############################### -* THIS CODE IS CREATED AUTOMATICALLY, DO NOT MODIFY THESE LINES DIRECTLY -* ANY DIRECT MODIFICATION WILL BE LOST AFTER NEXT AUTOMATIC UPDATE! - -sets - - fadeoutscen15 Food substitution scenarios including functional forms with targets and transition periods - / constant, - lin_zero_10_50, - lin_50pc_10_50_extend90, - lin_75pc_10_50_extend90, - lin_zero_20_50, - lin_zero_20_30, - lin_zero_20_70, - lin_50pc_20_50, - lin_50pc_20_50_extend65, - lin_50pc_20_50_extend80, - lin_80pc_20_50, - lin_80pc_20_50_extend95, - lin_90pc_20_50_extend95, - lin_99-98-90pc_20_50-60-100, - lin_zero_25_50, - lin_zero_25_30, - lin_zero_25_70, - lin_zero_25_75, - lin_50pc_25_50, - lin_50pc_25_50_extend65, - lin_50pc_25_50_extend75, - sigmoid_20pc_20_50, - sigmoid_50pc_20_50, - sigmoid_80pc_20_50, - sigmoid_25pc_25_50, - sigmoid_50pc_25_50, - sigmoid_75pc_25_50 / - -; -*######################### R SECTION END (SETS) ################################ -*############################################################################### - sets iter15 iterations between food demand model and magpie @@ -189,6 +149,12 @@ sets kfo_rd(kfo) Ruminant meat and dairy food products / livst_rum,livst_milk / + fadeoutscen15 Food substitution scenarios including functional forms with targets and transition periods + / constant, + lin_zero_10_50, lin_zero_20_50, lin_zero_20_30, lin_zero_20_70, lin_50pc_20_50, lin_50pc_20_50_extend65, lin_50pc_20_50_extend80, + lin_50pc_10_50_extend90, lin_75pc_10_50_extend90, lin_80pc_20_50, lin_80pc_20_50_extend95, lin_90pc_20_50_extend95, + lin_99-98-90pc_20_50-60-100, sigmoid_20pc_20_50, sigmoid_50pc_20_50, sigmoid_80pc_20_50 / + t_scen15(t_all) Target years for transition to exogenous scenario diets / y2010, y2030, y2050 / diff --git a/modules/70_livestock/fbask_jan16/sets.gms b/modules/70_livestock/fbask_jan16/sets.gms index 3c219ab94b..2382b598f7 100644 --- a/modules/70_livestock/fbask_jan16/sets.gms +++ b/modules/70_livestock/fbask_jan16/sets.gms @@ -5,46 +5,6 @@ *** | MAgPIE License Exception, version 1.0 (see LICENSE file). *** | Contact: magpie@pik-potsdam.de -*############################################################################### -*######################## R SECTION START (SETS) ############################### -* THIS CODE IS CREATED AUTOMATICALLY, DO NOT MODIFY THESE LINES DIRECTLY -* ANY DIRECT MODIFICATION WILL BE LOST AFTER NEXT AUTOMATIC UPDATE! - -sets - - fadeoutscen70 Feed substitution scenarios including functional forms with targets and transition periods - / constant, - lin_zero_10_50, - lin_50pc_10_50_extend90, - lin_75pc_10_50_extend90, - lin_zero_20_50, - lin_zero_20_30, - lin_zero_20_70, - lin_50pc_20_50, - lin_50pc_20_50_extend65, - lin_50pc_20_50_extend80, - lin_80pc_20_50, - lin_80pc_20_50_extend95, - lin_90pc_20_50_extend95, - lin_99-98-90pc_20_50-60-100, - lin_zero_25_50, - lin_zero_25_30, - lin_zero_25_70, - lin_zero_25_75, - lin_50pc_25_50, - lin_50pc_25_50_extend65, - lin_50pc_25_50_extend75, - sigmoid_20pc_20_50, - sigmoid_50pc_20_50, - sigmoid_80pc_20_50, - sigmoid_25pc_25_50, - sigmoid_50pc_25_50, - sigmoid_75pc_25_50 / - -; -*######################### R SECTION END (SETS) ################################ -*############################################################################### - sets cost_regr Cost regression parameters @@ -78,4 +38,9 @@ sets kcer70(kall) Cereals / tece, maiz, trce, rice_pro / + fadeoutscen70 Feed substitution scenarios including functional forms with targets and transition periods + / constant, + lin_zero_10_50, lin_zero_20_50, lin_zero_20_30, lin_zero_20_70, lin_50pc_20_50, lin_50pc_20_50_extend65, lin_50pc_20_50_extend80, + lin_50pc_10_50_extend90, lin_75pc_10_50_extend90, lin_80pc_20_50, lin_80pc_20_50_extend95, lin_90pc_20_50_extend95, + lin_99-98-90pc_20_50-60-100, sigmoid_20pc_20_50, sigmoid_50pc_20_50, sigmoid_80pc_20_50 / ; diff --git a/scripts/start_functions.R b/scripts/start_functions.R index 871544aeab..4074b48c69 100644 --- a/scripts/start_functions.R +++ b/scripts/start_functions.R @@ -73,16 +73,6 @@ .update_sets_modules <- function() { require(gms) - ### 15_food - fadeoutscen15 <- magclass::read.magpie("modules/15_food/input/f15_food_substitution_fader.csv") - fadeoutscen15 <- magclass::getNames(fadeoutscen15,dim=1) - - sets <- list(list(name = "fadeoutscen15", - desc = "Food substitution scenarios including functional forms with targets and transition periods", - items = fadeoutscen15)) - - gms::writeSets(sets , "modules/15_food/anthropometrics_jan18/sets.gms") - gms::writeSets(sets , "modules/15_food/anthro_iso_jun22/sets.gms") ### 56_ghg_policy ghgscen56 <- magclass::read.magpie("modules/56_ghg_policy/input/f56_pollutant_prices.cs3") @@ -109,16 +99,6 @@ items = scen2nd60)) gms::writeSets(sets , "modules/60_bioenergy/1stgen_priced_dec18/sets.gms") - - ### 70_livestock - fadeoutscen70 <- magclass::read.magpie("modules/70_livestock/fbask_jan16/input/f70_feed_substitution_fader.csv") - fadeoutscen70 <- magclass::getNames(fadeoutscen70,dim=1) - - sets <- list(list(name = "fadeoutscen70", - desc = "Feed substitution scenarios including functional forms with targets and transition periods", - items = fadeoutscen70)) - - gms::writeSets(sets , "modules/70_livestock/fbask_jan16/sets.gms") } # Function to extract information from info.txt From 893cbfdd6f3854aa011996cd5b70116c9c3f30db Mon Sep 17 00:00:00 2001 From: florianh Date: Thu, 9 May 2024 20:10:05 +0200 Subject: [PATCH 100/133] bugfix --- config/default.cfg | 2 +- modules/15_food/anthro_iso_jun22/sets.gms | 2 +- modules/15_food/anthropometrics_jan18/sets.gms | 2 +- modules/30_croparea/detail_apr24/input.gms | 2 +- modules/30_croparea/simple_apr24/input.gms | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index 1062936334..4ee81e75b5 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -772,7 +772,7 @@ cfg$gms$s30_betr_scenario_start <- 2020 # def = 2020 # * Target year (year when full implementation is reached): cfg$gms$s30_betr_scenario_target <- 2050 # def = 2050 # * Penalty for violation of fallow target (USD05MER per ha) -cfg$gms$s30_betr_penalty <- 500 # def = 500 +cfg$gms$s30_betr_penalty <- 2000 # def = 2000 # *** Options only available for `simple_apr24` realization *** diff --git a/modules/15_food/anthro_iso_jun22/sets.gms b/modules/15_food/anthro_iso_jun22/sets.gms index 269ae4f7ad..18aa119f71 100644 --- a/modules/15_food/anthro_iso_jun22/sets.gms +++ b/modules/15_food/anthro_iso_jun22/sets.gms @@ -159,7 +159,7 @@ sets / constant, lin_zero_10_50, lin_zero_20_50, lin_zero_20_30, lin_zero_20_70, lin_50pc_20_50, lin_50pc_20_50_extend65, lin_50pc_20_50_extend80, lin_50pc_10_50_extend90, lin_75pc_10_50_extend90, lin_80pc_20_50, lin_80pc_20_50_extend95, lin_90pc_20_50_extend95, - lin_99-98-90pc_20_50-60-100, sigmoid_20pc_20_50, sigmoid_50pc_20_50, sigmoid_80pc_20_50 / + lin_99-98-90pc_20_50-60-100, sigmoid_20pc_20_50, sigmoid_50pc_20_50, sigmoid_80pc_20_50, sigmoid_75pc_25_50, sigmoid_50pc_25_50, sigmoid_25pc_25_50 / t_scen15(t_all) Target years for transition to exogenous scenario diets / y2010, y2030, y2050 / diff --git a/modules/15_food/anthropometrics_jan18/sets.gms b/modules/15_food/anthropometrics_jan18/sets.gms index 86a7bbe4a9..cb2b471dcd 100644 --- a/modules/15_food/anthropometrics_jan18/sets.gms +++ b/modules/15_food/anthropometrics_jan18/sets.gms @@ -153,7 +153,7 @@ sets / constant, lin_zero_10_50, lin_zero_20_50, lin_zero_20_30, lin_zero_20_70, lin_50pc_20_50, lin_50pc_20_50_extend65, lin_50pc_20_50_extend80, lin_50pc_10_50_extend90, lin_75pc_10_50_extend90, lin_80pc_20_50, lin_80pc_20_50_extend95, lin_90pc_20_50_extend95, - lin_99-98-90pc_20_50-60-100, sigmoid_20pc_20_50, sigmoid_50pc_20_50, sigmoid_80pc_20_50 / + lin_99-98-90pc_20_50-60-100, sigmoid_20pc_20_50, sigmoid_50pc_20_50, sigmoid_80pc_20_50, sigmoid_75pc_25_50, sigmoid_50pc_25_50, sigmoid_25pc_25_50 / t_scen15(t_all) Target years for transition to exogenous scenario diets / y2010, y2030, y2050 / diff --git a/modules/30_croparea/detail_apr24/input.gms b/modules/30_croparea/detail_apr24/input.gms index 72ca248086..4923074708 100644 --- a/modules/30_croparea/detail_apr24/input.gms +++ b/modules/30_croparea/detail_apr24/input.gms @@ -26,7 +26,7 @@ scalars s30_betr_scenario_start Bioenergy land scenario start year / 2020 / s30_betr_scenario_target Bioenergy land scenario target year / 2050 / s30_betr_target Target share of bioenergy land on total cropland (1) / 0 / - s30_betr_penalty Penalty for violation of betr target (USD05MER per ha) / 500 / + s30_betr_penalty Penalty for violation of betr target (USD05MER per ha) / 2000 / ; diff --git a/modules/30_croparea/simple_apr24/input.gms b/modules/30_croparea/simple_apr24/input.gms index e8f919c20f..ac6585c0ca 100644 --- a/modules/30_croparea/simple_apr24/input.gms +++ b/modules/30_croparea/simple_apr24/input.gms @@ -20,7 +20,7 @@ scalars s30_betr_scenario_start Bioenergy land scenario start year / 2020 / s30_betr_scenario_target Bioenergy land scenario target year / 2050 / s30_betr_target Target share of bioenergy land on total cropland (1) / 0 / - s30_betr_penalty Penalty for violation of betr target (USD05MER per ha) / 500 / + s30_betr_penalty Penalty for violation of betr target (USD05MER per ha) / 2000 / ; $ifthen "%c30_bioen_type%" == "all" bioen_type_30(kbe30) = yes; From d1ca47d691dc7c75afc37e2357401cb2264823eb Mon Sep 17 00:00:00 2001 From: florianh Date: Fri, 10 May 2024 11:53:17 +0200 Subject: [PATCH 101/133] start script peatlandTax --- scripts/start/projects/paper_peatlandTax.R | 148 +++++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 scripts/start/projects/paper_peatlandTax.R diff --git a/scripts/start/projects/paper_peatlandTax.R b/scripts/start/projects/paper_peatlandTax.R new file mode 100644 index 0000000000..c81b4ac47b --- /dev/null +++ b/scripts/start/projects/paper_peatlandTax.R @@ -0,0 +1,148 @@ +# | (C) 2008-2024 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: paper peatlandTax +# position: 5 +# ---------------------------------------------------------- + +## Load lucode2 and gms to use setScenario later +library(lucode2) +library(gms) +library(gdx) +library(magpie4) + +# Load start_run(cfg) function which is needed to start MAgPIE runs +source("scripts/start_functions.R") + +# Source default cfg. This loads the object "cfg" in R environment +source("config/default.cfg") + +# create additional information to describe the runs +cfg$info$flag <- "V14LRc500" + +cfg$results_folder <- "output/:title:" +cfg$results_folder_highres <- "output" +cfg$force_replace <- TRUE +cfg$qos <- "priority_maxMem" +#cfg$qos <- "standby_maxMem_dayMax" + +# support function to create standardized title +.title <- function(cfg, ...) return(paste(cfg$info$flag, sep="_",...)) + + +# EUR <- "ALB,AUT,BEL,BGR,CYP,CZE,DEU,DNK,ESP,EST,FIN,FRA,FRO, +# GBR,GGY,GIB,GRC,HRV,HUN,IMN,IRL,ITA,JEY,LTU,LUX,LVA,MLT, +# NLD,POL,PRT,ROU,SVK,SVN,SWE" + +ssp <- "SSP2" +#cfg$input['calibration'] <- "calibration_H12c400_16Apr24.tgz" +cfg$input['calibration'] <- "calibration_H12c500_15Apr24.tgz" +cfg$gms$c_timesteps <- "5year" + +limitAff <- function(cfg,gdx) { + #download input files with high resolution + download_and_update(cfg) + + # #get tau from low resolution run + # ov_tau <- readGDX(gdx, "ov_tau",select=list(type="level")) + # write.magpie(ov_tau,"modules/13_tc/input/f13_tau_scenario.csv") + # cfg$gms$tc <- "exo" + + #get regional afforestation patterns from low resolution run with c200 + aff <- dimSums(landForestry(gdx)[,,c("aff","ndc")],dim=3) + #Take away initial NDC area for consistency with global afforestation limit + aff <- aff-setYears(aff[,1,],NULL) + #calculate maximum regional afforestation over time + aff_max <- setYears(aff[,1,],NULL) + for (r in getRegions(aff)) { + aff_max[r,,] <- max(aff[r,,]) + } + aff_max[aff_max < 0] <- 0 + write.magpie(aff_max,"modules/32_forestry/input/f32_max_aff_area.cs4") + cfg$gms$s32_max_aff_area_glo <- 0 + #check + if(cfg$gms$s32_max_aff_area < Inf) { + indicator <- abs(sum(aff_max)-cfg$gms$s32_max_aff_area) + if(indicator > 1e-06) warning(paste("Global and regional afforestation limit differ by",indicator,"Mha")) + } + return(cfg) +} + + +cfg$output <- c("rds_report") +cfg$sequential <- TRUE +cfg$title <- .title(cfg, paste(ssp,"1p5deg","PricePeatOff","AffEndo",sep="-")) +cfg <- setScenario(cfg,c(ssp,"NDC","rcp1p9","ForestryEndo")) +#cfg$input['cellular'] <- "rev4.104_h12_6aa915b6_cellularmagpie_c400_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz" +cfg$input['cellular'] <- "rev4.104_h12_4c83b5e5_cellularmagpie_c500_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz" +cfg$gms$c56_mute_ghgprices_until <- "y2030" +cfg$gms$c56_pollutant_prices <- paste0("R32M46-",ifelse(ssp=="SSP2",paste0(ssp,"EU"),ssp),"-PkBudg650") +cfg$gms$c60_2ndgen_biodem <- paste0("R32M46-",ifelse(ssp=="SSP2",paste0(ssp,"EU"),ssp),"-PkBudg650") +cfg$gms$c56_emis_policy <- "reddnatveg_nosoil_nopeat" +start_run(cfg, codeCheck = FALSE) +cfg$sequential <- FALSE + +PricePeatOff <- .title(cfg, paste(ssp,"1p5deg","PricePeatOff","AffEndo",sep="-")) + +#limitAff runs +cfg$output <- c("extra/highres", "extra/disaggregation", "rds_report", "rds_report_iso") + +cfg$title <- .title(cfg, paste(ssp,"NDC",sep="-")) +cfg <- setScenario(cfg,c(ssp,"NDC","rcp4p5","ForestryEndo")) +#cfg$input['cellular'] <- "rev4.104_h12_3d941455_cellularmagpie_c400_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz" +cfg$input['cellular'] <- "rev4.104_h12_9ab12c13_cellularmagpie_c500_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz" +cfg <- limitAff(cfg,file.path("output",PricePeatOff,"fulldata.gdx")) +cfg$gms$c56_mute_ghgprices_until <- "y2150" +cfg$gms$c56_pollutant_prices <- paste0("R32M46-",ifelse(ssp=="SSP2",paste0(ssp,"EU"),ssp),"-NDC") +cfg$gms$c60_2ndgen_biodem <- paste0("R32M46-",ifelse(ssp=="SSP2",paste0(ssp,"EU"),ssp),"-NDC") +cfg$gms$c56_emis_policy <- "reddnatveg_nosoil_nopeat" +start_run(cfg, codeCheck = FALSE) + +cfg$title <- .title(cfg, paste(ssp,"1p5deg","PricePeatOff",sep="-")) +cfg <- setScenario(cfg,c(ssp,"NDC","rcp1p9","ForestryEndo")) +#cfg$input['cellular'] <- "rev4.104_h12_6aa915b6_cellularmagpie_c400_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz" +cfg$input['cellular'] <- "rev4.104_h12_4c83b5e5_cellularmagpie_c500_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz" +cfg <- limitAff(cfg,file.path("output",PricePeatOff,"fulldata.gdx")) +cfg$gms$c56_mute_ghgprices_until <- "y2030" +cfg$gms$c56_pollutant_prices <- paste0("R32M46-",ifelse(ssp=="SSP2",paste0(ssp,"EU"),ssp),"-PkBudg650") +cfg$gms$c60_2ndgen_biodem <- paste0("R32M46-",ifelse(ssp=="SSP2",paste0(ssp,"EU"),ssp),"-PkBudg650") +cfg$gms$c56_emis_policy <- "reddnatveg_nosoil_nopeat" +start_run(cfg, codeCheck = FALSE) + +cfg$title <- .title(cfg, paste(ssp,"1p5deg","PricePeatCO2",sep="-")) +cfg <- setScenario(cfg,c(ssp,"NDC","rcp1p9","ForestryEndo")) +#cfg$input['cellular'] <- "rev4.104_h12_6aa915b6_cellularmagpie_c400_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz" +cfg$input['cellular'] <- "rev4.104_h12_4c83b5e5_cellularmagpie_c500_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz" +cfg <- limitAff(cfg,file.path("output",PricePeatOff,"fulldata.gdx")) +cfg$gms$c56_mute_ghgprices_until <- "y2030" +cfg$gms$c56_pollutant_prices <- paste0("R32M46-",ifelse(ssp=="SSP2",paste0(ssp,"EU"),ssp),"-PkBudg650") +cfg$gms$c60_2ndgen_biodem <- paste0("R32M46-",ifelse(ssp=="SSP2",paste0(ssp,"EU"),ssp),"-PkBudg650") +cfg$gms$c56_emis_policy <- "reddnatveg_nosoil_peatCO2only" +start_run(cfg, codeCheck = FALSE) + +cfg$title <- .title(cfg, paste(ssp,"1p5deg","PricePeatGHG",sep="-")) +cfg <- setScenario(cfg,c(ssp,"NDC","rcp1p9","ForestryEndo")) +#cfg$input['cellular'] <- "rev4.104_h12_6aa915b6_cellularmagpie_c400_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz" +cfg$input['cellular'] <- "rev4.104_h12_4c83b5e5_cellularmagpie_c500_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz" +cfg <- limitAff(cfg,file.path("output",PricePeatOff,"fulldata.gdx")) +cfg$gms$c56_mute_ghgprices_until <- "y2030" +cfg$gms$c56_pollutant_prices <- paste0("R32M46-",ifelse(ssp=="SSP2",paste0(ssp,"EU"),ssp),"-PkBudg650") +cfg$gms$c60_2ndgen_biodem <- paste0("R32M46-",ifelse(ssp=="SSP2",paste0(ssp,"EU"),ssp),"-PkBudg650") +cfg$gms$c56_emis_policy <- "reddnatveg_nosoil" +start_run(cfg, codeCheck = FALSE) + +cfg$title <- .title(cfg, paste(ssp,"1p5deg","PricePeatGHG_CH4GWP20",sep="-")) +cfg <- setScenario(cfg,c(ssp,"NDC","rcp1p9","ForestryEndo")) +#cfg$input['cellular'] <- "rev4.104_h12_6aa915b6_cellularmagpie_c400_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz" +cfg$input['cellular'] <- "rev4.104_h12_4c83b5e5_cellularmagpie_c500_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz" +cfg <- limitAff(cfg,file.path("output",PricePeatOff,"fulldata.gdx")) +cfg$gms$c56_mute_ghgprices_until <- "y2030" +cfg$gms$c56_pollutant_prices <- paste0("R32M46-",ifelse(ssp=="SSP2",paste0(ssp,"EU"),ssp),"-PkBudg650") +cfg$gms$c60_2ndgen_biodem <- paste0("R32M46-",ifelse(ssp=="SSP2",paste0(ssp,"EU"),ssp),"-PkBudg650") +cfg$gms$c56_emis_policy <- "reddnatveg_nosoil_CH4GWP20" +start_run(cfg, codeCheck = FALSE) From 2c61aa6003c876ad6d6dad70363dc45d20a8ca74 Mon Sep 17 00:00:00 2001 From: florianh Date: Sat, 11 May 2024 19:39:40 +0200 Subject: [PATCH 102/133] update --- modules/60_bioenergy/1stgen_priced_dec18/preloop.gms | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/60_bioenergy/1stgen_priced_dec18/preloop.gms b/modules/60_bioenergy/1stgen_priced_dec18/preloop.gms index 0a914aae3f..f92a9a2590 100644 --- a/modules/60_bioenergy/1stgen_priced_dec18/preloop.gms +++ b/modules/60_bioenergy/1stgen_priced_dec18/preloop.gms @@ -22,6 +22,10 @@ $elseif "%c60_2ndgen_biodem%" == "emulator" i60_bioenergy_dem(t,i) = f60_bioenergy_dem_emulator(t)/card(i); $elseif "%c60_2ndgen_biodem%" == "none" i60_bioenergy_dem(t,i) = 0; +** Harmonize till 2020 if not coupled or emulator +loop(t$(m_year(t) <= sm_fix_SSP2), + i60_bioenergy_dem(t,i) = f60_bioenergy_dem(t,i,"R32M46-SSP2EU-NPi"); +); $else i60_bioenergy_dem(t,i) = f60_bioenergy_dem(t,i,"%c60_2ndgen_biodem%") * p60_region_BE_shr(t,i) + f60_bioenergy_dem(t,i,"%c60_2ndgen_biodem_noselect%") * (1-p60_region_BE_shr(t,i)); From 02af343236f5811d0e582707016f432656de258a Mon Sep 17 00:00:00 2001 From: florianh Date: Mon, 13 May 2024 10:27:13 +0200 Subject: [PATCH 103/133] adde s30_betr_start --- config/default.cfg | 32 ++++++++++--------- modules/29_cropland/detail_apr24/input.gms | 4 +-- modules/30_croparea/detail_apr24/input.gms | 3 +- modules/30_croparea/detail_apr24/presolve.gms | 3 +- modules/30_croparea/simple_apr24/input.gms | 3 +- modules/30_croparea/simple_apr24/presolve.gms | 3 +- 6 files changed, 27 insertions(+), 21 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index 4ee81e75b5..8ec6a06f71 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -717,17 +717,17 @@ cfg$gms$land_snv <- "secdforest, forestry, past, other" #def = "secdforest, f # *** Options only available for `detail_apr24` realization *** -# * Minimum cluster share of treecover on total cropland area (including croparea, fallow land and tree cover). -# * s29_treecover_target is faded in linearly between s29_treecover_scenario_start and s29_treecover_scenario_target. +# * Sigmoid fader for minimum area share of treecover on total cropland at cluster level +# * Minimum area share of treecover on total cropland in target year cfg$gms$s29_treecover_target <- 0 # def = 0 # * Avoid loss of existing treecover (1=yes 0=no). # * If set to 1, `s29_treecover_target` will be adjusted based existing treecover area. cfg$gms$s29_treecover_keep <- 1 # def = 1 # * Maximum share of treecover on total cropland (1) cfg$gms$s29_treecover_max <- 0.4 # def = 0.4 -# * Start year of tree cover share fade-in: +# * Start year of fader cfg$gms$s29_treecover_scenario_start <- 2020 # def = 2020 -# * Target year (year when full implementation is reached): +# * Target year of fader (year when full implementation is reached) cfg$gms$s29_treecover_scenario_target <- 2050 # def = 2050 # * Penalty for violation of treecover target before scenario start (USD05MER per ha) cfg$gms$s29_treecover_penalty_before <- 2000 # def = 2000 @@ -738,16 +738,16 @@ cfg$gms$s29_cost_treecover_est <- 2000 # def = 2000 # * Tree cover recurring cost (USD05MER per ha) cfg$gms$s29_cost_treecover_recur <- 500 # def = 500 -# * Minimum cluster share of fallow land on total cropland area (including croparea, fallow land and tree cover). -# * s29_fallow_target is faded in linearly between s29_fallow_scenario_start and s29_fallow_scenario_target. +# * Sigmoid fader for minimum area share of fallow land on total cropland at cluster level +# * Minimum area share of fallow land on total cropland in target year cfg$gms$s29_fallow_target <- 0 # def = 0 -# * Maximum share of fallow land on total cropland (1) +# * Maximum share of fallow land on total cropland cfg$gms$s29_fallow_max <- 0.4 # def = 0.4 -# * Start year of tree cover share fade-in: +# * Start year of fader cfg$gms$s29_fallow_scenario_start <- 2020 # def = 2020 -# * Target year (year when full implementation is reached): +# * Target year of fader (year when full implementation is reached) cfg$gms$s29_fallow_scenario_target <- 2050 # def = 2050 -# * Penalty for violation of fallow target (USD05MER per ha) +# * Penalty for violation of fallow land target (USD05MER per ha) cfg$gms$s29_fallow_penalty <- 500 # def = 500 # ***--------------------- 30_croparea --------------------------------------- @@ -764,14 +764,16 @@ cfg$gms$c30_bioen_type <- "all" # def = "all" # * (c30_bioen_water): switch for irrigation of bioenergy crops; options: rainfed, irrigated, all cfg$gms$c30_bioen_water <- "rainfed" # def = "rainfed" -# * Minimum cluster share of bioenergy trees (betr) on total cropland area -# * s30_betr_target is faded in linearly between s30_betr_scenario_start and s30_betr_scenario_target. +# * Sigmoid fader for minimum area share of bioenergy trees (betr) on total cropland at cluster level +# * Minimum area share of bioenergy trees on total cropland in start year +cfg$gms$s30_betr_start <- 0 # def = 0 +# * Minimum area share of bioenergy trees on total cropland in target year cfg$gms$s30_betr_target <- 0 # def = 0 -# * Start year of tree cover share fade-in: +# * Start year of fader cfg$gms$s30_betr_scenario_start <- 2020 # def = 2020 -# * Target year (year when full implementation is reached): +# * Target year of fader (year when full implementation is reached) cfg$gms$s30_betr_scenario_target <- 2050 # def = 2050 -# * Penalty for violation of fallow target (USD05MER per ha) +# * Penalty for violation of the target (USD05MER per ha) cfg$gms$s30_betr_penalty <- 2000 # def = 2000 # *** Options only available for `simple_apr24` realization *** diff --git a/modules/29_cropland/detail_apr24/input.gms b/modules/29_cropland/detail_apr24/input.gms index ad9fa127b3..50b306a32c 100644 --- a/modules/29_cropland/detail_apr24/input.gms +++ b/modules/29_cropland/detail_apr24/input.gms @@ -21,14 +21,14 @@ scalars s29_treecover_bii_coeff BII coefficent to be used for tree cover on cropland 0=secondary vegetation 1=timber plantations (1) / 0 / s29_treecover_scenario_start Cropland treecover scenario start year / 2020 / s29_treecover_scenario_target Cropland treecover scenario target year / 2050 / - s29_treecover_target Target share of treecover on total cropland (1) / 0 / + s29_treecover_target Minimum share of treecover on total cropland in target year (1) / 0 / s29_treecover_keep Avoid loss of existing treecover (1=yes 0=no) / 1 / s29_treecover_max Maximum share of treecover on total cropland (1) / 0.4 / s29_treecover_penalty_before Penalty for violation of treecover target before scenario start (USD05MER per ha) / 2000 / s29_treecover_penalty Penalty for violation of treecover target after sceanrio start (USD05MER per ha) / 2000 / s29_fallow_scenario_start Fallow land scenario start year / 2020 / s29_fallow_scenario_target Fallow land scenario target year / 2050 / - s29_fallow_target Target share of fallow land on total cropland (1) / 0 / + s29_fallow_target Minimum share of fallow land on total cropland in target year (1) / 0 / s29_fallow_max Maximum share of fallow land on total cropland (1) / 0.4 / s29_fallow_penalty Penalty for violation of fallow target (USD05MER per ha) / 500 / ; diff --git a/modules/30_croparea/detail_apr24/input.gms b/modules/30_croparea/detail_apr24/input.gms index 4923074708..193e36dd93 100644 --- a/modules/30_croparea/detail_apr24/input.gms +++ b/modules/30_croparea/detail_apr24/input.gms @@ -25,7 +25,8 @@ scalars s30_implementation Switch for rule-based (1) or penalty-based (0) implementation of rotation scenarios / 1 / s30_betr_scenario_start Bioenergy land scenario start year / 2020 / s30_betr_scenario_target Bioenergy land scenario target year / 2050 / - s30_betr_target Target share of bioenergy land on total cropland (1) / 0 / + s30_betr_start Share of bioenergy land on total cropland in start year (1) / 0 / + s30_betr_target Share of bioenergy land on total cropland in target year (1) / 0 / s30_betr_penalty Penalty for violation of betr target (USD05MER per ha) / 2000 / ; diff --git a/modules/30_croparea/detail_apr24/presolve.gms b/modules/30_croparea/detail_apr24/presolve.gms index 4a028ffad2..a5f6187a7d 100644 --- a/modules/30_croparea/detail_apr24/presolve.gms +++ b/modules/30_croparea/detail_apr24/presolve.gms @@ -31,7 +31,8 @@ else ); * create betr target and penalty scenario -i30_betr_target(t) = s30_betr_target * i30_betr_scenario_fader(t); +i30_betr_target(t) = s30_betr_start * (1-i30_betr_scenario_fader(t)) + + s30_betr_target * i30_betr_scenario_fader(t); if (m_year(t) <= s30_betr_scenario_start, i30_betr_penalty(t) = 0; diff --git a/modules/30_croparea/simple_apr24/input.gms b/modules/30_croparea/simple_apr24/input.gms index ac6585c0ca..e8b9768473 100644 --- a/modules/30_croparea/simple_apr24/input.gms +++ b/modules/30_croparea/simple_apr24/input.gms @@ -19,7 +19,8 @@ scalars s30_rotation_scenario_target Rotation scenario target year / 2050 / s30_betr_scenario_start Bioenergy land scenario start year / 2020 / s30_betr_scenario_target Bioenergy land scenario target year / 2050 / - s30_betr_target Target share of bioenergy land on total cropland (1) / 0 / + s30_betr_start Share of bioenergy land on total cropland in start year (1) / 0 / + s30_betr_target Share of bioenergy land on total cropland in target year (1) / 0 / s30_betr_penalty Penalty for violation of betr target (USD05MER per ha) / 2000 / ; diff --git a/modules/30_croparea/simple_apr24/presolve.gms b/modules/30_croparea/simple_apr24/presolve.gms index fb57b1d9f4..23c3194651 100644 --- a/modules/30_croparea/simple_apr24/presolve.gms +++ b/modules/30_croparea/simple_apr24/presolve.gms @@ -24,7 +24,8 @@ crpmax30(crp30) = yes$(f30_rotation_max_shr(crp30) < 1); crpmin30(crp30) = yes$(f30_rotation_min_shr(crp30) > 0); * create betr target and penalty scenario -i30_betr_target(t) = s30_betr_target * i30_betr_scenario_fader(t); +i30_betr_target(t) = s30_betr_start * (1-i30_betr_scenario_fader(t)) + + s30_betr_target * i30_betr_scenario_fader(t); if (m_year(t) <= s30_betr_scenario_start, i30_betr_penalty(t) = 0; From be4d767a0f972cb11d3270e5d3e83b43d20b0857 Mon Sep 17 00:00:00 2001 From: florianh Date: Thu, 16 May 2024 09:08:16 +0200 Subject: [PATCH 104/133] sync --- CHANGELOG.md | 1 + modules/80_optimization/lp_nlp_apr17/not_used.txt | 2 -- modules/80_optimization/nlp_apr17/not_used.txt | 1 - modules/80_optimization/nlp_par/declarations.gms | 1 - modules/80_optimization/nlp_par/solve.gms | 3 +-- 5 files changed, 2 insertions(+), 6 deletions(-) delete mode 100644 modules/80_optimization/lp_nlp_apr17/not_used.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index bd69fe994a..3cbf51ddf8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **30_crop** the two realizations `penalty_apr22` and `rotation_apr22` have been merged into a single `30_croparea/detail_apr24` realization - **30_crop** the previous `30_crop/endo_apr21` realization has been moved to `30_croparea/simple_apr24` - **80_optimization** Simplifed cycling through CONOPT4, CONOPT4 with OPTFILE, CONOPT4 without preprocessing and CONOPT3. +- **scripts** start/test_runs.R added 2 more test runs from FSEC ### added - **29_cropland** new module `29_cropland` accounting for crop area, fallow cropland and tree cover on cropland with two realizations: `detail_apr24` and `simple_apr24` (default). diff --git a/modules/80_optimization/lp_nlp_apr17/not_used.txt b/modules/80_optimization/lp_nlp_apr17/not_used.txt deleted file mode 100644 index 4dd79412da..0000000000 --- a/modules/80_optimization/lp_nlp_apr17/not_used.txt +++ /dev/null @@ -1,2 +0,0 @@ -name,type,reason -sm_fix_SSP2,input,not needed diff --git a/modules/80_optimization/nlp_apr17/not_used.txt b/modules/80_optimization/nlp_apr17/not_used.txt index 7a59e90855..ea605f3b35 100644 --- a/modules/80_optimization/nlp_apr17/not_used.txt +++ b/modules/80_optimization/nlp_apr17/not_used.txt @@ -1,3 +1,2 @@ name,type,reason vm_landdiff,input,questionnaire -sm_fix_SSP2,input,not needed diff --git a/modules/80_optimization/nlp_par/declarations.gms b/modules/80_optimization/nlp_par/declarations.gms index 1734708bc8..f64f323589 100644 --- a/modules/80_optimization/nlp_par/declarations.gms +++ b/modules/80_optimization/nlp_par/declarations.gms @@ -16,6 +16,5 @@ parameters scalars s80_counter counter (1) - s80_objective objective function value (mio. USD05MER per yr) s80_resolve_option option for resolve (1) ; diff --git a/modules/80_optimization/nlp_par/solve.gms b/modules/80_optimization/nlp_par/solve.gms index 64beff7501..e4478be1e6 100644 --- a/modules/80_optimization/nlp_par/solve.gms +++ b/modules/80_optimization/nlp_par/solve.gms @@ -59,10 +59,9 @@ repeat loop(i2, j2(j)$cell(i2,j) = yes); display h2; s80_counter = sum(h2,p80_counter(h2)); - s80_objective = sum(i2,v11_cost_reg.l(i2)); display s80_counter; display magpie.modelStat; - display s80_objective; + display vm_cost_glo.l; magpie.modelStat$(magpie.modelStat=NA) = 13; p80_modelstat(t,h) = magpie.modelStat; From a11c5ea14884b530eefd93bfb690adf3901973c7 Mon Sep 17 00:00:00 2001 From: florianh Date: Thu, 16 May 2024 14:56:50 +0200 Subject: [PATCH 105/133] bugfix --- config/scenario_config.csv | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/scenario_config.csv b/config/scenario_config.csv index d2916722bb..0d3eb7168d 100755 --- a/config/scenario_config.csv +++ b/config/scenario_config.csv @@ -31,9 +31,9 @@ gms$c21_trade_liberalization;;;;l908080r807070;l909090r808080;l909090r808080;l90 gms$c22_protect_scenario;;;;none;none;none;none;none;none;BH;none;BH_IFL;BH;;;;;;;BH;;;;;BH_IFL;BH_IFL;BH_IFL;BH_IFL;BH_IFL;;;;;;;;;;;;;;;;;;;; gms$c22_protect_scenario_noselect;;;;;;;;;;;;;;;;;;;;;;;;;none;none;BH_IFL;none;BH_IFL;;;;;;;;;;;;;;;;;;;; gms$c30_bioen_water;;;;rainfed;rainfed;rainfed;rainfed;rainfed;rainfed;rainfed;all;rainfed;rainfed;;;;;;;rainfed;;;rainfed;all;;;;;;;;;;;;;;;;;;;;;;;;; -gms$s30_snv_shr;;;;0;0;0;0;0;0;0;0;0;0.2;;;;;;;0;;;;;0.2;0.2;0.2;0.2;0.2;;;;;;;;;;;;;;;;;;;; -gms$s30_snv_shr_noselect;;;;;;;;;;;;;;;;;;;;;;;;;0;0;0.2;0;0.2;;;;;;;;;;;;;;;;;;;; -gms$s30_snv_scenario_target;;;;;;;;;;;;;2030;;;;;;;;;;;;2030;2030;2030;2030;2030;;;;;;;;;;;;;;;;;;;; +gms$s29_snv_shr;;;;0;0;0;0;0;0;0;0;0;0.2;;;;;;;0;;;;;0.2;0.2;0.2;0.2;0.2;;;;;;;;;;;;;;;;;;;; +gms$s29_snv_shr_noselect;;;;;;;;;;;;;;;;;;;;;;;;;0;0;0.2;0;0.2;;;;;;;;;;;;;;;;;;;; +gms$s29_snv_scenario_target;;;;;;;;;;;;;2030;;;;;;;;;;;;2030;2030;2030;2030;2030;;;;;;;;;;;;;;;;;;;; gms$c31_grassl_yld_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$s32_aff_plantation;;;;0;0;0;0;0;0;0;1;0;0;;;;;;;0;;;0;1;;;;;;;;;;;;;;;;;;;;;;;;; gms$s32_aff_bii_coeff;;;;0;0;0;0;0;0;0;1;0;0;;;;;;;0;;;;;;;;;;;;;;;;;;;;;;;;;;;;; From 404be5cde5024b7a4c96238e62ef163dab57843e Mon Sep 17 00:00:00 2001 From: florianh Date: Wed, 29 May 2024 09:49:27 +0200 Subject: [PATCH 106/133] bugfix --- modules/35_natveg/pot_forest_may24/presolve.gms | 4 ---- 1 file changed, 4 deletions(-) diff --git a/modules/35_natveg/pot_forest_may24/presolve.gms b/modules/35_natveg/pot_forest_may24/presolve.gms index 399363a7f3..8d2ac2ede8 100644 --- a/modules/35_natveg/pot_forest_may24/presolve.gms +++ b/modules/35_natveg/pot_forest_may24/presolve.gms @@ -156,11 +156,7 @@ m_boundfix(v35_secdforest,(j,ac_sub),l,1e-6); * Secondary forest conservation * protection bound fix -<<<<<<< HEAD:modules/35_natveg/dynamic_feb21/presolve.gms -pm_land_conservation(t,j,"secdforest","protect")$(abs(pm_land_conservation(t,j,"secdforest","protect") - sum(ac_sub, pc35_secdforest(j,ac_sub))) < 1e-10) = sum(ac_sub, pc35_secdforest(j,ac_sub)); -======= pm_land_conservation(t,j,"secdforest","protect")$(abs(pm_land_conservation(t,j,"secdforest","protect") - sum(ac_sub, pc35_secdforest(j,ac_sub))) < 1e-6) = sum(ac_sub, pc35_secdforest(j,ac_sub)); ->>>>>>> 77d5df1d3bc91c04600d105414d2bbfcd4f01714:modules/35_natveg/pot_forest_may24/presolve.gms * set restoration target p35_land_restoration(j,"secdforest") = pm_land_conservation(t,j,"secdforest","restore"); * Do not restore secdforest in areas where total natural From f9be6ac59d69d5d537a22f100653a6b6b6e1a087 Mon Sep 17 00:00:00 2001 From: florianh Date: Wed, 29 May 2024 18:50:39 +0200 Subject: [PATCH 107/133] revisions --- CHANGELOG.md | 2 +- config/default.cfg | 4 ++- core/macros.gms | 5 ++-- modules/10_land/input/files | 2 -- .../29_cropland/detail_apr24/equations.gms | 3 ++- modules/29_cropland/detail_apr24/input.gms | 2 +- modules/29_cropland/detail_apr24/presolve.gms | 17 ++++++++++++ modules/29_cropland/detail_apr24/sets.gms | 3 --- modules/29_cropland/module.gms | 2 +- modules/29_cropland/simple_apr24/input.gms | 2 +- .../29_cropland/simple_apr24/realization.gms | 6 +++++ modules/29_cropland/simple_apr24/sets.gms | 3 --- .../30_croparea/detail_apr24/equations.gms | 27 ++++++++++++------- modules/30_croparea/detail_apr24/preloop.gms | 5 ++-- modules/30_croparea/detail_apr24/presolve.gms | 2 ++ .../32_forestry/dynamic_may24/presolve.gms | 5 +++- .../35_natveg/pot_forest_may24/presolve.gms | 7 +++-- .../macceff_aug22/equations.gms | 10 ------- .../59_som/cellpool_jan23/declarations.gms | 1 + modules/59_som/cellpool_jan23/preloop.gms | 3 +++ 20 files changed, 71 insertions(+), 40 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad38a3f888..3abfa65845 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### changed - **29_ageclass** module 29_ageclass has been renamed to 28_ageclass to make space for `29_cropland` just before `30_croparea` - **30_crop** module `30_crop` renamed to `30_croparea`, which now only accounts for crop area. -- **30_crop** SNV implementation has been moved from `30_crop` to `29_cropland` +- **30_crop** Semi-Natural Vegetation (SNV) implementation has been moved from `30_crop` to `29_cropland` - **30_crop** the two realizations `penalty_apr22` and `rotation_apr22` have been merged into a single `30_croparea/detail_apr24` realization - **30_crop** the previous `30_crop/endo_apr21` realization has been moved to `30_croparea/simple_apr24` - **default.cfg** update additional data to rev4.51 diff --git a/config/default.cfg b/config/default.cfg index f1b28d2754..2312deade7 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -717,7 +717,7 @@ cfg$gms$s29_snv_shr_noselect <- 0 # def = 0 # * Start year (should be close to 2019): cfg$gms$s29_snv_scenario_start <- 2020 # def = 2020 # * Target year (year when full implementation is reached): -cfg$gms$s29_snv_scenario_target <- 2029 # def = 2029 +cfg$gms$s29_snv_scenario_target <- 2030 # def = 2030 # * Switch and specification of countries for which SNV policy in # * s29_snv_shr apply. # * Options: list of iso-codes of countries where SNV policy should be applied @@ -732,6 +732,7 @@ cfg$gms$land_snv <- "secdforest, forestry, past, other" #def = "secdforest, f # *** Options only available for `detail_apr24` realization *** +## Agroforestry settings for treecover on cropland # * Sigmoid fader for minimum area share of treecover on total cropland at cluster level # * Minimum area share of treecover on total cropland in target year cfg$gms$s29_treecover_target <- 0 # def = 0 @@ -779,6 +780,7 @@ cfg$gms$c30_bioen_type <- "all" # def = "all" # * (c30_bioen_water): switch for irrigation of bioenergy crops; options: rainfed, irrigated, all cfg$gms$c30_bioen_water <- "rainfed" # def = "rainfed" +## Agroforestry settings for bioenergy trees # * Sigmoid fader for minimum area share of bioenergy trees (betr) on total cropland at cluster level # * Minimum area share of bioenergy trees on total cropland in start year cfg$gms$s30_betr_start <- 0 # def = 0 diff --git a/core/macros.gms b/core/macros.gms index 70830f9d68..b2304979ef 100644 --- a/core/macros.gms +++ b/core/macros.gms @@ -8,8 +8,9 @@ *****************************Technical macros*********************************** * Macro for fixing a variable in the case that lower and upper bound are too -* close to each other (closer than argument "sens") -* EXAMPLE: ma_boundfix(vm_land,(j,"ifft"),up,1e-6); +* close to each other (closer than argument "sens"). +* "arg" specifies the set for fixing. "sufx" specifies to what value the variable should be fixed ("l","lo","up"). +* EXAMPLE: m_boundfix(vm_land,(j,"ifft"),up,1e-6); $macro m_boundfix(x,arg,sufx,sens) x.fx arg$(x.up arg-x.lo arg0) + 0$(sum(s,w)<=0); diff --git a/modules/10_land/input/files b/modules/10_land/input/files index d6124da3a7..27b769596d 100644 --- a/modules/10_land/input/files +++ b/modules/10_land/input/files @@ -3,5 +3,3 @@ avl_land_t.cs3 avl_land_t_0.5.mz luh2_side_layers.cs3 avl_land_t_iso.cs3 -CroplandTreecover.cs2 -CroplandTreecover_0.5.mz diff --git a/modules/29_cropland/detail_apr24/equations.gms b/modules/29_cropland/detail_apr24/equations.gms index b5eab82988..8d4f749503 100644 --- a/modules/29_cropland/detail_apr24/equations.gms +++ b/modules/29_cropland/detail_apr24/equations.gms @@ -116,7 +116,8 @@ v29_cost_treecover_recur(j2) =e= sum(ac_sub, v29_treecover(j2,ac_sub)) * s29_cost_treecover_recur; -*' Cropland tree cover establishment rules. +*' Cropland tree cover establishment rules for distributing areas equally to age-classes. +*' For a 5-year time step ac_est includes only ac0. But for a 10-year time step ac_est includes ac0 and ac5. q29_treecover_est(j2,ac_est) .. v29_treecover(j2,ac_est) =e= sum(ac_est2, v29_treecover(j2,ac_est2))/card(ac_est2); diff --git a/modules/29_cropland/detail_apr24/input.gms b/modules/29_cropland/detail_apr24/input.gms index 50b306a32c..b9c53108eb 100644 --- a/modules/29_cropland/detail_apr24/input.gms +++ b/modules/29_cropland/detail_apr24/input.gms @@ -12,7 +12,7 @@ scalars s29_snv_shr Share of available cropland that is witheld for other land cover types (1) / 0 / s29_snv_shr_noselect Share of available cropland that is witheld for other land cover types (1) / 0 / s29_snv_scenario_start SNV scenario start year / 2020 / - s29_snv_scenario_target SNV scenario target year / 2029 / + s29_snv_scenario_target SNV scenario target year / 2030 / s29_snv_relocation_data_x1 First reference value in SNV target cropland data (1) / 0.2 / s29_snv_relocation_data_x2 Second reference value in SNV target cropland data (1) / 0.5 / s29_cost_treecover_est Tree cover establishment cost (USD05MER per ha) / 2000 / diff --git a/modules/29_cropland/detail_apr24/presolve.gms b/modules/29_cropland/detail_apr24/presolve.gms index 6894f2bacd..dba380188e 100644 --- a/modules/29_cropland/detail_apr24/presolve.gms +++ b/modules/29_cropland/detail_apr24/presolve.gms @@ -5,6 +5,10 @@ *** | MAgPIE License Exception, version 1.0 (see LICENSE file). *** | Contact: magpie@pik-potsdam.de +* ------------------------------------------------------- +* Semi-Natural Vegetation (SNV) +* ------------------------------------------------------- + *' @code *' Minimum semi-natural vegetation (SNV) share is fading in after 2020 p29_snv_shr(t,j) = i29_snv_scenario_fader(t) * @@ -32,6 +36,10 @@ p29_avl_cropland(t,j) = f29_avl_cropland(j,"%c29_marginal_land%") * (1 - p29_snv *' @stop +* ------------------------------------------------------- +* Tree cover on cropland +* ------------------------------------------------------- + * Growth of trees on cropland is modelled by shifting age-classes according to time step length. s29_shift = m_timestep_length_forestry/5; * example: ac10 in t = ac5 (ac10-1) in t-1 for a 5 yr time step (s29_shift = 1) @@ -46,6 +54,7 @@ v29_treecover.l(j,ac) = p29_treecover(t,j,ac); * create treecover target and penalty scenario i29_treecover_target(t,j) = s29_treecover_target * i29_treecover_scenario_fader(t); +* calculate treecover share pc29_treecover_share(j) = 0; pc29_treecover_share(j)$(pcm_land(j,"crop") > 1e-10) = sum(ac, pc29_treecover(j,ac)) / pcm_land(j,"crop"); pc29_treecover_share(j)$(pc29_treecover_share(j) > s29_treecover_max) = s29_treecover_max; @@ -53,18 +62,21 @@ if (s29_treecover_keep = 1, i29_treecover_target(t,j)$(i29_treecover_target(t,j) < pc29_treecover_share(j)) = pc29_treecover_share(j); ); +* Bounds for treecover. Only ac_est can increase in optimization. ac_sub can only decrease. v29_treecover.lo(j,ac_est) = 0; v29_treecover.up(j,ac_est) = Inf; v29_treecover.lo(j,ac_sub) = 0; v29_treecover.up(j,ac_sub) = pc29_treecover(j,ac_sub); m_boundfix(v29_treecover,(j,ac_sub),l,1e-6); +* set treecover penalty if (m_year(t) <= s29_treecover_scenario_start, i29_treecover_penalty(t) = s29_treecover_penalty_before; else i29_treecover_penalty(t) = s29_treecover_penalty; ); +* fix missing tree cover variable to zero in case of no penalty if (i29_treecover_penalty(t) > 0, v29_treecover_missing.lo(j) = 0; v29_treecover_missing.up(j) = Inf; @@ -72,6 +84,10 @@ else v29_treecover_missing.fx(j) = 0; ); +* ------------------------------------------------------- +* Fallow land +* ------------------------------------------------------- + * create fallow land target and penalty scenario i29_fallow_target(t) = s29_fallow_target * i29_fallow_scenario_fader(t); @@ -88,6 +104,7 @@ else ); ); +* Bounds for fallow land vm_fallow.lo(j) = 0; vm_fallow.up(j) = p29_avl_cropland(t,j); m_boundfix(vm_fallow,(j),l,1e-6); diff --git a/modules/29_cropland/detail_apr24/sets.gms b/modules/29_cropland/detail_apr24/sets.gms index e5d8286326..aa5a49bb36 100644 --- a/modules/29_cropland/detail_apr24/sets.gms +++ b/modules/29_cropland/detail_apr24/sets.gms @@ -10,9 +10,6 @@ sets marginal_land29 Marginal land scenarios / all_marginal, q33_marginal, no_marginal / - policy_target29 Target year for cropland policy - / none, by2029, by2050 / - relocation_target29 Cropland requiring relocation based on different SNV targets / SNV20TargetCropland, SNV50TargetCropland / diff --git a/modules/29_cropland/module.gms b/modules/29_cropland/module.gms index e330dbc7e6..bcf335c661 100644 --- a/modules/29_cropland/module.gms +++ b/modules/29_cropland/module.gms @@ -12,7 +12,7 @@ *' Area and carbon stocks for fallow land and tree cover are defined in this module. -*' @authors Florian Humpenöder +*' @authors Florian Humpenöder, Benjamin Bodirsky, Patrick v. Jeetze *###################### R SECTION START (MODULETYPES) ########################## $Ifi "%cropland%" == "detail_apr24" $include "./modules/29_cropland/detail_apr24/realization.gms" diff --git a/modules/29_cropland/simple_apr24/input.gms b/modules/29_cropland/simple_apr24/input.gms index eb33c95ec9..fdf7cdf40c 100644 --- a/modules/29_cropland/simple_apr24/input.gms +++ b/modules/29_cropland/simple_apr24/input.gms @@ -12,7 +12,7 @@ scalars s29_snv_shr Share of available cropland that is witheld for other land cover types (1) / 0 / s29_snv_shr_noselect Share of available cropland that is witheld for other land cover types (1) / 0 / s29_snv_scenario_start SNV scenario start year / 2020 / - s29_snv_scenario_target SNV scenario target year / 2029 / + s29_snv_scenario_target SNV scenario target year / 2030 / s29_snv_relocation_data_x1 First reference value in SNV target cropland data (1) / 0.2 / s29_snv_relocation_data_x2 Second reference value in SNV target cropland data (1) / 0.5 / ; diff --git a/modules/29_cropland/simple_apr24/realization.gms b/modules/29_cropland/simple_apr24/realization.gms index 3257388faa..ae6d324c77 100644 --- a/modules/29_cropland/simple_apr24/realization.gms +++ b/modules/29_cropland/simple_apr24/realization.gms @@ -11,6 +11,12 @@ *' Biodiversity BII values are fixed to zero. *' Costs are fixed to zero. +*' This realisation also includes the option to reserve a minimum semi-natural +*' vegetation share within the total available cropland for other land cover +*' classes, including grassland, forest, and other land (by a given target year), +*' in order to provide species habitats and to benefit from ecosystem ervices in +*' agricultural landscapes. + *' @limitations Fallow land and tree cover on cropland are fixed to zero *####################### R SECTION START (PHASES) ############################## diff --git a/modules/29_cropland/simple_apr24/sets.gms b/modules/29_cropland/simple_apr24/sets.gms index e5d8286326..aa5a49bb36 100644 --- a/modules/29_cropland/simple_apr24/sets.gms +++ b/modules/29_cropland/simple_apr24/sets.gms @@ -10,9 +10,6 @@ sets marginal_land29 Marginal land scenarios / all_marginal, q33_marginal, no_marginal / - policy_target29 Target year for cropland policy - / none, by2029, by2050 / - relocation_target29 Cropland requiring relocation based on different SNV targets / SNV20TargetCropland, SNV50TargetCropland / diff --git a/modules/30_croparea/detail_apr24/equations.gms b/modules/30_croparea/detail_apr24/equations.gms index 7f4a192878..e51d334eac 100644 --- a/modules/30_croparea/detail_apr24/equations.gms +++ b/modules/30_croparea/detail_apr24/equations.gms @@ -23,17 +23,15 @@ vm_land(j2,"crop") * sum(ct, i30_betr_target(ct)) - vm_area(j2,"betr","rainfed"); *' Rotational constraints prevent over-specialization. In this realization, -*' they are either implemented via a rules (i30_implementation = 1) or +*' they are either implemented via rules (i30_implementation = 1) or *' a penalty payment if the constraints are violated (i30_implementation = 0). - q30_rotation_penalty(i2) .. - vm_rotation_penalty(i2) =g= - sum(cell(i2,j2), - sum(rota30, v30_penalty(j2,rota30) * sum(ct, i30_rotation_incentives(ct,rota30))) - + sum(rotamax_red30, v30_penalty_max_irrig(j2,rotamax_red30) - * sum(ct, i30_rotation_incentives(ct,rotamax_red30))) - + v30_betr_missing(j2) * sum(ct, i30_betr_penalty(ct)) - ); +*' Rule-based rotational constraints (i30_implementation = 1): + +*' Minimum and maximum rotational constraints limit +*' the placing of crops. These rotational constraints reflect +*' crop rotations limiting the share a specific crop can cover of the total area +*' of a cluster. q30_rotation_max(j2,rotamax_red30)$(i30_implementation = 1) .. sum((rota_kcr30(rotamax_red30,kcr),w), vm_area(j2,kcr,w)) =l= @@ -43,6 +41,17 @@ sum((rota_kcr30(rotamin_red30,kcr),w), vm_area(j2,kcr,w)) =g= sum((kcr,w),vm_area(j2,kcr,w)) * sum(ct,i30_rotation_rules(ct,rotamin_red30)); +* 'Penalty-based rotational constraints (i30_implementation = 0): + + q30_rotation_penalty(i2) .. + vm_rotation_penalty(i2) =g= + sum(cell(i2,j2), + sum(rota30, v30_penalty(j2,rota30) * sum(ct, i30_rotation_incentives(ct,rota30))) + + sum(rotamax_red30, v30_penalty_max_irrig(j2,rotamax_red30) + * sum(ct, i30_rotation_incentives(ct,rotamax_red30))) + + v30_betr_missing(j2) * sum(ct, i30_betr_penalty(ct)) + ); + *' The penalty applies to the areas which exceed a certain maximum *' share of the land. Below this share, negative benefits are *' avoided by defining the penalty to be positive. diff --git a/modules/30_croparea/detail_apr24/preloop.gms b/modules/30_croparea/detail_apr24/preloop.gms index 8d2ac45a5f..61c6d15a85 100644 --- a/modules/30_croparea/detail_apr24/preloop.gms +++ b/modules/30_croparea/detail_apr24/preloop.gms @@ -10,12 +10,12 @@ m_sigmoid_time_interpol(i30_rotation_scenario_fader,s30_rotation_scenario_start,s30_rotation_scenario_target,0,1); m_sigmoid_time_interpol(i30_betr_scenario_fader,s30_betr_scenario_start,s30_betr_scenario_target,0,1); -** create crop rotation scenario +** Fader for rotational constraints i30_rotation_rules(t_all,rota30) = f30_rotation_rules(rota30,"default") * (1-i30_rotation_scenario_fader(t_all)) + f30_rotation_rules(rota30,"%c30_rotation_rules%") * (i30_rotation_scenario_fader(t_all)); -** create crop rotation scenario +** Fader for penalty for violating rotational constraints i30_rotation_incentives(t_all,rota30) = f30_rotation_incentives(rota30,"default") * (1-i30_rotation_scenario_fader(t_all)) + f30_rotation_incentives(rota30,"%c30_rotation_incentives%") * (i30_rotation_scenario_fader(t_all)); @@ -26,6 +26,7 @@ i30_rotation_incentives(t_all,rota30) = *cannot be smaller than 0! fm_croparea(t_past,j,w,kcr)$(fm_croparea(t_past,j,w,kcr)<0) = 0; +* fix penalty to zero in case of rule-based rotational contraints if(s30_implementation = 1, v30_penalty.fx(j,rota30) = 0; ); diff --git a/modules/30_croparea/detail_apr24/presolve.gms b/modules/30_croparea/detail_apr24/presolve.gms index 8b6bbb14b7..047c05ed2d 100644 --- a/modules/30_croparea/detail_apr24/presolve.gms +++ b/modules/30_croparea/detail_apr24/presolve.gms @@ -12,6 +12,8 @@ vm_area.fx(j,kbe30,w)=0; *' Second, the bounds for 2nd generation bioenergy area are released depending on *' the dynamic sets bioen_type_30 and bioen_water_30. *' SSP2 default settings are used for the historic period. +*' In addition, rule-based rotational constraints (i30_implementation = 1) +*' are assumed for the historic period. if(m_year(t) <= sm_fix_SSP2, vm_area.up(j,kbe30,"rainfed") = Inf; i30_implementation = 1; diff --git a/modules/32_forestry/dynamic_may24/presolve.gms b/modules/32_forestry/dynamic_may24/presolve.gms index 532966fe11..5537c528fc 100644 --- a/modules/32_forestry/dynamic_may24/presolve.gms +++ b/modules/32_forestry/dynamic_may24/presolve.gms @@ -14,7 +14,10 @@ v32_land_reduction.fx(j,type32,ac_est) = 0; p32_aff_pol_timestep("y1995",j) = 0; p32_aff_pol_timestep(t,j)$(ord(t)>1) = p32_aff_pol(t,j) - p32_aff_pol(t-1,j); * Suitable area (`p32_aff_pot`) for NPI/NDC afforestation - p32_aff_pot(t,j) = sum((kcr,w),vm_area.l(j,kcr,w) - vm_area.lo(j,kcr,w)) + (vm_land.l(j,"past") - vm_land.lo(j,"past")) - pm_land_conservation(t,j,"other","restore"); + p32_aff_pot(t,j) = sum((kcr,w),vm_area.l(j,kcr,w) - vm_area.lo(j,kcr,w)) + + (vm_fallow.l(j) - vm_fallow.lo(j)) + + (vm_land.l(j,"past") - vm_land.lo(j,"past")) + - pm_land_conservation(t,j,"other","restore"); *** NDC/NPI re/afforesation is further constrained by the remaining forest establishment potential p32_aff_pot(t,j)$(p32_aff_pot(t,j) > pcm_max_forest_est(j)) = pcm_max_forest_est(j); * suitable area `p32_aff_pot` can be negative, if land restoration is switched on (level smaller than lower bound), therefore set negative values to 0 diff --git a/modules/35_natveg/pot_forest_may24/presolve.gms b/modules/35_natveg/pot_forest_may24/presolve.gms index 8d2ac2ede8..c20b972644 100644 --- a/modules/35_natveg/pot_forest_may24/presolve.gms +++ b/modules/35_natveg/pot_forest_may24/presolve.gms @@ -55,8 +55,11 @@ p35_forest_recovery_area(t,j,ac_est)$(sum(ac_est2, p35_forest_recovery_area(t,j, * The proportion of secondary forest recovery in total natveg * recovery is derived from the remaining forest recovery area -pc35_forest_recovery_shr(j) = (pc35_max_forest_recovery(j) - sum(ac_est, p35_forest_recovery_area(t,j,ac_est))) - / (sum(land_ag, pcm_land(j,land_ag))+pcm_land(j,"urban")+1e-10); +pc35_forest_recovery_shr(j) = 0; +pc35_forest_recovery_shr(j)$((sum(land_ag, pcm_land(j,land_ag))+pcm_land(j,"urban")) > +1e-10) = + (pc35_max_forest_recovery(j) - sum(ac_est, p35_forest_recovery_area(t,j,ac_est))) + / (sum(land_ag, pcm_land(j,land_ag))+pcm_land(j,"urban")); +pc35_forest_recovery_shr(j)$(pc35_forest_recovery_shr(j) < 0) = 0; pc35_forest_recovery_shr(j)$(pc35_forest_recovery_shr(j) > 1) = 1; * Abandoned land pc35_land_other(j,"othernat",ac_est) that has not yet been allocated to * p35_forest_recovery_area(t,j,ac_est) is then distributed proportionally using the forest recovery share. diff --git a/modules/50_nr_soil_budget/macceff_aug22/equations.gms b/modules/50_nr_soil_budget/macceff_aug22/equations.gms index f292521c1b..8133c1316f 100644 --- a/modules/50_nr_soil_budget/macceff_aug22/equations.gms +++ b/modules/50_nr_soil_budget/macceff_aug22/equations.gms @@ -24,8 +24,6 @@ q50_nr_inputs(i2) .. vm_res_recycling(i2,"nr") + sum((cell(i2,j2),kcr,w), vm_area(j2,kcr,w) * f50_nr_fix_area(kcr)) + sum(cell(i2,j2),vm_fallow(j2) * f50_nr_fix_area("tece")) -* Commented out for consistency with q50_nr_surplus_nonagland -* + sum(cell(i2,j2),vm_treecover(j2)) * sum(ct,f50_nr_fixation_rates_nonagland(ct,i2)) + vm_manure_recycling(i2,"nr") + sum(kli, vm_manure(i2, kli, "stubble_grazing","nr")) + vm_nr_inorg_fert_reg(i2,"crop") @@ -86,14 +84,6 @@ q50_nr_surplus_pasture(i2) .. v50_nr_withdrawals_pasture(i2) =e= vm_prod_reg(i2,"pasture") * fm_attributes("nr","pasture"); -* Calculating Budget surplus for non-agricultural land - -* q50_nr_surplus_nonagland(i2) .. -* vm_nr_surplus_nonagland(i2) -* =e= -* sum((cell(i2,j2),nonagland50), vm_land(j2,nonagland50)) * sum(ct,f50_nr_fixation_rates_nonagland(ct,i2)) -* + sum(nonagland50, v50_nr_deposition(i2,nonagland50)); - *' For both crop land and pasture land, this equation gives the amount of nitrogen deposited from the atmosphere. q50_nr_deposition(i2,land) .. v50_nr_deposition(i2,land) =e= diff --git a/modules/59_som/cellpool_jan23/declarations.gms b/modules/59_som/cellpool_jan23/declarations.gms index 46831d6429..c4896263a5 100644 --- a/modules/59_som/cellpool_jan23/declarations.gms +++ b/modules/59_som/cellpool_jan23/declarations.gms @@ -12,6 +12,7 @@ parameters i59_input_share(i,inputs59) Share of land under input class (1) i59_cratio(j,kcr,w) Ratio of carbon density of land relative to natural vegetaion (1) i59_cratio_fallow(j) Ratio of carbon density of fallow land relative to natural vegetation (1) + i59_cratio_treecover Ratio of carbon density of tree cover on cropland relative to natural vegetation (1) p59_som_pool(j,land) Actual C pool (mio. tC) i59_subsoilc_density(t_all,j) Subsoil carbon density of a hectare of land (tC per ha) p59_land_before(j,land) Land area in previous time step (mio. ha) diff --git a/modules/59_som/cellpool_jan23/preloop.gms b/modules/59_som/cellpool_jan23/preloop.gms index 0454db31bb..26d2488ff8 100644 --- a/modules/59_som/cellpool_jan23/preloop.gms +++ b/modules/59_som/cellpool_jan23/preloop.gms @@ -73,6 +73,9 @@ i59_cratio_fallow(j) = sum((cell(i,j),climate59), * f59_cratio_landuse(i,climate59,"maiz") * f59_cratio_tillage(climate59,"reduced_tillage") * f59_cratio_inputs(climate59,"low_input")); + +i59_cratio_treecover = 1; + *' @stop p59_carbon_density(t,j,land) = 0; From f56a0c143b4ed711c6673c42f7b2023e40031b91 Mon Sep 17 00:00:00 2001 From: florianh Date: Thu, 30 May 2024 08:26:24 +0200 Subject: [PATCH 108/133] bugfix carbon density --- modules/29_cropland/detail_apr24/preloop.gms | 4 ++-- modules/29_cropland/simple_apr24/not_used.txt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/29_cropland/detail_apr24/preloop.gms b/modules/29_cropland/detail_apr24/preloop.gms index b65a0c2b43..c45d550fd2 100644 --- a/modules/29_cropland/detail_apr24/preloop.gms +++ b/modules/29_cropland/detail_apr24/preloop.gms @@ -32,9 +32,9 @@ pc29_treecover(j,ac) = (pc29_treecover_share(j) * pm_land_hist("y1995",j,"crop") *' 0 = Use natveg growth curve towards LPJmL natural vegetation *' 1 = Use plantation growth curve (faster than natveg) towards LPJmL natural vegetation if(s29_treecover_plantation = 0, - p29_carbon_density_ac(t,j,ac,ag_pools) = pm_carbon_density_ac(t,j,ac,ag_pools); + p29_carbon_density_ac(t,j,ac,ag_pools) = pm_carbon_density_secdforest_ac(t,j,ac,ag_pools); elseif s29_treecover_plantation = 1, - p29_carbon_density_ac(t,j,ac,ag_pools) = pm_carbon_density_ac_forestry(t,j,ac,ag_pools); + p29_carbon_density_ac(t,j,ac,ag_pools) = pm_carbon_density_plantation_ac(t,j,ac,ag_pools); ); ** set bii coefficients diff --git a/modules/29_cropland/simple_apr24/not_used.txt b/modules/29_cropland/simple_apr24/not_used.txt index a60069f62b..9ee70dc271 100644 --- a/modules/29_cropland/simple_apr24/not_used.txt +++ b/modules/29_cropland/simple_apr24/not_used.txt @@ -3,6 +3,6 @@ pm_land_hist,input,not needed fm_luh2_side_layers,input,not needed pm_interest,input,not needed fm_bii_coeff,input,not needed -pm_carbon_density_ac,input,not needed -pm_carbon_density_ac_forestry,input,not needed +pm_carbon_density_secdforest_ac,input,not needed +pm_carbon_density_plantation_ac,input,not needed fm_carbon_density,input,not needed From dce8e0d28dfa9ebe7e56963a7cfbd0840a189137 Mon Sep 17 00:00:00 2001 From: florianh Date: Thu, 30 May 2024 10:28:21 +0200 Subject: [PATCH 109/133] cleanup and consistency 32_forestry --- .../32_forestry/dynamic_may24/declarations.gms | 5 ++--- modules/32_forestry/dynamic_may24/postsolve.gms | 2 +- modules/32_forestry/dynamic_may24/preloop.gms | 3 +++ modules/32_forestry/dynamic_may24/presolve.gms | 17 +++-------------- 4 files changed, 9 insertions(+), 18 deletions(-) diff --git a/modules/32_forestry/dynamic_may24/declarations.gms b/modules/32_forestry/dynamic_may24/declarations.gms index 6b679b0a4d..c04fc094d7 100644 --- a/modules/32_forestry/dynamic_may24/declarations.gms +++ b/modules/32_forestry/dynamic_may24/declarations.gms @@ -20,8 +20,8 @@ parameters p32_carbon_density_ac(t,j,type32,ac,ag_pools) Carbon density for ac and ag_pools (tC per ha) p32_carbon_density_ac_forestry(t_all,j,ac) Above ground carbon density for age classes and carbon pools (tC per ha) p32_carbon_density_ac_marg(t_all,j,ac) Marginal above ground carbon density for age classes and carbon pools (tC per ha) - p32_land(t,j,type32,ac) Forestry land for each cell wood type and age class before and after optimization (mio. ha) - pc32_land(j,type32,ac) Forestry land per forestry land type initialization of the optimization (mio. ha) + p32_land(t,j,type32,ac) Forestry land pools before optimization (mio. ha) + pc32_land(j,type32,ac) Forestry land pools in current time step (mio. ha) p32_yield_forestry_future(t,j) Cellular timber yield expected in the future (m3 per ha per year) p32_IGR(t_all,j,ac) Instantaneous growth rate or periodic annual increment of forest growth (1) p32_rot_flg(t_all,j,ac) Identifier flag when calculating rotation length (1) @@ -32,7 +32,6 @@ parameters p32_cdr_ac(t,j,ac) Non-cumulative CDR from afforestation plantations for each age-class depending on planning horizon (tC per ha) p32_rotation_offset Offset calc in age class equivalents (1) p32_land_start_ac(j,type32,ac) Saving first value of starting land (mio. ha) - p32_land_before(t,j,type32,ac) Saving time value of starting land (mio. ha) p32_time(ac) Time as a function of age-classes (yr) p32_discount_factor(t_all,j,ac) Discount factor for each age class (1) p32_net_present_value(t_all,j,ac) Net present value for a representative 1ha land of plantations (mio. USD) diff --git a/modules/32_forestry/dynamic_may24/postsolve.gms b/modules/32_forestry/dynamic_may24/postsolve.gms index 1ec319b88b..d8aa765167 100644 --- a/modules/32_forestry/dynamic_may24/postsolve.gms +++ b/modules/32_forestry/dynamic_may24/postsolve.gms @@ -6,7 +6,7 @@ *** | Contact: magpie@pik-potsdam.de *' @code *' Exchange land information after optimization -p32_land(t,j,type32,ac) = v32_land.l(j,type32,ac); +pc32_land(j,type32,ac) = v32_land.l(j,type32,ac); *' @stop *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### diff --git a/modules/32_forestry/dynamic_may24/preloop.gms b/modules/32_forestry/dynamic_may24/preloop.gms index a3f792c24d..3fec5a9101 100644 --- a/modules/32_forestry/dynamic_may24/preloop.gms +++ b/modules/32_forestry/dynamic_may24/preloop.gms @@ -170,6 +170,9 @@ loop(j, ); ); +** Initialize forestry land types +pc32_land(j,type32,ac) = p32_land_start_ac(j,type32,ac); + *** NPI/NDC policies BEGIN ** Afforestation policies NPI and NDCs p32_aff_pol(t,j) = round(f32_aff_pol(t,j,"%c32_aff_policy%"),6); diff --git a/modules/32_forestry/dynamic_may24/presolve.gms b/modules/32_forestry/dynamic_may24/presolve.gms index 5537c528fc..b7854d8e6a 100644 --- a/modules/32_forestry/dynamic_may24/presolve.gms +++ b/modules/32_forestry/dynamic_may24/presolve.gms @@ -47,12 +47,6 @@ p32_cdr_ac(t,j,ac)$(ord(ac) > 1 AND (ord(ac)-1) <= s32_planing_horizon/5) = p32_carbon_density_ac(t,j,"aff",ac,"vegc") - p32_carbon_density_ac(t,j,"aff",ac-1,"vegc"); * Disturbance from generic sources to managed and natural forests -if((ord(t) = 1), - pc32_land(j,type32,ac) = p32_land_start_ac(j,type32,ac); -else - pc32_land(j,type32,ac) = p32_land(t-1,j,type32,ac); -); - p32_disturbance_loss_ftype32(t,j,"aff",ac_sub) = pc32_land(j,"aff",ac_sub) * f32_forest_shock(t,"%c32_shock_scenario%") * m_timestep_length; pc32_land(j,"aff",ac_est) = pc32_land(j,"aff",ac_est) + sum(ac_sub,p32_disturbance_loss_ftype32(t,j,"aff",ac_sub))/card(ac_est2); @@ -64,25 +58,20 @@ pc32_land(j,"aff",ac_sub) = pc32_land(j,"aff",ac_sub) - p32_disturbance_loss_fty s32_shift = m_yeardiff_forestry(t)/5; *' @stop -*' Shifting of age-classes in land. +*' Shifting of age-classes *` @code -if((ord(t)=1), -p32_land(t,j,type32,ac)$(ord(ac) > s32_shift) = p32_land_start_ac(j,type32,ac-s32_shift); -p32_land(t,j,type32,"acx") = p32_land(t,j,type32,"acx") + sum(ac$(ord(ac) > card(ac)-s32_shift), p32_land_start_ac(j,type32,ac)); -else * Example: ac10 in t = ac5 (ac10-1) in t-1 for a 5 yr time step (s32_shift = 1) p32_land(t,j,type32,ac)$(ord(ac) > s32_shift) = pc32_land(j,type32,ac-s32_shift); * Account for cases at the end of the age class set (s32_shift > 1) which are not shifted by the above calculation p32_land(t,j,type32,"acx") = p32_land(t,j,type32,"acx") + sum(ac$(ord(ac) > card(ac)-s32_shift), pc32_land(j,type32,ac)); -); + * set ac_est to zero p32_land(t,j,type32,ac_est) = 0; *' @stop ** Calculate v32_land.l v32_land.l(j,type32,ac) = p32_land(t,j,type32,ac); -pc32_land(j,type32,ac) = v32_land.l(j,type32,ac); -p32_land_before(t,j,type32,ac) = p32_land(t,j,type32,ac); +pc32_land(j,type32,ac) = p32_land(t,j,type32,ac); vm_land.l(j,"forestry") = sum((type32,ac), v32_land.l(j,type32,ac)); pcm_land(j,"forestry") = sum((type32,ac), v32_land.l(j,type32,ac)); pcm_land_forestry(j,type32) = sum(ac, v32_land.l(j,type32,ac)); From 6119e522a3c93bafc980c2bb3871a45e8b56b96e Mon Sep 17 00:00:00 2001 From: florianh Date: Sat, 1 Jun 2024 13:13:01 +0200 Subject: [PATCH 110/133] revision 59_som --- .../59_som/cellpool_aug16/declarations.gms | 7 +++--- modules/59_som/cellpool_aug16/postsolve.gms | 6 ++--- modules/59_som/cellpool_aug16/preloop.gms | 12 ++++++---- modules/59_som/cellpool_aug16/presolve.gms | 24 +++++++++---------- .../59_som/cellpool_jan23/declarations.gms | 9 +++---- modules/59_som/cellpool_jan23/postsolve.gms | 6 ++--- modules/59_som/cellpool_jan23/preloop.gms | 12 ++++++---- modules/59_som/cellpool_jan23/presolve.gms | 24 +++++++++---------- 8 files changed, 53 insertions(+), 47 deletions(-) diff --git a/modules/59_som/cellpool_aug16/declarations.gms b/modules/59_som/cellpool_aug16/declarations.gms index 80e3155d46..81eff1839a 100644 --- a/modules/59_som/cellpool_aug16/declarations.gms +++ b/modules/59_som/cellpool_aug16/declarations.gms @@ -7,15 +7,16 @@ parameters i59_lossrate(t) Rate of loss or recovery of SOM pool per timestep (1) - p59_carbon_density(t_all,j,land) Carbon density of a hectare of land (tC per ha) + p59_carbon_density(t_all,j,land) Soil carbon density of a hectare of land (tC per ha) + pc59_carbon_density(j,land) Soil carbon density of a hectare of land between time steps (tC per ha) i59_tillage_share(i,tillage59) Share of land under tillage class (1) i59_input_share(i,inputs59) Share of land under input class (1) i59_cratio(j,kcr,w) Ratio of carbon density of land relative to natural vegetaion (1) i59_cratio_fallow(j) Ratio of carbon density of fallow land relative to natural vegetation (1) i59_cratio_treecover Ratio of carbon density of tree cover on cropland relative to natural vegetation (1) - p59_som_pool(j,land) Actual C pool (mio. tC) + pc59_som_pool(j,land) Actual C pool (mio. tC) i59_subsoilc_density(t_all,j) Subsoil carbon density of a hectare of land (tC per ha) - p59_land_before(j,land) Land area in previous time step (mio. ha) + pc59_land_before(j,land) Land area in previous time step (mio. ha) ; equations diff --git a/modules/59_som/cellpool_aug16/postsolve.gms b/modules/59_som/cellpool_aug16/postsolve.gms index cd03390003..60e1f2c60f 100644 --- a/modules/59_som/cellpool_aug16/postsolve.gms +++ b/modules/59_som/cellpool_aug16/postsolve.gms @@ -5,9 +5,9 @@ *** | MAgPIE License Exception, version 1.0 (see LICENSE file). *** | Contact: magpie@pik-potsdam.de -p59_som_pool(j,land) = v59_som_pool.l(j,land); -p59_land_before(j,land) = vm_land.l(j,land); -p59_carbon_density(t,j,land)$(pcm_land(j,land) > 1e-10) = p59_som_pool(j,land) / pcm_land(j,land); +pc59_som_pool(j,land) = v59_som_pool.l(j,land); +pc59_land_before(j,land) = vm_land.l(j,land); +pc59_carbon_density(j,land)$(pc59_land_before(j,land) > 1e-10) = pc59_som_pool(j,land) / pc59_land_before(j,land); *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### ov59_som_target(t,j,land,"marginal") = v59_som_target.m(j,land); diff --git a/modules/59_som/cellpool_aug16/preloop.gms b/modules/59_som/cellpool_aug16/preloop.gms index 41fc1b9447..a2625bdf21 100644 --- a/modules/59_som/cellpool_aug16/preloop.gms +++ b/modules/59_som/cellpool_aug16/preloop.gms @@ -11,12 +11,12 @@ i59_subsoilc_density(t_all,j) = fm_carbon_density(t_all,j,"secdforest","soilc") - f59_topsoilc_density(t_all,j); -p59_som_pool(j,"crop") = +pc59_som_pool(j,"crop") = sum((climate59,kcr),sum(clcl_climate59(clcl,climate59), pm_climate_class(j,clcl)) * f59_cratio_landuse(climate59,kcr) * f59_topsoilc_density("y1995",j) * sum(w, fm_croparea("y1995",j,w,kcr))); -p59_som_pool(j,noncropland59) = +pc59_som_pool(j,noncropland59) = f59_topsoilc_density("y1995",j) * pm_land_start(j,noncropland59); @@ -28,7 +28,7 @@ p59_som_pool(j,noncropland59) = * ATTENTION: emissions in 1995 are not meaningful vm_carbon_stock.l(j,"crop","soilc",stockType) = - p59_som_pool(j,"crop") + i59_subsoilc_density("y1995",j) * pm_land_start(j,"crop"); + pc59_som_pool(j,"crop") + i59_subsoilc_density("y1995",j) * pm_land_start(j,"crop"); vm_carbon_stock.l(j,noncropland59,"soilc",stockType) = fm_carbon_density("y1995",j,noncropland59,"soilc") * pm_land_start(j,noncropland59); @@ -78,6 +78,8 @@ i59_cratio_treecover = 1; *' @stop -p59_carbon_density(t,j,land) = 0; +pc59_land_before(j,land) = pm_land_start(j,land); -p59_land_before(j,land) = pm_land_start(j,land); +p59_carbon_density(t,j,land) = 0; +pc59_carbon_density(j,land) = 0; +pc59_carbon_density(j,land)$(pc59_land_before(j,land) > 1e-10) = pc59_som_pool(j,land) / pc59_land_before(j,land); diff --git a/modules/59_som/cellpool_aug16/presolve.gms b/modules/59_som/cellpool_aug16/presolve.gms index 26cdb91674..1cf578801c 100644 --- a/modules/59_som/cellpool_aug16/presolve.gms +++ b/modules/59_som/cellpool_aug16/presolve.gms @@ -12,18 +12,18 @@ * Note: This will only account for transitions of primary forest to secondary forest and * other land to secondary forest. See current version of 35_natveg to check consistency. -p59_som_pool(j,"secdforest") = p59_som_pool(j,"secdforest") + - (p59_land_before(j,"primforest") - pcm_land(j,"primforest")) * - p59_carbon_density(t-1,j,"primforest") + - (p59_land_before(j,"other") - pcm_land(j,"other")) * - p59_carbon_density(t-1,j,"other"); +pc59_som_pool(j,"secdforest") = pc59_som_pool(j,"secdforest") + + (pc59_land_before(j,"primforest") - pcm_land(j,"primforest")) * + pc59_carbon_density(j,"primforest") + + (pc59_land_before(j,"other") - pcm_land(j,"other")) * + pc59_carbon_density(j,"other"); -p59_som_pool(j,"other") = p59_som_pool(j,"other") - - (p59_land_before(j,"other") - pcm_land(j,"other")) * - p59_carbon_density(t-1,j,"other"); +pc59_som_pool(j,"other") = pc59_som_pool(j,"other") - + (pc59_land_before(j,"other") - pcm_land(j,"other")) * + pc59_carbon_density(j,"other"); -p59_som_pool(j,"primforest") = p59_som_pool(j,"primforest") - - (p59_land_before(j,"primforest") - pcm_land(j,"primforest")) * - p59_carbon_density(t-1,j,"primforest"); +pc59_som_pool(j,"primforest") = pc59_som_pool(j,"primforest") - + (pc59_land_before(j,"primforest") - pcm_land(j,"primforest")) * + pc59_carbon_density(j,"primforest"); -p59_carbon_density(t,j,land)$(pcm_land(j,land) > 1e-10) = p59_som_pool(j,land) / pcm_land(j,land); +p59_carbon_density(t,j,land)$(pcm_land(j,land) > 1e-10) = pc59_som_pool(j,land) / pcm_land(j,land); diff --git a/modules/59_som/cellpool_jan23/declarations.gms b/modules/59_som/cellpool_jan23/declarations.gms index c4896263a5..632aba9c32 100644 --- a/modules/59_som/cellpool_jan23/declarations.gms +++ b/modules/59_som/cellpool_jan23/declarations.gms @@ -7,15 +7,16 @@ parameters i59_lossrate(t) Rate of loss or recovery of SOM pool per timestep (1) - p59_carbon_density(t_all,j,land) Carbon density of a hectare of land (tC per ha) + p59_carbon_density(t_all,j,land) Soil carbon density of a hectare of land (tC per ha) + pc59_carbon_density(j,land) Soil carbon density of a hectare of land between time steps (tC per ha) i59_tillage_share(i,tillage59) Share of land under tillage class (1) i59_input_share(i,inputs59) Share of land under input class (1) i59_cratio(j,kcr,w) Ratio of carbon density of land relative to natural vegetaion (1) i59_cratio_fallow(j) Ratio of carbon density of fallow land relative to natural vegetation (1) i59_cratio_treecover Ratio of carbon density of tree cover on cropland relative to natural vegetation (1) - p59_som_pool(j,land) Actual C pool (mio. tC) + pc59_som_pool(j,land) Actual C pool (mio. tC) i59_subsoilc_density(t_all,j) Subsoil carbon density of a hectare of land (tC per ha) - p59_land_before(j,land) Land area in previous time step (mio. ha) + pc59_land_before(j,land) Land area in previous time step (mio. ha) ; equations @@ -25,7 +26,7 @@ equations q59_nr_som(j) Soil organic matter loss (Mt N per yr) q59_nr_som_fertilizer(j) Bound of nitrogen fertilizer of soil organic matter loss (Mt N per yr) q59_nr_som_fertilizer2(j) Fraction of soil organic matter loss take is taken up by plants (Mt N per yr) - q59_carbon_soil(j,land,stockType) Soil carbon content calculation (mio. tC) + q59_carbon_soil(j,land,stockType) Soil carbon content calculation (mio. tC) ; positive variables diff --git a/modules/59_som/cellpool_jan23/postsolve.gms b/modules/59_som/cellpool_jan23/postsolve.gms index cd03390003..60e1f2c60f 100644 --- a/modules/59_som/cellpool_jan23/postsolve.gms +++ b/modules/59_som/cellpool_jan23/postsolve.gms @@ -5,9 +5,9 @@ *** | MAgPIE License Exception, version 1.0 (see LICENSE file). *** | Contact: magpie@pik-potsdam.de -p59_som_pool(j,land) = v59_som_pool.l(j,land); -p59_land_before(j,land) = vm_land.l(j,land); -p59_carbon_density(t,j,land)$(pcm_land(j,land) > 1e-10) = p59_som_pool(j,land) / pcm_land(j,land); +pc59_som_pool(j,land) = v59_som_pool.l(j,land); +pc59_land_before(j,land) = vm_land.l(j,land); +pc59_carbon_density(j,land)$(pc59_land_before(j,land) > 1e-10) = pc59_som_pool(j,land) / pc59_land_before(j,land); *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### ov59_som_target(t,j,land,"marginal") = v59_som_target.m(j,land); diff --git a/modules/59_som/cellpool_jan23/preloop.gms b/modules/59_som/cellpool_jan23/preloop.gms index 26d2488ff8..8393b1f201 100644 --- a/modules/59_som/cellpool_jan23/preloop.gms +++ b/modules/59_som/cellpool_jan23/preloop.gms @@ -11,12 +11,12 @@ i59_subsoilc_density(t_all,j) = fm_carbon_density(t_all,j,"secdforest","soilc") - f59_topsoilc_density(t_all,j); -p59_som_pool(j,"crop") = +pc59_som_pool(j,"crop") = sum((climate59,kcr),sum(clcl_climate59(clcl,climate59), pm_climate_class(j,clcl)) * sum(cell(i,j), f59_cratio_landuse(i,climate59,kcr)) * f59_topsoilc_density("y1995",j) * sum(w, fm_croparea("y1995",j,w,kcr))); -p59_som_pool(j,noncropland59) = +pc59_som_pool(j,noncropland59) = f59_topsoilc_density("y1995",j) * pm_land_start(j,noncropland59); @@ -28,7 +28,7 @@ p59_som_pool(j,noncropland59) = * ATTENTION: emissions in 1995 are not meaningful vm_carbon_stock.l(j,"crop","soilc",stockType) = - p59_som_pool(j,"crop") + i59_subsoilc_density("y1995",j) * pm_land_start(j,"crop"); + pc59_som_pool(j,"crop") + i59_subsoilc_density("y1995",j) * pm_land_start(j,"crop"); vm_carbon_stock.l(j,noncropland59,"soilc",stockType) = fm_carbon_density("y1995",j,noncropland59,"soilc") * pm_land_start(j,noncropland59); @@ -78,6 +78,8 @@ i59_cratio_treecover = 1; *' @stop -p59_carbon_density(t,j,land) = 0; +pc59_land_before(j,land) = pm_land_start(j,land); -p59_land_before(j,land) = pm_land_start(j,land); +p59_carbon_density(t,j,land) = 0; +pc59_carbon_density(j,land) = 0; +pc59_carbon_density(j,land)$(pc59_land_before(j,land) > 1e-10) = pc59_som_pool(j,land) / pc59_land_before(j,land); diff --git a/modules/59_som/cellpool_jan23/presolve.gms b/modules/59_som/cellpool_jan23/presolve.gms index 26cdb91674..1cf578801c 100644 --- a/modules/59_som/cellpool_jan23/presolve.gms +++ b/modules/59_som/cellpool_jan23/presolve.gms @@ -12,18 +12,18 @@ * Note: This will only account for transitions of primary forest to secondary forest and * other land to secondary forest. See current version of 35_natveg to check consistency. -p59_som_pool(j,"secdforest") = p59_som_pool(j,"secdforest") + - (p59_land_before(j,"primforest") - pcm_land(j,"primforest")) * - p59_carbon_density(t-1,j,"primforest") + - (p59_land_before(j,"other") - pcm_land(j,"other")) * - p59_carbon_density(t-1,j,"other"); +pc59_som_pool(j,"secdforest") = pc59_som_pool(j,"secdforest") + + (pc59_land_before(j,"primforest") - pcm_land(j,"primforest")) * + pc59_carbon_density(j,"primforest") + + (pc59_land_before(j,"other") - pcm_land(j,"other")) * + pc59_carbon_density(j,"other"); -p59_som_pool(j,"other") = p59_som_pool(j,"other") - - (p59_land_before(j,"other") - pcm_land(j,"other")) * - p59_carbon_density(t-1,j,"other"); +pc59_som_pool(j,"other") = pc59_som_pool(j,"other") - + (pc59_land_before(j,"other") - pcm_land(j,"other")) * + pc59_carbon_density(j,"other"); -p59_som_pool(j,"primforest") = p59_som_pool(j,"primforest") - - (p59_land_before(j,"primforest") - pcm_land(j,"primforest")) * - p59_carbon_density(t-1,j,"primforest"); +pc59_som_pool(j,"primforest") = pc59_som_pool(j,"primforest") - + (pc59_land_before(j,"primforest") - pcm_land(j,"primforest")) * + pc59_carbon_density(j,"primforest"); -p59_carbon_density(t,j,land)$(pcm_land(j,land) > 1e-10) = p59_som_pool(j,land) / pcm_land(j,land); +p59_carbon_density(t,j,land)$(pcm_land(j,land) > 1e-10) = pc59_som_pool(j,land) / pcm_land(j,land); From 442a7ab7503a18c6fc64c51932013d46473749e6 Mon Sep 17 00:00:00 2001 From: florianh Date: Sun, 2 Jun 2024 10:28:18 +0200 Subject: [PATCH 111/133] bugfix disaggregation --- config/default.cfg | 2 +- scripts/output/extra/disaggregation.R | 73 +++++++++++++++------------ 2 files changed, 41 insertions(+), 34 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index 2312deade7..565c1d7d69 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -2068,7 +2068,7 @@ cfg$files2export$start <- c("input/info.txt", "modules/14_yields/input/lpj_yields_0.5.mz", "modules/22_land_conservation/input/wdpa_baseline_0.5.mz", "modules/22_land_conservation/input/consv_prio_areas_0.5.mz", - "modules/30_crop/endo_apr21/input/avl_cropland_0.5.mz", + "modules/29_cropland/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", diff --git a/scripts/output/extra/disaggregation.R b/scripts/output/extra/disaggregation.R index ef98b04fca..1ead0e46b7 100644 --- a/scripts/output/extra/disaggregation.R +++ b/scripts/output/extra/disaggregation.R @@ -21,7 +21,7 @@ library(gms) # Basic configuration # ============================================= if (!exists("source_include")) { - outputdir <- "output/LAMA65_Sustainability/" + outputdir <- "output/default_2024-06-01_15.40.24/" readArgs("outputdir") } map_file <- Sys.glob(file.path(outputdir, "clustermap_*.rds")) @@ -75,12 +75,11 @@ if (length(map_file) > 1) { level = "cell", products = "kcr", product_aggr = FALSE, water_aggr = FALSE ) - fallow <- fallow(gdx, level = "cell") - area_shr <- area / (dimSums(area, dim = 3) + setNames(fallow, NULL) + 10^-10) + area_shr <- area / (dimSums(area, dim = 3) + 10^-10) # calculate share of crop land on total cell area crop_shr <- land_hr / dimSums(land_hr, dim = 3) - crop_shr <- setNames(crop_shr[, getYears(area_shr), "crop"], NULL) + crop_shr <- setNames(crop_shr[, getYears(area_shr), "crop_area"], NULL) # calculate crop area as share of total cell area area_shr_hr <- madrat::toolAggregate(area_shr, map_file, to = "cell") * crop_shr @@ -291,24 +290,15 @@ if (file.exists(wdpa_hr_file)) { # Account for country-specific SNV shares in post-processing # ------------------------------------------------------------- iso <- readGDX(gdx, "iso") -snv_pol_iso <- readGDX(gdx, "policy_countries30") -snv_pol_select <- readGDX(gdx, "s30_snv_shr", "s30_set_aside_shr") -snv_pol_noselect <- readGDX(gdx, "s30_snv_shr_noselect", "s30_set_aside_shr_noselect") +snv_pol_iso <- readGDX(gdx, "policy_countries29") +snv_pol_select <- readGDX(gdx, "s29_snv_shr") +snv_pol_noselect <- readGDX(gdx, "s29_snv_shr_noselect") snv_pol_shr <- new.magpie(iso, fill = snv_pol_noselect) snv_pol_shr[snv_pol_iso, , ] <- snv_pol_select avl_cropland_hr <- file.path(outputdir, "avl_cropland_0.5.mz") # available cropland (at high resolution) -marginal_land <- cfg$gms$c30_marginal_land # marginal land scenario -target_year <- cfg$gms$c30_snv_target # target year of SNV policy (default: "none") -if (is.null(target_year)) { - target_year <- cfg$gms$c30_set_aside_target -} -snv_pol_fader <- readGDX(gdx, "f30_scenario_fader", "f30_set_aside_fader", - format = "first_found", react = "silent" -)[, , target_year] -if (is.null(snv_pol_fader)) { - snv_pol_fader <- readGDX(gdx, "p30_snv_scenario_fader", format = "first_found") -} +marginal_land <- cfg$gms$c29_marginal_land # marginal land scenario +snv_pol_fader <- readGDX(gdx, "i29_snv_scenario_fader") # ============================================ # Start disaggregation @@ -345,30 +335,49 @@ land_hr <- .fixCoords(land_hr) ) gc() +# --------------------------------- +# Split land pools +# --------------------------------- +t <- readGDX(gdx,"t") +land_split_hr <- land_hr[ ,t , ] + +# split "crop" into crop_area, crop_fallow and crop_treecover +message("Disaggregating cropland") +carea <- land(gdx, level = "cell", subcategories = c("crop"))[,,c("crop_area","crop_fallow","crop_treecover")] +carea_shr <- carea / (dimSums(carea, dim = 3) + 10^-10) +# calculate crop area as share of total cell area +carea_hr <- madrat::toolAggregate(carea_shr, map_file, to = "cell") * setNames(land_split_hr[, , "crop"], NULL) +# check +if (abs(sum(dimSums(carea_hr, dim = 3) - setNames(land_split_hr[, , "crop"], NULL), na.rm = T)) > 0.1) warning("large Difference in crop disaggregation detected!") + +# drop crop +land_split_hr <- land_split_hr[, , "crop", invert = TRUE] +# combine land_split_hr with carea_hr +land_split_hr <- mbind(carea_hr, land_split_hr) + +rm(carea, carea_shr, carea_hr) +gc() + # --------------------------------- # Disaggregate MAgPIE crop types # --------------------------------- message("Disaggregating MAgPIE crop types") -area_shr_hr <- .dissagcrop(gdx, land_hr, map = map_file) +area_shr_hr <- .dissagcrop(gdx, land_split_hr, map = map_file) # Write output .writeDisagg(area_shr_hr, croparea_hr_share_out_file, comment = "unit: croparea fractions of total grid-cell", - message = "Write outputs cell.cropara_share" + message = "Write outputs cell.croparea_share" ) gc() -# --------------------------------- -# Split land pools -# --------------------------------- -land_split_hr <- land_hr[, getYears(area_shr_hr), ] area_hr <- area_shr_hr * dimSums(land_split_hr, dim = 3) rm(area_shr_hr) gc() -# replace crop in land_hr in with crop_kfo_rf, crop_kfo_ir, crop_kbe_rf +# replace crop_area in land_hr in with crop_kfo_rf, crop_kfo_ir, crop_kbe_rf # and crop_kbe_ir kbe <- c("betr", "begr") kfo <- setdiff(getNames(area_hr, dim = 1), kbe) @@ -389,14 +398,12 @@ crop_kbe_ir <- setNames( "crop_kbe_ir" ) crop_hr <- mbind(crop_kfo_rf, crop_kfo_ir, crop_kbe_rf, crop_kbe_ir) -# calculate Fallow -fallow <- setNames(land_split_hr[, , "crop"] - dimSums(area_hr, dim = 3), "fallow") -# drop crop -land_split_hr <- land_split_hr[, , "crop", invert = TRUE] +# drop crop_area +land_split_hr <- land_split_hr[, , "crop_area", invert = TRUE] # combine land_split_hr with crop_hr. -land_split_hr <- mbind(crop_hr, fallow, land_split_hr) +land_split_hr <- mbind(crop_hr, land_split_hr) -rm(crop_kfo_rf, crop_kfo_ir, crop_kbe_rf, crop_kbe_ir, crop_hr, fallow, area_hr) +rm(crop_kfo_rf, crop_kfo_ir, crop_kbe_rf, crop_kbe_ir, crop_hr, area_hr) # split "forestry" into timber plantations, pre-scribed afforestation (NPi/NDC) and endogenous afforestation (CO2 price driven) message("Disaggregating forestry") @@ -405,7 +412,7 @@ farea_shr <- farea / (dimSums(farea, dim = 3) + 10^-10) # calculate forestry area as share of total cell area farea_hr <- madrat::toolAggregate(farea_shr, map_file, to = "cell") * setNames(land_split_hr[, , "forestry"], NULL) # check -if (abs(sum(dimSums(farea_hr, dim = 3) - setNames(land_split_hr[, , "forestry"], NULL), na.rm = T)) > 0.1) warning("large Difference in crop disaggregation detected!") +if (abs(sum(dimSums(farea_hr, dim = 3) - setNames(land_split_hr[, , "forestry"], NULL), na.rm = T)) > 0.1) warning("large Difference in forestry disaggregation detected!") # rename df <- data.frame(matrix(nrow = 3, ncol = 2)) names(df) <- c("internal", "output") @@ -506,7 +513,7 @@ rm(land_consv_hr, urban_land_hr) land_bii_hr <- .fixCoords(land_bii_hr) -# Add primary and secondaray other land +# Add primary and secondary other land land_bii_hr <- PrimSecdOtherLand(land_bii_hr, land_hr_file) # specify potential natural vegetation From 07b187baf496e776c5bdc20de506ffdec98756e9 Mon Sep 17 00:00:00 2001 From: florianh Date: Tue, 11 Jun 2024 15:40:14 +0200 Subject: [PATCH 112/133] fix --- CHANGELOG.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 102c1f6ba6..6901ec309b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -84,12 +84,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **extra/disaggregation** fixed bug in disaggregation of land conservation related to switch from 59k to 67k that produced erroneous outputs - **scenario_config.csv** same revision for input files as in default.cfg - **scenario_fsec.csv** scenario settings -<<<<<<< HEAD -- **start/projects/fsec.R** scenario settings - **80_optimization** bugfix in nlp_par. Double solve statement was not working - **58_peatland** Added balance variable to avoid random infeasibilites -======= ->>>>>>> dc38aad92521933a64ae0860240a1c5859589590 - **scripts/start/test_runs.R** include all default output script, in particular disaggregation.R, which is needed for BII - **start/projects/fsec.R** scenario settings From 6496d8fd86f6a36d7d5f5719ec1c29b3c38f987e Mon Sep 17 00:00:00 2001 From: florianh Date: Tue, 11 Jun 2024 15:41:28 +0200 Subject: [PATCH 113/133] fix changelog --- CHANGELOG.md | 58 +++++++++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6901ec309b..37a0a1d040 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,65 +29,63 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [4.8.0] - 2024-06-10 ### changed -- **14_yields** revised timber yield calculations -- **15_food, default.cfg and scenario_config.csv** changed fader setup and introduced new switches for specifying food substitution scenarios and exogeneous food intake scenarios +- **41_area_equipped_for_irrigation** updated (non-default) AEI data (from Mehta2022 to Mehta2024) - **22_land_conservation and default.cfg** Added options for baseline protection -- **32_forestry** renamed interface `pm_demand_ext` to `pm_demand_forestry` +- **15_food, default.cfg and scenario_config.csv** changed fader setup and introduced new switches for specifying food substitution scenarios and exogeneous food intake scenarios +- **70_livestock** default.cfg and scenario_config.csv** changed fader setup and introduced new switches for specifying feed substitution with SCP scenarios +- **default.cfg** update additional data to rev4.50 +- **default.cfg** changed default realization for 44_biodiversity to new realization `bii_target_apr24` +- **80_optimization** Simplifed cycling through CONOPT4, CONOPT4 with OPTFILE, CONOPT4 without preprocessing and CONOPT3. +- **scripts** start/test_runs.R added 2 more test runs from FSEC - **32_forestry** revision and simplification of forestry implementation, renamed realization from `dynamic_feb21` to `dynamic_may24`. +- **32_forestry** renamed interface `pm_demand_ext` to `pm_demand_forestry` +- **default.cfg** Forestry sector included by default by using the `ForestryEndo` settings from `scenario_config.csv`: `s32_initial_distribution = 1`, `s32_demand_establishment = 1`, `s32_hvarea = 2`, `s35_secdf_distribution = 2`, `s35_hvarea = 2`, `s73_timber_demand_switch = 1` +- **14_yields** revised timber yield calculations - **35_natveg** `vm_land(j2,"forestry")` included in NPI/NDC constraint `q35_min_forest` - **35_natveg** replaced the realisation `dynamic_feb21` with realisation `pot_forest_may24`. The new realisation provides additional information on the potential forest area, which is now used to constrain forest and forestry expansion and recovery. The remaining area for forest establishment is provided to the forestry module via the new interface parameter `pcm_max_forest_est`. -- **41_area_equipped_for_irrigation** updated (non-default) AEI data (from Mehta2022 to Mehta2024) - **52_carbon** Separate carbon densities for forest and other land. Before there was only a single carbon density for natural vegetation land. -- **70_livestock** default.cfg and scenario_config.csv** changed fader setup and introduced new switches for specifying feed substitution with SCP scenarios -- **80_optimization** Simplifed cycling through CONOPT4, CONOPT4 with OPTFILE, CONOPT4 without preprocessing and CONOPT3. -- **default.cfg** changed default realization for 44_biodiversity to new realization `bii_target_apr24` - **default.cfg** defaults for `cfg$gms$sm_fix_SSP2`, `cfg$gms$sm_fix_cc` and other switches changed from 2020 to 2025 -- **default.cfg** Forestry sector included by default by using the `ForestryEndo` settings from `scenario_config.csv`: `s32_initial_distribution = 1`, `s32_demand_establishment = 1`, `s32_hvarea = 2`, `s35_secdf_distribution = 2`, `s35_hvarea = 2`, `s73_timber_demand_switch = 1` -- **default.cfg** update additional data to rev4.50 - **scripts** modified agmip_merge_report to use piamInterfaces -- **scripts** start/test_runs.R added 2 more test runs from FSEC ### added +- **default.cfg** added cropland growth constraint `cfg$gms$s30_annual_max_growth` +- **default.cfg** added technical cost for missing BII increase `cfg$gms$s44_cost_bii_missing` +- **default.cfg** added settings for new price-driven bioenergy realization `1st2ndgen_priced_feb24`: `cfg$gms$s60_2ndgen_bioenergy_dem_min_post_fix`, `cfg$gms$c60_bioenergy_subsidy_fix_SSP2`, `s60_bioenergy_gj_price_1st`, +`s60_bioenergy_price_2nd`, `c60_price_implementation` +- **core** added `coup2110`timesteps - **15_food** added additional sigmoid food substition scenarios `sigmoid_75pc_25_50`, `sigmoid_50pc_25_50` and `sigmoid_25pc_25_50` -- **21_trade** Minimum trade margin for forestry products `s21_min_trade_margin_forestry` - **30_crop** added regional cropland equation `q30_crop_reg` and presolve growth constraint - **44_biodiversity** added new realization `bii_target_apr24`, taking into account `f44_rr_layer` - **60_bioenergy** added new realization `1st2ndgen_priced_feb24` to enable price-driven 2nd gen bioenergy production -- **73_timber** added interface `im_timber_prod_cost` -- **citation** added abstract -- **core** added `coup2110`timesteps -- **default.cfg** added cropland growth constraint `cfg$gms$s30_annual_max_growth` -- **default.cfg** added settings for new price-driven bioenergy realization `1st2ndgen_priced_feb24`: `cfg$gms$s60_2ndgen_bioenergy_dem_min_post_fix`, `cfg$gms$c60_bioenergy_subsidy_fix_SSP2`, `s60_bioenergy_gj_price_1st`, -- **default.cfg** added technical cost for missing BII increase `cfg$gms$s44_cost_bii_missing` -- **default.cfg** cfg$gms$s80_secondsolve option for second solve statement with 0=off as default -- **scenario_config.csv** added preset for GENIE project -- **scripts** added "checkSummation" output script for consistency checking a report.mif - **scripts** added automatic set writer for new bioenergy realization to `start_functions` - **scripts** added start scripts for the GENIE project -`s60_bioenergy_price_2nd`, `c60_price_implementation` +- **scenario_config.csv** added preset for GENIE project +- **default.cfg** cfg$gms$s80_secondsolve option for second solve statement with 0=off as default +- **21_trade** Minimum trade margin for forestry products `s21_min_trade_margin_forestry` +- **73_timber** added interface `im_timber_prod_cost` +- **scripts** added "checkSummation" output script for consistency checking a report.mif +- **citation** added abstract ### removed +- **scripts/output/extra** removed scripts disaggregation_cropsplit and disaggregation_transitions +- **scripts** removed support for spam files in start_functions - **14_yields** removed interface `pm_timber_yield_initial` - **21_trade** removed interface `pm_selfsuff_ext`, removed `v21_manna_from_heaven` - **32_forestry** removed interface `pm_representative_rotation` -- **35_natveg** removed growing stock calculation and calibration, which is no longer needed. -- **62_material/16_demand** Removed double structure for forestry products. `pm_demand_foresty` is now used in `62_material` - **73_timber** removed interfaces `pm_demand_forestry_future` and `sm_wood_density` -- **scripts** removed support for spam files in start_functions -- **scripts/output/extra** removed scripts disaggregation_cropsplit and disaggregation_transitions +- **62_material/16_demand** Removed double structure for forestry products. `pm_demand_foresty` is now used in `62_material` +- **35_natveg** removed growing stock calculation and calibration, which is no longer needed. ### fixed - **14_yields** fix division by zero in preloop of managementcalib_aug19 -- **44_biodiversity** avoid division by zero -- **58_peatland** Added balance variable to avoid random infeasibilites -- **80_optimization** fixed a bug in nlp_apr17; cycling through CONOPT4, CONOPT4 without preprocessing and CONOPT3 was not working - **extra/disaggregation** fixed bug in disaggregation of land conservation related to switch from 59k to 67k that produced erroneous outputs +- **44_biodiversity** avoid division by zero - **scenario_config.csv** same revision for input files as in default.cfg - **scenario_fsec.csv** scenario settings -- **80_optimization** bugfix in nlp_par. Double solve statement was not working +- **start/projects/fsec.R** scenario settings +- **80_optimization** fixed a bug in nlp_apr17; cycling through CONOPT4, CONOPT4 without preprocessing and CONOPT3 was not working - **58_peatland** Added balance variable to avoid random infeasibilites - **scripts/start/test_runs.R** include all default output script, in particular disaggregation.R, which is needed for BII -- **start/projects/fsec.R** scenario settings ## [4.7.3] - 2024-04-12 From b42d80959f9cf5ebf3a9d679439f06d6e5d13b45 Mon Sep 17 00:00:00 2001 From: florianh Date: Tue, 11 Jun 2024 15:42:52 +0200 Subject: [PATCH 114/133] fix changelog --- CHANGELOG.md | 58 ++++++++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 37a0a1d040..99fe45d58d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,63 +29,63 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [4.8.0] - 2024-06-10 ### changed -- **41_area_equipped_for_irrigation** updated (non-default) AEI data (from Mehta2022 to Mehta2024) -- **22_land_conservation and default.cfg** Added options for baseline protection +- **14_yields** revised timber yield calculations - **15_food, default.cfg and scenario_config.csv** changed fader setup and introduced new switches for specifying food substitution scenarios and exogeneous food intake scenarios -- **70_livestock** default.cfg and scenario_config.csv** changed fader setup and introduced new switches for specifying feed substitution with SCP scenarios -- **default.cfg** update additional data to rev4.50 -- **default.cfg** changed default realization for 44_biodiversity to new realization `bii_target_apr24` -- **80_optimization** Simplifed cycling through CONOPT4, CONOPT4 with OPTFILE, CONOPT4 without preprocessing and CONOPT3. -- **scripts** start/test_runs.R added 2 more test runs from FSEC -- **32_forestry** revision and simplification of forestry implementation, renamed realization from `dynamic_feb21` to `dynamic_may24`. +- **22_land_conservation and default.cfg** Added options for baseline protection - **32_forestry** renamed interface `pm_demand_ext` to `pm_demand_forestry` -- **default.cfg** Forestry sector included by default by using the `ForestryEndo` settings from `scenario_config.csv`: `s32_initial_distribution = 1`, `s32_demand_establishment = 1`, `s32_hvarea = 2`, `s35_secdf_distribution = 2`, `s35_hvarea = 2`, `s73_timber_demand_switch = 1` -- **14_yields** revised timber yield calculations +- **32_forestry** revision and simplification of forestry implementation, renamed realization from `dynamic_feb21` to `dynamic_may24`. - **35_natveg** `vm_land(j2,"forestry")` included in NPI/NDC constraint `q35_min_forest` - **35_natveg** replaced the realisation `dynamic_feb21` with realisation `pot_forest_may24`. The new realisation provides additional information on the potential forest area, which is now used to constrain forest and forestry expansion and recovery. The remaining area for forest establishment is provided to the forestry module via the new interface parameter `pcm_max_forest_est`. +- **41_area_equipped_for_irrigation** updated (non-default) AEI data (from Mehta2022 to Mehta2024) - **52_carbon** Separate carbon densities for forest and other land. Before there was only a single carbon density for natural vegetation land. +- **70_livestock** default.cfg and scenario_config.csv** changed fader setup and introduced new switches for specifying feed substitution with SCP scenarios +- **80_optimization** Simplifed cycling through CONOPT4, CONOPT4 with OPTFILE, CONOPT4 without preprocessing and CONOPT3. +- **default.cfg** changed default realization for 44_biodiversity to new realization `bii_target_apr24` - **default.cfg** defaults for `cfg$gms$sm_fix_SSP2`, `cfg$gms$sm_fix_cc` and other switches changed from 2020 to 2025 +- **default.cfg** Forestry sector included by default by using the `ForestryEndo` settings from `scenario_config.csv`: `s32_initial_distribution = 1`, `s32_demand_establishment = 1`, `s32_hvarea = 2`, `s35_secdf_distribution = 2`, `s35_hvarea = 2`, `s73_timber_demand_switch = 1` +- **default.cfg** update additional data to rev4.50 - **scripts** modified agmip_merge_report to use piamInterfaces +- **scripts** start/test_runs.R added 2 more test runs from FSEC ### added -- **default.cfg** added cropland growth constraint `cfg$gms$s30_annual_max_growth` -- **default.cfg** added technical cost for missing BII increase `cfg$gms$s44_cost_bii_missing` -- **default.cfg** added settings for new price-driven bioenergy realization `1st2ndgen_priced_feb24`: `cfg$gms$s60_2ndgen_bioenergy_dem_min_post_fix`, `cfg$gms$c60_bioenergy_subsidy_fix_SSP2`, `s60_bioenergy_gj_price_1st`, -`s60_bioenergy_price_2nd`, `c60_price_implementation` -- **core** added `coup2110`timesteps - **15_food** added additional sigmoid food substition scenarios `sigmoid_75pc_25_50`, `sigmoid_50pc_25_50` and `sigmoid_25pc_25_50` +- **21_trade** Minimum trade margin for forestry products `s21_min_trade_margin_forestry` - **30_crop** added regional cropland equation `q30_crop_reg` and presolve growth constraint - **44_biodiversity** added new realization `bii_target_apr24`, taking into account `f44_rr_layer` - **60_bioenergy** added new realization `1st2ndgen_priced_feb24` to enable price-driven 2nd gen bioenergy production -- **scripts** added automatic set writer for new bioenergy realization to `start_functions` -- **scripts** added start scripts for the GENIE project -- **scenario_config.csv** added preset for GENIE project -- **default.cfg** cfg$gms$s80_secondsolve option for second solve statement with 0=off as default -- **21_trade** Minimum trade margin for forestry products `s21_min_trade_margin_forestry` - **73_timber** added interface `im_timber_prod_cost` -- **scripts** added "checkSummation" output script for consistency checking a report.mif - **citation** added abstract +- **core** added `coup2110`timesteps +- **default.cfg** added cropland growth constraint `cfg$gms$s30_annual_max_growth` +- **default.cfg** added settings for new price-driven bioenergy realization `1st2ndgen_priced_feb24`: `cfg$gms$s60_2ndgen_bioenergy_dem_min_post_fix`, `cfg$gms$c60_bioenergy_subsidy_fix_SSP2`, `s60_bioenergy_gj_price_1st`, +- **default.cfg** added technical cost for missing BII increase `cfg$gms$s44_cost_bii_missing` +- **default.cfg** cfg$gms$s80_secondsolve option for second solve statement with 0=off as default +- **scenario_config.csv** added preset for GENIE project +- **scripts** added "checkSummation" output script for consistency checking a report.mif +- **scripts** added automatic set writer for new bioenergy realization to `start_functions` +- **scripts** added start scripts for the GENIE project +`s60_bioenergy_price_2nd`, `c60_price_implementation` ### removed -- **scripts/output/extra** removed scripts disaggregation_cropsplit and disaggregation_transitions -- **scripts** removed support for spam files in start_functions - **14_yields** removed interface `pm_timber_yield_initial` - **21_trade** removed interface `pm_selfsuff_ext`, removed `v21_manna_from_heaven` - **32_forestry** removed interface `pm_representative_rotation` -- **73_timber** removed interfaces `pm_demand_forestry_future` and `sm_wood_density` -- **62_material/16_demand** Removed double structure for forestry products. `pm_demand_foresty` is now used in `62_material` - **35_natveg** removed growing stock calculation and calibration, which is no longer needed. +- **62_material/16_demand** Removed double structure for forestry products. `pm_demand_foresty` is now used in `62_material` +- **73_timber** removed interfaces `pm_demand_forestry_future` and `sm_wood_density` +- **scripts** removed support for spam files in start_functions +- **scripts/output/extra** removed scripts disaggregation_cropsplit and disaggregation_transitions ### fixed - **14_yields** fix division by zero in preloop of managementcalib_aug19 -- **extra/disaggregation** fixed bug in disaggregation of land conservation related to switch from 59k to 67k that produced erroneous outputs - **44_biodiversity** avoid division by zero +- **58_peatland** Added balance variable to avoid random infeasibilites +- **80_optimization** fixed a bug in nlp_apr17; cycling through CONOPT4, CONOPT4 without preprocessing and CONOPT3 was not working +- **extra/disaggregation** fixed bug in disaggregation of land conservation related to switch from 59k to 67k that produced erroneous outputs - **scenario_config.csv** same revision for input files as in default.cfg - **scenario_fsec.csv** scenario settings -- **start/projects/fsec.R** scenario settings -- **80_optimization** fixed a bug in nlp_apr17; cycling through CONOPT4, CONOPT4 without preprocessing and CONOPT3 was not working -- **58_peatland** Added balance variable to avoid random infeasibilites - **scripts/start/test_runs.R** include all default output script, in particular disaggregation.R, which is needed for BII +- **start/projects/fsec.R** scenario settings ## [4.7.3] - 2024-04-12 From 58d5ef86c79147a4e11b965b9ce33e734423a7fb Mon Sep 17 00:00:00 2001 From: florianh Date: Wed, 12 Jun 2024 16:35:45 +0200 Subject: [PATCH 115/133] test --- modules/32_forestry/dynamic_may24/declarations.gms | 2 -- modules/32_forestry/dynamic_may24/equations.gms | 4 ++-- modules/32_forestry/dynamic_may24/postsolve.gms | 4 ---- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/modules/32_forestry/dynamic_may24/declarations.gms b/modules/32_forestry/dynamic_may24/declarations.gms index c04fc094d7..5a806f3fa4 100644 --- a/modules/32_forestry/dynamic_may24/declarations.gms +++ b/modules/32_forestry/dynamic_may24/declarations.gms @@ -62,7 +62,6 @@ positive variables v32_cost_hvarea(i) Cost of harvesting timber from forests (mio. USD per yr) v32_land(j,type32,ac) Forestry land pools (mio. ha) v32_land_missing(j) Technical area balance term for timber plantation establishment (mio. ha) - v32_land_missing_ndc(j) Technical area balance term for NPI NDC reforestation (mio. ha) vm_landdiff_forestry Aggregated difference in forestry land compared to previous timestep (mio. ha) v32_cost_recur(i) Recurring forest management costs (USD per ha) v32_land_expansion(j,type32) Forestry land expansion (mio. ha) @@ -118,7 +117,6 @@ parameters ov32_cost_hvarea(t,i,type) Cost of harvesting timber from forests (mio. USD per yr) ov32_land(t,j,type32,ac,type) Forestry land pools (mio. ha) ov32_land_missing(t,j,type) Technical area balance term for timber plantation establishment (mio. ha) - ov32_land_missing_ndc(t,j,type) Technical area balance term for NPI NDC reforestation (mio. ha) ov_landdiff_forestry(t,type) Aggregated difference in forestry land compared to previous timestep (mio. ha) ov32_cost_recur(t,i,type) Recurring forest management costs (USD per ha) ov32_land_expansion(t,j,type32,type) Forestry land expansion (mio. ha) diff --git a/modules/32_forestry/dynamic_may24/equations.gms b/modules/32_forestry/dynamic_may24/equations.gms index d583c2040c..1cfdcf2597 100644 --- a/modules/32_forestry/dynamic_may24/equations.gms +++ b/modules/32_forestry/dynamic_may24/equations.gms @@ -24,7 +24,7 @@ q32_cost_total(i2) .. vm_cost_fore(i2) =e= v32_cost_recur(i2) + v32_cost_establishment(i2) + v32_cost_hvarea(i2) - + sum(cell(i2,j2), v32_land_missing(j2) + v32_land_missing_ndc(j2)) * s32_free_land_cost + + sum(cell(i2,j2), v32_land_missing(j2)) * s32_free_land_cost ; *----------------------------------------------- @@ -68,7 +68,7 @@ sum(ac_est, v32_land(j2,"aff",ac_est)) =l= sum(ac, v32_land(j2,"aff",ac)) - sum( *' The constraint `q32_aff_pol` accounts for the exogenous afforestation prescribed by NPI/NDC policies. q32_aff_pol(j2) .. - sum(ac_est, v32_land(j2,"ndc",ac_est)) + v32_land_missing_ndc(j2) =e= sum(ct, p32_aff_pol_timestep(ct,j2)); + sum(ac_est, v32_land(j2,"ndc",ac_est)) =e= sum(ct, p32_aff_pol_timestep(ct,j2)); *' The constraint `q32_max_aff` accounts for the allowed maximum global endogenous *' afforestation defined in `i32_max_aff_area_glo`. diff --git a/modules/32_forestry/dynamic_may24/postsolve.gms b/modules/32_forestry/dynamic_may24/postsolve.gms index d8aa765167..be0c978644 100644 --- a/modules/32_forestry/dynamic_may24/postsolve.gms +++ b/modules/32_forestry/dynamic_may24/postsolve.gms @@ -14,7 +14,6 @@ pc32_land(j,type32,ac) = v32_land.l(j,type32,ac); ov32_cost_hvarea(t,i,"marginal") = v32_cost_hvarea.m(i); ov32_land(t,j,type32,ac,"marginal") = v32_land.m(j,type32,ac); ov32_land_missing(t,j,"marginal") = v32_land_missing.m(j); - ov32_land_missing_ndc(t,j,"marginal") = v32_land_missing_ndc.m(j); ov_landdiff_forestry(t,"marginal") = vm_landdiff_forestry.m; ov32_cost_recur(t,i,"marginal") = v32_cost_recur.m(i); ov32_land_expansion(t,j,type32,"marginal") = v32_land_expansion.m(j,type32); @@ -59,7 +58,6 @@ pc32_land(j,type32,ac) = v32_land.l(j,type32,ac); ov32_cost_hvarea(t,i,"level") = v32_cost_hvarea.l(i); ov32_land(t,j,type32,ac,"level") = v32_land.l(j,type32,ac); ov32_land_missing(t,j,"level") = v32_land_missing.l(j); - ov32_land_missing_ndc(t,j,"level") = v32_land_missing_ndc.l(j); ov_landdiff_forestry(t,"level") = vm_landdiff_forestry.l; ov32_cost_recur(t,i,"level") = v32_cost_recur.l(i); ov32_land_expansion(t,j,type32,"level") = v32_land_expansion.l(j,type32); @@ -104,7 +102,6 @@ pc32_land(j,type32,ac) = v32_land.l(j,type32,ac); ov32_cost_hvarea(t,i,"upper") = v32_cost_hvarea.up(i); ov32_land(t,j,type32,ac,"upper") = v32_land.up(j,type32,ac); ov32_land_missing(t,j,"upper") = v32_land_missing.up(j); - ov32_land_missing_ndc(t,j,"upper") = v32_land_missing_ndc.up(j); ov_landdiff_forestry(t,"upper") = vm_landdiff_forestry.up; ov32_cost_recur(t,i,"upper") = v32_cost_recur.up(i); ov32_land_expansion(t,j,type32,"upper") = v32_land_expansion.up(j,type32); @@ -149,7 +146,6 @@ pc32_land(j,type32,ac) = v32_land.l(j,type32,ac); ov32_cost_hvarea(t,i,"lower") = v32_cost_hvarea.lo(i); ov32_land(t,j,type32,ac,"lower") = v32_land.lo(j,type32,ac); ov32_land_missing(t,j,"lower") = v32_land_missing.lo(j); - ov32_land_missing_ndc(t,j,"lower") = v32_land_missing_ndc.lo(j); ov_landdiff_forestry(t,"lower") = vm_landdiff_forestry.lo; ov32_cost_recur(t,i,"lower") = v32_cost_recur.lo(i); ov32_land_expansion(t,j,type32,"lower") = v32_land_expansion.lo(j,type32); From 00d08cf1a0f2701293df75dce187bb1eaba26cb2 Mon Sep 17 00:00:00 2001 From: Pascal Sauer <156898545+pascal-sauer@users.noreply.github.com> Date: Thu, 13 Jun 2024 10:37:12 +0200 Subject: [PATCH 116/133] Delete renv/settings.dcf --- renv/settings.dcf | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 renv/settings.dcf diff --git a/renv/settings.dcf b/renv/settings.dcf deleted file mode 100644 index 169d82f1bc..0000000000 --- a/renv/settings.dcf +++ /dev/null @@ -1,10 +0,0 @@ -bioconductor.version: -external.libraries: -ignored.packages: -package.dependency.fields: Imports, Depends, LinkingTo -r.version: -snapshot.type: implicit -use.cache: TRUE -vcs.ignore.cellar: TRUE -vcs.ignore.library: TRUE -vcs.ignore.local: TRUE From 6db3dcb7f94de8cf76005e9119d05cb3a0df4e7d Mon Sep 17 00:00:00 2001 From: florianh Date: Fri, 14 Jun 2024 08:48:34 +0200 Subject: [PATCH 117/133] accuracy in conditions changed to avoid very small numbers --- .../22_land_conservation/area_based_apr22/presolve.gms | 8 ++++---- modules/29_cropland/detail_apr24/presolve.gms | 2 +- modules/29_cropland/simple_apr24/presolve.gms | 2 +- modules/32_forestry/dynamic_may24/preloop.gms | 4 ++-- modules/32_forestry/dynamic_may24/presolve.gms | 6 +++--- modules/35_natveg/pot_forest_may24/postsolve.gms | 2 +- modules/35_natveg/pot_forest_may24/preloop.gms | 2 +- modules/35_natveg/pot_forest_may24/presolve.gms | 6 +++--- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/modules/22_land_conservation/area_based_apr22/presolve.gms b/modules/22_land_conservation/area_based_apr22/presolve.gms index 9debb3b725..e11d2d046e 100644 --- a/modules/22_land_conservation/area_based_apr22/presolve.gms +++ b/modules/22_land_conservation/area_based_apr22/presolve.gms @@ -70,7 +70,7 @@ pm_land_conservation(t,j,"past","restore")$(p22_conservation_area(t,j,"past") > pm_land_conservation(t,j,"secdforest","restore") = (p22_conservation_area(t,j,"primforest") + p22_conservation_area(t,j,"secdforest")) - (pcm_land(j,"primforest") + pcm_land(j,"secdforest")); -pm_land_conservation(t,j,"secdforest","restore")$(pm_land_conservation(t,j,"secdforest","restore") < 0) = 0; +pm_land_conservation(t,j,"secdforest","restore")$(pm_land_conservation(t,j,"secdforest","restore") < 1e-6) = 0; * Other land pm_land_conservation(t,j,"other","restore")$(p22_conservation_area(t,j,"other") > pcm_land(j,"other")) = p22_conservation_area(t,j,"other") - pcm_land(j,"other"); @@ -82,7 +82,7 @@ p22_secdforest_restore_pot(t,j) = sum(land, pcm_land(j, land)) - pcm_land(j, "urban") - sum(land_natveg, pcm_land(j, land_natveg)) - pm_land_conservation(t,j,"past","protect"); -p22_secdforest_restore_pot(t,j)$(p22_secdforest_restore_pot(t,j) < 0) = 0; +p22_secdforest_restore_pot(t,j)$(p22_secdforest_restore_pot(t,j) < 1e-6) = 0; pm_land_conservation(t,j,"secdforest","restore")$(pm_land_conservation(t,j,"secdforest","restore") > p22_secdforest_restore_pot(t,j)) = p22_secdforest_restore_pot(t,j); * Grassland restoration is limited by grassland restoration potential @@ -91,7 +91,7 @@ p22_past_restore_pot(t,j) = sum(land, pcm_land(j, land)) - sum(land_timber, pcm_land(j, land_timber)) - pm_land_conservation(t,j,"past","protect") - pm_land_conservation(t,j,"secdforest","restore"); -p22_past_restore_pot(t,j)$(p22_past_restore_pot(t,j) < 0) = 0; +p22_past_restore_pot(t,j)$(p22_past_restore_pot(t,j) < 1e-6) = 0; pm_land_conservation(t,j,"past","restore")$(pm_land_conservation(t,j,"past","restore") > p22_past_restore_pot(t,j)) = p22_past_restore_pot(t,j); * Other land restoration is limited by other land restoration potential @@ -100,7 +100,7 @@ p22_other_restore_pot(t,j) = sum(land, pcm_land(j, land)) - sum(land_timber, pcm_land(j, land_timber)) - sum(consv_type, pm_land_conservation(t,j,"past",consv_type)) - pm_land_conservation(t,j,"secdforest","restore"); -p22_other_restore_pot(t,j)$(p22_other_restore_pot(t,j) < 0) = 0; +p22_other_restore_pot(t,j)$(p22_other_restore_pot(t,j) < 1e-6) = 0; pm_land_conservation(t,j,"other","restore")$(pm_land_conservation(t,j,"other","restore") > p22_other_restore_pot(t,j)) = p22_other_restore_pot(t,j); else diff --git a/modules/29_cropland/detail_apr24/presolve.gms b/modules/29_cropland/detail_apr24/presolve.gms index dba380188e..b01a5b3690 100644 --- a/modules/29_cropland/detail_apr24/presolve.gms +++ b/modules/29_cropland/detail_apr24/presolve.gms @@ -28,7 +28,7 @@ p29_snv_relocation(t,j) = (i29_snv_scenario_fader(t) - i29_snv_scenario_fader(t- *' cases of cropland reduction p29_max_snv_relocation(t,j) = p29_snv_shr(t,j) * (i29_snv_scenario_fader(t) - i29_snv_scenario_fader(t-1)) * pcm_land(j,"crop") - sum(ac, pc29_treecover(j,ac)); -p29_max_snv_relocation(t,j)$(p29_max_snv_relocation(t,j) < 0) = 0; +p29_max_snv_relocation(t,j)$(p29_max_snv_relocation(t,j) < 1e-6) = 0; p29_snv_relocation(t,j)$(p29_snv_relocation(t, j) > p29_max_snv_relocation(t,j)) = p29_max_snv_relocation(t,j); *' Area potentially available for cropping diff --git a/modules/29_cropland/simple_apr24/presolve.gms b/modules/29_cropland/simple_apr24/presolve.gms index cebdb11b33..a49c401f8b 100644 --- a/modules/29_cropland/simple_apr24/presolve.gms +++ b/modules/29_cropland/simple_apr24/presolve.gms @@ -25,7 +25,7 @@ p29_snv_relocation(t,j) = (i29_snv_scenario_fader(t) - i29_snv_scenario_fader(t- *' cases of cropland reduction p29_max_snv_relocation(t,j) = p29_snv_shr(t,j) * (i29_snv_scenario_fader(t) - i29_snv_scenario_fader(t-1)) * pcm_land(j,"crop") - vm_treecover.l(j); -p29_max_snv_relocation(t,j)$(p29_max_snv_relocation(t,j) < 0) = 0; +p29_max_snv_relocation(t,j)$(p29_max_snv_relocation(t,j) < 1e-6) = 0; p29_snv_relocation(t,j)$(p29_snv_relocation(t, j) > p29_max_snv_relocation(t,j)) = p29_max_snv_relocation(t,j); *' Area potentially available for cropping diff --git a/modules/32_forestry/dynamic_may24/preloop.gms b/modules/32_forestry/dynamic_may24/preloop.gms index 3fec5a9101..bcf1b96ed1 100644 --- a/modules/32_forestry/dynamic_may24/preloop.gms +++ b/modules/32_forestry/dynamic_may24/preloop.gms @@ -185,12 +185,12 @@ p32_aff_togo(t,i) = smax(t2, sum(cell(i,j), p32_aff_pol(t2,j))) - sum(cell(i,j), * The global (`s32_max_aff_area`) and regional limit (`f32_max_aff_area`) for total afforestation (sum of endogenous and exogenous) is reduced by exogenous NPI/NDC afforestation (`p32_aff_pol`). if(s32_max_aff_area_glo = 1, i32_max_aff_area_glo(t) = s32_max_aff_area - smax(t2, sum(j, p32_aff_pol(t2,j))); - i32_max_aff_area_glo(t)$(i32_max_aff_area_glo(t) < 0) = 0; + i32_max_aff_area_glo(t)$(i32_max_aff_area_glo(t) < 1e-6) = 0; i32_max_aff_area_glo(t)$(m_year(t) <= sm_fix_SSP2) = Inf; i32_max_aff_area_reg(t,i) = 0; elseif s32_max_aff_area_glo = 0, i32_max_aff_area_reg(t,i) = f32_max_aff_area(i) - smax(t2, sum(cell(i,j), p32_aff_pol(t2,j))); - i32_max_aff_area_reg(t,i)$(i32_max_aff_area_reg(t,i) < 0) = 0; + i32_max_aff_area_reg(t,i)$(i32_max_aff_area_reg(t,i) < 1e-6) = 0; i32_max_aff_area_reg(t,i)$(m_year(t) <= sm_fix_SSP2) = Inf; i32_max_aff_area_glo(t) = 0; ); diff --git a/modules/32_forestry/dynamic_may24/presolve.gms b/modules/32_forestry/dynamic_may24/presolve.gms index cb8b22a51d..6ebf6d3240 100644 --- a/modules/32_forestry/dynamic_may24/presolve.gms +++ b/modules/32_forestry/dynamic_may24/presolve.gms @@ -14,14 +14,14 @@ v32_land_reduction.fx(j,type32,ac_est) = 0; p32_aff_pol_timestep("y1995",j) = 0; p32_aff_pol_timestep(t,j)$(ord(t)>1) = p32_aff_pol(t,j) - p32_aff_pol(t-1,j); * Suitable area (`p32_aff_pot`) for NPI/NDC afforestation - p32_aff_pot(t,j) = sum((kcr,w),vm_area.l(j,kcr,w) - vm_area.lo(j,kcr,w)) + p32_aff_pot(t,j) = 0.95 * (sum((kcr,w),vm_area.l(j,kcr,w) - vm_area.lo(j,kcr,w)) + (vm_fallow.l(j) - vm_fallow.lo(j)) + (vm_land.l(j,"past") - vm_land.lo(j,"past")) - - pm_land_conservation(t,j,"other","restore"); + - pm_land_conservation(t,j,"other","restore")); *** NDC/NPI re/afforesation is further constrained by the remaining forest establishment potential p32_aff_pot(t,j)$(p32_aff_pot(t,j) > pm_max_forest_est(t,j)) = pm_max_forest_est(t,j); * suitable area `p32_aff_pot` can be negative, if land restoration is switched on (level smaller than lower bound), therefore set negative values to 0 - p32_aff_pot(t,j)$(p32_aff_pot(t,j) < 0) = 0; + p32_aff_pot(t,j)$(p32_aff_pot(t,j) < 1e-6) = 0; * Limit prescribed NPI/NDC afforestation in `p32_aff_pol_timestep` if not enough suitable area (`p32_aff_pot`) for afforestation is available p32_aff_pol_timestep(t,j)$(p32_aff_pol_timestep(t,j) > p32_aff_pot(t,j)) = p32_aff_pot(t,j); ** END ndc ** diff --git a/modules/35_natveg/pot_forest_may24/postsolve.gms b/modules/35_natveg/pot_forest_may24/postsolve.gms index cad9959091..ec39f68557 100644 --- a/modules/35_natveg/pot_forest_may24/postsolve.gms +++ b/modules/35_natveg/pot_forest_may24/postsolve.gms @@ -13,7 +13,7 @@ pc35_land_other(j,othertype35,ac) = vm_land_other.l(j,othertype35,ac); * Set the forest establishment bound for the next time step pm_max_forest_est(t+1,j) = f35_pot_forest_area(t+1,j) - sum(land_forest, vm_land.l(j,land_forest)); -pm_max_forest_est(t+1,j)$(pm_max_forest_est(t+1,j) < 0) = 0; +pm_max_forest_est(t+1,j)$(pm_max_forest_est(t+1,j) < 1e-6) = 0; *#################### R SECTION START (OUTPUT DEFINITIONS) ##################### ov35_secdforest(t,j,ac,"marginal") = v35_secdforest.m(j,ac); diff --git a/modules/35_natveg/pot_forest_may24/preloop.gms b/modules/35_natveg/pot_forest_may24/preloop.gms index 3b61137ec0..7d04a1928d 100644 --- a/modules/35_natveg/pot_forest_may24/preloop.gms +++ b/modules/35_natveg/pot_forest_may24/preloop.gms @@ -48,7 +48,7 @@ p35_disturbance_loss_primf(t,j) = 0; * Hence, the area for forest establishments is given by the potential forest * area minus all forest areas in the previous time step. pm_max_forest_est(t,j) = f35_pot_forest_area(t,j) - sum(land_forest, pcm_land(j,land_forest)); -pm_max_forest_est(t,j)$(pm_max_forest_est(t,j) < 0) = 0; +pm_max_forest_est(t,j)$(pm_max_forest_est(t,j) < 1e-6) = 0; * ----------------------------------------- * Land conservation for climate mitigation diff --git a/modules/35_natveg/pot_forest_may24/presolve.gms b/modules/35_natveg/pot_forest_may24/presolve.gms index 50131a05d3..406ccbc762 100644 --- a/modules/35_natveg/pot_forest_may24/presolve.gms +++ b/modules/35_natveg/pot_forest_may24/presolve.gms @@ -59,7 +59,7 @@ pc35_forest_recovery_shr(j) = 0; pc35_forest_recovery_shr(j)$((sum(land_ag, pcm_land(j,land_ag))+pcm_land(j,"urban")) > 0) = (pc35_max_forest_recovery(j) - sum(ac_est, p35_forest_recovery_area(t,j,ac_est))) / (sum(land_ag, pcm_land(j,land_ag))+pcm_land(j,"urban")); -pc35_forest_recovery_shr(j)$(pc35_forest_recovery_shr(j) < 0) = 0; +pc35_forest_recovery_shr(j)$(pc35_forest_recovery_shr(j) < 1e-6) = 0; pc35_forest_recovery_shr(j)$(pc35_forest_recovery_shr(j) > 1) = 1; * Abandoned land pc35_land_other(j,"othernat",ac_est) that has not yet been allocated to * p35_forest_recovery_area(t,j,ac_est) is then distributed proportionally using the forest recovery share. @@ -68,7 +68,7 @@ p35_forest_recovery_area(t,j,ac_est) = p35_forest_recovery_area(t,j,ac_est) * pc35_forest_recovery_shr(j); p35_forest_recovery_area(t,j,ac_est)$(sum(ac_est2, p35_forest_recovery_area(t,j,ac_est2)) > pc35_max_forest_recovery(j)) = pc35_max_forest_recovery(j)/card(ac_est2); p35_forest_recovery_area(t,j,ac_est)$(p35_forest_recovery_area(t,j,ac_est) > pc35_land_other(j,"othernat",ac_est)) = pc35_land_other(j,"othernat",ac_est); -p35_forest_recovery_area(t,j,ac_est)$(p35_forest_recovery_area(t,j,ac_est) < 0) = 0; +p35_forest_recovery_area(t,j,ac_est)$(p35_forest_recovery_area(t,j,ac_est) < 1e-6) = 0; pc35_land_other(j,"othernat",ac_est) = pc35_land_other(j,"othernat",ac_est) - p35_forest_recovery_area(t,j,ac_est); pc35_land_other(j,"youngsecdf",ac_est) = pc35_land_other(j,"youngsecdf",ac_est) + p35_forest_recovery_area(t,j,ac_est); @@ -171,7 +171,7 @@ p35_land_restoration(j,"secdforest")$(sum(land_natveg, pcm_land(j,land_natveg)) * Since forest restoration cannot be bigger than the potential area for secdforest recovery, * any remaining restoration area is substracted and shifted to other land restoration. p35_restoration_shift(j) = p35_land_restoration(j,"secdforest") - pc35_max_forest_recovery(j); -p35_restoration_shift(j)$(p35_restoration_shift(j) < 0) = 0; +p35_restoration_shift(j)$(p35_restoration_shift(j) < 1e-6) = 0; p35_restoration_shift(j)$(p35_restoration_shift(j) > p35_land_restoration(j,"secdforest")) = p35_land_restoration(j,"secdforest"); p35_land_restoration(j,"secdforest") = p35_land_restoration(j,"secdforest") - p35_restoration_shift(j); pm_land_conservation(t,j,"other","restore") = pm_land_conservation(t,j,"other","restore") + p35_restoration_shift(j); From 1d64e11be8d6bbf5944edffcb1fd1eb053433e00 Mon Sep 17 00:00:00 2001 From: florianh Date: Fri, 14 Jun 2024 16:30:39 +0200 Subject: [PATCH 118/133] bugfix land restoration and country switches for agroforestry --- config/default.cfg | 27 +++++++++++---- .../area_based_apr22/presolve.gms | 14 +++++--- .../29_cropland/detail_apr24/declarations.gms | 4 +-- modules/29_cropland/detail_apr24/input.gms | 6 ++-- modules/29_cropland/detail_apr24/preloop.gms | 11 ++++--- modules/29_cropland/detail_apr24/presolve.gms | 12 ++++--- .../29_cropland/simple_apr24/declarations.gms | 4 +-- modules/29_cropland/simple_apr24/input.gms | 5 +-- modules/29_cropland/simple_apr24/preloop.gms | 10 +++--- modules/29_cropland/simple_apr24/presolve.gms | 8 ++--- .../30_croparea/detail_apr24/declarations.gms | 4 ++- .../30_croparea/detail_apr24/equations.gms | 2 +- modules/30_croparea/detail_apr24/input.gms | 32 ++++++++++++++++++ modules/30_croparea/detail_apr24/preloop.gms | 9 +++++ modules/30_croparea/detail_apr24/presolve.gms | 8 +++-- .../30_croparea/simple_apr24/declarations.gms | 4 ++- .../30_croparea/simple_apr24/equations.gms | 2 +- modules/30_croparea/simple_apr24/input.gms | 33 +++++++++++++++++++ modules/30_croparea/simple_apr24/preloop.gms | 8 +++++ modules/30_croparea/simple_apr24/presolve.gms | 8 +++-- 20 files changed, 165 insertions(+), 46 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index 9f0d72281c..fd45e39a2d 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -703,6 +703,12 @@ cfg$gms$cropland <- "simple_apr24" # def = simple_apr24 # * with observed cropland patterns and is recommended for productive runs. cfg$gms$c29_marginal_land <- "q33_marginal" # def = "q33_marginal" +# * Switch and specification of countries for selected policies in apply. +# * Options: list of iso-codes of countries where SNV policy should be applied +# * Note: must be written in the format: "IND, BRA, DEU" +# * Default: all iso countries +cfg$gms$policy_countries29 <- all_iso_countries + # * Share of available cropland that is withheld for maintaining semi-natural vegetation (SNV) # * in each square km in cropland areas, including grassland, forest and other land. For example, # * a share of 0.2 corresponds to 20 % of SNV in terms of the available cropland. @@ -718,12 +724,6 @@ cfg$gms$s29_snv_shr_noselect <- 0 # def = 0 cfg$gms$s29_snv_scenario_start <- 2025 # def = 2025 # * Target year (year when full implementation is reached): cfg$gms$s29_snv_scenario_target <- 2050 # def = 2050 -# * Switch and specification of countries for which SNV policy in -# * s29_snv_shr apply. -# * Options: list of iso-codes of countries where SNV policy should be applied -# * Note: must be written in the format: "IND, BRA, DEU" -# * Default: all iso countries -cfg$gms$policy_countries29 <- all_iso_countries # * Land types included in the SNV policy. This option allows for sensitivity analyses. # * plausible options: "secdforest, forestry, past, other", # * "secdforest, other", @@ -735,7 +735,10 @@ cfg$gms$land_snv <- "secdforest, forestry, past, other" #def = "secdforest, f ## Agroforestry settings for treecover on cropland # * Sigmoid fader for minimum area share of treecover on total cropland at cluster level # * Minimum area share of treecover on total cropland in target year +# Note: s29_treecover_target applies to countries selected in policy_countries29 +# s29_treecover_target_noselect applies to all other countries. cfg$gms$s29_treecover_target <- 0 # def = 0 +cfg$gms$s29_treecover_target_noselect <- 0 # def = 0 # * Avoid loss of existing treecover (1=yes 0=no). # * If set to 1, `s29_treecover_target` will be adjusted based existing treecover area. cfg$gms$s29_treecover_keep <- 1 # def = 1 @@ -780,12 +783,24 @@ cfg$gms$c30_bioen_type <- "all" # def = "all" # * (c30_bioen_water): switch for irrigation of bioenergy crops; options: rainfed, irrigated, all cfg$gms$c30_bioen_water <- "rainfed" # def = "rainfed" +# * Switch and specification of countries for selected policies in apply. +# * Options: list of iso-codes of countries where SNV policy should be applied +# * Note: must be written in the format: "IND, BRA, DEU" +# * Default: all iso countries +cfg$gms$policy_countries30 <- all_iso_countries + ## Agroforestry settings for bioenergy trees # * Sigmoid fader for minimum area share of bioenergy trees (betr) on total cropland at cluster level # * Minimum area share of bioenergy trees on total cropland in start year +# Note: s30_betr_start applies to countries selected in policy_countries30, +# s30_betr_start_noselect applies to all other countries. cfg$gms$s30_betr_start <- 0 # def = 0 +cfg$gms$s30_betr_start_noselect <- 0 # def = 0 # * Minimum area share of bioenergy trees on total cropland in target year +# Note: s30_betr_target applies to countries selected in policy_countries30, +# s30_betr_target_noselect applies to all other countries. cfg$gms$s30_betr_target <- 0 # def = 0 +cfg$gms$s30_betr_target_noselect <- 0 # def = 0 # * Start year of fader cfg$gms$s30_betr_scenario_start <- 2025 # def = 2025 # * Target year of fader (year when full implementation is reached) diff --git a/modules/22_land_conservation/area_based_apr22/presolve.gms b/modules/22_land_conservation/area_based_apr22/presolve.gms index e11d2d046e..bfcd84b69e 100644 --- a/modules/22_land_conservation/area_based_apr22/presolve.gms +++ b/modules/22_land_conservation/area_based_apr22/presolve.gms @@ -80,8 +80,10 @@ pm_land_conservation(t,j,"other","restore")$(p22_conservation_area(t,j,"other") * Secondary forest restoration is limited by secondary forest restoration potential p22_secdforest_restore_pot(t,j) = sum(land, pcm_land(j, land)) - pcm_land(j, "urban") - - sum(land_natveg, pcm_land(j, land_natveg)) - - pm_land_conservation(t,j,"past","protect"); + - sum(land_timber, pcm_land(j, land_timber)) + - pm_land_conservation(t,j,"past","protect") + - vm_land.lo(j,"crop") + - vm_treecover.l(j); p22_secdforest_restore_pot(t,j)$(p22_secdforest_restore_pot(t,j) < 1e-6) = 0; pm_land_conservation(t,j,"secdforest","restore")$(pm_land_conservation(t,j,"secdforest","restore") > p22_secdforest_restore_pot(t,j)) = p22_secdforest_restore_pot(t,j); @@ -90,7 +92,9 @@ p22_past_restore_pot(t,j) = sum(land, pcm_land(j, land)) - pcm_land(j, "urban") - sum(land_timber, pcm_land(j, land_timber)) - pm_land_conservation(t,j,"past","protect") - - pm_land_conservation(t,j,"secdforest","restore"); + - pm_land_conservation(t,j,"secdforest","restore") + - vm_land.lo(j,"crop") + - vm_treecover.l(j); p22_past_restore_pot(t,j)$(p22_past_restore_pot(t,j) < 1e-6) = 0; pm_land_conservation(t,j,"past","restore")$(pm_land_conservation(t,j,"past","restore") > p22_past_restore_pot(t,j)) = p22_past_restore_pot(t,j); @@ -99,7 +103,9 @@ p22_other_restore_pot(t,j) = sum(land, pcm_land(j, land)) - pcm_land(j, "urban") - sum(land_timber, pcm_land(j, land_timber)) - sum(consv_type, pm_land_conservation(t,j,"past",consv_type)) - - pm_land_conservation(t,j,"secdforest","restore"); + - pm_land_conservation(t,j,"secdforest","restore") + - vm_land.lo(j,"crop") + - vm_treecover.l(j); p22_other_restore_pot(t,j)$(p22_other_restore_pot(t,j) < 1e-6) = 0; pm_land_conservation(t,j,"other","restore")$(pm_land_conservation(t,j,"other","restore") > p22_other_restore_pot(t,j)) = p22_other_restore_pot(t,j); diff --git a/modules/29_cropland/detail_apr24/declarations.gms b/modules/29_cropland/detail_apr24/declarations.gms index 81699b8691..bfa7e79f98 100644 --- a/modules/29_cropland/detail_apr24/declarations.gms +++ b/modules/29_cropland/detail_apr24/declarations.gms @@ -11,13 +11,13 @@ scalars parameters p29_avl_cropland(t,j) Total available land for crop cultivation (mio. ha) - p29_country_snv_weight(i) SNV policy country weight per region (1) + p29_country_weight(i) Policy country weight per region (1) p29_snv_shr(t,j) Share of semi-natural vegetation in cropland areas (1) i29_snv_relocation_target(j) Overall cropland area that requires relocation due to SNV policy (mio. ha) p29_snv_relocation(t,j) Cropland area that is actually relocated during time step (mio. ha) p29_max_snv_relocation(t,j) Maximum cropland relocation during time step (mio. ha) p29_country_dummy(iso) Dummy parameter indicating whether country is affected by selected cropland policy (1) - i29_avl_cropland_iso(iso) Available land area for cropland at ISO level (mio. ha) + pm_avl_cropland_iso(iso) Available land area for cropland at ISO level (mio. ha) i29_snv_scenario_fader(t_all) SNV scenario fader (1) i29_treecover_scenario_fader(t_all) Cropland treecover scenario fader (1) diff --git a/modules/29_cropland/detail_apr24/input.gms b/modules/29_cropland/detail_apr24/input.gms index b8f49a524f..f974d223f1 100644 --- a/modules/29_cropland/detail_apr24/input.gms +++ b/modules/29_cropland/detail_apr24/input.gms @@ -22,6 +22,7 @@ scalars s29_treecover_scenario_start Cropland treecover scenario start year / 2025 / s29_treecover_scenario_target Cropland treecover scenario target year / 2050 / s29_treecover_target Minimum share of treecover on total cropland in target year (1) / 0 / + s29_treecover_target_noselect Minimum share of treecover on total cropland in target year (1) / 0 / s29_treecover_keep Avoid loss of existing treecover (1=yes 0=no) / 1 / s29_treecover_max Maximum share of treecover on total cropland (1) / 0.4 / s29_treecover_penalty_before Penalty for violation of treecover target before scenario start (USD05MER per ha) / 2000 / @@ -34,10 +35,11 @@ scalars ; -* Set-switch for countries affected by regional SNV policy +* Set-switch for countries affected by certain policies * Default: all iso countries selected sets - policy_countries29(iso) countries to be affected by SNV policy / ABW,AFG,AGO,AIA,ALA,ALB,AND,ARE,ARG,ARM, + policy_countries29(iso) countries to be affected by SNV policy + / ABW,AFG,AGO,AIA,ALA,ALB,AND,ARE,ARG,ARM, ASM,ATA,ATF,ATG,AUS,AUT,AZE,BDI,BEL,BEN, BES,BFA,BGD,BGR,BHR,BHS,BIH,BLM,BLR,BLZ, BMU,BOL,BRA,BRB,BRN,BTN,BVT,BWA,CAF,CAN, diff --git a/modules/29_cropland/detail_apr24/preloop.gms b/modules/29_cropland/detail_apr24/preloop.gms index c45d550fd2..1f288bd228 100644 --- a/modules/29_cropland/detail_apr24/preloop.gms +++ b/modules/29_cropland/detail_apr24/preloop.gms @@ -28,6 +28,8 @@ pc29_treecover_share(j)$(pm_land_hist("y2015",j,"crop") > 1e-10) = f29_treecover pc29_treecover_share(j)$(pc29_treecover_share(j) > s29_treecover_max) = s29_treecover_max; pc29_treecover(j,ac) = (pc29_treecover_share(j) * pm_land_hist("y1995",j,"crop")) / card(ac); +vm_treecover.l(j) = sum(ac, pc29_treecover(j,ac)); + *' Switch for tree cover on cropland: *' 0 = Use natveg growth curve towards LPJmL natural vegetation *' 1 = Use plantation growth curve (faster than natveg) towards LPJmL natural vegetation @@ -46,13 +48,12 @@ elseif s29_treecover_bii_coeff = 1, ); -****** Regional share of semi-natural vegetation (SNV) in cropland areas for selective countries: -* Country switch to determine countries for which a SNV policy shall be applied. -* In the default case, the SNV policy affects all countries when activated. +* Country switch to determine countries for which certain policies shall be applied. +* In the default case, the policy affects all countries when activated. p29_country_dummy(iso) = 0; p29_country_dummy(policy_countries29) = 1; * Because MAgPIE is not run at country-level, but at region level, a region * share is calculated that translates the countries' influence to regional level. * Countries are weighted by available cropland area. -i29_avl_cropland_iso(iso) = f29_avl_cropland_iso(iso,"%c29_marginal_land%"); -p29_country_snv_weight(i) = sum(i_to_iso(i,iso), p29_country_dummy(iso) * i29_avl_cropland_iso(iso)) / sum(i_to_iso(i,iso), i29_avl_cropland_iso(iso)); +pm_avl_cropland_iso(iso) = f29_avl_cropland_iso(iso,"%c29_marginal_land%"); +p29_country_weight(i) = sum(i_to_iso(i,iso), p29_country_dummy(iso) * pm_avl_cropland_iso(iso)) / sum(i_to_iso(i,iso), pm_avl_cropland_iso(iso)); diff --git a/modules/29_cropland/detail_apr24/presolve.gms b/modules/29_cropland/detail_apr24/presolve.gms index b01a5b3690..e1a7d63bcf 100644 --- a/modules/29_cropland/detail_apr24/presolve.gms +++ b/modules/29_cropland/detail_apr24/presolve.gms @@ -12,16 +12,16 @@ *' @code *' Minimum semi-natural vegetation (SNV) share is fading in after 2020 p29_snv_shr(t,j) = i29_snv_scenario_fader(t) * - (s29_snv_shr * sum(cell(i,j), p29_country_snv_weight(i)) - + s29_snv_shr_noselect * sum(cell(i,j), 1-p29_country_snv_weight(i))); + (s29_snv_shr * sum(cell(i,j), p29_country_weight(i)) + + s29_snv_shr_noselect * sum(cell(i,j), 1-p29_country_weight(i))); *' Cropland relocation in response to SNV policy is based on exogeneous land *' cover information from the Copernicus Global Land Service (@buchhorn_copernicus_2020). *' The rate of the policy implementation is derived based *' on the difference of scenario fader values in consecutive time steps p29_snv_relocation(t,j) = (i29_snv_scenario_fader(t) - i29_snv_scenario_fader(t-1)) * - (i29_snv_relocation_target(j) * sum(cell(i,j), p29_country_snv_weight(i)) - + s29_snv_shr_noselect * sum(cell(i,j), 1-p29_country_snv_weight(i))); + (i29_snv_relocation_target(j) * sum(cell(i,j), p29_country_weight(i)) + + s29_snv_shr_noselect * sum(cell(i,j), 1-p29_country_weight(i))); *' The following lines take care of mismatches in the input *' data (derived from satellite imagery from the Copernicus *' Global Land Service (@buchhorn_copernicus_2020)) and in @@ -52,7 +52,9 @@ pc29_treecover(j,ac) = p29_treecover(t,j,ac); v29_treecover.l(j,ac) = p29_treecover(t,j,ac); * create treecover target and penalty scenario -i29_treecover_target(t,j) = s29_treecover_target * i29_treecover_scenario_fader(t); +i29_treecover_target(t,j) = i29_treecover_scenario_fader(t) * + (s29_treecover_target * sum(cell(i,j), p29_country_weight(i)) + + s29_treecover_target_noselect * sum(cell(i,j), 1-p29_country_weight(i))); * calculate treecover share pc29_treecover_share(j) = 0; diff --git a/modules/29_cropland/simple_apr24/declarations.gms b/modules/29_cropland/simple_apr24/declarations.gms index 34207a40de..625f819b2c 100644 --- a/modules/29_cropland/simple_apr24/declarations.gms +++ b/modules/29_cropland/simple_apr24/declarations.gms @@ -7,13 +7,13 @@ parameters p29_avl_cropland(t,j) Total available land for crop cultivation (mio. ha) - p29_country_snv_weight(i) SNV policy country weight per region (1) + p29_country_weight(i) Policy country weight per region (1) p29_snv_shr(t,j) Share of semi-natural vegetation in cropland areas (1) i29_snv_relocation_target(j) Overall cropland area that requires relocation due to SNV policy (mio. ha) p29_snv_relocation(t,j) Cropland area that is actually relocated during time step (mio. ha) p29_max_snv_relocation(t,j) Maximum cropland relocation during time step (mio. ha) p29_country_dummy(iso) Dummy parameter indicating whether country is affected by selected cropland policy (1) - i29_avl_cropland_iso(iso) Available land area for cropland at ISO level (mio. ha) + pm_avl_cropland_iso(iso) Available land area for cropland at ISO level (mio. ha) i29_snv_scenario_fader(t_all) SNV scenario fader (1) ; diff --git a/modules/29_cropland/simple_apr24/input.gms b/modules/29_cropland/simple_apr24/input.gms index ab9e0beed5..f13c46f56f 100644 --- a/modules/29_cropland/simple_apr24/input.gms +++ b/modules/29_cropland/simple_apr24/input.gms @@ -17,10 +17,11 @@ scalars s29_snv_relocation_data_x2 Second reference value in SNV target cropland data (1) / 0.5 / ; -* Set-switch for countries affected by regional SNV policy +* Set-switch for countries affected by certain policies * Default: all iso countries selected sets - policy_countries29(iso) countries to be affected by SNV policy / ABW,AFG,AGO,AIA,ALA,ALB,AND,ARE,ARG,ARM, + policy_countries29(iso) countries to be affected by SNV policy + / ABW,AFG,AGO,AIA,ALA,ALB,AND,ARE,ARG,ARM, ASM,ATA,ATF,ATG,AUS,AUT,AZE,BDI,BEL,BEN, BES,BFA,BGD,BGR,BHR,BHS,BIH,BLM,BLR,BLZ, BMU,BOL,BRA,BRB,BRN,BTN,BVT,BWA,CAF,CAN, diff --git a/modules/29_cropland/simple_apr24/preloop.gms b/modules/29_cropland/simple_apr24/preloop.gms index 3113ccb053..9b06b11d8f 100644 --- a/modules/29_cropland/simple_apr24/preloop.gms +++ b/modules/29_cropland/simple_apr24/preloop.gms @@ -25,14 +25,12 @@ elseif s29_snv_shr > s29_snv_relocation_data_x1, m_linear_cell_data_interpol(i29_snv_relocation_target, s29_snv_shr,s29_snv_relocation_data_x1, s29_snv_relocation_data_x2,f29_snv_target_cropland(j, "SNV20TargetCropland"), f29_snv_target_cropland(j, "SNV50TargetCropland")); ); -****** Regional share of semi-natural vegetation (SNV) in cropland areas for selective countries: -* Country switch to determine countries for which a SNV policy shall be applied. -* In the default case, the SNV policy affects all countries when activated. +* Country switch to determine countries for which certain policies shall be applied. +* In the default case, the policy affects all countries when activated. p29_country_dummy(iso) = 0; p29_country_dummy(policy_countries29) = 1; * Because MAgPIE is not run at country-level, but at region level, a region * share is calculated that translates the countries' influence to regional level. * Countries are weighted by available cropland area. -i29_avl_cropland_iso(iso) = f29_avl_cropland_iso(iso,"%c29_marginal_land%"); -p29_country_snv_weight(i) = sum(i_to_iso(i,iso), p29_country_dummy(iso) * i29_avl_cropland_iso(iso)) / sum(i_to_iso(i,iso), i29_avl_cropland_iso(iso)); - +pm_avl_cropland_iso(iso) = f29_avl_cropland_iso(iso,"%c29_marginal_land%"); +p29_country_weight(i) = sum(i_to_iso(i,iso), p29_country_dummy(iso) * pm_avl_cropland_iso(iso)) / sum(i_to_iso(i,iso), pm_avl_cropland_iso(iso)); diff --git a/modules/29_cropland/simple_apr24/presolve.gms b/modules/29_cropland/simple_apr24/presolve.gms index a49c401f8b..955befb1e4 100644 --- a/modules/29_cropland/simple_apr24/presolve.gms +++ b/modules/29_cropland/simple_apr24/presolve.gms @@ -9,16 +9,16 @@ *' @code *' Minimum semi-natural vegetation (SNV) share is fading in after 2020 p29_snv_shr(t,j) = i29_snv_scenario_fader(t) * - (s29_snv_shr * sum(cell(i,j), p29_country_snv_weight(i)) - + s29_snv_shr_noselect * sum(cell(i,j), 1-p29_country_snv_weight(i))); + (s29_snv_shr * sum(cell(i,j), p29_country_weight(i)) + + s29_snv_shr_noselect * sum(cell(i,j), 1-p29_country_weight(i))); *' Cropland relocation in response to SNV policy is based on exogeneous land *' cover information from the Copernicus Global Land Service (@buchhorn_copernicus_2020). *' The rate of the policy implementation is derived based *' on the difference of scenario fader values in consecutive time steps p29_snv_relocation(t,j) = (i29_snv_scenario_fader(t) - i29_snv_scenario_fader(t-1)) * - (i29_snv_relocation_target(j) * sum(cell(i,j), p29_country_snv_weight(i)) - + s29_snv_shr_noselect * sum(cell(i,j), 1-p29_country_snv_weight(i))); + (i29_snv_relocation_target(j) * sum(cell(i,j), p29_country_weight(i)) + + s29_snv_shr_noselect * sum(cell(i,j), 1-p29_country_weight(i))); *' The following lines take care of mismatches in the input *' data (derived from satellite imagery from the Copernicus *' Global Land Service (@buchhorn_copernicus_2020)) and in diff --git a/modules/30_croparea/detail_apr24/declarations.gms b/modules/30_croparea/detail_apr24/declarations.gms index 1191876e08..749c03c37b 100644 --- a/modules/30_croparea/detail_apr24/declarations.gms +++ b/modules/30_croparea/detail_apr24/declarations.gms @@ -11,8 +11,10 @@ parameters i30_rotation_scenario_fader(t_all) Crop rotation scenario fader (1) i30_implementation Switch for rule-based (1) or penalty-based (0) implementation of rotation scenarios i30_betr_scenario_fader(t_all) Bioenergy land scenario fader (1) - i30_betr_target(t) Target share for bioenergy land on total cropland (1) + i30_betr_target(t,j) Target share for bioenergy land on total cropland (1) i30_betr_penalty(t) Penalty for violation of betr target (USD05MER per ha) + p30_country_weight(i) Policy country weight per region (1) + p30_country_dummy(iso) Dummy parameter indicating whether country is affected by selected policy (1) ; positive variables diff --git a/modules/30_croparea/detail_apr24/equations.gms b/modules/30_croparea/detail_apr24/equations.gms index e51d334eac..2015529b0d 100644 --- a/modules/30_croparea/detail_apr24/equations.gms +++ b/modules/30_croparea/detail_apr24/equations.gms @@ -20,7 +20,7 @@ q30_betr_missing(j2)$(sum(ct, i30_betr_penalty(ct)) > 0) .. v30_betr_missing(j2) =g= - vm_land(j2,"crop") * sum(ct, i30_betr_target(ct)) - vm_area(j2,"betr","rainfed"); + vm_land(j2,"crop") * sum(ct, i30_betr_target(ct,j2)) - vm_area(j2,"betr","rainfed"); *' Rotational constraints prevent over-specialization. In this realization, *' they are either implemented via rules (i30_implementation = 1) or diff --git a/modules/30_croparea/detail_apr24/input.gms b/modules/30_croparea/detail_apr24/input.gms index 057eaef0d4..68b3a60d11 100644 --- a/modules/30_croparea/detail_apr24/input.gms +++ b/modules/30_croparea/detail_apr24/input.gms @@ -26,11 +26,43 @@ scalars s30_betr_scenario_start Bioenergy land scenario start year / 2025 / s30_betr_scenario_target Bioenergy land scenario target year / 2050 / s30_betr_start Share of bioenergy land on total cropland in start year (1) / 0 / + s30_betr_start_noselect Share of bioenergy land on total cropland in start year (1) / 0 / s30_betr_target Share of bioenergy land on total cropland in target year (1) / 0 / + s30_betr_target_noselect Share of bioenergy land on total cropland in target year (1) / 0 / s30_betr_penalty Penalty for violation of betr target (USD05MER per ha) / 2000 / s30_annual_max_growth Max annual cropland growth as share of previous cropland (1) / Inf / ; +* Set-switch for countries affected by certain policies +* Default: all iso countries selected +sets + policy_countries30(iso) countries to be affected by SNV policy + / ABW,AFG,AGO,AIA,ALA,ALB,AND,ARE,ARG,ARM, + ASM,ATA,ATF,ATG,AUS,AUT,AZE,BDI,BEL,BEN, + BES,BFA,BGD,BGR,BHR,BHS,BIH,BLM,BLR,BLZ, + BMU,BOL,BRA,BRB,BRN,BTN,BVT,BWA,CAF,CAN, + CCK,CHN,CHE,CHL,CIV,CMR,COD,COG,COK,COL, + COM,CPV,CRI,CUB,CUW,CXR,CYM,CYP,CZE,DEU, + DJI,DMA,DNK,DOM,DZA,ECU,EGY,ERI,ESH,ESP, + EST,ETH,FIN,FJI,FLK,FRA,FRO,FSM,GAB,GBR, + GEO,GGY,GHA,GIB,GIN,GLP,GMB,GNB,GNQ,GRC, + GRD,GRL,GTM,GUF,GUM,GUY,HKG,HMD,HND,HRV, + HTI,HUN,IDN,IMN,IND,IOT,IRL,IRN,IRQ,ISL, + ISR,ITA,JAM,JEY,JOR,JPN,KAZ,KEN,KGZ,KHM, + KIR,KNA,KOR,KWT,LAO,LBN,LBR,LBY,LCA,LIE, + LKA,LSO,LTU,LUX,LVA,MAC,MAF,MAR,MCO,MDA, + MDG,MDV,MEX,MHL,MKD,MLI,MLT,MMR,MNE,MNG, + MNP,MOZ,MRT,MSR,MTQ,MUS,MWI,MYS,MYT,NAM, + NCL,NER,NFK,NGA,NIC,NIU,NLD,NOR,NPL,NRU, + NZL,OMN,PAK,PAN,PCN,PER,PHL,PLW,PNG,POL, + PRI,PRK,PRT,PRY,PSE,PYF,QAT,REU,ROU,RUS, + RWA,SAU,SDN,SEN,SGP,SGS,SHN,SJM,SLB,SLE, + SLV,SMR,SOM,SPM,SRB,SSD,STP,SUR,SVK,SVN, + SWE,SWZ,SXM,SYC,SYR,TCA,TCD,TGO,THA,TJK, + TKL,TKM,TLS,TON,TTO,TUN,TUR,TUV,TWN,TZA, + UGA,UKR,UMI,URY,USA,UZB,VAT,VCT,VEN,VGB, + VIR,VNM,VUT,WLF,WSM,YEM,ZAF,ZMB,ZWE / +; $ifthen "%c30_bioen_type%" == "all" bioen_type_30(kbe30) = yes; $else bioen_type_30("%c30_bioen_type%") = yes; diff --git a/modules/30_croparea/detail_apr24/preloop.gms b/modules/30_croparea/detail_apr24/preloop.gms index 61c6d15a85..cdef528e7f 100644 --- a/modules/30_croparea/detail_apr24/preloop.gms +++ b/modules/30_croparea/detail_apr24/preloop.gms @@ -30,3 +30,12 @@ fm_croparea(t_past,j,w,kcr)$(fm_croparea(t_past,j,w,kcr)<0) = 0; if(s30_implementation = 1, v30_penalty.fx(j,rota30) = 0; ); + +* Country switch to determine countries for which certain policies shall be applied. +* In the default case, the policy affects all countries when activated. +p30_country_dummy(iso) = 0; +p30_country_dummy(policy_countries30) = 1; +* Because MAgPIE is not run at country-level, but at region level, a region +* share is calculated that translates the countries' influence to regional level. +* Countries are weighted by available cropland area. +p30_country_weight(i) = sum(i_to_iso(i,iso), p30_country_dummy(iso) * pm_avl_cropland_iso(iso)) / sum(i_to_iso(i,iso), pm_avl_cropland_iso(iso)); diff --git a/modules/30_croparea/detail_apr24/presolve.gms b/modules/30_croparea/detail_apr24/presolve.gms index 047c05ed2d..fb18d303f3 100644 --- a/modules/30_croparea/detail_apr24/presolve.gms +++ b/modules/30_croparea/detail_apr24/presolve.gms @@ -33,8 +33,12 @@ else ); * create betr target and penalty scenario -i30_betr_target(t) = s30_betr_start * (1-i30_betr_scenario_fader(t)) - + s30_betr_target * i30_betr_scenario_fader(t); +i30_betr_target(t,j) = (1-i30_betr_scenario_fader(t)) * + (s30_betr_start * sum(cell(i,j), p29_country_weight(i)) + + s30_betr_start_noselect * sum(cell(i,j), 1-p29_country_weight(i))) + + i30_betr_scenario_fader(t) * + (s30_betr_target * sum(cell(i,j), p29_country_weight(i)) + + s30_betr_target_noselect * sum(cell(i,j), 1-p29_country_weight(i))); if (m_year(t) <= s30_betr_scenario_start, i30_betr_penalty(t) = 0; diff --git a/modules/30_croparea/simple_apr24/declarations.gms b/modules/30_croparea/simple_apr24/declarations.gms index 4013e895e8..cc118fa84a 100644 --- a/modules/30_croparea/simple_apr24/declarations.gms +++ b/modules/30_croparea/simple_apr24/declarations.gms @@ -8,8 +8,10 @@ parameters i30_rotation_scenario_fader(t_all) Crop rotation scenario fader (1) i30_betr_scenario_fader(t_all) Bioenergy land scenario fader (1) - i30_betr_target(t) Target share for bioenergy land on total cropland (1) + i30_betr_target(t,j) Target share for bioenergy land on total cropland (1) i30_betr_penalty(t) Penalty for violation of betr target (USD05MER per ha) + p30_country_weight(i) Policy country weight per region (1) + p30_country_dummy(iso) Dummy parameter indicating whether country is affected by selected policy (1) ; positive variables diff --git a/modules/30_croparea/simple_apr24/equations.gms b/modules/30_croparea/simple_apr24/equations.gms index 4df6b25bbf..42f01c1794 100644 --- a/modules/30_croparea/simple_apr24/equations.gms +++ b/modules/30_croparea/simple_apr24/equations.gms @@ -20,7 +20,7 @@ q30_betr_missing(j2)$(sum(ct, i30_betr_penalty(ct)) > 0) .. v30_betr_missing(j2) =g= - vm_land(j2,"crop") * sum(ct, i30_betr_target(ct)) - vm_area(j2,"betr","rainfed"); + vm_land(j2,"crop") * sum(ct, i30_betr_target(ct,j2)) - vm_area(j2,"betr","rainfed"); q30_cost(i2) .. vm_rotation_penalty(i2) =g= diff --git a/modules/30_croparea/simple_apr24/input.gms b/modules/30_croparea/simple_apr24/input.gms index 7fdea61cea..e99a128cb0 100644 --- a/modules/30_croparea/simple_apr24/input.gms +++ b/modules/30_croparea/simple_apr24/input.gms @@ -20,11 +20,44 @@ scalars s30_betr_scenario_start Bioenergy land scenario start year / 2025 / s30_betr_scenario_target Bioenergy land scenario target year / 2050 / s30_betr_start Share of bioenergy land on total cropland in start year (1) / 0 / + s30_betr_start_noselect Share of bioenergy land on total cropland in start year (1) / 0 / s30_betr_target Share of bioenergy land on total cropland in target year (1) / 0 / + s30_betr_target_noselect Share of bioenergy land on total cropland in target year (1) / 0 / s30_betr_penalty Penalty for violation of betr target (USD05MER per ha) / 2000 / s30_annual_max_growth Max annual cropland growth as share of previous cropland (1) / Inf / ; +* Set-switch for countries affected by certain policies +* Default: all iso countries selected +sets + policy_countries30(iso) countries to be affected by SNV policy + / ABW,AFG,AGO,AIA,ALA,ALB,AND,ARE,ARG,ARM, + ASM,ATA,ATF,ATG,AUS,AUT,AZE,BDI,BEL,BEN, + BES,BFA,BGD,BGR,BHR,BHS,BIH,BLM,BLR,BLZ, + BMU,BOL,BRA,BRB,BRN,BTN,BVT,BWA,CAF,CAN, + CCK,CHN,CHE,CHL,CIV,CMR,COD,COG,COK,COL, + COM,CPV,CRI,CUB,CUW,CXR,CYM,CYP,CZE,DEU, + DJI,DMA,DNK,DOM,DZA,ECU,EGY,ERI,ESH,ESP, + EST,ETH,FIN,FJI,FLK,FRA,FRO,FSM,GAB,GBR, + GEO,GGY,GHA,GIB,GIN,GLP,GMB,GNB,GNQ,GRC, + GRD,GRL,GTM,GUF,GUM,GUY,HKG,HMD,HND,HRV, + HTI,HUN,IDN,IMN,IND,IOT,IRL,IRN,IRQ,ISL, + ISR,ITA,JAM,JEY,JOR,JPN,KAZ,KEN,KGZ,KHM, + KIR,KNA,KOR,KWT,LAO,LBN,LBR,LBY,LCA,LIE, + LKA,LSO,LTU,LUX,LVA,MAC,MAF,MAR,MCO,MDA, + MDG,MDV,MEX,MHL,MKD,MLI,MLT,MMR,MNE,MNG, + MNP,MOZ,MRT,MSR,MTQ,MUS,MWI,MYS,MYT,NAM, + NCL,NER,NFK,NGA,NIC,NIU,NLD,NOR,NPL,NRU, + NZL,OMN,PAK,PAN,PCN,PER,PHL,PLW,PNG,POL, + PRI,PRK,PRT,PRY,PSE,PYF,QAT,REU,ROU,RUS, + RWA,SAU,SDN,SEN,SGP,SGS,SHN,SJM,SLB,SLE, + SLV,SMR,SOM,SPM,SRB,SSD,STP,SUR,SVK,SVN, + SWE,SWZ,SXM,SYC,SYR,TCA,TCD,TGO,THA,TJK, + TKL,TKM,TLS,TON,TTO,TUN,TUR,TUV,TWN,TZA, + UGA,UKR,UMI,URY,USA,UZB,VAT,VCT,VEN,VGB, + VIR,VNM,VUT,WLF,WSM,YEM,ZAF,ZMB,ZWE / +; + $ifthen "%c30_bioen_type%" == "all" bioen_type_30(kbe30) = yes; $else bioen_type_30("%c30_bioen_type%") = yes; $endif diff --git a/modules/30_croparea/simple_apr24/preloop.gms b/modules/30_croparea/simple_apr24/preloop.gms index 899afc80c9..adffa58780 100644 --- a/modules/30_croparea/simple_apr24/preloop.gms +++ b/modules/30_croparea/simple_apr24/preloop.gms @@ -15,3 +15,11 @@ m_sigmoid_time_interpol(i30_betr_scenario_fader,s30_betr_scenario_start,s30_betr *cannot be smaller than 0! fm_croparea(t_past,j,w,kcr)$(fm_croparea(t_past,j,w,kcr)<0) = 0; +* Country switch to determine countries for which certain policies shall be applied. +* In the default case, the policy affects all countries when activated. +p30_country_dummy(iso) = 0; +p30_country_dummy(policy_countries30) = 1; +* Because MAgPIE is not run at country-level, but at region level, a region +* share is calculated that translates the countries' influence to regional level. +* Countries are weighted by available cropland area. +p30_country_weight(i) = sum(i_to_iso(i,iso), p30_country_dummy(iso) * pm_avl_cropland_iso(iso)) / sum(i_to_iso(i,iso), pm_avl_cropland_iso(iso)); diff --git a/modules/30_croparea/simple_apr24/presolve.gms b/modules/30_croparea/simple_apr24/presolve.gms index c89314e5c7..2f23d5fb7f 100644 --- a/modules/30_croparea/simple_apr24/presolve.gms +++ b/modules/30_croparea/simple_apr24/presolve.gms @@ -24,8 +24,12 @@ crpmax30(crp30) = yes$(f30_rotation_max_shr(crp30) < 1); crpmin30(crp30) = yes$(f30_rotation_min_shr(crp30) > 0); * create betr target and penalty scenario -i30_betr_target(t) = s30_betr_start * (1-i30_betr_scenario_fader(t)) - + s30_betr_target * i30_betr_scenario_fader(t); +i30_betr_target(t,j) = (1-i30_betr_scenario_fader(t)) * + (s30_betr_start * sum(cell(i,j), p29_country_weight(i)) + + s30_betr_start_noselect * sum(cell(i,j), 1-p29_country_weight(i))) + + i30_betr_scenario_fader(t) * + (s30_betr_target * sum(cell(i,j), p29_country_weight(i)) + + s30_betr_target_noselect * sum(cell(i,j), 1-p29_country_weight(i))); if (m_year(t) <= s30_betr_scenario_start, i30_betr_penalty(t) = 0; From 4b703be35752391a5f4b15c216978b2b393f0b22 Mon Sep 17 00:00:00 2001 From: florianh Date: Fri, 14 Jun 2024 19:42:59 +0200 Subject: [PATCH 119/133] added EUR --- config/default.cfg | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/config/default.cfg b/config/default.cfg index fd45e39a2d..73aac6eb88 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -175,6 +175,11 @@ oecd90andEU <- "ALB,AUS,AUT,BEL,BIH,BGR,CAN,CYP,CZE,DNK,EST,FIN,FRA, NLD,NOR,NZL,POL,PRT,ROU,SRB,SVK,SVN,ESP,SWE,CHE,MKD,TUR, GBR,USA" +EUR <- "ALB,AUT,BEL,BGR,CYP,CZE,DEU,DNK,ESP,EST,FIN,FRA,FRO, + GBR,GGY,GIB,GRC,HRV,HUN,IMN,IRL,ITA,JEY,LTU,LUX,LVA,MLT, + NLD,POL,PRT,ROU,SVK,SVN,SWE" + + # ***--------------------- 09_drivers ---------------------------------------- # * (aug17): default drivers cfg$gms$drivers <- "aug17" # def = aug17 From 560138b6024990adb9d3dcd15b3692cf21cd97ab Mon Sep 17 00:00:00 2001 From: florianh Date: Sat, 15 Jun 2024 13:10:01 +0200 Subject: [PATCH 120/133] magpie4 version + peatland input files --- DESCRIPTION | 2 +- modules/58_peatland/input/files | 5 +---- modules/58_peatland/v2/input.gms | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 0b44903520..ba76854991 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -22,7 +22,7 @@ Imports: m4fsdp, madrat, magclass (>= 6.14.0), - magpie4, + magpie4 (>= 2.3.10), MagpieNCGains, magpiesets, mip, diff --git a/modules/58_peatland/input/files b/modules/58_peatland/input/files index 3509c27c10..09985440b4 100644 --- a/modules/58_peatland/input/files +++ b/modules/58_peatland/input/files @@ -1,6 +1,3 @@ * list of files that are required here -f58_peatland_degrad.cs2 -f58_peatland_intact.cs2 -f58_ipcc_wetland_ef.cs3 f58_ipcc_wetland_ef2.cs3 -f58_peatland_area.cs2 +f58_peatland_area.cs3 diff --git a/modules/58_peatland/v2/input.gms b/modules/58_peatland/v2/input.gms index 12007a7e7c..99c9207abf 100644 --- a/modules/58_peatland/v2/input.gms +++ b/modules/58_peatland/v2/input.gms @@ -19,7 +19,7 @@ scalars *Peatland area based on Global Peatland Map 2.0 and Global Peatland Database table f58_peatland_area(j,land58) Peatland area (mio. ha) $ondelim -$include "./modules/58_peatland/input/f58_peatland_area.cs2" +$include "./modules/58_peatland/input/f58_peatland_area.cs3" $offdelim ; From 4ac78c6372f37c8edbd4083c52d97fef67630549 Mon Sep 17 00:00:00 2001 From: florianh Date: Sat, 15 Jun 2024 13:17:20 +0200 Subject: [PATCH 121/133] Changelog --- CHANGELOG.md | 6 +++--- config/default.cfg | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99fe45d58d..50992afad8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,13 +17,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### added - **29_cropland** new module `29_cropland` accounting for crop area, fallow cropland and tree cover on cropland with two realizations: `detail_apr24` and `simple_apr24` (default). - **10_land** added interface `pm_land_hist` with historic land use patterns -- **32_forestry** added technical balance term `v32_land_missing_ndc` ### removed -- +- **32_forestry** removed technical balance term `v32_land_missing_ndc` ### fixed -- +- **22_land_conservation** avoid infeasibilities due to very small numbers, account for cropland tree cover and lower bound of cropland + ## [4.8.0] - 2024-06-10 diff --git a/config/default.cfg b/config/default.cfg index 73aac6eb88..9593e25f2c 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -175,7 +175,7 @@ oecd90andEU <- "ALB,AUS,AUT,BEL,BIH,BGR,CAN,CYP,CZE,DNK,EST,FIN,FRA, NLD,NOR,NZL,POL,PRT,ROU,SRB,SVK,SVN,ESP,SWE,CHE,MKD,TUR, GBR,USA" -EUR <- "ALB,AUT,BEL,BGR,CYP,CZE,DEU,DNK,ESP,EST,FIN,FRA,FRO, +isoCountriesEUR <- "ALB,AUT,BEL,BGR,CYP,CZE,DEU,DNK,ESP,EST,FIN,FRA,FRO, GBR,GGY,GIB,GRC,HRV,HUN,IMN,IRL,ITA,JEY,LTU,LUX,LVA,MLT, NLD,POL,PRT,ROU,SVK,SVN,SWE" From 105068168dde1eae359bad2aa1593f6c3eee78be Mon Sep 17 00:00:00 2001 From: florianh Date: Sat, 15 Jun 2024 13:23:54 +0200 Subject: [PATCH 122/133] changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 50992afad8..b0126a0c46 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### fixed - **22_land_conservation** avoid infeasibilities due to very small numbers, account for cropland tree cover and lower bound of cropland +- **32_forestry** avoid infeasibilities due to very small numbers +- **35_natveg** avoid infeasibilities due to very small numbers From 7c470239d66408ab94cec21bea47db3709370134 Mon Sep 17 00:00:00 2001 From: florianh Date: Sat, 15 Jun 2024 13:58:56 +0200 Subject: [PATCH 123/133] bugfix --- modules/30_croparea/detail_apr24/presolve.gms | 8 ++++---- modules/30_croparea/simple_apr24/presolve.gms | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/30_croparea/detail_apr24/presolve.gms b/modules/30_croparea/detail_apr24/presolve.gms index fb18d303f3..c110499ec6 100644 --- a/modules/30_croparea/detail_apr24/presolve.gms +++ b/modules/30_croparea/detail_apr24/presolve.gms @@ -34,11 +34,11 @@ else * create betr target and penalty scenario i30_betr_target(t,j) = (1-i30_betr_scenario_fader(t)) * - (s30_betr_start * sum(cell(i,j), p29_country_weight(i)) - + s30_betr_start_noselect * sum(cell(i,j), 1-p29_country_weight(i))) + (s30_betr_start * sum(cell(i,j), p30_country_weight(i)) + + s30_betr_start_noselect * sum(cell(i,j), 1-p30_country_weight(i))) + i30_betr_scenario_fader(t) * - (s30_betr_target * sum(cell(i,j), p29_country_weight(i)) - + s30_betr_target_noselect * sum(cell(i,j), 1-p29_country_weight(i))); + (s30_betr_target * sum(cell(i,j), p30_country_weight(i)) + + s30_betr_target_noselect * sum(cell(i,j), 1-p30_country_weight(i))); if (m_year(t) <= s30_betr_scenario_start, i30_betr_penalty(t) = 0; diff --git a/modules/30_croparea/simple_apr24/presolve.gms b/modules/30_croparea/simple_apr24/presolve.gms index 2f23d5fb7f..adc5cba7e2 100644 --- a/modules/30_croparea/simple_apr24/presolve.gms +++ b/modules/30_croparea/simple_apr24/presolve.gms @@ -25,11 +25,11 @@ crpmin30(crp30) = yes$(f30_rotation_min_shr(crp30) > 0); * create betr target and penalty scenario i30_betr_target(t,j) = (1-i30_betr_scenario_fader(t)) * - (s30_betr_start * sum(cell(i,j), p29_country_weight(i)) - + s30_betr_start_noselect * sum(cell(i,j), 1-p29_country_weight(i))) + (s30_betr_start * sum(cell(i,j), p30_country_weight(i)) + + s30_betr_start_noselect * sum(cell(i,j), 1-p30_country_weight(i))) + i30_betr_scenario_fader(t) * - (s30_betr_target * sum(cell(i,j), p29_country_weight(i)) - + s30_betr_target_noselect * sum(cell(i,j), 1-p29_country_weight(i))); + (s30_betr_target * sum(cell(i,j), p30_country_weight(i)) + + s30_betr_target_noselect * sum(cell(i,j), 1-p30_country_weight(i))); if (m_year(t) <= s30_betr_scenario_start, i30_betr_penalty(t) = 0; From d789ea6856dceebb339014b381238b07435bb795 Mon Sep 17 00:00:00 2001 From: florianh Date: Sat, 15 Jun 2024 14:00:08 +0200 Subject: [PATCH 124/133] update main.gms --- main.gms | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/main.gms b/main.gms index 50882b629f..db00b06172 100644 --- a/main.gms +++ b/main.gms @@ -147,44 +147,44 @@ $title magpie *' * Always try to access model outputs through the corresponding magpie package instead of accessing them directly with readGDX. It cannot be guaranteed that your script will work in the future if you do otherwise (as only the corresponding magpie package will be continuously adapted to changes in the GAMS code). *##################### R SECTION START (VERSION INFO) ########################## -* -* Used data set: rev4.106_h12_magpie.tgz +* +* Used data set: rev4.108_h12_magpie.tgz * md5sum: NA -* Repository: scp://cluster.pik-potsdam.de/p/projects/rd3mod/inputdata/output -* -* Used data set: rev4.106_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz +* Repository: https://rse.pik-potsdam.de/data/magpie/public +* +* Used data set: rev4.108_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz * md5sum: NA -* Repository: scp://cluster.pik-potsdam.de/p/projects/rd3mod/inputdata/output -* -* Used data set: rev4.106_h12_validation.tgz +* Repository: https://rse.pik-potsdam.de/data/magpie/public +* +* Used data set: rev4.108_h12_validation.tgz * md5sum: NA -* Repository: scp://cluster.pik-potsdam.de/p/projects/rd3mod/inputdata/output -* -* Used data set: additional_data_rev4.50.tgz +* Repository: https://rse.pik-potsdam.de/data/magpie/public +* +* Used data set: additional_data_rev4.51.tgz * md5sum: NA * Repository: scp://cluster.pik-potsdam.de/p/projects/landuse/data/input/archive -* +* * Used data set: calibration_H12_26Mar24.tgz * md5sum: NA * Repository: https://rse.pik-potsdam.de/data/magpie/public -* +* * Low resolution: c200 * High resolution: 0.5 -* +* * Total number of cells: 200 -* +* * Number of cells per region: * CAZ CHA EUR IND JPN LAM MEA NEU OAS REF SSA USA * 14 23 10 7 4 26 21 9 16 23 32 15 -* +* * Regionscode: 62eff8f7 -* -* Regions data revision: 4.106 -* +* +* Regions data revision: 4.108 +* * lpj2magpie settings: * * LPJmL data: MRI-ESM2-0:ssp370 -* * Revision: 4.106 -* +* * Revision: 4.108 +* * aggregation settings: * * Input resolution: 0.5 * * Output resolution: c200 @@ -193,10 +193,10 @@ $title magpie * CAZ CHA EUR IND JPN LAM MEA NEU OAS REF SSA USA * 14 23 10 7 4 26 21 9 16 23 32 15 * * Call: withCallingHandlers(expr, message = messageHandler, warning = warningHandler, error = errorHandler) -* -* -* Last modification (input data): Thu May 23 11:16:51 2024 -* +* +* +* Last modification (input data): Sat Jun 15 13:10:19 2024 +* *###################### R SECTION END (VERSION INFO) ########################### $offupper From e807eb57c7123a0a15ed3b6b6205d77ce7a4eac4 Mon Sep 17 00:00:00 2001 From: florianh Date: Mon, 17 Jun 2024 09:47:19 +0200 Subject: [PATCH 125/133] update default.cfg --- config/default.cfg | 4 ++-- modules/29_cropland/detail_apr24/input.gms | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config/default.cfg b/config/default.cfg index 9593e25f2c..f2a7d0d6ed 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -754,9 +754,9 @@ cfg$gms$s29_treecover_scenario_start <- 2025 # def = 2025 # * Target year of fader (year when full implementation is reached) cfg$gms$s29_treecover_scenario_target <- 2050 # def = 2050 # * Penalty for violation of treecover target before scenario start (USD05MER per ha) -cfg$gms$s29_treecover_penalty_before <- 2000 # def = 2000 +cfg$gms$s29_treecover_penalty_before <- 5000 # def = 5000 # * Penalty for violation of treecover target after scenario start (USD05MER per ha) -cfg$gms$s29_treecover_penalty <- 2000 # def = 2000 +cfg$gms$s29_treecover_penalty <- 5000 # def = 5000 # * Tree cover establishment cost (USD05MER per ha) cfg$gms$s29_cost_treecover_est <- 2000 # def = 2000 # * Tree cover recurring cost (USD05MER per ha) diff --git a/modules/29_cropland/detail_apr24/input.gms b/modules/29_cropland/detail_apr24/input.gms index f974d223f1..163dc134e1 100644 --- a/modules/29_cropland/detail_apr24/input.gms +++ b/modules/29_cropland/detail_apr24/input.gms @@ -25,8 +25,8 @@ scalars s29_treecover_target_noselect Minimum share of treecover on total cropland in target year (1) / 0 / s29_treecover_keep Avoid loss of existing treecover (1=yes 0=no) / 1 / s29_treecover_max Maximum share of treecover on total cropland (1) / 0.4 / - s29_treecover_penalty_before Penalty for violation of treecover target before scenario start (USD05MER per ha) / 2000 / - s29_treecover_penalty Penalty for violation of treecover target after sceanrio start (USD05MER per ha) / 2000 / + s29_treecover_penalty_before Penalty for violation of treecover target before scenario start (USD05MER per ha) / 5000 / + s29_treecover_penalty Penalty for violation of treecover target after sceanrio start (USD05MER per ha) / 5000 / s29_fallow_scenario_start Fallow land scenario start year / 2025 / s29_fallow_scenario_target Fallow land scenario target year / 2050 / s29_fallow_target Minimum share of fallow land on total cropland in target year (1) / 0 / From 6f55c1d810bf0eb7262a85baaed6485c94160432 Mon Sep 17 00:00:00 2001 From: florianh Date: Mon, 17 Jun 2024 10:35:42 +0200 Subject: [PATCH 126/133] code cleanup --- config/scenario_fsec.csv | 2 +- modules/30_croparea/detail_apr24/input.gms | 5 ++--- modules/30_croparea/detail_apr24/sets.gms | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/config/scenario_fsec.csv b/config/scenario_fsec.csv index c97584e0fd..d07aabcc7d 100644 --- a/config/scenario_fsec.csv +++ b/config/scenario_fsec.csv @@ -52,7 +52,7 @@ gms$c38_fac_req;reg;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$s38_target_labor_share;0;;;;;0.8;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$s42_watdem_nonagr_scenario;;;;1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$c42_env_flow_policy;off;;;;;;;;;;;;;;;;;;;;;;;;;;;;;on;;;;;;;;;;;;;;;;;;;;; -gms$s42_efp_startyear;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2020;;;;;;;;;;;;;;;;;;;;; +gms$s42_efp_startyear;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2025;;;;;;;;;;;;;;;;;;;;; gms$s42_efp_targetyear;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2050;;;;;;;;;;;;;;;;;;;;; gms$s44_bii_lower_bound;;;;;;;;;;;;;;;;;;;;;;0;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$c44_bii_decrease;;;;;;;;;;;;;;;;;;;;;;0;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/modules/30_croparea/detail_apr24/input.gms b/modules/30_croparea/detail_apr24/input.gms index 68b3a60d11..47c979fc0e 100644 --- a/modules/30_croparea/detail_apr24/input.gms +++ b/modules/30_croparea/detail_apr24/input.gms @@ -12,11 +12,10 @@ $setglobal c30_bioen_water rainfed * options: rainfed, irrigated, all $setglobal c30_rotation_rules default -*options: min, default, good, good_20div, setaside, legumes, sixfoldrotation, agroecology, -* betr0, betr10, betr20, betr25, betr30, betr40, betr50, FSEC +*options: min, default, good, good_20div, setaside, legumes, sixfoldrotation, agroecology, FSEC $setglobal c30_rotation_incentives none -*options: none, default, legumes, betr500, betr1000, agroecology +*options: none, default, legumes, agroecology scalars diff --git a/modules/30_croparea/detail_apr24/sets.gms b/modules/30_croparea/detail_apr24/sets.gms index 579e1f82b3..ff7210ef89 100644 --- a/modules/30_croparea/detail_apr24/sets.gms +++ b/modules/30_croparea/detail_apr24/sets.gms @@ -10,7 +10,7 @@ sets / none, default, legumes, agroecology / rotascen30 rotation constraint scenarios - / min, default, good,good_20div, setaside, legumes, sixfoldrotation, agroecology, FSEC / + / min, default, good, good_20div, setaside, legumes, sixfoldrotation, agroecology, FSEC / rota30 rotational rules / cereals1_max, cereals2_max, cereals_excl_rice_max, stalk_max, From c8933af394fd3d825f9b6886ab36b225169194d6 Mon Sep 17 00:00:00 2001 From: Pascal Sauer Date: Mon, 17 Jun 2024 12:29:03 +0200 Subject: [PATCH 127/133] warn instead stop when renv::snapshot fails --- output.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/output.R b/output.R index a439f41537..94ad9c62ed 100644 --- a/output.R +++ b/output.R @@ -198,7 +198,7 @@ runOutputs <- function(comp=NULL, output=NULL, outputdir=NULL, submit=NULL) { }, type = "message") }) if (!snapshotSuccess) { - stop(paste(errorMessage1, collapse = "\n"), paste(errorMessage2, collapse = "\n")) + warning(paste(errorMessage1, collapse = "\n"), paste(errorMessage2, collapse = "\n")) } message("done.") @@ -213,6 +213,8 @@ runOutputs <- function(comp=NULL, output=NULL, outputdir=NULL, submit=NULL) { if (!file.exists(file.path(runFolder, "renv.lock"))) { warning(normalizePath(runFolder), "/renv.lock does not exist.") message("Lockfile written to ", newLockfile) + } else if (!file.exists(newLockfile)) { + message("Could not write lockfile, see warning thrown earlier.") } else if (identical(readLines(file.path(runFolder, "renv.lock")), readLines(newLockfile))) { file.remove(newLockfile) } else { From a8ab9a48158013d3ff26aac76001eca9f3d4d0fe Mon Sep 17 00:00:00 2001 From: Pascal Sauer Date: Mon, 17 Jun 2024 12:33:56 +0200 Subject: [PATCH 128/133] Revert "Delete renv/settings.dcf" This reverts commit 00d08cf1a0f2701293df75dce187bb1eaba26cb2. --- renv/settings.dcf | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 renv/settings.dcf diff --git a/renv/settings.dcf b/renv/settings.dcf new file mode 100644 index 0000000000..169d82f1bc --- /dev/null +++ b/renv/settings.dcf @@ -0,0 +1,10 @@ +bioconductor.version: +external.libraries: +ignored.packages: +package.dependency.fields: Imports, Depends, LinkingTo +r.version: +snapshot.type: implicit +use.cache: TRUE +vcs.ignore.cellar: TRUE +vcs.ignore.library: TRUE +vcs.ignore.local: TRUE From 2924193c8dafd4bd7e6ca3c7992142e323b03eb3 Mon Sep 17 00:00:00 2001 From: florianh Date: Mon, 17 Jun 2024 13:45:21 +0200 Subject: [PATCH 129/133] bugfix fixing 2025 44_biodiverstiy --- CHANGELOG.md | 1 + modules/44_biodiversity/bii_target/presolve.gms | 11 ++++++----- modules/44_biodiversity/bii_target_apr24/presolve.gms | 11 ++++++----- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b0126a0c46..82ff4e80a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **22_land_conservation** avoid infeasibilities due to very small numbers, account for cropland tree cover and lower bound of cropland - **32_forestry** avoid infeasibilities due to very small numbers - **35_natveg** avoid infeasibilities due to very small numbers +- **44_biodiversity** Fixing to SSP2 parameters until 2025 was not working diff --git a/modules/44_biodiversity/bii_target/presolve.gms b/modules/44_biodiversity/bii_target/presolve.gms index f1bb9c25f4..de414061ef 100644 --- a/modules/44_biodiversity/bii_target/presolve.gms +++ b/modules/44_biodiversity/bii_target/presolve.gms @@ -5,12 +5,14 @@ *** | MAgPIE License Exception, version 1.0 (see LICENSE file). *** | Contact: magpie@pik-potsdam.de -if(m_year(t) = s44_start_year, * The start value for the linear interpolation is the BII at biome level in the start year. - p44_start_value(i,biome44) = v44_bii.l(i,biome44); +p44_start_value(i,biome44)$(m_year(t) = s44_start_year) = v44_bii.l(i,biome44); * The target value for the linear interpolation is the lower bound defined in `s44_bii_lower_bound`. - p44_target_value(i,biome44) = s44_bii_lower_bound; - +p44_target_value(i,biome44) = s44_bii_lower_bound; + +if (m_year(t) <= sm_fix_SSP2, + v44_bii.lo(i,biome44) = 0; +else * Linear increase of BII target values at biome level from start year to target year, and constant values thereafter. p44_bii_lower_bound(t2,i,biome44) = p44_start_value(i,biome44) + ((m_year(t2) - s44_start_year) / (s44_target_year - s44_start_year)) * (p44_target_value(i,biome44) - p44_start_value(i,biome44)); p44_bii_lower_bound(t2,i,biome44)$(m_year(t2) > s44_target_year) = p44_target_value(i,biome44); @@ -26,4 +28,3 @@ if(m_year(t) = s44_start_year, v44_bii.lo(i,biome44) = p44_bii_lower_bound(t,i,biome44); display p44_bii_lower_bound; ); - diff --git a/modules/44_biodiversity/bii_target_apr24/presolve.gms b/modules/44_biodiversity/bii_target_apr24/presolve.gms index 7f9ba294f7..0a45321b2a 100644 --- a/modules/44_biodiversity/bii_target_apr24/presolve.gms +++ b/modules/44_biodiversity/bii_target_apr24/presolve.gms @@ -5,12 +5,14 @@ *** | MAgPIE License Exception, version 1.0 (see LICENSE file). *** | Contact: magpie@pik-potsdam.de -if(m_year(t) = s44_start_year, * The start value for the linear interpolation is the BII at biome level in the start year. - p44_start_value(i,biome44) = v44_bii.l(i,biome44); +p44_start_value(i,biome44)$(m_year(t) = s44_start_year) = v44_bii.l(i,biome44); * The target value for the linear interpolation is the lower bound defined in `s44_bii_lower_bound`. - p44_target_value(i,biome44) = s44_bii_lower_bound; - +p44_target_value(i,biome44) = s44_bii_lower_bound; + +if (m_year(t) <= sm_fix_SSP2, + v44_bii.lo(i,biome44) = 0; +else * Linear increase of BII target values at biome level from start year to target year, and constant values thereafter. p44_bii_lower_bound(t2,i,biome44) = p44_start_value(i,biome44) + ((m_year(t2) - s44_start_year) / (s44_target_year - s44_start_year)) * (p44_target_value(i,biome44) - p44_start_value(i,biome44)); p44_bii_lower_bound(t2,i,biome44)$(m_year(t2) > s44_target_year) = p44_target_value(i,biome44); @@ -26,4 +28,3 @@ if(m_year(t) = s44_start_year, v44_bii.lo(i,biome44) = p44_bii_lower_bound(t,i,biome44); display p44_bii_lower_bound; ); - From 25cbd4f574b9570086a8cb27bfdb8945e26fe324 Mon Sep 17 00:00:00 2001 From: florianh Date: Mon, 17 Jun 2024 20:25:53 +0200 Subject: [PATCH 130/133] update input data --- config/default.cfg | 6 +- config/scenario_config.csv | 2 +- scripts/start/projects/paper_peatlandTax.R | 186 ++++++++++----------- scripts/start/projects/project_ABCDR.R | 84 ++++++++++ 4 files changed, 172 insertions(+), 106 deletions(-) create mode 100644 scripts/start/projects/project_ABCDR.R diff --git a/config/default.cfg b/config/default.cfg index f2a7d0d6ed..d01a222b1b 100644 --- a/config/default.cfg +++ b/config/default.cfg @@ -22,9 +22,9 @@ cfg$model <- "main.gms" #def = "main.gms" #### input settings #### # which input data sets should be used? -cfg$input <- c(regional = "rev4.108_h12_magpie.tgz", - cellular = "rev4.108_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", - validation = "rev4.108_h12_validation.tgz", +cfg$input <- c(regional = "rev4.109_h12_magpie.tgz", + cellular = "rev4.109_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz", + validation = "rev4.109_h12_validation.tgz", additional = "additional_data_rev4.51.tgz", calibration = "calibration_H12_26Mar24.tgz") diff --git a/config/scenario_config.csv b/config/scenario_config.csv index 3a11b77af6..8a2870327f 100755 --- a/config/scenario_config.csv +++ b/config/scenario_config.csv @@ -101,5 +101,5 @@ gms$c60_bioenergy_subsidy;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$c60_res_2ndgenBE_dem;;;;ssp1;ssp2;ssp2;ssp3;ssp4;ssp5;sdp;ssp2;sdp;sdp;;;;;;;sdp;;;;;ssp4;sdp;ssp4;ssp4;sdp;;;;;;;;;;;;;;;;;;;; gms$c70_feed_scen;;;;ssp1;ssp2;ssp2;ssp3;ssp4;ssp5;ssp1;ssp5;ssp1;ssp1;;;;;;;ssp1;;ssp1;;;ssp4;ssp1;ssp4;ssp4;ssp1;;;;;;;;;;;;;;;;;;;; gms$s73_timber_demand_switch;;;;;;;;;;;;;;;;;;;;;;;;;1;1;1;1;1;;;;;1;1;0;;;;;;;;;;;;; -input['cellular'];;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;rev4.108_h12_0bd54110_cellularmagpie_c200_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz;rev4.108_h12_6819938d_cellularmagpie_c200_MRI-ESM2-0-ssp126_lpjml-8e6c5eb1.tgz;rev4.108_h12_1b5c3817_cellularmagpie_c200_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz;rev4.108_h12_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;rev4.108_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz;rev4.108_h12_09a63995_cellularmagpie_c200_MRI-ESM2-0-ssp585_lpjml-8e6c5eb1.tgz;; +input['cellular'];;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;rev4.109_h12_0bd54110_cellularmagpie_c200_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz;rev4.109_h12_6819938d_cellularmagpie_c200_MRI-ESM2-0-ssp126_lpjml-8e6c5eb1.tgz;rev4.109_h12_1b5c3817_cellularmagpie_c200_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz;rev4.109_h12_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;rev4.109_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz;rev4.109_h12_09a63995_cellularmagpie_c200_MRI-ESM2-0-ssp585_lpjml-8e6c5eb1.tgz;; magicc_emis_scen;;;;;;;;;;;;;;;;;;;;;;REMIND_generic_C_SSP2EU-DSPkB650-DS_betax-rem-5.mif;REMIND_generic_C_SSP2EU-DSPkB650-DS_betax-rem-5.mif;REMIND_generic_C_SSP2EU-DSPkB650-DS_betax-rem-5.mif;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/scripts/start/projects/paper_peatlandTax.R b/scripts/start/projects/paper_peatlandTax.R index c81b4ac47b..15d7f39958 100644 --- a/scripts/start/projects/paper_peatlandTax.R +++ b/scripts/start/projects/paper_peatlandTax.R @@ -23,126 +23,108 @@ source("scripts/start_functions.R") source("config/default.cfg") # create additional information to describe the runs -cfg$info$flag <- "V14LRc500" +cfg$info$flag <- "PTax02H16" cfg$results_folder <- "output/:title:" cfg$results_folder_highres <- "output" cfg$force_replace <- TRUE -cfg$qos <- "priority_maxMem" -#cfg$qos <- "standby_maxMem_dayMax" +#cfg$qos <- "priority_maxMem" +cfg$qos <- "standby_maxMem_dayMax" # support function to create standardized title .title <- function(cfg, ...) return(paste(cfg$info$flag, sep="_",...)) +cfg$repositories <- append(list("https://rse.pik-potsdam.de/data/magpie/public"=NULL, + "./patch_inputdata"=NULL), + getOption("magpie_repos")) -# EUR <- "ALB,AUT,BEL,BGR,CYP,CZE,DEU,DNK,ESP,EST,FIN,FRA,FRO, -# GBR,GGY,GIB,GRC,HRV,HUN,IMN,IRL,ITA,JEY,LTU,LUX,LVA,MLT, -# NLD,POL,PRT,ROU,SVK,SVN,SWE" +cfg$input['regional'] <- "rev4.108_36f73207_magpie.tgz" +cfg$input['validation'] <- "rev4.108_36f73207_validation.tgz" +cfg$input['calibration'] <- "calibration_H16_14Jun24.tgz" +cfg$input['zzzpatchGHGprices'] <- "patchGHGprices.tgz" -ssp <- "SSP2" -#cfg$input['calibration'] <- "calibration_H12c400_16Apr24.tgz" -cfg$input['calibration'] <- "calibration_H12c500_15Apr24.tgz" cfg$gms$c_timesteps <- "5year" -limitAff <- function(cfg,gdx) { - #download input files with high resolution - download_and_update(cfg) - - # #get tau from low resolution run - # ov_tau <- readGDX(gdx, "ov_tau",select=list(type="level")) - # write.magpie(ov_tau,"modules/13_tc/input/f13_tau_scenario.csv") - # cfg$gms$tc <- "exo" - - #get regional afforestation patterns from low resolution run with c200 - aff <- dimSums(landForestry(gdx)[,,c("aff","ndc")],dim=3) - #Take away initial NDC area for consistency with global afforestation limit - aff <- aff-setYears(aff[,1,],NULL) - #calculate maximum regional afforestation over time - aff_max <- setYears(aff[,1,],NULL) - for (r in getRegions(aff)) { - aff_max[r,,] <- max(aff[r,,]) - } - aff_max[aff_max < 0] <- 0 - write.magpie(aff_max,"modules/32_forestry/input/f32_max_aff_area.cs4") - cfg$gms$s32_max_aff_area_glo <- 0 - #check - if(cfg$gms$s32_max_aff_area < Inf) { - indicator <- abs(sum(aff_max)-cfg$gms$s32_max_aff_area) - if(indicator > 1e-06) warning(paste("Global and regional afforestation limit differ by",indicator,"Mha")) - } - return(cfg) +cfg$output <- c(cfg$output, "extra/highres") +ssp <- "SSP2" +cfg <- setScenario(cfg,c(ssp,"NPI","rcp7p0")) +cfg$input['cellular'] <- "rev4.108_36f73207_2ca80312_cellularmagpie_c400_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz" +cfg$gms$c60_2ndgen_biodem <- paste0("R32M46-", if (ssp=="SSP2") "SSP2EU" else ssp,"-NPi") +cfg$gms$c56_pollutant_prices_noselect <- "T0-CO2" +cfg$gms$policy_countries56 <- isoCountriesEUR + +calc_ghgprice <- function() { + T0 <- read.magpie("modules/56_ghg_policy/input/f56_pollutant_prices.cs3") + T0 <- collapseNames(T0[,,getNames(T0,dim=2)[1]]) + T0[,,] <- 0 + + #T200 200 USD/tCO2 in 2050 + T200 <- new.magpie(getRegions(T0),c(seq(1995,2025,by=5),2050,2100,2150),getNames(T0),fill = 0) + T200[,"y2025","co2_c"] <- 0 + T200[,"y2050","co2_c"] <- 200 + T200[,"y2100","co2_c"] <- 200 + T200[,"y2150","co2_c"] <- 200 + T200 <- time_interpolate(T200,seq(2015,2100,by=5),TRUE) + T200 <- time_interpolate(T200,seq(2100,2150,by=5),TRUE) + T200[,,"ch4"] <- T200[,,"co2_c"]*28 + T200[,,"n2o_n_direct"] <- T200[,,"co2_c"]*265*44/28 + T200[,,"n2o_n_indirect"] <- T200[,,"co2_c"]*265*44/28 + T200[,,"co2_c"] <- T200[,,"co2_c"]*44/12 + + T50 <- T200 * 0.25 + T100 <- T200 * 0.5 + + GHG <- mbind(add_dimension(T0, dim = 3.2, add = "scen", nm = "T0-GHG"), + add_dimension(T50, dim = 3.2, add = "scen", nm = "T50-GHG"), + add_dimension(T100, dim = 3.2, add = "scen", nm = "T100-GHG"), + add_dimension(T200, dim = 3.2, add = "scen", nm = "T200-GHG")) + + CO2 <- GHG + CO2[,,c("ch4", "n2o_n_direct", "n2o_n_indirect")] <- 0 + getNames(CO2,dim=2) <- gsub("GHG","CO2", getNames(CO2,dim=2)) + + GHGCH4GWP20 <- GHG + GHGCH4GWP20[,,"ch4"] <- GHGCH4GWP20[,,"ch4"]/28*84 + getNames(GHGCH4GWP20,dim=2) <- gsub("GHG","GHG-CH4GWP20", getNames(GHGCH4GWP20,dim=2)) + + GHG <- mbind(CO2, GHG, GHGCH4GWP20) + if (!dir.exists("./patch_inputdata")) dir.create("./patch_inputdata") + if (dir.exists("./patch_inputdata/patchGHGprices")) unlink("./patch_inputdata/patchGHGprices", recursive = TRUE) + dir.create("./patch_inputdata/patchGHGprices") + write.magpie(GHG,file_name = "patch_inputdata/patchGHGprices/f56_pollutant_prices.cs3") + tardir("patch_inputdata/patchGHGprices", "patch_inputdata/patchGHGprices.tgz") + + # scen56 <- magclass::read.magpie("modules/56_ghg_policy/input/f56_emis_policy.csv",file_type = "cs3") + # scen56 <- magclass::getNames(scen56,dim=1) + # + # sets <- list(list(name = "ghgscen56", + # desc = "ghg price scenarios", + # items = ghgscen56), + # list(name = "scen56", + # desc = "emission policy scenarios", + # items = scen56)) + # gms::writeSets(sets, "modules/56_ghg_policy/price_aug22/sets.gms") + unlink("patch_inputdata/patchGHGprices", recursive=TRUE) + return(getNames(GHG, dim = 2)) } +ghgscen56 <- calc_ghgprice() -cfg$output <- c("rds_report") -cfg$sequential <- TRUE -cfg$title <- .title(cfg, paste(ssp,"1p5deg","PricePeatOff","AffEndo",sep="-")) -cfg <- setScenario(cfg,c(ssp,"NDC","rcp1p9","ForestryEndo")) -#cfg$input['cellular'] <- "rev4.104_h12_6aa915b6_cellularmagpie_c400_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz" -cfg$input['cellular'] <- "rev4.104_h12_4c83b5e5_cellularmagpie_c500_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz" -cfg$gms$c56_mute_ghgprices_until <- "y2030" -cfg$gms$c56_pollutant_prices <- paste0("R32M46-",ifelse(ssp=="SSP2",paste0(ssp,"EU"),ssp),"-PkBudg650") -cfg$gms$c60_2ndgen_biodem <- paste0("R32M46-",ifelse(ssp=="SSP2",paste0(ssp,"EU"),ssp),"-PkBudg650") -cfg$gms$c56_emis_policy <- "reddnatveg_nosoil_nopeat" -start_run(cfg, codeCheck = FALSE) -cfg$sequential <- FALSE - -PricePeatOff <- .title(cfg, paste(ssp,"1p5deg","PricePeatOff","AffEndo",sep="-")) - -#limitAff runs -cfg$output <- c("extra/highres", "extra/disaggregation", "rds_report", "rds_report_iso") - -cfg$title <- .title(cfg, paste(ssp,"NDC",sep="-")) -cfg <- setScenario(cfg,c(ssp,"NDC","rcp4p5","ForestryEndo")) -#cfg$input['cellular'] <- "rev4.104_h12_3d941455_cellularmagpie_c400_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz" -cfg$input['cellular'] <- "rev4.104_h12_9ab12c13_cellularmagpie_c500_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz" -cfg <- limitAff(cfg,file.path("output",PricePeatOff,"fulldata.gdx")) +cfg$title <- .title(cfg, paste(ssp,"Ref",sep="-")) cfg$gms$c56_mute_ghgprices_until <- "y2150" -cfg$gms$c56_pollutant_prices <- paste0("R32M46-",ifelse(ssp=="SSP2",paste0(ssp,"EU"),ssp),"-NDC") -cfg$gms$c60_2ndgen_biodem <- paste0("R32M46-",ifelse(ssp=="SSP2",paste0(ssp,"EU"),ssp),"-NDC") +cfg$gms$c56_pollutant_prices <- "T0-CO2" cfg$gms$c56_emis_policy <- "reddnatveg_nosoil_nopeat" +download_and_update(cfg) start_run(cfg, codeCheck = FALSE) -cfg$title <- .title(cfg, paste(ssp,"1p5deg","PricePeatOff",sep="-")) -cfg <- setScenario(cfg,c(ssp,"NDC","rcp1p9","ForestryEndo")) -#cfg$input['cellular'] <- "rev4.104_h12_6aa915b6_cellularmagpie_c400_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz" -cfg$input['cellular'] <- "rev4.104_h12_4c83b5e5_cellularmagpie_c500_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz" -cfg <- limitAff(cfg,file.path("output",PricePeatOff,"fulldata.gdx")) -cfg$gms$c56_mute_ghgprices_until <- "y2030" -cfg$gms$c56_pollutant_prices <- paste0("R32M46-",ifelse(ssp=="SSP2",paste0(ssp,"EU"),ssp),"-PkBudg650") -cfg$gms$c60_2ndgen_biodem <- paste0("R32M46-",ifelse(ssp=="SSP2",paste0(ssp,"EU"),ssp),"-PkBudg650") -cfg$gms$c56_emis_policy <- "reddnatveg_nosoil_nopeat" -start_run(cfg, codeCheck = FALSE) - -cfg$title <- .title(cfg, paste(ssp,"1p5deg","PricePeatCO2",sep="-")) -cfg <- setScenario(cfg,c(ssp,"NDC","rcp1p9","ForestryEndo")) -#cfg$input['cellular'] <- "rev4.104_h12_6aa915b6_cellularmagpie_c400_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz" -cfg$input['cellular'] <- "rev4.104_h12_4c83b5e5_cellularmagpie_c500_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz" -cfg <- limitAff(cfg,file.path("output",PricePeatOff,"fulldata.gdx")) -cfg$gms$c56_mute_ghgprices_until <- "y2030" -cfg$gms$c56_pollutant_prices <- paste0("R32M46-",ifelse(ssp=="SSP2",paste0(ssp,"EU"),ssp),"-PkBudg650") -cfg$gms$c60_2ndgen_biodem <- paste0("R32M46-",ifelse(ssp=="SSP2",paste0(ssp,"EU"),ssp),"-PkBudg650") -cfg$gms$c56_emis_policy <- "reddnatveg_nosoil_peatCO2only" -start_run(cfg, codeCheck = FALSE) -cfg$title <- .title(cfg, paste(ssp,"1p5deg","PricePeatGHG",sep="-")) -cfg <- setScenario(cfg,c(ssp,"NDC","rcp1p9","ForestryEndo")) -#cfg$input['cellular'] <- "rev4.104_h12_6aa915b6_cellularmagpie_c400_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz" -cfg$input['cellular'] <- "rev4.104_h12_4c83b5e5_cellularmagpie_c500_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz" -cfg <- limitAff(cfg,file.path("output",PricePeatOff,"fulldata.gdx")) -cfg$gms$c56_mute_ghgprices_until <- "y2030" -cfg$gms$c56_pollutant_prices <- paste0("R32M46-",ifelse(ssp=="SSP2",paste0(ssp,"EU"),ssp),"-PkBudg650") -cfg$gms$c60_2ndgen_biodem <- paste0("R32M46-",ifelse(ssp=="SSP2",paste0(ssp,"EU"),ssp),"-PkBudg650") -cfg$gms$c56_emis_policy <- "reddnatveg_nosoil" -start_run(cfg, codeCheck = FALSE) +cfg$gms$c56_mute_ghgprices_until <- "y2025" -cfg$title <- .title(cfg, paste(ssp,"1p5deg","PricePeatGHG_CH4GWP20",sep="-")) -cfg <- setScenario(cfg,c(ssp,"NDC","rcp1p9","ForestryEndo")) -#cfg$input['cellular'] <- "rev4.104_h12_6aa915b6_cellularmagpie_c400_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz" -cfg$input['cellular'] <- "rev4.104_h12_4c83b5e5_cellularmagpie_c500_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz" -cfg <- limitAff(cfg,file.path("output",PricePeatOff,"fulldata.gdx")) -cfg$gms$c56_mute_ghgprices_until <- "y2030" -cfg$gms$c56_pollutant_prices <- paste0("R32M46-",ifelse(ssp=="SSP2",paste0(ssp,"EU"),ssp),"-PkBudg650") -cfg$gms$c60_2ndgen_biodem <- paste0("R32M46-",ifelse(ssp=="SSP2",paste0(ssp,"EU"),ssp),"-PkBudg650") -cfg$gms$c56_emis_policy <- "reddnatveg_nosoil_CH4GWP20" -start_run(cfg, codeCheck = FALSE) +for (tax in ghgscen56) { + for (peat in c("peatOff", "peatOn")) { + cfg$title <- .title(cfg, paste(ssp,tax,peat,sep="-")) + cfg$gms$c56_pollutant_prices <- tax + cfg$gms$c56_emis_policy <- if (peat=="peatOff") "reddnatveg_nosoil_nopeat" else "reddnatveg_nosoil" + start_run(cfg, codeCheck = FALSE) + } +} diff --git a/scripts/start/projects/project_ABCDR.R b/scripts/start/projects/project_ABCDR.R new file mode 100644 index 0000000000..861376cf02 --- /dev/null +++ b/scripts/start/projects/project_ABCDR.R @@ -0,0 +1,84 @@ +# ---------------------------------------------------------- +# description: ABCDR Project runs +# position: 5 +# ---------------------------------------------------------- + +## Load lucode2 and gms to use setScenario later +library(lucode2) +library(gms) +library(magclass) +library(gdx) + +# Load start_run(cfg) function which is needed to start MAgPIE runs +source("scripts/start_functions.R") + +# Source default cfg. This loads the object "cfg" in R environment +source("config/default.cfg") + +#download default input data +#download_and_update(cfg) + +# create additional information to describe the runs +cfg$info$flag <- "ABCDR04" + +cfg$output <- c("rds_report") # Only run rds_report after model run +cfg$results_folder <- "output/:title:" +cfg$force_replace <- TRUE +cfg$force_download <- FALSE + +cfg$qos <- "standby_maxMem_dayMax" +#cfg$qos <- "priority" + +# support function to create standardized title +.title <- function(cfg, ...) return(paste(cfg$info$flag, sep="_",...)) + + +cfg$input['regional'] <- "rev4.108_36f73207_magpie.tgz" +cfg$input['validation'] <- "rev4.108_36f73207_validation.tgz" +cfg$input['calibration'] <- "calibration_H16_14Jun24.tgz" +cfg$input['cellular'] <- "rev4.108_36f73207_2ca80312_cellularmagpie_c400_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz" + +ssp <- "SSP2" + +cfg$gms$cropland <- "detail_apr24" +# cfg$gms$croparea <- "detail_apr24" + + +cfg$gms$scen_countries15 <- isoCountriesEUR +cfg$gms$policy_countries29 <- isoCountriesEUR +cfg$gms$policy_countries30 <- isoCountriesEUR + +cfg$gms$s29_treecover_penalty <- 5000 +cfg$gms$s30_betr_penalty <- 5000 + +for (pol in c("NDC","1p5deg")) { + for (diet in c("dietDefault","dietShift")) { + for (AFS in c("SRC","treeCover")) { + for (shr in c(0, 0.01, 0.05, 0.1, 0.2)) { + cfg$title <- .title(cfg, paste(ssp,pol,diet,paste0(AFS,sprintf("%02d",shr*100)),sep="-")) + if (pol == "NDC") { + cfg <- setScenario(cfg,c(ssp,"NDC","rcp4p5")) + cfg$input['cellular'] <- "rev4.108_36f73207_3d941455_cellularmagpie_c400_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz" + cfg$gms$c56_mute_ghgprices_until <- "y2150" + cfg$gms$c56_pollutant_prices <- paste0("R32M46-", if (ssp=="SSP2") "SSP2EU" else ssp,"-NDC") + cfg$gms$c60_2ndgen_biodem <- paste0("R32M46-", if (ssp=="SSP2") "SSP2EU" else ssp,"-NDC") + } else if (pol == "1p5deg") { + cfg <- setScenario(cfg,c(ssp,"NDC","rcp1p9")) + cfg$input['cellular'] <- "rev4.108_36f73207_6aa915b6_cellularmagpie_c400_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz" + cfg$gms$c56_mute_ghgprices_until <- "y2030" + cfg$gms$c56_pollutant_prices <- paste0("R32M46-", if (ssp=="SSP2") "SSP2EU" else ssp,"-PkBudg650") + cfg$gms$c60_2ndgen_biodem <- paste0("R32M46-", if (ssp=="SSP2") "SSP2EU" else ssp,"-PkBudg650") + } + if (diet == "dietShift") cfg <- setScenario(cfg,"eat_lancet_diet") + if (AFS == "SRC") { + cfg$gms$s29_treecover_target <- 0 + cfg$gms$s30_betr_target <- shr + } else if (AFS == "treeCover") { + cfg$gms$s29_treecover_target <- shr + cfg$gms$s30_betr_target <- 0 + } + start_run(cfg, codeCheck = FALSE) + } + } + } +} From 96b833e8620db83769343076a7e38a4c33aba9b6 Mon Sep 17 00:00:00 2001 From: florianh Date: Mon, 17 Jun 2024 23:09:48 +0200 Subject: [PATCH 131/133] update input data revision --- CHANGELOG.md | 1 + config/scenario_fsec.csv | 6 +++--- scripts/start/projects/paper_peatlandTax.R | 6 +++--- scripts/start/projects/project_ABCDR.R | 10 +++++----- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 82ff4e80a6..b7a0b5915f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **32_forestry** avoid infeasibilities due to very small numbers - **35_natveg** avoid infeasibilities due to very small numbers - **44_biodiversity** Fixing to SSP2 parameters until 2025 was not working +- **config** update to input data rev4.109. In the previous rev4.108, GDP had a wrong unit. diff --git a/config/scenario_fsec.csv b/config/scenario_fsec.csv index d07aabcc7d..9bf407fa60 100644 --- a/config/scenario_fsec.csv +++ b/config/scenario_fsec.csv @@ -76,9 +76,9 @@ gms$s62_max_dem_bioplastic;0;;;;400;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$c70_fac_req_regr;reg;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$c70_feed_scen;;;;;;;;;;;;;;;;;;ssp1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; gms$c73_build_demand;;;;;;;;;;;;;;;;;;;;;;;;50pc;;;;;;;;;;;;;;;;;;;;;;;;;;; -input['cellular'];rev4.108_FSEC_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;rev4.108_FSEC_0bd54110_cellularmagpie_c200_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz;rev4.108_FSEC_6819938d_cellularmagpie_c200_MRI-ESM2-0-ssp126_lpjml-8e6c5eb1.tgz;;rev4.108_FSEC_1b5c3817_cellularmagpie_c200_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz;rev4.108_FSEC_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;rev4.108_FSEC_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz;rev4.108_FSEC_09a63995_cellularmagpie_c200_MRI-ESM2-0-ssp585_lpjml-8e6c5eb1.tgz;;; -input['regional'];rev4.108_FSEC_magpie.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -input['validation'];rev4.108_FSEC_validation.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +input['cellular'];rev4.109_FSEC_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;rev4.109_FSEC_0bd54110_cellularmagpie_c200_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz;rev4.109_FSEC_6819938d_cellularmagpie_c200_MRI-ESM2-0-ssp126_lpjml-8e6c5eb1.tgz;;rev4.109_FSEC_1b5c3817_cellularmagpie_c200_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz;rev4.109_FSEC_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;rev4.109_FSEC_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz;rev4.109_FSEC_09a63995_cellularmagpie_c200_MRI-ESM2-0-ssp585_lpjml-8e6c5eb1.tgz;;; +input['regional'];rev4.109_FSEC_magpie.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +input['validation'];rev4.109_FSEC_validation.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; input['additional'];additional_data_rev4.51.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; input['calibration'];calibration_FSEC_26Mar24.tgz;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; magicc_emis_scen;bjoernAR6_C_SSP2-NDC.mif;;;bjoernAR6_C_SSP2-PkBudg900.mif;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;bjoernAR6_C_SSP1-NDC.mif;;;;;;;;;;;;bjoernAR6_C_RemSDP-900-MagSSP1.mif;; diff --git a/scripts/start/projects/paper_peatlandTax.R b/scripts/start/projects/paper_peatlandTax.R index 15d7f39958..ad4e0209b4 100644 --- a/scripts/start/projects/paper_peatlandTax.R +++ b/scripts/start/projects/paper_peatlandTax.R @@ -38,8 +38,8 @@ cfg$repositories <- append(list("https://rse.pik-potsdam.de/data/magpie/public"= "./patch_inputdata"=NULL), getOption("magpie_repos")) -cfg$input['regional'] <- "rev4.108_36f73207_magpie.tgz" -cfg$input['validation'] <- "rev4.108_36f73207_validation.tgz" +cfg$input['regional'] <- "rev4.109_36f73207_magpie.tgz" +cfg$input['validation'] <- "rev4.109_36f73207_validation.tgz" cfg$input['calibration'] <- "calibration_H16_14Jun24.tgz" cfg$input['zzzpatchGHGprices'] <- "patchGHGprices.tgz" @@ -48,7 +48,7 @@ cfg$gms$c_timesteps <- "5year" cfg$output <- c(cfg$output, "extra/highres") ssp <- "SSP2" cfg <- setScenario(cfg,c(ssp,"NPI","rcp7p0")) -cfg$input['cellular'] <- "rev4.108_36f73207_2ca80312_cellularmagpie_c400_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz" +cfg$input['cellular'] <- "rev4.109_36f73207_2ca80312_cellularmagpie_c400_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz" cfg$gms$c60_2ndgen_biodem <- paste0("R32M46-", if (ssp=="SSP2") "SSP2EU" else ssp,"-NPi") cfg$gms$c56_pollutant_prices_noselect <- "T0-CO2" cfg$gms$policy_countries56 <- isoCountriesEUR diff --git a/scripts/start/projects/project_ABCDR.R b/scripts/start/projects/project_ABCDR.R index 861376cf02..fab4fde8b5 100644 --- a/scripts/start/projects/project_ABCDR.R +++ b/scripts/start/projects/project_ABCDR.R @@ -33,10 +33,10 @@ cfg$qos <- "standby_maxMem_dayMax" .title <- function(cfg, ...) return(paste(cfg$info$flag, sep="_",...)) -cfg$input['regional'] <- "rev4.108_36f73207_magpie.tgz" -cfg$input['validation'] <- "rev4.108_36f73207_validation.tgz" +cfg$input['regional'] <- "rev4.109_36f73207_magpie.tgz" +cfg$input['validation'] <- "rev4.109_36f73207_validation.tgz" cfg$input['calibration'] <- "calibration_H16_14Jun24.tgz" -cfg$input['cellular'] <- "rev4.108_36f73207_2ca80312_cellularmagpie_c400_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz" +cfg$input['cellular'] <- "rev4.109_36f73207_2ca80312_cellularmagpie_c400_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz" ssp <- "SSP2" @@ -58,13 +58,13 @@ for (pol in c("NDC","1p5deg")) { cfg$title <- .title(cfg, paste(ssp,pol,diet,paste0(AFS,sprintf("%02d",shr*100)),sep="-")) if (pol == "NDC") { cfg <- setScenario(cfg,c(ssp,"NDC","rcp4p5")) - cfg$input['cellular'] <- "rev4.108_36f73207_3d941455_cellularmagpie_c400_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz" + cfg$input['cellular'] <- "rev4.109_36f73207_3d941455_cellularmagpie_c400_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz" cfg$gms$c56_mute_ghgprices_until <- "y2150" cfg$gms$c56_pollutant_prices <- paste0("R32M46-", if (ssp=="SSP2") "SSP2EU" else ssp,"-NDC") cfg$gms$c60_2ndgen_biodem <- paste0("R32M46-", if (ssp=="SSP2") "SSP2EU" else ssp,"-NDC") } else if (pol == "1p5deg") { cfg <- setScenario(cfg,c(ssp,"NDC","rcp1p9")) - cfg$input['cellular'] <- "rev4.108_36f73207_6aa915b6_cellularmagpie_c400_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz" + cfg$input['cellular'] <- "rev4.109_36f73207_6aa915b6_cellularmagpie_c400_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz" cfg$gms$c56_mute_ghgprices_until <- "y2030" cfg$gms$c56_pollutant_prices <- paste0("R32M46-", if (ssp=="SSP2") "SSP2EU" else ssp,"-PkBudg650") cfg$gms$c60_2ndgen_biodem <- paste0("R32M46-", if (ssp=="SSP2") "SSP2EU" else ssp,"-PkBudg650") From 38d34ea17667a00d35111583770280d4f4f28d7f Mon Sep 17 00:00:00 2001 From: florianh Date: Mon, 17 Jun 2024 23:45:34 +0200 Subject: [PATCH 132/133] update input data --- scripts/start/projects/paper_peatlandTax.R | 4 ++-- scripts/start/projects/project_ABCDR.R | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/start/projects/paper_peatlandTax.R b/scripts/start/projects/paper_peatlandTax.R index ad4e0209b4..984c321eb5 100644 --- a/scripts/start/projects/paper_peatlandTax.R +++ b/scripts/start/projects/paper_peatlandTax.R @@ -23,7 +23,7 @@ source("scripts/start_functions.R") source("config/default.cfg") # create additional information to describe the runs -cfg$info$flag <- "PTax02H16" +cfg$info$flag <- "PTax03H16" cfg$results_folder <- "output/:title:" cfg$results_folder_highres <- "output" @@ -48,7 +48,7 @@ cfg$gms$c_timesteps <- "5year" cfg$output <- c(cfg$output, "extra/highres") ssp <- "SSP2" cfg <- setScenario(cfg,c(ssp,"NPI","rcp7p0")) -cfg$input['cellular'] <- "rev4.109_36f73207_2ca80312_cellularmagpie_c400_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz" +cfg$input['cellular'] <- "rev4.109_36f73207_44a213b6_cellularmagpie_c400_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1_clusterweight-ba4466a8.tgz" cfg$gms$c60_2ndgen_biodem <- paste0("R32M46-", if (ssp=="SSP2") "SSP2EU" else ssp,"-NPi") cfg$gms$c56_pollutant_prices_noselect <- "T0-CO2" cfg$gms$policy_countries56 <- isoCountriesEUR diff --git a/scripts/start/projects/project_ABCDR.R b/scripts/start/projects/project_ABCDR.R index fab4fde8b5..b21af3cdf6 100644 --- a/scripts/start/projects/project_ABCDR.R +++ b/scripts/start/projects/project_ABCDR.R @@ -19,7 +19,7 @@ source("config/default.cfg") #download_and_update(cfg) # create additional information to describe the runs -cfg$info$flag <- "ABCDR04" +cfg$info$flag <- "ABCDR05" cfg$output <- c("rds_report") # Only run rds_report after model run cfg$results_folder <- "output/:title:" @@ -36,7 +36,7 @@ cfg$qos <- "standby_maxMem_dayMax" cfg$input['regional'] <- "rev4.109_36f73207_magpie.tgz" cfg$input['validation'] <- "rev4.109_36f73207_validation.tgz" cfg$input['calibration'] <- "calibration_H16_14Jun24.tgz" -cfg$input['cellular'] <- "rev4.109_36f73207_2ca80312_cellularmagpie_c400_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz" +cfg$input['cellular'] <- "rev4.109_36f73207_44a213b6_cellularmagpie_c400_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1_clusterweight-ba4466a8.tgz" ssp <- "SSP2" @@ -58,13 +58,13 @@ for (pol in c("NDC","1p5deg")) { cfg$title <- .title(cfg, paste(ssp,pol,diet,paste0(AFS,sprintf("%02d",shr*100)),sep="-")) if (pol == "NDC") { cfg <- setScenario(cfg,c(ssp,"NDC","rcp4p5")) - cfg$input['cellular'] <- "rev4.109_36f73207_3d941455_cellularmagpie_c400_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz" + cfg$input['cellular'] <- "rev4.109_36f73207_30c9dc61_cellularmagpie_c400_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1_clusterweight-ba4466a8.tgz" cfg$gms$c56_mute_ghgprices_until <- "y2150" cfg$gms$c56_pollutant_prices <- paste0("R32M46-", if (ssp=="SSP2") "SSP2EU" else ssp,"-NDC") cfg$gms$c60_2ndgen_biodem <- paste0("R32M46-", if (ssp=="SSP2") "SSP2EU" else ssp,"-NDC") } else if (pol == "1p5deg") { cfg <- setScenario(cfg,c(ssp,"NDC","rcp1p9")) - cfg$input['cellular'] <- "rev4.109_36f73207_6aa915b6_cellularmagpie_c400_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz" + cfg$input['cellular'] <- "rev4.109_36f73207_bc624950_cellularmagpie_c400_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1_clusterweight-ba4466a8.tgz" cfg$gms$c56_mute_ghgprices_until <- "y2030" cfg$gms$c56_pollutant_prices <- paste0("R32M46-", if (ssp=="SSP2") "SSP2EU" else ssp,"-PkBudg650") cfg$gms$c60_2ndgen_biodem <- paste0("R32M46-", if (ssp=="SSP2") "SSP2EU" else ssp,"-PkBudg650") From 57638fca458f6291cf0181b95eb195479dcd2664 Mon Sep 17 00:00:00 2001 From: florianh Date: Tue, 18 Jun 2024 09:39:39 +0200 Subject: [PATCH 133/133] changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b7a0b5915f..20324851e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,7 +26,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **32_forestry** avoid infeasibilities due to very small numbers - **35_natveg** avoid infeasibilities due to very small numbers - **44_biodiversity** Fixing to SSP2 parameters until 2025 was not working -- **config** update to input data rev4.109. In the previous rev4.108, GDP had a wrong unit. +- **config** update to input data rev4.109. In the previous rev4.108, MER GDP was wrong and was identical to PPP GDP