-
Notifications
You must be signed in to change notification settings - Fork 63
Add LineCouplings extension #3730
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
24 commits
Select commit
Hold shift + click to select a range
12dcf47
Add Line Mutual Coupling extension
colineplqt 2a21b97
Fix for IIDM v1.16
colineplqt 75692f0
Add documentation
colineplqt 5f615d7
Merge branch 'main' into mutual-coupling
colineplqt d67a2a1
Extension is now at network level
colineplqt 635f6ad
Add methods to manage and validate mutual couplings in LineCouplings …
colineplqt 7f72ae7
Add tests
colineplqt 4be4f59
Documentation
colineplqt ecd9615
Merge branch 'main' into mutual-coupling
colineplqt 1de0110
Add Line Couplings extension link to documentation
colineplqt 6ac2100
Add tests and remove single setters on line position
colineplqt 8fe179c
Add test for removing mutual couplings by instance
colineplqt eb57969
Remove comment
colineplqt 8d5b8f6
Add tests
colineplqt 7557057
Improve javadoc
colineplqt 0fdeb43
Refactor: introduce line segments
colineplqt 442a4cb
Clarify mutual coupling symmetry in documentation and enforce NaN val…
colineplqt fe73f56
Merge branch 'main' into mutual-coupling
colineplqt 552b696
Adapt to IIDM v1.17
colineplqt 0c009fc
Review.
colineplqt fc2b453
Add listener in case of line deletion and test.
colineplqt 56e610e
Merge branch 'main' into mutual-coupling
colineplqt a2223c1
Replace `DefaultNetworkListener` with `NetworkListener`.
colineplqt f7e2129
Apply suggestions from code review
colineplqt 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
75 changes: 75 additions & 0 deletions
75
iidm/iidm-extensions/src/main/java/com/powsybl/iidm/network/extensions/LineCouplings.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,75 @@ | ||
| /** | ||
| * Copyright (c) 2026, 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.network.extensions; | ||
|
|
||
| import com.powsybl.commons.PowsyblException; | ||
| import com.powsybl.commons.extensions.Extension; | ||
| import com.powsybl.iidm.network.Line; | ||
| import com.powsybl.iidm.network.Network; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Optional; | ||
|
|
||
| /** | ||
| * This extension stores the mutual couplings on the network. | ||
| * | ||
| * @author Coline Piloquet {@literal <coline.piloquet at rte-france.com>} | ||
| */ | ||
| public interface LineCouplings extends Extension<Network> { | ||
|
|
||
| String NAME = "lineCouplings"; | ||
|
|
||
| @Override | ||
| default String getName() { | ||
| return NAME; | ||
| } | ||
|
|
||
| /** | ||
| * Gets all mutual couplings in the network. | ||
| * @return a list of mutual couplings | ||
| */ | ||
| List<MutualCoupling> getMutualCouplings(); | ||
|
|
||
| /** | ||
| * Adds a mutual coupling. | ||
| * @param mutualCoupling the mutual coupling to add | ||
| * @return the current line couplings extension | ||
| * @throws PowsyblException if the coupling is invalid or already exists | ||
| */ | ||
| LineCouplings add(MutualCoupling mutualCoupling); | ||
|
|
||
| /** | ||
| * Creates a new mutual coupling adder. | ||
| * @return a mutual coupling adder | ||
| */ | ||
| MutualCouplingAdder newMutualCoupling(); | ||
|
|
||
| /** | ||
| * Finds a mutual coupling between two lines. | ||
| * The order of the lines does not matter. | ||
| * @param line1 the first line | ||
| * @param line2 the second line | ||
| * @return the mutual coupling if found, or empty if not | ||
| */ | ||
| Optional<MutualCoupling> findMutualCoupling(Line line1, Line line2); | ||
|
|
||
| /** | ||
| * Removes a mutual coupling. | ||
| * @param mutualCoupling the mutual coupling to remove | ||
| * @return true if the mutual coupling was removed, false otherwise | ||
| */ | ||
| boolean removeMutualCoupling(MutualCoupling mutualCoupling); | ||
|
|
||
| /** | ||
| * Removes a mutual coupling between two lines. | ||
| * @param line1 the first line | ||
| * @param line2 the second line | ||
| * @return true if the mutual coupling was removed, false otherwise | ||
| */ | ||
| boolean removeMutualCoupling(Line line1, Line line2); | ||
| } |
22 changes: 22 additions & 0 deletions
22
...iidm-extensions/src/main/java/com/powsybl/iidm/network/extensions/LineCouplingsAdder.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,22 @@ | ||
| /** | ||
| * Copyright (c) 2026, 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.network.extensions; | ||
|
|
||
| import com.powsybl.commons.extensions.ExtensionAdder; | ||
| import com.powsybl.iidm.network.Network; | ||
|
|
||
| /** | ||
| * @author Coline Piloquet {@literal <coline.piloquet at rte-france.com>} | ||
| */ | ||
| public interface LineCouplingsAdder extends ExtensionAdder<Network, LineCouplings> { | ||
|
|
||
| @Override | ||
| default Class<LineCouplings> getExtensionClass() { | ||
| return LineCouplings.class; | ||
| } | ||
| } |
39 changes: 39 additions & 0 deletions
39
iidm/iidm-extensions/src/main/java/com/powsybl/iidm/network/extensions/LineSegment.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,39 @@ | ||
| /** | ||
| * Copyright (c) 2026, 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.network.extensions; | ||
|
|
||
| import com.powsybl.commons.PowsyblException; | ||
|
|
||
| /** | ||
| * Represents a line segment defined by its start and end positions. | ||
| * The positions must satisfy the following conditions: | ||
| * - The start and end positions must be valid double values. | ||
| * - The start position must be greater than or equal to 0. | ||
| * - The end position must be less than or equal to 1. | ||
| * - The start position must be less than or equal to the end position. | ||
| * | ||
| * @author Coline Piloquet {@literal <coline.piloquet at rte-france.com>} | ||
| */ | ||
| public record LineSegment(double start, double end) { | ||
|
|
||
| public static final LineSegment FULL_LINE = new LineSegment(0, 1); | ||
|
|
||
| /** | ||
| * Constructs a LineSegment using the specified start and end positions. | ||
| * The line segment is valid only if the following conditions are met: | ||
| * - The start and end positions are valid double values. | ||
| * - The start position is greater than or equal to 0. | ||
| * - The end position is less than or equal to 1. | ||
| * - The start position is less than or equal to the end position. | ||
| */ | ||
| public LineSegment { | ||
| if (Double.isNaN(start) || Double.isNaN(end) || start < 0 || end > 1 || start > end) { | ||
| throw new PowsyblException("Invalid line segment: start: " + start + ", end: " + end + "."); | ||
| } | ||
| } | ||
| } |
83 changes: 83 additions & 0 deletions
83
iidm/iidm-extensions/src/main/java/com/powsybl/iidm/network/extensions/MutualCoupling.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,83 @@ | ||
| /** | ||
| * Copyright (c) 2026, 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.network.extensions; | ||
|
|
||
| import com.powsybl.iidm.network.Line; | ||
|
|
||
| /** | ||
| * This extension models electrical coupling between pairs of lines. | ||
| * | ||
| * @author Coline Piloquet {@literal <coline.piloquet at rte-france.com>} | ||
| */ | ||
| public interface MutualCoupling { | ||
|
|
||
| /** | ||
| * Gets the first line. | ||
| * @return the first line | ||
| */ | ||
| Line getLine1(); | ||
|
|
||
| /** | ||
| * Gets the second line. | ||
| * @return the second line | ||
| */ | ||
| Line getLine2(); | ||
|
|
||
| /** | ||
| * Gets the mutual coupling resistance. | ||
| * @return the resistance in ohms | ||
| */ | ||
| double getR(); | ||
|
|
||
| /** | ||
| * Sets the mutual coupling resistance. | ||
| * @param r the resistance in ohms | ||
| */ | ||
| void setR(double r); | ||
|
|
||
| /** | ||
| * Gets the mutual coupling reactance. | ||
| * @return the reactance in ohms | ||
| */ | ||
| double getX(); | ||
|
|
||
| /** | ||
| * Sets the mutual coupling reactance. | ||
| * @param x the reactance in ohms | ||
| */ | ||
| void setX(double x); | ||
|
|
||
| /** | ||
| * Gets the starting and ending position of the mutual coupling on the first line. | ||
| * The positions are a proportion of the line length and are between 0 and 1. | ||
| * @return the starting position | ||
| */ | ||
| LineSegment getLine1Segment(); | ||
|
|
||
| /** | ||
| * Gets the starting and ending position of the mutual coupling on the second line. | ||
| * The positions are a proportion of the line length and are between 0 and 1. | ||
| * @return the starting position | ||
| */ | ||
| LineSegment getLine2Segment(); | ||
|
|
||
| /** | ||
| * Sets the starting and ending position of the mutual coupling on the second line. | ||
| * The positions are a proportion of the line length and are between 0 and 1. | ||
| * @param line1Segment the segment on line 1 | ||
| */ | ||
| void setLine1Segment(LineSegment line1Segment); | ||
|
|
||
| /** | ||
| * Sets the starting and ending position of the mutual coupling on the second line. | ||
| * The positions are a proportion of the line length and are between 0 and 1. | ||
| * @param line2Segment the segment on line 2 | ||
| */ | ||
| void setLine2Segment(LineSegment line2Segment); | ||
|
|
||
| } | ||
68 changes: 68 additions & 0 deletions
68
...idm-extensions/src/main/java/com/powsybl/iidm/network/extensions/MutualCouplingAdder.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,68 @@ | ||
| /** | ||
| * Copyright (c) 2026, 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.network.extensions; | ||
|
|
||
| import com.powsybl.iidm.network.Line; | ||
|
|
||
| /** | ||
| * This interface is a builder to add a mutual coupling between two lines. | ||
| * | ||
| * @author Coline Piloquet {@literal <coline.piloquet at rte-france.com>} | ||
| */ | ||
| public interface MutualCouplingAdder { | ||
|
|
||
| /** | ||
| * Sets the first line. | ||
| * @param line1 the first line | ||
| * @return the current mutual coupling adder | ||
| */ | ||
| MutualCouplingAdder withLine1(Line line1); | ||
|
|
||
| /** | ||
| * Sets the second line. | ||
| * @param line2 the second line | ||
| * @return the current mutual coupling adder | ||
| */ | ||
| MutualCouplingAdder withLine2(Line line2); | ||
|
|
||
| /** | ||
| * Sets the mutual coupling resistance. | ||
| * @param r the resistance in ohms | ||
| * @return the current mutual coupling adder | ||
| */ | ||
| MutualCouplingAdder withR(double r); | ||
|
|
||
| /** | ||
| * Sets the mutual coupling reactance. | ||
| * @param x the reactance in ohms | ||
| * @return the current mutual coupling adder | ||
| */ | ||
| MutualCouplingAdder withX(double x); | ||
|
|
||
| /** | ||
| * Sets the position of the mutual coupling on the first line. | ||
| * The positions are a proportion of the line length and are between 0 and 1. | ||
| * @param segment the segment of the line | ||
| * @return the current mutual coupling adder | ||
| */ | ||
| MutualCouplingAdder withLine1Segment(LineSegment segment); | ||
|
|
||
| /** | ||
| * Sets the position of the mutual coupling on the second line. | ||
| * The positions are a proportion of the line length and are between 0 and 1. | ||
| * @param segment the segment of the line | ||
| * @return the current mutual coupling adder | ||
| */ | ||
| MutualCouplingAdder withLine2Segment(LineSegment segment); | ||
|
|
||
| /** | ||
| * Adds the mutual coupling. | ||
| * @return the added mutual coupling | ||
| */ | ||
| MutualCoupling add(); | ||
| } |
28 changes: 28 additions & 0 deletions
28
...m-impl/src/main/java/com/powsybl/iidm/network/impl/extensions/LineCouplingsAdderImpl.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,28 @@ | ||
| /** | ||
| * Copyright (c) 2026, 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.network.impl.extensions; | ||
|
|
||
| import com.powsybl.commons.extensions.AbstractExtensionAdder; | ||
| import com.powsybl.iidm.network.Network; | ||
| import com.powsybl.iidm.network.extensions.LineCouplingsAdder; | ||
| import com.powsybl.iidm.network.extensions.LineCouplings; | ||
|
|
||
| /** | ||
| * @author Coline Piloquet {@literal <coline.piloquet at rte-france.com>} | ||
| */ | ||
| public class LineCouplingsAdderImpl extends AbstractExtensionAdder<Network, LineCouplings> implements LineCouplingsAdder { | ||
|
|
||
| public LineCouplingsAdderImpl(Network network) { | ||
| super(network); | ||
| } | ||
|
|
||
| @Override | ||
| protected LineCouplingsImpl createExtension(Network network) { | ||
| return new LineCouplingsImpl(); | ||
| } | ||
| } |
Oops, something went wrong.
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.