diff --git a/src/main/java/com/powsybl/openloadflow/OpenLoadFlowProvider.java b/src/main/java/com/powsybl/openloadflow/OpenLoadFlowProvider.java index 111ed87d92..5730816aa1 100644 --- a/src/main/java/com/powsybl/openloadflow/OpenLoadFlowProvider.java +++ b/src/main/java/com/powsybl/openloadflow/OpenLoadFlowProvider.java @@ -30,7 +30,6 @@ import com.powsybl.openloadflow.network.LfBranch; import com.powsybl.openloadflow.network.LfBus; import com.powsybl.openloadflow.network.LfNetwork; -import com.powsybl.openloadflow.network.LfNetworkParameters; import com.powsybl.openloadflow.network.impl.LfNetworkLoaderImpl; import com.powsybl.openloadflow.network.impl.Networks; import com.powsybl.openloadflow.network.util.ZeroImpedanceFlows; @@ -126,7 +125,7 @@ private LoadFlowResult runAc(Network network, LoadFlowParameters parameters, Rep parameters.isDistributedSlack() && (parameters.getBalanceType() == LoadFlowParameters.BalanceType.PROPORTIONAL_TO_LOAD || parameters.getBalanceType() == LoadFlowParameters.BalanceType.PROPORTIONAL_TO_CONFORM_LOAD) && parametersExt.isLoadPowerFactorConstant(), parameters.isDc()); // zero or low impedance branch flows computation - computeZeroImpedanceFlows(result.getNetwork(), parameters.isDc(), parametersExt.getLowImpedanceThreshold()); + computeZeroImpedanceFlows(result.getNetwork()); } LoadFlowResult.ComponentResult.Status status; @@ -158,11 +157,11 @@ private LoadFlowResult runAc(Network network, LoadFlowParameters parameters, Rep return new LoadFlowResultImpl(ok, Collections.emptyMap(), null, componentResults); } - private void computeZeroImpedanceFlows(LfNetwork network, boolean dc, double lowImpedanceThreshold) { - Graph zeroImpedanceSubGraph = network.createZeroImpedanceSubGraph(dc, lowImpedanceThreshold); + private void computeZeroImpedanceFlows(LfNetwork network) { + Graph zeroImpedanceSubGraph = network.createZeroImpedanceSubGraph(); if (!zeroImpedanceSubGraph.vertexSet().isEmpty()) { SpanningTreeAlgorithm.SpanningTree spanningTree = new KruskalMinimumSpanningTree<>(zeroImpedanceSubGraph).getSpanningTree(); - new ZeroImpedanceFlows(zeroImpedanceSubGraph, spanningTree).compute(dc, lowImpedanceThreshold); + new ZeroImpedanceFlows(zeroImpedanceSubGraph, spanningTree).compute(); } } @@ -176,13 +175,12 @@ private LoadFlowResult runDc(Network network, LoadFlowParameters parameters, Rep Networks.resetState(network); - List componentsResult = results.stream().map(r -> processResult(network, r, parameters, dcParameters.getNetworkParameters())).collect(Collectors.toList()); + List componentsResult = results.stream().map(r -> processResult(network, r, parameters)).collect(Collectors.toList()); boolean ok = results.stream().anyMatch(DcLoadFlowResult::isSucceeded); return new LoadFlowResultImpl(ok, Collections.emptyMap(), null, componentsResult); } - private LoadFlowResult.ComponentResult processResult(Network network, DcLoadFlowResult result, LoadFlowParameters parameters, - LfNetworkParameters networkParameters) { + private LoadFlowResult.ComponentResult processResult(Network network, DcLoadFlowResult result, LoadFlowParameters parameters) { if (result.isSucceeded() && parameters.isWriteSlackBus()) { SlackTerminal.reset(network); } @@ -196,7 +194,7 @@ private LoadFlowResult.ComponentResult processResult(Network network, DcLoadFlow false, true); // zero or low impedance branch flows computation - computeZeroImpedanceFlows(result.getNetwork(), true, networkParameters.getLowImpedanceThreshold()); + computeZeroImpedanceFlows(result.getNetwork()); } return new LoadFlowResultImpl.ComponentResultImpl( diff --git a/src/main/java/com/powsybl/openloadflow/ac/equations/AcEquationSystem.java b/src/main/java/com/powsybl/openloadflow/ac/equations/AcEquationSystem.java index 666c261686..6da1ec646f 100644 --- a/src/main/java/com/powsybl/openloadflow/ac/equations/AcEquationSystem.java +++ b/src/main/java/com/powsybl/openloadflow/ac/equations/AcEquationSystem.java @@ -25,8 +25,7 @@ private AcEquationSystem() { private static void createBusEquation(LfBus bus, EquationSystem equationSystem, - AcEquationSystemCreationParameters creationParameters, - double lowImpedanceThreshold) { + AcEquationSystemCreationParameters creationParameters) { var p = equationSystem.createEquation(bus, AcEquationType.BUS_TARGET_P); bus.setP(p); var q = equationSystem.createEquation(bus, AcEquationType.BUS_TARGET_Q); @@ -39,7 +38,7 @@ private static void createBusEquation(LfBus bus, p.setActive(false); } - createGeneratorControlEquations(bus, equationSystem, creationParameters, lowImpedanceThreshold); + createGeneratorControlEquations(bus, equationSystem, creationParameters); createShuntEquations(bus, equationSystem); @@ -60,24 +59,22 @@ private static void createBusEquation(LfBus bus, private static void createBusesEquations(LfNetwork network, EquationSystem equationSystem, - AcEquationSystemCreationParameters creationParameters, - double lowImpedanceThreshold) { + AcEquationSystemCreationParameters creationParameters) { for (LfBus bus : network.getBuses()) { - createBusEquation(bus, equationSystem, creationParameters, lowImpedanceThreshold); + createBusEquation(bus, equationSystem, creationParameters); } } private static void createGeneratorControlEquations(LfBus bus, EquationSystem equationSystem, - AcEquationSystemCreationParameters creationParameters, - double lowImpedanceThreshold) { + AcEquationSystemCreationParameters creationParameters) { bus.getVoltageControl() .ifPresent(voltageControl -> { if (bus.isVoltageControlled()) { if (voltageControl.isVoltageControlLocal()) { - createLocalVoltageControlEquation(bus, equationSystem, creationParameters, lowImpedanceThreshold); + createLocalVoltageControlEquation(bus, equationSystem, creationParameters); } else { - createRemoteVoltageControlEquations(voltageControl, equationSystem, creationParameters, lowImpedanceThreshold); + createRemoteVoltageControlEquations(voltageControl, equationSystem, creationParameters); } updateGeneratorVoltageControl(voltageControl, equationSystem); } @@ -86,8 +83,7 @@ private static void createGeneratorControlEquations(LfBus bus, private static void createLocalVoltageControlEquation(LfBus bus, EquationSystem equationSystem, - AcEquationSystemCreationParameters creationParameters, - double lowImpedanceThreshold) { + AcEquationSystemCreationParameters creationParameters) { EquationTerm vTerm = equationSystem.getVariable(bus.getNum(), AcVariableType.BUS_V) .createTerm(); bus.setCalculatedV(vTerm); @@ -100,7 +96,7 @@ private static void createLocalVoltageControlEquation(LfBus bus, // which is modeled here with: V + slope * (sum_branch qBranch) = TargetV - slope * qLoads + slope * qGenerators equationSystem.createEquation(bus, AcEquationType.BUS_TARGET_V_WITH_SLOPE) .addTerm(vTerm) - .addTerms(createReactiveTerms(bus, equationSystem.getVariableSet(), creationParameters, lowImpedanceThreshold) + .addTerms(createReactiveTerms(bus, equationSystem.getVariableSet(), creationParameters) .stream() .map(term -> term.multiply(slope)) .collect(Collectors.toList())); @@ -157,8 +153,7 @@ private static void createShuntEquations(LfBus bus, EquationSystem equationSystem, - AcEquationSystemCreationParameters creationParameters, - double lowImpedanceThreshold) { + AcEquationSystemCreationParameters creationParameters) { LfBus controlledBus = voltageControl.getControlledBus(); // create voltage equation at voltage controlled bus @@ -178,12 +173,12 @@ private static void createRemoteVoltageControlEquations(VoltageControl voltageCo // which can be rewritten in a more simple way // 0 = (qPercent_i - 1) * q_i + qPercent_i * sum_j(q_j) where j are all the voltage controller buses except i Equation zero = equationSystem.createEquation(controllerBus, AcEquationType.DISTR_Q) - .addTerms(createReactiveTerms(controllerBus, equationSystem.getVariableSet(), creationParameters, lowImpedanceThreshold).stream() + .addTerms(createReactiveTerms(controllerBus, equationSystem.getVariableSet(), creationParameters).stream() .map(term -> term.multiply(() -> controllerBus.getRemoteVoltageControlReactivePercent() - 1)) .collect(Collectors.toList())); for (LfBus otherControllerBus : voltageControl.getControllerBuses()) { if (otherControllerBus != controllerBus) { - zero.addTerms(createReactiveTerms(otherControllerBus, equationSystem.getVariableSet(), creationParameters, lowImpedanceThreshold).stream() + zero.addTerms(createReactiveTerms(otherControllerBus, equationSystem.getVariableSet(), creationParameters).stream() .map(term -> term.multiply(controllerBus::getRemoteVoltageControlReactivePercent)) .collect(Collectors.toList())); } @@ -249,12 +244,11 @@ static void updateRemoteVoltageControlEquations(VoltageControl voltageControl, E private static List> createReactiveTerms(LfBus controllerBus, VariableSet variableSet, - AcEquationSystemCreationParameters creationParameters, - double lowImpedanceThreshold) { + AcEquationSystemCreationParameters creationParameters) { List> terms = new ArrayList<>(); for (LfBranch branch : controllerBus.getBranches()) { EquationTerm q; - if (branch.isZeroImpedanceBranch(false, lowImpedanceThreshold)) { + if (branch.isZeroImpedance()) { if (!branch.isSpanningTreeEdge()) { continue; } @@ -744,10 +738,9 @@ private static void createHvdcAcEmulationEquations(LfHvdc hvdc, EquationSystem equationSystem, - AcEquationSystemCreationParameters creationParameters, - double lowImpedanceThreshold) { + AcEquationSystemCreationParameters creationParameters) { // create zero and non zero impedance branch equations - if (branch.isZeroImpedanceBranch(false, lowImpedanceThreshold)) { + if (branch.isZeroImpedance()) { if (branch.isSpanningTreeEdge()) { createNonImpedantBranch(branch, branch.getBus1(), branch.getBus2(), equationSystem); } @@ -758,27 +751,24 @@ private static void createBranchEquations(LfBranch branch, private static void createBranchesEquations(LfNetwork network, EquationSystem equationSystem, - AcEquationSystemCreationParameters creationParameters, - double lowImpedanceThreshold) { + AcEquationSystemCreationParameters creationParameters) { for (LfBranch branch : network.getBranches()) { - createBranchEquations(branch, equationSystem, creationParameters, lowImpedanceThreshold); + createBranchEquations(branch, equationSystem, creationParameters); } } public static EquationSystem create(LfNetwork network) { - return create(network, new AcEquationSystemCreationParameters(), LfNetworkParameters.LOW_IMPEDANCE_THRESHOLD_DEFAULT_VALUE); + return create(network, new AcEquationSystemCreationParameters()); } - public static EquationSystem create(LfNetwork network, - AcEquationSystemCreationParameters creationParameters, - double lowImpedanceThreshold) { + public static EquationSystem create(LfNetwork network, AcEquationSystemCreationParameters creationParameters) { Objects.requireNonNull(network); Objects.requireNonNull(creationParameters); EquationSystem equationSystem = new EquationSystem<>(true); - createBusesEquations(network, equationSystem, creationParameters, lowImpedanceThreshold); - createBranchesEquations(network, equationSystem, creationParameters, lowImpedanceThreshold); + createBusesEquations(network, equationSystem, creationParameters); + createBranchesEquations(network, equationSystem, creationParameters); for (LfHvdc hvdc : network.getHvdcs()) { createHvdcAcEmulationEquations(hvdc, equationSystem); @@ -786,7 +776,7 @@ public static EquationSystem create(LfNetwork ne EquationSystemPostProcessor.findAll().forEach(pp -> pp.onCreate(equationSystem)); - network.addListener(new AcEquationSystemUpdater(equationSystem, lowImpedanceThreshold)); + network.addListener(new AcEquationSystemUpdater(equationSystem)); return equationSystem; } diff --git a/src/main/java/com/powsybl/openloadflow/ac/equations/AcEquationSystemUpdater.java b/src/main/java/com/powsybl/openloadflow/ac/equations/AcEquationSystemUpdater.java index 3a84b18890..18d931aa4c 100644 --- a/src/main/java/com/powsybl/openloadflow/ac/equations/AcEquationSystemUpdater.java +++ b/src/main/java/com/powsybl/openloadflow/ac/equations/AcEquationSystemUpdater.java @@ -15,8 +15,8 @@ */ public class AcEquationSystemUpdater extends AbstractEquationSystemUpdater { - public AcEquationSystemUpdater(EquationSystem equationSystem, double lowImpedanceThreshold) { - super(equationSystem, lowImpedanceThreshold); + public AcEquationSystemUpdater(EquationSystem equationSystem) { + super(equationSystem); } @Override @@ -61,7 +61,7 @@ protected void updateNonImpedantBranchEquations(LfBranch branch, boolean enable) @Override public void onDisableChange(LfElement element, boolean disabled) { - updateElementEquations(element, !disabled, false); + updateElementEquations(element, !disabled); switch (element.getType()) { case BUS: LfBus bus = (LfBus) element; diff --git a/src/main/java/com/powsybl/openloadflow/ac/outerloop/AcLoadFlowContext.java b/src/main/java/com/powsybl/openloadflow/ac/outerloop/AcLoadFlowContext.java index 7fb9d40207..c61fc13ca5 100644 --- a/src/main/java/com/powsybl/openloadflow/ac/outerloop/AcLoadFlowContext.java +++ b/src/main/java/com/powsybl/openloadflow/ac/outerloop/AcLoadFlowContext.java @@ -35,8 +35,7 @@ public AcLoadFlowContext(LfNetwork network, AcLoadFlowParameters parameters) { @Override public EquationSystem getEquationSystem() { if (equationSystem == null) { - equationSystem = AcEquationSystem.create(network, parameters.getEquationSystemCreationParameters(), - parameters.getNetworkParameters().getLowImpedanceThreshold()); + equationSystem = AcEquationSystem.create(network, parameters.getEquationSystemCreationParameters()); } return equationSystem; } diff --git a/src/main/java/com/powsybl/openloadflow/dc/DcLoadFlowContext.java b/src/main/java/com/powsybl/openloadflow/dc/DcLoadFlowContext.java index 6c78d67c64..48eae0ebb3 100644 --- a/src/main/java/com/powsybl/openloadflow/dc/DcLoadFlowContext.java +++ b/src/main/java/com/powsybl/openloadflow/dc/DcLoadFlowContext.java @@ -29,7 +29,7 @@ public DcLoadFlowContext(LfNetwork network, DcLoadFlowParameters parameters) { @Override public EquationSystem getEquationSystem() { if (equationSystem == null) { - equationSystem = DcEquationSystem.create(network, parameters.getEquationSystemCreationParameters(), parameters.getNetworkParameters().getLowImpedanceThreshold(), true); + equationSystem = DcEquationSystem.create(network, parameters.getEquationSystemCreationParameters(), true); } return equationSystem; } diff --git a/src/main/java/com/powsybl/openloadflow/dc/equations/DcEquationSystem.java b/src/main/java/com/powsybl/openloadflow/dc/equations/DcEquationSystem.java index e500044e9c..25a563c045 100644 --- a/src/main/java/com/powsybl/openloadflow/dc/equations/DcEquationSystem.java +++ b/src/main/java/com/powsybl/openloadflow/dc/equations/DcEquationSystem.java @@ -13,13 +13,6 @@ import com.powsybl.openloadflow.network.LfBus; import com.powsybl.openloadflow.network.LfNetwork; import com.powsybl.openloadflow.util.EvaluableConstants; -import org.jgrapht.Graph; -import org.jgrapht.alg.interfaces.SpanningTreeAlgorithm; -import org.jgrapht.alg.spanning.KruskalMinimumSpanningTree; -import org.jgrapht.graph.Pseudograph; - -import java.util.ArrayList; -import java.util.List; /** * @author Geoffroy Jamgotchian @@ -111,48 +104,31 @@ private static void createImpedantBranch(EquationSystem equationSystem, - DcEquationSystemCreationParameters creationParameters, - double lowImpedanceThreshold) { - List nonImpedantBranches = new ArrayList<>(); + DcEquationSystemCreationParameters creationParameters) { for (LfBranch branch : network.getBranches()) { LfBus bus1 = branch.getBus1(); LfBus bus2 = branch.getBus2(); - if (branch.isZeroImpedanceBranch(true, lowImpedanceThreshold)) { - if (bus1 != null && bus2 != null) { - nonImpedantBranches.add(branch); + if (branch.isZeroImpedance()) { + if (branch.isSpanningTreeEdge()) { + createNonImpedantBranch(equationSystem, branch, bus1, bus2); } } else { createImpedantBranch(equationSystem, creationParameters, branch, bus1, bus2); } } - - // create non impedant equations only on minimum spanning forest calculated from non impedant subgraph - if (!nonImpedantBranches.isEmpty()) { - Graph nonImpedantSubGraph = new Pseudograph<>(LfBranch.class); - for (LfBranch branch : nonImpedantBranches) { - nonImpedantSubGraph.addVertex(branch.getBus1()); - nonImpedantSubGraph.addVertex(branch.getBus2()); - nonImpedantSubGraph.addEdge(branch.getBus1(), branch.getBus2(), branch); - } - - SpanningTreeAlgorithm.SpanningTree spanningTree = new KruskalMinimumSpanningTree<>(nonImpedantSubGraph).getSpanningTree(); - for (LfBranch branch : spanningTree.getEdges()) { - createNonImpedantBranch(equationSystem, branch, branch.getBus1(), branch.getBus2()); - } - } } public static EquationSystem create(LfNetwork network, DcEquationSystemCreationParameters creationParameters, - double lowImpedanceThreshold, boolean withListener) { + boolean withListener) { EquationSystem equationSystem = new EquationSystem<>(creationParameters.isIndexTerms()); createBuses(network, equationSystem); - createBranches(network, equationSystem, creationParameters, lowImpedanceThreshold); + createBranches(network, equationSystem, creationParameters); EquationSystemPostProcessor.findAll().forEach(pp -> pp.onCreate(equationSystem)); if (withListener) { - network.addListener(new DcEquationSystemUpdater(equationSystem, lowImpedanceThreshold)); + network.addListener(new DcEquationSystemUpdater(equationSystem)); } return equationSystem; diff --git a/src/main/java/com/powsybl/openloadflow/dc/equations/DcEquationSystemUpdater.java b/src/main/java/com/powsybl/openloadflow/dc/equations/DcEquationSystemUpdater.java index 478ab9ef72..308aefc0e3 100644 --- a/src/main/java/com/powsybl/openloadflow/dc/equations/DcEquationSystemUpdater.java +++ b/src/main/java/com/powsybl/openloadflow/dc/equations/DcEquationSystemUpdater.java @@ -15,8 +15,8 @@ */ public class DcEquationSystemUpdater extends AbstractEquationSystemUpdater { - public DcEquationSystemUpdater(EquationSystem equationSystem, double lowImpedanceThreshold) { - super(equationSystem, lowImpedanceThreshold); + public DcEquationSystemUpdater(EquationSystem equationSystem) { + super(equationSystem); } @Override @@ -33,7 +33,7 @@ protected void updateNonImpedantBranchEquations(LfBranch branch, boolean enable) @Override public void onDisableChange(LfElement element, boolean disabled) { - updateElementEquations(element, !disabled, true); + updateElementEquations(element, !disabled); switch (element.getType()) { case BUS: LfBus bus = (LfBus) element; diff --git a/src/main/java/com/powsybl/openloadflow/lf/AbstractEquationSystemUpdater.java b/src/main/java/com/powsybl/openloadflow/lf/AbstractEquationSystemUpdater.java index f14f78d2e2..70f6a78f53 100644 --- a/src/main/java/com/powsybl/openloadflow/lf/AbstractEquationSystemUpdater.java +++ b/src/main/java/com/powsybl/openloadflow/lf/AbstractEquationSystemUpdater.java @@ -22,11 +22,8 @@ public abstract class AbstractEquationSystemUpdater & Quantity protected final EquationSystem equationSystem; - protected final double lowImpedanceThreshold; - - protected AbstractEquationSystemUpdater(EquationSystem equationSystem, double lowImpedanceThreshold) { + protected AbstractEquationSystemUpdater(EquationSystem equationSystem) { this.equationSystem = equationSystem; - this.lowImpedanceThreshold = lowImpedanceThreshold; } protected static void checkSlackBus(LfBus bus, boolean disabled) { @@ -37,13 +34,8 @@ protected static void checkSlackBus(LfBus bus, boolean disabled) { protected abstract void updateNonImpedantBranchEquations(LfBranch branch, boolean enable); - protected boolean isNonImpedantBranchWithEquation(LfBranch branch, boolean dc) { - return branch.isZeroImpedanceBranch(dc, lowImpedanceThreshold) - && branch.isSpanningTreeEdge(); - } - - protected void updateElementEquations(LfElement element, boolean enable, boolean dc) { - if (element instanceof LfBranch && isNonImpedantBranchWithEquation((LfBranch) element, dc)) { + protected void updateElementEquations(LfElement element, boolean enable) { + if (element instanceof LfBranch && ((LfBranch) element).isZeroImpedance() && ((LfBranch) element).isSpanningTreeEdge()) { updateNonImpedantBranchEquations((LfBranch) element, enable); } else { // update all equations related to the element diff --git a/src/main/java/com/powsybl/openloadflow/network/LfBranch.java b/src/main/java/com/powsybl/openloadflow/network/LfBranch.java index 9708edc832..dc0b0d0580 100644 --- a/src/main/java/com/powsybl/openloadflow/network/LfBranch.java +++ b/src/main/java/com/powsybl/openloadflow/network/LfBranch.java @@ -139,7 +139,7 @@ default List getLimits2(LimitType type) { double computeApparentPower2(); - boolean isZeroImpedanceBranch(boolean dc, double lowImpedanceThreshold); + boolean isZeroImpedance(); void setSpanningTreeEdge(boolean spanningTreeEdge); diff --git a/src/main/java/com/powsybl/openloadflow/network/LfNetwork.java b/src/main/java/com/powsybl/openloadflow/network/LfNetwork.java index 8a22611a23..2e4e389f22 100644 --- a/src/main/java/com/powsybl/openloadflow/network/LfNetwork.java +++ b/src/main/java/com/powsybl/openloadflow/network/LfNetwork.java @@ -517,8 +517,8 @@ public static List load(T network, LfNetworkLoader networkLoad * The graph is intentionally not cached as a parameter so far, to avoid the complexity of invalidating it if changes occur * @return the zero-impedance subgraph */ - public Graph createZeroImpedanceSubGraph(boolean dc, double lowImpedanceThreshold) { - return createSubGraph(branch -> branch.isZeroImpedanceBranch(dc, lowImpedanceThreshold) + public Graph createZeroImpedanceSubGraph() { + return createSubGraph(branch -> branch.isZeroImpedance() && branch.getBus1() != null && branch.getBus2() != null); } diff --git a/src/main/java/com/powsybl/openloadflow/network/impl/AbstractImpedantLfBranch.java b/src/main/java/com/powsybl/openloadflow/network/impl/AbstractImpedantLfBranch.java index a8ebbfe181..25d0e7beb4 100644 --- a/src/main/java/com/powsybl/openloadflow/network/impl/AbstractImpedantLfBranch.java +++ b/src/main/java/com/powsybl/openloadflow/network/impl/AbstractImpedantLfBranch.java @@ -32,8 +32,8 @@ public abstract class AbstractImpedantLfBranch extends AbstractLfBranch { protected Evaluable i2 = NAN; - protected AbstractImpedantLfBranch(LfNetwork network, LfBus bus1, LfBus bus2, PiModel piModel) { - super(network, bus1, bus2, piModel); + protected AbstractImpedantLfBranch(LfNetwork network, LfBus bus1, LfBus bus2, PiModel piModel, boolean dc, double lowImpedanceThreshold) { + super(network, bus1, bus2, piModel, dc, lowImpedanceThreshold); } @Override diff --git a/src/main/java/com/powsybl/openloadflow/network/impl/AbstractLfBranch.java b/src/main/java/com/powsybl/openloadflow/network/impl/AbstractLfBranch.java index 9161caee22..8a2691c9be 100644 --- a/src/main/java/com/powsybl/openloadflow/network/impl/AbstractLfBranch.java +++ b/src/main/java/com/powsybl/openloadflow/network/impl/AbstractLfBranch.java @@ -49,12 +49,15 @@ public abstract class AbstractLfBranch extends AbstractElement implements LfBran private ReactivePowerControl reactivePowerControl; - protected AbstractLfBranch(LfNetwork network, LfBus bus1, LfBus bus2, PiModel piModel) { + protected boolean zeroImpedance; + + protected AbstractLfBranch(LfNetwork network, LfBus bus1, LfBus bus2, PiModel piModel, boolean dc, double lowImpedanceThreshold) { super(network); this.bus1 = bus1; this.bus2 = bus2; this.piModel = Objects.requireNonNull(piModel); this.piModel.setBranch(this); + zeroImpedance = isZeroImpedanceBranch(piModel, dc, lowImpedanceThreshold); } protected static List createSortedLimitsList(LoadingLimits loadingLimits, LfBus bus) { @@ -244,12 +247,8 @@ public double computeApparentPower2() { } @Override - public boolean isZeroImpedanceBranch(boolean dc, double lowImpedanceThreshold) { - if (dc) { - return FastMath.abs(piModel.getX()) < lowImpedanceThreshold; - } else { - return piModel.getZ() < lowImpedanceThreshold; - } + public boolean isZeroImpedance() { + return this.zeroImpedance; } @Override @@ -291,5 +290,14 @@ public void setMinZ(boolean dc, double lowImpedanceThreshold) { if (piModel.setMinZ(lowImpedanceThreshold, dc)) { LOGGER.trace("Branch {} has a low impedance, set to min {}", getId(), lowImpedanceThreshold); } + this.zeroImpedance = false; + } + + public static boolean isZeroImpedanceBranch(PiModel piModel, boolean dc, double lowImpedanceThreshold) { + if (dc) { + return FastMath.abs(piModel.getX()) < lowImpedanceThreshold; + } else { + return piModel.getZ() < lowImpedanceThreshold; + } } } diff --git a/src/main/java/com/powsybl/openloadflow/network/impl/LfBranchImpl.java b/src/main/java/com/powsybl/openloadflow/network/impl/LfBranchImpl.java index ab1ee609c5..cf2a243e73 100644 --- a/src/main/java/com/powsybl/openloadflow/network/impl/LfBranchImpl.java +++ b/src/main/java/com/powsybl/openloadflow/network/impl/LfBranchImpl.java @@ -23,12 +23,12 @@ public class LfBranchImpl extends AbstractImpedantLfBranch { private final Ref> branchRef; - protected LfBranchImpl(LfNetwork network, LfBus bus1, LfBus bus2, PiModel piModel, Branch branch) { - super(network, bus1, bus2, piModel); + protected LfBranchImpl(LfNetwork network, LfBus bus1, LfBus bus2, PiModel piModel, Branch branch, boolean dc, double lowImpedanceThreshold) { + super(network, bus1, bus2, piModel, dc, lowImpedanceThreshold); this.branchRef = new Ref<>(branch); } - private static LfBranchImpl createLine(Line line, LfNetwork network, LfBus bus1, LfBus bus2, double zb) { + private static LfBranchImpl createLine(Line line, LfNetwork network, LfBus bus1, LfBus bus2, double zb, boolean dc, double lowImpedanceThreshold) { PiModel piModel = new SimplePiModel() .setR1(1 / Transformers.getRatioPerUnitBase(line)) .setR(line.getR() / zb) @@ -38,10 +38,11 @@ private static LfBranchImpl createLine(Line line, LfNetwork network, LfBus bus1, .setB1(line.getB1() * zb) .setB2(line.getB2() * zb); - return new LfBranchImpl(network, bus1, bus2, piModel, line); + return new LfBranchImpl(network, bus1, bus2, piModel, line, dc, lowImpedanceThreshold); } - private static LfBranchImpl createTransformer(TwoWindingsTransformer twt, LfNetwork network, LfBus bus1, LfBus bus2, double zb, boolean twtSplitShuntAdmittance) { + private static LfBranchImpl createTransformer(TwoWindingsTransformer twt, LfNetwork network, LfBus bus1, LfBus bus2, double zb, + boolean twtSplitShuntAdmittance, boolean dc, double lowImpedanceThreshold) { PiModel piModel = null; double baseRatio = Transformers.getRatioPerUnitBase(twt); @@ -85,18 +86,19 @@ private static LfBranchImpl createTransformer(TwoWindingsTransformer twt, LfNetw piModel = Transformers.createPiModel(tapCharacteristics, zb, baseRatio, twtSplitShuntAdmittance); } - return new LfBranchImpl(network, bus1, bus2, piModel, twt); + return new LfBranchImpl(network, bus1, bus2, piModel, twt, dc, lowImpedanceThreshold); } - public static LfBranchImpl create(Branch branch, LfNetwork network, LfBus bus1, LfBus bus2, boolean twtSplitShuntAdmittance) { + public static LfBranchImpl create(Branch branch, LfNetwork network, LfBus bus1, LfBus bus2, boolean twtSplitShuntAdmittance, + boolean dc, double lowImpedanceThreshold) { Objects.requireNonNull(branch); double nominalV2 = branch.getTerminal2().getVoltageLevel().getNominalV(); double zb = nominalV2 * nominalV2 / PerUnit.SB; if (branch instanceof Line) { - return createLine((Line) branch, network, bus1, bus2, zb); + return createLine((Line) branch, network, bus1, bus2, zb, dc, lowImpedanceThreshold); } else if (branch instanceof TwoWindingsTransformer) { TwoWindingsTransformer twt = (TwoWindingsTransformer) branch; - return createTransformer(twt, network, bus1, bus2, zb, twtSplitShuntAdmittance); + return createTransformer(twt, network, bus1, bus2, zb, twtSplitShuntAdmittance, dc, lowImpedanceThreshold); } else { throw new PowsyblException("Unsupported type of branch for flow equations of branch: " + branch.getId()); } diff --git a/src/main/java/com/powsybl/openloadflow/network/impl/LfDanglingLineBranch.java b/src/main/java/com/powsybl/openloadflow/network/impl/LfDanglingLineBranch.java index 637257f9e9..c9f9ded8ae 100644 --- a/src/main/java/com/powsybl/openloadflow/network/impl/LfDanglingLineBranch.java +++ b/src/main/java/com/powsybl/openloadflow/network/impl/LfDanglingLineBranch.java @@ -26,12 +26,14 @@ public class LfDanglingLineBranch extends AbstractImpedantLfBranch { private final Ref danglingLineRef; - protected LfDanglingLineBranch(LfNetwork network, LfBus bus1, LfBus bus2, PiModel piModel, DanglingLine danglingLine) { - super(network, bus1, bus2, piModel); + protected LfDanglingLineBranch(LfNetwork network, LfBus bus1, LfBus bus2, PiModel piModel, DanglingLine danglingLine, + boolean dc, double lowImpedanceThreshold) { + super(network, bus1, bus2, piModel, dc, lowImpedanceThreshold); this.danglingLineRef = new Ref<>(danglingLine); } - public static LfDanglingLineBranch create(DanglingLine danglingLine, LfNetwork network, LfBus bus1, LfBus bus2) { + public static LfDanglingLineBranch create(DanglingLine danglingLine, LfNetwork network, LfBus bus1, LfBus bus2, + boolean dc, double lowImpedanceThreshold) { Objects.requireNonNull(danglingLine); Objects.requireNonNull(bus1); Objects.requireNonNull(bus2); @@ -44,7 +46,7 @@ public static LfDanglingLineBranch create(DanglingLine danglingLine, LfNetwork n .setG2(danglingLine.getG() / 2 * zb) .setB1(danglingLine.getB() / 2 * zb) .setB2(danglingLine.getB() / 2 * zb); - return new LfDanglingLineBranch(network, bus1, bus2, piModel, danglingLine); + return new LfDanglingLineBranch(network, bus1, bus2, piModel, danglingLine, dc, lowImpedanceThreshold); } private DanglingLine getDanglingLine() { diff --git a/src/main/java/com/powsybl/openloadflow/network/impl/LfLegBranch.java b/src/main/java/com/powsybl/openloadflow/network/impl/LfLegBranch.java index dcfd608b03..853f8e473e 100644 --- a/src/main/java/com/powsybl/openloadflow/network/impl/LfLegBranch.java +++ b/src/main/java/com/powsybl/openloadflow/network/impl/LfLegBranch.java @@ -23,8 +23,9 @@ public class LfLegBranch extends AbstractImpedantLfBranch { private final Ref legRef; - protected LfLegBranch(LfNetwork network, LfBus bus1, LfBus bus0, PiModel piModel, ThreeWindingsTransformer twt, ThreeWindingsTransformer.Leg leg) { - super(network, bus1, bus0, piModel); + protected LfLegBranch(LfNetwork network, LfBus bus1, LfBus bus0, PiModel piModel, ThreeWindingsTransformer twt, ThreeWindingsTransformer.Leg leg, + boolean dc, double lowImpedanceThreshold) { + super(network, bus1, bus0, piModel, dc, lowImpedanceThreshold); this.twtRef = new Ref<>(twt); this.legRef = new Ref<>(leg); } @@ -38,7 +39,7 @@ private ThreeWindingsTransformer.Leg getLeg() { } public static LfLegBranch create(LfNetwork network, LfBus bus1, LfBus bus0, ThreeWindingsTransformer twt, ThreeWindingsTransformer.Leg leg, - boolean twtSplitShuntAdmittance) { + boolean twtSplitShuntAdmittance, boolean dc, double lowImpedanceThreshold) { Objects.requireNonNull(bus0); Objects.requireNonNull(twt); Objects.requireNonNull(leg); @@ -87,7 +88,7 @@ public static LfLegBranch create(LfNetwork network, LfBus bus1, LfBus bus0, Thre piModel = Transformers.createPiModel(tapCharacteristics, zb, baseRatio, twtSplitShuntAdmittance); } - return new LfLegBranch(network, bus1, bus0, piModel, twt, leg); + return new LfLegBranch(network, bus1, bus0, piModel, twt, leg, dc, lowImpedanceThreshold); } private int getLegNum() { diff --git a/src/main/java/com/powsybl/openloadflow/network/impl/LfNetworkLoaderImpl.java b/src/main/java/com/powsybl/openloadflow/network/impl/LfNetworkLoaderImpl.java index bfe85b976b..ea295f1ffe 100644 --- a/src/main/java/com/powsybl/openloadflow/network/impl/LfNetworkLoaderImpl.java +++ b/src/main/java/com/powsybl/openloadflow/network/impl/LfNetworkLoaderImpl.java @@ -316,13 +316,13 @@ public void visitHvdcConverterStation(HvdcConverterStation converterStation) return lfBus; } - private static void addBranch(LfNetwork lfNetwork, LfBranch lfBranch, LfNetworkLoadingReport report, boolean dc, double lowImpedanceThreshold) { + private static void addBranch(LfNetwork lfNetwork, LfBranch lfBranch, LfNetworkLoadingReport report) { 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.isZeroImpedanceBranch(dc, lowImpedanceThreshold)) { + if (lfBranch.isZeroImpedance()) { LOGGER.trace("Branch {} is non impedant", lfBranch.getId()); report.nonImpedantBranches++; } @@ -335,8 +335,9 @@ private static void createBranches(List lfBuses, LfNetwork lfNetwork, Loa for (Branch branch : loadingContext.branchSet) { 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()); - addBranch(lfNetwork, lfBranch, report, parameters.isDc(), parameters.getLowImpedanceThreshold()); + LfBranchImpl lfBranch = LfBranchImpl.create(branch, lfNetwork, lfBus1, lfBus2, parameters.isTwtSplitShuntAdmittance(), + parameters.isDc(), parameters.getLowImpedanceThreshold()); + addBranch(lfNetwork, lfBranch, report); postProcessors.forEach(pp -> pp.onBranchAdded(branch, lfBranch)); } @@ -346,8 +347,8 @@ private static void createBranches(List lfBuses, LfNetwork lfNetwork, Loa lfNetwork.addBus(lfBus2); lfBuses.add(lfBus2); LfBus lfBus1 = getLfBus(danglingLine.getTerminal(), lfNetwork, parameters.isBreakers()); - LfBranch lfBranch = LfDanglingLineBranch.create(danglingLine, lfNetwork, lfBus1, lfBus2); - addBranch(lfNetwork, lfBranch, report, parameters.isDc(), parameters.getLowImpedanceThreshold()); + LfBranch lfBranch = LfDanglingLineBranch.create(danglingLine, lfNetwork, lfBus1, lfBus2, parameters.isDc(), parameters.getLowImpedanceThreshold()); + addBranch(lfNetwork, lfBranch, report); postProcessors.forEach(pp -> { pp.onBusAdded(danglingLine, lfBus2); pp.onBranchAdded(danglingLine, lfBranch); @@ -360,12 +361,12 @@ private static void createBranches(List lfBuses, LfNetwork lfNetwork, Loa LfBus lfBus1 = getLfBus(t3wt.getLeg1().getTerminal(), lfNetwork, parameters.isBreakers()); LfBus lfBus2 = getLfBus(t3wt.getLeg2().getTerminal(), lfNetwork, parameters.isBreakers()); LfBus lfBus3 = getLfBus(t3wt.getLeg3().getTerminal(), lfNetwork, parameters.isBreakers()); - 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, parameters.isDc(), parameters.getLowImpedanceThreshold()); - addBranch(lfNetwork, lfBranch2, report, parameters.isDc(), parameters.getLowImpedanceThreshold()); - addBranch(lfNetwork, lfBranch3, report, parameters.isDc(), parameters.getLowImpedanceThreshold()); + LfLegBranch lfBranch1 = LfLegBranch.create(lfNetwork, lfBus1, lfBus0, t3wt, t3wt.getLeg1(), parameters.isTwtSplitShuntAdmittance(), parameters.isDc(), parameters.getLowImpedanceThreshold()); + LfLegBranch lfBranch2 = LfLegBranch.create(lfNetwork, lfBus2, lfBus0, t3wt, t3wt.getLeg2(), parameters.isTwtSplitShuntAdmittance(), parameters.isDc(), parameters.getLowImpedanceThreshold()); + LfLegBranch lfBranch3 = LfLegBranch.create(lfNetwork, lfBus3, lfBus0, t3wt, t3wt.getLeg3(), parameters.isTwtSplitShuntAdmittance(), parameters.isDc(), parameters.getLowImpedanceThreshold()); + addBranch(lfNetwork, lfBranch1, report); + addBranch(lfNetwork, lfBranch2, report); + addBranch(lfNetwork, lfBranch3, report); postProcessors.forEach(pp -> { pp.onBusAdded(t3wt, lfBus0); pp.onBranchAdded(t3wt, lfBranch1); @@ -440,19 +441,18 @@ private static void createSwitches(List switches, LfNetwork lfNetwork, L Bus bus2 = vl.getBusBreakerView().getBus2(sw.getId()); LfBus lfBus1 = lfNetwork.getBusById(bus1.getId()); LfBus lfBus2 = lfNetwork.getBusById(bus2.getId()); - LfSwitch lfSwitch = new LfSwitch(lfNetwork, lfBus1, lfBus2, sw); - addBranch(lfNetwork, lfSwitch, report, dc, lowImpedanceThreshold); + LfSwitch lfSwitch = new LfSwitch(lfNetwork, lfBus1, lfBus2, sw, dc, lowImpedanceThreshold); + addBranch(lfNetwork, lfSwitch, report); postProcessors.forEach(pp -> pp.onBranchAdded(sw, lfSwitch)); } } } - private static void fixAllVoltageControls(LfNetwork lfNetwork, boolean minImpedance, boolean transformerVoltageControl, - boolean dc, double lowImpedanceThreshold) { + private static void fixAllVoltageControls(LfNetwork lfNetwork, boolean minImpedance, boolean transformerVoltageControl) { // If min impedance is set, there is no zero-impedance branch if (!minImpedance) { // Merge the discrete voltage control in each zero impedance connected set - List> connectedSets = new ConnectivityInspector<>(lfNetwork.createZeroImpedanceSubGraph(dc, lowImpedanceThreshold)).connectedSets(); + List> connectedSets = new ConnectivityInspector<>(lfNetwork.createZeroImpedanceSubGraph()).connectedSets(); connectedSets.forEach(connectedSet -> mergeVoltageControls(connectedSet, transformerVoltageControl)); } } @@ -751,13 +751,12 @@ private LfNetwork create(int numCC, int numSC, List buses, List swi if (!parameters.isDc()) { // Fixing voltage controls need to be done after creating switches, as the zero-impedance graph is changed with switches - fixAllVoltageControls(lfNetwork, parameters.isMinImpedance(), parameters.isTransformerVoltageControl(), - parameters.isDc(), parameters.getLowImpedanceThreshold()); + fixAllVoltageControls(lfNetwork, parameters.isMinImpedance(), parameters.isTransformerVoltageControl()); } if (!parameters.isMinImpedance()) { // create zero impedance equations only on minimum spanning forest calculated from zero impedance sub graph - Graph zeroImpedanceSubGraph = lfNetwork.createZeroImpedanceSubGraph(parameters.isDc(), parameters.getLowImpedanceThreshold()); + Graph zeroImpedanceSubGraph = lfNetwork.createZeroImpedanceSubGraph(); if (!zeroImpedanceSubGraph.vertexSet().isEmpty()) { SpanningTreeAlgorithm.SpanningTree spanningTree = new KruskalMinimumSpanningTree<>(zeroImpedanceSubGraph).getSpanningTree(); for (LfBranch branch : spanningTree.getEdges()) { diff --git a/src/main/java/com/powsybl/openloadflow/network/impl/LfSwitch.java b/src/main/java/com/powsybl/openloadflow/network/impl/LfSwitch.java index d33b793eba..5a68051bcc 100644 --- a/src/main/java/com/powsybl/openloadflow/network/impl/LfSwitch.java +++ b/src/main/java/com/powsybl/openloadflow/network/impl/LfSwitch.java @@ -27,8 +27,8 @@ public class LfSwitch extends AbstractLfBranch { private final Ref switchRef; - public LfSwitch(LfNetwork network, LfBus bus1, LfBus bus2, Switch aSwitch) { - super(network, bus1, bus2, new SimplePiModel()); + public LfSwitch(LfNetwork network, LfBus bus1, LfBus bus2, Switch aSwitch, boolean dc, double lowImpedanceThreshold) { + super(network, bus1, bus2, new SimplePiModel(), dc, lowImpedanceThreshold); this.switchRef = new Ref<>(aSwitch); } diff --git a/src/main/java/com/powsybl/openloadflow/network/util/ZeroImpedanceFlows.java b/src/main/java/com/powsybl/openloadflow/network/util/ZeroImpedanceFlows.java index 079b51c67d..4fb1e73af7 100644 --- a/src/main/java/com/powsybl/openloadflow/network/util/ZeroImpedanceFlows.java +++ b/src/main/java/com/powsybl/openloadflow/network/util/ZeroImpedanceFlows.java @@ -35,7 +35,7 @@ public ZeroImpedanceFlows(Graph zeroImpedanceSubGraph, Spanning this.tree = spanningTree; } - public void compute(boolean dc, double lowImpedanceThreshold) { + public void compute() { Set processed = new HashSet<>(); graph.vertexSet().forEach(lfBus -> { @@ -43,7 +43,7 @@ public void compute(boolean dc, double lowImpedanceThreshold) { return; } TreeByLevels treeByLevels = new TreeByLevels(graph, tree, lfBus); - treeByLevels.updateFlows(dc, lowImpedanceThreshold); + treeByLevels.updateFlows(); processed.addAll(treeByLevels.getProcessedLfBuses()); }); @@ -104,7 +104,7 @@ private static LfBus getOtherSideBus(LfBranch branch, LfBus bus) { return branch.getBus1().equals(bus) ? branch.getBus2() : branch.getBus1(); } - private void updateFlows(boolean dc, double lowImpedanceThreshold) { + private void updateFlows() { Map descendantZeroImpedanceFlow = new HashMap<>(); // traverse the tree from leaves to root @@ -112,7 +112,7 @@ private void updateFlows(boolean dc, double lowImpedanceThreshold) { int level = levels.size() - 1; while (level >= 1) { levels.get(level).forEach(bus -> { - PQ balance = balanceWithImpedance(bus, dc, lowImpedanceThreshold); + PQ balance = balanceWithImpedance(bus); PQ z0flow = getDescendantZeroImpedanceFlow(descendantZeroImpedanceFlow, bus); PQ branchFlow = balance.add(z0flow); @@ -124,7 +124,7 @@ private void updateFlows(boolean dc, double lowImpedanceThreshold) { } } - private PQ balanceWithImpedance(LfBus bus, boolean dc, double lowImpedanceThreshold) { + private PQ balanceWithImpedance(LfBus bus) { // balance considering injections and flow from lines with impedance // take care of the sign @@ -132,7 +132,7 @@ private PQ balanceWithImpedance(LfBus bus, boolean dc, double lowImpedanceThresh // only lines with impedance List adjacentBranchesWithImpedance = bus.getBranches().stream() - .filter(branch -> !branch.isZeroImpedanceBranch(dc, lowImpedanceThreshold)).collect(Collectors.toList()); + .filter(branch -> !branch.isZeroImpedance()).collect(Collectors.toList()); adjacentBranchesWithImpedance.forEach(branch -> { PQ branchFlow = getBranchFlow(branch, bus); diff --git a/src/main/java/com/powsybl/openloadflow/sensi/DcSensitivityAnalysis.java b/src/main/java/com/powsybl/openloadflow/sensi/DcSensitivityAnalysis.java index 7552d179a9..5c4edab9ea 100644 --- a/src/main/java/com/powsybl/openloadflow/sensi/DcSensitivityAnalysis.java +++ b/src/main/java/com/powsybl/openloadflow/sensi/DcSensitivityAnalysis.java @@ -832,8 +832,7 @@ public void analyse(Network network, List contingencies, var dcLoadFlowParameters = createDcLoadFlowParameters(lfNetworkParameters, matrixFactory, lfParameters); // create DC equation system for sensitivity analysis - EquationSystem equationSystem = DcEquationSystem.create(lfNetwork, dcLoadFlowParameters.getEquationSystemCreationParameters(), - dcLoadFlowParameters.getNetworkParameters().getLowImpedanceThreshold(), false); + EquationSystem equationSystem = DcEquationSystem.create(lfNetwork, dcLoadFlowParameters.getEquationSystemCreationParameters(), false); // next we only work with valid factors var validFactorHolder = writeInvalidFactors(allFactorHolder, resultWriter); diff --git a/src/test/java/com/powsybl/openloadflow/dc/DcLoadFlowMatrixTest.java b/src/test/java/com/powsybl/openloadflow/dc/DcLoadFlowMatrixTest.java index 0338e2a4b1..6527ea2deb 100644 --- a/src/test/java/com/powsybl/openloadflow/dc/DcLoadFlowMatrixTest.java +++ b/src/test/java/com/powsybl/openloadflow/dc/DcLoadFlowMatrixTest.java @@ -21,7 +21,6 @@ import com.powsybl.openloadflow.network.FirstSlackBusSelector; import com.powsybl.openloadflow.network.LfBus; import com.powsybl.openloadflow.network.LfNetwork; -import com.powsybl.openloadflow.network.LfNetworkParameters; import com.powsybl.openloadflow.network.impl.Networks; import com.powsybl.openloadflow.network.util.UniformValueVoltageInitializer; import org.junit.jupiter.api.Test; @@ -60,7 +59,7 @@ void buildDcMatrix() { LfNetwork mainNetwork = lfNetworks.get(0); DcEquationSystemCreationParameters creationParameters = new DcEquationSystemCreationParameters(true, false, false, true); - EquationSystem equationSystem = DcEquationSystem.create(mainNetwork, creationParameters, LfNetworkParameters.LOW_IMPEDANCE_THRESHOLD_DEFAULT_VALUE, false); + EquationSystem equationSystem = DcEquationSystem.create(mainNetwork, creationParameters, false); for (LfBus b : mainNetwork.getBuses()) { equationSystem.createEquation(b.getNum(), DcEquationType.BUS_TARGET_P); @@ -110,7 +109,7 @@ void buildDcMatrix() { lfNetworks = Networks.load(network, new FirstSlackBusSelector()); mainNetwork = lfNetworks.get(0); - equationSystem = DcEquationSystem.create(mainNetwork, creationParameters, LfNetworkParameters.LOW_IMPEDANCE_THRESHOLD_DEFAULT_VALUE, false); + equationSystem = DcEquationSystem.create(mainNetwork, creationParameters, false); try (var j = new JacobianMatrix<>(equationSystem, matrixFactory)) { try (DcTargetVector targets = new DcTargetVector(mainNetwork, equationSystem)) { diff --git a/src/test/java/com/powsybl/openloadflow/equations/EquationSystemTest.java b/src/test/java/com/powsybl/openloadflow/equations/EquationSystemTest.java index a1f801157a..7a307d187a 100644 --- a/src/test/java/com/powsybl/openloadflow/equations/EquationSystemTest.java +++ b/src/test/java/com/powsybl/openloadflow/equations/EquationSystemTest.java @@ -173,7 +173,7 @@ void writeDcSystemTest() { List lfNetworks = Networks.load(EurostagTutorialExample1Factory.create(), new FirstSlackBusSelector()); LfNetwork network = lfNetworks.get(0); - EquationSystem equationSystem = DcEquationSystem.create(network, new DcEquationSystemCreationParameters(true, false, false, true), LfNetworkParameters.LOW_IMPEDANCE_THRESHOLD_DEFAULT_VALUE, false); + EquationSystem equationSystem = DcEquationSystem.create(network, new DcEquationSystemCreationParameters(true, false, false, true), false); String ref = String.join(System.lineSeparator(), "bus_target_φ0 = φ0", "bus_target_p1 = dc_p_2(φ0, φ1) + dc_p_1(φ1, φ2) + dc_p_1(φ1, φ2)",