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

revision forestry implementation #673

Merged
merged 30 commits into from May 22, 2024
Merged

Conversation

flohump
Copy link
Contributor

@flohump flohump commented May 10, 2024

🐦 Description of this PR 🐦

This PR includes a revision and simplification of the forestry implementation AND makes "ForestryEndo" (MAgPIE with forestry sector) a default setting.

Details:

  • renamed from 32_forestry/dynamic_feb21 to 32_forestry/dynamic_may24
  • no calibration of timber yields / carbon densities for better consistency with LPJmL
  • equal distribution of plantation area to age-classes based on rotation length
  • Poulter AC distribution in secdforest
  • plantations harvest is enforced once rotation age has been reached
  • all harvested plantations will go to establishment at cell level, unless future demand is smaller than current demand. This is some kind of sticky forestry to avoid strong jumps in patterns.
  • additional plantation establishment is based on future demand (current was used so far) and a global increasing share for the contribution of plantations to fulfilling wood demand. Here, the model has a high degree of freedom to go into cells with high yields.
  • I added discounted future production costs (PV) for the establishment decision to the costs (but it has almost no effect)
  • The following regional calibration factors are no longer used: growing stock, regional average yield, plantation contribution. These come from the pre-processing but some are hard-coded for the H12 regions (in particular plantation contribution), i.e. they will not work for other regional setups.
  • I added a lower bound of 50 USD/ton on trade margins in all regions to avoid unrealistic exports, especially from EUR. This avoids a decline of growing stocks due to excessive exports.
  • I also found and fixed some bugs, e.g. related to the future demand calculation

With this setup the model is feasible. Production from heaven is zero. No missing land for establishment. There is some additional trade for feasibility for MEA, and for EUR after 2050.

  • The equal distribution of age-classes at the beginning together with the replanting assumption makes sure that in each time step wood can be harvested.
  • At global and regional level, plantation establishment is broadly comparable to the current version.
  • Harvest yields are of course much lower.
  • The same holds true for harvest and regrowth emissions of plantations.

All test runs including FSEC and HR are feasible in all time steps.

changed

  • 32_forestry revision and simplification of forestry implementation, renamed realization from dynamic_feb21 to dynamic_may24. Renamed pm_demand_ext to pm_demand_forestry
  • 32_forestry renamed interface pm_demand_ext to pm_demand_forestry
  • default.cfg ForestryEndo as default setting
  • 14_yields revised timber yield calculations

removed

  • 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
  • 35_natveg removed growing stock calculation and calibration, which is no longer needed.

fixed

  • 62_material/16_demand Removed double structure for forestry products. pm_demand_foresty is now used in 62_material

added

  • 21_trade Minimum trade margin for forestry products s21_min_trade_margin_forestry
  • 73_timber added interface im_timber_prod_cost

🔧 Checklist for PR creator 🔧

  • Label pull request from the label list.

    • Low risk: Simple bugfixes (missing files, updated documentation, typos) or changes in start or output scripts
    • Medium risk: Uncritical changes in the model core (e.g. moderate modifications in non-default realizations)
    • High risk: Critical changes in model core or default settings (e.g. changing a model default or adjusting a core mechanic in the model)
  • Self-review own code

    • No hard coded numbers and cluster/country/region names.
    • The new code doesn't contain declared but unused parameters or variables.
    • magpie4 R library has been updated accordingly and backwards compatible where necessary.
    • scenario_config.csv has been updated accordingly (important if default.cfg has been updated)
  • Document changes

    • Add changes to CHANGELOG.md
    • Where relevant, put In-code documentation comments
    • Properly address updates in interfaces in the module documentations
    • run goxygen::goxygen() and verify the modified code is properly documented
  • Perform test runs

    • Low risk:
      • Run a compilation check via Rscript start.R --> "compilation check"
    • Medium risk:
      • Run test runs via Rscript start.R --> "test runs"
      • Check logs for errors/warnings
    • High risk:
      • Run test runs via Rscript start.R --> "test runs"
      • Check logs for errors/warnings
      • Default run from the PR target branch for comparison
      • Provide relevant comparison plots (land-use, emissions, food prices, land-use intensity,...)

