-
Notifications
You must be signed in to change notification settings - Fork 0
add new fields to security analysis results (tab N) #200
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 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7ae4ff4
add new fields for the N tab of security analysis
carojeandat 7d3b34c
add test for PreContingencyLimitViolation's new fields
carojeandat 51e310a
fix
carojeandat 6a4121f
facto tests
carojeandat 04dab64
fix
carojeandat 030448e
clean
carojeandat a963246
clean
carojeandat 660c324
remove springboottest
carojeandat 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
122 changes: 122 additions & 0 deletions
122
src/test/java/org/gridsuite/securityanalysis/server/AbstractLimitViolationTest.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,122 @@ | ||
| /** | ||
| * 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.AbstractLimitViolationEntity; | ||
| import org.gridsuite.securityanalysis.server.entities.SubjectLimitViolationEntity; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.springframework.boot.test.context.SpringBootTest; | ||
|
|
||
| import static com.powsybl.iidm.network.test.EurostagTutorialExample1Factory.NGEN_NHV1; | ||
| import static com.powsybl.iidm.network.test.EurostagTutorialExample1Factory.NHV1_NHV2_1; | ||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
|
||
| /** | ||
| * @author Caroline Jeandat <caroline.jeandat at rte-france.com> | ||
| */ | ||
| @SpringBootTest | ||
| abstract class AbstractLimitViolationTest { | ||
|
|
||
| @Test | ||
| void testAbstractLimitViolationEntityNewFields() { | ||
| testAbstractLimitViolationMapping("10'", 10 * 60, 1200, 1, 1250, TwoSides.TWO, "1'", 1100, 10 * 60, null); | ||
| } | ||
|
|
||
| @Test | ||
| void testAbstractLimitViolationEntityNewFieldsWithPermanentLimitReached() { | ||
| testAbstractLimitViolationMapping(LimitViolationUtils.PERMANENT_LIMIT_NAME, Integer.MAX_VALUE, 1100, 1, 1150, | ||
| TwoSides.TWO, "10'", 1100, Integer.MAX_VALUE, null); | ||
| } | ||
|
|
||
| @Test | ||
| void testAbstractLimitViolationEntityNewFieldsWithPermanentLimitReachedAndNoTemporaryLimit() { | ||
| testAbstractLimitViolationMapping(LimitViolationUtils.PERMANENT_LIMIT_NAME, Integer.MAX_VALUE, 500, 1, 1000, | ||
| TwoSides.ONE, null, 500, Integer.MAX_VALUE, null); | ||
| } | ||
|
|
||
| @Test | ||
| void testAbstractLimitViolationEntityNewFieldsWithLastLimitReached() { | ||
| testAbstractLimitViolationMapping("N/A", 0, 1100, 1, 3000, TwoSides.TWO, null, 1100, 0, null); | ||
| } | ||
|
|
||
| @Test | ||
| void testAbstractLimitViolationEntityNewFieldsWithLimitReductionEffective() { | ||
| // for this test to be relevant, "value" needs to be less that "limit" | ||
| testAbstractLimitViolationMapping("10'", 60, 1200, 0.8, 1150, TwoSides.TWO, "1'", 1100, 10 * 60, 60); | ||
| } | ||
|
|
||
| @Test | ||
| void test2wtContingencyLimitViolationEntityNewFieldsWithLimitReductionEffective() { | ||
| // for this test to be relevant, "value" needs to be less that "limit" | ||
| Network network = EurostagTutorialExample1Factory.createWithFixedCurrentLimits(); | ||
| // create limit set for two windings transformer | ||
| network.getTwoWindingsTransformer(NGEN_NHV1).getOrCreateSelectedOperationalLimitsGroup1().newCurrentLimits() | ||
| .setPermanentLimit(100) | ||
| .beginTemporaryLimit() | ||
| .setName("10'") | ||
| .setValue(200) | ||
| .setAcceptableDuration(60 * 10) | ||
| .endTemporaryLimit() | ||
| .beginTemporaryLimit() | ||
| .setName("1'") | ||
| .setValue(300) | ||
| .setAcceptableDuration(60) | ||
| .endTemporaryLimit() | ||
| .beginTemporaryLimit() | ||
| .setName("N/A") | ||
| .setValue(Double.MAX_VALUE) | ||
| .setAcceptableDuration(0) | ||
| .endTemporaryLimit() | ||
| .add(); | ||
|
|
||
| LimitViolation limitViolation = new LimitViolation(NGEN_NHV1, "NGEN_NHV1_name", LimitViolationType.CURRENT, | ||
| "10'", 60, 200, 0.8, 180, TwoSides.ONE); | ||
|
|
||
| SubjectLimitViolationEntity subjectLimitViolationEntity = new SubjectLimitViolationEntity(NGEN_NHV1, | ||
| "NGEN_NHV1_name"); | ||
|
|
||
| AbstractLimitViolationEntity limitViolationEntity = createLimitViolationEntity(network, limitViolation, | ||
| subjectLimitViolationEntity); | ||
|
|
||
| assertEquals("1'", limitViolationEntity.getNextLimitName()); | ||
| assertEquals(100, limitViolationEntity.getPatlLimit()); | ||
| assertEquals(60 * 10, limitViolationEntity.getAcceptableDuration()); | ||
| assertEquals(60, limitViolationEntity.getUpcomingAcceptableDuration()); | ||
| assertEquals(100 * limitViolation.getValue() / limitViolationEntity.getPatlLimit(), | ||
| limitViolationEntity.getPatlLoading()); | ||
| } | ||
|
|
||
| private void testAbstractLimitViolationMapping(String limitName, int acceptableDuration, double limit, | ||
| double limitReduction, double value, TwoSides side, String expectedNextLimitName, long expectedPatlLimit, | ||
| Integer expectedAcceptableDuration, Integer expectedUpcomingAcceptableDuration) { | ||
| Network network = EurostagTutorialExample1Factory.createWithFixedCurrentLimits(); | ||
| LimitViolation limitViolation = new LimitViolation(NHV1_NHV2_1, "NHV1_NHV2_1_name", LimitViolationType.CURRENT, | ||
| limitName, acceptableDuration, limit, limitReduction, value, side); | ||
|
|
||
| SubjectLimitViolationEntity subjectLimitViolationEntity = new SubjectLimitViolationEntity(NHV1_NHV2_1, | ||
| "NHV1_NHV2_1_name"); | ||
|
|
||
| AbstractLimitViolationEntity limitViolationEntity = createLimitViolationEntity(network, limitViolation, | ||
| subjectLimitViolationEntity); | ||
|
|
||
| assertEquals(expectedNextLimitName, limitViolationEntity.getNextLimitName()); | ||
| assertEquals(expectedPatlLimit, limitViolationEntity.getPatlLimit()); | ||
| assertEquals(expectedAcceptableDuration, limitViolationEntity.getAcceptableDuration()); | ||
| assertEquals(expectedUpcomingAcceptableDuration, limitViolationEntity.getUpcomingAcceptableDuration()); | ||
| assertEquals(100 * limitViolation.getValue() / limitViolationEntity.getPatlLimit(), | ||
| limitViolationEntity.getPatlLoading()); | ||
| } | ||
|
|
||
| protected abstract AbstractLimitViolationEntity createLimitViolationEntity(Network network, | ||
| LimitViolation limitViolation, SubjectLimitViolationEntity subjectLimitViolationEntity); | ||
| } | ||
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
25 changes: 25 additions & 0 deletions
25
src/test/java/org/gridsuite/securityanalysis/server/PreContingencyLimitViolationTest.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,25 @@ | ||
| /** | ||
| * 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.security.LimitViolation; | ||
| import org.gridsuite.securityanalysis.server.entities.PreContingencyLimitViolationEntity; | ||
| import org.gridsuite.securityanalysis.server.entities.SubjectLimitViolationEntity; | ||
| import org.springframework.boot.test.context.SpringBootTest; | ||
|
|
||
| /** | ||
| * @author Caroline Jeandat <caroline.jeandat at rte-france.com> | ||
| */ | ||
| @SpringBootTest | ||
| class PreContingencyLimitViolationTest extends AbstractLimitViolationTest { | ||
|
|
||
| @Override | ||
| protected PreContingencyLimitViolationEntity createLimitViolationEntity(Network network, LimitViolation limitViolation, SubjectLimitViolationEntity subjectLimitViolationEntity) { | ||
| return PreContingencyLimitViolationEntity.toEntity(network, limitViolation, subjectLimitViolationEntity); | ||
| } | ||
| } |
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.