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

Voltage angle limit #2613

Closed
wants to merge 36 commits into from
Closed
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
103625b
VoltageAngleLimit
marqueslanauja Jun 14, 2023
4c7f665
Merge branch 'main' into VoltageAngleLimits
marqueslanauja Jun 14, 2023
fbcfc5a
deterministic switchTerminalForVoltage. Add unitary test.
marqueslanauja Jun 14, 2023
a47b52f
Unitary test for voltageAngleLimit
marqueslanauja Jun 15, 2023
56183bc
Merge branch 'main' into VoltageAngleLimits
marqueslanauja Jun 21, 2023
0f31334
LimitViolation. Add unitary tests
marqueslanauja Jun 21, 2023
e3e3751
DefaultLimitViolationDetector. Add unitary tests
marqueslanauja Jun 22, 2023
3346714
set subjectId to the id of the TerminalRef from
marqueslanauja Jun 22, 2023
a02a374
LimitViolations. More unitary tests
marqueslanauja Jun 22, 2023
2e767dc
More unitary tests. Minor changes.
marqueslanauja Jun 22, 2023
64d05b1
Fix mergingView
marqueslanauja Jun 23, 2023
e87786d
merge voltageAngleLimits
marqueslanauja Jun 23, 2023
8599a9d
merge tests
marqueslanauja Jun 26, 2023
cc882d9
VoltageAngleLimit Xml
marqueslanauja Jun 28, 2023
01cbf70
xml tests
marqueslanauja Jun 29, 2023
ebd058c
More adder tests
marqueslanauja Jun 29, 2023
fca5f9d
Fix code smells
marqueslanauja Jun 29, 2023
bf1af69
Fix code smell
marqueslanauja Jun 29, 2023
26c0e44
Bump iidm xml version to 1.11
olperr1 Jun 20, 2023
5f620aa
Merge branch 'main' into VoltageAngleLimits
marqueslanauja Jul 11, 2023
fff3df0
Merge branch 'main' into xiidm_version_1_11
annetill Jul 11, 2023
e9d2bca
Remove switches as TerminalRef
marqueslanauja Jul 12, 2023
e9fafee
Fix code smell
marqueslanauja Jul 12, 2023
8cb0690
Reviewer comments
marqueslanauja Jul 12, 2023
33f5153
small refactor: move methods related to terminal ref
zamarrenolm Jul 14, 2023
29b958e
Move code to TerminalRef class
marqueslanauja Jul 14, 2023
3a5bff0
Fix code smell
marqueslanauja Jul 14, 2023
41e0ff9
Merge branch 'xiidm_version_1_11' into VoltageAngleLimits
zamarrenolm Jul 14, 2023
827e207
bump xiidm version to 1.11 for voltage angle limit
zamarrenolm Jul 14, 2023
d92d769
from xiidm 1.11
zamarrenolm Jul 14, 2023
e2d7750
Add name
marqueslanauja Jul 17, 2023
c40db24
TerminalRef side optional
marqueslanauja Jul 17, 2023
acc5c81
Fix bugs
marqueslanauja Jul 17, 2023
bba935d
Merge branch 'main' into xiidm_version_1_11
olperr1 Jul 18, 2023
bb1df86
Merge branch 'xiidm_version_1_11' into VoltageAngleLimits
olperr1 Jul 18, 2023
22a8d08
Merge branch 'evolution_xiidm/1.11' into VoltageAngleLimits
olperr1 Jul 28, 2023
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 @@ -125,7 +125,7 @@ private void readBoundariesAndTerminals(NetworkXmlReaderContext networkContext,
case "terminal":
id = networkContext.getAnonymizer().deanonymizeString(networkContext.getReader().getAttributeValue(null, "id"));
side = networkContext.getReader().getAttributeValue(null, "side");
cgmesControlArea.add(TerminalRefXml.readTerminalRef(network, id, side));
cgmesControlArea.add(TerminalRef.resolve(id, side, network));
break;
default:
throw new PowsyblException("Unknown element name <" + reader.getLocalName() + "> in <controlArea>");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_10" xmlns:cca="http://www.powsybl.org/schema/iidm/ext/cgmes_control_areas/1_0" id="sim1" caseDate="2021-02-02T09:27:39.856+01:00" forecastDistance="0" sourceFormat="test" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_11" xmlns:cca="http://www.powsybl.org/schema/iidm/ext/cgmes_control_areas/1_0" id="sim1" caseDate="2021-02-02T09:27:39.856+01:00" forecastDistance="0" sourceFormat="test" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:substation id="P1" country="FR" tso="RTE" geographicalTags="A">
<iidm:voltageLevel id="VLGEN" nominalV="24.0" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_10" xmlns:clbn="http://www.powsybl.org/schema/iidm/ext/cgmes_line_boundary_node/1_0" id="sim1" caseDate="2013-01-15T18:45:00.000+01:00" forecastDistance="0" sourceFormat="test" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_11" xmlns:clbn="http://www.powsybl.org/schema/iidm/ext/cgmes_line_boundary_node/1_0" id="sim1" caseDate="2013-01-15T18:45:00.000+01:00" forecastDistance="0" sourceFormat="test" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:substation id="P1" country="FR" tso="RTE" geographicalTags="A">
<iidm:voltageLevel id="VLGEN" nominalV="24.0" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_10" xmlns:csshm="http://www.powsybl.org/schema/iidm/ext/cgmes_ssh_metadata/1_0" id="sim1" caseDate="2020-09-07T15:44:10.209+02:00" forecastDistance="0" sourceFormat="test" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_11" xmlns:csshm="http://www.powsybl.org/schema/iidm/ext/cgmes_ssh_metadata/1_0" id="sim1" caseDate="2020-09-07T15:44:10.209+02:00" forecastDistance="0" sourceFormat="test" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:substation id="P1" country="FR" tso="RTE" geographicalTags="A">
<iidm:voltageLevel id="VLGEN" nominalV="24.0" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_10" xmlns:csm="http://www.powsybl.org/schema/iidm/ext/cgmes_sv_metadata/1_0" id="sim1" caseDate="2020-09-07T15:44:10.209+02:00" forecastDistance="0" sourceFormat="test" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_11" xmlns:csm="http://www.powsybl.org/schema/iidm/ext/cgmes_sv_metadata/1_0" id="sim1" caseDate="2020-09-07T15:44:10.209+02:00" forecastDistance="0" sourceFormat="test" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:substation id="P1" country="FR" tso="RTE" geographicalTags="A">
<iidm:voltageLevel id="VLGEN" nominalV="24.0" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_10" xmlns:cc="http://www.powsybl.org/schema/iidm/ext/cim_characteristics/1_0" id="sim1" caseDate="2020-09-08T14:28:13.738+02:00" forecastDistance="0" sourceFormat="test" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_11" xmlns:cc="http://www.powsybl.org/schema/iidm/ext/cim_characteristics/1_0" id="sim1" caseDate="2020-09-08T14:28:13.738+02:00" forecastDistance="0" sourceFormat="test" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:substation id="P1" country="FR" tso="RTE" geographicalTags="A">
<iidm:voltageLevel id="VLGEN" nominalV="24.0" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
Expand Down
2 changes: 1 addition & 1 deletion entsoe-util/src/test/resources/entsoeAreaRef.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_10" xmlns:ea="http://www.itesla_project.eu/schema/iidm/ext/entsoe_area/1_0" id="test" caseDate="2016-06-27T12:27:58.535+02:00" forecastDistance="0" sourceFormat="test" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_11" xmlns:ea="http://www.itesla_project.eu/schema/iidm/ext/entsoe_area/1_0" id="test" caseDate="2016-06-27T12:27:58.535+02:00" forecastDistance="0" sourceFormat="test" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:substation id="S" country="FR"></iidm:substation>
<iidm:extension id="S">
<ea:entsoeArea>BE</ea:entsoeArea>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_10" xmlns:slt="http://www.powsybl.org/schema/iidm/ext/slack_terminal/1_5" id="ieee118cdf" caseDate="1993-08-25T00:00:00.000Z" forecastDistance="0" sourceFormat="IEEE-CDF" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_11" xmlns:slt="http://www.powsybl.org/schema/iidm/ext/slack_terminal/1_5" id="ieee118cdf" caseDate="1993-08-25T00:00:00.000Z" forecastDistance="0" sourceFormat="IEEE-CDF" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:substation id="S1">
<iidm:voltageLevel id="VL1" nominalV="161.0" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_10" xmlns:slt="http://www.powsybl.org/schema/iidm/ext/slack_terminal/1_5" id="ieee14cdf-solved" caseDate="1993-08-19T00:00:00.000Z" forecastDistance="0" sourceFormat="IEEE-CDF" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_11" xmlns:slt="http://www.powsybl.org/schema/iidm/ext/slack_terminal/1_5" id="ieee14cdf-solved" caseDate="1993-08-19T00:00:00.000Z" forecastDistance="0" sourceFormat="IEEE-CDF" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:substation id="S1">
<iidm:voltageLevel id="VL1" nominalV="1.0" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_10" xmlns:slt="http://www.powsybl.org/schema/iidm/ext/slack_terminal/1_5" id="ieee14cdf" caseDate="1993-08-19T00:00:00.000Z" forecastDistance="0" sourceFormat="IEEE-CDF" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_11" xmlns:slt="http://www.powsybl.org/schema/iidm/ext/slack_terminal/1_5" id="ieee14cdf" caseDate="1993-08-19T00:00:00.000Z" forecastDistance="0" sourceFormat="IEEE-CDF" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:substation id="S1">
<iidm:voltageLevel id="VL1" nominalV="135.0" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_10" xmlns:slt="http://www.powsybl.org/schema/iidm/ext/slack_terminal/1_5" id="ieee300cdf" caseDate="1991-05-13T00:00:00.000Z" forecastDistance="0" sourceFormat="IEEE-CDF" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_11" xmlns:slt="http://www.powsybl.org/schema/iidm/ext/slack_terminal/1_5" id="ieee300cdf" caseDate="1991-05-13T00:00:00.000Z" forecastDistance="0" sourceFormat="IEEE-CDF" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:substation id="S1">
<iidm:voltageLevel id="VL1" nominalV="115.0" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_10" xmlns:slt="http://www.powsybl.org/schema/iidm/ext/slack_terminal/1_5" id="ieee30cdf" caseDate="1993-08-20T00:00:00.000Z" forecastDistance="0" sourceFormat="IEEE-CDF" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_11" xmlns:slt="http://www.powsybl.org/schema/iidm/ext/slack_terminal/1_5" id="ieee30cdf" caseDate="1993-08-20T00:00:00.000Z" forecastDistance="0" sourceFormat="IEEE-CDF" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:substation id="S1">
<iidm:voltageLevel id="VL1" nominalV="132.0" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_10" xmlns:slt="http://www.powsybl.org/schema/iidm/ext/slack_terminal/1_5" id="ieee33" caseDate="2022-09-23T00:00:00.000Z" forecastDistance="0" sourceFormat="IEEE-CDF" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_11" xmlns:slt="http://www.powsybl.org/schema/iidm/ext/slack_terminal/1_5" id="ieee33" caseDate="2022-09-23T00:00:00.000Z" forecastDistance="0" sourceFormat="IEEE-CDF" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:substation id="S1">
<iidm:voltageLevel id="VL1" nominalV="12.66" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_10" xmlns:slt="http://www.powsybl.org/schema/iidm/ext/slack_terminal/1_5" id="ieee57cdf" caseDate="1993-08-25T00:00:00.000Z" forecastDistance="0" sourceFormat="IEEE-CDF" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_11" xmlns:slt="http://www.powsybl.org/schema/iidm/ext/slack_terminal/1_5" id="ieee57cdf" caseDate="1993-08-25T00:00:00.000Z" forecastDistance="0" sourceFormat="IEEE-CDF" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:substation id="S1">
<iidm:voltageLevel id="VL1" nominalV="1.0" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_10" xmlns:slt="http://www.powsybl.org/schema/iidm/ext/slack_terminal/1_5" id="ieee69" caseDate="2022-09-23T00:00:00.000Z" forecastDistance="0" sourceFormat="IEEE-CDF" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_11" xmlns:slt="http://www.powsybl.org/schema/iidm/ext/slack_terminal/1_5" id="ieee69" caseDate="2022-09-23T00:00:00.000Z" forecastDistance="0" sourceFormat="IEEE-CDF" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:substation id="S1">
<iidm:voltageLevel id="VL1" nominalV="12.66" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_10" xmlns:slt="http://www.powsybl.org/schema/iidm/ext/slack_terminal/1_5" id="ieee9cdf" caseDate="2009-04-26T00:00:00.000Z" forecastDistance="0" sourceFormat="IEEE-CDF" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_11" xmlns:slt="http://www.powsybl.org/schema/iidm/ext/slack_terminal/1_5" id="ieee9cdf" caseDate="2009-04-26T00:00:00.000Z" forecastDistance="0" sourceFormat="IEEE-CDF" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:substation id="S1">
<iidm:voltageLevel id="VL1" nominalV="100.0" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_10" xmlns:slt="http://www.powsybl.org/schema/iidm/ext/slack_terminal/1_5" id="ieee9zeroimpedancecdf" caseDate="2009-04-26T00:00:00.000Z" forecastDistance="0" sourceFormat="IEEE-CDF" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_11" xmlns:slt="http://www.powsybl.org/schema/iidm/ext/slack_terminal/1_5" id="ieee9zeroimpedancecdf" caseDate="2009-04-26T00:00:00.000Z" forecastDistance="0" sourceFormat="IEEE-CDF" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:substation id="S1">
<iidm:voltageLevel id="VL1" nominalV="100.0" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ public enum LimitType {
ACTIVE_POWER,
APPARENT_POWER,
CURRENT,
VOLTAGE
VOLTAGE,
VOLTAGE_ANGLE
}
11 changes: 11 additions & 0 deletions iidm/iidm-api/src/main/java/com/powsybl/iidm/network/Network.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.powsybl.commons.reporter.Reporter;
import com.powsybl.computation.ComputationManager;
import com.powsybl.computation.local.LocalComputationManager;

import org.joda.time.DateTime;

import java.io.IOException;
Expand Down Expand Up @@ -1190,6 +1191,16 @@ default int getConnectableCount() {
*/
BusView getBusView();

/**
* Get a builder to create a new VoltageAngleLimit.
*/
public VoltageAngleLimitAdder newVoltageAngleLimit();

/**
* Get all voltageAngleLimits.
*/
List<VoltageAngleLimit> getVoltageAngleLimits();

/**
* Merge with an other network. At the end of the merge the other network
* is empty.
Expand Down
124 changes: 124 additions & 0 deletions iidm/iidm-api/src/main/java/com/powsybl/iidm/network/TerminalRef.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/**
* Copyright (c) 2023, 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;

import com.powsybl.commons.PowsyblException;

/**
* @author Luma Zamarreño <zamarrenolm at aia.es>
* @author José Antonio Marqués <marquesja at aia.es>
*/
public final class TerminalRef {

public enum Side {
ONE,
TWO,
THREE
}

private final String id;
private final Side side;
annetill marked this conversation as resolved.
Show resolved Hide resolved

private TerminalRef(String id, Side side) {
this.id = id;
this.side = side;
}

public static TerminalRef create(String id) {
return new TerminalRef(id, Side.ONE);
}

public static TerminalRef create(String id, Side side) {
return new TerminalRef(id, side);
}

public static TerminalRef.Side getConnectableSide(Terminal terminal) {
Connectable<?> c = terminal.getConnectable();
if (c instanceof Injection) {
return TerminalRef.Side.ONE;
} else if (c instanceof Branch) {
return toSide(((Branch) c).getSide(terminal));
} else if (c instanceof ThreeWindingsTransformer) {
return toSide(((ThreeWindingsTransformer) c).getSide(terminal));
} else {
throw new IllegalStateException("Unexpected Connectable instance: " + c.getClass());
}
}

// FIXME(Luma) This has been moved from TerminalRefXml,
// Makes sense to have it here,
// In the future ...
// a Terminal ref specified for a switch could be resolved to different terminals depending on the topology
// This could also be written as TerminalRef.create(id , side).resolve(network)
public static Terminal resolve(String id, String sideText, Network network) {
Side side = sideText == null ? Side.ONE : Side.valueOf(sideText);
return resolve(id, side, network);
}

public static Terminal resolve(String id, Side side, Network network) {
Identifiable<?> identifiable = network.getIdentifiable(id);
if (identifiable == null) {
throw new PowsyblException("Terminal reference identifiable not found: '" + id + "'");
}
if (identifiable instanceof Connectable) {
return getTerminal((Connectable<?>) identifiable, side);
} else {
throw new PowsyblException("Unexpected terminal reference identifiable instance: " + identifiable.getClass());
}
}

private static Terminal getTerminal(Connectable<?> connectable, Side side) {
if (connectable instanceof Injection) {
return ((Injection<?>) connectable).getTerminal();
} else if (connectable instanceof Branch) {
if (side.equals(Side.ONE)) {
return ((Branch<?>) connectable).getTerminal1();
} else if (side.equals(Side.TWO)) {
return ((Branch<?>) connectable).getTerminal2();
} else {
throw new IllegalStateException("Unexpected Branch side: " + side.name());
}
} else if (connectable instanceof ThreeWindingsTransformer) {
if (side.equals(Side.ONE)) {
return ((ThreeWindingsTransformer) connectable).getLeg1().getTerminal();
} else if (side.equals(Side.TWO)) {
return ((ThreeWindingsTransformer) connectable).getLeg2().getTerminal();
} else {
return ((ThreeWindingsTransformer) connectable).getLeg3().getTerminal();
}
} else {
throw new PowsyblException("Unexpected terminal reference identifiable instance: " + connectable.getClass());
}
}

private static TerminalRef.Side toSide(Branch.Side side) {
if (side.equals(Branch.Side.ONE)) {
return TerminalRef.Side.ONE;
} else {
return TerminalRef.Side.TWO;
}
}

private static TerminalRef.Side toSide(ThreeWindingsTransformer.Side side) {
if (side.equals(ThreeWindingsTransformer.Side.ONE)) {
return TerminalRef.Side.ONE;
} else if (side.equals(ThreeWindingsTransformer.Side.TWO)) {
return TerminalRef.Side.TWO;
} else {
return TerminalRef.Side.THREE;
}
}

public String getId() {
return id;
}

public Side getSide() {
return side;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* Copyright (c) 2023, 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;

/**
* @author Luma Zamarreño <zamarrenolm at aia.es>
* @author José Antonio Marqués <marquesja at aia.es>
*/
public interface VoltageAngleLimit extends OperationalLimits {

public enum FlowDirection {
FROM_TO,
TO_FROM,
BOTH_DIRECTIONS
}

@Override
default LimitType getLimitType() {
return LimitType.VOLTAGE_ANGLE;
}

/**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a name ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I will do it. Name could be optional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I considered it optional.

* Get the Terminal from
*/
Terminal getTerminalFrom();

/**
* Get the Terminal to
*/
Terminal getTerminalTo();

/**
* Get the VoltageAngle limit value
*/
double getLimit();

/**
* Get the flow direction
*/
FlowDirection getFlowDirection();
}
Loading