|
17 | 17 | import org.junit.jupiter.api.Test;
|
18 | 18 | import org.springframework.boot.test.context.SpringBootTest;
|
19 | 19 |
|
| 20 | +import static com.powsybl.iidm.network.test.EurostagTutorialExample1Factory.NGEN_NHV1; |
| 21 | +import static com.powsybl.iidm.network.test.EurostagTutorialExample1Factory.NHV1_NHV2_1; |
20 | 22 | import static org.junit.jupiter.api.Assertions.assertEquals;
|
21 | 23 |
|
22 | 24 | /**
|
23 | 25 | * @author Kevin Le Saulnier <kevin.lesaulnier at rte-france.com>
|
24 | 26 | */
|
25 | 27 | @SpringBootTest
|
26 | 28 | class ContingencyLimitViolationTest {
|
27 |
| - |
28 | 29 | @Test
|
29 | 30 | void testContingencyLimitViolationEntityNewFields() {
|
30 |
| - testContingencyLimitViolationMapping("10'", 10 * 60, 1200, 1250, TwoSides.TWO, "1'", 1100); |
| 31 | + testContingencyLimitViolationMapping("10'", 10 * 60, 1200, 1, 1250, TwoSides.TWO, "1'", 1100, 10 * 60, null); |
31 | 32 | }
|
32 | 33 |
|
33 | 34 | @Test
|
34 | 35 | void testContingencyLimitViolationEntityNewFieldsWithPermanentLimitReached() {
|
35 |
| - testContingencyLimitViolationMapping(LimitViolationUtils.PERMANENT_LIMIT_NAME, Integer.MAX_VALUE, 1100, 1150, TwoSides.TWO, "10'", 1100); |
| 36 | + testContingencyLimitViolationMapping(LimitViolationUtils.PERMANENT_LIMIT_NAME, Integer.MAX_VALUE, 1100, 1, 1150, TwoSides.TWO, "10'", 1100, Integer.MAX_VALUE, null); |
36 | 37 | }
|
37 | 38 |
|
38 | 39 | @Test
|
39 | 40 | void testContingencyLimitViolationEntityNewFieldsWithPermanentLimitReachedAndNoTemporaryLimit() {
|
40 |
| - testContingencyLimitViolationMapping(LimitViolationUtils.PERMANENT_LIMIT_NAME, Integer.MAX_VALUE, 500, 1000, TwoSides.ONE, null, 500); |
| 41 | + testContingencyLimitViolationMapping(LimitViolationUtils.PERMANENT_LIMIT_NAME, Integer.MAX_VALUE, 500, 1, 1000, TwoSides.ONE, null, 500, Integer.MAX_VALUE, null); |
41 | 42 | }
|
42 | 43 |
|
43 | 44 | @Test
|
44 | 45 | void testContingencyLimitViolationEntityNewFieldsWithLastLimitReached() {
|
45 |
| - testContingencyLimitViolationMapping("N/A", 0, 1100, 3000, TwoSides.TWO, null, 1100); |
| 46 | + testContingencyLimitViolationMapping("N/A", 0, 1100, 1, 3000, TwoSides.TWO, null, 1100, 0, null); |
| 47 | + } |
| 48 | + |
| 49 | + @Test |
| 50 | + void testContingencyLimitViolationEntityNewFieldsWithLimitReductionEffective() { |
| 51 | + // for this test to be relevant, "value" needs to be less that "limit" |
| 52 | + testContingencyLimitViolationMapping("10'", 60, 1200, 0.8, 1150, TwoSides.TWO, "1'", 1100, 10 * 60, 60); |
| 53 | + } |
| 54 | + |
| 55 | + @Test |
| 56 | + void test2wtContingencyLimitViolationEntityNewFieldsWithLimitReductionEffective() { |
| 57 | + // for this test to be relevant, "value" needs to be less that "limit" |
| 58 | + Network network = EurostagTutorialExample1Factory.createWithFixedCurrentLimits(); |
| 59 | + // create limit set for two windings transformer |
| 60 | + network.getTwoWindingsTransformer(NGEN_NHV1).getOrCreateSelectedOperationalLimitsGroup1().newCurrentLimits() |
| 61 | + .setPermanentLimit(100) |
| 62 | + .beginTemporaryLimit() |
| 63 | + .setName("10'") |
| 64 | + .setValue(200) |
| 65 | + .setAcceptableDuration(60 * 10) |
| 66 | + .endTemporaryLimit() |
| 67 | + .beginTemporaryLimit() |
| 68 | + .setName("1'") |
| 69 | + .setValue(300) |
| 70 | + .setAcceptableDuration(60) |
| 71 | + .endTemporaryLimit() |
| 72 | + .beginTemporaryLimit() |
| 73 | + .setName("N/A") |
| 74 | + .setValue(Double.MAX_VALUE) |
| 75 | + .setAcceptableDuration(0) |
| 76 | + .endTemporaryLimit() |
| 77 | + .add(); |
| 78 | + |
| 79 | + LimitViolation limitViolation = new LimitViolation(NGEN_NHV1, "NGEN_NHV1_name", LimitViolationType.CURRENT, "10'", 60, 200, 0.8, 180, TwoSides.ONE); |
| 80 | + |
| 81 | + SubjectLimitViolationEntity subjectLimitViolationEntity = new SubjectLimitViolationEntity(NGEN_NHV1, "NGEN_NHV1_name"); |
| 82 | + |
| 83 | + ContingencyLimitViolationEntity contingencyLimitViolationEntity = ContingencyLimitViolationEntity.toEntity(network, limitViolation, subjectLimitViolationEntity); |
| 84 | + |
| 85 | + assertEquals("1'", contingencyLimitViolationEntity.getNextLimitName()); |
| 86 | + assertEquals(100, contingencyLimitViolationEntity.getPatlLimit()); |
| 87 | + assertEquals(60 * 10, contingencyLimitViolationEntity.getAcceptableDuration()); |
| 88 | + assertEquals(60, contingencyLimitViolationEntity.getUpcomingAcceptableDuration()); |
| 89 | + assertEquals(100 * limitViolation.getValue() / contingencyLimitViolationEntity.getPatlLimit(), contingencyLimitViolationEntity.getPatlLoading()); |
46 | 90 | }
|
47 | 91 |
|
48 |
| - private void testContingencyLimitViolationMapping(String limitName, int acceptableDuration, double limit, double value, TwoSides side, String expectedNextLimitName, long expectedPatlLimit) { |
| 92 | + private void testContingencyLimitViolationMapping(String limitName, int acceptableDuration, double limit, double limitReduction, double value, TwoSides side, String expectedNextLimitName, long expectedPatlLimit, Integer expectedAcceptableDuration, Integer expectedUpcomingAcceptableDuration) { |
49 | 93 | Network network = EurostagTutorialExample1Factory.createWithFixedCurrentLimits();
|
50 |
| - LimitViolation limitViolation = new LimitViolation("NHV1_NHV2_1", "NHV1_NHV2_1_name", LimitViolationType.CURRENT, limitName, acceptableDuration, limit, 1, value, side); |
| 94 | + LimitViolation limitViolation = new LimitViolation(NHV1_NHV2_1, "NHV1_NHV2_1_name", LimitViolationType.CURRENT, limitName, acceptableDuration, limit, limitReduction, value, side); |
51 | 95 |
|
52 |
| - SubjectLimitViolationEntity subjectLimitViolationEntity = new SubjectLimitViolationEntity("NHV1_NHV2_1", "NHV1_NHV2_1_name"); |
| 96 | + SubjectLimitViolationEntity subjectLimitViolationEntity = new SubjectLimitViolationEntity(NHV1_NHV2_1, "NHV1_NHV2_1_name"); |
53 | 97 |
|
54 | 98 | ContingencyLimitViolationEntity contingencyLimitViolationEntity = ContingencyLimitViolationEntity.toEntity(network, limitViolation, subjectLimitViolationEntity);
|
55 | 99 |
|
56 | 100 | assertEquals(expectedNextLimitName, contingencyLimitViolationEntity.getNextLimitName());
|
57 | 101 | assertEquals(expectedPatlLimit, contingencyLimitViolationEntity.getPatlLimit());
|
| 102 | + assertEquals(expectedAcceptableDuration, contingencyLimitViolationEntity.getAcceptableDuration()); |
| 103 | + assertEquals(expectedUpcomingAcceptableDuration, contingencyLimitViolationEntity.getUpcomingAcceptableDuration()); |
58 | 104 | assertEquals(100 * limitViolation.getValue() / contingencyLimitViolationEntity.getPatlLimit(), contingencyLimitViolationEntity.getPatlLoading());
|
59 | 105 | }
|
60 | 106 | }
|
0 commit comments