Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove transformer voltage controls when no PV buses at non controlled side #482

Merged
merged 21 commits into from
May 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public void initialize(OuterLoopContext context) {
for (LfBranch controllerBranch : getControllerBranches(context.getNetwork())) {
controllerBranch.setVoltageControlEnabled(true);
}
context.getNetwork().fixTransformerVoltageControls();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public OuterLoopStatus check(OuterLoopContext context, Reporter reporter) {
branch.setVoltageControlEnabled(true);
status = OuterLoopStatus.UNSTABLE;
}
context.getNetwork().fixTransformerVoltageControls();
}

// At second outer loop iteration, the transformers are rounded. The generator voltage controls that were
Expand Down
46 changes: 46 additions & 0 deletions src/main/java/com/powsybl/openloadflow/network/LfNetwork.java
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,52 @@ public boolean isValid() {
return valid;
}

/**
* Disable transformer voltage control when there is no generator controlling voltage on the connected component
* that belong to the not controlled side of the transformer.
*/
public void fixTransformerVoltageControls() {
List<LfBranch> controllerBranches = new ArrayList<>(1);
for (LfBranch branch : branches) {
if (!branch.isDisabled() && branch.isVoltageController() && branch.isVoltageControlEnabled()) {
controllerBranches.add(branch);
}
if (branch.isDisabled()) {
// apply contingency (in case we are inside a security analysis)
getConnectivity().cut(branch);
}
}
for (LfBranch branch : controllerBranches) {
getConnectivity().cut(branch);
}
int disabledTransformerCount = 0;
Map<Integer, Boolean> componentNoPVBusesMap = new HashMap<>();
for (LfBranch branch : controllerBranches) {
var voltageControl = branch.getVoltageControl().orElseThrow();
LfBus notControlledSide;
if (voltageControl.getControlled() == branch.getBus1()) {
notControlledSide = branch.getBus2();
} else if (voltageControl.getControlled() == branch.getBus2()) {
notControlledSide = branch.getBus1();
} else {
continue;
}
boolean noPvBusesInComponent = componentNoPVBusesMap.computeIfAbsent(getConnectivity().getComponentNumber(notControlledSide),
k -> getConnectivity().getConnectedComponent(notControlledSide).stream().noneMatch(LfBus::isVoltageControlled));
if (noPvBusesInComponent) {
branch.setVoltageControlEnabled(false);
LOGGER.trace("Transformer {} voltage control has been disabled because no PV buses on not controlled side connected component",
branch.getId());
disabledTransformerCount++;
}
}
getConnectivity().reset();
if (disabledTransformerCount > 0) {
LOGGER.warn("{} transformer voltage controls have been disabled because no PV buses on not controlled side connected component",
disabledTransformerCount);
}
}

@Override
public String toString() {
return "{CC" + numCC +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ private void calculatePostContingencySensitivityValues(List<LfSensitivityFactor<
for (LfBranch branch : lfNetwork.getBranches()) {
branch.getVoltageControl().ifPresent(vc -> branch.setVoltageControlEnabled(true));
}
lfNetwork.fixTransformerVoltageControls();
}

// we make the assumption that we ran a loadflow before, and thus this jacobian is the right one
Expand Down Expand Up @@ -245,6 +246,7 @@ public void analyse(Network network, List<PropagatedContingency> contingencies,
for (LfBranch branch : lfNetwork.getBranches()) {
branch.getVoltageControl().ifPresent(vc -> branch.setVoltageControlEnabled(true));
}
lfNetwork.fixTransformerVoltageControls();
}

// we make the assumption that we ran a loadflow before, and thus this jacobian is the right one
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ void voltageControlT2wtTest3() {
.setTargetV(135.0);

LoadFlowResult result = loadFlowRunner.run(network, parameters);
assertFalse(result.isOk());
assertTrue(result.isOk());

parametersExt.setTransformerVoltageControlMode(OpenLoadFlowParameters.TransformerVoltageControlMode.AFTER_GENERATOR_VOLTAGE_CONTROL);
LoadFlowResult result2 = loadFlowRunner.run(network, parameters);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,26 @@ void testBusVoltagePerTargetVTwt() {
assertEquals(0.035205d, result.getBusVoltageSensitivityValue("T2wT", "BUS_2"), LoadFlowAssert.DELTA_V);
assertEquals(1d, result.getBusVoltageSensitivityValue("T2wT", "BUS_3"), LoadFlowAssert.DELTA_V);
assertEquals(1.055117d, result.getBusVoltageSensitivityValue("T2wT", "BUS_4"), LoadFlowAssert.DELTA_V);

t2wt.getRatioTapChanger()
.setTargetDeadband(0)
.setRegulating(true)
.setTapPosition(3)
.setRegulationTerminal(t2wt.getTerminal1()) // control will be disabled.
.setTargetV(135.0);

SensitivityAnalysisResult result2 = sensiRunner.run(network, factors, Collections.emptyList(), Collections.emptyList(), sensiParameters);

assertEquals(4, result2.getValues().size());
annetill marked this conversation as resolved.
Show resolved Hide resolved
assertEquals(0d, result2.getBusVoltageSensitivityValue("T2wT", "BUS_1"), LoadFlowAssert.DELTA_V);
assertEquals(0d, result2.getBusVoltageSensitivityValue("T2wT", "BUS_2"), LoadFlowAssert.DELTA_V);
assertEquals(0d, result2.getBusVoltageSensitivityValue("T2wT", "BUS_3"), LoadFlowAssert.DELTA_V);
assertEquals(0d, result2.getBusVoltageSensitivityValue("T2wT", "BUS_4"), LoadFlowAssert.DELTA_V);

assertEquals(135.0, result2.getBusVoltageFunctionReferenceValue("BUS_1"), LoadFlowAssert.DELTA_V);
assertEquals(133.77, result2.getBusVoltageFunctionReferenceValue("BUS_2"), LoadFlowAssert.DELTA_V);
assertEquals(25.88, result2.getBusVoltageFunctionReferenceValue("BUS_3"), LoadFlowAssert.DELTA_V);
assertEquals(25.16, result2.getBusVoltageFunctionReferenceValue("BUS_4"), LoadFlowAssert.DELTA_V);
}

@Test
Expand Down