Skip to content

Commit

Permalink
powsybl 6 tieline remove(boolean updateDangling)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonenst committed Aug 30, 2023
1 parent 648a09f commit eadad61
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,20 @@ public DanglingLine getDanglingLine(String voltageLevelId) {

@Override
public void remove() {
remove(false);
}

@Override
public void remove(boolean updateDanglingLines) {
var resource = getResource();

index.notifyBeforeRemoval(this);

if (updateDanglingLines) {
updateDanglingLine(getDanglingLine1());
updateDanglingLine(getDanglingLine2());
}

getDanglingLine1().removeTieLine();
getDanglingLine2().removeTieLine();
index.removeTieLine(resource.getId());
Expand Down Expand Up @@ -399,4 +409,22 @@ static int getOverloadDuration(Branch.Overload o1, Branch.Overload o2) {
int duration2 = o2 != null ? o2.getTemporaryLimit().getAcceptableDuration() : Integer.MAX_VALUE;
return Math.min(duration1, duration2);
}

private static void updateDanglingLine(DanglingLine danglingLine) {
// Only update if we have values
if (!Double.isNaN(danglingLine.getBoundary().getP())) {
danglingLine.setP0(-danglingLine.getBoundary().getP());
if (danglingLine.getGeneration() != null) {
// We do not reset regulation if we only have computed a dc load flow
danglingLine.getGeneration().setTargetP(0.0);
}
}
if (!Double.isNaN(danglingLine.getBoundary().getQ())) {
danglingLine.setQ0(-danglingLine.getBoundary().getQ());
if (danglingLine.getGeneration() != null) {
// If q values are available a complete ac load flow has been computed, we reset regulation
danglingLine.getGeneration().setTargetQ(0.0).setVoltageRegulationOn(false).setTargetV(Double.NaN);
}
}
}
}

0 comments on commit eadad61

Please sign in to comment.