Skip to content
Merged
Show file tree
Hide file tree
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 Jan 22, 2026
2a21b97
Fix for IIDM v1.16
colineplqt Jan 29, 2026
75692f0
Add documentation
colineplqt Jan 29, 2026
5f615d7
Merge branch 'main' into mutual-coupling
colineplqt Apr 16, 2026
d67a2a1
Extension is now at network level
colineplqt Apr 17, 2026
635f6ad
Add methods to manage and validate mutual couplings in LineCouplings …
colineplqt Apr 20, 2026
7f72ae7
Add tests
colineplqt Apr 20, 2026
4be4f59
Documentation
colineplqt Apr 20, 2026
ecd9615
Merge branch 'main' into mutual-coupling
colineplqt Apr 20, 2026
1de0110
Add Line Couplings extension link to documentation
colineplqt Apr 20, 2026
6ac2100
Add tests and remove single setters on line position
colineplqt Apr 20, 2026
8fe179c
Add test for removing mutual couplings by instance
colineplqt Apr 20, 2026
eb57969
Remove comment
colineplqt Apr 20, 2026
8d5b8f6
Add tests
colineplqt Apr 20, 2026
7557057
Improve javadoc
colineplqt Apr 20, 2026
0fdeb43
Refactor: introduce line segments
colineplqt Apr 20, 2026
442a4cb
Clarify mutual coupling symmetry in documentation and enforce NaN val…
colineplqt Jun 4, 2026
fe73f56
Merge branch 'main' into mutual-coupling
colineplqt Jun 4, 2026
552b696
Adapt to IIDM v1.17
colineplqt Jun 4, 2026
0c009fc
Review.
colineplqt Jun 17, 2026
fc2b453
Add listener in case of line deletion and test.
colineplqt Jun 17, 2026
56e610e
Merge branch 'main' into mutual-coupling
colineplqt Jun 17, 2026
a2223c1
Replace `DefaultNetworkListener` with `NetworkListener`.
colineplqt Jun 17, 2026
f7e2129
Apply suggestions from code review
colineplqt Jun 17, 2026
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
38 changes: 38 additions & 0 deletions docs/grid_model/extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,44 @@ Side 1 and side 2 correspond respectively to terminal1 and terminal2 of the line

This extension is provided in the `com.powsybl:powsybl-iidm-extensions` module.

(line-couplings-extension)=
## Line Couplings

This extension models the mutual coupling between two lines. It is attached to the `Network` object and contains a list of mutual couplings.

The attributes of a `MutualCoupling` are:

| Attribute | Type | Unit | Required | Default value | Description |
|--------------|-------------|------|----------|---------------|---------------------------------------------------------------|
| line1 | Line | - | yes | - | The first coupled line |
| line2 | Line | - | yes | - | The second coupled line |
| r | double | Ω | yes | - | The mutual coupling resistance |
| x | double | Ω | yes | - | The mutual coupling reactance |
| line1Segment | LineSegment | - | no | 0..1 | The starting and ending positions on the first line (0 to 1) |
| line2Segment | LineSegment | - | no | 0..1 | The starting and ending positions on the second line (0 to 1) |

The position of the mutual coupling is expressed as a ratio between 0 and 1, through a `LineSegment` object.
A `LineSegment` has a start and an end position, with the constraint that: 0 ≤ start ≤ end ≤ 1
Mutual coupling is symmetric: a coupling between line1 and line2 is equivalent to a coupling between line2 and line1.
Mutual couplings are considered symmetric. Therefore, the extension cannot contain both (line1, line2) and (line2, line1).

Example of code to add a mutual coupling:

```java
Line line1 = network.getLine("L1");
Line line2 = network.getLine("L2");
network.newExtension(LineCouplingsAdder.class).add();
network.getExtension(LineCouplings.class)
.newMutualCoupling()
.withLine1(line1)
.withLine2(line2)
.withR(0.1)
.withX(0.4)
.add();
```

This extension is provided in the `com.powsybl:powsybl-iidm-extensions` module.

(two-winding-transformer-fortescue)=
## Two-winding Transformer Fortescue

Expand Down
1 change: 1 addition & 0 deletions docs/grid_model/network_subnetwork.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ In the PowSyBl grid model, the Network contains [substations](#substation), whic
The `SourceFormat` attribute is a required attribute that indicates the origin of the network model automatically set by the [importers](../grid_exchange_formats/index.md). If the case date and the forecast distance cannot be found in the case file, the network is considered as a snapshot: the case date is set to the current date, and the forecast distance is set to `0`.

**Available extensions**
- [Line Couplings](extensions.md#line-couplings)

(substation)=
## Substation
Expand Down
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);
}
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;
}
}
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 + ".");
}
}
}
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);
Comment thread
olperr1 marked this conversation as resolved.

/**
* 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);

}
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();
}
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();
}
}
Loading
Loading