Skip to content

Commit

Permalink
Two retain parameters
Browse files Browse the repository at this point in the history
Signed-off-by: Hadrien <[email protected]>
  • Loading branch information
Hadrien-Godard committed Oct 5, 2023
1 parent eacb6c1 commit 1bd8222
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ 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);

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());
Expand All @@ -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
Expand Down Expand Up @@ -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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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());
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,24 +404,9 @@ private static void createBranches(List<LfBus> 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);
Expand Down

0 comments on commit 1bd8222

Please sign in to comment.