Skip to content

Commit

Permalink
Merge branch 'develop_new' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
mppalves committed Apr 14, 2024
2 parents 7f8229d + bd76178 commit abec054
Show file tree
Hide file tree
Showing 11 changed files with 213 additions and 429 deletions.
10 changes: 5 additions & 5 deletions config/default.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ cfg <- list()
#### Main settings ####

# short description of the actual run
cfg$title <- "default"
cfg$title <- "test33_merged_new_inputs_luh_2015"

# path to the submodel to be used relative to main model folder
cfg$model <- "main.gms" #def = "main.gms"
Expand All @@ -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_grassland_mar22.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,
Expand Down Expand Up @@ -273,7 +273,7 @@ cfg$gms$tc <- "endo_jan22" # def = endo_jan22
cfg$gms$c13_tccost <- "medium" # def = medium

# * ignore historical tau (1) or use it as lower bound (0)
cfg$gms$s13_ignore_tau_historical <- 1 # def = 1
cfg$gms$s13_ignore_tau_historical <- 0 # def = 1

# * Maximum regional tech cost expressed as share of regional GDP
# * A meaningful value would be 0.002. However, this bound causes infeasibilities in some cases.
Expand Down Expand Up @@ -328,7 +328,7 @@ cfg$gms$s14_degradation <- 0 # def = 0
# must be supplied in the input directory, or yields must be recalibrated during preprocessing.)
# This switch should only be activated for penalty_apr22 crop realization.
# For other realizations, it is recommended not to use this yield calibration.
cfg$gms$s14_use_yield_calib <- 0 # def = 0
cfg$gms$s14_use_yield_calib <- 0 # def = 1

# Include a minimum yield for wood harvest in secondary vegetation (tDM per ha per yr).
# Age classes with wood yields below this threshold have a production of zero.
Expand Down Expand Up @@ -737,7 +737,7 @@ cfg$gms$land_snv <- "secdforest, forestry, past, other" #def = "secdforest, f
# * (endo_jun13): dynamic pasture
# * (grasslands_apr22): Grassland management separating managed pastures from rangelands
# NOTE: It is recommended to recalibrate the model when changing this setting!
cfg$gms$past <- "endo_jun13" # def = endo_jun13
cfg$gms$past <- "grasslands_apr22" # def = endo_jun13

# * Factor requirements (USD04 per ton DM)
cfg$gms$s31_fac_req_past <- 1 # def = 1
Expand Down
60 changes: 30 additions & 30 deletions main.gms
Original file line number Diff line number Diff line change
Expand Up @@ -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.99_h12_magpie.tgz
*
* Used data set: rev4.104_h12_magpie.tgz
* md5sum: NA
* Repository: scp://cluster.pik-potsdam.de/p/projects/rd3mod/inputdata/output
*
* Used data set: rev4.99_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.99_h12_validation.tgz
* Repository: https://rse.pik-potsdam.de/data/magpie/public
*
* Used data set: rev4.104_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: additional_data_rev4.47.tgz
* Repository: https://rse.pik-potsdam.de/data/magpie/public
*
* Used data set: rev4.104_h12_validation.tgz
* md5sum: NA
* Repository: scp://cluster.pik-potsdam.de/p/projects/landuse/data/input/archive
*
* Used data set: calibration_H12_per_ton_fao_may22_glo_08Aug23.tgz
* Repository: https://rse.pik-potsdam.de/data/magpie/public
*
* Used data set: additional_data_rev4.48.tgz
* md5sum: NA
* Repository: https://rse.pik-potsdam.de/data/magpie/public
*
*
* Used data set: calibration_H12_grassland_mar22.tgz
* md5sum: 99507cd40ca11b541b3c6120208cca2d
* Repository: /p/projects/landuse/data/input/calibration
*
* 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.99
*
*
* Regions data revision: 4.104
*
* lpj2magpie settings:
* * LPJmL data: MRI-ESM2-0:ssp370
* * Revision: 4.99
*
* * Revision: 4.104
*
* aggregation settings:
* * Input resolution: 0.5
* * Output resolution: c200
Expand All @@ -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): Wed Feb 7 15:35:14 2024
*
*
*
* Last modification (input data): Sat Apr 13 23:04:55 2024
*
*###################### R SECTION END (VERSION INFO) ###########################

$offupper
Expand All @@ -221,7 +221,7 @@ $offlisting

$setglobal c_timesteps coup2100
$setglobal c_past till_2010
$setglobal c_title default
$setglobal c_title test33_merged_new_inputs_luh_2015

scalars
s_use_gdx use of gdx files / 0 /
Expand Down Expand Up @@ -250,7 +250,7 @@ $setglobal land_conservation area_based_apr22
$setglobal ageclass feb21

$setglobal crop endo_apr21
$setglobal past endo_jun13
$setglobal past grasslands_apr22

$setglobal forestry dynamic_feb21

Expand Down
2 changes: 1 addition & 1 deletion modules/13_tc/endo_jan22/input.gms
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


