iiasa / message_ix

The integrated assessment and energy systems model MESSAGEix
https://docs.messageix.org
Apache License 2.0
111 stars 149 forks source link

Resolve issues related to `technical_lifetime` and historical vintages in Westeros tutorials #815

Closed behnam-zakeri closed 1 month ago

behnam-zakeri commented 3 months ago

This PR resolves issues related to Westeros "baseline" tutorial, including #525, #609, #813, and #814. This PR does the following:

  1. Defines vintage-activity years for each technology based on technical_lifetime of that technology (addressing #525)
  2. Defines vintage and activity for historical parameters, i.e., adding historical years to relevant parameters (addressing #609, partially related to this comment in #451, and partially related to #624)
  3. Corrects the units, makes sure they are consistent, and adds a note (partially addressing #814).
  4. Adds capacity-related parameters for the grid (resolving #813). An investment cost of 800 USD/kW and fixed O&M cost of 16 USD/kW/a is added.

How to review

PR checklist

codecov[bot] commented 3 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 95.6%. Comparing base (0cc8102) to head (fde7729). Report is 7 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #815 +/- ## ======================================= + Coverage 95.4% 95.6% +0.1% ======================================= Files 46 46 Lines 4354 4335 -19 ======================================= - Hits 4156 4145 -11 + Misses 198 190 -8 ``` | [Files](https://app.codecov.io/gh/iiasa/message_ix/pull/815?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=iiasa) | Coverage Δ | | |---|---|---| | [message\_ix/testing/\_\_init\_\_.py](https://app.codecov.io/gh/iiasa/message_ix/pull/815?src=pr&el=tree&filepath=message_ix%2Ftesting%2F__init__.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=iiasa#diff-bWVzc2FnZV9peC90ZXN0aW5nL19faW5pdF9fLnB5) | `99.6% <100.0%> (ø)` | | | [message\_ix/tests/test\_feature\_price\_emission.py](https://app.codecov.io/gh/iiasa/message_ix/pull/815?src=pr&el=tree&filepath=message_ix%2Ftests%2Ftest_feature_price_emission.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=iiasa#diff-bWVzc2FnZV9peC90ZXN0cy90ZXN0X2ZlYXR1cmVfcHJpY2VfZW1pc3Npb24ucHk=) | `100.0% <100.0%> (ø)` | | | [message\_ix/tests/test\_macro.py](https://app.codecov.io/gh/iiasa/message_ix/pull/815?src=pr&el=tree&filepath=message_ix%2Ftests%2Ftest_macro.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=iiasa#diff-bWVzc2FnZV9peC90ZXN0cy90ZXN0X21hY3JvLnB5) | `100.0% <ø> (ø)` | | | [message\_ix/tests/test\_report.py](https://app.codecov.io/gh/iiasa/message_ix/pull/815?src=pr&el=tree&filepath=message_ix%2Ftests%2Ftest_report.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=iiasa#diff-bWVzc2FnZV9peC90ZXN0cy90ZXN0X3JlcG9ydC5weQ==) | `100.0% <100.0%> (ø)` | | | [message\_ix/tests/test\_soft\_constraints.py](https://app.codecov.io/gh/iiasa/message_ix/pull/815?src=pr&el=tree&filepath=message_ix%2Ftests%2Ftest_soft_constraints.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=iiasa#diff-bWVzc2FnZV9peC90ZXN0cy90ZXN0X3NvZnRfY29uc3RyYWludHMucHk=) | `100.0% <100.0%> (ø)` | | | [message\_ix/tests/test\_tutorials.py](https://app.codecov.io/gh/iiasa/message_ix/pull/815?src=pr&el=tree&filepath=message_ix%2Ftests%2Ftest_tutorials.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=iiasa#diff-bWVzc2FnZV9peC90ZXN0cy90ZXN0X3R1dG9yaWFscy5weQ==) | `97.6% <ø> (ø)` | | | [message\_ix/tests/util/test\_tutorial.py](https://app.codecov.io/gh/iiasa/message_ix/pull/815?src=pr&el=tree&filepath=message_ix%2Ftests%2Futil%2Ftest_tutorial.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=iiasa#diff-bWVzc2FnZV9peC90ZXN0cy91dGlsL3Rlc3RfdHV0b3JpYWwucHk=) | `100.0% <100.0%> (ø)` | | ... and [1 file with indirect coverage changes](https://app.codecov.io/gh/iiasa/message_ix/pull/815/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=iiasa)
behnam-zakeri commented 2 months ago

Thanks @glatterf42 for the quick review. I hadn't changed the objective functions in those test because we need to add investment cost for the grid (one of the ToDos) which will change the objective function. I discussed with @OFR-IIASA this morning, and we believe it's not needed to update the investment cost of wind and coal power plants (the optional ToDo), because this tutorial is not representing the reality of today, or in fact any period in history, and just wants to showcase how the model works with two technologies with different investment cost. As such, I will leave the investment cost for wind and coal power plants as it is for the time being.

glatterf42 commented 1 month ago

Highjacking this PR to enable ruff for all tutorial files since I started migrating to make_df and was annoyed by the code not following our code style.

As for the question I raised earlier, I have now concluded from your PR description, @behnam-zakeri, that all issues except #814 are indeed closed by this PR since #814 is the only one where you say "partially addressing". Assuming this is true, once we get the tests to pass, this PR is good to go :)

behnam-zakeri commented 1 month ago

Thanks @glatterf42 for the kind reminder and sorry for the delay. This PR indeed closes the issues https://github.com/iiasa/message_ix/issues/525, https://github.com/iiasa/message_ix/issues/609, https://github.com/iiasa/message_ix/issues/813, and https://github.com/iiasa/message_ix/issues/814. I correct the description to show that this resolves #814 fully and not partially.