Skip to content
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 generator filter on terminal P absolute #47

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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 @@ -180,7 +180,8 @@ private static String getGeneratorFieldValue(FieldType field, String propertyNam
case COUNTRY,
NOMINAL_VOLTAGE,
VOLTAGE_LEVEL_ID -> getVoltageLevelFieldValue(field, null, generator.getTerminal().getVoltageLevel());
case CONNECTED -> getTerminalFieldValue(field, generator.getTerminal());
case CONNECTED,
P_ABSOLUTE -> getTerminalFieldValue(field, generator.getTerminal());
case SUBSTATION_PROPERTIES -> generator.getTerminal().getVoltageLevel().getNullableSubstation().getProperty(propertyName);
case VOLTAGE_LEVEL_PROPERTIES -> generator.getTerminal().getVoltageLevel().getProperty(propertyName);
default -> throw new PowsyblException(FIELD_AND_TYPE_NOT_IMPLEMENTED + " [" + field + "," + generator.getType() + "]");
Expand Down Expand Up @@ -236,6 +237,7 @@ private static String getTerminalFieldValue(FieldType field, @Nullable Terminal
case REGULATING_TERMINAL_CONNECTABLE_ID ->
terminal.getConnectable() != null ?
terminal.getConnectable().getId() : null;
case P_ABSOLUTE -> String.valueOf(Math.abs(terminal.getP()));
default -> throw new PowsyblException(FIELD_AND_TYPE_NOT_IMPLEMENTED + " [" + field + ",terminal]");
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public enum FieldType {
FORCED_OUTAGE_RATE,
P0,
Q0,
P_ABSOLUTE,
LOW_VOLTAGE_LIMIT,
HIGH_VOLTAGE_LIMIT,
SECTION_COUNT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,13 @@ private static Stream<Arguments> provideArgumentsForGeneratorTest() {
Mockito.when(genStartup.getPlannedOutageRate()).thenReturn(50.0);
Mockito.when(genStartup.getForcedOutageRate()).thenReturn(50.0);
Mockito.when(gen.getExtension(any())).thenReturn(genStartup);
// Terminal fields
Terminal terminal = Mockito.mock(Terminal.class);
Mockito.when(gen.getTerminal()).thenReturn(terminal);
Mockito.when(terminal.getP()).thenReturn(-100.0);
// VoltageLevel fields
VoltageLevel voltageLevel = Mockito.mock(VoltageLevel.class);
Terminal terminal = Mockito.mock(Terminal.class);
Mockito.when(terminal.getVoltageLevel()).thenReturn(voltageLevel);
Mockito.when(gen.getTerminal()).thenReturn(terminal);
Mockito.when(voltageLevel.getNominalV()).thenReturn(13.0);

// for testing none EXISTS
Expand All @@ -152,11 +154,13 @@ private static Stream<Arguments> provideArgumentsForGeneratorTest() {
Mockito.when(genStartup1.getPlannedOutageRate()).thenReturn(Double.NaN);
Mockito.when(genStartup1.getForcedOutageRate()).thenReturn(Double.NaN);
Mockito.when(gen1.getExtension(any())).thenReturn(genStartup1);
// Terminal fields
Terminal terminal1 = Mockito.mock(Terminal.class);
Mockito.when(gen1.getTerminal()).thenReturn(terminal1);
Mockito.when(terminal1.getP()).thenReturn(Double.NaN);
// VoltageLevel fields
VoltageLevel voltageLevel1 = Mockito.mock(VoltageLevel.class);
Terminal terminal1 = Mockito.mock(Terminal.class);
Mockito.when(terminal1.getVoltageLevel()).thenReturn(voltageLevel1);
Mockito.when(gen1.getTerminal()).thenReturn(terminal1);
Mockito.when(voltageLevel1.getNominalV()).thenReturn(Double.NaN);

return Stream.of(
Expand All @@ -174,6 +178,8 @@ private static Stream<Arguments> provideArgumentsForGeneratorTest() {
Arguments.of(EQUALS, FieldType.TARGET_Q, 30.0, null, gen, false),
Arguments.of(EQUALS, FieldType.RATED_S, 60.0, null, gen, true),
Arguments.of(EQUALS, FieldType.RATED_S, 50.0, null, gen, false),
Arguments.of(EQUALS, FieldType.P_ABSOLUTE, 100.0, null, gen, true),
Arguments.of(EQUALS, FieldType.P_ABSOLUTE, 50.0, null, gen, false),
// GeneratorStartup extension fields
Arguments.of(EQUALS, FieldType.PLANNED_ACTIVE_POWER_SET_POINT, 50.0, null, gen, true),
Arguments.of(EQUALS, FieldType.PLANNED_ACTIVE_POWER_SET_POINT, 40.0, null, gen, false),
Expand Down Expand Up @@ -207,6 +213,9 @@ private static Stream<Arguments> provideArgumentsForGeneratorTest() {
Arguments.of(GREATER_OR_EQUALS, FieldType.RATED_S, 50.0, null, gen, true),
Arguments.of(GREATER_OR_EQUALS, FieldType.RATED_S, 60.0, null, gen, true),
Arguments.of(GREATER_OR_EQUALS, FieldType.RATED_S, 70.0, null, gen, false),
Arguments.of(GREATER_OR_EQUALS, FieldType.P_ABSOLUTE, 90.0, null, gen, true),
Arguments.of(GREATER_OR_EQUALS, FieldType.P_ABSOLUTE, 100.0, null, gen, true),
Arguments.of(GREATER_OR_EQUALS, FieldType.P_ABSOLUTE, 110.0, null, gen, false),
// GeneratorStartup extension fields
Arguments.of(GREATER_OR_EQUALS, FieldType.PLANNED_ACTIVE_POWER_SET_POINT, 40.0, null, gen, true),
Arguments.of(GREATER_OR_EQUALS, FieldType.PLANNED_ACTIVE_POWER_SET_POINT, 50.0, null, gen, true),
Expand Down Expand Up @@ -245,6 +254,10 @@ private static Stream<Arguments> provideArgumentsForGeneratorTest() {
Arguments.of(GREATER, FieldType.RATED_S, 50.0, null, gen, true),
Arguments.of(GREATER, FieldType.RATED_S, 60.0, null, gen, false),
Arguments.of(GREATER, FieldType.RATED_S, 70.0, null, gen, false),
Arguments.of(GREATER, FieldType.P_ABSOLUTE, 90.0, null, gen, true),
Arguments.of(GREATER, FieldType.P_ABSOLUTE, 100.0, null, gen, false),
Arguments.of(GREATER, FieldType.P_ABSOLUTE, 110.0, null, gen, false),

// GeneratorStartup extension fields
Arguments.of(GREATER, FieldType.PLANNED_ACTIVE_POWER_SET_POINT, 40.0, null, gen, true),
Arguments.of(GREATER, FieldType.PLANNED_ACTIVE_POWER_SET_POINT, 50.0, null, gen, false),
Expand Down Expand Up @@ -283,6 +296,9 @@ private static Stream<Arguments> provideArgumentsForGeneratorTest() {
Arguments.of(LOWER_OR_EQUALS, FieldType.RATED_S, 70.0, null, gen, true),
Arguments.of(LOWER_OR_EQUALS, FieldType.RATED_S, 60.0, null, gen, true),
Arguments.of(LOWER_OR_EQUALS, FieldType.RATED_S, 50.0, null, gen, false),
Arguments.of(LOWER_OR_EQUALS, FieldType.P_ABSOLUTE, 110.0, null, gen, true),
Arguments.of(LOWER_OR_EQUALS, FieldType.P_ABSOLUTE, 100.0, null, gen, true),
Arguments.of(LOWER_OR_EQUALS, FieldType.P_ABSOLUTE, 90.0, null, gen, false),
// GeneratorStartup extension fields
Arguments.of(LOWER_OR_EQUALS, FieldType.PLANNED_ACTIVE_POWER_SET_POINT, 60.0, null, gen, true),
Arguments.of(LOWER_OR_EQUALS, FieldType.PLANNED_ACTIVE_POWER_SET_POINT, 50.0, null, gen, true),
Expand Down Expand Up @@ -321,6 +337,9 @@ private static Stream<Arguments> provideArgumentsForGeneratorTest() {
Arguments.of(LOWER, FieldType.RATED_S, 70.0, null, gen, true),
Arguments.of(LOWER, FieldType.RATED_S, 60.0, null, gen, false),
Arguments.of(LOWER, FieldType.RATED_S, 50.0, null, gen, false),
Arguments.of(LOWER, FieldType.P_ABSOLUTE, 110.0, null, gen, true),
Arguments.of(LOWER, FieldType.P_ABSOLUTE, 100.0, null, gen, false),
Arguments.of(LOWER, FieldType.P_ABSOLUTE, 90.0, null, gen, false),
// GeneratorStartup extension fields
Arguments.of(LOWER, FieldType.PLANNED_ACTIVE_POWER_SET_POINT, 60.0, null, gen, true),
Arguments.of(LOWER, FieldType.PLANNED_ACTIVE_POWER_SET_POINT, 50.0, null, gen, false),
Expand Down Expand Up @@ -353,6 +372,8 @@ private static Stream<Arguments> provideArgumentsForGeneratorTest() {
Arguments.of(BETWEEN, FieldType.TARGET_Q, null, Set.of(45.0, 50.0), gen, false),
Arguments.of(BETWEEN, FieldType.RATED_S, null, Set.of(50.0, 70.0), gen, true),
Arguments.of(BETWEEN, FieldType.RATED_S, null, Set.of(65.0, 70.0), gen, false),
Arguments.of(BETWEEN, FieldType.P_ABSOLUTE, null, Set.of(90.0, 110.0), gen, true),
Arguments.of(BETWEEN, FieldType.P_ABSOLUTE, null, Set.of(80.0, 90.0), gen, false),
// GeneratorStartup extension fields
Arguments.of(BETWEEN, FieldType.PLANNED_ACTIVE_POWER_SET_POINT, null, Set.of(40.0, 60.0), gen, true),
Arguments.of(BETWEEN, FieldType.PLANNED_ACTIVE_POWER_SET_POINT, null, Set.of(55.0, 60.0), gen, false),
Expand Down Expand Up @@ -380,6 +401,8 @@ private static Stream<Arguments> provideArgumentsForGeneratorTest() {
Arguments.of(EXISTS, FieldType.TARGET_Q, null, null, gen1, false),
Arguments.of(EXISTS, FieldType.RATED_S, null, null, gen, true),
Arguments.of(EXISTS, FieldType.RATED_S, null, null, gen1, false),
Arguments.of(EXISTS, FieldType.P_ABSOLUTE, null, null, gen, true),
Arguments.of(EXISTS, FieldType.P_ABSOLUTE, null, null, gen1, false),
// GeneratorStartup extension fields
Arguments.of(EXISTS, FieldType.PLANNED_ACTIVE_POWER_SET_POINT, null, null, gen, true),
Arguments.of(EXISTS, FieldType.PLANNED_ACTIVE_POWER_SET_POINT, null, null, gen1, false),
Expand Down Expand Up @@ -407,6 +430,8 @@ private static Stream<Arguments> provideArgumentsForGeneratorTest() {
Arguments.of(NOT_EXISTS, FieldType.TARGET_Q, null, null, gen1, true),
Arguments.of(NOT_EXISTS, FieldType.RATED_S, null, null, gen, false),
Arguments.of(NOT_EXISTS, FieldType.RATED_S, null, null, gen1, true),
Arguments.of(NOT_EXISTS, FieldType.P_ABSOLUTE, null, null, gen, false),
Arguments.of(NOT_EXISTS, FieldType.P_ABSOLUTE, null, null, gen1, true),
// GeneratorStartup extension fields
Arguments.of(NOT_EXISTS, FieldType.PLANNED_ACTIVE_POWER_SET_POINT, null, null, gen, false),
Arguments.of(NOT_EXISTS, FieldType.PLANNED_ACTIVE_POWER_SET_POINT, null, null, gen1, true),
Expand Down Expand Up @@ -434,6 +459,8 @@ private static Stream<Arguments> provideArgumentsForGeneratorTest() {
Arguments.of(IN, FieldType.TARGET_Q, null, Set.of(30.0, 50.0), gen, false),
Arguments.of(IN, FieldType.RATED_S, null, Set.of(50.0, 60.0, 70.0), gen, true),
Arguments.of(IN, FieldType.RATED_S, null, Set.of(50.0, 70.0), gen, false),
Arguments.of(IN, FieldType.P_ABSOLUTE, null, Set.of(90.0, 100.0, 110.0), gen, true),
Arguments.of(IN, FieldType.P_ABSOLUTE, null, Set.of(90.0, 110.0), gen, false),
// GeneratorStartup extension fields
Arguments.of(IN, FieldType.PLANNED_ACTIVE_POWER_SET_POINT, null, Set.of(40.0, 50.0, 60.0), gen, true),
Arguments.of(IN, FieldType.PLANNED_ACTIVE_POWER_SET_POINT, null, Set.of(40.0, 60.0), gen, false),
Expand Down Expand Up @@ -461,6 +488,8 @@ private static Stream<Arguments> provideArgumentsForGeneratorTest() {
Arguments.of(NOT_IN, FieldType.TARGET_Q, null, Set.of(30.0, 40.0, 50.0), gen, false),
Arguments.of(NOT_IN, FieldType.RATED_S, null, Set.of(50.0, 70.0), gen, true),
Arguments.of(NOT_IN, FieldType.RATED_S, null, Set.of(50.0, 60.0, 70.0), gen, false),
Arguments.of(NOT_IN, FieldType.P_ABSOLUTE, null, Set.of(90.0, 110.0), gen, true),
Arguments.of(NOT_IN, FieldType.P_ABSOLUTE, null, Set.of(90.0, 100.0, 110.0), gen, false),
// GeneratorStartup extension fields
Arguments.of(NOT_IN, FieldType.PLANNED_ACTIVE_POWER_SET_POINT, null, Set.of(40.0, 60.0), gen, true),
Arguments.of(NOT_IN, FieldType.PLANNED_ACTIVE_POWER_SET_POINT, null, Set.of(40.0, 50.0, 60.0), gen, false),
Expand Down
Loading