scalars
s13_ignore_tau_historical ignore historical tau (1) or use it as lower bound (0) (binary) / 1 /
s13_ignore_tau_historical ignore historical tau (1) or use it as lower bound (0) (binary) / 0 /
s13_max_gdp_shr Maximum tech cost as share of regional GDP / Inf /
;

Expand Down
2 changes: 2 additions & 0 deletions modules/31_past/grasslands_apr22/declarations.gms
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ i31_grassl_areas(t_all,j) Celullar grassland areas
i31_lambda_grass(t,i,grassland) Grassland Scaling factor for non-linear management calibration (1)
i31_grassl_yld_hist_reg(t,i,grassland) Grassland FAO yields per region at the historical referende year (tDM per ha)
i31_grass_hist_yld(t_all,i, grassland) FAO gassland yields (tDM per ha)
p31_pastr_suit_sf(j) Pasture suitability scaling factor (1)
pc31_grasslands_conversion_cost(t,j) Adjusted expansion costs to avoid unrealistic exchange between pastr and range in the first time step (USD05MER per ha)
;

*#################### R SECTION START (OUTPUT DECLARATIONS) ####################
Expand Down
8 changes: 4 additions & 4 deletions modules/31_past/grasslands_apr22/equations.gms
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ q31_pasture_areas(j2)..
*' in comparison with areas in the previous time step 'pc31_grass'.

q31_expansion_cost(j2,grassland) ..
v31_cost_grass_expansion(j2, grassland) =g=
(v31_grass_area(j2, grassland) - pc31_grass(j2,grassland)) * s31_cost_expansion;
v31_cost_grass_expansion(j2, grassland) =g=
(v31_grass_area(j2, grassland) - pc31_grass(j2,grassland)) * sum(ct, pc31_grasslands_conversion_cost(ct,j2));

*' Cost of production account for the cost of moving animals to grassland areas plus the costs of
*' expanding aras of production.
*' Cost of production (s31_cost_grass_prod) account for the cost of moving animals to grassland areas
*' plus the costs of expanding aras of production.

q31_cost_prod_past(i2) ..
vm_cost_prod_past(i2) =e= sum(cell(i2,j2), vm_prod(j2,"pasture")) * s31_cost_grass_prod +
Expand Down
5 changes: 0 additions & 5 deletions modules/31_past/grasslands_apr22/input.gms
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ i31_manpast_suit(t_all,j) = f31_pastr_suitability(t_all,j)
$if "%c31_grassl_yld_scenario%" == "nocc" i31_manpast_suit(t_all,j) = f31_pastr_suitability("y1995",j);
$if "%c31_grassl_yld_scenario%" == "nocc_hist" i31_manpast_suit(t_all,j)$(m_year(t_all) > sm_fix_cc) = i31_manpast_suit(t_all,j)$(m_year(t_all) = sm_fix_cc);


scalar s31_limit_calib Relative managament calibration switch (1=limited 0=pure relative) / 1 /;


table f31_grassl_yld(t_all,j,grassland,w) LPJmL potential yields per cell (rainfed only) (tDM per ha)
$ondelim
$include "./modules/31_past/input/f31_grassl_yld.cs3"
Expand All @@ -41,14 +39,11 @@ $offdelim
$if "%c31_grassl_yld_scenario%" == "nocc" f31_grassl_yld(t_all,j,grassland,w) = f31_grassl_yld("y1995",j,grassland,w);
$if "%c31_grassl_yld_scenario%" == "nocc_hist" f31_grassl_yld(t_all,j,grassland,w)$(m_year(t_all) > sm_fix_cc) = f31_grassl_yld(t_all,j,grassland,w)$(m_year(t_all) = sm_fix_cc);


table f31_grass_bio(t_all,i, grassland) Estimated regional grass biomass consumption in the past (tDM)
$ondelim
$include "./modules/31_past/input/f31_grass_bio_hist.cs3"
$offdelim;



table f31_LUH2v2(t_all,j, f31_luh) LUH2v2 land classes separating rangelands from managed pastures
$ondelim
$include "./modules/31_past/input/f31_LUH2v2.cs3"
Expand Down
14 changes: 14 additions & 0 deletions modules/31_past/grasslands_apr22/preloop.gms
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,20 @@


pc31_grass(j,grassland) = f31_LUH2v2("y1995",j,grassland);
pc31_grasslands_conversion_cost(t,j) = 0;
pc31_grasslands_conversion_cost("y1995",j) = 1000;

* This next part calibrates pasture suitability for managed pastures ("pastr") across various
* regions and time periods. It initializes the suitability for regions with no previous data using 1995
* baseline values from the LUH2v2 dataset. A scaling factor, calculated only where there is existing
* data to avoid division by zero, adjusts pasture suitability based on the ratio of estimated pastures to
* manually adjusted pastures from 1995. This factor is then applied to update suitability for all
* regions and periods. Historical data is directly assigned from LUH2v2 for past periods.