📉 Performance changes 📈

  • Current develop branch default : PR673_dev_SSP2-Ref 22.8 mins
  • This PR's default : PR673_thisPR5_SSP2-Ref 27 mins

More run times, all in mins:
GAMS,PR673_dev_SSP2-NDC,29.7
GAMS,PR673_dev_SSP2-NDC-ForestryEndo,23.6
GAMS,PR673_dev_SSP2-PkBudg650,22.1
GAMS,PR673_dev_SSP2-PkBudg650-ForestryEndo,25.3
GAMS,PR673_dev_SSP2-Ref,22.8
GAMS,PR673_dev_SSP2-Ref-ForestryEndo,24
GAMS,PR673_thisPR5_SSP2-NDC,25.6
GAMS,PR673_thisPR5_SSP2-PkBudg650,28.7
GAMS,PR673_thisPR5_SSP2-Ref,27

export-33
export-37
export-39
export-40
export-30
export-31
export-32
export-34
export-35
export-36
export-38

🚨 Checklist for reviewer 🚨

  • PR is labeled correctly
  • Code changes look reasonable
    • No hard coded numbers and cluster/country/region names.
    • No unnecessary increase in module interfaces
    • model behavior/performance is satisfactory.
  • Changes are properly documented
    • CHANGELOG is updated correctly
    • Updates in interfaces have been properly addressed in the module documentations
    • In-code documentation looks appropriate
  • content review done (at least 1)
  • RSE review done (at least 1)

@flohump flohump added enhancement New feature or request Major Substantial modifications High risk Higher risk labels May 17, 2024
@flohump flohump marked this pull request as ready for review May 20, 2024 20:30
Copy link
Member

@tscheypidi tscheypidi left a comment

Choose a reason for hiding this comment

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

looks good to me, just some minor things. In addition to the separate comments I saw that you changed/removed quite a lot of interfaces (nice!), but I did not see any changes in the corresponding goxygen documentation in the affected module.gms files. Can you please check verify that the module descriptions are still valid even with these changes in interfaces?

CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated
- **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`. Renamed `pm_demand_ext` to `pm_demand_forestry`
- **32_forestry** renamed interface `pm_demand_ext` to `pm_demand_forestry`
- **default.cfg** ForestryEndo as default setting
Copy link
Member

Choose a reason for hiding this comment

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

do you mean forestry dynamic_may24 as default?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. Here I mean making forestry a default in MAgPIE. I revised with more details:
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

CHANGELOG.md Outdated Show resolved Hide resolved
config/scenario_fsec.csv Show resolved Hide resolved
flohump and others added 4 commits May 21, 2024 09:15
Co-authored-by: Jan Dietrich <dietrich@pik-potsdam.de>
@flohump
Copy link
Contributor Author

flohump commented May 21, 2024

looks good to me, just some minor things. In addition to the separate comments I saw that you changed/removed quite a lot of interfaces (nice!), but I did not see any changes in the corresponding goxygen documentation in the affected module.gms files. Can you please check verify that the module descriptions are still valid even with these changes in interfaces?

I checked all corresponding module descriptions. The removed interfaces did not appear there. But I spotted some other outdated information and spelling mistakes, which are no fixed.
In addition, I removed outdated code from 35_natveg

@flohump flohump requested a review from tscheypidi May 21, 2024 08:20
Copy link
Member

@abhimishr abhimishr left a comment

Choose a reason for hiding this comment

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

Left only two minor comments

@flohump
Copy link
Contributor Author

flohump commented May 21, 2024

Left only two minor comments

Thanks for your review.

@flohump flohump requested a review from abhimishr May 21, 2024 16:08
Copy link
Member

@abhimishr abhimishr left a comment

Choose a reason for hiding this comment

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

Good to go now 🚀

@flohump flohump merged commit 580b922 into magpiemodel:develop May 22, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request High risk Higher risk Major Substantial modifications
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants