Skip to content

Commit

Permalink
Merge pull request magpiemodel#585 from caviddhen/cellRes
Browse files Browse the repository at this point in the history
Cluster-level Residues Realization
  • Loading branch information
caviddhen authored Sep 23, 2023
2 parents aa3c5ae + eb39503 commit 4834073
Show file tree
Hide file tree
Showing 18 changed files with 521 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
-

### added
- **18_residues** Included cluster-level residue realization, for cluster-level production of residues (but balancing of recycling and burning budgets remains at region-level, for computational lightness)
- **14_yields/config** Added option for considering impacts of land degradation on yields. If `s14_degradation` is switched to 1, MAgPIE will include cluster-specific information on the state of nature's contributions to people relevant for yields `./modules/14_yields/input/f14_yld_ncp_report.cs3`.

### removed
Expand Down
10 changes: 5 additions & 5 deletions main.gms
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ $title magpie
* md5sum: d42abd58de683506a807b411d7fe87cb
* Repository: /p/projects/rd3mod/mirror/rse.pik-potsdam.de/data/magpie/public
*
* Used data set: additional_data_rev4.43.tgz
* md5sum: 7f537e5df805af11f0e67e84e6010290
* Repository: /p/projects/rd3mod/mirror/rse.pik-potsdam.de/data/magpie/public
* Used data set: additional_data_rev4.45.tgz
* md5sum: bb51c8c8608b8b9363582eb4aa220754
* Repository: /p/projects/landuse/data/input/archive
*
* Used data set: calibration_H12_per_ton_fao_may22_glo_08Aug23.tgz
* md5sum: 5d34e4b54112db10f330f1e59dd60cc9
Expand Down Expand Up @@ -195,7 +195,7 @@ $title magpie
* * Call: withCallingHandlers(expr, message = messageHandler, warning = warningHandler, error = errorHandler)
*
*
* Last modification (input data): Wed Aug 23 14:34:40 2023
* Last modification (input data): Fri Sep 22 15:20:24 2023
*
*###################### R SECTION END (VERSION INFO) ###########################

Expand Down Expand Up @@ -284,7 +284,7 @@ $setglobal bioenergy 1stgen_priced_dec18
$setglobal material exo_flexreg_apr16
$setglobal livestock fbask_jan16

$setglobal disagg_lvst foragebased_aug18
$setglobal disagg_lvst foragebased_jul23

$setglobal timber default

