Skip to content

Commit

Permalink
New version of IIDM current limits
Browse files Browse the repository at this point in the history
  • Loading branch information
geofjamg committed Nov 2, 2016
1 parent ba9f1cb commit 1eb29a3
Show file tree
Hide file tree
Showing 21 changed files with 395 additions and 136 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1285,7 +1285,7 @@ private void writeTemporaryCurrentLimits(CurrentLimits limits, TableFormatter fo
formatter.writeCell(limitNum)
.writeCell(branchNum)
.writeCell(side1 ? 1 : 2)
.writeCell(tl.getLimit())
.writeCell(tl.getValue())
.writeCell(tl.getAcceptableDuration())
.writeCell(faultNum)
.writeCell(curativeActionNum);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,11 @@ private static void createCurrentLimits(cim1.model.Terminal t, Supplier<CurrentL
if (olt.getDirection() != cim1.model.OperationalLimitDirectionKind.absoluteValue) {
throw new RuntimeException("Direction not supported " + olt.getDirection());
}
int acceptableDuration = (int) olt.getAcceptableDuration();
cla.beginTemporaryLimit()
.setLimit(value)
.setAcceptableDuration((int) olt.getAcceptableDuration())
.setName(Integer.toString(acceptableDuration))
.setValue(value)
.setAcceptableDuration(acceptableDuration)
.endTemporaryLimit();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,32 @@ public interface CurrentLimits {
/**
* Temporary current limit.
*/
public interface TemporaryLimit {
interface TemporaryLimit {

/**
* Get the temporary limit in A.
* @return the temporary limit in A
* Get the temporary limit name
* @return the temporary limit name
*/
float getLimit();
String getName();

/**
* Get the temporary limit value in A.
* @return the temporary limit value in A
*/
float getValue();

/**
* Get the acceptable duration of the limit in second.
* @return the acceptable duration of the limit in second
*/
int getAcceptableDuration();

/**
* Check if the temporary limit is a real limit corresponding to an overloading protection or just an operating
* rule
* @return false if it is a real limit, false otherwise
*/
boolean isFictitious();
}

/**
Expand All @@ -46,4 +58,11 @@ public interface TemporaryLimit {
*/
Collection<TemporaryLimit> getTemporaryLimits();

/**
* Get a temporary limit from its acceptable duration. Return null if there is non temporay limit with this
* acceptable duration.
* @param acceptableDuration acceptable duration in second
* @return the temporary limit
*/
TemporaryLimit getTemporaryLimit(int acceptableDuration);
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@
*/
public interface CurrentLimitsAdder {

public static interface TemporaryLimitAdder {
interface TemporaryLimitAdder {

TemporaryLimitAdder setLimit(float limit);
TemporaryLimitAdder setName(String name);

TemporaryLimitAdder setValue(float value);

TemporaryLimitAdder setAcceptableDuration(int duration);

TemporaryLimitAdder setFictitious(boolean fictitious);

CurrentLimitsAdder endTemporaryLimit();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ enum Side {
TWO
}

interface Overload {

CurrentLimits.TemporaryLimit getTemporaryLimit();

float getPreviousLimit();
}

/**
* Get the first terminal.
*/
Expand All @@ -43,4 +50,28 @@ enum Side {
boolean isOverloaded();

int getOverloadDuration();

boolean checkPermanentLimit(Side side, float limitReduction);

boolean checkPermanentLimit(Side side);

boolean checkPermanentLimit1(float limitReduction);

boolean checkPermanentLimit1();

boolean checkPermanentLimit2(float limitReduction);

boolean checkPermanentLimit2();

Overload checkTemporaryLimits(Side side, float limitReduction);

Overload checkTemporaryLimits(Side side);

Overload checkTemporaryLimits1(float limitReduction);

Overload checkTemporaryLimits1();

Overload checkTemporaryLimits2(float limitReduction);

Overload checkTemporaryLimits2();
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,27 +92,129 @@ public CurrentLimitsAdder newCurrentLimits2() {
}

public boolean isOverloaded() {
return (limits1 != null && getTerminal1().getI() >= limits1.getPermanentLimit())
|| (limits2 != null && getTerminal2().getI() >= limits2.getPermanentLimit());
return checkTemporaryLimits1() != null || checkTemporaryLimits2() != null;
}

private static int getOverloadDuration(CurrentLimits limits, Terminal t) {
if (limits != null) {
float i1 = t.getI();
float previousLimit = limits.getPermanentLimit();
for (CurrentLimits.TemporaryLimit tl : limits.getTemporaryLimits()) {
if (i1 >= previousLimit && i1 < tl.getLimit()) {
return tl.getAcceptableDuration();
}
previousLimit = tl.getLimit();
public int getOverloadDuration() {
TwoTerminalsConnectable.Overload o1 = checkTemporaryLimits1();
TwoTerminalsConnectable.Overload o2 = checkTemporaryLimits1();
int duration1 = o1 != null ? o1.getTemporaryLimit().getAcceptableDuration() : Integer.MAX_VALUE;
int duration2 = o2 != null ? o2.getTemporaryLimit().getAcceptableDuration() : Integer.MAX_VALUE;
return Math.min(duration1, duration2);
}

public boolean checkPermanentLimit(Side side, float limitReduction) {
Objects.requireNonNull(side);
switch (side) {
case ONE:
return checkPermanentLimit1(limitReduction);

case TWO:
return checkPermanentLimit2(limitReduction);

default:
throw new AssertionError();
}
}

public boolean checkPermanentLimit(Side side) {
return checkPermanentLimit(side, 1f);
}

public boolean checkPermanentLimit1(float limitReduction) {
return checkPermanentLimit(getTerminal1(), getCurrentLimits1(), limitReduction);
}

public boolean checkPermanentLimit1() {
return checkPermanentLimit1(1f);
}

public boolean checkPermanentLimit2(float limitReduction) {
return checkPermanentLimit(getTerminal2(), getCurrentLimits2(), limitReduction);
}

public boolean checkPermanentLimit2() {
return checkPermanentLimit2(1f);
}

public static boolean checkPermanentLimit(Terminal terminal, CurrentLimits limits, float limitReduction) {
float i = terminal.getI();
if (limits != null && !Float.isNaN(limits.getPermanentLimit()) && !Float.isNaN(i) ) {
if (i > limits.getPermanentLimit() * limitReduction) {
return true;
}
}
return Integer.MAX_VALUE;
return false;
}

public int getOverloadDuration() {
int duration1 = getOverloadDuration(limits1, getTerminal1());
int duration2 = getOverloadDuration(limits2, getTerminal2());
return Math.min(duration1, duration2);
static class OverloadImpl implements TwoTerminalsConnectable.Overload {

private final CurrentLimits.TemporaryLimit temporaryLimit;

private final float previousLimit;

private OverloadImpl(CurrentLimits.TemporaryLimit temporaryLimit, float previousLimit) {
this.temporaryLimit = Objects.requireNonNull(temporaryLimit);
this.previousLimit = previousLimit;
}

@Override
public CurrentLimits.TemporaryLimit getTemporaryLimit() {
return temporaryLimit;
}

@Override
public float getPreviousLimit() {
return previousLimit;
}
}

public OverloadImpl checkTemporaryLimits(Side side, float limitReduction) {
Objects.requireNonNull(side);
switch (side) {
case ONE:
return checkTemporaryLimits1(limitReduction);

case TWO:
return checkTemporaryLimits2(limitReduction);

default:
throw new AssertionError();
}
}

public OverloadImpl checkTemporaryLimits(Side side) {
return checkTemporaryLimits(side, 1f);
}

public OverloadImpl checkTemporaryLimits1(float limitReduction) {
return checkTemporaryLimits(getTerminal1(), limits1, limitReduction);
}

public OverloadImpl checkTemporaryLimits1() {
return checkTemporaryLimits1(1f);
}

public OverloadImpl checkTemporaryLimits2(float limitReduction) {
return checkTemporaryLimits(getTerminal2(), limits2, limitReduction);
}

public OverloadImpl checkTemporaryLimits2() {
return checkTemporaryLimits2(1f);
}

private static OverloadImpl checkTemporaryLimits(TerminalExt t, CurrentLimits limits, float limitReduction) {
Objects.requireNonNull(t);
float i = t.getI();
if (limits != null && !Float.isNaN(limits.getPermanentLimit()) && !Float.isNaN(i)) {
float previousLimit = limits.getPermanentLimit();
for (CurrentLimits.TemporaryLimit tl : limits.getTemporaryLimits()) { // iterate in ascending order
if (i >= previousLimit * limitReduction && i < tl.getValue() * limitReduction) {
return new OverloadImpl(tl, previousLimit);
}
previousLimit = tl.getValue();
}
}
return null;
}
}

0 comments on commit 1eb29a3

Please sign in to comment.