-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add way to build tap changers by copying existing ones
Signed-off-by: CHIQUET Benoit <benoit.chiquet@rte-france.com>
- Loading branch information
Showing
4 changed files
with
252 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
iidm/iidm-impl/src/test/java/com/powsybl/iidm/network/impl/tck/TapChangerHolderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.powsybl.iidm.network.impl.tck; | ||
|
||
import com.powsybl.iidm.network.tck.AbstractTapChangerHolderTest; | ||
|
||
public class TapChangerHolderTest extends AbstractTapChangerHolderTest { | ||
} |
185 changes: 185 additions & 0 deletions
185
iidm/iidm-tck/src/test/java/com/powsybl/iidm/network/tck/AbstractTapChangerHolderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
package com.powsybl.iidm.network.tck; | ||
|
||
import com.powsybl.iidm.network.*; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static com.powsybl.iidm.network.PhaseTapChanger.RegulationMode.FIXED_TAP; | ||
import static com.powsybl.iidm.network.RatioTapChanger.RegulationMode.VOLTAGE; | ||
import static com.powsybl.iidm.network.TopologyKind.BUS_BREAKER; | ||
import static com.powsybl.iidm.network.TwoSides.ONE; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public abstract class AbstractTapChangerHolderTest { | ||
|
||
@Test | ||
void shouldReuseCopiedPhaseTapChangerPropertiesFixedTapExample() { | ||
Network network = exampleNetwork(); | ||
PhaseTapChanger existingPhaseTapChanger = network.getTwoWindingsTransformer("transformer") | ||
.newPhaseTapChanger() | ||
.setTapPosition(1) | ||
.setRegulationValue(12) | ||
.setRegulationMode(FIXED_TAP) | ||
.setLowTapPosition(0) | ||
.setRegulating(false) | ||
.setTargetDeadband(3) | ||
.beginStep().setAlpha(1).setRho(2).setR(3).setG(4).setB(5).setX(6) | ||
.endStep() | ||
.beginStep().setAlpha(2).setRho(3).setR(4).setG(5).setB(6).setX(7) | ||
.endStep() | ||
.beginStep().setAlpha(3).setRho(4).setR(5).setG(6).setB(7).setX(8) | ||
.endStep() | ||
.add(); | ||
|
||
PhaseTapChanger newPhaseTapChanger = network.getTwoWindingsTransformer("transformer2") | ||
.newPhaseTapChanger(existingPhaseTapChanger) | ||
.add(); | ||
|
||
assertEquals(existingPhaseTapChanger.getTapPosition(), newPhaseTapChanger.getTapPosition()); | ||
assertEquals(existingPhaseTapChanger.getLowTapPosition(), newPhaseTapChanger.getLowTapPosition()); | ||
assertEquals(existingPhaseTapChanger.getRegulationValue(), newPhaseTapChanger.getRegulationValue()); | ||
assertEquals(existingPhaseTapChanger.getRegulationMode(), newPhaseTapChanger.getRegulationMode()); | ||
assertEquals(existingPhaseTapChanger.isRegulating(), newPhaseTapChanger.isRegulating()); | ||
assertEquals(existingPhaseTapChanger.getTargetDeadband(), newPhaseTapChanger.getTargetDeadband()); | ||
|
||
newPhaseTapChanger.getAllSteps().forEach((tap, newStep) -> { | ||
PhaseTapChangerStep existingStep = existingPhaseTapChanger.getStep(tap); | ||
assertEquals(existingStep.getAlpha(), newStep.getAlpha()); | ||
assertEquals(existingStep.getRho(), newStep.getRho()); | ||
assertEquals(existingStep.getR(), newStep.getR()); | ||
assertEquals(existingStep.getG(), newStep.getG()); | ||
assertEquals(existingStep.getB(), newStep.getB()); | ||
assertEquals(existingStep.getX(), newStep.getX()); | ||
}); | ||
} | ||
|
||
@Test | ||
void shouldReuseCopiedPhaseTapChangerPropertiesActivePowerControlExample() { | ||
Network network = exampleNetwork(); | ||
PhaseTapChanger existingPhaseTapChanger = network.getTwoWindingsTransformer("transformer") | ||
.newPhaseTapChanger() | ||
.setTapPosition(1) | ||
.setRegulationValue(12) | ||
.setRegulationMode(PhaseTapChanger.RegulationMode.ACTIVE_POWER_CONTROL) | ||
.setRegulationTerminal(network.getTwoWindingsTransformer("transformer").getTerminal(ONE)) | ||
.setLowTapPosition(0) | ||
.setRegulating(false) | ||
.setTargetDeadband(3) | ||
.beginStep().setAlpha(1).setRho(2).setR(3).setG(4).setB(5).setX(6) | ||
.endStep() | ||
.beginStep().setAlpha(2).setRho(3).setR(4).setG(5).setB(6).setX(7) | ||
.endStep() | ||
.beginStep().setAlpha(3).setRho(4).setR(5).setG(6).setB(7).setX(8) | ||
.endStep() | ||
.add(); | ||
|
||
PhaseTapChanger newPhaseTapChanger = network.getTwoWindingsTransformer("transformer2") | ||
.newPhaseTapChanger(existingPhaseTapChanger) | ||
.add(); | ||
|
||
assertEquals(existingPhaseTapChanger.getTapPosition(), newPhaseTapChanger.getTapPosition()); | ||
assertEquals(existingPhaseTapChanger.getLowTapPosition(), newPhaseTapChanger.getLowTapPosition()); | ||
assertEquals(existingPhaseTapChanger.getRegulationValue(), newPhaseTapChanger.getRegulationValue()); | ||
assertEquals(existingPhaseTapChanger.getRegulationMode(), newPhaseTapChanger.getRegulationMode()); | ||
assertEquals(existingPhaseTapChanger.isRegulating(), newPhaseTapChanger.isRegulating()); | ||
assertEquals(existingPhaseTapChanger.getTargetDeadband(), newPhaseTapChanger.getTargetDeadband()); | ||
assertEquals(existingPhaseTapChanger.getRegulationTerminal(), newPhaseTapChanger.getRegulationTerminal()); | ||
|
||
newPhaseTapChanger.getAllSteps().forEach((tap, newStep) -> { | ||
PhaseTapChangerStep existingStep = existingPhaseTapChanger.getStep(tap); | ||
assertEquals(existingStep.getAlpha(), newStep.getAlpha()); | ||
assertEquals(existingStep.getRho(), newStep.getRho()); | ||
assertEquals(existingStep.getR(), newStep.getR()); | ||
assertEquals(existingStep.getG(), newStep.getG()); | ||
assertEquals(existingStep.getB(), newStep.getB()); | ||
assertEquals(existingStep.getX(), newStep.getX()); | ||
}); | ||
} | ||
|
||
@Test | ||
void shouldReuseCopiedRatioTapChangerProperties() { | ||
Network network = exampleNetwork(); | ||
RatioTapChanger existingRatioTapChanger = network.getTwoWindingsTransformer("transformer").newRatioTapChanger() | ||
.setTapPosition(1) | ||
.setTargetV(400) | ||
.setRegulationValue(12) | ||
.setRegulationMode(VOLTAGE) | ||
.setLowTapPosition(0) | ||
.setRegulating(false) | ||
.setLoadTapChangingCapabilities(true) | ||
.setTargetDeadband(3) | ||
.beginStep().setRho(2).setR(3).setG(4).setB(5).setX(6) | ||
.endStep() | ||
.beginStep().setRho(3).setR(4).setG(5).setB(6).setX(7) | ||
.endStep() | ||
.beginStep().setRho(4).setR(5).setG(6).setB(7).setX(8) | ||
.endStep() | ||
.add(); | ||
|
||
RatioTapChanger newRatioTapChanger = network.getTwoWindingsTransformer("transformer2") | ||
.newRatioTapChanger(existingRatioTapChanger) | ||
.add(); | ||
|
||
assertEquals(existingRatioTapChanger.getTapPosition(), newRatioTapChanger.getTapPosition()); | ||
assertEquals(existingRatioTapChanger.getLowTapPosition(), newRatioTapChanger.getLowTapPosition()); | ||
assertEquals(existingRatioTapChanger.getRegulationValue(), newRatioTapChanger.getRegulationValue()); | ||
assertEquals(existingRatioTapChanger.getRegulationMode(), newRatioTapChanger.getRegulationMode()); | ||
assertEquals(existingRatioTapChanger.isRegulating(), newRatioTapChanger.isRegulating()); | ||
assertEquals(existingRatioTapChanger.getTargetDeadband(), newRatioTapChanger.getTargetDeadband()); | ||
assertEquals(existingRatioTapChanger.getRegulationTerminal(), newRatioTapChanger.getRegulationTerminal()); | ||
assertEquals(existingRatioTapChanger.getTargetV(), newRatioTapChanger.getTargetV()); | ||
assertEquals(existingRatioTapChanger.hasLoadTapChangingCapabilities(), newRatioTapChanger.hasLoadTapChangingCapabilities()); | ||
|
||
newRatioTapChanger.getAllSteps().forEach((tap, newStep) -> { | ||
RatioTapChangerStep existingStep = existingRatioTapChanger.getStep(tap); | ||
assertEquals(existingStep.getRho(), newStep.getRho()); | ||
assertEquals(existingStep.getR(), newStep.getR()); | ||
assertEquals(existingStep.getG(), newStep.getG()); | ||
assertEquals(existingStep.getB(), newStep.getB()); | ||
assertEquals(existingStep.getX(), newStep.getX()); | ||
}); | ||
} | ||
|
||
Network exampleNetwork() { | ||
Network network = Network.create("test", "test"); | ||
Substation substation = network.newSubstation() | ||
.setId("substation") | ||
.setCountry(Country.AD) | ||
.add(); | ||
VoltageLevel vl1 = substation.newVoltageLevel() | ||
.setId("vl1") | ||
.setTopologyKind(BUS_BREAKER) | ||
.setName("name") | ||
.setNominalV(225) | ||
.setLowVoltageLimit(200) | ||
.setHighVoltageLimit(250) | ||
.add(); | ||
vl1.getBusBreakerView().newBus().setId("bus1").add(); | ||
VoltageLevel vl2 = substation.newVoltageLevel() | ||
.setId("vl2") | ||
.setTopologyKind(BUS_BREAKER) | ||
.setName("name") | ||
.setNominalV(90) | ||
.setLowVoltageLimit(80) | ||
.setHighVoltageLimit(100) | ||
.add(); | ||
vl2.getBusBreakerView().newBus().setId("bus2").add(); | ||
|
||
substation.newTwoWindingsTransformer() | ||
.setId("transformer") | ||
.setR(17) | ||
.setX(10) | ||
.setBus1("bus1") | ||
.setBus2("bus2") | ||
.add(); | ||
|
||
substation.newTwoWindingsTransformer() | ||
.setId("transformer2") | ||
.setR(12) | ||
.setX(15) | ||
.setBus1("bus1") | ||
.setBus2("bus2") | ||
.add(); | ||
|
||
return network; | ||
} | ||
} |