Expand Down
76 changes: 76 additions & 0 deletions modules/18_residues/flexcluster_jul23/declarations.gms
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
*** | (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: [email protected]


positive variables
v18_prod_res(j,kres) Cluster-level production of residues (mio. tDM)
v18_res_biomass_ag_clust(j,kcr) Production of aboveground residues in each cluster (mio. tDM)
vm_res_biomass_ag(i,kcr,attributes) Production of aboveground residues in each region (mio. tDM)
vm_res_biomass_bg(i,kcr,dm_nr) Production of belowground residues in each region (mio. tDM)

v18_res_ag_removal(j,kcr,attributes) Removal of crop residues in respective attribute units DM GJ Nr P K WM C (mio. tX)
v18_res_ag_removal_reg(i,kcr,attributes) Regional removal of crop residues in respective attribute units DM GJ Nr P K WM C (mio. tX)
v18_res_ag_recycling(i,kcr,attributes) Recycling of crop residues to soils in respective attribute units DM GJ Nr P K WM C (mio. tX)
vm_res_ag_burn(i,kcr,attributes) Regional residues burned on fields in respective attribute units DM GJ Nr P K WM C (mio. tX)

vm_res_recycling(i,npk) Residues recycled to croplands in respective nutrients Nr P K units (mio. tX)
vm_cost_prod_kres(i,kres) Production costs of harvesting crop residues (mio. USD05MER per yr)
;

equations

q18_prod_res_ag_clust(j,kcr) Cluster-level production constraint of aboveground residues (mio. tDM)
q18_prod_res_ag_reg(i,kcr,attributes) Regional production constraint of aboveground residues (mio. tDM)

q18_prod_res_bg_clust(i,kcr,dm_nr) Cluster-level production constraint of belowground residues (mio. tDM)

q18_regional_removals(i,kcr,attributes) Calculation of regional level removals (mio. tX)
q18_res_field_balance(i,kcr,attributes) Calculation of the residues amount recycled to soils (mio. tDM)
q18_clust_field_constraint(j,kres) Make sure the amount removed in any cluster does not exceed the amount available (mio. tDM)
q18_res_field_burn(i,kcr,attributes) Fixing of the residues amount burned in a region in respective attribute units DM GJ Nr P K WM C (mio. tX)
q18_translate(j,kres,attributes) Transformation of the multiple crop residues into supply balance crop residues in respective attribute units DM GJ Nr P K WM C (mio. tX)

q18_res_recycling_nr(i) Nutrient recycling of reaactive nitrogen (mio. tNr)
q18_res_recycling_pk(i,pk18) Nutrient recycling of phosphorus and potash (mio. tX)
q18_cost_prod_res(i,kres) Production costs of harvesting crop residues (mio. USD05MER)

q18_prod_res_reg(i,kall) Regional production of residues (mio. tDM)

;

parameters
i18_res_use_burn(t_all,dev18,kcr) Share of residues burned on field (1)
;

*#################### R SECTION START (OUTPUT DECLARATIONS) ####################
parameters
ov18_prod_res(t,j,kres,type) Cluster-level production of residues (mio. tDM)
ov18_res_biomass_ag_clust(t,j,kcr,type) Production of aboveground residues in each cluster (mio. tDM)
ov_res_biomass_ag(t,i,kcr,attributes,type) Production of aboveground residues in each region (mio. tDM)
ov_res_biomass_bg(t,i,kcr,dm_nr,type) Production of belowground residues in each region (mio. tDM)
ov18_res_ag_removal(t,j,kcr,attributes,type) Removal of crop residues in respective attribute units DM GJ Nr P K WM C (mio. tX)
ov18_res_ag_removal_reg(t,i,kcr,attributes,type) Regional removal of crop residues in respective attribute units DM GJ Nr P K WM C (mio. tX)
ov18_res_ag_recycling(t,i,kcr,attributes,type) Recycling of crop residues to soils in respective attribute units DM GJ Nr P K WM C (mio. tX)
ov_res_ag_burn(t,i,kcr,attributes,type) Regional residues burned on fields in respective attribute units DM GJ Nr P K WM C (mio. tX)
ov_res_recycling(t,i,npk,type) Residues recycled to croplands in respective nutrients Nr P K units (mio. tX)
ov_cost_prod_kres(t,i,kres,type) Production costs of harvesting crop residues (mio. USD05MER per yr)
oq18_prod_res_ag_clust(t,j,kcr,type) Cluster-level production constraint of aboveground residues (mio. tDM)
oq18_prod_res_ag_reg(t,i,kcr,attributes,type) Regional production constraint of aboveground residues (mio. tDM)
oq18_prod_res_bg_clust(t,i,kcr,dm_nr,type) Cluster-level production constraint of belowground residues (mio. tDM)
oq18_regional_removals(t,i,kcr,attributes,type) Calculation of regional level removals (mio. tX)
oq18_res_field_balance(t,i,kcr,attributes,type) Calculation of the residues amount recycled to soils (mio. tDM)
oq18_clust_field_constraint(t,j,kres,type) Make sure the amount removed in any cluster does not exceed the amount available (mio. tDM)
oq18_res_field_burn(t,i,kcr,attributes,type) Fixing of the residues amount burned in a region in respective attribute units DM GJ Nr P K WM C (mio. tX)
oq18_translate(t,j,kres,attributes,type) Transformation of the multiple crop residues into supply balance crop residues in respective attribute units DM GJ Nr P K WM C (mio. tX)
oq18_res_recycling_nr(t,i,type) Nutrient recycling of reaactive nitrogen (mio. tNr)
oq18_res_recycling_pk(t,i,pk18,type) Nutrient recycling of phosphorus and potash (mio. tX)
oq18_cost_prod_res(t,i,kres,type) Production costs of harvesting crop residues (mio. USD05MER)
oq18_prod_res_reg(t,i,kall,type) Regional production of residues (mio. tDM)
;
*##################### R SECTION END (OUTPUT DECLARATIONS) #####################

*** EOF declarations.gms ***
150 changes: 150 additions & 0 deletions modules/18_residues/flexcluster_jul23/equations.gms
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
*** | (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: [email protected]

*' @equations

*' The AG crop residue biomass `vm_res_biomass_ag` is calculated as a function
*' of harvested area `vm_area` and production `vm_prod_reg`. `f18_cgf` contains
*' slope and intercept parameters of the CGFs.

q18_prod_res_ag_clust(j2,kcr) ..
v18_res_biomass_ag_clust(j2,kcr)
=e=
(sum(w, vm_area(j2,kcr,w)) * sum((ct, cell(i2,j2)), f18_multicropping(ct,i2)) * f18_cgf("intercept",kcr)
+ vm_prod(j2,kcr) * f18_cgf("slope",kcr));

q18_prod_res_ag_reg(i2,kcr,attributes) ..
vm_res_biomass_ag(i2,kcr,attributes)
=e=
sum(cell(i2,j2), v18_res_biomass_ag_clust(j2,kcr))
* f18_attributes_residue_ag(attributes,kcr);

*' The BG crop residue biomass `vm_res_biomass_bg` is calculated as a function of
*' total aboveground biomass.

q18_prod_res_bg_clust(i2,kcr,dm_nr) ..
vm_res_biomass_bg(i2,kcr,dm_nr)
=e=
(vm_prod_reg(i2,kcr) + vm_res_biomass_ag(i2,kcr,"dm")) * f18_cgf("bg_to_ag",kcr)
* f18_attributes_residue_bg(dm_nr,kcr);

*' Variable of removals at regional level needs to be greater than
*' the regionally-summed cluster-level variable. This is not an equal-to
*' for run-time considerations, but should be noted if regional removals
*' vm_res_biomass_ag are to be incentivised.

q18_regional_removals(i2,kcr,attributes) ..
sum(cell(i2,j2), v18_res_ag_removal(j2,kcr,attributes))
=e=
v18_res_ag_removal_reg(i2,kcr,attributes);


*' In contrast to AG biomass, AG production `vm_res_biomass_ag(i,kcr,attributes)`
*' is defined as the part of residues which is removed from the field. The
*' difference between biomass and production is either burned on field or
*' remains on the fields (either incorporated in soils or not) and decays.
*' The field balance equations ensures that the production of AG residues
*' `vm_res_biomass_ag(i,kcr,attributes)` is properly assigned to different uses:
*' removal, on-field burning and recycling of AG residues.

q18_res_field_balance(i2,kcr,attributes) ..
vm_res_biomass_ag(i2,kcr,attributes)
=e=
v18_res_ag_removal_reg(i2,kcr,attributes)
+ vm_res_ag_burn(i2,kcr,attributes)
+ v18_res_ag_recycling(i2,kcr,attributes);

*' make sure removal is less than biomass produced in each cluster
q18_clust_field_constraint(j2,kres) ..
sum(kres_kcr(kres,kcr), v18_res_biomass_ag_clust(j2,kcr))
=g=
v18_prod_res(j2, kres);

*' The amount of residues burned on fields in a region `vm_res_ag_burn` is
*' determined by the share (ic18_res_use_min_shr) of AG residue biomass.
*' Based on @smil_nitrogen_1999, residue burning is fixed to 15% of total AG
*' crop residue dry matter in developed and 25% in developing regions for each
*' crop. For future time steps, these rates are scenario dependent, and either
*' kept constant or reduced to 10% and 0% in 2050.

q18_res_field_burn(i2,kcr,attributes) ..
vm_res_ag_burn(i2,kcr,attributes)
=e=
sum(ct, im_development_state(ct,i2) * i18_res_use_burn(ct,"high_income",kcr)
+ (1-im_development_state(ct,i2)) * i18_res_use_burn(ct,"low_income",kcr))
* vm_res_biomass_ag(i2,kcr,attributes);


*' While the residue biomass is estimated with a crop-specific nutrient
*' composition (which is required for consistent nutrient budgets), the
*' removed residues are assumed to have homogeneous properties
*' (to reduce the number of commodities in MAgPIE) within three crop residue
*' groups (cereal straw, fibrous residues that cannot be digested
*' by monogastrics, and non-fibrous residues that can be digested).
*' The following constraint, in combination with the field balance equation,
*' guarantees that mass balances are not violated while a homogeneous
*' good is extracted from heterogeneous goods.

q18_translate(j2,kres,attributes)..
sum(kres_kcr(kres,kcr), v18_res_ag_removal(j2,kcr,attributes))
=e=
v18_prod_res(j2,kres) * fm_attributes(attributes,kres);

*' sum to the regional amount of residues produced for the regional interface
q18_prod_res_reg(i2,kres)..
vm_prod_reg(i2,kres)
=e=
sum(cell(i2,j2), v18_prod_res(j2,kres)) ;


*' Residues recycled to croplands in nutrients `vm_res_recycling(i2,"nr")` are
*' calculated based on the amount of AG residues left on field for recycling, the
*' nutrients coming from burned residues, and on biomass that is left in
*' BG residues. They are calculated to be transmitted to the nitrogen budget
*' module [50_nr_soil_budget].

q18_res_recycling_nr(i2) ..
vm_res_recycling(i2,"nr")
=e=
sum(kcr, v18_res_ag_recycling(i2,kcr,"nr")
+ vm_res_ag_burn(i2,kcr,"nr")*(1-f18_res_combust_eff(kcr))
+ vm_res_biomass_bg(i2,kcr,"nr")
);

*' Similar to the recycled nutrients, the potash recycling is determined by the
*' amount of AG residues with the potash content and the amounts of potash from
*' burning residues. As P and K are not volatile and hardly water soluble, only
*' removed aboveground crop residues have to be considered, while nutrients from
*' burned AG as well as BG stay on the field.

q18_res_recycling_pk(i2,pk18) ..
vm_res_recycling(i2,pk18)
=e=
sum(kcr,
v18_res_ag_recycling(i2,kcr,pk18)
+ vm_res_ag_burn(i2,kcr,pk18)
);

*' Costs of residues production are determined as factor costs per ton
*' assuming 15 USD per ton, using the lower range from
*' [this source](hwww1.agric.gov.ab.ca/$Department/deptdocs.nsf/All/faq7514),
*' 10USD baling costs per large round bale plus 2USD pro bale stocking and hauling,
*' 1 large round bale is approximately 500 kg, resulting in 24USD per ton,
*' for developing prices see [here](citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.557.5823&rep=rep1&type=pdf).
*' Tha calcuated factor costs per ton are therefore 24 for `res_cereals`, `res_fibrous`
*' and `res_nonfibrous`.

q18_cost_prod_res(i2,kres) ..
vm_cost_prod_kres(i2,kres)
=e=
vm_prod_reg(i2,kres) * fm_attributes("wm",kres) * f18_fac_req_kres(kres);

*' Trade of AG residues is not considered, so that all produced AG residues have
*' to be assigned to uses within the respective world region.


*** EOF constraints.gms ***
51 changes: 51 additions & 0 deletions modules/18_residues/flexcluster_jul23/input.gms
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
*** | (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: [email protected]

$setglobal c18_burn_scen phaseout
* options: phaseout,constant

table f18_multicropping(t_all,i) Multicropping indicator as ratio of area harvested by physical area (1)
$ondelim
$include "./modules/18_residues/input/f18_multicropping.csv"
$offdelim;

table f18_attributes_residue_ag(attributes,kve) Nutrient content of aboveground crop residues in respective attribute units DM GJ Nr P K WM C (X per DM)
$ondelim
$include "./modules/18_residues/input/f18_attributes_residue_ag.csv"
$offdelim;


table f18_attributes_residue_bg(dm_nr,kve) Nutrient content of belowground crop residues in reactive nitorgen and carbon units Nr C (X per DM)
$ondelim
$include "./modules/18_residues/input/f18_attributes_residue_bg.csv"
$offdelim;

table f18_cgf(cgf,kve) Crop growth functions for all vegetation types containing slope intercept and belowground to aboveground ratio (1)
$ondelim
$include "./modules/18_residues/flexcluster_jul23/input/f18_cgf.csv"
$offdelim;

table f18_res_use_burn(t_all,burn_scen18,dev18,kcr) Minimum and maximum burn share use for residues developing over time (1)
$ondelim
$include "./modules/18_residues/flexcluster_jul23/input/f18_res_use_burn.cs3"
$offdelim;

parameter f18_res_combust_eff(kve) Combustion efficiency of residue burning (1)
/
$ondelim
$include "./modules/18_residues/input/f18_res_combust_eff.cs4"
$offdelim
/;

parameter f18_fac_req_kres(kres) Factor requirements (USD05MER per tDM)
/
$ondelim
$include "./modules/18_residues/flexcluster_jul23/input/f18_fac_req_kres.csv"
$offdelim
/;

*** EOF input.gms ***
4 changes: 4 additions & 0 deletions modules/18_residues/flexcluster_jul23/input/files
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* list of files that are required here
f18_cgf.csv
f18_res_use_burn.cs3
f18_fac_req_kres.csv
Loading

0 comments on commit 4834073

Please sign in to comment.