-
Notifications
You must be signed in to change notification settings - Fork 43
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 fix to Matpower importer to import some pglib files #3256
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
matpower/matpower-model/src/main/java/com/powsybl/matpower/model/MatpowerReader.java
Outdated
Show resolved
Hide resolved
gen.setRampThirtyMinutes(generators.getDouble(row, 18)); | ||
gen.setRampQ(generators.getDouble(row, 19)); | ||
gen.setApf(generators.getDouble(row, 20)); | ||
if (generators.getDimensions()[1] > MATPOWER_V1_GENERATORS_COLUMNS) { |
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.
As discussed together, it would be safer to use the following test here:
if (generators.getDimensions()[1] >= MATPOWER_V2_GENERATORS_COLUMNS)
=>
- if dimension <
MATPOWER_V1_GENERATORS_COLUMNS
: error - if dimension in
[ MATPOWER_V1_GENERATORS_COLUMNS ; MATPOWER_V2_GENERATORS_COLUMNS [
: considered as V1 format; - if dimension >=
MATPOWER_V2_GENERATORS_COLUMNS
: considered as V2 format.
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
gen.setRampThirtyMinutes(generators.getDouble(row, 18)); | ||
gen.setRampQ(generators.getDouble(row, 19)); | ||
gen.setApf(generators.getDouble(row, 20)); | ||
if (generatorColumnsToRead > 9) { |
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, the method will throw an exception in case of a generator table in v1 format (method called with MATPOWER_V1_GENERATORS_COLUMNS
which equals 10).
But it may be clearer to have this test instead:
if (generatorColumnsToRead > 9) { | |
if (generatorColumnsToRead == MATPOWER_V2_GENERATORS_COLUMNS) { |
because it will be easier to relate it to the possible values for generatorColumnsToRead
.
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 tried another design
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Quality Gate passedIssues Measures |
Please check if the PR fulfills these requirements
Does this PR already have an issue describing the problem?
No
What kind of change does this PR introduce?
Feature
What is the current behavior?
Some matpower files like pglib_opf_case1354_pegase.m from https://github.com/power-grid-lib/pglib-opf cannot be imported because the generator column count correspond to v1 format and not v2.
What is the new behavior (if this is a feature change)?
We accept to read the file anyway even with missing columns.
Does this PR introduce a breaking change or deprecate an API?
If yes, please check if the following requirements are fulfilled
What changes might users need to make in their application due to this PR? (migration steps)
Other information: