Skip to content

Commit

Permalink
Branch does not extend connectable (#2591)
Browse files Browse the repository at this point in the history
* Branch extends Identifiable but does not extend Connectable
* Remove deprecated branch methods
* Rename Line-2WT specific branch-named classes
* Create BranchUtil class to limit duplication
* Revert "Export tielines in graphviz export (#2587)" (reverts commit 8692533)
* Revert "Fix AMPL writer: writing current limits which are on paired dangling lines (#2585)" (reverts commit 8201583)
* Revert "Add tie lines support in limit violation detector (#2586)" (reverts commit 308a534)
* Keep ampl unit test from #2585
* Keep unit test and small fixes from #2586


Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
  • Loading branch information
flo-dup authored May 31, 2023
1 parent 16be660 commit b7f9c3d
Show file tree
Hide file tree
Showing 28 changed files with 910 additions and 725 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1718,8 +1718,6 @@ private void writeCurrentLimits() throws IOException {

writeBranchCurrentLimits(formatter);

writeTieLineCurrentLimits(formatter);

writeThreeWindingsTransformerCurrentLimits(formatter);

writeDanglingLineCurrentLimits(formatter);
Expand All @@ -1740,20 +1738,6 @@ private void writeBranchCurrentLimits(TableFormatter formatter) throws IOExcepti
}
}

private void writeTieLineCurrentLimits(TableFormatter formatter) throws IOException {
for (TieLine line : network.getTieLines()) {
String lineId = line.getId();
Optional<CurrentLimits> currentLimits1 = line.getDanglingLine1().getCurrentLimits();
if (currentLimits1.isPresent()) {
writeTemporaryCurrentLimits(currentLimits1.get(), formatter, lineId, true, "_1_");
}
Optional<CurrentLimits> currentLimits2 = line.getDanglingLine2().getCurrentLimits();
if (currentLimits2.isPresent()) {
writeTemporaryCurrentLimits(currentLimits2.get(), formatter, lineId, false, "_2_");
}
}
}

private void writeThreeWindingsTransformerCurrentLimits(TableFormatter formatter) throws IOException {
for (ThreeWindingsTransformer twt : network.getThreeWindingsTransformers()) {
Optional<CurrentLimits> currentLimits1 = twt.getLeg1().getCurrentLimits();
Expand Down
222 changes: 21 additions & 201 deletions iidm/iidm-api/src/main/java/com/powsybl/iidm/network/Branch.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
*
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
public interface Branch<I extends Branch<I>> extends Connectable<I> {
public interface Branch<I extends Branch<I>> extends Identifiable<I> {

enum Side {
ONE,
Expand Down Expand Up @@ -192,7 +192,7 @@ default Collection<OperationalLimits> getOperationalLimits2() {

ApparentPowerLimitsAdder newApparentPowerLimits2();

default Optional<CurrentLimits> getCurrentLimits(Branch.Side side) {
default Optional<CurrentLimits> getCurrentLimits(Side side) {
switch (side) {
case ONE:
return getCurrentLimits1();
Expand All @@ -203,7 +203,7 @@ default Optional<CurrentLimits> getCurrentLimits(Branch.Side side) {
}
}

default Optional<ActivePowerLimits> getActivePowerLimits(Branch.Side side) {
default Optional<ActivePowerLimits> getActivePowerLimits(Side side) {
switch (side) {
case ONE:
return getActivePowerLimits1();
Expand All @@ -214,7 +214,7 @@ default Optional<ActivePowerLimits> getActivePowerLimits(Branch.Side side) {
}
}

default Optional<ApparentPowerLimits> getApparentPowerLimits(Branch.Side side) {
default Optional<ApparentPowerLimits> getApparentPowerLimits(Side side) {
switch (side) {
case ONE:
return getApparentPowerLimits1();
Expand All @@ -225,7 +225,7 @@ default Optional<ApparentPowerLimits> getApparentPowerLimits(Branch.Side side) {
}
}

default Optional<? extends LoadingLimits> getLimits(LimitType type, Branch.Side side) {
default Optional<? extends LoadingLimits> getLimits(LimitType type, Side side) {
switch (type) {
case CURRENT:
return getCurrentLimits(side);
Expand All @@ -238,7 +238,7 @@ default Optional<? extends LoadingLimits> getLimits(LimitType type, Branch.Side
}
}

default CurrentLimits getNullableCurrentLimits(Branch.Side side) {
default CurrentLimits getNullableCurrentLimits(Side side) {
switch (side) {
case ONE:
return getNullableCurrentLimits1();
Expand All @@ -249,7 +249,7 @@ default CurrentLimits getNullableCurrentLimits(Branch.Side side) {
}
}

default ActivePowerLimits getNullableActivePowerLimits(Branch.Side side) {
default ActivePowerLimits getNullableActivePowerLimits(Side side) {
switch (side) {
case ONE:
return getNullableActivePowerLimits1();
Expand All @@ -260,7 +260,7 @@ default ActivePowerLimits getNullableActivePowerLimits(Branch.Side side) {
}
}

default ApparentPowerLimits getNullableApparentPowerLimits(Branch.Side side) {
default ApparentPowerLimits getNullableApparentPowerLimits(Side side) {
switch (side) {
case ONE:
return getNullableApparentPowerLimits1();
Expand All @@ -271,7 +271,7 @@ default ApparentPowerLimits getNullableApparentPowerLimits(Branch.Side side) {
}
}

default LoadingLimits getNullableLimits(LimitType type, Branch.Side side) {
default LoadingLimits getNullableLimits(LimitType type, Side side) {
switch (type) {
case CURRENT:
return getNullableCurrentLimits(side);
Expand All @@ -296,207 +296,27 @@ default LoadingLimits getNullableLimits(LimitType type, Branch.Side side) {

int getOverloadDuration();

/**
* @deprecated Since 4.3.0, use {@link #checkPermanentLimit(Side, float, LimitType)} instead.
*/
@Deprecated(since = "4.3.0")
default boolean checkPermanentLimit(Side side, float limitReduction) {
return checkPermanentLimit(side, limitReduction, LimitType.CURRENT);
}

default boolean checkPermanentLimit(Side side, float limitReduction, LimitType type) {
if (type == LimitType.CURRENT) {
return checkPermanentLimit(side, limitReduction);
} else {
throw new UnsupportedOperationException(
String.format("Limit type %s not supported in default implementation. Only %s is supported.", type.name(), LimitType.CURRENT));
}
}

/**
* @deprecated Since 4.3.0, use {@link #checkPermanentLimit(Side, LimitType)} instead.
*/
@Deprecated(since = "4.3.0")
default boolean checkPermanentLimit(Side side) {
return checkPermanentLimit(side, LimitType.CURRENT);
}

default boolean checkPermanentLimit(Side side, LimitType type) {
if (type == LimitType.CURRENT) {
return checkPermanentLimit(side);
} else {
throw new UnsupportedOperationException(
String.format("Limit type %s not supported in default implementation. Only %s is supported.", type.name(), LimitType.CURRENT));
}
}

/**
* @deprecated Since 4.3.0, use {@link #checkPermanentLimit1(float, LimitType)} instead.
*/
@Deprecated(since = "4.3.0")
default boolean checkPermanentLimit1(float limitReduction) {
return checkPermanentLimit1(limitReduction, LimitType.CURRENT);
}

default boolean checkPermanentLimit1(float limitReduction, LimitType type) {
if (type == LimitType.CURRENT) {
return checkPermanentLimit1(limitReduction);
} else {
throw new UnsupportedOperationException(
String.format("Limit type %s not supported in default implementation. Only %s is supported.", type.name(), LimitType.CURRENT));
}
}

/**
* @deprecated Since 4.3.0, use {@link #checkPermanentLimit1(LimitType)} instead.
*/
@Deprecated(since = "4.3.0")
default boolean checkPermanentLimit1() {
return checkPermanentLimit1(LimitType.CURRENT);
}

default boolean checkPermanentLimit1(LimitType type) {
if (type == LimitType.CURRENT) {
return checkPermanentLimit1();
} else {
throw new UnsupportedOperationException(
String.format("Limit type %s not supported in default implementation. Only %s is supported.", type.name(), LimitType.CURRENT));
}
}

/**
* @deprecated Since 4.3.0, use {@link #checkPermanentLimit2(float, LimitType)} instead.
*/
@Deprecated(since = "4.3.0")
default boolean checkPermanentLimit2(float limitReduction) {
return checkPermanentLimit2(limitReduction, LimitType.CURRENT);
}

default boolean checkPermanentLimit2(float limitReduction, LimitType type) {
if (type == LimitType.CURRENT) {
return checkPermanentLimit2(limitReduction);
} else {
throw new UnsupportedOperationException(
String.format("Limit type %s not supported in default implementation. Only %s is supported.", type.name(), LimitType.CURRENT));
}
}

/**
* @deprecated Since 4.3.0, use {@link #checkPermanentLimit2(LimitType)} instead.
*/
@Deprecated(since = "4.3.0")
default boolean checkPermanentLimit2() {
return checkPermanentLimit2(LimitType.CURRENT);
}

default boolean checkPermanentLimit2(LimitType type) {
if (type == LimitType.CURRENT) {
return checkPermanentLimit2();
} else {
throw new UnsupportedOperationException(
String.format("Limit type %s not supported in default implementation. Only %s is supported.", type.name(), LimitType.CURRENT));
}
}

/**
* @deprecated Since 4.3.0, use {@link #checkTemporaryLimits(Side, float, LimitType)} instead.
*/
@Deprecated(since = "4.3.0")
default Overload checkTemporaryLimits(Side side, float limitReduction) {
return checkTemporaryLimits(side, limitReduction, LimitType.CURRENT);
}
boolean checkPermanentLimit(Side side, float limitReduction, LimitType type);

default Overload checkTemporaryLimits(Side side, float limitReduction, LimitType type) {
if (type == LimitType.CURRENT) {
return checkTemporaryLimits(side, limitReduction);
} else {
throw new UnsupportedOperationException(
String.format("Limit type %s not supported in default implementation. Only %s is supported.", type.name(), LimitType.CURRENT));
}
}
boolean checkPermanentLimit(Side side, LimitType type);

/**
* @deprecated Since 4.3.0, use {@link #checkTemporaryLimits(Side, LimitType)} instead.
*/
@Deprecated(since = "4.3.0")
default Overload checkTemporaryLimits(Side side) {
return checkTemporaryLimits(side, LimitType.CURRENT);
}
boolean checkPermanentLimit1(float limitReduction, LimitType type);

default Overload checkTemporaryLimits(Side side, LimitType type) {
if (type == LimitType.CURRENT) {
return checkTemporaryLimits(side);
} else {
throw new UnsupportedOperationException(
String.format("Limit type %s not supported in default implementation. Only %s is supported.", type.name(), LimitType.CURRENT));
}
}
boolean checkPermanentLimit1(LimitType type);

/**
* @deprecated Since 4.3.0, use {@link #checkTemporaryLimits1(float, LimitType)} instead.
*/
@Deprecated(since = "4.3.0")
default Overload checkTemporaryLimits1(float limitReduction) {
return checkTemporaryLimits1(limitReduction, LimitType.CURRENT);
}
boolean checkPermanentLimit2(float limitReduction, LimitType type);

default Overload checkTemporaryLimits1(float limitReduction, LimitType type) {
if (type == LimitType.CURRENT) {
return checkTemporaryLimits1(limitReduction);
} else {
throw new UnsupportedOperationException(
String.format("Limit type %s not supported in default implementation. Only %s is supported.", type.name(), LimitType.CURRENT));
}
}
boolean checkPermanentLimit2(LimitType type);

/**
* @deprecated Since 4.3.0, use {@link #checkTemporaryLimits1(LimitType)} instead.
*/
@Deprecated(since = "4.3.0")
default Overload checkTemporaryLimits1() {
return checkTemporaryLimits1(LimitType.CURRENT);
}
Overload checkTemporaryLimits(Side side, float limitReduction, LimitType type);

default Overload checkTemporaryLimits1(LimitType type) {
if (type == LimitType.CURRENT) {
return checkTemporaryLimits1();
} else {
throw new UnsupportedOperationException(
String.format("Limit type %s not supported in default implementation. Only %s is supported.", type.name(), LimitType.CURRENT));
}
}
Overload checkTemporaryLimits(Side side, LimitType type);

/**
* @deprecated Since 4.3.0, use {@link #checkTemporaryLimits2(float, LimitType)} instead.
*/
@Deprecated(since = "4.3.0")
default Overload checkTemporaryLimits2(float limitReduction) {
return checkTemporaryLimits2(limitReduction, LimitType.CURRENT);
}
Overload checkTemporaryLimits1(float limitReduction, LimitType type);

default Overload checkTemporaryLimits2(float limitReduction, LimitType type) {
if (type == LimitType.CURRENT) {
return checkTemporaryLimits2(limitReduction);
} else {
throw new UnsupportedOperationException(
String.format("Limit type %s not supported in default implementation. Only %s is supported.", type.name(), LimitType.CURRENT));
}
}
Overload checkTemporaryLimits1(LimitType type);

/**
* @deprecated Since 4.3.0, use {@link #checkTemporaryLimits2(LimitType)} instead.
*/
@Deprecated(since = "4.3.0")
default Overload checkTemporaryLimits2() {
return checkTemporaryLimits2(LimitType.CURRENT);
}
Overload checkTemporaryLimits2(float limitReduction, LimitType type);

default Overload checkTemporaryLimits2(LimitType type) {
if (type == LimitType.CURRENT) {
return checkTemporaryLimits2();
} else {
throw new UnsupportedOperationException(
String.format("Limit type %s not supported in default implementation. Only %s is supported.", type.name(), LimitType.CURRENT));
}
}
Overload checkTemporaryLimits2(LimitType type);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
public interface BranchAdder<T extends Branch<? super T>, A extends BranchAdder> extends IdentifiableAdder<T, A> {
public interface BranchAdder<T extends Branch<? super T> & Connectable<? super T>, A extends BranchAdder> extends IdentifiableAdder<T, A> {

A setVoltageLevel1(String voltageLevelId1);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
* @see LineAdder
*/
public interface Line extends Branch<Line>, MutableLineCharacteristics<Line> {
public interface Line extends Branch<Line>, Connectable<Line>, MutableLineCharacteristics<Line> {

/**
* @deprecated tie lines are not lines anymore.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
* @author Luma Zamarreño <zamarrenolm at aia.es>
* @author José Antonio Marqués <marquesja at aia.es>
*/
public interface TieLine extends Identifiable<TieLine>, LineCharacteristics {
public interface TieLine extends Branch<TieLine>, LineCharacteristics {

/**
* Get the UCTE Xnode code corresponding to this tie line in the case where the
Expand All @@ -183,7 +183,7 @@ public interface TieLine extends Identifiable<TieLine>, LineCharacteristics {
/**
* Get the dangling line of this tie line corresponding to the given side
*/
DanglingLine getDanglingLine(Branch.Side side);
DanglingLine getDanglingLine(Side side);

/**
* Get the dangling line of this tie line corresponding to the given voltage level
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
* @see PhaseTapChanger
* @see TwoWindingsTransformerAdder
*/
public interface TwoWindingsTransformer extends Branch<TwoWindingsTransformer>, RatioTapChangerHolder, PhaseTapChangerHolder {
public interface TwoWindingsTransformer extends Branch<TwoWindingsTransformer>, Connectable<TwoWindingsTransformer>, RatioTapChangerHolder, PhaseTapChangerHolder {

Optional<Substation> getSubstation();

Expand Down
Loading

0 comments on commit b7f9c3d

Please sign in to comment.