-
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 all 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
150 changes: 150 additions & 0 deletions
150
...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,150 @@ | ||
| /** | ||
| * 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.Objects; | ||
|
|
||
| import static com.powsybl.iidm.modification.topology.TopologyModificationUtils.cleanNodeBreakerTopology; | ||
| import static com.powsybl.iidm.modification.topology.TopologyModificationUtils.createTopologyAndGetConnectableNode; | ||
| 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 { | ||
| private final String connectableId; | ||
| private final String targetBusOrBusBarSectionId; | ||
| private final String targetVoltageLevelId; | ||
| private final Terminal terminal; | ||
|
|
||
| /** | ||
| * @param connectableId non-null id of the connectable whose feeder bay will be moved (BusOrBusBarSection are not accepted) | ||
| * @param targetBusOrBusBarId non-null id of the target BusOrBusBar section | ||
| * @param targetVoltageLevelId non-null id of the target voltage Level | ||
| * @param terminal non-null terminal | ||
| */ | ||
| MoveFeederBay(String connectableId, String targetBusOrBusBarId, String targetVoltageLevelId, Terminal terminal) { | ||
| this.connectableId = Objects.requireNonNull(connectableId); | ||
| this.targetBusOrBusBarSectionId = Objects.requireNonNull(targetBusOrBusBarId); | ||
| this.targetVoltageLevelId = Objects.requireNonNull(targetVoltageLevelId); | ||
| this.terminal = Objects.requireNonNull(terminal); | ||
| } | ||
|
|
||
| @Override | ||
| public void apply(Network network, NamingStrategy namingStrategy, boolean throwException, | ||
| ComputationManager computationManager, ReportNode reportNode) { | ||
| // Get and validate connectable | ||
| Connectable<?> connectable = network.getConnectable(connectableId); | ||
| if (!validateConnectable(connectable, throwException, reportNode)) { | ||
| return; | ||
| } | ||
|
|
||
| // Get voltage level and perform move operation based on topology kind | ||
| VoltageLevel voltageLevel = network.getVoltageLevel(targetVoltageLevelId); | ||
| if (voltageLevel.getTopologyKind() == TopologyKind.NODE_BREAKER) { | ||
| moveInNodeBreakerTopology(network, connectable, voltageLevel, namingStrategy, reportNode); | ||
| } else { | ||
| moveInBusBreakerTopology(terminal); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Move the connectable in node-breaker topology | ||
| */ | ||
| private void moveInNodeBreakerTopology(Network network, Connectable<?> connectable, | ||
| VoltageLevel voltageLevel, NamingStrategy namingStrategy, | ||
| ReportNode reportNode) { | ||
| // Clean existing topology | ||
| cleanNodeBreakerTopology(network, connectableId, reportNode); | ||
|
|
||
| // Create new topology and Get node information | ||
| int side = getSideFromTerminal(terminal, connectable); | ||
| int connectableNode = createTopologyAndGetConnectableNode(side, targetBusOrBusBarSectionId, network, voltageLevel, connectable, namingStrategy, reportNode); | ||
|
|
||
| // Move the terminal of the connectable to the new node | ||
| terminal.getNodeBreakerView().moveConnectable(connectableNode, voltageLevel.getId()); | ||
| } | ||
|
|
||
| /** | ||
| * Move the connectable in bus-breaker topology | ||
| */ | ||
| private void moveInBusBreakerTopology(Terminal terminal) { | ||
| terminal.getBusBreakerView().moveConnectable(targetBusOrBusBarSectionId, terminal.isConnected()); | ||
| } | ||
|
|
||
| /** | ||
| * Get the side value | ||
| */ | ||
| private int getSideFromTerminal(Terminal terminal, Connectable<?> connectable) { | ||
| if (connectable instanceof Injection<?>) { | ||
| return 0; | ||
| } else if (connectable instanceof Branch<?> || connectable instanceof ThreeWindingsTransformer) { | ||
| return terminal.getSide().getNum(); | ||
| } | ||
| throw new IllegalStateException("Unsupported connectable type: " + connectable.getClass().getSimpleName()); | ||
| } | ||
|
|
||
| @Override | ||
| public String getName() { | ||
| return "MoveFeederBay"; | ||
| } | ||
|
|
||
| @Override | ||
| public NetworkModificationImpact hasImpactOnNetwork(Network network) { | ||
| impact = DEFAULT_IMPACT; | ||
| Connectable<?> connectable = network.getConnectable(connectableId); | ||
| BusbarSection targetBusbarSection = network.getBusbarSection(targetBusOrBusBarSectionId); | ||
|
|
||
| // Check preconditions: valid connectable and target busbar section | ||
| 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
|
||
|
|
||
| VoltageLevel targetVoltageLevel = targetBusbarSection.getTerminal().getVoltageLevel(); | ||
|
|
||
| // Check if any terminal is in the same voltage level | ||
| boolean hasTerminalInTargetVoltageLevel = connectable.getTerminals().stream() | ||
| .anyMatch(t -> t.getVoltageLevel().getId().equals(targetVoltageLevel.getId())); | ||
|
|
||
| if (!hasTerminalInTargetVoltageLevel) { | ||
| impact = NetworkModificationImpact.CANNOT_BE_APPLIED; | ||
| return impact; | ||
olperr1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| return impact; | ||
| } | ||
|
|
||
| /** | ||
| * Check if the connectable is valid for this modification | ||
| */ | ||
| private boolean validateConnectable(Connectable<?> connectable, boolean throwException, ReportNode reportNode) { | ||
| if (connectable == null) { | ||
| notFoundConnectableReport(reportNode, connectableId); | ||
| logOrThrow(throwException, "Connectable not found: " + connectableId); | ||
| return false; | ||
| } | ||
|
|
||
| if (connectable instanceof BusbarSection) { | ||
| moveFeederBayBusbarSectionReport(reportNode, connectableId); | ||
| logOrThrow(throwException, "BusbarSection connectables are not allowed as MoveFeederBay input: " + 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); | ||
| } | ||
|
|
||
| /** | ||
| * @param connectableId the non-null ID of the connectable | ||
| */ | ||
| public MoveFeederBayBuilder withConnectableId(String connectableId) { | ||
| this.connectableId = connectableId; | ||
| return this; | ||
| } | ||
|
|
||
| public MoveFeederBayBuilder withTargetBusOrBusBarSectionId(String busOrBbsId) { | ||
| this.targetBusOrBusBarSectionId = busOrBbsId; | ||
| return this; | ||
| } | ||
|
|
||
| public MoveFeederBayBuilder withTargetVoltageLevelId(String voltageLevelId) { | ||
| 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.