Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic sets in 56_ghg_policy and 60_bioenergy and update of GHG emission policies #254

Merged
merged 6 commits into from
Mar 1, 2021

Conversation

flohump
Copy link
Contributor

@flohump flohump commented Feb 28, 2021

Please fill following information
(Add additional info if you think its important and not covered by this Pull Request (PR)):

Purpose of this PR

  • Automatic sets in 56_ghg_policy and 60_bioenergy and update of GHG emission policies.
  • Automatic sets will make it much easier to update GHG price and bioenergy demand scenarios in mrcommons
  • The GHG emission policies have been revised for better understanding and to avoid confusion. The default setting is renamed to "redd+natveg_nosoil", which is content-wise unchanged.

Performance loss/gain from current default behavior

  • No test runs.

Type of change

  • Bug fix (Change which fixes an issue).
  • New feature (Change which adds functionality).
  • Minor change (Change which does not modify core model code i.e., in /modules).
  • Major change (fix or feature that would change current model behavior).

How Has This Been Tested?

  • Runs using starting script which tests current defaults (using test_runs.R).
  • Runs using starting script which successfully runs the same scenarios as in test_runs.R but with the changes from PR.
  • (If applicable) Runs using different scenarios/mappings which are not the default (12 regions/c200 clusters).

Additions or Changes to default configuration (default.cfg):

Additions are the introduction of new model components in default config

Changes are deletion or updates to the existing model components in default config

  • Realizations:
  • Scenario switches:
  • Scalars/Constants:
  • Model interfaces:
  • Others:

Checklist:

  • Self-review of my own code.
  • Compilation check (model starts without compilation errors).
  • Added changes to CHANGELOG.md
  • No hard coded numbers and cluster/country/region names.
  • The code doesn't contain declared but unused parameters or variables.
  • In-code comments added including documentation comments.
  • Compiled and checked resulting documentation with goxygen::goxygen() for the new/updated parts.
  • Changes to magpie4 R library for post processing of model output (ideally backward compatible).

Special comments/warnings

  • Notes

content <- c(content,';')

gms::replace_in_file("modules/56_ghg_policy/price_jan20/sets.gms",content,subject)

Copy link
Member

Choose a reason for hiding this comment

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

overall approach looks good to me, but code needs some streamlining:

you are re-using here code which is used to modify our core/sets.gms file. Instead of duplicating that code by copying it I would like to ask you to ousource that part into a function and call that function where needed. Doing so will ensure that bugfixes in that part will be deployed automatically to all places where it is used and the code will become easier readable.
From what I can see the function would require three inputs: the file to be modied, the set name and description, and the set elements.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately, this is not possible because the sets cannot be written to sets.gms in sequence. All sets have to be written at once, otherwise only the last set written will be in the code. But I can move the .tmp function and the modification header into functions that are called from within .update_sets and .update_sets_bioen_ghgprice_scen. What do you suggest?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added .set_modification and .set_formatting. If you have further suggestions for streamlining, just let me know.

Copy link
Member

Choose a reason for hiding this comment

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

Why not write a function then which writes all sets at once? (set entries could be provided as a list of entries and the function would simply 1) write the header 2) loop through the sets and write them 3) write the footer)

Copy link
Member

Choose a reason for hiding this comment

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

(the set mappings in core/sets.gms should also fit in this scheme if you treat each set mapping (e.g. CAZ . (AUS,CAN,HMD,NZL,SPM)) as single set element and put that paste-magic which is creating these mappings outside of that function)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. I hope this is fine now.

@flohump flohump requested a review from tscheypidi March 1, 2021 13:06
@flohump flohump merged commit 5028f4f into magpiemodel:develop Mar 1, 2021
@flohump flohump deleted the f_BioenGHG branch June 18, 2024 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants