-
Notifications
You must be signed in to change notification settings - Fork 153
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
Add commodity flow of capacity variables #451
base: main
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## main #451 +/- ##
=====================================
Coverage 93.0% 93.0%
=====================================
Files 43 43
Lines 3373 3373
=====================================
Hits 3137 3137
Misses 236 236 |
#452 is modifying the CI setup. Please restart the tests here (manually or via rebase) once that one is merged, hopefully within an hour. |
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 edited the PR description to re-add the checklist that's auto inserted by the template. These items, particularly documentation, are essential—even for minor PRs. This one is not minor, because it alters the core model formulation.
At the absolute minimum, when completing the item “Update release notes,” mention the parameters, variables, and equations that are added/affected by the additions here. Then, users might have a thin hope of understanding that changes have been made, and might try to puzzle them out or even use them.
Much better would be to update the inline documentation in the GAMS files, or add a new file in docs/, with plain-language description. For a good example, see #190 by @behnam-zakeri: https://github.com/iiasa/message_ix/pull/190/files, in particular
- additions in model_core.gms and parameter_def.gms.
- how the corresponding item in the release notes links to these descriptions.
As a reminder, if time feels tight, there is always the option to task a specific colleague with some or all of this work.
Postponed to v3.4 because:
|
I've added the WIP tag, since there is still more time/investigation needed to finish up the PR, as discussed in today's MESSAGEix meeting. Due to that and the following
we postpone to v3.5. |
* CAP_NEW(location,tec,year) ) \ | ||
* commodity input and output associated with retirement of technology capacity (via differentials of capacity of successive periods) | ||
* for first model period (differential with historical remaining capacity) | ||
+ SUM( (location,tec,vintage,year2)$( inv_tec(tec) AND map_tec_lifetime(location,tec,vintage,year2) \ |
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.
map_tec_lifetime issue for the first year scrap release equation:
If we say the first model year is 700 and the vintage is 690:
According to this equation which is valid only for the first model year, based on the conditions specified here
year = 700, year2 = 690. In this case for a technology that has vintage 690 map_tec_lifetime(location,tec,690,690) becomes a condition that needs to be satisfied. And map_tec_lifetime does not have this entry for vintage years. In this case there will be no scrap released for the first model year.
As another example, if we say the vintage year is 680 and the lifetime is 20 years, the only way to make sure this plant will retire in the first model period (700) is to check map_tec_lifetime and see the entry for (680, 690). Otherwise, we don't know when it is supposed to retire. We either need to make this historical vintage year addition to map_tec_lifetime or change the equations to satisfy the necessary condition.
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.
Just to add a bit on Gamze's comment above, for the capacity supposed to end its activity in 690 and retire in 700, the historical capacity that existed in 690 cannot be taken into account, because the map_tec_lifetime
condition does not pass for the period pair of (year2, year) = (690, 700)
. map_tec_lifetime(location,tec,vintage,year2)
is only defined for year2 >= fmy = 700
.
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.
Even if the necessary map_tec_lifetime is added manually in GAMS, the if conditions are not satisfied and no scrap is released in the first year. Not sure why this is happening... The equations printed in the .lst format are attached. The gdx files are in: I:\unlu\power_sector_integration\24.05
AND first_period(year) AND seq_period(year2,year) ), \ | ||
* output by all new capacity of technologies located at 'location' sending to 'node' and 'time' distributed over years of periods | ||
output_cap_ret(location,tec,vintage,node,commodity,level,time) \ | ||
* ( remaining_capacity(node,tec,vintage,year2) - CAP(location,tec,vintage,year) ) \ |
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.
Reformulation of the first year scrap release equation:
The remaining capacity seems to be a binary value, does it make sense to perform a subtraction such as
( remaining_capacity(node,tec,vintage,year2) - CAP(location,tec,vintage,year) )?
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.
Here we can use something like:
- output by all new capacity of technologies located at 'location' sending to 'node' and 'time' distributed over years of periods
output_cap_ret(location,tec,vintage,node,commodity,level,time)
( historical_new_capacity(node,tec,vintage) - CAP(location,tec,vintage,year)/ duration_period(year) )
- input by all new capacity of technologies located at 'location' taking from 'node' and 'time' distributed over years of periods
- input_cap_ret(location,tec,vintage,node,commodity,level,time)
(historical_new_capacity(node,tec,vintage) - CAP(location,tec,vintage,year)/ duration_period(year)))
We might need to sum the historical_new_capacity over vintage years (if there are two different vintages with different life times both retiring in the first model year...)
/ duration_period(year) ) \ | ||
* for other model periods (differential with installed capacity of preceding period) | ||
+ SUM( (location,tec,vintage,year2)$( inv_tec(tec) AND map_tec_lifetime(location,tec,vintage,year2) \ | ||
AND NOT first_period(year) AND seq_period(year2,year) ), \ |
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.
Another suspected issue here is:
For the capacity (e.g. vintage=740
) ending its activity in e.g. year2=750
, because the condition seq_period(750,760)
still passes, this part of the equation keeps the term -CAP(location,tec,740,760)
(in line 613), which we expect to be 0 by definition. But differently from our expectation, it appears that while solving the LP model, a spurious non-zero value is assigned to this CAP(location,tec,740,760)
.
The issue related to the historical vintage The problem of non-zero To avoid this behavior, we may need to introduce an additional equation of the following kind:
|
08f6b19
to
2eecda9
Compare
- scaling factor adjusts for difference in length of construction and retirement periods of capacities in related commodity flows - added missing closing parenthesis to sums in commodity flow
- scaling factor adjusts for difference in length of construction and retirement periods of capacities in related commodity flows - added missing closing parenthesis to sums in commodity flow
…ture periods period to first model year
77957bb
to
4e79291
Compare
This PR cleans up and supersedes #387.
PR checklist
Things to review
Expected review time: One hour or one and a half hour