Fix masking of ramp constraints for assets with NaN ramp limits#1494
Merged
lkstrp merged 4 commits intoPyPSA:masterfrom Dec 16, 2025
Merged
Fix masking of ramp constraints for assets with NaN ramp limits#1494lkstrp merged 4 commits intoPyPSA:masterfrom
lkstrp merged 4 commits intoPyPSA:masterfrom
Conversation
Contributor
Author
|
Hi @lkstrp, |
lkstrp
approved these changes
Dec 16, 2025
Contributor
|
Thanks @sasa821 for spotting and fixing it! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1493
Changes proposed in this Pull Request
This PR fixes a bug in PyPSA ≥ 1.0 where ramp constraints were applied to fixed generators and links with NaN ramp_limit_up/down once ramping was enabled for any other asset of the same component.
In the
define_ramp_limit_constraintsfunction, the masking logic for fixed components currently uses:Calling
.all()collapses the array across all dimensions and produces a scalar boolean. As a result, once any fixed asset has a ramp limit defined, the ramp constraint is applied to all fixed assets, including those with NaN ramp limits.Consequently, assets without specified ramp limits can receive ramp constraints equal to zero, leading to unintended infeasibilities (e.g. for load-shedding or slack generators).
This PR replaces the scalar check with element-wise masking, so that ramp constraints are only created for assets (and snapshots) where ramp limits are explicitly defined.
Checklist
docs.docs/release-notes.mdof the upcoming release is included.