i31_manpast_suit(t_all,j)$(i31_manpast_suit(t_all,j) = 0) = f31_LUH2v2("y1995",j,"pastr");
p31_pastr_suit_sf(j) = (f31_LUH2v2("y1995",j,"pastr") / i31_manpast_suit("y1995",j))$(i31_manpast_suit("y1995",j) <> 0);
i31_manpast_suit(t_all,j) = i31_manpast_suit(t_all,j) * p31_pastr_suit_sf(j);
i31_manpast_suit(t_past,j) = f31_LUH2v2(t_past,j,"pastr");

***YIELD CORRECTION ACCOUNTING FOR REGIONAL DIFFERENCES IN MANAGEMENT***

Expand Down Expand Up @@ -44,6 +57,7 @@ pc31_grass(j,grassland) = f31_LUH2v2("y1995",j,grassland);
*' to an additive term in case of a strongly underestimated baseline. The scalar
* 's31_limit_calib' can be used to switch limited calibration on (1) and off (0).


i31_grass_yields(t,j,grassland) = f31_grassl_yld(t,j,grassland,"rainfed");
i31_grassl_areas(t_all,j) = sum(grassland, f31_LUH2v2(t_all,j,grassland));
i31_grass_hist_yld(t_past,i,grassland) = (f31_grass_bio(t_past,i, grassland) /
Expand Down
42 changes: 22 additions & 20 deletions modules/31_past/grasslands_apr22/realization.gms
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,29 @@
*** | MAgPIE License Exception, version 1.0 (see LICENSE file).
*** | Contact: magpie@pik-potsdam.de

*' @description In the grasslands_apr22 realization, grassland areas and related
*' carbon stocks are modelled endogenously. The initial spatially explicit patterns
*' of grasslands ("past") are defined in the module [10_land] by the land use input
*' data set. These areas are further divided into rangelands and managed pastures
*' under different management assumptions. For future time steps, grasslands spatial
*' distribution depend on the demand of grass biomass to feed livestock as calculated
*' in the module [70_livestock] and from the intensity of grassland utilization
*' ("grassland yields"). Grassland yields are defined separately for rangelands
*' and managed pasture based on historical estimates or areas and biomass production
*' for these two systems. Managed pastures yields can be increased endogenously
*' by investments in technology as calculated in [13_tc]. Rising yields alter the
*' nitrogen budged on grasslands triggering costs for N inorganic fertilization as
*' calculated in [50_nr_soil_budget] and control the balance between intensive and
*' extensive grass biomass production.
*' @description In the grassland_apr22 realization, grassland areas and their associated
*' carbon stocks are endogenously modeled. The initial spatially explicit distributions of
*' grasslands ("past") are established in the [10_land] module based on the land use input
*' data set. These areas are here divided into rangelands and managed pastures, each under
*' varying management assumptions. For future time steps, the spatial distribution of
*' grasslands is influenced by the demand for grass biomass to feed livestock, as
*' determined in the [70_livestock] module, and by the intensity of grassland utilization,
*' referred to as "grassland yields." Yields for rangelands and managed pastures are
*' calculated based on historical data of area coverage and biomass production for these
*' systems. Yields for managed pastures can be increased through investments in technology,
*' as modeled in [13_tc]. Increased yields modify the nitrogen budget on grasslands,
*' leading to costs associated with nitrogen inorganic fertilization as computed in
*' [50_nr_soil_budget], and help manage the balance between intensive and extensive grass
*' biomass production.

*' @limitations At the moment this realization only runs with a single climate scenario
*' (SPP1-RCP2p6 from MRI_ESM-0), which is used in all (except constant climate) settings.
*' We currently do not accout for specific differences within intensive
*' pasture management systems and related degradation of grasslands for both
*' rangelands or managed pastures. Grass production costs and conversion costs between
*' grassland types are set 1 USD05MER per unit due to lack of data.
*' @limitations Currently, this model operates under a single climate scenario
*' (SPP1-RCP2p6 from MRI_ESM-0), which applies to all configurations except those assuming
*' a constant climate. At present, the model does not address specific variations within
*' intensive pasture management systems and the subsequent degradation of grasslands for
*' both rangelands and managed pastures. Grass biomass production costs is uniformly set at 1
*' USD05MER per unit due to limited data availability. Finally, a conversion cost of
*' 1000 USD05MER between grassland types was set as a technical solution to
*' prevent unrealistic transformations of grassland types in the initial time step.



Expand Down
8 changes: 2 additions & 6 deletions modules/31_past/grasslands_apr22/sets.gms
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ sets
grassland(f31_luh) Grassland cover types (pastr = managed pastures and range = rangelands)
/ pastr, range /

grass_to31(grassland) pasture management options
/ pastr,range /

grass_from31(grassland) pasture management options
/ pastr,range /

land31 land use types landinitialization
/ crop,past,range,primforest,secdforest,forestry,urban,primother,secdother /
;
1 change: 1 addition & 0 deletions modules/31_past/input/files
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ f31_pastr_suitability.cs2
f31_LUH2v2.cs3
f31_grassl_yld.cs3
f31_grass_bio_hist.cs3
avl_land_full_t.cs3
Loading

0 comments on commit abec054

Please sign in to comment.