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 5088662f28..c5ab8e36a3 100644 --- a/src/main/java/com/powsybl/openloadflow/network/impl/LfBranchImpl.java +++ b/src/main/java/com/powsybl/openloadflow/network/impl/LfBranchImpl.java @@ -70,7 +70,7 @@ private static LfBranchImpl createLine(Line line, LfNetwork network, LfBus bus1, } private static LfBranchImpl createTransformer(TwoWindingsTransformer twt, LfNetwork network, LfBus bus1, LfBus bus2, double zb, - boolean retain, LfNetworkParameters parameters) { + boolean retainPtc, boolean retainRtc, LfNetworkParameters parameters) { PiModel piModel = null; double baseRatio = Transformers.getRatioPerUnitBase(twt); @@ -78,7 +78,7 @@ private static LfBranchImpl createTransformer(TwoWindingsTransformer twt, LfNetw PhaseTapChanger ptc = twt.getPhaseTapChanger(); if (ptc != null && (ptc.isRegulating() - && ptc.getRegulationMode() != PhaseTapChanger.RegulationMode.FIXED_TAP || retain)) { + && ptc.getRegulationMode() != PhaseTapChanger.RegulationMode.FIXED_TAP || retainPtc)) { // we have a phase control, whatever we also have a voltage control or not, we create a pi model array // based on phase taps mixed with voltage current tap Integer rtcPosition = Transformers.getCurrentPosition(twt.getRatioTapChanger()); @@ -91,7 +91,7 @@ private static LfBranchImpl createTransformer(TwoWindingsTransformer twt, LfNetw } RatioTapChanger rtc = twt.getRatioTapChanger(); - if (rtc != null && (rtc.isRegulating() && rtc.hasLoadTapChangingCapabilities() || retain)) { + if (rtc != null && (rtc.isRegulating() && rtc.hasLoadTapChangingCapabilities() || retainRtc)) { if (piModel == null) { // we have a voltage control, we create a pi model array based on voltage taps mixed with phase current // tap @@ -127,7 +127,7 @@ public static LfBranchImpl create(Branch branch, LfNetwork network, LfBus bus if (branch instanceof Line line) { return createLine(line, network, bus1, bus2, zb, parameters); } else if (branch instanceof TwoWindingsTransformer twt) { - return createTransformer(twt, network, bus1, bus2, zb, rtcToOperate.contains(twt) || pstToOperate.contains(twt), parameters); + return createTransformer(twt, network, bus1, bus2, zb, pstToOperate.contains(twt), rtcToOperate.contains(twt), parameters); } 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/LfLegBranch.java b/src/main/java/com/powsybl/openloadflow/network/impl/LfLegBranch.java index bd634bd096..99d09924bd 100644 --- a/src/main/java/com/powsybl/openloadflow/network/impl/LfLegBranch.java +++ b/src/main/java/com/powsybl/openloadflow/network/impl/LfLegBranch.java @@ -40,7 +40,7 @@ private ThreeWindingsTransformer.Leg getLeg() { } public static LfLegBranch create(LfNetwork network, LfBus bus1, LfBus bus0, ThreeWindingsTransformer twt, - ThreeWindingsTransformer.Leg leg, boolean retain, LfNetworkParameters parameters) { + ThreeWindingsTransformer.Leg leg, boolean retainPtc, boolean retainRtc, LfNetworkParameters parameters) { Objects.requireNonNull(bus0); Objects.requireNonNull(twt); Objects.requireNonNull(leg); @@ -53,7 +53,7 @@ public static LfLegBranch create(LfNetwork network, LfBus bus1, LfBus bus0, Thre PhaseTapChanger ptc = leg.getPhaseTapChanger(); if (ptc != null && (ptc.isRegulating() - && ptc.getRegulationMode() != PhaseTapChanger.RegulationMode.FIXED_TAP || retain)) { + && ptc.getRegulationMode() != PhaseTapChanger.RegulationMode.FIXED_TAP || retainPtc)) { // we have a phase control, whatever we also have a voltage control or not, we create a pi model array // based on phase taps mixed with voltage current tap Integer rtcPosition = Transformers.getCurrentPosition(leg.getRatioTapChanger()); @@ -66,7 +66,7 @@ public static LfLegBranch create(LfNetwork network, LfBus bus1, LfBus bus0, Thre } RatioTapChanger rtc = leg.getRatioTapChanger(); - if (rtc != null && (rtc.isRegulating() && rtc.hasLoadTapChangingCapabilities() || retain)) { + if (rtc != null && (rtc.isRegulating() && rtc.hasLoadTapChangingCapabilities() || retainRtc)) { if (piModel == null) { // we have a voltage control, we create a pi model array based on voltage taps mixed with phase current // tap 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 015dde3ed9..8c57903421 100644 --- a/src/main/java/com/powsybl/openloadflow/network/impl/LfNetworkLoaderImpl.java +++ b/src/main/java/com/powsybl/openloadflow/network/impl/LfNetworkLoaderImpl.java @@ -404,24 +404,9 @@ private static void createBranches(List lfBuses, LfNetwork lfNetwork, Lis 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 lfBranch2; - LfLegBranch lfBranch3; - if (rtcToOperate.contains(t3wt.getLeg1()) || pstToOperate.contains(t3wt.getLeg1())) { - lfBranch1 = LfLegBranch.create(lfNetwork, lfBus1, lfBus0, t3wt, t3wt.getLeg1(), true, parameters); - } else { - lfBranch1 = LfLegBranch.create(lfNetwork, lfBus1, lfBus0, t3wt, t3wt.getLeg1(), false, parameters); - } - if (rtcToOperate.contains(t3wt.getLeg2()) || pstToOperate.contains(t3wt.getLeg2())) { - lfBranch2 = LfLegBranch.create(lfNetwork, lfBus2, lfBus0, t3wt, t3wt.getLeg2(), true, parameters); - } else { - lfBranch2 = LfLegBranch.create(lfNetwork, lfBus2, lfBus0, t3wt, t3wt.getLeg2(), false, parameters); - } - if (rtcToOperate.contains(t3wt.getLeg3()) || pstToOperate.contains(t3wt.getLeg3())) { - lfBranch3 = LfLegBranch.create(lfNetwork, lfBus3, lfBus0, t3wt, t3wt.getLeg3(), true, parameters); - } else { - lfBranch3 = LfLegBranch.create(lfNetwork, lfBus3, lfBus0, t3wt, t3wt.getLeg3(), false, parameters); - } + LfLegBranch lfBranch1 = LfLegBranch.create(lfNetwork, lfBus1, lfBus0, t3wt, t3wt.getLeg1(), pstToOperate.contains(t3wt.getLeg1()), rtcToOperate.contains(t3wt.getLeg1()), parameters); + LfLegBranch lfBranch2 = LfLegBranch.create(lfNetwork, lfBus2, lfBus0, t3wt, t3wt.getLeg2(), pstToOperate.contains(t3wt.getLeg2()), rtcToOperate.contains(t3wt.getLeg2()), parameters); + LfLegBranch lfBranch3 = LfLegBranch.create(lfNetwork, lfBus3, lfBus0, t3wt, t3wt.getLeg3(), pstToOperate.contains(t3wt.getLeg3()), rtcToOperate.contains(t3wt.getLeg3()), parameters); addBranch(lfNetwork, lfBranch1, report); addBranch(lfNetwork, lfBranch2, report); addBranch(lfNetwork, lfBranch3, report);