-
Notifications
You must be signed in to change notification settings - Fork 0
New fields in SA results - limit violations #197
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,7 +52,7 @@ public static PreContingencyLimitViolationEntity toEntity(Network network, Limit | |
.limitReduction(limitViolation.getLimitReduction()) | ||
.value(limitViolation.getValue()) | ||
.side(limitViolation.getSide()) | ||
.loading(computeLoading(limitViolation)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we don't want the same changes for N results? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. N results will be chaged on other US |
||
.loading(computeLoading(limitViolation, limitViolation.getLimit())) | ||
.locationId(ComputationResultUtils.getViolationLocationId(limitViolation, network)) | ||
.build(); | ||
} | ||
|
33 changes: 33 additions & 0 deletions
33
src/main/resources/db/changelog/changesets/changelog_20250903T125946Z.xml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.1" encoding="UTF-8" standalone="no"?> | ||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:pro="http://www.liquibase.org/xml/ns/pro" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-latest.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd"> | ||
<changeSet author="lesaulnierkev (generated)" id="1756904408172-1"> | ||
<addColumn tableName="contingency_limit_violation"> | ||
<column name="next_limit_name" type="varchar(255)"/> | ||
</addColumn> | ||
</changeSet> | ||
<changeSet author="lesaulnierkev (generated)" id="1756904408172-2"> | ||
<addColumn tableName="pre_contingency_limit_violation"> | ||
<column name="next_limit_name" type="varchar(255)"/> | ||
</addColumn> | ||
</changeSet> | ||
<changeSet author="lesaulnierkev (generated)" id="1756904408172-3"> | ||
<addColumn tableName="contingency_limit_violation"> | ||
<column name="patl_limit" type="float(53)"/> | ||
</addColumn> | ||
</changeSet> | ||
<changeSet author="lesaulnierkev (generated)" id="1756904408172-4"> | ||
<addColumn tableName="pre_contingency_limit_violation"> | ||
<column name="patl_limit" type="float(53)"/> | ||
</addColumn> | ||
</changeSet> | ||
<changeSet author="lesaulnierkev (generated)" id="1756904408172-7"> | ||
<addColumn tableName="contingency_limit_violation"> | ||
<column name="patl_loading" type="float(53)"/> | ||
</addColumn> | ||
</changeSet> | ||
<changeSet author="lesaulnierkev (generated)" id="1756904408172-8"> | ||
<addColumn tableName="pre_contingency_limit_violation"> | ||
<column name="patl_loading" type="float(53)"/> | ||
</addColumn> | ||
</changeSet> | ||
</databaseChangeLog> |
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
60 changes: 60 additions & 0 deletions
60
src/test/java/org/gridsuite/securityanalysis/server/ContingencyLimitViolationTest.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/** | ||
* Copyright (c) 2025, RTE (http://www.rte-france.com) | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
package org.gridsuite.securityanalysis.server; | ||
|
||
import com.powsybl.iidm.network.Network; | ||
import com.powsybl.iidm.network.TwoSides; | ||
import com.powsybl.iidm.network.test.EurostagTutorialExample1Factory; | ||
import com.powsybl.iidm.network.util.LimitViolationUtils; | ||
import com.powsybl.security.LimitViolation; | ||
import com.powsybl.security.LimitViolationType; | ||
import org.gridsuite.securityanalysis.server.entities.ContingencyLimitViolationEntity; | ||
import org.gridsuite.securityanalysis.server.entities.SubjectLimitViolationEntity; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
/** | ||
* @author Kevin Le Saulnier <kevin.lesaulnier at rte-france.com> | ||
*/ | ||
@SpringBootTest | ||
class ContingencyLimitViolationTest { | ||
|
||
@Test | ||
void testContingencyLimitViolationEntityNewFields() { | ||
testContingencyLimitViolationMapping("10'", 10 * 60, 1200, 1250, TwoSides.TWO, "1'", 1100); | ||
} | ||
|
||
@Test | ||
void testContingencyLimitViolationEntityNewFieldsWithPermanentLimitReached() { | ||
testContingencyLimitViolationMapping(LimitViolationUtils.PERMANENT_LIMIT_NAME, Integer.MAX_VALUE, 1100, 1150, TwoSides.TWO, "10'", 1100); | ||
} | ||
|
||
@Test | ||
void testContingencyLimitViolationEntityNewFieldsWithPermanentLimitReachedAndNoTemporaryLimit() { | ||
testContingencyLimitViolationMapping(LimitViolationUtils.PERMANENT_LIMIT_NAME, Integer.MAX_VALUE, 500, 1000, TwoSides.ONE, null, 500); | ||
} | ||
|
||
@Test | ||
void testContingencyLimitViolationEntityNewFieldsWithLastLimitReached() { | ||
testContingencyLimitViolationMapping("N/A", 0, 1100, 3000, TwoSides.TWO, null, 1100); | ||
} | ||
|
||
private void testContingencyLimitViolationMapping(String limitName, int acceptableDuration, double limit, double value, TwoSides side, String expectedNextLimitName, long expectedPatlLimit) { | ||
Network network = EurostagTutorialExample1Factory.createWithFixedCurrentLimits(); | ||
LimitViolation limitViolation = new LimitViolation("NHV1_NHV2_1", "NHV1_NHV2_1_name", LimitViolationType.CURRENT, limitName, acceptableDuration, limit, 1, value, side); | ||
|
||
SubjectLimitViolationEntity subjectLimitViolationEntity = new SubjectLimitViolationEntity("NHV1_NHV2_1", "NHV1_NHV2_1_name"); | ||
|
||
ContingencyLimitViolationEntity contingencyLimitViolationEntity = ContingencyLimitViolationEntity.toEntity(network, limitViolation, subjectLimitViolationEntity); | ||
|
||
assertEquals(expectedNextLimitName, contingencyLimitViolationEntity.getNextLimitName()); | ||
assertEquals(expectedPatlLimit, contingencyLimitViolationEntity.getPatlLimit()); | ||
assertEquals(100 * limitViolation.getValue() / contingencyLimitViolationEntity.getPatlLimit(), contingencyLimitViolationEntity.getPatlLoading()); | ||
} | ||
} |
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
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
NIT: if you're dealing with branches, you could have used TwoSides
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.
fixed