-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cluster-level Residues Realization #585
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for this impressive work and major contribution! The code is well documented, so even though I don't know much at all about how magpie's gams code works I could follow rather well! The one bigger thing I'd suggest though is not using the word "cell" or "cellular" anymore, as it means cluster in some cases and gridcell in others. In magpie's gams code, cell always means cluster (as Patrick told me), so I'd suggest always using the words "cluster" or "cluster-level" (as you already do in some cases) instead.
main.gms
Outdated
@@ -221,7 +221,7 @@ $offlisting | |||
|
|||
$setglobal c_timesteps coup2100 | |||
$setglobal c_past till_2010 | |||
$setglobal c_title default | |||
$setglobal c_title testCellRes7_flexcell |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you really intend to commit your changes to main.gms?
|
||
positive variables | ||
v18_prod_res(j,kres) Cluster-level production of residues (mio. tDM) | ||
v18_res_biomass_ag_cell(j,kcr) Production of aboveground residues in each cluster (mio. tDM) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really think we should stop calling clusters cells, how about this variable name?
v18_res_biomass_ag_cell(j,kcr) Production of aboveground residues in each cluster (mio. tDM) | |
v18_res_biomass_ag_cluster(j,kcr) Production of aboveground residues in each cluster (mio. tDM) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe that means that the whole realization name than should be changed?
According to that it might make sense to be a bit more specific as only the removals are on cluster/cell level?
Sorry I know renaming always costs some efforts ^^'
*#################### R SECTION START (OUTPUT DECLARATIONS) #################### | ||
parameters | ||
ov18_prod_res(t,j,kres,type) Cellular production of residues (mio. tDM) | ||
ov18_res_biomass_ag_cell(t,j,kcr,type) Production of aboveground residues in each cell (mio. tDM) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, now cell no longer means cluster but it actually means cellular (as in our 59k/67k cells)? Or do you actually mean cluster again?
oq18_prod_res_bg_cell(t,i,kcr,dm_nr,type) Cellular 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_cell_field_constraint(t,j,kres,type) Make sure the amount removed in any cell does not exceet the amoutn available |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oq18_cell_field_constraint(t,j,kres,type) Make sure the amount removed in any cell does not exceet the amoutn available | |
oq18_cell_field_constraint(t,j,kres,type) Make sure the amount removed in any cell does not exceed the amount available |
oq18_res_field_balance(t,i,kcr,attributes,type) Calculation of the residues amount recycled to soils (mio. tDM) | ||
oq18_cell_field_constraint(t,j,kres,type) Make sure the amount removed in any cell does not exceet the amoutn available | ||
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 redisues in respective attribute units DM GJ Nr P K WM C (mio. tX) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oq18_translate(t,j,kres,attributes,type) Transformation of the multiple crop residues into supply balance crop redisues 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) |
@@ -0,0 +1,2 @@ | |||
name,type,reason | |||
vm_prod,input,questionnaire |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does "questionnaire" mean here?
scripts/start/testCellRes.R
Outdated
# | Contact: [email protected] | ||
|
||
# ------------------------------------------------ | ||
# description: start run with default.cfg settings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be copied from default.R, please adapt.
scripts/start/testCellRes.R
Outdated
# Source default cfg. This loads the object "cfg" in R environment | ||
source("config/default.cfg") | ||
|
||
#start MAgPIE run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#start MAgPIE run |
scripts/start/testCellRes.R
Outdated
#start MAgPIE run | ||
cfg$title <- "testCellRes2_default_noNewEquation" | ||
|
||
#start MAgPIE run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#start MAgPIE run |
scripts/start/testCellRes.R
Outdated
#start MAgPIE run | ||
|
||
cfg$gms$residues <- "flexreg_apr16" | ||
#start_run(cfg, codeCheck = TRUE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#start_run(cfg, codeCheck = TRUE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Equation look good to me. Realization despription highlights that residue production/removal is on cluster level, but changelog as well as naming might be changed to a clearer name, as it might be that upcoming realizations might be as well on cluster level having other features (e.g. recycling on cluster level).
CHANGELOG.md
Outdated
@@ -11,7 +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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe more specific what variables are on cluster level?
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will that be an interface soon?
If so maybe already now make it an interface and think about how to fill it for the reg module realization?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
v18_prod_res will be the interface, and this one already has an equation distributing it felxibly added to the reg module realization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just some typos and one important thing: Please double check that the correct realization name is used everywhere. While you're at it I think it would be a good idea also rename once again to flexcluster_jul23 to be consistent with the 3-letter-month used for all other realizations.
main.gms
Outdated
@@ -241,7 +241,7 @@ $setglobal food anthro_iso_jun22 | |||
$setglobal demand sector_may15 | |||
$setglobal production flexreg_apr16 | |||
|
|||
$setglobal residues flexreg_apr16 | |||
$setglobal residues flexcell_july23 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$setglobal residues flexcell_july23 | |
$setglobal residues flexcluster_july23 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency the realization should probably be renamed like this (jul instead of july)
$setglobal residues flexcell_july23 | |
$setglobal residues flexcluster_jul23 |
|
||
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
v18_res_biomass_ag_clust(j,kcr) Production of aboveground residues in each cluster (mio. tDM) | |
v18_res_biomass_ag_clust(j,kcr) Production of aboveground residues in each cluster (mio. tDM) |
; | ||
|
||
parameters | ||
i18_res_use_burn(t_all,dev18,kcr) Share of residues burned on field (1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i18_res_use_burn(t_all,dev18,kcr) Share of residues burned on field (1) | |
i18_res_use_burn(t_all,dev18,kcr) Share of residues burned on field (1) |
oq18_prod_res_ag_reg(t,i,kcr,attributes,type) Regional production constraint of aboveground residues (mio. tDM) | ||
oq18_prod_res_bg_cell(t,i,kcr,dm_nr,type) Cluster-level production constraint of belowground residues (mio. tDM) | ||
oq18_res_field_balance(t,i,kcr,attributes,type) Calculation of the residues amount recycled to soils (mio. tDM) | ||
oq18_cell_field_constraint(t,j,kres,type) Make sure the amount removed in any cell does not exceet the amoutn available |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It probably makes sense, but this is the only parameter without a unit in the description.
oq18_prod_res_ag_reg(t,i,kcr,attributes,type) Regional production constraint of aboveground residues (mio. tDM) | ||
oq18_prod_res_bg_cell(t,i,kcr,dm_nr,type) Cluster-level production constraint of belowground residues (mio. tDM) | ||
oq18_res_field_balance(t,i,kcr,attributes,type) Calculation of the residues amount recycled to soils (mio. tDM) | ||
oq18_cell_field_constraint(t,j,kres,type) Make sure the amount removed in any cell does not exceet the amoutn available |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oq18_cell_field_constraint(t,j,kres,type) Make sure the amount removed in any cell does not exceet the amoutn available | |
oq18_cell_field_constraint(t,j,kres,type) Make sure the amount removed in any cell does not exceed the amount available |
* vm_res_biomass_ag(i2,kcr,attributes); | ||
|
||
|
||
*' While the residue biomass is estiamted with a crop-specific nutrient |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*' While the residue biomass is estiamted with a crop-specific nutrient | |
*' While the residue biomass is estimated with a crop-specific nutrient |
|
||
|
||
*####################### R SECTION START (PHASES) ############################## | ||
$Ifi "%phase%" == "sets" $include "./modules/18_residues/flexcell_july23/sets.gms" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please have another look that "flexcell_july23" is renamed everywhere
pk18(npk) subset of npk containing P and K nutrients | ||
/p, k/ | ||
|
||
dev18 country develoment indicator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dev18 country develoment indicator | |
dev18 country development indicator |
It might make sense to install a plugin into your editor that checks for typos 😉
🐦 Description of this PR 🐦
Add a cluster-level residues realization of reduced complexity. This realization allows for tracking the cluster-level production of agricultural residues via the new variable v18_prod_res. Other fates of residues (i.e. recycling and burning), as well as below-ground production, still happen at regional level, in order to reduce runtime.
🔧 Checklist for PR creator 🔧
Label pull request from the label list.
Self-review own code
magpie4
R library has been updated accordingly and backwards compatible where necessary.scenario_config.csv
has been updated accordingly (important ifdefault.cfg
has been updated)Document changes
CHANGELOG.md
goxygen::goxygen()
and verify the modified code is properly documentedPerform test runs
Rscript start.R --> "compilation check"
Rscript start.R --> "test runs"
Rscript start.R --> "test runs"
📉 Performance changes 📈
🚨 Checklist for reviewer 🚨
CHANGELOG
is updated correctly