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

Nominal voltage filter on whole network #575

Merged
merged 6 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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 @@ -62,17 +62,31 @@ public static VoltageLevelFilter createNominalVoltageLowerBoundFilter(Network ne
return createNominalVoltageFilter(network, voltageLevelIds, nominalVoltageLowerBound, Double.MAX_VALUE, depth);
}

public static VoltageLevelFilter createNominalVoltageLowerBoundFilter(Network network, double nominalVoltageLowerBound) {
return createNominalVoltageFilter(network, nominalVoltageLowerBound, Double.MAX_VALUE);
}

public static VoltageLevelFilter createNominalVoltageUpperBoundFilter(Network network, List<String> voltageLevelIds, double nominalVoltageUpperBound, int depth) {
return createNominalVoltageFilter(network, voltageLevelIds, 0, nominalVoltageUpperBound, depth);
}

public static VoltageLevelFilter createNominalVoltageUpperBoundFilter(Network network, double nominalVoltageUpperBound) {
return createNominalVoltageFilter(network, 0, nominalVoltageUpperBound);
}

public static VoltageLevelFilter createNominalVoltageFilter(Network network, List<String> voltageLevelIds,
double nominalVoltageLowerBound, double nominalVoltageUpperBound,
int depth) {
checkVoltageBoundValues(nominalVoltageLowerBound, nominalVoltageUpperBound);
Predicate<VoltageLevel> voltageLevelPredicate = voltageLevel -> voltageLevel.getNominalV() >= nominalVoltageLowerBound && voltageLevel.getNominalV() <= nominalVoltageUpperBound;
return createVoltageLevelFilterWithPredicate(network, voltageLevelIds, depth, getPredicateFromVoltageBounds(nominalVoltageLowerBound, nominalVoltageUpperBound));
}

return createVoltageLevelFilterWithPredicate(network, voltageLevelIds, depth, voltageLevelPredicate);
public static VoltageLevelFilter createNominalVoltageFilter(Network network, double nominalVoltageLowerBound, double nominalVoltageUpperBound) {
return createNominalVoltageFilterWithPredicate(network, getPredicateFromVoltageBounds(nominalVoltageLowerBound, nominalVoltageUpperBound));
}

private static Predicate<VoltageLevel> getPredicateFromVoltageBounds(double nominalVoltageLowerBound, double nominalVoltageUpperBound) {
olperr1 marked this conversation as resolved.
Show resolved Hide resolved
checkVoltageBoundValues(nominalVoltageLowerBound, nominalVoltageUpperBound);
return voltageLevel -> voltageLevel.getNominalV() >= nominalVoltageLowerBound && voltageLevel.getNominalV() <= nominalVoltageUpperBound;
}

public static VoltageLevelFilter createVoltageLevelFilterWithPredicate(Network network, List<String> voltageLevelIds, int depth, Predicate<VoltageLevel> voltageLevelPredicate) {
Expand All @@ -95,6 +109,10 @@ public static VoltageLevelFilter createVoltageLevelFilterWithPredicate(Network n
return new VoltageLevelFilter(voltageLevels);
}

public static VoltageLevelFilter createNominalVoltageFilterWithPredicate(Network network, Predicate<VoltageLevel> voltageLevelPredicate) {
return new VoltageLevelFilter(network.getVoltageLevelStream().filter(voltageLevelPredicate).collect(Collectors.toSet()));
}

public static Collection<VoltageLevel> getNextDepthVoltageLevels(Network network, List<VoltageLevel> voltageLevels) {
List<String> voltageLevelIds = voltageLevels.stream().map(VoltageLevel::getId).collect(Collectors.toList());
VoltageLevelFilter voltageLevelFilter = createVoltageLevelsDepthFilter(network, voltageLevelIds, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,45 @@ void testVoltageFilteredDiagramTwoBounds() {
}

@Test
void testVoltageFilteredDiagramLowBound() {
void testVoltageFilteredDiagramLowerBound() {
Network network = IeeeCdfNetworkFactory.create14();
Path svgFileVoltageFilter = fileSystem.getPath("nad-test-voltage-filter.svg");
NetworkAreaDiagram.draw(network, svgFileVoltageFilter, new NadParameters(), VoltageLevelFilter.createNominalVoltageLowerBoundFilter(network, List.of("VL4"), 120, 2));
assertEquals(toString("/IEEE_14_bus_voltage_filter1.svg"), getContentFile(svgFileVoltageFilter));
}

@Test
void testVoltageFilteredDiagramHighBound() {
void testVoltageFilteredDiagramUpperBound() {
Network network = IeeeCdfNetworkFactory.create14();
Path svgFileVoltageFilter = fileSystem.getPath("nad-test-voltage-filter.svg");
NetworkAreaDiagram.draw(network, svgFileVoltageFilter, new NadParameters(), VoltageLevelFilter.createNominalVoltageUpperBoundFilter(network, List.of("VL4"), 180, 2));
assertEquals(toString("/IEEE_14_bus_voltage_filter2.svg"), getContentFile(svgFileVoltageFilter));
}

@Test
void testVoltageFilteredDiagramNoVoltageLevelIdInput() {
Network network = IeeeCdfNetworkFactory.create14();
Path svgFileVoltageFilter = fileSystem.getPath("nad-test-voltage-filter.svg");
NetworkAreaDiagram.draw(network, svgFileVoltageFilter, new NadParameters(), VoltageLevelFilter.createNominalVoltageFilter(network, 120, 180));
assertEquals(toString("/IEEE_14_bus_voltage_filter1.svg"), getContentFile(svgFileVoltageFilter));
}

@Test
void testVoltageFilteredDiagramLowerBoundNoVoltageLevelIdInput() {
Network network = IeeeCdfNetworkFactory.create14();
Path svgFileVoltageFilter = fileSystem.getPath("nad-test-voltage-filter.svg");
NetworkAreaDiagram.draw(network, svgFileVoltageFilter, new NadParameters(), VoltageLevelFilter.createNominalVoltageLowerBoundFilter(network, 120));
olperr1 marked this conversation as resolved.
Show resolved Hide resolved
assertEquals(toString("/IEEE_14_bus_voltage_filter1.svg"), getContentFile(svgFileVoltageFilter));
}

@Test
void testVoltageFilteredDiagramUpperBoundNoVoltageLevelIdInput() {
Network network = IeeeCdfNetworkFactory.create14();
Path svgFileVoltageFilter = fileSystem.getPath("nad-test-voltage-filter.svg");
NetworkAreaDiagram.draw(network, svgFileVoltageFilter, new NadParameters(), VoltageLevelFilter.createNominalVoltageUpperBoundFilter(network, 90));
assertEquals(toString("/IEEE_14_bus_voltage_filter4.svg"), getContentFile(svgFileVoltageFilter));
}

@Test
void testVoltageFilteredDiagramOutOfBound() {
ListAppender<ILoggingEvent> logWatcher = new ListAppender<>();
Expand Down
Loading