-
Notifications
You must be signed in to change notification settings - Fork 17
Fixed negativity in sqrt in costs.py by np.clip. #4065
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
Conversation
|
Closes #4024 |
1eb51dd to
4b52644
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4065 +/- ##
==========================================
- Coverage 46.60% 46.50% -0.11%
==========================================
Files 122 124 +2
Lines 28711 28961 +250
==========================================
+ Hits 13381 13468 +87
- Misses 15330 15493 +163 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
4b52644 to
4422c12
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.
I've spoken with quite a few people about this, some of these comments and concerns are written in the original issue.
The model is clearly flawed because it uses net electric to try and estimate the O&M cost. This is done because all O&M models in the literature are fits on data from existing fission/gas plants. I suspect net electric is used here as a loose proxy for plant complexity.
My suggestion is to accept and merge this PR because it will fix the negative square root, and does no harm: the cost model will produce a NaN if given a negative number and so producing a 0 instead is no worse.
An issue should be created where we can discuss and plan how to produce more realistic O&M costs that rely on something a bit more meaningful that net electric.
@geograham @j-a-foster how does this sound to you? If we all agree, I will merge this PR, create an issue and we can discuss our concerns further there and plan if/how we want to fix it.
process/costs.py
Outdated
|
|
||
| annoam = cost_variables.ucoam[cost_variables.lsa - 1] * np.sqrt( | ||
| heat_transport_variables.p_plant_electric_net_mw / 1200.0e0 | ||
| np.clip(heat_transport_variables.p_plant_electric_net_mw, 0, np.inf) |
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.
Can we add a warning when the net electric is negative and the value will be clipped?
I think this makes sense - a warning about clipped net electric in the meantime is also a good idea. |
|
Funnily enough that might bring us almost full circle back to issue #4024; but in some way progress is still made by identifying the bug. @timothy-nunn If you're happy with @geograham 's solution then I'll add a warning back in. |
Hi @OceanNuclear, I think lets add the warning. This warning won't be a cryptic 'divide by 0' warning and it will reported as a model warning ( |
… of the method coelc to warn in case p_plant_electric_net_mw is negative. Also caught a third place where sqrt_p_plant_electric_net_mw is needed .(missed earlier as it was commented out)
timothy-nunn
left a comment
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 improving the clarity of the error message
Clarified what's the purpose of the calculation inside the warning. Co-authored-by: Timothy <75321887+timothy-nunn@users.noreply.github.com>
timothy-nunn
left a comment
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 /1200 was in the square root before
…previously over-corrected)
Description
Patches away the RuntimeWarning caused by sqrt(p_plant_electric_net_mw/1200), where p_plant_electric_net_mw may cross over to negative values briefly during the optimization process (but is expected to always converge on a positive value).
Checklist
I confirm that I have completed the following checks: