Skip to content

Commit

Permalink
Fix min impedance check.
Browse files Browse the repository at this point in the history
Signed-off-by: Anne Tilloy <anne.tilloy@rte-france.com>
  • Loading branch information
annetill committed Jul 12, 2022
1 parent 51b5c35 commit 19456f0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
package com.powsybl.openloadflow.network;

import net.jafama.FastMath;
import org.apache.commons.math3.util.FastMath;

/**
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
Expand Down Expand Up @@ -149,7 +149,7 @@ private void rescaleZ(double z) {
@Override
public boolean setMinZ(double minZ, boolean dc) {
if (dc) {
if (this.x < minZ) {
if (FastMath.abs(this.x) < minZ) {
this.x = minZ;
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,13 +301,13 @@ public void visitHvdcConverterStation(HvdcConverterStation<?> converterStation)
return lfBus;
}

private static void addBranch(LfNetwork lfNetwork, LfBranch lfBranch, LfNetworkLoadingReport report) {
private static void addBranch(LfNetwork lfNetwork, LfBranch lfBranch, LfNetworkLoadingReport report, boolean dc) {
boolean connectedToSameBus = lfBranch.getBus1() == lfBranch.getBus2();
if (connectedToSameBus) {
LOGGER.trace("Discard branch '{}' because connected to same bus at both ends", lfBranch.getId());
report.branchesDiscardedBecauseConnectedToSameBusAtBothEnds++;
} else {
if (lfBranch.getPiModel().getZ() == 0) {
if (lfBranch.isZeroImpedanceBranch(dc)) {
LOGGER.trace("Branch {} is non impedant", lfBranch.getId());
report.nonImpedantBranches++;
}
Expand All @@ -321,7 +321,7 @@ private static void createBranches(List<LfBus> lfBuses, LfNetwork lfNetwork, Loa
LfBus lfBus1 = getLfBus(branch.getTerminal1(), lfNetwork, parameters.isBreakers());
LfBus lfBus2 = getLfBus(branch.getTerminal2(), lfNetwork, parameters.isBreakers());
LfBranchImpl lfBranch = LfBranchImpl.create(branch, lfNetwork, lfBus1, lfBus2, parameters.isTwtSplitShuntAdmittance(), parameters.isAddRatioToLinesWithDifferentNominalVoltageAtBothEnds(), report);
addBranch(lfNetwork, lfBranch, report);
addBranch(lfNetwork, lfBranch, report, parameters.isDc());
postProcessors.forEach(pp -> pp.onBranchAdded(branch, lfBranch));
}

Expand All @@ -331,7 +331,7 @@ private static void createBranches(List<LfBus> lfBuses, LfNetwork lfNetwork, Loa
lfBuses.add(lfBus2);
LfBus lfBus1 = getLfBus(danglingLine.getTerminal(), lfNetwork, parameters.isBreakers());
LfBranch lfBranch = LfDanglingLineBranch.create(danglingLine, lfNetwork, lfBus1, lfBus2);
addBranch(lfNetwork, lfBranch, report);
addBranch(lfNetwork, lfBranch, report, parameters.isDc());
postProcessors.forEach(pp -> {
pp.onBusAdded(danglingLine, lfBus2);
pp.onBranchAdded(danglingLine, lfBranch);
Expand All @@ -347,9 +347,9 @@ private static void createBranches(List<LfBus> lfBuses, LfNetwork lfNetwork, Loa
LfLegBranch lfBranch1 = LfLegBranch.create(lfNetwork, lfBus1, lfBus0, t3wt, t3wt.getLeg1(), parameters.isTwtSplitShuntAdmittance());
LfLegBranch lfBranch2 = LfLegBranch.create(lfNetwork, lfBus2, lfBus0, t3wt, t3wt.getLeg2(), parameters.isTwtSplitShuntAdmittance());
LfLegBranch lfBranch3 = LfLegBranch.create(lfNetwork, lfBus3, lfBus0, t3wt, t3wt.getLeg3(), parameters.isTwtSplitShuntAdmittance());
addBranch(lfNetwork, lfBranch1, report);
addBranch(lfNetwork, lfBranch2, report);
addBranch(lfNetwork, lfBranch3, report);
addBranch(lfNetwork, lfBranch1, report, parameters.isDc());
addBranch(lfNetwork, lfBranch2, report, parameters.isDc());
addBranch(lfNetwork, lfBranch3, report, parameters.isDc());
postProcessors.forEach(pp -> {
pp.onBusAdded(t3wt, lfBus0);
pp.onBranchAdded(t3wt, lfBranch1);
Expand Down Expand Up @@ -416,7 +416,7 @@ private static void createTransformersVoltageControls(LfNetwork lfNetwork, boole
}

private static void createSwitches(List<Switch> switches, LfNetwork lfNetwork, List<LfNetworkLoaderPostProcessor> postProcessors,
LfNetworkLoadingReport report) {
LfNetworkLoadingReport report, boolean dc) {
if (switches != null) {
for (Switch sw : switches) {
VoltageLevel vl = sw.getVoltageLevel();
Expand All @@ -425,7 +425,7 @@ private static void createSwitches(List<Switch> switches, LfNetwork lfNetwork, L
LfBus lfBus1 = lfNetwork.getBusById(bus1.getId());
LfBus lfBus2 = lfNetwork.getBusById(bus2.getId());
LfSwitch lfSwitch = new LfSwitch(lfNetwork, lfBus1, lfBus2, sw);
addBranch(lfNetwork, lfSwitch, report);
addBranch(lfNetwork, lfSwitch, report, dc);
postProcessors.forEach(pp -> pp.onBranchAdded(sw, lfSwitch));
}
}
Expand Down Expand Up @@ -724,7 +724,7 @@ private static LfNetwork create(int numCC, int numSC, List<Bus> buses, List<Swit
}

if (parameters.isBreakers()) {
createSwitches(switches, lfNetwork, postProcessors, report);
createSwitches(switches, lfNetwork, postProcessors, report, parameters.isDc());
}

if (!parameters.isDc()) {
Expand Down

0 comments on commit 19456f0

Please sign in to comment.