-
Notifications
You must be signed in to change notification settings - Fork 154
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
Enhancing storage equations by considering mode
and lvl_temporal
#633
Conversation
37a55fd
to
63737a2
Compare
message_ix/models.py
Outdated
@@ -415,6 +419,61 @@ def enforce(scenario): | |||
scenario.remove_set(set_name, existing) | |||
scenario.add_set(set_name, expected) | |||
|
|||
# Enforcing new indexes for existing set and parameters |
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.
@khaeru, following the discussion under #631, I drafted a workflow to help reinitialize some existing sets and parameters here. The code checks if the item is empty before re-initializing, and if not raises an exception. I do believe this can be done much more compact and maybe under a separate method than enforce()
.
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.
@khaeru Resuming working on this, I was wondering if you have time to have a look at the above point. In principle, it's a design issue; how we would like to alert users that they need to re-parameterize some existing sets and parameters in their scenario to make it work with the enhanced code.
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.
@behnam-zakeri I've just pushed a couple commits with the requested changes.
Per this:
users that they need to re-parameterize some existing sets and parameters in their scenario to make it work with the enhanced code.
Did you already write some documentation or helper code about how they should do this? I think we ought to provide some…
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 pushed another couple of commits to add a helper function expand_dims()
.
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, @khaeru both for expanding the doc, the elegant workaround for adding the re-initialized items, and the help function. It looks like very well-structured code and fits the purpose nicely.
63737a2
to
66aaa6b
Compare
b444837
to
ce47871
Compare
And it will be nice if @JulianHunt4 or @adrivinca can review this content-wise, i.e, related to the functionality of storage. |
e94847c
to
cf979a7
Compare
Thanks for the PR, it seems everything works well. I wrote a comment to a point in the GAMs code where the mode component And last I was wondering if the branch should be rebased to message_ix 3.6, or if, since there are no conflicts, it does not matter. |
Thanks @adrivinca. Where is your comment, I can't see that? |
@@ -51,8 +51,8 @@ | |||
* :math:`REL_{r,n,y} \in \mathbb{R}` Auxiliary variable for left-hand side of relations (linear constraints) | |||
* :math:`COMMODITY\_USE_{n,c,l,y} \in \mathbb{R}` Auxiliary variable for amount of commodity used at specific level | |||
* :math:`COMMODITY\_BALANCE_{n,c,l,y,h} \in \mathbb{R}` Auxiliary variable for right-hand side of :ref:`commodity_balance` | |||
* :math:`STORAGE_{n,t,l,c,y,h} \in \mathbb{R}` State of charge or content of storage at each sub-annual timestep | |||
* :math:`STORAGE\_CHARGE_{n,t,l,c,y,h} \in \mathbb{R}` Charging of storage in each sub-annual timestep (negative for discharging) | |||
* :math:`STORAGE_{n,t,l,c,y,h} \in \mathbb{R}` State of charge or content of storage at each sub-annual time slice |
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.
shouldn't you add the mode
set here as well? or is it for version compatibility?
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 for noting this. I went through and added some missing indexes in the inline documentation.
@khaeru if you don't have any additional concerns here, I can merge this. |
GitHub says "This branch cannot be rebased due to conflicts". I'll try to rebase, then let's see if tests pass. |
04d8c57
to
70267db
Compare
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.
Ready to merge once checks all pass.
Thanks a lot @khaeru for finalizing this. |
53e020e
to
70267db
Compare
70267db
to
af375da
Compare
This PR addresses #632 by adding
mode
to the mapping set of storage technologies (map_tec_storage
) and also to storage equations.More details:
This change means re-initializing the existing set of
map_tec_storage
with new index sets. Based on the discussion in #631, this re-initializing happens automatically by modifications in the filemodels.py
, only if the mapping set is empty. If the set is not empty, an exception is raised, telling the user that they need to update this set.Moreover, this PR improves the documentation of storage section to reflect the above changes and more than that, adding required details for each equation.
How to review
keep_solution=False
); solve the cloned scenario again. The cloned scenario should solve without an error, if there is no content in the setmap_tec_storage
in that scenario. Otherwise, there should be an error asking you to update this set.test_feature_storage.py
from this PR on the main branch; it should fail.PR checklist
test_feature_storage.py
) to reflect the new changes.