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

Light support of generators connected to the same bus but controlling different buses #578

Merged
merged 2 commits into from
Jul 5, 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 @@ -79,10 +79,10 @@ private static void createVoltageControls(LfNetwork lfNetwork, List<LfBus> lfBus
LfBus generatorControlledBus = lfGenerator.getControlledBus(lfNetwork);

// check that remote control bus is the same for the generators of current controller bus which have voltage control on
checkUniqueControlledBus(controlledBus, generatorControlledBus, controllerBus);

// check that target voltage is the same for the generators of current controller bus which have voltage control on
checkUniqueTargetVControllerBus(lfGenerator, controllerTargetV, controllerBus, generatorControlledBus);
if (checkUniqueControlledBus(controlledBus, generatorControlledBus, controllerBus)) {
// check that target voltage is the same for the generators of current controller bus which have voltage control on
checkUniqueTargetVControllerBus(lfGenerator, controllerTargetV, controllerBus, generatorControlledBus);
}
});

if (voltageRemoteControl || controlledBus == controllerBus) {
Expand Down Expand Up @@ -151,14 +151,16 @@ private static void checkUniqueTargetVControlledBus(double controllerTargetV, Lf
}
}

private static void checkUniqueControlledBus(LfBus controlledBus, LfBus controlledBusGen, LfBus controller) {
private static boolean checkUniqueControlledBus(LfBus controlledBus, LfBus controlledBusGen, LfBus controller) {
Objects.requireNonNull(controlledBus);
Objects.requireNonNull(controlledBusGen);
if (controlledBus.getNum() != controlledBusGen.getNum()) {
String generatorIds = controller.getGenerators().stream().map(LfGenerator::getId).collect(Collectors.joining(", "));
throw new PowsyblException("Generators [" + generatorIds
+ "] connected to bus '" + controller.getId() + "' must control the voltage of the same bus");
LOGGER.warn("Generators [{}] are connected to the same bus '{}' but control the voltage of different buses: {} (kept) and {} (rejected)",
generatorIds, controller.getId(), controlledBus.getId(), controlledBusGen.getId());
return false;
}
return true;
}

private static void checkUniqueTargetVControllerBus(LfGenerator lfGenerator, double previousTargetV, LfBus controllerBus, LfBus controlledBus) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,4 +435,23 @@ void testGeneratorReactiveLimits() {
assertEquals(-120, network.getGenerator("GEN").getTerminal().getQ());
assertEquals(-160, network.getGenerator("GEN1").getTerminal().getQ(), 0.01);
}

@Test
void testGeneratorsConnectedToSameBusNotControllingSameBus() {
var network = EurostagTutorialExample1Factory.create();
network.getVoltageLevel("VLGEN").newGenerator()
.setId("GEN2")
.setConnectableBus("NGEN")
.setBus("NGEN")
.setMinP(0)
.setMaxP(100)
.setTargetP(1)
.setVoltageRegulatorOn(true)
.setTargetV(148)
.setRegulatingTerminal(network.getLoad("LOAD").getTerminal())
.add();
loadFlowRunner.run(network);
assertVoltageEquals(24.5, network.getBusBreakerView().getBus("NGEN"));
assertVoltageEquals(147.57, network.getBusBreakerView().getBus("NLOAD"));
}
}