Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -831,32 +831,32 @@ private static Stream<Arguments> provideUtilCheckTemporaryLimitsArguments() {
ThreeWindingsTransformer transformer = network3wt.getThreeWindingsTransformer(EurostagTutorialExample1Factory.NGEN_V2_NHV1);

return Stream.of(
Arguments.of(l, ThreeSides.ONE, List.of(1., 0.95), LimitType.CURRENT, 299, List.of()), // below any permanent limit
Arguments.of(l, ThreeSides.ONE, List.of(1., 0.8), LimitType.CURRENT, 310, List.of(
Arguments.of(l, ThreeSides.ONE, List.of(1., 0.95, 1.12), LimitType.CURRENT, 299, List.of()), // below any permanent limit
Arguments.of(l, ThreeSides.ONE, List.of(1., 0.8, 1.37), LimitType.CURRENT, 310, List.of(
new ExpectedOverload(
LimitViolationUtils.PERMANENT_LIMIT_NAME,
EurostagTutorialExample1Factory.ACTIVATED_ONE_TWO,
300,
60 * 40
)
)), // above permanent of activated_1_2
Arguments.of(l, ThreeSides.ONE, List.of(1., 0.82), LimitType.CURRENT, 510, List.of(
Arguments.of(l, ThreeSides.ONE, List.of(1., 0.82, 1.23), LimitType.CURRENT, 510, List.of(
new ExpectedOverload(
LimitViolationUtils.PERMANENT_LIMIT_NAME,
EurostagTutorialExample1Factory.ACTIVATED_ONE_TWO,
300,
60 * 40
)
)), // above permanent of Default, but no temporary above. `checkAllTemporaryLimits` doesn't detect anything in this case. It is the responsibility of `checkPermanentLimit`
Arguments.of(l, ThreeSides.ONE, List.of(1., 0.7), LimitType.CURRENT, 701, List.of(
Arguments.of(l, ThreeSides.ONE, List.of(1., 0.7, 1.5), LimitType.CURRENT, 701, List.of(
new ExpectedOverload(
"40'",
EurostagTutorialExample1Factory.ACTIVATED_ONE_TWO,
700,
30
)
)), // above first temporary of 1_2
Arguments.of(l, ThreeSides.ONE, List.of(1., 0.92), LimitType.CURRENT, 1122, List.of(
Arguments.of(l, ThreeSides.ONE, List.of(1., 0.92, 2.), LimitType.CURRENT, 1122, List.of(
new ExpectedOverload(
"40'",
EurostagTutorialExample1Factory.ACTIVATED_ONE_TWO,
Expand All @@ -870,7 +870,7 @@ private static Stream<Arguments> provideUtilCheckTemporaryLimitsArguments() {
60 * 10
)
)), // above permanent of 1_1
Arguments.of(l, ThreeSides.ONE, List.of(1., 0.87), LimitType.CURRENT, 1450, List.of(
Arguments.of(l, ThreeSides.ONE, List.of(1., 0.87, 1.43), LimitType.CURRENT, 1450, List.of(
new ExpectedOverload(
"40'",
EurostagTutorialExample1Factory.ACTIVATED_ONE_TWO,
Expand All @@ -884,7 +884,7 @@ private static Stream<Arguments> provideUtilCheckTemporaryLimitsArguments() {
60
)
)), // above first temporary of 1_1
Arguments.of(l, ThreeSides.ONE, List.of(1., 0.3), LimitType.CURRENT, 1500, List.of(
Arguments.of(l, ThreeSides.ONE, List.of(1., 0.3, 3.1), LimitType.CURRENT, 1500, List.of(
new ExpectedOverload(
"40'",
EurostagTutorialExample1Factory.ACTIVATED_ONE_TWO,
Expand All @@ -898,7 +898,7 @@ private static Stream<Arguments> provideUtilCheckTemporaryLimitsArguments() {
0
)
)), // above last temporary of 1_1
Arguments.of(l, ThreeSides.ONE, List.of(1., 0.84), LimitType.CURRENT, 1601, List.of(
Arguments.of(l, ThreeSides.ONE, List.of(1., 0.84, 1.75), LimitType.CURRENT, 1601, List.of(
new ExpectedOverload(
"0.5'",
EurostagTutorialExample1Factory.ACTIVATED_ONE_TWO,
Expand All @@ -912,17 +912,17 @@ private static Stream<Arguments> provideUtilCheckTemporaryLimitsArguments() {
0
)
)), // above last temporary of 1_2
Arguments.of(transformer, ThreeSides.THREE, List.of(1., 0.99), LimitType.ACTIVE_POWER, 200, List.of()), //under all limits
Arguments.of(transformer, ThreeSides.THREE, List.of(1., 0.96), LimitType.ACTIVE_POWER, 275, List.of()), // above permanent of Default, but no temporary above. `checkAllTemporaryLimits` doesn't detect anything in this case. It is the responsibility of `checkPermanentLimit`
Arguments.of(transformer, ThreeSides.THREE, List.of(1., 0.88), LimitType.ACTIVE_POWER, 375, List.of(
Arguments.of(transformer, ThreeSides.THREE, List.of(1., 0.99, 1.01), LimitType.ACTIVE_POWER, 200, List.of()), //under all limits
Arguments.of(transformer, ThreeSides.THREE, List.of(1., 0.96, 1.87), LimitType.ACTIVE_POWER, 275, List.of()), // above permanent of Default, but no temporary above. `checkAllTemporaryLimits` doesn't detect anything in this case. It is the responsibility of `checkPermanentLimit`
Arguments.of(transformer, ThreeSides.THREE, List.of(1., 0.88, 1.64), LimitType.ACTIVE_POWER, 375, List.of(
new ExpectedOverload(
LimitViolationUtils.PERMANENT_LIMIT_NAME,
EurostagTutorialExample1Factory.ACTIVATED_THREE_ONE,
350,
45 * 60
)
)), // above permanent of activated_3_1
Arguments.of(transformer, ThreeSides.THREE, List.of(1., 0.77), LimitType.ACTIVE_POWER, 405, List.of(
Arguments.of(transformer, ThreeSides.THREE, List.of(1., 0.77, 1.67), LimitType.ACTIVE_POWER, 405, List.of(
new ExpectedOverload(
"45'",
EurostagTutorialExample1Factory.ACTIVATED_THREE_ONE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ private LimitReduction(LimitType limitType, double value, boolean monitoringOnly
} else {
throw new PowsyblException(limitType + " is not a supported limit type for limit reduction");
}
if (value > 1. || value < 0.) {
throw new PowsyblException("Limit reduction value should be in [0;1]");
if (value < 0.) {
throw new PowsyblException("Limit reduction value should be equal or more than 0");
Comment thread
NathanDissoubray marked this conversation as resolved.
Outdated
}
this.value = value;
this.monitoringOnly = monitoringOnly;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
*/

public class LimitReductionList {
public static final String VERSION = "1.1";
// v1.2 introduces limit increase (reduction with value above 1)
public static final String VERSION = "1.2";
private final List<LimitReduction> limitReductions;

public LimitReductionList(List<LimitReduction> limitReductions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,54 @@ void testVoltageViolationDetection() {
});
}

@Test
void testSingleTempLimitIncrease() {
Network network = EurostagTutorialExample1Factory.createWithMultipleSelectedFixedCurrentLimits();
Line line = network.getLine(EurostagTutorialExample1Factory.NHV1_NHV2_1);
DefaultLimitReductionsApplier applier = new DefaultLimitReductionsApplier(
List.of(LimitReduction.builder(LimitType.CURRENT, 1.1)
.withOperationalLimitsGroupIdSelection(List.of(EurostagTutorialExample1Factory.ACTIVATED_ONE_ONE))
.withLimitDurationCriteria(new EqualityTemporaryDurationCriterion(600))
.build()
)
);
line.setSelectedOperationalLimitsGroup1(EurostagTutorialExample1Factory.ACTIVATED_ONE_ONE);
LimitViolationDetection.checkLimitViolation(
line, TwoSides.ONE, 1300., LimitType.CURRENT, Set.of(LoadingLimitType.TATL, LoadingLimitType.PATL), applier, violationsCollector::add
);
assertEquals(1, violationsCollector.size());
LimitViolation violation = violationsCollector.getFirst();
// the limit at 1200 is raised to 1320
assertEquals(LimitViolationUtils.PERMANENT_LIMIT_NAME, violation.getLimitName());
assertEquals(600, violation.getAcceptableDuration());
assertEquals(1100, violation.getLimit());
assertEquals(1, violation.getLimitReduction());
}

@Test
void testTempLimitInterveredWithIncrease() {
Comment thread
olperr1 marked this conversation as resolved.
Outdated
Network network = EurostagTutorialExample1Factory.createWithMultipleSelectedFixedCurrentLimits();
Line line = network.getLine(EurostagTutorialExample1Factory.NHV1_NHV2_1);
DefaultLimitReductionsApplier applier = new DefaultLimitReductionsApplier(
List.of(LimitReduction.builder(LimitType.CURRENT, 1.3)
.withOperationalLimitsGroupIdSelection(List.of(EurostagTutorialExample1Factory.ACTIVATED_ONE_ONE))
.withLimitDurationCriteria(new EqualityTemporaryDurationCriterion(600))
.build()
)
);
line.setSelectedOperationalLimitsGroup1(EurostagTutorialExample1Factory.ACTIVATED_ONE_ONE);
LimitViolationDetection.checkLimitViolation(
line, TwoSides.ONE, 1300., LimitType.CURRENT, Set.of(LoadingLimitType.TATL, LoadingLimitType.PATL), applier, violationsCollector::add
);
assertEquals(1, violationsCollector.size());
LimitViolation violation = violationsCollector.getFirst();
// the limit at 1200 is raised to 1560 above the limit at 1500
assertEquals(LimitViolationUtils.PERMANENT_LIMIT_NAME, violation.getLimitName());
assertEquals(60, violation.getAcceptableDuration());
assertEquals(1100, violation.getLimit());
assertEquals(1, violation.getLimitReduction());
}
Comment thread
olperr1 marked this conversation as resolved.

@Test
void testVoltageViolationDetectionWithDetailLimitViolationId() {
Network network = EurostagTutorialExample1Factory.createWithFixedCurrentLimits();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,21 @@ void limitReductionReadV10() {
compareLimitReductionList(expectedReductions, limitReductionList);
}

@Test
void limitReductionReadV11() {
LimitReductionList limitReductionList = LimitReductionListSerDeUtil.read(getClass().getResourceAsStream("/LimitReductionsV1.1.json"));
LimitReductionList expectedReductions = new LimitReductionList(
List.of(
getLimitReduction1(),
getLimitReduction2(),
getLimitReduction3(),
getLimitReduction4(),
getLimitReduction5()
)
);
compareLimitReductionList(expectedReductions, limitReductionList);
}

private void compareLimitReductionList(LimitReductionList expected, LimitReductionList actual) {
Assertions.assertThat(actual.getLimitReductions())
.hasSize(expected.getLimitReductions().size())
Expand Down Expand Up @@ -79,19 +94,27 @@ private void compareLimitReductionList(LimitReductionList expected, LimitReducti

@Test
void roundTripTest() throws IOException {
LimitReductionList limitReductionList = new LimitReductionList(List.of(getLimitReduction1(), getLimitReduction2(), getLimitReduction3(), getLimitReduction4(), getLimitReduction5()));
LimitReductionList limitReductionList = new LimitReductionList(
List.of(
getLimitReduction1(),
getLimitReduction2(),
getLimitReduction3(),
getLimitReduction4(),
getLimitReduction5(),
getLimitReduction6()
));

roundTripTest(limitReductionList, LimitReductionListSerDeUtil::write,
LimitReductionListSerDeUtil::read,
"/LimitReductionsV1.1.json");
"/LimitReductionsV1.2.json");
}

@Test
void compatibilityWithOldCriterion() throws IOException {
LimitReductionList reductionList = LimitReductionListSerDeUtil.read(getClass().getResourceAsStream("/LimitReductionsV1.0.json"));
try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
LimitReductionListSerDeUtil.write(reductionList, bos);
ComparisonUtils.assertTxtEquals(getClass().getResourceAsStream("/LimitReductions_no_limits_groupV1.1.json"), new ByteArrayInputStream(bos.toByteArray()));
ComparisonUtils.assertTxtEquals(getClass().getResourceAsStream("/LimitReductions_no_limits_groupV1.2.json"), new ByteArrayInputStream(bos.toByteArray()));
} catch (Exception e) {
// Should not happen
fail();
Expand Down Expand Up @@ -151,4 +174,10 @@ private LimitReduction getLimitReduction5() {
.withOperationalLimitsGroupIdSelection("DEFAULT", "activated_1_3", "activated_2_1")
.build();
}

private LimitReduction getLimitReduction6() {
return LimitReduction.builder(LimitType.CURRENT, 1.13)
.withLimitDurationCriteria(IntervalTemporaryDurationCriterion.builder().setLowBound(60, true).build())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,8 @@ void unsupportedLimitType() {

@Test
void unsupportedLimitReductionValues() {
String expectedMessage = "Limit reduction value should be in [0;1]";
String expectedMessage = "Limit reduction value should be equal or more than 0";
Comment thread
NathanDissoubray marked this conversation as resolved.
Outdated
Exception e = assertThrows(PowsyblException.class, () -> new LimitReduction(LimitType.CURRENT, -0.5, true));
assertEquals(expectedMessage, e.getMessage());

e = assertThrows(PowsyblException.class, () -> new LimitReduction(LimitType.CURRENT, 1.3));
assertEquals(expectedMessage, e.getMessage());
}
}
Loading
Loading