-
Notifications
You must be signed in to change notification settings - Fork 159
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
Correct GAMS for the assignment of "capacity_factor" at "year" #705
Conversation
Codecov Report
@@ Coverage Diff @@
## main #705 +/- ##
=====================================
Coverage 94.4% 94.4%
=====================================
Files 43 43
Lines 3432 3449 +17
=====================================
+ Hits 3241 3258 +17
Misses 191 191
|
Can confirm: on my main branch, the new test fails with the following error message: While this looks good, I'm also receiving a new RuntimeWarning:
I will try to understand where that comes from. |
6ae50f5
to
a0dc951
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.
Looks good to me, but I'd like to understand this RuntimeWarning
before approving.
) | ||
if i[1] != "year": | ||
cf.loc[i, "duration-corrected"] = cf.loc[i, "value"] * duration | ||
act.loc[i, "cf-corrected"] = act.loc[i, "lvl"] / float( |
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.
This seems to cause the RuntimeWarning
. I'm wondering about i
and the hardcoded index 1
: is that always correct or does it assume a certain structure of i
? If so, can we change to using no assumption?
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.
The problem arises in the test_capacity_factor_zero_two
, where the solar_pv_ppl
has a capacity_factor
of 0
in the time slice night
. In
if i[1] != "year":
cf.loc[i, "duration-corrected"] = cf.loc[i, "value"] * duration
act.loc[i, "cf-corrected"] = act.loc[i, "lvl"] / float(
cf.loc[i, "duration-corrected"]
)
this gives us a division by 0 since cf.loc[i, "value"]
is 0. So we have to provide some condition/prescription on how to deal with cases like this.
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've now added a condition that checks if either duration
or cf.loc[i, "value"]
are 0
. In that case, we now set act.loc[i, "cf-corrected"]
to act.loc[i, "lvl"]
, so we don't change it. This relies on the assumption that in this case, act.loc[i, "lvl"]
will also be 0, which is implied (and asserted) by the test in line 19.
All the tests are still passing for me, but there's no RuntimeWarning
anymore.
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 @glatterf42 for reviewing this and suggesting improvements. Indeed, as you noted, zero capacity factors are tested and they can be excluded from the follow-up calculations. The index i
in that loop is a tuple with two members, the first one being the technology name and the second time slices. So, the index 1
is always related to time.
a0dc951
to
09fca14
Compare
* Set cf-corrected act to lvl act if cf or duration are 0 * This assumes somewhat that lvl act will be 0 in that case * Line 19 suggests that this is the case * Fix some typos
09fca14
to
55abd89
Compare
This PR resolves issue #409. The GAMS formulation is corrected not to assign a capacity factor of 1 at "year" if the value is missing in a scenario with sub-annual time slices. The weighted average of capacity factors defined for sub-annual time slices can be used to calculate the capacity factor for "year". This is tested by extending the existing tests in
test_capacity_factor_feature
, i.e., adding data for parameter "operation_factor", which uses capacity factor at "year".How to review
The test
test_capacity_factor_feature
should pass with the GAMS formulation in this PR. However, this test must fail if using GAMS formulation of the main branch ofmessage_ix
. So, first, copy this test to your main branch and ensure it fails. Then, switch to this branch and run the tests again and make sure they pass.PR checklist