-
Notifications
You must be signed in to change notification settings - Fork 50
Implement move feederbay network modification #3396
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 2 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
372b453
implement move feederbay network modification
ghazwarhili 25d0e70
code review remarks
ghazwarhili fc974e0
Merge branch 'main' into add-move-feeder-bay-modification
olperr1 9dd6ebb
review remarks
ghazwarhili 919223c
code review remarks part 2
ghazwarhili 6ea9672
code review remarks
ghazwarhili e115a7e
add test
ghazwarhili 6d35150
fix sonar issues
ghazwarhili 52c02dd
fix the calculated connectable node
ghazwarhili 26bd0ba
Merge branch 'main' into add-move-feeder-bay-modification
ghazwarhili f8bbc69
code review remarks [doc]
ghazwarhili 9bc5ce5
Merge remote-tracking branch 'origin/add-move-feeder-bay-modification…
ghazwarhili 32e5dce
Merge branch 'main' into add-move-feeder-bay-modification
ghazwarhili a1a5675
replace repositioning by moving
ghazwarhili bc017b5
Merge remote-tracking branch 'origin/add-move-feeder-bay-modification…
ghazwarhili 6d3a065
enhance doc description for moving feeder bay
ghazwarhili f8a4508
enhance doc
ghazwarhili 58b224a
Merge branch 'main' into add-move-feeder-bay-modification
olperr1 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
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
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
132 changes: 132 additions & 0 deletions
132
...iidm-modification/src/main/java/com/powsybl/iidm/modification/topology/MoveFeederBay.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,132 @@ | ||
| /** | ||
| * 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/. | ||
| * SPDX-License-Identifier: MPL-2.0 | ||
| */ | ||
| package com.powsybl.iidm.modification.topology; | ||
|
|
||
| import com.powsybl.commons.report.ReportNode; | ||
| import com.powsybl.computation.ComputationManager; | ||
| import com.powsybl.iidm.modification.AbstractNetworkModification; | ||
| import com.powsybl.iidm.modification.NetworkModificationImpact; | ||
| import com.powsybl.iidm.network.*; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import java.util.Objects; | ||
|
|
||
| import static com.powsybl.iidm.modification.topology.TopologyModificationUtils.cleanNodeBreakerTopology; | ||
| import static com.powsybl.iidm.modification.topology.TopologyModificationUtils.createTopology; | ||
| import static com.powsybl.iidm.modification.util.ModificationLogs.logOrThrow; | ||
| import static com.powsybl.iidm.modification.util.ModificationReports.moveFeederBayBusbarSectionReport; | ||
| import static com.powsybl.iidm.modification.util.ModificationReports.notFoundConnectableReport; | ||
|
|
||
| /** | ||
| * This modification moves a feeder bay from one busbar section to another. | ||
| * It identifies and updates the relevant switches and connections to achieve the move operation. | ||
| * | ||
| * @author Ghazwa Rehili {@literal <ghazwa.rehili at rte-france.com>} | ||
| */ | ||
| public class MoveFeederBay extends AbstractNetworkModification { | ||
ghazwarhili marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| private final String connectableId; | ||
| private final String targetBusOrBusbarSectionId; | ||
| private final String targetVoltageLevelId; | ||
| private final Terminal terminal; | ||
|
|
||
| /** | ||
| * Constructor | ||
| * @param connectableId non-null id of the connectable whose feeder bay will be moved (busbar sections are not accepted) | ||
| * @param terminal non-null id of the terminal | ||
| * @param targetBusbarSectionId non-null id of the target busbar section | ||
| * @param targetVoltageLevelId non-null id of the target voltage Level | ||
| */ | ||
| public MoveFeederBay(String connectableId, String targetBusbarSectionId, String targetVoltageLevelId, Terminal terminal) { | ||
olperr1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| this.connectableId = Objects.requireNonNull(connectableId); | ||
| this.targetBusOrBusbarSectionId = Objects.requireNonNull(targetBusbarSectionId); | ||
| this.targetVoltageLevelId = Objects.requireNonNull(targetVoltageLevelId); | ||
| this.terminal = Objects.requireNonNull(terminal); | ||
| } | ||
|
|
||
| @Override | ||
| public void apply(Network network, NamingStrategy namingStrategy, boolean throwException, ComputationManager computationManager, ReportNode reportNode) { | ||
| Connectable<?> connectable = network.getConnectable(connectableId); | ||
| if (!checkConnectable(throwException, reportNode, connectable)) { | ||
| return; | ||
| } | ||
| VoltageLevel voltageLevel = network.getVoltageLevel(targetVoltageLevelId); | ||
| if (voltageLevel.getTopologyKind() == TopologyKind.NODE_BREAKER) { | ||
| cleanNodeBreakerTopology(network, connectableId, reportNode); | ||
| createTopology(getSideFromTerminal(terminal, connectable), targetBusOrBusbarSectionId, network, voltageLevel, connectable, namingStrategy, reportNode); | ||
| Map<VoltageLevel, Integer> firstAvailableNodes = new HashMap<>(); | ||
| int connectableNode = firstAvailableNodes.compute(voltageLevel, this::getNextAvailableNode); | ||
olperr1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| terminal.getNodeBreakerView().moveConnectable(connectableNode, voltageLevel.getId()); | ||
| } else { | ||
| terminal.getBusBreakerView().moveConnectable(targetBusOrBusbarSectionId, terminal.isConnected()); | ||
| } | ||
| } | ||
|
|
||
| private int getSideFromTerminal(Terminal terminal, Connectable<?> connectable) { | ||
| if (connectable instanceof Injection<?>) { | ||
| return 0; | ||
| } else if (connectable instanceof Branch<?>) { | ||
olperr1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return terminal.getSide().getNum(); | ||
| } | ||
| throw new IllegalStateException("Unexpected connectable: " + connectable); | ||
| } | ||
|
|
||
| private int getNextAvailableNode(VoltageLevel vl, Integer node) { | ||
| return node == null ? vl.getNodeBreakerView().getMaximumNodeIndex() + 1 : node + 1; | ||
| } | ||
|
|
||
| @Override | ||
| public String getName() { | ||
| return "MoveFeederBay"; | ||
| } | ||
|
|
||
| @Override | ||
| public NetworkModificationImpact hasImpactOnNetwork(Network network) { | ||
| NetworkModificationImpact impact = DEFAULT_IMPACT; | ||
olperr1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| // Check connectable and target busbar section exists | ||
| Connectable<?> connectable = network.getConnectable(connectableId); | ||
| BusbarSection targetBusbarSection = network.getBusbarSection(targetBusOrBusbarSectionId); | ||
| if (connectable == null || connectable instanceof BusbarSection || targetBusbarSection == null) { | ||
| impact = NetworkModificationImpact.CANNOT_BE_APPLIED; | ||
| return impact; | ||
| } | ||
ghazwarhili marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // Check that at least one terminal is in the same voltage level as the target busbar section | ||
| VoltageLevel targetVoltageLevel = targetBusbarSection.getTerminal().getVoltageLevel(); | ||
| boolean hasTerminalInTargetVoltageLevel = false; | ||
|
|
||
| for (Terminal terminal : connectable.getTerminals()) { | ||
| if (terminal.getVoltageLevel().getId().equals(targetVoltageLevel.getId())) { | ||
| hasTerminalInTargetVoltageLevel = true; | ||
| break; | ||
| } | ||
| } | ||
olperr1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| if (!hasTerminalInTargetVoltageLevel) { | ||
| impact = NetworkModificationImpact.CANNOT_BE_APPLIED; | ||
| return impact; | ||
olperr1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| return impact; | ||
| } | ||
|
|
||
| private boolean checkConnectable(boolean throwException, ReportNode reportNode, Connectable<?> connectable) { | ||
| if (connectable instanceof BusbarSection) { | ||
| moveFeederBayBusbarSectionReport(reportNode, connectableId); | ||
| logOrThrow(throwException, "BusbarSection connectables are not allowed as MoveFeederBay input: " + connectableId); | ||
| return false; | ||
| } | ||
| if (connectable == null) { | ||
| notFoundConnectableReport(reportNode, connectableId); | ||
| logOrThrow(throwException, "Connectable not found: " + connectableId); | ||
| return false; | ||
| } | ||
| return true; | ||
| } | ||
| } | ||
49 changes: 49 additions & 0 deletions
49
...dification/src/main/java/com/powsybl/iidm/modification/topology/MoveFeederBayBuilder.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,49 @@ | ||
| /** | ||
| * 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/. | ||
| * SPDX-License-Identifier: MPL-2.0 | ||
| */ | ||
| package com.powsybl.iidm.modification.topology; | ||
|
|
||
| import com.powsybl.iidm.network.Terminal; | ||
|
|
||
ghazwarhili marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /** | ||
| * @author Ghazwa Rehili {@literal <ghazwa.rehili at rte-france.com>} | ||
| */ | ||
|
|
||
| public class MoveFeederBayBuilder { | ||
| private String connectableId = null; | ||
| private String targetBusOrBusbarSectionId = null; | ||
| private String targetVoltageLevelId = null; | ||
| private Terminal terminal = null; | ||
|
|
||
| public MoveFeederBay build() { | ||
| return new MoveFeederBay(connectableId, targetBusOrBusbarSectionId, targetVoltageLevelId, terminal); | ||
EtienneLt marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| /** | ||
| * @param connectableId the non-null ID of the connectable | ||
| */ | ||
| public MoveFeederBayBuilder withConnectableId(String connectableId) { | ||
| this.connectableId = connectableId; | ||
| return this; | ||
| } | ||
|
|
||
| public MoveFeederBayBuilder withBusOrBusbarSectionId(String busOrBbs) { | ||
olperr1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| this.targetBusOrBusbarSectionId = busOrBbs; | ||
olperr1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return this; | ||
| } | ||
|
|
||
| public MoveFeederBayBuilder withVoltageLevelId(String voltageLevelId) { | ||
olperr1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| this.targetVoltageLevelId = voltageLevelId; | ||
| return this; | ||
| } | ||
|
|
||
| public MoveFeederBayBuilder withTerminal(Terminal terminal) { | ||
| this.terminal = terminal; | ||
| return this; | ||
| } | ||
| } | ||
|
|
||
Oops, something went wrong.
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.